knotes/summarywidget.cpp
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 <qobject.h>
00025 #include <qlabel.h>
00026 #include <qlayout.h>
00027
00028 #include <dcopclient.h>
00029 #include <dcopref.h>
00030 #include <kapplication.h>
00031 #include <kdebug.h>
00032 #include <kglobal.h>
00033 #include <kiconloader.h>
00034 #include <klocale.h>
00035 #include <kurllabel.h>
00036 #include <kstandarddirs.h>
00037
00038 #include <knotes/resourcenotes.h>
00039 #include <knotes/resourcemanager.h>
00040
00041 #include "core.h"
00042 #include "plugin.h"
00043
00044 #include "summarywidget.h"
00045
00046 SummaryWidget::SummaryWidget( Kontact::Plugin *plugin,
00047 QWidget *parent, const char *name )
00048 : Kontact::Summary( parent, name ), mLayout( 0 ), mPlugin( plugin )
00049 {
00050 mMainLayout = new QVBoxLayout( this, 3, 3 );
00051
00052 mCalendar = new KCal::CalendarLocal();
00053 KNotesResourceManager *manager = new KNotesResourceManager();
00054 QObject::connect( manager, SIGNAL( sigRegisteredNote( KCal::Journal* ) ),
00055 this, SLOT( addNote( KCal::Journal* ) ) );
00056 QObject::connect( manager, SIGNAL( sigDeregisteredNote( KCal::Journal* ) ),
00057 this, SLOT( removeNote( KCal::Journal* ) ) );
00058 manager->load();
00059
00060 QPixmap icon = KGlobal::iconLoader()->loadIcon( "kontact_notes", KIcon::Desktop, KIcon::SizeMedium );
00061 QWidget* heading = createHeader( this, icon, i18n( "Notes" ) );
00062
00063 mMainLayout->addWidget(heading);
00064 mLayout = new QVBoxLayout( mMainLayout );
00065
00066 updateView();
00067 }
00068
00069 void SummaryWidget::updateView()
00070 {
00071 mNotes = mCalendar->journals();
00072
00073 delete mLayout;
00074 mLayout = new QVBoxLayout( mMainLayout );
00075
00076 mLabels.setAutoDelete( true );
00077 mLabels.clear();
00078 mLabels.setAutoDelete( false );
00079
00080 KCal::Journal::List::Iterator it;
00081 for (it = mNotes.begin(); it != mNotes.end(); ++it) {
00082 KURLLabel *urlLabel = new KURLLabel(
00083 (*it)->uid(), (*it)->summary(), this );
00084 urlLabel->setTextFormat(RichText);
00085 urlLabel->show();
00086 mLayout->addWidget( urlLabel );
00087 mLabels.append( urlLabel );
00088
00089 connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ),
00090 this, SLOT( urlClicked( const QString& ) ) );
00091 }
00092 }
00093
00094 void SummaryWidget::urlClicked( const QString & )
00095 {
00096 if ( !mPlugin->isRunningStandalone() )
00097 mPlugin->core()->selectPlugin( mPlugin );
00098 else
00099 mPlugin->bringToForeground();
00100 }
00101
00102 void SummaryWidget::addNote( KCal::Journal *j )
00103 {
00104 mCalendar->addJournal( j );
00105 updateView();
00106 }
00107
00108 void SummaryWidget::removeNote( KCal::Journal *j )
00109 {
00110 mCalendar->deleteJournal( j );
00111 updateView();
00112 }
00113
00114
00115 #include "summarywidget.moc"
This file is part of the documentation for kontact Library Version 3.3.2.