author | zecke <zecke> | 2002-06-15 16:46:37 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-15 16:46:37 (UTC) |
commit | ff47b17768607d8819ef5cd3316a1cab0abdcf3a (patch) (unidiff) | |
tree | addbc4d7d8826ce2952aca872e67e3575d77cda7 /libopie/todoevent.cpp | |
parent | 9f41969610f9db5d60d6080abae0b21e54a549e2 (diff) | |
download | opie-ff47b17768607d8819ef5cd3316a1cab0abdcf3a.zip opie-ff47b17768607d8819ef5cd3316a1cab0abdcf3a.tar.gz opie-ff47b17768607d8819ef5cd3316a1cab0abdcf3a.tar.bz2 |
Summary support
-rw-r--r-- | libopie/todoevent.cpp | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index aa348a2..fb7073c 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp | |||
@@ -1,240 +1,269 @@ | |||
1 | 1 | ||
2 | #include <opie/todoevent.h> | 2 | #include <opie/todoevent.h> |
3 | 3 | ||
4 | 4 | ||
5 | #include <qpe/palmtopuidgen.h> | 5 | #include <qpe/palmtopuidgen.h> |
6 | #include <qpe/stringutil.h> | 6 | #include <qpe/stringutil.h> |
7 | #include <qpe/palmtoprecord.h> | 7 | #include <qpe/palmtoprecord.h> |
8 | 8 | ||
9 | #include <qpe/stringutil.h> | 9 | #include <qpe/stringutil.h> |
10 | #include <qpe/categories.h> | 10 | #include <qpe/categories.h> |
11 | #include <qpe/categoryselect.h> | 11 | #include <qpe/categoryselect.h> |
12 | 12 | ||
13 | #include <qobject.h> | 13 | #include <qobject.h> |
14 | 14 | ||
15 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) | 15 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) |
16 | { | 16 | { |
17 | *this = event; | 17 | *this = event; |
18 | } | 18 | } |
19 | 19 | ||
20 | ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category, | 20 | ToDoEvent::ToDoEvent(bool completed, int priority, |
21 | const QString &description, bool hasDate, QDate date, int uid ) | 21 | const QStringList &category, |
22 | const QString& summary, | ||
23 | const QString &description, | ||
24 | bool hasDate, QDate date, int uid ) | ||
22 | { | 25 | { |
23 | m_date = date; | 26 | m_date = date; |
24 | m_isCompleted = completed; | 27 | m_isCompleted = completed; |
25 | m_hasDate = hasDate; | 28 | m_hasDate = hasDate; |
26 | m_priority = priority; | 29 | m_priority = priority; |
27 | m_category = category; | 30 | m_category = category; |
31 | m_sum = summary; | ||
28 | m_desc = Qtopia::simplifyMultiLineSpace(description ); | 32 | m_desc = Qtopia::simplifyMultiLineSpace(description ); |
29 | if (uid == -1 ) { | 33 | if (uid == -1 ) { |
30 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); | 34 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); |
31 | uid = uidgen->generate(); | 35 | uid = uidgen->generate(); |
32 | delete uidgen; | 36 | delete uidgen; |
33 | }// generate the ids | 37 | }// generate the ids |
34 | m_uid = uid; | 38 | m_uid = uid; |
35 | } | 39 | } |
36 | QArray<int> ToDoEvent::categories()const | 40 | QArray<int> ToDoEvent::categories()const |
37 | { | 41 | { |
38 | QArray<int> array(m_category.count() ); // currently the datebook can be only in one category | 42 | QArray<int> array(m_category.count() ); // currently the datebook can be only in one category |
39 | array = Qtopia::Record::idsFromString( m_category.join(";") ); | 43 | array = Qtopia::Record::idsFromString( m_category.join(";") ); |
40 | return array; | 44 | return array; |
41 | } | 45 | } |
42 | bool ToDoEvent::match( const QRegExp ®Exp )const | 46 | bool ToDoEvent::match( const QRegExp ®Exp )const |
43 | { | 47 | { |
44 | if( QString::number( m_priority ).find( regExp ) != -1 ){ | 48 | if( QString::number( m_priority ).find( regExp ) != -1 ){ |
45 | return true; | 49 | return true; |
46 | }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){ | 50 | }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){ |
47 | return true; | 51 | return true; |
48 | }else if(m_desc.find( regExp ) != -1 ){ | 52 | }else if(m_desc.find( regExp ) != -1 ){ |
49 | return true; | 53 | return true; |
50 | } | 54 | } |
51 | return false; | 55 | return false; |
52 | } | 56 | } |
53 | bool ToDoEvent::isCompleted() const | 57 | bool ToDoEvent::isCompleted() const |
54 | { | 58 | { |
55 | return m_isCompleted; | 59 | return m_isCompleted; |
56 | } | 60 | } |
57 | bool ToDoEvent::hasDate() const | 61 | bool ToDoEvent::hasDate() const |
58 | { | 62 | { |
59 | return m_hasDate; | 63 | return m_hasDate; |
60 | } | 64 | } |
61 | int ToDoEvent::priority()const | 65 | int ToDoEvent::priority()const |
62 | { | 66 | { |
63 | return m_priority; | 67 | return m_priority; |
64 | } | 68 | } |
65 | QStringList ToDoEvent::allCategories()const | 69 | QStringList ToDoEvent::allCategories()const |
66 | { | 70 | { |
67 | return m_category; | 71 | return m_category; |
68 | } | 72 | } |
73 | QString ToDoEvent::extra(const QString& )const | ||
74 | { | ||
75 | return QString::null; | ||
76 | } | ||
77 | QString ToDoEvent::summary() const | ||
78 | { | ||
79 | return m_sum; | ||
80 | } | ||
69 | void ToDoEvent::insertCategory(const QString &str ) | 81 | void ToDoEvent::insertCategory(const QString &str ) |
70 | { | 82 | { |
71 | m_category.append( str ); | 83 | m_category.append( str ); |
72 | } | 84 | } |
73 | void ToDoEvent::clearCategories() | 85 | void ToDoEvent::clearCategories() |
74 | { | 86 | { |
75 | m_category.clear(); | 87 | m_category.clear(); |
76 | } | 88 | } |
77 | void ToDoEvent::setCategories(const QStringList &list ) | 89 | void ToDoEvent::setCategories(const QStringList &list ) |
78 | { | 90 | { |
79 | m_category = list; | 91 | m_category = list; |
80 | } | 92 | } |
81 | QDate ToDoEvent::date()const | 93 | QDate ToDoEvent::date()const |
82 | { | 94 | { |
83 | return m_date; | 95 | return m_date; |
84 | } | 96 | } |
85 | 97 | ||
86 | QString ToDoEvent::description()const | 98 | QString ToDoEvent::description()const |
87 | { | 99 | { |
88 | return m_desc; | 100 | return m_desc; |
89 | } | 101 | } |
90 | void ToDoEvent::setCompleted( bool completed ) | 102 | void ToDoEvent::setCompleted( bool completed ) |
91 | { | 103 | { |
92 | m_isCompleted = completed; | 104 | m_isCompleted = completed; |
93 | } | 105 | } |
94 | void ToDoEvent::setHasDate( bool hasDate ) | 106 | void ToDoEvent::setHasDate( bool hasDate ) |
95 | { | 107 | { |
96 | m_hasDate = hasDate; | 108 | m_hasDate = hasDate; |
97 | } | 109 | } |
98 | void ToDoEvent::setDescription(const QString &desc ) | 110 | void ToDoEvent::setDescription(const QString &desc ) |
99 | { | 111 | { |
100 | m_desc = Qtopia::simplifyMultiLineSpace(desc ); | 112 | m_desc = Qtopia::simplifyMultiLineSpace(desc ); |
101 | } | 113 | } |
114 | void ToDoEvent::setExtra( const QString&, const QString& ) | ||
115 | { | ||
116 | |||
117 | } | ||
118 | void ToDoEvent::setSummary( const QString& sum ) | ||
119 | { | ||
120 | m_sum = sum; | ||
121 | } | ||
102 | void ToDoEvent::setCategory( const QString &cat ) | 122 | void ToDoEvent::setCategory( const QString &cat ) |
103 | { | 123 | { |
104 | qWarning("setCategory %s", cat.latin1() ); | 124 | qWarning("setCategory %s", cat.latin1() ); |
105 | m_category.clear(); | 125 | m_category.clear(); |
106 | m_category << cat; | 126 | m_category << cat; |
107 | } | 127 | } |
108 | void ToDoEvent::setPriority(int prio ) | 128 | void ToDoEvent::setPriority(int prio ) |
109 | { | 129 | { |
110 | m_priority = prio; | 130 | m_priority = prio; |
111 | } | 131 | } |
112 | void ToDoEvent::setDate( QDate date ) | 132 | void ToDoEvent::setDate( QDate date ) |
113 | { | 133 | { |
114 | m_date = date; | 134 | m_date = date; |
115 | } | 135 | } |
116 | bool ToDoEvent::isOverdue( ) | 136 | bool ToDoEvent::isOverdue( ) |
117 | { | 137 | { |
118 | if( m_hasDate ) | 138 | if( m_hasDate ) |
119 | return QDate::currentDate() > m_date; | 139 | return QDate::currentDate() > m_date; |
120 | return false; | 140 | return false; |
121 | } | 141 | } |
122 | 142 | ||
123 | /*! | 143 | /*! |
124 | Returns a richt text string | 144 | Returns a richt text string |
125 | */ | 145 | */ |
126 | QString ToDoEvent::richText() const | 146 | QString ToDoEvent::richText() const |
127 | { | 147 | { |
128 | QString text; | 148 | QString text; |
129 | QStringList catlist; | 149 | QStringList catlist; |
130 | 150 | ||
131 | // Description of the todo | 151 | // Description of the todo |
132 | if ( !description().isEmpty() ){ | 152 | if ( !description().isEmpty() ){ |
153 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; | ||
154 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
133 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 155 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
134 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 156 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
135 | } | 157 | } |
136 | text += "<b>" + QObject::tr( "Priority:") +" </b>" | 158 | text += "<b>" + QObject::tr( "Priority:") +" </b>" |
137 | + QString::number( priority() ) + "<br>"; | 159 | + QString::number( priority() ) + "<br>"; |
138 | if (hasDate() ){ | 160 | if (hasDate() ){ |
139 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; | 161 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; |
140 | text += date().toString(); | 162 | text += date().toString(); |
141 | text += "<br>"; | 163 | text += "<br>"; |
142 | } | 164 | } |
143 | 165 | ||
144 | // Open database of all categories and get the list of | 166 | // Open database of all categories and get the list of |
145 | // the categories this todoevent belongs to. | 167 | // the categories this todoevent belongs to. |
146 | // Then print them... | 168 | // Then print them... |
147 | // I am not sure whether there is no better way doing this !? | 169 | // I am not sure whether there is no better way doing this !? |
148 | Categories catdb; | 170 | Categories catdb; |
149 | bool firstloop = true; | 171 | bool firstloop = true; |
150 | catdb.load( categoryFileName() ); | 172 | catdb.load( categoryFileName() ); |
151 | catlist = allCategories(); | 173 | catlist = allCategories(); |
152 | 174 | ||
153 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 175 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
154 | for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { | 176 | for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { |
155 | if (!firstloop){ | 177 | if (!firstloop){ |
156 | text += ", "; | 178 | text += ", "; |
157 | } | 179 | } |
158 | firstloop = false; | 180 | firstloop = false; |
159 | text += catdb.label ("todo", (*it).toInt()); | 181 | text += catdb.label ("todo", (*it).toInt()); |
160 | } | 182 | } |
161 | text += "<br>"; | 183 | text += "<br>"; |
162 | return text; | 184 | return text; |
163 | } | 185 | } |
164 | 186 | ||
165 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ | 187 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ |
166 | if( !hasDate() && !toDoEvent.hasDate() ) return true; | 188 | if( !hasDate() && !toDoEvent.hasDate() ) return true; |
167 | if( !hasDate() && toDoEvent.hasDate() ) return true; | 189 | if( !hasDate() && toDoEvent.hasDate() ) return true; |
168 | if( hasDate() && toDoEvent.hasDate() ){ | 190 | if( hasDate() && toDoEvent.hasDate() ){ |
169 | if( date() == toDoEvent.date() ){ // let's the priority decide | 191 | if( date() == toDoEvent.date() ){ // let's the priority decide |
170 | return priority() < toDoEvent.priority(); | 192 | return priority() < toDoEvent.priority(); |
171 | }else{ | 193 | }else{ |
172 | return date() < toDoEvent.date(); | 194 | return date() < toDoEvent.date(); |
173 | } | 195 | } |
174 | } | 196 | } |
175 | return false; | 197 | return false; |
176 | } | 198 | } |
177 | bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const | 199 | bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const |
178 | { | 200 | { |
179 | if( !hasDate() && !toDoEvent.hasDate() ) return true; | 201 | if( !hasDate() && !toDoEvent.hasDate() ) return true; |
180 | if( !hasDate() && toDoEvent.hasDate() ) return true; | 202 | if( !hasDate() && toDoEvent.hasDate() ) return true; |
181 | if( hasDate() && toDoEvent.hasDate() ){ | 203 | if( hasDate() && toDoEvent.hasDate() ){ |
182 | if( date() == toDoEvent.date() ){ // let's the priority decide | 204 | if( date() == toDoEvent.date() ){ // let's the priority decide |
183 | return priority() <= toDoEvent.priority(); | 205 | return priority() <= toDoEvent.priority(); |
184 | }else{ | 206 | }else{ |
185 | return date() <= toDoEvent.date(); | 207 | return date() <= toDoEvent.date(); |
186 | } | 208 | } |
187 | } | 209 | } |
188 | return true; | 210 | return true; |
189 | } | 211 | } |
190 | bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const | 212 | bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const |
191 | { | 213 | { |
192 | if( !hasDate() && !toDoEvent.hasDate() ) return false; | 214 | if( !hasDate() && !toDoEvent.hasDate() ) return false; |
193 | if( !hasDate() && toDoEvent.hasDate() ) return false; | 215 | if( !hasDate() && toDoEvent.hasDate() ) return false; |
194 | if( hasDate() && toDoEvent.hasDate() ){ | 216 | if( hasDate() && toDoEvent.hasDate() ){ |
195 | if( date() == toDoEvent.date() ){ // let's the priority decide | 217 | if( date() == toDoEvent.date() ){ // let's the priority decide |
196 | return priority() > toDoEvent.priority(); | 218 | return priority() > toDoEvent.priority(); |
197 | }else{ | 219 | }else{ |
198 | return date() > toDoEvent.date(); | 220 | return date() > toDoEvent.date(); |
199 | } | 221 | } |
200 | } | 222 | } |
201 | return false; | 223 | return false; |
202 | } | 224 | } |
203 | bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const | 225 | bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const |
204 | { | 226 | { |
205 | if( !hasDate() && !toDoEvent.hasDate() ) return true; | 227 | if( !hasDate() && !toDoEvent.hasDate() ) return true; |
206 | if( !hasDate() && toDoEvent.hasDate() ) return false; | 228 | if( !hasDate() && toDoEvent.hasDate() ) return false; |
207 | if( hasDate() && toDoEvent.hasDate() ){ | 229 | if( hasDate() && toDoEvent.hasDate() ){ |
208 | if( date() == toDoEvent.date() ){ // let's the priority decide | 230 | if( date() == toDoEvent.date() ){ // let's the priority decide |
209 | return priority() > toDoEvent.priority(); | 231 | return priority() > toDoEvent.priority(); |
210 | }else{ | 232 | }else{ |
211 | return date() > toDoEvent.date(); | 233 | return date() > toDoEvent.date(); |
212 | } | 234 | } |
213 | } | 235 | } |
214 | return true; | 236 | return true; |
215 | } | 237 | } |
216 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const | 238 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const |
217 | { | 239 | { |
218 | if( m_date == toDoEvent.m_date && m_isCompleted == toDoEvent.m_isCompleted && m_hasDate == toDoEvent.m_hasDate && m_priority == toDoEvent.m_priority && m_category == toDoEvent.m_category && m_desc == toDoEvent.m_desc ) | 240 | if( m_priority == toDoEvent.m_priority && |
241 | m_isCompleted == toDoEvent.m_isCompleted && | ||
242 | m_hasDate == toDoEvent.m_hasDate && | ||
243 | m_date == toDoEvent.m_date && | ||
244 | m_category == toDoEvent.m_category && | ||
245 | m_sum == toDoEvent.m_sum && | ||
246 | m_desc == toDoEvent.m_desc ) | ||
219 | return true; | 247 | return true; |
220 | return false; | 248 | return false; |
221 | } | 249 | } |
222 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) | 250 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) |
223 | { | 251 | { |
224 | m_date = item.m_date; | 252 | m_date = item.m_date; |
225 | m_isCompleted = item.m_isCompleted; | 253 | m_isCompleted = item.m_isCompleted; |
226 | m_hasDate = item.m_hasDate; | 254 | m_hasDate = item.m_hasDate; |
227 | m_priority = item.m_priority; | 255 | m_priority = item.m_priority; |
228 | m_category = item.m_category; | 256 | m_category = item.m_category; |
229 | m_desc = item.m_desc; | 257 | m_desc = item.m_desc; |
230 | m_uid = item.m_uid; | 258 | m_uid = item.m_uid; |
259 | m_sum = item.m_sum; | ||
231 | return *this; | 260 | return *this; |
232 | } | 261 | } |
233 | 262 | ||
234 | 263 | ||
235 | 264 | ||
236 | 265 | ||
237 | 266 | ||
238 | 267 | ||
239 | 268 | ||
240 | 269 | ||