summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp30
-rw-r--r--kaddressbook/kaimportoldialog.cpp10
-rw-r--r--kaddressbook/undocmds.cpp5
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
@@ -106,24 +106,25 @@
#include "xxportmanager.h"
#include "incsearchwidget.h"
#include "jumpbuttonbar.h"
#include "extensionmanager.h"
#include "addresseeconfig.h"
#include <kcmultidialog.h>
#ifdef _WIN32_
#include "kaimportoldialog.h"
#endif
+bool pasteWithNewUid = true;
#ifdef KAB_EMBEDDED
KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
: QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
#else //KAB_EMBEDDED
KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
: QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
mReadWrite( readWrite ), mModified( false )
#endif //KAB_EMBEDDED
@@ -389,25 +390,29 @@ void KABCore::createAboutData()
"for: Zaurus 5500 / 7x0 / 8x0\n"
#endif
"(c) 2004 Ulf Schenk\n"
"(c) 1997-2003, The KDE PIM Team\n"
"Tobias Koenig Current maintainer tokoe@kde.org\n"
"Don Sanders Original author\n"
"Cornelius Schumacher Co-maintainer schumacher@kde.org\n"
"Mike Pilone GUI and framework redesign mpilone@slac.com\n"
"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 )
{
KABC::Addressee addr = mAddressBook->findByUid( uid );
if ( !mDetails->isHidden() )
mDetails->setAddressee( addr );
if ( !addr.isEmpty() ) {
emit contactSelected( addr.formattedName() );
KABC::Picture pic = addr.photo();
if ( pic.isIntern() ) {
@@ -585,25 +590,25 @@ void KABCore::cutContacts()
}
}
void KABCore::pasteContacts()
{
QClipboard *cb = QApplication::clipboard();
KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
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;
for ( it = list.begin(); it != list.end(); ++it )
(*it).setResource( resource );
PwPasteCommand *command = new PwPasteCommand( this, list );
UndoStack::instance()->push( command );
RedoStack::instance()->clear();
setModified( true );
}
@@ -845,26 +850,43 @@ void KABCore::addEmail( QString aStr )
}
void KABCore::importVCard( const KURL &url, bool showPreview )
{
mXXPortManager->importVCard( url, showPreview );
}
void KABCore::importFromOL()
{
#ifdef _WIN32_
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
}
void KABCore::importVCard( const QString &vCard, bool showPreview )
{
mXXPortManager->importVCard( vCard, showPreview );
}
//US added a second method without defaultparameter
void KABCore::editContact2() {
editContact( QString::null );
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp
index 5e7d7c4..ef949e7 100644
--- a/kaddressbook/kaimportoldialog.cpp
+++ b/kaddressbook/kaimportoldialog.cpp
@@ -239,25 +239,25 @@ void KAImportOLdialog::readContactData( DWORD folder )
}
}
void KAImportOLdialog::slotOk()
{
QDialog::accept();
}
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()) );
addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) );
addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) );
addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) );
addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) );
addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) );
QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday());
if ( dtb.isValid() )
addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday()));
@@ -620,16 +620,20 @@ void KAImportOLdialog::slotCancel()
}
bool KAImportOLdialog::addAddressee( KABC::Addressee a )
{
bool add = true;
KABC::Addressee::List::Iterator it;
for ( it = mAList.begin(); it != mAList.end(); ++it ) {
if ( (*it).uid() == a.uid() ) {
add = false;
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
@@ -27,25 +27,25 @@
#include <qclipboard.h>
#include <klocale.h>
#include <kdebug.h>
#include <kapplication.h>
#include <kabc/addressbook.h>
#include "addresseeutil.h"
#include "addresseeconfig.h"
#include "kabcore.h"
#include "undocmds.h"
-
+extern bool pasteWithNewUid;
/////////////////////////////////
// PwDelete Methods
PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc,
const QStringList &uidList)
: Command(), mDocument(doc), mAddresseeList(), mUidList(uidList)
{
redo();
}
PwDeleteCommand::~PwDeleteCommand()
{
@@ -103,25 +103,26 @@ void PwPasteCommand::undo()
for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it )
mCore->addressBook()->removeAddressee( *it );
}
void PwPasteCommand::redo()
{
QStringList uids;
KABC::Addressee::List::Iterator it;
for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) {
/* 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 );
}
if ( uids.count() < 4 ) {
QStringList::Iterator uidIt;
for ( uidIt = uids.begin(); uidIt != uids.end(); ++uidIt )
mCore->editContact( *uidIt );
}
}
/////////////////////////////////
// PwNew Methods