summaryrefslogtreecommitdiff
path: root/libopie/pim/otodo.h
blob: 75af44cfc687e1a1bf53fd8c967e282282c14d9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219

#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<OTodo> 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 = 0 /*empty*/ );

    OTodo( bool completed, int priority,
           const QArray<int>& category,
           const QString& summary = QString::null,
           const QString& description = QString::null,
           ushort progress = 0,
           bool hasDate = false,  QDate date = QDate::currentDate(),
           int uid = 0 /* empty */ );

    /* 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;

    /**
     * reimplementation
     */
    QString type()const;
    QString toShortText()const;
    QMap<QString, QString> toExtraMap()const;
    QString recordField(int id )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;
    OTodo &operator=(const OTodo &toDoEvent );

 private:
    class OTodoPrivate;
    struct OTodoData;

    void deref();
    void changeOrModify();
    void copy( OTodoData* src, OTodoData* dest );
    OTodoPrivate *d;
    OTodoData *data;

};
inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
    return !(*this == toDoEvent);
}


#endif