Diffstat (limited to 'libopie2/opiepim/core/opimtodo.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimtodo.cpp | 127 |
1 files changed, 112 insertions, 15 deletions
diff --git a/libopie2/opiepim/core/opimtodo.cpp b/libopie2/opiepim/core/opimtodo.cpp index 27b36a6..16ca987 100644 --- a/libopie2/opiepim/core/opimtodo.cpp +++ b/libopie2/opiepim/core/opimtodo.cpp @@ -66,2 +66,3 @@ struct OPimTodo::OPimTodoData : public QShared delete notifiers; + delete state; } @@ -89,3 +90,2 @@ OPimTodo::OPimTodo( const OPimTodo &event ) data->ref(); - // owarn << "ref up" << oendl; } @@ -96,6 +96,4 @@ OPimTodo::~OPimTodo() - // owarn << "~OPimTodo " << oendl; if ( data->deref() ) { - // owarn << "OPimTodo::dereffing" << oendl; delete data; @@ -114,3 +112,2 @@ OPimTodo::OPimTodo( bool completed, int priority, { - // owarn << "OPimTodoData " + summary << oendl; setCategories( category ); @@ -137,3 +134,2 @@ OPimTodo::OPimTodo( bool completed, int priority, { - // owarn << "OPimTodoData" + summary << oendl; setCategories( idsFromString( category.join( ";" ) ) ); @@ -189,3 +185,14 @@ bool OPimTodo::hasDueDate() const - +/** + * \brief Does this Todo have a start date + * + * Does this Todo have a start date. The decision + * is based on if the internal startDate isValid + * in the sense of QDate::isValid. + * + * @return True if the startDate isValid + * @see startDate + * @see setStartDate + * @see QDate::isValid() + */ bool OPimTodo::hasStartDate() const @@ -195,3 +202,12 @@ bool OPimTodo::hasStartDate() const - +/** + * \brief Does this Todo have a Date when it was completed + * + * As in \sa hasStartDate() it is determined if there + * is a completed date by looking if the internal date + * isValid \sa QDate::isValid. + * + * @see hasStartDate + * @return True if the completedDate is set and valid. + */ bool OPimTodo::hasCompletedDate() const @@ -310,3 +326,2 @@ void OPimTodo::setDescription( const QString &desc ) { - // owarn << "desc " + desc << oendl; changeOrModify(); @@ -382,3 +397,3 @@ void OPimTodo::setMaintainer( const OPimMaintainer& pim ) -bool OPimTodo::isOverdue( ) +bool OPimTodo::isOverdue( )const { @@ -595,6 +610,4 @@ void OPimTodo::deref() - // owarn << "deref in ToDoEvent" << oendl; if ( data->deref() ) { - // owarn << "deleting" << oendl; delete data; @@ -610,3 +623,2 @@ OPimTodo &OPimTodo::operator=( const OPimTodo &item ) OPimRecord::operator=( item ); - //owarn << "operator= ref " << oendl; item.data->ref(); @@ -653,3 +665,2 @@ void OPimTodo::changeOrModify() { - owarn << "changeOrModify" << oendl; data->deref(); @@ -701,5 +712,74 @@ QString OPimTodo::type() const -QString OPimTodo::recordField( int /*id*/ ) const +QString OPimTodo::recordField( int id) const { - return QString::null; + QString res; + Q_UNUSED( id ) +#if 0 + switch( id ) { + case HasDate: + res = (hasDueDate() ? + QObject::tr( "Has a due-date" ) + : QObject::tr( "No due-date" )); + break; + case Completed: + res = ( isCompleted() ? + QObject::tr( "Completed" ) : + QObject::tr( "Not completed" )); + break; + case Description: + res = description(); + break; + case Summary: + res = summary(); + break; + case Priority: + res = QString::number( priority() ); + break; + case DateDay: + res = QString::number( dueDate().day() ); + break; + case DateMonth: + res = QString::number( dueDate().month() ); + break; + case DateYear: + res = QString::number( dueDate().year() ); + break; + case Progress: + res = QString::number( progress() ); + break; + case State: + res = QString::number( state().state() ); + break; + case Recurrence: + res = ( hasRecurrence() ? + QString::null /*recurrence().summary()*/ : + QObject::tr("No reccurrence")); + break; + case Alarms: + break; + case Reminders: + break; + case Maintainer: + break; + case StartDate: + res = ( hasStartDate() ? + /*TimeString::()*/ QString::null : + QObject::tr( "No start-date" ) ); + break; + case CompletedDate: + res = ( hasCompletedDate() ? + /*TimeString::()*/ QString::null : + QObject::tr( "No completed-date" ) ); + break; + case DueDate: + res = ( hasDueDate() ? + /*TimeString::()*/ QString::null : + QObject::tr( "No due-date" ); + break; + default: + res = OPimRecord::recordField( id ); + } + +#endif + return res; } @@ -712,2 +792,19 @@ int OPimTodo::rtti() const +/** + * \brief Provide a SafeCast to OPimTodo from a OPimRecord + * + * Provide a safe cast that will return 0 if the record + * type is not OPimTodo. In the other case it will + * be casted to OPimTodo and returned + * + * @param rec The OPimRecord to be casted + * + * @return a pointer to OPimTodo or 0l + */ +OPimTodo* OPimTodo::safeCast( const OPimRecord* rec ) { + return (rec && rec->rtti() == OPimResolver::TodoList ) ? + static_cast<OPimTodo*>( const_cast<OPimRecord*>(rec) ) : + 0l; +} + } |