diff options
Diffstat (limited to 'kontact/plugins/summary')
-rw-r--r-- | kontact/plugins/summary/Makefile.am | 26 | ||||
-rw-r--r-- | kontact/plugins/summary/dropwidget.cpp | 44 | ||||
-rw-r--r-- | kontact/plugins/summary/dropwidget.h | 42 | ||||
-rw-r--r-- | kontact/plugins/summary/kcmkontactsummary.cpp | 189 | ||||
-rw-r--r-- | kontact/plugins/summary/kcmkontactsummary.desktop | 79 | ||||
-rw-r--r-- | kontact/plugins/summary/kcmkontactsummary.h | 62 | ||||
-rw-r--r-- | kontact/plugins/summary/kontactsummary_part.rc | 9 | ||||
-rw-r--r-- | kontact/plugins/summary/summaryplugin.desktop | 97 | ||||
-rw-r--r-- | kontact/plugins/summary/summaryview_part.cpp | 434 | ||||
-rw-r--r-- | kontact/plugins/summary/summaryview_part.h | 103 | ||||
-rw-r--r-- | kontact/plugins/summary/summaryview_plugin.cpp | 123 | ||||
-rw-r--r-- | kontact/plugins/summary/summaryview_plugin.h | 62 |
12 files changed, 1270 insertions, 0 deletions
diff --git a/kontact/plugins/summary/Makefile.am b/kontact/plugins/summary/Makefile.am new file mode 100644 index 000000000..ab83c72a5 --- /dev/null +++ b/kontact/plugins/summary/Makefile.am @@ -0,0 +1,26 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces -I$(top_srcdir)/certmanager/lib \ + -I$(top_srcdir)/libkdepim \ + -I$(top_srcdir) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_summaryplugin.la kcm_kontactsummary.la +libkontact_summaryplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_summaryplugin_la_LIBADD = -lkutils \ + $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(LIB_KPARTS) \ + $(top_builddir)/libkdepim/libkdepim.la $(top_builddir)/libkpimidentities/libkpimidentities.la + +libkontact_summaryplugin_la_SOURCES = summaryview_plugin.cpp summaryview_part.cpp dropwidget.cpp + +kcm_kontactsummary_la_SOURCES = kcmkontactsummary.cpp +kcm_kontactsummary_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) \ + -avoid-version -no-undefined +kcm_kontactsummary_la_LIBADD = $(LIB_KDEUI) $(LIB_KUTILS) + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir)/kontact +service_DATA = summaryplugin.desktop + +kde_services_DATA = kcmkontactsummary.desktop + +kpartrcdir = $(kde_datadir)/kontactsummary +kpartrc_DATA = kontactsummary_part.rc diff --git a/kontact/plugins/summary/dropwidget.cpp b/kontact/plugins/summary/dropwidget.cpp new file mode 100644 index 000000000..0d6aa5305 --- /dev/null +++ b/kontact/plugins/summary/dropwidget.cpp @@ -0,0 +1,44 @@ +/* + This file is part of KDE Kontact. + + Copyright (C) 2004 Tobias Koenig <tokoe@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <qdragobject.h> + +#include "dropwidget.h" + +DropWidget::DropWidget( QWidget *parent, const char *name ) + : QWidget( parent, name ) +{ + setAcceptDrops( true ); +} + +void DropWidget::dragEnterEvent( QDragEnterEvent *event ) +{ + event->accept( QTextDrag::canDecode( event ) ); +} + +void DropWidget::dropEvent( QDropEvent *event ) +{ + int alignment = ( event->pos().x() < (width() / 2) ? Qt::AlignLeft : Qt::AlignRight ); + alignment |= ( event->pos().y() < (height() / 2) ? Qt::AlignTop : Qt::AlignBottom ); + emit summaryWidgetDropped( this, event->source(), alignment ); +} + +#include "dropwidget.moc" diff --git a/kontact/plugins/summary/dropwidget.h b/kontact/plugins/summary/dropwidget.h new file mode 100644 index 000000000..7cde7f5e0 --- /dev/null +++ b/kontact/plugins/summary/dropwidget.h @@ -0,0 +1,42 @@ +/* + This file is part of KDE Kontact. + + Copyright (C) 2004 Tobias Koenig <tokoe@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef DROP_WIDGET_H +#define DROP_WIDGET_H + +#include <qwidget.h> + +class DropWidget : public QWidget +{ + Q_OBJECT + + public: + DropWidget( QWidget *parent, const char *name = 0 ); + + signals: + void summaryWidgetDropped( QWidget *target, QWidget *widget, int alignment ); + + protected: + virtual void dragEnterEvent( QDragEnterEvent* ); + virtual void dropEvent( QDropEvent* ); +}; + +#endif diff --git a/kontact/plugins/summary/kcmkontactsummary.cpp b/kontact/plugins/summary/kcmkontactsummary.cpp new file mode 100644 index 000000000..d52d991fc --- /dev/null +++ b/kontact/plugins/summary/kcmkontactsummary.cpp @@ -0,0 +1,189 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2004 Tobias Koenig <tokoe@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include <kaboutdata.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kdialog.h> +#include <kiconloader.h> +#include <kiconloader.h> +#include <klocale.h> +#include <plugin.h> +#include <kplugininfo.h> +#include <ktrader.h> + +#include <qlayout.h> +#include <qlabel.h> +#include <qpixmap.h> + +#include "kcmkontactsummary.h" + +#include <kdepimmacros.h> + +extern "C" +{ + KDE_EXPORT KCModule *create_kontactsummary( QWidget *parent, const char * ) { + return new KCMKontactSummary( parent, "kcmkontactsummary" ); + } +} + +class PluginItem : public QCheckListItem +{ + public: + PluginItem( KPluginInfo *info, KListView *parent ) + : QCheckListItem( parent, QString::null, QCheckListItem::CheckBox ), + mInfo( info ) + { + QPixmap pm = KGlobal::iconLoader()->loadIcon( mInfo->icon(), KIcon::Small ); + setPixmap( 0, pm ); + } + + KPluginInfo* pluginInfo() const + { + return mInfo; + } + + virtual QString text( int column ) const + { + if ( column == 0 ) + return mInfo->name(); + else if ( column == 1 ) + return mInfo->comment(); + else + return QString::null; + } + + private: + KPluginInfo *mInfo; +}; + +PluginView::PluginView( QWidget *parent, const char *name ) + : KListView( parent, name ) +{ + addColumn( i18n( "Name" ) ); + setAllColumnsShowFocus( true ); + setFullWidth( true ); +} + +PluginView::~PluginView() +{ +} + +KCMKontactSummary::KCMKontactSummary( QWidget *parent, const char *name ) + : KCModule( parent, name ) +{ + QVBoxLayout *layout = new QVBoxLayout( this, 0, KDialog::spacingHint() ); + + QLabel *label = new QLabel( i18n( "Here you can select which summary plugins to have visible in your summary view." ), this ); + layout->addWidget( label ); + + mPluginView = new PluginView( this ); + layout->addWidget( mPluginView ); + + layout->setStretchFactor( mPluginView, 1 ); + + connect( mPluginView, SIGNAL( clicked( QListViewItem* ) ), + this, SLOT( itemClicked( QListViewItem* ) ) ); + load(); + + KAboutData *about = new KAboutData( I18N_NOOP( "kontactsummary" ), + I18N_NOOP( "KDE Kontact Summary" ), + 0, 0, KAboutData::License_GPL, + I18N_NOOP( "(c), 2004 Tobias Koenig" ) ); + + about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); + setAboutData( about ); +} + +void KCMKontactSummary::load() +{ + KTrader::OfferList offers = KTrader::self()->query( + QString::fromLatin1( "Kontact/Plugin" ), + QString( "[X-KDE-KontactPluginVersion] == %1" ).arg( KONTACT_PLUGIN_VERSION ) ); + + QStringList activeSummaries; + + KConfig config( "kontact_summaryrc" ); + if ( !config.hasKey( "ActiveSummaries" ) ) { + activeSummaries << "kontact_kaddressbookplugin"; + activeSummaries << "kontact_specialdatesplugin"; + activeSummaries << "kontact_korganizerplugin"; + activeSummaries << "kontact_todoplugin"; + activeSummaries << "kontact_kpilotplugin"; + activeSummaries << "kontact_weatherplugin"; + activeSummaries << "kontact_newstickerplugin"; + } else { + activeSummaries = config.readListEntry( "ActiveSummaries" ); + } + + mPluginView->clear(); + mPluginList.clear(); + + mPluginList = KPluginInfo::fromServices( offers, &config, "Plugins" ); + KPluginInfo::List::Iterator it; + for ( it = mPluginList.begin(); it != mPluginList.end(); ++it ) { + (*it)->load(); + + if ( !(*it)->isPluginEnabled() ) + continue; + + QVariant var = (*it)->property( "X-KDE-KontactPluginHasSummary" ); + if ( !var.isValid() ) + continue; + + if ( var.toBool() == true ) { + PluginItem *item = new PluginItem( *it, mPluginView ); + + if ( activeSummaries.find( (*it)->pluginName() ) != activeSummaries.end() ) + item->setOn( true ); + } + } +} + +void KCMKontactSummary::save() +{ + QStringList activeSummaries; + + QListViewItemIterator it( mPluginView, QListViewItemIterator::Checked ); + while ( it.current() ) { + PluginItem *item = static_cast<PluginItem*>( it.current() ); + activeSummaries.append( item->pluginInfo()->pluginName() ); + ++it; + } + + KConfig config( "kontact_summaryrc" ); + config.writeEntry( "ActiveSummaries", activeSummaries ); +} + +void KCMKontactSummary::defaults() +{ + emit changed( true ); +} + +void KCMKontactSummary::itemClicked( QListViewItem* ) +{ + emit changed( true ); +} + +#include "kcmkontactsummary.moc" diff --git a/kontact/plugins/summary/kcmkontactsummary.desktop b/kontact/plugins/summary/kcmkontactsummary.desktop new file mode 100644 index 000000000..5442d5c0b --- /dev/null +++ b/kontact/plugins/summary/kcmkontactsummary.desktop @@ -0,0 +1,79 @@ +[Desktop Entry] +Icon=kontact_summary +Type=Service +ServiceTypes=KCModule + +X-KDE-ModuleType=Library +X-KDE-Library=kontactsummary +X-KDE-FactoryName=kontactsummary +X-KDE-ParentApp=kontact_summaryplugin +X-KDE-ParentComponents=kontact_summaryplugin +X-KDE-CfgDlgHierarchy=KontactSummary + +Name=Summary View Items +Name[bg]=Обобщение +Name[ca]=Vista resum d'elements +Name[da]=Elementer i opsummeringsvisning +Name[de]=Elemente der Zusammenfassungsansicht +Name[el]=Αντικείμενα προβολής σύνοψης +Name[es]=Elementos de la vista de sumario +Name[et]=Kokkuvõttevaate elemendid +Name[it]=Elementi vista sommario +Name[ja]=要約ビューの項目 +Name[km]=ធាតុទិដ្ឋភាពសង្ខេប +Name[nds]=Översicht-Indrääg +Name[nl]=Overzichtsweergave-items +Name[pl]=Elementy widoku podsumowania +Name[sr]=Ставке приказа сажетка +Name[sr@Latn]=Stavke prikaza sažetka +Name[sv]=Objekt i översiktsvy +Name[tr]=Özet Görünüm Ögeleri +Name[zh_CN]=摘要视图项目 +Name[zh_TW]=摘要檢視項目 +Comment=General Configuration of Kontact's Summary View +Comment[af]=Algemene opstelling van Kontact se opsomming aansig +Comment[bg]=Настройка на обобщението +Comment[bs]=Opšte podešavanje Kontactovog prozora Sažetak +Comment[ca]=Configuració general de la vista de resum del Kontact +Comment[cs]=Obecné nastavení souhrnného pohledu pro Kontact +Comment[da]=Generel indstilling af Kontact's sammendragsvisning +Comment[de]=Allgemeine Einstellungen für die Übersichtsansicht von Kontact +Comment[el]=Γενικές ρυθμίσεις της Προβολής Σύνοψης του Kontact +Comment[es]=Configuración general de la vista del resumen de Kontact +Comment[et]=Kontacti kokkuvõttevaate üldised seadistused +Comment[eu]=Kontact-en laburpen ikuspegiaren konfigurazio orokorra +Comment[fa]=پیکربندی عمومی نمای خلاصۀ Kontact +Comment[fi]=Kontactin yhteenvetonäkymän yleiset asetukset +Comment[fr]=Configuration générale de la vue résumée de Kontact +Comment[fy]=Algemiene ynstellings fan Kontact's oersichtswerjefte +Comment[gl]=Configuración xeral para a vista de resumo de Kontact +Comment[hu]=A Kontact áttekintő nézetének beállításai +Comment[is]=Almennar stillingar fyrir Kontact yfirlitssýn +Comment[it]=Configurazione generale della vista sommario di Kontact +Comment[ja]=Kontact の要約表示の一般的な設定 +Comment[ka]=Kontact დაიჯესტის ხედის ზოგადი პარამეტრები +Comment[kk]=Тұжырымдаманың жалпы параметрлері +Comment[km]=ការកំណត់រចនាសម្ព័ន្ធទូទៅនៃទិដ្ឋភាពសង្ខេបរបស់ Kontact +Comment[lt]=Kontact Santraukos vaizdo bendrasis konfigūravimas +Comment[mk]=Општа конфигурација на прегледот на Контакт +Comment[ms]=Konfigurasi Am Paparan Ringkasan Kontact +Comment[nb]=Generelt oppsett av Kontact's sammendragsoversikt +Comment[nds]=Allgemeen Instellen för de Översichtansicht von Kontact +Comment[ne]=सम्पर्कको सारांश दृश्यको साधारण कन्फिगरेसन +Comment[nl]=Algemene instellingen van Kontact's overzichtsweergave +Comment[nn]=Generelt oppsett av samandragsvisinga i Kontact +Comment[pl]=Ogólna konfiguracja widoku podsumowania w Kontact +Comment[pt]=Configuração Geral da Vista Sumária do Kontact +Comment[pt_BR]=Configuração Geral da Visão de Resumo do Kontact +Comment[ru]=Настройка сводок Kontact +Comment[sk]=Všeobecné nastavenie súhrnu Kontact +Comment[sl]=Splošne nastavitve za prikaz povzetka v Kontract +Comment[sr]=Опште подешавање Kontact-овог приказа сажетка +Comment[sr@Latn]=Opšte podešavanje Kontact-ovog prikaza sažetka +Comment[sv]=Allmän inställning av Kontacts översiktsvy +Comment[ta]=கான்டாக்கின் சுருக்க காட்சியின் பொது கட்டமைப்பு +Comment[tg]=Танзимотҳои умумии дайджести Kontact +Comment[tr]=Kontact'ın Özet Görünümü için Genel Yapılandırma +Comment[uk]=Загальні параметри підсумків Kontact +Comment[zh_CN]=Kontact 概览视图的常规配置 +Comment[zh_TW]=Kontacts 摘要檢視的一般設定 diff --git a/kontact/plugins/summary/kcmkontactsummary.h b/kontact/plugins/summary/kcmkontactsummary.h new file mode 100644 index 000000000..3c6c6d05d --- /dev/null +++ b/kontact/plugins/summary/kcmkontactsummary.h @@ -0,0 +1,62 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2004 Tobias Koenig <tokoe@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#ifndef KCMKONTACTSUMMARY_H +#define KCMKONTACTSUMMARY_H + +#include <kcmodule.h> +#include <klistview.h> + +class KPluginInfo; + +class PluginView : public KListView +{ + Q_OBJECT + + public: + PluginView( QWidget *parent, const char *name = 0 ); + ~PluginView(); +}; + +class KCMKontactSummary : public KCModule +{ + Q_OBJECT + + public: + KCMKontactSummary( QWidget *parent = 0, const char *name = 0 ); + + virtual void load(); + virtual void save(); + virtual void defaults(); + + private slots: + void itemClicked( QListViewItem* ); + + private: + PluginView *mPluginView; + + KPluginInfo::List mPluginList; +}; + +#endif diff --git a/kontact/plugins/summary/kontactsummary_part.rc b/kontact/plugins/summary/kontactsummary_part.rc new file mode 100644 index 000000000..9c121426c --- /dev/null +++ b/kontact/plugins/summary/kontactsummary_part.rc @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<!DOCTYPE gui> +<gui name="kontactsummary" version="3"> + <MenuBar> + <Menu name="settings"><text>&Settings</text> + <Action name="summaryview_configure" group="settings_configure"/> + </Menu> + </MenuBar> +</gui> diff --git a/kontact/plugins/summary/summaryplugin.desktop b/kontact/plugins/summary/summaryplugin.desktop new file mode 100644 index 000000000..d2aa1c956 --- /dev/null +++ b/kontact/plugins/summary/summaryplugin.desktop @@ -0,0 +1,97 @@ +[Desktop Entry] +Type=Service +Icon=kontact_summary +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_summaryplugin +X-KDE-KontactPluginVersion=6 + +X-KDE-PluginInfo-Name=kontact_summaryplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=LGPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=Summary View Component +Comment[bg]=Обобщение +Comment[ca]=Component de vista resum +Comment[da]=Komponent for opsummeringsvisning +Comment[de]=Zusammenfassungsansicht-Komponente +Comment[el]=Συστατικό προβολής σύνοψης +Comment[es]=Componente Vista de resumen +Comment[et]=Kokkuvõttevaate plugin +Comment[fr]=Composant de la vue résumée +Comment[is]=Eining fyrir yfirlitssýn +Comment[it]=Componente vista sommario +Comment[ja]=要約ビューコンポーネント +Comment[km]=សមាសភាគទិដ្ឋភាពសង្ខេប +Comment[nds]=Översicht-Komponent +Comment[nl]=Overzichtsweergaveitem +Comment[pl]=Składnik widoku podsumowania +Comment[ru]=Просмотр сводок +Comment[sr]=Компонента приказа сажетка +Comment[sr@Latn]=Komponenta prikaza sažetka +Comment[sv]=Översiktsvykomponent +Comment[tr]=Özet Görünüm Bileşeni +Comment[zh_CN]=摘要视图组件 +Comment[zh_TW]=摘要檢視組件 +Name=Summary +Name[af]=Opsomming +Name[ar]=الموجز +Name[bg]=Обобщение +Name[br]=Diverrañ +Name[bs]=Sažetak +Name[ca]=Resum +Name[cs]=Souhrn +Name[cy]=Crynodeb +Name[da]=Opsummering +Name[de]=Übersicht +Name[el]=Σύνοψη +Name[eo]=Resumo +Name[es]=Resumen +Name[et]=Kokkuvõte +Name[eu]=Laburpena +Name[fa]=خلاصه +Name[fi]=Yhteenveto +Name[fr]=Résumé +Name[fy]=Oersicht +Name[ga]=Achoimre +Name[gl]=Resumo +Name[he]=תקציר +Name[hi]=सारांश +Name[hu]=Áttekintő +Name[is]=Yfirlit +Name[it]=Sommario +Name[ja]=要約 +Name[ka]=დაიჯესტი +Name[kk]=Тұжырым +Name[km]=សង្ខេប +Name[lt]=Santrauka +Name[mk]=Преглед +Name[ms]=Ringkasan +Name[nb]=Sammendrag +Name[nds]=Översicht +Name[ne]=सारांश +Name[nl]=Overzicht +Name[nn]=Samandrag +Name[pl]=Podsumowanie +Name[pt]=Resumo +Name[pt_BR]=Resumo +Name[ro]=Sumar +Name[ru]=Сводки +Name[se]=Čoahkkáigeassu +Name[sk]=Súhrn +Name[sl]=Povzetek +Name[sr]=Сажетак +Name[sr@Latn]=Sažetak +Name[sv]=Översikt +Name[ta]=சுருக்கம் +Name[tg]=Дайджест +Name[th]=หน้าสรุป +Name[tr]=Özet +Name[uk]=Зведення +Name[uz]=Hisobot +Name[uz@cyrillic]=Ҳисобот +Name[zh_CN]=概览 +Name[zh_TW]=摘要 +#Always last +InitialPreference=0 diff --git a/kontact/plugins/summary/summaryview_part.cpp b/kontact/plugins/summary/summaryview_part.cpp new file mode 100644 index 000000000..9597de674 --- /dev/null +++ b/kontact/plugins/summary/summaryview_part.cpp @@ -0,0 +1,434 @@ +/* + This file is part of KDE Kontact. + + Copyright (C) 2003 Sven Lüppken <sven@kde.org> + Copyright (C) 2003 Tobias König <tokoe@kde.org> + Copyright (C) 2003 Daniel Molkentin <molkentin@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <qframe.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qtimer.h> + +#include <dcopclient.h> +#include <kaction.h> +#include <kapplication.h> +#include <kconfig.h> +#include <kdcopservicestarter.h> +#include <kdebug.h> +#include <kdialog.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kservice.h> +#include <ktrader.h> +#include <kstandarddirs.h> +#include <qscrollview.h> +#include <kglobal.h> +#include <klocale.h> +#include <kcmultidialog.h> + +#include <kparts/componentfactory.h> +#include <kparts/event.h> + +#include <libkpimidentities/identity.h> +#include <libkpimidentities/identitymanager.h> + +#include <infoextension.h> +#include <sidebarextension.h> + +#include "plugin.h" +#include "summary.h" + +#include "summaryview_part.h" + +#include "broadcaststatus.h" +using KPIM::BroadcastStatus; + +namespace Kontact +{ + class MainWindow; +} + +SummaryViewPart::SummaryViewPart( Kontact::Core *core, const char*, + const KAboutData *aboutData, + QObject *parent, const char *name ) + : KParts::ReadOnlyPart( parent, name ), + mCore( core ), mFrame( 0 ), mConfigAction( 0 ) +{ + setInstance( new KInstance( aboutData ) ); + + loadLayout(); + + initGUI( core ); + + connect( kapp, SIGNAL( kdisplayPaletteChanged() ), SLOT( slotAdjustPalette() ) ); + slotAdjustPalette(); + + setDate( QDate::currentDate() ); + connect( mCore, SIGNAL( dayChanged( const QDate& ) ), + SLOT( setDate( const QDate& ) ) ); + + KParts::InfoExtension *info = new KParts::InfoExtension( this, "Summary" ); + connect( this, SIGNAL( textChanged( const QString& ) ), + info, SIGNAL( textChanged( const QString& ) ) ); + + mConfigAction = new KAction( i18n( "&Configure Summary View..." ), + "configure", 0, this, + SLOT( slotConfigure() ), actionCollection(), + "summaryview_configure" ); + + setXMLFile( "kontactsummary_part.rc" ); + + QTimer::singleShot( 0, this, SLOT( slotTextChanged() ) ); +} + +SummaryViewPart::~SummaryViewPart() +{ + saveLayout(); +} + +bool SummaryViewPart::openFile() +{ + kdDebug(5006) << "SummaryViewPart:openFile()" << endl; + return true; +} + +void SummaryViewPart::partActivateEvent( KParts::PartActivateEvent *event ) +{ + // inform the plugins that the part has been activated so that they can + // update the displayed information + if ( event->activated() && ( event->part() == this ) ) { + updateSummaries(); + } + + KParts::ReadOnlyPart::partActivateEvent( event ); +} + +void SummaryViewPart::updateSummaries() +{ + QMap<QString, Kontact::Summary*>::Iterator it; + for ( it = mSummaries.begin(); it != mSummaries.end(); ++it ) + it.data()->updateSummary( false ); +} + +void SummaryViewPart::updateWidgets() +{ + mMainWidget->setUpdatesEnabled( false ); + + delete mFrame; + + KPIM::IdentityManager idm( true, this ); + const KPIM::Identity &id = idm.defaultIdentity(); + + QString currentUser = i18n( "Summary for %1" ).arg( id.fullName() ); + mUsernameLabel->setText( QString::fromLatin1( "<b>%1</b>" ).arg( currentUser ) ); + + mSummaries.clear(); + + mFrame = new DropWidget( mMainWidget ); + connect( mFrame, SIGNAL( summaryWidgetDropped( QWidget*, QWidget*, int ) ), + this, SLOT( summaryWidgetMoved( QWidget*, QWidget*, int ) ) ); + + mMainLayout->insertWidget( 2, mFrame ); + + QStringList activeSummaries; + + KConfig config( "kontact_summaryrc" ); + if ( !config.hasKey( "ActiveSummaries" ) ) { + activeSummaries << "kontact_kmailplugin"; + activeSummaries << "kontact_specialdatesplugin"; + activeSummaries << "kontact_korganizerplugin"; + activeSummaries << "kontact_todoplugin"; + activeSummaries << "kontact_newstickerplugin"; + } else { + activeSummaries = config.readListEntry( "ActiveSummaries" ); + } + + // Collect all summary widgets with a summaryHeight > 0 + QStringList loadedSummaries; + + QValueList<Kontact::Plugin*> plugins = mCore->pluginList(); + QValueList<Kontact::Plugin*>::ConstIterator end = plugins.end(); + QValueList<Kontact::Plugin*>::ConstIterator it = plugins.begin(); + for ( ; it != end; ++it ) { + Kontact::Plugin *plugin = *it; + if ( activeSummaries.find( plugin->identifier() ) == activeSummaries.end() ) + continue; + + Kontact::Summary *summary = plugin->createSummaryWidget( mFrame ); + if ( summary ) { + if ( summary->summaryHeight() > 0 ) { + mSummaries.insert( plugin->identifier(), summary ); + + connect( summary, SIGNAL( message( const QString& ) ), + BroadcastStatus::instance(), SLOT( setStatusMsg( const QString& ) ) ); + connect( summary, SIGNAL( summaryWidgetDropped( QWidget*, QWidget*, int ) ), + this, SLOT( summaryWidgetMoved( QWidget*, QWidget*, int ) ) ); + + if ( !mLeftColumnSummaries.contains( plugin->identifier() ) && + !mRightColumnSummaries.contains( plugin->identifier() ) ) { + mLeftColumnSummaries.append( plugin->identifier() ); + } + + loadedSummaries.append( plugin->identifier() ); + } else { + summary->hide(); + } + } + } + + // Remove all unavailable summary widgets + { + QStringList::Iterator strIt; + for ( strIt = mLeftColumnSummaries.begin(); strIt != mLeftColumnSummaries.end(); ++strIt ) { + if ( loadedSummaries.find( *strIt ) == loadedSummaries.end() ) { + strIt = mLeftColumnSummaries.remove( strIt ); + --strIt; + } + } + for ( strIt = mRightColumnSummaries.begin(); strIt != mRightColumnSummaries.end(); ++strIt ) { + if ( loadedSummaries.find( *strIt ) == loadedSummaries.end() ) { + strIt = mRightColumnSummaries.remove( strIt ); + --strIt; + } + } + } + + // Add vertical line between the two rows of summary widgets. + QFrame *vline = new QFrame( mFrame ); + vline->setFrameStyle( QFrame::VLine | QFrame::Plain ); + + QHBoxLayout *layout = new QHBoxLayout( mFrame ); + + mLeftColumn = new QVBoxLayout( layout, KDialog::spacingHint() ); + layout->addWidget( vline ); + mRightColumn = new QVBoxLayout( layout, KDialog::spacingHint() ); + + + QStringList::Iterator strIt; + for ( strIt = mLeftColumnSummaries.begin(); strIt != mLeftColumnSummaries.end(); ++strIt ) { + if ( mSummaries.find( *strIt ) != mSummaries.end() ) + mLeftColumn->addWidget( mSummaries[ *strIt ] ); + } + + for ( strIt = mRightColumnSummaries.begin(); strIt != mRightColumnSummaries.end(); ++strIt ) { + if ( mSummaries.find( *strIt ) != mSummaries.end() ) + mRightColumn->addWidget( mSummaries[ *strIt ] ); + } + + mFrame->show(); + + mMainWidget->setUpdatesEnabled( true ); + mMainWidget->update(); + + mLeftColumn->addStretch(); + mRightColumn->addStretch(); +} + +void SummaryViewPart::summaryWidgetMoved( QWidget *target, QWidget *widget, int alignment ) +{ + if ( target == widget ) + return; + + if ( target == mFrame ) { + if ( mLeftColumn->findWidget( widget ) == -1 && mRightColumn->findWidget( widget ) == -1 ) + return; + } else { + if ( mLeftColumn->findWidget( target ) == -1 && mRightColumn->findWidget( target ) == -1 || + mLeftColumn->findWidget( widget ) == -1 && mRightColumn->findWidget( widget ) == -1 ) + return; + } + + if ( mLeftColumn->findWidget( widget ) != -1 ) { + mLeftColumn->remove( widget ); + mLeftColumnSummaries.remove( widgetName( widget ) ); + } else if ( mRightColumn->findWidget( widget ) != -1 ) { + mRightColumn->remove( widget ); + mRightColumnSummaries.remove( widgetName( widget ) ); + } + + if ( target == mFrame ) { + int pos = 0; + + if ( alignment & Qt::AlignTop ) + pos = 0; + + if ( alignment & Qt::AlignLeft ) { + if ( alignment & Qt::AlignBottom ) + pos = mLeftColumnSummaries.count(); + + mLeftColumn->insertWidget( pos, widget ); + mLeftColumnSummaries.insert( mLeftColumnSummaries.at( pos ), widgetName( widget ) ); + } else { + if ( alignment & Qt::AlignBottom ) + pos = mRightColumnSummaries.count(); + + mRightColumn->insertWidget( pos, widget ); + mRightColumnSummaries.insert( mRightColumnSummaries.at( pos ), widgetName( widget ) ); + } + + return; + } + + int targetPos = mLeftColumn->findWidget( target ); + if ( targetPos != -1 ) { + if ( alignment == Qt::AlignBottom ) + targetPos++; + + mLeftColumn->insertWidget( targetPos, widget ); + mLeftColumnSummaries.insert( mLeftColumnSummaries.at( targetPos ), widgetName( widget ) ); + } else { + targetPos = mRightColumn->findWidget( target ); + + if ( alignment == Qt::AlignBottom ) + targetPos++; + + mRightColumn->insertWidget( targetPos, widget ); + mRightColumnSummaries.insert( mRightColumnSummaries.at( targetPos ), widgetName( widget ) ); + } +} + +void SummaryViewPart::slotTextChanged() +{ + emit textChanged( i18n( "What's next?" ) ); +} + +void SummaryViewPart::slotAdjustPalette() +{ + mMainWidget->setPaletteBackgroundColor( kapp->palette().active().base() ); +} + +void SummaryViewPart::setDate( const QDate& newDate ) +{ + QString date( "<b>%1</b>" ); + date = date.arg( KGlobal::locale()->formatDate( newDate ) ); + mDateLabel->setText( date ); +} + +void SummaryViewPart::slotConfigure() +{ + KCMultiDialog dlg( mMainWidget, "ConfigDialog", true ); + + QStringList modules = configModules(); + modules.prepend( "kcmkontactsummary.desktop" ); + connect( &dlg, SIGNAL( configCommitted() ), + this, SLOT( updateWidgets() ) ); + + QStringList::ConstIterator strIt; + for ( strIt = modules.begin(); strIt != modules.end(); ++strIt ) + dlg.addModule( *strIt ); + + dlg.exec(); +} + +QStringList SummaryViewPart::configModules() const +{ + QStringList modules; + + QMap<QString, Kontact::Summary*>::ConstIterator it; + for ( it = mSummaries.begin(); it != mSummaries.end(); ++it ) { + QStringList cm = it.data()->configModules(); + QStringList::ConstIterator strIt; + for ( strIt = cm.begin(); strIt != cm.end(); ++strIt ) + if ( !(*strIt).isEmpty() && !modules.contains( *strIt ) ) + modules.append( *strIt ); + } + + return modules; +} + +void SummaryViewPart::initGUI( Kontact::Core *core ) +{ + QScrollView *sv = new QScrollView( core ); + + sv->setResizePolicy( QScrollView::AutoOneFit ); + sv->setFrameStyle( QFrame::NoFrame | QFrame::Plain ); + sv->setHScrollBarMode( QScrollView::AlwaysOff ); + + mMainWidget = new QFrame( sv->viewport() ); + sv->addChild( mMainWidget ); + mMainWidget->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + sv->setFocusPolicy( QWidget::StrongFocus ); + setWidget( sv ); + + mMainLayout = new QVBoxLayout( mMainWidget,KDialog::marginHint(), + KDialog::spacingHint() ); + + QHBoxLayout *hbl = new QHBoxLayout( mMainLayout ); + mUsernameLabel = new QLabel( mMainWidget ); + hbl->addWidget( mUsernameLabel ); + mDateLabel = new QLabel( mMainWidget ); + mDateLabel->setAlignment( AlignRight ); + hbl->addWidget( mDateLabel ); + + QFrame *hline = new QFrame( mMainWidget ); + hline->setFrameStyle( QFrame::HLine | QFrame::Plain ); + mMainLayout->insertWidget( 1, hline ); + + mFrame = new DropWidget( mMainWidget ); + mMainLayout->insertWidget( 2, mFrame ); + + connect( mFrame, SIGNAL( summaryWidgetDropped( QWidget*, QWidget*, int ) ), + this, SLOT( summaryWidgetMoved( QWidget*, QWidget*, int ) ) ); + + updateWidgets(); +} + +void SummaryViewPart::loadLayout() +{ + KConfig config( "kontact_summaryrc" ); + + if ( !config.hasKey( "LeftColumnSummaries" ) ) { + mLeftColumnSummaries << "kontact_korganizerplugin"; + mLeftColumnSummaries << "kontact_todoplugin"; + mLeftColumnSummaries << "kontact_kaddressbookplugin"; + mLeftColumnSummaries << "kontact_specialdatesplugin"; + } else { + mLeftColumnSummaries = config.readListEntry( "LeftColumnSummaries" ); + } + + if ( !config.hasKey( "RightColumnSummaries" ) ) { + mRightColumnSummaries << "kontact_newstickerplugin"; + } else { + mRightColumnSummaries = config.readListEntry( "RightColumnSummaries" ); + } +} + +void SummaryViewPart::saveLayout() +{ + KConfig config( "kontact_summaryrc" ); + + config.writeEntry( "LeftColumnSummaries", mLeftColumnSummaries ); + config.writeEntry( "RightColumnSummaries", mRightColumnSummaries ); + + config.sync(); +} + +QString SummaryViewPart::widgetName( QWidget *widget ) const +{ + QMap<QString, Kontact::Summary*>::ConstIterator it; + for ( it = mSummaries.begin(); it != mSummaries.end(); ++it ) { + if ( it.data() == widget ) + return it.key(); + } + + return QString::null; +} + +#include "summaryview_part.moc" diff --git a/kontact/plugins/summary/summaryview_part.h b/kontact/plugins/summary/summaryview_part.h new file mode 100644 index 000000000..f98d7d065 --- /dev/null +++ b/kontact/plugins/summary/summaryview_part.h @@ -0,0 +1,103 @@ +/* + This file is part of KDE Kontact. + + Copyright (C) 2003 Sven Lüppken <sven@kde.org> + Copyright (C) 2003 Tobias König <tokoe@kde.org> + Copyright (C) 2003 Daniel Molkentin <molkentin@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef SUMMARYVIEW_PART_H +#define SUMMARYVIEW_PART_H + +#include <qdatetime.h> +#include <qmap.h> + +#include <kparts/part.h> + +#include "core.h" +#include "dropwidget.h" + +namespace Kontact +{ + class Plugin; + class Summary; +} + +namespace KParts +{ + class PartActivateEvent; +} + +class QFrame; +class QLabel; +class QGridLayout; +class KAction; +class KCMultiDialog; + +class SummaryViewPart : public KParts::ReadOnlyPart +{ + Q_OBJECT + + public: + SummaryViewPart( Kontact::Core *core, const char *widgetName, + const KAboutData *aboutData, + QObject *parent = 0, const char *name = 0 ); + ~SummaryViewPart(); + + public slots: + void slotTextChanged(); + void slotAdjustPalette(); + void setDate( const QDate& newDate ); + void updateSummaries(); + + signals: + void textChanged( const QString& ); + + protected: + virtual bool openFile(); + virtual void partActivateEvent( KParts::PartActivateEvent *event ); + + protected slots: + void slotConfigure(); + void updateWidgets(); + void summaryWidgetMoved( QWidget *target, QWidget *widget, int alignment ); + + private: + void initGUI( Kontact::Core *core ); + void loadLayout(); + void saveLayout(); + QString widgetName( QWidget* ) const; + + QStringList configModules() const; + + QMap<QString, Kontact::Summary*> mSummaries; + Kontact::Core *mCore; + DropWidget *mFrame; + QFrame *mMainWidget; + QVBoxLayout *mMainLayout; + QVBoxLayout *mLeftColumn; + QVBoxLayout *mRightColumn; + QLabel *mUsernameLabel; + QLabel *mDateLabel; + KAction *mConfigAction; + + QStringList mLeftColumnSummaries; + QStringList mRightColumnSummaries; +}; + +#endif diff --git a/kontact/plugins/summary/summaryview_plugin.cpp b/kontact/plugins/summary/summaryview_plugin.cpp new file mode 100644 index 000000000..a73faf7e0 --- /dev/null +++ b/kontact/plugins/summary/summaryview_plugin.cpp @@ -0,0 +1,123 @@ +/* This file is part of the KDE project + Copyright (C) 2003 Sven L�ppken <sven@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + */ + +#include "summaryview_plugin.h" +#include "core.h" +#include "summaryview_part.h" + +#include <dcopref.h> +#include <kgenericfactory.h> +#include <kparts/componentfactory.h> +#include <kaboutdata.h> +#include <kaction.h> + +#include <qpopupmenu.h> + +typedef KGenericFactory< SummaryView, Kontact::Core > SummaryViewFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_summaryplugin, + SummaryViewFactory( "kontact_summaryplugin" ) ) + +SummaryView::SummaryView( Kontact::Core *core, const char *name, const QStringList& ) + : Kontact::Plugin( core, core, name), + mAboutData( 0 ), mPart( 0 ) +{ + setInstance( SummaryViewFactory::instance() ); + + mSyncAction = new KSelectAction( i18n( "Synchronize All" ), "reload", 0, this, + SLOT( doSync() ), actionCollection(), + "kontact_summary_sync" ); + connect( mSyncAction, SIGNAL( activated( const QString& ) ), this, SLOT( syncAccount( const QString& ) ) ); + connect( mSyncAction->popupMenu(), SIGNAL( aboutToShow() ), this, SLOT( fillSyncActionSubEntries() ) ); + + insertSyncAction( mSyncAction ); + fillSyncActionSubEntries(); +} + +void SummaryView::fillSyncActionSubEntries() +{ + QStringList menuItems; + menuItems.append( i18n("All") ); + + DCOPRef ref( "kmail", "KMailIface" ); + DCOPReply reply = ref.call( "accounts" ); + + if ( reply.isValid() ) + { + const QStringList accounts = reply; + menuItems += accounts; + } + mSyncAction->clear(); + mSyncAction->setItems( menuItems ); +} + +void SummaryView::syncAccount( const QString& account ) +{ + const QString acc = account == i18n("All") ? QString() : account; + DCOPRef ref( "kmail", "KMailIface" ); + ref.send( "checkAccount", acc ); + fillSyncActionSubEntries(); +} + +SummaryView::~SummaryView() +{ +} + +void SummaryView::doSync() +{ + if ( mPart ) + mPart->updateSummaries(); + + const QValueList<Kontact::Plugin*> pluginList = core()->pluginList(); + for ( QValueList<Kontact::Plugin*>::ConstIterator it = pluginList.begin(), end = pluginList.end(); + it != end; ++it ) { + // execute all sync actions but our own + QPtrList<KAction> *actions = (*it)->syncActions(); + for ( QPtrList<KAction>::Iterator jt = actions->begin(), end = actions->end(); jt != end; ++jt ) { + if ( *jt != mSyncAction ) + (*jt)->activate(); + } + } + fillSyncActionSubEntries(); +} + +KParts::ReadOnlyPart *SummaryView::createPart() +{ + mPart = new SummaryViewPart( core(), "summarypartframe", aboutData(), + this, "summarypart" ); + return mPart; +} + +const KAboutData *SummaryView::aboutData() +{ + if ( !mAboutData ) { + mAboutData = new KAboutData( "kontactsummary", I18N_NOOP("Kontact Summary"), + "1.1", + I18N_NOOP("Kontact Summary View"), + KAboutData::License_LGPL, + I18N_NOOP("(c) 2003 The Kontact developers" ) ); + mAboutData->addAuthor( "Sven Lueppken", "", "sven@kde.org" ); + mAboutData->addAuthor( "Cornelius Schumacher", "", "schumacher@kde.org" ); + mAboutData->addAuthor( "Tobias Koenig", "", "tokoe@kde.org" ); + mAboutData->setProductName( "kontact/summary" ); + } + + return mAboutData; +} + +#include "summaryview_plugin.moc" diff --git a/kontact/plugins/summary/summaryview_plugin.h b/kontact/plugins/summary/summaryview_plugin.h new file mode 100644 index 000000000..9093a1b34 --- /dev/null +++ b/kontact/plugins/summary/summaryview_plugin.h @@ -0,0 +1,62 @@ +/* + This file is part of KDE Kontact. + + Copyright (C) 2003 Sven L�ppken <sven@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef SUMMARYVIEW_PLUGIN_H +#define SUMMARYVIEW_PLUGIN_H +#include "plugin.h" + +#include <klocale.h> +#include <kparts/part.h> + +#include <qmap.h> + +class KSelectAction; + +class SummaryViewPart; + +class SummaryView : public Kontact::Plugin +{ + Q_OBJECT + + public: + SummaryView( Kontact::Core *core, const char *name, const QStringList& ); + ~SummaryView(); + + int weight() const { return 100; } + + const KAboutData *aboutData(); + + protected: + virtual KParts::ReadOnlyPart* createPart(); + + private slots: + + void doSync(); + void syncAccount( const QString& account ); + void fillSyncActionSubEntries(); + + private: + KAboutData *mAboutData; + SummaryViewPart *mPart; + KSelectAction *mSyncAction; +}; + +#endif |