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