author | eilers <eilers> | 2003-11-10 08:28:38 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-11-10 08:28:38 (UTC) |
commit | f3326a60ba002b420f33b6132dc1740c0fc4ffef (patch) (side-by-side diff) | |
tree | 6809f30857a241cf3334f7d25f60edc6fbb83901 /libopie2 | |
parent | efa3f9a756fb5a9afd0d35bc783e1331bf40bc6a (diff) | |
download | opie-f3326a60ba002b420f33b6132dc1740c0fc4ffef.zip opie-f3326a60ba002b420f33b6132dc1740c0fc4ffef.tar.gz opie-f3326a60ba002b420f33b6132dc1740c0fc4ffef.tar.bz2 |
Platform MacOS-X: Disable backtrce in odebug..
Libopie PIM: Finishing SQL-Backend for Todo. Recurrance events are supported now.
What is still missing: Custom entries currently not stored. It isn't easy to
implement them with enabled prefetch-cache.
LibopieDB2: Adding -lsqlite here instead linking it to libopie
-rw-r--r-- | libopie2/opiecore/oglobalsettings.h | 2 | ||||
-rw-r--r-- | libopie2/opiedb/opiedb.pro | 4 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.cpp | 31 | ||||
-rw-r--r-- | libopie2/opiepim/core/orecur.cpp | 147 | ||||
-rw-r--r-- | libopie2/opiepim/core/orecur.h | 12 |
5 files changed, 153 insertions, 43 deletions
diff --git a/libopie2/opiecore/oglobalsettings.h b/libopie2/opiecore/oglobalsettings.h index d3f357e..e3ac148 100644 --- a/libopie2/opiecore/oglobalsettings.h +++ b/libopie2/opiecore/oglobalsettings.h @@ -206,3 +206,3 @@ class OGlobalSettings /** - * Debug output is sent to files /var/log/***. + * Debug output is sent to files /var/log/. */ diff --git a/libopie2/opiedb/opiedb.pro b/libopie2/opiedb/opiedb.pro index bf547ab..6a4e8f1 100644 --- a/libopie2/opiedb/opiedb.pro +++ b/libopie2/opiedb/opiedb.pro @@ -31,2 +31,4 @@ OBJECTS_DIR = obj +LIBS += -lsqlite -lqpe + !contains( platform, x11 ) { @@ -36,3 +38,3 @@ OBJECTS_DIR = obj contains( platform, x11 ) { - LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib + LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp index ebd03bb..3913661 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.cpp +++ b/libopie2/opiepim/backend/otodoaccesssql.cpp @@ -125,3 +125,5 @@ namespace { qu += "description, summary, priority, DueDate, progress , state, "; - qu += "Recurrence, reminders, alarms, maintainer, startdate, completeddate);"; + // This is the recurrance-stuff .. Exceptions are currently not supported (see ORecur.cpp) ! (eilers) + qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, "; + qu += "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) );"; @@ -176,2 +178,3 @@ namespace { QString qu; + QMap<int, QString> recMap = m_todo.recurrence().toMap(); qu = "insert into todolist VALUES(" @@ -188,3 +191,10 @@ namespace { + QString::number( m_todo.state().state() ) + "," - + "'" + m_todo.recurrence().toString() + "'"+ ","; + + "'" + recMap[ ORecur::RType ] + "'" + "," + + "'" + recMap[ ORecur::RWeekdays ] + "'" + "," + + "'" + recMap[ ORecur::RPosition ] + "'" + "," + + "'" + recMap[ ORecur::RFreq ] + "'" + "," + + "'" + recMap[ ORecur::RHasEndDate ] + "'" + "," + + "'" + recMap[ ORecur::EndDate ] + "'" + "," + + "'" + recMap[ ORecur::Created ] + "'" + "," + + "'" + recMap[ ORecur::Exceptions ] + "'" + ","; @@ -526,2 +536,4 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { + qWarning("Item is completed: %d", item.data("completed").toInt() ); + OTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(), @@ -554,4 +566,15 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { - // Recurrence not supported yet - // to.setRecurrence( + QMap<int, QString> recMap; + recMap.insert( ORecur::RType , item.data("RType") ); + recMap.insert( ORecur::RWeekdays , item.data("RWeekdays") ); + recMap.insert( ORecur::RPosition , item.data("RPosition") ); + recMap.insert( ORecur::RFreq , item.data("RFreq") ); + recMap.insert( ORecur::RHasEndDate, item.data("RHasEndDate") ); + recMap.insert( ORecur::EndDate , item.data("EndDate") ); + recMap.insert( ORecur::Created , item.data("Created") ); + recMap.insert( ORecur::Exceptions , item.data("Exceptions") ); + + ORecur recur; + recur.fromMap( recMap ); + to.setRecurrence( recur ); diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp index eae1fdc..8c9ad46 100644 --- a/libopie2/opiepim/core/orecur.cpp +++ b/libopie2/opiepim/core/orecur.cpp @@ -458,50 +458,23 @@ QString ORecur::toString()const { QString buf; + QMap<int, QString> recMap = toMap(); buf += " rtype=\""; - switch ( data->type ) { - case ORecur::Daily: - buf += "Daily"; - break; - case ORecur::Weekly: - buf += "Weekly"; - break; - case ORecur::MonthlyDay: - buf += "MonthlyDay"; - break; - case ORecur::MonthlyDate: - buf += "MonthlyDate"; - break; - case ORecur::Yearly: - buf += "Yearly"; - break; - default: - buf += "NoRepeat"; - break; - } + buf += recMap[ORecur::RType]; buf += "\""; if (data->days > 0 ) - buf += " rweekdays=\"" + QString::number( static_cast<int>( data->days ) ) + "\""; + buf += " rweekdays=\"" + recMap[ORecur::RWeekdays] + "\""; if ( data->pos != 0 ) - buf += " rposition=\"" + QString::number(data->pos ) + "\""; + buf += " rposition=\"" + recMap[ORecur::RPosition] + "\""; - buf += " rfreq=\"" + QString::number( data->freq ) + "\""; - buf += " rhasenddate=\"" + QString::number( static_cast<int>( data->hasEnd ) ) + "\""; + buf += " rfreq=\"" + recMap[ORecur::RFreq] + "\""; + buf += " rhasenddate=\"" + recMap[ORecur::RHasEndDate]+ "\""; if ( data->hasEnd ) buf += " enddt=\"" - + QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) + + recMap[ORecur::EndDate] + "\""; - buf += " created=\"" + QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) + "\""; + buf += " created=\"" + recMap[ORecur::Created] + "\""; if ( data->list.isEmpty() ) return buf; - // save exceptions list here!! - ExceptionList::ConstIterator it; - ExceptionList list = data->list; buf += " exceptions=\""; - QDate date; - for ( it = list.begin(); it != list.end(); ++it ) { - date = (*it); - if ( it != list.begin() ) buf += " "; - - buf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() ); - } + buf += recMap[ORecur::Exceptions]; buf += "\" "; @@ -510 +483,103 @@ QString ORecur::toString()const { } + +QString ORecur::rTypeString() const +{ + QString retString; + switch ( data->type ) { + case ORecur::Daily: + retString = "Daily"; + break; + case ORecur::Weekly: + retString = "Weekly"; + break; + case ORecur::MonthlyDay: + retString = "MonthlyDay"; + break; + case ORecur::MonthlyDate: + retString = "MonthlyDate"; + break; + case ORecur::Yearly: + retString = "Yearly"; + break; + default: + retString = "NoRepeat"; + break; + + } + + return retString; +} + +QMap<QString, ORecur::RepeatType> ORecur::rTypeValueConvertMap() const +{ + QMap<QString, RepeatType> convertMap; + + convertMap.insert( QString( "Daily" ), ORecur::Daily ); + convertMap.insert( QString( "Weekly" ), ORecur::Weekly ); + convertMap.insert( QString( "MonthlyDay" ), ORecur::MonthlyDay ); + convertMap.insert( QString( "MonthlyDate" ), ORecur::MonthlyDate ); + convertMap.insert( QString( "Yearly" ), ORecur::Yearly ); + convertMap.insert( QString( "NoRepeat" ), ORecur::NoRepeat ); + + return convertMap; +} + + +QMap<int, QString> ORecur::toMap() const +{ + QMap<int, QString> retMap; + + retMap.insert( ORecur::RType, rTypeString() ); + retMap.insert( ORecur::RWeekdays, QString::number( static_cast<int>( data->days ) ) ); + retMap.insert( ORecur::RPosition, QString::number(data->pos ) ); + retMap.insert( ORecur::RFreq, QString::number( data->freq ) ); + retMap.insert( ORecur::RHasEndDate, QString::number( static_cast<int>( data->hasEnd ) ) ); + if( data -> hasEnd ) + retMap.insert( ORecur::EndDate, QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) ); + retMap.insert( ORecur::Created, QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) ); + + if ( data->list.isEmpty() ) return retMap; + + // save exceptions list here!! + ExceptionList::ConstIterator it; + ExceptionList list = data->list; + QString exceptBuf; + QDate date; + for ( it = list.begin(); it != list.end(); ++it ) { + date = (*it); + if ( it != list.begin() ) exceptBuf += " "; + + exceptBuf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() ); + } + + retMap.insert( ORecur::Exceptions, exceptBuf ); + + return retMap; +} + +void ORecur::fromMap( const QMap<int, QString>& map ) +{ + QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); + + data -> type = repTypeMap[ map [ORecur::RType] ]; + data -> days = (char) map[ ORecur::RWeekdays ].toInt(); + data -> pos = map[ ORecur::RPosition ].toInt(); + data -> freq = map[ ORecur::RFreq ].toInt(); + data -> hasEnd= map[ ORecur::RHasEndDate ].toInt() ? true : false; + OTimeZone utc = OTimeZone::utc(); + if ( data -> hasEnd ){ + data -> end = utc.fromUTCDateTime( (time_t) map[ ORecur::EndDate ].toLong() ).date(); + } + data -> create = utc.fromUTCDateTime( (time_t) map[ ORecur::Created ].toLong() ).date(); + +#if 0 + // FIXME: Exceptions currently not supported... + // Convert the list of exceptions from QString into ExceptionList + data -> list.clear(); + QString exceptStr = map[ ORecur::Exceptions ]; + QStringList exceptList = QStringList::split( " ", exceptStr ); + ... +#endif + + +} diff --git a/libopie2/opiepim/core/orecur.h b/libopie2/opiepim/core/orecur.h index b214b3f..47901b0 100644 --- a/libopie2/opiepim/core/orecur.h +++ b/libopie2/opiepim/core/orecur.h @@ -11,3 +11,3 @@ #include <qvaluelist.h> - +#include <qmap.h> @@ -20,2 +20,5 @@ public: FRI = 0x10, SAT = 0x20, SUN = 0x40 }; + enum Fields{ RType = 0, RWeekdays, RPosition, RFreq, RHasEndDate, + EndDate, Created, Exceptions }; + ORecur(); @@ -75,2 +78,5 @@ public: void setService( const QString& ser ); + + QMap<int, QString> toMap() const; + void fromMap( const QMap<int, QString>& map ); @@ -83,2 +89,6 @@ private: + /* Converts rType to String */ + QString rTypeString() const; + /* Returns a map to convert Stringname for RType to RepeatType */ + QMap<QString, RepeatType> rTypeValueConvertMap() const; |