author | zautrix <zautrix> | 2004-07-12 12:43:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-12 12:43:54 (UTC) |
commit | cbc789907408fa3359444c464ba5a86be892f301 (patch) (unidiff) | |
tree | 82d02fc50134c1e64acf4ea9f5388ac3396602b3 | |
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 | |||
@@ -54,128 +54,129 @@ | |||
54 | #include <kaboutdata.h> | 54 | #include <kaboutdata.h> |
55 | #include <libkdepim/categoryselectdialog.h> | 55 | #include <libkdepim/categoryselectdialog.h> |
56 | 56 | ||
57 | #include "addresseeutil.h" | 57 | #include "addresseeutil.h" |
58 | #include "addresseeeditordialog.h" | 58 | #include "addresseeeditordialog.h" |
59 | #include "extensionmanager.h" | 59 | #include "extensionmanager.h" |
60 | #include "kstdaction.h" | 60 | #include "kstdaction.h" |
61 | #include "kaddressbookservice.h" | 61 | #include "kaddressbookservice.h" |
62 | #include "ldapsearchdialog.h" | 62 | #include "ldapsearchdialog.h" |
63 | #include "printing/printingwizard.h" | 63 | #include "printing/printingwizard.h" |
64 | #else // KAB_EMBEDDED | 64 | #else // KAB_EMBEDDED |
65 | 65 | ||
66 | #include <kapplication.h> | 66 | #include <kapplication.h> |
67 | #include "KDGanttMinimizeSplitter.h" | 67 | #include "KDGanttMinimizeSplitter.h" |
68 | #include "kaddressbookmain.h" | 68 | #include "kaddressbookmain.h" |
69 | #include "kactioncollection.h" | 69 | #include "kactioncollection.h" |
70 | #include <qapp.h> | 70 | #include <qapp.h> |
71 | #include <qmenubar.h> | 71 | #include <qmenubar.h> |
72 | //#include <qtoolbar.h> | 72 | //#include <qtoolbar.h> |
73 | #include <qmessagebox.h> | 73 | #include <qmessagebox.h> |
74 | #include <kdebug.h> | 74 | #include <kdebug.h> |
75 | #include <kiconloader.h> // needed for SmallIcon | 75 | #include <kiconloader.h> // needed for SmallIcon |
76 | #include <kresources/kcmkresources.h> | 76 | #include <kresources/kcmkresources.h> |
77 | #include <ktoolbar.h> | 77 | #include <ktoolbar.h> |
78 | 78 | ||
79 | #include <kcmkabconfig.h> | 79 | #include <kcmkabconfig.h> |
80 | 80 | ||
81 | //US#include <qpe/resource.h> // needed for Resource::loadPixmap | 81 | //US#include <qpe/resource.h> // needed for Resource::loadPixmap |
82 | //#include <qlabel.h> | 82 | //#include <qlabel.h> |
83 | #endif // KAB_EMBEDDED | 83 | #endif // KAB_EMBEDDED |
84 | #include <kcmkabconfig.h> | 84 | #include <kcmkabconfig.h> |
85 | 85 | ||
86 | 86 | ||
87 | #include <kresources/selectdialog.h> | 87 | #include <kresources/selectdialog.h> |
88 | #include <kmessagebox.h> | 88 | #include <kmessagebox.h> |
89 | 89 | ||
90 | #include <picture.h> | 90 | #include <picture.h> |
91 | #include <resource.h> | 91 | #include <resource.h> |
92 | 92 | ||
93 | //US#include <qsplitter.h> | 93 | //US#include <qsplitter.h> |
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 | ||
118 | bool pasteWithNewUid = true; | ||
118 | 119 | ||
119 | #ifdef KAB_EMBEDDED | 120 | #ifdef KAB_EMBEDDED |
120 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 121 | KABCore::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 |
125 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 126 | KABCore::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 |
142 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 143 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
143 | #endif //KAB_EMBEDDED | 144 | #endif //KAB_EMBEDDED |
144 | 145 | ||
145 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 146 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
146 | SLOT( addressBookChanged() ) ); | 147 | SLOT( addressBookChanged() ) ); |
147 | 148 | ||
148 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 149 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
149 | "X-Department", "KADDRESSBOOK" ); | 150 | "X-Department", "KADDRESSBOOK" ); |
150 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 151 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
151 | "X-Profession", "KADDRESSBOOK" ); | 152 | "X-Profession", "KADDRESSBOOK" ); |
152 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 153 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
153 | "X-AssistantsName", "KADDRESSBOOK" ); | 154 | "X-AssistantsName", "KADDRESSBOOK" ); |
154 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 155 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
155 | "X-ManagersName", "KADDRESSBOOK" ); | 156 | "X-ManagersName", "KADDRESSBOOK" ); |
156 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 157 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
157 | "X-SpousesName", "KADDRESSBOOK" ); | 158 | "X-SpousesName", "KADDRESSBOOK" ); |
158 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 159 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
159 | "X-Office", "KADDRESSBOOK" ); | 160 | "X-Office", "KADDRESSBOOK" ); |
160 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 161 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
161 | "X-IMAddress", "KADDRESSBOOK" ); | 162 | "X-IMAddress", "KADDRESSBOOK" ); |
162 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 163 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
163 | "X-Anniversary", "KADDRESSBOOK" ); | 164 | "X-Anniversary", "KADDRESSBOOK" ); |
164 | 165 | ||
165 | //US added this field to become compatible with Opie addressbook | 166 | //US added this field to become compatible with Opie addressbook |
166 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 167 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
167 | "X-Gender", "KADDRESSBOOK" ); | 168 | "X-Gender", "KADDRESSBOOK" ); |
168 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 169 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
169 | "X-Children", "KADDRESSBOOK" ); | 170 | "X-Children", "KADDRESSBOOK" ); |
170 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 171 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
171 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 172 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
172 | 173 | ||
173 | initGUI(); | 174 | initGUI(); |
174 | 175 | ||
175 | mIncSearchWidget->setFocus(); | 176 | mIncSearchWidget->setFocus(); |
176 | 177 | ||
177 | 178 | ||
178 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 179 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
179 | SLOT( setContactSelected( const QString& ) ) ); | 180 | SLOT( setContactSelected( const QString& ) ) ); |
180 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 181 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
181 | SLOT( editContact( const QString& ) ) ); | 182 | SLOT( editContact( const QString& ) ) ); |
@@ -337,129 +338,133 @@ KABC::Resource *KABCore::requestResource( QWidget *parent ) | |||
337 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 338 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
338 | KABC::Resource *resource; | 339 | KABC::Resource *resource; |
339 | while ( ( resource = resIt.current() ) != 0 ) { | 340 | while ( ( resource = resIt.current() ) != 0 ) { |
340 | ++resIt; | 341 | ++resIt; |
341 | if ( !resource->readOnly() ) { | 342 | if ( !resource->readOnly() ) { |
342 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 343 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
343 | if ( res ) | 344 | if ( res ) |
344 | kresResources.append( res ); | 345 | kresResources.append( res ); |
345 | } | 346 | } |
346 | } | 347 | } |
347 | 348 | ||
348 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 349 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
349 | return static_cast<KABC::Resource*>( res ); | 350 | return static_cast<KABC::Resource*>( res ); |
350 | } | 351 | } |
351 | 352 | ||
352 | #ifndef KAB_EMBEDDED | 353 | #ifndef KAB_EMBEDDED |
353 | KAboutData *KABCore::createAboutData() | 354 | KAboutData *KABCore::createAboutData() |
354 | #else //KAB_EMBEDDED | 355 | #else //KAB_EMBEDDED |
355 | void KABCore::createAboutData() | 356 | void KABCore::createAboutData() |
356 | #endif //KAB_EMBEDDED | 357 | #endif //KAB_EMBEDDED |
357 | { | 358 | { |
358 | #ifndef KAB_EMBEDDED | 359 | #ifndef KAB_EMBEDDED |
359 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 360 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
360 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 361 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
361 | KAboutData::License_GPL_V2, | 362 | KAboutData::License_GPL_V2, |
362 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 363 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
363 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 364 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
364 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 365 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
365 | about->addAuthor( "Cornelius Schumacher", | 366 | about->addAuthor( "Cornelius Schumacher", |
366 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 367 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
367 | "schumacher@kde.org" ); | 368 | "schumacher@kde.org" ); |
368 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 369 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
369 | "mpilone@slac.com" ); | 370 | "mpilone@slac.com" ); |
370 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 371 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
371 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 372 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
372 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 373 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
373 | "michel@klaralvdalens-datakonsult.se" ); | 374 | "michel@klaralvdalens-datakonsult.se" ); |
374 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 375 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
375 | "hansen@kde.org" ); | 376 | "hansen@kde.org" ); |
376 | 377 | ||
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 | ||
404 | void KABCore::setContactSelected( const QString &uid ) | 409 | void 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 | ||
426 | 431 | ||
427 | mExtensionManager->setSelectionChanged(); | 432 | mExtensionManager->setSelectionChanged(); |
428 | 433 | ||
429 | // update the actions | 434 | // update the actions |
430 | bool selected = !uid.isEmpty(); | 435 | bool selected = !uid.isEmpty(); |
431 | 436 | ||
432 | if ( mReadWrite ) { | 437 | if ( mReadWrite ) { |
433 | mActionCut->setEnabled( selected ); | 438 | mActionCut->setEnabled( selected ); |
434 | mActionPaste->setEnabled( selected ); | 439 | mActionPaste->setEnabled( selected ); |
435 | } | 440 | } |
436 | 441 | ||
437 | mActionCopy->setEnabled( selected ); | 442 | mActionCopy->setEnabled( selected ); |
438 | mActionDelete->setEnabled( selected ); | 443 | mActionDelete->setEnabled( selected ); |
439 | mActionEditAddressee->setEnabled( selected ); | 444 | mActionEditAddressee->setEnabled( selected ); |
440 | mActionMail->setEnabled( selected ); | 445 | mActionMail->setEnabled( selected ); |
441 | mActionMailVCard->setEnabled( selected ); | 446 | mActionMailVCard->setEnabled( selected ); |
442 | mActionWhoAmI->setEnabled( selected ); | 447 | mActionWhoAmI->setEnabled( selected ); |
443 | mActionCategories->setEnabled( selected ); | 448 | mActionCategories->setEnabled( selected ); |
444 | } | 449 | } |
445 | 450 | ||
446 | void KABCore::sendMail() | 451 | void KABCore::sendMail() |
447 | { | 452 | { |
448 | #ifndef KAB_EMBEDDED | 453 | #ifndef KAB_EMBEDDED |
449 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 454 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
450 | #else //KAB_EMBEDDED | 455 | #else //KAB_EMBEDDED |
451 | qDebug("KABCore::sendMail() ust be fixed"); | 456 | qDebug("KABCore::sendMail() ust be fixed"); |
452 | #endif //KAB_EMBEDDED | 457 | #endif //KAB_EMBEDDED |
453 | } | 458 | } |
454 | 459 | ||
455 | void KABCore::sendMail( const QString& email ) | 460 | void KABCore::sendMail( const QString& email ) |
456 | { | 461 | { |
457 | #ifndef KAB_EMBEDDED | 462 | #ifndef KAB_EMBEDDED |
458 | kapp->invokeMailer( email, "" ); | 463 | kapp->invokeMailer( email, "" ); |
459 | #else //KAB_EMBEDDED | 464 | #else //KAB_EMBEDDED |
460 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); | 465 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); |
461 | #endif //KAB_EMBEDDED | 466 | #endif //KAB_EMBEDDED |
462 | } | 467 | } |
463 | 468 | ||
464 | void KABCore::mailVCard() | 469 | void KABCore::mailVCard() |
465 | { | 470 | { |
@@ -533,129 +538,129 @@ void KABCore::browse( const QString& url ) | |||
533 | #else //KAB_EMBEDDED | 538 | #else //KAB_EMBEDDED |
534 | qDebug("KABCore::browse must be fixed"); | 539 | qDebug("KABCore::browse must be fixed"); |
535 | #endif //KAB_EMBEDDED | 540 | #endif //KAB_EMBEDDED |
536 | } | 541 | } |
537 | 542 | ||
538 | void KABCore::selectAllContacts() | 543 | void KABCore::selectAllContacts() |
539 | { | 544 | { |
540 | mViewManager->setSelected( QString::null, true ); | 545 | mViewManager->setSelected( QString::null, true ); |
541 | } | 546 | } |
542 | 547 | ||
543 | void KABCore::deleteContacts() | 548 | void KABCore::deleteContacts() |
544 | { | 549 | { |
545 | QStringList uidList = mViewManager->selectedUids(); | 550 | QStringList uidList = mViewManager->selectedUids(); |
546 | deleteContacts( uidList ); | 551 | deleteContacts( uidList ); |
547 | } | 552 | } |
548 | 553 | ||
549 | void KABCore::deleteContacts( const QStringList &uids ) | 554 | void KABCore::deleteContacts( const QStringList &uids ) |
550 | { | 555 | { |
551 | if ( uids.count() > 0 ) { | 556 | if ( uids.count() > 0 ) { |
552 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 557 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
553 | UndoStack::instance()->push( command ); | 558 | UndoStack::instance()->push( command ); |
554 | RedoStack::instance()->clear(); | 559 | RedoStack::instance()->clear(); |
555 | 560 | ||
556 | // now if we deleted anything, refresh | 561 | // now if we deleted anything, refresh |
557 | setContactSelected( QString::null ); | 562 | setContactSelected( QString::null ); |
558 | setModified( true ); | 563 | setModified( true ); |
559 | } | 564 | } |
560 | } | 565 | } |
561 | 566 | ||
562 | void KABCore::copyContacts() | 567 | void KABCore::copyContacts() |
563 | { | 568 | { |
564 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 569 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
565 | 570 | ||
566 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 571 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
567 | 572 | ||
568 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 573 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
569 | 574 | ||
570 | QClipboard *cb = QApplication::clipboard(); | 575 | QClipboard *cb = QApplication::clipboard(); |
571 | cb->setText( clipText ); | 576 | cb->setText( clipText ); |
572 | } | 577 | } |
573 | 578 | ||
574 | void KABCore::cutContacts() | 579 | void 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 | ||
588 | void KABCore::pasteContacts() | 593 | void 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 | ||
597 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 602 | void 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 | ||
611 | void KABCore::setWhoAmI() | 616 | void 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 ) |
622 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 627 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
623 | } | 628 | } |
624 | 629 | ||
625 | void KABCore::setCategories() | 630 | void KABCore::setCategories() |
626 | { | 631 | { |
627 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 632 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
628 | if ( !dlg.exec() ) | 633 | if ( !dlg.exec() ) |
629 | return; | 634 | return; |
630 | 635 | ||
631 | bool merge = false; | 636 | bool merge = false; |
632 | QString msg = i18n( "Merge with existing categories?" ); | 637 | QString msg = i18n( "Merge with existing categories?" ); |
633 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 638 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
634 | merge = true; | 639 | merge = true; |
635 | 640 | ||
636 | QStringList categories = dlg.selectedCategories(); | 641 | QStringList categories = dlg.selectedCategories(); |
637 | 642 | ||
638 | QStringList uids = mViewManager->selectedUids(); | 643 | QStringList uids = mViewManager->selectedUids(); |
639 | QStringList::Iterator it; | 644 | QStringList::Iterator it; |
640 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 645 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
641 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 646 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
642 | if ( !addr.isEmpty() ) { | 647 | if ( !addr.isEmpty() ) { |
643 | if ( !merge ) | 648 | if ( !merge ) |
644 | addr.setCategories( categories ); | 649 | addr.setCategories( categories ); |
645 | else { | 650 | else { |
646 | QStringList addrCategories = addr.categories(); | 651 | QStringList addrCategories = addr.categories(); |
647 | QStringList::Iterator catIt; | 652 | QStringList::Iterator catIt; |
648 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 653 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
649 | if ( !addrCategories.contains( *catIt ) ) | 654 | if ( !addrCategories.contains( *catIt ) ) |
650 | addrCategories.append( *catIt ); | 655 | addrCategories.append( *catIt ); |
651 | } | 656 | } |
652 | addr.setCategories( addrCategories ); | 657 | addr.setCategories( addrCategories ); |
653 | } | 658 | } |
654 | 659 | ||
655 | mAddressBook->insertAddressee( addr ); | 660 | mAddressBook->insertAddressee( addr ); |
656 | } | 661 | } |
657 | } | 662 | } |
658 | 663 | ||
659 | if ( uids.count() > 0 ) | 664 | if ( uids.count() > 0 ) |
660 | setModified( true ); | 665 | setModified( true ); |
661 | } | 666 | } |
@@ -793,130 +798,147 @@ void KABCore::newContact() | |||
793 | } | 798 | } |
794 | } | 799 | } |
795 | 800 | ||
796 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 801 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
797 | resource = static_cast<KABC::Resource*>( res ); | 802 | resource = static_cast<KABC::Resource*>( res ); |
798 | 803 | ||
799 | if ( resource ) { | 804 | if ( resource ) { |
800 | KABC::Addressee addr; | 805 | KABC::Addressee addr; |
801 | addr.setResource( resource ); | 806 | addr.setResource( resource ); |
802 | mEditorDialog->setAddressee( addr ); | 807 | mEditorDialog->setAddressee( addr ); |
803 | KApplication::execDialog ( mEditorDialog ); | 808 | KApplication::execDialog ( mEditorDialog ); |
804 | 809 | ||
805 | } else | 810 | } else |
806 | return; | 811 | return; |
807 | 812 | ||
808 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 813 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
809 | 814 | ||
810 | 815 | ||
811 | } | 816 | } |
812 | 817 | ||
813 | void KABCore::addEmail( QString aStr ) | 818 | void KABCore::addEmail( QString aStr ) |
814 | { | 819 | { |
815 | #ifndef KAB_EMBEDDED | 820 | #ifndef KAB_EMBEDDED |
816 | QString fullName, email; | 821 | QString fullName, email; |
817 | 822 | ||
818 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 823 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
819 | 824 | ||
820 | // Try to lookup the addressee matching the email address | 825 | // Try to lookup the addressee matching the email address |
821 | bool found = false; | 826 | bool found = false; |
822 | QStringList emailList; | 827 | QStringList emailList; |
823 | KABC::AddressBook::Iterator it; | 828 | KABC::AddressBook::Iterator it; |
824 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 829 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
825 | emailList = (*it).emails(); | 830 | emailList = (*it).emails(); |
826 | if ( emailList.contains( email ) > 0 ) { | 831 | if ( emailList.contains( email ) > 0 ) { |
827 | found = true; | 832 | found = true; |
828 | (*it).setNameFromString( fullName ); | 833 | (*it).setNameFromString( fullName ); |
829 | editContact( (*it).uid() ); | 834 | editContact( (*it).uid() ); |
830 | } | 835 | } |
831 | } | 836 | } |
832 | 837 | ||
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 | ||
847 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 852 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
848 | { | 853 | { |
849 | mXXPortManager->importVCard( url, showPreview ); | 854 | mXXPortManager->importVCard( url, showPreview ); |
850 | } | 855 | } |
851 | void KABCore::importFromOL() | 856 | void 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 | ||
863 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 885 | void 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 |
869 | void KABCore::editContact2() { | 891 | void KABCore::editContact2() { |
870 | editContact( QString::null ); | 892 | editContact( QString::null ); |
871 | } | 893 | } |
872 | 894 | ||
873 | void KABCore::editContact( const QString &uid ) | 895 | void 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(); |
883 | if ( uidList.count() > 0 ) | 905 | if ( uidList.count() > 0 ) |
884 | localUID = *( uidList.at( 0 ) ); | 906 | localUID = *( uidList.at( 0 ) ); |
885 | } | 907 | } |
886 | 908 | ||
887 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 909 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
888 | if ( !addr.isEmpty() ) { | 910 | if ( !addr.isEmpty() ) { |
889 | mEditorDialog->setAddressee( addr ); | 911 | mEditorDialog->setAddressee( addr ); |
890 | KApplication::execDialog ( mEditorDialog ); | 912 | KApplication::execDialog ( mEditorDialog ); |
891 | } | 913 | } |
892 | } | 914 | } |
893 | 915 | ||
894 | void KABCore::save() | 916 | void KABCore::save() |
895 | { | 917 | { |
896 | if ( !mModified ) | 918 | if ( !mModified ) |
897 | return; | 919 | return; |
898 | QString text = i18n( "There was an error while attempting to save\n the " | 920 | QString text = i18n( "There was an error while attempting to save\n the " |
899 | "address book. Please check that some \nother application is " | 921 | "address book. Please check that some \nother application is " |
900 | "not using it. " ); | 922 | "not using it. " ); |
901 | statusMessage(i18n("Saving addressbook ... ")); | 923 | statusMessage(i18n("Saving addressbook ... ")); |
902 | #ifndef KAB_EMBEDDED | 924 | #ifndef KAB_EMBEDDED |
903 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 925 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
904 | if ( !b || !b->save() ) { | 926 | if ( !b || !b->save() ) { |
905 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 927 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
906 | } | 928 | } |
907 | #else //KAB_EMBEDDED | 929 | #else //KAB_EMBEDDED |
908 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 930 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
909 | if ( !b || !b->save() ) { | 931 | if ( !b || !b->save() ) { |
910 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 932 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
911 | } | 933 | } |
912 | #endif //KAB_EMBEDDED | 934 | #endif //KAB_EMBEDDED |
913 | 935 | ||
914 | statusMessage(i18n("Addressbook saved!")); | 936 | statusMessage(i18n("Addressbook saved!")); |
915 | setModified( false ); | 937 | setModified( false ); |
916 | } | 938 | } |
917 | 939 | ||
918 | void KABCore::statusMessage(QString mess , int time ) | 940 | void KABCore::statusMessage(QString mess , int time ) |
919 | { | 941 | { |
920 | //topLevelWidget()->setCaption( mess ); | 942 | //topLevelWidget()->setCaption( mess ); |
921 | // pending setting timer to revome message | 943 | // pending setting timer to revome message |
922 | } | 944 | } |
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp index 5e7d7c4..ef949e7 100644 --- a/kaddressbook/kaimportoldialog.cpp +++ b/kaddressbook/kaimportoldialog.cpp | |||
@@ -187,129 +187,129 @@ void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent | |||
187 | ts = i18n("Unknown"); | 187 | ts = i18n("Unknown"); |
188 | } | 188 | } |
189 | hChild->setText( 1,ts); | 189 | hChild->setText( 1,ts); |
190 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); | 190 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); |
191 | mfChild.m_lpDispatch->AddRef(); | 191 | mfChild.m_lpDispatch->AddRef(); |
192 | addFolder(hChild, mfChild.m_lpDispatch); | 192 | addFolder(hChild, mfChild.m_lpDispatch); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | void KAImportOLdialog::slotApply() | 196 | void KAImportOLdialog::slotApply() |
197 | { | 197 | { |
198 | importedItems = 0; | 198 | importedItems = 0; |
199 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); | 199 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); |
200 | while ( child ) { | 200 | while ( child ) { |
201 | if ( child->isOn() ) | 201 | if ( child->isOn() ) |
202 | readContactData( child->data() ); | 202 | readContactData( child->data() ); |
203 | child = (OLEListViewItem*) child->itemBelow(); | 203 | child = (OLEListViewItem*) child->itemBelow(); |
204 | } | 204 | } |
205 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); | 205 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); |
206 | KMessageBox::information(this,mes); | 206 | KMessageBox::information(this,mes); |
207 | } | 207 | } |
208 | void KAImportOLdialog::readContactData( DWORD folder ) | 208 | void KAImportOLdialog::readContactData( DWORD folder ) |
209 | { | 209 | { |
210 | 210 | ||
211 | LPDISPATCH dispItem = (LPDISPATCH)folder; | 211 | LPDISPATCH dispItem = (LPDISPATCH)folder; |
212 | dispItem->AddRef(); | 212 | dispItem->AddRef(); |
213 | MAPIFolder mf(dispItem); | 213 | MAPIFolder mf(dispItem); |
214 | mf.m_lpDispatch->AddRef(); | 214 | mf.m_lpDispatch->AddRef(); |
215 | _Items folderItems; | 215 | _Items folderItems; |
216 | _variant_t indx((long)0); | 216 | _variant_t indx((long)0); |
217 | LPDISPATCH itm; | 217 | LPDISPATCH itm; |
218 | int i; | 218 | int i; |
219 | folderItems = mf.GetItems(); | 219 | folderItems = mf.GetItems(); |
220 | QProgressBar bar( folderItems.GetCount(),0 ); | 220 | QProgressBar bar( folderItems.GetCount(),0 ); |
221 | bar.setCaption (i18n("Importing - close to abort!") ); | 221 | bar.setCaption (i18n("Importing - close to abort!") ); |
222 | int h = bar.sizeHint().height() ; | 222 | int h = bar.sizeHint().height() ; |
223 | int w = 300; | 223 | int w = 300; |
224 | int dw = QApplication::desktop()->width(); | 224 | int dw = QApplication::desktop()->width(); |
225 | int dh = QApplication::desktop()->height(); | 225 | int dh = QApplication::desktop()->height(); |
226 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 226 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
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 | } |
241 | void KAImportOLdialog::slotOk() | 241 | void KAImportOLdialog::slotOk() |
242 | { | 242 | { |
243 | QDialog::accept(); | 243 | QDialog::accept(); |
244 | } | 244 | } |
245 | 245 | ||
246 | void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) | 246 | void 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 ); |
276 | addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); | 276 | addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) ); |
277 | 277 | ||
278 | QString tempS; | 278 | QString tempS; |
279 | tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); | 279 | tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer()); |
280 | if ( tempS.length() > 12 ) | 280 | if ( tempS.length() > 12 ) |
281 | addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); | 281 | addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS ); |
282 | tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); | 282 | tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer()); |
283 | if ( !tempS.isEmpty() ) | 283 | if ( !tempS.isEmpty() ) |
284 | addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); | 284 | addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS ); |
285 | tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); | 285 | tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer()); |
286 | if ( !tempS.isEmpty() ) | 286 | if ( !tempS.isEmpty() ) |
287 | addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); | 287 | addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS ); |
288 | tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); | 288 | tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer()); |
289 | if ( !tempS.isEmpty() ) | 289 | if ( !tempS.isEmpty() ) |
290 | addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); | 290 | addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS ); |
291 | tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); | 291 | tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer()); |
292 | if ( !tempS.isEmpty() ) | 292 | if ( !tempS.isEmpty() ) |
293 | addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); | 293 | addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS ); |
294 | tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()); | 294 | tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()); |
295 | if ( !tempS.isEmpty() ) | 295 | if ( !tempS.isEmpty() ) |
296 | addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); | 296 | addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS ); |
297 | tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); | 297 | tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer()); |
298 | if ( !tempS.isEmpty() ) | 298 | if ( !tempS.isEmpty() ) |
299 | addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); | 299 | addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS ); |
300 | dtb = mDdate2Qdtr(aItem->GetAnniversary()); | 300 | dtb = mDdate2Qdtr(aItem->GetAnniversary()); |
301 | if (dtb.isValid() ) { | 301 | if (dtb.isValid() ) { |
302 | QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); | 302 | QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate); |
303 | addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 303 | addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
304 | } | 304 | } |
305 | int sec = aItem->GetSensitivity() ; | 305 | int sec = aItem->GetSensitivity() ; |
306 | if ( sec > 1 )// mapping pers -> private | 306 | if ( sec > 1 )// mapping pers -> private |
307 | --sec; | 307 | --sec; |
308 | addressee.setSecrecy( sec ); | 308 | addressee.setSecrecy( sec ); |
309 | //addressee.setLogo( const Picture &logo ); | 309 | //addressee.setLogo( const Picture &logo ); |
310 | //addressee.setPhoto( const Picture &photo ); | 310 | //addressee.setPhoto( const Picture &photo ); |
311 | //addressee.setSound( const Sound &sound ); | 311 | //addressee.setSound( const Sound &sound ); |
312 | //addressee.setAgent( const Agent &agent ); | 312 | //addressee.setAgent( const Agent &agent ); |
313 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()); | 313 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()); |
314 | addressee.setCategories( QStringList::split( ";", cat )); | 314 | addressee.setCategories( QStringList::split( ";", cat )); |
315 | 315 | ||
@@ -568,68 +568,72 @@ void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem ) | |||
568 | if ( insert ) { | 568 | if ( insert ) { |
569 | addressAdd->setType( KABC::Address::Home ); | 569 | addressAdd->setType( KABC::Address::Home ); |
570 | if ( addressMail == addressHome ) { | 570 | if ( addressMail == addressHome ) { |
571 | addressHome.setType( KABC::Address::Postal+ KABC::Address::Home ); | 571 | addressHome.setType( KABC::Address::Postal+ KABC::Address::Home ); |
572 | addressee.insertAddress( addressHome ); | 572 | addressee.insertAddress( addressHome ); |
573 | } else { | 573 | } else { |
574 | addressAdd->setType( KABC::Address::Work ); | 574 | addressAdd->setType( KABC::Address::Work ); |
575 | if ( addressMail == addressWork ){ | 575 | if ( addressMail == addressWork ){ |
576 | addressWork.setType( KABC::Address::Postal+ KABC::Address::Work ); | 576 | addressWork.setType( KABC::Address::Postal+ KABC::Address::Work ); |
577 | addressee.insertAddress( addressWork ); | 577 | addressee.insertAddress( addressWork ); |
578 | 578 | ||
579 | } else { | 579 | } else { |
580 | addressAdd->setType( 0 ); | 580 | addressAdd->setType( 0 ); |
581 | if ( addressOther == addressMail ){ | 581 | if ( addressOther == addressMail ){ |
582 | addressOther.setType( KABC::Address::Postal ); | 582 | addressOther.setType( KABC::Address::Postal ); |
583 | addressee.insertAddress( addressOther ); | 583 | addressee.insertAddress( addressOther ); |
584 | } else { | 584 | } else { |
585 | addressee.insertAddress( *addressAdd ); | 585 | addressee.insertAddress( *addressAdd ); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | } | 588 | } |
589 | } | 589 | } |
590 | #endif | 590 | #endif |
591 | // ++++++++++++++++++++++ end of ALL addresses | 591 | // ++++++++++++++++++++++ end of ALL addresses |
592 | //GetUserProperties(); | 592 | //GetUserProperties(); |
593 | tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer()); | 593 | tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer()); |
594 | if ( !tempS.isEmpty() ) | 594 | if ( !tempS.isEmpty() ) |
595 | addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS ); | 595 | addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS ); |
596 | tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer()); | 596 | tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer()); |
597 | if ( !tempS.isEmpty() ) | 597 | if ( !tempS.isEmpty() ) |
598 | addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS ); | 598 | addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS ); |
599 | int gen = aItem->GetGender(); | 599 | int gen = aItem->GetGender(); |
600 | if ( gen != 0 ) { // 0 undef - 1 female - 2 male | 600 | if ( gen != 0 ) { // 0 undef - 1 female - 2 male |
601 | if ( gen == 1 ) | 601 | if ( gen == 1 ) |
602 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); | 602 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); |
603 | else | 603 | else |
604 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); | 604 | addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); |
605 | } | 605 | } |
606 | 606 | ||
607 | #if 0 | 607 | #if 0 |
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 | } |
617 | void KAImportOLdialog::slotCancel() | 617 | void KAImportOLdialog::slotCancel() |
618 | { | 618 | { |
619 | reject(); | 619 | reject(); |
620 | } | 620 | } |
621 | 621 | ||
622 | bool KAImportOLdialog::addAddressee( KABC::Addressee a ) | 622 | bool 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 | |||
@@ -1,179 +1,180 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (C) 1999 Don Sanders <sanders@kde.org> | 3 | Copyright (C) 1999 Don Sanders <sanders@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
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 | 39 | extern bool pasteWithNewUid; | |
40 | ///////////////////////////////// | 40 | ///////////////////////////////// |
41 | // PwDelete Methods | 41 | // PwDelete Methods |
42 | 42 | ||
43 | PwDeleteCommand::PwDeleteCommand(KABC::AddressBook *doc, | 43 | PwDeleteCommand::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 | ||
50 | PwDeleteCommand::~PwDeleteCommand() | 50 | PwDeleteCommand::~PwDeleteCommand() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | QString PwDeleteCommand::name() | 54 | QString PwDeleteCommand::name() |
55 | { | 55 | { |
56 | return i18n( "Delete" ); | 56 | return i18n( "Delete" ); |
57 | } | 57 | } |
58 | 58 | ||
59 | void PwDeleteCommand::undo() | 59 | void 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) |
64 | { | 64 | { |
65 | mDocument->insertAddressee(*iter); | 65 | mDocument->insertAddressee(*iter); |
66 | } | 66 | } |
67 | 67 | ||
68 | mAddresseeList.clear(); | 68 | mAddresseeList.clear(); |
69 | } | 69 | } |
70 | 70 | ||
71 | void PwDeleteCommand::redo() | 71 | void PwDeleteCommand::redo() |
72 | { | 72 | { |
73 | // Just remove it from the document. This is enough to make the user | 73 | // Just remove it from the document. This is enough to make the user |
74 | // Think the item has been deleted | 74 | // Think the item has been deleted |
75 | KABC::Addressee a; | 75 | KABC::Addressee a; |
76 | QStringList::Iterator iter; | 76 | QStringList::Iterator iter; |
77 | for (iter = mUidList.begin(); iter != mUidList.end(); ++iter) | 77 | for (iter = mUidList.begin(); iter != mUidList.end(); ++iter) |
78 | { | 78 | { |
79 | a = mDocument->findByUid(*iter); | 79 | a = mDocument->findByUid(*iter); |
80 | mDocument->removeAddressee(a); | 80 | mDocument->removeAddressee(a); |
81 | mAddresseeList.append(a); | 81 | mAddresseeList.append(a); |
82 | AddresseeConfig::instance()->remove(a.uid()); | 82 | AddresseeConfig::instance()->remove(a.uid()); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | ///////////////////////////////// | 86 | ///////////////////////////////// |
87 | // PwPaste Methods | 87 | // PwPaste Methods |
88 | 88 | ||
89 | PwPasteCommand::PwPasteCommand( KABCore *core, const KABC::Addressee::List &list ) | 89 | PwPasteCommand::PwPasteCommand( KABCore *core, const KABC::Addressee::List &list ) |
90 | : Command(), mCore( core ), mAddresseeList( list ) | 90 | : Command(), mCore( core ), mAddresseeList( list ) |
91 | { | 91 | { |
92 | redo(); | 92 | redo(); |
93 | } | 93 | } |
94 | 94 | ||
95 | QString PwPasteCommand::name() | 95 | QString PwPasteCommand::name() |
96 | { | 96 | { |
97 | return i18n( "Paste" ); | 97 | return i18n( "Paste" ); |
98 | } | 98 | } |
99 | 99 | ||
100 | void PwPasteCommand::undo() | 100 | void 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 | ||
107 | void PwPasteCommand::redo() | 107 | void 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 | ||
129 | PwNewCommand::PwNewCommand( KABC::AddressBook *doc, const KABC::Addressee &a ) | 130 | PwNewCommand::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 | ||
135 | PwNewCommand::~PwNewCommand() | 136 | PwNewCommand::~PwNewCommand() |
136 | { | 137 | { |
137 | } | 138 | } |
138 | 139 | ||
139 | QString PwNewCommand::name() | 140 | QString PwNewCommand::name() |
140 | { | 141 | { |
141 | return i18n( "New Contact" ); | 142 | return i18n( "New Contact" ); |
142 | } | 143 | } |
143 | 144 | ||
144 | void PwNewCommand::undo() | 145 | void PwNewCommand::undo() |
145 | { | 146 | { |
146 | mDocument->removeAddressee( mA ); | 147 | mDocument->removeAddressee( mA ); |
147 | } | 148 | } |
148 | 149 | ||
149 | void PwNewCommand::redo() | 150 | void PwNewCommand::redo() |
150 | { | 151 | { |
151 | mDocument->insertAddressee( mA ); | 152 | mDocument->insertAddressee( mA ); |
152 | } | 153 | } |
153 | 154 | ||
154 | ///////////////////////////////// | 155 | ///////////////////////////////// |
155 | // PwEdit Methods | 156 | // PwEdit Methods |
156 | 157 | ||
157 | PwEditCommand::PwEditCommand(KABC::AddressBook *doc, | 158 | PwEditCommand::PwEditCommand(KABC::AddressBook *doc, |
158 | const KABC::Addressee &oldA, | 159 | const KABC::Addressee &oldA, |
159 | const KABC::Addressee &newA ) | 160 | const KABC::Addressee &newA ) |
160 | : Command(), mDocument(doc), mOldA(oldA), mNewA(newA) | 161 | : Command(), mDocument(doc), mOldA(oldA), mNewA(newA) |
161 | { | 162 | { |
162 | redo(); | 163 | redo(); |
163 | } | 164 | } |
164 | 165 | ||
165 | PwEditCommand::~PwEditCommand() | 166 | PwEditCommand::~PwEditCommand() |
166 | { | 167 | { |
167 | } | 168 | } |
168 | 169 | ||
169 | QString PwEditCommand::name() | 170 | QString PwEditCommand::name() |
170 | { | 171 | { |
171 | return i18n( "Entry Edit" ); | 172 | return i18n( "Entry Edit" ); |
172 | } | 173 | } |
173 | 174 | ||
174 | void PwEditCommand::undo() | 175 | void PwEditCommand::undo() |
175 | { | 176 | { |
176 | mDocument->insertAddressee(mOldA); | 177 | mDocument->insertAddressee(mOldA); |
177 | } | 178 | } |
178 | 179 | ||
179 | void PwEditCommand::redo() | 180 | void PwEditCommand::redo() |