-rw-r--r-- | library/backend/task.cpp | 173 |
1 files changed, 155 insertions, 18 deletions
diff --git a/library/backend/task.cpp b/library/backend/task.cpp index f0a38f1..a00adb3 100644 --- a/library/backend/task.cpp +++ b/library/backend/task.cpp @@ -1,6 +1,6 @@ /********************************************************************** -** Copyright (C) 2001 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the @@ -19,12 +19,14 @@ **********************************************************************/ -#include <qpe/task.h> -#include <qregexp.h> -#include <qstring.h> -#include <qpe/recordfields.h> +#include "task.h" +#include "recordfields.h" #include "vobject_p.h" -#include "timeconversion.h" #include "qfiledirect_p.h" +#include <qtopia/timeconversion.h> + +#include <qregexp.h> +#include <qstring.h> + #include <stdio.h> @@ -32,4 +34,18 @@ using namespace Qtopia; UidGen Task::sUidGen( UidGen::Qtopia ); +/*! + \class Task + \brief The Task class holds the data of a todo entry. + + This data includes the priority of the task, a description, an optional due + date, and whether the task is completed or not. + + \ingroup qtopiaemb + \ingroup qtopiadesktop +*/ + +/*! + Creates a new, empty task. +*/ Task::Task() : Record(), mDue( FALSE ), mDueDate( QDate::currentDate() ), @@ -38,4 +54,87 @@ mCompleted( FALSE ), mPriority( 3 ), mDesc() } +/*! + \fn void Task::setPriority( int priority ) + + Sets the priority of the task to \a priority. +*/ + +/*! + \fn int Task::priority() const + + Returns the priority of the task. +*/ + +/*! + \fn void Task::setDescription( const QString &description ) + + Sets the description of the task to \a description. + */ + +/*! + \fn const QString &Task::description() const + + Returns the description of the task. + */ + +/*! + \fn void Task::setDueDate( const QDate &date, bool hasDue ) + + \internal + If \a hasDue is TRUE sets the due date of the task to \a date. + Otherwise clears the due date of the task. +*/ + +/*! + \fn void Task::setDueDate( const QDate &date ) + + Sets the due date of the task to \a date. +*/ + +/*! + \fn void Task::clearDueDate( ) + + Clears the due date of the task. +*/ + +/*! + \fn void Task::setCompleted( bool b ) + + If \a b is TRUE marks the task as completed. Otherwise marks the task as + uncompleted. +*/ + +/*! + \fn bool Task::isCompleted() const + + Returns TRUE if the task is completed. Otherwise returns FALSE. +*/ + +/*! + \fn const QDate &Task::dueDate() const + + Returns the due date of the task. + */ + +/*! + \fn bool Task::hasDueDate() const + + Returns TRUE if there is a due date set for the task. Otherwise returns + FALSE. +*/ + +/*! + \fn void Task::setHasDueDate( bool b ) + + \internal + Just don't ask. I really can't justify the function. +*/ + + +/*! + \internal + Creates a new task. The properties of the task are set from \a m. +*/ + Task::Task( const QMap<int, QString> &m ) : Record(), mDue( FALSE ), mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc() @@ -52,12 +151,21 @@ mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc() case Date: mDueDate = TimeConversion::fromString( (*it) ); break; case TaskUid: setUid( (*it).toInt() ); break; - default: break; + case TaskRid: + case TaskRinfo: + break; } } +/*! + Destroys a task. +*/ Task::~Task() { } +/*! + \internal + Returns the task as a map of field ids to property values. +*/ QMap<int, QString> Task::toMap() const { @@ -65,8 +173,11 @@ QMap<int, QString> Task::toMap() const m.insert( HasDate, hasDueDate() ? "1" : "0" ); m.insert( Completed, isCompleted() ? "1" : "0" ); - m.insert( TaskCategory, idsToString( categories() ) ); - m.insert( TaskDescription, description() ); + if ( categories().count() ) + m.insert( TaskCategory, idsToString( categories() ) ); + if ( !description().isEmpty() ) + m.insert( TaskDescription, description() ); m.insert( Priority, QString::number( priority() ) ); - m.insert( Date, TimeConversion::toString( dueDate() ) ); + if ( hasDueDate() ) + m.insert( Date, TimeConversion::toString( dueDate() ) ); m.insert( TaskUid, QString::number(uid()) ); @@ -76,4 +187,8 @@ QMap<int, QString> Task::toMap() const } +/*! + \internal + Appends the task information to \a buf. +*/ void Task::save( QString& buf ) const { @@ -118,18 +233,25 @@ void Task::save( QString& buf ) const } -bool Task::match ( const QRegExp &r ) const +/*! + Returns TRUE if the task matches the regular expressions \a regexp. + Otherwise returns FALSE. +*/ +bool Task::match ( const QRegExp ®exp ) const { // match on priority, description on due date... bool match; match = false; - if ( QString::number( mPriority ).find( r ) > -1 ) + if ( QString::number( mPriority ).find( regexp ) > -1 ) match = true; - else if ( mDue && mDueDate.toString().find( r ) > -1 ) + else if ( mDue && mDueDate.toString().find( regexp ) > -1 ) match = true; - else if ( mDesc.find( r ) > -1 ) + else if ( mDesc.find( regexp ) > -1 ) match = true; return match; } +/*! + \internal +*/ static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) { @@ -140,4 +262,7 @@ static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QSt } +/*! + \internal +*/ static inline VObject *safeAddProp( VObject *o, const char *prop) { @@ -149,4 +274,7 @@ static inline VObject *safeAddProp( VObject *o, const char *prop) +/*! + \internal +*/ static VObject *createVObject( const Task &t ) { @@ -165,5 +293,7 @@ static VObject *createVObject( const Task &t ) } - +/*! + \internal +*/ static Task parseVObject( VObject *obj ) { @@ -208,5 +338,7 @@ static Task parseVObject( VObject *obj ) - +/*! + Writes the list of \a tasks as a set of VCards to the file \a filename. +*/ void Task::writeVCalendar( const QString &filename, const QValueList<Task> &tasks) { @@ -227,4 +359,7 @@ void Task::writeVCalendar( const QString &filename, const QValueList<Task> &task } +/*! + Writes \a task as a VCard to the file \a filename. +*/ void Task::writeVCalendar( const QString &filename, const Task &task) { @@ -242,5 +377,7 @@ void Task::writeVCalendar( const QString &filename, const Task &task) } - +/*! + Returns the set of tasks read as VCards from the file \a filename. +*/ QValueList<Task> Task::readVCalendar( const QString &filename ) { |