summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp82
-rw-r--r--core/pim/today/today.h14
2 files changed, 72 insertions, 24 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index d10082f..1cdc6b4 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -1,477 +1,511 @@
1/* 1/*
2 * today.cpp : main class 2 * today.cpp : main class
3 * 3 *
4 * --------------------- 4 * ---------------------
5 * 5 *
6 * begin : Sun 10 17:20:00 CEST 2002 6 * begin : Sun 10 17:20:00 CEST 2002
7 * copyright : (c) 2002 by Maximilian Reiß 7 * copyright : (c) 2002 by Maximilian Reiß
8 * email : max.reiss@gmx.de 8 * email : max.reiss@gmx.de
9 * 9 *
10 */ 10 */
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19 19
20#include "today.h" 20#include "today.h"
21#include "minidom.h" 21#include "minidom.h"
22#include "TodoItem.h" 22#include "TodoItem.h"
23 23
24#include <qpe/datebookdb.h> 24#include <qpe/datebookdb.h>
25#include <qpe/timestring.h> 25#include <qpe/timestring.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qpe/qcopenvelope_qws.h> 27#include <qpe/qcopenvelope_qws.h>
28#include <qpe/qprocess.h> 28#include <qpe/qprocess.h>
29#include <qpe/resource.h> 29#include <qpe/resource.h>
30 30
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qtextstream.h> 34#include <qtextstream.h>
35#include <qcheckbox.h> 35#include <qcheckbox.h>
36#include <qspinbox.h> 36#include <qspinbox.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qtimer.h> 39#include <qtimer.h>
40#include <qpixmap.h> 40#include <qpixmap.h>
41#include <qfileinfo.h> 41#include <qfileinfo.h>
42#include <qlayout.h> 42#include <qlayout.h>
43 43
44//#include <iostream.h> 44//#include <iostream.h>
45//#include <unistd.h> 45//#include <unistd.h>
46#include <stdlib.h> 46#include <stdlib.h>
47 47
48 48
49 49
50int MAX_LINES_TASK; 50int MAX_LINES_TASK;
51int MAX_CHAR_CLIP; 51int MAX_CHAR_CLIP;
52int MAX_LINES_MEET; 52int MAX_LINES_MEET;
53int SHOW_LOCATION; 53int SHOW_LOCATION;
54int SHOW_NOTES; 54int SHOW_NOTES;
55// show only later dates 55// show only later dates
56int ONLY_LATER; 56int ONLY_LATER;
57int AUTOSTART; 57int AUTOSTART;
58 58
59int NEW_START=1; 59int NEW_START=1;
60/* 60/*
61 * Constructs a Example which is a child of 'parent', with the 61 * Constructs a Example which is a child of 'parent', with the
62 * name 'name' and widget flags set to 'f' 62 * name 'name' and widget flags set to 'f'
63 */ 63 */
64Today::Today( QWidget* parent, const char* name, WFlags fl ) 64Today::Today( QWidget* parent, const char* name, WFlags fl )
65 : TodayBase( parent, name, fl ) { 65 : TodayBase( parent, name, fl ) {
66 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); 66 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) );
67 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); 67 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) );
68 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); 68 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) );
69 QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); 69 QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) );
70 70
71
72 autoStart();
73 draw(); 71 draw();
72 autoStart();
74} 73}
75 74
76void Today::autoStart() { 75void Today::autoStart() {
77 Config cfg("today"); 76 Config cfg("today");
78 cfg.setGroup("Autostart"); 77 cfg.setGroup("Autostart");
79 AUTOSTART = cfg.readNumEntry("autostart",1); 78 AUTOSTART = cfg.readNumEntry("autostart",1);
80 if (AUTOSTART) { 79 if (AUTOSTART) {
81 QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); 80 QCopEnvelope e("QPE/System", "autoStart(QString,QString)");
82 e << QString("add"); 81 e << QString("add");
83 e << QString("today"); 82 e << QString("today");
84 } else { 83 } else {
85 QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); 84 QCopEnvelope e("QPE/System", "autoStart(QString,QString)");
86 e << QString("remove"); 85 e << QString("remove");
87 e << QString("today"); 86 e << QString("today");
88 } 87 }
89} 88}
90 89
91void Today::draw() { 90void Today::draw() {
92 init(); 91 init();
93 getDates(); 92 getDates();
94 getMail(); 93 getMail();
95 getTodo(); 94 getTodo();
96 // how often refresh 95 // how often refresh
97 QTimer::singleShot( 30*1000, this, SLOT(draw()) ); 96 QTimer::singleShot( 10*1000, this, SLOT(draw() ) );
98} 97}
99 98
100 99
101/* 100/*
102 * Check if the todolist.xml was modified (if there are new entries. 101 * Check if the todolist.xml was modified (if there are new entries.
103 * Returns true if it was modified. 102 * Returns true if it was modified.
104 */ 103 */
105bool Today::checkIfModified() { 104bool Today::checkIfModified() {
106 105
107 QDir dir; 106 QDir dir;
108 QString homedir = dir.homeDirPath (); 107 QString homedir = dir.homeDirPath ();
109 QString time; 108 QString time;
110 109
111 Config cfg("today"); 110 Config cfg("today");
112 cfg.setGroup("Files"); 111 cfg.setGroup("Files");
113 time = cfg.readEntry("todolisttimestamp", ""); 112 time = cfg.readEntry("todolisttimestamp", "");
114 113
115 QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); 114 QFileInfo file = (homedir +"/Applications/todolist/todolist.xml");
116 QDateTime fileTime = file.lastModified(); 115 QDateTime fileTime = file.lastModified();
117 if (time.compare(fileTime.toString()) == 0) { 116 if (time.compare(fileTime.toString()) == 0) {
118 return false; 117 return false;
119 } else { 118 } else {
120 cfg.writeEntry("todolisttimestamp", fileTime.toString() ); 119 cfg.writeEntry("todolisttimestamp", fileTime.toString() );
121 cfg.write(); 120 cfg.write();
122 return true; 121 return true;
123 } 122 }
124} 123}
125 124
126 125
127void Today::init() { 126void Today::init() {
128 QDate date = QDate::currentDate(); 127 QDate date = QDate::currentDate();
129 QString time = (tr( date.toString()) ); 128 QString time = (tr( date.toString()) );
130// QString time = (tr( date.toString()) , white); 129// QString time = (tr( date.toString()) , white);
131 130
132 TextLabel1->setText(time); 131 TextLabel1->setText(time);
133 db = new DateBookDB; 132 db = new DateBookDB;
134 133
135 // read config 134 // read config
136 Config cfg("today"); 135 Config cfg("today");
137 cfg.setGroup("BaseConfig"); 136 cfg.setGroup("BaseConfig");
138 137
139 // how many lines should be showed in the task section 138 // how many lines should be showed in the task section
140 MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); 139 MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5);
141 // after how many chars should the be cut off on tasks and notes 140 // after how many chars should the be cut off on tasks and notes
142 MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30); 141 MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30);
143 // how many lines should be showed in the datebook section 142 // how many lines should be showed in the datebook section
144 MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); 143 MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5);
145 // If location is to be showed too, 1 to activate it. 144 // If location is to be showed too, 1 to activate it.
146 SHOW_LOCATION = cfg.readNumEntry("showlocation",1); 145 SHOW_LOCATION = cfg.readNumEntry("showlocation",1);
147 // if notes should be shown 146 // if notes should be shown
148 SHOW_NOTES = cfg.readNumEntry("shownotes",0); 147 SHOW_NOTES = cfg.readNumEntry("shownotes",0);
149 ONLY_LATER = cfg.readNumEntry("onlylater",1); 148 ONLY_LATER = cfg.readNumEntry("onlylater",1);
150 149
151} 150}
152 151
153void Today::startConfig() { 152void Today::startConfig() {
154 conf = new todayconfig ( this, "", true ); 153 conf = new todayconfig ( this, "", true );
155 154
156 155
157 //Config cfg = new Config("today"); 156 //Config cfg = new Config("today");
158 157
159 // read the config 158 // read the config
160 Config cfg("today"); 159 Config cfg("today");
161 cfg.setGroup("BaseConfig"); 160 cfg.setGroup("BaseConfig");
162 161
163 //init(); 162 //init();
164 163
165 conf->SpinBox1->setValue(MAX_LINES_MEET); 164 conf->SpinBox1->setValue(MAX_LINES_MEET);
166 // location show box 165 // location show box
167 conf->CheckBox1->setChecked(SHOW_LOCATION); 166 conf->CheckBox1->setChecked(SHOW_LOCATION);
168 // notes show box 167 // notes show box
169 conf->CheckBox2->setChecked(SHOW_NOTES); 168 conf->CheckBox2->setChecked(SHOW_NOTES);
170 // task lines 169 // task lines
171 conf->SpinBox2->setValue(MAX_LINES_TASK); 170 conf->SpinBox2->setValue(MAX_LINES_TASK);
172 // clip when? 171 // clip when?
173 conf->SpinBox7->setValue(MAX_CHAR_CLIP); 172 conf->SpinBox7->setValue(MAX_CHAR_CLIP);
174 // only later 173 // only later
175 conf->CheckBox3->setChecked(ONLY_LATER); 174 conf->CheckBox3->setChecked(ONLY_LATER);
176 175
177 conf->CheckBoxAuto->setChecked(AUTOSTART); 176 conf->CheckBoxAuto->setChecked(AUTOSTART);
178 177
179 conf->exec(); 178 conf->exec();
180 179
181 int maxlinestask = conf->SpinBox2->value(); 180 int maxlinestask = conf->SpinBox2->value();
182 int maxmeet = conf->SpinBox1->value(); 181 int maxmeet = conf->SpinBox1->value();
183 int location = conf->CheckBox1->isChecked(); 182 int location = conf->CheckBox1->isChecked();
184 int notes = conf->CheckBox2->isChecked(); 183 int notes = conf->CheckBox2->isChecked();
185 int maxcharclip = conf->SpinBox7->value(); 184 int maxcharclip = conf->SpinBox7->value();
186 int onlylater = conf->CheckBox3->isChecked(); 185 int onlylater = conf->CheckBox3->isChecked();
187 int autostart =conf->CheckBoxAuto->isChecked(); 186 int autostart =conf->CheckBoxAuto->isChecked();
188 187
189 cfg.writeEntry("maxlinestask",maxlinestask); 188 cfg.writeEntry("maxlinestask",maxlinestask);
190 cfg.writeEntry("maxcharclip", maxcharclip); 189 cfg.writeEntry("maxcharclip", maxcharclip);
191 cfg.writeEntry("maxlinesmeet",maxmeet); 190 cfg.writeEntry("maxlinesmeet",maxmeet);
192 cfg.writeEntry("showlocation",location); 191 cfg.writeEntry("showlocation",location);
193 cfg.writeEntry("shownotes", notes); 192 cfg.writeEntry("shownotes", notes);
194 cfg.writeEntry("onlylater", onlylater); 193 cfg.writeEntry("onlylater", onlylater);
195 cfg.setGroup("Autostart"); 194 cfg.setGroup("Autostart");
196 cfg.writeEntry("autostart", autostart); 195 cfg.writeEntry("autostart", autostart);
197 // sync it to "disk" 196 // sync it to "disk"
198 cfg.write(); 197 cfg.write();
199 autoStart();
200 draw(); 198 draw();
199 autoStart();
201} 200}
202 201
203 202
204/* 203/*
205 * Get all events that are in the datebook xml file for today 204 * Get all events that are in the datebook xml file for today
206 */ 205 */
207void Today::getDates() { 206void Today::getDates() {
208 QDate date = QDate::currentDate(); 207 QDate date = QDate::currentDate();
209 QWidget* AllDateBookEvents = new QWidget( ); 208 QWidget* AllDateBookEvents = new QWidget( );
210 QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); 209 QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents);
211 //QTime time = QTime::currentTime();
212 210
213 QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); 211 QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date);
214 212
215 Config config( "qpe" ); 213 Config config( "qpe" );
216 // if 24 h format 214 // if 24 h format
217 //bool ampm = config.readBoolEntry( "AMPM", TRUE ); 215 //bool ampm = config.readBoolEntry( "AMPM", TRUE );
218 216
219 int count=0; 217 int count=0;
220 218
221 if ( list.count() > 0 ) { 219 if ( list.count() > 0 ) {
222 QString msg; 220
223
224 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); 221 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin();
225 it!=list.end(); ++it ) { 222 it!=list.end(); ++it ) {
226 223
227 count++; 224 count++;
228 225
229 if ( count <= MAX_LINES_MEET ) { 226 if ( count <= MAX_LINES_MEET ) {
227
228 QTime time = QTime::currentTime();
230 229
231 230 if (!ONLY_LATER) {
232 DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents); 231 DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents);
233 layoutDates->addWidget(l); 232 layoutDates->addWidget(l);
234 connect (l, SIGNAL(editEvent(const Event &)), 233 connect (l, SIGNAL(editEvent(const Event &)),
235 this, SIGNAL(editEvent(const Event &))); 234 this, SIGNAL(editEvent(const Event &)));
235 } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) {
236 // show only later appointments
237 DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents);
238 layoutDates->addWidget(l);
239 connect (l, SIGNAL(editEvent(const Event &)),
240 this, SIGNAL(editEvent(const Event &)));
241 } else {
242 QLabel* noMoreEvents = new QLabel(AllDateBookEvents);
243 noMoreEvents->setText("No more appointments today");
244 layoutDates->addWidget(noMoreEvents);
245 }
236 } 246 }
237 247 }
238 } 248 } else {
239 layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 249 QLabel* noEvents = new QLabel(AllDateBookEvents);
240 sv1->addChild(AllDateBookEvents); 250 noEvents->setText("No appointments today");
241 251 layoutDates->addWidget(noEvents);
242 //if (msg.isEmpty()) {
243 // msg = tr("No more appointments today");
244 //}
245 //DatesField->setText(msg);
246 } 252 }
253
254 layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
255 sv1->addChild(AllDateBookEvents);
256
257
247} 258}
248 259
249/* 260/*
250 * Parse in the todolist.xml 261 * Parse in the todolist.xml
251 */ 262 */
252QList<TodoItem> Today::loadTodo(const char *filename) { 263QList<TodoItem> Today::loadTodo(const char *filename) {
253 DOM *todo; 264 DOM *todo;
254 ELE *tasks; 265 ELE *tasks;
255 ELE **tasklist; 266 ELE **tasklist;
256 ATT **attlist; 267 ATT **attlist;
257 int i, j; 268 int i, j;
258 char *description; 269 char *description;
259 int completed; 270 int completed;
260 int priority; 271 int priority;
261 TodoItem *tmp; 272 TodoItem *tmp;
262 QList<TodoItem> loadtodolist; 273 QList<TodoItem> loadtodolist;
263 274
264 todo = minidom_load(filename); 275 todo = minidom_load(filename);
265 276
266 tasks = todo->el; 277 tasks = todo->el;
267 tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ 278 tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/
268 if(tasks) { 279 if(tasks) {
269 tasklist = tasks->el; 280 tasklist = tasks->el;
270 i = 0; 281 i = 0;
271 while((tasklist) && (tasklist[i])) { 282 while((tasklist) && (tasklist[i])) {
272 attlist = tasklist[i]->at; 283 attlist = tasklist[i]->at;
273 j = 0; 284 j = 0;
274 description = NULL; 285 description = NULL;
275 priority = -1; 286 priority = -1;
276 completed = -1; 287 completed = -1;
277 while((attlist) && (attlist[j])) { 288 while((attlist) && (attlist[j])) {
278 if(!attlist[j]->name) { 289 if(!attlist[j]->name) {
279 continue; 290 continue;
280 } 291 }
281 if(!strcmp(attlist[j]->name, "Description")) { 292 if(!strcmp(attlist[j]->name, "Description")) {
282 description = attlist[j]->value; 293 description = attlist[j]->value;
283 } 294 }
284 // get Completed tag (0 or 1) 295 // get Completed tag (0 or 1)
285 if(!strcmp(attlist[j]->name, "Completed")) { 296 if(!strcmp(attlist[j]->name, "Completed")) {
286 QString s = attlist[j]->name; 297 QString s = attlist[j]->name;
287 if(s == "Completed") { 298 if(s == "Completed") {
288 completed = QString(attlist[j]->value).toInt(); 299 completed = QString(attlist[j]->value).toInt();
289 } 300 }
290 } 301 }
291 // get Priority (1 to 5) 302 // get Priority (1 to 5)
292 if(!strcmp(attlist[j]->name, "Priority")) { 303 if(!strcmp(attlist[j]->name, "Priority")) {
293 QString s = attlist[j]->name; 304 QString s = attlist[j]->name;
294 if(s == "Priority") { 305 if(s == "Priority") {
295 priority = QString(attlist[j]->value).toInt(); 306 priority = QString(attlist[j]->value).toInt();
296 } 307 }
297 } 308 }
298 j++; 309 j++;
299 } 310 }
300 if(description) { 311 if(description) {
301 tmp = new TodoItem(description, completed, priority); 312 tmp = new TodoItem(description, completed, priority);
302 loadtodolist.append(tmp); 313 loadtodolist.append(tmp);
303 } 314 }
304 i++; 315 i++;
305 } 316 }
306 } 317 }
307 318
308 minidom_free(todo); 319 minidom_free(todo);
309 320
310 return loadtodolist; 321 return loadtodolist;
311} 322}
312 323
313 324
314void Today::getMail() { 325void Today::getMail() {
315 Config cfg("opiemail"); 326 Config cfg("opiemail");
316 cfg.setGroup("today"); 327 cfg.setGroup("today");
317 328
318 // how many lines should be showed in the task section 329 // how many lines should be showed in the task section
319 int NEW_MAILS = cfg.readNumEntry("newmails",0); 330 int NEW_MAILS = cfg.readNumEntry("newmails",0);
320 int OUTGOING = cfg.readNumEntry("outgoing",0); 331 int OUTGOING = cfg.readNumEntry("outgoing",0);
321 332
322 333
323 QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); 334 QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING);
324 335
325 336
326 MailField->setText(output); 337 MailField->setText(output);
327} 338}
328 339
329 340
330/* 341/*
331 * Get the todos 342 * Get the todos
332 * 343 *
333 */ 344 */
334void Today::getTodo() { 345void Today::getTodo() {
335 346
336 // if the todolist.xml file was not modified in between, do not parse it. 347 // if the todolist.xml file was not modified in between, do not parse it.
337 if (!checkIfModified() && !NEW_START) { 348 if (!checkIfModified() && !NEW_START) {
338 return; 349 return;
339 } 350 }
340 NEW_START=0; 351 NEW_START=0;
341 352
342 QString output; 353 QString output;
343 QString tmpout; 354 QString tmpout;
344 int count = 0; 355 int count = 0;
345 356
346 QDir dir; 357 QDir dir;
347 QString homedir = dir.homeDirPath (); 358 QString homedir = dir.homeDirPath ();
348 // see if todolist.xml does exist. 359 // see if todolist.xml does exist.
349 QFile f(homedir +"/Applications/todolist/todolist.xml"); 360 QFile f(homedir +"/Applications/todolist/todolist.xml");
350 if ( f.exists() ) { 361 if ( f.exists() ) {
351 QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); 362 QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml");
352 363
353 TodoItem *item; 364 TodoItem *item;
354 for( item = todolist.first(); item; item = todolist.next()) { 365 for( item = todolist.first(); item; item = todolist.next()) {
355 if (!(item->getCompleted() == 1) ) { 366 if (!(item->getCompleted() == 1) ) {
356 count++; 367 count++;
357 if (count <= MAX_LINES_TASK) { 368 if (count <= MAX_LINES_TASK) {
358 tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); 369 tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>")));
359 } 370 }
360 } 371 }
361 } 372 }
362 } 373 }
363 374
364 if (count > 0) { 375 if (count > 0) {
365 if( count == 1 ) { 376 if( count == 1 ) {
366 output = tr("There is <b> 1</b> active task: <br>" ); 377 output = tr("There is <b> 1</b> active task: <br>" );
367 } else { 378 } else {
368 output = tr("There are <b> %1</b> active tasks: <br>").arg(count); 379 output = tr("There are <b> %1</b> active tasks: <br>").arg(count);
369 } 380 }
370 output += tmpout; 381 output += tmpout;
371 } else { 382 } else {
372 output = tr("No active tasks"); 383 output = tr("No active tasks");
373 } 384 }
374 385
375 TodoField->setText(tr(output)); 386 TodoField->setText(tr(output));
376} 387}
377 388
378/* 389/*
379 * launches datebook 390 * launches datebook
380 */ 391 */
381void Today::startDatebook() { 392void Today::startDatebook() {
382 QCopEnvelope e("QPE/System", "execute(QString)"); 393 QCopEnvelope e("QPE/System", "execute(QString)");
383 e << QString("datebook"); 394 e << QString("datebook");
384} 395}
385 396
386/* 397/*
387 * launches todolist 398 * launches todolist
388 */ 399 */
389void Today::startTodo() { 400void Today::startTodo() {
390 QCopEnvelope e("QPE/System", "execute(QString)"); 401 QCopEnvelope e("QPE/System", "execute(QString)");
391 e << QString("todolist"); 402 e << QString("todolist");
392} 403}
393 404
394/* 405/*
395 * launch opiemail 406 * launch opiemail
396 */ 407 */
397void Today::startMail() { 408void Today::startMail() {
398 QCopEnvelope e("QPE/System", "execute(QString)"); 409 QCopEnvelope e("QPE/System", "execute(QString)");
399 e << QString("opiemail"); 410 e << QString("opiemail");
400} 411}
401 412
402/* 413/*
403 * Destroys the object and frees any allocated resources 414 * Destroys the object and frees any allocated resources
404 */ 415 */
405Today::~Today() { 416Today::~Today() {
406 // no need to delete child widgets, Qt does it all for us 417 // no need to delete child widgets, Qt does it all for us
407} 418}
408 419
409 420
410DateBookEvent::DateBookEvent(const EffectiveEvent &ev, 421DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
411 QWidget* parent = 0, 422 QWidget* parent = 0,
412 const char* name = 0, 423 const char* name = 0,
413 WFlags fl = 0) : 424 WFlags fl = 0) :
414 ClickableLabel(parent,name,fl), event(ev) { 425 ClickableLabel(parent,name,fl), event(ev) {
415 426
416 QString msg; 427 QString msg;
417 QTime time = QTime::currentTime(); 428 QTime time = QTime::currentTime();
418 429
419 if (!ONLY_LATER) { 430 if (!ONLY_LATER) {
420 msg += "<B>" + (ev).description() + "</B>"; 431 msg += "<B>" + (ev).description() + "</B>";
421 if ( (ev).event().hasAlarm() ) { 432 if ( (ev).event().hasAlarm() ) {
422 msg += " <b>[with alarm]</b>"; 433 msg += " <b>[with alarm]</b>";
423 } 434 }
424 // include location or not 435 // include location or not
425 if (SHOW_LOCATION == 1) { 436 if (SHOW_LOCATION == 1) {
426 msg += "<BR><i>" + (ev).location(); 437 msg += "<BR><i>" + (ev).location();
427 msg += "</i>"; 438 msg += "</i>";
428 } 439 }
429 440
430 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { 441 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) {
431 msg += "<br>All day"; 442 msg += "<br>All day";
432 } else { 443 } else {
433 // start time of event 444 // start time of event
434 msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) 445 msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) )
435 // end time of event 446 // end time of event
436 + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); 447 + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) );
437 } 448 }
438 // include possible note or not 449 // include possible note or not
439 if (SHOW_NOTES == 1) { 450 if (SHOW_NOTES == 1) {
440 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; 451 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>";
441 } 452 }
442 } else if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { 453 }
454 setText(msg);
455 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
456 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
457}
458
459
460DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
461 QWidget* parent = 0,
462 const char* name = 0,
463 WFlags fl = 0) :
464 ClickableLabel(parent,name,fl), event(ev) {
465
466 QString msg;
467 QTime time = QTime::currentTime();
468
469 if ((time.toString() <= TimeString::dateString((ev).event().end())) ) {
470 // show only later appointments
443 msg += "<B>" + (ev).description() + "</B>"; 471 msg += "<B>" + (ev).description() + "</B>";
444 if ( (ev).event().hasAlarm() ) { 472 if ( (ev).event().hasAlarm() ) {
445 msg += " <b>[with alarm]</b>"; 473 msg += " <b>[with alarm]</b>";
446 } 474 }
447 // include location or not 475 // include location or not
448 if (SHOW_LOCATION == 1) { 476 if (SHOW_LOCATION == 1) {
449 msg += "<BR><i>" + (ev).location(); 477 msg += "<BR><i>" + (ev).location();
450 msg += "</i>"; 478 msg += "</i>";
451 } 479 }
452 480
453 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { 481 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) {
454 msg += "<br>All day"; 482 msg += "<br>All day";
455 } else { 483 } else {
456 // start time of event 484 // start time of event
457 msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) 485 msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) )
458 // end time of event 486 // end time of event
459 + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); 487 + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) );
460 } 488 }
461 // include possible note or not 489 // include possible note or not
462 if (SHOW_NOTES == 1) { 490 if (SHOW_NOTES == 1) {
463 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; 491 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>";
464 } 492 }
465 } 493 }
466 494
495 // if (msg.isEmpty()) {
496 // msg = tr("No more appointments today");
497 // }
467 setText(msg); 498 setText(msg);
468 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 499 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
469 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 500 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
470} 501}
471 502
472void DateBookEvent::editMe() { 503void DateBookEvent::editMe() {
473 emit editEvent(event.event()); 504 emit editEvent(event.event());
474} 505}
475 506
507void DateBookEventLater::editMe() {
508 emit editEvent(event.event());
509}
476 510
477 511
diff --git a/core/pim/today/today.h b/core/pim/today/today.h
index 0a0837c..b3f0654 100644
--- a/core/pim/today/today.h
+++ b/core/pim/today/today.h
@@ -1,84 +1,98 @@
1/* 1/*
2 * today.h 2 * today.h
3 * 3 *
4 * --------------------- 4 * ---------------------
5 * 5 *
6 * begin : Sun 10 17:20:00 CEST 2002 6 * begin : Sun 10 17:20:00 CEST 2002
7 * copyright : (c) 2002 by Maximilian Reiß 7 * copyright : (c) 2002 by Maximilian Reiß
8 * email : max.reiss@gmx.de 8 * email : max.reiss@gmx.de
9 * 9 *
10 */ 10 */
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19 19
20 20
21#ifndef TODAY_H 21#ifndef TODAY_H
22#define TODAY_H 22#define TODAY_H
23 23
24#include <qpe/datebookdb.h> 24#include <qpe/datebookdb.h>
25#include <qpe/event.h> 25#include <qpe/event.h>
26 26
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qlist.h> 28#include <qlist.h>
29 29
30#include "TodoItem.h" 30#include "TodoItem.h"
31#include "todayconfig.h" 31#include "todayconfig.h"
32#include "todaybase.h" 32#include "todaybase.h"
33#include "clickablelabel.h" 33#include "clickablelabel.h"
34 34
35class QVBoxLayout; 35class QVBoxLayout;
36 36
37class Today : public TodayBase { 37class Today : public TodayBase {
38 Q_OBJECT 38 Q_OBJECT
39 39
40 public: 40 public:
41 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 41 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
42 ~Today(); 42 ~Today();
43 43
44 private slots: 44 private slots:
45 void startConfig(); 45 void startConfig();
46 void startTodo(); 46 void startTodo();
47 void startDatebook(); 47 void startDatebook();
48 void startMail(); 48 void startMail();
49 void draw(); 49 void draw();
50 private: 50 private:
51 void init(); 51 void init();
52 void getDates(); 52 void getDates();
53 void getTodo(); 53 void getTodo();
54 void getMail(); 54 void getMail();
55 void autoStart(); 55 void autoStart();
56 bool checkIfModified(); 56 bool checkIfModified();
57 QList<TodoItem> loadTodo(const char *filename); 57 QList<TodoItem> loadTodo(const char *filename);
58 private: 58 private:
59 DateBookDB *db; 59 DateBookDB *db;
60 todayconfig *conf; 60 todayconfig *conf;
61 //Config cfg; 61 //Config cfg;
62 int MAX_LINES_TASK; 62 int MAX_LINES_TASK;
63 int MAX_CHAR_CLIP; 63 int MAX_CHAR_CLIP;
64 int MAX_LINES_MEET; 64 int MAX_LINES_MEET;
65 int SHOW_LOCATION; 65 int SHOW_LOCATION;
66 int SHOW_NOTES; 66 int SHOW_NOTES;
67}; 67};
68 68
69class DateBookEvent: public ClickableLabel { 69class DateBookEvent: public ClickableLabel {
70 Q_OBJECT 70 Q_OBJECT
71public: 71public:
72 DateBookEvent(const EffectiveEvent &ev, 72 DateBookEvent(const EffectiveEvent &ev,
73 QWidget* parent = 0, const char* name = 0, 73 QWidget* parent = 0, const char* name = 0,
74 WFlags fl = 0); 74 WFlags fl = 0);
75signals: 75signals:
76 void editEvent(const Event &e); 76 void editEvent(const Event &e);
77private slots: 77private slots:
78 void editMe(); 78 void editMe();
79private: 79private:
80 const EffectiveEvent event; 80 const EffectiveEvent event;
81}; 81};
82 82
83class DateBookEventLater: public ClickableLabel {
84 Q_OBJECT
85public:
86 DateBookEventLater(const EffectiveEvent &ev,
87 QWidget* parent = 0, const char* name = 0,
88 WFlags fl = 0);
89signals:
90 void editEvent(const Event &e);
91private slots:
92 void editMe();
93private:
94 const EffectiveEvent event;
95};
96
83#endif // TODAY_H 97#endif // TODAY_H
84 98