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 /kaddressbook/features | |
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 'kaddressbook/features')
-rw-r--r-- | kaddressbook/features/Makefile.am | 36 | ||||
-rw-r--r-- | kaddressbook/features/distributionlist.desktop | 116 | ||||
-rw-r--r-- | kaddressbook/features/distributionlistng.desktop | 86 | ||||
-rw-r--r-- | kaddressbook/features/distributionlistngwidget.cpp | 249 | ||||
-rw-r--r-- | kaddressbook/features/distributionlistngwidget.h | 104 | ||||
-rw-r--r-- | kaddressbook/features/distributionlistwidget.cpp | 673 | ||||
-rw-r--r-- | kaddressbook/features/distributionlistwidget.h | 140 | ||||
-rw-r--r-- | kaddressbook/features/resourceselection.cpp | 421 | ||||
-rw-r--r-- | kaddressbook/features/resourceselection.desktop | 110 | ||||
-rw-r--r-- | kaddressbook/features/resourceselection.h | 81 |
10 files changed, 2016 insertions, 0 deletions
diff --git a/kaddressbook/features/Makefile.am b/kaddressbook/features/Makefile.am new file mode 100644 index 000000000..d3311c77b --- /dev/null +++ b/kaddressbook/features/Makefile.am @@ -0,0 +1,36 @@ +INCLUDES = -I$(top_srcdir)/kaddressbook/interfaces -I$(top_srcdir)/kaddressbook \ + -I$(top_srcdir) $(all_includes) + +if compile_newdistrlists +TARGET_DISTRIBUTIONLISTNG=libkaddrbk_distributionlistng.la +DISTRIBUTIONLISTNG_DESKTOPFILE=distributionlistng.desktop +else +DISTRIBUTIONLIST_DESKTOPFILE=distributionlist.desktop +endif + +kde_module_LTLIBRARIES = $(TARGET_DISTRIBUTIONLISTNG) libkaddrbk_distributionlist.la libkaddrbk_resourceselection.la + +XXLIBS = $(top_builddir)/kaddressbook/interfaces/libkabinterfaces.la \ + $(top_builddir)/libkdepim/libkdepim.la + + +if compile_newdistrlists +libkaddrbk_distributionlistng_la_SOURCES = distributionlistngwidget.cpp +libkaddrbk_distributionlistng_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined +libkaddrbk_distributionlistng_la_LIBADD = $(XXLIBS) +else +libkaddrbk_distributionlist_la_SOURCES = distributionlistwidget.cpp +libkaddrbk_distributionlist_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined +libkaddrbk_distributionlist_la_LIBADD = $(XXLIBS) +endif + +libkaddrbk_resourceselection_la_SOURCES = resourceselection.cpp +libkaddrbk_resourceselection_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined +libkaddrbk_resourceselection_la_LIBADD = $(XXLIBS) + +noinst_HEADERS = distributionlistwidget.h distributionlistngwidget.h resourceselection.h + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir)/kaddressbook +service_DATA = $(DISTRIBUTIONLISTNG_DESKTOPFILE) $(DISTRIBUTIONLIST_DESKTOPFILE) resourceselection.desktop diff --git a/kaddressbook/features/distributionlist.desktop b/kaddressbook/features/distributionlist.desktop new file mode 100644 index 000000000..b05d7b5e8 --- /dev/null +++ b/kaddressbook/features/distributionlist.desktop @@ -0,0 +1,116 @@ +[Desktop Entry] +X-KDE-Library=libkaddrbk_distributionlist +Name=KAB Distribution List Plugin +Name[af]=KAB verspreiding lys inprop module +Name[ar]=ملحق قائمة توزيع KAB +Name[be]=Дапаўненне KAB "Сьпіс распаўсюджвання" +Name[bg]=Приставка за списъка за разпращане на KAB +Name[br]=Lugent roll ingaladur evit KAB +Name[bs]=KAB dodatak za distribucione liste +Name[ca]=Endollable de la llista de distribució KAB +Name[cs]=Modul distribučního seznamu +Name[cy]=Ategyn Rhestr Ddosbarthu KAB +Name[da]=KAB-Distribution liste-plugin +Name[de]=Verteilerlisten-Modul für Adressbuch +Name[el]=Πρόσθετο λίστας διανομής του KAB +Name[eo]=KAB Distribulista Kromprogramo +Name[es]=Plugin KAB para listas de distribución +Name[et]=KAB postiloendi plugin +Name[eu]=KAB banaketa zerrenda plugin-a +Name[fa]=وصلۀ فهرست توزیع KAB +Name[fi]=KAB-jakelulistaliitännäinen +Name[fr]=Module de liste de diffusion pour KAB +Name[fy]=KAB Distribúsjelist-plugin +Name[gl]=Extensión de Lista de Distribución KAB +Name[hi]=केएबी वितरण सूची प्लगइन +Name[hu]=KAB címlista bővítőmodul +Name[is]=Íforrit fyrir KAB dreifilista +Name[it]=Plugin lista di distribuzione KAB +Name[ja]=KAB 配布リストプラグイン +Name[ka]=KAB დისტრიბუციის სიის მოდული +Name[kk]=KAB тарату тізімінің плагин модулі +Name[km]=កម្មវិធីជំនួយបញ្ជីចែកចាយរបស់ KAB +Name[lt]=KAB platinimo sąrašo priedas +Name[ms]=Plugin Senarai Agihan KAB +Name[nb]=KAB programtillegg for distribusjonslister +Name[nds]=Verdeellist-Moduul för KAdressbook +Name[ne]=KAB वितरण सूची प्लगइन +Name[nl]=KAB Distributielijst-plugin +Name[nn]=Programtillegg for KAB distribusjonsliste +Name[pl]=Wtyczka KAB do obsługi list wysyłkowych +Name[pt]='Plugin' de Lista de Distribuição do KAB +Name[pt_BR]=Plug-in de Lista de Distribuição do KAB +Name[ru]=Списки рассылки +Name[se]=KAB:a distribušuvdnalistu lassemoduvla +Name[sk]=KAB plugin distribučného zoznamu +Name[sl]=Vstavek za distribucijski seznam KAB +Name[sr]=Прикључак KAB-а за дистрибуционе листе +Name[sr@Latn]=Priključak KAB-a za distribucione liste +Name[sv]=Adressbokens insticksprogram för distributionslistor +Name[ta]=KABயின் பகிர்ந்தளித்தல் பட்டியல் சொருகுப்பொருள் +Name[tg]=Рӯйхати ба ҳар тараф мефиристодагӣ +Name[tr]=KAB Dağıtım Listesi Eklentisi +Name[uk]=Втулок списку розповсюдження KAB +Name[uz]=Tarqatish roʻyxat plagini +Name[uz@cyrillic]=Тарқатиш рўйхат плагини +Name[zh_CN]=KAB 分发列表插件 +Comment=Plugin for managing distribution lists +Comment[af]=Inprop module vir die bestuur van verspreiding lyste +Comment[ar]=ملحق لإدارة قوائم التوزيع +Comment[be]=Дапаўненне для кіравання сьпісамі распаўсюджвання +Comment[bg]=Приставка за управление на списъци +Comment[br]=Lugent melestradur ar rolloù ingaladur +Comment[bs]=Dodatak za upravljanje distribucionim listama +Comment[ca]=Endollable per a gestionar llistes de distribució +Comment[cs]=Modul pro správu distribučních seznamů +Comment[cy]=Ategyn ar gyfer rheoli rhestri dosbarthu +Comment[da]=Plugin til at håndtere distributionslister +Comment[de]=Modul zur Verwaltung von Verteilerlisten +Comment[el]=Πρόσθετο για τη διαχείριση λιστών διανομής +Comment[eo]=Kromaĵo por administri distribulistojn +Comment[es]=Plugin para gestionar listas de distribución +Comment[et]=Plugin postiloendite haldamiseks +Comment[eu]=Banaketa zerrendak kudeatzeko plugin-a +Comment[fa]=وصله برای مدیریت فهرستهای توزیع +Comment[fi]=Liitännäinen jakelulistojen hallintaan +Comment[fr]=Module pour gérer des listes de diffusion +Comment[fy]=Plugin foar nit behearen fan distribúsjelisten +Comment[gl]=Plugin para manexar listas de distribución +Comment[he]=תוסף לניהול רשימות תפוצה +Comment[hi]=वितरण सूची प्रबंधन के लिए प्लगइन +Comment[hu]=Bővítőmodul címlisták kezeléséhez +Comment[is]=Íforrit til að sjá um dreifilista +Comment[it]=Plugin per gestire liste di distribuzione +Comment[ja]=配布リスト管理用プラグイン +Comment[ka]=სადისტრიბუციო სიათა მართვის მოდული +Comment[kk]=Тарату тізімімен айналысу плагин модулі +Comment[km]=កម្មវិធីជំនួយដើម្បីគ្រប់គ្រងបញ្ជីចែកចាយ +Comment[lt]=Priedas platinimo sąrašų tvarkymui +Comment[ms]=Plug masuk untuk pengurusan senarai edaran +Comment[nb]=Programtillegg for å håndtere distribusjonslister +Comment[nds]=Moduul för't Plegen vun Verdeellisten +Comment[ne]=व्यवस्थापन वितरण सूचीका लागि प्लगइन +Comment[nl]=Plugin voor het beheren van distributielijsten +Comment[nn]=Programtillegg for handtering av distibusjonsliste +Comment[pl]=Wtyczka do zarządzania listami wysyłkowymi +Comment[pt]=Um 'plugin' para gerir as listas de distribuição +Comment[pt_BR]=Plug-in para gerenciar listas de distribuição +Comment[ro]=Modul pentru administrarea listelor de distribuţie +Comment[ru]=Работа со списками рассылок +Comment[se]=Lassemoduvla mii gieđahallá distribušuvdnalisttuid +Comment[sk]=Plugin pre správu distribučných zoznamov +Comment[sl]=Vstavek za upravljanje distribucijskih seznamov +Comment[sr]=Прикључак за управљање дистрибуционим листама +Comment[sr@Latn]=Priključak za upravljanje distribucionim listama +Comment[sv]=Insticksprogram för att hantera distributionslistor +Comment[ta]=பகிர்தல் பட்டியல் நிர்வகித்தலின் சொருகுப்பொருள் +Comment[tg]=Кор бо рӯйхати ба ҳар тараф мефиристодагӣ +Comment[tr]=Dağıtım listelerini yönetmek için eklenti +Comment[uk]=Втулок для керування списками розповсюдження +Comment[uz]=Tarqatish roʻyxatlarni boshqarish uchu plagin +Comment[uz@cyrillic]=Тарқатиш рўйхатларни бошқариш учу плагин +Comment[zh_CN]=管理分发列表的插件 +Comment[zh_TW]=管理分配清單外掛程式 +Type=Service +ServiceTypes=KAddressBook/Extension +X-KDE-KAddressBook-ExtensionPluginVersion=1 diff --git a/kaddressbook/features/distributionlistng.desktop b/kaddressbook/features/distributionlistng.desktop new file mode 100644 index 000000000..84d7070bb --- /dev/null +++ b/kaddressbook/features/distributionlistng.desktop @@ -0,0 +1,86 @@ +[Desktop Entry] +X-KDE-Library=libkaddrbk_distributionlistng +Name=KAB Distribution List Next Generation Plugin +Name[bg]=Приставка от следващо поколение за списъка за разпращане на KAB +Name[ca]=Endollable de la propera generació de la llista de distribució KAB +Name[da]=Næste generations-plugin til KAB-Distribution-liste +Name[de]=Verteilerlisten-Modul für neues Adressbuch +Name[el]=Πρόσθετο επόμενης γενιάς λίστας διανομής του KAB +Name[es]=Complemento de nueva generación KAB para listas de distribución +Name[et]=KAB postiloendi järgmise põlvkonna plugin +Name[fr]=Module de liste de diffusion nouvelle génération pour KAB +Name[is]=Næstu kynslóðar íforrit fyrir KAB dreifilista +Name[it]=Plugin lista di distribuzione KAB di nuova generazione +Name[ja]=KAB 配布リスト次世代プラグイン +Name[km]=កម្មវិធីជំនួយជំនាន់ក្រោយរបស់បញ្ជីចែកចាយ KAB +Name[nds]=Verbetert Verdeellist-Moduul för KAdressbook +Name[nl]=Plugin voor KAB Distributielijst (Nieuwe Generatie) +Name[pl]=Wtyczka KAB do obsługi list wysyłkowych +Name[ru]=Списки рассылки (новая версия) +Name[sk]=KAB plugin distribučného zoznamu ďaľšej generácie +Name[sr]=Прикључак KAB-а наредне генерације за дистрибуционе листе +Name[sr@Latn]=Priključak KAB-a naredne generacije za distribucione liste +Name[sv]=Adressbokens nästa generation insticksprogram för distributionslistor +Name[tr]=KAB Dağıtım Listesi Sonraki Kuşak Eklentisi +Name[zh_CN]=KAB 分发列表生成插件 +Name[zh_TW]=KAB 分派清單下一代外掛程式 +Comment=Plugin for managing distribution lists +Comment[af]=Inprop module vir die bestuur van verspreiding lyste +Comment[ar]=ملحق لإدارة قوائم التوزيع +Comment[be]=Дапаўненне для кіравання сьпісамі распаўсюджвання +Comment[bg]=Приставка за управление на списъци +Comment[br]=Lugent melestradur ar rolloù ingaladur +Comment[bs]=Dodatak za upravljanje distribucionim listama +Comment[ca]=Endollable per a gestionar llistes de distribució +Comment[cs]=Modul pro správu distribučních seznamů +Comment[cy]=Ategyn ar gyfer rheoli rhestri dosbarthu +Comment[da]=Plugin til at håndtere distributionslister +Comment[de]=Modul zur Verwaltung von Verteilerlisten +Comment[el]=Πρόσθετο για τη διαχείριση λιστών διανομής +Comment[eo]=Kromaĵo por administri distribulistojn +Comment[es]=Plugin para gestionar listas de distribución +Comment[et]=Plugin postiloendite haldamiseks +Comment[eu]=Banaketa zerrendak kudeatzeko plugin-a +Comment[fa]=وصله برای مدیریت فهرستهای توزیع +Comment[fi]=Liitännäinen jakelulistojen hallintaan +Comment[fr]=Module pour gérer des listes de diffusion +Comment[fy]=Plugin foar nit behearen fan distribúsjelisten +Comment[gl]=Plugin para manexar listas de distribución +Comment[he]=תוסף לניהול רשימות תפוצה +Comment[hi]=वितरण सूची प्रबंधन के लिए प्लगइन +Comment[hu]=Bővítőmodul címlisták kezeléséhez +Comment[is]=Íforrit til að sjá um dreifilista +Comment[it]=Plugin per gestire liste di distribuzione +Comment[ja]=配布リスト管理用プラグイン +Comment[ka]=სადისტრიბუციო სიათა მართვის მოდული +Comment[kk]=Тарату тізімімен айналысу плагин модулі +Comment[km]=កម្មវិធីជំនួយដើម្បីគ្រប់គ្រងបញ្ជីចែកចាយ +Comment[lt]=Priedas platinimo sąrašų tvarkymui +Comment[ms]=Plug masuk untuk pengurusan senarai edaran +Comment[nb]=Programtillegg for å håndtere distribusjonslister +Comment[nds]=Moduul för't Plegen vun Verdeellisten +Comment[ne]=व्यवस्थापन वितरण सूचीका लागि प्लगइन +Comment[nl]=Plugin voor het beheren van distributielijsten +Comment[nn]=Programtillegg for handtering av distibusjonsliste +Comment[pl]=Wtyczka do zarządzania listami wysyłkowymi +Comment[pt]=Um 'plugin' para gerir as listas de distribuição +Comment[pt_BR]=Plug-in para gerenciar listas de distribuição +Comment[ro]=Modul pentru administrarea listelor de distribuţie +Comment[ru]=Работа со списками рассылок +Comment[se]=Lassemoduvla mii gieđahallá distribušuvdnalisttuid +Comment[sk]=Plugin pre správu distribučných zoznamov +Comment[sl]=Vstavek za upravljanje distribucijskih seznamov +Comment[sr]=Прикључак за управљање дистрибуционим листама +Comment[sr@Latn]=Priključak za upravljanje distribucionim listama +Comment[sv]=Insticksprogram för att hantera distributionslistor +Comment[ta]=பகிர்தல் பட்டியல் நிர்வகித்தலின் சொருகுப்பொருள் +Comment[tg]=Кор бо рӯйхати ба ҳар тараф мефиристодагӣ +Comment[tr]=Dağıtım listelerini yönetmek için eklenti +Comment[uk]=Втулок для керування списками розповсюдження +Comment[uz]=Tarqatish roʻyxatlarni boshqarish uchu plagin +Comment[uz@cyrillic]=Тарқатиш рўйхатларни бошқариш учу плагин +Comment[zh_CN]=管理分发列表的插件 +Comment[zh_TW]=管理分配清單外掛程式 +Type=Service +ServiceTypes=KAddressBook/Extension +X-KDE-KAddressBook-ExtensionPluginVersion=1 diff --git a/kaddressbook/features/distributionlistngwidget.cpp b/kaddressbook/features/distributionlistngwidget.cpp new file mode 100644 index 000000000..fee8377a6 --- /dev/null +++ b/kaddressbook/features/distributionlistngwidget.cpp @@ -0,0 +1,249 @@ +/* + This file is part of KAddressBook. + Copyright (c) 2007 Klaralvdalens Datakonsult AB <frank@kdab.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 "distributionlistngwidget.h" +#include "interfaces/core.h" +#include "searchmanager.h" + +#include <libkdepim/distributionlist.h> +#include <libkdepim/kvcarddrag.h> + +#include <kabc/vcardconverter.h> + +#include <kdialog.h> +#include <kiconloader.h> +#include <klistview.h> +#include <klocale.h> +#include <kpopupmenu.h> + +#include <qevent.h> +#include <qguardedptr.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qpoint.h> +#include <qtimer.h> +#include <qpushbutton.h> +#include <qtooltip.h> + +KAB::DistributionListNg::ListBox::ListBox( QWidget* parent ) : KListBox( parent ) +{ + setAcceptDrops( true ); +} + +void KAB::DistributionListNg::ListBox::dragMoveEvent( QDragMoveEvent *event ) +{ + QListBoxItem *item = itemAt( event->pos() ); + if ( !item ) { + event->ignore(); + } + else { + event->accept( itemRect( item ) ); + } +} + +void KAB::DistributionListNg::ListBox::dragEnterEvent( QDragEnterEvent *event ) +{ + KListBox::dragEnterEvent( event ); +} + +void KAB::DistributionListNg::ListBox::dropEvent( QDropEvent *event ) +{ + QListBoxItem *item = itemAt( event->pos() ); + if ( !item || index( item ) == 0 ) + return; + + QString vcards; + if ( !KVCardDrag::decode( event, vcards ) ) + return; + + KABC::VCardConverter converter; + emit dropped( item->text(), converter.parseVCards( vcards ) ); +} + +namespace KAB { +namespace DistributionListNg { + +class Factory : public KAB::ExtensionFactory +{ + public: + KAB::ExtensionWidget *extension( KAB::Core *core, QWidget *parent, const char *name ) + { + return new KAB::DistributionListNg::MainWidget( core, parent, name ); + } + + QString identifier() const + { + return "distribution_list_editor"; + } +}; + +} +} + +extern "C" { + void *init_libkaddrbk_distributionlistng() + { + return ( new KAB::DistributionListNg::Factory ); + } +} + +QString KAB::DistributionListNg::MainWidget::title() const +{ + return i18n( "Distribution List Editor NG" ); +} + +QString KAB::DistributionListNg::MainWidget::identifier() const +{ + return "distribution_list_editor_ng"; +} + +KAB::DistributionListNg::MainWidget::MainWidget( KAB::Core *core, QWidget *parent, const char *name ) : KAB::ExtensionWidget( core, parent, name ) +{ + QVBoxLayout *layout = new QVBoxLayout( this ); + layout->setSpacing( KDialog::spacingHint() ); + + QHBoxLayout *buttonLayout = new QHBoxLayout(); + layout->addLayout( buttonLayout ); + + QLabel *label = new QLabel( this ); + label->setText( i18n( "Distribution Lists" ) ); + buttonLayout->addWidget( label ); + buttonLayout->addStretch( 1 ); + + mAddButton = new QPushButton( this ); + mAddButton->setIconSet( SmallIconSet( "add" ) ); + QToolTip::add( mAddButton, i18n( "Add distribution list" ) ); + connect( mAddButton, SIGNAL(clicked()), core, SLOT(newDistributionList()) ); + buttonLayout->addWidget( mAddButton ); + + mEditButton = new QPushButton( this ); + mEditButton->setIconSet( SmallIconSet( "edit" ) ); + QToolTip::add( mEditButton, i18n( "Edit distribution list" ) ); + connect( mEditButton, SIGNAL(clicked()), this, SLOT(editSelectedDistributionList()) ); + buttonLayout->addWidget( mEditButton ); + + mRemoveButton = new QPushButton( this ); + mRemoveButton->setIconSet( SmallIconSet( "remove" ) ); + QToolTip::add( mRemoveButton, i18n( "Remove distribution list" ) ); + connect( mRemoveButton, SIGNAL(clicked()), this, SLOT(deleteSelectedDistributionList()) ); + buttonLayout->addWidget( mRemoveButton ); + + mListBox = new ListBox( this ); + connect( mListBox, SIGNAL( contextMenuRequested( QListBoxItem*, const QPoint& ) ), + this, SLOT( contextMenuRequested( QListBoxItem*, const QPoint& ) ) ); + connect( mListBox, SIGNAL( dropped( const QString &, const KABC::Addressee::List & ) ), + this, SLOT( contactsDropped( const QString &, const KABC::Addressee::List & ) ) ); + connect( mListBox, SIGNAL( highlighted( int ) ), + this, SLOT( itemSelected( int ) ) ); + layout->addWidget( mListBox ); + + connect( core, SIGNAL( contactsUpdated() ), + this, SLOT( updateEntries() ) ); + connect( core->addressBook(), SIGNAL( addressBookChanged( AddressBook* ) ), + this, SLOT( updateEntries() ) ); + + // When contacts are changed, update both distr list combo and contents of displayed distr list + connect( core, SIGNAL( contactsUpdated() ), + this, SLOT( updateEntries() ) ); + + QTimer::singleShot( 0, this, SLOT( updateEntries() ) ); +} + +void KAB::DistributionListNg::MainWidget::contextMenuRequested( QListBoxItem *item, const QPoint &point ) +{ + QGuardedPtr<KPopupMenu> menu = new KPopupMenu( this ); + menu->insertItem( i18n( "New Distribution List..." ), core(), SLOT( newDistributionList() ) ); + if ( item ) + { + menu->insertItem( i18n( "Edit..." ), this, SLOT( editSelectedDistributionList() ) ); + menu->insertItem( i18n( "Delete" ), this, SLOT( deleteSelectedDistributionList() ) ); + } + menu->exec( point ); + delete menu; +} + +void KAB::DistributionListNg::MainWidget::editSelectedDistributionList() +{ + const QListBoxItem* const item = mListBox->selectedItem(); + if ( !item ) + return; + core()->editDistributionList( item->text() ); +} + +void KAB::DistributionListNg::MainWidget::deleteSelectedDistributionList() +{ + const QListBoxItem* const item = mListBox->selectedItem(); + const QString name = item ? item->text() : QString(); + if ( name.isNull() ) + return; + const KPIM::DistributionList list = KPIM::DistributionList::findByName( + core()->addressBook(), name ); + if ( list.isEmpty() ) + return; + core()->deleteDistributionLists( name ); +} + +void KAB::DistributionListNg::MainWidget::contactsDropped( const QString &listName, const KABC::Addressee::List &addressees ) +{ + if ( addressees.isEmpty() ) + return; + + KPIM::DistributionList list = KPIM::DistributionList::findByName( + core()->addressBook(), listName ); + if ( list.isEmpty() ) // not found [should be impossible] + return; + + for ( KABC::Addressee::List::ConstIterator it = addressees.begin(); it != addressees.end(); ++it ) { + list.insertEntry( *it ); + } + + core()->addressBook()->insertAddressee( list ); + changed( list ); +} + +void KAB::DistributionListNg::MainWidget::changed( const KABC::Addressee& dist ) +{ + emit modified( KABC::Addressee::List() << dist ); +} + +void KAB::DistributionListNg::MainWidget::updateEntries() +{ + const bool hadSelection = mListBox->selectedItem() != 0; + const QStringList newEntries = core()->distributionListNames(); + if ( !mCurrentEntries.isEmpty() && newEntries == mCurrentEntries ) + return; + mCurrentEntries = newEntries; + mListBox->clear(); + mListBox->insertItem( i18n( "All Contacts" ), 0 ); + mListBox->insertStringList( mCurrentEntries ); + if ( !hadSelection ) + mListBox->setSelected( 0, true ); +} + +void KAB::DistributionListNg::MainWidget::itemSelected( int index ) +{ + core()->setSelectedDistributionList( index == 0 ? QString() : mListBox->item( index )->text() ); + mEditButton->setEnabled( index > 0 ); + mRemoveButton->setEnabled( index > 0 ); +} + +#include "distributionlistngwidget.moc" diff --git a/kaddressbook/features/distributionlistngwidget.h b/kaddressbook/features/distributionlistngwidget.h new file mode 100644 index 000000000..4a174dd83 --- /dev/null +++ b/kaddressbook/features/distributionlistngwidget.h @@ -0,0 +1,104 @@ +/* + This file is part of KAddressBook. + Copyright (c) 2007 Klaralvdalens Datakonsult AB <frank@kdab.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 KAB_DISTRIBUTIONLISTNG_MAINWIDGET_H +#define KAB_DISTRIBUTIONLISTNG_MAINWIDGET_H + +#include "extensionwidget.h" + +#include <kabc/addressee.h> + +#include <klistbox.h> + +#include <qstringlist.h> + +class QDragEnterEvent; +class QDragMoveEvent; +class QDropEvent; +class QPoint; +class QPushButton; + +namespace KABC { + class DistributionListManager; +} + +namespace KAB { +namespace DistributionListNg { + +class ListBox : public KListBox +{ + Q_OBJECT +public: + ListBox( QWidget* parent = 0 ); + +signals: + + void dropped( const QString &listName, const KABC::Addressee::List &addressees ); + +protected: + //override + void dragEnterEvent( QDragEnterEvent *event ); + //override + void dragMoveEvent( QDragMoveEvent *event ); + //override + void dropEvent( QDropEvent *event ); +}; + +class MainWidget : public KAB::ExtensionWidget +{ + Q_OBJECT + +public: + explicit MainWidget( KAB::Core *core, QWidget *parent = 0, const char *name = 0 ); + + //impl + QString title() const; + + //impl + QString identifier() const; + + +private: + void changed( const KABC::Addressee& ); + +private slots: + + void deleteSelectedDistributionList(); + void editSelectedDistributionList(); + + void contextMenuRequested( QListBoxItem *item, const QPoint &point ); + void updateEntries(); + void itemSelected( int index ); + void contactsDropped( const QString &listName, const KABC::Addressee::List &addressees ); + +private: + ListBox *mListBox; + QStringList mCurrentEntries; + QPushButton *mAddButton; + QPushButton *mEditButton; + QPushButton *mRemoveButton; +}; + +} // namespace DistributionListNg +} // namespace KAB + +#endif // KAB_DISTRIBUTIONLISTNG_MAINWIDGET_H diff --git a/kaddressbook/features/distributionlistwidget.cpp b/kaddressbook/features/distributionlistwidget.cpp new file mode 100644 index 000000000..9c322d6f6 --- /dev/null +++ b/kaddressbook/features/distributionlistwidget.cpp @@ -0,0 +1,673 @@ +/* + This file is part of KAddressBook. + Copyright (c) 2002 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 "distributionlistwidget.h" + +#include <qbuttongroup.h> +#include <qcombobox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qlistview.h> +#include <qpushbutton.h> +#include <qradiobutton.h> + +#include <kaccelmanager.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kinputdialog.h> +#include <klocale.h> +#include <kmessagebox.h> + +#include <kabc/addresseedialog.h> +#ifdef KDEPIM_NEW_DISTRLISTS +#include <libkdepim/distributionlist.h> +typedef KPIM::DistributionList DistributionList; +#else +#include <kabc/distributionlist.h> +typedef KABC::DistributionList DistributionList; +#endif +#include <kabc/stdaddressbook.h> +#include <kabc/vcardconverter.h> +#include <libkdepim/kvcarddrag.h> + +#include "core.h" + +class DistributionListFactory : public KAB::ExtensionFactory +{ + public: + KAB::ExtensionWidget *extension( KAB::Core *core, QWidget *parent, const char *name ) + { + return new DistributionListWidget( core, parent, name ); + } + + QString identifier() const + { + return "distribution_list_editor"; + } +}; + +extern "C" { + void *init_libkaddrbk_distributionlist() + { + return ( new DistributionListFactory ); + } +} + +/** + We have to catch when the 'Del' key is pressed, otherwise + the event is forwarded to the ViewManager and it tries to + remove a contact instead of the distribution list. + */ +class DeletePressedCatcher : public QObject +{ + public: + DeletePressedCatcher( DistributionListWidget *parent ) + : QObject( parent, "DeletePressedCatcher" ), mWidget( parent ) + { + } + + protected: + bool eventFilter( QObject*, QEvent *event ) + { + if ( event->type() == QEvent::AccelOverride ) { + QKeyEvent *keyEvent = (QKeyEvent*)event; + if ( keyEvent->key() == Qt::Key_Delete ) { + keyEvent->accept(); + mWidget->removeContact(); + return true; + } else + return false; + } else { + return false; + } + } + + private: + DistributionListWidget *mWidget; +}; + +class ContactItem : public QListViewItem +{ + public: + ContactItem( DistributionListView *parent, const KABC::Addressee &addressee, + const QString &email = QString::null ) : + QListViewItem( parent ), + mAddressee( addressee ), + mEmail( email ) + { + setText( 0, addressee.realName() ); + if ( email.isEmpty() ) { + setText( 1, addressee.preferredEmail() ); + setText( 2, i18n( "Yes" ) ); + } else { + setText( 1, email ); + setText( 2, i18n( "No" ) ); + } + } + + KABC::Addressee addressee() const + { + return mAddressee; + } + + QString email() const + { + return mEmail; + } + + protected: + bool acceptDrop( const QMimeSource* ) + { + return true; + } + + private: + KABC::Addressee mAddressee; + QString mEmail; +}; + +DistributionListWidget::DistributionListWidget( KAB::Core *core, QWidget *parent, + const char *name ) + : KAB::ExtensionWidget( core, parent, name ) +#ifndef KDEPIM_NEW_DISTRLISTS + , mManager( 0 ) +#endif +{ + QGridLayout *topLayout = new QGridLayout( this, 3, 4, KDialog::marginHint(), + KDialog::spacingHint() ); + + mNameCombo = new QComboBox( this ); + topLayout->addWidget( mNameCombo, 0, 0 ); + connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateContactView() ) ); + + mCreateListButton = new QPushButton( i18n( "New List..." ), this ); + topLayout->addWidget( mCreateListButton, 0, 1 ); + connect( mCreateListButton, SIGNAL( clicked() ), SLOT( createList() ) ); + + mEditListButton = new QPushButton( i18n( "Rename List..." ), this ); + topLayout->addWidget( mEditListButton, 0, 2 ); + connect( mEditListButton, SIGNAL( clicked() ), SLOT( editList() ) ); + + mRemoveListButton = new QPushButton( i18n( "Remove List" ), this ); + topLayout->addWidget( mRemoveListButton, 0, 3 ); + connect( mRemoveListButton, SIGNAL( clicked() ), SLOT( removeList() ) ); + + mContactView = new DistributionListView( this ); + mContactView->addColumn( i18n( "Name" ) ); + mContactView->addColumn( i18n( "Email" ) ); + mContactView->addColumn( i18n( "Use Preferred" ) ); + mContactView->setEnabled( false ); + mContactView->setAllColumnsShowFocus( true ); + mContactView->setFullWidth( true ); + topLayout->addMultiCellWidget( mContactView, 1, 1, 0, 3 ); + connect( mContactView, SIGNAL( selectionChanged() ), + SLOT( selectionContactViewChanged() ) ); + connect( mContactView, SIGNAL( dropped( QDropEvent*, QListViewItem* ) ), + SLOT( dropped( QDropEvent*, QListViewItem* ) ) ); + + mAddContactButton = new QPushButton( i18n( "Add Contact" ), this ); + mAddContactButton->setEnabled( false ); + topLayout->addWidget( mAddContactButton, 2, 0 ); + connect( mAddContactButton, SIGNAL( clicked() ), SLOT( addContact() ) ); + + mEntryCountLabel = new QLabel( this ); + topLayout->addWidget( mEntryCountLabel, 2, 1 ); + + mChangeEmailButton = new QPushButton( i18n( "Change Email..." ), this ); + topLayout->addWidget( mChangeEmailButton, 2, 2 ); + connect( mChangeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) ); + + mRemoveContactButton = new QPushButton( i18n( "Remove Contact" ), this ); + topLayout->addWidget( mRemoveContactButton, 2, 3 ); + connect( mRemoveContactButton, SIGNAL( clicked() ), SLOT( removeContact() ) ); + +#ifdef KDEPIM_NEW_DISTRLISTS + // When contacts are changed, update both distr list combo and contents of displayed distr list + connect( core, SIGNAL( contactsUpdated() ), + this, SLOT( updateNameCombo() ) ); +#else + mManager = new KABC::DistributionListManager( core->addressBook() ); + + connect( KABC::DistributionListWatcher::self(), SIGNAL( changed() ), + this, SLOT( updateNameCombo() ) ); +#endif + + connect( core->addressBook(), SIGNAL( addressBookChanged( AddressBook* ) ), + this, SLOT( updateNameCombo() ) ); + + updateNameCombo(); + + QObject *catcher = new DeletePressedCatcher( this ); + installEventFilter( catcher ); + mContactView->installEventFilter( catcher ); + + mContactView->restoreLayout( KGlobal::config(), "DistributionListViewColumns" ); + + KAcceleratorManager::manage( this ); +} + +DistributionListWidget::~DistributionListWidget() +{ +#ifndef KDEPIM_NEW_DISTRLISTS + delete mManager; +#endif + + mContactView->saveLayout( KGlobal::config(), "DistributionListViewColumns" ); +} + +void DistributionListWidget::save() +{ +#ifndef KDEPIM_NEW_DISTRLISTS + mManager->save(); +#endif +} + +void DistributionListWidget::selectionContactViewChanged() +{ + ContactItem *contactItem = + static_cast<ContactItem *>( mContactView->selectedItem() ); + bool state = contactItem; + + mChangeEmailButton->setEnabled( state ); + mRemoveContactButton->setEnabled( state ); +} + +bool DistributionListWidget::alreadyExists( const QString& distrListName ) const +{ +#ifdef KDEPIM_NEW_DISTRLISTS + return core()->distributionListNames().contains( distrListName ); +#else + return mManager->listNames().contains( distrListName ); +#endif +} + +void DistributionListWidget::createList() +{ + QString newName = KInputDialog::getText( i18n( "New Distribution List" ), + i18n( "Please enter name:" ), + QString::null, 0, this ); + + if ( newName.isEmpty() ) return; + + if ( alreadyExists( newName ) ) { + KMessageBox::sorry( this, i18n( "The name already exists" ) ); + return; + } +#ifdef KDEPIM_NEW_DISTRLISTS + KABC::Resource* resource = core()->requestResource( this ); + if ( !resource ) + return; + + KPIM::DistributionList dist; + dist.setResource( resource ); + dist.setName( newName ); + // Creates undo-redo command, calls setModified, also triggers contactsUpdated, + // which triggers updateNameCombo, so the new name appears + changed( dist ); + core()->addressBook()->insertAddressee( dist ); + +#else + new KABC::DistributionList( mManager, newName ); + changed(); + + updateNameCombo(); +#endif + + // Select the new one in the list + mNameCombo->setCurrentText( newName ); + // Display the contents of the list we just selected (well, it's empty) + updateContactView(); +} + +void DistributionListWidget::editList() +{ + const QString oldName = mNameCombo->currentText(); + + const QString newName = KInputDialog::getText( i18n( "Rename Distribution List" ), + i18n( "Please enter name:" ), + oldName, 0, this ); + + if ( newName.isEmpty() ) return; + + if ( alreadyExists( newName ) ) { + KMessageBox::sorry( this, i18n( "The name already exists." ) ); + return; + } +#ifdef KDEPIM_NEW_DISTRLISTS + KPIM::DistributionList dist = KPIM::DistributionList::findByName( + core()->addressBook(), mNameCombo->currentText() ); + if ( dist.isEmpty() ) // not found [should be impossible] + return; + + dist.setFormattedName( newName ); + core()->addressBook()->insertAddressee( dist ); + + changed( dist ); +#else + KABC::DistributionList *list = mManager->list( oldName ); + list->setName( newName ); + mManager->save(); + updateNameCombo(); +#endif + + // Select the new name in the list (updateNameCombo couldn't know we wanted that one) + mNameCombo->setCurrentText( newName ); + // Display the contents of the list we just selected + updateContactView(); + +#ifndef KDEPIM_NEW_DISTRLISTS + changed(); +#endif +} + +void DistributionListWidget::removeList() +{ + int result = KMessageBox::warningContinueCancel( this, + i18n( "<qt>Delete distribution list <b>%1</b>?</qt>" ) .arg( mNameCombo->currentText() ), + QString::null, KGuiItem( i18n("Delete"), "editdelete") ); + + if ( result != KMessageBox::Continue ) + return; + +#ifdef KDEPIM_NEW_DISTRLISTS + KPIM::DistributionList dist = KPIM::DistributionList::findByName( + core()->addressBook(), mNameCombo->currentText() ); + if ( dist.isEmpty() ) // not found [should be impossible] + return; + + emit deleted( dist.uid() ); + core()->addressBook()->removeAddressee( dist ); +#else + mManager->remove( mManager->list( mNameCombo->currentText() ) ); + mNameCombo->removeItem( mNameCombo->currentItem() ); + + updateContactView(); + + changed(); +#endif +} + +void DistributionListWidget::addContact() +{ +#ifdef KDEPIM_NEW_DISTRLISTS + KPIM::DistributionList dist = KPIM::DistributionList::findByName( + core()->addressBook(), mNameCombo->currentText() ); + if ( dist.isEmpty() ) { // not found + kdDebug(5720) << k_funcinfo << mNameCombo->currentText() << " not found" << endl; + return; + } +#else + KABC::DistributionList *list = mManager->list( mNameCombo->currentText() ); + if ( !list ) + return; + KABC::DistributionList& dist = *list; +#endif + + const KABC::Addressee::List addrList = selectedContacts(); + KABC::Addressee::List::ConstIterator it; + for ( it = addrList.begin(); it != addrList.end(); ++it ) + dist.insertEntry( *it ); + +#ifdef KDEPIM_NEW_DISTRLISTS + core()->addressBook()->insertAddressee( dist ); + changed( dist ); +#else + updateContactView(); + changed(); +#endif +} + +void DistributionListWidget::removeContact() +{ +#ifdef KDEPIM_NEW_DISTRLISTS + KPIM::DistributionList dist = KPIM::DistributionList::findByName( + core()->addressBook(), mNameCombo->currentText() ); + if ( dist.isEmpty() ) // not found + return; +#else + KABC::DistributionList *list = mManager->list( mNameCombo->currentText() ); + if ( !list ) + return; + KABC::DistributionList& dist = *list; +#endif + + ContactItem *contactItem = + static_cast<ContactItem *>( mContactView->selectedItem() ); + if ( !contactItem ) + return; + + dist.removeEntry( contactItem->addressee(), contactItem->email() ); + delete contactItem; + +#ifdef KDEPIM_NEW_DISTRLISTS + core()->addressBook()->insertAddressee( dist ); + changed( dist ); +#else + changed(); +#endif +} + +void DistributionListWidget::changeEmail() +{ +#ifdef KDEPIM_NEW_DISTRLISTS + KPIM::DistributionList dist = KPIM::DistributionList::findByName( + core()->addressBook(), mNameCombo->currentText() ); + if ( dist.isEmpty() ) // not found + return; +#else + KABC::DistributionList *list = mManager->list( mNameCombo->currentText() ); + if ( !list ) + return; + KABC::DistributionList& dist = *list; +#endif + + ContactItem *contactItem = + static_cast<ContactItem *>( mContactView->selectedItem() ); + if ( !contactItem ) + return; + + bool canceled = false; + const QString email = EmailSelector::getEmail( contactItem->addressee().emails(), + contactItem->email(), this, canceled); + if( canceled) + return; + dist.removeEntry( contactItem->addressee(), contactItem->email() ); + dist.insertEntry( contactItem->addressee(), email ); + +#ifdef KDEPIM_NEW_DISTRLISTS + core()->addressBook()->insertAddressee( dist ); + changed( dist ); +#else + updateContactView(); + changed(); +#endif +} + +void DistributionListWidget::updateContactView() +{ + mContactView->clear(); + + bool isListSelected = false; +#ifdef KDEPIM_NEW_DISTRLISTS + KPIM::DistributionList dist; + if ( mNameCombo->count() != 0 ) + dist = KPIM::DistributionList::findByName( + core()->addressBook(), mNameCombo->currentText() ); + isListSelected = !dist.isEmpty(); +#else + KABC::DistributionList *list = mManager->list( mNameCombo->currentText() ); + isListSelected = list != 0; +#endif + if ( !isListSelected ) { + mEditListButton->setEnabled( false ); + mRemoveListButton->setEnabled( false ); + mChangeEmailButton->setEnabled( false ); + mRemoveContactButton->setEnabled( false ); + mContactView->setEnabled( false ); + return; + } + mEditListButton->setEnabled( true ); + mRemoveListButton->setEnabled( true ); + mContactView->setEnabled( true ); + + uint entryCount = 0; +#ifdef KDEPIM_NEW_DISTRLISTS + const KPIM::DistributionList::Entry::List entries = dist.entries( core()->addressBook() ); + KPIM::DistributionList::Entry::List::ConstIterator it; +#else + const KABC::DistributionList::Entry::List entries = list->entries(); + KABC::DistributionList::Entry::List::ConstIterator it; +#endif + for ( it = entries.begin(); it != entries.end(); ++it, ++entryCount ) + new ContactItem( mContactView, (*it).addressee, (*it).email ); + + bool state = mContactView->selectedItem() != 0; + mChangeEmailButton->setEnabled( state ); + mRemoveContactButton->setEnabled( state ); + + mEntryCountLabel->setText( i18n( "Count: %n contact", "Count: %n contacts", entryCount ) ); +} + +void DistributionListWidget::updateNameCombo() +{ + int pos = mNameCombo->currentItem(); + mNameCombo->clear(); +#ifdef KDEPIM_NEW_DISTRLISTS + const QStringList names = core()->distributionListNames(); +#else + mManager->load(); + const QStringList names = mManager->listNames(); +#endif + mNameCombo->insertStringList( names ); + mNameCombo->setCurrentItem( QMIN( pos, (int)names.count() - 1 ) ); + + updateContactView(); +} + +void DistributionListWidget::dropEvent( QDropEvent *e ) +{ + if ( mNameCombo->count() == 0 ) + return; + +#ifdef KDEPIM_NEW_DISTRLISTS + KPIM::DistributionList dist = KPIM::DistributionList::findByName( + core()->addressBook(), mNameCombo->currentText() ); + if ( dist.isEmpty() ) + return; +#else + KABC::DistributionList *list = mManager->list( mNameCombo->currentText() ); + if ( !list ) + return; + KABC::DistributionList& dist = *list; +#endif + + QString vcards; + if ( KVCardDrag::decode( e, vcards ) ) { + KABC::VCardConverter converter; + const KABC::Addressee::List lst = converter.parseVCards( vcards ); + for ( KABC::Addressee::List::ConstIterator it = lst.begin(); it != lst.end(); ++it ) + dist.insertEntry( *it ); + +#ifdef KDEPIM_NEW_DISTRLISTS + core()->addressBook()->insertAddressee( dist ); + changed( dist ); +#else + changed(); + updateContactView(); +#endif + } +} + +void DistributionListWidget::contactsSelectionChanged() +{ + mAddContactButton->setEnabled( contactsSelected() && mNameCombo->count() > 0 ); +} + +QString DistributionListWidget::title() const +{ + return i18n( "Distribution List Editor" ); +} + +QString DistributionListWidget::identifier() const +{ + return "distribution_list_editor"; +} + +void DistributionListWidget::dropped( QDropEvent *e, QListViewItem* ) +{ + dropEvent( e ); +} + +#ifdef KDEPIM_NEW_DISTRLISTS +void DistributionListWidget::changed( const KABC::Addressee& dist ) +{ + emit modified( KABC::Addressee::List() << dist ); +} +#else +void DistributionListWidget::changed() +{ + save(); +} +#endif + +DistributionListView::DistributionListView( QWidget *parent, const char* name ) + : KListView( parent, name ) +{ + setDragEnabled( true ); + setAcceptDrops( true ); + setAllColumnsShowFocus( true ); +} + +void DistributionListView::dragEnterEvent( QDragEnterEvent* e ) +{ + bool canDecode = QTextDrag::canDecode( e ); + e->accept( canDecode ); +} + +void DistributionListView::viewportDragMoveEvent( QDragMoveEvent *e ) +{ + bool canDecode = QTextDrag::canDecode( e ); + e->accept( canDecode ); +} + +void DistributionListView::viewportDropEvent( QDropEvent *e ) +{ + emit dropped( e, 0 ); +} + +void DistributionListView::dropEvent( QDropEvent *e ) +{ + emit dropped( e, 0 ); +} + + +EmailSelector::EmailSelector( const QStringList &emails, + const QString ¤t, QWidget *parent ) + : KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok|Cancel, Ok, + parent ) +{ + QFrame *topFrame = plainPage(); + QBoxLayout *topLayout = new QVBoxLayout( topFrame ); + + mButtonGroup = new QButtonGroup( 1, Horizontal, i18n("Email Addresses"), + topFrame ); + mButtonGroup->setRadioButtonExclusive( true ); + topLayout->addWidget( mButtonGroup ); + + QRadioButton *button = new QRadioButton( i18n("Preferred address"), mButtonGroup ); + button->setDown( true ); + mEmailMap.insert( mButtonGroup->id( button ), "" ); + + QStringList::ConstIterator it; + for ( it = emails.begin(); it != emails.end(); ++it ) { + button = new QRadioButton( *it, mButtonGroup ); + mEmailMap.insert( mButtonGroup->id( button ), *it ); + if ( (*it) == current ) + button->setDown( true ); + } +} + +QString EmailSelector::selected() const +{ + QButton *button = mButtonGroup->selected(); + if ( button ) + return mEmailMap[ mButtonGroup->id( button ) ]; + + return QString::null; +} + +QString EmailSelector::getEmail( const QStringList &emails, + const QString ¤t, QWidget *parent, bool &canceled ) +{ + EmailSelector dlg( emails, current, parent ); + if(dlg.exec()) + { + canceled = false; + return dlg.selected(); + } + canceled = true; + return QString(); +} + + +#include "distributionlistwidget.moc" diff --git a/kaddressbook/features/distributionlistwidget.h b/kaddressbook/features/distributionlistwidget.h new file mode 100644 index 000000000..d52a06ab0 --- /dev/null +++ b/kaddressbook/features/distributionlistwidget.h @@ -0,0 +1,140 @@ +/* + This file is part of KAddressBook. + Copyright (c) 2002 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 DISTRIBUTIONLISTWIDGET_H +#define DISTRIBUTIONLISTWIDGET_H + +#include <config.h> // for KDEPIM_NEW_DISTRLISTS +#include <kdialogbase.h> +#include <klistview.h> + +#include "extensionwidget.h" + +class QButtonGroup; +class QComboBox; +class QListView; + +class DistributionListView; + +namespace KAB { +class Core; +} + +namespace KABC { +class AddressBook; +class DistributionListManager; +} + +class DistributionListWidget : public KAB::ExtensionWidget +{ + Q_OBJECT + + public: + DistributionListWidget( KAB::Core*, QWidget *parent, const char *name = 0 ); + virtual ~DistributionListWidget(); + + void contactsSelectionChanged(); + + QString title() const; + QString identifier() const; + + public slots: + void save(); + void dropped( QDropEvent*, QListViewItem* ); + + void removeContact(); + + private slots: + void createList(); + void editList(); + void removeList(); + void addContact(); + void changeEmail(); + void updateNameCombo(); + void updateContactView(); + void selectionContactViewChanged(); + + private: +#ifdef KDEPIM_NEW_DISTRLISTS + void changed( const KABC::Addressee& dist ); +#else + void changed(); +#endif + bool alreadyExists( const QString& distrListName ) const; + + protected: + void dropEvent( QDropEvent* ); + + private: + QComboBox *mNameCombo; + QLabel *mEntryCountLabel; + DistributionListView *mContactView; + +#ifndef KDEPIM_NEW_DISTRLISTS + KABC::DistributionListManager *mManager; +#endif + QPushButton *mCreateListButton; + QPushButton *mEditListButton; + QPushButton *mRemoveListButton; + QPushButton *mChangeEmailButton; + QPushButton *mAddContactButton; + QPushButton *mRemoveContactButton; +}; + +/** + @short Helper class +*/ +class DistributionListView : public KListView +{ + Q_OBJECT + + public: + DistributionListView( QWidget *parent, const char* name = 0 ); + + protected: + void dragEnterEvent( QDragEnterEvent *e ); + void dropEvent( QDropEvent *e ); + void viewportDragMoveEvent( QDragMoveEvent *e ); + void viewportDropEvent( QDropEvent *e ); +}; + +/** + @short Helper class +*/ +class EmailSelector : public KDialogBase +{ + public: + EmailSelector( const QStringList &emails, const QString ¤t, + QWidget *parent ); + + QString selected() const; + + static QString getEmail( const QStringList &emails, const QString ¤t, + QWidget *parent, bool &canceled ); + + private: + QButtonGroup *mButtonGroup; + QMap<int, QString> mEmailMap; +}; + +#endif diff --git a/kaddressbook/features/resourceselection.cpp b/kaddressbook/features/resourceselection.cpp new file mode 100644 index 000000000..c7e89dbf5 --- /dev/null +++ b/kaddressbook/features/resourceselection.cpp @@ -0,0 +1,421 @@ +/* + This file is part of KAddressBook. + 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 <qlayout.h> +#include <qpushbutton.h> +#include <qtimer.h> +#include <qlabel.h> +#include <qheader.h> +#include <qtooltip.h> + +#include <kabc/resource.h> +#include <kdialog.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <kinputdialog.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kresources/configdialog.h> + +#include "core.h" + +#include "resourceselection.h" +#include <libkdepim/resourceabc.h> + +class AddressBookWrapper : public KABC::AddressBook +{ + public: + AddressBookWrapper( KABC::AddressBook* ); + + KRES::Manager<KABC::Resource>* getResourceManager() + { + return resourceManager(); + } +}; + +class ResourceItem : public QCheckListItem +{ + public: + ResourceItem( KListView *parent, KABC::Resource *resource ) + : QCheckListItem( parent, resource->resourceName(), CheckBox ), + mResource( resource ), mChecked( false ), + mIsSubresource( false ), mSubItemsCreated( false ), + mResourceIdentifier() + { + setOn( resource->isActive() ); + setPixmap( 0, KGlobal::iconLoader()->loadIcon( "contents", KIcon::Small ) ); + mChecked = isOn(); + } + + ResourceItem( KPIM::ResourceABC *resourceABC, ResourceItem* parent, + const QString& resourceIdent ) + : QCheckListItem( parent, resourceABC->subresourceLabel( resourceIdent ), CheckBox ), + mResource( resourceABC ), mChecked( false ), + mIsSubresource( true ), mSubItemsCreated( false ), + mResourceIdentifier( resourceIdent ) + { + KPIM::ResourceABC* res = dynamic_cast<KPIM::ResourceABC *>( mResource ); + setOn( res->subresourceActive( mResourceIdentifier ) ); + setPixmap( 0, KGlobal::iconLoader()->loadIcon( "contents", KIcon::Small ) ); + mChecked = isOn(); + } + + void createSubresourceItems(); + + void setChecked( bool state ) { mChecked = state; } + bool checked() const { return mChecked; } + KABC::Resource *resource() const { return mResource; } + QString resourceIdentifier() const { return mResourceIdentifier; } + bool isSubResource() const { return mIsSubresource; } + + virtual void stateChange( bool active ); + + private: + KABC::Resource * const mResource; + bool mChecked; + const bool mIsSubresource; + bool mSubItemsCreated; + const QString mResourceIdentifier; +}; + +// Comes from korganizer/resourceview.cpp +void ResourceItem::createSubresourceItems() +{ + KPIM::ResourceABC* res = dynamic_cast<KPIM::ResourceABC *>( mResource ); + QStringList subresources; + if ( res ) + subresources = res->subresources(); + if ( !subresources.isEmpty() ) { + setOpen( true ); + setExpandable( true ); + // This resource has subresources + QStringList::ConstIterator it; + for ( it = subresources.begin(); it != subresources.end(); ++it ) { + (void)new ResourceItem( res, this, *it ); + } + } + mSubItemsCreated = true; +} + +// TODO: connect this to some signalResourceModified +// void ResourceItem::setGuiState() +// { +// if ( mIsSubresource ) +// setOn( mResource->subresourceActive( mResourceIdentifier ) ); +// else +// setOn( mResource->isActive() ); +// } + +void ResourceItem::stateChange( bool active ) +{ + //kdDebug(5720) << k_funcinfo << this << " " << text( 0 ) << " active=" << active << endl; + if ( active && !mIsSubresource ) { + if ( !mSubItemsCreated ) + createSubresourceItems(); + } + + setOpen( active && childCount() > 0 ); +} + +//// + +ResourceSelection::ResourceSelection( KAB::Core *core, QWidget *parent, const char *name ) + : KAB::ExtensionWidget( core, parent, name ), mManager( 0 ) +{ + initGUI(); + + AddressBookWrapper *wrapper = static_cast<AddressBookWrapper*>( core->addressBook() ); + mManager = wrapper->getResourceManager(); + + connect( mAddButton, SIGNAL( clicked() ), SLOT( add() ) ); + connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) ); + connect( mRemoveButton, SIGNAL( clicked() ), SLOT( remove() ) ); + + connect( mListView, SIGNAL( clicked( QListViewItem* ) ), + SLOT( currentChanged( QListViewItem* ) ) ); + + QTimer::singleShot( 0, this, SLOT( updateView() ) ); +} + +ResourceSelection::~ResourceSelection() +{ +} + +QString ResourceSelection::title() const +{ + return i18n( "Address Books" ); +} + +QString ResourceSelection::identifier() const +{ + return "resourceselection"; +} + +void ResourceSelection::add() +{ + QStringList types = mManager->resourceTypeNames(); + QStringList descs = mManager->resourceTypeDescriptions(); + + bool ok = false; + QString desc = KInputDialog::getItem( i18n( "Add Address Book" ), + i18n( "Please select type of the new address book:" ), + descs, 0, false, &ok, this ); + if ( !ok ) + return; + + QString type = types[ descs.findIndex( desc ) ]; + + // Create new resource + KABC::Resource *resource = mManager->createResource( type ); + if ( !resource ) { + KMessageBox::error( this, i18n("<qt>Unable to create an address book of type <b>%1</b>.</qt>") + .arg( type ) ); + return; + } + + resource->setResourceName( i18n( "%1 address book" ).arg( type ) ); + resource->setAddressBook(core()->addressBook()); + + KRES::ConfigDialog dlg( this, QString( "contact" ), resource ); + + if ( dlg.exec() ) { + core()->addressBook()->addResource( resource ); + resource->asyncLoad(); + + mLastResource = resource->identifier(); + updateView(); + } else { + delete resource; + resource = 0; + } +} + +void ResourceSelection::edit() +{ + ResourceItem *item = selectedItem(); + if ( !item ) + return; + + KRES::ConfigDialog dlg( this, QString( "contact" ), item->resource() ); + + if ( dlg.exec() ) { + mManager->change( item->resource() ); + item->resource()->asyncLoad(); + + mLastResource = item->resource()->identifier(); + updateView(); + } +} + +void ResourceSelection::remove() +{ + ResourceItem *item = selectedItem(); + if ( !item ) + return; + + int result = KMessageBox::warningContinueCancel( this, + i18n( "<qt>Do you really want to remove the address book <b>%1</b>?</qt>" ) + .arg( item->resource()->resourceName() ), "", + KGuiItem( i18n( "&Remove" ), "editdelete" ) ); + if ( result == KMessageBox::Cancel ) + return; + + mLastResource = item->resource()->identifier(); + + core()->addressBook()->removeResource( item->resource() ); + core()->addressBook()->emitAddressBookChanged(); + + updateView(); +} + +void ResourceSelection::currentChanged( QListViewItem *item ) +{ + ResourceItem *resItem = static_cast<ResourceItem*>( item ); + bool state = (resItem && !resItem->isSubResource() ); + + mEditButton->setEnabled( state ); + mRemoveButton->setEnabled( state ); + + if ( !resItem ) + return; + + KABC::Resource *resource = resItem->resource(); + + if ( resItem->checked() != resItem->isOn() ) { + resItem->setChecked( resItem->isOn() ); + if ( resItem->isSubResource() ) { + KPIM::ResourceABC *res = dynamic_cast<KPIM::ResourceABC *>( resource ); + res->setSubresourceActive( resItem->resourceIdentifier(), resItem->isOn() ); + mManager->change( resource ); + } else { + resource->setActive( resItem->isOn() ); + mManager->change( resource ); + + if ( resItem->checked() ) { + if ( !resource->addressBook() ) + resource->setAddressBook( core()->addressBook() ); + + if ( !resource->isOpen() ) + resource->open(); + + resource->asyncLoad(); + } else { + resource->close(); + } + } + + mLastResource = resource->identifier(); + core()->addressBook()->emitAddressBookChanged(); + //updateView(); + } +} + +void ResourceSelection::updateView() +{ + if ( !mManager ) + return; + + mListView->clear(); + + KRES::Manager<KABC::Resource>::Iterator it; + for ( it = mManager->begin(); it != mManager->end(); ++it ) { + + new ResourceItem( mListView, *it ); + KPIM::ResourceABC* resource = dynamic_cast<KPIM::ResourceABC *>( *it ); + if ( resource ) { + disconnect( resource, 0, this, 0 ); + connect( resource, SIGNAL( signalSubresourceAdded( KPIM::ResourceABC *, + const QString &, const QString & ) ), + SLOT( slotSubresourceAdded( KPIM::ResourceABC *, + const QString &, const QString & ) ) ); + + connect( resource, SIGNAL( signalSubresourceRemoved( KPIM::ResourceABC *, + const QString &, const QString & ) ), + SLOT( slotSubresourceRemoved( KPIM::ResourceABC *, + const QString &, const QString & ) ) ); + //connect( resource, SIGNAL( resourceSaved( KPIM::ResourceABC * ) ), + // SLOT( closeResource( KPIM::ResourceABC * ) ) ); + } + } + + QListViewItemIterator itemIt( mListView ); + while ( itemIt.current() ) { + ResourceItem *item = static_cast<ResourceItem*>( itemIt.current() ); + if ( item->resource()->identifier() == mLastResource ) { + mListView->setSelected( item, true ); + mListView->ensureItemVisible( item ); + break; + } + ++itemIt; + } + + core()->addressBook()->emitAddressBookChanged(); +} + + +// Add a new entry +void ResourceSelection::slotSubresourceAdded( KPIM::ResourceABC *resource, + const QString& /*type*/, + const QString& subResource ) +{ + kdDebug(5720) << k_funcinfo << resource->resourceName() << " " << subResource << endl; + QListViewItem *i = mListView->findItem( resource->resourceName(), 0 ); + if ( !i ) + // Not found + return; + + ResourceItem *item = static_cast<ResourceItem *>( i ); + (void)new ResourceItem( resource, item, subResource ); +} + +// Remove an entry +void ResourceSelection::slotSubresourceRemoved( KPIM::ResourceABC* resource, + const QString& /*type*/, + const QString& subResource ) +{ + core()->addressBook()->emitAddressBookChanged(); + updateView(); +} + +ResourceItem* ResourceSelection::selectedItem() const +{ + return static_cast<ResourceItem*>( mListView->selectedItem() ); +} + +void ResourceSelection::initGUI() +{ + QBoxLayout *topLayout = new QVBoxLayout( this ); + topLayout->setSpacing( KDialog::spacingHint() ); + + QBoxLayout *buttonLayout = new QHBoxLayout(); + buttonLayout->setSpacing( KDialog::spacingHint() ); + topLayout->addLayout( buttonLayout ); + + QLabel *abLabel = new QLabel( i18n( "Address Books" ), this ); + buttonLayout->addWidget( abLabel ); + buttonLayout->addStretch( 1 ); + + mAddButton = new QPushButton( this ); + mAddButton->setIconSet( SmallIconSet( "add" ) ); + QToolTip::add( mAddButton, i18n( "Add addressbook" ) ); + buttonLayout->addWidget( mAddButton ); + mEditButton = new QPushButton( this ); + mEditButton->setIconSet( SmallIconSet( "edit" ) ); + mEditButton->setEnabled( false ); + QToolTip::add( mEditButton, i18n( "Edit addressbook settings" ) ); + buttonLayout->addWidget( mEditButton ); + mRemoveButton = new QPushButton( this ); + mRemoveButton->setIconSet( SmallIconSet( "remove" ) ); + mRemoveButton->setEnabled( false ); + QToolTip::add( mRemoveButton, i18n( "Remove addressbook" ) ); + buttonLayout->addWidget( mRemoveButton ); + + mListView = new KListView( this ); + mListView->header()->hide(); + mListView->addColumn( i18n( "Address Books" ) ); + mListView->setFullWidth( true ); + topLayout->addWidget( mListView ); +} + +class ResourceSelectionFactory : public KAB::ExtensionFactory +{ + public: + KAB::ExtensionWidget *extension( KAB::Core *core, QWidget *parent, const char *name ) + { + return new ResourceSelection( core, parent, name ); + } + + QString identifier() const + { + return "resourceselection"; + } +}; + +extern "C" { + void *init_libkaddrbk_resourceselection() + { + return ( new ResourceSelectionFactory ); + } +} + +#include "resourceselection.moc" diff --git a/kaddressbook/features/resourceselection.desktop b/kaddressbook/features/resourceselection.desktop new file mode 100644 index 000000000..4879e939f --- /dev/null +++ b/kaddressbook/features/resourceselection.desktop @@ -0,0 +1,110 @@ +[Desktop Entry] +X-KDE-Library=libkaddrbk_resourceselection +Name=Address Book Management Plugin +Name[af]=Adres boek bestuur inprop module +Name[be]=Дапаўненне "Кіраванне адраснамі кнігамі" +Name[bg]=Приставка за управление на адресника +Name[br]=Lugent melestradur ar c'harnedoù chomlec'hioù +Name[bs]=Dodatak za rukovanje adresarom +Name[ca]=Endollable de gestió de llibretes d'adreces +Name[cs]=Modul pro správu knih adres +Name[da]=Plugin for adressebogshåndtering +Name[de]=Adressbuchverwaltungs-Modul +Name[el]=Πρόσθετο διαχείρισης βιβλίου διευθύνσεων +Name[eo]=Adresar-administra kromaĵo +Name[es]=Extensión para gestionar la libreta de direcciones +Name[et]=Aadressihalduri plugin +Name[eu]=Helbide-liburu kudeaketa plugin-a +Name[fa]=وصلۀ مدیریت کتاب نشانی +Name[fi]=Osoitekirjan ylläpidon laajennus +Name[fr]=Module de gestion de carnet d'adresses +Name[fy]=Plugin foar adresboekbehear +Name[ga]=Breiseán Bhainisteoireacht Leabhar na Seoltaí +Name[gl]=Extensión para xestión do Caderno de Enderezos +Name[he]=תוסף מנהל הכתובות +Name[hu]=Címjegyzékkezelő bővítőmodul +Name[is]=Umsjónaríforrit vistfangaflettis +Name[it]=Plugin per gestire rubriche indirizzi +Name[ja]=アドレス帳管理プラグイン +Name[ka]=წიგნაკის მართვის მოდული +Name[kk]=Адрестік кітапшамен айналысу плагин модулі +Name[km]=កម្មវិធីជំនួយការគ្រប់គ្រងសៀវភៅអាសយដ្ឋាន +Name[lt]=Adresų knygelės tvarkymo priedas +Name[mk]=Приклучок за менаџирање адресари +Name[ms]=Plugin Pengurusan Buku Alamat +Name[nb]=Programtillegg for adressebok behandling +Name[nds]=Adressbookpleeg-Moduul +Name[ne]=ठेगाना पुस्तिका व्यवस्थापन प्लगइन +Name[nl]=Plugin voor adresboekbeheer +Name[nn]=Programtillegg for adressebokhandtering +Name[pl]=Wtyczka zarządzania Książką adresową +Name[pt]='Plugin' de Gestão do Livro de Endereços +Name[pt_BR]=Plug-in de Gerenciamento do Livro de Endereços +Name[ru]=Управление адресной книгой +Name[se]=Lassemoduvla mii gieđáhalla čujuhusgirjjiid +Name[sk]=Modul pre správu adresára +Name[sl]=Vstavek Upravitelj adresarjev +Name[sr]=Прикључак управљања адресаром +Name[sr@Latn]=Priključak upravljanja adresarom +Name[sv]=Insticksprogram för adressbokshantering +Name[ta]=முகவரி புத்தகம் மேலாண்மை சொருகுப்பொருள் +Name[tg]=Идоракунии китоби адресӣ +Name[tr]=Adres Defteri Düzenleme Eklentisi +Name[uk]=Втулок для керування адресною книгою +Name[zh_CN]=地址簿管理插件 +Name[zh_TW]=管理通訊錄外掛程式 +Comment=Plugin for managing address books +Comment[af]=Inprop module om adres boeke te bestuur +Comment[be]=Дапаўненне для кіравання адраснамі кнігамі +Comment[bg]=Приставка за управление на адресника +Comment[br]=Lugent melestradur ar c'harnedoù chomlec'hioù +Comment[bs]=Dodatak za upravljanje adresarima +Comment[ca]=Endollable per gestionar llibretes d'adreces +Comment[cs]=Modul pro správu knih adres +Comment[da]=Plugin til at håndtere adressebøger +Comment[de]=Modul zur Verwaltung von Adressbüchern +Comment[el]=Πρόσθετο για τη διαχείριση βιβλίων διευθύνσεων +Comment[eo]=Kromaĵo por administri ddresarojn +Comment[es]=Extenxión para gestionar libretas de direcciones +Comment[et]=Plugin aadressiraamatute haldamiseks +Comment[eu]=Helbide-liburuak kudeatzeko plugin-a +Comment[fa]=وصله برای مدیریت کتابهای نشانی +Comment[fi]=Osoitekirjojen ylläpidon laajennus +Comment[fr]=Module pour gérer les carnets d'adresses +Comment[fy]=Plugin foar it behearen fan adresboeken +Comment[gl]=Extensión para xestionar cadernos de enderezos +Comment[he]=תוסף לניהול פנקסי כתובות +Comment[hu]=Bővítőmodul címjegyzékek kezeléséhez +Comment[is]=Íforrit til að sjá um vistfangaskrár +Comment[it]=Plugin per gestire rubriche indirizzi +Comment[ja]=アドレス帳管理用プラグイン +Comment[ka]=წიგნაკის მართვის მოდული +Comment[kk]=Адрестік кітапшамен айналысу плагин модулі +Comment[km]=កម្មវិធីជំនួយដើម្បីគ្រប់គ្រងសៀវភៅអាសយដ្ឋាន +Comment[lt]=Priedas adresų knygelių tvarkymui +Comment[mk]=Приклучок за менаџирање адресари +Comment[ms]=Plugin untuk pengurusan buku alamat +Comment[nb]=Programtillegg for å håndtere adressebøker +Comment[nds]=Moduul för't Plegen vun Adressböker +Comment[ne]=ठगाना पुस्तिका व्यवस्थापनका लागि प्लगइन +Comment[nl]=Plugin voor het beheren van adresboeken +Comment[nn]=Programtillegg for handtering av adressebøker +Comment[pl]=Wtyczka do zarządzania książkami adresowymi +Comment[pt]=Um 'plugin' para gerir os livros de endereços +Comment[pt_BR]=Plug-in para gerenciar livros de endereços +Comment[ru]=Управление адресными книгами +Comment[se]=Lassemoduvla mii gieđahallá čujuhusgirjjiid +Comment[sk]=Modul pre správu adresárov +Comment[sl]=Vstavek za upravljanje adresarjev +Comment[sr]=Прикључак за управљање адресарима +Comment[sr@Latn]=Priključak za upravljanje adresarima +Comment[sv]=Insticksprogram för att hantera adressböcker +Comment[ta]=பகிர்தல் பட்டியல் நிர்வகித்தலின் சொருகுப்பொருள் +Comment[tg]=Идоракунии китобҳои адресӣ +Comment[tr]=Adres defteterini düzenlemek için eklenti +Comment[uk]=Втулок для керування адресними книгами +Comment[zh_CN]=管理地址簿的插件 +Comment[zh_TW]=管理通訊錄外掛程式 +Type=Service +ServiceTypes=KAddressBook/Extension +X-KDE-KAddressBook-ExtensionPluginVersion=1 diff --git a/kaddressbook/features/resourceselection.h b/kaddressbook/features/resourceselection.h new file mode 100644 index 000000000..07c458f37 --- /dev/null +++ b/kaddressbook/features/resourceselection.h @@ -0,0 +1,81 @@ +/* + This file is part of KAddressBook. + 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 RESOURCESELECTION_H +#define RESOURCESELECTION_H + +#include <klistview.h> + +#include "extensionwidget.h" + +class QListViewItem; +class QPushButton; + +namespace KPIM { class ResourceABC; } + +class ResourceItem; + +class ResourceSelection : public KAB::ExtensionWidget +{ + Q_OBJECT + + public: + ResourceSelection( KAB::Core*, QWidget *parent, const char *name ); + virtual ~ResourceSelection(); + + QString title() const; + QString identifier() const; + + void contactsSelectionChanged() {}; + + private slots: + void add(); + void edit(); + void remove(); + void currentChanged( QListViewItem* ); + + void updateView(); + + void slotSubresourceAdded( KPIM::ResourceABC *resource, + const QString& /*type*/, + const QString& subResource ); + void slotSubresourceRemoved( KPIM::ResourceABC* /*resource*/, + const QString& /*type*/, + const QString& subResource ); + + private: + void initGUI(); + + ResourceItem* selectedItem() const; + + KListView *mListView; + QPushButton *mAddButton; + QPushButton *mEditButton; + QPushButton *mRemoveButton; + + QString mLastResource; + + KRES::Manager<KABC::Resource> *mManager; +}; + +#endif |