xxport.h
00001 /* 00002 This file is part of KAddressbook. 00003 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of TQt, and distribute the resulting executable, 00021 without including the source code for TQt in the source distribution. 00022 */ 00023 00024 #ifndef KAB_XXPORT_H 00025 #define KAB_XXPORT_H 00026 00027 #include <tqobject.h> 00028 00029 #include <tdeabc/addressbook.h> 00030 #include <tdeabc/addresseelist.h> 00031 #include <klibloader.h> 00032 #include <kxmlguiclient.h> 00033 #include <tdepimmacros.h> 00034 00035 #define KAB_XXPORT_PLUGIN_VERSION 1 00036 00037 class TDEApplication; 00038 00046 #define K_EXPORT_KADDRESSBOOK_XXFILTER_CATALOG( libname, XXPortClass, catalog ) \ 00047 class KDE_NO_EXPORT localXXPortFactory : public KAB::XXPortFactory { \ 00048 KAB::XXPort *xxportObject( TDEABC::AddressBook *ab, TQWidget *parent, const char *name ) \ 00049 { const char *cat = catalog; \ 00050 if (cat) TDEGlobal::locale()->insertCatalogue(cat); \ 00051 return new XXPortClass( ab, parent, name ); \ 00052 } \ 00053 }; \ 00054 K_EXPORT_COMPONENT_FACTORY( libname, localXXPortFactory ) 00055 00062 #define K_EXPORT_KADDRESSBOOK_XXFILTER( libname, XXPortClass ) \ 00063 K_EXPORT_KADDRESSBOOK_XXFILTER_CATALOG( libname, XXPortClass, NULL ) 00064 00065 00066 namespace KAB { 00067 00068 class KDE_EXPORT XXPort : public TQObject, virtual public KXMLGUIClient 00069 { 00070 Q_OBJECT 00071 00072 00073 public: 00074 XXPort( TDEABC::AddressBook *ab, TQWidget *parent, const char *name = 0 ); 00075 ~XXPort(); 00076 00081 virtual TQString identifier() const = 0; 00082 00087 virtual bool requiresSorting() const { return false; } 00088 00093 void setTDEApplication( TDEApplication *app ); 00094 00101 void processEvents() const; 00102 00103 public slots: 00107 virtual bool exportContacts( const TDEABC::AddresseeList &list, const TQString& identifier ); 00108 00112 virtual TDEABC::AddresseeList importContacts( const TQString& identifier ) const; 00113 00114 signals: 00120 void exportActivated( const TQString&, const TQString& ); 00121 00127 void importActivated( const TQString&, const TQString& ); 00128 00129 protected: 00133 void createImportAction( const TQString &label, const TQString &identifier = TQString() ); 00134 00138 void createExportAction( const TQString &label, const TQString &identifier = TQString() ); 00139 00143 TDEABC::AddressBook *addressBook() const; 00144 00149 TQWidget *parentWidget() const; 00150 00151 private slots: 00152 void slotImportActivated( const TQString& ); 00153 void slotExportActivated( const TQString& ); 00154 00155 private: 00156 TDEABC::AddressBook *mAddressBook; 00157 TQWidget *mParentWidget; 00158 00159 class XXPortPrivate; 00160 XXPortPrivate *d; 00161 }; 00162 00163 class XXPortFactory : public KLibFactory 00164 { 00165 public: 00166 virtual XXPort *xxportObject( TDEABC::AddressBook *ab, TQWidget *parent, 00167 const char *name = 0 ) = 0; 00168 00169 protected: 00170 virtual TQObject* createObject( TQObject*, const char*, const char*, 00171 const TQStringList & ) 00172 { 00173 return 0; 00174 } 00175 }; 00176 00177 00178 } /* namespace KAB */ 00179 00180 #endif