summaryrefslogtreecommitdiff
path: root/libopie
Side-by-side diff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontactfields.cpp233
-rw-r--r--libopie/pim/ocontactfields.h7
-rw-r--r--libopie/pim/opimnotifymanager.cpp72
-rw-r--r--libopie/pim/opimnotifymanager.h24
-rw-r--r--libopie/pim/otodoaccesssql.cpp52
-rw-r--r--libopie/pim/otodoaccesssql.h2
-rw-r--r--libopie/pim/otodoaccessxml.cpp2
7 files changed, 260 insertions, 132 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
@@ -2,223 +2,232 @@
#include "ocontactfields.h"
#include <qstringlist.h>
#include <qobject.h>
// We should use our own enum in the future ..
#include <qpe/recordfields.h>
#include <qpe/config.h>
#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] );
list.append( mapIdToStr[Qtopia::BusinessPager] );
list.append( mapIdToStr[Qtopia::BusinessWebPage] );
list.append( mapIdToStr[Qtopia::DefaultEmail] );
list.append( mapIdToStr[Qtopia::Emails] );
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] );
if (sorted) list.sort();
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] );
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] );
- 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;
ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) );
ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) );
ret_map.insert( Qtopia::Title, QObject::tr( "Name Title") );
ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) );
ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) );
ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) );
ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ));
@@ -320,25 +329,25 @@ QMap<int, QString> OContactFields::idToUntrFields()
ret_map.insert( Qtopia::Manager, "Manager" );
// home
ret_map.insert( Qtopia::HomeStreet, "Home Street" );
ret_map.insert( Qtopia::HomeCity, "Home City" );
ret_map.insert( Qtopia::HomeState, "Home State" );
ret_map.insert( Qtopia::HomeZip, "Home Zip" );
ret_map.insert( Qtopia::HomeCountry, "Home Country" );
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" );
// other
ret_map.insert( Qtopia::Notes, "Notes" );
ret_map.insert( Qtopia::Groups, "Groups" );
return ret_map;
}
@@ -348,24 +357,26 @@ QMap<QString, int> OContactFields::trFieldsToId()
QMap<int, QString> idtostr = idToTrFields();
QMap<QString, int> ret_map;
QMap<int, QString>::Iterator it;
for( it = idtostr.begin(); it != idtostr.end(); ++it )
ret_map.insert( *it, it.key() );
return ret_map;
}
+/* ======================================================================= */
+
QMap<QString, int> OContactFields::untrFieldsToId()
{
QMap<int, QString> idtostr = idToUntrFields();
QMap<QString, int> ret_map;
QMap<int, QString>::Iterator it;
for( it = idtostr.begin(); it != idtostr.end(); ++it )
ret_map.insert( *it, it.key() );
return ret_map;
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
@@ -34,24 +34,31 @@ class OContactFields{
/** Store fieldorder to contact. */
void saveToRecord( OContact& );
/** Get Fieldorder from contact. */
void loadFromRecord( const OContact& );
private:
QString fieldOrder;
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 );
static QStringList trfields( bool sorted = true );
static QStringList untrfields( bool sorted = true );
static QMap<int, QString> idToTrFields();
static QMap<QString, int> trFieldsToId();
static QMap<int, QString> idToUntrFields();
static QMap<QString, int> untrFieldsToId();
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
@@ -1,14 +1,18 @@
#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() {
}
/* use static_cast and type instead of dynamic... */
void OPimNotifyManager::add( const OPimNotify& noti) {
if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
m_rem.append( rem );
}else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
@@ -58,17 +62,85 @@ void OPimNotifyManager::setReminders( const Reminders& rem) {
void OPimNotifyManager::registerNotify( const OPimNotify& ) {
}
/* FIXME!!! */
/**
* same as above...
* Also implement Url model
* have a MainWindow....
*/
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/libopie/pim/opimnotifymanager.h b/libopie/pim/opimnotifymanager.h
index 0ac30a1..48410e7 100644
--- a/libopie/pim/opimnotifymanager.h
+++ b/libopie/pim/opimnotifymanager.h
@@ -30,25 +30,47 @@ public:
/* register is a Ansi C keyword... */
/**
* This function will register the Notify to the Alarm Server
* or datebook depending on the type of the notify
*/
void registerNotify( const OPimNotify& );
/**
* 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;
class Private;
Private *d;
};
#endif
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
@@ -1,23 +1,26 @@
#include <qdatetime.h>
#include <qpe/global.h>
#include <opie2/osqldriver.h>
#include <opie2/osqlresult.h>
#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
* LOAD query
* INSERT
* REMOVE
* CLEAR
*/
namespace {
/**
* CreateQuery for the Todolist Table
@@ -111,25 +114,26 @@ namespace {
QDate m_start;
QDate m_end;
bool m_inc :1;
};
CreateQuery::CreateQuery() : OSQLQuery() {}
CreateQuery::~CreateQuery() {}
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() {}
LoadQuery::~LoadQuery() {}
QString LoadQuery::query()const {
QString qu;
// We do not need "distinct" here. The primary key is always unique..
//qu += "select distinct uid from todolist";
qu += "select uid from todolist";
return qu;
@@ -172,32 +176,41 @@ namespace {
QString qu;
qu = "insert into todolist VALUES("
+ QString::number( m_todo.uid() ) + ","
+ "'" + m_todo.idsToString( m_todo.categories() ) + "'" + ","
+ QString::number( m_todo.isCompleted() ) + ","
+ "'" + m_todo.description() + "'" + ","
+ "'" + m_todo.summary() + "'" + ","
+ QString::number(m_todo.priority() ) + ","
+ "'" + 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) + "'"
+ ")";
qWarning("add %s", qu.latin1() );
return qu;
}
RemoveQuery::RemoveQuery(int uid )
: OSQLQuery(), m_uid( uid ) {}
RemoveQuery::~RemoveQuery() {}
@@ -521,24 +534,35 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
if ( isOk )
to.setPriority( prioInt );
bool hasStartDate = false; QDate startDate = QDate::currentDate();
hasStartDate = date( startDate, item.data("startdate") );
bool hasCompletedDate = false; QDate completedDate = QDate::currentDate();
hasCompletedDate = date( completedDate, item.data("completeddate") );
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 {
FindQuery find( uid );
return todo( m_driver->query(&find) );
}
/*
* update the dict
*/
void OTodoAccessBackendSQL::fillDict() {
/* initialize dict */
@@ -612,36 +636,28 @@ QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
}
// Shrink to fit..
m_currentQuery.resize(arraycounter);
return m_currentQuery;
#endif
QArray<int> empty;
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;
ar[OTodo::State ] = false;
ar[OTodo::Reminders] = false;
ar[OTodo::Notifiers] = false;
ar[OTodo::Maintainer] = false;
return ar;
}
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
@@ -35,22 +35,22 @@ public:
QArray<int> matchRegexp( const QRegExp &r ) const;
void removeAllCompleted();
private:
void update()const;
void fillDict();
inline bool date( QDate& date, const QString& )const;
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;
bool m_dirty : 1;
};
#endif
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
@@ -559,25 +559,25 @@ QString OTodoAccessXML::toString( const OTodo& ev )const {
if ( ev.hasRecurrence() ) {
str += ev.recurrence().toString();
}
if ( ev.hasStartDate() )
str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" ";
if ( ev.hasCompletedDate() )
str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" ";
if ( ev.hasState() )
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();
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() )