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 <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 &/*uid*/ ) 00091 { 00092 if ( !mPlugin->isRunningStandalone() ) 00093 mPlugin->core()->selectPlugin( mPlugin ); 00094 else 00095 mPlugin->bringToForeground(); 00096 } 00097 00098 #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 Fri Aug 27 12:53:45 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003