author | zautrix <zautrix> | 2005-08-17 19:23:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-17 19:23:08 (UTC) |
commit | dfb9cdc7d39b988e23e5491e1c8f0e8c5713dae5 (patch) (side-by-side diff) | |
tree | f2c58bbb72294d1a7d1d3fac8c11e15087a01460 /kaddressbook/xxportmanager.cpp | |
parent | fefa169958abb9c487205d92b54c79532b6f924a (diff) | |
download | kdepimpi-dfb9cdc7d39b988e23e5491e1c8f0e8c5713dae5.zip kdepimpi-dfb9cdc7d39b988e23e5491e1c8f0e8c5713dae5.tar.gz kdepimpi-dfb9cdc7d39b988e23e5491e1c8f0e8c5713dae5.tar.bz2 |
import fix
Diffstat (limited to 'kaddressbook/xxportmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/xxportmanager.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp index 7cb67ed..405f7ec 100644 --- a/kaddressbook/xxportmanager.cpp +++ b/kaddressbook/xxportmanager.cpp @@ -14,195 +14,202 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <qlayout.h> #include <qlist.h> #include <kabc/addressbook.h> #include <kabc/resource.h> #include <kdebug.h> #include <kdialogbase.h> #include <klocale.h> #include <kmessagebox.h> #ifndef KAB_EMBEDDED #include <ktrader.h> #else //KAB_EMBEDDED extern "C" { void* init_microkaddrbk_csv_xxport(); void* init_microkaddrbk_kde2_xxport(); void* init_microkaddrbk_vcard_xxport(); // void* init_microkaddrbk_opie_xxport(); void* init_microkaddrbk_qtopia_xxport(); void* init_microkaddrbk_sharpdtm_xxport(); } #endif //KAB_EMBEDDED #include <addresseeview.h> #include "kabcore.h" #include "undocmds.h" #include "xxportselectdialog.h" #include "xxportmanager.h" +#include "nameeditdialog.h" KURL XXPortManager::importURL = KURL(); QString XXPortManager::importData = QString::null; class PreviewDialog : public KDialogBase { public: PreviewDialog( const KABC::Addressee &addr, QWidget *parent, const char *name = 0 ); }; XXPortManager::XXPortManager( KABCore *core, QObject *parent, const char *name ) : QObject( parent, name ), mCore( core ), mShowPreview( false ) { loadPlugins(); } XXPortManager::~XXPortManager() { } void XXPortManager::restoreSettings() { } void XXPortManager::saveSettings() { } void XXPortManager::importVCard( const KURL &url ) { importVCard( url, false ); } void XXPortManager::importVCard( const KURL &url, bool showPreview ) { importURL = url; mShowPreview = showPreview; slotImport( "vcard", "<empty>" ); mShowPreview = false; importURL = KURL(); } void XXPortManager::importVCard( const QString &vCard, bool showPreview ) { importData = vCard; mShowPreview = showPreview; slotImport( "vcard", "<empty>" ); mShowPreview = false; importData = ""; } void XXPortManager::slotImport( const QString &identifier, const QString &data ) { XXPortObject *obj = mXXPortObjects[ identifier ]; if ( !obj ) { KMessageBox::error( mCore, i18n( "<qt>No import plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); return; } KABC::Resource *resource = mCore->requestResource( mCore ); if ( !resource ) return; KABC::AddresseeList list = obj->importContacts( data ); bool useUndo = ( list.count() < 25 ); #ifdef DESKTOP_VERSION useUndo = true; #endif mShowPreview = true; KABC::AddresseeList::Iterator it; bool imported = false; int count = 0; + + KConfig config( locateLocal("config", "kabcrc") ); + config.setGroup( "General" ); + int FormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); + + for ( it = list.begin(); it != list.end(); ++it ) { if ( mShowPreview ) { PreviewDialog dlg( *it, mCore ); connect( &dlg, SIGNAL( closeClicked() ), this, SLOT ( noPreview()) ); if ( !dlg.exec() ) { if ( mShowPreview ) continue; } } - (*it).setResource( resource ); + if ( (*it).formattedName().isEmpty() ) + (*it).setFormattedName( NameEditDialog::formattedName( (*it), FormattedNameType ) ); if ( useUndo ) { + ++count; // We use a PwNewCommand so the user can undo it. PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it ); UndoStack::instance()->push( command ); RedoStack::instance()->clear(); } else { ++count; mCore->addressBook()->insertAddressee( (*it), true, true ); } imported = true; } - if ( imported ) { KMessageBox::information( mCore, i18n( "%1 contacts\nsuccessfully\nimported.").arg( count) ); - emit modified(); } } void XXPortManager::noPreview() { mShowPreview = false; } void XXPortManager::slotExport( const QString &identifier, const QString &data ) { XXPortObject *obj = mXXPortObjects[ identifier ]; if ( !obj ) { KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); return; } KABC::AddresseeList addrList; XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore ); if ( dlg.exec() ) addrList = dlg.contacts(); else return; if ( !obj->exportContacts( addrList, data ) ) KMessageBox::error( mCore, i18n( "Unable to export contacts." ) ); else KMessageBox::information( mCore, i18n( "contacts successfully exported." ) ); } void XXPortManager::loadPlugins() { mXXPortObjects.clear(); #ifndef KAB_EMBEDDED KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/XXPort" ); KTrader::OfferList::ConstIterator it; for ( it = plugins.begin(); it != plugins.end(); ++it ) { if ( !(*it)->hasServiceType( "KAddressBook/XXPort" ) ) continue; KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); if ( !factory ) { kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl; continue; } XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory ); if ( !xxportFactory ) { kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl; |