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