author | zautrix <zautrix> | 2004-07-12 12:43:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-12 12:43:54 (UTC) |
commit | cbc789907408fa3359444c464ba5a86be892f301 (patch) (side-by-side diff) | |
tree | 82d02fc50134c1e64acf4ea9f5388ac3396602b3 /kaddressbook | |
parent | a55fa40fa32b115c7f7803fb6af0da5184cd7dff (diff) | |
download | kdepimpi-cbc789907408fa3359444c464ba5a86be892f301.zip kdepimpi-cbc789907408fa3359444c464ba5a86be892f301.tar.gz kdepimpi-cbc789907408fa3359444c464ba5a86be892f301.tar.bz2 |
Windows import fixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 30 | ||||
-rw-r--r-- | kaddressbook/kaimportoldialog.cpp | 10 | ||||
-rw-r--r-- | kaddressbook/undocmds.cpp | 5 |
3 files changed, 36 insertions, 9 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index f4263c4..1a34e4d 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -115,6 +115,7 @@ #include "kaimportoldialog.h" #endif +bool pasteWithNewUid = true; #ifdef KAB_EMBEDDED KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) @@ -398,7 +399,11 @@ void KABCore::createAboutData() "Greg Stern DCOP interface\n" "Mark Westcot Contact pinning\n" "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" - "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); + "Steffen Hansen LDAP Lookup hansen@kde.org\n" +#ifdef _WIN32_ + "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n" +#endif + ); } void KABCore::setContactSelected( const QString &uid ) @@ -594,7 +599,7 @@ void KABCore::pasteContacts() pasteContacts( list ); } -void KABCore::pasteContacts( KABC::Addressee::List &list ) +void KABCore::pasteContacts( KABC::Addressee::List &list ) { KABC::Resource *resource = requestResource( this ); KABC::Addressee::List::Iterator it; @@ -854,8 +859,25 @@ void KABCore::importFromOL() KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); idgl->exec(); KABC::Addressee::List list = idgl->getAddressList(); - if ( list.count() > 0 ) - pasteContacts( list ); + if ( list.count() > 0 ) { + KABC::Addressee::List listNew; + KABC::Addressee::List listExisting; + KABC::Addressee::List::Iterator it; + KABC::AddressBook::Iterator iter; + for ( it = list.begin(); it != list.end(); ++it ) { + if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) + listNew.append( (*it) ); + else + listExisting.append( (*it) ); + } + if ( listExisting.count() > 0 ) + KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); + if ( listNew.count() > 0 ) { + pasteWithNewUid = false; + pasteContacts( listNew ); + pasteWithNewUid = true; + } + } delete idgl; #endif } diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp index 5e7d7c4..ef949e7 100644 --- a/kaddressbook/kaimportoldialog.cpp +++ b/kaddressbook/kaimportoldialog.cpp @@ -248,7 +248,7 @@ void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) KABC::Addressee addressee; addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); - + //GetLastModificationTime() //addressee.setName( const QString &name ); //addressee.setFormattedName( const QString &formattedName ); addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); @@ -629,7 +629,11 @@ bool KAImportOLdialog::addAddressee( KABC::Addressee a ) break; } } - if ( add ) - mAList.append ( a ); + if ( add ) { + if ( mABook->findByUid(a.uid() ).isEmpty()) + mAList.append ( a ); + else + add = false; + } return add; } diff --git a/kaddressbook/undocmds.cpp b/kaddressbook/undocmds.cpp index 5fbeec3..5807dc0 100644 --- a/kaddressbook/undocmds.cpp +++ b/kaddressbook/undocmds.cpp @@ -36,7 +36,7 @@ #include "kabcore.h" #include "undocmds.h" - +extern bool pasteWithNewUid; ///////////////////////////////// // PwDelete Methods @@ -112,7 +112,8 @@ void PwPasteCommand::redo() /* we have to set a new uid for the contact, otherwise insertAddressee() ignore it. */ - (*it).setUid( KApplication::randomString( 10 ) ); + if ( pasteWithNewUid ) + (*it).setUid( KApplication::randomString( 10 ) ); uids.append( (*it).uid() ); mCore->addressBook()->insertAddressee( *it ); } |