author | zautrix <zautrix> | 2004-10-09 02:17:06 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-09 02:17:06 (UTC) |
commit | c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d (patch) (side-by-side diff) | |
tree | b83f7cfe5d4bb681b756fe95446e5e3fc193bc36 /kabc/addressbook.cpp | |
parent | 07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861 (diff) | |
download | kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.zip kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.gz kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.bz2 |
import ir fixes
-rw-r--r-- | kabc/addressbook.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index dc3cda1..bf6d053 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp @@ -393,40 +393,48 @@ void AddressBook::export2File( QString fileName ) if ( !(*it).IDStr().isEmpty() ) { (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); } KABC::VCardConverter converter; QString vcard; //Resource *resource() const; converter.addresseeToVCard( *it, vcard, version ); t << vcard << "\r\n"; } t << "\r\n\r\n"; outFile.close(); } -void AddressBook::importFromFile( QString fileName ) +void AddressBook::importFromFile( QString fileName, bool replaceLabel ) { KABC::Addressee::List list; QFile file( fileName ); file.open( IO_ReadOnly ); QByteArray rawData = file.readAll(); 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; list = tool.parseVCards( data ); KABC::Addressee::List::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { (*it).setResource( 0 ); + if ( replaceLabel ) + (*it).removeVoice(); insertAddressee( (*it), false, true ); } } bool AddressBook::saveAB() { bool ok = true; deleteRemovedAddressees(); Iterator ait; for ( ait = begin(); ait != end(); ++ait ) { |