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 @@ -65,4 +65,5 @@ struct OPimTodo::OPimTodoData : public QShared delete maintainer; delete notifiers; + delete state; } @@ -88,5 +89,4 @@ OPimTodo::OPimTodo( const OPimTodo &event ) { data->ref(); - // owarn << "ref up" << oendl; } @@ -95,8 +95,6 @@ OPimTodo::~OPimTodo() { - // owarn << "~OPimTodo " << oendl; if ( data->deref() ) { - // owarn << "OPimTodo::dereffing" << oendl; delete data; data = 0l; @@ -113,5 +111,4 @@ OPimTodo::OPimTodo( bool completed, int priority, : OPimRecord( uid ) { - // owarn << "OPimTodoData " + summary << oendl; setCategories( category ); @@ -136,5 +133,4 @@ OPimTodo::OPimTodo( bool completed, int priority, : OPimRecord( uid ) { - // owarn << "OPimTodoData" + summary << oendl; setCategories( idsFromString( category.join( ";" ) ) ); @@ -188,5 +184,16 @@ 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 { @@ -194,5 +201,14 @@ 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 { @@ -309,5 +325,4 @@ void OPimTodo::setHasDueDate( bool hasDate ) void OPimTodo::setDescription( const QString &desc ) { - // owarn << "desc " + desc << oendl; changeOrModify(); data->desc = Qtopia::simplifyMultiLineSpace( desc ); @@ -381,5 +396,5 @@ void OPimTodo::setMaintainer( const OPimMaintainer& pim ) -bool OPimTodo::isOverdue( ) +bool OPimTodo::isOverdue( )const { if ( data->hasDate && !data->isCompleted ) @@ -594,8 +609,6 @@ void OPimTodo::deref() { - // owarn << "deref in ToDoEvent" << oendl; if ( data->deref() ) { - // owarn << "deleting" << oendl; delete data; data = 0; @@ -609,5 +622,4 @@ OPimTodo &OPimTodo::operator=( const OPimTodo &item ) OPimRecord::operator=( item ); - //owarn << "operator= ref " << oendl; item.data->ref(); deref(); @@ -652,5 +664,4 @@ void OPimTodo::changeOrModify() if ( data->count != 1 ) { - owarn << "changeOrModify" << oendl; data->deref(); OPimTodoData* d2 = new OPimTodoData(); @@ -700,7 +711,76 @@ 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; } @@ -711,3 +791,20 @@ 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; +} + } |