summaryrefslogtreecommitdiff
path: root/libopie2
Side-by-side diff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp52
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.h2
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp2
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp72
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.h24
-rw-r--r--libopie2/opiepim/ocontactfields.cpp233
-rw-r--r--libopie2/opiepim/ocontactfields.h7
7 files changed, 260 insertions, 132 deletions
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
@@ -8,8 +8,11 @@
#include <opie2/osqlmanager.h>
#include <opie2/osqlquery.h>
#include "otodoaccesssql.h"
+#include "opimstate.h"
+#include "opimnotifymanager.h"
+#include "orecur.h"
/*
* first some query
* CREATE query
@@ -119,9 +122,10 @@ namespace {
QString CreateQuery::query()const {
QString qu;
qu += "create table todolist( uid PRIMARY KEY, categories, completed, ";
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;
}
LoadQuery::LoadQuery() : OSQLQuery() {}
@@ -180,16 +184,25 @@ namespace {
+ "'" + QString::number(year) + "-"
+ QString::number(month)
+ "-" + QString::number( day ) + "'" + ","
+ 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) + "-"
+ QString::number(eMonth)
+ "-"+QString::number(eDay) + "'"
+ ")";
@@ -529,8 +542,19 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
if ( hasStartDate )
to.setStartDate( startDate );
if ( hasCompletedDate )
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(
return to;
}
OTodo OTodoAccessBackendSQL::todo( int uid )const {
@@ -620,20 +644,12 @@ QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
return empty;
}
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{
QBitArray ar( OTodo::CompletedDate + 1 );
ar.fill( true );
ar[OTodo::CrossReference] = false;
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
@@ -43,9 +43,9 @@ private:
inline OTodo todo( const OSQLResult& )const;
inline OTodo todo( OSQLResultItem& )const;
inline QArray<int> uids( const OSQLResult& )const;
OTodo todo( int uid )const;
- QBitArray sup();
+ QBitArray sup() const;
QAsciiDict<int> m_dict;
OSQLDriver* m_driver;
QArray<int> m_uids;
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
@@ -567,9 +567,9 @@ QString OTodoAccessXML::toString( const OTodo& ev )const {
str += "State=\""+QString::number( ev.state().state() )+"\" ";
/*
* 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:....
*/
if ( ev.hasNotifiers() ) {
OPimNotifyManager manager = ev.notifiers();
OPimNotifyManager::Alarms alarms = manager.alarms();
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
@@ -1,6 +1,10 @@
#include "opimnotifymanager.h"
+#include "oconversion.h"
+
+#include <qstringlist.h>
+
OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
: m_rem( rem ), m_al( al )
{}
OPimNotifyManager::~OPimNotifyManager() {
@@ -66,9 +70,77 @@ void OPimNotifyManager::registerNotify( const OPimNotify& ) {
*/
void OPimNotifyManager::deregister( const OPimNotify& ) {
}
+
bool OPimNotifyManager::isEmpty()const {
qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() );
if ( m_rem.isEmpty() && m_al.isEmpty() ) return true;
else return false;
}
+
+// 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
@@ -38,11 +38,33 @@ public:
* this will do the opposite..
*/
void deregister( const OPimNotify& );
-
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:
Reminders m_rem;
Alarms m_al;
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
@@ -10,65 +10,81 @@
#include <opie/ocontact.h>
/*!
\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 ] );
if (sorted) list.sort();
return list;
}
/*!
\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 ] );
if (sorted) list.sort();
return list;
}
-
/*!
\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();
list.append( mapIdToStr[Qtopia::BusinessPhone] );
list.append( mapIdToStr[Qtopia::BusinessFax] );
list.append( mapIdToStr[Qtopia::BusinessMobile] );
@@ -88,60 +104,24 @@ QStringList OContactFields::trphonefields( bool sorted )
return list;
}
-
/*!
\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 );
list.append( mapIdToStr[Qtopia::BusinessStreet] );
list.append( mapIdToStr[Qtopia::BusinessCity] );
list.append( mapIdToStr[Qtopia::BusinessState] );
@@ -153,64 +133,93 @@ QStringList OContactFields::trfields( bool sorted )
list.append( mapIdToStr[Qtopia::HomeState] );
list.append( mapIdToStr[Qtopia::HomeZip] );
list.append( mapIdToStr[Qtopia::HomeCountry] );
- list += trdetailsfields( sorted );
-
- list.append( mapIdToStr[Qtopia::Notes] );
- list.append( mapIdToStr[Qtopia::Groups] );
+ list += detailsfields( sorted, translated );
if (sorted) list.sort();
return list;
}
+
/*!
\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()
{
QMap<int, QString> ret_map;
@@ -328,9 +337,9 @@ QMap<int, QString> OContactFields::idToUntrFields()
ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" );
//personal
ret_map.insert( Qtopia::Spouse, "Spouse" );
- ret_map.insert( Qtopia::Gender, "Gender" );
+ ret_map.insert( Qtopia::Gender, "Gender" );
ret_map.insert( Qtopia::Birthday, "Birthday" );
ret_map.insert( Qtopia::Anniversary, "Anniversary" );
ret_map.insert( Qtopia::Nickname, "Nickname" );
ret_map.insert( Qtopia::Children, "Children" );
@@ -356,8 +365,10 @@ QMap<QString, int> OContactFields::trFieldsToId()
return ret_map;
}
+/* ======================================================================= */
+
QMap<QString, int> OContactFields::untrFieldsToId()
{
QMap<int, QString> idtostr = idToUntrFields();
QMap<QString, int> ret_map;
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
@@ -42,8 +42,15 @@ class OContactFields{
QString globalFieldOrder;
bool changedFieldOrder;
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 );
static QStringList untrphonefields( bool sorted = true );
static QStringList trdetailsfields( bool sorted = true );
static QStringList untrdetailsfields( bool sorted = true );