-rw-r--r-- | kabc/addressbook.cpp | 16 | ||||
-rw-r--r-- | kabc/addressbook.h | 2 | ||||
-rw-r--r-- | kabc/addressee.cpp | 17 | ||||
-rw-r--r-- | kabc/addressee.h | 1 |
4 files changed, 31 insertions, 5 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index dc3cda1..bf6d053 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -404,6 +404,6 @@ void AddressBook::export2File( QString fileName ) } -void AddressBook::importFromFile( QString fileName ) +void AddressBook::importFromFile( QString fileName, bool replaceLabel ) { - KABC::Addressee::List list; + KABC::Addressee::List list; QFile file( fileName ); @@ -413,4 +413,10 @@ void AddressBook::importFromFile( QString fileName ) file.close(); - - QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); + qDebug("AddressBook::importFromFile "); + QString data; + if ( replaceLabel ) { + data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); + data.replace ( QRegExp("LABEL") , "ADR" ); + data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); + } else + data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); KABC::VCardTool tool; @@ -420,2 +426,4 @@ void AddressBook::importFromFile( QString fileName ) (*it).setResource( 0 ); + if ( replaceLabel ) + (*it).removeVoice(); insertAddressee( (*it), false, true ); diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 3603ec1..cea1b03 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h @@ -145,3 +145,3 @@ class AddressBook : public QObject void export2File( QString fileName ); - void importFromFile( QString fileName ); + void importFromFile( QString fileName, bool replaceLabel = false ); /** diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 19a1845..3f3d5c0 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp @@ -317,2 +317,19 @@ void Addressee::mergeContact( const Addressee& ad ) +bool Addressee::removeVoice() +{ + PhoneNumber::List phoneN = phoneNumbers(); + PhoneNumber::List::Iterator phoneIt; + bool found = false; + for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { + if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found + if ((*phoneIt).type() - PhoneNumber::Voice ) { + (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); + insertPhoneNumber( (*phoneIt) ); + found = true; + } + } + + } + return found; +} void Addressee::simplifyAddresses() diff --git a/kabc/addressee.h b/kabc/addressee.h index 44f0629..9336edc 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h @@ -123,2 +123,3 @@ class Addressee void simplifyPhoneNumberTypes(); + bool removeVoice(); |