author | zecke <zecke> | 2003-05-07 16:02:41 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-05-07 16:02:41 (UTC) |
commit | accd04a63230ac46978f77deae1b0d1419618730 (patch) (side-by-side diff) | |
tree | 6a54ce4cdda8d86a781838b7b990939e2962d461 | |
parent | ef9b40f99443fabed972d29ce47c2ccb29e77210 (diff) | |
download | opie-accd04a63230ac46978f77deae1b0d1419618730.zip opie-accd04a63230ac46978f77deae1b0d1419618730.tar.gz opie-accd04a63230ac46978f77deae1b0d1419618730.tar.bz2 |
try to use less memory and only create objects like
ORecur, OPimState, OPimNotifyManager and OPimMaintainer if necessary
-rw-r--r-- | libopie/pim/otodo.cpp | 81 | ||||
-rw-r--r-- | libopie/pim/otodo.h | 16 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.cpp | 81 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.h | 16 |
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 @@ -24,4 +24,8 @@ struct OTodo::OTodoData : public QShared { OTodoData() : QShared() { + recur = 0; + state = 0; + maintainer = 0; + notifiers = 0; }; @@ -34,10 +38,10 @@ struct OTodo::OTodoData : public QShared { 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; }; @@ -152,12 +156,34 @@ 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 ) @@ -202,13 +228,23 @@ void OTodo::setCompletedDate( const QDate& 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( ) @@ -261,6 +297,12 @@ QString OTodo::toRichText() const 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); } @@ -406,10 +448,19 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) { 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 { 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 @@ -129,4 +129,9 @@ public: /** + * does it have a state? + */ + bool hasState()const; + + /** * What is the state of this OTodo? */ @@ -134,4 +139,9 @@ public: /** + * has recurrence? + */ + bool hasRecurrence()const; + + /** * the recurrance of this */ @@ -139,4 +149,9 @@ public: /** + * does this OTodo have a maintainer? + */ + bool hasMaintainer()const; + + /** * the Maintainer of this OTodo */ @@ -159,4 +174,5 @@ public: QString toRichText() const; + bool hasNotifiers()const; /* * check if the sharing is still fine!! -zecke 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 @@ -24,4 +24,8 @@ struct OTodo::OTodoData : public QShared { OTodoData() : QShared() { + recur = 0; + state = 0; + maintainer = 0; + notifiers = 0; }; @@ -34,10 +38,10 @@ struct OTodo::OTodoData : public QShared { 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; }; @@ -152,12 +156,34 @@ 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 ) @@ -202,13 +228,23 @@ void OTodo::setCompletedDate( const QDate& 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( ) @@ -261,6 +297,12 @@ QString OTodo::toRichText() const 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); } @@ -406,10 +448,19 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) { 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 { 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 @@ -129,4 +129,9 @@ public: /** + * does it have a state? + */ + bool hasState()const; + + /** * What is the state of this OTodo? */ @@ -134,4 +139,9 @@ public: /** + * has recurrence? + */ + bool hasRecurrence()const; + + /** * the recurrance of this */ @@ -139,4 +149,9 @@ public: /** + * does this OTodo have a maintainer? + */ + bool hasMaintainer()const; + + /** * the Maintainer of this OTodo */ @@ -159,4 +174,5 @@ public: QString toRichText() const; + bool hasNotifiers()const; /* * check if the sharing is still fine!! -zecke |