summaryrefslogtreecommitdiff
path: root/library/backend/task.cpp
Side-by-side diff
Diffstat (limited to 'library/backend/task.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/task.cpp173
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,5 +1,5 @@
/**********************************************************************
-** 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.
**
@@ -20,10 +20,12 @@
-#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>
@@ -33,2 +35,16 @@ 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 ),
@@ -39,2 +55,85 @@ 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 ),
@@ -53,3 +152,5 @@ mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc()
case TaskUid: setUid( (*it).toInt() ); break;
- default: break;
+ case TaskRid:
+ case TaskRinfo:
+ break;
}
@@ -57,2 +158,5 @@ mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc()
+/*!
+ Destroys a task.
+*/
Task::~Task()
@@ -61,2 +165,6 @@ Task::~Task()
+/*!
+ \internal
+ Returns the task as a map of field ids to property values.
+*/
QMap<int, QString> Task::toMap() const
@@ -66,6 +174,9 @@ QMap<int, QString> Task::toMap() const
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()) );
@@ -77,2 +188,6 @@ QMap<int, QString> Task::toMap() const
+/*!
+ \internal
+ Appends the task information to \a buf.
+*/
void Task::save( QString& buf ) const
@@ -119,3 +234,7 @@ 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 &regexp ) const
{
@@ -124,7 +243,7 @@ bool Task::match ( const QRegExp &r ) const
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;
@@ -133,2 +252,5 @@ bool Task::match ( const QRegExp &r ) const
+/*!
+ \internal
+*/
static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value )
@@ -141,2 +263,5 @@ static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QSt
+/*!
+ \internal
+*/
static inline VObject *safeAddProp( VObject *o, const char *prop)
@@ -150,2 +275,5 @@ static inline VObject *safeAddProp( VObject *o, const char *prop)
+/*!
+ \internal
+*/
static VObject *createVObject( const Task &t )
@@ -166,3 +294,5 @@ static VObject *createVObject( const Task &t )
-
+/*!
+ \internal
+*/
static Task parseVObject( VObject *obj )
@@ -209,3 +339,5 @@ 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)
@@ -228,2 +360,5 @@ 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)
@@ -243,3 +378,5 @@ 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 )