kaddressbook

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 Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #ifndef KAB_XXPORT_H
00025 #define KAB_XXPORT_H
00026 
00027 #include <qobject.h>
00028 
00029 #include <kabc/addressbook.h>
00030 #include <kabc/addresseelist.h>
00031 #include <klibloader.h>
00032 #include <kxmlguiclient.h>
00033 #include <kdepimmacros.h>
00034 
00035 #define KAB_XXPORT_PLUGIN_VERSION 1
00036 
00037 class KApplication;
00038 
00046 #define K_EXPORT_KADDRESSBOOK_XXFILTER_CATALOG( libname, XXPortClass, catalog ) \
00047  class KDE_NO_EXPORT localXXPortFactory : public KAB::XXPortFactory { \
00048     KAB::XXPort *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) \
00049      { const char *cat = catalog; \
00050        if (cat) KGlobal::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 QObject, virtual public KXMLGUIClient
00069 {
00070   Q_OBJECT
00071 
00072   public:
00073     XXPort( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
00074     ~XXPort();
00075 
00080     virtual QString identifier() const = 0;
00081 
00086     virtual bool requiresSorting() const { return false; }
00087 
00092     void setKApplication( KApplication *app );
00093 
00100     void processEvents() const;
00101 
00102   public slots:
00106     virtual bool exportContacts( const KABC::AddresseeList &list, const QString& identifier );
00107 
00111     virtual KABC::AddresseeList importContacts( const QString& identifier ) const;
00112 
00113   signals:
00119     void exportActivated( const QString&, const QString& );
00120 
00126     void importActivated( const QString&, const QString& );
00127 
00128   protected:
00132     void createImportAction( const QString &label, const QString &identifier = QString::null );
00133 
00137     void createExportAction( const QString &label, const QString &identifier = QString::null );
00138 
00142     KABC::AddressBook *addressBook() const;
00143 
00148     QWidget *parentWidget() const;
00149 
00150   private slots:
00151     void slotImportActivated( const QString& );
00152     void slotExportActivated( const QString& );
00153 
00154   private:
00155     KABC::AddressBook *mAddressBook;
00156     QWidget *mParentWidget;
00157 
00158     class XXPortPrivate;
00159     XXPortPrivate *d;
00160 };
00161 
00162 class XXPortFactory : public KLibFactory
00163 {
00164   public:
00165     virtual XXPort *xxportObject( KABC::AddressBook *ab, QWidget *parent,
00166                                   const char *name = 0 ) = 0;
00167 
00168   protected:
00169     virtual QObject* createObject( QObject*, const char*, const char*,
00170                                    const QStringList & )
00171     {
00172       return 0;
00173     }
00174 };
00175 
00176 
00177 } /* namespace KAB */
00178 
00179 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys