author | ulf69 <ulf69> | 2004-07-20 21:28:10 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-20 21:28:10 (UTC) |
commit | 6f2ccd235ef49d5606ecf4e540e8884f7a9b7ec4 (patch) (side-by-side diff) | |
tree | 8ce4d24be2dfd04c386665723530435b66701286 | |
parent | fba0c028ac0ce15d0f7473439e025c56f108145e (diff) | |
download | kdepimpi-6f2ccd235ef49d5606ecf4e540e8884f7a9b7ec4.zip kdepimpi-6f2ccd235ef49d5606ecf4e540e8884f7a9b7ec4.tar.gz kdepimpi-6f2ccd235ef49d5606ecf4e540e8884f7a9b7ec4.tar.bz2 |
remove the export was successfull dialog if the user canceled the operation
-rw-r--r-- | kaddressbook/xxport/csv_xxport.cpp | 6 | ||||
-rw-r--r-- | kaddressbook/xxport/opie/opie_xxport.cpp | 54 | ||||
-rw-r--r-- | kaddressbook/xxport/vcard_xxport.cpp | 30 |
3 files changed, 45 insertions, 45 deletions
diff --git a/kaddressbook/xxport/csv_xxport.cpp b/kaddressbook/xxport/csv_xxport.cpp index caee66d..d4d5475 100644 --- a/kaddressbook/xxport/csv_xxport.cpp +++ b/kaddressbook/xxport/csv_xxport.cpp @@ -111,19 +111,19 @@ bool CSVXXPort::exportContacts( const KABC::AddresseeList &list, const QString& doExport( &file, list ); file.close(); return true; } - + #else //KAB_EMBEDDED QString fileName = KFileDialog::getSaveFileName( "addressbook.csv", i18n("Save file"), parentWidget() ); if ( fileName.isEmpty() ) - return true; + return false; QFile file( fileName ); if ( !file.open( IO_WriteOnly ) ) { QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ); KMessageBox::error( parentWidget(), txt.arg( fileName ) ); return false; @@ -133,13 +133,13 @@ bool CSVXXPort::exportContacts( const KABC::AddresseeList &list, const QString& file.close(); return true; #endif //KAB_EMBEDDED - + } KABC::AddresseeList CSVXXPort::importContacts( const QString& ) const { CSVImportDialog dlg( addressBook(), parentWidget() ); if ( dlg.exec() ) diff --git a/kaddressbook/xxport/opie/opie_xxport.cpp b/kaddressbook/xxport/opie/opie_xxport.cpp index db30d34..c9b0163 100644 --- a/kaddressbook/xxport/opie/opie_xxport.cpp +++ b/kaddressbook/xxport/opie/opie_xxport.cpp @@ -85,137 +85,137 @@ OpieXXPort::OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name createExportAction( i18n( "Export Opie..." ) ); } bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) { QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; - + #ifndef KAB_EMBEDDED QString fileName = KFileDialog::getSaveFileName( name ); #else //KAB_EMBEDDED QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); #endif //KAB_EMBEDDED - + if ( fileName.isEmpty() ) - return true; + return false; OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); - + if ( !access ) { qDebug("Unable to access file() %s", fileName.latin1()); addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); return false; } KABC::OpieConverter mConverter; - + bool res = mConverter.init(); if (!res) { QString text( i18n( "Unable to initialize opie converter.<br>Most likely a problem with the category file." ) ); qDebug(text); KMessageBox::error( parentWidget(), text ); delete access; - return false; + return false; } - + //Now check if the file has already entries, and ask the user if he wants to delete them first. OContactAccess::List contactList = access->allRecords(); if (contactList.count() > 0) { QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { // Clean the database.. access->clear(); } } - - + + KABC::Addressee::List::ConstIterator it; for ( it = list.begin(); it != list.end(); ++it ) { OContact c; KABC::Addressee addressee = (*it); - + res = mConverter.addresseeToOpie( *it, c ); if (res == true) { res = access->add(c); if (res == false) qDebug("Unable to append Contact %s", c.fullName().latin1()); } else { qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); } } - + access->save(); delete access; //US the deletion of the access object deletes the backend object as well. - + return true; } KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const { KABC::AddresseeList adrlst; - + QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; - + #ifndef KAB_EMBEDDED QString fileName = KFileDialog::getOpenFileName( name ); #else //KAB_EMBEDDED QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() ); #endif //KAB_EMBEDDED - + if ( fileName.isEmpty() ) return KABC::AddresseeList(); OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); - + if ( !access ) { qDebug("Unable to access file() %s", fileName.latin1()); addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); return KABC::AddresseeList(); } access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available - + KABC::OpieConverter mConverter; bool res = mConverter.init(); if (!res) { QString text( i18n( "Unable to initialize opie converter.<br>Most likely a problem with the category file." ) ); qDebug(text); KMessageBox::error( parentWidget(), text ); delete access; return KABC::AddresseeList(); } - - + + OContactAccess::List::Iterator it; OContactAccess::List allList = access->allRecords(); for ( it = allList.begin(); it != allList.end(); ++it ) { OContact c = (*it); - + KABC::Addressee addressee; - - res = mConverter.opieToAddressee( c, addressee ); - + + res = mConverter.opieToAddressee( c, addressee ); + if ( !addressee.isEmpty() && res ) { adrlst.append( addressee ); } - + // qDebug("found %s", c.fullName().latin1()); } - + delete access; //US the deletion of the access object deletes the backend object as well. - + return adrlst; - + } diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp index adf47cd..4819341 100644 --- a/kaddressbook/xxport/vcard_xxport.cpp +++ b/kaddressbook/xxport/vcard_xxport.cpp @@ -87,21 +87,21 @@ bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString QString name; if ( list.count() == 1 ) name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf"; else name = "addressbook.vcf"; - + #ifndef KAB_EMBEDDED QString fileName = KFileDialog::getSaveFileName( name ); #else //KAB_EMBEDDED QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); #endif //KAB_EMBEDDED - + if ( fileName.isEmpty() ) - return true; + return false; QFile outFile( fileName ); if ( !outFile.open( IO_WriteOnly ) ) { QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); KMessageBox::error( parentWidget(), text.arg( fileName ) ); return false; @@ -165,57 +165,57 @@ KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const KIO::NetAccess::removeTempFile( fileName ); } else { QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" ); KMessageBox::error( parentWidget(), text.arg( url.url() ), caption ); } - + } - + #else //KAB_EMBEDDED - - + + if ( !XXPortManager::importData.isEmpty() ) addrList = parseVCard( XXPortManager::importData ); else { if ( XXPortManager::importURL.isEmpty() ) { fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); if ( fileName.isEmpty() ) return addrList; - + } else { //US url = XXPortManager::importURL; qDebug("VCardXXPort::importContacts Urls at the moment not supported"); if ( url.isEmpty() ) return addrList; - + } - + QFile file( fileName ); file.open( IO_ReadOnly ); QByteArray rawData = file.readAll(); file.close(); QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); addrList = parseVCard( data ); - + } -#endif //KAB_EMBEDDED - +#endif //KAB_EMBEDDED + return addrList; } KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const -{ - +{ + KABC::VCardTool tool; KABC::AddresseeList addrList; addrList = tool.parseVCards( data ); // LR : I switched to the code, which is in current cvs HEAD /* uint numVCards = data.contains( "BEGIN:VCARD", false ); |