summaryrefslogtreecommitdiffabout
path: root/kaddressbook/xxportmanager.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kaddressbook/xxportmanager.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kaddressbook/xxportmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxportmanager.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp
index 405f7ec..95b240d 100644
--- a/kaddressbook/xxportmanager.cpp
+++ b/kaddressbook/xxportmanager.cpp
@@ -1,80 +1,82 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qlist.h> 32#include <qlist.h>
33//Added by qt3to4:
34#include <Q3VBoxLayout>
33 35
34#include <kabc/addressbook.h> 36#include <kabc/addressbook.h>
35#include <kabc/resource.h> 37#include <kabc/resource.h>
36#include <kdebug.h> 38#include <kdebug.h>
37#include <kdialogbase.h> 39#include <kdialogbase.h>
38#include <klocale.h> 40#include <klocale.h>
39#include <kmessagebox.h> 41#include <kmessagebox.h>
40 42
41#ifndef KAB_EMBEDDED 43#ifndef KAB_EMBEDDED
42#include <ktrader.h> 44#include <ktrader.h>
43#else //KAB_EMBEDDED 45#else //KAB_EMBEDDED
44extern "C" 46extern "C"
45{ 47{
46 void* init_microkaddrbk_csv_xxport(); 48 void* init_microkaddrbk_csv_xxport();
47 void* init_microkaddrbk_kde2_xxport(); 49 void* init_microkaddrbk_kde2_xxport();
48 void* init_microkaddrbk_vcard_xxport(); 50 void* init_microkaddrbk_vcard_xxport();
49 // void* init_microkaddrbk_opie_xxport(); 51 // void* init_microkaddrbk_opie_xxport();
50 void* init_microkaddrbk_qtopia_xxport(); 52 void* init_microkaddrbk_qtopia_xxport();
51 void* init_microkaddrbk_sharpdtm_xxport(); 53 void* init_microkaddrbk_sharpdtm_xxport();
52} 54}
53#endif //KAB_EMBEDDED 55#endif //KAB_EMBEDDED
54 56
55#include <addresseeview.h> 57#include <addresseeview.h>
56 58
57#include "kabcore.h" 59#include "kabcore.h"
58#include "undocmds.h" 60#include "undocmds.h"
59#include "xxportselectdialog.h" 61#include "xxportselectdialog.h"
60 62
61#include "xxportmanager.h" 63#include "xxportmanager.h"
62#include "nameeditdialog.h" 64#include "nameeditdialog.h"
63 65
64KURL XXPortManager::importURL = KURL(); 66KURL XXPortManager::importURL = KURL();
65QString XXPortManager::importData = QString::null; 67QString XXPortManager::importData = QString::null;
66 68
67class PreviewDialog : public KDialogBase 69class PreviewDialog : public KDialogBase
68{ 70{
69 public: 71 public:
70 PreviewDialog( const KABC::Addressee &addr, 72 PreviewDialog( const KABC::Addressee &addr,
71 QWidget *parent, const char *name = 0 ); 73 QWidget *parent, const char *name = 0 );
72}; 74};
73 75
74XXPortManager::XXPortManager( KABCore *core, QObject *parent, const char *name ) 76XXPortManager::XXPortManager( KABCore *core, QObject *parent, const char *name )
75 : QObject( parent, name ), mCore( core ), mShowPreview( false ) 77 : QObject( parent, name ), mCore( core ), mShowPreview( false )
76{ 78{
77 loadPlugins(); 79 loadPlugins();
78} 80}
79 81
80XXPortManager::~XXPortManager() 82XXPortManager::~XXPortManager()
@@ -172,99 +174,96 @@ void XXPortManager::noPreview()
172{ 174{
173 mShowPreview = false; 175 mShowPreview = false;
174} 176}
175void XXPortManager::slotExport( const QString &identifier, const QString &data ) 177void XXPortManager::slotExport( const QString &identifier, const QString &data )
176{ 178{
177 XXPortObject *obj = mXXPortObjects[ identifier ]; 179 XXPortObject *obj = mXXPortObjects[ identifier ];
178 if ( !obj ) { 180 if ( !obj ) {
179 KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); 181 KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) );
180 return; 182 return;
181 } 183 }
182 184
183 KABC::AddresseeList addrList; 185 KABC::AddresseeList addrList;
184 XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore ); 186 XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore );
185 if ( dlg.exec() ) 187 if ( dlg.exec() )
186 addrList = dlg.contacts(); 188 addrList = dlg.contacts();
187 else 189 else
188 return; 190 return;
189 if ( !obj->exportContacts( addrList, data ) ) 191 if ( !obj->exportContacts( addrList, data ) )
190 KMessageBox::error( mCore, i18n( "Unable to export contacts." ) ); 192 KMessageBox::error( mCore, i18n( "Unable to export contacts." ) );
191 else 193 else
192 KMessageBox::information( mCore, i18n( "contacts successfully exported." ) ); 194 KMessageBox::information( mCore, i18n( "contacts successfully exported." ) );
193} 195}
194 196
195void XXPortManager::loadPlugins() 197void XXPortManager::loadPlugins()
196{ 198{
197 mXXPortObjects.clear(); 199 mXXPortObjects.clear();
198 200
199#ifndef KAB_EMBEDDED 201#ifndef KAB_EMBEDDED
200 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" ); 202 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" );
201 KTrader::OfferList::ConstIterator it; 203 KTrader::OfferList::ConstIterator it;
202 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 204 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
203 if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) ) 205 if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) )
204 continue; 206 continue;
205 207
206 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 208 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
207 if ( !factory ) { 209 if ( !factory ) {
208 kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; 210 kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl;
209 continue; 211 continue;
210 } 212 }
211 213
212 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); 214 XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory );
213 215
214 if ( !xxportFactory ) { 216 if ( !xxportFactory ) {
215 kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; 217 kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl;
216 continue; 218 continue;
217 } 219 }
218 220
219#else //KAB_EMBEDDED 221#else //KAB_EMBEDDED
220 QList<XXPortFactory> factorylist; 222 QList<XXPortFactory*> factorylist;
221 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_csv_xxport())); 223 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_csv_xxport()));
222 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_kde2_xxport())); 224 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_kde2_xxport()));
223 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_vcard_xxport())); 225 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_vcard_xxport()));
224 //US factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_opie_xxport())); 226 //US factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_opie_xxport()));
225 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_qtopia_xxport())); 227 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_qtopia_xxport()));
226 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_sharpdtm_xxport())); 228 factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_sharpdtm_xxport()));
227 229
228 QListIterator<XXPortFactory> it(factorylist); 230 for(QList<XXPortFactory*>::iterator it=factorylist.begin();it!=factorylist.end();++it) {
229 for ( ; it.current(); ++it ) 231 XXPortFactory *xxportFactory = *it;
230 {
231 XXPortFactory *xxportFactory = it.current();
232#endif //KAB_EMBEDDED 232#endif //KAB_EMBEDDED
233 233
234 XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore ); 234 XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore );
235 if ( obj ) { 235 if ( obj ) {
236 mCore->addGUIClient( obj ); 236 mCore->addGUIClient( obj );
237 mXXPortObjects.insert( obj->identifier(), obj ); 237 mXXPortObjects.insert( obj->identifier(), obj );
238 connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ), 238 connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ),
239 this, SLOT( slotExport( const QString&, const QString& ) ) ); 239 this, SLOT( slotExport( const QString&, const QString& ) ) );
240 connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ), 240 connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ),
241 this, SLOT( slotImport( const QString&, const QString& ) ) ); 241 this, SLOT( slotImport( const QString&, const QString& ) ) );
242 } 242 }
243 } 243 }
244} 244}
245 245
246 246
247PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, 247PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent,
248 const char *name ) 248 const char *name )
249 : KDialogBase( Plain, i18n( "Import this contact?" ), Ok | User1| User2, Ok, parent, 249 : KDialogBase( Plain, i18n( "Import this contact?" ), Ok | User1| User2, Ok, parent,
250 name, true, true ,i18n( "Import all!" ),i18n( "No" ) ) 250 name, true, true ,i18n( "Import all!" ),i18n( "No" ) )
251{ 251{
252 QWidget *page = plainPage(); 252 QWidget *page = plainPage();
253 QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() ); 253 Q3VBoxLayout *layout = new Q3VBoxLayout( page, marginHint(), spacingHint() );
254 connect( this, SIGNAL( user1Clicked() ), this, SLOT ( slotClose() ) ); 254 connect( this, SIGNAL( user1Clicked() ), this, SLOT ( slotClose() ) );
255 connect( this, SIGNAL( user2Clicked() ), this, SLOT ( slotCancel() ) ); 255 connect( this, SIGNAL( user2Clicked() ), this, SLOT ( slotCancel() ) );
256 256
257 KABC::AddresseeView *view = new KABC::AddresseeView( page ); 257 KABC::AddresseeView *view = new KABC::AddresseeView( page );
258 view->setAddressee( addr ); 258 view->setAddressee( addr );
259 layout->addWidget( view ); 259 layout->addWidget( view );
260#ifdef DESKTOP_VERSION 260#ifdef DESKTOP_VERSION
261 resize( 640, 480 ); 261 resize( 640, 480 );
262#else 262#else
263 showMaximized(); 263 showMaximized();
264#endif 264#endif
265} 265}
266 266
267#ifndef KAB_EMBEDDED 267#ifndef KAB_EMBEDDED_
268#include "xxportmanager.moc" 268#include "moc_xxportmanager.cpp"
269#endif //KAB_EMBEDDED 269#endif //KAB_EMBEDDED
270