00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#include <qlabel.h>
00025
#include <qlayout.h>
00026
00027
#include <dcopclient.h>
00028
#include <dcopref.h>
00029
#include <kapplication.h>
00030
#include <kdebug.h>
00031
#include <kglobal.h>
00032
#include <kiconloader.h>
00033
#include <klocale.h>
00034
#include <kurllabel.h>
00035
#include <kstandarddirs.h>
00036
00037
#include "core.h"
00038
#include "plugin.h"
00039
00040
#include "summarywidget.h"
00041
00042 SummaryWidget::SummaryWidget(
Kontact::Plugin *plugin,
00043
QWidget *parent,
const char *name )
00044 : Kontact::
Summary( parent, name ), mPlugin( plugin )
00045 {
00046 mMainLayout =
new QVBoxLayout(
this, 3, 3 );
00047
00048 mCalendar =
new KCal::CalendarResources;
00049 mResource =
new KCal::ResourceLocal( ::locate(
"data",
"knotes/notes.ics" ) );
00050 mCalendar->resourceManager()->add( mResource );
00051 mCalendar->load();
00052
00053 connect( mCalendar, SIGNAL( calendarChanged() ), SLOT( updateView() ) );
00054
00055
QPixmap icon = KGlobal::iconLoader()->loadIcon(
"kontact_notes", KIcon::Desktop, KIcon::SizeMedium );
00056
QWidget* heading =
createHeader(
this, icon, i18n(
"Notes" ) );
00057
00058 mMainLayout->addWidget(heading);
00059 mLayout =
new QVBoxLayout( mMainLayout );
00060
00061 updateView();
00062 }
00063
00064
void SummaryWidget::updateView()
00065 {
00066 mNotes = mCalendar->journals();
00067
00068
delete mLayout;
00069 mLayout =
new QVBoxLayout( mMainLayout );
00070
00071 mLabels.setAutoDelete(
true );
00072 mLabels.clear();
00073 mLabels.setAutoDelete(
false );
00074
00075 KCal::Journal::List::Iterator it;
00076
for (it = mNotes.begin(); it != mNotes.end(); ++it) {
00077 KURLLabel *urlLabel =
new KURLLabel(
00078 (*it)->uid(), (*it)->summary(),
this );
00079 urlLabel->setTextFormat(RichText);
00080 mLayout->addWidget( urlLabel );
00081 mLabels.append( urlLabel );
00082
00083 connect( urlLabel, SIGNAL( leftClickedURL(
const QString& ) ),
00084
this, SLOT( urlClicked(
const QString& ) ) );
00085 }
00086
00087 mLayout->addStretch();
00088 }
00089
00090
void SummaryWidget::urlClicked(
const QString & )
00091 {
00092
if ( !mPlugin->isRunningStandalone() )
00093 mPlugin->core()->selectPlugin( mPlugin );
00094
else
00095 mPlugin->bringToForeground();
00096 }
00097
00098
#include "summarywidget.moc"