author | bipolar <bipolar> | 2002-03-08 03:17:37 (UTC) |
---|---|---|
committer | bipolar <bipolar> | 2002-03-08 03:17:37 (UTC) |
commit | 5bb6c01c2a9a40e5bff20a2725f6aacf85d16ef3 (patch) (unidiff) | |
tree | 4d40fb06ae37c1420723529e5f75bb7c41ae8c00 /core | |
parent | 11b56113b6641e0b85c6015eafab802dd7663198 (diff) | |
download | opie-5bb6c01c2a9a40e5bff20a2725f6aacf85d16ef3.zip opie-5bb6c01c2a9a40e5bff20a2725f6aacf85d16ef3.tar.gz opie-5bb6c01c2a9a40e5bff20a2725f6aacf85d16ef3.tar.bz2 |
ljp: fixed QString problem
-rw-r--r-- | core/pim/today/today.cpp | 165 |
1 files changed, 83 insertions, 82 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 0fa7ad5..af1d4e4 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -85,25 +85,26 @@ void Today::autoStart() { | |||
85 | 85 | ||
86 | void Today::draw() { | 86 | void Today::draw() { |
87 | init(); | 87 | init(); |
88 | getDates(); | 88 | getDates(); |
89 | getMail(); | 89 | getMail(); |
90 | getTodo(); | 90 | getTodo(); |
91 | // how often refresh | 91 | // how often refresh |
92 | QTimer::singleShot( 5*1000, this, SLOT(draw()) ); | 92 | QTimer::singleShot( 5*1000, this, SLOT(draw()) ); |
93 | } | 93 | } |
94 | 94 | ||
95 | void Today::init() { | 95 | void Today::init() { |
96 | QDate date = QDate::currentDate(); | 96 | QDate date = QDate::currentDate(); |
97 | QString time = (tr( date.toString() ), white); | 97 | QString time = (tr( date.toString()) ); |
98 | // QString time = (tr( date.toString()) , white); | ||
98 | 99 | ||
99 | TextLabel1->setText(time); | 100 | TextLabel1->setText(time); |
100 | db = new DateBookDB; | 101 | db = new DateBookDB; |
101 | 102 | ||
102 | // read config | 103 | // read config |
103 | Config cfg("today"); | 104 | Config cfg("today"); |
104 | cfg.setGroup("BaseConfig"); | 105 | cfg.setGroup("BaseConfig"); |
105 | 106 | ||
106 | // how many lines should be showed in the task section | 107 | // how many lines should be showed in the task section |
107 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); | 108 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); |
108 | // after how many chars should the be cut off on tasks and notes | 109 | // after how many chars should the be cut off on tasks and notes |
109 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30); | 110 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30); |
@@ -177,82 +178,82 @@ void Today::getDates() { | |||
177 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); | 178 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); |
178 | 179 | ||
179 | Config config( "qpe" ); | 180 | Config config( "qpe" ); |
180 | // if 24 h format | 181 | // if 24 h format |
181 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); | 182 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); |
182 | 183 | ||
183 | int count=0; | 184 | int count=0; |
184 | 185 | ||
185 | if ( list.count() > 0 ) { | 186 | if ( list.count() > 0 ) { |
186 | QString msg; | 187 | QString msg; |
187 | 188 | ||
188 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 189 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); |
189 | it!=list.end(); ++it ) { | 190 | it!=list.end(); ++it ) { |
190 | 191 | ||
191 | count++; | 192 | count++; |
192 | 193 | ||
193 | if ( count <= MAX_LINES_MEET ) { | 194 | if ( count <= MAX_LINES_MEET ) { |
194 | //cout << time.toString() << endl; | 195 | //cout << time.toString() << endl; |
195 | //cout << TimeString::dateString((*it).event().end()) << endl; | 196 | //cout << TimeString::dateString((*it).event().end()) << endl; |
196 | 197 | ||
197 | // decide if to get all day or only later appointments | 198 | // decide if to get all day or only later appointments |
198 | if (!ONLY_LATER) { | 199 | if (!ONLY_LATER) { |
199 | msg += "<B>" + (*it).description() + "</B>"; | 200 | msg += "<B>" + (*it).description() + "</B>"; |
200 | if ( (*it).event().hasAlarm() ) { | 201 | if ( (*it).event().hasAlarm() ) { |
201 | msg += " <b>[with alarm]</b>"; | 202 | msg += " <b>[with alarm]</b>"; |
202 | } | 203 | } |
203 | // include location or not | 204 | // include location or not |
204 | if (SHOW_LOCATION == 1) { | 205 | if (SHOW_LOCATION == 1) { |
205 | msg += "<BR><i>" + (*it).location(); | 206 | msg += "<BR><i>" + (*it).location(); |
206 | msg += "</i>"; | 207 | msg += "</i>"; |
207 | } | 208 | } |
208 | 209 | ||
209 | if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) { | 210 | if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) { |
210 | msg += "<br>All day"; | 211 | msg += "<br>All day"; |
211 | } else { | 212 | } else { |
212 | // start time of event | 213 | // start time of event |
213 | msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) ) | 214 | msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) ) |
214 | // end time of event | 215 | // end time of event |
215 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ); | 216 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ); |
216 | } | 217 | } |
217 | msg += "<BR>"; | 218 | msg += "<BR>"; |
218 | // include possible note or not | 219 | // include possible note or not |
219 | if (SHOW_NOTES == 1) { | 220 | if (SHOW_NOTES == 1) { |
220 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 221 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
221 | } | 222 | } |
222 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { | 223 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { |
223 | msg += "<B>" + (*it).description() + "</B>"; | 224 | msg += "<B>" + (*it).description() + "</B>"; |
224 | if ( (*it).event().hasAlarm() ) { | 225 | if ( (*it).event().hasAlarm() ) { |
225 | msg += " <b>[with alarm]</b>"; | 226 | msg += " <b>[with alarm]</b>"; |
226 | } | 227 | } |
227 | // include location or not | 228 | // include location or not |
228 | if (SHOW_LOCATION == 1) { | 229 | if (SHOW_LOCATION == 1) { |
229 | msg+= "<BR><i>" + (*it).location(); | 230 | msg+= "<BR><i>" + (*it).location(); |
230 | msg += "</i>"; | 231 | msg += "</i>"; |
231 | } | 232 | } |
232 | 233 | ||
233 | if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) { | 234 | if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) { |
234 | msg += "<br>All day"; | 235 | msg += "<br>All day"; |
235 | } else { | 236 | } else { |
236 | // start time of event | 237 | // start time of event |
237 | msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) ) | 238 | msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) ) |
238 | // end time of event | 239 | // end time of event |
239 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ); | 240 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ); |
240 | } | 241 | } |
241 | msg += "<BR>"; | 242 | msg += "<BR>"; |
242 | // include possible note or not | 243 | // include possible note or not |
243 | if (SHOW_NOTES == 1) { | 244 | if (SHOW_NOTES == 1) { |
244 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 245 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
245 | } | 246 | } |
246 | } | 247 | } |
247 | } | 248 | } |
248 | } | 249 | } |
249 | if (msg.isEmpty()) { | 250 | if (msg.isEmpty()) { |
250 | msg = tr("No more appointments today"); | 251 | msg = tr("No more appointments today"); |
251 | } | 252 | } |
252 | DatesField->setText(msg); | 253 | DatesField->setText(msg); |
253 | } | 254 | } |
254 | } | 255 | } |
255 | 256 | ||
256 | /* | 257 | /* |
257 | * Parse in the todolist.xml | 258 | * Parse in the todolist.xml |
258 | */ | 259 | */ |
@@ -273,49 +274,49 @@ QList<TodoItem> Today::loadTodo(const char *filename) { | |||
273 | tasks = todo->el; | 274 | tasks = todo->el; |
274 | tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ | 275 | tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ |
275 | if(tasks) { | 276 | if(tasks) { |
276 | tasklist = tasks->el; | 277 | tasklist = tasks->el; |
277 | i = 0; | 278 | i = 0; |
278 | while((tasklist) && (tasklist[i])) { | 279 | while((tasklist) && (tasklist[i])) { |
279 | attlist = tasklist[i]->at; | 280 | attlist = tasklist[i]->at; |
280 | j = 0; | 281 | j = 0; |
281 | description = NULL; | 282 | description = NULL; |
282 | priority = -1; | 283 | priority = -1; |
283 | completed = -1; | 284 | completed = -1; |
284 | while((attlist) && (attlist[j])) { | 285 | while((attlist) && (attlist[j])) { |
285 | if(!attlist[j]->name) { | 286 | if(!attlist[j]->name) { |
286 | continue; | 287 | continue; |
287 | } | 288 | } |
288 | if(!strcmp(attlist[j]->name, "Description")) { | 289 | if(!strcmp(attlist[j]->name, "Description")) { |
289 | description = attlist[j]->value; | 290 | description = attlist[j]->value; |
290 | } | 291 | } |
291 | // get Completed tag (0 or 1) | 292 | // get Completed tag (0 or 1) |
292 | if(!strcmp(attlist[j]->name, "Completed")) { | 293 | if(!strcmp(attlist[j]->name, "Completed")) { |
293 | QString s = attlist[j]->name; | 294 | QString s = attlist[j]->name; |
294 | if(s == "Completed") { | 295 | if(s == "Completed") { |
295 | completed = QString(attlist[j]->value).toInt(); | 296 | completed = QString(attlist[j]->value).toInt(); |
296 | } | 297 | } |
297 | } | 298 | } |
298 | // get Priority (1 to 5) | 299 | // get Priority (1 to 5) |
299 | if(!strcmp(attlist[j]->name, "Priority")) { | 300 | if(!strcmp(attlist[j]->name, "Priority")) { |
300 | QString s = attlist[j]->name; | 301 | QString s = attlist[j]->name; |
301 | if(s == "Priority") { | 302 | if(s == "Priority") { |
302 | priority = QString(attlist[j]->value).toInt(); | 303 | priority = QString(attlist[j]->value).toInt(); |
303 | } | 304 | } |
304 | } | 305 | } |
305 | j++; | 306 | j++; |
306 | } | 307 | } |
307 | if(description) { | 308 | if(description) { |
308 | tmp = new TodoItem(description, completed, priority); | 309 | tmp = new TodoItem(description, completed, priority); |
309 | loadtodolist.append(tmp); | 310 | loadtodolist.append(tmp); |
310 | } | 311 | } |
311 | i++; | 312 | i++; |
312 | } | 313 | } |
313 | } | 314 | } |
314 | 315 | ||
315 | minidom_free(todo); | 316 | minidom_free(todo); |
316 | 317 | ||
317 | return loadtodolist; | 318 | return loadtodolist; |
318 | } | 319 | } |
319 | 320 | ||
320 | 321 | ||
321 | void Today::getMail() { | 322 | void Today::getMail() { |
@@ -344,28 +345,28 @@ void Today::getTodo() { | |||
344 | int count = 0; | 345 | int count = 0; |
345 | 346 | ||
346 | QDir dir; | 347 | QDir dir; |
347 | QString homedir = dir.homeDirPath (); | 348 | QString homedir = dir.homeDirPath (); |
348 | // see if todolist.xml does exist. | 349 | // see if todolist.xml does exist. |
349 | QFile f(homedir +"/Applications/todolist/todolist.xml"); | 350 | QFile f(homedir +"/Applications/todolist/todolist.xml"); |
350 | if ( f.exists() ) { | 351 | if ( f.exists() ) { |
351 | QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); | 352 | QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); |
352 | 353 | ||
353 | TodoItem *item; | 354 | TodoItem *item; |
354 | for( item = todolist.first(); item; item = todolist.next()) { | 355 | for( item = todolist.first(); item; item = todolist.next()) { |
355 | if (!(item->getCompleted() == 1) ) { | 356 | if (!(item->getCompleted() == 1) ) { |
356 | count++; | 357 | count++; |
357 | if (count <= MAX_LINES_TASK) { | 358 | if (count <= MAX_LINES_TASK) { |
358 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); | 359 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); |
359 | } | 360 | } |
360 | } | 361 | } |
361 | } | 362 | } |
362 | } | 363 | } |
363 | 364 | ||
364 | if (count > 0) { | 365 | if (count > 0) { |
365 | if( count == 1 ) { | 366 | if( count == 1 ) { |
366 | output = tr("There is <b> 1</b> active task: <br>" ); | 367 | output = tr("There is <b> 1</b> active task: <br>" ); |
367 | } else { | 368 | } else { |
368 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); | 369 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); |
369 | } | 370 | } |
370 | output += tmpout; | 371 | output += tmpout; |
371 | } else { | 372 | } else { |