summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/otodo.cpp81
-rw-r--r--libopie/pim/otodo.h16
-rw-r--r--libopie2/opiepim/otodo.cpp81
-rw-r--r--libopie2/opiepim/otodo.h16
4 files changed, 164 insertions, 30 deletions
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index ea66d39..f3df119 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -1,89 +1,93 @@
#include <qobject.h>
#include <qshared.h>
#include <qpe/palmtopuidgen.h>
#include <qpe/stringutil.h>
#include <qpe/palmtoprecord.h>
#include <qpe/stringutil.h>
#include <qpe/categories.h>
#include <qpe/categoryselect.h>
#include "opimstate.h"
#include "orecur.h"
#include "opimmaintainer.h"
#include "opimnotifymanager.h"
#include "opimresolver.h"
#include "otodo.h"
struct OTodo::OTodoData : public QShared {
OTodoData() : QShared() {
+ recur = 0;
+ state = 0;
+ maintainer = 0;
+ notifiers = 0;
};
QDate date;
bool isCompleted:1;
bool hasDate:1;
int priority;
QString desc;
QString sum;
QMap<QString, QString> extra;
ushort prog;
- OPimState state;
- ORecur recur;
- OPimMaintainer maintainer;
+ OPimState *state;
+ ORecur *recur;
+ OPimMaintainer *maintainer;
QDate start;
QDate completed;
- OPimNotifyManager notifiers;
+ OPimNotifyManager *notifiers;
};
OTodo::OTodo(const OTodo &event )
: OPimRecord( event ), data( event.data )
{
data->ref();
// qWarning("ref up");
}
OTodo::~OTodo() {
// qWarning("~OTodo " );
if ( data->deref() ) {
// qWarning("OTodo::dereffing");
delete data;
data = 0l;
}
}
OTodo::OTodo(bool completed, int priority,
const QArray<int> &category,
const QString& summary,
const QString &description,
ushort progress,
bool hasDate, QDate date, int uid )
: OPimRecord( uid )
{
// qWarning("OTodoData " + summary);
setCategories( category );
data = new OTodoData;
data->date = date;
data->isCompleted = completed;
data->hasDate = hasDate;
data->priority = priority;
data->sum = summary;
data->prog = progress;
data->desc = Qtopia::simplifyMultiLineSpace(description );
}
OTodo::OTodo(bool completed, int priority,
const QStringList &category,
const QString& summary,
const QString &description,
ushort progress,
bool hasDate, QDate date, int uid )
: OPimRecord( uid )
{
// qWarning("OTodoData" + summary);
setCategories( idsFromString( category.join(";") ) );
@@ -106,207 +110,245 @@ bool OTodo::match( const QRegExp &regExp )const
return true;
}else if(data->desc.find( regExp ) != -1 ){
return true;
}else if(data->sum.find( regExp ) != -1 ) {
return true;
}
return false;
}
bool OTodo::isCompleted() const
{
return data->isCompleted;
}
bool OTodo::hasDueDate() const
{
return data->hasDate;
}
bool OTodo::hasStartDate()const {
return data->start.isValid();
}
bool OTodo::hasCompletedDate()const {
return data->completed.isValid();
}
int OTodo::priority()const
{
return data->priority;
}
QString OTodo::summary() const
{
return data->sum;
}
ushort OTodo::progress() const
{
return data->prog;
}
QDate OTodo::dueDate()const
{
return data->date;
}
QDate OTodo::startDate()const {
return data->start;
}
QDate OTodo::completedDate()const {
return data->completed;
}
QString OTodo::description()const
{
return data->desc;
}
+bool OTodo::hasState() const{
+ if (!data->state ) return false;
+ return ( data->state->state() != OPimState::Undefined );
+}
OPimState OTodo::state()const {
- return data->state;
+ if (!data->state ) {
+ OPimState state;
+ return state;
+ }
+
+ return (*data->state);
+}
+bool OTodo::hasRecurrence()const {
+ if (!data->recur) return false;
+ return data->recur->doesRecur();
}
ORecur OTodo::recurrence()const {
- return data->recur;
+ if (!data->recur) return ORecur();
+
+ return (*data->recur);
+}
+bool OTodo::hasMaintainer()const {
+ if (!data->maintainer) return false;
+
+ return (data->maintainer->mode() != OPimMaintainer::Undefined );
}
OPimMaintainer OTodo::maintainer()const {
- return data->maintainer;
+ if (!data->maintainer) return OPimMaintainer();
+
+ return (*data->maintainer);
}
void OTodo::setCompleted( bool completed )
{
changeOrModify();
data->isCompleted = completed;
}
void OTodo::setHasDueDate( bool hasDate )
{
changeOrModify();
data->hasDate = hasDate;
}
void OTodo::setDescription(const QString &desc )
{
// qWarning( "desc " + desc );
changeOrModify();
data->desc = Qtopia::simplifyMultiLineSpace(desc );
}
void OTodo::setSummary( const QString& sum )
{
changeOrModify();
data->sum = sum;
}
void OTodo::setPriority(int prio )
{
changeOrModify();
data->priority = prio;
}
void OTodo::setDueDate( const QDate& date )
{
changeOrModify();
data->date = date;
}
void OTodo::setStartDate( const QDate& date ) {
changeOrModify();
data->start = date;
}
void OTodo::setCompletedDate( const QDate& date ) {
changeOrModify();
data->completed = date;
}
void OTodo::setState( const OPimState& state ) {
changeOrModify();
- data->state = state;
+ if (data->state )
+ (*data->state) = state;
+ else
+ data->state = new OPimState( state );
}
void OTodo::setRecurrence( const ORecur& rec) {
changeOrModify();
- data->recur = rec;
+ if (data->recur )
+ (*data->recur) = rec;
+ else
+ data->recur = new ORecur( rec );
}
void OTodo::setMaintainer( const OPimMaintainer& pim ) {
changeOrModify();
- data->maintainer = pim;
+
+ if (data->maintainer )
+ (*data->maintainer) = pim;
+ else
+ data->maintainer = new OPimMaintainer( pim );
}
bool OTodo::isOverdue( )
{
if( data->hasDate && !data->isCompleted)
return QDate::currentDate() > data->date;
return false;
}
void OTodo::setProgress(ushort progress )
{
changeOrModify();
data->prog = progress;
}
QString OTodo::toShortText() const {
return summary();
}
/*!
Returns a richt text string
*/
QString OTodo::toRichText() const
{
QString text;
QStringList catlist;
// Description of the todo
if ( !summary().isEmpty() ) {
text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
}
if( !description().isEmpty() ){
text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ;
}
text += "<br><br><br>";
text += "<b>" + QObject::tr( "Priority:") +" </b>"
+ QString::number( priority() ) + " <br>";
text += "<b>" + QObject::tr( "Progress:") + " </b>"
+ QString::number( progress() ) + " %<br>";
if (hasDueDate() ){
text += "<b>" + QObject::tr( "Deadline:") + " </b>";
text += dueDate().toString();
text += "<br>";
}
text += "<b>" + QObject::tr( "Category:") + "</b> ";
text += categoryNames( "Todo List" ).join(", ");
text += "<br>";
return text;
}
+bool OTodo::hasNotifiers()const {
+ if (!data->notifiers) return false;
+ return data->notifiers->isEmpty();
+}
OPimNotifyManager& OTodo::notifiers() {
- return data->notifiers;
+ if (!data->notifiers )
+ data->notifiers = new OPimNotifyManager;
+ return (*data->notifiers);
}
bool OTodo::operator<( const OTodo &toDoEvent )const{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
if( hasDueDate() && toDoEvent.hasDueDate() ){
if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
return priority() < toDoEvent.priority();
}else{
return dueDate() < toDoEvent.dueDate();
}
}
return false;
}
bool OTodo::operator<=(const OTodo &toDoEvent )const
{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
if( hasDueDate() && toDoEvent.hasDueDate() ){
if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
return priority() <= toDoEvent.priority();
}else{
return dueDate() <= toDoEvent.dueDate();
}
}
return true;
}
bool OTodo::operator>(const OTodo &toDoEvent )const
{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
if( hasDueDate() && toDoEvent.hasDueDate() ){
if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
return priority() > toDoEvent.priority();
}else{
return dueDate() > toDoEvent.dueDate();
}
}
return false;
}
bool OTodo::operator>=(const OTodo &toDoEvent )const
{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
if( hasDueDate() && toDoEvent.hasDueDate() ){
if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
return priority() > toDoEvent.priority();
}else{
@@ -360,65 +402,74 @@ QMap<int, QString> OTodo::toMap() const {
map.insert( Completed, QString::number( data->isCompleted ) );
map.insert( Description, data->desc );
map.insert( Summary, data->sum );
map.insert( Priority, QString::number( data->priority ) );
map.insert( DateDay, QString::number( data->date.day() ) );
map.insert( DateMonth, QString::number( data->date.month() ) );
map.insert( DateYear, QString::number( data->date.year() ) );
map.insert( Progress, QString::number( data->prog ) );
// map.insert( CrossReference, crossToString() );
/* FIXME!!! map.insert( State, );
map.insert( Recurrence, );
map.insert( Reminders, );
map.
*/
return map;
}
QMap<QString, QString> OTodo::toExtraMap()const {
return data->extra;
}
/**
* change or modify looks at the ref count and either
* creates a new QShared Object or it can modify it
* right in place
*/
void OTodo::changeOrModify() {
if ( data->count != 1 ) {
qWarning("changeOrModify");
data->deref();
OTodoData* d2 = new OTodoData();
copy(data, d2 );
data = d2;
}
}
// WATCHOUT
/*
* if you add something to the Data struct
* be sure to copy it here
*/
void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->date = src->date;
dest->isCompleted = src->isCompleted;
dest->hasDate = src->hasDate;
dest->priority = src->priority;
dest->desc = src->desc;
dest->sum = src->sum;
dest->extra = src->extra;
dest->prog = src->prog;
- dest->state = src->state;
- dest->recur = src->recur;
- dest->maintainer = src->maintainer;
+
+ if (src->state )
+ dest->state = new OPimState( *src->state );
+
+ if (src->recur )
+ dest->recur = new ORecur( *src->recur );
+
+ if (src->maintainer )
+ dest->maintainer = new OPimMaintainer( *src->maintainer )
+ ;
dest->start = src->start;
dest->completed = src->completed;
- dest->notifiers = src->notifiers;
+
+ if (src->notifiers )
+ dest->notifiers = new OPimNotifyManager( *src->notifiers );
}
QString OTodo::type() const {
return QString::fromLatin1("OTodo");
}
QString OTodo::recordField(int /*id*/ )const {
return QString::null;
}
int OTodo::rtti(){
return OPimResolver::TodoList;
}
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h
index 2f66f55..a58d9aa 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -83,126 +83,142 @@ public:
/**
*destructor
*/
~OTodo();
/**
* Is this event completed?
*/
bool isCompleted() const;
/**
* Does this Event have a deadline
*/
bool hasDueDate() const;
bool hasStartDate()const;
bool hasCompletedDate()const;
/**
* Does this Event has an alarm time ?
*/
bool hasAlarmDateTime() const;
/**
* What is the priority?
*/
int priority()const ;
/**
* progress as ushort 0, 20, 40, 60, 80 or 100%
*/
ushort progress() const;
/**
* The due Date
*/
QDate dueDate()const;
/**
* When did it start?
*/
QDate startDate()const;
/**
* When was it completed?
*/
QDate completedDate()const;
/**
+ * does it have a state?
+ */
+ bool hasState()const;
+
+ /**
* What is the state of this OTodo?
*/
OPimState state()const;
/**
+ * has recurrence?
+ */
+ bool hasRecurrence()const;
+
+ /**
* the recurrance of this
*/
ORecur recurrence()const;
/**
+ * does this OTodo have a maintainer?
+ */
+ bool hasMaintainer()const;
+
+ /**
* the Maintainer of this OTodo
*/
OPimMaintainer maintainer()const;
/**
* The description of the todo
*/
QString description()const;
/**
* A small summary of the todo
*/
QString summary() const;
/**
* @reimplemented
* Return this todoevent in a RichText formatted QString
*/
QString toRichText() const;
+ bool hasNotifiers()const;
/*
* check if the sharing is still fine!! -zecke
*/
/**
* return a reference to our notifiers...
*/
OPimNotifyManager &notifiers();
/**
* reimplementations
*/
QString type()const;
QString toShortText()const;
QMap<QString, QString> toExtraMap()const;
QString recordField(int id )const;
/**
* toMap puts all data into the map. int relates
* to ToDoEvent RecordFields enum
*/
QMap<int, QString> toMap()const;
/**
* Set if this Todo is completed
*/
void setCompleted(bool completed );
/**
* set if this todo got an end data
*/
void setHasDueDate( bool hasDate );
// FIXME we do not have these for start, completed
// cause we'll use the isNull() of QDate for figuring
// out if it's has a date...
// decide what to do here? -zecke
/**
* Set the priority of the Todo
*/
void setPriority(int priority );
/**
* Set the progress.
*/
void setProgress( ushort progress );
/**
* set the end date
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index ea66d39..f3df119 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -1,89 +1,93 @@
#include <qobject.h>
#include <qshared.h>
#include <qpe/palmtopuidgen.h>
#include <qpe/stringutil.h>
#include <qpe/palmtoprecord.h>
#include <qpe/stringutil.h>
#include <qpe/categories.h>
#include <qpe/categoryselect.h>
#include "opimstate.h"
#include "orecur.h"
#include "opimmaintainer.h"
#include "opimnotifymanager.h"
#include "opimresolver.h"
#include "otodo.h"
struct OTodo::OTodoData : public QShared {
OTodoData() : QShared() {
+ recur = 0;
+ state = 0;
+ maintainer = 0;
+ notifiers = 0;
};
QDate date;
bool isCompleted:1;
bool hasDate:1;
int priority;
QString desc;
QString sum;
QMap<QString, QString> extra;
ushort prog;
- OPimState state;
- ORecur recur;
- OPimMaintainer maintainer;
+ OPimState *state;
+ ORecur *recur;
+ OPimMaintainer *maintainer;
QDate start;
QDate completed;
- OPimNotifyManager notifiers;
+ OPimNotifyManager *notifiers;
};
OTodo::OTodo(const OTodo &event )
: OPimRecord( event ), data( event.data )
{
data->ref();
// qWarning("ref up");
}
OTodo::~OTodo() {
// qWarning("~OTodo " );
if ( data->deref() ) {
// qWarning("OTodo::dereffing");
delete data;
data = 0l;
}
}
OTodo::OTodo(bool completed, int priority,
const QArray<int> &category,
const QString& summary,
const QString &description,
ushort progress,
bool hasDate, QDate date, int uid )
: OPimRecord( uid )
{
// qWarning("OTodoData " + summary);
setCategories( category );
data = new OTodoData;
data->date = date;
data->isCompleted = completed;
data->hasDate = hasDate;
data->priority = priority;
data->sum = summary;
data->prog = progress;
data->desc = Qtopia::simplifyMultiLineSpace(description );
}
OTodo::OTodo(bool completed, int priority,
const QStringList &category,
const QString& summary,
const QString &description,
ushort progress,
bool hasDate, QDate date, int uid )
: OPimRecord( uid )
{
// qWarning("OTodoData" + summary);
setCategories( idsFromString( category.join(";") ) );
@@ -106,207 +110,245 @@ bool OTodo::match( const QRegExp &regExp )const
return true;
}else if(data->desc.find( regExp ) != -1 ){
return true;
}else if(data->sum.find( regExp ) != -1 ) {
return true;
}
return false;
}
bool OTodo::isCompleted() const
{
return data->isCompleted;
}
bool OTodo::hasDueDate() const
{
return data->hasDate;
}
bool OTodo::hasStartDate()const {
return data->start.isValid();
}
bool OTodo::hasCompletedDate()const {
return data->completed.isValid();
}
int OTodo::priority()const
{
return data->priority;
}
QString OTodo::summary() const
{
return data->sum;
}
ushort OTodo::progress() const
{
return data->prog;
}
QDate OTodo::dueDate()const
{
return data->date;
}
QDate OTodo::startDate()const {
return data->start;
}
QDate OTodo::completedDate()const {
return data->completed;
}
QString OTodo::description()const
{
return data->desc;
}
+bool OTodo::hasState() const{
+ if (!data->state ) return false;
+ return ( data->state->state() != OPimState::Undefined );
+}
OPimState OTodo::state()const {
- return data->state;
+ if (!data->state ) {
+ OPimState state;
+ return state;
+ }
+
+ return (*data->state);
+}
+bool OTodo::hasRecurrence()const {
+ if (!data->recur) return false;
+ return data->recur->doesRecur();
}
ORecur OTodo::recurrence()const {
- return data->recur;
+ if (!data->recur) return ORecur();
+
+ return (*data->recur);
+}
+bool OTodo::hasMaintainer()const {
+ if (!data->maintainer) return false;
+
+ return (data->maintainer->mode() != OPimMaintainer::Undefined );
}
OPimMaintainer OTodo::maintainer()const {
- return data->maintainer;
+ if (!data->maintainer) return OPimMaintainer();
+
+ return (*data->maintainer);
}
void OTodo::setCompleted( bool completed )
{
changeOrModify();
data->isCompleted = completed;
}
void OTodo::setHasDueDate( bool hasDate )
{
changeOrModify();
data->hasDate = hasDate;
}
void OTodo::setDescription(const QString &desc )
{
// qWarning( "desc " + desc );
changeOrModify();
data->desc = Qtopia::simplifyMultiLineSpace(desc );
}
void OTodo::setSummary( const QString& sum )
{
changeOrModify();
data->sum = sum;
}
void OTodo::setPriority(int prio )
{
changeOrModify();
data->priority = prio;
}
void OTodo::setDueDate( const QDate& date )
{
changeOrModify();
data->date = date;
}
void OTodo::setStartDate( const QDate& date ) {
changeOrModify();
data->start = date;
}
void OTodo::setCompletedDate( const QDate& date ) {
changeOrModify();
data->completed = date;
}
void OTodo::setState( const OPimState& state ) {
changeOrModify();
- data->state = state;
+ if (data->state )
+ (*data->state) = state;
+ else
+ data->state = new OPimState( state );
}
void OTodo::setRecurrence( const ORecur& rec) {
changeOrModify();
- data->recur = rec;
+ if (data->recur )
+ (*data->recur) = rec;
+ else
+ data->recur = new ORecur( rec );
}
void OTodo::setMaintainer( const OPimMaintainer& pim ) {
changeOrModify();
- data->maintainer = pim;
+
+ if (data->maintainer )
+ (*data->maintainer) = pim;
+ else
+ data->maintainer = new OPimMaintainer( pim );
}
bool OTodo::isOverdue( )
{
if( data->hasDate && !data->isCompleted)
return QDate::currentDate() > data->date;
return false;
}
void OTodo::setProgress(ushort progress )
{
changeOrModify();
data->prog = progress;
}
QString OTodo::toShortText() const {
return summary();
}
/*!
Returns a richt text string
*/
QString OTodo::toRichText() const
{
QString text;
QStringList catlist;
// Description of the todo
if ( !summary().isEmpty() ) {
text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
}
if( !description().isEmpty() ){
text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ;
}
text += "<br><br><br>";
text += "<b>" + QObject::tr( "Priority:") +" </b>"
+ QString::number( priority() ) + " <br>";
text += "<b>" + QObject::tr( "Progress:") + " </b>"
+ QString::number( progress() ) + " %<br>";
if (hasDueDate() ){
text += "<b>" + QObject::tr( "Deadline:") + " </b>";
text += dueDate().toString();
text += "<br>";
}
text += "<b>" + QObject::tr( "Category:") + "</b> ";
text += categoryNames( "Todo List" ).join(", ");
text += "<br>";
return text;
}
+bool OTodo::hasNotifiers()const {
+ if (!data->notifiers) return false;
+ return data->notifiers->isEmpty();
+}
OPimNotifyManager& OTodo::notifiers() {
- return data->notifiers;
+ if (!data->notifiers )
+ data->notifiers = new OPimNotifyManager;
+ return (*data->notifiers);
}
bool OTodo::operator<( const OTodo &toDoEvent )const{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
if( hasDueDate() && toDoEvent.hasDueDate() ){
if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
return priority() < toDoEvent.priority();
}else{
return dueDate() < toDoEvent.dueDate();
}
}
return false;
}
bool OTodo::operator<=(const OTodo &toDoEvent )const
{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
if( hasDueDate() && toDoEvent.hasDueDate() ){
if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
return priority() <= toDoEvent.priority();
}else{
return dueDate() <= toDoEvent.dueDate();
}
}
return true;
}
bool OTodo::operator>(const OTodo &toDoEvent )const
{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
if( hasDueDate() && toDoEvent.hasDueDate() ){
if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
return priority() > toDoEvent.priority();
}else{
return dueDate() > toDoEvent.dueDate();
}
}
return false;
}
bool OTodo::operator>=(const OTodo &toDoEvent )const
{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
if( hasDueDate() && toDoEvent.hasDueDate() ){
if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
return priority() > toDoEvent.priority();
}else{
@@ -360,65 +402,74 @@ QMap<int, QString> OTodo::toMap() const {
map.insert( Completed, QString::number( data->isCompleted ) );
map.insert( Description, data->desc );
map.insert( Summary, data->sum );
map.insert( Priority, QString::number( data->priority ) );
map.insert( DateDay, QString::number( data->date.day() ) );
map.insert( DateMonth, QString::number( data->date.month() ) );
map.insert( DateYear, QString::number( data->date.year() ) );
map.insert( Progress, QString::number( data->prog ) );
// map.insert( CrossReference, crossToString() );
/* FIXME!!! map.insert( State, );
map.insert( Recurrence, );
map.insert( Reminders, );
map.
*/
return map;
}
QMap<QString, QString> OTodo::toExtraMap()const {
return data->extra;
}
/**
* change or modify looks at the ref count and either
* creates a new QShared Object or it can modify it
* right in place
*/
void OTodo::changeOrModify() {
if ( data->count != 1 ) {
qWarning("changeOrModify");
data->deref();
OTodoData* d2 = new OTodoData();
copy(data, d2 );
data = d2;
}
}
// WATCHOUT
/*
* if you add something to the Data struct
* be sure to copy it here
*/
void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->date = src->date;
dest->isCompleted = src->isCompleted;
dest->hasDate = src->hasDate;
dest->priority = src->priority;
dest->desc = src->desc;
dest->sum = src->sum;
dest->extra = src->extra;
dest->prog = src->prog;
- dest->state = src->state;
- dest->recur = src->recur;
- dest->maintainer = src->maintainer;
+
+ if (src->state )
+ dest->state = new OPimState( *src->state );
+
+ if (src->recur )
+ dest->recur = new ORecur( *src->recur );
+
+ if (src->maintainer )
+ dest->maintainer = new OPimMaintainer( *src->maintainer )
+ ;
dest->start = src->start;
dest->completed = src->completed;
- dest->notifiers = src->notifiers;
+
+ if (src->notifiers )
+ dest->notifiers = new OPimNotifyManager( *src->notifiers );
}
QString OTodo::type() const {
return QString::fromLatin1("OTodo");
}
QString OTodo::recordField(int /*id*/ )const {
return QString::null;
}
int OTodo::rtti(){
return OPimResolver::TodoList;
}
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index 2f66f55..a58d9aa 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -83,126 +83,142 @@ public:
/**
*destructor
*/
~OTodo();
/**
* Is this event completed?
*/
bool isCompleted() const;
/**
* Does this Event have a deadline
*/
bool hasDueDate() const;
bool hasStartDate()const;
bool hasCompletedDate()const;
/**
* Does this Event has an alarm time ?
*/
bool hasAlarmDateTime() const;
/**
* What is the priority?
*/
int priority()const ;
/**
* progress as ushort 0, 20, 40, 60, 80 or 100%
*/
ushort progress() const;
/**
* The due Date
*/
QDate dueDate()const;
/**
* When did it start?
*/
QDate startDate()const;
/**
* When was it completed?
*/
QDate completedDate()const;
/**
+ * does it have a state?
+ */
+ bool hasState()const;
+
+ /**
* What is the state of this OTodo?
*/
OPimState state()const;
/**
+ * has recurrence?
+ */
+ bool hasRecurrence()const;
+
+ /**
* the recurrance of this
*/
ORecur recurrence()const;
/**
+ * does this OTodo have a maintainer?
+ */
+ bool hasMaintainer()const;
+
+ /**
* the Maintainer of this OTodo
*/
OPimMaintainer maintainer()const;
/**
* The description of the todo
*/
QString description()const;
/**
* A small summary of the todo
*/
QString summary() const;
/**
* @reimplemented
* Return this todoevent in a RichText formatted QString
*/
QString toRichText() const;
+ bool hasNotifiers()const;
/*
* check if the sharing is still fine!! -zecke
*/
/**
* return a reference to our notifiers...
*/
OPimNotifyManager &notifiers();
/**
* reimplementations
*/
QString type()const;
QString toShortText()const;
QMap<QString, QString> toExtraMap()const;
QString recordField(int id )const;
/**
* toMap puts all data into the map. int relates
* to ToDoEvent RecordFields enum
*/
QMap<int, QString> toMap()const;
/**
* Set if this Todo is completed
*/
void setCompleted(bool completed );
/**
* set if this todo got an end data
*/
void setHasDueDate( bool hasDate );
// FIXME we do not have these for start, completed
// cause we'll use the isNull() of QDate for figuring
// out if it's has a date...
// decide what to do here? -zecke
/**
* Set the priority of the Todo
*/
void setPriority(int priority );
/**
* Set the progress.
*/
void setProgress( ushort progress );
/**
* set the end date