-rw-r--r-- | libopie/pim/ocontact.h | 2 | ||||
-rw-r--r-- | libopie/pim/ocontactaccessbackend_xml.h | 24 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_xml.h | 24 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.h | 2 |
4 files changed, 30 insertions, 22 deletions
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h index 65ba43e..1fd1c75 100644 --- a/libopie/pim/ocontact.h +++ b/libopie/pim/ocontact.h @@ -39,18 +39,16 @@ class ContactPrivate; class QPC_EXPORT OContact : public OPimRecord { friend class DataSet; public: OContact(); OContact( const QMap<int, QString> &fromMap ); virtual ~OContact(); - enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; - /* * do we need to inline them * if yes do we need to inline them this way? * -zecke */ void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } diff --git a/libopie/pim/ocontactaccessbackend_xml.h b/libopie/pim/ocontactaccessbackend_xml.h index ae6ec9e..c765ff5 100644 --- a/libopie/pim/ocontactaccessbackend_xml.h +++ b/libopie/pim/ocontactaccessbackend_xml.h @@ -12,16 +12,19 @@ * ToDo: XML-Backend: Automatic reload if something was changed... * * * ===================================================================== * Version: $Id$ * ===================================================================== * History: * $Log$ + * Revision 1.9 2002/12/08 12:48:57 eilers + * Moved journal-enum from ocontact into i the xml-backend.. + * * Revision 1.8 2002/11/14 17:04:24 eilers * Sorting will now work if fullname is identical on some entries * * Revision 1.7 2002/11/13 15:02:46 eilers * Small Bug in sorted fixed * * Revision 1.6 2002/11/13 14:14:51 eilers * Added sorted for Contacts.. @@ -337,17 +340,17 @@ class OContactAccessBackend_XML : public OContactAccessBackend { } return m_currentQuery; } bool add ( const OContact &newcontact ) { //qWarning("odefaultbackend: ACTION::ADD"); - updateJournal (newcontact, OContact::ACTION_ADD); + updateJournal (newcontact, ACTION_ADD); addContact_p( newcontact ); m_changed = true; return true; } bool replace ( const OContact &contact ) @@ -359,17 +362,17 @@ class OContactAccessBackend_XML : public OContactAccessBackend { QValueListIterator<OContact> it; for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ if ( (*it).uid() == contact.uid() ){ found = true; break; } } if (found) { - updateJournal (contact, OContact::ACTION_REPLACE); + updateJournal (contact, ACTION_REPLACE); m_contactList.remove (it); m_contactList.append (contact); return true; } else return false; } bool remove ( int uid ) @@ -380,29 +383,32 @@ class OContactAccessBackend_XML : public OContactAccessBackend { QValueListIterator<OContact> it; for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ if ((*it).uid() == uid){ found = true; break; } } if (found) { - updateJournal ( *it, OContact::ACTION_REMOVE); + updateJournal ( *it, ACTION_REMOVE); m_contactList.remove (it); return true; } else return false; } bool reload(){ /* Reload is the same as load in this implementation */ return ( load() ); } private: + + enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; + void addContact_p( const OContact &newcontact ){ m_contactList.append (newcontact); } /* This function loads the xml-database and the journalfile */ bool load( const QString filename, bool isJournal ) { /* We use the time of the last read to check if the file was @@ -412,17 +418,17 @@ class OContactAccessBackend_XML : public OContactAccessBackend { QFileInfo fi( filename ); m_readtime = fi.lastModified (); } const int JOURNALACTION = Qtopia::Notes + 1; const int JOURNALROW = JOURNALACTION + 1; bool foundAction = false; - OContact::journal_action action = OContact::ACTION_ADD; + journal_action action = ACTION_ADD; int journalKey = 0; QMap<int, QString> contactMap; QMap<QString, QString> customMap; QMap<QString, QString>::Iterator customIt; QAsciiDict<int> dict( 47 ); dict.setAutoDelete( TRUE ); dict.insert( "Uid", new int(Qtopia::AddressUid) ); @@ -533,17 +539,17 @@ class OContactAccessBackend_XML : public OContactAccessBackend { case Qtopia::AddressUid: contact.setUid( it.data().toInt() ); break; case Qtopia::AddressCategory: contact.setCategories( Qtopia::Record::idsFromString( it.data( ))); break; */ case JOURNALACTION: - action = OContact::journal_action(it.data().toInt()); + action = journal_action(it.data().toInt()); foundAction = true; qWarning ("ODefBack(journal)::ACTION found: %d", action); break; case JOURNALROW: journalKey = it.data().toInt(); break; default: // no conversion needed add them to the map contactMap.insert( *find, it.data() ); @@ -555,25 +561,25 @@ class OContactAccessBackend_XML : public OContactAccessBackend { for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) { contact.setCustomField( customIt.key(), customIt.data() ); } if (foundAction){ foundAction = false; switch ( action ) { - case OContact::ACTION_ADD: + case ACTION_ADD: addContact_p (contact); break; - case OContact::ACTION_REMOVE: + case ACTION_REMOVE: if ( !remove (contact.uid()) ) qWarning ("ODefBack(journal)::Unable to remove uid: %d", contact.uid() ); break; - case OContact::ACTION_REPLACE: + case ACTION_REPLACE: if ( !replace ( contact ) ) qWarning ("ODefBack(journal)::Unable to replace uid: %d", contact.uid() ); break; default: qWarning ("Unknown action: ignored !"); break; } @@ -590,17 +596,17 @@ class OContactAccessBackend_XML : public OContactAccessBackend { } delete root; qWarning("returning from loading" ); return true; } void updateJournal( const OContact& cnt, - OContact::journal_action action ) { + journal_action action ) { QFile f( m_journalName ); bool created = !f.exists(); if ( !f.open(IO_WriteOnly|IO_Append) ) return; QString buf; QCString str; diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h index ae6ec9e..c765ff5 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h @@ -12,16 +12,19 @@ * ToDo: XML-Backend: Automatic reload if something was changed... * * * ===================================================================== * Version: $Id$ * ===================================================================== * History: * $Log$ + * Revision 1.9 2002/12/08 12:48:57 eilers + * Moved journal-enum from ocontact into i the xml-backend.. + * * Revision 1.8 2002/11/14 17:04:24 eilers * Sorting will now work if fullname is identical on some entries * * Revision 1.7 2002/11/13 15:02:46 eilers * Small Bug in sorted fixed * * Revision 1.6 2002/11/13 14:14:51 eilers * Added sorted for Contacts.. @@ -337,17 +340,17 @@ class OContactAccessBackend_XML : public OContactAccessBackend { } return m_currentQuery; } bool add ( const OContact &newcontact ) { //qWarning("odefaultbackend: ACTION::ADD"); - updateJournal (newcontact, OContact::ACTION_ADD); + updateJournal (newcontact, ACTION_ADD); addContact_p( newcontact ); m_changed = true; return true; } bool replace ( const OContact &contact ) @@ -359,17 +362,17 @@ class OContactAccessBackend_XML : public OContactAccessBackend { QValueListIterator<OContact> it; for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ if ( (*it).uid() == contact.uid() ){ found = true; break; } } if (found) { - updateJournal (contact, OContact::ACTION_REPLACE); + updateJournal (contact, ACTION_REPLACE); m_contactList.remove (it); m_contactList.append (contact); return true; } else return false; } bool remove ( int uid ) @@ -380,29 +383,32 @@ class OContactAccessBackend_XML : public OContactAccessBackend { QValueListIterator<OContact> it; for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ if ((*it).uid() == uid){ found = true; break; } } if (found) { - updateJournal ( *it, OContact::ACTION_REMOVE); + updateJournal ( *it, ACTION_REMOVE); m_contactList.remove (it); return true; } else return false; } bool reload(){ /* Reload is the same as load in this implementation */ return ( load() ); } private: + + enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; + void addContact_p( const OContact &newcontact ){ m_contactList.append (newcontact); } /* This function loads the xml-database and the journalfile */ bool load( const QString filename, bool isJournal ) { /* We use the time of the last read to check if the file was @@ -412,17 +418,17 @@ class OContactAccessBackend_XML : public OContactAccessBackend { QFileInfo fi( filename ); m_readtime = fi.lastModified (); } const int JOURNALACTION = Qtopia::Notes + 1; const int JOURNALROW = JOURNALACTION + 1; bool foundAction = false; - OContact::journal_action action = OContact::ACTION_ADD; + journal_action action = ACTION_ADD; int journalKey = 0; QMap<int, QString> contactMap; QMap<QString, QString> customMap; QMap<QString, QString>::Iterator customIt; QAsciiDict<int> dict( 47 ); dict.setAutoDelete( TRUE ); dict.insert( "Uid", new int(Qtopia::AddressUid) ); @@ -533,17 +539,17 @@ class OContactAccessBackend_XML : public OContactAccessBackend { case Qtopia::AddressUid: contact.setUid( it.data().toInt() ); break; case Qtopia::AddressCategory: contact.setCategories( Qtopia::Record::idsFromString( it.data( ))); break; */ case JOURNALACTION: - action = OContact::journal_action(it.data().toInt()); + action = journal_action(it.data().toInt()); foundAction = true; qWarning ("ODefBack(journal)::ACTION found: %d", action); break; case JOURNALROW: journalKey = it.data().toInt(); break; default: // no conversion needed add them to the map contactMap.insert( *find, it.data() ); @@ -555,25 +561,25 @@ class OContactAccessBackend_XML : public OContactAccessBackend { for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) { contact.setCustomField( customIt.key(), customIt.data() ); } if (foundAction){ foundAction = false; switch ( action ) { - case OContact::ACTION_ADD: + case ACTION_ADD: addContact_p (contact); break; - case OContact::ACTION_REMOVE: + case ACTION_REMOVE: if ( !remove (contact.uid()) ) qWarning ("ODefBack(journal)::Unable to remove uid: %d", contact.uid() ); break; - case OContact::ACTION_REPLACE: + case ACTION_REPLACE: if ( !replace ( contact ) ) qWarning ("ODefBack(journal)::Unable to replace uid: %d", contact.uid() ); break; default: qWarning ("Unknown action: ignored !"); break; } @@ -590,17 +596,17 @@ class OContactAccessBackend_XML : public OContactAccessBackend { } delete root; qWarning("returning from loading" ); return true; } void updateJournal( const OContact& cnt, - OContact::journal_action action ) { + journal_action action ) { QFile f( m_journalName ); bool created = !f.exists(); if ( !f.open(IO_WriteOnly|IO_Append) ) return; QString buf; QCString str; diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h index 65ba43e..1fd1c75 100644 --- a/libopie2/opiepim/ocontact.h +++ b/libopie2/opiepim/ocontact.h @@ -39,18 +39,16 @@ class ContactPrivate; class QPC_EXPORT OContact : public OPimRecord { friend class DataSet; public: OContact(); OContact( const QMap<int, QString> &fromMap ); virtual ~OContact(); - enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; - /* * do we need to inline them * if yes do we need to inline them this way? * -zecke */ void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |