kaddressbook

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 Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
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   // do nothing
00068   return false;
00069 }
00070 
00071 KABC::AddresseeList XXPort::importContacts( const QString& ) const
00072 {
00073   // do nothing
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"
KDE Home | KDE Accessibility Home | Description of Access Keys