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