diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch) | |
tree | 67208f7c145782a7e90b123b982ca78d88cc2c87 /kontact/plugins | |
download | tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kontact/plugins')
113 files changed, 12289 insertions, 0 deletions
diff --git a/kontact/plugins/Makefile.am b/kontact/plugins/Makefile.am new file mode 100644 index 000000000..986713b93 --- /dev/null +++ b/kontact/plugins/Makefile.am @@ -0,0 +1,6 @@ +if compile_kpilot +KPILOT_KONTACTPLUGIN = kpilot +endif + +SUBDIRS = $(KPILOT_KONTACTPLUGIN) kaddressbook kmail knotes korganizer \ + summary weather knode newsticker specialdates akregator karm diff --git a/kontact/plugins/akregator/Makefile.am b/kontact/plugins/akregator/Makefile.am new file mode 100644 index 000000000..d97f14341 --- /dev/null +++ b/kontact/plugins/akregator/Makefile.am @@ -0,0 +1,14 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces -I$(top_srcdir)/akregator/src -I$(top_srcdir) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_akregator.la +libkontact_akregator_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_akregator_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(LIB_KPARTS) +libkontact_akregator_la_SOURCES = akregator_plugin.cpp akregator_partiface.stub + +METASOURCES = AUTO + +akregator_partiface_DIR = $(top_srcdir)/akregator/src + +servicedir = $(kde_servicesdir)/kontact +service_DATA = akregatorplugin.desktop akregatorplugin3.2.desktop + diff --git a/kontact/plugins/akregator/akregator_plugin.cpp b/kontact/plugins/akregator/akregator_plugin.cpp new file mode 100644 index 000000000..d57cea7f6 --- /dev/null +++ b/kontact/plugins/akregator/akregator_plugin.cpp @@ -0,0 +1,156 @@ +/* + This file is part of Akregator. + + Copyright (C) 2004 Sashmit Bhaduri <smt@vfemail.net> + + 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 <qwidget.h> + +#include <dcopclient.h> +#include <dcopref.h> +#include <kaboutdata.h> +#include <kaction.h> +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <kiconloader.h> +#include <kmessagebox.h> +#include <kparts/componentfactory.h> + +#include <core.h> +#include <plugin.h> + +#include <akregator_options.h> +#include <akregator_part.h> +#include "akregator_plugin.h" +namespace Akregator { + +typedef KGenericFactory<Akregator::Plugin, Kontact::Core > PluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_akregator, + PluginFactory( "kontact_akregator" ) ) + +Plugin::Plugin( Kontact::Core *core, const char *, const QStringList& ) + : Kontact::Plugin( core, core, "akregator" ), m_stub(0) +{ + + setInstance( PluginFactory::instance() ); + + insertNewAction( new KAction( i18n( "New Feed..." ), "bookmark_add", CTRL+SHIFT+Key_F, this, SLOT( addFeed() ), actionCollection(), "feed_new" ) ); + + m_uniqueAppWatcher = new Kontact::UniqueAppWatcher( + new Kontact::UniqueAppHandlerFactory<Akregator::UniqueAppHandler>(), this ); +} + +Plugin::~Plugin() +{ +} + +bool Plugin::isRunningStandalone() +{ + return m_uniqueAppWatcher->isRunningStandalone(); +} + +QStringList Plugin::invisibleToolbarActions() const +{ + return QStringList( "file_new_contact" ); +} + + +Akregator::AkregatorPartIface_stub *Plugin::interface() +{ + if ( !m_stub ) { + part(); + } + + Q_ASSERT( m_stub ); + return m_stub; +} + + +MyBasePart* Plugin::createPart() +{ + MyBasePart* p = loadPart(); + + connect(p, SIGNAL(showPart()), this, SLOT(showPart())); + m_stub = new Akregator::AkregatorPartIface_stub( dcopClient(), "akregator", + "AkregatorIface" ); + m_stub->openStandardFeedList(); + return p; +} + + +void Plugin::showPart() +{ + core()->selectPlugin(this); +} + +void Plugin::addFeed() +{ + interface()->addFeed(); +} + +QStringList Plugin::configModules() const +{ + QStringList modules; + modules << "PIM/akregator.desktop"; + return modules; +} + +void Plugin::readProperties( KConfig *config ) +{ + if ( part() ) { + Akregator::Part *myPart = static_cast<Akregator::Part*>( part() ); + myPart->readProperties( config ); + } +} + +void Plugin::saveProperties( KConfig *config ) +{ + if ( part() ) { + Akregator::Part *myPart = static_cast<Akregator::Part*>( part() ); + myPart->saveProperties( config ); + } +} + +void UniqueAppHandler::loadCommandLineOptions() +{ + KCmdLineArgs::addCmdLineOptions( akregator_options ); +} + +int UniqueAppHandler::newInstance() +{ + kdDebug(5602) << k_funcinfo << endl; + // Ensure part is loaded + (void)plugin()->part(); + DCOPRef akr( "akregator", "AkregatorIface" ); +// DCOPReply reply = kAB.call( "handleCommandLine" ); + // if ( reply.isValid() ) { + // bool handled = reply; + // kdDebug(5602) << k_funcinfo << "handled=" << handled << endl; + // if ( !handled ) // no args -> simply bring kaddressbook plugin to front + return Kontact::UniqueAppHandler::newInstance(); + // } + // return 0; +} + +} // namespace Akregator +#include "akregator_plugin.moc" diff --git a/kontact/plugins/akregator/akregator_plugin.h b/kontact/plugins/akregator/akregator_plugin.h new file mode 100644 index 000000000..af1a905f9 --- /dev/null +++ b/kontact/plugins/akregator/akregator_plugin.h @@ -0,0 +1,81 @@ +/* + This file is part of Akregator. + + Copyright (C) 2004 Sashmit Bhaduri <smt@vfemail.net> + + 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 AKREGATOR_PLUGIN_H +#define AKREGATOR_PLUGIN_H + +#include <klocale.h> +#include <kparts/part.h> + +#include <kparts/part.h> +#include <plugin.h> +#include "akregator_partiface_stub.h" +#include <uniqueapphandler.h> + +class KAboutData; + +namespace Akregator { + +typedef KParts::ReadOnlyPart MyBasePart; + +class UniqueAppHandler : public Kontact::UniqueAppHandler +{ + public: + UniqueAppHandler( Kontact::Plugin* plugin ) : Kontact::UniqueAppHandler( plugin ) {} + virtual void loadCommandLineOptions(); + virtual int newInstance(); +}; + + +class Plugin : public Kontact::Plugin +{ + Q_OBJECT + + public: + Plugin( Kontact::Core *core, const char *name, + const QStringList & ); + ~Plugin(); + + int weight() const { return 700; } + + AkregatorPartIface_stub *interface(); + + virtual QStringList configModules() const; + virtual QStringList invisibleToolbarActions() const; + virtual bool isRunningStandalone(); + virtual void readProperties( KConfig *config ); + virtual void saveProperties( KConfig *config ); + + private slots: + void showPart(); + void addFeed(); + + protected: + MyBasePart *createPart(); + AkregatorPartIface_stub *m_stub; + Kontact::UniqueAppWatcher *m_uniqueAppWatcher; +}; + +} // namespace Akregator +#endif diff --git a/kontact/plugins/akregator/akregatorplugin.desktop b/kontact/plugins/akregator/akregatorplugin.desktop new file mode 100644 index 000000000..015ae80a1 --- /dev/null +++ b/kontact/plugins/akregator/akregatorplugin.desktop @@ -0,0 +1,87 @@ +[Desktop Entry] +Type=Service +Icon=akregator +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_akregator +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPartLibraryName=libakregatorpart +X-KDE-KontactPartLoadOnStart=false + +X-KDE-PluginInfo-Name=kontact_akregator +X-KDE-PluginInfo-Version=1.0b2 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=Feed Reader Component (Akregator Plugin) +Comment[bg]=Приставка за Akregator +Comment[ca]=Component lector d'enllaços (endollable de l'Akregator) +Comment[da]=Feed-læserkomponent (Akregator-plugin) +Comment[de]=News-Leser (Akregator-Modul) +Comment[el]=Συστατικό ανάγνωσης ροών (Πρόσθετο του Akregator) +Comment[es]=Componente de lectura de fuentes (complemento de Akregator) +Comment[et]=Uudistevoogude plugin (Akregator) +Comment[fr]=Composant du lecteur de flux (Module pour Akregator) +Comment[is]=Fréttastraumalestur (Akregator íforrit) +Comment[it]=Componente lettore fonti (plugin Akregator) +Comment[ja]=フィードリーダーコンポーネント (Akregator プラグイン) +Comment[km]=មមាសភាគកម្មវិធីអានមតិព័ត៌មាន (កម្មវិធីជំនួយ Akregator) +Comment[nds]=Stroomleser-Komponent (Akregator-Moduul) +Comment[nl]=Component om feeds te lezen (Akregator-plugin) +Comment[pl]=Składnik do czytania kanałów RSS (wtyczka Akregator) +Comment[ru]=Просмотр лент новостей (модуль Akregator) +Comment[sk]=Komponent na čítanie kanálov (Modul pre Akregator) +Comment[sr]=Компонента читања довода (прикључак Akregator-а) +Comment[sr@Latn]=Komponenta čitanja dovoda (priključak Akregator-a) +Comment[sv]=Komponent för läsning av kanaler (Akregator-insticksprogram) +Comment[tr]=Kaynak Okuyucu Bileşeni (Akregator Eklentisi) +Comment[zh_CN]=新闻源阅读器组件(Akregator 插件) +Comment[zh_TW]=Feed 閱讀器組件(Akregator 外掛程式) +Name=Feeds +Name[af]=Strome +Name[bg]=Новини +Name[ca]=Enllaços +Name[cs]=Kanály +Name[da]=Kilder +Name[de]=Nachrichten +Name[el]=Ροές +Name[eo]=Fluoj +Name[es]=Orígenes +Name[et]=Uudisevood +Name[eu]=Iturriak +Name[fa]=خوراندنها +Name[fi]=Syötteet +Name[fr]=Flux +Name[fy]=Nijsoanfier +Name[ga]=Fothaí +Name[gl]=Fontes +Name[he]=ערוצים +Name[hu]=Hírforrások +Name[is]=Fréttastraumar +Name[it]=Fonti +Name[ja]=フィード +Name[ka]=კვება +Name[kk]=Ақпарлар +Name[km]=មតិព័ត៌មាន +Name[lt]=Kanalai +Name[ms]=Suapan +Name[nb]=Kanaler +Name[nds]=Narichtenströöm +Name[ne]=फिड +Name[nn]=Kanalar +Name[pl]=Kanały +Name[pt]=Fontes +Name[pt_BR]=Fontes de Notícias +Name[ru]=Ленты новостей +Name[sk]=Kanály +Name[sl]=Viri +Name[sr]=Доводи +Name[sr@Latn]=Dovodi +Name[sv]=Kanaler +Name[ta]=உள்ளீடுகள் +Name[tr]=Haberler +Name[uk]=Подачі +Name[uz]=Yangiliklar tasmalari +Name[uz@cyrillic]=Янгиликлар тасмалари +Name[zh_CN]=种子 + diff --git a/kontact/plugins/akregator/akregatorplugin3.2.desktop b/kontact/plugins/akregator/akregatorplugin3.2.desktop new file mode 100644 index 000000000..7bd29ffbc --- /dev/null +++ b/kontact/plugins/akregator/akregatorplugin3.2.desktop @@ -0,0 +1,112 @@ +[Desktop Entry] +Type=Service +Icon=akregator +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_akregator +X-KDE-KontactPluginVersion=3 +X-KDE-KontactPartLibraryName=libakregatorpart + +X-KDE-PluginInfo-Name=kontact_akregator +X-KDE-PluginInfo-Version=1.0b2 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=Akregator Plugin +Comment[af]=Akregator inprop module +Comment[bg]=Приставка за Akregator +Comment[br]=Lugant Akregator +Comment[ca]=Endollable Akregator +Comment[cs]=Modul Akregatoru +Comment[de]=Akregator-Modul +Comment[el]=Πρόσθετο του Akregator +Comment[eo]=Akregator-kromaĵo +Comment[es]=Extensión de Akregator +Comment[et]=Akregatori plugin +Comment[eu]=Akregator plugin-a +Comment[fa]=وصلۀ Akregator +Comment[fi]=Akregator-liitännäinen +Comment[fr]=Module pour Akregator +Comment[fy]=Akregatorplugin +Comment[ga]=Breiseán Akregator +Comment[gl]=Extensión para Akregator +Comment[he]=תוסף עבור Akregator +Comment[hu]=Akregator bővítőmodul +Comment[is]=Akregator íforrit +Comment[it]=Plugin aKregator +Comment[ja]=Akregator プラグイン +Comment[ka]=Akregator-ის მოდული +Comment[kk]=Akregator модулі +Comment[km]=កម្មវិធីជំនួយ Akregator +Comment[lt]=Akregator priedas +Comment[mk]=Приклучок за Akregator +Comment[ms]=Plugin Akregator +Comment[nb]=Akgregator-programtillegg +Comment[nds]=Akregator-Moduul +Comment[ne]=एक्रिगेटर प्लगइन +Comment[nl]=Akregatorplugin +Comment[nn]=Akregator-programtillegg +Comment[pl]=Wtyczka Akregatora +Comment[pt]='Plugin' Akregator +Comment[pt_BR]=Plug-in do Akregator +Comment[ru]=Модуль Akregator +Comment[sk]=Modul Akregator +Comment[sl]=Vstavek Akregator +Comment[sr]=Прикључак Akregator-а +Comment[sr@Latn]=Priključak Akregator-a +Comment[sv]=Akregator-insticksprogram +Comment[ta]=Akregator சொருகுப்பொருள் +Comment[tr]=Akregator Eklentisi +Comment[uk]=Втулок Akregator +Comment[uz]=Akregator plagini +Comment[uz@cyrillic]=Akregator плагини +Comment[zh_CN]=Akregator 插件 +Comment[zh_TW]=Akregator 外掛程式 +Name=Feeds +Name[af]=Strome +Name[bg]=Новини +Name[ca]=Enllaços +Name[cs]=Kanály +Name[da]=Kilder +Name[de]=Nachrichten +Name[el]=Ροές +Name[eo]=Fluoj +Name[es]=Orígenes +Name[et]=Uudisevood +Name[eu]=Iturriak +Name[fa]=خوراندنها +Name[fi]=Syötteet +Name[fr]=Flux +Name[fy]=Nijsoanfier +Name[ga]=Fothaí +Name[gl]=Fontes +Name[he]=ערוצים +Name[hu]=Hírforrások +Name[is]=Fréttastraumar +Name[it]=Fonti +Name[ja]=フィード +Name[ka]=კვება +Name[kk]=Ақпарлар +Name[km]=មតិព័ត៌មាន +Name[lt]=Kanalai +Name[ms]=Suapan +Name[nb]=Kanaler +Name[nds]=Narichtenströöm +Name[ne]=फिड +Name[nn]=Kanalar +Name[pl]=Kanały +Name[pt]=Fontes +Name[pt_BR]=Fontes de Notícias +Name[ru]=Ленты новостей +Name[sk]=Kanály +Name[sl]=Viri +Name[sr]=Доводи +Name[sr@Latn]=Dovodi +Name[sv]=Kanaler +Name[ta]=உள்ளீடுகள் +Name[tr]=Haberler +Name[uk]=Подачі +Name[uz]=Yangiliklar tasmalari +Name[uz@cyrillic]=Янгиликлар тасмалари +Name[zh_CN]=种子 + diff --git a/kontact/plugins/kaddressbook/Makefile.am b/kontact/plugins/kaddressbook/Makefile.am new file mode 100644 index 000000000..a769f29d8 --- /dev/null +++ b/kontact/plugins/kaddressbook/Makefile.am @@ -0,0 +1,18 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces -I$(top_srcdir) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_kaddressbookplugin.la +libkontact_kaddressbookplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -lkabc +libkontact_kaddressbookplugin_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(top_builddir)/libkdepim/libkdepim.la + +libkontact_kaddressbookplugin_la_SOURCES = kaddressbook_plugin.cpp \ + kaddressbookiface.stub \ + kmailIface.stub + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir)/kontact +service_DATA = kaddressbookplugin.desktop + +kaddressbookiface_DIR = $(top_srcdir)/kaddressbook +kmailIface_DIR = $(top_srcdir)/kmail +kmailIface_DCOPIDLNG = true diff --git a/kontact/plugins/kaddressbook/kaddressbook_plugin.cpp b/kontact/plugins/kaddressbook/kaddressbook_plugin.cpp new file mode 100644 index 000000000..e2f5a706f --- /dev/null +++ b/kontact/plugins/kaddressbook/kaddressbook_plugin.cpp @@ -0,0 +1,218 @@ +/* + This file is part of Kontact. + + Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@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 <qwidget.h> +#include <qdragobject.h> + +#include <kaction.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <kiconloader.h> +#include <kmessagebox.h> +#include <kparts/componentfactory.h> + +#include <kaddrbook.h> +#include <kabc/addressbook.h> +#include <kabc/stdaddressbook.h> + +#include <dcopclient.h> +#include "kmailIface_stub.h" + +#include <libkdepim/maillistdrag.h> + +#include "core.h" +#include "plugin.h" + +#include "kaddressbook_plugin.h" + +typedef KGenericFactory< KAddressbookPlugin, Kontact::Core > KAddressbookPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_kaddressbookplugin, + KAddressbookPluginFactory( "kontact_kaddressbookplugin" ) ) + +KAddressbookPlugin::KAddressbookPlugin( Kontact::Core *core, const char *, const QStringList& ) + : Kontact::Plugin( core, core, "kaddressbook" ), + mStub( 0 ) +{ + setInstance( KAddressbookPluginFactory::instance() ); + + insertNewAction( new KAction( i18n( "New Contact..." ), "identity", + CTRL+SHIFT+Key_C, this, SLOT( slotNewContact() ), actionCollection(), + "new_contact" ) ); + + insertNewAction( new KAction( i18n( "&New Distribution List..." ), "kontact_contacts", 0, this, + SLOT( slotNewDistributionList() ), actionCollection(), "new_distributionlist" ) ); + + insertSyncAction( new KAction( i18n( "Synchronize Contacts" ), "reload", + 0, this, SLOT( slotSyncContacts() ), actionCollection(), + "kaddressbook_sync" ) ); + mUniqueAppWatcher = new Kontact::UniqueAppWatcher( + new Kontact::UniqueAppHandlerFactory<KABUniqueAppHandler>(), this ); +} + +KAddressbookPlugin::~KAddressbookPlugin() +{ +} + +KParts::ReadOnlyPart* KAddressbookPlugin::createPart() +{ + KParts::ReadOnlyPart * part = loadPart(); + if ( !part ) return 0; + + // Create the stub that allows us to talk to the part + mStub = new KAddressBookIface_stub( dcopClient(), "kaddressbook", + "KAddressBookIface" ); + return part; +} + +QStringList KAddressbookPlugin::configModules() const +{ + QStringList modules; + modules << "PIM/kabconfig.desktop" << "PIM/kabldapconfig.desktop"; + return modules; +} + +QStringList KAddressbookPlugin::invisibleToolbarActions() const +{ + return QStringList( "file_new_contact" ); +} + +KAddressBookIface_stub *KAddressbookPlugin::interface() +{ + if ( !mStub ) { + part(); + } + Q_ASSERT( mStub ); + return mStub; +} + +void KAddressbookPlugin::slotNewContact() +{ + interface()->newContact(); +} + + +void KAddressbookPlugin::slotNewDistributionList() +{ + interface()->newDistributionList(); +} + +void KAddressbookPlugin::slotSyncContacts() +{ + DCOPRef ref( "kmail", "KMailICalIface" ); + ref.send( "triggerSync", QString("Contact") ); +} + +bool KAddressbookPlugin::createDCOPInterface( const QString& serviceType ) +{ + if ( serviceType == "DCOP/AddressBook" ) { + Q_ASSERT( mStub ); + return true; + } + + return false; +} + +void KAddressbookPlugin::configUpdated() +{ +} + +bool KAddressbookPlugin::isRunningStandalone() +{ + return mUniqueAppWatcher->isRunningStandalone(); +} + +bool KAddressbookPlugin::canDecodeDrag( QMimeSource *mimeSource ) +{ + return QTextDrag::canDecode( mimeSource ) || + KPIM::MailListDrag::canDecode( mimeSource ); +} + +#include <dcopref.h> + +void KAddressbookPlugin::processDropEvent( QDropEvent *event ) +{ + KPIM::MailList mails; + if ( KPIM::MailListDrag::decode( event, mails ) ) { + if ( mails.count() != 1 ) { + KMessageBox::sorry( core(), + i18n( "Drops of multiple mails are not supported." ) ); + } else { + KPIM::MailSummary mail = mails.first(); + + KMailIface_stub kmailIface( "kmail", "KMailIface" ); + QString sFrom = kmailIface.getFrom( mail.serialNumber() ); + + if ( !sFrom.isEmpty() ) { + KAddrBookExternal::addEmail( sFrom, core() ); + } + } + return; + } + + KMessageBox::sorry( core(), i18n( "Cannot handle drop events of type '%1'." ) + .arg( event->format() ) ); +} + + +void KAddressbookPlugin::loadProfile( const QString& directory ) +{ + DCOPRef ref( "kaddressbook", "KAddressBookIface" ); + ref.send( "loadProfile", directory ); +} + +void KAddressbookPlugin::saveToProfile( const QString& directory ) const +{ + DCOPRef ref( "kaddressbook", "KAddressBookIface" ); + ref.send( "saveToProfile", directory ); +} + +//// + +#include "../../../kaddressbook/kaddressbook_options.h" + +void KABUniqueAppHandler::loadCommandLineOptions() +{ + KCmdLineArgs::addCmdLineOptions( kaddressbook_options ); +} + +int KABUniqueAppHandler::newInstance() +{ + kdDebug(5602) << k_funcinfo << endl; + // Ensure part is loaded + (void)plugin()->part(); + DCOPRef kAB( "kaddressbook", "KAddressBookIface" ); + DCOPReply reply = kAB.call( "handleCommandLine" ); + if ( reply.isValid() ) { + bool handled = reply; + kdDebug(5602) << k_funcinfo << "handled=" << handled << endl; + if ( !handled ) // no args -> simply bring kaddressbook plugin to front + return Kontact::UniqueAppHandler::newInstance(); + } + return 0; +} + +#include "kaddressbook_plugin.moc" + +// vim: sw=2 sts=2 tw=80 et diff --git a/kontact/plugins/kaddressbook/kaddressbook_plugin.h b/kontact/plugins/kaddressbook/kaddressbook_plugin.h new file mode 100644 index 000000000..f66d44aaf --- /dev/null +++ b/kontact/plugins/kaddressbook/kaddressbook_plugin.h @@ -0,0 +1,86 @@ +/* + This file is part of Kontact. + + Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@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 KADDRESSBOOK_PLUGIN_H +#define KADDRESSBOOK_PLUGIN_H + +#include <klocale.h> +#include <kparts/part.h> + +#include "kaddressbookiface_stub.h" +#include "plugin.h" +#include <uniqueapphandler.h> + +class KAboutData; + +class KABUniqueAppHandler : public Kontact::UniqueAppHandler +{ +public: + KABUniqueAppHandler( Kontact::Plugin* plugin ) : Kontact::UniqueAppHandler( plugin ) {} + virtual void loadCommandLineOptions(); + virtual int newInstance(); +}; + +class KAddressbookPlugin : public Kontact::Plugin +{ + Q_OBJECT + + public: + KAddressbookPlugin( Kontact::Core *core, const char *name, const QStringList& ); + ~KAddressbookPlugin(); + + virtual bool createDCOPInterface( const QString &serviceType ); + virtual bool isRunningStandalone(); + int weight() const { return 300; } + + bool canDecodeDrag( QMimeSource * ); + void processDropEvent( QDropEvent * ); + + virtual QStringList configModules() const; + + virtual QStringList invisibleToolbarActions() const; + + virtual void configUpdated(); + + KAddressBookIface_stub *interface(); + + //override + void loadProfile( const QString& directory ); + + //override + void saveToProfile( const QString& directory ) const; + + protected: + KParts::ReadOnlyPart *createPart(); + private slots: + void slotNewContact(); + void slotNewDistributionList(); + void slotSyncContacts(); + + private: + KAddressBookIface_stub *mStub; + Kontact::UniqueAppWatcher *mUniqueAppWatcher; +}; + +#endif diff --git a/kontact/plugins/kaddressbook/kaddressbookplugin.desktop b/kontact/plugins/kaddressbook/kaddressbookplugin.desktop new file mode 100644 index 000000000..f5208ea52 --- /dev/null +++ b/kontact/plugins/kaddressbook/kaddressbookplugin.desktop @@ -0,0 +1,100 @@ +[Desktop Entry] +Type=Service +Icon=kontact_contacts +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_kaddressbookplugin +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPartLibraryName=libkaddressbookpart +X-KDE-KontactPartExecutableName=kaddressbook +X-KDE-KontactPluginHasSummary=false + +X-KDE-PluginInfo-Website=http://www.kaddressbook.org/ +X-KDE-PluginInfo-Name=kontact_kaddressbookplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=Contacts Component (KAdressbook Plugin) +Comment[bg]=Приставка за адресника +Comment[ca]=Component de contactes (endollable del KAdressbook) +Comment[da]=Kontaktkomponent (KAddressbook-plugin) +Comment[de]=Kontakte-Komponente (Adressbuch-Modul) +Comment[el]=Συστατικό επαφών (Πρόσθετο του KAdressbook) +Comment[es]=Componente de contactos (complemento de KAddressbook) +Comment[et]=Kontaktide plugin (KDE aadressiraamat) +Comment[fr]=Composant des contacts (module externe KAdressBook) +Comment[is]=Vistfangaskráreining (KAddressBook íforrit) +Comment[it]=Componente contatti (plugin KAddressbook) +Comment[ja]=アドレス帳コンポーネント (KAddressbook プラグイン) +Comment[km]=សមាសភាគទំនាក់ទំនង (កម្មវិធីជំនួយ KAdressbook) +Comment[nds]=Kontakten-Komponent (KAddressbook-Moduul) +Comment[nl]=Adresboekcomponent (KAddressbook-plugin) +Comment[pl]=Składnik wizytówek (wtyczka KAddressBook) +Comment[ru]=Контакты (модуль KAddressBook) +Comment[sr]=Компонента контаката (прикључак KAddressBook-а) +Comment[sr@Latn]=Komponenta kontakata (priključak KAddressBook-a) +Comment[sv]=Kontaktkomponent (adressboksinsticksprogram) +Comment[tr]=Kişiler Bileşeni (KAdresDefteri Eklentisi) +Comment[zh_CN]=联系人组件(KAddressbook 插件) +Comment[zh_TW]=聯絡人組件(KAddressBook 外掛程式) +Name=Contacts +Name[af]=Kontakte +Name[ar]=المراسلون +Name[be]=Кантакты +Name[bg]=Контакти +Name[br]=Darempredoù +Name[bs]=Kontakti +Name[ca]=Contactes +Name[cs]=Kontakty +Name[cy]=Cysylltau +Name[da]=Kontakter +Name[de]=Kontakte +Name[el]=Επαφές +Name[eo]=Kontaktoj +Name[es]=Contactos +Name[et]=Kontaktid +Name[eu]=Kontaktuak +Name[fa]=تماسها +Name[fi]=Yhteystiedot +Name[fy]=Adressen +Name[ga]=Teagmhálacha +Name[gl]=Contactos +Name[he]=אנשי קשר +Name[hi]=सम्पर्कों +Name[hu]=Névjegyek +Name[is]=Tengiliðir +Name[it]=Contatti +Name[ja]=コンタクト +Name[ka]=კონტაქტები +Name[kk]=Контакттар +Name[km]=ទំនាក់ទំនង +Name[lt]=Kontaktai +Name[mk]=Контакти +Name[ms]=Orang hubungan +Name[nds]=Kontakten +Name[ne]=सम्पर्क +Name[nl]=Adressen +Name[nn]=Kontaktar +Name[pa]=ਸੰਪਰਕ +Name[pl]=Wizytówki +Name[pt]=Contactos +Name[pt_BR]=Contatos +Name[ro]=Contacte +Name[ru]=Контакты +Name[rw]=Amaderesi +Name[se]=Oktavuođat +Name[sk]=Kontakty +Name[sl]=Stiki +Name[sr]=Контакти +Name[sr@Latn]=Kontakti +Name[sv]=Kontakter +Name[ta]=தொடர்புகள் +Name[tg]=Алоқот +Name[th]=ที่อยู่ติดต่อ +Name[tr]=Kişiler +Name[uk]=Контакти +Name[uz]=Aloqalar +Name[uz@cyrillic]=Алоқалар +Name[zh_CN]=联系人 +Name[zh_TW]=聯絡人 diff --git a/kontact/plugins/karm/Makefile.am b/kontact/plugins/karm/Makefile.am new file mode 100644 index 000000000..e3fb02276 --- /dev/null +++ b/kontact/plugins/karm/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces -I$(top_srcdir)/karm -I$(top_srcdir) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_karm.la +libkontact_karm_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_karm_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la + +libkontact_karm_la_SOURCES = karm_plugin.cpp karmdcopiface.stub + +METASOURCES = AUTO + +karmdcopiface_DIR = $(top_srcdir)/karm + +servicedir = $(kde_servicesdir)/kontact +service_DATA = karmplugin.desktop + +DISTCLEANFILES = karmdcopiface.h karmdcopiface.stub diff --git a/kontact/plugins/karm/karm_plugin.cpp b/kontact/plugins/karm/karm_plugin.cpp new file mode 100644 index 000000000..a3a9d277d --- /dev/null +++ b/kontact/plugins/karm/karm_plugin.cpp @@ -0,0 +1,71 @@ +/* + This file is part of Kontact. + + Copyright (c) 2004 Tobias Koenig <tokoe@kde.org> + adapted for karm 2005 by Thorsten Staerk <kde@staerk.de> + + 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 <kgenericfactory.h> +#include <kparts/componentfactory.h> + +#include "core.h" +#include "plugin.h" + +#include "karm_plugin.h" +#include "karmdcopiface_stub.h" + +typedef KGenericFactory<KarmPlugin, Kontact::Core> KarmPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_karm, + KarmPluginFactory( "kontact_karm" ) ) + +KarmPlugin::KarmPlugin( Kontact::Core *core, const char *, const QStringList& ) + : Kontact::Plugin( core, core, "KArm" ) +{ + setInstance( KarmPluginFactory::instance() ); + (void)dcopClient(); + insertNewAction( new KAction( i18n( "New Task" ), "karm", + CTRL+SHIFT+Key_W, this, SLOT( newTask() ), actionCollection(), + "new_task" ) ); +} + +KarmPlugin::~KarmPlugin() +{ +} + +KParts::ReadOnlyPart* KarmPlugin::createPart() +{ + KParts::ReadOnlyPart * part = loadPart(); + if ( !part ) return 0; + + // this calls a DCOP interface from karm via the lib KarmDCOPIface_stub that is generated automatically + mStub = new KarmDCOPIface_stub( dcopClient(), "KArm", + "KarmDCOPIface" ); + + return part; +} + +void KarmPlugin::newTask() +{ + kdDebug() << "Entering newTask" << endl; + mStub->addTask("New Task"); +} + +#include "karm_plugin.moc" diff --git a/kontact/plugins/karm/karm_plugin.h b/kontact/plugins/karm/karm_plugin.h new file mode 100644 index 000000000..c5ef3e289 --- /dev/null +++ b/kontact/plugins/karm/karm_plugin.h @@ -0,0 +1,57 @@ +/* + This file is part of Kontact. + + Copyright (c) 2004 Tobias Koenig <tokoe@kde.org> + adapted for karm 2005 by Thorsten Staerk <kde@staerk.de> + + 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 KARM_PLUGIN_H +#define KARM_PLUGIN_H + +#include <klocale.h> +#include <kparts/part.h> +#include "karmdcopiface_stub.h" + +#include "plugin.h" + +class KAboutData; + +class KarmPlugin : public Kontact::Plugin +{ + Q_OBJECT + + public: + KarmPlugin( Kontact::Core *core, const char *name, + const QStringList & ); + ~KarmPlugin(); + + int weight() const { return 700; } + + protected: + KParts::ReadOnlyPart *createPart(); + KarmDCOPIface_stub *mStub; + + public slots: + void newTask(); + +}; + +#endif diff --git a/kontact/plugins/karm/karmplugin.desktop b/kontact/plugins/karm/karmplugin.desktop new file mode 100644 index 000000000..469989fe6 --- /dev/null +++ b/kontact/plugins/karm/karmplugin.desktop @@ -0,0 +1,59 @@ +[Desktop Entry] +Type=Service +Icon=karm +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_karm +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPartLibraryName=libkarmpart + +X-KDE-PluginInfo-Name=kontact_karm +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=false + +Comment=Time Tracker Component (KArm Plugin) +Comment[bg]=Приставка за KArm +Comment[ca]=Component de seguiment dels temps (endollable del KArm) +Comment[da]=Time Tracker-komponent (KArm-plugin) +Comment[de]=Zeitplaner-Komponente (KArm-Modul) +Comment[el]=Συστατικό γραμμής χρόνου (Πρόσθετο του KArm) +Comment[es]=Componente de seguimiento de tiempos (complemento de KArm) +Comment[et]=Ajaarvestaja plugin (KArm) +Comment[fr]=Composant de suivi temporel (Module pour KArm) +Comment[is]=Tímastjórnunareining (KArm íforrit) +Comment[it]=Componente segna-tempo (plugin Karm) +Comment[ja]=タイムトラッカーコンポーネント (KArm プラグイン) +Comment[km]=សមាសភាគកម្មវិធីតាមដានពេលវេលា (កម្មវិធីជំនួយ KArm) +Comment[nds]=Tietlogbook-Komponent (KArm-Moduul) +Comment[nl]=Tijdsregistratiecomponent (KArm-plugin) +Comment[pl]=Składnik śledzenia czasu (wtyczka KArm) +Comment[ru]=Отслеживание времени (модуль KArm) +Comment[sr]=Компонента праћења времена (прикључак KArm-а) +Comment[sr@Latn]=Komponenta praćenja vremena (priključak KArm-a) +Comment[sv]=Komponent för tidmätning (Karm-insticksprogram) +Comment[tr]=Zaman İzleyici Bileşeni (KArm Eklentisi) +Comment[zh_CN]=时间追踪组件(KArm 插件) +Comment[zh_TW]=時間追蹤器組件(KArm 外掛程式) + +Name=Timer +Name[bg]=Таймер +Name[ca]=Cronòmetre +Name[de]=Stoppuhr +Name[el]=Χρονόμετρο +Name[es]=Temporizador +Name[et]=Ajaarvestaja +Name[fr]=Minuteur +Name[is]=Tímamælir +Name[ja]=タイマー +Name[km]=កម្មវិធីកំណត់ពេលវេលា +Name[nds]=Tietgever +Name[nl]=Tijdklok +Name[pl]=Stoper +Name[ru]=Таймер +Name[sk]=Časovač +Name[sr]=Тајмер +Name[sr@Latn]=Tajmer +Name[sv]=Tidmätning +Name[zh_CN]=计时器 +Name[zh_TW]=計時器 diff --git a/kontact/plugins/kitchensync/Makefile.am b/kontact/plugins/kitchensync/Makefile.am new file mode 100644 index 000000000..c6df9113f --- /dev/null +++ b/kontact/plugins/kitchensync/Makefile.am @@ -0,0 +1,14 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces $(all_includes) + +kde_module_LTLIBRARIES = libkontact_kitchensync.la +libkontact_kitchensync_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_kitchensync_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la + +libkontact_kitchensync_la_SOURCES = kitchensync_plugin.cpp + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir)/kontact +service_DATA = kitchensync.desktop + +kitchensynciface_DIR = $(top_srcdir)/kitchensync diff --git a/kontact/plugins/kitchensync/kitchensync.desktop b/kontact/plugins/kitchensync/kitchensync.desktop new file mode 100644 index 000000000..0b1ac5078 --- /dev/null +++ b/kontact/plugins/kitchensync/kitchensync.desktop @@ -0,0 +1,52 @@ +[Desktop Entry] +Type=Service +Icon=kitchensync +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_kitchensync +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPartLibraryName=libkitchensyncpart + +X-KDE-PluginInfo-Name=kontact_kitchensync +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=false + +Comment=Synchronization Component (Kitchensynk Plugin) +Comment[bg]=Приставка за синхронизация +Comment[ca]=Component de sincronització (endollable del KitchenSync) +Comment[da]=Synkronisergingskomponent (Kitchensync-plugin) +Comment[de]=Abgleich-Komponente (KitchenSync-Modul) +Comment[el]=Συστατικό συγχρονισμού (Πρόσθετο του Kitchensynk) +Comment[en_GB]=Synchronisation Component (Kitchensynk Plugin) +Comment[es]=Componente de sincronización (complemento de KitchenSync) +Comment[et]=Sünkroniseerimise plugin (KitchenSync) +Comment[fr]=Composant de synchronisation (Module KitchenSync) +Comment[is]=Samstillingareining (KitchenSync íforrit) +Comment[it]=Componente di sincronizzazione (plugin KitchenSync) +Comment[ja]=同期コンポーネント (KitchenSync プラグイン) +Comment[km]=ការធ្វើសមកាលកម្មសមាសភាគ (កម្មវិធីជំនួយ Kitchensynk) +Comment[nds]=Synkroniseer-Komponent (Kitchensynk-Moduul) +Comment[nl]=Synchronisatiecomponent (Kitchensynk-plugin) +Comment[pl]=Składnik synchronizacji (wtyczka KitchenSync) +Comment[ru]=Синхронизация (модуль KitchenSync) +Comment[sk]=Synchronizačný komponent (Modul pre Kitchensynk) +Comment[sr]=Компонента синхронизације (прикључак KitchenSync-а) +Comment[sr@Latn]=Komponenta sinhronizacije (priključak KitchenSync-a) +Comment[sv]=Synkroniseringskomponent (Kitchensynk-insticksprogram) +Comment[tr]=Eşzamanlama Eklentisi (Kitchensynk Eklentisi) +Comment[zh_CN]=同步组件(KitchenSync 插件) +Comment[zh_TW]=同步組件(KitchenSynk 外掛程式) +Name=Sync +Name[bg]=Синхронизация +Name[de]=Abgleich +Name[el]=Συγχρονισμός +Name[et]=Sünkroniseerimine +Name[fr]=Synchroniser +Name[is]=Samstilling +Name[ja]=同期 +Name[nds]=Synkroniseren +Name[pl]=Synchronizacja +Name[ru]=Синхронизация +Name[sv]=Synkronisering +Name[zh_TW]=同步 diff --git a/kontact/plugins/kitchensync/kitchensync_plugin.cpp b/kontact/plugins/kitchensync/kitchensync_plugin.cpp new file mode 100644 index 000000000..4de6cf8da --- /dev/null +++ b/kontact/plugins/kitchensync/kitchensync_plugin.cpp @@ -0,0 +1,67 @@ +/* + This file is part of Kontact. + + Copyright (c) 2003 Cornelius Schumacher <schumacher@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 <qwidget.h> + +#include <kaboutdata.h> +#include <kaction.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <kiconloader.h> +#include <kmessagebox.h> +#include <kparts/componentfactory.h> + +#include "core.h" +#include "plugin.h" + +#include "kitchensync_plugin.h" + +typedef KGenericFactory< KitchenSyncPlugin, Kontact::Core > KitchenSyncPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_kitchensync, + KitchenSyncPluginFactory( "kontact_kitchensync" ) ) + +KitchenSyncPlugin::KitchenSyncPlugin( Kontact::Core *core, const char *, const QStringList& ) + : Kontact::Plugin( core, core, "KitchenSync" ) +{ + setInstance( KitchenSyncPluginFactory::instance() ); +} + +KitchenSyncPlugin::~KitchenSyncPlugin() +{ +} + +KParts::ReadOnlyPart* KitchenSyncPlugin::createPart() +{ + return loadPart(); +} + +QStringList KitchenSyncPlugin::configModules() const +{ + QStringList modules; + modules << "PIM/kitchensync.desktop"; + return modules; +} + +#include "kitchensync_plugin.moc" diff --git a/kontact/plugins/kitchensync/kitchensync_plugin.h b/kontact/plugins/kitchensync/kitchensync_plugin.h new file mode 100644 index 000000000..fafa12d71 --- /dev/null +++ b/kontact/plugins/kitchensync/kitchensync_plugin.h @@ -0,0 +1,51 @@ +/* + This file is part of Kontact. + + Copyright (c) 2003 Cornelius Schumacher <schumacher@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 KITCHENSYNC_PLUGIN_H +#define KITCHENSYNC_PLUGIN_H + +#include <klocale.h> +#include <kparts/part.h> + +#include "plugin.h" + +class KAboutData; + +class KitchenSyncPlugin : public Kontact::Plugin +{ + Q_OBJECT + + public: + KitchenSyncPlugin( Kontact::Core *core, const char *name, + const QStringList & ); + ~KitchenSyncPlugin(); + + int weight() const { return 800; } + + virtual QStringList configModules() const; + protected: + KParts::ReadOnlyPart *createPart(); +}; + +#endif diff --git a/kontact/plugins/kmail/Makefile.am b/kontact/plugins/kmail/Makefile.am new file mode 100644 index 000000000..d176693a3 --- /dev/null +++ b/kontact/plugins/kmail/Makefile.am @@ -0,0 +1,29 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces -I$(top_srcdir)/kmail -I$(top_builddir)/kmail \ + -I$(top_srcdir)/libkdepim \ + -I$(top_srcdir) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_kmailplugin.la kcm_kmailsummary.la + +libkontact_kmailplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_kmailplugin_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(top_builddir)/libkcal/libkcal.la $(LIB_KPARTS) + +libkontact_kmailplugin_la_SOURCES = kmail_plugin.cpp kmailIface.stub \ + summarywidget.cpp summarywidget.skel + +kcm_kmailsummary_la_SOURCES = kcmkmailsummary.cpp +kcm_kmailsummary_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) \ + -avoid-version -no-undefined +kcm_kmailsummary_la_LIBADD = $(LIB_KDEUI) + +kmailIface_DCOPIDLNG = true + +summarywidget_DCOPIDLNG = true + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir)/kontact +service_DATA = kmailplugin.desktop + +kde_services_DATA = kcmkmailsummary.desktop + +kmailIface_DIR = $(top_srcdir)/kmail diff --git a/kontact/plugins/kmail/kcmkmailsummary.cpp b/kontact/plugins/kmail/kcmkmailsummary.cpp new file mode 100644 index 000000000..02627c0fe --- /dev/null +++ b/kontact/plugins/kmail/kcmkmailsummary.cpp @@ -0,0 +1,192 @@ +/* + This file is part of 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 <qcheckbox.h> +#include <qlayout.h> + +#include <dcopref.h> + +#include <kaboutdata.h> +#include <kaccelmanager.h> +#include <kapplication.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kdialog.h> +#include <klistview.h> +#include <klocale.h> + +#include "kcmkmailsummary.h" + +#include <kdepimmacros.h> + +extern "C" +{ + KDE_EXPORT KCModule *create_kmailsummary( QWidget *parent, const char * ) + { + return new KCMKMailSummary( parent, "kcmkmailsummary" ); + } +} + +KCMKMailSummary::KCMKMailSummary( QWidget *parent, const char *name ) + : KCModule( parent, name ) +{ + initGUI(); + + connect( mFolderView, SIGNAL( clicked( QListViewItem* ) ), SLOT( modified() ) ); + connect( mFullPath, SIGNAL( toggled( bool ) ), SLOT( modified() ) ); + + KAcceleratorManager::manage( this ); + + load(); + + KAboutData *about = new KAboutData( I18N_NOOP( "kcmkmailsummary" ), + I18N_NOOP( "Mail Summary Configuration Dialog" ), + 0, 0, KAboutData::License_GPL, + I18N_NOOP( "(c) 2004 Tobias Koenig" ) ); + + about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); + setAboutData( about ); +} + +void KCMKMailSummary::modified() +{ + emit changed( true ); +} + +void KCMKMailSummary::initGUI() +{ + QVBoxLayout *layout = new QVBoxLayout( this, 0, KDialog::spacingHint() ); + + mFolderView = new KListView( this ); + mFolderView->setRootIsDecorated( true ); + mFolderView->setFullWidth( true ); + + mFolderView->addColumn( i18n( "Summary" ) ); + + mFullPath = new QCheckBox( i18n( "Show full path for folders" ), this ); + + layout->addWidget( mFolderView ); + layout->addWidget( mFullPath ); +} + +void KCMKMailSummary::initFolders() +{ + DCOPRef kmail( "kmail", "KMailIface" ); + + QStringList folderList; + kmail.call( "folderList" ).get( folderList ); + + mFolderView->clear(); + mFolderMap.clear(); + + QStringList::Iterator it; + for ( it = folderList.begin(); it != folderList.end(); ++it ) { + QString displayName; + if ( (*it) == "/Local" ) + displayName = i18n( "prefix for local folders", "Local" ); + else { + DCOPRef folderRef = kmail.call( "getFolder(QString)", *it ); + folderRef.call( "displayName()" ).get( displayName ); + } + if ( (*it).contains( '/' ) == 1 ) { + if ( mFolderMap.find( *it ) == mFolderMap.end() ) + mFolderMap.insert( *it, new QListViewItem( mFolderView, + displayName ) ); + } else { + const int pos = (*it).findRev( '/' ); + const QString parentFolder = (*it).left( pos ); + mFolderMap.insert( *it, + new QCheckListItem( mFolderMap[ parentFolder ], + displayName, + QCheckListItem::CheckBox ) ); + } + } +} + +void KCMKMailSummary::loadFolders() +{ + KConfig config( "kcmkmailsummaryrc" ); + config.setGroup( "General" ); + + QStringList folders; + if ( !config.hasKey( "ActiveFolders" ) ) + folders << "/Local/inbox"; + else + folders = config.readListEntry( "ActiveFolders" ); + + QMap<QString, QListViewItem*>::Iterator it; + for ( it = mFolderMap.begin(); it != mFolderMap.end(); ++it ) { + if ( QCheckListItem *qli = dynamic_cast<QCheckListItem*>( it.data() ) ) { + if ( folders.contains( it.key() ) ) { + qli->setOn( true ); + mFolderView->ensureItemVisible( it.data() ); + } else { + qli->setOn( false ); + } + } + } + mFullPath->setChecked( config.readBoolEntry( "ShowFullPath", true ) ); +} + +void KCMKMailSummary::storeFolders() +{ + KConfig config( "kcmkmailsummaryrc" ); + config.setGroup( "General" ); + + QStringList folders; + + QMap<QString, QListViewItem*>::Iterator it; + for ( it = mFolderMap.begin(); it != mFolderMap.end(); ++it ) + if ( QCheckListItem *qli = dynamic_cast<QCheckListItem*>( it.data() ) ) + if ( qli->isOn() ) + folders.append( it.key() ); + + config.writeEntry( "ActiveFolders", folders ); + config.writeEntry( "ShowFullPath", mFullPath->isChecked() ); + + config.sync(); +} + +void KCMKMailSummary::load() +{ + initFolders(); + loadFolders(); + + emit changed( false ); +} + +void KCMKMailSummary::save() +{ + storeFolders(); + + emit changed( false ); +} + +void KCMKMailSummary::defaults() +{ + mFullPath->setChecked( true ); + + emit changed( true ); +} + +#include "kcmkmailsummary.moc" diff --git a/kontact/plugins/kmail/kcmkmailsummary.desktop b/kontact/plugins/kmail/kcmkmailsummary.desktop new file mode 100644 index 000000000..2b8c7d99e --- /dev/null +++ b/kontact/plugins/kmail/kcmkmailsummary.desktop @@ -0,0 +1,107 @@ +[Desktop Entry] +Icon=kontact_mail +Type=Service +ServiceTypes=KCModule + +X-KDE-ModuleType=Library +X-KDE-Library=kmailsummary +X-KDE-FactoryName=kmailsummary +X-KDE-ParentApp=kontact_kmailplugin +X-KDE-ParentComponents=kontact_kmailplugin +X-KDE-CfgDlgHierarchy=KontactSummary + +Name=E-Mail Overview +Name[bg]=Преглед на пощата +Name[ca]=Resum de correu +Name[da]=Oversigt over e-mail +Name[de]=E-Mail-Übersicht +Name[el]=Επισκόπηση αλληλογραφίας +Name[es]=Resumen de correo electrónico +Name[et]=E-posti ülevaade +Name[fr]=Aperçu du courriel +Name[is]=Yfirsýn á tölvupóst +Name[it]=Panoramica posta elettronica +Name[ja]=メールの要約 +Name[km]=ទិដ្ឋភាពទូទៅរបស់អ៊ីមែល +Name[nds]=Nettpost-Översicht +Name[nl]=E-mailoverzicht +Name[pl]=Poczta +Name[ru]=Сведения о почте +Name[sk]=Prehľad pošty +Name[sr]=Преглед е-поште +Name[sr@Latn]=Pregled e-pošte +Name[sv]=E-postöversikt +Name[tr]=E-Postalara Genel Bakış +Name[zh_CN]=邮件概览 +Name[zh_TW]=郵件概要 +Comment=E-Mail Summary Setup +Comment[bg]=Настройки на обобщението на писмата +Comment[ca]=Configuració del resum de correu +Comment[da]=Opsætning af post-opsummering +Comment[de]=Einstellungen für E-Mail-Übersicht +Comment[el]=Ρύθμιση σύνοψης αλληλογραφίας +Comment[es]=Configuración del resumen de correo electrónico +Comment[et]=E-posti kokkuvõtte seadistus +Comment[fr]=Configuration du résumé des courriels +Comment[is]=Uppsetning póstyfirlits +Comment[it]=Impostazioni sommario posta elettronica +Comment[ja]=メール要約の設定 +Comment[km]=រៀបចំសេចក្ដីសង្ខេបអ៊ីមែល +Comment[nds]=Instellen för Nettpost-Översicht +Comment[nl]=Instellingen voor e-mailoverzicht +Comment[pl]=Ustawienia podsumowania e-maili +Comment[ru]=Настройка сводки почты +Comment[sk]=Nastavenie súhrnu pošty +Comment[sr]=Подешавање сажетка е-поште +Comment[sr@Latn]=Podešavanje sažetka e-pošte +Comment[sv]=Inställning av e-postöversikt +Comment[tr]=E-Posta Özet Yapılandırması +Comment[zh_CN]=邮件摘要设置 +Comment[zh_TW]=郵件摘要設定 +Keywords=email, summary, configure, settings +Keywords[af]=email,summary,configure,settings +Keywords[bg]=резюме, общо, обобщение, пощенски, клиент, е-поща, email, summary, configure, settings +Keywords[bs]=email, summary, configure, settings, sažetak, postavke +Keywords[ca]=correu-e, resum, configuració, arranjament +Keywords[cs]=email,souhrn,nastavení,nastavit +Keywords[da]=e-mail, opsummering, indstil, opsætning +Keywords[de]=E-Mail,email,Übersicht,einstellen,Einstellungen,Einrichten +Keywords[el]=αλληλογραφία, σύνοψη, ρύθμιση, ρυθμίσεις +Keywords[es]=correo, resumen, configurar, opciones +Keywords[et]=e-post, meil, seadistamine, seadistused +Keywords[eu]=eposta, laburpena, konfiguratu, ezarpenak +Keywords[fa]=email، خلاصه، پیکربندی، تنظیمات +Keywords[fi]=sähköposti, yhteenveto, asetukset +Keywords[fr]=message,messagerie,courriel,résumé,vue,configurer,paramètres,paramètre +Keywords[fy]=email,e-mail,e-post,oersicht,gearfetting,ynstellings, konfiguraasje +Keywords[ga]=ríomhphost, achoimre, cumraigh, socruithe +Keywords[gl]=email, resumo, configurar, opcións +Keywords[he]=email, summary, configure, settings, דוא"ל, תקציר, תצורה, הגדרת, דואל, דואר, דואר אלקטרוני +Keywords[hu]=e-mail,áttekintés,konfigurálás,beállítások +Keywords[is]=tölvupóstur, yfirlit, stillingar, stilla +Keywords[it]=posta elettronica, email, sommario, configura, impostazioni +Keywords[ja]=メール,要約,設定,設定 +Keywords[ka]=ელფოსტა,დაიჯესტი,კონფიგურაცია,პარამეტრები +Keywords[km]=អ៊ីមែល,សង្ខេប,កំណត់រចនាសម្ព័ន្ធ,ការកំណត់ +Keywords[lt]=email, summary, configure, settings, e. paštas, santrauka, konfigūruoti, nustatymai +Keywords[mk]=email, summary, configure, settings, е-пошта, преглед, конфигурација, поставувања +Keywords[ms]=e-mel, ringkasan, konfigur, seting +Keywords[nb]=e-post, sammendrag, oppsett, innstillinger +Keywords[nds]=Nettpost,Nettbreef,Översicht,instellen +Keywords[ne]=इमेल, सारांश, कन्फिगर, सेटिङ +Keywords[nl]=email,e-mail,overzicht,samenvatting,instellingen,configuratie +Keywords[nn]=e-post,samandrag,oppsett,innstillingar +Keywords[pl]=e-mail,list,podsumowanie,konfiguracja,ustawienia +Keywords[pt]=e-mail, sumário, configurar, configuração +Keywords[pt_BR]=e-mail, resumo, configurar, configurações +Keywords[ru]=email,summary,configure,settings,настройки,сводка,почта +Keywords[sk]=email,súhrn,nastavenie +Keywords[sl]=e-pošta,pošta,povzetek,nastavi,nastavitve +Keywords[sr]=емаил, сажетак, подеси, поставке +Keywords[sr@Latn]=email, sažetak, podesi, postavke +Keywords[sv]=e-post, översikt, anpassa, inställningar +Keywords[ta]=மின்னஞ்சல்,சுருக்கம்,கட்டமைப்பு,அமைவுகள் +Keywords[tg]=email, summary, configure, settings,танзимот, дайджест,почта +Keywords[tr]=e-posta, özet, yapılandır, yapılandırma +Keywords[uk]=пошта, підсумок, налаштування, параметри +Keywords[zh_CN]=email, summary, configure, settings, 电子邮件, 摘要, 配置, 设置 diff --git a/kontact/plugins/kmail/kcmkmailsummary.h b/kontact/plugins/kmail/kcmkmailsummary.h new file mode 100644 index 000000000..e2959dead --- /dev/null +++ b/kontact/plugins/kmail/kcmkmailsummary.h @@ -0,0 +1,61 @@ +/* + This file is part of 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 KCMKMAILSUMMARY_H +#define KCMKMAILSUMMARY_H + +#include <qvaluelist.h> + +#include <kcmodule.h> + +class KListView; + +class QCheckBox; +class QCheckListItem; + +class KCMKMailSummary : public KCModule +{ + Q_OBJECT + + public: + KCMKMailSummary( QWidget *parent = 0, const char *name = 0 ); + + virtual void load(); + virtual void save(); + virtual void defaults(); + + private slots: + void modified(); + + private: + void initGUI(); + void initFolders(); + void loadFolders(); + void storeFolders(); + + KListView *mFolderView; + QCheckBox *mFullPath; + QMap<QString, QListViewItem*> mFolderMap; +}; + +#endif diff --git a/kontact/plugins/kmail/kmail_plugin.cpp b/kontact/plugins/kmail/kmail_plugin.cpp new file mode 100644 index 000000000..3d9f45bec --- /dev/null +++ b/kontact/plugins/kmail/kmail_plugin.cpp @@ -0,0 +1,221 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 Kontact Developer + + 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 <qwidget.h> + +#include <kaction.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <kiconloader.h> +#include <kparts/componentfactory.h> +#include <kstandarddirs.h> +#include <dcopclient.h> +#include <ktempfile.h> + +#include <kabc/addressee.h> + +#include <libkcal/vcaldrag.h> +#include <libkcal/icaldrag.h> +#include <libkcal/calendarlocal.h> + +#include <libkdepim/kvcarddrag.h> + +#include <kmail/kmail_part.h> +#include <kmail/kmkernel.h> + +#include "core.h" +#include "summarywidget.h" + +#include "kmail_plugin.h" + +using namespace KCal; + +typedef KGenericFactory<KMailPlugin, Kontact::Core> KMailPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_kmailplugin, + KMailPluginFactory( "kontact_kmailplugin" ) ) + +KMailPlugin::KMailPlugin(Kontact::Core *core, const char *, const QStringList& ) + : Kontact::Plugin( core, core, "kmail" ), + mStub( 0 ) +{ + setInstance( KMailPluginFactory::instance() ); + + insertNewAction( new KAction( i18n( "New Message..." ), "mail_new", + CTRL+SHIFT+Key_M, this, SLOT( slotNewMail() ), actionCollection(), + "new_mail" ) ); + + insertSyncAction( new KAction( i18n( "Synchronize Mail" ), "reload", + 0, this, SLOT( slotSyncFolders() ), actionCollection(), + "sync_mail" ) ); + + mUniqueAppWatcher = new Kontact::UniqueAppWatcher( + new Kontact::UniqueAppHandlerFactory<KMailUniqueAppHandler>(), this ); +} + +bool KMailPlugin::canDecodeDrag( QMimeSource *qms ) +{ + return ( ICalDrag::canDecode( qms ) || + VCalDrag::canDecode( qms ) || + KVCardDrag::canDecode( qms ) ); +} + +void KMailPlugin::processDropEvent( QDropEvent * de ) +{ + kdDebug() << k_funcinfo << endl; + CalendarLocal cal( QString::fromLatin1("UTC") ); + KABC::Addressee::List list; + + if ( VCalDrag::decode( de, &cal ) || ICalDrag::decode( de, &cal ) ) { + KTempFile tmp( locateLocal( "tmp", "incidences-" ), ".ics" ); + cal.save( tmp.name() ); + openComposer( KURL::fromPathOrURL( tmp.name() ) ); + } + else if ( KVCardDrag::decode( de, list ) ) { + KABC::Addressee::List::Iterator it; + QStringList to; + for ( it = list.begin(); it != list.end(); ++it ) { + to.append( ( *it ).fullEmail() ); + } + openComposer( to.join(", ") ); + } + +} + +void KMailPlugin::openComposer( const KURL& attach ) +{ + (void) part(); // ensure part is loaded + Q_ASSERT( mStub ); + if ( mStub ) { + if ( attach.isValid() ) + mStub->newMessage( "", "", "", false, true, KURL(), attach ); + else + mStub->newMessage( "", "", "", false, true, KURL(), KURL() ); + } +} + +void KMailPlugin::openComposer( const QString& to ) +{ + (void) part(); // ensure part is loaded + Q_ASSERT( mStub ); + if ( mStub ) { + mStub->newMessage( to, "", "", false, true, KURL(), KURL() ); + } +} + +void KMailPlugin::slotNewMail() +{ + openComposer( QString::null ); +} + +void KMailPlugin::slotSyncFolders() +{ + DCOPRef ref( "kmail", "KMailIface" ); + ref.send( "checkMail" ); +} + +KMailPlugin::~KMailPlugin() +{ +} + +bool KMailPlugin::createDCOPInterface( const QString& serviceType ) +{ + if ( serviceType == "DCOP/ResourceBackend/IMAP" ) { + if ( part() ) + return true; + } + + return false; +} + +QString KMailPlugin::tipFile() const +{ + QString file = ::locate("data", "kmail/tips"); + return file; +} + +KParts::ReadOnlyPart* KMailPlugin::createPart() +{ + KParts::ReadOnlyPart *part = loadPart(); + if ( !part ) return 0; + + mStub = new KMailIface_stub( dcopClient(), "kmail", "KMailIface" ); + + return part; +} + +QStringList KMailPlugin::invisibleToolbarActions() const +{ + return QStringList( "new_message" ); +} + +bool KMailPlugin::isRunningStandalone() +{ + return mUniqueAppWatcher->isRunningStandalone(); +} + +Kontact::Summary *KMailPlugin::createSummaryWidget( QWidget *parent ) +{ + return new SummaryWidget( this, parent ); +} + +//// + +#include "../../../kmail/kmail_options.h" +void KMailUniqueAppHandler::loadCommandLineOptions() +{ + KCmdLineArgs::addCmdLineOptions( kmail_options ); +} + +int KMailUniqueAppHandler::newInstance() +{ + // Ensure part is loaded + (void)plugin()->part(); + DCOPRef kmail( "kmail", "KMailIface" ); + DCOPReply reply = kmail.call( "handleCommandLine", false ); + if ( reply.isValid() ) { + bool handled = reply; + //kdDebug(5602) << k_funcinfo << "handled=" << handled << endl; + if ( !handled ) // no args -> simply bring kmail plugin to front + return Kontact::UniqueAppHandler::newInstance(); + } + return 0; +} + +bool KMailPlugin::queryClose() const { + KMailIface_stub stub( kapp->dcopClient(), "kmail", "KMailIface" ); + bool canClose=stub.canQueryClose(); + return canClose; +} + +void KMailPlugin::loadProfile( const QString& profileDirectory ) { + DCOPRef ref( "kmail", "KMailIface" ); + ref.send( "loadProfile", profileDirectory ); +} + +void KMailPlugin::saveToProfile( const QString& profileDirectory ) { + DCOPRef ref( "kmail", "KMailIface" ); + ref.send( "saveToProfile", profileDirectory ); +} + +#include "kmail_plugin.moc" diff --git a/kontact/plugins/kmail/kmail_plugin.h b/kontact/plugins/kmail/kmail_plugin.h new file mode 100644 index 000000000..0d6013867 --- /dev/null +++ b/kontact/plugins/kmail/kmail_plugin.h @@ -0,0 +1,86 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 Kontact Developer + + 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 KMAIL_PLUGIN_H +#define KMAIL_PLUGIN_H + +#include <klocale.h> +#include <kparts/part.h> + +#include "kmailIface_stub.h" +#include <plugin.h> +#include <summary.h> +#include <uniqueapphandler.h> + +class QMimeSource; +class QDropEvent; + +class KMailUniqueAppHandler : public Kontact::UniqueAppHandler +{ +public: + KMailUniqueAppHandler( Kontact::Plugin* plugin ) : Kontact::UniqueAppHandler( plugin ) {} + virtual void loadCommandLineOptions(); + virtual int newInstance(); +}; + +class KMailPlugin : public Kontact::Plugin +{ + Q_OBJECT + + public: + KMailPlugin( Kontact::Core *core, const char *name, const QStringList& ); + ~KMailPlugin(); + + virtual bool isRunningStandalone(); + virtual bool createDCOPInterface( const QString& serviceType ); + virtual Kontact::Summary *createSummaryWidget( QWidget *parent ); + virtual QString tipFile() const; + int weight() const { return 200; } + + virtual QStringList invisibleToolbarActions() const; + virtual bool queryClose() const; + + //override + void loadProfile( const QString& profileDirectory ); + + //override + void saveToProfile( const QString& profileDirectory ); + + protected: + virtual KParts::ReadOnlyPart* createPart(); + void openComposer( const KURL& = KURL() ); + void openComposer( const QString& to ); + bool canDecodeDrag( QMimeSource * ); + void processDropEvent( QDropEvent * ); + + + protected slots: + void slotNewMail(); + void slotSyncFolders(); + + private: + KMailIface_stub *mStub; + Kontact::UniqueAppWatcher *mUniqueAppWatcher; +}; + +#endif diff --git a/kontact/plugins/kmail/kmailplugin.desktop b/kontact/plugins/kmail/kmailplugin.desktop new file mode 100644 index 000000000..55ba5e97b --- /dev/null +++ b/kontact/plugins/kmail/kmailplugin.desktop @@ -0,0 +1,67 @@ +[Desktop Entry] +Type=Service +Icon=kontact_mail +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_kmailplugin +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPartLibraryName=libkmailpart +X-KDE-KontactPartExecutableName=kmail +X-KDE-KontactPartLoadOnStart=true +X-KDE-KontactPluginHasSummary=true + +X-KDE-PluginInfo-Website=http://kmail.kde.org/ +X-KDE-PluginInfo-Name=kontact_kmailplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=E-Mail Component (KMail Plugin) +Comment[bg]=Модул за е-поща +Comment[ca]=Component de correu (endollable del KMail) +Comment[da]=Post-komponent (KMail-plugin) +Comment[de]=E-Mail-Komponente (KMail-Modul) +Comment[el]=Συστατικό αλληλογραφίας (Πρόσθετο του KMail) +Comment[es]=Componente de correo electrónico (complemento de KMail) +Comment[et]=E-posti plugin (KMail) +Comment[fr]=Composant de courriel (Module pour KMail) +Comment[is]=Pósteining (KMail íforrit) +Comment[it]=Componente posta elettronica (plugin KMail) +Comment[ja]=メールコンポーネント (KMail プラグイン) +Comment[km]=សមាសភាគអ៊ីមែល (កម្មវិធីជំនួយ KMail) +Comment[nds]=Nettpost-Komponent (KMail-Moduul) +Comment[nl]=E-mailcomponent (KMail-plugin) +Comment[pl]=Składnik poczty (wtyczka KMail) +Comment[pt_BR]=Componente de e-mail (plug-in do KMail) +Comment[ru]=Электронная почта (модуль KMail) +Comment[sk]=Poštový komponent (Model pre KMail) +Comment[sr]=Компонента е-поште (прикључак KMail-а) +Comment[sr@Latn]=Komponenta e-pošte (priključak KMail-a) +Comment[sv]=E-postkomponent (Kmail-insticksprogram) +Comment[tr]=E-Posta Bileşeni (KMail Eklentisi) +Comment[zh_CN]=邮件组件(KMail 插件) +Comment[zh_TW]=電子郵件組件(KMail 外掛程式) +Name=E-Mail +Name[bg]=Е-поща +Name[ca]=Correu +Name[da]=E-mail +Name[el]=Αλληλογραφία +Name[es]=Correo electrónico +Name[et]=E-post +Name[fr]=Courriel +Name[is]=Tölvupóstur +Name[it]=Posta elettronica +Name[ja]=メール +Name[km]=អ៊ីមែល +Name[nds]=Nettpost +Name[nl]=E-mail +Name[pl]=E-mail +Name[pt_BR]=E-mail +Name[ru]=Электронная почта +Name[sk]=Pošta +Name[sr]=Е-пошта +Name[sr@Latn]=E-pošta +Name[sv]=E-post +Name[tr]=E-Posta +Name[zh_CN]=邮件 +Name[zh_TW]=電子郵件 diff --git a/kontact/plugins/kmail/summarywidget.cpp b/kontact/plugins/kmail/summarywidget.cpp new file mode 100644 index 000000000..79f2f4657 --- /dev/null +++ b/kontact/plugins/kmail/summarywidget.cpp @@ -0,0 +1,182 @@ +/* -*- mode: C++; c-file-style: "gnu" -*- + + This file is part of Kontact. + Copyright (c) 2003 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 <qlabel.h> +#include <qlayout.h> + +#include <dcopref.h> +#include <kapplication.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kdialog.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kparts/part.h> + +#include "core.h" +#include "summary.h" +#include "summarywidget.h" + +#include <time.h> + +SummaryWidget::SummaryWidget( Kontact::Plugin *plugin, QWidget *parent, const char *name ) + : Kontact::Summary( parent, name ), + DCOPObject( QCString("MailSummary") ), + mPlugin( plugin ) +{ + QVBoxLayout *mainLayout = new QVBoxLayout( this, 3, 3 ); + + QPixmap icon = KGlobal::iconLoader()->loadIcon( "kontact_mail", KIcon::Desktop, + KIcon::SizeMedium ); + QWidget *header = createHeader(this, icon, i18n("E-Mail")); + mLayout = new QGridLayout( 1, 3, 3 ); + + mainLayout->addWidget(header); + mainLayout->addLayout(mLayout); + + slotUnreadCountChanged(); + connectDCOPSignal( 0, 0, "unreadCountChanged()", "slotUnreadCountChanged()", + false ); +} + +void SummaryWidget::selectFolder( const QString& folder ) +{ + if ( mPlugin->isRunningStandalone() ) + mPlugin->bringToForeground(); + else + mPlugin->core()->selectPlugin( mPlugin ); + QByteArray data; + QDataStream arg( data, IO_WriteOnly ); + arg << folder; + emitDCOPSignal( "kmailSelectFolder(QString)", data ); +} + +void SummaryWidget::updateSummary( bool ) +{ + // check whether we need to update the message counts + DCOPRef kmail( "kmail", "KMailIface" ); + const int timeOfLastMessageCountChange = + kmail.call( "timeOfLastMessageCountChange()" ); + if ( timeOfLastMessageCountChange > mTimeOfLastMessageCountUpdate ) + slotUnreadCountChanged(); +} + +void SummaryWidget::slotUnreadCountChanged() +{ + DCOPRef kmail( "kmail", "KMailIface" ); + DCOPReply reply = kmail.call( "folderList" ); + if ( reply.isValid() ) { + QStringList folderList = reply; + updateFolderList( folderList ); + } + else { + kdDebug(5602) << "Calling kmail->KMailIface->folderList() via DCOP failed." + << endl; + } + mTimeOfLastMessageCountUpdate = ::time( 0 ); +} + +void SummaryWidget::updateFolderList( const QStringList& folders ) +{ + mLabels.setAutoDelete( true ); + mLabels.clear(); + mLabels.setAutoDelete( false ); + + KConfig config( "kcmkmailsummaryrc" ); + config.setGroup( "General" ); + + QStringList activeFolders; + if ( !config.hasKey( "ActiveFolders" ) ) + activeFolders << "/Local/inbox"; + else + activeFolders = config.readListEntry( "ActiveFolders" ); + + int counter = 0; + QStringList::ConstIterator it; + DCOPRef kmail( "kmail", "KMailIface" ); + for ( it = folders.begin(); it != folders.end(); ++it ) { + if ( activeFolders.contains( *it ) ) { + DCOPRef folderRef = kmail.call( "getFolder(QString)", *it ); + const int numMsg = folderRef.call( "messages()" ); + const int numUnreadMsg = folderRef.call( "unreadMessages()" ); + + if ( numUnreadMsg == 0 ) continue; + + QString folderPath; + if ( config.readBoolEntry( "ShowFullPath", true ) ) + folderRef.call( "displayPath()" ).get( folderPath ); + else + folderRef.call( "displayName()" ).get( folderPath ); + + KURLLabel *urlLabel = new KURLLabel( *it, folderPath, this ); + urlLabel->installEventFilter( this ); + urlLabel->setAlignment( AlignLeft ); + urlLabel->show(); + connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ), + SLOT( selectFolder( const QString& ) ) ); + mLayout->addWidget( urlLabel, counter, 0 ); + mLabels.append( urlLabel ); + + QLabel *label = + new QLabel( QString( i18n("%1: number of unread messages " + "%2: total number of messages", "%1 / %2") ) + .arg( numUnreadMsg ).arg( numMsg ), this ); + label->setAlignment( AlignLeft ); + label->show(); + mLayout->addWidget( label, counter, 2 ); + mLabels.append( label ); + + counter++; + } + } + + if ( counter == 0 ) { + QLabel *label = new QLabel( i18n( "No unread messages in your monitored folders" ), this ); + label->setAlignment( AlignHCenter | AlignVCenter ); + mLayout->addMultiCellWidget( label, 0, 0, 0, 2 ); + label->show(); + mLabels.append( label ); + } +} + +bool SummaryWidget::eventFilter( QObject *obj, QEvent* e ) +{ + if ( obj->inherits( "KURLLabel" ) ) { + KURLLabel* label = static_cast<KURLLabel*>( obj ); + if ( e->type() == QEvent::Enter ) + emit message( i18n( "Open Folder: \"%1\"" ).arg( label->text() ) ); + if ( e->type() == QEvent::Leave ) + emit message( QString::null ); + } + + return Kontact::Summary::eventFilter( obj, e ); +} + +QStringList SummaryWidget::configModules() const +{ + return QStringList( "kcmkmailsummary.desktop" ); +} + +#include "summarywidget.moc" diff --git a/kontact/plugins/kmail/summarywidget.h b/kontact/plugins/kmail/summarywidget.h new file mode 100644 index 000000000..563a021e1 --- /dev/null +++ b/kontact/plugins/kmail/summarywidget.h @@ -0,0 +1,73 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 SUMMARYWIDGET_H +#define SUMMARYWIDGET_H + +#include <qmap.h> +#include <qtimer.h> +#include <qwidget.h> + +#include <dcopobject.h> +#include <kurllabel.h> +#include <kparts/part.h> + +#include "plugin.h" +#include "summary.h" + +class QGridLayout; +class QString; + +class SummaryWidget : public Kontact::Summary, public DCOPObject +{ + Q_OBJECT + K_DCOP + + public: + SummaryWidget( Kontact::Plugin *plugin, QWidget *parent, const char *name = 0 ); + + int summaryHeight() const { return 1; } + QStringList configModules() const; + + k_dcop_hidden: + void slotUnreadCountChanged(); + + protected: + virtual bool eventFilter( QObject *obj, QEvent* e ); + + public slots: + virtual void updateSummary( bool force ); + + private slots: + void selectFolder( const QString& ); + + private: + void updateFolderList( const QStringList& folders ); + + QPtrList<QLabel> mLabels; + QGridLayout *mLayout; + Kontact::Plugin *mPlugin; + int mTimeOfLastMessageCountUpdate; +}; + +#endif diff --git a/kontact/plugins/knode/Makefile.am b/kontact/plugins/knode/Makefile.am new file mode 100644 index 000000000..bf4ba753a --- /dev/null +++ b/kontact/plugins/knode/Makefile.am @@ -0,0 +1,14 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces -I$(top_srcdir)/knode -I$(top_srcdir) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_knodeplugin.la +libkontact_knodeplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_knodeplugin_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(LIB_KPARTS) + +libkontact_knodeplugin_la_SOURCES = knode_plugin.cpp knodeiface.stub + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir)/kontact +service_DATA = knodeplugin.desktop + +knodeiface_DIR = $(top_srcdir)/knode diff --git a/kontact/plugins/knode/knode_plugin.cpp b/kontact/plugins/knode/knode_plugin.cpp new file mode 100644 index 000000000..6ad7fedb1 --- /dev/null +++ b/kontact/plugins/knode/knode_plugin.cpp @@ -0,0 +1,123 @@ +/* + This file is part of Kontact. + + Copyright (c) 2003 Zack Rusin <zack@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 "knode_plugin.h" + +#include "core.h" + +#include <kapplication.h> +#include <kparts/componentfactory.h> +#include <kgenericfactory.h> +#include <kapplication.h> +#include <kaction.h> +#include <kiconloader.h> +#include <kdebug.h> + +#include <dcopclient.h> + +#include <qwidget.h> + + +typedef KGenericFactory<KNodePlugin, Kontact::Core> KNodePluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_knodeplugin, + KNodePluginFactory( "kontact_knodeplugin" ) ) + + +KNodePlugin::KNodePlugin( Kontact::Core *core, const char *, const QStringList& ) + : Kontact::Plugin( core, core, "knode" ), mStub(0) +{ + setInstance( KNodePluginFactory::instance() ); + + insertNewAction( new KAction( i18n( "New Article..." ), "mail_new", CTRL+SHIFT+Key_A, + this, SLOT( slotPostArticle() ), actionCollection(), "post_article" ) ); + + mUniqueAppWatcher = new Kontact::UniqueAppWatcher( + new Kontact::UniqueAppHandlerFactory<KNodeUniqueAppHandler>(), this ); +} + +KNodePlugin::~KNodePlugin() +{ +} + +bool KNodePlugin::createDCOPInterface( const QString& /*serviceType*/ ) +{ + return false; +} + +bool KNodePlugin::isRunningStandalone() +{ + return mUniqueAppWatcher->isRunningStandalone(); +} + +QStringList KNodePlugin::invisibleToolbarActions() const +{ + return QStringList( "article_postNew" ); +} + +void KNodePlugin::slotPostArticle() +{ + (void) part(); // ensure part is loaded + Q_ASSERT( mStub ); + if ( mStub ) + mStub->postArticle(); +} + +KParts::ReadOnlyPart* KNodePlugin::createPart() +{ + KParts::ReadOnlyPart *part = loadPart(); + if ( !part ) return 0; + + mStub = new KNodeIface_stub( dcopClient(), "knode", "KNodeIface" ); + return part; +} + +//// + +#include "../../../knode/knode_options.h" +void KNodeUniqueAppHandler::loadCommandLineOptions() +{ + KCmdLineArgs::addCmdLineOptions( knode_options ); +} + +int KNodeUniqueAppHandler::newInstance() +{ + // Ensure part is loaded + (void)plugin()->part(); + DCOPRef knode( "knode", "KNodeIface" ); + DCOPReply reply = knode.call( "handleCommandLine" ); +#if 0 + if ( reply.isValid() ) { + bool handled = reply; + kdDebug(5602) << k_funcinfo << "handled=" << handled << endl; + if ( !handled ) +#endif + // in all cases, bring knode plugin to front + return Kontact::UniqueAppHandler::newInstance(); +#if 0 + } + return 0; +#endif +} + +#include "knode_plugin.moc" diff --git a/kontact/plugins/knode/knode_plugin.h b/kontact/plugins/knode/knode_plugin.h new file mode 100644 index 000000000..78d4275ed --- /dev/null +++ b/kontact/plugins/knode/knode_plugin.h @@ -0,0 +1,68 @@ +/* + This file is part of Kontact. + + Copyright (c) 2003 Zack Rusin <zack@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 KNODE_PLUGIN_H +#define KNODE_PLUGIN_H + +#include <klocale.h> +#include <kparts/part.h> + +#include "knodeiface_stub.h" +#include "plugin.h" +#include <uniqueapphandler.h> + +class KNodeUniqueAppHandler : public Kontact::UniqueAppHandler +{ +public: + KNodeUniqueAppHandler( Kontact::Plugin* plugin ) : Kontact::UniqueAppHandler( plugin ) {} + virtual void loadCommandLineOptions(); + virtual int newInstance(); +}; + +class KNodePlugin : public Kontact::Plugin +{ + Q_OBJECT + + public: + KNodePlugin( Kontact::Core *core, const char *name, const QStringList& ); + ~KNodePlugin(); + + virtual bool createDCOPInterface( const QString& serviceType ); + virtual bool isRunningStandalone(); + int weight() const { return 500; } + + virtual QStringList invisibleToolbarActions() const; + + protected: + virtual KParts::ReadOnlyPart* createPart(); + + protected slots: + void slotPostArticle(); + + private: + KNodeIface_stub *mStub; + Kontact::UniqueAppWatcher *mUniqueAppWatcher; +}; + +#endif diff --git a/kontact/plugins/knode/knodeplugin.desktop b/kontact/plugins/knode/knodeplugin.desktop new file mode 100644 index 000000000..d84c16f7e --- /dev/null +++ b/kontact/plugins/knode/knodeplugin.desktop @@ -0,0 +1,98 @@ +[Desktop Entry] +Type=Service +Icon=kontact_news +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_knodeplugin +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPartLibraryName=libknodepart +X-KDE-KontactPartExecutableName=knode + +X-KDE-PluginInfo-Name=kontact_knodeplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=false + +Comment=Newsreader Component (KNode Plugin) +Comment[bg]=Приставка за KNode +Comment[ca]=Component de notícies (endollable del KNode) +Comment[da]=Nyhedskomponent (KNode-plugin) +Comment[de]=News-Komponente (KNode-Modul) +Comment[el]=Συστατικό ανάγνωσης νέων (Πρόσθετο του KNode) +Comment[es]=Componente de noticias (complemento de KNode) +Comment[et]=Uudistelugeja plugin (KNode) +Comment[fr]=Composant de lecteur de nouvelles (Module pour KNode) +Comment[is]=Fréttaeining (KNode íforrit) +Comment[it]=Componente lettore di news (plugin KNode) +Comment[ja]=ニュースリーダーコンポーネント (KNode プラグイン) +Comment[km]=សមាសភាគ Newsreader (កម្មវិធីជំនួយ KNode) +Comment[nds]=Narichtenkieker-Komponent (KNode-Moduul) +Comment[nl]=Nieuwscomponent (KNode-plugin) +Comment[pl]=Składnik wiadomości (wtyczka KNode) +Comment[ru]=Новости (модуль KNode) +Comment[sr]=Компонента вести (прикључак KNode-а) +Comment[sr@Latn]=Komponenta vesti (priključak KNode-a) +Comment[sv]=Komponent för läsning av diskussionsgrupper (Knode-insticksprogram) +Comment[tr]=Haber Okuyucu Bileşeni (KNode Eklentisi) +Comment[zh_CN]=新闻组阅读器组件(KNode 插件) +Comment[zh_TW]=新聞閱讀器組件(KNode 外掛程式) +Name=News +Name[af]=Nuus +Name[ar]=الأخبار +Name[be]=Навіны +Name[bg]=Новини +Name[br]=Keleier +Name[bs]=Usenet +Name[ca]=Notícies +Name[cs]=Novinky +Name[cy]=Newyddion +Name[da]=Nyheder +Name[de]=Usenet +Name[el]=Νέα +Name[eo]=Novaĵoj +Name[es]=Noticias +Name[et]=Uudisegrupid +Name[eu]=Berriak +Name[fa]=اخبار +Name[fi]=Uutiset +Name[fr]=Nouvelles +Name[fy]=Nijs +Name[ga]=Nuacht +Name[gl]=Novas +Name[he]=חדשות +Name[hi]=समाचार +Name[hu]=Hírek +Name[is]=Fréttir +Name[ja]=ニュース +Name[ka]=სიახლეები +Name[kk]=Жаңалықтар +Name[km]=ព័ត៌មាន +Name[lt]=Naujienos +Name[mk]=Вести +Name[ms]=Berita +Name[nb]=Njus +Name[nds]=Narichten +Name[ne]=समाचार +Name[nl]=Nieuws +Name[nn]=Nyheiter +Name[pa]=ਖ਼ਬਰਾਂ +Name[pl]=Listy dyskusyjne +Name[pt]=Notícias +Name[pt_BR]=Notícias +Name[ro]=Ştiri +Name[ru]=Новости +Name[se]=Ođđasat +Name[sk]=Diskusné skupiny +Name[sl]=Novice +Name[sr]=Вести +Name[sr@Latn]=Vesti +Name[sv]=Nyheter +Name[ta]=செய்திகள் +Name[tg]=Ахборот +Name[th]=ข่าว +Name[tr]=Haberler +Name[uk]=Новини +Name[uz]=Yangiliklar +Name[uz@cyrillic]=Янгиликлар +Name[zh_CN]=新闻 +Name[zh_TW]=新聞 diff --git a/kontact/plugins/knotes/Makefile.am b/kontact/plugins/knotes/Makefile.am new file mode 100644 index 000000000..4a3b1710f --- /dev/null +++ b/kontact/plugins/knotes/Makefile.am @@ -0,0 +1,23 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces -I$(top_srcdir) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_knotesplugin.la +libkontact_knotesplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_knotesplugin_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la \ + $(LIB_KPARTS) $(top_builddir)/libkdepim/libkdepim.la \ + $(top_builddir)/libkcal/libkcal.la -lkresources -lkdeprint \ + $(top_builddir)/knotes/libknotesresources.la \ + $(top_builddir)/knotes/libknoteseditor.la \ + $(top_builddir)/knotes/libknotesprinting.la + +libkontact_knotesplugin_la_SOURCES = knotes_plugin.cpp knotes_part.cpp summarywidget.cpp \ + knotetip.cpp KNotesIface.skel + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir)/kontact +service_DATA = knotesplugin.desktop + +partdir = $(kde_datadir)/knotes +part_DATA = knotes_part.rc + +KNotesIface_DIR = $(top_srcdir)/knotes diff --git a/kontact/plugins/knotes/knotes_part.cpp b/kontact/plugins/knotes/knotes_part.cpp new file mode 100644 index 000000000..5bd160d1d --- /dev/null +++ b/kontact/plugins/knotes/knotes_part.cpp @@ -0,0 +1,413 @@ +/* + This file is part of the KDE project + Copyright (C) 2002-2003 Daniel Molkentin <molkentin@kde.org> + Copyright (C) 2004-2006 Michael Brade <brade@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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <qpopupmenu.h> +#include <qclipboard.h> + +#include <kapplication.h> +#include <kdebug.h> +#include <kaction.h> +#include <kmessagebox.h> + +#include <libkdepim/infoextension.h> +#include <libkdepim/sidebarextension.h> + +#include "knotes/knoteprinter.h" +#include "knotes/resourcemanager.h" + +#include "knotes_part.h" +#include "knotes_part_p.h" +#include "knotetip.h" + + +KNotesPart::KNotesPart( QObject *parent, const char *name ) + : DCOPObject( "KNotesIface" ), KParts::ReadOnlyPart( parent, name ), + mNotesView( new KNotesIconView() ), + mNoteTip( new KNoteTip( mNotesView ) ), + mNoteEditDlg( 0 ), + mManager( new KNotesResourceManager() ) +{ + mNoteList.setAutoDelete( true ); + + setInstance( new KInstance( "knotes" ) ); + + // create the actions + new KAction( i18n( "&New" ), "knotes", CTRL+Key_N, this, SLOT( newNote() ), + actionCollection(), "file_new" ); + new KAction( i18n( "Rename..." ), "text", this, SLOT( renameNote() ), + actionCollection(), "edit_rename" ); + new KAction( i18n( "Delete" ), "editdelete", Key_Delete, this, SLOT( killSelectedNotes() ), + actionCollection(), "edit_delete" ); + new KAction( i18n( "Print Selected Notes..." ), "print", CTRL+Key_P, this, SLOT( printSelectedNotes() ), + actionCollection(), "print_note" ); + + // TODO icons: s/editdelete/knotes_delete/ or the other way round in knotes + + // set the view up + mNotesView->setSelectionMode( QIconView::Extended ); + mNotesView->setItemsMovable( false ); + mNotesView->setResizeMode( QIconView::Adjust ); + mNotesView->setAutoArrange( true ); + mNotesView->setSorting( true ); + + connect( mNotesView, SIGNAL( executed( QIconViewItem* ) ), + this, SLOT( editNote( QIconViewItem* ) ) ); + connect( mNotesView, SIGNAL( returnPressed( QIconViewItem* ) ), + this, SLOT( editNote( QIconViewItem* ) ) ); + connect( mNotesView, SIGNAL( itemRenamed( QIconViewItem* ) ), + this, SLOT( renamedNote( QIconViewItem* ) ) ); + connect( mNotesView, SIGNAL( contextMenuRequested( QIconViewItem*, const QPoint& ) ), + this, SLOT( popupRMB( QIconViewItem*, const QPoint& ) ) ); + connect( mNotesView, SIGNAL( onItem( QIconViewItem* ) ), + this, SLOT( slotOnItem( QIconViewItem* ) ) ); + connect( mNotesView, SIGNAL( onViewport() ), + this, SLOT( slotOnViewport() ) ); + connect( mNotesView, SIGNAL( currentChanged( QIconViewItem* ) ), + this, SLOT( slotOnCurrentChanged( QIconViewItem* ) ) ); + + slotOnCurrentChanged( 0 ); + + new KParts::SideBarExtension( mNotesView, this, "NotesSideBarExtension" ); + + setWidget( mNotesView ); + setXMLFile( "knotes_part.rc" ); + + // connect the resource manager + connect( mManager, SIGNAL( sigRegisteredNote( KCal::Journal* ) ), + this, SLOT( createNote( KCal::Journal* ) ) ); + connect( mManager, SIGNAL( sigDeregisteredNote( KCal::Journal* ) ), + this, SLOT( killNote( KCal::Journal* ) ) ); + + // read the notes + mManager->load(); +} + +KNotesPart::~KNotesPart() +{ + delete mNoteTip; + mNoteTip = 0; + + delete mManager; + mManager = 0; +} + +void KNotesPart::printSelectedNotes() +{ + QValueList<KCal::Journal*> journals; + + for ( QIconViewItem *it = mNotesView->firstItem(); it; it = it->nextItem() ) { + if ( it->isSelected() ) { + journals.append( static_cast<KNotesIconViewItem *>( it )->journal() ); + } + } + + if ( journals.isEmpty() ) { + KMessageBox::information( mNotesView, i18n("To print notes, first select the notes to print from the list."), i18n("Print Notes") ); + return; + } + + KNotePrinter printer; + printer.printNotes(journals ); + +#if 0 + QString content; + if ( m_editor->textFormat() == PlainText ) + content = QStyleSheet::convertFromPlainText( m_editor->text() ); + else + content = m_editor->text(); + + KNotePrinter printer; + printer.setMimeSourceFactory( m_editor->mimeSourceFactory() ); + //printer.setFont( m_config->font() ); + //printer.setContext( m_editor->context() ); + //printer.setStyleSheet( m_editor->styleSheet() ); + printer.setColorGroup( colorGroup() ); + printer.printNote( , content ); +#endif +} + +bool KNotesPart::openFile() +{ + return false; +} + + +// public KNotes DCOP interface implementation + +QString KNotesPart::newNote( const QString& name, const QString& text ) +{ + // create the new note + KCal::Journal *journal = new KCal::Journal(); + + // new notes have the current date/time as title if none was given + if ( !name.isEmpty() ) + journal->setSummary( name ); + else + journal->setSummary( KGlobal::locale()->formatDateTime( QDateTime::currentDateTime() ) ); + + // the body of the note + journal->setDescription( text ); + + + + // Edit the new note if text is empty + if ( text.isNull() ) + { + if ( !mNoteEditDlg ) + mNoteEditDlg = new KNoteEditDlg( widget() ); + + mNoteEditDlg->setTitle( journal->summary() ); + mNoteEditDlg->setText( journal->description() ); + + if ( mNoteEditDlg->exec() == QDialog::Accepted ) + { + journal->setSummary( mNoteEditDlg->title() ); + journal->setDescription( mNoteEditDlg->text() ); + } + else + { + delete journal; + return ""; + } + } + + mManager->addNewNote( journal ); + mManager->save(); + + KNotesIconViewItem *note = mNoteList[ journal->uid() ]; + mNotesView->ensureItemVisible( note ); + mNotesView->setCurrentItem( note ); + + return journal->uid(); +} + +QString KNotesPart::newNoteFromClipboard( const QString& name ) +{ + const QString& text = KApplication::clipboard()->text(); + return newNote( name, text ); +} + +void KNotesPart::killNote( const QString& id ) +{ + killNote( id, false ); +} + +void KNotesPart::killNote( const QString& id, bool force ) +{ + KNotesIconViewItem *note = mNoteList[ id ]; + + if ( note && + ( (!force && KMessageBox::warningContinueCancelList( mNotesView, + i18n( "Do you really want to delete this note?" ), + mNoteList[ id ]->text(), i18n( "Confirm Delete" ), + KStdGuiItem::del() ) == KMessageBox::Continue) + || force ) + ) + { + mManager->deleteNote( mNoteList[id]->journal() ); + mManager->save(); + } +} + +QString KNotesPart::name( const QString& id ) const +{ + KNotesIconViewItem *note = mNoteList[ id ]; + if ( note ) + return note->text(); + else + return QString::null; +} + +QString KNotesPart::text( const QString& id ) const +{ + KNotesIconViewItem *note = mNoteList[id]; + if ( note ) + return note->journal()->description(); + else + return QString::null; +} + +void KNotesPart::setName( const QString& id, const QString& newName ) +{ + KNotesIconViewItem *note = mNoteList[ id ]; + if ( note ) { + note->setText( newName ); + mManager->save(); + } +} + +void KNotesPart::setText( const QString& id, const QString& newText ) +{ + KNotesIconViewItem *note = mNoteList[ id ]; + if ( note ) { + note->journal()->setDescription( newText ); + mManager->save(); + } +} + +QMap<QString, QString> KNotesPart::notes() const +{ + QMap<QString, QString> notes; + QDictIterator<KNotesIconViewItem> it( mNoteList ); + + for ( ; it.current(); ++it ) + notes.insert( (*it)->journal()->uid(), (*it)->journal()->summary() ); + + return notes; +} + + +// private stuff + +void KNotesPart::killSelectedNotes() +{ + QPtrList<KNotesIconViewItem> items; + QStringList notes; + + KNotesIconViewItem *knivi; + for ( QIconViewItem *it = mNotesView->firstItem(); it; it = it->nextItem() ) { + if ( it->isSelected() ) { + knivi = static_cast<KNotesIconViewItem *>( it ); + items.append( knivi ); + notes.append( knivi->text() ); + } + } + + if ( items.isEmpty() ) + return; + + int ret = KMessageBox::warningContinueCancelList( mNotesView, + i18n( "Do you really want to delete this note?", + "Do you really want to delete these %n notes?", items.count() ), + notes, i18n( "Confirm Delete" ), + KStdGuiItem::del() ); + + if ( ret == KMessageBox::Continue ) { + QPtrListIterator<KNotesIconViewItem> kniviIt( items ); + while ( (knivi = *kniviIt) ) { + ++kniviIt; + mManager->deleteNote( knivi->journal() ); + } + + mManager->save(); + } +} + +void KNotesPart::popupRMB( QIconViewItem *item, const QPoint& pos ) +{ + QPopupMenu *contextMenu = NULL; + + if ( item ) + contextMenu = static_cast<QPopupMenu *>( factory()->container( "note_context", this ) ); + else + contextMenu = static_cast<QPopupMenu *>( factory()->container( "notepart_context", this ) ); + + if ( !contextMenu ) + return; + + contextMenu->popup( pos ); +} + +void KNotesPart::slotOnItem( QIconViewItem *i ) +{ + // TODO: disable (i.e. setNote( QString::null )) when mouse button pressed + + KNotesIconViewItem *item = static_cast<KNotesIconViewItem *>( i ); + mNoteTip->setNote( item ); +} + +void KNotesPart::slotOnViewport() +{ + mNoteTip->setNote( 0 ); +} + +// TODO: also with takeItem, clear(), + +// create and kill the icon view item corresponding to the note, edit the note + +void KNotesPart::createNote( KCal::Journal *journal ) +{ + // make sure all fields are existent, initialize them with default values + QString property = journal->customProperty( "KNotes", "BgColor" ); + if ( property.isNull() ) + journal->setCustomProperty( "KNotes", "BgColor", "#ffff00" ); + + property = journal->customProperty( "KNotes", "FgColor" ); + if ( property.isNull() ) + journal->setCustomProperty( "KNotes", "FgColor", "#000000" ); + + property = journal->customProperty( "KNotes", "RichText" ); + if ( property.isNull() ) + journal->setCustomProperty( "KNotes", "RichText", "true" ); + + mNoteList.insert( journal->uid(), new KNotesIconViewItem( mNotesView, journal ) ); +} + +void KNotesPart::killNote( KCal::Journal *journal ) +{ + mNoteList.remove( journal->uid() ); +} + +void KNotesPart::editNote( QIconViewItem *item ) +{ + if ( !mNoteEditDlg ) + mNoteEditDlg = new KNoteEditDlg( widget() ); + + KCal::Journal *journal = static_cast<KNotesIconViewItem *>( item )->journal(); + + mNoteEditDlg->setRichText( journal->customProperty( "KNotes", "RichText" ) == "true" ); + mNoteEditDlg->setTitle( journal->summary() ); + mNoteEditDlg->setText( journal->description() ); + + if ( mNoteEditDlg->exec() == QDialog::Accepted ) { + item->setText( mNoteEditDlg->title() ); + journal->setDescription( mNoteEditDlg->text() ); + mManager->save(); + } +} + +void KNotesPart::renameNote() +{ + mNotesView->currentItem()->rename(); +} + +void KNotesPart::renamedNote( QIconViewItem* ) +{ + mManager->save(); +} + +void KNotesPart::slotOnCurrentChanged( QIconViewItem* ) +{ + KAction *renameAction = actionCollection()->action( "edit_rename" ); + KAction *deleteAction = actionCollection()->action( "edit_delete" ); + + if ( !mNotesView->currentItem() ) { + renameAction->setEnabled( false ); + deleteAction->setEnabled( false ); + } else { + renameAction->setEnabled( true ); + deleteAction->setEnabled( true ); + } +} + +#include "knotes_part.moc" +#include "knotes_part_p.moc" + diff --git a/kontact/plugins/knotes/knotes_part.h b/kontact/plugins/knotes/knotes_part.h new file mode 100644 index 000000000..c034d04fb --- /dev/null +++ b/kontact/plugins/knotes/knotes_part.h @@ -0,0 +1,101 @@ +/* + This file is part of the KDE project + Copyright (C) 2002 Daniel Molkentin <molkentin@kde.org> + Copyright (C) 2004-2006 Michael Brade <brade@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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KNOTES_PART_H +#define KNOTES_PART_H + +#include <qdict.h> + +#include <kiconview.h> +#include <kglobal.h> +#include <kiconloader.h> + +#include <libkcal/journal.h> +#include <kparts/part.h> + +#include "knotes/KNotesIface.h" + +class KIconView; +class QIconViewItem; +class KNotesIconViewItem; +class KNoteTip; +class KNoteEditDlg; +class KNotesResourceManager; + +namespace KCal { +class Journal; +} + +class KNotesPart : public KParts::ReadOnlyPart, virtual public KNotesIface +{ + Q_OBJECT + + public: + KNotesPart( QObject *parent = 0, const char *name = 0 ); + ~KNotesPart(); + + bool openFile(); + + public slots: + QString newNote( const QString& name = QString::null, + const QString& text = QString::null ); + QString newNoteFromClipboard( const QString& name = QString::null ); + + public: + void killNote( const QString& id ); + void killNote( const QString& id, bool force ); + + QString name( const QString& id ) const; + QString text( const QString& id ) const; + + void setName( const QString& id, const QString& newName ); + void setText( const QString& id, const QString& newText ); + + QMap<QString, QString> notes() const; + + private slots: + void createNote( KCal::Journal *journal ); + void killNote( KCal::Journal *journal ); + + void editNote( QIconViewItem *item ); + + void renameNote(); + void renamedNote( QIconViewItem *item ); + + void slotOnItem( QIconViewItem *item ); + void slotOnViewport(); + void slotOnCurrentChanged( QIconViewItem *item ); + + void popupRMB( QIconViewItem *item, const QPoint& pos ); + void killSelectedNotes(); + + void printSelectedNotes(); + + private: + KIconView *mNotesView; + KNoteTip *mNoteTip; + KNoteEditDlg *mNoteEditDlg; + + KNotesResourceManager *mManager; + QDict<KNotesIconViewItem> mNoteList; +}; + +#endif diff --git a/kontact/plugins/knotes/knotes_part.rc b/kontact/plugins/knotes/knotes_part.rc new file mode 100644 index 000000000..ef4461868 --- /dev/null +++ b/kontact/plugins/knotes/knotes_part.rc @@ -0,0 +1,23 @@ +<!DOCTYPE kpartgui> +<kpartgui name="knotes" version="5"> + <MenuBar> + <Menu name="file"><text>&File</text> + <Merge/> + <Action name="print_note"/> + </Menu> + <Menu name="edit"><text>&Edit</text> + <Action name="edit_rename"/> + <Action name="edit_delete"/> + </Menu> + </MenuBar> + <Menu name="note_context"> + <Action name="file_new"/> + <Action name="edit_rename"/> + <Action name="edit_delete"/> + <Action name="print_note"/> + </Menu> + <Menu name="notepart_context"> + <Action name="file_new"/> + </Menu> + +</kpartgui> diff --git a/kontact/plugins/knotes/knotes_part_p.h b/kontact/plugins/knotes/knotes_part_p.h new file mode 100644 index 000000000..55a0374b6 --- /dev/null +++ b/kontact/plugins/knotes/knotes_part_p.h @@ -0,0 +1,188 @@ +/* + This file is part of the KDE project + Copyright (C) 2004-2006 Michael Brade <brade@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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. +*/ + +#ifndef KNOTES_PART_P_H +#define KNOTES_PART_P_H + +#include <qlayout.h> +#include <qlabel.h> + +#include <kactioncollection.h> +#include <klocale.h> +#include <kiconview.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <kiconeffect.h> +#include <klineedit.h> +#include <ktoolbar.h> +#include <kpopupmenu.h> +#include <kdialogbase.h> +#include <kxmlguiclient.h> +#include <kxmlguifactory.h> +#include <kxmlguibuilder.h> + +#include <libkcal/calendarlocal.h> +#include <libkcal/journal.h> +#include <libkcal/icaldrag.h> +#include <libkdepim/kpimprefs.h> + +#include "knotes/knoteedit.h" + + +class KNotesIconViewItem : public KIconViewItem +{ + public: + KNotesIconViewItem( KIconView *parent, KCal::Journal *journal ) + : KIconViewItem( parent ), + mJournal( journal ) + { + setRenameEnabled( true ); + + KIconEffect effect; + QColor color( journal->customProperty( "KNotes", "BgColor" ) ); + QPixmap icon = KGlobal::iconLoader()->loadIcon( "knotes", KIcon::Desktop ); + icon = effect.apply( icon, KIconEffect::Colorize, 1, color, false ); + setPixmap( icon ); + setText( journal->summary() ); + } + + KCal::Journal *journal() + { + return mJournal; + } + + virtual void setText( const QString& text ) + { + KIconViewItem::setText( text ); + mJournal->setSummary( text ); + } + + private: + KCal::Journal *mJournal; +}; + + +class KNotesIconView : public KIconView +{ + protected: + QDragObject* dragObject() + { + QValueList<KNotesIconViewItem*> selectedItems; + for ( QIconViewItem *it = firstItem(); it; it = it->nextItem() ) { + if ( it->isSelected() ) + selectedItems.append( static_cast<KNotesIconViewItem *>( it ) ); + } + if ( selectedItems.count() != 1 ) + return KIconView::dragObject(); + + KCal::CalendarLocal cal( KPimPrefs::timezone() ); + KCal::Incidence *i = selectedItems.first()->journal()->clone(); + cal.addIncidence( i ); + KCal::ICalDrag *icd = new KCal::ICalDrag( &cal, this ); + return icd; + } +}; + + +class KNoteEditDlg : public KDialogBase, virtual public KXMLGUIClient +{ + Q_OBJECT + + public: + KNoteEditDlg( QWidget *parent = 0, const char *name = 0 ) + : KDialogBase( Plain, i18n( "Edit Note" ), Ok | Cancel, Ok, + parent, name, true, true ) + { + // this dialog is modal to prevent one from editing the same note twice in two + // different windows + + setInstance( new KInstance( "knotes" ) ); // TODO: hm, memleak?? + setXMLFile( "knotesui.rc" ); + actionCollection()->setWidget( this ); + + QWidget *page = plainPage(); + QVBoxLayout *layout = new QVBoxLayout( page ); + + QHBoxLayout *hbl = new QHBoxLayout( layout, marginHint() ); + QLabel *label = new QLabel( page); + label->setText( i18n( "Name:" ) ); + hbl->addWidget( label,0 ); + mTitleEdit= new KLineEdit( page, "name" ); + hbl->addWidget( mTitleEdit, 1,Qt::AlignVCenter ); + + mNoteEdit = new KNoteEdit( actionCollection(), page ); + mNoteEdit->setTextFormat( RichText ); + mNoteEdit->setFocus(); + + KXMLGUIBuilder builder( page ); + KXMLGUIFactory factory( &builder, this ); + factory.addClient( this ); + + mTool = static_cast<KToolBar *>(factory.container( "note_tool", this )); + + layout->addWidget( mTool ); + layout->addWidget( mNoteEdit ); + } + + QString text() const + { + return mNoteEdit->text(); + } + + void setText( const QString& text ) + { + mNoteEdit->setText( text ); + } + + QString title() const + { + return mTitleEdit->text(); + } + + void setTitle( const QString& text ) + { + mTitleEdit->setText( text ); + } + + void setRichText( bool rt ) + { + mNoteEdit->setTextFormat( rt ? RichText : PlainText ); + } + + private: + KLineEdit *mTitleEdit; + KNoteEdit *mNoteEdit; + KToolBar *mTool; + KPopupMenu *mEditMenu; +}; + + +#endif diff --git a/kontact/plugins/knotes/knotes_plugin.cpp b/kontact/plugins/knotes/knotes_plugin.cpp new file mode 100644 index 000000000..beaaa6331 --- /dev/null +++ b/kontact/plugins/knotes/knotes_plugin.cpp @@ -0,0 +1,97 @@ +/* + This file is part of Kontact + Copyright (c) 2002 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 <dcopref.h> +#include <kaboutdata.h> +#include <kaction.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <kiconloader.h> +#include <kstatusbar.h> + +#include "core.h" +#include "knotes_part.h" +#include "summarywidget.h" + +#include "knotes_plugin.h" + + +typedef KGenericFactory< KNotesPlugin, Kontact::Core > KNotesPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_knotesplugin, + KNotesPluginFactory( "kontact_knotesplugin" ) ) + + +KNotesPlugin::KNotesPlugin( Kontact::Core *core, const char *, const QStringList & ) + : Kontact::Plugin( core, core, "knotes" ), + mAboutData( 0 ) +{ + setInstance( KNotesPluginFactory::instance() ); + + insertNewAction( new KAction( i18n( "New Note..." ), "knotes", CTRL+SHIFT+Key_N, + this, SLOT( slotNewNote() ), actionCollection(), "new_note" ) ); + insertSyncAction( new KAction( i18n( "Synchronize Notes" ), "reload", 0, + this, SLOT( slotSyncNotes() ), actionCollection(), "knotes_sync" ) ); +} + +KNotesPlugin::~KNotesPlugin() +{ +} + +KParts::ReadOnlyPart* KNotesPlugin::createPart() +{ + return new KNotesPart( this, "notes" ); +} + +Kontact::Summary *KNotesPlugin::createSummaryWidget( QWidget *parentWidget ) +{ + return new KNotesSummaryWidget( this, parentWidget ); +} + +const KAboutData *KNotesPlugin::aboutData() +{ + if ( !mAboutData ) { + mAboutData = new KAboutData( "knotes", I18N_NOOP( "Notes Management" ), + "0.5", I18N_NOOP( "Notes Management" ), + KAboutData::License_GPL_V2, + "(c) 2003-2004 The Kontact developers" ); + mAboutData->addAuthor( "Michael Brade", "Current Maintainer", "brade@kde.org" ); + mAboutData->addAuthor( "Tobias Koenig", "", "tokoe@kde.org" ); + } + + return mAboutData; +} + + +// private slots + +void KNotesPlugin::slotNewNote() +{ + if ( part() ) + static_cast<KNotesPart *>( part() )->newNote(); +} + +void KNotesPlugin::slotSyncNotes() +{ + DCOPRef ref( "kmail", "KMailICalIface" ); + ref.send( "triggerSync", QString("Note") ); +} + +#include "knotes_plugin.moc" + diff --git a/kontact/plugins/knotes/knotes_plugin.h b/kontact/plugins/knotes/knotes_plugin.h new file mode 100644 index 000000000..d4d58cb03 --- /dev/null +++ b/kontact/plugins/knotes/knotes_plugin.h @@ -0,0 +1,58 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Daniel Molkentin <molkentin@kde.org> + 2004 Michael Brade <brade@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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + */ + +#ifndef KNOTES_PLUGIN_H +#define KNOTES_PLUGIN_H + +#include <klocale.h> + +#include "plugin.h" + +class KNotesPart; +class SummaryWidget; + + +class KNotesPlugin : public Kontact::Plugin +{ + Q_OBJECT + + public: + KNotesPlugin( Kontact::Core *core, const char *name, const QStringList& ); + ~KNotesPlugin(); + + virtual Kontact::Summary *createSummaryWidget( QWidget *parentWidget ); + + int weight() const { return 600; } + + const KAboutData *aboutData(); + + protected: + KParts::ReadOnlyPart* createPart(); + + private slots: + void slotNewNote(); + void slotSyncNotes(); + + private: + KAboutData *mAboutData; +}; + +#endif + diff --git a/kontact/plugins/knotes/knotesplugin.desktop b/kontact/plugins/knotes/knotesplugin.desktop new file mode 100644 index 000000000..e7fe8fc0c --- /dev/null +++ b/kontact/plugins/knotes/knotesplugin.desktop @@ -0,0 +1,95 @@ +[Desktop Entry] +Type=Service +Icon=kontact_notes +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_knotesplugin +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPluginHasSummary=true + +X-KDE-PluginInfo-Website=http://pim.kde.org/components/knotes.php +X-KDE-PluginInfo-Name=kontact_knotesplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=LGPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=Notes Component (KNotes Plugin) +Comment[bg]=Приставка за бележки +Comment[ca]=Component de notes (endollable del KNotes) +Comment[da]=Notatkomponent (KNotes-plugin) +Comment[de]=Notizen-Komponente (KNotes-Modul) +Comment[el]=Συσταικό σημειώσεων (Πρόσθετο του KNotes) +Comment[es]=Componente de notas (complemento de KNotes) +Comment[et]=Märkmete plugin (KNotes) +Comment[fr]=Composant de notes (Module KNotes) +Comment[is]=Minnismiðaeining (KNotes íforrit) +Comment[it]=Componente note (plugin KNotes) +Comment[ja]=メモコンポーネント (KNotes プラグイン) +Comment[km]=សមាសភាគចំណាំ (កម្មវិធីជំនួយ KNotes) +Comment[nds]=Notizen-Komponent (KNotes-Moduul) +Comment[nl]=Notitiecomponent (KNotes-plugin) +Comment[pl]=Składnik notatek (wtyczka KNotes) +Comment[ru]=Заметки (модуль KNotes) +Comment[sr]=Компонента белешки (прикључак KNotes-а) +Comment[sr@Latn]=Komponenta beleški (priključak KNotes-a) +Comment[sv]=Anteckningskomponent (Knotes-insticksprogram) +Comment[tr]=Notlar Bileşeni (KNotes Eklentisi) +Comment[zh_CN]=便笺组件(KNotes 插件) +Comment[zh_TW]=便條組件(KNotes 外掛程式) +Name=Notes +Name[af]=Notas +Name[ar]=الملاحظات +Name[be]=Нататкі +Name[bg]=Бележки +Name[br]=Notennoù +Name[bs]=Bilješke +Name[cs]=Poznámky +Name[cy]=Nodiadau +Name[da]=Noter +Name[de]=Notizen +Name[el]=Σημειώσεις +Name[eo]=Notoj +Name[es]=Notas +Name[et]=Märkmed +Name[eu]=Oharrak +Name[fa]=یادداشتها +Name[fi]=Muistio +Name[fy]=Notysjes +Name[ga]=Nótaí +Name[gl]=Notas +Name[he]=פתקים +Name[hi]=टीप +Name[hu]=Feljegyzések +Name[is]=Minnismiðar +Name[it]=Note +Name[ja]=メモ +Name[ka]=ჩანიშვნები +Name[kk]=Жазбалар +Name[km]=ចំណាំ +Name[lt]=Užrašai +Name[mk]=Белешки +Name[ms]=Nota +Name[nds]=Notizen +Name[ne]=टिपोट +Name[nl]=Notities +Name[nn]=Notat +Name[pl]=Notatki +Name[pt]=Notas +Name[pt_BR]=Notas +Name[ro]=Notiţe +Name[ru]=Заметки +Name[se]=Nohtat +Name[sk]=Poznámky +Name[sl]=Notice +Name[sr]=Белешке +Name[sr@Latn]=Beleške +Name[sv]=Anteckningar +Name[ta]=குறிப்புகள் +Name[tg]=Ахборот +Name[th]=บันทึกช่วยจำ +Name[tr]=Notlar +Name[uk]=Примітки +Name[uz]=Yozma xotira +Name[uz@cyrillic]=Ёзма хотира +Name[zh_CN]=便笺 +Name[zh_TW]=備忘錄 diff --git a/kontact/plugins/knotes/knotetip.cpp b/kontact/plugins/knotes/knotetip.cpp new file mode 100644 index 000000000..6e2c998d7 --- /dev/null +++ b/kontact/plugins/knotes/knotetip.cpp @@ -0,0 +1,227 @@ +/* + This file is part of the KDE project + Copyright (C) 2004 Michael Brade <brade@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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. +*/ + +#include <qtooltip.h> +#include <qlayout.h> +#include <qtextedit.h> + +#include <kapplication.h> +#include <kglobalsettings.h> + +#include "knotetip.h" +#include "knotes_part_p.h" + + +KNoteTip::KNoteTip( KIconView *parent ) + : QFrame( 0, 0, WX11BypassWM | // this will make Seli happy >:-P + WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WStyle_StaysOnTop ), + mFilter( false ), + mView( parent ), + mNoteIVI( 0 ), + mPreview( new QTextEdit( this ) ) +{ + mPreview->setReadOnly( true ); + mPreview->setHScrollBarMode( QScrollView::AlwaysOff ); + mPreview->setVScrollBarMode( QScrollView::AlwaysOff ); + + QBoxLayout *layout = new QVBoxLayout( this ); + layout->addWidget( mPreview ); + + setPalette( QToolTip::palette() ); + setMargin( 1 ); + setFrameStyle( QFrame::Plain | QFrame::Box ); + hide(); +} + +KNoteTip::~KNoteTip() +{ + delete mPreview; + mPreview = 0; +} + +void KNoteTip::setNote( KNotesIconViewItem *item ) +{ + if ( mNoteIVI == item ) + return; + + mNoteIVI = item; + + if ( !mNoteIVI ) { + killTimers(); + if ( isVisible() ) { + setFilter( false ); + hide(); + } + } else { + KCal::Journal *journal = item->journal(); + if ( journal->customProperty( "KNotes", "RichText" ) == "true" ) + mPreview->setTextFormat( Qt::RichText ); + else + mPreview->setTextFormat( Qt::PlainText ); + + QColor fg( journal->customProperty( "KNotes", "FgColor" ) ); + QColor bg( journal->customProperty( "KNotes", "BgColor" ) ); + setColor( fg, bg ); + + mPreview->setText( journal->description() ); + mPreview->zoomTo( 8 ); + mPreview->sync(); + + int w = 400; + int h = mPreview->heightForWidth( w ); + while ( w > 60 && h == mPreview->heightForWidth( w - 20 ) ) + w -= 20; + + QRect desk = KGlobalSettings::desktopGeometry( mNoteIVI->rect().center() ); + resize( w, QMIN( h, desk.height() / 2 - 20 ) ); + + hide(); + killTimers(); + setFilter( true ); + startTimer( 600 ); // delay showing the tooltip for 0.7 sec + } +} + + +// protected, virtual methods + +void KNoteTip::resizeEvent( QResizeEvent *ev ) +{ + QFrame::resizeEvent( ev ); + reposition(); +} + +void KNoteTip::timerEvent( QTimerEvent * ) +{ + killTimers(); + + if ( !isVisible() ) { + startTimer( 15000 ); // show the tooltip for 15 sec + reposition(); + show(); + } else { + setFilter( false ); + hide(); + } +} + +bool KNoteTip::eventFilter( QObject *, QEvent *e ) +{ + switch ( e->type() ) { + case QEvent::Leave: + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::KeyPress: + case QEvent::KeyRelease: + case QEvent::FocusIn: + case QEvent::FocusOut: + case QEvent::Wheel: + killTimers(); + setFilter( false ); + hide(); + default: + break; + } + + return false; +} + + +// private stuff + +void KNoteTip::setColor( const QColor &fg, const QColor &bg ) +{ + QPalette newpalette = palette(); + newpalette.setColor( QColorGroup::Background, bg ); + newpalette.setColor( QColorGroup::Foreground, fg ); + newpalette.setColor( QColorGroup::Base, bg ); // text background + newpalette.setColor( QColorGroup::Text, fg ); // text color + newpalette.setColor( QColorGroup::Button, bg ); + + // the shadow + newpalette.setColor( QColorGroup::Midlight, bg.light(110) ); + newpalette.setColor( QColorGroup::Shadow, bg.dark(116) ); + newpalette.setColor( QColorGroup::Light, bg.light(180) ); + newpalette.setColor( QColorGroup::Dark, bg.dark(108) ); + setPalette( newpalette ); + + // set the text color + mPreview->setColor( fg ); +} + + +void KNoteTip::setFilter( bool enable ) +{ + if ( enable == mFilter ) + return; + + if ( enable ) { + kapp->installEventFilter( this ); + QApplication::setGlobalMouseTracking( true ); + } else { + QApplication::setGlobalMouseTracking( false ); + kapp->removeEventFilter( this ); + } + + mFilter = enable; +} + +void KNoteTip::reposition() +{ + if ( !mNoteIVI ) + return; + + QRect rect = mNoteIVI->rect(); + QPoint off = mView->mapToGlobal( mView->contentsToViewport( QPoint( 0, 0 ) ) ); + rect.moveBy( off.x(), off.y() ); + + QPoint pos = rect.center(); + + // should the tooltip be shown to the left or to the right of the ivi? + QRect desk = KGlobalSettings::desktopGeometry( pos ); + if ( rect.center().x() + width() > desk.right() ) { + // to the left + if ( pos.x() - width() < 0 ) + pos.setX( 0 ); + else + pos.setX( pos.x() - width() ); + } + + // should the tooltip be shown above or below the ivi ? + if ( rect.bottom() + height() > desk.bottom() ) { + // above + pos.setY( rect.top() - height() ); + } else + pos.setY( rect.bottom() ); + + move( pos ); + update(); +} diff --git a/kontact/plugins/knotes/knotetip.h b/kontact/plugins/knotes/knotetip.h new file mode 100644 index 000000000..f07b75f0c --- /dev/null +++ b/kontact/plugins/knotes/knotetip.h @@ -0,0 +1,68 @@ +/* + This file is part of the KDE project + Copyright (C) 2004 Michael Brade <brade@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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of this program with any edition of + the Qt library by Trolltech AS, Norway (or with modified versions + of Qt that use the same license as Qt), and distribute linked + combinations including the two. You must obey the GNU General + Public License in all respects for all of the code used other than + Qt. If you modify this file, you may extend this exception to + your version of the file, but you are not obligated to do so. If + you do not wish to do so, delete this exception statement from + your version. +*/ + +#ifndef KNOTETIP_H +#define KNOTETIP_H + +#include <qframe.h> + +class QTextEdit; +class KIconView; +class KNotesIconViewItem; + +class KNoteTip : public QFrame +{ + public: + KNoteTip( KIconView *parent ); + ~KNoteTip(); + + void setNote( KNotesIconViewItem *item ); + + protected: + virtual bool eventFilter( QObject *, QEvent *e ); + virtual void timerEvent( QTimerEvent * ); + virtual void resizeEvent( QResizeEvent * ); + + private: + void setColor( const QColor &fg, const QColor &bg ); + void setFilter( bool enable ); + void reposition(); + + private: + bool mFilter; + + KIconView *mView; + KNotesIconViewItem *mNoteIVI; + + QTextEdit *mPreview; +}; + +#endif diff --git a/kontact/plugins/knotes/summarywidget.cpp b/kontact/plugins/knotes/summarywidget.cpp new file mode 100644 index 000000000..3045ede53 --- /dev/null +++ b/kontact/plugins/knotes/summarywidget.cpp @@ -0,0 +1,164 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 <qobject.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qtooltip.h> + +#include <dcopclient.h> +#include <dcopref.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kurllabel.h> +#include <kstandarddirs.h> + +#include <knotes/resourcenotes.h> +#include <knotes/resourcemanager.h> + +#include "core.h" +#include "plugin.h" + +#include "summarywidget.h" + +KNotesSummaryWidget::KNotesSummaryWidget( Kontact::Plugin *plugin, + QWidget *parent, const char *name ) + : Kontact::Summary( parent, name ), mLayout( 0 ), mPlugin( plugin ) +{ + QVBoxLayout *mainLayout = new QVBoxLayout( this, 3, 3 ); + + QPixmap icon = KGlobal::iconLoader()->loadIcon( "kontact_notes", + KIcon::Desktop, KIcon::SizeMedium ); + QWidget* header = createHeader( this, icon, i18n( "Notes" ) ); + mainLayout->addWidget( header ); + + mLayout = new QGridLayout( mainLayout, 7, 3, 3 ); + mLayout->setRowStretch( 6, 1 ); + + mCalendar = new KCal::CalendarLocal( QString::fromLatin1("UTC") ); + KNotesResourceManager *manager = new KNotesResourceManager(); + + QObject::connect( manager, SIGNAL( sigRegisteredNote( KCal::Journal* ) ), + this, SLOT( addNote( KCal::Journal* ) ) ); + QObject::connect( manager, SIGNAL( sigDeregisteredNote( KCal::Journal* ) ), + this, SLOT( removeNote( KCal::Journal* ) ) ); + manager->load(); + + + updateView(); +} + +void KNotesSummaryWidget::updateView() +{ + mNotes = mCalendar->journals(); + QLabel *label; + + for ( label = mLabels.first(); label; label = mLabels.next() ) + label->deleteLater(); + mLabels.clear(); + + KIconLoader loader( "knotes" ); + + int counter = 0; + QPixmap pm = loader.loadIcon( "knotes", KIcon::Small ); + + KCal::Journal::List::Iterator it; + if ( mNotes.count() ) { + for (it = mNotes.begin(); it != mNotes.end(); ++it) { + + // Fill Note Pixmap Field + label = new QLabel( this ); + label->setPixmap( pm ); + label->setMaximumWidth( label->minimumSizeHint().width() ); + label->setAlignment( AlignVCenter ); + mLayout->addWidget( label, counter, 0 ); + mLabels.append( label ); + + // File Note Summary Field + QString newtext = (*it)->summary(); + + KURLLabel *urlLabel = new KURLLabel( (*it)->uid(), newtext, this ); + urlLabel->installEventFilter( this ); + urlLabel->setTextFormat(RichText); + urlLabel->setAlignment( urlLabel->alignment() | Qt::WordBreak ); + mLayout->addWidget( urlLabel, counter, 1 ); + mLabels.append( urlLabel ); + + if ( !(*it)->description().isEmpty() ) { + QToolTip::add( urlLabel, (*it)->description().left( 80 ) ); + } + + connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ), + this, SLOT( urlClicked( const QString& ) ) ); + counter++; + } + + } else { + QLabel *noNotes = new QLabel( i18n( "No Notes Available" ), this ); + noNotes->setAlignment( AlignHCenter | AlignVCenter ); + mLayout->addWidget( noNotes, 0, 1 ); + mLabels.append( noNotes ); + } + + for ( label = mLabels.first(); label; label = mLabels.next() ) + label->show(); +} + +void KNotesSummaryWidget::urlClicked( const QString &/*uid*/ ) +{ + if ( !mPlugin->isRunningStandalone() ) + mPlugin->core()->selectPlugin( mPlugin ); + else + mPlugin->bringToForeground(); +} + +bool KNotesSummaryWidget::eventFilter( QObject *obj, QEvent* e ) +{ + if ( obj->inherits( "KURLLabel" ) ) { + KURLLabel* label = static_cast<KURLLabel*>( obj ); + if ( e->type() == QEvent::Enter ) + emit message( i18n( "Read Note: \"%1\"" ).arg( label->text() ) ); + if ( e->type() == QEvent::Leave ) + emit message( QString::null ); + } + + return Kontact::Summary::eventFilter( obj, e ); +} + +void KNotesSummaryWidget::addNote( KCal::Journal *j ) +{ + mCalendar->addJournal( j ); + updateView(); +} + +void KNotesSummaryWidget::removeNote( KCal::Journal *j ) +{ + mCalendar->deleteJournal( j ); + updateView(); +} + + +#include "summarywidget.moc" diff --git a/kontact/plugins/knotes/summarywidget.h b/kontact/plugins/knotes/summarywidget.h new file mode 100644 index 000000000..f21d829fa --- /dev/null +++ b/kontact/plugins/knotes/summarywidget.h @@ -0,0 +1,71 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 SUMMARYWIDGET_H +#define SUMMARYWIDGET_H + +#include "summary.h" + +#include <qmap.h> +#include <qptrlist.h> +#include <qwidget.h> + +#include <libkcal/resourcelocal.h> +#include <libkcal/calendarresources.h> + +class QGridLayout; +class QLabel; + +namespace Kontact { + class Plugin; +} + +class KNotesSummaryWidget : public Kontact::Summary +{ + Q_OBJECT + + public: + KNotesSummaryWidget( Kontact::Plugin *plugin, QWidget *parent, const char *name = 0 ); + + void updateSummary( bool force = false ) { Q_UNUSED( force ); updateView(); } + + protected: + virtual bool eventFilter( QObject *obj, QEvent* e ); + + protected slots: + void urlClicked( const QString& ); + void updateView(); + void addNote( KCal::Journal* ); + void removeNote( KCal::Journal* ); + + private: + KCal::CalendarLocal *mCalendar; + KCal::Journal::List mNotes; + + QGridLayout *mLayout; + + QPtrList<QLabel> mLabels; + Kontact::Plugin *mPlugin; +}; + +#endif diff --git a/kontact/plugins/korganizer/Makefile.am b/kontact/plugins/korganizer/Makefile.am new file mode 100644 index 000000000..a987e4941 --- /dev/null +++ b/kontact/plugins/korganizer/Makefile.am @@ -0,0 +1,58 @@ +# top_srcdir/korganizer is a hack, to get korganizeriface.h +INCLUDES = -I$(top_srcdir)/kontact/interfaces \ + -I$(top_srcdir)/libkdepim \ + -I$(top_srcdir)/korganizer \ + -I$(top_srcdir)/korganizer/interfaces \ + -I$(top_srcdir) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_korganizerplugin.la \ + libkontact_todoplugin.la \ + libkontact_journalplugin.la \ + kcm_korgsummary.la + +noinst_LTLIBRARIES = libcommon.la +libcommon_la_SOURCES = korg_uniqueapp.cpp + +libkontact_korganizerplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_korganizerplugin_la_LIBADD = libcommon.la \ + $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(LIB_KPARTS) \ + $(top_builddir)/korganizer/libkorganizer_calendar.la +libkontact_korganizerplugin_la_SOURCES = korganizerplugin.cpp \ + kcalendariface.stub \ + summarywidget.cpp \ + korganizeriface.stub + +korganizeriface_DIR = $(top_srcdir)/korganizer +korganizeriface_DCOPIDLNG = true + +libkontact_todoplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_todoplugin_la_LIBADD = libcommon.la \ + $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(LIB_KPARTS) \ + $(top_builddir)/korganizer/libkorganizer_calendar.la \ + $(top_builddir)/korganizer/libkorganizer.la +libkontact_todoplugin_la_SOURCES = todoplugin.cpp \ + kcalendariface.stub \ + todosummarywidget.cpp \ + korganizeriface.stub + +libkontact_journalplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_journalplugin_la_LIBADD = libcommon.la \ + $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(LIB_KPARTS) \ + $(top_builddir)/korganizer/libkorganizer_calendar.la +libkontact_journalplugin_la_SOURCES = journalplugin.cpp kcalendariface.stub + +kcm_korgsummary_la_SOURCES = kcmkorgsummary.cpp +kcm_korgsummary_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) \ + $(all_libraries) \ + -avoid-version -no-undefined +kcm_korgsummary_la_LIBADD = $(LIB_KDEUI) + +METASOURCES = AUTO + +kcalendariface_DIR = $(top_srcdir)/korganizer + +servicedir = $(kde_servicesdir)/kontact +service_DATA = korganizerplugin.desktop todoplugin.desktop journalplugin.desktop + +kde_services_DATA = kcmkorgsummary.desktop + diff --git a/kontact/plugins/korganizer/journalplugin.cpp b/kontact/plugins/korganizer/journalplugin.cpp new file mode 100644 index 000000000..178901b4c --- /dev/null +++ b/kontact/plugins/korganizer/journalplugin.cpp @@ -0,0 +1,139 @@ +/* + This file is part of Kontact. + + Copyright (c) 2004 Allen Winter <winter@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 <qwidget.h> + +#include <kapplication.h> +#include <kaction.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <kiconloader.h> +#include <kmessagebox.h> +#include <dcopclient.h> +#include <dcopref.h> + +#include "core.h" +#include "journalplugin.h" +#include "korg_uniqueapp.h" + + +typedef KGenericFactory< JournalPlugin, Kontact::Core > JournalPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_journalplugin, + JournalPluginFactory( "kontact_journalplugin" ) ) + +JournalPlugin::JournalPlugin( Kontact::Core *core, const char *, const QStringList& ) + : Kontact::Plugin( core, core, "korganizer" ), + mIface( 0 ) +{ + setInstance( JournalPluginFactory::instance() ); + instance()->iconLoader()->addAppDir("kdepim"); + + insertNewAction( new KAction( i18n( "New Journal..." ), "newjournal", + CTRL+SHIFT+Key_J, this, SLOT( slotNewJournal() ), actionCollection(), + "new_journal" ) ); + insertSyncAction( new KAction( i18n( "Synchronize Journal" ), "reload", + 0, this, SLOT( slotSyncJournal() ), actionCollection(), + "journal_sync" ) ); + + + mUniqueAppWatcher = new Kontact::UniqueAppWatcher( + new Kontact::UniqueAppHandlerFactory<KOrganizerUniqueAppHandler>(), this ); +} + +JournalPlugin::~JournalPlugin() +{ +} + +KParts::ReadOnlyPart *JournalPlugin::createPart() +{ + KParts::ReadOnlyPart *part = loadPart(); + + if ( !part ) + return 0; + + dcopClient(); // ensure that we register to DCOP as "korganizer" + mIface = new KCalendarIface_stub( dcopClient(), "kontact", "CalendarIface" ); + + return part; +} + +void JournalPlugin::select() +{ + interface()->showJournalView(); +} + +QStringList JournalPlugin::invisibleToolbarActions() const +{ + QStringList invisible; + invisible += "new_event"; + invisible += "new_todo"; + invisible += "new_journal"; + + invisible += "view_day"; + invisible += "view_list"; + invisible += "view_workweek"; + invisible += "view_week"; + invisible += "view_nextx"; + invisible += "view_month"; + invisible += "view_todo"; + return invisible; +} + +KCalendarIface_stub *JournalPlugin::interface() +{ + if ( !mIface ) { + part(); + } + Q_ASSERT( mIface ); + return mIface; +} + +void JournalPlugin::slotNewJournal() +{ + interface()->openJournalEditor( "" ); +} + +void JournalPlugin::slotSyncJournal() +{ + DCOPRef ref( "kmail", "KMailICalIface" ); + ref.send( "triggerSync", QString("Journal") ); +} + +bool JournalPlugin::createDCOPInterface( const QString& serviceType ) +{ + kdDebug(5602) << k_funcinfo << serviceType << endl; + if ( serviceType == "DCOP/Organizer" || serviceType == "DCOP/Calendar" ) { + if ( part() ) + return true; + } + + return false; +} + +bool JournalPlugin::isRunningStandalone() +{ + return mUniqueAppWatcher->isRunningStandalone(); +} + +#include "journalplugin.moc" diff --git a/kontact/plugins/korganizer/journalplugin.desktop b/kontact/plugins/korganizer/journalplugin.desktop new file mode 100644 index 000000000..8f33753ed --- /dev/null +++ b/kontact/plugins/korganizer/journalplugin.desktop @@ -0,0 +1,89 @@ +[Desktop Entry] +Type=Service +Icon=kontact_journal +ServiceTypes=Kontact/Plugin + +X-KDE-Library=libkontact_journalplugin +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPartLibraryName=libkorganizerpart +X-KDE-KontactPartExecutableName=korganizer +X-KDE-KontactPluginHasSummary=false + +X-KDE-PluginInfo-Website=http://korganizer.kde.org +X-KDE-PluginInfo-Name=kontact_journalplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=Journal Component (KOrganizer Plugin) +Comment[bg]=Приставка за KOrganizer +Comment[ca]=Component de diari (endollable del KOrganizer) +Comment[da]=Journalkomponent (KOrganizer-plugin) +Comment[de]=Journal-Komponente (KOrganizer-Modul) +Comment[el]=Συστατικό χρονικών (Πρόσθετο του KOrganizer) +Comment[es]=Componente de diario (Complemento de KOrganizer) +Comment[et]=Päevikuplugin (KOrganizer) +Comment[fr]= Composant de journal (Module KOrganizer) +Comment[is]=Dagbókareining (Journal KOrganizer íforrit) +Comment[it]=Componente diario (plugin KOrganizer) +Comment[ja]=ジャーナルコンポーネント (KOrganizer プラグイン) +Comment[km]=សមាភាគទិនានុប្បវត្តិ (កម្មវិធីជំនួយ KOrganizer) +Comment[nds]=Daagböker-Komponent (KOrganizer-Moduul) +Comment[nl]=Journaalcomponent (KOrganizer-plugin) +Comment[pl]=Składnik dziennika (wtyczka Korganizer) +Comment[ru]=Журнал (модуль KOrganizer) +Comment[sr]=Компонента дневника (прикључак KOrganizer-а) +Comment[sr@Latn]=Komponenta dnevnika (priključak KOrganizer-a) +Comment[sv]=Journalkomponent (Korganizer-insticksprogram) +Comment[tr]=Günlük Bileşeni (KOrganizer Eklentisi) +Comment[zh_CN]=日记组件(KOrganizer 插件) +Comment[zh_TW]=日誌組件(KOrganizer 外掛程式) +Name=Journal +Name[af]=Joernaal +Name[ar]=اليومية +Name[bg]=Дневник +Name[br]=Deizlevr +Name[ca]=Diari +Name[cs]=Deník +Name[cy]=Dyddlyfr +Name[el]=Χρονικό +Name[eo]=Ĵurnalo +Name[es]=Diario +Name[et]=Päevik +Name[eu]=Egunkaria +Name[fa]=نشریه +Name[fi]=Päiväkirja +Name[fy]=Journaal +Name[ga]=Iris +Name[gl]=Xornal +Name[he]=יומן +Name[hu]=Napló +Name[is]=Dagbók +Name[it]=Diario +Name[ja]=ジャーナル +Name[ka]=ჟურნალი +Name[kk]=Күнделік +Name[km]=ទិនានុប្បវត្តិ +Name[lt]=Dienynas +Name[ms]=Jurnal +Name[nb]=Dagbok +Name[nds]=Daagbook +Name[ne]=जर्नल +Name[nl]=Journaal +Name[nn]=Dagbok +Name[pl]=Dziennik +Name[pt]=Diário +Name[pt_BR]=Diário +Name[ru]=Журнал +Name[sk]=Žurnál +Name[sl]=Dnevnik +Name[sr]=Дневник +Name[sr@Latn]=Dnevnik +Name[ta]=பத்திரிகை +Name[th]=วารสาร +Name[tr]=Günlük +Name[uk]=Журнал +Name[uz]=Kundalik +Name[uz@cyrillic]=Кундалик +Name[zh_CN]=日记 +Name[zh_TW]=日誌 diff --git a/kontact/plugins/korganizer/journalplugin.h b/kontact/plugins/korganizer/journalplugin.h new file mode 100644 index 000000000..668c2b289 --- /dev/null +++ b/kontact/plugins/korganizer/journalplugin.h @@ -0,0 +1,63 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2004 Allen Winter <winter@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 KONTACT_JOURNALPLUGIN_H +#define KONTACT_JOURNALPLUGIN_H + +#include <klocale.h> +#include <kparts/part.h> + +#include "kcalendariface_stub.h" +#include "plugin.h" +#include "uniqueapphandler.h" + +class JournalPlugin : public Kontact::Plugin +{ + Q_OBJECT + public: + JournalPlugin( Kontact::Core *core, const char *name, const QStringList& ); + ~JournalPlugin(); + + virtual bool createDCOPInterface( const QString& serviceType ); + virtual bool isRunningStandalone(); + int weight() const { return 500; } + + virtual QStringList invisibleToolbarActions() const; + + void select(); + + KCalendarIface_stub *interface(); + + protected: + KParts::ReadOnlyPart *createPart(); + + private slots: + void slotNewJournal(); + void slotSyncJournal(); + + private: + KCalendarIface_stub *mIface; + Kontact::UniqueAppWatcher *mUniqueAppWatcher; +}; + +#endif diff --git a/kontact/plugins/korganizer/kcmkorgsummary.cpp b/kontact/plugins/korganizer/kcmkorgsummary.cpp new file mode 100644 index 000000000..9ab0b6838 --- /dev/null +++ b/kontact/plugins/korganizer/kcmkorgsummary.cpp @@ -0,0 +1,200 @@ +/* + This file is part of 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 <qbuttongroup.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qradiobutton.h> +#include <qspinbox.h> + +#include <kaboutdata.h> +#include <kapplication.h> +#include <kaccelmanager.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <klocale.h> + +#include "kcmkorgsummary.h" + +#include <kdepimmacros.h> + +extern "C" +{ + KDE_EXPORT KCModule *create_korgsummary( QWidget *parent, const char * ) + { + return new KCMKOrgSummary( parent, "kcmkorgsummary" ); + } +} + +KCMKOrgSummary::KCMKOrgSummary( QWidget *parent, const char *name ) + : KCModule( parent, name ) +{ + initGUI(); + + customDaysChanged( 1 ); + + connect( mCalendarGroup, SIGNAL( clicked( int ) ), SLOT( modified() ) ); + connect( mCalendarGroup, SIGNAL( clicked( int ) ), SLOT( buttonClicked( int ) ) ); + connect( mTodoGroup, SIGNAL( clicked( int ) ), SLOT( modified() ) ); + connect( mCustomDays, SIGNAL( valueChanged( int ) ), SLOT( modified() ) ); + connect( mCustomDays, SIGNAL( valueChanged( int ) ), SLOT( customDaysChanged( int ) ) ); + + KAcceleratorManager::manage( this ); + + load(); + + KAboutData *about = new KAboutData( I18N_NOOP( "kcmkorgsummary" ), + I18N_NOOP( "Schedule Configuration Dialog" ), + 0, 0, KAboutData::License_GPL, + I18N_NOOP( "(c) 2003 - 2004 Tobias Koenig" ) ); + + about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); + setAboutData( about ); +} + +void KCMKOrgSummary::modified() +{ + emit changed( true ); +} + +void KCMKOrgSummary::buttonClicked( int id ) +{ + mCustomDays->setEnabled( id == 4 ); +} + +void KCMKOrgSummary::customDaysChanged( int value ) +{ + mCustomDays->setSuffix( i18n( " day", " days", value ) ); +} + +void KCMKOrgSummary::initGUI() +{ + QVBoxLayout *layout = new QVBoxLayout( this, 0, KDialog::spacingHint() ); + + mCalendarGroup = new QButtonGroup( 0, Vertical, i18n( "Appointments" ), this ); + QVBoxLayout *boxLayout = new QVBoxLayout( mCalendarGroup->layout(), + KDialog::spacingHint() ); + + QLabel *label = new QLabel( i18n( "How many days should the calendar show at once?" ), mCalendarGroup ); + boxLayout->addWidget( label ); + + QRadioButton *button = new QRadioButton( i18n( "One day" ), mCalendarGroup ); + boxLayout->addWidget( button ); + + button = new QRadioButton( i18n( "Five days" ), mCalendarGroup ); + boxLayout->addWidget( button ); + + button = new QRadioButton( i18n( "One week" ), mCalendarGroup ); + boxLayout->addWidget( button ); + + button = new QRadioButton( i18n( "One month" ), mCalendarGroup ); + boxLayout->addWidget( button ); + + QHBoxLayout *hbox = new QHBoxLayout( boxLayout, KDialog::spacingHint() ); + + button = new QRadioButton( "", mCalendarGroup ); + hbox->addWidget( button ); + + mCustomDays = new QSpinBox( 1, 365, 1, mCalendarGroup ); + mCustomDays->setEnabled( false ); + hbox->addWidget( mCustomDays ); + + hbox->addStretch( 1 ); + + layout->addWidget( mCalendarGroup ); + + mTodoGroup = new QButtonGroup( 2, Horizontal, i18n( "To-dos" ), this ); + new QRadioButton( i18n( "Show all to-dos" ), mTodoGroup ); + new QRadioButton( i18n( "Show today's to-dos only" ), mTodoGroup ); + + layout->addWidget( mTodoGroup ); + + layout->addStretch(); +} + +void KCMKOrgSummary::load() +{ + KConfig config( "kcmkorgsummaryrc" ); + + config.setGroup( "Calendar" ); + int days = config.readNumEntry( "DaysToShow", 1 ); + if ( days == 1 ) + mCalendarGroup->setButton( 0 ); + else if ( days == 5 ) + mCalendarGroup->setButton( 1 ); + else if ( days == 7 ) + mCalendarGroup->setButton( 2 ); + else if ( days == 31 ) + mCalendarGroup->setButton( 3 ); + else { + mCalendarGroup->setButton( 4 ); + mCustomDays->setValue( days ); + mCustomDays->setEnabled( true ); + } + + config.setGroup( "Todo" ); + bool allTodos = config.readBoolEntry( "ShowAllTodos", false ); + + if ( allTodos ) + mTodoGroup->setButton( 0 ); + else + mTodoGroup->setButton( 1 ); + + emit changed( false ); +} + +void KCMKOrgSummary::save() +{ + KConfig config( "kcmkorgsummaryrc" ); + + config.setGroup( "Calendar" ); + + int days; + switch ( mCalendarGroup->selectedId() ) { + case 0: days = 1; break; + case 1: days = 5; break; + case 2: days = 7; break; + case 3: days = 31; break; + case 4: + default: days = mCustomDays->value(); break; + } + config.writeEntry( "DaysToShow", days ); + + config.setGroup( "Todo" ); + config.writeEntry( "ShowAllTodos", mTodoGroup->selectedId() == 0 ); + + config.sync(); + + emit changed( false ); +} + +void KCMKOrgSummary::defaults() +{ + mCalendarGroup->setButton( 0 ); + mTodoGroup->setButton( 1 ); + + emit changed( true ); +} + +#include "kcmkorgsummary.moc" diff --git a/kontact/plugins/korganizer/kcmkorgsummary.desktop b/kontact/plugins/korganizer/kcmkorgsummary.desktop new file mode 100644 index 000000000..2f657852e --- /dev/null +++ b/kontact/plugins/korganizer/kcmkorgsummary.desktop @@ -0,0 +1,125 @@ +[Desktop Entry] +Icon=kontact_date +Type=Service +ServiceTypes=KCModule + +X-KDE-ModuleType=Library +X-KDE-Library=korgsummary +X-KDE-FactoryName=korgsummary +X-KDE-ParentApp=kontact_korganizerplugin,kontact_todoplugin +X-KDE-ParentComponents=kontact_korganizerplugin,kontact_todoplugin +X-KDE-CfgDlgHierarchy=KontactSummary + +Name=Appointment and To-do Overview +Name[bg]=Преглед на срещи и задачи +Name[ca]=Resum de cites i tasques pendents +Name[da]=Oversigt over møder og gøremål +Name[de]=Übersicht über Termine und Aufgaben +Name[el]=Επισκόπηση ραντεβού και προς υλοποίηση εργασιών +Name[es]=Resumen de citas y tareas pendientes +Name[et]=Kohtumised ja ülesannete ülevaade +Name[fr]=Aperçu des rendez-vous et des tâches +Name[is]=Yfirlit um fundi og verkþætti +Name[it]=Panoramica appuntamenti e cose da fare +Name[ja]=約束と To-Do の要約 +Name[km]=ទិដ្ឋភាពការណាត់ និងការងារត្រូវធ្វើ +Name[nds]=Termin- un Opgaven-Översicht +Name[nl]=Overzicht van evenementen en taken +Name[pl]=Spotkania i zadania +Name[ru]=Сводка встреч и задач +Name[sr]=Преглед састанака и обавеза +Name[sr@Latn]=Pregled sastanaka i obaveza +Name[sv]=Översikt av möten och uppgifter +Name[tr]=Randevulara ve Yapılacaklara Genel Bakış +Name[zh_CN]=约会和待办概览 +Name[zh_TW]=約會與待辦事項概觀 +Comment=Appointments and To-dos Summary Setup +Comment[af]=Afsprake en te-doen opsomming opstelling +Comment[bg]=Приставка за обобщен преглед на срещите и задачите +Comment[ca]=Configuració del resum de cites i tasques pendents +Comment[cs]=Nastavení souhrnu schůzek a úkolů +Comment[da]=Indstilling af oversigt over møder og gøremål +Comment[de]=Einstellung der Übersicht über Termine und Aufgaben +Comment[el]=Ρύθμιση ραντεβού και προς υλοποίηση εργασιών +Comment[es]=Configuración del resumen de citas y de tareas pendientes +Comment[et]=Kohtumiste ja ülesannete kokkuvõtte seadistus +Comment[eu]=Hitzordu eta egitekoen laburpenen konfigurazioa +Comment[fa]=برپایی خلاصۀ قرار ملاقاتها و کارهایی که باید انجام شوند +Comment[fi]=Tapaamiset ja tehtävät -yhteenvedon asetukset +Comment[fr]=Configuration du résumé des évènements et des tâches +Comment[fy]=Oersichtsynstellings foar eveneminten en taken +Comment[gl]=Configuración de sumarios de tarefas e notas +Comment[hu]=A találkozók és feladatok áttekintőjének beállítása +Comment[is]=Uppsetning á yfirliti yfir fundi og verkefni +Comment[it]=Impostazioni sommario appuntamenti e cose da fare +Comment[ja]=約束と To-Do の要約設定 +Comment[ka]=შეხვედრათა და გასაკეთებელთა რეზიუმეს დაყენება +Comment[kk]=Кездесулер мен Жоспарлар тұжырымының баптау +Comment[km]=រៀបចំសេចក្ដីសង្ខេបការណាត់ និងការងារត្រូវធ្វើ +Comment[lt]=Susitikimų ir užduočių santraukos nustatymai +Comment[mk]=Поставување на преглед за состаноци и задачи +Comment[nb]=Oppsett av sammendraget av gjøremål og avtaler +Comment[nds]=Termin- un Opgaven-Översicht instellen +Comment[ne]=भेटघाट र गर्नुपर्ने कार्यहरूको सारांश सेटअप +Comment[nl]=Overzichtsinstellingen voor evenementen en taken +Comment[nn]=Oppsett av samandrag av avtalar og oppgåver +Comment[pl]=Ustawienia podsumowania spotkań i zadań +Comment[pt]=Configuração do Sumário de Compromissos e A-fazeres +Comment[pt_BR]=Configuração do Resumo de Compromissos e Tarefas +Comment[ru]=Настройка сводки встреч и задач +Comment[sk]=Nastavenie súhrnu pripomienok a úloh +Comment[sl]=Nastavitve povzetka sestankov in opravil +Comment[sr]=Подешавање сажетка састанака и обавеза +Comment[sr@Latn]=Podešavanje sažetka sastanaka i obaveza +Comment[sv]=Inställning av översikt av möten och uppgifter +Comment[tr]=Özel Günler ve Yapılacaklar Listesi Yapılandırması +Comment[uk]=Налаштування зведення зустрічей і завдань +Comment[zh_CN]=约会和待办摘要设置 +Comment[zh_TW]=約會與待辦事項摘要設定 +Keywords=calendar, todos, configure, settings +Keywords[af]=calendar,todos,configure,settings +Keywords[be]=каляндар, заданні, настроіць, настаўленні, calendar, todos, configure, settings +Keywords[bg]=календар, задачи, организатор, calendar, todos, configure, settings +Keywords[bs]=calendar, todos, configure, settings, kalendar, zadaci, postavke +Keywords[ca]=calendari, pendents, configuració, arranjament +Keywords[cs]=kalendář,úkoly,nastavit,nastavení +Keywords[da]=kalender, gøremål, indstil, opsætning +Keywords[de]=Kalender,Aufgaben,einstellen,Einstellungen,Einrichten +Keywords[el]=ημερολόγιο, προς υλοποίηση, ρύθμιση, ρυθμίσεις +Keywords[es]=calendario, tareas pendientes, configurar, opciones +Keywords[et]=kalender, ülesanded, seadistamine, seadistused +Keywords[eu]=egutegia, egitekoak, konfiguratu, ezarpenak +Keywords[fa]=تقویم، کارهای انجامی، پیکربندی، تنظیمات +Keywords[fi]=kalenteri, tehtävät, muokkaa, asetukset +Keywords[fr]=calendrier,agenda,tâches,configurer,paramètres,paramètre +Keywords[fy]=kalinder,aginda,taken,todo,ynstellings,konfiguraasje +Keywords[ga]=féilire, tascanna, cumraigh, socruithe +Keywords[gl]=calendario, pendentes, configurar, opcións +Keywords[he]=calendar, todos, configure, settings, יומן, יומנים, משימות, מטלות, הגדרות, תצורה +Keywords[hu]=naptár,feladatok,konfigurálás,beállítások +Keywords[is]=dagatal, verkefni, stillingar, stilla +Keywords[it]=calendario, cose da fare, configura, impostazioni +Keywords[ja]=カレンダー, To-Do, 設定 +Keywords[ka]=კალენდარი,გასაკეთებლები,კონფიგურაცია,პარამეტრები +Keywords[km]=ប្រតិទិន,ការងារត្រូវធ្វើ,កំណត់រចនាសម្ព័ន្ធ,ការកំណត់ +Keywords[lt]=calendar, todos, configure, settings, kalendorius, darbai, konfigūruoti, nustatymai +Keywords[ms]=kalendar, tugasan, konfigur, seting +Keywords[nb]=kalender, gjørelister, oppsett, innstillinger +Keywords[nds]=Kalenner,Opgaven,Opgaav,instellen,Mööt,Möten +Keywords[ne]=क्यालेन्डर, गर्नुपर्ने कार्यहरू, कन्फिगर, सेटिङ +Keywords[nl]=kalender,agenda,taken,todo,instellingen,configuratie +Keywords[nn]=kalender,hugselister,oppsett,innstillingar +Keywords[pl]=kalendarz,do zrobienia,konfiguracja,ustawienia +Keywords[pt]=calendário, a fazer, configurar, configuração +Keywords[pt_BR]=calendário, pendências, configurar, configurações +Keywords[ru]=calendar,todos,configure,settings,настройка,календарь,задачи +Keywords[sk]=kalendár,úlohy,nastavenie +Keywords[sl]=koledar,za narediti,nastavitve,nastavi +Keywords[sr]=calendar, todos, configure, settings, календар, послови, подеси, поставке +Keywords[sr@Latn]=calendar, todos, configure, settings, kalendar, poslovi, podesi, postavke +Keywords[sv]=kalender, uppgifter, anpassa, inställningar +Keywords[ta]=நாள்காட்டி,செய்யவேண்டியவைகள்,கட்டமைப்பு,அமைவுகள் +Keywords[tg]=calendar, todos, configure, settings,танзимот, тақвим,вазифа +Keywords[tr]=takvim, yapılacaklar, yapılandır, yapılandırma +Keywords[uk]=календар, завдання, налаштування, параметри +Keywords[zh_CN]=calendar, todos, configure, settings, 日历, 待办事项, 配置, 设置 diff --git a/kontact/plugins/korganizer/kcmkorgsummary.h b/kontact/plugins/korganizer/kcmkorgsummary.h new file mode 100644 index 000000000..cf484e56d --- /dev/null +++ b/kontact/plugins/korganizer/kcmkorgsummary.h @@ -0,0 +1,56 @@ +/* + This file is part of 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 KCMKORGSUMMARY_H +#define KCMKORGSUMMARY_H + +#include <kcmodule.h> + +class QSpinxBox; +class QButtonGroup; + +class KCMKOrgSummary : public KCModule +{ + Q_OBJECT + + public: + KCMKOrgSummary( QWidget *parent = 0, const char *name = 0 ); + + virtual void load(); + virtual void save(); + virtual void defaults(); + + private slots: + void modified(); + void buttonClicked( int ); + void customDaysChanged( int ); + + private: + void initGUI(); + + QButtonGroup *mCalendarGroup; + QButtonGroup *mTodoGroup; + QSpinBox *mCustomDays; +}; + +#endif diff --git a/kontact/plugins/korganizer/korg_uniqueapp.cpp b/kontact/plugins/korganizer/korg_uniqueapp.cpp new file mode 100644 index 000000000..b70042353 --- /dev/null +++ b/kontact/plugins/korganizer/korg_uniqueapp.cpp @@ -0,0 +1,38 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2003 David Faure <faure@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 "korg_uniqueapp.h" +#include <kdebug.h> +#include "../../korganizer/korganizer_options.h" + +void KOrganizerUniqueAppHandler::loadCommandLineOptions() +{ + KCmdLineArgs::addCmdLineOptions( korganizer_options ); +} + +int KOrganizerUniqueAppHandler::newInstance() +{ + //kdDebug(5602) << k_funcinfo << endl; + // Ensure part is loaded + (void)plugin()->part(); + // TODO handle command line options + return Kontact::UniqueAppHandler::newInstance(); +} diff --git a/kontact/plugins/korganizer/korg_uniqueapp.h b/kontact/plugins/korganizer/korg_uniqueapp.h new file mode 100644 index 000000000..d21f8c526 --- /dev/null +++ b/kontact/plugins/korganizer/korg_uniqueapp.h @@ -0,0 +1,37 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2003 David Faure <faure@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 KORG_UNIQUEAPP_H +#define KORG_UNIQUEAPP_H + +#include <uniqueapphandler.h> + +class KOrganizerUniqueAppHandler : public Kontact::UniqueAppHandler +{ +public: + KOrganizerUniqueAppHandler( Kontact::Plugin* plugin ) : Kontact::UniqueAppHandler( plugin ) {} + virtual void loadCommandLineOptions(); + virtual int newInstance(); +}; + + +#endif /* KORG_UNIQUEAPP_H */ + diff --git a/kontact/plugins/korganizer/korganizerplugin.cpp b/kontact/plugins/korganizer/korganizerplugin.cpp new file mode 100644 index 000000000..7aef2e6e0 --- /dev/null +++ b/kontact/plugins/korganizer/korganizerplugin.cpp @@ -0,0 +1,227 @@ +/* + This file is part of Kontact. + + Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@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 <qcursor.h> +#include <qfile.h> +#include <qwidget.h> +#include <qdragobject.h> + +#include <kapplication.h> +#include <kabc/vcardconverter.h> +#include <kaction.h> +#include <dcopref.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <kiconloader.h> +#include <kmessagebox.h> +#include <kstandarddirs.h> +#include <ktempfile.h> + +#include <dcopclient.h> + +#include <libkdepim/kvcarddrag.h> +#include <libkdepim/maillistdrag.h> + +#include "core.h" +#include "summarywidget.h" +#include "korganizerplugin.h" +#include "korg_uniqueapp.h" + +typedef KGenericFactory< KOrganizerPlugin, Kontact::Core > KOrganizerPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_korganizerplugin, + KOrganizerPluginFactory( "kontact_korganizerplugin" ) ) + +KOrganizerPlugin::KOrganizerPlugin( Kontact::Core *core, const char *, const QStringList& ) + : Kontact::Plugin( core, core, "korganizer" ), + mIface( 0 ) +{ + + setInstance( KOrganizerPluginFactory::instance() ); + instance()->iconLoader()->addAppDir("kdepim"); + + insertNewAction( new KAction( i18n( "New Event..." ), "newappointment", + CTRL+SHIFT+Key_E, this, SLOT( slotNewEvent() ), actionCollection(), + "new_event" ) ); + + insertSyncAction( new KAction( i18n( "Synchronize Calendar" ), "reload", + 0, this, SLOT( slotSyncEvents() ), actionCollection(), + "korganizer_sync" ) ); + + mUniqueAppWatcher = new Kontact::UniqueAppWatcher( + new Kontact::UniqueAppHandlerFactory<KOrganizerUniqueAppHandler>(), this ); +} + +KOrganizerPlugin::~KOrganizerPlugin() +{ +} + +Kontact::Summary *KOrganizerPlugin::createSummaryWidget( QWidget *parent ) +{ + return new SummaryWidget( this, parent ); +} + +KParts::ReadOnlyPart *KOrganizerPlugin::createPart() +{ + KParts::ReadOnlyPart *part = loadPart(); + + if ( !part ) + return 0; + + mIface = new KCalendarIface_stub( dcopClient(), "kontact", "CalendarIface" ); + + return part; +} + +QString KOrganizerPlugin::tipFile() const +{ + QString file = ::locate("data", "korganizer/tips"); + return file; +} + +QStringList KOrganizerPlugin::invisibleToolbarActions() const +{ + QStringList invisible; + invisible += "new_event"; + invisible += "new_todo"; + invisible += "new_journal"; + + invisible += "view_todo"; + invisible += "view_journal"; + return invisible; +} + +void KOrganizerPlugin::select() +{ + interface()->showEventView(); +} + +KCalendarIface_stub *KOrganizerPlugin::interface() +{ + if ( !mIface ) { + part(); + } + Q_ASSERT( mIface ); + return mIface; +} + +void KOrganizerPlugin::slotNewEvent() +{ + interface()->openEventEditor( "" ); +} + +void KOrganizerPlugin::slotSyncEvents() +{ + DCOPRef ref( "kmail", "KMailICalIface" ); + ref.send( "triggerSync", QString("Calendar") ); +} + +bool KOrganizerPlugin::createDCOPInterface( const QString& serviceType ) +{ + kdDebug(5602) << k_funcinfo << serviceType << endl; + if ( serviceType == "DCOP/Organizer" || serviceType == "DCOP/Calendar" ) { + if ( part() ) + return true; + } + + return false; +} + +bool KOrganizerPlugin::isRunningStandalone() +{ + return mUniqueAppWatcher->isRunningStandalone(); +} + +bool KOrganizerPlugin::canDecodeDrag( QMimeSource *mimeSource ) +{ + return QTextDrag::canDecode( mimeSource ) || + KPIM::MailListDrag::canDecode( mimeSource ); +} + +void KOrganizerPlugin::processDropEvent( QDropEvent *event ) +{ + QString text; + + KABC::VCardConverter converter; + if ( KVCardDrag::canDecode( event ) && KVCardDrag::decode( event, text ) ) { + KABC::Addressee::List contacts = converter.parseVCards( text ); + KABC::Addressee::List::Iterator it; + + QStringList attendees; + for ( it = contacts.begin(); it != contacts.end(); ++it ) { + QString email = (*it).fullEmail(); + if ( email.isEmpty() ) + attendees.append( (*it).realName() + "<>" ); + else + attendees.append( email ); + } + + interface()->openEventEditor( i18n( "Meeting" ), QString::null, QString::null, + attendees ); + return; + } + + if ( QTextDrag::decode( event, text ) ) { + kdDebug(5602) << "DROP:" << text << endl; + interface()->openEventEditor( text ); + return; + } + + KPIM::MailList mails; + if ( KPIM::MailListDrag::decode( event, mails ) ) { + if ( mails.count() != 1 ) { + KMessageBox::sorry( core(), + i18n("Drops of multiple mails are not supported." ) ); + } else { + KPIM::MailSummary mail = mails.first(); + QString txt = i18n("From: %1\nTo: %2\nSubject: %3").arg( mail.from() ) + .arg( mail.to() ).arg( mail.subject() ); + + KTempFile tf; + tf.setAutoDelete( true ); + QString uri = QString::fromLatin1("kmail:") + QString::number( mail.serialNumber() ); + tf.file()->writeBlock( event->encodedData( "message/rfc822" ) ); + tf.close(); + interface()->openEventEditor( i18n("Mail: %1").arg( mail.subject() ), txt, + uri, tf.name(), QStringList(), "message/rfc822" ); + } + return; + } + + KMessageBox::sorry( core(), i18n("Cannot handle drop events of type '%1'.") + .arg( event->format() ) ); +} + +void KOrganizerPlugin::loadProfile( const QString& directory ) +{ + DCOPRef ref( "korganizer", "KOrganizerIface" ); + ref.send( "loadProfile", directory ); +} + +void KOrganizerPlugin::saveToProfile( const QString& directory ) const +{ + DCOPRef ref( "korganizer", "KOrganizerIface" ); + ref.send( "saveToProfile", directory ); +} + +#include "korganizerplugin.moc" diff --git a/kontact/plugins/korganizer/korganizerplugin.desktop b/kontact/plugins/korganizer/korganizerplugin.desktop new file mode 100644 index 000000000..7a29913c1 --- /dev/null +++ b/kontact/plugins/korganizer/korganizerplugin.desktop @@ -0,0 +1,101 @@ +[Desktop Entry] +Type=Service +Icon=kontact_date +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_korganizerplugin +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPartLibraryName=libkorganizerpart +X-KDE-KontactPartExecutableName=korganizer +X-KDE-KontactPluginHasSummary=true + +X-KDE-PluginInfo-Website=http://korganizer.kde.org +X-KDE-PluginInfo-Name=kontact_korganizerplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=Calendar Component (KOrganizer Plugin) +Comment[bg]=Приставка за KOrganizer +Comment[ca]=Component de calendari (endollable del KOrganizer) +Comment[da]=Kalenderkomponent (KOrganizer-plugin) +Comment[de]=Kalender-Komponente (KOrganizer-Modul) +Comment[el]=Συστατικό ημερολογίου (Πρόσθετο του KOrganizer) +Comment[es]=Componente de calendario (complemento de KOrganizer) +Comment[et]=Kalendriplugin (KOrganizer) +Comment[fr]= Composant de calendrier (Module KOrganizer) +Comment[is]=Dagatalseining (KOrganizer íforrit) +Comment[it]=Componente calendario (plugin KOrganizer) +Comment[ja]=カレンダーコンポーネント (KOrganizer プラグイン) +Comment[km]=សមាសភាគប្រតិទិន (កម្មវិធីជំនួយ KOrganizer) +Comment[nds]=Kalenner-Komponent (KOrganizer-Moduul) +Comment[nl]=Agendacomponent (KOrganizer-plugin) +Comment[pl]=Składnik kalendarza (wtyczka KOrganizer) +Comment[ru]=Календарь (модуль KOrganizer) +Comment[sk]=Kalendárový komponent (Modeul pre KOrganizer) +Comment[sr]=Компонента календара (прикључак KOrganizer-а) +Comment[sr@Latn]=Komponenta kalendara (priključak KOrganizer-a) +Comment[sv]=Kalenderkomponent (Korganizer-insticksprogram) +Comment[tr]=Takvim Bileşeni (KOrganizer Eklentisi) +Comment[zh_CN]=日历组件(KOrganizer 插件) +Comment[zh_TW]=行事曆組件(KOrganizer 外掛程式) +Name=Calendar +Name[af]=Kalender +Name[ar]=التقويم +Name[be]=Каляндар +Name[bg]=Календар +Name[br]=Deiziadur +Name[bs]=Kalendar +Name[ca]=Calendari +Name[cs]=Kalendář +Name[cy]=Calendr +Name[da]=Kalender +Name[de]=Kalender +Name[el]=Ημερολόγιο +Name[eo]=Kalendaro +Name[es]=Calendario +Name[et]=Kalender +Name[eu]=Egutegia +Name[fa]=تقویم +Name[fi]=Kalenteri +Name[fr]=Calendrier +Name[fy]=Aginda +Name[ga]=Féilire +Name[gl]=Calendario +Name[he]=לוח שנה +Name[hi]=कैलेन्डर +Name[hu]=Naptár +Name[is]=Dagatal +Name[it]=Calendario +Name[ja]=カレンダー +Name[ka]=კალენდარი +Name[kk]=Күнтізбе +Name[km]=ប្រតិទិន +Name[lt]=Kalendorius +Name[mk]=Календар +Name[ms]=Kalendar +Name[nb]=Kalender +Name[nds]=Kalenner +Name[ne]=क्यालेन्डर +Name[nl]=Agenda +Name[nn]=Kalender +Name[pa]=ਕੈਲੰਡਰ +Name[pl]=Kalendarz +Name[pt]=Calendário +Name[pt_BR]=Calendário +Name[ru]=Календарь +Name[se]=Kaleandar +Name[sk]=Kalendár +Name[sl]=Koledar +Name[sr]=Календар +Name[sr@Latn]=Kalendar +Name[sv]=Kalender +Name[ta]=நாள்காட்டி +Name[tg]=Тақвим +Name[th]=บันทึกประจำวัน +Name[tr]=Takvim +Name[uk]=Календар +Name[uz]=Kalendar +Name[uz@cyrillic]=Календар +Name[zh_CN]=日历 +Name[zh_TW]=行事曆 diff --git a/kontact/plugins/korganizer/korganizerplugin.h b/kontact/plugins/korganizer/korganizerplugin.h new file mode 100644 index 000000000..df8259961 --- /dev/null +++ b/kontact/plugins/korganizer/korganizerplugin.h @@ -0,0 +1,75 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@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 KORGANIZER_PLUGIN_H +#define KORGANIZER_PLUGIN_H + +#include <klocale.h> +#include <kparts/part.h> + +#include "kcalendariface_stub.h" +#include "plugin.h" +#include "uniqueapphandler.h" + +class KOrganizerPlugin : public Kontact::Plugin +{ + Q_OBJECT + + public: + KOrganizerPlugin( Kontact::Core *core, const char *name, const QStringList& ); + ~KOrganizerPlugin(); + + virtual bool createDCOPInterface( const QString& serviceType ); + virtual bool isRunningStandalone(); + int weight() const { return 400; } + + bool canDecodeDrag( QMimeSource * ); + void processDropEvent( QDropEvent * ); + + virtual Kontact::Summary *createSummaryWidget( QWidget *parent ); + + virtual QString tipFile() const; + virtual QStringList invisibleToolbarActions() const; + + void select(); + + KCalendarIface_stub *interface(); + + + void loadProfile( const QString& path ); + void saveToProfile( const QString& path ) const; + + protected: + KParts::ReadOnlyPart *createPart(); + + private slots: + void slotNewEvent(); + void slotSyncEvents(); + + private: + KCalendarIface_stub *mIface; + Kontact::UniqueAppWatcher *mUniqueAppWatcher; +}; + +#endif diff --git a/kontact/plugins/korganizer/summarywidget.cpp b/kontact/plugins/korganizer/summarywidget.cpp new file mode 100644 index 000000000..68742248f --- /dev/null +++ b/kontact/plugins/korganizer/summarywidget.cpp @@ -0,0 +1,313 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 <qcursor.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qtooltip.h> + +#include <kdialog.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kparts/part.h> +#include <kpopupmenu.h> +#include <kstandarddirs.h> +#include <kurllabel.h> +#include <libkcal/event.h> +#include <libkcal/resourcecalendar.h> +#include <libkcal/resourcelocal.h> +#include <libkcal/incidenceformatter.h> +#include <libkdepim/kpimprefs.h> + +#include "korganizeriface_stub.h" + +#include "core.h" +#include "plugin.h" +#include "korganizerplugin.h" + +#include "korganizer/stdcalendar.h" + +#include "summarywidget.h" + +SummaryWidget::SummaryWidget( KOrganizerPlugin *plugin, QWidget *parent, + const char *name ) + : Kontact::Summary( parent, name ), mPlugin( plugin ), mCalendar( 0 ) +{ + QVBoxLayout *mainLayout = new QVBoxLayout( this, 3, 3 ); + + QPixmap icon = KGlobal::iconLoader()->loadIcon( "kontact_date", + KIcon::Desktop, KIcon::SizeMedium ); + QWidget *header = createHeader( this, icon, i18n( "Calendar" ) ); + mainLayout->addWidget( header ); + + mLayout = new QGridLayout( mainLayout, 7, 5, 3 ); + mLayout->setRowStretch( 6, 1 ); + + mCalendar = KOrg::StdCalendar::self(); + mCalendar->load(); + + connect( mCalendar, SIGNAL( calendarChanged() ), SLOT( updateView() ) ); + connect( mPlugin->core(), SIGNAL( dayChanged( const QDate& ) ), + SLOT( updateView() ) ); + + updateView(); +} + +SummaryWidget::~SummaryWidget() +{ +} + +void SummaryWidget::updateView() +{ + mLabels.setAutoDelete( true ); + mLabels.clear(); + mLabels.setAutoDelete( false ); + + KIconLoader loader( "kdepim" ); + + KConfig config( "kcmkorgsummaryrc" ); + + config.setGroup( "Calendar" ); + int days = config.readNumEntry( "DaysToShow", 1 ); + + QLabel *label = 0; + int counter = 0; + QPixmap pm = loader.loadIcon( "appointment", KIcon::Small ); + + QDate dt; + QDate currentDate = QDate::currentDate(); + for ( dt=currentDate; + dt<=currentDate.addDays( days - 1 ); + dt=dt.addDays(1) ) { + + KCal::Event *ev; + + KCal::Event::List events_orig = mCalendar->events( dt ); + KCal::Event::List::ConstIterator it = events_orig.begin(); + + KCal::Event::List events; + events.setAutoDelete( true ); + QDateTime qdt; + + // prevent implicitely sharing while finding recurring events + // replacing the QDate with the currentDate + for ( ; it != events_orig.end(); ++it ) { + ev = (*it)->clone(); + if ( ev->recursOn( dt ) ) { + qdt = ev->dtStart(); + qdt.setDate( dt ); + ev->setDtStart( qdt ); + } + events.append( ev ); + } + + // sort the events for this date by summary + events = KCal::Calendar::sortEvents( &events, + KCal::EventSortSummary, + KCal::SortDirectionAscending ); + // sort the events for this date by start date + events = KCal::Calendar::sortEvents( &events, + KCal::EventSortStartDate, + KCal::SortDirectionAscending ); + + for ( it=events.begin(); it!=events.end(); ++it ) { + ev = *it; + + // Count number of days remaining in multiday event + int span=1; int dayof=1; + if ( ev->isMultiDay() ) { + QDate d = ev->dtStart().date(); + if ( d < currentDate ) { + d = currentDate; + } + while ( d < ev->dtEnd().date() ) { + if ( d < dt ) { + dayof++; + } + span++; + d=d.addDays( 1 ); + } + } + + // If this date is part of a floating, multiday event, then we + // only make a print for the first day of the event. + if ( ev->isMultiDay() && ev->doesFloat() && dayof != 1 ) continue; + + // Fill Appointment Pixmap Field + label = new QLabel( this ); + label->setPixmap( pm ); + label->setMaximumWidth( label->minimumSizeHint().width() ); + label->setAlignment( AlignVCenter ); + mLayout->addWidget( label, counter, 0 ); + mLabels.append( label ); + + // Fill Event Date Field + bool makeBold = false; + QString datestr; + + // Modify event date for printing + QDate sD = QDate::QDate( dt.year(), dt.month(), dt.day() ); + if ( ( sD.month() == currentDate.month() ) && + ( sD.day() == currentDate.day() ) ) { + datestr = i18n( "Today" ); + makeBold = true; + } else if ( ( sD.month() == currentDate.addDays( 1 ).month() ) && + ( sD.day() == currentDate.addDays( 1 ).day() ) ) { + datestr = i18n( "Tomorrow" ); + } else { + datestr = KGlobal::locale()->formatDate( sD ); + } + + // Print the date span for multiday, floating events, for the + // first day of the event only. + if ( ev->isMultiDay() && ev->doesFloat() && dayof == 1 && span > 1 ) { + datestr = KGlobal::locale()->formatDate( ev->dtStart().date() ); + datestr += " -\n " + + KGlobal::locale()->formatDate( sD.addDays( span-1 ) ); + } + + label = new QLabel( datestr, this ); + label->setAlignment( AlignLeft | AlignVCenter ); + if ( makeBold ) { + QFont font = label->font(); + font.setBold( true ); + label->setFont( font ); + } + mLayout->addWidget( label, counter, 1 ); + mLabels.append( label ); + + // Fill Event Summary Field + QString newtext = ev->summary(); + if ( ev->isMultiDay() && !ev->doesFloat() ) { + newtext.append( QString(" (%1/%2)").arg( dayof ).arg( span ) ); + } + + KURLLabel *urlLabel = new KURLLabel( this ); + urlLabel->setText( newtext ); + urlLabel->setURL( ev->uid() ); + urlLabel->installEventFilter( this ); + urlLabel->setAlignment( urlLabel->alignment() | Qt::WordBreak ); + mLayout->addWidget( urlLabel, counter, 2 ); + mLabels.append( urlLabel ); + + connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ), + this, SLOT( viewEvent( const QString& ) ) ); + connect( urlLabel, SIGNAL( rightClickedURL( const QString& ) ), + this, SLOT( popupMenu( const QString& ) ) ); + + QString tipText( KCal::IncidenceFormatter::toolTipString( ev, true ) ); + if ( !tipText.isEmpty() ) { + QToolTip::add( urlLabel, tipText ); + } + + // Fill Event Time Range Field (only for non-floating Events) + if ( !ev->doesFloat() ) { + QTime sST = ev->dtStart().time(); + QTime sET = ev->dtEnd().time(); + if ( ev->isMultiDay() ) { + if ( ev->dtStart().date() < dt ) { + sST = QTime::QTime( 0, 0 ); + } + if ( ev->dtEnd().date() > dt ) { + sET = QTime::QTime( 23, 59 ); + } + } + datestr = i18n( "Time from - to", "%1 - %2" ) + .arg( KGlobal::locale()->formatTime( sST ) ) + .arg( KGlobal::locale()->formatTime( sET ) ); + label = new QLabel( datestr, this ); + label->setAlignment( AlignLeft | AlignVCenter ); + mLayout->addWidget( label, counter, 3 ); + mLabels.append( label ); + } + + counter++; + } + } + + if ( !counter ) { + QLabel *noEvents = new QLabel( + i18n( "No appointments pending within the next day", + "No appointments pending within the next %n days", + days ), this, "nothing to see" ); + noEvents->setAlignment( AlignHCenter | AlignVCenter ); + mLayout->addWidget( noEvents, 0, 2 ); + mLabels.append( noEvents ); + } + + for ( label = mLabels.first(); label; label = mLabels.next() ) + label->show(); +} + +void SummaryWidget::viewEvent( const QString &uid ) +{ + mPlugin->core()->selectPlugin( "kontact_korganizerplugin" ); //ensure loaded + KOrganizerIface_stub iface( "korganizer", "KOrganizerIface" ); + iface.editIncidence( uid ); +} + +void SummaryWidget::removeEvent( const QString &uid ) +{ + mPlugin->core()->selectPlugin( "kontact_korganizerplugin" ); //ensure loaded + KOrganizerIface_stub iface( "korganizer", "KOrganizerIface" ); + iface.deleteIncidence( uid, false ); +} + +void SummaryWidget::popupMenu( const QString &uid ) +{ + KPopupMenu popup( this ); + QToolTip::remove( this ); + popup.insertItem( i18n( "&Edit Appointment..." ), 0 ); + popup.insertItem( KGlobal::iconLoader()->loadIcon( "editdelete", KIcon::Small), + i18n( "&Delete Appointment" ), 1 ); + + switch ( popup.exec( QCursor::pos() ) ) { + case 0: + viewEvent( uid ); + break; + case 1: + removeEvent( uid ); + break; + } +} + +bool SummaryWidget::eventFilter( QObject *obj, QEvent* e ) +{ + if ( obj->inherits( "KURLLabel" ) ) { + KURLLabel* label = static_cast<KURLLabel*>( obj ); + if ( e->type() == QEvent::Enter ) + emit message( i18n( "Edit Appointment: \"%1\"" ).arg( label->text() ) ); + if ( e->type() == QEvent::Leave ) + emit message( QString::null ); + } + + return Kontact::Summary::eventFilter( obj, e ); +} + +QStringList SummaryWidget::configModules() const +{ + return QStringList( "kcmkorgsummary.desktop" ); +} + +#include "summarywidget.moc" diff --git a/kontact/plugins/korganizer/summarywidget.h b/kontact/plugins/korganizer/summarywidget.h new file mode 100644 index 000000000..c9c572eca --- /dev/null +++ b/kontact/plugins/korganizer/summarywidget.h @@ -0,0 +1,70 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 SUMMARYWIDGET_H +#define SUMMARYWIDGET_H + +#include <qptrlist.h> +#include <qwidget.h> + +#include <libkcal/calendarresources.h> + +#include "summary.h" + +class QGridLayout; +class QLabel; + +class KOrganizerPlugin; + +class SummaryWidget : public Kontact::Summary +{ + Q_OBJECT + + public: + SummaryWidget( KOrganizerPlugin *plugin, QWidget *parent, + const char *name = 0 ); + ~SummaryWidget(); + + int summaryHeight() const { return 3; } + QStringList configModules() const; + public slots: + void updateSummary( bool force = false ) { Q_UNUSED( force ); updateView(); } + + protected: + virtual bool eventFilter( QObject *obj, QEvent* e ); + + private slots: + void updateView(); + void popupMenu( const QString &uid ); + void viewEvent( const QString &uid ); + void removeEvent( const QString &uid ); + + private: + KOrganizerPlugin *mPlugin; + QGridLayout *mLayout; + + QPtrList<QLabel> mLabels; + KCal::CalendarResources *mCalendar; +}; + +#endif diff --git a/kontact/plugins/korganizer/todoplugin.cpp b/kontact/plugins/korganizer/todoplugin.cpp new file mode 100644 index 000000000..4cb281b84 --- /dev/null +++ b/kontact/plugins/korganizer/todoplugin.cpp @@ -0,0 +1,230 @@ +/* + This file is part of Kontact. + + Copyright (c) 2003 Cornelius Schumacher <schumacher@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 <qwidget.h> +#include <qdragobject.h> +#include <qfile.h> + +#include <kapplication.h> +#include <kabc/vcardconverter.h> +#include <kaction.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <kiconloader.h> +#include <kmessagebox.h> +#include <dcopclient.h> +#include <dcopref.h> +#include <ktempfile.h> + +#include <libkcal/calendarlocal.h> +#include <libkcal/icaldrag.h> + +#include <libkdepim/maillistdrag.h> +#include <libkdepim/kvcarddrag.h> +#include <libkdepim/kpimprefs.h> + +#include "core.h" + +#include "todoplugin.h" +#include "todosummarywidget.h" +#include "korg_uniqueapp.h" + +typedef KGenericFactory< TodoPlugin, Kontact::Core > TodoPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_todoplugin, + TodoPluginFactory( "kontact_todoplugin" ) ) + +TodoPlugin::TodoPlugin( Kontact::Core *core, const char *, const QStringList& ) + : Kontact::Plugin( core, core, "korganizer" ), + mIface( 0 ) +{ + setInstance( TodoPluginFactory::instance() ); + instance()->iconLoader()->addAppDir("kdepim"); + + insertNewAction( new KAction( i18n( "New To-do..." ), "newtodo", + CTRL+SHIFT+Key_T, this, SLOT( slotNewTodo() ), actionCollection(), + "new_todo" ) ); + + insertSyncAction( new KAction( i18n( "Synchronize To-do List" ), "reload", + 0, this, SLOT( slotSyncTodos() ), actionCollection(), + "todo_sync" ) ); + + mUniqueAppWatcher = new Kontact::UniqueAppWatcher( + new Kontact::UniqueAppHandlerFactory<KOrganizerUniqueAppHandler>(), this ); +} + +TodoPlugin::~TodoPlugin() +{ +} + +Kontact::Summary *TodoPlugin::createSummaryWidget( QWidget *parent ) +{ + return new TodoSummaryWidget( this, parent ); +} + +KParts::ReadOnlyPart *TodoPlugin::createPart() +{ + KParts::ReadOnlyPart *part = loadPart(); + + if ( !part ) + return 0; + + dcopClient(); // ensure that we register to DCOP as "korganizer" + mIface = new KCalendarIface_stub( dcopClient(), "kontact", "CalendarIface" ); + + return part; +} + +void TodoPlugin::select() +{ + interface()->showTodoView(); +} + +QStringList TodoPlugin::invisibleToolbarActions() const +{ + QStringList invisible; + invisible += "new_event"; + invisible += "new_todo"; + invisible += "new_journal"; + + invisible += "view_day"; + invisible += "view_list"; + invisible += "view_workweek"; + invisible += "view_week"; + invisible += "view_nextx"; + invisible += "view_month"; + invisible += "view_journal"; + return invisible; +} + +KCalendarIface_stub *TodoPlugin::interface() +{ + if ( !mIface ) { + part(); + } + Q_ASSERT( mIface ); + return mIface; +} + +void TodoPlugin::slotNewTodo() +{ + interface()->openTodoEditor( "" ); +} + +void TodoPlugin::slotSyncTodos() +{ + DCOPRef ref( "kmail", "KMailICalIface" ); + ref.send( "triggerSync", QString("Todo") ); +} + +bool TodoPlugin::createDCOPInterface( const QString& serviceType ) +{ + kdDebug(5602) << k_funcinfo << serviceType << endl; + if ( serviceType == "DCOP/Organizer" || serviceType == "DCOP/Calendar" ) { + if ( part() ) + return true; + } + + return false; +} + +bool TodoPlugin::canDecodeDrag( QMimeSource *mimeSource ) +{ + return QTextDrag::canDecode( mimeSource ) || + KPIM::MailListDrag::canDecode( mimeSource ); +} + +bool TodoPlugin::isRunningStandalone() +{ + return mUniqueAppWatcher->isRunningStandalone(); +} + +void TodoPlugin::processDropEvent( QDropEvent *event ) +{ + QString text; + + KABC::VCardConverter converter; + if ( KVCardDrag::canDecode( event ) && KVCardDrag::decode( event, text ) ) { + KABC::Addressee::List contacts = converter.parseVCards( text ); + KABC::Addressee::List::Iterator it; + + QStringList attendees; + for ( it = contacts.begin(); it != contacts.end(); ++it ) { + QString email = (*it).fullEmail(); + if ( email.isEmpty() ) + attendees.append( (*it).realName() + "<>" ); + else + attendees.append( email ); + } + + interface()->openTodoEditor( i18n( "Meeting" ), QString::null, QString::null, + attendees ); + return; + } + + if ( KCal::ICalDrag::canDecode( event) ) { + KCal::CalendarLocal cal( KPimPrefs::timezone() ); + if ( KCal::ICalDrag::decode( event, &cal ) ) { + KCal::Journal::List journals = cal.journals(); + if ( !journals.isEmpty() ) { + event->accept(); + KCal::Journal *j = journals.first(); + interface()->openTodoEditor( i18n("Note: %1").arg( j->summary() ), j->description(), QString() ); + return; + } + // else fall through to text decoding + } + } + + if ( QTextDrag::decode( event, text ) ) { + interface()->openTodoEditor( text ); + return; + } + + KPIM::MailList mails; + if ( KPIM::MailListDrag::decode( event, mails ) ) { + if ( mails.count() != 1 ) { + KMessageBox::sorry( core(), + i18n("Drops of multiple mails are not supported." ) ); + } else { + KPIM::MailSummary mail = mails.first(); + QString txt = i18n("From: %1\nTo: %2\nSubject: %3").arg( mail.from() ) + .arg( mail.to() ).arg( mail.subject() ); + + KTempFile tf; + tf.setAutoDelete( true ); + QString uri = "kmail:" + QString::number( mail.serialNumber() ) + "/" + + mail.messageId(); + tf.file()->writeBlock( event->encodedData( "message/rfc822" ) ); + tf.close(); + interface()->openTodoEditor( i18n("Mail: %1").arg( mail.subject() ), txt, + uri, tf.name(), QStringList(), "message/rfc822" ); + } + return; + } + + KMessageBox::sorry( core(), i18n("Cannot handle drop events of type '%1'.") + .arg( event->format() ) ); +} + +#include "todoplugin.moc" diff --git a/kontact/plugins/korganizer/todoplugin.desktop b/kontact/plugins/korganizer/todoplugin.desktop new file mode 100644 index 000000000..a571539d8 --- /dev/null +++ b/kontact/plugins/korganizer/todoplugin.desktop @@ -0,0 +1,65 @@ +[Desktop Entry] +Type=Service +Icon=kontact_todo +ServiceTypes=Kontact/Plugin + +X-KDE-Library=libkontact_todoplugin +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPartLibraryName=libkorganizerpart +X-KDE-KontactPartExecutableName=korganizer +X-KDE-KontactPluginHasSummary=true + +X-KDE-PluginInfo-Website=http://korganizer.kde.org +X-KDE-PluginInfo-Name=kontact_todoplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=To-do List Component (KOrganizer plugin) +Comment[bg]=Приставка за KOrganizer +Comment[ca]=Component de llista de pendents (endollable del KOrganizer) +Comment[da]=Komponent til gøremålsliste (KOrganizer-plugin) +Comment[de]=Aufgabenlisten-Komponente (KOrganizer-Modul) +Comment[el]=Συστατικό λίστα προς υλοποίηση εργασιών (Πρόσθετο του KOrganizer) +Comment[es]=Componente de tareas pendientes (complemento de KOrganizer) +Comment[et]=Ülesannete nimekirja plugin (KOrganizer) +Comment[fr]=Composant de la liste des tâches (Module KOrganizer) +Comment[is]=Verkefnaeining (KOrganizer íforrit) +Comment[it]=Componente elenco delle cose da fare (plugin KOrganizer) +Comment[ja]=To-Do リストコンポーネント (KOrganizer プラグイン) +Comment[km]=សមាសភាគបញ្ជីការងារត្រូវធ្វើ (កម្មវិធីជំនួយ KOrganizer) +Comment[nds]=Opgavenlist-Komponent (KOrganizer-Moduul) +Comment[nl]=Takenlijstcomponent (KOrganizer-plugin) +Comment[pl]=Składnik zadań (wtyczka KOrganizer) +Comment[ru]=Задачи (модуль KOrganizer) +Comment[sk]=Komponent zoznamu úloh (Modul pre KOrganizer) +Comment[sr]=Прикључак листе обавеза (прикључак KOrganizer-а) +Comment[sr@Latn]=Priključak liste obaveza (priključak KOrganizer-a) +Comment[sv]=Uppgiftslistkomponent (Korganizer-insticksprogram) +Comment[tr]=Yapılacak İşler Bileşeni (KOrganizer eklentisi) +Comment[zh_CN]=待办清单组件(KOrganizer 插件) +Comment[zh_TW]=待辦事項清單組件(KOrganizer 外掛程式) +Name=To-do +Name[bg]=Задачи +Name[ca]=Pendents +Name[da]=Gøremål +Name[de]=Aufgaben +Name[el]=Προς υλοποίηση εργασίες +Name[es]=Tareas pendientes +Name[et]=Ülesanded +Name[fr]=Tâches +Name[is]=Verkefni +Name[it]=Cose da fare +Name[ja]=To-Do +Name[km]=ការងារត្រូវធ្វើ +Name[nds]=Opgaav +Name[nl]=Takenlijst +Name[pl]=Lista zadań +Name[ru]=Задачи +Name[sk]=Zoznam úloh +Name[sr]=Обавезе +Name[sr@Latn]=Obaveze +Name[sv]=Uppgift +Name[tr]=Yapılacak Ögeleri +Name[zh_CN]=待办清单 +Name[zh_TW]=待辦事項 diff --git a/kontact/plugins/korganizer/todoplugin.h b/kontact/plugins/korganizer/todoplugin.h new file mode 100644 index 000000000..ce0cb5823 --- /dev/null +++ b/kontact/plugins/korganizer/todoplugin.h @@ -0,0 +1,68 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2003 Cornelius Schumacher <schumacher@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 KONTACT_TODOPLUGIN_H +#define KONTACT_TODOPLUGIN_H + +#include <klocale.h> +#include <kparts/part.h> + +#include "kcalendariface_stub.h" +#include "plugin.h" +#include "uniqueapphandler.h" + +class TodoPlugin : public Kontact::Plugin +{ + Q_OBJECT + public: + TodoPlugin( Kontact::Core *core, const char *name, const QStringList& ); + ~TodoPlugin(); + + virtual bool createDCOPInterface( const QString& serviceType ); + virtual bool isRunningStandalone(); + int weight() const { return 450; } + + bool canDecodeDrag( QMimeSource * ); + void processDropEvent( QDropEvent * ); + + virtual QStringList invisibleToolbarActions() const; + + virtual Kontact::Summary *createSummaryWidget( QWidget *parent ); + + void select(); + + KCalendarIface_stub *interface(); + + protected: + KParts::ReadOnlyPart *createPart(); + + private slots: + void slotNewTodo(); + void slotSyncTodos(); + + private: + KCalendarIface_stub *mIface; + Kontact::UniqueAppWatcher *mUniqueAppWatcher; +}; + +#endif diff --git a/kontact/plugins/korganizer/todosummarywidget.cpp b/kontact/plugins/korganizer/todosummarywidget.cpp new file mode 100644 index 000000000..d52941ee4 --- /dev/null +++ b/kontact/plugins/korganizer/todosummarywidget.cpp @@ -0,0 +1,270 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 <qcursor.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qtooltip.h> + +#include <kdialog.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kparts/part.h> +#include <kpopupmenu.h> +#include <kstandarddirs.h> +#include <kurllabel.h> +#include <libkcal/resourcecalendar.h> +#include <libkcal/resourcelocal.h> +#include <libkcal/todo.h> +#include <libkcal/incidenceformatter.h> +#include <libkdepim/kpimprefs.h> + +#include "korganizeriface_stub.h" + +#include "core.h" +#include "plugin.h" +#include "todoplugin.h" + +#include "korganizer/stdcalendar.h" +#include "korganizer/koglobals.h" +#include "korganizer/incidencechanger.h" + +#include "todosummarywidget.h" + +TodoSummaryWidget::TodoSummaryWidget( TodoPlugin *plugin, + QWidget *parent, const char *name ) + : Kontact::Summary( parent, name ), mPlugin( plugin ) +{ + QVBoxLayout *mainLayout = new QVBoxLayout( this, 3, 3 ); + + QPixmap icon = KGlobal::iconLoader()->loadIcon( "kontact_todo", + KIcon::Desktop, KIcon::SizeMedium ); + QWidget *header = createHeader( this, icon, i18n( "To-do" ) ); + mainLayout->addWidget( header ); + + mLayout = new QGridLayout( mainLayout, 7, 4, 3 ); + mLayout->setRowStretch( 6, 1 ); + + mCalendar = KOrg::StdCalendar::self(); + mCalendar->load(); + + connect( mCalendar, SIGNAL( calendarChanged() ), SLOT( updateView() ) ); + connect( mPlugin->core(), SIGNAL( dayChanged( const QDate& ) ), + SLOT( updateView() ) ); + + updateView(); +} + +TodoSummaryWidget::~TodoSummaryWidget() +{ +} + +void TodoSummaryWidget::updateView() +{ + mLabels.setAutoDelete( true ); + mLabels.clear(); + mLabels.setAutoDelete( false ); + + KConfig config( "kcmkorgsummaryrc" ); + config.setGroup( "Todo" ); + bool showAllTodos = config.readBoolEntry( "ShowAllTodos", false ); + + KIconLoader loader( "kdepim" ); + + QLabel *label = 0; + int counter = 0; + + QDate currentDate = QDate::currentDate(); + KCal::Todo::List todos = mCalendar->todos(); + if ( todos.count() > 0 ) { + QPixmap pm = loader.loadIcon( "todo", KIcon::Small ); + KCal::Todo::List::ConstIterator it; + for ( it = todos.begin(); it != todos.end(); ++it ) { + KCal::Todo *todo = *it; + + bool accepted = false; + QString stateText; + + // show all incomplete todos + if ( showAllTodos && !todo->isCompleted()) + accepted = true; + + // show uncomplete todos from the last days + if ( todo->hasDueDate() && !todo->isCompleted() && + todo->dtDue().date() < currentDate ) { + accepted = true; + stateText = i18n( "overdue" ); + } + + // show todos which started somewhere in the past and has to be finished in future + if ( todo->hasStartDate() && todo->hasDueDate() && + todo->dtStart().date() < currentDate && + currentDate < todo->dtDue().date() ) { + accepted = true; + stateText = i18n( "in progress" ); + } + + // all todos which start today + if ( todo->hasStartDate() && todo->dtStart().date() == currentDate ) { + accepted = true; + stateText = i18n( "starts today" ); + } + + // all todos which end today + if ( todo->hasDueDate() && todo->dtDue().date() == currentDate ) { + accepted = true; + stateText = i18n( "ends today" ); + } + + if ( !accepted ) + continue; + + label = new QLabel( this ); + label->setPixmap( pm ); + label->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ); + mLayout->addWidget( label, counter, 0 ); + mLabels.append( label ); + + label = new QLabel( QString::number( todo->percentComplete() ) + "%", this ); + label->setAlignment( AlignHCenter | AlignVCenter ); + label->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ); + mLayout->addWidget( label, counter, 1 ); + mLabels.append( label ); + + QString sSummary = todo->summary(); + if ( todo->relatedTo() ) { // show parent only, not entire ancestry + sSummary = todo->relatedTo()->summary() + ":" + todo->summary(); + } + KURLLabel *urlLabel = new KURLLabel( this ); + urlLabel->setText( sSummary ); + urlLabel->setURL( todo->uid() ); + urlLabel->installEventFilter( this ); + urlLabel->setTextFormat( Qt::RichText ); + mLayout->addWidget( urlLabel, counter, 2 ); + mLabels.append( urlLabel ); + + connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ), + this, SLOT( viewTodo( const QString& ) ) ); + connect( urlLabel, SIGNAL( rightClickedURL( const QString& ) ), + this, SLOT( popupMenu( const QString& ) ) ); + + QString tipText( KCal::IncidenceFormatter::toolTipString( todo, true ) ); + if ( !tipText.isEmpty() ) { + QToolTip::add( urlLabel, tipText ); + } + + label = new QLabel( stateText, this ); + label->setAlignment( AlignLeft | AlignVCenter ); + label->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ); + mLayout->addWidget( label, counter, 3 ); + mLabels.append( label ); + + counter++; + } + } + + if ( counter == 0 ) { + QLabel *noTodos = new QLabel( i18n( "No to-dos pending" ), this ); + noTodos->setAlignment( AlignHCenter | AlignVCenter ); + mLayout->addWidget( noTodos, 0, 1 ); + mLabels.append( noTodos ); + } + + for ( label = mLabels.first(); label; label = mLabels.next() ) + label->show(); +} + +void TodoSummaryWidget::viewTodo( const QString &uid ) +{ + mPlugin->core()->selectPlugin( "kontact_todoplugin" );//ensure loaded + KOrganizerIface_stub iface( "korganizer", "KOrganizerIface" ); + iface.editIncidence( uid ); +} + +void TodoSummaryWidget::removeTodo( const QString &uid ) +{ + mPlugin->core()->selectPlugin( "kontact_todoplugin" );//ensure loaded + KOrganizerIface_stub iface( "korganizer", "KOrganizerIface" ); + iface.deleteIncidence( uid, false ); +} + +void TodoSummaryWidget::completeTodo( const QString &uid ) +{ + KCal::Todo *todo = mCalendar->todo( uid ); + IncidenceChanger *changer = new IncidenceChanger( mCalendar, this ); + if ( !todo->isReadOnly() && changer->beginChange( todo ) ) { + KCal::Todo *oldTodo = todo->clone(); + todo->setCompleted( QDateTime::currentDateTime() ); + changer->changeIncidence( oldTodo, todo, KOGlobals::COMPLETION_MODIFIED ); + changer->endChange( todo ); + delete oldTodo; + updateView(); + } +} + +void TodoSummaryWidget::popupMenu( const QString &uid ) +{ + KPopupMenu popup( this ); + QToolTip::remove( this ); + popup.insertItem( i18n( "&Edit To-do..." ), 0 ); + popup.insertItem( KGlobal::iconLoader()->loadIcon( "editdelete", KIcon::Small), + i18n( "&Delete To-do" ), 1 ); + KCal::Todo *todo = mCalendar->todo( uid ); + if ( !todo->isCompleted() ) { + popup.insertItem( KGlobal::iconLoader()->loadIcon( "checkedbox", KIcon::Small), + i18n( "&Mark To-do Completed" ), 2 ); + } + + switch ( popup.exec( QCursor::pos() ) ) { + case 0: + viewTodo( uid ); + break; + case 1: + removeTodo( uid ); + break; + case 2: + completeTodo( uid ); + break; + } +} + +bool TodoSummaryWidget::eventFilter( QObject *obj, QEvent* e ) +{ + if ( obj->inherits( "KURLLabel" ) ) { + KURLLabel* label = static_cast<KURLLabel*>( obj ); + if ( e->type() == QEvent::Enter ) + emit message( i18n( "Edit To-do: \"%1\"" ).arg( label->text() ) ); + if ( e->type() == QEvent::Leave ) + emit message( QString::null ); + } + + return Kontact::Summary::eventFilter( obj, e ); +} + +QStringList TodoSummaryWidget::configModules() const +{ + return QStringList( "kcmtodosummary.desktop" ); +} + +#include "todosummarywidget.moc" diff --git a/kontact/plugins/korganizer/todosummarywidget.h b/kontact/plugins/korganizer/todosummarywidget.h new file mode 100644 index 000000000..d5aca429e --- /dev/null +++ b/kontact/plugins/korganizer/todosummarywidget.h @@ -0,0 +1,72 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 TODO_SUMMARYWIDGET_H +#define TODO_SUMMARYWIDGET_H + +#include <qptrlist.h> +#include <qwidget.h> + +#include <libkcal/calendarresources.h> + +#include "summary.h" + +class QGridLayout; +class QLabel; + +class TodoPlugin; + +class TodoSummaryWidget : public Kontact::Summary +{ + Q_OBJECT + + public: + TodoSummaryWidget( TodoPlugin *plugin, QWidget *parent, + const char *name = 0 ); + ~TodoSummaryWidget(); + + int summaryHeight() const { return 3; } + QStringList configModules() const; + + public slots: + void updateSummary( bool force = false ) { Q_UNUSED( force ); updateView(); } + + protected: + virtual bool eventFilter( QObject *obj, QEvent* e ); + + private slots: + void updateView(); + void popupMenu( const QString &uid ); + void viewTodo( const QString &uid ); + void removeTodo( const QString &uid ); + void completeTodo( const QString &uid ); + + private: + TodoPlugin *mPlugin; + QGridLayout *mLayout; + + QPtrList<QLabel> mLabels; + KCal::CalendarResources *mCalendar; +}; + +#endif diff --git a/kontact/plugins/kpilot/Makefile.am b/kontact/plugins/kpilot/Makefile.am new file mode 100644 index 000000000..2383a4fbd --- /dev/null +++ b/kontact/plugins/kpilot/Makefile.am @@ -0,0 +1,24 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces \ + -I$(top_srcdir)/libkdepim \ + -I$(top_srcdir) \ + -I$(top_srcdir)/kpilot/lib \ + -I$(top_srcdir)/kpilot/kpilot \ + $(PISOCK_INCLUDE) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_kpilotplugin.la +libkontact_kpilotplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_kpilotplugin_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la \ + $(LIB_KPARTS) \ + $(top_builddir)/libkdepim/libkdepim.la \ + $(top_builddir)/kpilot/lib/libkpilot.la + +libkontact_kpilotplugin_la_SOURCES = kpilot_plugin.cpp summarywidget.cpp \ + summarywidget.skel pilotDaemonDCOP.stub + +pilotDaemonDCOP_DIR = $(top_srcdir)/kpilot/kpilot +pilotDaemonDCOP_DCOPIDLNG = true + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir)/kontact +service_DATA = kpilotplugin.desktop diff --git a/kontact/plugins/kpilot/kpilot_plugin.cpp b/kontact/plugins/kpilot/kpilot_plugin.cpp new file mode 100644 index 000000000..ed6104bd4 --- /dev/null +++ b/kontact/plugins/kpilot/kpilot_plugin.cpp @@ -0,0 +1,69 @@ +/* + This file is part of Kontact. + Copyright (C) 2003 Tobias Koenig <tokoe@kde.org> + Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> + + 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 "options.h" + +#include <kaboutdata.h> +#include <kgenericfactory.h> +#include <kparts/componentfactory.h> + +#include "core.h" +#include "summarywidget.h" + +#include "kpilot_plugin.h" + +typedef KGenericFactory< KPilotPlugin, Kontact::Core > KPilotPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_kpilotplugin, + KPilotPluginFactory( "kontact_kpilotplugin" ) ) + +KPilotPlugin::KPilotPlugin( Kontact::Core *core, const char *name, const QStringList& ) + : Kontact::Plugin( core, core, "kpilot" ), mAboutData( 0 ) +{ + setInstance( KPilotPluginFactory::instance() ); + // TODO: Make sure kpilotDaemon is running! + + +} + +Kontact::Summary *KPilotPlugin::createSummaryWidget( QWidget *parentWidget ) +{ + return new SummaryWidget( parentWidget ); +} + +const KAboutData *KPilotPlugin::aboutData() +{ + if ( !mAboutData ) { + mAboutData = new KAboutData("kpilotplugin", I18N_NOOP("KPilot Information"), + KPILOT_VERSION, + I18N_NOOP("KPilot - HotSync software for KDE\n\n"), + KAboutData::License_GPL, "(c) 2004 Reinhold Kainhofer"); + mAboutData->addAuthor("Reinhold Kainhofer", + I18N_NOOP("Plugin Developer"), "reinhold@kainhofer.com", "http://reinhold.kainhofer.com/Linux/"); + mAboutData->addAuthor("Dan Pilone", + I18N_NOOP("Project Leader"), + 0, "http://www.kpilot.org/"); + mAboutData->addAuthor("Adriaan de Groot", + I18N_NOOP("Maintainer"), + "groot@kde.org", "http://people.fruitsalad.org/adridg/"); + } + + return mAboutData; +} diff --git a/kontact/plugins/kpilot/kpilot_plugin.h b/kontact/plugins/kpilot/kpilot_plugin.h new file mode 100644 index 000000000..9b76bd644 --- /dev/null +++ b/kontact/plugins/kpilot/kpilot_plugin.h @@ -0,0 +1,49 @@ +/* + This file is part of Kontact. + Copyright (C) 2003 Tobias Koenig <tokoe@kde.org> + Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> + + 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 KPilot_PLUGIN_H +#define KPilot_PLUGIN_H + +#include "plugin.h" +#include "pilotDaemonDCOP_stub.h" + +class SummaryWidget; + +class KPilotPlugin : public Kontact::Plugin +{ + public: + KPilotPlugin( Kontact::Core *core, const char *name, const QStringList& ); + KPilotPlugin(); + + virtual Kontact::Summary *createSummaryWidget( QWidget *parentWidget ); + + virtual bool showInSideBar() const { return false; } +// virtual QStringList configModules() const; + + const KAboutData *aboutData(); + + protected: + virtual KParts::ReadOnlyPart *createPart() { return 0; } + private: + KAboutData *mAboutData; +}; + +#endif diff --git a/kontact/plugins/kpilot/kpilotplugin.desktop b/kontact/plugins/kpilot/kpilotplugin.desktop new file mode 100644 index 000000000..7ad217fd9 --- /dev/null +++ b/kontact/plugins/kpilot/kpilotplugin.desktop @@ -0,0 +1,44 @@ +[Desktop Entry] +Type=Service +Icon=kpilot +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_kpilotplugin +X-KDE-KontactIdentifier=kpilot +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPluginHasSummary=true +X-KDE-KontactPluginHasPart=false + +X-KDE-PluginInfo-Website=http://www.slac.com/~pilone/kpilot_home/ +X-KDE-PluginInfo-Name=kontact_kpilotplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=Palm Tools Component (KPilot Plugin) +Comment[bg]=Приставка за KPilot +Comment[ca]=Component d'eines de la Palm (endollable del KPilot) +Comment[da]=Komponent til palm-værktøjer (KPilot-plugin) +Comment[de]=Palm-Komponente (KPilot-Modul) +Comment[el]=Συστατικό εργαλείων Palm (Πρόσθετο του KPilot) +Comment[es]=Componente de herramientas de Palm (complemento KPilot) +Comment[et]=Palmi tööriistade plugin (KPilot) +Comment[fr]=Composant d'outils pour Palms (Module KPilot) +Comment[is]=Palm verkfæraeining (KPilot íforrit) +Comment[it]=Componente strumenti Palm (plugin KPilot) +Comment[ja]=Palm ツールコンポーネント (KPilot プラグイン) +Comment[km]=សមាសភាគឧបករណ៍ Palm (កម្មវិធីជំនួយ KPilot) +Comment[nds]=Palmreekner-Warktüüchkomponent (KPilot-Moduul) +Comment[nl]=Component met hulpmiddelen voor PalmOS(tm)-apparaten (KPilot-plugin) +Comment[pl]=Składnik narzędzi Palma (wtyczka KPilot) +Comment[ru]=Синхронизация с Palm (модуль KPilot) +Comment[sr]=Компонента алата за Palm (прикључак KPilot-а) +Comment[sr@Latn]=Komponenta alata za Palm (priključak KPilot-a) +Comment[sv]=Palm Pilot-verktygskomponent (Kpilot-insticksprogram) +Comment[tr]=Palm Araçları Bileşeni (KPilot Eklentisi) +Comment[zh_CN]=Palm 工具组件(KPilot 插件) +Comment[zh_TW]=Palm 工具組件(KPilot 外掛程式) +Name=Palm +Name[nds]=Palmreekner +Name[nl]=PalmOS(tm)-apparaat +Name[sv]=Palm Pilot diff --git a/kontact/plugins/kpilot/summarywidget.cpp b/kontact/plugins/kpilot/summarywidget.cpp new file mode 100644 index 000000000..4230e6479 --- /dev/null +++ b/kontact/plugins/kpilot/summarywidget.cpp @@ -0,0 +1,242 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> + Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> + + 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 <qimage.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qtooltip.h> +#include <qfile.h> +#include <qlabel.h> +#include <qtextedit.h> +#include <qvbox.h> + +#include <dcopclient.h> +#include <dcopref.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kglobalsettings.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kurllabel.h> +#include <kdialogbase.h> +#include <kmessagebox.h> + +#include "pilotDaemonDCOP_stub.h" + +#include <ktextedit.h> + +#include "summarywidget.h" + +SummaryWidget::SummaryWidget( QWidget *parent, const char *name ) + : Kontact::Summary( parent, name ), + DCOPObject( "KPilotSummaryWidget" ), + mDCOPSuccess( false ), + mStartedDaemon( false ), + mShouldStopDaemon( true ) +{ + mLayout = new QGridLayout( this, 2, 3, 3, 3 ); + + int row=0; + QPixmap icon = KGlobal::iconLoader()->loadIcon( "kpilot", KIcon::Desktop, KIcon::SizeMedium ); + QWidget *header = createHeader( this, icon, i18n( "KPilot Configuration" ) ); + mLayout->addMultiCellWidget( header, row,row, 0,3 ); + + // Last sync information + row++; + mSyncTimeTextLabel = new QLabel( i18n( "<i>Last sync:</i>" ), this); + mLayout->addWidget( mSyncTimeTextLabel, row, 0 ); + mSyncTimeLabel = new QLabel( i18n( "No information available" ), this ); + mLayout->addWidget( mSyncTimeLabel, row, 1 ); + mShowSyncLogLabel = new KURLLabel( "", i18n( "[View Sync Log]" ), this ); + mLayout->addWidget( mShowSyncLogLabel, row, 3 ); + connect( mShowSyncLogLabel, SIGNAL( leftClickedURL( const QString& ) ), + this, SLOT( showSyncLog( const QString& ) ) ); + + // User + row++; + mPilotUserTextLabel = new QLabel( i18n( "<i>User:</i>" ), this); + mLayout->addWidget( mPilotUserTextLabel, row, 0); + mPilotUserLabel = new QLabel( i18n( "Unknown" ), this ); + mLayout->addMultiCellWidget( mPilotUserLabel, row, row, 1, 3 ); + + // Device information + row++; + mPilotDeviceTextLabel = new QLabel( i18n( "<i>Device:</i>" ), this); + mLayout->addWidget( mPilotDeviceTextLabel, row, 0 ); + mPilotDeviceLabel = new QLabel( i18n( "Unknown" ), this ); + mLayout->addMultiCellWidget( mPilotDeviceLabel, row, row, 1, 3 ); + + // Status + row++; + mDaemonStatusTextLabel = new QLabel( i18n( "<i>Status:</i>" ), this); + mLayout->addWidget( mDaemonStatusTextLabel, row, 0 ); + mDaemonStatusLabel = new QLabel( i18n( "No communication with the daemon possible" ), this ); + mLayout->addMultiCellWidget( mDaemonStatusLabel, row, row, 1, 3 ); + + // Conduits: + row++; + mConduitsTextLabel = new QLabel( i18n( "<i>Conduits:</i>" ), this ); + mConduitsTextLabel->setAlignment( AlignAuto | AlignTop | ExpandTabs ); + mLayout->addWidget( mConduitsTextLabel, row, 0 ); + mConduitsLabel = new QLabel( i18n( "No information available" ), this ); + mConduitsLabel->setAlignment( mConduitsLabel->alignment() | Qt::WordBreak ); + mLayout->addMultiCellWidget( mConduitsLabel, row, row, 1, 3 ); + + // widgets shown if kpilotDaemon is not running + row++; + mNoConnectionLabel = new QLabel( i18n( "KPilot is currently not running." ), this ); + mLayout->addMultiCellWidget( mNoConnectionLabel, row, row, 1, 2 ); + mNoConnectionStartLabel = new KURLLabel( "", i18n( "[Start KPilot]" ), this ); + mLayout->addWidget( mNoConnectionStartLabel, row, 3 ); + connect( mNoConnectionStartLabel, SIGNAL( leftClickedURL( const QString& ) ), + this, SLOT( startKPilot() ) ); + + if ( !kapp->dcopClient()->isApplicationRegistered( "kpilotDaemon" ) ) { + startKPilot(); + } + + connectDCOPSignal( 0, 0, "kpilotDaemonStatusDetails(QDateTime,QString,QStringList,QString,QString,QString,bool)", + "receiveDaemonStatusDetails(QDateTime,QString,QStringList,QString,QString,QString,bool)", false ); + connect( kapp->dcopClient(), SIGNAL( applicationRemoved( const QCString & ) ), SLOT( slotAppRemoved( const QCString& ) ) ); +} + +SummaryWidget::~SummaryWidget() +{ + if ( mStartedDaemon && mShouldStopDaemon ) { + PilotDaemonDCOP_stub dcopToDaemon( "kpilotDaemon", "KPilotDaemonIface" ); + dcopToDaemon.quitNow(); // ASYNC, always succeeds. + } +} + +QStringList SummaryWidget::configModules() const +{ + QStringList modules; + modules << "kpilot_config.desktop"; + return modules; +} + +void SummaryWidget::receiveDaemonStatusDetails(QDateTime lastSyncTime, QString status, QStringList conduits, QString logFileName, QString userName, QString pilotDevice, bool killOnExit ) +{ + mDCOPSuccess = true; + mLastSyncTime = lastSyncTime; + mDaemonStatus = status; + mConduits = conduits; + mSyncLog = logFileName; + mUserName = userName; + mPilotDevice = pilotDevice; + mShouldStopDaemon = killOnExit; + updateView(); +} + +void SummaryWidget::updateView() +{ + if ( mDCOPSuccess ) { + if ( mLastSyncTime.isValid() ) { + mSyncTimeLabel->setText( mLastSyncTime.toString(Qt::LocalDate) ); + } else { + mSyncTimeLabel->setText( i18n( "No information available" ) ); + } + if ( !mSyncLog.isEmpty() ) { + mShowSyncLogLabel->setEnabled( true ); + mShowSyncLogLabel->setURL( mSyncLog ); + } else { + mShowSyncLogLabel->setEnabled( false ); + } + mPilotUserLabel->setText( mUserName.isEmpty() ? i18n( "unknown" ) : mUserName ); + mPilotDeviceLabel->setText( mPilotDevice.isEmpty() ? i18n( "unknown" ) : mPilotDevice ); + mDaemonStatusLabel->setText( mDaemonStatus ); + mConduitsLabel->setText( mConduits.join( ", " ) ); + } else { + mSyncTimeLabel->setText( i18n( "No information available (Daemon not running?)" ) ); + mShowSyncLogLabel->setEnabled( false ); + mPilotUserLabel->setText( i18n( "unknown" ) ); + mPilotDeviceLabel->setText( i18n( "unknown" ) ); + mDaemonStatusLabel->setText( i18n( "No communication with the daemon possible" ) ); + mConduitsLabel->setText( i18n( "No information available" ) ); + } + + mSyncTimeTextLabel->setShown( mDCOPSuccess ); + mSyncTimeLabel->setShown( mDCOPSuccess ); + mShowSyncLogLabel->setShown( mDCOPSuccess ); + mPilotUserTextLabel->setShown( mDCOPSuccess ); + mPilotUserLabel->setShown( mDCOPSuccess ); + mPilotDeviceTextLabel->setShown( mDCOPSuccess ); + mPilotDeviceLabel->setShown( mDCOPSuccess ); + mDaemonStatusTextLabel->setShown( mDCOPSuccess ); + mDaemonStatusLabel->setShown( mDCOPSuccess ); + mConduitsTextLabel->setShown( mDCOPSuccess ); + mConduitsLabel->setShown( mDCOPSuccess ); + mNoConnectionLabel->setShown( !mDCOPSuccess ); + mNoConnectionStartLabel->setShown( !mDCOPSuccess ); +} + +void SummaryWidget::showSyncLog( const QString &filename ) +{ + KDialogBase dlg( this, 0, true, QString::null, KDialogBase::Ok, KDialogBase::Ok ); + dlg.setCaption( i18n( "KPilot HotSync Log" ) ); + + QTextEdit *edit = new QTextEdit( dlg.makeVBoxMainWidget() ); + edit->setReadOnly( true ); + + QFile f(filename); + if ( !f.open( IO_ReadOnly ) ) { + KMessageBox::error( this, i18n( "Unable to open Hotsync log %1." ).arg( filename ) ); + return; + } + + QTextStream s( &f ); + while ( !s.eof() ) + edit->append( s.readLine() ); + + edit->moveCursor( QTextEdit::MoveHome, false ); + + f.close(); + + dlg.setInitialSize( QSize( 400, 350 ) ); + dlg.exec(); +} + +void SummaryWidget::startKPilot() +{ + QString error; + QCString appID; + if ( !KApplication::kdeinitExec( "kpilotDaemon", QString( "--fail-silently" ) ) ) { + kdDebug(5602) << "No service available..." << endl; + mStartedDaemon = true; + } +} + +void SummaryWidget::slotAppRemoved( const QCString & appId ) +{ + if ( appId == "kpilotDaemon" ) + { + mDCOPSuccess = false; + updateView(); + } +} + + +#include "summarywidget.moc" + diff --git a/kontact/plugins/kpilot/summarywidget.h b/kontact/plugins/kpilot/summarywidget.h new file mode 100644 index 000000000..94fda7e55 --- /dev/null +++ b/kontact/plugins/kpilot/summarywidget.h @@ -0,0 +1,99 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> + Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> + + 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 SUMMARYWIDGET_H +#define SUMMARYWIDGET_H + +#include "summary.h" + +#include <dcopobject.h> +#include <pilotDaemonDCOP.h> + +#include <qmap.h> +#include <qpixmap.h> +#include <qptrlist.h> +#include <qstringlist.h> +#include <qtimer.h> +#include <qwidget.h> +#include <qdatetime.h> + +class QGridLayout; +class QLabel; +class KURLLabel; + +class SummaryWidget : public Kontact::Summary, public DCOPObject +{ + Q_OBJECT + K_DCOP + + public: + SummaryWidget( QWidget *parent, const char *name = 0 ); + virtual ~SummaryWidget(); + + int summaryHeight() const { return 1; } + + QStringList configModules() const; + + k_dcop: + // all the information is pushed to Kontact by the daemon, to remove the chance of Kontact calling a daemon + // that is blocked for some reason, and blocking itself. + void receiveDaemonStatusDetails( QDateTime, QString, QStringList, QString, QString, QString, bool ); + private slots: + void updateView(); + void showSyncLog( const QString &filename ); + void startKPilot(); + void slotAppRemoved( const QCString & ); + private: + QTimer mTimer; + + QLabel*mSyncTimeTextLabel; + QLabel*mSyncTimeLabel; + KURLLabel*mShowSyncLogLabel; + QLabel*mPilotUserTextLabel; + QLabel*mPilotUserLabel; + QLabel*mPilotDeviceTextLabel; + QLabel*mPilotDeviceLabel; + QLabel*mDaemonStatusTextLabel; + QLabel*mDaemonStatusLabel; + QLabel*mConduitsTextLabel; + QLabel*mConduitsLabel; + QLabel*mNoConnectionLabel; + KURLLabel*mNoConnectionStartLabel; + + QGridLayout *mLayout; + + QDateTime mLastSyncTime; + QString mDaemonStatus; + QStringList mConduits; + QString mSyncLog; + QString mUserName; + QString mPilotDevice; + bool mDCOPSuccess; + + bool mStartedDaemon; // Record whether the daemon was started by kontact + bool mShouldStopDaemon; +}; + +#endif + diff --git a/kontact/plugins/newsticker/Makefile.am b/kontact/plugins/newsticker/Makefile.am new file mode 100644 index 000000000..779936802 --- /dev/null +++ b/kontact/plugins/newsticker/Makefile.am @@ -0,0 +1,26 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces \ + -I$(top_srcdir)/libkdepim \ + -I$(top_srcdir) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_newstickerplugin.la kcm_kontactknt.la +libkontact_newstickerplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_newstickerplugin_la_LIBADD = $(LIB_KPARTS) $(LIB_KDEUI) \ + $(top_builddir)/libkdepim/libkdepim.la ../../interfaces/libkpinterfaces.la + +libkontact_newstickerplugin_la_SOURCES = newsticker_plugin.cpp \ + summarywidget.cpp summarywidget.skel + +kcm_kontactknt_la_SOURCES = kcmkontactknt.cpp +kcm_kontactknt_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) \ + -avoid-version -no-undefined +kcm_kontactknt_la_LIBADD = $(LIB_KDEUI) + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir)/kontact +service_DATA = newstickerplugin.desktop + +kde_services_DATA = kcmkontactknt.desktop + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kcmkontactnt.pot diff --git a/kontact/plugins/newsticker/kcmkontactknt.cpp b/kontact/plugins/newsticker/kcmkontactknt.cpp new file mode 100644 index 000000000..18f439c8e --- /dev/null +++ b/kontact/plugins/newsticker/kcmkontactknt.cpp @@ -0,0 +1,452 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 <qgroupbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qlineedit.h> +#include <qvaluevector.h> +#include <qspinbox.h> + +#include <dcopref.h> +#include <dcopclient.h> + +#include <kaboutdata.h> +#include <kapplication.h> +#include <kaccelmanager.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <klistview.h> +#include <klocale.h> +#include <kpushbutton.h> + +#include "kcmkontactknt.h" + +#include "newsfeeds.h" + +#include <kdepimmacros.h> + +extern "C" +{ + KDE_EXPORT KCModule *create_kontactknt( QWidget *parent, const char * ) + { + return new KCMKontactKNT( parent, "kcmkontactknt" ); + } +} + +NewsEditDialog::NewsEditDialog( const QString& title, const QString& url, QWidget *parent ) + : KDialogBase( Plain, i18n( "New News Feed" ), Ok | Cancel, + Ok, parent, 0, true, true ) +{ + QWidget *page = plainPage(); + QGridLayout *layout = new QGridLayout( page, 2, 3, marginHint(), + spacingHint() ); + + QLabel *label = new QLabel( i18n( "Name:" ), page ); + layout->addWidget( label, 0, 0 ); + + mTitle = new QLineEdit( page ); + label->setBuddy( mTitle ); + layout->addMultiCellWidget( mTitle, 0, 0, 1, 2 ); + + label = new QLabel( i18n( "URL:" ), page ); + layout->addWidget( label, 1, 0 ); + + mURL = new QLineEdit( page ); + label->setBuddy( mURL ); + layout->addMultiCellWidget( mURL, 1, 1, 1, 2 ); + + mTitle->setText( title ); + mURL->setText( url ); + mTitle->setFocus(); + connect( mTitle, SIGNAL( textChanged( const QString& ) ), + this, SLOT( modified() ) ); + connect( mURL, SIGNAL( textChanged( const QString& ) ), + this, SLOT( modified() ) ); + + modified(); +} + +void NewsEditDialog::modified() +{ + enableButton( KDialogBase::Ok, !title().isEmpty() && !url().isEmpty() ); +} + +QString NewsEditDialog::title() const +{ + return mTitle->text(); +} + +QString NewsEditDialog::url() const +{ + return mURL->text(); +} + +class NewsItem : public QListViewItem +{ + public: + NewsItem( QListView *parent, const QString& title, const QString& url, bool custom ) + : QListViewItem( parent ), mTitle( title ), mUrl( url ), mCustom( custom ) + { + setText( 0, mTitle ); + } + + NewsItem( QListViewItem *parent, const QString& title, const QString& url, bool custom ) + : QListViewItem( parent ), mTitle( title ), mUrl( url ), mCustom( custom ) + { + setText( 0, mTitle ); + } + + QString title() const { return mTitle; } + QString url() const { return mUrl; } + bool custom() const { return mCustom; } + + private: + QString mTitle; + QString mUrl; + bool mCustom; +}; + +KCMKontactKNT::KCMKontactKNT( QWidget *parent, const char *name ) + : KCModule( parent, name ) +{ + initGUI(); + + connect( mAllNews, SIGNAL( currentChanged( QListViewItem* ) ), + this, SLOT( allCurrentChanged( QListViewItem* ) ) ); + connect( mSelectedNews, SIGNAL( selectionChanged( QListViewItem* ) ), + this, SLOT( selectedChanged( QListViewItem* ) ) ); + + connect( mUpdateInterval, SIGNAL( valueChanged( int ) ), SLOT( modified() ) ); + connect( mArticleCount, SIGNAL( valueChanged( int ) ), SLOT( modified() ) ); + + connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addNews() ) ); + connect( mRemoveButton, SIGNAL( clicked() ), this, SLOT( removeNews() ) ); + connect( mNewButton, SIGNAL( clicked() ), this, SLOT( newFeed() ) ); + connect( mDeleteButton, SIGNAL( clicked() ), this, SLOT( deleteFeed() ) ); + + KAcceleratorManager::manage( this ); + + load(); +} + +void KCMKontactKNT::loadNews() +{ + QValueVector<QListViewItem*> parents; + QValueVector<QListViewItem*>::Iterator it; + + parents.append( new QListViewItem( mAllNews, i18n( "Arts" ) ) ); + parents.append( new QListViewItem( mAllNews, i18n( "Business" ) ) ); + parents.append( new QListViewItem( mAllNews, i18n( "Computers" ) ) ); + parents.append( new QListViewItem( mAllNews, i18n( "Misc" ) ) ); + parents.append( new QListViewItem( mAllNews, i18n( "Recreation" ) ) ); + parents.append( new QListViewItem( mAllNews, i18n( "Society" ) ) ); + + for ( it = parents.begin(); it != parents.end(); ++it ) + (*it)->setSelectable( false ); + + for ( int i = 0; i < DEFAULT_NEWSSOURCES; ++i ) { + NewsSourceData data = NewsSourceDefault[ i ]; + new NewsItem( parents[ data.category() ], data.name(), data.url(), false ); + mFeedMap.insert( data.url(), data.name() ); + } +} + +void KCMKontactKNT::loadCustomNews() +{ + KConfig config( "kcmkontactkntrc" ); + QMap<QString, QString> customFeeds = config.entryMap( "CustomFeeds" ); + config.setGroup( "CustomFeeds" ); + + mCustomItem = new QListViewItem( mAllNews, i18n( "Custom" ) ); + mCustomItem->setSelectable( false ); + + if ( customFeeds.count() == 0 ) + mCustomItem->setVisible( false ); + + QMap<QString, QString>::Iterator it; + for ( it = customFeeds.begin(); it != customFeeds.end(); ++it ) { + QStringList value = config.readListEntry( it.key() ); + mCustomFeeds.append( new NewsItem( mCustomItem, value[ 0 ], value[ 1 ], true ) ); + mFeedMap.insert( value[ 1 ], value[ 0 ] ); + mCustomItem->setVisible( true ); + } +} + +void KCMKontactKNT::storeCustomNews() +{ + KConfig config( "kcmkontactkntrc" ); + config.deleteGroup( "CustomFeeds" ); + config.setGroup( "CustomFeeds" ); + + int counter = 0; + QValueList<NewsItem*>::Iterator it; + for ( it = mCustomFeeds.begin(); it != mCustomFeeds.end(); ++it ) { + QStringList value; + value << (*it)->title() << (*it)->url(); + config.writeEntry( QString::number( counter ), value ); + + ++counter; + } + + config.sync(); +} + +void KCMKontactKNT::addNews() +{ + if ( !dcopActive() ) + return; + + NewsItem *item = dynamic_cast<NewsItem*>( mAllNews->selectedItem() ); + if ( item == 0 ) + return; + + DCOPRef service( "rssservice", "RSSService" ); + service.send( "add(QString)", item->url() ); + + scanNews(); + + emit changed( true ); +} + +void KCMKontactKNT::removeNews() +{ + if ( !dcopActive() ) + return; + + NewsItem *item = dynamic_cast<NewsItem*>( mSelectedNews->selectedItem() ); + if ( item == 0 ) + return; + + DCOPRef service( "rssservice", "RSSService" ); + service.send( "remove(QString)", item->url() ); + + scanNews(); + + emit changed( true ); +} + +void KCMKontactKNT::newFeed() +{ + NewsEditDialog dlg( "", "", this ); + + if ( dlg.exec() ) { + NewsItem *item = new NewsItem( mCustomItem, dlg.title(), dlg.url(), true ); + mCustomFeeds.append( item ); + mFeedMap.insert( dlg.url(), dlg.title() ); + + mCustomItem->setVisible( true ); + mCustomItem->setOpen( true ); + mAllNews->ensureItemVisible( item ); + mAllNews->setSelected( item, true ); + + emit changed( true ); + } +} + +void KCMKontactKNT::deleteFeed() +{ + NewsItem *item = dynamic_cast<NewsItem*>( mAllNews->selectedItem() ); + if ( !item ) + return; + + if ( mCustomFeeds.find( item ) == mCustomFeeds.end() ) + return; + + mCustomFeeds.remove( item ); + mFeedMap.remove( item->url() ); + delete item; + + if ( mCustomFeeds.count() == 0 ) + mCustomItem->setVisible( false ); + + emit changed( true ); +} + +void KCMKontactKNT::scanNews() +{ + if ( !dcopActive() ) + return; + + mSelectedNews->clear(); + + DCOPRef service( "rssservice", "RSSService" ); + QStringList urls = service.call( "list()" ); + + for ( uint i = 0; i < urls.count(); ++i ) + { + QString url = urls[ i ]; + QString feedName = mFeedMap[ url ]; + if ( feedName.isEmpty() ) + feedName = url; + new NewsItem( mSelectedNews, feedName, url, false ); + } +} + +void KCMKontactKNT::selectedChanged( QListViewItem *item ) +{ + mRemoveButton->setEnabled( item && item->isSelected() ); +} + +void KCMKontactKNT::allCurrentChanged( QListViewItem *item ) +{ + NewsItem *newsItem = dynamic_cast<NewsItem*>( item ); + + bool addState = false; + bool delState = false; + if ( newsItem && newsItem->isSelected() ) { + addState = true; + delState = (mCustomFeeds.find( newsItem ) != mCustomFeeds.end()); + } + + mAddButton->setEnabled( addState ); + mDeleteButton->setEnabled( delState ); +} + +void KCMKontactKNT::modified() +{ + emit changed( true ); +} + +void KCMKontactKNT::initGUI() +{ + QGridLayout *layout = new QGridLayout( this, 2, 3, KDialog::marginHint(), + KDialog::spacingHint() ); + + mAllNews = new KListView( this ); + mAllNews->addColumn( i18n( "All" ) ); + mAllNews->setRootIsDecorated( true ); + mAllNews->setFullWidth( true ); + layout->addWidget( mAllNews, 0, 0 ); + + QVBoxLayout *vbox = new QVBoxLayout( layout, KDialog::spacingHint() ); + + vbox->addStretch(); + mAddButton = new KPushButton( i18n( "Add" ), this ); + mAddButton->setEnabled( false ); + vbox->addWidget( mAddButton ); + mRemoveButton = new KPushButton( i18n( "Remove" ), this ); + mRemoveButton->setEnabled( false ); + vbox->addWidget( mRemoveButton ); + vbox->addStretch(); + + mSelectedNews = new KListView( this ); + mSelectedNews->addColumn( i18n( "Selected" ) ); + mSelectedNews->setFullWidth( true ); + layout->addWidget( mSelectedNews, 0, 2 ); + + QGroupBox *box = new QGroupBox( 0, Qt::Vertical, + i18n( "News Feed Settings" ), this ); + + QGridLayout *boxLayout = new QGridLayout( box->layout(), 2, 3, + KDialog::spacingHint() ); + + QLabel *label = new QLabel( i18n( "Refresh time:" ), box ); + boxLayout->addWidget( label, 0, 0 ); + + mUpdateInterval = new QSpinBox( 1, 3600, 1, box ); + mUpdateInterval->setSuffix( " sec." ); + label->setBuddy( mUpdateInterval ); + boxLayout->addWidget( mUpdateInterval, 0, 1 ); + + label = new QLabel( i18n( "Number of items shown:" ), box ); + boxLayout->addWidget( label, 1, 0 ); + + mArticleCount = new QSpinBox( box ); + label->setBuddy( mArticleCount ); + boxLayout->addWidget( mArticleCount, 1, 1 ); + + mNewButton = new KPushButton( i18n( "New Feed..." ), box ); + boxLayout->addWidget( mNewButton, 0, 2 ); + + mDeleteButton = new KPushButton( i18n( "Delete Feed" ), box ); + mDeleteButton->setEnabled( false ); + boxLayout->addWidget( mDeleteButton, 1, 2 ); + + layout->addMultiCellWidget( box, 1, 1, 0, 2 ); +} + +bool KCMKontactKNT::dcopActive() const +{ + QString error; + QCString appID; + bool isGood = true; + DCOPClient *client = kapp->dcopClient(); + if ( !client->isApplicationRegistered( "rssservice" ) ) { + if ( KApplication::startServiceByDesktopName( "rssservice", QStringList(), &error, &appID ) ) + isGood = false; + } + + return isGood; +} + +void KCMKontactKNT::load() +{ + mAllNews->clear(); + + loadNews(); + loadCustomNews(); + scanNews(); + + KConfig config( "kcmkontactkntrc" ); + config.setGroup( "General" ); + + mUpdateInterval->setValue( config.readNumEntry( "UpdateInterval", 600 ) ); + mArticleCount->setValue( config.readNumEntry( "ArticleCount", 4 ) ); + + emit changed( false ); +} + +void KCMKontactKNT::save() +{ + storeCustomNews(); + + KConfig config( "kcmkontactkntrc" ); + config.setGroup( "General" ); + + config.writeEntry( "UpdateInterval", mUpdateInterval->value() ); + config.writeEntry( "ArticleCount", mArticleCount->value() ); + + config.sync(); + + emit changed( false ); +} + +void KCMKontactKNT::defaults() +{ +} + +const KAboutData* KCMKontactKNT::aboutData() const +{ + KAboutData *about = new KAboutData( I18N_NOOP( "kcmkontactknt" ), + I18N_NOOP( "Newsticker Configuration Dialog" ), + 0, 0, KAboutData::License_GPL, + I18N_NOOP( "(c) 2003 - 2004 Tobias Koenig" ) ); + + about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); + + return about; +} + +#include "kcmkontactknt.moc" diff --git a/kontact/plugins/newsticker/kcmkontactknt.desktop b/kontact/plugins/newsticker/kcmkontactknt.desktop new file mode 100644 index 000000000..d866e252a --- /dev/null +++ b/kontact/plugins/newsticker/kcmkontactknt.desktop @@ -0,0 +1,156 @@ +[Desktop Entry] +Icon=knode +Type=Service +ServiceTypes=KCModule + +X-KDE-ModuleType=Library +X-KDE-Library=kontactknt +X-KDE-FactoryName=kontactknt +X-KDE-ParentApp=kontact_newstickerplugin +X-KDE-ParentComponents=kontact_newstickerplugin +X-KDE-CfgDlgHierarchy=KontactSummary + +Name=News Ticker +Name[af]=Nuus tikker +Name[az]=Xəbər Gözləyici +Name[br]=Kliker keleier +Name[ca]=Teletip de notícies +Name[cy]=Ticer Newyddion +Name[da]=Nyhedstelegraf +Name[de]=Newsticker +Name[el]=Προβολέας ειδήσεων +Name[eo]=Novaĵprezentilo +Name[es]=Teletipo de noticias +Name[et]=Uudistejälgija +Name[eu]=Berri markatzailea +Name[fa]=Ticker اخبار +Name[fi]=Uutisnäytin +Name[fr]=Téléscripteur de nouvelles +Name[fy]=Nijs Tikker +Name[gl]=Colector de Novas +Name[he]=חדשות רצות +Name[hi]=न्यूज टिकर +Name[hr]=Ticker sa novostima +Name[hu]=RSS hírmegjelenítő +Name[id]=Ticker Berita +Name[is]=Fréttastrimill +Name[it]=Ticker notizie +Name[ja]=ニュースティッカー +Name[ka]=სიახლეთა ტიკერი +Name[kk]=Жаңалық таспасы +Name[km]=កម្មវិធីទទួលព័ត៌មាន +Name[lt]=News pranešėjas +Name[lv]=Ziņu Tikkers +Name[ms]=Pengetik Berita +Name[nb]=Nyhetstelegraf +Name[nds]=Narichten-Ticker +Name[ne]=न्यूज टिकर +Name[nn]=Nyheitstelegraf +Name[pl]=Wiadomości +Name[pt]=Extractor de Notícias +Name[pt_BR]=Animação de Notícias +Name[ro]=Ştiri Internet +Name[ru]=Новости +Name[sk]=Sledovanie správ +Name[sl]=Prikazovalnik novic +Name[sr]=Откуцавач вести +Name[sr@Latn]=Otkucavač vesti +Name[sv]=Nyhetsövervakare +Name[ta]=செய்திகள் குறிப்பான் +Name[tg]=Ахборот +Name[th]=ตั๋วข่าว +Name[tr]=Haber İzleyici +Name[uk]=Стрічка новин +Name[ven]=Musengulusi wa Mafhungo +Name[vi]=Trình kiểm tra news +Name[xh]=Umchola-choli weendaba +Name[zh_CN]=新闻点点通 +Name[zh_TW]=新聞顯示器 +Name[zu]=Umlungiseleli Wezindaba +Comment=News Ticker Summary Setup +Comment[af]=Nuus tikker opsomming opstelling +Comment[bg]=Настройване обобщението на новините +Comment[ca]=Configuració del resum del teletip de notícies +Comment[cs]=Nastavení souhrnu newstickeru +Comment[da]=Nyhedstelegrafs opsætning af opsummering +Comment[de]=Einstellung der News-übersicht +Comment[el]=Περίληψη ρύθμισης προβολέα ρυθμίσεων +Comment[es]=Configuración del resumen del teletipo de noticias +Comment[et]=Uudistejälgija kokkuvõtte seadistus +Comment[eu]=Berri markatzailearen laburpenaren konfigurazioa +Comment[fa]=برپایی خلاصۀTicker اخبار +Comment[fi]=Uutisnäyttimen yhteenvedon asetukset +Comment[fr]=Configuration du résumé du téléscripteur de nouvelles +Comment[fy]=Oersichtsynstellings nijstikker +Comment[gl]=Configuración do Resumo de Fontes de Novas +Comment[he]=הגדרות תקציר חדשות רצות +Comment[hu]=A hírmegjelenítő áttekintőjének beállításai +Comment[is]=Uppsetning á yfirliti yfir fréttastrimla +Comment[it]=Impostazioni sommario ticker notizie +Comment[ja]=ニュースティッカーの設定 +Comment[ka]=სიახლეთა ტიკერის დაიჯესტის კონფიგურაცია +Comment[kk]=Жаңалық таспасының тұжырымынын баптау +Comment[km]=រៀបចំសេចក្ដីសង្ខេបកម្មវិធីទទួលព័ត៌មាន +Comment[lt]=News Ticker santraukos nustatymai +Comment[nb]=Oppsett av sammendraget til nyhetstelegrafen +Comment[nds]=Narichten-Översicht instellen +Comment[ne]=न्यूज टिकर सारांश सेटअप +Comment[nl]=Overzichtsinstellingen nieuwsticker +Comment[nn]=Oppsett av nyhendetelegrafsamandrag +Comment[pl]=Ustawienia podsumowania wiadomości +Comment[pt]=Configuração do Sumário do Extractor de Notícias +Comment[pt_BR]=Configuração de Resumo de Notícias +Comment[ru]=Настройка сводки новостей +Comment[sk]=Nastavenie súhrnu správ +Comment[sl]=Nastavitve povzetka novic +Comment[sr]=Подешавање сажетка приказивања вести +Comment[sr@Latn]=Podešavanje sažetka prikazivanja vesti +Comment[sv]=Inställning av nyhetsövervakningsöversikt +Comment[tr]=Haber Yakalayıcı Özet Ayarları +Comment[uk]=Налаштування зведення стрічки новин +Comment[zh_CN]=新闻点点通摘要设置 +Comment[zh_TW]=新聞顯示器摘要設定 +Keywords=news ticker, configure, settings +Keywords[bg]=новини, източник, настройки, news ticker, configure, settings +Keywords[bs]=news ticker, configure, settings, vijesti, newsticker, podešavanje +Keywords[ca]=teletip, configura, opcions +Keywords[cs]=novinky,nastavení +Keywords[da]=nyhedstelegraf, indstil, opsætning +Keywords[de]=Newsticker,Einrichten,Einstellungen +Keywords[el]=προβολέας ειδήσεων, ρύθμιση, ρυθμίσεις +Keywords[es]=teletipo de noticias, configurar, opciones +Keywords[et]=uudistejälgija, seadistamine, seadistused +Keywords[eu]=berri markatzaileak, konfiguratu, ezarpenak +Keywords[fa]=ticker اخبار، پیکربندی، تنظیمات +Keywords[fi]=uutiset, asetukset, muokkaa +Keywords[fr]=configurer,paramètre,news ticker, téléscripteur +Keywords[fy]=newsticker,instellingen,ynstellings,configuratie,nieuws,nijs +Keywords[gl]=capturador de novas, configurar, opcións +Keywords[he]=news ticker, configure, settings, חדשות, תצורה, הגדרות +Keywords[hu]=hírmegjelenítő,konfigurálás,beállítások +Keywords[is]=fréttastrimill, stillingar, stilla +Keywords[it]=ticker notizie, configura, impostazioni +Keywords[ja]=ニュースティッカー,設定,設定 +Keywords[ka]=სიახლეთა ტიკერი, კონფიგურაცია, პარამეტრები +Keywords[km]=កម្មវិធីទទួលព័ត៌មាន,កំណត់រចនាសម្ព័ន្ធ,ការកំណត់ +Keywords[lt]=news ticker, configure, settings, konfigūravimas, nustatymai, naujienų pranešėjas +Keywords[ms]=Pengetik berita, konfigur, seting +Keywords[nb]=nyhetstelegraf, oppsett, innstillinger +Keywords[nds]=Narichten-Ticker, instellen +Keywords[ne]=न्यूज टिकर, कन्फिगर, सेटिङ +Keywords[nl]=newsticker,instellingen,configuratie,nieuws +Keywords[nn]=nyhendetelegraf,oppsett,innstillingar +Keywords[pl]=news ticker,wiadomości,nagłówki,konfiguracja,ustawienia +Keywords[pt]=notícias, configurar, configuração +Keywords[pt_BR]=mostrador de notícias,configurar, preferências +Keywords[ru]=news ticker, configure, settings, настройка, новости +Keywords[sk]=zdroje správ,nastavenie +Keywords[sl]=prikazovalnik novic, nastavi, nastavitve +Keywords[sr]=news ticker, подеси, поставке +Keywords[sr@Latn]=news ticker, podesi, postavke +Keywords[sv]=nyhetsövervakare, anpassa, inställningar +Keywords[ta]=கேமுகவரிப்புத்தகம்,கட்டமைப்பு,அமைவுகள் +Keywords[tg]=news ticker, configure, settings, танзимот +Keywords[tr]=haber izleyici, yapılandırma, yapılandır +Keywords[uk]=новини, налаштування, параметри +Keywords[zh_CN]=news ticker, configure, settings, 新闻点点通, 配置, 设置 diff --git a/kontact/plugins/newsticker/kcmkontactknt.h b/kontact/plugins/newsticker/kcmkontactknt.h new file mode 100644 index 000000000..7463cf004 --- /dev/null +++ b/kontact/plugins/newsticker/kcmkontactknt.h @@ -0,0 +1,102 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 KCMKONTACTKNT_H +#define KCMKONTACTKNT_H + +#include <kcmodule.h> + +class QListViewItem; +class QSpinxBox; + +class KAboutData; +class KListView; +class KPushButton; + +class NewsItem; + +class KCMKontactKNT : public KCModule +{ + Q_OBJECT + + public: + KCMKontactKNT( QWidget *parent = 0, const char *name = 0 ); + + virtual void load(); + virtual void save(); + virtual void defaults(); + virtual const KAboutData* aboutData() const; + + private slots: + void addNews(); + void removeNews(); + void newFeed(); + void deleteFeed(); + + void selectedChanged( QListViewItem *item ); + void allCurrentChanged( QListViewItem *item ); + + void modified(); + + private: + void initGUI(); + void loadNews(); + void loadCustomNews(); + void storeCustomNews(); + void scanNews(); + + bool dcopActive() const; + + KListView *mAllNews; + KListView *mSelectedNews; + QListViewItem *mCustomItem; + + KPushButton *mAddButton; + KPushButton *mRemoveButton; + KPushButton *mNewButton; + KPushButton *mDeleteButton; + QSpinBox *mUpdateInterval; + QSpinBox *mArticleCount; + + QMap<QString, QString> mFeedMap; + QValueList<NewsItem*> mCustomFeeds; +}; + +class NewsEditDialog : public KDialogBase +{ + Q_OBJECT + + public: + NewsEditDialog( const QString&, const QString&, QWidget *parent ); + QString title() const; + QString url() const; + + private slots: + void modified(); + + private: + QLineEdit *mTitle; + QLineEdit *mURL; +}; + +#endif diff --git a/kontact/plugins/newsticker/newsfeeds.h b/kontact/plugins/newsticker/newsfeeds.h new file mode 100644 index 000000000..fb5ef4098 --- /dev/null +++ b/kontact/plugins/newsticker/newsfeeds.h @@ -0,0 +1,315 @@ +/* + This file is part of 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 NEWSFEEDS_H +#define NEWSFEEDS_H + +#include <qvaluelist.h> + +#define DEFAULT_NEWSSOURCES 60 + +class NewsSourceData +{ + public: + typedef QValueList<NewsSourceData> List; + + enum Category { Arts, Business, Computers, Misc, + Recreation, Society }; + + NewsSourceData( const QString &name = I18N_NOOP( "Unknown" ), + const QString &url = QString::null, + const QString &icon = QString::null, + const Category category= Computers ) + : mName( name ), mURL( url ), mIcon( icon ), mCategory( category ) + { + } + + QString name() const { return mName; } + QString url() const { return mURL; } + QString icon() const { return mIcon; } + Category category() const { return mCategory; } + + QString mName; + QString mURL; + QString mIcon; + Category mCategory; +}; + +static NewsSourceData NewsSourceDefault[DEFAULT_NEWSSOURCES] = { + // Arts --------------- + NewsSourceData( + QString::fromLatin1("Bureau 42"), + QString::fromLatin1("http://www.bureau42.com/rdf/"), + QString::fromLatin1("http://www.bureau42.com/favicon.ico"), + NewsSourceData::Arts ), + NewsSourceData( + QString::fromLatin1("eFilmCritic"), + QString::fromLatin1("http://efilmcritic.com/fo.rdf"), + QString::fromLatin1("http://efilmcritic.com/favicon.ico"), + NewsSourceData::Arts ), + // Business ----------- + NewsSourceData( + QString::fromLatin1("Internet.com Business"), + QString::fromLatin1("http://headlines.internet.com/internetnews/bus-news/news.rss"), + QString::null, + NewsSourceData::Business ), + NewsSourceData( + QString::fromLatin1("TradeSims"), + QString::fromLatin1("http://www.tradesims.com/AEX.rdf"), + QString::null, + NewsSourceData::Business ), + // Computers ---------- + NewsSourceData( + QString::fromLatin1("KDE Deutschland"), + QString::fromLatin1("http://www.kde.de/nachrichten/nachrichten.rdf"), + QString::fromLatin1("http://www.kde.de/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("KDE France"), + QString::fromLatin1("http://www.kde-france.org/backend-breves.php3"), + QString::null, + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("FreeBSD Project News"), + QString::fromLatin1("http://www.freebsd.org/news/news.rdf"), + QString::fromLatin1("http://www.freebsd.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("dot.kde.org"), + QString::fromLatin1("http://www.kde.org/dotkdeorg.rdf"), + QString::fromLatin1("http://www.kde.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( QString::fromLatin1("KDE-Look.org"), + QString::fromLatin1("http://www.kde.org/kde-look-content.rdf"), + QString::fromLatin1("http://kde-look.org/img/favicon-1-1.ico"), + NewsSourceData::Computers ), + NewsSourceData( QString::fromLatin1("KDE-Apps.org"), + QString::fromLatin1("http://www.kde.org/dot/kde-apps-content.rdf"), + QString::fromLatin1("http://kde-apps.org/img/favicon-1-1.ico"), + NewsSourceData::Computers ), + NewsSourceData( QString::fromLatin1("DesktopLinux"), + QString::fromLatin1("http://www.desktoplinux.com/backend/index.html"), + QString::fromLatin1("http://www.desktoplinux.com/images/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( QString::fromLatin1("DistroWatch"), + QString::fromLatin1("http://distrowatch.com/news/dw.xml"), + QString::fromLatin1("http://distrowatch.com/favicon.ico"), + NewsSourceData::Computers ), + /*URL changed*/ + NewsSourceData( + QString::fromLatin1("GNOME News"), + QString::fromLatin1("http://www.gnomedesktop.org/node/feed"), + QString::null, + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Slashdot"), + QString::fromLatin1("http://slashdot.org/slashdot.rdf"), + QString::fromLatin1("http://slashdot.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Ask Slashdot"), + QString::fromLatin1("http://slashdot.org/askslashdot.rdf"), + QString::fromLatin1("http://slashdot.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Slashdot: Features"), + QString::fromLatin1("http://slashdot.org/features.rdf"), + QString::fromLatin1("http://slashdot.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Slashdot: Apache"), + QString::fromLatin1("http://slashdot.org/apache.rdf"), + QString::fromLatin1("http://slashdot.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Slashdot: Books"), + QString::fromLatin1("http://slashdot.org/books.rdf"), + QString::fromLatin1("http://slashdot.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Jabber News"), + QString::fromLatin1("http://www.jabber.org/news/rss.xml"), + QString::null, + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Freshmeat"), + QString::fromLatin1("http://freshmeat.net/backend/fm.rdf"), + QString::fromLatin1("http://freshmeat.net/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Linux Weekly News"), + QString::fromLatin1("http://www.lwn.net/headlines/rss"), + QString::fromLatin1("http://www.lwn.net/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("heise online news"), + QString::fromLatin1("http://www.heise.de/newsticker/heise.rdf"), + QString::fromLatin1("http://www.heise.de/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("RUS-CERT Ticker"), + QString::fromLatin1("http://cert.uni-stuttgart.de/ticker/rus-cert.rdf"), + QString::fromLatin1("http://cert.uni-stuttgart.de/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("RUS-CERT Elsewhere"), + QString::fromLatin1("http://cert.uni-stuttgart.de/ticker/rus-cert-elsewhere.rdf"), + QString::fromLatin1("http://cert.uni-stuttgart.de/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Kuro5hin"), + QString::fromLatin1("http://kuro5hin.org/backend.rdf"), + QString::fromLatin1("http://kuro5hin.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Prolinux"), + QString::fromLatin1("http://www.pl-forum.de/backend/pro-linux.rdf"), + QString::fromLatin1("http://www.prolinux.de/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("LinuxSecurity.com"), + QString::fromLatin1("http://www.linuxsecurity.com/linuxsecurity_hybrid.rdf"), + QString::fromLatin1("http://www.linuxsecurity.com/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Linux Game Tome"), + QString::fromLatin1("http://happypenguin.org/html/news.rdf"), + QString::null, + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Mozilla"), + QString::fromLatin1("http://www.mozilla.org/news.rdf"), + QString::fromLatin1("http://www.mozillazine.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("MozillaZine"), + QString::fromLatin1("http://www.mozillazine.org/contents.rdf"), + QString::fromLatin1("http://www.mozillazine.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Daemon News"), + QString::fromLatin1("http://daily.daemonnews.org/ddn.rdf.php3"), + QString::null, + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("use Perl;"), + QString::fromLatin1("http://use.perl.org/useperl.rdf"), + QString::null, + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Root prompt"), + QString::fromLatin1("http://www.rootprompt.org/rss/"), + QString::fromLatin1("http://www.rootprompt.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("SecurityFocus"), + QString::fromLatin1("http://www.securityfocus.com/topnews-rdf.html"), + QString::fromLatin1("http://www.securityfocus.com/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("Arstechnica"), + QString::fromLatin1("http://arstechnica.com/etc/rdf/ars.rdf"), + QString::fromLatin1("http://arstechnica.com/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("amiga-news.de - deutschsprachige Amiga Nachrichten"), + QString::fromLatin1("http://www.amiga-news.de/de/backends/news/index.rss"), + QString::fromLatin1("http://www.amiga-news.de/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("amiga-news.de - english Amiga news"), + QString::fromLatin1("http://www.amiga-news.de/en/backends/news/index.rss"), + QString::fromLatin1("http://www.amiga-news.de/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("FreshPorts - the place for ports"), + QString::fromLatin1("http://www.freshports.org/news.php3"), + QString::fromLatin1("http://www.freshports.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("zez.org - about code "), + QString::fromLatin1("http://zez.org/article/rssheadlines"), + QString::null, + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("BSDatwork.com"), + QString::fromLatin1("http://BSDatwork.com/backend.php"), + QString::fromLatin1("http://BSDatwork.com/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("FreshSource - the place for source"), + QString::fromLatin1("http://www.freshsource.org/news.php"), + QString::fromLatin1("http://www.freshsource.org/favicon.ico"), + NewsSourceData::Computers ), + NewsSourceData( + QString::fromLatin1("The FreeBSD Diary"), + QString::fromLatin1("http://www.freebsddiary.org/news.php"), + QString::fromLatin1("http://www.freebsddiary.org/favicon.ico"), + NewsSourceData::Computers ), + // Miscellaneous ------ + NewsSourceData( + QString::fromLatin1("tagesschau.de"), + QString::fromLatin1("http://www.tagesschau.de/newsticker.rdf"), + QString::fromLatin1("http://www.tagesschau.de/favicon.ico"), + NewsSourceData::Misc ), + NewsSourceData( + QString::fromLatin1("CNN Top Stories"), + QString::fromLatin1("http://rss.cnn.com/rss/cnn_topstories.rss"), + QString::fromLatin1("http://www.cnn.com/favicon.ico"), + NewsSourceData::Misc ), + /*feed URL changed*/ + NewsSourceData( + QString::fromLatin1("HotWired"), + QString::fromLatin1("http://www.wired.com/news/feeds/rss2/0,2610,,00.xml"), + QString::fromLatin1("http://www.hotwired.com/favicon.ico"), + NewsSourceData::Misc ), + NewsSourceData( + QString::fromLatin1("The Register"), + QString::fromLatin1("http://www.theregister.co.uk/headlines.rss"), + QString::fromLatin1("http://www.theregister.co.uk/favicon.ico"), + NewsSourceData::Misc ), + NewsSourceData( + QString::fromLatin1( "Christian Science Monitor" ), + QString::fromLatin1( "http://www.csmonitor.com/rss/csm.rss"), + QString::fromLatin1( "http://www.csmonitor.com/favicon.ico"), + NewsSourceData::Misc ), + // Recreation + // Society + NewsSourceData( + QString::fromLatin1("nippon.it"), + QString::fromLatin1("http://www.nippon.it/backend.it.php"), + QString::fromLatin1("http://www.nippon.it/favicon.ico"), + NewsSourceData::Society ), + NewsSourceData( + QString::fromLatin1( "gflash" ), + QString::fromLatin1( "http://www.gflash.de/backend.php"), + QString::fromLatin1( "http://www.gflash.de/favicon.ico"), + NewsSourceData::Society ), + NewsSourceData( + QString::fromLatin1( "Quintessenz" ), + QString::fromLatin1( "http://quintessenz.at/cgi-bin/rdf"), + QString::fromLatin1( "http://quintessenz.at/favicon.ico"), + NewsSourceData::Society ) +}; + +#endif diff --git a/kontact/plugins/newsticker/newsticker_plugin.cpp b/kontact/plugins/newsticker/newsticker_plugin.cpp new file mode 100644 index 000000000..0bc42bd14 --- /dev/null +++ b/kontact/plugins/newsticker/newsticker_plugin.cpp @@ -0,0 +1,43 @@ +/* + This file is part of Kontact. + Copyright (C) 2003 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 <kgenericfactory.h> +#include <klocale.h> +#include <kparts/componentfactory.h> +#include "core.h" + +#include "summarywidget.h" + +#include "newsticker_plugin.h" + +typedef KGenericFactory< NewsTickerPlugin, Kontact::Core > NewsTickerPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_newstickerplugin, + NewsTickerPluginFactory( "kontact_newstickerplugin" ) ) + +NewsTickerPlugin::NewsTickerPlugin( Kontact::Core *core, const char *name, const QStringList& ) + : Kontact::Plugin( core, core, name ) +{ + setInstance( NewsTickerPluginFactory::instance() ); +} + +Kontact::Summary *NewsTickerPlugin::createSummaryWidget( QWidget* parentWidget ) +{ + return new SummaryWidget( parentWidget ); +} diff --git a/kontact/plugins/newsticker/newsticker_plugin.h b/kontact/plugins/newsticker/newsticker_plugin.h new file mode 100644 index 000000000..d912da797 --- /dev/null +++ b/kontact/plugins/newsticker/newsticker_plugin.h @@ -0,0 +1,40 @@ +/* + This file is part of Kontact. + Copyright (C) 2003 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 NEWSTICKER_PLUGIN_H +#define NEWSTICKER_PLUGIN_H + +#include "plugin.h" + +class SummaryWidget; + +class NewsTickerPlugin : public Kontact::Plugin +{ + public: + NewsTickerPlugin( Kontact::Core *core, const char *name, const QStringList& ); + NewsTickerPlugin(); + + virtual Kontact::Summary *createSummaryWidget( QWidget* parentWidget ); + + protected: + virtual KParts::ReadOnlyPart* createPart() { return 0L; } +}; + +#endif diff --git a/kontact/plugins/newsticker/newstickerplugin.desktop b/kontact/plugins/newsticker/newstickerplugin.desktop new file mode 100644 index 000000000..18a34cda9 --- /dev/null +++ b/kontact/plugins/newsticker/newstickerplugin.desktop @@ -0,0 +1,99 @@ +[Desktop Entry] +Type=Service +Icon=knewsticker +ServiceTypes=Kontact/Plugin,KPluginInfo +TryExec=rssservice + +X-KDE-Library=libkontact_newstickerplugin +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPluginHasSummary=true +X-KDE-KontactPluginHasPart=false + +X-KDE-PluginInfo-Name=kontact_newstickerplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=LGPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=Newsticker Component +Comment[bg]=Компонент за новини +Comment[ca]=Component de teletip de notícies +Comment[da]=Nyhedstelegraf-komponent +Comment[de]=Newsticker-Komponente +Comment[el]=Συστατικό προβολέα ειδήσεων +Comment[es]=Componente de teletipo de noticias +Comment[et]=Uudistejälgija plugin +Comment[fr]=Composant Newsticker +Comment[is]=Fréttastrimilseining +Comment[it]=Componente ticker notizie +Comment[ja]=ニュースティッカーコンポーネント +Comment[km]=សមាសភាគ Newsticker +Comment[nds]=Narichtentelegraaf-Komponent +Comment[nl]=Nieuwstickercomponent +Comment[pl]=Składnik paska wiadomości +Comment[ru]=Компонент новостей +Comment[sr]=Компонента откуцавача вести +Comment[sr@Latn]=Komponenta otkucavača vesti +Comment[sv]=Nyhetsövervakningskomponent +Comment[tr]=Haber İzleyici Bileşeni +Comment[zh_CN]=新闻点点通组件 +Comment[zh_TW]=新聞顯示組件 +Name=News +Name[af]=Nuus +Name[ar]=الأخبار +Name[be]=Навіны +Name[bg]=Новини +Name[br]=Keleier +Name[bs]=Usenet +Name[ca]=Notícies +Name[cs]=Novinky +Name[cy]=Newyddion +Name[da]=Nyheder +Name[de]=Usenet +Name[el]=Νέα +Name[eo]=Novaĵoj +Name[es]=Noticias +Name[et]=Uudisegrupid +Name[eu]=Berriak +Name[fa]=اخبار +Name[fi]=Uutiset +Name[fr]=Nouvelles +Name[fy]=Nijs +Name[ga]=Nuacht +Name[gl]=Novas +Name[he]=חדשות +Name[hi]=समाचार +Name[hu]=Hírek +Name[is]=Fréttir +Name[ja]=ニュース +Name[ka]=სიახლეები +Name[kk]=Жаңалықтар +Name[km]=ព័ត៌មាន +Name[lt]=Naujienos +Name[mk]=Вести +Name[ms]=Berita +Name[nb]=Njus +Name[nds]=Narichten +Name[ne]=समाचार +Name[nl]=Nieuws +Name[nn]=Nyheiter +Name[pa]=ਖ਼ਬਰਾਂ +Name[pl]=Listy dyskusyjne +Name[pt]=Notícias +Name[pt_BR]=Notícias +Name[ro]=Ştiri +Name[ru]=Новости +Name[se]=Ođđasat +Name[sk]=Diskusné skupiny +Name[sl]=Novice +Name[sr]=Вести +Name[sr@Latn]=Vesti +Name[sv]=Nyheter +Name[ta]=செய்திகள் +Name[tg]=Ахборот +Name[th]=ข่าว +Name[tr]=Haberler +Name[uk]=Новини +Name[uz]=Yangiliklar +Name[uz@cyrillic]=Янгиликлар +Name[zh_CN]=新闻 +Name[zh_TW]=新聞 diff --git a/kontact/plugins/newsticker/summarywidget.cpp b/kontact/plugins/newsticker/summarywidget.cpp new file mode 100644 index 000000000..14b7bc27a --- /dev/null +++ b/kontact/plugins/newsticker/summarywidget.cpp @@ -0,0 +1,319 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 <qclipboard.h> +#include <qeventloop.h> +#include <qhbox.h> +#include <qlayout.h> +#include <qpixmap.h> +#include <qpopupmenu.h> +#include <qcursor.h> + +#include <dcopclient.h> +#include <kapplication.h> +#include <kcharsets.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kurllabel.h> + +#include "summarywidget.h" + +SummaryWidget::SummaryWidget( QWidget *parent, const char *name ) + : Kontact::Summary( parent, name ), + DCOPObject( "NewsTickerPlugin" ), mLayout( 0 ), mFeedCounter( 0 ) +{ + QVBoxLayout *vlay = new QVBoxLayout( this, 3, 3 ); + + QPixmap icon = KGlobal::iconLoader()->loadIcon( "kontact_news", + KIcon::Desktop, KIcon::SizeMedium ); + + QWidget *header = createHeader( this, icon, i18n( "News Feeds" ) ); + vlay->addWidget( header ); + + QString error; + QCString appID; + + bool dcopAvailable = true; + if ( !kapp->dcopClient()->isApplicationRegistered( "rssservice" ) ) { + if ( KApplication::startServiceByDesktopName( "rssservice", QStringList(), &error, &appID ) ) { + QLabel *label = new QLabel( i18n( "No rss dcop service available.\nYou need rssservice to use this plugin." ), this ); + vlay->addWidget( label, Qt::AlignHCenter ); + dcopAvailable = false; + } + } + + mBaseWidget = new QWidget( this, "baseWidget" ); + vlay->addWidget( mBaseWidget ); + + connect( &mTimer, SIGNAL( timeout() ), this, SLOT( updateDocuments() ) ); + + readConfig(); + + connectDCOPSignal( 0, 0, "documentUpdateError(DCOPRef,int)", "documentUpdateError(DCOPRef, int)", false ); + + if ( dcopAvailable ) + initDocuments(); + + connectDCOPSignal( 0, 0, "added(QString)", "documentAdded(QString)", false ); + connectDCOPSignal( 0, 0, "removed(QString)", "documentRemoved(QString)", false ); +} + +int SummaryWidget::summaryHeight() const +{ + return ( mFeeds.count() == 0 ? 1 : mFeeds.count() ); +} + +void SummaryWidget::documentAdded( QString ) +{ + initDocuments(); +} + +void SummaryWidget::documentRemoved( QString ) +{ + initDocuments(); +} + +void SummaryWidget::configChanged() +{ + readConfig(); + + updateView(); +} + +void SummaryWidget::readConfig() +{ + KConfig config( "kcmkontactkntrc" ); + config.setGroup( "General" ); + + mUpdateInterval = config.readNumEntry( "UpdateInterval", 600 ); + mArticleCount = config.readNumEntry( "ArticleCount", 4 ); +} + +void SummaryWidget::initDocuments() +{ + mFeeds.clear(); + + DCOPRef dcopCall( "rssservice", "RSSService" ); + QStringList urls; + dcopCall.call( "list()" ).get( urls ); + + if ( urls.isEmpty() ) { // add default + urls.append( "http://www.kde.org/dotkdeorg.rdf" ); + dcopCall.send( "add(QString)", urls[ 0 ] ); + } + + QStringList::Iterator it; + for ( it = urls.begin(); it != urls.end(); ++it ) { + DCOPRef feedRef = dcopCall.call( "document(QString)", *it ); + + Feed feed; + feed.ref = feedRef; + feedRef.call( "title()" ).get( feed.title ); + feedRef.call( "link()" ).get( feed.url ); + feedRef.call( "pixmap()" ).get( feed.logo ); + mFeeds.append( feed ); + + disconnectDCOPSignal( "rssservice", feedRef.obj(), "documentUpdated(DCOPRef)", 0 ); + connectDCOPSignal( "rssservice", feedRef.obj(), "documentUpdated(DCOPRef)", + "documentUpdated(DCOPRef)", false ); + + if ( qApp ) + qApp->eventLoop()->processEvents( QEventLoop::ExcludeUserInput | + QEventLoop::ExcludeSocketNotifiers ); + } + + updateDocuments(); +} + +void SummaryWidget::updateDocuments() +{ + mTimer.stop(); + + FeedList::Iterator it; + for ( it = mFeeds.begin(); it != mFeeds.end(); ++it ) + (*it).ref.send( "refresh()" ); + + mTimer.start( 1000 * mUpdateInterval ); +} + +void SummaryWidget::documentUpdated( DCOPRef feedRef ) +{ + ArticleMap map; + + int numArticles = feedRef.call( "count()" ); + for ( int i = 0; i < numArticles; ++i ) { + DCOPRef artRef = feedRef.call( "article(int)", i ); + QString title, url; + + if ( qApp ) + qApp->eventLoop()->processEvents( QEventLoop::ExcludeUserInput | + QEventLoop::ExcludeSocketNotifiers ); + + artRef.call( "title()" ).get( title ); + artRef.call( "link()" ).get( url ); + + QPair<QString, KURL> article(title, KURL( url )); + map.append( article ); + } + + FeedList::Iterator it; + for ( it = mFeeds.begin(); it != mFeeds.end(); ++it ) + if ( (*it).ref.obj() == feedRef.obj() ) { + (*it).map = map; + if ( (*it).title.isEmpty() ) + feedRef.call( "title()" ).get( (*it).title ); + if ( (*it).url.isEmpty() ) + feedRef.call( "link()" ).get( (*it).url ); + if ( (*it).logo.isNull() ) + feedRef.call( "pixmap()" ).get( (*it).logo ); + } + + mFeedCounter++; + if ( mFeedCounter == mFeeds.count() ) { + mFeedCounter = 0; + updateView(); + } +} + +void SummaryWidget::updateView() +{ + mLabels.setAutoDelete( true ); + mLabels.clear(); + mLabels.setAutoDelete( false ); + + delete mLayout; + mLayout = new QVBoxLayout( mBaseWidget, 3 ); + + QFont boldFont; + boldFont.setBold( true ); + boldFont.setPointSize( boldFont.pointSize() + 2 ); + + FeedList::Iterator it; + for ( it = mFeeds.begin(); it != mFeeds.end(); ++it ) { + QHBox *hbox = new QHBox( mBaseWidget ); + mLayout->addWidget( hbox ); + + // icon + KURLLabel *urlLabel = new KURLLabel( hbox ); + urlLabel->setURL( (*it).url ); + urlLabel->setPixmap( (*it).logo ); + urlLabel->setMaximumSize( urlLabel->minimumSizeHint() ); + mLabels.append( urlLabel ); + + connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ), + kapp, SLOT( invokeBrowser( const QString& ) ) ); + connect( urlLabel, SIGNAL( rightClickedURL( const QString& ) ), + this, SLOT( rmbMenu( const QString& ) ) ); + + // header + QLabel *label = new QLabel( hbox ); + label->setText( KCharsets::resolveEntities( (*it).title ) ); + label->setAlignment( AlignLeft|AlignVCenter ); + label->setFont( boldFont ); + label->setIndent( 6 ); + label->setMaximumSize( label->minimumSizeHint() ); + mLabels.append( label ); + + hbox->setMaximumWidth( hbox->minimumSizeHint().width() ); + hbox->show(); + + // articles + ArticleMap articles = (*it).map; + ArticleMap::Iterator artIt; + int numArticles = 0; + for ( artIt = articles.begin(); artIt != articles.end() && numArticles < mArticleCount; ++artIt ) { + urlLabel = new KURLLabel( (*artIt).second.url(), (*artIt).first, mBaseWidget ); + urlLabel->installEventFilter( this ); + //TODO: RichText causes too much horizontal space between articles + //urlLabel->setTextFormat( RichText ); + mLabels.append( urlLabel ); + mLayout->addWidget( urlLabel ); + + connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ), + kapp, SLOT( invokeBrowser( const QString& ) ) ); + connect( urlLabel, SIGNAL( rightClickedURL( const QString& ) ), + this, SLOT( rmbMenu( const QString& ) ) ); + + + numArticles++; + } + } + + for ( QLabel *label = mLabels.first(); label; label = mLabels.next() ) + label->show(); +} + +void SummaryWidget::documentUpdateError( DCOPRef feedRef, int errorCode ) +{ + kdDebug() << " error while updating document, error code: " << errorCode << endl; + FeedList::Iterator it; + for ( it = mFeeds.begin(); it != mFeeds.end(); ++it ) { + if ( (*it).ref.obj() == feedRef.obj() ) { + mFeeds.remove( it ); + break; + } + } + + if ( mFeedCounter == mFeeds.count() ) { + mFeedCounter = 0; + updateView(); + } + +} + +QStringList SummaryWidget::configModules() const +{ + return "kcmkontactknt.desktop"; +} + +void SummaryWidget::updateSummary( bool ) +{ + updateDocuments(); +} + +void SummaryWidget::rmbMenu( const QString& url ) +{ + QPopupMenu menu; + menu.insertItem( i18n( "Copy URL to Clipboard" ) ); + int id = menu.exec( QCursor::pos() ); + if ( id != -1 ) + kapp->clipboard()->setText( url, QClipboard::Clipboard ); +} + +bool SummaryWidget::eventFilter( QObject *obj, QEvent* e ) +{ + if ( obj->inherits( "KURLLabel" ) ) { + KURLLabel* label = static_cast<KURLLabel*>( obj ); + if ( e->type() == QEvent::Enter ) + emit message( label->url() ); + if ( e->type() == QEvent::Leave ) + emit message( QString::null ); + } + + return Kontact::Summary::eventFilter( obj, e ); +} + +#include "summarywidget.moc" diff --git a/kontact/plugins/newsticker/summarywidget.h b/kontact/plugins/newsticker/summarywidget.h new file mode 100644 index 000000000..ad914334b --- /dev/null +++ b/kontact/plugins/newsticker/summarywidget.h @@ -0,0 +1,115 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 SUMMARYWIDGET_H +#define SUMMARYWIDGET_H + +#include <dcopobject.h> +#include <dcopref.h> + +#include <qmap.h> +#include <qptrlist.h> +#include <qtimer.h> +#include <qwidget.h> + +#include "summary.h" +#include <kurl.h> + +class QVBoxLayout; +class QLabel; + +class DCOPRef; +class KURLLabel; + +typedef QValueList< QPair<QString, KURL> > ArticleMap; + +typedef struct { + DCOPRef ref; + QString title; + QString url; + QPixmap logo; + ArticleMap map; +} Feed; + +typedef QValueList<Feed> FeedList; + +class SummaryWidget : public Kontact::Summary, public DCOPObject +{ + Q_OBJECT + K_DCOP + + public: + SummaryWidget( QWidget *parent, const char *name = 0 ); + + int summaryHeight() const; + QStringList configModules() const; + + k_dcop: + /** + * Inform the newsticker summary widget that an RSSDocument has been updated. + */ + void documentUpdated( DCOPRef ); + /** + * Inform the newsticker summary widget that a feed has been added. + */ + void documentAdded( QString ); + /** + * Inform the newsticker summary widget that a feed has been removed. + */ + void documentRemoved( QString ); + /** + * Inform the newsticker summary widget that an error occurred while updating a feed. + * @param ref DCOPRef to the failing RSSDocument. + * @param errorCode indicates the cause of the failure: 1 = RSS Parse Error, 2 = Could not access file, 3 = Unknown error. + */ + void documentUpdateError( DCOPRef ref, int errorCode ); + + public slots: + void updateSummary( bool force = false ); + void configChanged(); + + protected slots: + void updateDocuments(); + void rmbMenu( const QString& ); + + protected: + virtual bool eventFilter( QObject *obj, QEvent *e ); + void initDocuments(); + void updateView(); + void readConfig(); + + private: + QVBoxLayout *mLayout; + QWidget* mBaseWidget; + + QPtrList<QLabel> mLabels; + + FeedList mFeeds; + + QTimer mTimer; + int mUpdateInterval; + int mArticleCount; + uint mFeedCounter; +}; + +#endif diff --git a/kontact/plugins/specialdates/Makefile.am b/kontact/plugins/specialdates/Makefile.am new file mode 100644 index 000000000..7bedb2051 --- /dev/null +++ b/kontact/plugins/specialdates/Makefile.am @@ -0,0 +1,31 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces \ + -I$(top_srcdir)/libkdepim \ + -I$(top_srcdir) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_specialdatesplugin.la kcm_sdsummary.la +libkontact_specialdatesplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_specialdatesplugin_la_LIBADD = \ + $(top_builddir)/kontact/interfaces/libkpinterfaces.la \ + $(top_builddir)/libkdepim/libkdepim.la \ + $(top_builddir)/libkholidays/libkholidays.la \ + $(top_builddir)/korganizer/libkorganizer_calendar.la \ + $(top_builddir)/kaddressbook/libkaddressbook.la + +libkontact_specialdatesplugin_la_SOURCES = specialdates_plugin.cpp \ + sdsummarywidget.cpp + +kcm_sdsummary_la_SOURCES = kcmsdsummary.cpp +kcm_sdsummary_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) \ + -avoid-version -no-undefined +kcm_sdsummary_la_LIBADD = $(LIB_KDEUI) + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir)/kontact +service_DATA = specialdatesplugin.desktop + +kde_services_DATA = kcmsdsummary.desktop + +specialdatesiface_DIR = $(top_srcdir)/specialdates +kmailIface_DIR = $(top_srcdir)/kmail +kmailIface_DCOPIDLNG = true diff --git a/kontact/plugins/specialdates/kcmsdsummary.cpp b/kontact/plugins/specialdates/kcmsdsummary.cpp new file mode 100644 index 000000000..9bb0211a5 --- /dev/null +++ b/kontact/plugins/specialdates/kcmsdsummary.cpp @@ -0,0 +1,248 @@ +/* + This file is part of Kontact. + Copyright (c) 2004 Tobias Koenig <tokoe@kde.org> + Copyright (c) 2004 Allen Winter <winter@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 <qbuttongroup.h> +#include <qcheckbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qradiobutton.h> +#include <qspinbox.h> + +#include <kaboutdata.h> +#include <kapplication.h> +#include <kaccelmanager.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <klocale.h> + +#include "kcmsdsummary.h" + +#include <kdepimmacros.h> + +extern "C" +{ + KDE_EXPORT KCModule *create_sdsummary( QWidget *parent, const char * ) + { + return new KCMSDSummary( parent, "kcmsdsummary" ); + } +} + +KCMSDSummary::KCMSDSummary( QWidget *parent, const char *name ) + : KCModule( parent, name ) +{ + initGUI(); + + customDaysChanged( 1 ); + + connect( mDaysGroup, SIGNAL( clicked( int ) ), SLOT( modified() ) ); + connect( mDaysGroup, SIGNAL( clicked( int ) ), SLOT( buttonClicked( int ) ) ); + connect( mCalendarGroup, SIGNAL( clicked( int ) ), SLOT( modified() ) ); + connect( mContactGroup, SIGNAL( clicked( int ) ), SLOT( modified() ) ); + connect( mCustomDays, SIGNAL( valueChanged( int ) ), SLOT( modified() ) ); + connect( mCustomDays, SIGNAL( valueChanged( int ) ), SLOT( customDaysChanged( int ) ) ); + + KAcceleratorManager::manage( this ); + + load(); +} + +void KCMSDSummary::modified() +{ + emit changed( true ); +} + +void KCMSDSummary::buttonClicked( int id ) +{ + mCustomDays->setEnabled( id == 4 ); +} + +void KCMSDSummary::customDaysChanged( int value ) +{ + mCustomDays->setSuffix( i18n( " day", " days", value ) ); +} + +void KCMSDSummary::initGUI() +{ + QGridLayout *layout = new QGridLayout( this, 3, 2, KDialog::spacingHint() ); + + mDaysGroup = new QButtonGroup( 0, Vertical, i18n( "Special Dates Summary" ), this ); + QVBoxLayout *boxLayout = new QVBoxLayout( mDaysGroup->layout(), + KDialog::spacingHint() ); + + QLabel *label = new QLabel( i18n( "How many days should the special dates summary show at once?" ), mDaysGroup ); + boxLayout->addWidget( label ); + + QRadioButton *button = new QRadioButton( i18n( "One day" ), mDaysGroup ); + boxLayout->addWidget( button ); + + button = new QRadioButton( i18n( "Five days" ), mDaysGroup ); + boxLayout->addWidget( button ); + + button = new QRadioButton( i18n( "One week" ), mDaysGroup ); + boxLayout->addWidget( button ); + + button = new QRadioButton( i18n( "One month" ), mDaysGroup ); + boxLayout->addWidget( button ); + + QHBoxLayout *hbox = new QHBoxLayout( boxLayout, KDialog::spacingHint() ); + + button = new QRadioButton( "", mDaysGroup ); + hbox->addWidget( button ); + + mCustomDays = new QSpinBox( 1, 365, 1, mDaysGroup ); + mCustomDays->setEnabled( false ); + hbox->addWidget( mCustomDays ); + + hbox->addStretch( 1 ); + + layout->addMultiCellWidget( mDaysGroup, 0, 0, 0, 1 ); + + mCalendarGroup = new QButtonGroup( 1, Horizontal, i18n( "Special Dates From Calendar" ), this ); + + mShowBirthdaysFromCal = new QCheckBox( i18n( "Show birthdays" ), mCalendarGroup ); + mShowAnniversariesFromCal = new QCheckBox( i18n( "Show anniversaries" ), mCalendarGroup ); + mShowHolidays = new QCheckBox( i18n( "Show holidays" ), mCalendarGroup ); + + mShowSpecialsFromCal = new QCheckBox( i18n( "Show special occasions" ), mCalendarGroup ); + + mContactGroup = new QButtonGroup( 1, Horizontal, i18n( "Special Dates From Contact List" ), this ); + + mShowBirthdaysFromKAB = new QCheckBox( i18n( "Show birthdays" ), mContactGroup ); + mShowAnniversariesFromKAB = new QCheckBox( i18n( "Show anniversaries" ), mContactGroup ); + + layout->addWidget( mCalendarGroup, 1, 0 ); + layout->addWidget( mContactGroup, 1, 1 ); + + layout->setRowStretch( 2, 1 ); +} + +void KCMSDSummary::load() +{ + KConfig config( "kcmsdsummaryrc" ); + + config.setGroup( "Days" ); + int days = config.readNumEntry( "DaysToShow", 7 ); + if ( days == 1 ) + mDaysGroup->setButton( 0 ); + else if ( days == 5 ) + mDaysGroup->setButton( 1 ); + else if ( days == 7 ) + mDaysGroup->setButton( 2 ); + else if ( days == 31 ) + mDaysGroup->setButton( 3 ); + else { + mDaysGroup->setButton( 4 ); + mCustomDays->setValue( days ); + mCustomDays->setEnabled( true ); + } + + config.setGroup( "EventTypes" ); + + mShowBirthdaysFromKAB-> + setChecked( config.readBoolEntry( "ShowBirthdaysFromContacts", true ) ); + mShowBirthdaysFromCal-> + setChecked( config.readBoolEntry( "ShowBirthdaysFromCalendar", true ) ); + + mShowAnniversariesFromKAB-> + setChecked( config.readBoolEntry( "ShowAnniversariesFromContacts", true ) ); + mShowAnniversariesFromCal-> + setChecked( config.readBoolEntry( "ShowAnniversariesFromCalendar", true ) ); + + mShowHolidays-> + setChecked( config.readBoolEntry( "ShowHolidays", true ) ); + + mShowSpecialsFromCal-> + setChecked( config.readBoolEntry( "ShowSpecialsFromCalendar", true ) ); + + emit changed( false ); +} + +void KCMSDSummary::save() +{ + KConfig config( "kcmsdsummaryrc" ); + + config.setGroup( "Days" ); + + int days; + switch ( mDaysGroup->selectedId() ) { + case 0: days = 1; break; + case 1: days = 5; break; + case 2: days = 7; break; + case 3: days = 31; break; + case 4: + default: days = mCustomDays->value(); break; + } + config.writeEntry( "DaysToShow", days ); + + config.setGroup( "EventTypes" ); + + config.writeEntry( "ShowBirthdaysFromContacts", + mShowBirthdaysFromKAB->isChecked() ); + config.writeEntry( "ShowBirthdaysFromCalendar", + mShowBirthdaysFromCal->isChecked() ); + + config.writeEntry( "ShowAnniversariesFromContacts", + mShowAnniversariesFromKAB->isChecked() ); + config.writeEntry( "ShowAnniversariesFromCalendar", + mShowAnniversariesFromCal->isChecked() ); + + config.writeEntry( "ShowHolidays", + mShowHolidays->isChecked() ); + + config.writeEntry( "ShowSpecialsFromCalendar", + mShowSpecialsFromCal->isChecked() ); + + config.sync(); + + emit changed( false ); +} + +void KCMSDSummary::defaults() +{ + mDaysGroup->setButton( 7 ); + mShowBirthdaysFromKAB->setChecked( true ); + mShowBirthdaysFromCal->setChecked( true ); + mShowAnniversariesFromKAB->setChecked( true ); + mShowAnniversariesFromCal->setChecked( true ); + mShowHolidays->setChecked( true ); + mShowSpecialsFromCal->setChecked( true ); + + emit changed( true ); +} + +const KAboutData* KCMSDSummary::aboutData() const +{ + KAboutData *about = new KAboutData( I18N_NOOP( "kcmsdsummary" ), + I18N_NOOP( "Special Dates Configuration Dialog" ), + 0, 0, KAboutData::License_GPL, + I18N_NOOP( "(c) 2004 Tobias Koenig" ) ); + + about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); + about->addAuthor( "Allen Winter", 0, "winter@kde.org" ); + + return about; +} + +#include "kcmsdsummary.moc" diff --git a/kontact/plugins/specialdates/kcmsdsummary.desktop b/kontact/plugins/specialdates/kcmsdsummary.desktop new file mode 100644 index 000000000..f294c3835 --- /dev/null +++ b/kontact/plugins/specialdates/kcmsdsummary.desktop @@ -0,0 +1,126 @@ +[Desktop Entry] +Icon=cookie +Type=Service +ServiceTypes=KCModule + +X-KDE-ModuleType=Library +X-KDE-Library=sdsummary +X-KDE-FactoryName=sdsummary +X-KDE-ParentApp=kontact_specialdatesplugin +X-KDE-ParentComponents=kontact_specialdatesplugin +X-KDE-CfgDlgHierarchy=KontactSummary + +Name=Special Dates Overview +Name[bg]=Преглед на специални случаи +Name[ca]=Resum de dates especials +Name[da]=Oversigt over særlige datoer +Name[de]=Übersicht über besondere Termine +Name[el]=Επισκόπηση σημαντικών ημερομηνιών +Name[es]=Resumen de fechas especiales +Name[et]=Tähtpäevade ülevaade +Name[fr]=Aperçu des dates importantes +Name[is]=Yfirlit sérstakra daga +Name[it]=Panoramica delle date speciali +Name[ja]=特別な日の要約 +Name[km]=ទិដ្ឋភាពកាលបរិច្ឆេទពិសេស +Name[nds]=Översicht besünner Daten +Name[nl]=Overzicht van speciale data +Name[pl]=Daty specjalne +Name[pt_BR]=Resumo de Datas Especiais +Name[ru]=Сводка особых дат +Name[sr]=Преглед посебних датума +Name[sr@Latn]=Pregled posebnih datuma +Name[sv]=Översikt av speciella datum +Name[tr]=Özel Tarihlere Genel Bakış +Name[zh_CN]=特殊日期概览 +Name[zh_TW]=特殊日期概觀 +Comment=Special Dates Summary Setup +Comment[af]=Spesiale datums opsomming opstelling +Comment[bg]=Настройки на специалните случаи +Comment[ca]=Configuració del resum de les dates especials +Comment[cs]=Nastavení souhrnu speciálních datumů +Comment[da]=Opsummering af opsætning af særlige datoer +Comment[de]=Einstellung der Übersicht über besondere Termine +Comment[el]=Ρύθμιση σύνοψης σημαντικών ημερομηνιών +Comment[es]=Configuración del resumen de las fechas especiales +Comment[et]=Tähtpäevade kokkuvõtte seadistus +Comment[eu]=Data berezien laburpenen konfigurazioa +Comment[fa]=برپایی خلاصۀ تاریخهای ویژه +Comment[fi]=Erikoispäivien yhteenvedon asetukset +Comment[fr]=Configuration du résumé des dates particulières +Comment[fy]=Spesjale datums oersichts opset +Comment[gl]=Configuración do Resumo de Datas Especiais +Comment[he]=תצורת תאריכים מיוחדים +Comment[hu]=A fontos dátumok áttekintőjének beállításai +Comment[is]=Yfirlitsuppsetning sérstakra daga +Comment[it]=Impostazioni per le date speciali +Comment[ja]=特別な日の要約設定 +Comment[ka]=განსაკუთრებულ თარიღთა დაიჯესტის კონფიგურაცია +Comment[kk]=Ерекше күндер тұжырымының баптауы +Comment[km]=រៀបចំសេចក្ដីសង្ខេបថ្ងៃពិសេស +Comment[lt]=Ypatingų datų santraukos sąranka +Comment[mk]=Поставувања за прегледот на специјални датуми +Comment[ms]=Setup Ringkasan Tarikh Khusus +Comment[nb]=Sammendragsoppsett for spesielle datoer +Comment[nds]=Översicht över besünner Daag instellen +Comment[ne]=विशेष मिति सारांश सेटअप +Comment[nl]=Instellingen voor speciale data in overzicht +Comment[nn]=Oppsett av samandrag for spesielle datoar +Comment[pl]=Ustawienia podsumowania dat specjalnych +Comment[pt]=Configuração do Sumário de Datas Especiais +Comment[pt_BR]=Configuração do Resumo de Datas Especiais +Comment[ru]=Настройка особых дат +Comment[sk]=Nastavenie súhrnu špeciálnych dátumov +Comment[sl]=Nastavitve povzetka posebnih datumov +Comment[sr]=Подешавање сажетка посебних датума +Comment[sr@Latn]=Podešavanje sažetka posebnih datuma +Comment[sv]=Inställning av översikt av speciella datum +Comment[ta]=விசேஷ தேதிகள் சுருக்க அமைப்பு +Comment[th]=ต้้งค่าส่วนสรุปวันพิเศษ +Comment[tr]=Özel Tarih Özeti Yapılandırması +Comment[uk]=Налаштування підсумку особливих дат +Comment[zh_CN]=特殊日期摘要设置 +Comment[zh_TW]=特殊日期摘要設定 +Keywords=birthday, anniversary, holiday, configure, settings +Keywords[af]=birtday,anniversary, holiday, conifugre, settings, verjaarsdag, herdenking, vakansie +Keywords[bg]=рождени, рожден, дни, ден, годишнина, годишнини, обобщение, birthday, anniversary, configure, settings +Keywords[ca]=data de naixement, aniversari, vacances, configuració, arranjament +Keywords[cs]=narozeniny,výročí,nastavení,nastavit,svátek +Keywords[da]=fødselsdag, årsdag, helligdage, indstil, opsætning +Keywords[de]=Geburtstag,Jahrestag,Feiertag,einstellen,Einstellungen,Einrichten +Keywords[el]=γενέθλια, επέτειος, εορτή, ρύθμιση, ρυθμίσεις +Keywords[es]=cumpleaños, aniversario, vacaciones, configurar, preferencias +Keywords[et]=sünnipäev, tähtpäev, pidupäev, seadistamine, seadistused +Keywords[eu]=urtebetezea, urteurrena, jaia, konfiguratu, ezarpenak +Keywords[fa]=تولد، جشن سالانه، تعطیلات، پیکربندی، تنظیمات +Keywords[fi]=syntymäpäivä, juhlapäivä, loma, aseta, asetukset +Keywords[fr]=anniversaire,date de naissance,vacances,configurer,paramètres,préférences +Keywords[fy]=verjaardag,jubileum,vakantie,instellingen,configuratie,feestdag, jierdei, fakânsje, ynstellings, feestdei +Keywords[gl]=cumpreanos, aniversario, vacacións, configurar, opcións +Keywords[he]=birthday, anniversary, holiday, configure, settings, יום הולדת, הולדת, שנה, יום שנה, חג, חגים, תצורה, הגדרות +Keywords[hu]=születésnap,évforduló,szabadság,konfigurálás,beállítások +Keywords[is]=afmæli, frídagar, stillingar, stilla +Keywords[it]=compleanno, anniversario, vacanze, configura, impostazioni +Keywords[ja]=誕生日,記念日,休日,設定,設定 +Keywords[ka]=დაბადების დღე,სახელობის დღე,დასვენების დღე,კონფიგურაცია,პარამეტრები +Keywords[km]=ថ្ងៃខួបកំណើត,បុណ្យខួប,វិស្សមកាល,កំណត់រចនាសម្ព័ន្ធ,ការកំណត់ +Keywords[lt]=birthday, anniversary, holiday, configure, settings, konfigūruoti, nustatymai, gimtadieniai, išeiginės,sukaktys +Keywords[mk]=birthday, anniversary, holiday, configure, settings, роденден, годишнина, конфигурирање, конфигурација, поставувања +Keywords[ms]=tarikh lahir, ulang tahun, cuti, konfigur, seting +Keywords[nb]=fødselsdag, jubileum, ferie, sette opp, innstillinger +Keywords[nds]=Geboortsdag,Johrdag,Fierdag,instellen +Keywords[ne]=जन्मदिन, वार्षिकोत्सव, बिदा, कन्फिगर, सेटिङ +Keywords[nl]=verjaardag,jubileum,vakantie,instellingen,configuratie,feestdag +Keywords[nn]=fødselsdag,bursdag,gebursdag,jubileum,ferie,helgedag,merkedag,oppsett,innstillingar +Keywords[pl]=urodziny,rocznica,rocznice,wakacje,urlop,konfiguracja,ustawienia +Keywords[pt]=data de nascimento, aniversário, feriado, configurar, configuração +Keywords[pt_BR]=aniversário,aniversário de casamento, feriados,configurar,configurações +Keywords[ru]=birthday,anniversary,configure,settings,дни рождения,настройки,праздники,годовщины +Keywords[sl]=rojstni dan, obletnica, praznik, nastavi, nastavitve +Keywords[sr]=birthday, anniversary, holiday, configure, settings, рођендан, годишњица, подеси, поставке, подешавања +Keywords[sr@Latn]=birthday, anniversary, holiday, configure, settings, rođendan, godišnjica, podesi, postavke, podešavanja +Keywords[sv]=födelsedag,årsdag,helgdag,anpassa,inställningar +Keywords[ta]=பிறந்தநாள், ஆண்டுவிழா, விடுமுறை, வடிவமைப்பு, அமைப்புகள் +Keywords[tr]=doğumgünü, evlilik yıldönümü, tatil, yapılandır, ypılandırma +Keywords[uk]=birthday, anniversary, holiday, configure, settings, день народження, ювілей, свято, налаштування, параметри +Keywords[zh_CN]=birthday, anniversary, holiday, configure, settings, 周年纪念, 配置, 设置, 假日 diff --git a/kontact/plugins/specialdates/kcmsdsummary.h b/kontact/plugins/specialdates/kcmsdsummary.h new file mode 100644 index 000000000..60b2ea082 --- /dev/null +++ b/kontact/plugins/specialdates/kcmsdsummary.h @@ -0,0 +1,69 @@ +/* + This file is part of Kontact. + Copyright (c) 2004 Tobias Koenig <tokoe@kde.org> + Copyright (c) 2004 Allen Winter <winter@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 KCMSDSUMMARY_H +#define KCMSDSUMMARY_H + +#include <kcmodule.h> + +class QButtonGroup; +class QCheckBox; +class QSpinBox; + +class KAboutData; + +class KCMSDSummary : public KCModule +{ + Q_OBJECT + + public: + KCMSDSummary( QWidget *parent = 0, const char *name = 0 ); + + virtual void load(); + virtual void save(); + virtual void defaults(); + virtual const KAboutData* aboutData() const; + + private slots: + void modified(); + void buttonClicked( int ); + void customDaysChanged( int ); + + private: + void initGUI(); + + QButtonGroup *mDaysGroup; + QButtonGroup *mCalendarGroup; + QButtonGroup *mContactGroup; + QCheckBox *mShowBirthdaysFromKAB; + QCheckBox *mShowBirthdaysFromCal; + QCheckBox *mShowAnniversariesFromKAB; + QCheckBox *mShowAnniversariesFromCal; + QCheckBox *mShowHolidays; + QCheckBox *mShowHolidaysFromCal; + QCheckBox *mShowSpecialsFromCal; + QSpinBox *mCustomDays; +}; + +#endif diff --git a/kontact/plugins/specialdates/sdsummarywidget.cpp b/kontact/plugins/specialdates/sdsummarywidget.cpp new file mode 100644 index 000000000..721073490 --- /dev/null +++ b/kontact/plugins/specialdates/sdsummarywidget.cpp @@ -0,0 +1,637 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> + Copyright (c) 2004 Allen Winter <winter@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 <qcursor.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qimage.h> +#include <qtooltip.h> + +#include <dcopclient.h> +#include <dcopref.h> +#include <kabc/stdaddressbook.h> +#include <korganizer/stdcalendar.h> +#include <kapplication.h> +#include <kdialog.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kparts/part.h> +#include <kpopupmenu.h> +#include <kstandarddirs.h> +#include <kurllabel.h> +#include <libkcal/event.h> +#include <libkcal/resourcecalendar.h> +#include <libkcal/resourcelocal.h> +#include <libkdepim/kpimprefs.h> + +#include "core.h" +#include "plugin.h" + +#include "sdsummarywidget.h" + +enum SDIncidenceType { + IncidenceTypeContact, IncidenceTypeEvent +}; +enum SDCategory { + CategoryBirthday, CategoryAnniversary, CategoryHoliday, CategoryOther +}; + +class SDEntry +{ + public: + SDIncidenceType type; + SDCategory category; + int yearsOld; + int daysTo; + QDate date; + QString summary; + QString desc; + int span; // #days in the special occassion. + KABC::Addressee addressee; + + bool operator<( const SDEntry &entry ) const + { + return daysTo < entry.daysTo; + } +}; + +SDSummaryWidget::SDSummaryWidget( Kontact::Plugin *plugin, QWidget *parent, + const char *name ) + : Kontact::Summary( parent, name ), mPlugin( plugin ), mCalendar( 0 ), mHolidays( 0 ) +{ + // Create the Summary Layout + QVBoxLayout *mainLayout = new QVBoxLayout( this, 3, 3 ); + + QPixmap icon = KGlobal::iconLoader()->loadIcon( "cookie", + KIcon::Desktop, KIcon::SizeMedium ); + + QWidget *header = createHeader( this, icon, i18n( "Special Dates" ) ); + mainLayout->addWidget(header); + + mLayout = new QGridLayout( mainLayout, 7, 6, 3 ); + mLayout->setRowStretch( 6, 1 ); + + // Setup the Addressbook + KABC::StdAddressBook *ab = KABC::StdAddressBook::self( true ); + connect( ab, SIGNAL( addressBookChanged( AddressBook* ) ), + this, SLOT( updateView() ) ); + connect( mPlugin->core(), SIGNAL( dayChanged( const QDate& ) ), + this, SLOT( updateView() ) ); + + // Setup the Calendar + mCalendar = new KCal::CalendarResources( KPimPrefs::timezone() ); + mCalendar->readConfig(); + + KCal::CalendarResourceManager *manager = mCalendar->resourceManager(); + if ( manager->isEmpty() ) { + KConfig config( "korganizerrc" ); + config.setGroup( "General" ); + QString fileName = config.readPathEntry( "Active Calendar" ); + + QString resourceName; + if ( fileName.isEmpty() ) { + fileName = locateLocal( "data", "korganizer/std.ics" ); + resourceName = i18n( "Default KOrganizer resource" ); + } else { + resourceName = i18n( "Active Calendar" ); + } + + KCal::ResourceCalendar *defaultResource = + new KCal::ResourceLocal( fileName ); + + defaultResource->setResourceName( resourceName ); + + manager->add( defaultResource ); + manager->setStandardResource( defaultResource ); + } + mCalendar = KOrg::StdCalendar::self(); + mCalendar->load(); + + connect( mCalendar, SIGNAL( calendarChanged() ), + this, SLOT( updateView() ) ); + connect( mPlugin->core(), SIGNAL( dayChanged( const QDate& ) ), + this, SLOT( updateView() ) ); + + // Update Configuration + configUpdated(); +} + +void SDSummaryWidget::configUpdated() +{ + KConfig config( "kcmsdsummaryrc" ); + + config.setGroup( "Days" ); + mDaysAhead = config.readNumEntry( "DaysToShow", 7 ); + + config.setGroup( "EventTypes" ); + mShowBirthdaysFromKAB = + config.readBoolEntry( "ShowBirthdaysFromContacts", true ); + mShowBirthdaysFromCal = + config.readBoolEntry( "ShowBirthdaysFromCalendar", true ); + + mShowAnniversariesFromKAB = + config.readBoolEntry( "ShowAnniversariesFromContacts", true ); + mShowAnniversariesFromCal = + config.readBoolEntry( "ShowAnniversariesFromCalendar", true ); + + mShowHolidays = + config.readBoolEntry( "ShowHolidays", true ); + + mShowSpecialsFromCal = + config.readBoolEntry( "ShowSpecialsFromCalendar", true ); + + updateView(); +} + +bool SDSummaryWidget::initHolidays() +{ + KConfig hconfig( "korganizerrc" ); + hconfig.setGroup( "Time & Date" ); + QString location = hconfig.readEntry( "Holidays" ); + if ( !location.isEmpty() ) { + if ( mHolidays ) delete mHolidays; + mHolidays = new KHolidays( location ); + return true; + } + return false; +} + +// number of days remaining in an Event +int SDSummaryWidget::span( KCal::Event *event ) +{ + int span=1; + if ( event->isMultiDay() && event->doesFloat() ) { + QDate d = event->dtStart().date(); + if ( d < QDate::currentDate() ) { + d = QDate::currentDate(); + } + while ( d < event->dtEnd().date() ) { + span++; + d=d.addDays( 1 ); + } + } + return span; +} + +// day of a multiday Event +int SDSummaryWidget::dayof( KCal::Event *event, const QDate& date ) +{ + int dayof=1; + QDate d = event->dtStart().date(); + if ( d < QDate::currentDate() ) { + d = QDate::currentDate(); + } + while ( d < event->dtEnd().date() ) { + if ( d < date ) { + dayof++; + } + d = d.addDays( 1 ); + } + return dayof; +} + + + +void SDSummaryWidget::updateView() +{ + mLabels.setAutoDelete( true ); + mLabels.clear(); + mLabels.setAutoDelete( false ); + + KABC::StdAddressBook *ab = KABC::StdAddressBook::self( true ); + QValueList<SDEntry> dates; + QLabel *label = 0; + + // No reason to show the date year + QString savefmt = KGlobal::locale()->dateFormat(); + KGlobal::locale()->setDateFormat( KGlobal::locale()-> + dateFormat().replace( 'Y', ' ' ) ); + + // Search for Birthdays and Anniversaries in the Addressbook + KABC::AddressBook::Iterator it; + for ( it = ab->begin(); it != ab->end(); ++it ) { + QDate birthday = (*it).birthday().date(); + if ( birthday.isValid() && mShowBirthdaysFromKAB ) { + SDEntry entry; + entry.type = IncidenceTypeContact; + entry.category = CategoryBirthday; + dateDiff( birthday, entry.daysTo, entry.yearsOld ); + + entry.date = birthday; + entry.addressee = *it; + entry.span = 1; + if ( entry.daysTo <= mDaysAhead ) + dates.append( entry ); + } + + QString anniversaryAsString = + (*it).custom( "KADDRESSBOOK" , "X-Anniversary" ); + if ( !anniversaryAsString.isEmpty() ) { + QDate anniversary = QDate::fromString( anniversaryAsString, Qt::ISODate ); + if ( anniversary.isValid() && mShowAnniversariesFromKAB ) { + SDEntry entry; + entry.type = IncidenceTypeContact; + entry.category = CategoryAnniversary; + dateDiff( anniversary, entry.daysTo, entry.yearsOld ); + + entry.date = anniversary; + entry.addressee = *it; + entry.span = 1; + if ( entry.daysTo <= mDaysAhead ) + dates.append( entry ); + } + } + } + + // Search for Birthdays, Anniversaries, Holidays, and Special Occasions + // in the Calendar + QDate dt; + QDate currentDate = QDate::currentDate(); + for ( dt=currentDate; + dt<=currentDate.addDays( mDaysAhead - 1 ); + dt=dt.addDays(1) ) { + KCal::Event::List events = mCalendar->events( dt, + KCal::EventSortStartDate, + KCal::SortDirectionAscending ); + KCal::Event *ev; + KCal::Event::List::ConstIterator it; + for ( it=events.begin(); it!=events.end(); ++it ) { + ev = *it; + if ( !ev->categoriesStr().isEmpty() ) { + QStringList::ConstIterator it2; + QStringList c = ev->categories(); + for ( it2=c.begin(); it2!=c.end(); ++it2 ) { + + // Append Birthday Event? + if ( mShowBirthdaysFromCal && + ( ( *it2 ).upper() == i18n( "BIRTHDAY" ) ) ) { + SDEntry entry; + entry.type = IncidenceTypeEvent; + entry.category = CategoryBirthday; + entry.date = dt; + entry.summary = ev->summary(); + entry.desc = ev->description(); + dateDiff( ev->dtStart().date(), entry.daysTo, entry.yearsOld ); + entry.span = 1; + dates.append( entry ); + break; + } + + // Append Anniversary Event? + if ( mShowAnniversariesFromCal && + ( ( *it2 ).upper() == i18n( "ANNIVERSARY" ) ) ) { + SDEntry entry; + entry.type = IncidenceTypeEvent; + entry.category = CategoryAnniversary; + entry.date = dt; + entry.summary = ev->summary(); + entry.desc = ev->description(); + dateDiff( ev->dtStart().date(), entry.daysTo, entry.yearsOld ); + entry.span = 1; + dates.append( entry ); + break; + } + + // Append Holiday Event? + if ( mShowHolidays && + ( ( *it2 ).upper() == i18n( "HOLIDAY" ) ) ) { + SDEntry entry; + entry.type = IncidenceTypeEvent; + entry.category = CategoryHoliday; + entry.date = dt; + entry.summary = ev->summary(); + entry.desc = ev->description(); + dateDiff( dt, entry.daysTo, entry.yearsOld ); + entry.yearsOld = -1; //ignore age of holidays + entry.span = span( ev ); + if ( entry.span > 1 && dayof( ev, dt ) > 1 ) // skip days 2,3,... + break; + dates.append( entry ); + break; + } + + // Append Special Occasion Event? + if ( mShowSpecialsFromCal && + ( ( *it2 ).upper() == i18n( "SPECIAL OCCASION" ) ) ) { + SDEntry entry; + entry.type = IncidenceTypeEvent; + entry.category = CategoryOther; + entry.date = dt; + entry.summary = ev->summary(); + entry.desc = ev->description(); + dateDiff( dt, entry.daysTo, entry.yearsOld ); + entry.yearsOld = -1; //ignore age of special occasions + entry.span = span( ev ); + if ( entry.span > 1 && dayof( ev, dt ) > 1 ) // skip days 2,3,... + break; + dates.append( entry ); + break; + } + } + } + } + } + + // Seach for Holidays + if ( mShowHolidays ) { + if ( initHolidays() ) { + for ( dt=currentDate; + dt<=currentDate.addDays( mDaysAhead - 1 ); + dt=dt.addDays(1) ) { + QValueList<KHoliday> holidays = mHolidays->getHolidays( dt ); + QValueList<KHoliday>::ConstIterator it = holidays.begin(); + for ( ; it != holidays.end(); ++it ) { + SDEntry entry; + entry.type = IncidenceTypeEvent; + entry.category = ((*it).Category==KHolidays::HOLIDAY)?CategoryHoliday:CategoryOther; + entry.date = dt; + entry.summary = (*it).text; + dateDiff( dt, entry.daysTo, entry.yearsOld ); + entry.yearsOld = -1; //ignore age of holidays + entry.span = 1; + dates.append( entry ); + } + } + } + } + + // Sort, then Print the Special Dates + qHeapSort( dates ); + + if ( !dates.isEmpty() ) { + int counter = 0; + QValueList<SDEntry>::Iterator addrIt; + QString lines; + for ( addrIt = dates.begin(); addrIt != dates.end(); ++addrIt ) { + bool makeBold = (*addrIt).daysTo == 0; // i.e., today + + // Pixmap + QImage icon_img; + QString icon_name; + KABC::Picture pic; + switch( (*addrIt).category ) { // TODO: better icons + case CategoryBirthday: + icon_name = "cookie"; + pic = (*addrIt).addressee.photo(); + if ( pic.isIntern() && !pic.data().isNull() ) { + QImage img = pic.data(); + if ( img.width() > img.height() ) { + icon_img = img.scaleWidth( 32 ); + } else { + icon_img = img.scaleHeight( 32 ); + } + } + break; + case CategoryAnniversary: + icon_name = "kdmconfig"; + pic = (*addrIt).addressee.photo(); + if ( pic.isIntern() && !pic.data().isNull() ) { + QImage img = pic.data(); + if ( img.width() > img.height() ) { + icon_img = img.scaleWidth( 32 ); + } else { + icon_img = img.scaleHeight( 32 ); + } + } + break; + case CategoryHoliday: + icon_name = "kdmconfig"; break; + case CategoryOther: + icon_name = "cookie"; break; + } + label = new QLabel( this ); + if ( icon_img.isNull() ) { + label->setPixmap( KGlobal::iconLoader()->loadIcon( icon_name, + KIcon::Small ) ); + } else { + label->setPixmap( icon_img ); + } + label->setMaximumWidth( label->minimumSizeHint().width() ); + label->setAlignment( AlignVCenter ); + mLayout->addWidget( label, counter, 0 ); + mLabels.append( label ); + + // Event date + QString datestr; + + //Muck with the year -- change to the year 'daysTo' days away + int year = currentDate.addDays( (*addrIt).daysTo ).year(); + QDate sD = QDate::QDate( year, + (*addrIt).date.month(), (*addrIt).date.day() ); + + if ( (*addrIt).daysTo == 0 ) { + datestr = i18n( "Today" ); + } else if ( (*addrIt).daysTo == 1 ) { + datestr = i18n( "Tomorrow" ); + } else { + datestr = KGlobal::locale()->formatDate( sD ); + } + // Print the date span for multiday, floating events, for the + // first day of the event only. + if ( (*addrIt).span > 1 ) { + QString endstr = + KGlobal::locale()->formatDate( sD.addDays( (*addrIt).span - 1 ) ); + datestr += " -\n " + endstr; + } + + label = new QLabel( datestr, this ); + label->setAlignment( AlignLeft | AlignVCenter ); + mLayout->addWidget( label, counter, 1 ); + mLabels.append( label ); + if ( makeBold ) { + QFont font = label->font(); + font.setBold( true ); + label->setFont( font ); + } + + // Countdown + label = new QLabel( this ); + if ( (*addrIt).daysTo == 0 ) { + label->setText( i18n( "now" ) ); + } else { + label->setText( i18n( "in 1 day", "in %n days", (*addrIt).daysTo ) ); + } + + label->setAlignment( AlignLeft | AlignVCenter ); + mLayout->addWidget( label, counter, 2 ); + mLabels.append( label ); + + // What + QString what; + switch( (*addrIt).category ) { + case CategoryBirthday: + what = i18n( "Birthday" ); break; + case CategoryAnniversary: + what = i18n( "Anniversary" ); break; + case CategoryHoliday: + what = i18n( "Holiday" ); break; + case CategoryOther: + what = i18n( "Special Occasion" ); break; + } + label = new QLabel( this ); + label->setText( what ); + label->setAlignment( AlignLeft | AlignVCenter ); + mLayout->addWidget( label, counter, 3 ); + mLabels.append( label ); + + // Description + if ( (*addrIt).type == IncidenceTypeContact ) { + KURLLabel *urlLabel = new KURLLabel( this ); + urlLabel->installEventFilter( this ); + urlLabel->setURL( (*addrIt).addressee.uid() ); + urlLabel->setText( (*addrIt).addressee.realName() ); + urlLabel->setTextFormat( Qt::RichText ); + mLayout->addWidget( urlLabel, counter, 4 ); + mLabels.append( urlLabel ); + + connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ), + this, SLOT( mailContact( const QString& ) ) ); + connect( urlLabel, SIGNAL( rightClickedURL( const QString& ) ), + this, SLOT( popupMenu( const QString& ) ) ); + } else { + label = new QLabel( this ); + label->setText( (*addrIt).summary ); + label->setTextFormat( Qt::RichText ); + mLayout->addWidget( label, counter, 4 ); + mLabels.append( label ); + if ( !(*addrIt).desc.isEmpty() ) { + QToolTip::add( label, (*addrIt).desc ); + } + } + + // Age + if ( (*addrIt).category == CategoryBirthday || + (*addrIt).category == CategoryAnniversary ) { + label = new QLabel( this ); + if ( (*addrIt).yearsOld <= 0 ) { + label->setText( "" ); + } else { + label->setText( i18n( "one year", "%n years", (*addrIt).yearsOld ) ); + } + label->setAlignment( AlignLeft | AlignVCenter ); + mLayout->addWidget( label, counter, 5 ); + mLabels.append( label ); + } + + counter++; + } + } else { + label = new QLabel( + i18n( "No special dates within the next 1 day", + "No special dates pending within the next %n days", + mDaysAhead ), this, "nothing to see" ); + label->setAlignment( AlignHCenter | AlignVCenter ); + mLayout->addMultiCellWidget( label, 0, 0, 0, 4 ); + mLabels.append( label ); + } + + for ( label = mLabels.first(); label; label = mLabels.next() ) + label->show(); + + KGlobal::locale()->setDateFormat( savefmt ); +} + +void SDSummaryWidget::mailContact( const QString &uid ) +{ + KABC::StdAddressBook *ab = KABC::StdAddressBook::self( true ); + QString email = ab->findByUid( uid ).fullEmail(); + + kapp->invokeMailer( email, QString::null ); +} + +void SDSummaryWidget::viewContact( const QString &uid ) +{ + if ( !mPlugin->isRunningStandalone() ) + mPlugin->core()->selectPlugin( "kontact_kaddressbookplugin" ); + else + mPlugin->bringToForeground(); + + DCOPRef dcopCall( "kaddressbook", "KAddressBookIface" ); + dcopCall.send( "showContactEditor(QString)", uid ); +} + +void SDSummaryWidget::popupMenu( const QString &uid ) +{ + KPopupMenu popup( this ); + popup.insertItem( KGlobal::iconLoader()->loadIcon( "kmail", KIcon::Small ), + i18n( "Send &Mail" ), 0 ); + popup.insertItem( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Small ), + i18n( "View &Contact" ), 1 ); + + switch ( popup.exec( QCursor::pos() ) ) { + case 0: + mailContact( uid ); + break; + case 1: + viewContact( uid ); + break; + } +} + +bool SDSummaryWidget::eventFilter( QObject *obj, QEvent* e ) +{ + if ( obj->inherits( "KURLLabel" ) ) { + KURLLabel* label = static_cast<KURLLabel*>( obj ); + if ( e->type() == QEvent::Enter ) + emit message( i18n( "Mail to:\"%1\"" ).arg( label->text() ) ); + if ( e->type() == QEvent::Leave ) + emit message( QString::null ); + } + + return Kontact::Summary::eventFilter( obj, e ); +} + +void SDSummaryWidget::dateDiff( const QDate &date, int &days, int &years ) +{ + QDate currentDate; + QDate eventDate; + + if ( QDate::leapYear( date.year() ) && date.month() == 2 && date.day() == 29 ) { + currentDate = QDate( date.year(), QDate::currentDate().month(), QDate::currentDate().day() ); + if ( !QDate::leapYear( QDate::currentDate().year() ) ) + eventDate = QDate( date.year(), date.month(), 28 ); // celebrate one day earlier ;) + else + eventDate = QDate( date.year(), date.month(), date.day() ); + } else { + currentDate = QDate( 0, QDate::currentDate().month(), QDate::currentDate().day() ); + eventDate = QDate( 0, date.month(), date.day() ); + } + + int offset = currentDate.daysTo( eventDate ); + if ( offset < 0 ) { + days = 365 + offset; + years = QDate::currentDate().year() + 1 - date.year(); + } else { + days = offset; + years = QDate::currentDate().year() - date.year(); + } +} + +QStringList SDSummaryWidget::configModules() const +{ + return QStringList( "kcmsdsummary.desktop" ); +} + +#include "sdsummarywidget.moc" diff --git a/kontact/plugins/specialdates/sdsummarywidget.h b/kontact/plugins/specialdates/sdsummarywidget.h new file mode 100644 index 000000000..74cd08942 --- /dev/null +++ b/kontact/plugins/specialdates/sdsummarywidget.h @@ -0,0 +1,84 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> + Copyright (c) 2004 Allen Winter <winter@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 SDSUMMARYWIDGET_H +#define SDSUMMARYWIDGET_H + +#include <qptrlist.h> +#include <qwidget.h> + +#include <libkcal/calendarresources.h> +#include <libkholidays/kholidays.h> + +#include "summary.h" + +namespace Kontact { + class Plugin; +} + +class QGridLayout; +class QLabel; + +class SDSummaryWidget : public Kontact::Summary +{ + Q_OBJECT + + public: + SDSummaryWidget( Kontact::Plugin *plugin, QWidget *parent, + const char *name = 0 ); + + QStringList configModules() const; + void configUpdated(); + void updateSummary( bool force = false ) { Q_UNUSED( force ); updateView(); } + + protected: + virtual bool eventFilter( QObject *obj, QEvent* e ); + + private slots: + void updateView(); + void popupMenu( const QString &uid ); + void mailContact( const QString &uid ); + void viewContact( const QString &uid ); + + private: + int span( KCal::Event *event ); + int dayof( KCal::Event *event, const QDate &date ); + bool initHolidays(); + void dateDiff( const QDate &date, int &days, int &years ); + QGridLayout *mLayout; + QPtrList<QLabel> mLabels; + Kontact::Plugin *mPlugin; + KCal::CalendarResources *mCalendar; + int mDaysAhead; + bool mShowBirthdaysFromKAB; + bool mShowBirthdaysFromCal; + bool mShowAnniversariesFromKAB; + bool mShowAnniversariesFromCal; + bool mShowHolidays; + bool mShowSpecialsFromCal; + + KHolidays::KHolidays *mHolidays; +}; + +#endif diff --git a/kontact/plugins/specialdates/specialdates_plugin.cpp b/kontact/plugins/specialdates/specialdates_plugin.cpp new file mode 100644 index 000000000..f0149fd9a --- /dev/null +++ b/kontact/plugins/specialdates/specialdates_plugin.cpp @@ -0,0 +1,70 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> + Copyright (c) 2004-2005 Allen Winter <winter@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 <kgenericfactory.h> +#include <klocale.h> +#include <kparts/componentfactory.h> + +#include "core.h" +#include "sdsummarywidget.h" + +#include "specialdates_plugin.h" + +typedef KGenericFactory< SpecialdatesPlugin, Kontact::Core > SpecialdatesPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_specialdatesplugin, + SpecialdatesPluginFactory( "kontact_specialdatesplugin" ) ) + +SpecialdatesPlugin::SpecialdatesPlugin( Kontact::Core *core, const char *name, const QStringList& ) + : Kontact::Plugin( core, core, name ), + mAboutData( 0 ) +{ + setInstance( SpecialdatesPluginFactory::instance() ); +} + +SpecialdatesPlugin::~SpecialdatesPlugin() +{ +} + +Kontact::Summary *SpecialdatesPlugin::createSummaryWidget( QWidget *parentWidget ) +{ + return new SDSummaryWidget( this, parentWidget ); +} + +const KAboutData *SpecialdatesPlugin::aboutData() +{ + if ( !mAboutData ) { + mAboutData = new KAboutData( "specialdates", + I18N_NOOP( "Special Dates Summary" ), + "1.0", + I18N_NOOP( "Kontact Special Dates Summary" ), + KAboutData::License_LGPL, + I18N_NOOP( "(c) 2004-2005 The KDE PIM Team" ) ); + mAboutData->addAuthor( "Allen Winter", "Current Maintainer", "winter@kde.org" ); + mAboutData->addAuthor( "Tobias Koenig", "", "tokoe@kde.org" ); + mAboutData->setProductName( "kontact/specialdates" ); + } + + return mAboutData; +} diff --git a/kontact/plugins/specialdates/specialdates_plugin.h b/kontact/plugins/specialdates/specialdates_plugin.h new file mode 100644 index 000000000..6534afb5c --- /dev/null +++ b/kontact/plugins/specialdates/specialdates_plugin.h @@ -0,0 +1,52 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> + Copyright (c) 2004 Allen Winter <winter@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 SPECIALDATES_PLUGIN_H +#define SPECIALDATES_PLUGIN_H + +#include "plugin.h" + +class SDSummaryWidget; + +class SpecialdatesPlugin : public Kontact::Plugin +{ + public: + SpecialdatesPlugin( Kontact::Core *core, const char *name, const QStringList& ); + ~SpecialdatesPlugin(); + + int weight() const { return 310; } + + const KAboutData *aboutData(); + + virtual Kontact::Summary *createSummaryWidget( QWidget *parentWidget ); + + protected: + virtual KParts::ReadOnlyPart *createPart() { return false; } + + private: + KAboutData *mAboutData; + +}; + +#endif diff --git a/kontact/plugins/specialdates/specialdatesplugin.desktop b/kontact/plugins/specialdates/specialdatesplugin.desktop new file mode 100644 index 000000000..bceb13ada --- /dev/null +++ b/kontact/plugins/specialdates/specialdatesplugin.desktop @@ -0,0 +1,92 @@ +[Desktop Entry] +Type=Service +Icon=cookie +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkontact_specialdatesplugin +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPluginHasPart=false +X-KDE-KontactPluginHasSummary=true + +X-KDE-PluginInfo-Name=kontact_specialdatesplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + +Name=Special Dates +Name[af]=Spesiale datums +Name[ar]=التواريخ المرقومة +Name[bg]=Специални случаи +Name[br]=Deiziadoù dibar +Name[ca]=Dates especials +Name[cs]=Speciální data +Name[da]=Særlige datoer +Name[de]=Besondere Termine +Name[el]=Σημαντικές ημερομηνίες +Name[eo]=Specialaj Datoj +Name[es]=Fechas especiales +Name[et]=Tähtpäevad +Name[eu]=Data bereziak +Name[fa]=تاریخهای ویژه +Name[fi]=Erikoispäivät +Name[fr]=Dates importantes +Name[fy]=Spesjale datums +Name[ga]=Dátaí Speisialta +Name[gl]=Datas Especiais +Name[he]=תאריכים מיוחדים +Name[hu]=Fontos dátumok +Name[is]=Sérstakir dagar +Name[it]=Date speciali +Name[ja]=特別な日 +Name[ka]=განსაკუტრებული თარიღები +Name[kk]=Ерекше күндер +Name[km]=ថ្ងៃពិសេស +Name[lt]=Ypatingos datos +Name[mk]=Специјални датуми +Name[ms]=Tarikh Khusus +Name[nb]=Spesielle datoer +Name[nds]=Besünner Daag +Name[ne]=विशेष मिति +Name[nl]=Speciale data +Name[nn]=Spesielle datoar +Name[pl]=Daty specjalne +Name[pt]=Datas Especiais +Name[pt_BR]=Datas Especiais +Name[ru]=Особые даты +Name[sk]=Špeciálne dátumy +Name[sl]=Posebni datumi +Name[sr]=Посебни датуми +Name[sr@Latn]=Posebni datumi +Name[sv]=Speciella datum +Name[ta]=விசேஷ தேதிகள் +Name[th]=วันพิเศษ +Name[tr]=Özel Tarihler +Name[uk]=Особливі дати +Name[uz]=Maxsus kunlar +Name[uz@cyrillic]=Махсус кунлар +Name[zh_CN]=特殊日期 +Name[zh_TW]=特殊日期 +Comment=Special Dates Component +Comment[bg]=Обобщение на специалните случаи +Comment[ca]=Component de dates especials +Comment[da]=Komponent til særlige datoer +Comment[de]=Komponente für Übersicht über besondere Termine +Comment[el]=Συστατικό σημαντικών ημερομηνιών +Comment[es]=Componente de fechas especiales +Comment[et]=Tähtpäevade plugin +Comment[fr]=Composant des dates importantes +Comment[is]=Eining fyrir sérstaka daga +Comment[it]=Componente per le date speciali +Comment[ja]=特別な日コンポーネント +Comment[km]=សមាសភាគកាលបរិច្ឆេទពិសេស +Comment[nds]=Komponent för besünner Daten +Comment[nl]=Component voor overzicht van speciale data +Comment[pl]=Składnik dat specjalnych +Comment[pt_BR]=Componente de Datas Especiais +Comment[ru]=Особые даты +Comment[sr]=Компонента посебних датума +Comment[sr@Latn]=Komponenta posebnih datuma +Comment[sv]=Speciella datumkomponent +Comment[tr]=Özel Tarihler Bileşeni +Comment[zh_CN]=特殊日期组件 +Comment[zh_TW]=特殊日期組件 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 diff --git a/kontact/plugins/test/Makefile.am b/kontact/plugins/test/Makefile.am new file mode 100644 index 000000000..3fbac9eb3 --- /dev/null +++ b/kontact/plugins/test/Makefile.am @@ -0,0 +1,20 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces $(all_includes) + +kde_module_LTLIBRARIES = libkptestplugin.la +libkptestplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkptestplugin_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(LIB_KPARTS) + +libkptestplugin_la_SOURCES = test_plugin.cpp test_part.cpp kaddressbookiface.stub + +kaddressbookiface_DIR = $(top_srcdir)/kaddressbook + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir) +service_DATA = kptestplugin.desktop + +rc_DATA = kptestplugin.rc +rcdir = $(kde_datadir)/kptestplugin + +kpartrc_DATA = testpartui.rc +kpartrcdir = $(kde_datadir)/testpart diff --git a/kontact/plugins/test/kptestplugin.desktop b/kontact/plugins/test/kptestplugin.desktop new file mode 100644 index 000000000..17a3e52e9 --- /dev/null +++ b/kontact/plugins/test/kptestplugin.desktop @@ -0,0 +1,113 @@ +[Desktop Entry] +Type=Service +Icon=konsole +ServiceTypes=Kontact/Plugin,KPluginInfo + +X-KDE-Library=libkptestplugin +X-KDE-KontactPluginVersion=6 + +X-KDE-PluginInfo-Name=kptestplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-EnabledByDefault=false + +Comment=Kontact Test Plugin +Comment[af]=Kontact toets inprop module +Comment[be]=Тэставае дапаўненне Кантакту +Comment[bg]=Приставка за проба +Comment[bs]=Kontact testni dodatak +Comment[ca]=Endollable de prova per a Kontact +Comment[cy]=Ategyn Prawf Kontact +Comment[da]=Kontact Test-plugin +Comment[de]=Test-Modul für Kontact +Comment[el]=Δοκιμαστικό πρόσθετο του Kontact +Comment[eo]=Kontact-Testkromaĵo +Comment[es]=Plugin de prueba para Kontact +Comment[et]=Kontacti testplugin +Comment[eu]=Kontact-en proba plugin-a +Comment[fa]=وصلۀ آزمون Kontact +Comment[fi]=Kontactin testiliitännäinen +Comment[fr]=Module de test pour Kontact +Comment[fy]=Kontact Test-plugin +Comment[gl]=Extensión de Proba para Kontact +Comment[he]=תוסף ניסיון עבור Kontact +Comment[hi]=कॉन्टेक्ट जांच प्लगइन +Comment[hu]=Kontact tesztmodul +Comment[is]=Kontact prufu íforrit +Comment[it]=Plugin test Kontact +Comment[ja]=Kontact テストプラグイン +Comment[ka]=Kontact სატესტო მოდული +Comment[kk]=Сынақ модулі +Comment[km]=កម្មវិធីជំនួយការសាកល្បងក្នុង Kontact +Comment[lt]=Kontact bandymo priedas +Comment[mk]=Приклучок за тест на Контакт +Comment[ms]=Plugin Ujian Kontact +Comment[nb]=Kontact test-programtillegg +Comment[nds]=Test-Moduul för Kontact +Comment[ne]=परीक्षण प्लगइनमा सम्पर्क गर्नुहोस् +Comment[nl]=Kontact Test-plugin +Comment[nn]=Kontact, test-programtillegg +Comment[pl]=Wtyczka Kontact do testowania +Comment[pt]='Plugin' de Teste do Kontact +Comment[pt_BR]=Plug-in para Teste do Kontact +Comment[ro]=Modul de test Kontact +Comment[ru]=Проверочный модуль Kontact +Comment[se]=Kontact, geahččalanlassemoduvla +Comment[sl]=Preizkusni vstavek za Kontact +Comment[sr]=Пробни прикључак Kontact-а +Comment[sr@Latn]=Probni priključak Kontact-a +Comment[sv]=Kontact-testinsticksprogram +Comment[ta]=பரிசோதனை சொருகுப்பொருளை தொடர்பு கொள் +Comment[tg]=Модули матнии Kontact +Comment[tr]=Kontact Test Eklentisi +Comment[uk]=Тестовий втулок Kontact +Comment[uz]=Kontact uchun sinash plagini +Comment[uz@cyrillic]=Kontact учун синаш плагини +Comment[zh_CN]=Kontact Test 插件 +Comment[zh_TW]=Kontact 測試外掛程式 +Name=TestPlugin +Name[af]=Toets inprop module +Name[be]=Тэставае дапаўненне +Name[bg]=Приставка за тестване +Name[ca]=Endollable de prova +Name[cy]=AtegynPrawf +Name[de]=TestModul +Name[el]=Πρόσθετο ελέγχου +Name[eo]=Testo-kromaĵo +Name[fa]=وصلۀ آزمون +Name[fr]=Module de test +Name[fy]=Test-plugin +Name[he]=תוסף ניסיון +Name[hi]=टेस्ट-प्लगइन +Name[hr]=Probni dodatak +Name[hu]=Tesztmodul +Name[is]=Prufu íforrit +Name[it]=Plugin Test +Name[ja]=テストプラグイン +Name[ka]=სატესტო მოდული +Name[kk]=Сынақ модулі +Name[km]=កម្មវិធីជំនួយការសាកល្បង +Name[mk]=Приклучок за тест +Name[ms]=Plugin Ujian +Name[nb]=Test-programtillegg +Name[nds]=Testmoduul +Name[ne]=परीक्षण प्लगइन +Name[nl]=Test-plugin +Name[nn]=Test-programtillegg +Name[nso]=Plugin ya Teko +Name[pl]=Wtyczka testowa +Name[pt_BR]=Plug-in de Teste +Name[ro]=Modul de test +Name[ru]=Проверочный модуль +Name[se]=Geahččalan-lassemoduvla +Name[sk]=TestModul +Name[sl]=Preizkusni vstavek +Name[sr]=Пробни прикључак +Name[sr@Latn]=Probni priključak +Name[sv]=Testinsticksprogram +Name[ta]=சோதனை சொருகுப்பொருள் +Name[tg]=Модули матнӣ +Name[tr]=Test Eklentisi +Name[uk]=Тестовий втулок +Name[ven]=Lingani Plugin +Name[zh_CN]=Test 插件 +Name[zh_TW]=測試外掛程式 diff --git a/kontact/plugins/test/kptestplugin.rc b/kontact/plugins/test/kptestplugin.rc new file mode 100644 index 000000000..0931d6c90 --- /dev/null +++ b/kontact/plugins/test/kptestplugin.rc @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<!DOCTYPE gui> +<gui name="kptestplugin" version="1"> +<MenuBar> + <Menu name="edit"><Text>&Edit</Text> + <Action name="edit_test"/> + </Menu> +</MenuBar> +</gui> + diff --git a/kontact/plugins/test/test_part.cpp b/kontact/plugins/test/test_part.cpp new file mode 100644 index 000000000..6477d1420 --- /dev/null +++ b/kontact/plugins/test/test_part.cpp @@ -0,0 +1,117 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@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 "test_part.h" +#include "kaddressbookiface_stub.h" + +#include <qtextedit.h> +#include <qcombobox.h> + +#include "sidebarextension.h" + +#include <kmessagebox.h> +#include <klocale.h> +#include <kaction.h> +#include <kapplication.h> +#include <kdebug.h> +#include <dcopclient.h> +#include <kdcopservicestarter.h> +#include <ktrader.h> +#include <kservice.h> + + +TestPart::TestPart(QObject *parent, const char *name) // ## parentWidget + : KParts::ReadOnlyPart(parent, name) +{ + setInstance( new KInstance("testpart") ); // ## memleak + m_edit = new QTextEdit; + setWidget(m_edit); + setXMLFile("testpartui.rc"); + new KAction( "new contact (test)", 0, this, SLOT( newContact() ), actionCollection(), "test_deleteevent" ); + m_kab_stub = 0L; + + new KParts::SideBarExtension(new QComboBox(this), this, "sbe"); + + kapp->dcopClient()->setNotifications( true ); + connect( kapp->dcopClient(), SIGNAL( applicationRemoved( const QCString&)), + this, SLOT( unregisteredFromDCOP( const QCString& )) ); +} + +TestPart::~TestPart() +{ + kapp->dcopClient()->setNotifications( false ); + delete m_kab_stub; +} + +void TestPart::newContact() +{ + if ( !connectToAddressBook() ) + return; + + kdDebug(5602) << "Calling newContact" << endl; + m_kab_stub->newContact(); + + // If critical call: test that it worked ok + if ( !m_kab_stub->ok() ) { + kdDebug(5602) << "Communication problem - ERROR" << endl; + // TODO handle the error + } +} + +bool TestPart::connectToAddressBook() +{ + if ( !m_kab_stub ) + { + QString error; + QCString dcopService; + int result = KDCOPServiceStarter::self()->findServiceFor( "DCOP/AddressBook", QString::null, QString::null, &error, &dcopService ); + if ( result != 0 ) { + // You might want to show "error" (if not empty) here, using e.g. KMessageBox + return false; + } + // TODO document the required named for the dcop interfaces e.g. "CalendarIface". + QCString dcopObjectId = "KAddressBookIface"; + m_kab_stub = new KAddressBookIface_stub(kapp->dcopClient(), dcopService, dcopObjectId); + } + return m_kab_stub != 0L; +} + +void TestPart::unregisteredFromDCOP( const QCString& appId ) +{ + if ( m_kab_stub && m_kab_stub->app() == appId ) + { + // Delete the stub so that the next time we need the addressbook, + // we'll know that we need to start a new one. + delete m_kab_stub; + m_kab_stub = 0L; + } +} + +bool TestPart::openFile() +{ + m_edit->setText(m_file); + return true; +} + +#include "test_part.moc" diff --git a/kontact/plugins/test/test_part.h b/kontact/plugins/test/test_part.h new file mode 100644 index 000000000..8f2a927c1 --- /dev/null +++ b/kontact/plugins/test/test_part.h @@ -0,0 +1,61 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@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 TEST_PART_H +#define TEST_PART_H + + + +#include <kparts/part.h> + +class QTextEdit; +class KAddressBookIface_stub; + +class TestPart : public KParts::ReadOnlyPart +{ + Q_OBJECT + +public: + + TestPart(QObject *parent=0, const char *name=0); + ~TestPart(); + +protected: + + virtual bool openFile(); + bool connectToAddressBook(); + +protected slots: + + void newContact(); + void unregisteredFromDCOP( const QCString& ); + +private: + + QTextEdit *m_edit; + KAddressBookIface_stub *m_kab_stub; + +}; + + +#endif diff --git a/kontact/plugins/test/test_plugin.cpp b/kontact/plugins/test/test_plugin.cpp new file mode 100644 index 000000000..62bd74bd2 --- /dev/null +++ b/kontact/plugins/test/test_plugin.cpp @@ -0,0 +1,61 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@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 <kmessagebox.h> +#include <kaction.h> +#include <kgenericfactory.h> +#include <kstatusbar.h> + +#include "core.h" + +#include "test_plugin.h" +#include "test_part.h" + +typedef KGenericFactory< TestPlugin, Kontact::Core > TestPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkptestplugin, TestPluginFactory( "kptestplugin" ) ) + +TestPlugin::TestPlugin(Kontact::Core *_core, const char *name, const QStringList &) + : Kontact::Plugin(_core, _core, name) +{ + setInstance(TestPluginFactory::instance()); + + insertNewAction(new KAction("Test", 0, this, SLOT(slotTestMenu()), actionCollection(), "edit_test")); + + setXMLFile("kptestplugin.rc"); +} + +TestPlugin::~TestPlugin() +{ +} + +void TestPlugin::slotTestMenu() +{ + core()->statusBar()->message("Test menu activated"); +} + +KParts::Part* TestPlugin::createPart() +{ + return new TestPart(this, "testpart"); +} + +#include "test_plugin.moc" diff --git a/kontact/plugins/test/test_plugin.h b/kontact/plugins/test/test_plugin.h new file mode 100644 index 000000000..35b60283d --- /dev/null +++ b/kontact/plugins/test/test_plugin.h @@ -0,0 +1,51 @@ +/* + This file is part of KDE Kontact. + + Copyright (c) 2001 Matthias Hoelzer-Kluepfel <mhk@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 TEST_PLUGIN_H +#define TEST_PLUGIN_H + + +#include "plugin.h" + + +class TestPart; + + +class TestPlugin : public Kontact::Plugin +{ + Q_OBJECT + +public: + + TestPlugin(Kontact::Core *core, const char *name, const QStringList &); + ~TestPlugin(); + +protected: + KParts::Part* createPart(); + +private slots: + + void slotTestMenu(); +}; + +#endif diff --git a/kontact/plugins/test/testpartui.rc b/kontact/plugins/test/testpartui.rc new file mode 100644 index 000000000..ad5c6764d --- /dev/null +++ b/kontact/plugins/test/testpartui.rc @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<!DOCTYPE gui> +<gui name="testpart" version="1"> +<MenuBar> + <Menu name="edit"><Text>&Edit</Text> + <Action name="test_deleteevent"/> + </Menu> +</MenuBar> +</gui> + diff --git a/kontact/plugins/weather/Makefile.am b/kontact/plugins/weather/Makefile.am new file mode 100644 index 000000000..dc547a0ce --- /dev/null +++ b/kontact/plugins/weather/Makefile.am @@ -0,0 +1,13 @@ +INCLUDES = -I$(top_srcdir)/kontact/interfaces -I$(top_srcdir)/libkdepim -I$(top_srcdir) $(all_includes) + +kde_module_LTLIBRARIES = libkontact_weatherplugin.la +libkontact_weatherplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkontact_weatherplugin_la_LIBADD = $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(LIB_KPARTS) $(top_builddir)/libkdepim/libkdepim.la + +libkontact_weatherplugin_la_SOURCES = weather_plugin.cpp summarywidget.cpp \ + summarywidget.skel + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir)/kontact +service_DATA = weatherplugin.desktop diff --git a/kontact/plugins/weather/summarywidget.cpp b/kontact/plugins/weather/summarywidget.cpp new file mode 100644 index 000000000..04a559ae4 --- /dev/null +++ b/kontact/plugins/weather/summarywidget.cpp @@ -0,0 +1,230 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 <qimage.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qtooltip.h> + +#include <dcopclient.h> +#include <dcopref.h> +#include <kapplication.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kglobalsettings.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kprocess.h> +#include <kurllabel.h> + +#include "summarywidget.h" + +SummaryWidget::SummaryWidget( QWidget *parent, const char *name ) + : Kontact::Summary( parent, name ), + DCOPObject( "WeatherSummaryWidget" ), mProc( 0 ) +{ + mLayout = new QVBoxLayout( this, 3, 3 ); + mLayout->setAlignment( Qt::AlignTop ); + + QPixmap icon = KGlobal::iconLoader()->loadIcon( "kweather", KIcon::Desktop, KIcon::SizeMedium ); + QWidget *header = createHeader( this, icon, i18n( "Weather Service" ) ); + mLayout->addWidget( header ); + + QString error; + QCString appID; + bool serviceAvailable = true; + if ( !kapp->dcopClient()->isApplicationRegistered( "KWeatherService" ) ) { + if ( KApplication::startServiceByDesktopName( "kweatherservice", QStringList(), &error, &appID ) ) { + QLabel *label = new QLabel( i18n( "No weather dcop service available;\nyou need KWeather to use this plugin." ), this ); + mLayout->addWidget( label, Qt::AlignHCenter | AlignVCenter ); + serviceAvailable = false; + } + } + + if ( serviceAvailable ) { + connectDCOPSignal( 0, 0, "fileUpdate(QString)", "refresh(QString)", false ); + connectDCOPSignal( 0, 0, "stationRemoved(QString)", "stationRemoved(QString)", false ); + + DCOPRef dcopCall( "KWeatherService", "WeatherService" ); + DCOPReply reply = dcopCall.call( "listStations()", true ); + if ( reply.isValid() ) { + mStations = reply; + + connect( &mTimer, SIGNAL( timeout() ), this, SLOT( timeout() ) ); + mTimer.start( 0 ); + } else { + kdDebug(5602) << "ERROR: dcop reply not valid..." << endl; + } + } +} + + +void SummaryWidget::updateView() +{ + mLayouts.setAutoDelete( true ); + mLayouts.clear(); + mLayouts.setAutoDelete( false ); + + mLabels.setAutoDelete( true ); + mLabels.clear(); + mLabels.setAutoDelete( false ); + + if ( mStations.count() == 0 ) { + kdDebug(5602) << "No weather stations defined..." << endl; + return; + } + + + QValueList<WeatherData> dataList = mWeatherMap.values(); + qHeapSort( dataList ); + + QValueList<WeatherData>::Iterator it; + for ( it = dataList.begin(); it != dataList.end(); ++it ) { + QString cover; + for ( uint i = 0; i < (*it).cover().count(); ++i ) + cover += QString( "- %1\n" ).arg( (*it).cover()[ i ] ); + + QImage img; + img = (*it).icon(); + + QGridLayout *layout = new QGridLayout( mLayout, 3, 3, 3 ); + mLayouts.append( layout ); + + KURLLabel* urlLabel = new KURLLabel( this ); + urlLabel->installEventFilter( this ); + urlLabel->setURL( (*it).stationID() ); + urlLabel->setPixmap( img.smoothScale( 32, 32 ) ); + urlLabel->setMaximumSize( urlLabel->sizeHint() ); + urlLabel->setAlignment( AlignTop ); + layout->addMultiCellWidget( urlLabel, 0, 1, 0, 0 ); + mLabels.append( urlLabel ); + connect ( urlLabel, SIGNAL( leftClickedURL( const QString& ) ), + this, SLOT( showReport( const QString& ) ) ); + + QLabel* label = new QLabel( this ); + label->setText( QString( "%1 (%2)" ).arg( (*it).name() ).arg( (*it).temperature() ) ); + QFont font = label->font(); + font.setBold( true ); + label->setFont( font ); + label->setAlignment( AlignLeft ); + layout->addMultiCellWidget( label, 0, 0, 1, 2 ); + mLabels.append( label ); + + QString labelText; + labelText = QString( "<b>%1:</b> %2<br>" + "<b>%3:</b> %4<br>" + "<b>%5:</b> %6" ) + .arg( i18n( "Last updated on" ) ) + .arg( (*it).date() ) + .arg( i18n( "Wind Speed" ) ) + .arg( (*it).windSpeed() ) + .arg( i18n( "Rel. Humidity" ) ) + .arg( (*it).relativeHumidity() ); + + QToolTip::add( label, labelText.replace( " ", " " ) ); + + label = new QLabel( cover, this ); + label->setAlignment( AlignLeft ); + layout->addMultiCellWidget( label, 1, 1, 1, 2 ); + mLabels.append( label ); + } + + for ( QLabel *label = mLabels.first(); label; label = mLabels.next() ) + label->show(); +} + +void SummaryWidget::timeout() +{ + mTimer.stop(); + + DCOPRef dcopCall( "KWeatherService", "WeatherService" ); + dcopCall.send( "updateAll()" ); + + mTimer.start( 15 * 60000 ); +} + +void SummaryWidget::refresh( QString station ) +{ + DCOPRef dcopCall( "KWeatherService", "WeatherService" ); + + mWeatherMap[ station ].setIcon( dcopCall.call( "currentIcon(QString)", station, true ) ); + mWeatherMap[ station ].setName( dcopCall.call( "stationName(QString)", station, true ) ); + mWeatherMap[ station ].setCover( dcopCall.call( "cover(QString)", station, true ) ); + mWeatherMap[ station ].setDate( dcopCall.call( "date(QString)", station, true ) ); + mWeatherMap[ station ].setTemperature( dcopCall.call( "temperature(QString)", station, true ) ); + mWeatherMap[ station ].setWindSpeed( dcopCall.call( "wind(QString)", station, true ) ); + mWeatherMap[ station ].setRelativeHumidity( dcopCall.call( "relativeHumidity(QString)", station, true ) ); + mWeatherMap[ station ].setStationID(station); + + updateView(); +} + +void SummaryWidget::stationRemoved( QString station ) +{ + mWeatherMap.remove( station ); + updateView(); +} + +bool SummaryWidget::eventFilter( QObject *obj, QEvent* e ) +{ + if ( obj->inherits( "KURLLabel" ) ) { + if ( e->type() == QEvent::Enter ) + emit message( + i18n( "View Weather Report for Station" ) ); + if ( e->type() == QEvent::Leave ) + emit message( QString::null ); + } + + return Kontact::Summary::eventFilter( obj, e ); +} + +QStringList SummaryWidget::configModules() const +{ + return QStringList( "kcmweatherservice.desktop" ); +} + +void SummaryWidget::updateSummary( bool ) +{ + timeout(); +} + +void SummaryWidget::showReport( const QString &stationID ) +{ + mProc = new KProcess; + QApplication::connect( mProc, SIGNAL( processExited( KProcess* ) ), + this, SLOT( reportFinished( KProcess* ) ) ); + *mProc << "kweatherreport"; + *mProc << stationID; + + if ( !mProc->start() ) { + delete mProc; + mProc = 0; + } +} + +void SummaryWidget::reportFinished( KProcess* ) +{ + mProc->deleteLater(); + mProc = 0; +} + +#include "summarywidget.moc" diff --git a/kontact/plugins/weather/summarywidget.h b/kontact/plugins/weather/summarywidget.h new file mode 100644 index 000000000..40e0bb705 --- /dev/null +++ b/kontact/plugins/weather/summarywidget.h @@ -0,0 +1,123 @@ +/* + This file is part of Kontact. + Copyright (c) 2003 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 SUMMARYWIDGET_H +#define SUMMARYWIDGET_H + +#include "summary.h" + +#include <dcopobject.h> + +#include <qmap.h> +#include <qpixmap.h> +#include <qptrlist.h> +#include <qstringlist.h> +#include <qtimer.h> +#include <qwidget.h> + +class KProcess; + +class QGridLayout; +class QLabel; +class QVBoxLayout; + +class WeatherData +{ + public: + void setIcon( const QPixmap &icon ) { mIcon = icon; } + QPixmap icon() const { return mIcon; } + + void setName( const QString &name ) { mName = name; } + QString name() const { return mName; } + + void setCover( const QStringList& cover ) { mCover = cover; } + QStringList cover() const { return mCover; } + + void setDate( const QString &date ) { mDate = date; } + QString date() const { return mDate; } + + void setTemperature( const QString &temperature ) { mTemperature = temperature; } + QString temperature() const { return mTemperature; } + + void setWindSpeed( const QString &windSpeed ) { mWindSpeed = windSpeed; } + QString windSpeed() const { return mWindSpeed; } + + void setRelativeHumidity( const QString &relativeHumidity ) { mRelativeHumidity = relativeHumidity; } + QString relativeHumidity() const { return mRelativeHumidity; } + + void setStationID( const QString &station ) { mStationID = station;} + QString stationID() { return mStationID; } + + bool operator< ( const WeatherData &data ) + { + return ( QString::localeAwareCompare( mName, data.mName ) < 0 ); + } + + private: + QPixmap mIcon; + QString mName; + QStringList mCover; + QString mDate; + QString mTemperature; + QString mWindSpeed; + QString mRelativeHumidity; + QString mStationID; +}; + +class SummaryWidget : public Kontact::Summary, public DCOPObject +{ + Q_OBJECT + K_DCOP + public: + SummaryWidget( QWidget *parent, const char *name = 0 ); + + QStringList configModules() const; + + void updateSummary( bool force = false ); + + k_dcop: + virtual void refresh( QString ); + virtual void stationRemoved( QString ); + + protected: + virtual bool eventFilter( QObject *obj, QEvent *e ); + + private slots: + void updateView(); + void timeout(); + void showReport( const QString& ); + void reportFinished( KProcess* ); + + private: + QStringList mStations; + QMap<QString, WeatherData> mWeatherMap; + QTimer mTimer; + + QPtrList<QLabel> mLabels; + QPtrList<QGridLayout> mLayouts; + QVBoxLayout *mLayout; + + KProcess* mProc; +}; + +#endif diff --git a/kontact/plugins/weather/weather_plugin.cpp b/kontact/plugins/weather/weather_plugin.cpp new file mode 100644 index 000000000..4c1a91e6e --- /dev/null +++ b/kontact/plugins/weather/weather_plugin.cpp @@ -0,0 +1,61 @@ +/* + This file is part of Kontact. + Copyright (C) 2003 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 <kaboutdata.h> +#include <kgenericfactory.h> +#include <kparts/componentfactory.h> + +#include "core.h" +#include "summarywidget.h" + +#include "weather_plugin.h" + +typedef KGenericFactory< WeatherPlugin, Kontact::Core > WeatherPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_weatherplugin, + WeatherPluginFactory( "kontact_weatherplugin" ) ) + +WeatherPlugin::WeatherPlugin( Kontact::Core *core, const char *name, const QStringList& ) + : Kontact::Plugin( core, core, name ), mAboutData( 0 ) +{ + setInstance( WeatherPluginFactory::instance() ); +} + +Kontact::Summary *WeatherPlugin::createSummaryWidget( QWidget *parentWidget ) +{ + return new SummaryWidget( parentWidget ); +} + +const KAboutData *WeatherPlugin::aboutData() +{ + if ( !mAboutData ) { + mAboutData = new KAboutData( "weatherplugin", I18N_NOOP( "Weather Information" ), + "0.1", + I18N_NOOP( "Weather Information" ), + KAboutData::License_GPL_V2, + "(c) 2003 The Kontact developers" ); + mAboutData->addAuthor( "Ian Reinhart Geiser", "", "geiseri@kde.org" ); + mAboutData->addAuthor( "Tobias Koenig", "", "tokoe@kde.org" ); + mAboutData->addCredit( "John Ratke", + I18N_NOOP( "Improvements and more code cleanups" ), + "jratke@comcast.net" ); + } + + return mAboutData; +} diff --git a/kontact/plugins/weather/weather_plugin.h b/kontact/plugins/weather/weather_plugin.h new file mode 100644 index 000000000..637ebea9c --- /dev/null +++ b/kontact/plugins/weather/weather_plugin.h @@ -0,0 +1,44 @@ +/* + This file is part of Kontact. + Copyright (C) 2003 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 WEATHER_PLUGIN_H +#define WEATHER_PLUGIN_H + +#include "plugin.h" + +class SummaryWidget; + +class WeatherPlugin : public Kontact::Plugin +{ + public: + WeatherPlugin( Kontact::Core *core, const char *name, const QStringList& ); + WeatherPlugin(); + + virtual Kontact::Summary *createSummaryWidget( QWidget *parentWidget ); + + const KAboutData *aboutData(); + + protected: + virtual KParts::ReadOnlyPart *createPart() { return 0; } + private: + KAboutData *mAboutData; +}; + +#endif diff --git a/kontact/plugins/weather/weatherplugin.desktop b/kontact/plugins/weather/weatherplugin.desktop new file mode 100644 index 000000000..68c1924e3 --- /dev/null +++ b/kontact/plugins/weather/weatherplugin.desktop @@ -0,0 +1,92 @@ +[Desktop Entry] +Type=Service +Icon=kweather +ServiceTypes=Kontact/Plugin,KPluginInfo +TryExec=kweatherservice + +X-KDE-Library=libkontact_weatherplugin +X-KDE-KontactIdentifier=weather +X-KDE-KontactPluginVersion=6 +X-KDE-KontactPluginHasSummary=true +X-KDE-KontactPluginHasPart=false + +X-KDE-PluginInfo-Name=kontact_weatherplugin +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=LGPL +X-KDE-PluginInfo-EnabledByDefault=true + +Comment=Kontact Weather Component +Comment[bg]=Приставка за метеорологичното време +Comment[ca]=Component del temps del Kontact +Comment[da]=Vejrkomponent til Kontact +Comment[de]=Wetter-Komponente für Kontact +Comment[el]=Συστατικό καιρού του Kontact +Comment[es]=Extensión de meteorología para Kontact +Comment[et]=Kontacti ilmaplugin +Comment[fr]=Composant météo pour Kontact +Comment[is]=Kontact veðurfréttaeining +Comment[it]=Componente meteorologico di Kontact +Comment[ja]=Kontact 気象情報コンポーネント +Comment[km]=សមាសភាគអាកាសធាតុ Kontact +Comment[nds]=Kontact-Wederkomponent +Comment[nl]=Kontact Weercomponent +Comment[pl]=Składnik Kontaktu wiadomości o pogodzie +Comment[ru]=Компонент информации о погоде для Kontact +Comment[sr]=Компонента времена за Kontact +Comment[sr@Latn]=Komponenta vremena za Kontact +Comment[sv]=Kontacts väderkomponent +Comment[tr]=Kontact Hava Durumu Bileşeni +Comment[zh_CN]=Kontact 天气插件 +Comment[zh_TW]=Kontact 天氣組件 +Name=Weather Service +Name[af]=Weer diens +Name[ar]=خدمة الطقس +Name[bg]=Информация за времето +Name[br]=Servij an amzer +Name[ca]=Servei meteorològic +Name[cs]=Služba počasí +Name[cy]=GwasanaethTywydd +Name[da]=Vejrtjeneste +Name[de]=Wetterdienst +Name[el]=Υπηρεσία πρόβλεψης Καιρού +Name[eo]=Veterservo +Name[es]=Servicio meteorológico +Name[et]=Ilmateade +Name[eu]=Eguraldiaren zerbitzua +Name[fa]=خدمت آب و هوا +Name[fi]=Sääpalvelu +Name[fr]=KWeatherService +Name[fy]=Waarberjocht +Name[ga]=Seirbhís Aimsire +Name[gl]=Servicio do Tempo +Name[he]=שירות מזג אוויר +Name[hu]=Időjárás +Name[is]=Veðurþjónusta +Name[it]=Servizio meteorologico +Name[ja]=気象サービス +Name[ka]=ამინდის მომსახურება +Name[kk]=Ауа райы қызметі +Name[km]=សេវាអាកាសធាតុ +Name[lt]=Orų tarnyba +Name[mk]=Временска прогноза +Name[nb]=Værtjeneste +Name[nds]=Wederdeenst +Name[ne]=मौसम कार्य +Name[nl]=Weerbericht +Name[nn]=Vêrmelding +Name[pl]=Pogoda +Name[pt]=Serviço Meteorológico +Name[pt_BR]=Serviço de Previsão do Tempo +Name[ru]=Погода +Name[sk]=Služba počasie +Name[sl]=Vremenska storitev +Name[sr]=Време +Name[sr@Latn]=Vreme +Name[sv]=Väderleksprognos +Name[th]=รายงานอากาศ +Name[tr]=Hava Durumu Servisi +Name[uk]=Служба погоди +Name[uz]=Ob-havo xizmati +Name[uz@cyrillic]=Об-ҳаво хизмати +Name[zh_CN]=天气服务 +Name[zh_TW]=天氣服務 |