-rw-r--r-- | core/pim/today/today.cpp | 149 |
1 files changed, 92 insertions, 57 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index d715fc1..69bcb68 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -41,2 +41,3 @@ | |||
41 | #include <qfileinfo.h> | 41 | #include <qfileinfo.h> |
42 | #include <qlayout.h> | ||
42 | 43 | ||
@@ -47,2 +48,3 @@ | |||
47 | 48 | ||
49 | |||
48 | int MAX_LINES_TASK; | 50 | int MAX_LINES_TASK; |
@@ -55,2 +57,4 @@ int ONLY_LATER; | |||
55 | int AUTOSTART; | 57 | int AUTOSTART; |
58 | |||
59 | int NEW_START=1; | ||
56 | /* | 60 | /* |
@@ -71,3 +75,2 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) | |||
71 | 75 | ||
72 | |||
73 | void Today::autoStart() { | 76 | void Today::autoStart() { |
@@ -205,3 +208,6 @@ void Today::getDates() { | |||
205 | QDate date = QDate::currentDate(); | 208 | QDate date = QDate::currentDate(); |
206 | QTime time = QTime::currentTime(); | 209 | QWidget* AllDateBookEvents = new QWidget( ); |
210 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); | ||
211 | //QTime time = QTime::currentTime(); | ||
212 | |||
207 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); | 213 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); |
@@ -223,61 +229,18 @@ void Today::getDates() { | |||
223 | if ( count <= MAX_LINES_MEET ) { | 229 | if ( count <= MAX_LINES_MEET ) { |
224 | //cout << time.toString() << endl; | ||
225 | //cout << TimeString::dateString((*it).event().end()) << endl; | ||
226 | 230 | ||
227 | // decide if to get all day or only later appointments | ||
228 | if (!ONLY_LATER) { | ||
229 | msg += "<B>" + (*it).description() + "</B>"; | ||
230 | if ( (*it).event().hasAlarm() ) { | ||
231 | msg += " <b>[with alarm]</b>"; | ||
232 | } | ||
233 | // include location or not | ||
234 | if (SHOW_LOCATION == 1) { | ||
235 | msg += "<BR><i>" + (*it).location(); | ||
236 | msg += "</i>"; | ||
237 | } | ||
238 | 231 | ||
239 | if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) { | 232 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents); |
240 | msg += "<br>All day"; | 233 | layoutDates->addWidget(l); |
241 | } else { | 234 | connect (l, SIGNAL(editEvent(const Event &)), |
242 | // start time of event | 235 | this, SIGNAL(editEvent(const Event &))); |
243 | msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) ) | ||
244 | // end time of event | ||
245 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ); | ||
246 | } | ||
247 | msg += "<BR>"; | ||
248 | // include possible note or not | ||
249 | if (SHOW_NOTES == 1) { | ||
250 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | ||
251 | } | ||
252 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { | ||
253 | msg += "<B>" + (*it).description() + "</B>"; | ||
254 | if ( (*it).event().hasAlarm() ) { | ||
255 | msg += " <b>[with alarm]</b>"; | ||
256 | } | ||
257 | // include location or not | ||
258 | if (SHOW_LOCATION == 1) { | ||
259 | msg+= "<BR><i>" + (*it).location(); | ||
260 | msg += "</i>"; | ||
261 | } | 236 | } |
262 | 237 | ||
263 | if ( (TimeString::timeString(QTime((*it).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((*it).event().end().time()) ) == "23:59") ) { | ||
264 | msg += "<br>All day"; | ||
265 | } else { | ||
266 | // start time of event | ||
267 | msg += "<br>" + TimeString::timeString(QTime((*it).event().start().time()) ) | ||
268 | // end time of event | ||
269 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ); | ||
270 | } | 238 | } |
271 | msg += "<BR>"; | 239 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
272 | // include possible note or not | 240 | sv1->addChild(AllDateBookEvents); |
273 | if (SHOW_NOTES == 1) { | 241 | |
274 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 242 | //if (msg.isEmpty()) { |
275 | } | 243 | // msg = tr("No more appointments today"); |
276 | } | 244 | //} |
277 | } | 245 | //DatesField->setText(msg); |
278 | } | ||
279 | if (msg.isEmpty()) { | ||
280 | msg = tr("No more appointments today"); | ||
281 | } | ||
282 | DatesField->setText(msg); | ||
283 | } | 246 | } |
@@ -373,5 +336,6 @@ void Today::getTodo() { | |||
373 | // if the todolist.xml file was not modified in between, do not parse it. | 336 | // if the todolist.xml file was not modified in between, do not parse it. |
374 | if (!checkIfModified()) { | 337 | if (!checkIfModified() && !NEW_START) { |
375 | return; | 338 | return; |
376 | } | 339 | } |
340 | NEW_START=0; | ||
377 | 341 | ||
@@ -443 +407,72 @@ Today::~Today() { | |||
443 | } | 407 | } |
408 | |||
409 | |||
410 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | ||
411 | QWidget* parent = 0, | ||
412 | const char* name = 0, | ||
413 | WFlags fl = 0) : | ||
414 | ClickableLabel(parent,name,fl), event(ev) { | ||
415 | |||
416 | QString msg; | ||
417 | QTime time = QTime::currentTime(); | ||
418 | |||
419 | if (!ONLY_LATER) { | ||
420 | msg += "<B>" + (ev).description() + "</B>"; | ||
421 | if ( (ev).event().hasAlarm() ) { | ||
422 | msg += " <b>[with alarm]</b>"; | ||
423 | } | ||
424 | // include location or not | ||
425 | if (SHOW_LOCATION == 1) { | ||
426 | msg += "<BR><i>" + (ev).location(); | ||
427 | msg += "</i>"; | ||
428 | } | ||
429 | |||
430 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | ||
431 | msg += "<br>All day"; | ||
432 | } else { | ||
433 | // start time of event | ||
434 | msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) | ||
435 | // end time of event | ||
436 | + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); | ||
437 | } | ||
438 | msg += "<BR>"; | ||
439 | // include possible note or not | ||
440 | if (SHOW_NOTES == 1) { | ||
441 | msg += " <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | ||
442 | } | ||
443 | } else if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { | ||
444 | msg += "<B>" + (ev).description() + "</B>"; | ||
445 | if ( (ev).event().hasAlarm() ) { | ||
446 | msg += " <b>[with alarm]</b>"; | ||
447 | } | ||
448 | // include location or not | ||
449 | if (SHOW_LOCATION == 1) { | ||
450 | msg+= "<BR><i>" + (ev).location(); | ||
451 | msg += "</i>"; | ||
452 | } | ||
453 | |||
454 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | ||
455 | msg += "<br>All day"; | ||
456 | } else { | ||
457 | // start time of event | ||
458 | msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) | ||
459 | // end time of event | ||
460 | + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); | ||
461 | } | ||
462 | // include possible note or not | ||
463 | if (SHOW_NOTES == 1) { | ||
464 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | ||
465 | } | ||
466 | } | ||
467 | |||
468 | setText(msg); | ||
469 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | ||
470 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | ||
471 | } | ||
472 | |||
473 | void DateBookEvent::editMe() { | ||
474 | emit editEvent(event.event()); | ||
475 | } | ||
476 | |||
477 | |||
478 | |||