00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <tqmap.h>
00025 #include <tqsignalmapper.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 TQSignalMapper *mExportMapper;
00039 TQSignalMapper *mImportMapper;
00040 KApplication *mKApp;
00041 };
00042
00043 XXPort::XXPort( KABC::AddressBook *ab, TQWidget *parent,
00044 const char *name )
00045 : TQObject( parent, name ), mAddressBook( ab ), mParentWidget( parent ),
00046 d( new XXPortPrivate )
00047 {
00048 setInstance( new KInstance( "kaddressbook" ) );
00049
00050 d->mExportMapper = new TQSignalMapper( this );
00051 d->mImportMapper = new TQSignalMapper( this );
00052
00053 connect( d->mExportMapper, TQT_SIGNAL( mapped( const TQString& ) ),
00054 TQT_SLOT( slotExportActivated( const TQString& ) ) );
00055 connect( d->mImportMapper, TQT_SIGNAL( mapped( const TQString& ) ),
00056 TQT_SLOT( slotImportActivated( const TQString& ) ) );
00057 }
00058
00059 XXPort::~XXPort()
00060 {
00061 delete d;
00062 d = 0;
00063 }
00064
00065 bool XXPort::exportContacts( const KABC::AddresseeList&, const TQString& )
00066 {
00067
00068 return false;
00069 }
00070
00071 KABC::AddresseeList XXPort::importContacts( const TQString& ) const
00072 {
00073
00074 return KABC::AddresseeList();
00075 }
00076
00077 void XXPort::createImportAction( const TQString &label, const TQString &data )
00078 {
00079 TQString id = "file_import_" + identifier() + ( data.isEmpty() ? TQString( "" ) : "_" + data );
00080 KAction *action = new KAction( label, 0, d->mImportMapper, TQT_SLOT( map() ), actionCollection(), id.latin1() );
00081
00082 d->mImportMapper->setMapping( action, ( data.isEmpty() ? TQString( "<empty>" ) : data ) );
00083
00084 setXMLFile( identifier() + "_xxportui.rc" );
00085 }
00086
00087 void XXPort::createExportAction( const TQString &label, const TQString &data )
00088 {
00089 TQString id = "file_export_" + identifier() + ( data.isEmpty() ? TQString( "" ) : "_" + data );
00090 KAction *action = new KAction( label, 0, d->mExportMapper, TQT_SLOT( map() ), actionCollection(), id.latin1() );
00091
00092 d->mExportMapper->setMapping( action, ( data.isEmpty() ? TQString( "<empty>" ) : data ) );
00093
00094 setXMLFile( identifier() + "_xxportui.rc" );
00095 }
00096
00097 KABC::AddressBook *XXPort::addressBook() const
00098 {
00099 return mAddressBook;
00100 }
00101
00102 TQWidget *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 TQString &data )
00119 {
00120 emit exportActivated( identifier(), ( data == "<empty>" ? TQString() : data ) );
00121 }
00122
00123 void XXPort::slotImportActivated( const TQString &data )
00124 {
00125 emit importActivated( identifier(), ( data == "<empty>" ? TQString() : data ) );
00126 }
00127
00128 #include "xxport.moc"