xxport.cpp
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 #include <tqmap.h> 00025 #include <tqsignalmapper.h> 00026 00027 #include <tdeaction.h> 00028 #include <kinstance.h> 00029 #include <tdemessagebox.h> 00030 #include <tdeapplication.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 TDEApplication *mKApp; 00041 }; 00042 00043 XXPort::XXPort( TDEABC::AddressBook *ab, TQWidget *parent, 00044 const char *name ) 00045 : TQObject( parent, name ), mAddressBook( ab ), mParentWidget( parent ), 00046 d( new XXPortPrivate ) 00047 { 00048 setInstance( new TDEInstance( "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 TDEABC::AddresseeList&, const TQString& ) 00066 { 00067 // do nothing 00068 return false; 00069 } 00070 00071 TDEABC::AddresseeList XXPort::importContacts( const TQString& ) const 00072 { 00073 // do nothing 00074 return TDEABC::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 TDEAction *action = new TDEAction( 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 TDEAction *action = new TDEAction( 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 TDEABC::AddressBook *XXPort::addressBook() const 00098 { 00099 return mAddressBook; 00100 } 00101 00102 TQWidget *XXPort::parentWidget() const 00103 { 00104 return mParentWidget; 00105 } 00106 00107 void XXPort::setTDEApplication( TDEApplication *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"