author | zautrix <zautrix> | 2005-08-17 19:09:13 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-17 19:09:13 (UTC) |
commit | fefa169958abb9c487205d92b54c79532b6f924a (patch) (side-by-side diff) | |
tree | 9de8347c47fb0b0fb4b39c78730352eb16d619c7 /kaddressbook/xxportmanager.cpp | |
parent | 14f656fff72f1e7c2fedbb196fb97bbdd4fb1aac (diff) | |
download | kdepimpi-fefa169958abb9c487205d92b54c79532b6f924a.zip kdepimpi-fefa169958abb9c487205d92b54c79532b6f924a.tar.gz kdepimpi-fefa169958abb9c487205d92b54c79532b6f924a.tar.bz2 |
import fix
Diffstat (limited to 'kaddressbook/xxportmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/xxportmanager.cpp | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp index 89a2626..7cb67ed 100644 --- a/kaddressbook/xxportmanager.cpp +++ b/kaddressbook/xxportmanager.cpp @@ -121,36 +121,53 @@ void XXPortManager::slotImport( const QString &identifier, const QString &data ) 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; for ( it = list.begin(); it != list.end(); ++it ) { if ( mShowPreview ) { PreviewDialog dlg( *it, mCore ); - if ( !dlg.exec() ) - continue; + connect( &dlg, SIGNAL( closeClicked() ), this, SLOT ( noPreview()) ); + if ( !dlg.exec() ) { + if ( mShowPreview ) + continue; + } } (*it).setResource( resource ); - // We use a PwNewCommand so the user can undo it. - PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it ); - UndoStack::instance()->push( command ); - RedoStack::instance()->clear(); + if ( useUndo ) { + // 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( "contacts successfully 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; @@ -219,24 +236,28 @@ void XXPortManager::loadPlugins() } } PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, const char *name ) - : KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent, - name, true, true ) + : KDialogBase( Plain, i18n( "Import this contact?" ), Ok | User1| User2, Ok, parent, + name, true, true ,i18n( "Import all!" ),i18n( "No" ) ) { QWidget *page = plainPage(); QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() ); + connect( this, SIGNAL( user1Clicked() ), this, SLOT ( slotClose() ) ); + connect( this, SIGNAL( user2Clicked() ), this, SLOT ( slotCancel() ) ); KABC::AddresseeView *view = new KABC::AddresseeView( page ); view->setAddressee( addr ); - layout->addWidget( view ); - - resize( 400, 300 ); +#ifdef DESKTOP_VERSION + resize( 640, 480 ); +#else + showMaximized(); +#endif } #ifndef KAB_EMBEDDED #include "xxportmanager.moc" #endif //KAB_EMBEDDED |