author | harlekin <harlekin> | 2002-03-12 00:11:24 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-03-12 00:11:24 (UTC) |
commit | 4c020c281eb21a92175b47330fb7ac60184a2bca (patch) (unidiff) | |
tree | b59dc913190b04728ae96ed3730d523c2b228e75 | |
parent | 3c5feb8676f75f4e218ea0278f02d225e8985301 (diff) | |
download | opie-4c020c281eb21a92175b47330fb7ac60184a2bca.zip opie-4c020c281eb21a92175b47330fb7ac60184a2bca.tar.gz opie-4c020c281eb21a92175b47330fb7ac60184a2bca.tar.bz2 |
fixes must obvious bugs
-rw-r--r-- | core/pim/today/today.cpp | 82 | ||||
-rw-r--r-- | core/pim/today/today.h | 14 |
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 | |||
@@ -55,59 +55,58 @@ int SHOW_NOTES; | |||
55 | // show only later dates | 55 | // show only later dates |
56 | int ONLY_LATER; | 56 | int ONLY_LATER; |
57 | int AUTOSTART; | 57 | int AUTOSTART; |
58 | 58 | ||
59 | int NEW_START=1; | 59 | int 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 | */ |
64 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 64 | Today::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 | ||
76 | void Today::autoStart() { | 75 | void 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 | ||
91 | void Today::draw() { | 90 | void 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 | */ |
105 | bool Today::checkIfModified() { | 104 | bool 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", ""); |
@@ -183,80 +182,92 @@ void Today::startConfig() { | |||
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 | */ |
207 | void Today::getDates() { | 206 | void 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 | */ |
252 | QList<TodoItem> Today::loadTodo(const char *filename) { | 263 | QList<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; |
@@ -426,52 +437,75 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | |||
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 | |||
460 | DateBookEventLater::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 | ||
472 | void DateBookEvent::editMe() { | 503 | void DateBookEvent::editMe() { |
473 | emit editEvent(event.event()); | 504 | emit editEvent(event.event()); |
474 | } | 505 | } |
475 | 506 | ||
507 | void 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 | |||
@@ -67,18 +67,32 @@ class Today : public TodayBase { | |||
67 | }; | 67 | }; |
68 | 68 | ||
69 | class DateBookEvent: public ClickableLabel { | 69 | class DateBookEvent: public ClickableLabel { |
70 | Q_OBJECT | 70 | Q_OBJECT |
71 | public: | 71 | public: |
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); |
75 | signals: | 75 | signals: |
76 | void editEvent(const Event &e); | 76 | void editEvent(const Event &e); |
77 | private slots: | 77 | private slots: |
78 | void editMe(); | 78 | void editMe(); |
79 | private: | 79 | private: |
80 | const EffectiveEvent event; | 80 | const EffectiveEvent event; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | class DateBookEventLater: public ClickableLabel { | ||
84 | Q_OBJECT | ||
85 | public: | ||
86 | DateBookEventLater(const EffectiveEvent &ev, | ||
87 | QWidget* parent = 0, const char* name = 0, | ||
88 | WFlags fl = 0); | ||
89 | signals: | ||
90 | void editEvent(const Event &e); | ||
91 | private slots: | ||
92 | void editMe(); | ||
93 | private: | ||
94 | const EffectiveEvent event; | ||
95 | }; | ||
96 | |||
83 | #endif // TODAY_H | 97 | #endif // TODAY_H |
84 | 98 | ||