summaryrefslogtreecommitdiffabout
Unidiff
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
@@ -94,48 +94,49 @@
94#include <qvbox.h> 94#include <qvbox.h>
95#include <qlayout.h> 95#include <qlayout.h>
96#include <qclipboard.h> 96#include <qclipboard.h>
97 97
98#include <libkdepim/categoryselectdialog.h> 98#include <libkdepim/categoryselectdialog.h>
99 99
100#include "addresseeutil.h" 100#include "addresseeutil.h"
101#include "undocmds.h" 101#include "undocmds.h"
102#include "addresseeeditordialog.h" 102#include "addresseeeditordialog.h"
103#include "viewmanager.h" 103#include "viewmanager.h"
104#include "details/detailsviewcontainer.h" 104#include "details/detailsviewcontainer.h"
105#include "kabprefs.h" 105#include "kabprefs.h"
106#include "xxportmanager.h" 106#include "xxportmanager.h"
107#include "incsearchwidget.h" 107#include "incsearchwidget.h"
108#include "jumpbuttonbar.h" 108#include "jumpbuttonbar.h"
109#include "extensionmanager.h" 109#include "extensionmanager.h"
110#include "addresseeconfig.h" 110#include "addresseeconfig.h"
111#include <kcmultidialog.h> 111#include <kcmultidialog.h>
112 112
113#ifdef _WIN32_ 113#ifdef _WIN32_
114 114
115#include "kaimportoldialog.h" 115#include "kaimportoldialog.h"
116#endif 116#endif
117 117
118bool pasteWithNewUid = true;
118 119
119#ifdef KAB_EMBEDDED 120#ifdef KAB_EMBEDDED
120KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 121KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
121 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 122 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
122 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 123 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
123 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 124 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
124#else //KAB_EMBEDDED 125#else //KAB_EMBEDDED
125KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 126KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
126 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 127 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
127 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 128 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
128 mReadWrite( readWrite ), mModified( false ) 129 mReadWrite( readWrite ), mModified( false )
129#endif //KAB_EMBEDDED 130#endif //KAB_EMBEDDED
130{ 131{
131#ifdef KAB_EMBEDDED 132#ifdef KAB_EMBEDDED
132 //US we define here our own global actioncollection. 133 //US we define here our own global actioncollection.
133 //mActionCollection = new KActionCollection(this); 134 //mActionCollection = new KActionCollection(this);
134#endif //KAB_EMBEDDED 135#endif //KAB_EMBEDDED
135 mExtensionBarSplitter = 0; 136 mExtensionBarSplitter = 0;
136 mIsPart = !parent->inherits( "KAddressBookMain" ); 137 mIsPart = !parent->inherits( "KAddressBookMain" );
137 138
138 mAddressBook = KABC::StdAddressBook::self(); 139 mAddressBook = KABC::StdAddressBook::self();
139 KABC::StdAddressBook::setAutomaticSave( false ); 140 KABC::StdAddressBook::setAutomaticSave( false );
140 141
141#ifndef KAB_EMBEDDED 142#ifndef KAB_EMBEDDED
@@ -377,49 +378,53 @@ void KABCore::createAboutData()
377 return about; 378 return about;
378#endif //KAB_EMBEDDED 379#endif //KAB_EMBEDDED
379 380
380 QString version; 381 QString version;
381#include <../version> 382#include <../version>
382 QMessageBox::about( this, "About KAddressbook/Pi", 383 QMessageBox::about( this, "About KAddressbook/Pi",
383 "KAddressbook/Platform-independent\n" 384 "KAddressbook/Platform-independent\n"
384 "(KA/Pi) " +version + " - " + 385 "(KA/Pi) " +version + " - " +
385#ifdef DESKTOP_VERSION 386#ifdef DESKTOP_VERSION
386 "Desktop Edition\n" 387 "Desktop Edition\n"
387#else 388#else
388 "PDA-Edition\n" 389 "PDA-Edition\n"
389 "for: Zaurus 5500 / 7x0 / 8x0\n" 390 "for: Zaurus 5500 / 7x0 / 8x0\n"
390#endif 391#endif
391 392
392 "(c) 2004 Ulf Schenk\n" 393 "(c) 2004 Ulf Schenk\n"
393 "(c) 1997-2003, The KDE PIM Team\n" 394 "(c) 1997-2003, The KDE PIM Team\n"
394 "Tobias Koenig Current maintainer tokoe@kde.org\n" 395 "Tobias Koenig Current maintainer tokoe@kde.org\n"
395 "Don Sanders Original author\n" 396 "Don Sanders Original author\n"
396 "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" 397 "Cornelius Schumacher Co-maintainer schumacher@kde.org\n"
397 "Mike Pilone GUI and framework redesign mpilone@slac.com\n" 398 "Mike Pilone GUI and framework redesign mpilone@slac.com\n"
398 "Greg Stern DCOP interface\n" 399 "Greg Stern DCOP interface\n"
399 "Mark Westcot Contact pinning\n" 400 "Mark Westcot Contact pinning\n"
400 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 401 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
401 "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); 402 "Steffen Hansen LDAP Lookup hansen@kde.org\n"
403#ifdef _WIN32_
404 "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n"
405#endif
406 );
402} 407}
403 408
404void KABCore::setContactSelected( const QString &uid ) 409void KABCore::setContactSelected( const QString &uid )
405{ 410{
406 KABC::Addressee addr = mAddressBook->findByUid( uid ); 411 KABC::Addressee addr = mAddressBook->findByUid( uid );
407 if ( !mDetails->isHidden() ) 412 if ( !mDetails->isHidden() )
408 mDetails->setAddressee( addr ); 413 mDetails->setAddressee( addr );
409 414
410 if ( !addr.isEmpty() ) { 415 if ( !addr.isEmpty() ) {
411 emit contactSelected( addr.formattedName() ); 416 emit contactSelected( addr.formattedName() );
412 KABC::Picture pic = addr.photo(); 417 KABC::Picture pic = addr.photo();
413 if ( pic.isIntern() ) { 418 if ( pic.isIntern() ) {
414//US emit contactSelected( pic.data() ); 419//US emit contactSelected( pic.data() );
415//US instead use: 420//US instead use:
416 QPixmap px; 421 QPixmap px;
417 if (pic.data().isNull() != true) 422 if (pic.data().isNull() != true)
418 { 423 {
419 px.convertFromImage(pic.data()); 424 px.convertFromImage(pic.data());
420 } 425 }
421 426
422 emit contactSelected( px ); 427 emit contactSelected( px );
423 } 428 }
424 } 429 }
425 430
@@ -573,49 +578,49 @@ void KABCore::copyContacts()
573 578
574void KABCore::cutContacts() 579void KABCore::cutContacts()
575{ 580{
576 QStringList uidList = mViewManager->selectedUids(); 581 QStringList uidList = mViewManager->selectedUids();
577 582
578//US if ( uidList.size() > 0 ) { 583//US if ( uidList.size() > 0 ) {
579 if ( uidList.count() > 0 ) { 584 if ( uidList.count() > 0 ) {
580 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 585 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
581 UndoStack::instance()->push( command ); 586 UndoStack::instance()->push( command );
582 RedoStack::instance()->clear(); 587 RedoStack::instance()->clear();
583 588
584 setModified( true ); 589 setModified( true );
585 } 590 }
586} 591}
587 592
588void KABCore::pasteContacts() 593void KABCore::pasteContacts()
589{ 594{
590 QClipboard *cb = QApplication::clipboard(); 595 QClipboard *cb = QApplication::clipboard();
591 596
592 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 597 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
593 598
594 pasteContacts( list ); 599 pasteContacts( list );
595} 600}
596 601
597void KABCore::pasteContacts( KABC::Addressee::List &list ) 602void KABCore::pasteContacts( KABC::Addressee::List &list )
598{ 603{
599 KABC::Resource *resource = requestResource( this ); 604 KABC::Resource *resource = requestResource( this );
600 KABC::Addressee::List::Iterator it; 605 KABC::Addressee::List::Iterator it;
601 for ( it = list.begin(); it != list.end(); ++it ) 606 for ( it = list.begin(); it != list.end(); ++it )
602 (*it).setResource( resource ); 607 (*it).setResource( resource );
603 608
604 PwPasteCommand *command = new PwPasteCommand( this, list ); 609 PwPasteCommand *command = new PwPasteCommand( this, list );
605 UndoStack::instance()->push( command ); 610 UndoStack::instance()->push( command );
606 RedoStack::instance()->clear(); 611 RedoStack::instance()->clear();
607 612
608 setModified( true ); 613 setModified( true );
609} 614}
610 615
611void KABCore::setWhoAmI() 616void KABCore::setWhoAmI()
612{ 617{
613 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 618 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
614 619
615 if ( addrList.count() > 1 ) { 620 if ( addrList.count() > 1 ) {
616 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 621 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
617 return; 622 return;
618 } 623 }
619 624
620 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 625 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
621 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 626 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
@@ -833,50 +838,67 @@ void KABCore::addEmail( QString aStr )
833 if ( !found ) { 838 if ( !found ) {
834 KABC::Addressee addr; 839 KABC::Addressee addr;
835 addr.setNameFromString( fullName ); 840 addr.setNameFromString( fullName );
836 addr.insertEmail( email, true ); 841 addr.insertEmail( email, true );
837 842
838 mAddressBook->insertAddressee( addr ); 843 mAddressBook->insertAddressee( addr );
839 mViewManager->refreshView( addr.uid() ); 844 mViewManager->refreshView( addr.uid() );
840 editContact( addr.uid() ); 845 editContact( addr.uid() );
841 } 846 }
842#else //KAB_EMBEDDED 847#else //KAB_EMBEDDED
843 qDebug("KABCore::addEmail finsih method"); 848 qDebug("KABCore::addEmail finsih method");
844#endif //KAB_EMBEDDED 849#endif //KAB_EMBEDDED
845} 850}
846 851
847void KABCore::importVCard( const KURL &url, bool showPreview ) 852void KABCore::importVCard( const KURL &url, bool showPreview )
848{ 853{
849 mXXPortManager->importVCard( url, showPreview ); 854 mXXPortManager->importVCard( url, showPreview );
850} 855}
851void KABCore::importFromOL() 856void KABCore::importFromOL()
852{ 857{
853#ifdef _WIN32_ 858#ifdef _WIN32_
854 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 859 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
855 idgl->exec(); 860 idgl->exec();
856 KABC::Addressee::List list = idgl->getAddressList(); 861 KABC::Addressee::List list = idgl->getAddressList();
857 if ( list.count() > 0 ) 862 if ( list.count() > 0 ) {
858 pasteContacts( list ); 863 KABC::Addressee::List listNew;
864 KABC::Addressee::List listExisting;
865 KABC::Addressee::List::Iterator it;
866 KABC::AddressBook::Iterator iter;
867 for ( it = list.begin(); it != list.end(); ++it ) {
868 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
869 listNew.append( (*it) );
870 else
871 listExisting.append( (*it) );
872 }
873 if ( listExisting.count() > 0 )
874 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
875 if ( listNew.count() > 0 ) {
876 pasteWithNewUid = false;
877 pasteContacts( listNew );
878 pasteWithNewUid = true;
879 }
880 }
859 delete idgl; 881 delete idgl;
860#endif 882#endif
861} 883}
862 884
863void KABCore::importVCard( const QString &vCard, bool showPreview ) 885void KABCore::importVCard( const QString &vCard, bool showPreview )
864{ 886{
865 mXXPortManager->importVCard( vCard, showPreview ); 887 mXXPortManager->importVCard( vCard, showPreview );
866} 888}
867 889
868//US added a second method without defaultparameter 890//US added a second method without defaultparameter
869void KABCore::editContact2() { 891void KABCore::editContact2() {
870 editContact( QString::null ); 892 editContact( QString::null );
871} 893}
872 894
873void KABCore::editContact( const QString &uid ) 895void KABCore::editContact( const QString &uid )
874{ 896{
875 897
876 if ( mExtensionManager->isQuickEditVisible() ) 898 if ( mExtensionManager->isQuickEditVisible() )
877 return; 899 return;
878 900
879 // First, locate the contact entry 901 // First, locate the contact entry
880 QString localUID = uid; 902 QString localUID = uid;
881 if ( localUID.isNull() ) { 903 if ( localUID.isNull() ) {
882 QStringList uidList = mViewManager->selectedUids(); 904 QStringList uidList = mViewManager->selectedUids();
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp
index 5e7d7c4..ef949e7 100644
--- a/kaddressbook/kaimportoldialog.cpp
+++ b/kaddressbook/kaimportoldialog.cpp
@@ -227,49 +227,49 @@ void KAImportOLdialog::readContactData( DWORD folder )
227 bar.show(); 227 bar.show();
228 for(i=1; i <= folderItems.GetCount(); ++i) 228 for(i=1; i <= folderItems.GetCount(); ++i)
229 { 229 {
230 qApp->processEvents(); 230 qApp->processEvents();
231 if ( ! bar.isVisible() ) 231 if ( ! bar.isVisible() )
232 return ; 232 return ;
233 bar.setProgress( i ); 233 bar.setProgress( i );
234 indx = (long)i; 234 indx = (long)i;
235 itm = folderItems.Item(indx.Detach()); 235 itm = folderItems.Item(indx.Detach());
236 _ContactItem * pItem = (_ContactItem *)&itm; 236 _ContactItem * pItem = (_ContactItem *)&itm;
237 ol2kapiContact( pItem ); 237 ol2kapiContact( pItem );
238 itm->Release(); 238 itm->Release();
239 } 239 }
240} 240}
241void KAImportOLdialog::slotOk() 241void KAImportOLdialog::slotOk()
242{ 242{
243 QDialog::accept(); 243 QDialog::accept();
244} 244}
245 245
246void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) 246void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem )
247{ 247{
248 KABC::Addressee addressee; 248 KABC::Addressee addressee;
249 249
250 addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer())); 250 addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer()));
251 251 //GetLastModificationTime()
252 //addressee.setName( const QString &name ); 252 //addressee.setName( const QString &name );
253 //addressee.setFormattedName( const QString &formattedName ); 253 //addressee.setFormattedName( const QString &formattedName );
254 addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) ); 254 addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) );
255 addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) ); 255 addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) );
256 addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) ); 256 addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) );
257 addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) ); 257 addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) );
258 addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) ); 258 addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) );
259 addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) ); 259 addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) );
260 QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday()); 260 QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday());
261 if ( dtb.isValid() ) 261 if ( dtb.isValid() )
262 addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday())); 262 addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday()));
263 263
264 //QString::fromUcs2(aItem->.GetBuffer()) 264 //QString::fromUcs2(aItem->.GetBuffer())
265 //addressee.setMailer( const QString &mailer ); 265 //addressee.setMailer( const QString &mailer );
266 //addressee.setTimeZone( const TimeZone &timeZone ); 266 //addressee.setTimeZone( const TimeZone &timeZone );
267 //addressee.setGeo( const Geo &geo ); 267 //addressee.setGeo( const Geo &geo );
268 //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix 268 //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix
269 addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) ); 269 addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );
270 addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()) ); 270 addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()) );
271 addressee.setNote( QString::fromUcs2(aItem->GetBody().GetBuffer()) ); 271 addressee.setNote( QString::fromUcs2(aItem->GetBody().GetBuffer()) );
272 272
273 addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) ); 273 addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) );
274 //addressee.setRevision( const QDateTime &revision ); 274 //addressee.setRevision( const QDateTime &revision );
275 // addressee.setSortString( const QString &sortString ); 275 // addressee.setSortString( const QString &sortString );
@@ -608,28 +608,32 @@ void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem )
608 // pending 608 // pending
609 - IM address: no clue where to get info about the helper ID 609 - IM address: no clue where to get info about the helper ID
610 -custom fields: difficult to implement - not implemented 610 -custom fields: difficult to implement - not implemented
611 -keys: makes no sense 611 -keys: makes no sense
612#endif 612#endif
613 613
614 if ( addAddressee( addressee )) 614 if ( addAddressee( addressee ))
615 ++importedItems; 615 ++importedItems;
616} 616}
617void KAImportOLdialog::slotCancel() 617void KAImportOLdialog::slotCancel()
618{ 618{
619 reject(); 619 reject();
620} 620}
621 621
622bool KAImportOLdialog::addAddressee( KABC::Addressee a ) 622bool KAImportOLdialog::addAddressee( KABC::Addressee a )
623{ 623{
624 bool add = true; 624 bool add = true;
625 KABC::Addressee::List::Iterator it; 625 KABC::Addressee::List::Iterator it;
626 for ( it = mAList.begin(); it != mAList.end(); ++it ) { 626 for ( it = mAList.begin(); it != mAList.end(); ++it ) {
627 if ( (*it).uid() == a.uid() ) { 627 if ( (*it).uid() == a.uid() ) {
628 add = false; 628 add = false;
629 break; 629 break;
630 } 630 }
631 } 631 }
632 if ( add ) 632 if ( add ) {
633 mAList.append ( a ); 633 if ( mABook->findByUid(a.uid() ).isEmpty())
634 mAList.append ( a );
635 else
636 add = false;
637 }
634 return add; 638 return add;
635} 639}
diff --git a/kaddressbook/undocmds.cpp b/kaddressbook/undocmds.cpp
index 5fbeec3..5807dc0 100644
--- a/kaddressbook/undocmds.cpp
+++ b/kaddressbook/undocmds.cpp
@@ -15,49 +15,49 @@
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#include <qtextstream.h> 24#include <qtextstream.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27#include <qclipboard.h> 27#include <qclipboard.h>
28 28
29#include <klocale.h> 29#include <klocale.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kapplication.h> 31#include <kapplication.h>
32#include <kabc/addressbook.h> 32#include <kabc/addressbook.h>
33 33
34#include "addresseeutil.h" 34#include "addresseeutil.h"
35#include "addresseeconfig.h" 35#include "addresseeconfig.h"
36#include "kabcore.h" 36#include "kabcore.h"
37 37
38#include "undocmds.h" 38#include "undocmds.h"
39 39extern bool pasteWithNewUid;
40///////////////////////////////// 40/////////////////////////////////
41// PwDelete Methods 41// PwDelete Methods
42 42
43PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc, 43PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc,
44 const QStringList &uidList) 44 const QStringList &uidList)
45 : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList) 45 : Command(), mDocument(doc), mAddresseeList(), mUidList(uidList)
46{ 46{
47 redo(); 47 redo();
48} 48}
49 49
50PwDeleteCommand::~PwDeleteCommand() 50PwDeleteCommand::~PwDeleteCommand()
51{ 51{
52} 52}
53 53
54QString PwDeleteCommand::name() 54QString PwDeleteCommand::name()
55{ 55{
56 return i18n( "Delete" ); 56 return i18n( "Delete" );
57} 57}
58 58
59void PwDeleteCommand::undo() 59void PwDeleteCommand::undo()
60{ 60{
61 // Put it back in the document 61 // Put it back in the document
62 KABC::Addressee::List::Iterator iter; 62 KABC::Addressee::List::Iterator iter;
63 for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter) 63 for (iter = mAddresseeList.begin(); iter != mAddresseeList.end(); ++iter)
@@ -91,49 +91,50 @@ PwPasteCommand::PwPasteCommand( KABCore *core, const KABC::Addressee::List &list
91{ 91{
92 redo(); 92 redo();
93} 93}
94 94
95QString PwPasteCommand::name() 95QString PwPasteCommand::name()
96{ 96{
97 return i18n( "Paste" ); 97 return i18n( "Paste" );
98} 98}
99 99
100void PwPasteCommand::undo() 100void PwPasteCommand::undo()
101{ 101{
102 KABC::Addressee::List::Iterator it; 102 KABC::Addressee::List::Iterator it;
103 for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) 103 for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it )
104 mCore->addressBook()->removeAddressee( *it ); 104 mCore->addressBook()->removeAddressee( *it );
105} 105}
106 106
107void PwPasteCommand::redo() 107void PwPasteCommand::redo()
108{ 108{
109 QStringList uids; 109 QStringList uids;
110 KABC::Addressee::List::Iterator it; 110 KABC::Addressee::List::Iterator it;
111 for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) { 111 for ( it = mAddresseeList.begin(); it != mAddresseeList.end(); ++it ) {
112 /* we have to set a new uid for the contact, otherwise insertAddressee() 112 /* we have to set a new uid for the contact, otherwise insertAddressee()
113 ignore it. 113 ignore it.
114 */ 114 */
115 (*it).setUid( KApplication::randomString( 10 ) ); 115 if ( pasteWithNewUid )
116 (*it).setUid( KApplication::randomString( 10 ) );
116 uids.append( (*it).uid() ); 117 uids.append( (*it).uid() );
117 mCore->addressBook()->insertAddressee( *it ); 118 mCore->addressBook()->insertAddressee( *it );
118 } 119 }
119 if ( uids.count() < 4 ) { 120 if ( uids.count() < 4 ) {
120 QStringList::Iterator uidIt; 121 QStringList::Iterator uidIt;
121 for ( uidIt = uids.begin(); uidIt != uids.end(); ++uidIt ) 122 for ( uidIt = uids.begin(); uidIt != uids.end(); ++uidIt )
122 mCore->editContact( *uidIt ); 123 mCore->editContact( *uidIt );
123 } 124 }
124} 125}
125 126
126///////////////////////////////// 127/////////////////////////////////
127// PwNew Methods 128// PwNew Methods
128 129
129PwNewCommand::PwNewCommand( KABC::AddressBook *doc, const KABC::Addressee &a ) 130PwNewCommand::PwNewCommand( KABC::AddressBook *doc, const KABC::Addressee &a )
130 : Command(), mDocument( doc ), mA( a ) 131 : Command(), mDocument( doc ), mA( a )
131{ 132{
132 mDocument->insertAddressee(mA); 133 mDocument->insertAddressee(mA);
133} 134}
134 135
135PwNewCommand::~PwNewCommand() 136PwNewCommand::~PwNewCommand()
136{ 137{
137} 138}
138 139
139QString PwNewCommand::name() 140QString PwNewCommand::name()