summaryrefslogtreecommitdiff
path: root/core/pim
authorharlekin <harlekin>2002-03-05 22:23:54 (UTC)
committer harlekin <harlekin>2002-03-05 22:23:54 (UTC)
commitc84da23a6ff2a8ff51b4da70f83b261f1e548be1 (patch) (unidiff)
tree4d87cf43f7b9c48765b4879e4ee5c6e9ca5841b3 /core/pim
parent3ccfa79645d8bd99c7b559f9fa315d028db2c75d (diff)
downloadopie-c84da23a6ff2a8ff51b4da70f83b261f1e548be1.zip
opie-c84da23a6ff2a8ff51b4da70f83b261f1e548be1.tar.gz
opie-c84da23a6ff2a8ff51b4da70f83b261f1e548be1.tar.bz2
cosmetic changes on request from zecke
Diffstat (limited to 'core/pim') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/today/today.cpp140
1 files changed, 50 insertions, 90 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index c63a9ef..6a0e9fc 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -55,8 +55,7 @@ int ONLY_LATER;
55 * name 'name' and widget flags set to 'f' 55 * name 'name' and widget flags set to 'f'
56 */ 56 */
57Today::Today( QWidget* parent, const char* name, WFlags fl ) 57Today::Today( QWidget* parent, const char* name, WFlags fl )
58 : TodayBase( parent, name, fl ) 58 : TodayBase( parent, name, fl ) {
59{
60 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); 59 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) );
61 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); 60 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) );
62 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); 61 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) );
@@ -66,19 +65,16 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
66} 65}
67 66
68 67
69void Today::draw() 68void Today::draw() {
70{
71 init(); 69 init();
72 getDates(); 70 getDates();
73 getMail(); 71 getMail();
74 getTodo(); 72 getTodo();
75 // how often refresh 73 // how often refresh
76 QTimer::singleShot( 5*1000, this, SLOT(draw()) ); 74 QTimer::singleShot( 5*1000, this, SLOT(draw()) );
77
78} 75}
79 76
80void Today::init() 77void Today::init() {
81{
82 QDate date = QDate::currentDate(); 78 QDate date = QDate::currentDate();
83 QString time = (date.toString()); 79 QString time = (date.toString());
84 80
@@ -103,8 +99,7 @@ void Today::init()
103 99
104} 100}
105 101
106void Today::startConfig() 102void Today::startConfig() {
107{
108 conf = new todayconfig ( this, "", true ); 103 conf = new todayconfig ( this, "", true );
109 104
110 105
@@ -153,8 +148,7 @@ void Today::startConfig()
153/* 148/*
154 * Get all events that are in the datebook xml file for today 149 * Get all events that are in the datebook xml file for today
155 */ 150 */
156void Today::getDates() 151void Today::getDates() {
157{
158 QDate date = QDate::currentDate(); 152 QDate date = QDate::currentDate();
159 QTime time = QTime::currentTime(); 153 QTime time = QTime::currentTime();
160 QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); 154 QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date);
@@ -173,32 +167,25 @@ void Today::getDates()
173 167
174 count++; 168 count++;
175 169
176 if ( count <= MAX_LINES_MEET ) 170 if ( count <= MAX_LINES_MEET ) {
177 {
178 //cout << time.toString() << endl; 171 //cout << time.toString() << endl;
179 //cout << TimeString::dateString((*it).event().end()) << endl; 172 //cout << TimeString::dateString((*it).event().end()) << endl;
180 173
181 // decide if to get all day or only later appointments 174 // decide if to get all day or only later appointments
182 if (!ONLY_LATER) 175 if (!ONLY_LATER) {
183 {
184 msg += "<B>" + (*it).description() + "</B>"; 176 msg += "<B>" + (*it).description() + "</B>";
185 if ( (*it).event().hasAlarm() ) 177 if ( (*it).event().hasAlarm() ) {
186 {
187 msg += " <b>[with alarm]</b>"; 178 msg += " <b>[with alarm]</b>";
188 } 179 }
189 // include location or not 180 // include location or not
190 if (SHOW_LOCATION == 1) 181 if (SHOW_LOCATION == 1) {
191 {
192 msg += "<BR><i>" + (*it).location(); 182 msg += "<BR><i>" + (*it).location();
193 msg += "</i>"; 183 msg += "</i>";
194 } 184 }
195 185
196 if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) 186 if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) {
197 {
198 msg += "<br>All day"; 187 msg += "<br>All day";
199 } 188 } else {
200 else
201 {
202 // start time of event 189 // start time of event
203 msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) ) 190 msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) )
204 // end time of event 191 // end time of event
@@ -206,31 +193,23 @@ void Today::getDates()
206 } 193 }
207 msg += "<BR>"; 194 msg += "<BR>";
208 // include possible note or not 195 // include possible note or not
209 if (SHOW_NOTES == 1) 196 if (SHOW_NOTES == 1) {
210 {
211 msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; 197 msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>";
212 } 198 }
213 } 199 } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) {
214 else if ((time.toString() <= TimeString::dateString((*it).event().end())) )
215 {
216 msg += "<B>" + (*it).description() + "</B>"; 200 msg += "<B>" + (*it).description() + "</B>";
217 if ( (*it).event().hasAlarm() ) 201 if ( (*it).event().hasAlarm() ) {
218 {
219 msg += " <b>[with alarm]</b>"; 202 msg += " <b>[with alarm]</b>";
220 } 203 }
221 // include location or not 204 // include location or not
222 if (SHOW_LOCATION == 1) 205 if (SHOW_LOCATION == 1) {
223 {
224 msg+= "<BR><i>" + (*it).location(); 206 msg+= "<BR><i>" + (*it).location();
225 msg += "</i>"; 207 msg += "</i>";
226 } 208 }
227 209
228 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") ) {
229 {
230 msg += "<br>All day"; 211 msg += "<br>All day";
231 } 212 } else {
232 else
233 {
234 // start time of event 213 // start time of event
235 msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) ) 214 msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) )
236 // end time of event 215 // end time of event
@@ -238,15 +217,13 @@ void Today::getDates()
238 } 217 }
239 msg += "<BR>"; 218 msg += "<BR>";
240 // include possible note or not 219 // include possible note or not
241 if (SHOW_NOTES == 1) 220 if (SHOW_NOTES == 1) {
242 {
243 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>";
244 } 222 }
245 } 223 }
246 } 224 }
247 } 225 }
248 if (msg.isEmpty()) 226 if (msg.isEmpty()) {
249 {
250 msg = "No more appointments today"; 227 msg = "No more appointments today";
251 } 228 }
252 DatesField->setText(msg); 229 DatesField->setText(msg);
@@ -256,8 +233,7 @@ void Today::getDates()
256/* 233/*
257 * Parse in the todolist.xml 234 * Parse in the todolist.xml
258 */ 235 */
259QList<TodoItem> Today::loadTodo(const char *filename) 236QList<TodoItem> Today::loadTodo(const char *filename) {
260{
261 DOM *todo; 237 DOM *todo;
262 ELE *tasks; 238 ELE *tasks;
263 ELE **tasklist; 239 ELE **tasklist;
@@ -273,47 +249,39 @@ QList<TodoItem> Today::loadTodo(const char *filename)
273 249
274 tasks = todo->el; 250 tasks = todo->el;
275 tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ 251 tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/
276 if(tasks) 252 if(tasks) {
277 {
278 tasklist = tasks->el; 253 tasklist = tasks->el;
279 i = 0; 254 i = 0;
280 while((tasklist) && (tasklist[i])) 255 while((tasklist) && (tasklist[i])) {
281 {
282 attlist = tasklist[i]->at; 256 attlist = tasklist[i]->at;
283 j = 0; 257 j = 0;
284 description = NULL; 258 description = NULL;
285 priority = -1; 259 priority = -1;
286 completed = -1; 260 completed = -1;
287 while((attlist) && (attlist[j])) 261 while((attlist) && (attlist[j])) {
288 { 262 if(!attlist[j]->name) {
289 // SEGFAULT HERE WITH MORE THAN 7 ENTRIES 263 continue;
290 if(!attlist[j]->name) continue; 264 }
291 if(!strcmp(attlist[j]->name, "Description")) 265 if(!strcmp(attlist[j]->name, "Description")) {
292 {
293 description = attlist[j]->value; 266 description = attlist[j]->value;
294 } 267 }
295 // get Completed tag (0 or 1) 268 // get Completed tag (0 or 1)
296 if(!strcmp(attlist[j]->name, "Completed")) 269 if(!strcmp(attlist[j]->name, "Completed")) {
297 {
298 QString s = attlist[j]->name; 270 QString s = attlist[j]->name;
299 if(s == "Completed") 271 if(s == "Completed") {
300 {
301 completed = QString(attlist[j]->value).toInt(); 272 completed = QString(attlist[j]->value).toInt();
302 } 273 }
303 } 274 }
304 // get Priority (1 to 5) 275 // get Priority (1 to 5)
305 if(!strcmp(attlist[j]->name, "Priority")) 276 if(!strcmp(attlist[j]->name, "Priority")) {
306 {
307 QString s = attlist[j]->name; 277 QString s = attlist[j]->name;
308 if(s == "Priority") 278 if(s == "Priority") {
309 {
310 priority = QString(attlist[j]->value).toInt(); 279 priority = QString(attlist[j]->value).toInt();
311 } 280 }
312 } 281 }
313 j++; 282 j++;
314 } 283 }
315 if(description) 284 if(description) {
316 {
317 tmp = new TodoItem(description, completed, priority); 285 tmp = new TodoItem(description, completed, priority);
318 loadtodolist.append(tmp); 286 loadtodolist.append(tmp);
319 } 287 }
@@ -327,8 +295,7 @@ QList<TodoItem> Today::loadTodo(const char *filename)
327} 295}
328 296
329 297
330void Today::getMail() 298void Today::getMail() {
331{
332 Config cfg("opiemail"); 299 Config cfg("opiemail");
333 cfg.setGroup("today"); 300 cfg.setGroup("today");
334 301
@@ -336,7 +303,8 @@ void Today::getMail()
336 int NEW_MAILS = cfg.readNumEntry("newmails",0); 303 int NEW_MAILS = cfg.readNumEntry("newmails",0);
337 int OUTGOING = cfg.readNumEntry("outgoing",0); 304 int OUTGOING = cfg.readNumEntry("outgoing",0);
338 305
339 QString output = tr("<b>%1</b> new mails, <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); 306
307 QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING);
340 308
341 309
342 MailField->setText(output); 310 MailField->setText(output);
@@ -347,8 +315,7 @@ void Today::getMail()
347 * Get the todos 315 * Get the todos
348 * 316 *
349 */ 317 */
350void Today::getTodo() 318void Today::getTodo() {
351{
352 QString output; 319 QString output;
353 QString tmpout; 320 QString tmpout;
354 int count = 0; 321 int count = 0;
@@ -357,31 +324,28 @@ void Today::getTodo()
357 QString homedir = dir.homeDirPath (); 324 QString homedir = dir.homeDirPath ();
358 // see if todolist.xml does exist. 325 // see if todolist.xml does exist.
359 QFile f(homedir +"/Applications/todolist/todolist.xml"); 326 QFile f(homedir +"/Applications/todolist/todolist.xml");
360 if ( f.exists() ) 327 if ( f.exists() ) {
361 {
362 QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); 328 QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml");
363 329
364 TodoItem *item; 330 TodoItem *item;
365 for( item = todolist.first(); item; item = todolist.next()) 331 for( item = todolist.first(); item; item = todolist.next()) {
366 { 332 if (!(item->getCompleted() == 1) ) {
367 if (!(item->getCompleted() == 1) )
368 {
369 count++; 333 count++;
370 if (count <= MAX_LINES_TASK) 334 if (count <= MAX_LINES_TASK) {
371 {
372 tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); 335 tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>")));
373 } 336 }
374 } 337 }
375 } 338 }
376 } 339 }
377 340
378 if (count > 0) 341 if (count > 0) {
379 { 342 if( count == 1 ) {
343 output = QString("There is <b> 1</b> active task: <br>" );
344 } else {
380 output = QString("There are <b> %1</b> active tasks: <br>").arg(count); 345 output = QString("There are <b> %1</b> active tasks: <br>").arg(count);
381 output += tmpout;
382 } 346 }
383 else 347 output += tmpout;
384 { 348 } else {
385 output = ("No active tasks"); 349 output = ("No active tasks");
386 } 350 }
387 351
@@ -391,8 +355,7 @@ void Today::getTodo()
391/* 355/*
392 * launches datebook 356 * launches datebook
393 */ 357 */
394void Today::startDatebook() 358void Today::startDatebook() {
395{
396 QCopEnvelope e("QPE/System", "execute(QString)"); 359 QCopEnvelope e("QPE/System", "execute(QString)");
397 e << QString("datebook"); 360 e << QString("datebook");
398} 361}
@@ -400,8 +363,7 @@ void Today::startDatebook()
400/* 363/*
401 * launches todolist 364 * launches todolist
402 */ 365 */
403void Today::startTodo() 366void Today::startTodo() {
404{
405 QCopEnvelope e("QPE/System", "execute(QString)"); 367 QCopEnvelope e("QPE/System", "execute(QString)");
406 e << QString("todolist"); 368 e << QString("todolist");
407} 369}
@@ -409,8 +371,7 @@ void Today::startTodo()
409/* 371/*
410 * launch opiemail 372 * launch opiemail
411 */ 373 */
412void Today::startMail() 374void Today::startMail() {
413{
414 QCopEnvelope e("QPE/System", "execute(QString)"); 375 QCopEnvelope e("QPE/System", "execute(QString)");
415 e << QString("opiemail"); 376 e << QString("opiemail");
416} 377}
@@ -418,7 +379,6 @@ void Today::startMail()
418/* 379/*
419 * Destroys the object and frees any allocated resources 380 * Destroys the object and frees any allocated resources
420 */ 381 */
421Today::~Today() 382Today::~Today() {
422{
423 // no need to delete child widgets, Qt does it all for us 383 // no need to delete child widgets, Qt does it all for us
424} 384}