author | zecke <zecke> | 2002-09-20 12:59:29 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-20 12:59:29 (UTC) |
commit | a05c10c9744020be31c3038b2de3401b5cc673fb (patch) (side-by-side diff) | |
tree | 20d059bf00fc1199c34a60a8be4cb842ebfe4d14 /libopie/pim/otodo.h | |
parent | 7099778ab711f78cfd86dadad1b8af993e008f38 (diff) | |
download | opie-a05c10c9744020be31c3038b2de3401b5cc673fb.zip opie-a05c10c9744020be31c3038b2de3401b5cc673fb.tar.gz opie-a05c10c9744020be31c3038b2de3401b5cc673fb.tar.bz2 |
Our new common template based start for Accessing and Manipulating
the Records
The CROSS_REFERENCE branch will get ported to it.
We use templates for several reasons
They allow us to share code and to be easily extended
I've to make them not inline to save memory...
I've to port all DBs and Record related classes
-rw-r--r-- | libopie/pim/otodo.h | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h new file mode 100644 index 0000000..429108a --- a/dev/null +++ b/libopie/pim/otodo.h @@ -0,0 +1,205 @@ + +#ifndef OPIE_TODO_EVENT_H +#define OPIE_TODO_EVENT_H + + +#include <qarray.h> +#include <qmap.h> +#include <qregexp.h> +#include <qstringlist.h> +#include <qdatetime.h> +#include <qvaluelist.h> + +#include <qpe/recordfields.h> +#include <qpe/palmtopuidgen.h> + +#include <opie/opimrecord.h> + + +class OTodo : public OPimRecord { +public: + typedef QValueList<ToDoEvent> ValueList; + enum RecordFields { + Uid = Qtopia::UID_ID, + Category = Qtopia::CATEGORY_ID, + HasDate, + Completed, + Description, + Summary, + Priority, + DateDay, + DateMonth, + DateYear, + Progress, + CrossReference, + HasAlarmDateTime, + AlarmDateTime + }; + public: + // priorities from Very low to very high + enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; + + /* Constructs a new ToDoEvent + @param completed Is the TodoEvent completed + @param priority What is the priority of this ToDoEvent + @param category Which category does it belong( uid ) + @param summary A small summary of the todo + @param description What is this ToDoEvent about + @param hasDate Does this Event got a deadline + @param date what is the deadline? + @param uid what is the UUID of this Event + **/ + OTodo( bool completed = false, int priority = Normal, + const QStringList &category = QStringList(), + const QString &summary = QString::null , + const QString &description = QString::null, + ushort progress = 0, + bool hasDate = false, QDate date = QDate::currentDate(), + int uid = -1 ); + + /* Copy c'tor + + **/ + OTodo(const OTodo & ); + + /** + *destructor + */ + ~OTodo(); + + /** + * Is this event completed? + */ + bool isCompleted() const; + + /** + * Does this Event have a deadline + */ + bool hasDueDate() const; + + /** + * Does this Event has an alarm time ? + */ + bool hasAlarmDateTime() const; + + /** + * What is the priority? + */ + int priority()const ; + + /** + * progress as ushort 0, 20, 40, 60, 80 or 100% + */ + ushort progress() const; + + /** + * The due Date + */ + QDate dueDate()const; + + /** + * Alarm Date and Time + */ + QDateTime alarmDateTime()const; + + /** + * The description of the todo + */ + QString description()const; + + /** + * A small summary of the todo + */ + QString summary() const; + + /** + * @reimplemented + * Return this todoevent in a RichText formatted QString + */ + QString toRichText() const; + + + /** + * returns a list of apps which have related items + */ + QStringList relatedApps()const; + + /** + * returns all relations for one app + */ + QArray<int> relations( const QString& app )const; + + /** + * toMap puts all data into the map. int relates + * to ToDoEvent RecordFields enum + */ + QMap<int, QString> toMap()const; + + /** + * Set if this Todo is completed + */ + void setCompleted(bool completed ); + + /** + * set if this todo got an end data + */ + void setHasDueDate( bool hasDate ); + + /** + * set if this todo has an alarm time and date + */ + void setHasAlarmDateTime ( bool hasAlarm ); + + /** + * Set the priority of the Todo + */ + void setPriority(int priority ); + + /** + * Set the progress. + */ + void setProgress( ushort progress ); + + /** + * set the end date + */ + void setDueDate( QDate date ); + + /** + * set the alarm time + */ + void setAlarmDateTime ( const QDateTime& alarm ); + + void setDescription(const QString& ); + void setSummary(const QString& ); + bool isOverdue(); + + + bool match( const QRegExp &r )const; + + bool operator<(const OTodo &toDoEvent )const; + bool operator<=(const OTodo &toDoEvent )const; + bool operator!=(const OTodo &toDoEvent )const; + bool operator>(const OTodo &toDoEvent )const; + bool operator>=(const OTodo &toDoEvent)const; + bool operator==(const OTodo &toDoEvent )const; + ToDoEvent &operator=(const OTodo &toDoEvent ); + + private: + class OTodoPrivate; + struct OTodoEventData; + + void deref(); + void changeOrModify(); + void copy( OTodoData* src, OTodoData* dest ); + ToDoEventPrivate *d; + ToDoEventData *data; + + static Qtopia::UidGen m_gen; +}; + inline bool ToDoEvent::operator!=(const ToDoEvent &toDoEvent )const { + return !(*this == toDoEvent); + } +}; + +#endif |