summaryrefslogtreecommitdiff
path: root/core
Unidiff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp294
1 files changed, 127 insertions, 167 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,82 +167,65 @@ void Today::getDates()
173 167
174 count++; 168 count++;
175 169
176 if ( count <= MAX_LINES_MEET ) 170 if ( count <= MAX_LINES_MEET ) {
177 { 171 //cout << time.toString() << endl;
178 //cout << time.toString() << endl; 172 //cout << TimeString::dateString((*it).event().end()) << endl;
179 //cout << TimeString::dateString((*it).event().end()) << endl; 173
174 // decide if to get all day or only later appointments
175 if (!ONLY_LATER) {
176 msg += "<B>" + (*it).description() + "</B>";
177 if ( (*it).event().hasAlarm() ) {
178 msg += " <b>[with alarm]</b>";
179 }
180 // include location or not
181 if (SHOW_LOCATION == 1) {
182 msg += "<BR><i>" + (*it).location();
183 msg += "</i>";
184 }
185
186 if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) {
187 msg += "<br>All day";
188 } else {
189 // start time of event
190 msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) )
191 // end time of event
192 + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) );
193 }
194 msg += "<BR>";
195 // include possible note or not
196 if (SHOW_NOTES == 1) {
197 msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>";
198 }
199 } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) {
200 msg += "<B>" + (*it).description() + "</B>";
201 if ( (*it).event().hasAlarm() ) {
202 msg += " <b>[with alarm]</b>";
203 }
204 // include location or not
205 if (SHOW_LOCATION == 1) {
206 msg+= "<BR><i>" + (*it).location();
207 msg += "</i>";
208 }
180 209
181 // decide if to get all day or only later appointments 210 if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) {
182 if (!ONLY_LATER) 211 msg += "<br>All day";
183 { 212 } else {
184 msg += "<B>" + (*it).description() + "</B>"; 213 // start time of event
185 if ( (*it).event().hasAlarm() ) 214 msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) )
186 { 215 // end time of event
187 msg += " <b>[with alarm]</b>"; 216 + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) );
188 } 217 }
189 // include location or not 218 msg += "<BR>";
190 if (SHOW_LOCATION == 1) 219 // include possible note or not
191 { 220 if (SHOW_NOTES == 1) {
192 msg += "<BR><i>" + (*it).location(); 221 msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>";
193 msg += "</i>"; 222 }
194 }
195
196 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";
199 }
200 else
201 {
202 // start time of event
203 msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) )
204 // end time of event
205 + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) );
206 }
207 msg += "<BR>";
208 // include possible note or not
209 if (SHOW_NOTES == 1)
210 {
211 msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>";
212 }
213 }
214 else if ((time.toString() <= TimeString::dateString((*it).event().end())) )
215 {
216 msg += "<B>" + (*it).description() + "</B>";
217 if ( (*it).event().hasAlarm() )
218 {
219 msg += " <b>[with alarm]</b>";
220 }
221 // include location or not
222 if (SHOW_LOCATION == 1)
223 {
224 msg+= "<BR><i>" + (*it).location();
225 msg += "</i>";
226 }
227
228 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";
231 }
232 else
233 {
234 // start time of event
235 msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) )
236 // end time of event
237 + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) );
238 }
239 msg += "<BR>";
240 // include possible note or not
241 if (SHOW_NOTES == 1)
242 {
243 msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>";
244 }
245 }
246 } 223 }
247 }
248 if (msg.isEmpty())
249 {
250 msg = "No more appointments today";
251 } 224 }
225 }
226 if (msg.isEmpty()) {
227 msg = "No more appointments today";
228 }
252 DatesField->setText(msg); 229 DatesField->setText(msg);
253 } 230 }
254} 231}
@@ -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,62 +249,53 @@ 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 { 253 tasklist = tasks->el;
278 tasklist = tasks->el; 254 i = 0;
279 i = 0; 255 while((tasklist) && (tasklist[i])) {
280 while((tasklist) && (tasklist[i])) 256 attlist = tasklist[i]->at;
281 { 257 j = 0;
282 attlist = tasklist[i]->at; 258 description = NULL;
283 j = 0; 259 priority = -1;
284 description = NULL; 260 completed = -1;
285 priority = -1; 261 while((attlist) && (attlist[j])) {
286 completed = -1; 262 if(!attlist[j]->name) {
287 while((attlist) && (attlist[j])) 263 continue;
288 {
289 // SEGFAULT HERE WITH MORE THAN 7 ENTRIES
290 if(!attlist[j]->name) continue;
291 if(!strcmp(attlist[j]->name, "Description"))
292 {
293 description = attlist[j]->value;
294 }
295 // get Completed tag (0 or 1)
296 if(!strcmp(attlist[j]->name, "Completed"))
297 {
298 QString s = attlist[j]->name;
299 if(s == "Completed")
300 {
301 completed = QString(attlist[j]->value).toInt();
302 }
303 }
304 // get Priority (1 to 5)
305 if(!strcmp(attlist[j]->name, "Priority"))
306 {
307 QString s = attlist[j]->name;
308 if(s == "Priority")
309 {
310 priority = QString(attlist[j]->value).toInt();
311 }
312 }
313 j++;
314 }
315 if(description)
316 {
317 tmp = new TodoItem(description, completed, priority);
318 loadtodolist.append(tmp);
319 }
320 i++;
321 } 264 }
265 if(!strcmp(attlist[j]->name, "Description")) {
266 description = attlist[j]->value;
267 }
268 // get Completed tag (0 or 1)
269 if(!strcmp(attlist[j]->name, "Completed")) {
270 QString s = attlist[j]->name;
271 if(s == "Completed") {
272 completed = QString(attlist[j]->value).toInt();
273 }
274 }
275 // get Priority (1 to 5)
276 if(!strcmp(attlist[j]->name, "Priority")) {
277 QString s = attlist[j]->name;
278 if(s == "Priority") {
279 priority = QString(attlist[j]->value).toInt();
280 }
281 }
282 j++;
283 }
284 if(description) {
285 tmp = new TodoItem(description, completed, priority);
286 loadtodolist.append(tmp);
287 }
288 i++;
322 } 289 }
323 290 }
291
324 minidom_free(todo); 292 minidom_free(todo);
325 293
326 return loadtodolist; 294 return loadtodolist;
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,33 +324,30 @@ 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 { 328 QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml");
362 QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); 329
363 330 TodoItem *item;
364 TodoItem *item; 331 for( item = todolist.first(); item; item = todolist.next()) {
365 for( item = todolist.first(); item; item = todolist.next()) 332 if (!(item->getCompleted() == 1) ) {
366 { 333 count++;
367 if (!(item->getCompleted() == 1) ) 334 if (count <= MAX_LINES_TASK) {
368 { 335 tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>")));
369 count++;
370 if (count <= MAX_LINES_TASK)
371 {
372 tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>")));
373 }
374 }
375 } 336 }
337 }
376 } 338 }
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 }
383 else
384 {
385 output = ("No active tasks");
386 } 346 }
347 output += tmpout;
348 } else {
349 output = ("No active tasks");
350 }
387 351
388 TodoField->setText(output); 352 TodoField->setText(output);
389} 353}
@@ -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}