summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-06-27 14:33:51 (UTC)
committer harlekin <harlekin>2002-06-27 14:33:51 (UTC)
commit63d7fd9b233a5b6a9e3670b6ef1c09a2e87ffa42 (patch) (unidiff)
treee5c81e0728f394fba918f9e71cbacd33de870aee
parent540fd6a4a7cc86070c94f41833c4b9b9fa0e9824 (diff)
downloadopie-63d7fd9b233a5b6a9e3670b6ef1c09a2e87ffa42.zip
opie-63d7fd9b233a5b6a9e3670b6ef1c09a2e87ffa42.tar.gz
opie-63d7fd9b233a5b6a9e3670b6ef1c09a2e87ffa42.tar.bz2
should fix bug #83
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index ad1ec90..62becb0 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -1,631 +1,637 @@
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 21
22#include <qpe/timestring.h> 22#include <qpe/timestring.h>
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25//#include <qpe/qprocess.h>
26#include <qpe/resource.h> 25#include <qpe/resource.h>
27#include <qpe/contact.h> 26#include <qpe/contact.h>
28#include <qpe/global.h> 27#include <qpe/global.h>
29#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
30 29
31#include <qdir.h> 30#include <qdir.h>
32#include <qfile.h> 31#include <qfile.h>
33#include <qdatetime.h> 32#include <qdatetime.h>
34#include <qtextstream.h> 33#include <qtextstream.h>
35#include <qcheckbox.h> 34#include <qcheckbox.h>
36#include <qspinbox.h> 35#include <qspinbox.h>
37#include <qpushbutton.h> 36#include <qpushbutton.h>
38#include <qlabel.h> 37#include <qlabel.h>
39#include <qtimer.h> 38#include <qtimer.h>
40#include <qpixmap.h> 39#include <qpixmap.h>
41//#include <qfileinfo.h>
42#include <qlayout.h> 40#include <qlayout.h>
43#include <qtl.h> 41#include <qtl.h>
44 42
45 43
46//#include <iostream.h>
47#include <unistd.h> 44#include <unistd.h>
48#include <stdlib.h> 45#include <stdlib.h>
49 46
50int MAX_LINES_TASK; 47int MAX_LINES_TASK;
51int MAX_CHAR_CLIP; 48int MAX_CHAR_CLIP;
52int MAX_LINES_MEET; 49int MAX_LINES_MEET;
53int SHOW_LOCATION; 50int SHOW_LOCATION;
54int SHOW_NOTES; 51int SHOW_NOTES;
55// show only later dates 52// show only later dates
56int ONLY_LATER; 53int ONLY_LATER;
57int AUTOSTART; 54int AUTOSTART;
58int NEW_START=1; 55int NEW_START=1;
59QString AUTOSTART_TIMER; 56QString AUTOSTART_TIMER;
60int NEXTDAYS=1; 57int NEXTDAYS=1;
61 58
62 59
63/* Constructs a Example which is a child of 'parent', with the 60/* Constructs a Example which is a child of 'parent', with the
64 * name 'name' and widget flags set to 'f' 61 * name 'name' and widget flags set to 'f'
65 */ 62 */
66Today::Today( QWidget* parent, const char* name, WFlags fl ) 63Today::Today( QWidget* parent, const char* name, WFlags fl )
67 : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { 64 : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) {
68 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); 65 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) );
69 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); 66 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) );
70 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); 67 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) );
71 QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); 68 QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) );
72 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT(editCard() ) ); 69 QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT(editCard() ) );
73 70
74#if defined(Q_WS_QWS) 71#if defined(Q_WS_QWS)
75#if !defined(QT_NO_COP) 72#if !defined(QT_NO_COP)
76 QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); 73 QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this );
77 connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), 74 connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)),
78 this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); 75 this, SLOT ( channelReceived(const QCString &, const QByteArray &)) );
79#endif 76#endif
80#endif 77#endif
81 78
82 79
83 80
84 db = NULL; 81 db = NULL;
85 setOwnerField(); 82 setOwnerField();
86 todo = new ToDoDB; 83 todo = new ToDoDB;
87 draw(); 84 draw();
88 getTodo(); 85 getTodo();
89 autoStart(); 86 autoStart();
90} 87}
91 88
92/* 89/*
93 * Qcop receive method. 90 * Qcop receive method.
94 */ 91 */
95void Today::channelReceived(const QCString &msg, const QByteArray & data) { 92void Today::channelReceived(const QCString &msg, const QByteArray & data) {
96 QDataStream stream(data, IO_ReadOnly ); 93 QDataStream stream(data, IO_ReadOnly );
97 if ( msg == "message(QString)" ) { 94 if ( msg == "message(QString)" ) {
98 QString message; 95 QString message;
99 stream >> message; 96 stream >> message;
100 setOwnerField(message); 97 setOwnerField(message);
101 } 98 }
102 99
103} 100}
104 101
105/* 102/*
106 * Initialises the owner field with the default value, the username 103 * Initialises the owner field with the default value, the username
107 */ 104 */
108void Today::setOwnerField() { 105void Today::setOwnerField() {
109 QString file = Global::applicationFileName("addressbook", "businesscard.vcf"); 106 QString file = Global::applicationFileName("addressbook", "businesscard.vcf");
110 if (QFile::exists(file)) { 107 if (QFile::exists(file)) {
111 Contact cont = Contact::readVCard(file)[0]; 108 Contact cont = Contact::readVCard(file)[0];
112 QString returnString = cont.fullName(); 109 QString returnString = cont.fullName();
113 OwnerField->setText( "<b>" +tr ("Owned by ") + returnString + "</b>"); 110 OwnerField->setText( "<b>" +tr ("Owned by ") + returnString + "</b>");
114 } else { 111 } else {
115 OwnerField->setText( "<b>" + tr ("Please fill out the business card")+" </b>"); 112 OwnerField->setText( "<b>" + tr ("Please fill out the business card")+" </b>");
116 } 113 }
117} 114}
118 115
119/* 116/*
120 * Set the owner field with a given QString, for example per qcop. 117 * Set the owner field with a given QString, for example per qcop.
121 */ 118 */
122void Today::setOwnerField(QString &message) { 119void Today::setOwnerField(QString &message) {
123 if (!message.isEmpty()) { 120 if (!message.isEmpty()) {
124 OwnerField->setText("<b>" + message + "</b>"); 121 OwnerField->setText("<b>" + message + "</b>");
125 } 122 }
126} 123}
127 124
128/* 125/*
129 * Autostart, uses the new (opie only) autostart method in the launcher code. 126 * Autostart, uses the new (opie only) autostart method in the launcher code.
130 * If registered against that today ist started on each resume. 127 * If registered against that today ist started on each resume.
131 */ 128 */
132void Today::autoStart() { 129void Today::autoStart() {
133 Config cfg("today"); 130 Config cfg("today");
134 cfg.setGroup("Autostart"); 131 cfg.setGroup("Autostart");
135 int AUTOSTART = cfg.readNumEntry("autostart",1); 132 int AUTOSTART = cfg.readNumEntry("autostart",1);
136// qDebug(QString("%1").arg(AUTOSTART)); 133// qDebug(QString("%1").arg(AUTOSTART));
137 if (AUTOSTART) { 134 if (AUTOSTART) {
138 QCopEnvelope e("QPE/System", "autoStart(QString,QString,QString)"); 135 QCopEnvelope e("QPE/System", "autoStart(QString,QString,QString)");
139 e << QString("add"); 136 e << QString("add");
140 e << QString("today"); 137 e << QString("today");
141 e << AUTOSTART_TIMER; 138 e << AUTOSTART_TIMER;
142 } else { 139 } else {
143 qDebug("Nun in else bei autostart"); 140 qDebug("Nun in else bei autostart");
144 QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); 141 QCopEnvelope e("QPE/System", "autoStart(QString,QString)");
145 e << QString("remove"); 142 e << QString("remove");
146 e << QString("today"); 143 e << QString("today");
147 } 144 }
148} 145}
149 146
150/* 147/*
151 * Repaint method. Reread all fields. 148 * Repaint method. Reread all fields.
152 */ 149 */
153void Today::draw() { 150void Today::draw() {
154 init(); 151 init();
155 getDates(); 152 getDates();
156 getMail(); 153 getMail();
157 154
158 // if the todolist.xml file was not modified in between, do not parse it. 155 // if the todolist.xml file was not modified in between, do not parse it.
159 if (checkIfModified() || NEW_START==1) { 156 if (checkIfModified() || NEW_START==1) {
160 if (todo) delete todo; 157 if (todo) delete todo;
161 todo = new ToDoDB; 158 todo = new ToDoDB;
162 getTodo(); 159 getTodo();
163 } 160 }
164 161
165 // how often refresh 162 // how often refresh
166 QTimer::singleShot( 20*1000, this, SLOT(draw() ) ); 163 QTimer::singleShot( 20*1000, this, SLOT(draw() ) );
167} 164}
168 165
169/* 166/*
170 * Check if the todolist.xml was modified (if there are new entries. 167 * Check if the todolist.xml was modified (if there are new entries.
171 * Returns true if it was modified. 168 * Returns true if it was modified.
172 */ 169 */
173bool Today::checkIfModified() { 170bool Today::checkIfModified() {
174 171
175 QDir dir; 172 QDir dir;
176 QString homedir = dir.homeDirPath (); 173 QString homedir = dir.homeDirPath ();
177 QString time; 174 QString time;
178 175
179 Config cfg("today"); 176 Config cfg("today");
180 cfg.setGroup("Files"); 177 cfg.setGroup("Files");
181 time = cfg.readEntry("todolisttimestamp", ""); 178 time = cfg.readEntry("todolisttimestamp", "");
182 179
183 QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); 180 QFileInfo file = (homedir +"/Applications/todolist/todolist.xml");
184 QDateTime fileTime = file.lastModified(); 181 QDateTime fileTime = file.lastModified();
185 if (time.compare(fileTime.toString()) == 0) { 182 if (time.compare(fileTime.toString()) == 0) {
186 return false; 183 return false;
187 } else { 184 } else {
188 cfg.writeEntry("todolisttimestamp", fileTime.toString() ); 185 cfg.writeEntry("todolisttimestamp", fileTime.toString() );
189 cfg.write(); 186 cfg.write();
190 return true; 187 return true;
191 } 188 }
192} 189}
193 190
194 191
195/* 192/*
196 * Init stuff needed for today. Reads the config file. 193 * Init stuff needed for today. Reads the config file.
197 */ 194 */
198void Today::init() { 195void Today::init() {
199 QDate date = QDate::currentDate(); 196 QDate date = QDate::currentDate();
200 QString time = (tr( date.toString()) ); 197 QString time = (tr( date.toString()) );
201 198
202 TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); 199 TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>"));
203 200
204 // read config 201 // read config
205 Config cfg("today"); 202 Config cfg("today");
206 cfg.setGroup("BaseConfig"); 203 cfg.setGroup("BaseConfig");
207 204
208 // -- config file section -- 205 // -- config file section --
209 // how many lines should be showed in the task section 206 // how many lines should be showed in the task section
210 MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); 207 MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5);
211 // after how many chars should the be cut off on tasks and notes 208 // after how many chars should the be cut off on tasks and notes
212 MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40); 209 MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40);
213 // how many lines should be showed in the datebook section 210 // how many lines should be showed in the datebook section
214 MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); 211 MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5);
215 // If location is to be showed too, 1 to activate it. 212 // If location is to be showed too, 1 to activate it.
216 SHOW_LOCATION = cfg.readNumEntry("showlocation",1); 213 SHOW_LOCATION = cfg.readNumEntry("showlocation",1);
217 // if notes should be shown 214 // if notes should be shown
218 SHOW_NOTES = cfg.readNumEntry("shownotes",0); 215 SHOW_NOTES = cfg.readNumEntry("shownotes",0);
219 // should only later appointments be shown or all for the current day. 216 // should only later appointments be shown or all for the current day.
220 ONLY_LATER = cfg.readNumEntry("onlylater",1); 217 ONLY_LATER = cfg.readNumEntry("onlylater",1);
221 218
222 cfg.setGroup("Autostart"); 219 cfg.setGroup("Autostart");
223 AUTOSTART = cfg.readNumEntry("autostart",1); 220 AUTOSTART = cfg.readNumEntry("autostart",1);
224 AUTOSTART_TIMER = cfg.readEntry("autostartdelay", "0"); 221 AUTOSTART_TIMER = cfg.readEntry("autostartdelay", "0");
225 222
226 //db = new DateBookDB; 223 //db = new DateBookDB;
227} 224}
228 225
229/* 226/*
230 * The method for the configuration dialog. 227 * The method for the configuration dialog.
231 */ 228 */
232void Today::startConfig() { 229void Today::startConfig() {
233 230
234 conf = new todayconfig ( this, "", true ); 231 conf = new todayconfig ( this, "", true );
235 // read the config 232 // read the config
236 Config cfg("today"); 233 Config cfg("today");
237 cfg.setGroup("BaseConfig"); 234 cfg.setGroup("BaseConfig");
238 235
239 //init(); 236 //init();
240 237
241 conf->SpinBox1->setValue(MAX_LINES_MEET); 238 conf->SpinBox1->setValue(MAX_LINES_MEET);
242 // location show box 239 // location show box
243 conf->CheckBox1->setChecked(SHOW_LOCATION); 240 conf->CheckBox1->setChecked(SHOW_LOCATION);
244 // notes show box 241 // notes show box
245 conf->CheckBox2->setChecked(SHOW_NOTES); 242 conf->CheckBox2->setChecked(SHOW_NOTES);
246 // task lines 243 // task lines
247 conf->SpinBox2->setValue(MAX_LINES_TASK); 244 conf->SpinBox2->setValue(MAX_LINES_TASK);
248 // clip when? 245 // clip when?
249 conf->SpinBox7->setValue(MAX_CHAR_CLIP); 246 conf->SpinBox7->setValue(MAX_CHAR_CLIP);
250 // only later 247 // only later
251 conf->CheckBox3->setChecked(ONLY_LATER); 248 conf->CheckBox3->setChecked(ONLY_LATER);
252 // if today should be autostarted 249 // if today should be autostarted
253 conf->CheckBoxAuto->setChecked(AUTOSTART); 250 conf->CheckBoxAuto->setChecked(AUTOSTART);
254 // autostart only if device has been suspended for X minutes 251 // autostart only if device has been suspended for X minutes
255 conf->SpinBoxTime->setValue( AUTOSTART_TIMER.toInt() ); 252 conf->SpinBoxTime->setValue( AUTOSTART_TIMER.toInt() );
256 253
257 conf->exec(); 254 conf->exec();
258 255
259 int maxlinestask = conf->SpinBox2->value(); 256 int maxlinestask = conf->SpinBox2->value();
260 int maxmeet = conf->SpinBox1->value(); 257 int maxmeet = conf->SpinBox1->value();
261 int location = conf->CheckBox1->isChecked(); 258 int location = conf->CheckBox1->isChecked();
262 int notes = conf->CheckBox2->isChecked(); 259 int notes = conf->CheckBox2->isChecked();
263 int maxcharclip = conf->SpinBox7->value(); 260 int maxcharclip = conf->SpinBox7->value();
264 int onlylater = conf->CheckBox3->isChecked(); 261 int onlylater = conf->CheckBox3->isChecked();
265 int autostart = conf->CheckBoxAuto->isChecked(); 262 int autostart = conf->CheckBoxAuto->isChecked();
266 int autostartdelay = conf->SpinBoxTime->value(); 263 int autostartdelay = conf->SpinBoxTime->value();
267 264
268 265
269 cfg.writeEntry("maxlinestask",maxlinestask); 266 cfg.writeEntry("maxlinestask",maxlinestask);
270 cfg.writeEntry("maxcharclip", maxcharclip); 267 cfg.writeEntry("maxcharclip", maxcharclip);
271 cfg.writeEntry("maxlinesmeet",maxmeet); 268 cfg.writeEntry("maxlinesmeet",maxmeet);
272 cfg.writeEntry("showlocation",location); 269 cfg.writeEntry("showlocation",location);
273 cfg.writeEntry("shownotes", notes); 270 cfg.writeEntry("shownotes", notes);
274 cfg.writeEntry("onlylater", onlylater); 271 cfg.writeEntry("onlylater", onlylater);
275 cfg.setGroup("Autostart"); 272 cfg.setGroup("Autostart");
276 cfg.writeEntry("autostart", autostart); 273 cfg.writeEntry("autostart", autostart);
277 cfg.writeEntry("autostartdelay", autostartdelay); 274 cfg.writeEntry("autostartdelay", autostartdelay);
278 275
279 // sync it to "disk" 276 // sync it to "disk"
280 cfg.write(); 277 cfg.write();
281 NEW_START=1; 278 NEW_START=1;
282 draw(); 279 draw();
283 AUTOSTART=autostart; 280 AUTOSTART=autostart;
284 autoStart(); 281 autoStart();
285} 282}
286 283
287 284
288/* 285/*
289 * Get all events that are in the datebook xml file for today 286 * Get all events that are in the datebook xml file for today
290 */ 287 */
291void Today::getDates() { 288void Today::getDates() {
292 QDate date = QDate::currentDate(); 289 QDate date = QDate::currentDate();
293 290
294 if (AllDateBookEvents) delete AllDateBookEvents; 291 if (AllDateBookEvents) delete AllDateBookEvents;
295 AllDateBookEvents = new QWidget( ); 292 AllDateBookEvents = new QWidget( );
296 QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); 293 QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents);
297 294
298 if (db) { 295 if (db) {
299 delete db; 296 delete db;
300 } 297 }
301 db = new DateBookDB; 298 db = new DateBookDB;
302 299
303 QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); 300 QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date);
304 301
305 qBubbleSort(list); 302 qBubbleSort(list);
306 // printf("Get dates\n"); 303 // printf("Get dates\n");
307 304
308 Config config( "qpe" ); 305 Config config( "qpe" );
309 // if 24 h format 306 // if 24 h format
310 //bool ampm = config.readBoolEntry( "AMPM", TRUE ); 307 //bool ampm = config.readBoolEntry( "AMPM", TRUE );
311 308
312 int count=0; 309 int count=0;
313 310
314 if ( list.count() > 0 ) { 311 if ( list.count() > 0 ) {
315 312
316 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); 313 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin();
317 it!=list.end(); ++it ) { 314 it!=list.end(); ++it ) {
318 315
319 316
320 if ( count <= MAX_LINES_MEET ) { 317 if ( count <= MAX_LINES_MEET ) {
321 318
322 QTime time = QTime::currentTime(); 319 QTime time = QTime::currentTime();
323 320
324 if (!ONLY_LATER) { 321 if (!ONLY_LATER) {
325 count++; 322 count++;
326 DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); 323 DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES);
327 layoutDates->addWidget(l); 324 layoutDates->addWidget(l);
328 connect (l, SIGNAL(editEvent(const Event &)), 325 connect (l, SIGNAL(editEvent(const Event &)),
329 this, SLOT(editEvent(const Event &))); 326 this, SLOT(editEvent(const Event &)));
330 } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { 327 } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) {
331 count++; 328 count++;
332 329
333 // show only later appointments 330 // show only later appointments
334 DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); 331 DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES);
335 layoutDates->addWidget(l); 332 layoutDates->addWidget(l);
336 connect (l, SIGNAL(editEvent(const Event &)), 333 connect (l, SIGNAL(editEvent(const Event &)),
337 this, SLOT(editEvent(const Event &))); 334 this, SLOT(editEvent(const Event &)));
338 } 335 }
339 } 336 }
340 } 337 }
341 if (ONLY_LATER && count==0) { 338 if (ONLY_LATER && count==0) {
342 QLabel* noMoreEvents = new QLabel(AllDateBookEvents); 339 QLabel* noMoreEvents = new QLabel(AllDateBookEvents);
343 noMoreEvents->setText(tr("No more appointments today")); 340 noMoreEvents->setText(tr("No more appointments today"));
344 layoutDates->addWidget(noMoreEvents); 341 layoutDates->addWidget(noMoreEvents);
345 } 342 }
346 } else { 343 } else {
347 QLabel* noEvents = new QLabel(AllDateBookEvents); 344 QLabel* noEvents = new QLabel(AllDateBookEvents);
348 noEvents->setText(tr("No appointments today")); 345 noEvents->setText(tr("No appointments today"));
349 layoutDates->addWidget(noEvents); 346 layoutDates->addWidget(noEvents);
350 } 347 }
351 348
352 layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 349 layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
353 sv1->addChild(AllDateBookEvents); 350 sv1->addChild(AllDateBookEvents);
354 AllDateBookEvents->show(); 351 AllDateBookEvents->show();
355} 352}
356 353
357 354
358void Today::getMail() { 355void Today::getMail() {
359 Config cfg("opiemail"); 356 Config cfg("opiemail");
360 cfg.setGroup("today"); 357 cfg.setGroup("today");
361 358
362 // how many lines should be showed in the task section 359 // how many lines should be showed in the task section
363 int NEW_MAILS = cfg.readNumEntry("newmails",0); 360 int NEW_MAILS = cfg.readNumEntry("newmails",0);
364 int OUTGOING = cfg.readNumEntry("outgoing",0); 361 int OUTGOING = cfg.readNumEntry("outgoing",0);
365 362
366 QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); 363 QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING);
367 364
368 MailField->setText(output); 365 MailField->setText(output);
369} 366}
370 367
371 368
372/* 369/*
373 * Get the todos 370 * Get the todos
374 */ 371 */
375void Today::getTodo() { 372void Today::getTodo() {
376 373
377 QString output; 374 QString output;
378 QString tmpout; 375 QString tmpout;
379 int count = 0; 376 int count = 0;
380 int ammount = 0; 377 int ammount = 0;
381 378
382 // get overdue todos first 379 // get overdue todos first
383 QValueList<ToDoEvent> overDueList = todo->overDue(); 380 QValueList<ToDoEvent> overDueList = todo->overDue();
384 qBubbleSort(overDueList); 381 qBubbleSort(overDueList);
385 for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); 382 for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin();
386 it!=overDueList.end(); ++it ) { 383 it!=overDueList.end(); ++it ) {
387 if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { 384 if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) {
388 tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; 385 QString desc = (*it).summary();
389 ammount++; 386 if( desc.isEmpty() ) {
390 } 387 desc = (*it).description();
388 }
389 tmpout += "<font color=#e00000><b>-" + desc.mid(0, MAX_CHAR_CLIP) + "</b></font><br>";
390
391 ammount++;
392 }
391 } 393 }
392 394
393 // get total number of still open todos 395 // get total number of still open todos
394 QValueList<ToDoEvent> openTodo = todo->rawToDos(); 396 QValueList<ToDoEvent> openTodo = todo->rawToDos();
395 qBubbleSort(openTodo); 397 qBubbleSort(openTodo);
396 for ( QValueList<ToDoEvent>::Iterator it=openTodo.begin(); 398 for ( QValueList<ToDoEvent>::Iterator it=openTodo.begin();
397 it!=openTodo.end(); ++it ) { 399 it!=openTodo.end(); ++it ) {
398 if (!(*it).isCompleted()){ 400 if (!(*it).isCompleted()){
399 count +=1; 401 count +=1;
400 // not the overdues, we allready got them, and not if we are 402 // not the overdues, we allready got them, and not if we are
401 // over the maxlines 403 // over the maxlines
402 if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { 404 if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) {
403 tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; 405 QString desc = (*it).summary();
404 ammount++; 406 if( desc.isEmpty() ) {
407 desc = (*it).description();
408 }
409 tmpout += "<b>-</b>" + desc.mid(0, MAX_CHAR_CLIP) + "<br>";
410 ammount++;
411 }
405 } 412 }
406 }
407 } 413 }
408 414
409 415
410 if (count > 0) { 416 if (count > 0) {
411 if( count == 1 ) { 417 if( count == 1 ) {
412 output = tr("There is <b> 1</b> active task: <br>" ); 418 output = tr("There is <b> 1</b> active task: <br>" );
413 } else { 419 } else {
414 output = tr("There are <b> %1</b> active tasks: <br>").arg(count); 420 output = tr("There are <b> %1</b> active tasks: <br>").arg(count);
415 } 421 }
416 output += tmpout; 422 output += tmpout;
417 } else { 423 } else {
418 output = tr("No active tasks"); 424 output = tr("No active tasks");
419 } 425 }
420 426
421 TodoField->setText(tr(output)); 427 TodoField->setText(tr(output));
422} 428}
423 429
424 430
425void Today::startAddressbook() { 431void Today::startAddressbook() {
426 QCopEnvelope e("QPE/System", "execute(QString)"); 432 QCopEnvelope e("QPE/System", "execute(QString)");
427 e << QString("addressbook"); 433 e << QString("addressbook");
428} 434}
429 435
430extern QPEApplication *todayApp; 436extern QPEApplication *todayApp;
431 437
432/* 438/*
433 * launch addressbook (personal card) 439 * launch addressbook (personal card)
434 */ 440 */
435void Today::editCard() { 441void Today::editCard() {
436 442
437 startAddressbook(); 443 startAddressbook();
438 444
439 while( !QCopChannel::isRegistered("QPE/Addressbook")) todayApp->processEvents(); 445 while( !QCopChannel::isRegistered("QPE/Addressbook")) todayApp->processEvents();
440 QCopEnvelope v("QPE/Addressbook", "editPersonalAndClose()"); 446 QCopEnvelope v("QPE/Addressbook", "editPersonalAndClose()");
441} 447}
442 448
443/* 449/*
444 * launches datebook 450 * launches datebook
445 */ 451 */
446void Today::startDatebook() { 452void Today::startDatebook() {
447 QCopEnvelope e("QPE/System", "execute(QString)"); 453 QCopEnvelope e("QPE/System", "execute(QString)");
448 e << QString("datebook"); 454 e << QString("datebook");
449} 455}
450 456
451/* 457/*
452 * starts the edit dialog as known from datebook 458 * starts the edit dialog as known from datebook
453 */ 459 */
454void Today::editEvent(const Event &e) { 460void Today::editEvent(const Event &e) {
455 startDatebook(); 461 startDatebook();
456 462
457 while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); 463 while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents();
458 QCopEnvelope env("QPE/Datebook", "editEvent(int)"); 464 QCopEnvelope env("QPE/Datebook", "editEvent(int)");
459 env << e.uid(); 465 env << e.uid();
460} 466}
461 467
462/* 468/*
463 * launches todolist 469 * launches todolist
464 */ 470 */
465void Today::startTodo() { 471void Today::startTodo() {
466 QCopEnvelope e("QPE/System", "execute(QString)"); 472 QCopEnvelope e("QPE/System", "execute(QString)");
467 e << QString("todolist"); 473 e << QString("todolist");
468} 474}
469 475
470/* 476/*
471 * launch opiemail 477 * launch opiemail
472 */ 478 */
473void Today::startMail() { 479void Today::startMail() {
474 QCopEnvelope e("QPE/System", "execute(QString)"); 480 QCopEnvelope e("QPE/System", "execute(QString)");
475 e << QString("opiemail"); 481 e << QString("opiemail");
476//Right now start both, maybe decide which to rum via config file .. 482//Right now start both, maybe decide which to rum via config file ..
477 QCopEnvelope f("QPE/System", "execute(QString)"); 483 QCopEnvelope f("QPE/System", "execute(QString)");
478 f << QString("qtmail"); 484 f << QString("qtmail");
479} 485}
480 486
481 487
482Today::~Today() { 488Today::~Today() {
483} 489}
484 490
485/* 491/*
486 * Gets the events for the current day, if it should get all dates 492 * Gets the events for the current day, if it should get all dates
487 */ 493 */
488DateBookEvent::DateBookEvent(const EffectiveEvent &ev, 494DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
489 QWidget* parent, 495 QWidget* parent,
490 int SHOW_LOCATION, 496 int SHOW_LOCATION,
491 int SHOW_NOTES, 497 int SHOW_NOTES,
492 const char* name, 498 const char* name,
493 WFlags fl) : 499 WFlags fl) :
494 OClickableLabel(parent,name,fl), event(ev) { 500 OClickableLabel(parent,name,fl), event(ev) {
495 501
496 QString msg; 502 QString msg;
497 //QTime time = QTime::currentTime(); 503 //QTime time = QTime::currentTime();
498 504
499 Config config( "qpe" ); 505 Config config( "qpe" );
500 config.setGroup( "Time" ); 506 config.setGroup( "Time" );
501 // if 24 h format 507 // if 24 h format
502 ampm = config.readBoolEntry( "AMPM", TRUE ); 508 ampm = config.readBoolEntry( "AMPM", TRUE );
503 509
504 510
505 if (!ONLY_LATER) { 511 if (!ONLY_LATER) {
506 msg += "<B>" + (ev).description() + "</B>"; 512 msg += "<B>" + (ev).description() + "</B>";
507 if ( (ev).event().hasAlarm() ) { 513 if ( (ev).event().hasAlarm() ) {
508 msg += " <b>[with alarm]</b>"; 514 msg += " <b>[with alarm]</b>";
509 } 515 }
510 // include location or not 516 // include location or not
511 if (SHOW_LOCATION == 1) { 517 if (SHOW_LOCATION == 1) {
512 msg += "<BR><i>" + (ev).location() + "</i>"; 518 msg += "<BR><i>" + (ev).location() + "</i>";
513 } 519 }
514 520
515 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { 521 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) {
516 msg += "<br>All day"; 522 msg += "<br>All day";
517 } else { 523 } else {
518 // start time of event 524 // start time of event
519 msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) 525 msg += "<br>" + ampmTime(QTime((ev).event().start().time()) )
520 // end time of event 526 // end time of event
521 + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); 527 + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) );
522 } 528 }
523 529
524 // include possible note or not 530 // include possible note or not
525 if (SHOW_NOTES == 1) { 531 if (SHOW_NOTES == 1) {
526 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); 532 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP);
527 } 533 }
528 } 534 }
529 setText(msg); 535 setText(msg);
530 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 536 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
531 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 537 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
532} 538}
533 539
534 540
535QString DateBookEvent::ampmTime(QTime tm) { 541QString DateBookEvent::ampmTime(QTime tm) {
536 542
537 QString s; 543 QString s;
538 if( ampm ) { 544 if( ampm ) {
539 int hour = tm.hour(); 545 int hour = tm.hour();
540 if (hour == 0) 546 if (hour == 0)
541 hour = 12; 547 hour = 12;
542 if (hour > 12) 548 if (hour > 12)
543 hour -= 12; 549 hour -= 12;
544 s.sprintf( "%2d:%02d %s", hour, tm.minute(), 550 s.sprintf( "%2d:%02d %s", hour, tm.minute(),
545 (tm.hour() >= 12) ? "PM" : "AM" ); 551 (tm.hour() >= 12) ? "PM" : "AM" );
546 return s; 552 return s;
547 } else { 553 } else {
548 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); 554 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
549 return s; 555 return s;
550 } 556 }
551 557
552} 558}
553 559
554 560
555DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, 561DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
556 QWidget* parent, 562 QWidget* parent,
557 int SHOW_LOCATION, 563 int SHOW_LOCATION,
558 int SHOW_NOTES, 564 int SHOW_NOTES,
559 const char* name, 565 const char* name,
560 WFlags fl) : 566 WFlags fl) :
561 OClickableLabel(parent,name,fl), event(ev) { 567 OClickableLabel(parent,name,fl), event(ev) {
562 568
563 QString msg; 569 QString msg;
564 QTime time = QTime::currentTime(); 570 QTime time = QTime::currentTime();
565 571
566 Config config( "qpe" ); 572 Config config( "qpe" );
567 config.setGroup( "Time" ); 573 config.setGroup( "Time" );
568 // if 24 h format 574 // if 24 h format
569 ampm = config.readBoolEntry( "AMPM", TRUE ); 575 ampm = config.readBoolEntry( "AMPM", TRUE );
570 576
571 577
572 if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { 578 if ((time.toString() <= TimeString::dateString((ev).event().end())) ) {
573 // show only later appointments 579 // show only later appointments
574 msg += "<B>" + (ev).description() + "</B>"; 580 msg += "<B>" + (ev).description() + "</B>";
575 if ( (ev).event().hasAlarm() ) { 581 if ( (ev).event().hasAlarm() ) {
576 msg += " <b>[with alarm]</b>"; 582 msg += " <b>[with alarm]</b>";
577 } 583 }
578 // include location or not 584 // include location or not
579 if (SHOW_LOCATION == 1) { 585 if (SHOW_LOCATION == 1) {
580 msg += "<BR><i>" + (ev).location() + "</i>"; 586 msg += "<BR><i>" + (ev).location() + "</i>";
581 } 587 }
582 588
583 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { 589 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) {
584 msg += "<br>All day"; 590 msg += "<br>All day";
585 } else { 591 } else {
586 // start time of event 592 // start time of event
587 msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) 593 msg += "<br>" + ampmTime(QTime((ev).event().start().time()) )
588 // end time of event 594 // end time of event
589 + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); 595 + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) );
590 } 596 }
591 // include possible note or not 597 // include possible note or not
592 if (SHOW_NOTES == 1) { 598 if (SHOW_NOTES == 1) {
593 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); 599 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP);
594 } 600 }
595 } 601 }
596 602
597 setText(msg); 603 setText(msg);
598 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 604 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
599 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 605 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
600} 606}
601 607
602 608
603QString DateBookEventLater::ampmTime(QTime tm) { 609QString DateBookEventLater::ampmTime(QTime tm) {
604 610
605 QString s; 611 QString s;
606 if( ampm ) { 612 if( ampm ) {
607 int hour = tm.hour(); 613 int hour = tm.hour();
608 if (hour == 0) 614 if (hour == 0)
609 hour = 12; 615 hour = 12;
610 if (hour > 12) 616 if (hour > 12)
611 hour -= 12; 617 hour -= 12;
612 s.sprintf( "%2d:%02d %s", hour, tm.minute(), 618 s.sprintf( "%2d:%02d %s", hour, tm.minute(),
613 (tm.hour() >= 12) ? "PM" : "AM" ); 619 (tm.hour() >= 12) ? "PM" : "AM" );
614 return s; 620 return s;
615 } else { 621 } else {
616 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); 622 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
617 return s; 623 return s;
618 } 624 }
619 625
620} 626}
621 627
622 628
623void DateBookEvent::editMe() { 629void DateBookEvent::editMe() {
624 emit editEvent(event.event()); 630 emit editEvent(event.event());
625} 631}
626 632
627void DateBookEventLater::editMe() { 633void DateBookEventLater::editMe() {
628 emit editEvent(event.event()); 634 emit editEvent(event.event());
629} 635}
630 636
631 637