kontact Library API Documentation

summarywidget.cpp

00001 /* 00002 This file is part of Kontact. 00003 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of Qt, and distribute the resulting executable, 00021 without including the source code for Qt in the source distribution. 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 &/*uid*/ ) 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"
KDE Logo
This file is part of the documentation for kontact Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:47:00 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003