author | eilers <eilers> | 2003-10-20 15:58:00 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-10-20 15:58:00 (UTC) |
commit | fccc5d110dea3bc32176694c8e5fc7f014706be6 (patch) (side-by-side diff) | |
tree | 6dd44a78cadfd55fc8935dc661318e3ab12dd7b7 | |
parent | 758775c190470e569a0616bbd87d1a378c19b747 (diff) | |
download | opie-fccc5d110dea3bc32176694c8e5fc7f014706be6.zip opie-fccc5d110dea3bc32176694c8e5fc7f014706be6.tar.gz opie-fccc5d110dea3bc32176694c8e5fc7f014706be6.tar.bz2 |
Pushing todo closer to sql support. Recurrances and custom entries still missing.
But before I add this, I have to do some cleanup..
-rw-r--r-- | libopie/pim/ocontactfields.cpp | 233 | ||||
-rw-r--r-- | libopie/pim/ocontactfields.h | 7 | ||||
-rw-r--r-- | libopie/pim/opimnotifymanager.cpp | 72 | ||||
-rw-r--r-- | libopie/pim/opimnotifymanager.h | 24 | ||||
-rw-r--r-- | libopie/pim/otodoaccesssql.cpp | 52 | ||||
-rw-r--r-- | libopie/pim/otodoaccesssql.h | 2 | ||||
-rw-r--r-- | libopie/pim/otodoaccessxml.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.cpp | 52 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.h | 2 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.cpp | 72 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.h | 24 | ||||
-rw-r--r-- | libopie2/opiepim/ocontactfields.cpp | 233 | ||||
-rw-r--r-- | libopie2/opiepim/ocontactfields.h | 7 |
14 files changed, 520 insertions, 264 deletions
diff --git a/libopie/pim/ocontactfields.cpp b/libopie/pim/ocontactfields.cpp index 7206f0d..0f08a5a 100644 --- a/libopie/pim/ocontactfields.cpp +++ b/libopie/pim/ocontactfields.cpp @@ -13,20 +13,29 @@ \internal - Returns a list of details field names for a contact. + Returns a list of personal field names for a contact. */ -QStringList OContactFields::untrdetailsfields( bool sorted ) +QStringList OContactFields::personalfields( bool sorted, bool translated ) { QStringList list; - QMap<int, QString> mapIdToStr = idToUntrFields(); + QMap<int, QString> mapIdToStr; + if ( translated ) + mapIdToStr = idToTrFields(); + else + mapIdToStr = idToUntrFields(); - list.append( mapIdToStr[ Qtopia::Office ] ); - list.append( mapIdToStr[ Qtopia::Profession ] ); - list.append( mapIdToStr[ Qtopia::Assistant ] ); - list.append( mapIdToStr[ Qtopia::Manager ] ); + list.append( mapIdToStr[ Qtopia::AddressUid ] ); + list.append( mapIdToStr[ Qtopia::AddressCategory ] ); - list.append( mapIdToStr[ Qtopia::Spouse ] ); - list.append( mapIdToStr[ Qtopia::Gender ] ); - list.append( mapIdToStr[ Qtopia::Birthday ] ); - list.append( mapIdToStr[ Qtopia::Anniversary ] ); - list.append( mapIdToStr[ Qtopia::Nickname ] ); - list.append( mapIdToStr[ Qtopia::Children ] ); + list.append( mapIdToStr[ Qtopia::Title ] ); + list.append( mapIdToStr[ Qtopia::FirstName ] ); + list.append( mapIdToStr[ Qtopia::MiddleName ] ); + list.append( mapIdToStr[ Qtopia::LastName ] ); + list.append( mapIdToStr[ Qtopia::Suffix ] ); + list.append( mapIdToStr[ Qtopia::FileAs ] ); + + list.append( mapIdToStr[ Qtopia::JobTitle ] ); + list.append( mapIdToStr[ Qtopia::Department ] ); + list.append( mapIdToStr[ Qtopia::Company ] ); + + list.append( mapIdToStr[ Qtopia::Notes ] ); + list.append( mapIdToStr[ Qtopia::Groups ] ); @@ -38,20 +47,24 @@ QStringList OContactFields::untrdetailsfields( bool sorted ) \internal - Returns a translated list of details field names for a contact. + Returns a list of details field names for a contact. */ -QStringList OContactFields::trdetailsfields( bool sorted ) +QStringList OContactFields::detailsfields( bool sorted, bool translated ) { QStringList list; - QMap<int, QString> mapIdToStr = idToTrFields(); + QMap<int, QString> mapIdToStr; + if ( translated ) + mapIdToStr = idToTrFields(); + else + mapIdToStr = idToUntrFields(); - list.append( mapIdToStr[Qtopia::Office] ); - list.append( mapIdToStr[Qtopia::Profession] ); - list.append( mapIdToStr[Qtopia::Assistant] ); - list.append( mapIdToStr[Qtopia::Manager] ); + list.append( mapIdToStr[ Qtopia::Office ] ); + list.append( mapIdToStr[ Qtopia::Profession ] ); + list.append( mapIdToStr[ Qtopia::Assistant ] ); + list.append( mapIdToStr[ Qtopia::Manager ] ); - list.append( mapIdToStr[Qtopia::Spouse] ); - list.append( mapIdToStr[Qtopia::Gender] ); - list.append( mapIdToStr[Qtopia::Birthday] ); - list.append( mapIdToStr[Qtopia::Anniversary] ); - list.append( mapIdToStr[Qtopia::Nickname] ); - list.append( mapIdToStr[Qtopia::Children] ); + list.append( mapIdToStr[ Qtopia::Spouse ] ); + list.append( mapIdToStr[ Qtopia::Gender ] ); + list.append( mapIdToStr[ Qtopia::Birthday ] ); + list.append( mapIdToStr[ Qtopia::Anniversary ] ); + list.append( mapIdToStr[ Qtopia::Nickname ] ); + list.append( mapIdToStr[ Qtopia::Children ] ); @@ -61,11 +74,14 @@ QStringList OContactFields::trdetailsfields( bool sorted ) - /*! \internal - Returns a translated list of phone field names for a contact. + Returns a list of phone field names for a contact. */ -QStringList OContactFields::trphonefields( bool sorted ) +QStringList OContactFields::phonefields( bool sorted, bool translated ) { QStringList list; - QMap<int, QString> mapIdToStr = idToTrFields(); + QMap<int, QString> mapIdToStr; + if ( translated ) + mapIdToStr = idToTrFields(); + else + mapIdToStr = idToUntrFields(); @@ -91,54 +107,18 @@ QStringList OContactFields::trphonefields( bool sorted ) - /*! \internal - Returns a list of phone field names for a contact. + Returns a list of field names for a contact. */ -QStringList OContactFields::untrphonefields( bool sorted ) +QStringList OContactFields::fields( bool sorted, bool translated ) { QStringList list; - QMap<int, QString> mapIdToStr = idToUntrFields(); - - list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); - list.append( mapIdToStr[ Qtopia::BusinessFax ] ); - list.append( mapIdToStr[ Qtopia::BusinessMobile ] ); - list.append( mapIdToStr[ Qtopia::BusinessPager ] ); - list.append( mapIdToStr[ Qtopia::BusinessWebPage ] ); - - list.append( mapIdToStr[ Qtopia::DefaultEmail ] ); - list.append( mapIdToStr[ Qtopia::Emails ] ); + QMap<int, QString> mapIdToStr; + if ( translated ) + mapIdToStr = idToTrFields(); + else + mapIdToStr = idToUntrFields(); - list.append( mapIdToStr[ Qtopia::HomePhone ] ); - list.append( mapIdToStr[ Qtopia::HomeFax ] ); - list.append( mapIdToStr[ Qtopia::HomeMobile ] ); - //list.append( mapIdToStr[Qtopia::HomePager] ); - list.append( mapIdToStr[Qtopia::HomeWebPage] ); + list += personalfields( sorted, translated ); - if (sorted) list.sort(); - - return list; -} - - -/*! - \internal - Returns a translated list of field names for a contact. -*/ -QStringList OContactFields::trfields( bool sorted ) -{ - QStringList list; - QMap<int, QString> mapIdToStr = idToTrFields(); - - list.append( mapIdToStr[Qtopia::Title]); - list.append( mapIdToStr[Qtopia::FirstName] ); - list.append( mapIdToStr[Qtopia::MiddleName] ); - list.append( mapIdToStr[Qtopia::LastName] ); - list.append( mapIdToStr[Qtopia::Suffix] ); - list.append( mapIdToStr[Qtopia::FileAs] ); - - list.append( mapIdToStr[Qtopia::JobTitle] ); - list.append( mapIdToStr[Qtopia::Department] ); - list.append( mapIdToStr[Qtopia::Company] ); - - list += trphonefields( sorted ); + list += phonefields( sorted, translated ); @@ -156,6 +136,3 @@ QStringList OContactFields::trfields( bool sorted ) - list += trdetailsfields( sorted ); - - list.append( mapIdToStr[Qtopia::Notes] ); - list.append( mapIdToStr[Qtopia::Groups] ); + list += detailsfields( sorted, translated ); @@ -166,48 +143,80 @@ QStringList OContactFields::trfields( bool sorted ) + /*! \internal - Returns an untranslated list of field names for a contact. + Returns an untranslated list of personal field names for a contact. */ -QStringList OContactFields::untrfields( bool sorted ) +QStringList OContactFields::untrpersonalfields( bool sorted ) { - QStringList list; - QMap<int, QString> mapIdToStr = idToUntrFields(); + return personalfields( sorted, false ); +} - list.append( mapIdToStr[ Qtopia::AddressUid ] ); - list.append( mapIdToStr[ Qtopia::AddressCategory ] ); - list.append( mapIdToStr[ Qtopia::Title ] ); - list.append( mapIdToStr[ Qtopia::FirstName ] ); - list.append( mapIdToStr[ Qtopia::MiddleName ] ); - list.append( mapIdToStr[ Qtopia::LastName ] ); - list.append( mapIdToStr[ Qtopia::Suffix ] ); - list.append( mapIdToStr[ Qtopia::FileAs ] ); +/*! + \internal + Returns a translated list of personal field names for a contact. +*/ +QStringList OContactFields::trpersonalfields( bool sorted ) +{ + return personalfields( sorted, true ); +} - list.append( mapIdToStr[ Qtopia::JobTitle ] ); - list.append( mapIdToStr[ Qtopia::Department ] ); - list.append( mapIdToStr[ Qtopia::Company ] ); - list += untrphonefields( sorted ); +/*! + \internal + Returns an untranslated list of details field names for a contact. +*/ +QStringList OContactFields::untrdetailsfields( bool sorted ) +{ + return detailsfields( sorted, false ); +} - list.append( mapIdToStr[ Qtopia::BusinessStreet ] ); - list.append( mapIdToStr[ Qtopia::BusinessCity ] ); - list.append( mapIdToStr[ Qtopia::BusinessState ] ); - list.append( mapIdToStr[ Qtopia::BusinessZip ] ); - list.append( mapIdToStr[ Qtopia::BusinessCountry ] ); - list.append( mapIdToStr[ Qtopia::HomeStreet ] ); - list.append( mapIdToStr[ Qtopia::HomeCity ] ); - list.append( mapIdToStr[ Qtopia::HomeState ] ); - list.append( mapIdToStr[ Qtopia::HomeZip ] ); - list.append( mapIdToStr[ Qtopia::HomeCountry ] ); +/*! + \internal + Returns a translated list of details field names for a contact. +*/ +QStringList OContactFields::trdetailsfields( bool sorted ) +{ + return detailsfields( sorted, true ); +} - list += untrdetailsfields( sorted ); - list.append( mapIdToStr[ Qtopia::Notes ] ); - list.append( mapIdToStr[ Qtopia::Groups ] ); +/*! + \internal + Returns a translated list of phone field names for a contact. +*/ +QStringList OContactFields::trphonefields( bool sorted ) +{ + return phonefields( sorted, true ); +} - if (sorted) list.sort(); +/*! + \internal + Returns an untranslated list of phone field names for a contact. +*/ +QStringList OContactFields::untrphonefields( bool sorted ) +{ + return phonefields( sorted, false ); +} - return list; + +/*! + \internal + Returns a translated list of field names for a contact. +*/ +QStringList OContactFields::trfields( bool sorted ) +{ + return fields( sorted, true ); +} + +/*! + \internal + Returns an untranslated list of field names for a contact. +*/ +QStringList OContactFields::untrfields( bool sorted ) +{ + return fields( sorted, false ); } + QMap<int, QString> OContactFields::idToTrFields() @@ -331,3 +340,3 @@ QMap<int, QString> OContactFields::idToUntrFields() ret_map.insert( Qtopia::Spouse, "Spouse" ); - ret_map.insert( Qtopia::Gender, "Gender" ); + ret_map.insert( Qtopia::Gender, "Gender" ); ret_map.insert( Qtopia::Birthday, "Birthday" ); @@ -359,2 +368,4 @@ QMap<QString, int> OContactFields::trFieldsToId() +/* ======================================================================= */ + QMap<QString, int> OContactFields::untrFieldsToId() diff --git a/libopie/pim/ocontactfields.h b/libopie/pim/ocontactfields.h index 9f6171b..f105de7 100644 --- a/libopie/pim/ocontactfields.h +++ b/libopie/pim/ocontactfields.h @@ -45,2 +45,9 @@ class OContactFields{ public: + static QStringList personalfields( bool sorted = true, bool translated = false ); + static QStringList phonefields( bool sorted = true, bool translated = false ); + static QStringList detailsfields( bool sorted = true, bool translated = false ); + static QStringList fields( bool sorted = true, bool translated = false ); + + static QStringList trpersonalfields( bool sorted = true ); + static QStringList untrpersonalfields( bool sorted = true ); static QStringList trphonefields( bool sorted = true ); diff --git a/libopie/pim/opimnotifymanager.cpp b/libopie/pim/opimnotifymanager.cpp index 06b5987..53ad4c3 100644 --- a/libopie/pim/opimnotifymanager.cpp +++ b/libopie/pim/opimnotifymanager.cpp @@ -2,2 +2,6 @@ +#include "oconversion.h" + +#include <qstringlist.h> + OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) @@ -69,2 +73,3 @@ void OPimNotifyManager::deregister( const OPimNotify& ) { } + bool OPimNotifyManager::isEmpty()const { @@ -74 +79,68 @@ bool OPimNotifyManager::isEmpty()const { } + +// Taken from otodoaccessxml.. +QString OPimNotifyManager::alarmsToString() const +{ + QString str; + + OPimNotifyManager::Alarms alarms = m_al; + if ( !alarms.isEmpty() ) { + QStringList als; + OPimNotifyManager::Alarms::Iterator it = alarms.begin(); + for ( ; it != alarms.end(); ++it ) { + /* only if time is valid */ + if ( (*it).dateTime().isValid() ) { + als << OConversion::dateTimeToString( (*it).dateTime() ) + + ":" + QString::number( (*it).duration() ) + + ":" + QString::number( (*it).sound() ) + + ":"; + } + } + // now write the list + qWarning("als: %s", als.join("____________").latin1() ); + str = als.join(";"); + } + + return str; +} +QString OPimNotifyManager::remindersToString() const +{ + QString str; + + OPimNotifyManager::Reminders reminders = m_rem; + if (!reminders.isEmpty() ) { + OPimNotifyManager::Reminders::Iterator it = reminders.begin(); + QStringList records; + for ( ; it != reminders.end(); ++it ) { + records << QString::number( (*it).recordUid() ); + } + str = records.join(";"); + } + + return str; +} + +void OPimNotifyManager::alarmsFromString( const QString& str ) +{ + QStringList als = QStringList::split(";", str ); + for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { + QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty + qWarning("alarm: %s", alarm.join("___").latin1() ); + qWarning("alarm[0]: %s %s", alarm[0].latin1(), + OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); + OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), + alarm[1].toInt() ); + add( al ); + } +} + +void OPimNotifyManager::remindersFromString( const QString& str ) +{ + + QStringList rems = QStringList::split(";", str ); + for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { + OPimReminder rem( (*it).toInt() ); + add( rem ); + } + +} diff --git a/libopie/pim/opimnotifymanager.h b/libopie/pim/opimnotifymanager.h index 0ac30a1..48410e7 100644 --- a/libopie/pim/opimnotifymanager.h +++ b/libopie/pim/opimnotifymanager.h @@ -41,5 +41,27 @@ public: - bool isEmpty()const; + /** + * Return all alarms as string + */ + QString alarmsToString() const; + /** + * Return all notifiers as string + */ + QString remindersToString() const; + + /** + * Convert string to alarms + * @param str String created by alarmsToString() + */ + void alarmsFromString( const QString& str ); + + /** + * Convert string to reminders + * @param str String created by remindersToString() + */ + void remindersFromString( const QString& str ); + + + private: diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp index d255c66..ebd03bb 100644 --- a/libopie/pim/otodoaccesssql.cpp +++ b/libopie/pim/otodoaccesssql.cpp @@ -11,2 +11,5 @@ #include "otodoaccesssql.h" +#include "opimstate.h" +#include "opimnotifymanager.h" +#include "orecur.h" @@ -122,3 +125,4 @@ namespace { qu += "description, summary, priority, DueDate, progress , state, "; - qu += "Recurrence, notifiers, maintainer, startdate, completeddate)"; + qu += "Recurrence, reminders, alarms, maintainer, startdate, completeddate);"; + qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; return qu; @@ -183,10 +187,19 @@ namespace { + QString::number( m_todo.progress() ) + "," - + "''" + "," // state (conversion needed) -// + QString::number( m_todo.state() ) + "," - + "''" + "," // Recurrence (conversion needed) - + "''" + "," // Notifiers (conversion needed) - + "''" + "," // Maintainers (conversion needed) + + QString::number( m_todo.state().state() ) + "," + + "'" + m_todo.recurrence().toString() + "'"+ ","; + + if ( m_todo.hasNotifiers() ) { + OPimNotifyManager manager = m_todo.notifiers(); + qu += "'" + manager.remindersToString() + "'" + "," + + "'" + manager.alarmsToString() + "'" + ","; + } + else{ + qu += QString( "''" ) + "," + + "''" + ","; + } + + qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !) + "'" + QString::number(sYear) + "-" - + QString::number(sMonth) - + "-" + QString::number(sDay) + "'" + "," + + QString::number(sMonth) + + "-" + QString::number(sDay) + "'" + "," + "'" + QString::number(eYear) + "-" @@ -532,2 +545,13 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { to.setCompletedDate( completedDate ); + + OPimNotifyManager& manager = to.notifiers(); + manager.alarmsFromString( item.data("alarms") ); + manager.remindersFromString( item.data("reminders") ); + + OPimState pimState; + pimState.setState( QString( item.data("state") ).toInt() ); + to.setState( pimState ); + + // Recurrence not supported yet + // to.setRecurrence( @@ -623,14 +647,6 @@ QBitArray OTodoAccessBackendSQL::supports()const { - QBitArray ar( OTodo::CompletedDate + 1 ); - ar.fill( true ); - ar[OTodo::CrossReference] = false; - ar[OTodo::State ] = false; - ar[OTodo::Reminders] = false; - ar[OTodo::Notifiers] = false; - ar[OTodo::Maintainer] = false; - - return ar; + return sup(); } -QBitArray OTodoAccessBackendSQL::sup() { +QBitArray OTodoAccessBackendSQL::sup() const{ diff --git a/libopie/pim/otodoaccesssql.h b/libopie/pim/otodoaccesssql.h index 77d8b77..1c55567 100644 --- a/libopie/pim/otodoaccesssql.h +++ b/libopie/pim/otodoaccesssql.h @@ -46,3 +46,3 @@ private: OTodo todo( int uid )const; - QBitArray sup(); + QBitArray sup() const; diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp index f688735..4a5cb33 100644 --- a/libopie/pim/otodoaccessxml.cpp +++ b/libopie/pim/otodoaccessxml.cpp @@ -570,3 +570,3 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { * save reminders and notifiers! - * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:.... + * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:.... */ diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp index d255c66..ebd03bb 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.cpp +++ b/libopie2/opiepim/backend/otodoaccesssql.cpp @@ -11,2 +11,5 @@ #include "otodoaccesssql.h" +#include "opimstate.h" +#include "opimnotifymanager.h" +#include "orecur.h" @@ -122,3 +125,4 @@ namespace { qu += "description, summary, priority, DueDate, progress , state, "; - qu += "Recurrence, notifiers, maintainer, startdate, completeddate)"; + qu += "Recurrence, reminders, alarms, maintainer, startdate, completeddate);"; + qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; return qu; @@ -183,10 +187,19 @@ namespace { + QString::number( m_todo.progress() ) + "," - + "''" + "," // state (conversion needed) -// + QString::number( m_todo.state() ) + "," - + "''" + "," // Recurrence (conversion needed) - + "''" + "," // Notifiers (conversion needed) - + "''" + "," // Maintainers (conversion needed) + + QString::number( m_todo.state().state() ) + "," + + "'" + m_todo.recurrence().toString() + "'"+ ","; + + if ( m_todo.hasNotifiers() ) { + OPimNotifyManager manager = m_todo.notifiers(); + qu += "'" + manager.remindersToString() + "'" + "," + + "'" + manager.alarmsToString() + "'" + ","; + } + else{ + qu += QString( "''" ) + "," + + "''" + ","; + } + + qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !) + "'" + QString::number(sYear) + "-" - + QString::number(sMonth) - + "-" + QString::number(sDay) + "'" + "," + + QString::number(sMonth) + + "-" + QString::number(sDay) + "'" + "," + "'" + QString::number(eYear) + "-" @@ -532,2 +545,13 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { to.setCompletedDate( completedDate ); + + OPimNotifyManager& manager = to.notifiers(); + manager.alarmsFromString( item.data("alarms") ); + manager.remindersFromString( item.data("reminders") ); + + OPimState pimState; + pimState.setState( QString( item.data("state") ).toInt() ); + to.setState( pimState ); + + // Recurrence not supported yet + // to.setRecurrence( @@ -623,14 +647,6 @@ QBitArray OTodoAccessBackendSQL::supports()const { - QBitArray ar( OTodo::CompletedDate + 1 ); - ar.fill( true ); - ar[OTodo::CrossReference] = false; - ar[OTodo::State ] = false; - ar[OTodo::Reminders] = false; - ar[OTodo::Notifiers] = false; - ar[OTodo::Maintainer] = false; - - return ar; + return sup(); } -QBitArray OTodoAccessBackendSQL::sup() { +QBitArray OTodoAccessBackendSQL::sup() const{ diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h index 77d8b77..1c55567 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.h +++ b/libopie2/opiepim/backend/otodoaccesssql.h @@ -46,3 +46,3 @@ private: OTodo todo( int uid )const; - QBitArray sup(); + QBitArray sup() const; diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index f688735..4a5cb33 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp @@ -570,3 +570,3 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { * save reminders and notifiers! - * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:.... + * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:.... */ diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp index 06b5987..53ad4c3 100644 --- a/libopie2/opiepim/core/opimnotifymanager.cpp +++ b/libopie2/opiepim/core/opimnotifymanager.cpp @@ -2,2 +2,6 @@ +#include "oconversion.h" + +#include <qstringlist.h> + OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) @@ -69,2 +73,3 @@ void OPimNotifyManager::deregister( const OPimNotify& ) { } + bool OPimNotifyManager::isEmpty()const { @@ -74 +79,68 @@ bool OPimNotifyManager::isEmpty()const { } + +// Taken from otodoaccessxml.. +QString OPimNotifyManager::alarmsToString() const +{ + QString str; + + OPimNotifyManager::Alarms alarms = m_al; + if ( !alarms.isEmpty() ) { + QStringList als; + OPimNotifyManager::Alarms::Iterator it = alarms.begin(); + for ( ; it != alarms.end(); ++it ) { + /* only if time is valid */ + if ( (*it).dateTime().isValid() ) { + als << OConversion::dateTimeToString( (*it).dateTime() ) + + ":" + QString::number( (*it).duration() ) + + ":" + QString::number( (*it).sound() ) + + ":"; + } + } + // now write the list + qWarning("als: %s", als.join("____________").latin1() ); + str = als.join(";"); + } + + return str; +} +QString OPimNotifyManager::remindersToString() const +{ + QString str; + + OPimNotifyManager::Reminders reminders = m_rem; + if (!reminders.isEmpty() ) { + OPimNotifyManager::Reminders::Iterator it = reminders.begin(); + QStringList records; + for ( ; it != reminders.end(); ++it ) { + records << QString::number( (*it).recordUid() ); + } + str = records.join(";"); + } + + return str; +} + +void OPimNotifyManager::alarmsFromString( const QString& str ) +{ + QStringList als = QStringList::split(";", str ); + for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { + QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty + qWarning("alarm: %s", alarm.join("___").latin1() ); + qWarning("alarm[0]: %s %s", alarm[0].latin1(), + OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); + OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), + alarm[1].toInt() ); + add( al ); + } +} + +void OPimNotifyManager::remindersFromString( const QString& str ) +{ + + QStringList rems = QStringList::split(";", str ); + for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { + OPimReminder rem( (*it).toInt() ); + add( rem ); + } + +} diff --git a/libopie2/opiepim/core/opimnotifymanager.h b/libopie2/opiepim/core/opimnotifymanager.h index 0ac30a1..48410e7 100644 --- a/libopie2/opiepim/core/opimnotifymanager.h +++ b/libopie2/opiepim/core/opimnotifymanager.h @@ -41,5 +41,27 @@ public: - bool isEmpty()const; + /** + * Return all alarms as string + */ + QString alarmsToString() const; + /** + * Return all notifiers as string + */ + QString remindersToString() const; + + /** + * Convert string to alarms + * @param str String created by alarmsToString() + */ + void alarmsFromString( const QString& str ); + + /** + * Convert string to reminders + * @param str String created by remindersToString() + */ + void remindersFromString( const QString& str ); + + + private: diff --git a/libopie2/opiepim/ocontactfields.cpp b/libopie2/opiepim/ocontactfields.cpp index 7206f0d..0f08a5a 100644 --- a/libopie2/opiepim/ocontactfields.cpp +++ b/libopie2/opiepim/ocontactfields.cpp @@ -13,20 +13,29 @@ \internal - Returns a list of details field names for a contact. + Returns a list of personal field names for a contact. */ -QStringList OContactFields::untrdetailsfields( bool sorted ) +QStringList OContactFields::personalfields( bool sorted, bool translated ) { QStringList list; - QMap<int, QString> mapIdToStr = idToUntrFields(); + QMap<int, QString> mapIdToStr; + if ( translated ) + mapIdToStr = idToTrFields(); + else + mapIdToStr = idToUntrFields(); - list.append( mapIdToStr[ Qtopia::Office ] ); - list.append( mapIdToStr[ Qtopia::Profession ] ); - list.append( mapIdToStr[ Qtopia::Assistant ] ); - list.append( mapIdToStr[ Qtopia::Manager ] ); + list.append( mapIdToStr[ Qtopia::AddressUid ] ); + list.append( mapIdToStr[ Qtopia::AddressCategory ] ); - list.append( mapIdToStr[ Qtopia::Spouse ] ); - list.append( mapIdToStr[ Qtopia::Gender ] ); - list.append( mapIdToStr[ Qtopia::Birthday ] ); - list.append( mapIdToStr[ Qtopia::Anniversary ] ); - list.append( mapIdToStr[ Qtopia::Nickname ] ); - list.append( mapIdToStr[ Qtopia::Children ] ); + list.append( mapIdToStr[ Qtopia::Title ] ); + list.append( mapIdToStr[ Qtopia::FirstName ] ); + list.append( mapIdToStr[ Qtopia::MiddleName ] ); + list.append( mapIdToStr[ Qtopia::LastName ] ); + list.append( mapIdToStr[ Qtopia::Suffix ] ); + list.append( mapIdToStr[ Qtopia::FileAs ] ); + + list.append( mapIdToStr[ Qtopia::JobTitle ] ); + list.append( mapIdToStr[ Qtopia::Department ] ); + list.append( mapIdToStr[ Qtopia::Company ] ); + + list.append( mapIdToStr[ Qtopia::Notes ] ); + list.append( mapIdToStr[ Qtopia::Groups ] ); @@ -38,20 +47,24 @@ QStringList OContactFields::untrdetailsfields( bool sorted ) \internal - Returns a translated list of details field names for a contact. + Returns a list of details field names for a contact. */ -QStringList OContactFields::trdetailsfields( bool sorted ) +QStringList OContactFields::detailsfields( bool sorted, bool translated ) { QStringList list; - QMap<int, QString> mapIdToStr = idToTrFields(); + QMap<int, QString> mapIdToStr; + if ( translated ) + mapIdToStr = idToTrFields(); + else + mapIdToStr = idToUntrFields(); - list.append( mapIdToStr[Qtopia::Office] ); - list.append( mapIdToStr[Qtopia::Profession] ); - list.append( mapIdToStr[Qtopia::Assistant] ); - list.append( mapIdToStr[Qtopia::Manager] ); + list.append( mapIdToStr[ Qtopia::Office ] ); + list.append( mapIdToStr[ Qtopia::Profession ] ); + list.append( mapIdToStr[ Qtopia::Assistant ] ); + list.append( mapIdToStr[ Qtopia::Manager ] ); - list.append( mapIdToStr[Qtopia::Spouse] ); - list.append( mapIdToStr[Qtopia::Gender] ); - list.append( mapIdToStr[Qtopia::Birthday] ); - list.append( mapIdToStr[Qtopia::Anniversary] ); - list.append( mapIdToStr[Qtopia::Nickname] ); - list.append( mapIdToStr[Qtopia::Children] ); + list.append( mapIdToStr[ Qtopia::Spouse ] ); + list.append( mapIdToStr[ Qtopia::Gender ] ); + list.append( mapIdToStr[ Qtopia::Birthday ] ); + list.append( mapIdToStr[ Qtopia::Anniversary ] ); + list.append( mapIdToStr[ Qtopia::Nickname ] ); + list.append( mapIdToStr[ Qtopia::Children ] ); @@ -61,11 +74,14 @@ QStringList OContactFields::trdetailsfields( bool sorted ) - /*! \internal - Returns a translated list of phone field names for a contact. + Returns a list of phone field names for a contact. */ -QStringList OContactFields::trphonefields( bool sorted ) +QStringList OContactFields::phonefields( bool sorted, bool translated ) { QStringList list; - QMap<int, QString> mapIdToStr = idToTrFields(); + QMap<int, QString> mapIdToStr; + if ( translated ) + mapIdToStr = idToTrFields(); + else + mapIdToStr = idToUntrFields(); @@ -91,54 +107,18 @@ QStringList OContactFields::trphonefields( bool sorted ) - /*! \internal - Returns a list of phone field names for a contact. + Returns a list of field names for a contact. */ -QStringList OContactFields::untrphonefields( bool sorted ) +QStringList OContactFields::fields( bool sorted, bool translated ) { QStringList list; - QMap<int, QString> mapIdToStr = idToUntrFields(); - - list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); - list.append( mapIdToStr[ Qtopia::BusinessFax ] ); - list.append( mapIdToStr[ Qtopia::BusinessMobile ] ); - list.append( mapIdToStr[ Qtopia::BusinessPager ] ); - list.append( mapIdToStr[ Qtopia::BusinessWebPage ] ); - - list.append( mapIdToStr[ Qtopia::DefaultEmail ] ); - list.append( mapIdToStr[ Qtopia::Emails ] ); + QMap<int, QString> mapIdToStr; + if ( translated ) + mapIdToStr = idToTrFields(); + else + mapIdToStr = idToUntrFields(); - list.append( mapIdToStr[ Qtopia::HomePhone ] ); - list.append( mapIdToStr[ Qtopia::HomeFax ] ); - list.append( mapIdToStr[ Qtopia::HomeMobile ] ); - //list.append( mapIdToStr[Qtopia::HomePager] ); - list.append( mapIdToStr[Qtopia::HomeWebPage] ); + list += personalfields( sorted, translated ); - if (sorted) list.sort(); - - return list; -} - - -/*! - \internal - Returns a translated list of field names for a contact. -*/ -QStringList OContactFields::trfields( bool sorted ) -{ - QStringList list; - QMap<int, QString> mapIdToStr = idToTrFields(); - - list.append( mapIdToStr[Qtopia::Title]); - list.append( mapIdToStr[Qtopia::FirstName] ); - list.append( mapIdToStr[Qtopia::MiddleName] ); - list.append( mapIdToStr[Qtopia::LastName] ); - list.append( mapIdToStr[Qtopia::Suffix] ); - list.append( mapIdToStr[Qtopia::FileAs] ); - - list.append( mapIdToStr[Qtopia::JobTitle] ); - list.append( mapIdToStr[Qtopia::Department] ); - list.append( mapIdToStr[Qtopia::Company] ); - - list += trphonefields( sorted ); + list += phonefields( sorted, translated ); @@ -156,6 +136,3 @@ QStringList OContactFields::trfields( bool sorted ) - list += trdetailsfields( sorted ); - - list.append( mapIdToStr[Qtopia::Notes] ); - list.append( mapIdToStr[Qtopia::Groups] ); + list += detailsfields( sorted, translated ); @@ -166,48 +143,80 @@ QStringList OContactFields::trfields( bool sorted ) + /*! \internal - Returns an untranslated list of field names for a contact. + Returns an untranslated list of personal field names for a contact. */ -QStringList OContactFields::untrfields( bool sorted ) +QStringList OContactFields::untrpersonalfields( bool sorted ) { - QStringList list; - QMap<int, QString> mapIdToStr = idToUntrFields(); + return personalfields( sorted, false ); +} - list.append( mapIdToStr[ Qtopia::AddressUid ] ); - list.append( mapIdToStr[ Qtopia::AddressCategory ] ); - list.append( mapIdToStr[ Qtopia::Title ] ); - list.append( mapIdToStr[ Qtopia::FirstName ] ); - list.append( mapIdToStr[ Qtopia::MiddleName ] ); - list.append( mapIdToStr[ Qtopia::LastName ] ); - list.append( mapIdToStr[ Qtopia::Suffix ] ); - list.append( mapIdToStr[ Qtopia::FileAs ] ); +/*! + \internal + Returns a translated list of personal field names for a contact. +*/ +QStringList OContactFields::trpersonalfields( bool sorted ) +{ + return personalfields( sorted, true ); +} - list.append( mapIdToStr[ Qtopia::JobTitle ] ); - list.append( mapIdToStr[ Qtopia::Department ] ); - list.append( mapIdToStr[ Qtopia::Company ] ); - list += untrphonefields( sorted ); +/*! + \internal + Returns an untranslated list of details field names for a contact. +*/ +QStringList OContactFields::untrdetailsfields( bool sorted ) +{ + return detailsfields( sorted, false ); +} - list.append( mapIdToStr[ Qtopia::BusinessStreet ] ); - list.append( mapIdToStr[ Qtopia::BusinessCity ] ); - list.append( mapIdToStr[ Qtopia::BusinessState ] ); - list.append( mapIdToStr[ Qtopia::BusinessZip ] ); - list.append( mapIdToStr[ Qtopia::BusinessCountry ] ); - list.append( mapIdToStr[ Qtopia::HomeStreet ] ); - list.append( mapIdToStr[ Qtopia::HomeCity ] ); - list.append( mapIdToStr[ Qtopia::HomeState ] ); - list.append( mapIdToStr[ Qtopia::HomeZip ] ); - list.append( mapIdToStr[ Qtopia::HomeCountry ] ); +/*! + \internal + Returns a translated list of details field names for a contact. +*/ +QStringList OContactFields::trdetailsfields( bool sorted ) +{ + return detailsfields( sorted, true ); +} - list += untrdetailsfields( sorted ); - list.append( mapIdToStr[ Qtopia::Notes ] ); - list.append( mapIdToStr[ Qtopia::Groups ] ); +/*! + \internal + Returns a translated list of phone field names for a contact. +*/ +QStringList OContactFields::trphonefields( bool sorted ) +{ + return phonefields( sorted, true ); +} - if (sorted) list.sort(); +/*! + \internal + Returns an untranslated list of phone field names for a contact. +*/ +QStringList OContactFields::untrphonefields( bool sorted ) +{ + return phonefields( sorted, false ); +} - return list; + +/*! + \internal + Returns a translated list of field names for a contact. +*/ +QStringList OContactFields::trfields( bool sorted ) +{ + return fields( sorted, true ); +} + +/*! + \internal + Returns an untranslated list of field names for a contact. +*/ +QStringList OContactFields::untrfields( bool sorted ) +{ + return fields( sorted, false ); } + QMap<int, QString> OContactFields::idToTrFields() @@ -331,3 +340,3 @@ QMap<int, QString> OContactFields::idToUntrFields() ret_map.insert( Qtopia::Spouse, "Spouse" ); - ret_map.insert( Qtopia::Gender, "Gender" ); + ret_map.insert( Qtopia::Gender, "Gender" ); ret_map.insert( Qtopia::Birthday, "Birthday" ); @@ -359,2 +368,4 @@ QMap<QString, int> OContactFields::trFieldsToId() +/* ======================================================================= */ + QMap<QString, int> OContactFields::untrFieldsToId() diff --git a/libopie2/opiepim/ocontactfields.h b/libopie2/opiepim/ocontactfields.h index 9f6171b..f105de7 100644 --- a/libopie2/opiepim/ocontactfields.h +++ b/libopie2/opiepim/ocontactfields.h @@ -45,2 +45,9 @@ class OContactFields{ public: + static QStringList personalfields( bool sorted = true, bool translated = false ); + static QStringList phonefields( bool sorted = true, bool translated = false ); + static QStringList detailsfields( bool sorted = true, bool translated = false ); + static QStringList fields( bool sorted = true, bool translated = false ); + + static QStringList trpersonalfields( bool sorted = true ); + static QStringList untrpersonalfields( bool sorted = true ); static QStringList trphonefields( bool sorted = true ); |