kaddressbook
xxport.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <qmap.h>
00025 #include <qsignalmapper.h>
00026
00027 #include <kaction.h>
00028 #include <kinstance.h>
00029 #include <kmessagebox.h>
00030 #include <kapplication.h>
00031 #include "xxport.h"
00032
00033 using namespace KAB;
00034
00035 class XXPort::XXPortPrivate
00036 {
00037 public:
00038 QSignalMapper *mExportMapper;
00039 QSignalMapper *mImportMapper;
00040 KApplication *mKApp;
00041 };
00042
00043 XXPort::XXPort( KABC::AddressBook *ab, QWidget *parent,
00044 const char *name )
00045 : QObject( parent, name ), mAddressBook( ab ), mParentWidget( parent ),
00046 d( new XXPortPrivate )
00047 {
00048 setInstance( new KInstance( "kaddressbook" ) );
00049
00050 d->mExportMapper = new QSignalMapper( this );
00051 d->mImportMapper = new QSignalMapper( this );
00052
00053 connect( d->mExportMapper, SIGNAL( mapped( const QString& ) ),
00054 SLOT( slotExportActivated( const QString& ) ) );
00055 connect( d->mImportMapper, SIGNAL( mapped( const QString& ) ),
00056 SLOT( slotImportActivated( const QString& ) ) );
00057 }
00058
00059 XXPort::~XXPort()
00060 {
00061 delete d;
00062 d = 0;
00063 }
00064
00065 bool XXPort::exportContacts( const KABC::AddresseeList&, const QString& )
00066 {
00067
00068 return false;
00069 }
00070
00071 KABC::AddresseeList XXPort::importContacts( const QString& ) const
00072 {
00073
00074 return KABC::AddresseeList();
00075 }
00076
00077 void XXPort::createImportAction( const QString &label, const QString &data )
00078 {
00079 QString id = "file_import_" + identifier() + ( data.isEmpty() ? QString( "" ) : "_" + data );
00080 KAction *action = new KAction( label, 0, d->mImportMapper, SLOT( map() ), actionCollection(), id.latin1() );
00081
00082 d->mImportMapper->setMapping( action, ( data.isEmpty() ? QString( "<empty>" ) : data ) );
00083
00084 setXMLFile( identifier() + "_xxportui.rc" );
00085 }
00086
00087 void XXPort::createExportAction( const QString &label, const QString &data )
00088 {
00089 QString id = "file_export_" + identifier() + ( data.isEmpty() ? QString( "" ) : "_" + data );
00090 KAction *action = new KAction( label, 0, d->mExportMapper, SLOT( map() ), actionCollection(), id.latin1() );
00091
00092 d->mExportMapper->setMapping( action, ( data.isEmpty() ? QString( "<empty>" ) : data ) );
00093
00094 setXMLFile( identifier() + "_xxportui.rc" );
00095 }
00096
00097 KABC::AddressBook *XXPort::addressBook() const
00098 {
00099 return mAddressBook;
00100 }
00101
00102 QWidget *XXPort::parentWidget() const
00103 {
00104 return mParentWidget;
00105 }
00106
00107 void XXPort::setKApplication( KApplication *app )
00108 {
00109 d->mKApp = app;
00110 }
00111
00112 void XXPort::processEvents() const
00113 {
00114 if ( d->mKApp )
00115 d->mKApp->processEvents();
00116 }
00117
00118 void XXPort::slotExportActivated( const QString &data )
00119 {
00120 emit exportActivated( identifier(), ( data == "<empty>" ? QString::null : data ) );
00121 }
00122
00123 void XXPort::slotImportActivated( const QString &data )
00124 {
00125 emit importActivated( identifier(), ( data == "<empty>" ? QString::null : data ) );
00126 }
00127
00128 #include "xxport.moc"
|