-rw-r--r-- | kabc/addressbook.cpp | 26 | ||||
-rw-r--r-- | kabc/addressbook.h | 4 | ||||
-rw-r--r-- | kabc/addressee.cpp | 12 | ||||
-rw-r--r-- | kabc/addressee.h | 3 |
4 files changed, 41 insertions, 4 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 1050f55..ff05f7e 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -403,12 +403,13 @@ void AddressBook::export2File( QString fileName ) | |||
403 | t << "\r\n\r\n"; | 403 | t << "\r\n\r\n"; |
404 | outFile.close(); | 404 | outFile.close(); |
405 | } | 405 | } |
406 | void AddressBook::importFromFile( QString fileName, bool replaceLabel ) | 406 | void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) |
407 | { | 407 | { |
408 | 408 | ||
409 | if ( removeOld ) | ||
410 | setUntagged(); | ||
409 | KABC::Addressee::List list; | 411 | KABC::Addressee::List list; |
410 | QFile file( fileName ); | 412 | QFile file( fileName ); |
411 | |||
412 | file.open( IO_ReadOnly ); | 413 | file.open( IO_ReadOnly ); |
413 | QByteArray rawData = file.readAll(); | 414 | QByteArray rawData = file.readAll(); |
414 | file.close(); | 415 | file.close(); |
@@ -426,11 +427,30 @@ void AddressBook::importFromFile( QString fileName, bool replaceLabel ) | |||
426 | (*it).setResource( 0 ); | 427 | (*it).setResource( 0 ); |
427 | if ( replaceLabel ) | 428 | if ( replaceLabel ) |
428 | (*it).removeVoice(); | 429 | (*it).removeVoice(); |
430 | if ( removeOld ) | ||
431 | (*it).setTagged( true ); | ||
429 | insertAddressee( (*it), false, true ); | 432 | insertAddressee( (*it), false, true ); |
430 | } | 433 | } |
431 | 434 | if ( removeOld ) | |
435 | removeUntagged(); | ||
436 | } | ||
437 | void AddressBook::setUntagged() | ||
438 | { | ||
439 | Iterator ait; | ||
440 | for ( ait = begin(); ait != end(); ++ait ) { | ||
441 | (*ait).setTagged( false ); | ||
442 | } | ||
443 | } | ||
444 | void AddressBook::removeUntagged() | ||
445 | { | ||
446 | Iterator ait; | ||
447 | for ( ait = begin(); ait != end(); ++ait ) { | ||
448 | if (!(*ait).tagged()) | ||
449 | removeAddressee( ait ); | ||
432 | } | 450 | } |
433 | 451 | ||
452 | deleteRemovedAddressees(); | ||
453 | } | ||
434 | bool AddressBook::saveAB() | 454 | bool AddressBook::saveAB() |
435 | { | 455 | { |
436 | bool ok = true; | 456 | bool ok = true; |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index cea1b03..532e05d 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -143,7 +143,9 @@ class AddressBook : public QObject | |||
143 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
144 | bool saveAB( ); | 144 | bool saveAB( ); |
145 | void export2File( QString fileName ); | 145 | void export2File( QString fileName ); |
146 | void importFromFile( QString fileName, bool replaceLabel = false ); | 146 | void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); |
147 | void setUntagged(); | ||
148 | void removeUntagged(); | ||
147 | /** | 149 | /** |
148 | Returns a iterator for first entry of address book. | 150 | Returns a iterator for first entry of address book. |
149 | */ | 151 | */ |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 3f3d5c0..607ae26 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -88,6 +88,7 @@ struct Addressee::AddresseeData : public KShared | |||
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | ||
91 | }; | 92 | }; |
92 | 93 | ||
93 | Addressee::Addressee() | 94 | Addressee::Addressee() |
@@ -1821,6 +1822,17 @@ bool Addressee::changed() const | |||
1821 | return mData->changed; | 1822 | return mData->changed; |
1822 | } | 1823 | } |
1823 | 1824 | ||
1825 | void Addressee::setTagged( bool value ) | ||
1826 | { | ||
1827 | detach(); | ||
1828 | mData->tagged = value; | ||
1829 | } | ||
1830 | |||
1831 | bool Addressee::tagged() const | ||
1832 | { | ||
1833 | return mData->tagged; | ||
1834 | } | ||
1835 | |||
1824 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1836 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1825 | { | 1837 | { |
1826 | if (!a.mData) return s; | 1838 | if (!a.mData) return s; |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 9336edc..0aa2c51 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -833,6 +833,9 @@ class Addressee | |||
833 | */ | 833 | */ |
834 | bool changed() const; | 834 | bool changed() const; |
835 | 835 | ||
836 | void setTagged( bool value ); | ||
837 | bool tagged() const; | ||
838 | |||
836 | private: | 839 | private: |
837 | Addressee copy(); | 840 | Addressee copy(); |
838 | void detach(); | 841 | void detach(); |