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