Diffstat (limited to 'kabc/plugins/qtopia/qtopiaconverter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp index 9693a68..9b3903b 100644 --- a/kabc/plugins/qtopia/qtopiaconverter.cpp +++ b/kabc/plugins/qtopia/qtopiaconverter.cpp @@ -21,33 +21,35 @@ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ //US #include "kglobal.h" #include "klocale.h" #include "qtopiaconverter.h" #include <qfile.h> #include <qdir.h> -#include <qtextstream.h> +#include <q3textstream.h> +//Added by qt3to4: +#include <Q3ValueList> //#include <.h> #include <libkdepim/ksyncprofile.h> using namespace KABC; QtopiaConverter::QtopiaConverter() { m_edit = 0; } QtopiaConverter::~QtopiaConverter() { deinit(); } @@ -58,34 +60,34 @@ bool QtopiaConverter::init() m_edit = new CategoryEdit( fn); return true; } void QtopiaConverter::deinit() { if (m_edit) { delete m_edit; m_edit = 0; } } QString QtopiaConverter::categoriesToNumber( const QStringList &list, const QString &app ) { startover: QStringList dummy; - QValueList<OpieCategories>::ConstIterator catIt; - QValueList<OpieCategories> categories = m_edit->categories(); + Q3ValueList<OpieCategories>::ConstIterator catIt; + Q3ValueList<OpieCategories> categories = m_edit->categories(); bool found = false; for ( QStringList::ConstIterator listIt = list.begin(); listIt != list.end(); ++listIt ) { /* skip empty category name */ if ( (*listIt).isEmpty() ) continue; found = false; for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { /* * We currently do not take app into account * if name matches and the id isn't already in dummy we'll add it */ if ( (*catIt).name() == (*listIt) && !dummy.contains(( *catIt).id() ) ) { // the same name found= true; dummy << (*catIt).id(); } } @@ -179,33 +181,33 @@ QString QtopiaConverter::dateToString( const QDate &d ) return str; } bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr ) { { //LR adr.setUid( el.attribute("Uid" ) ); adr.setFamilyName( el.attribute( "LastName" ) ); adr.setGivenName( el.attribute( "FirstName" ) ); adr.setAdditionalName( el.attribute( "MiddleName" ) ); adr.setSuffix( el.attribute( "Suffix" ) ); adr.setNickName( el.attribute( "Nickname" ) ); QDate date = dateFromString( el.attribute( "Birthday" ) ); if ( date.isValid() ) - adr.setBirthday( date ); + adr.setBirthday( (QDateTime)date ); adr.setRole( el.attribute( "JobTitle" ) ); if ( !el.attribute( "FileAs" ).isEmpty() ) adr.setFormattedName( el.attribute( "FileAs" ) ); adr.setOrganization( el.attribute( "Company" ) ); KABC::PhoneNumber businessPhoneNum( el.attribute( "BusinessPhone" ), KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); KABC::PhoneNumber businessFaxNum( el.attribute( "BusinessFax" ), KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); KABC::PhoneNumber businessMobile( el.attribute( "BusinessMobile" ), KABC::PhoneNumber::Car ); KABC::PhoneNumber businessPager( el.attribute( "BusinessPager" ), KABC::PhoneNumber::Pager ); if ( !businessPhoneNum.number().isEmpty() ) @@ -304,33 +306,33 @@ bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr ) if ( !el.attribute( "Children" ).isEmpty() ) adr.insertCustom("KADDRESSBOOK", "X-Children", el.attribute("Children") ); if ( !el.attribute( "Office" ).isEmpty() ) adr.insertCustom("KADDRESSBOOK", "X-Office", el.attribute("Office") ); if ( !el.attribute( "Profession" ).isEmpty() ) adr.insertCustom("KADDRESSBOOK", "X-Profession", el.attribute("Profession") ); if ( !el.attribute( "Assistant" ).isEmpty() ) adr.insertCustom("KADDRESSBOOK", "X-AssistantsName", el.attribute("Assistant") ); if ( !el.attribute( "Manager" ).isEmpty() ) adr.insertCustom("KADDRESSBOOK", "X-ManagersName", el.attribute("Manager") ); } return true; } -bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *stream ) +bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, Q3TextStream *stream ) { *stream << "<Contact "; *stream << "FirstName=\"" << escape(ab.givenName()) << "\" "; *stream << "MiddleName=\"" << escape(ab.additionalName()) << "\" "; *stream << "LastName=\"" << escape(ab.familyName()) << "\" "; *stream << "Suffix=\"" << escape(ab.suffix()) << "\" "; QString sortStr; sortStr = ab.formattedName(); /* is formattedName is empty we use the assembled name as fallback */ if (sortStr.isEmpty() ) sortStr = ab.assembledName(); *stream << "FileAs=\"" << escape(sortStr) << "\" "; *stream << "JobTitle=\"" << escape(ab.role()) << "\" "; *stream << "Department=\"" << escape(ab.custom( "KADDRESSBOOK", "X-Department" )) << "\" "; @@ -471,39 +473,39 @@ QStringList AddressBook::attributes()const { #endif CategoryEdit::CategoryEdit(){ } CategoryEdit::CategoryEdit(const QString &fileName){ parse( fileName ); } CategoryEdit::~CategoryEdit(){ } void CategoryEdit::save(const QString& fileName)const{ QFile file( fileName ); QString endl = "\n"; - if ( file.open( IO_WriteOnly ) ) { - QTextStream stream( &file ); - stream.setEncoding( QTextStream::UnicodeUTF8 ); + if ( file.open( QIODevice::WriteOnly ) ) { + Q3TextStream stream( &file ); + stream.setEncoding( Q3TextStream::UnicodeUTF8 ); stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; stream << "<!DOCTYPE CategoryList>" << endl; stream << "<Categories>" << endl; - for ( QValueList<OpieCategories>::ConstIterator it = m_categories.begin(); + for ( Q3ValueList<OpieCategories>::ConstIterator it = m_categories.begin(); it != m_categories.end(); ++it ) { stream << "<Category id=\""<< ( (*it).id() ) << "\" "; if ( !(*it).app().isEmpty() ) stream << " app=\""<< ( (*it).app() ) << "\" "; stream << "name=\"" << ( (*it).name() ) << "\" "; stream << " />" << endl; } stream << "</Categories>" << endl; file.close(); } } int CategoryEdit::addCategory( const QString &name, int id ){ return addCategory( QString::null, name, id ); @@ -524,33 +526,33 @@ int CategoryEdit::addCategory( const QString &appName, const QString &name, in OpieCategories categories(QString::number(id), name, appName); //pending FIXME LR m_categories.remove( categories); m_categories.append( categories); return id; } /* * we parse the simple Category File here * We also keep track of global Cats * and Of Organizer and Contact cats and then * we will add them to the kde side... */ void CategoryEdit::parse( const QString &tempFile ){ clear(); QDomDocument doc( "mydocument" ); QFile f( tempFile ); - if ( !f.open( IO_ReadOnly ) ) + if ( !f.open( QIODevice::ReadOnly ) ) return; if ( !doc.setContent( &f ) ) { f.close(); return; } f.close(); QStringList global, contact, organizer; // print out the element names of all elements that are a direct child // of the outermost element. QDomElement docElem = doc.documentElement(); QDomNode n = docElem.firstChild(); if( docElem.nodeName() == QString::fromLatin1("Categories") ){ while( !n.isNull() ) { @@ -574,33 +576,33 @@ void CategoryEdit::parse( const QString &tempFile ){ m_categories.append( category ); // cheater } n = n.nextSibling(); } } updateKDE( "kaddressbookrc", global + contact ); updateKDE( "korganizerrc", global + organizer ); } void CategoryEdit::clear() { ids.clear(); m_categories.clear(); } QString CategoryEdit::categoryById( const QString &id, const QString &app )const { - QValueList<OpieCategories>::ConstIterator it; + Q3ValueList<OpieCategories>::ConstIterator it; QString category; QString fallback; for( it = m_categories.begin(); it != m_categories.end(); ++it ){ if( id.stripWhiteSpace() == (*it).id().stripWhiteSpace() ){ if( app == (*it).app() ){ category = (*it).name(); break; }else{ fallback = (*it).name(); } } } return category.isEmpty() ? fallback : category; } QStringList CategoryEdit::categoriesByIds( const QStringList& ids, const QString& app) { |