summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-03-13 00:03:08 (UTC)
committer harlekin <harlekin>2002-03-13 00:03:08 (UTC)
commit8e9330a8626076a3dd289a1abbe218eccd3a1784 (patch) (unidiff)
tree458506d9a708cf47c49268f8336b9ce7a7fafedd
parentffa1d178f1daedafe801183c8a41a06023423713 (diff)
downloadopie-8e9330a8626076a3dd289a1abbe218eccd3a1784.zip
opie-8e9330a8626076a3dd289a1abbe218eccd3a1784.tar.gz
opie-8e9330a8626076a3dd289a1abbe218eccd3a1784.tar.bz2
many bugfixes, should work right now again, also now the dates are allways in the right order, at least i hope so
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/changelog6
-rw-r--r--core/pim/today/opie-today.control2
-rw-r--r--core/pim/today/today.cpp45
-rw-r--r--core/pim/today/today.h2
4 files changed, 41 insertions, 14 deletions
diff --git a/core/pim/today/changelog b/core/pim/today/changelog
index ded4458..d0dd966 100644
--- a/core/pim/today/changelog
+++ b/core/pim/today/changelog
@@ -1,57 +1,63 @@
10.2.9
2
3* Many bugfixes.
4* Today now apparently sorts the dates _allways_ right, i would assume it
5to be a qt bug
6
10.2.8 70.2.8
2 8
3* Appointments are now clickable (connection to datebook still missing) 9* Appointments are now clickable (connection to datebook still missing)
4* autostart support (opie only) 10* autostart support (opie only)
5 11
60.2.7 120.2.7
7 13
8* check if todolist.xml was changed before parsing it 14* check if todolist.xml was changed before parsing it
9* check only every 30 sec for changes. 15* check only every 30 sec for changes.
10* some visual stuff 16* some visual stuff
11* as usual many little improvements .-) 17* as usual many little improvements .-)
12 18
130.2.6 190.2.6
14 20
15* added scrollbars to dates and todo 21* added scrollbars to dates and todo
16* all day detection 22* all day detection
17* some smaller bugfixes 23* some smaller bugfixes
18 24
190.2.5 250.2.5
20 26
21* some other minor fixes regarding autoupdate 27* some other minor fixes regarding autoupdate
22* fixed segfault with todolist > 7 entries 28* fixed segfault with todolist > 7 entries
23* fixed the "ugly grey border around buttons" issue 29* fixed the "ugly grey border around buttons" issue
24* fixed the "empty calendar field" "bug" 30* fixed the "empty calendar field" "bug"
25* shown only later appointments as option 31* shown only later appointments as option
26 32
27 33
280.2.4 340.2.4
29 35
30* added support for email 36* added support for email
31* autoupdates after 1 min 37* autoupdates after 1 min
32* QCopEnvelope instead of system() 38* QCopEnvelope instead of system()
33* starting to use qvbox in gui 39* starting to use qvbox in gui
34 40
35 41
360.2.3 420.2.3
37 43
38* the 4 am release 44* the 4 am release
39* several bugfixes 45* several bugfixes
40 46
41 47
420.2.2 480.2.2
43 49
44* started working on calling other apps 50* started working on calling other apps
45* and finished it 51* and finished it
46 52
470.2.1 530.2.1
48 54
49* images no more inline 55* images no more inline
50* config dialog 56* config dialog
51 57
520.1.1 580.1.1
53 59
54* started changelog. 60* started changelog.
55* fixed segfault on empty/nonexistant todolist.xml 61* fixed segfault on empty/nonexistant todolist.xml
56* better handling for file location 62* better handling for file location
57 63
diff --git a/core/pim/today/opie-today.control b/core/pim/today/opie-today.control
index 5ad8f01..f875624 100644
--- a/core/pim/today/opie-today.control
+++ b/core/pim/today/opie-today.control
@@ -1,10 +1,10 @@
1Files: bin/today apps/Applications/today.desktop pics/today_icon.png pics/today/today_logo.png pics/today/config.png pics/today/mail.png 1Files: bin/today apps/Applications/today.desktop pics/today_icon.png pics/today/today_logo.png pics/today/config.png pics/today/mail.png
2Priority: optional 2Priority: optional
3Section: opie/applications 3Section: opie/applications
4Maintainer: Maximilian Reiß <max.reiss@gmx.de> 4Maintainer: Maximilian Reiß <max.reiss@gmx.de>
5Architecture: arm 5Architecture: arm
6Version: 0.2.8-$SUB_VERSION 6Version: 0.2.9-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION) 7Depends: opie-base ($QPE_VERSION)
8License: GPL 8License: GPL
9Description: today screen 9Description: today screen
10 A short overview over current appointments and tasks. 10 A short overview over current appointments and tasks.
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 1cdc6b4..81d4d36 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -1,491 +1,510 @@
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#include "minidom.h" 21#include "minidom.h"
22#include "TodoItem.h" 22#include "TodoItem.h"
23 23
24#include <qpe/datebookdb.h> 24#include <qpe/datebookdb.h>
25#include <qpe/timestring.h> 25#include <qpe/timestring.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qpe/qcopenvelope_qws.h> 27#include <qpe/qcopenvelope_qws.h>
28#include <qpe/qprocess.h> 28#include <qpe/qprocess.h>
29#include <qpe/resource.h> 29#include <qpe/resource.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 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
48
49
50int MAX_LINES_TASK; 49int MAX_LINES_TASK;
51int MAX_CHAR_CLIP; 50int MAX_CHAR_CLIP;
52int MAX_LINES_MEET; 51int MAX_LINES_MEET;
53int SHOW_LOCATION; 52int SHOW_LOCATION;
54int SHOW_NOTES; 53int SHOW_NOTES;
55// show only later dates 54// show only later dates
56int ONLY_LATER; 55int ONLY_LATER;
57int AUTOSTART; 56int AUTOSTART;
58 57
59int NEW_START=1; 58int NEW_START=1;
60/* 59/*
61 * Constructs a Example which is a child of 'parent', with the 60 * Constructs a Example which is a child of 'parent', with the
62 * name 'name' and widget flags set to 'f' 61 * name 'name' and widget flags set to 'f'
63 */ 62 */
64Today::Today( QWidget* parent, const char* name, WFlags fl ) 63Today::Today( QWidget* parent, const char* name, WFlags fl )
65 : TodayBase( parent, name, fl ) { 64 : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) {
66 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); 65 QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) );
67 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); 66 QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) );
68 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); 67 QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) );
69 QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); 68 QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) );
70 69
71 draw(); 70 draw();
72 autoStart(); 71 autoStart();
73} 72}
74 73
75void Today::autoStart() { 74void Today::autoStart() {
76 Config cfg("today"); 75 Config cfg("today");
77 cfg.setGroup("Autostart"); 76 cfg.setGroup("Autostart");
78 AUTOSTART = cfg.readNumEntry("autostart",1); 77 AUTOSTART = cfg.readNumEntry("autostart",1);
79 if (AUTOSTART) { 78 if (AUTOSTART) {
80 QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); 79 QCopEnvelope e("QPE/System", "autoStart(QString,QString)");
81 e << QString("add"); 80 e << QString("add");
82 e << QString("today"); 81 e << QString("today");
83 } else { 82 } else {
84 QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); 83 QCopEnvelope e("QPE/System", "autoStart(QString,QString)");
85 e << QString("remove"); 84 e << QString("remove");
86 e << QString("today"); 85 e << QString("today");
87 } 86 }
88} 87}
89 88
90void Today::draw() { 89void Today::draw() {
91 init(); 90 init();
92 getDates(); 91 getDates();
93 getMail(); 92 getMail();
94 getTodo(); 93 getTodo();
95 // how often refresh 94 // how often refresh
96 QTimer::singleShot( 10*1000, this, SLOT(draw() ) ); 95 QTimer::singleShot( 10*1000, this, SLOT(draw() ) );
97} 96}
98 97
99 98
100/* 99/*
101 * Check if the todolist.xml was modified (if there are new entries. 100 * Check if the todolist.xml was modified (if there are new entries.
102 * Returns true if it was modified. 101 * Returns true if it was modified.
103 */ 102 */
104bool Today::checkIfModified() { 103bool Today::checkIfModified() {
105 104
106 QDir dir; 105 QDir dir;
107 QString homedir = dir.homeDirPath (); 106 QString homedir = dir.homeDirPath ();
108 QString time; 107 QString time;
109 108
110 Config cfg("today"); 109 Config cfg("today");
111 cfg.setGroup("Files"); 110 cfg.setGroup("Files");
112 time = cfg.readEntry("todolisttimestamp", ""); 111 time = cfg.readEntry("todolisttimestamp", "");
113 112
114 QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); 113 QFileInfo file = (homedir +"/Applications/todolist/todolist.xml");
115 QDateTime fileTime = file.lastModified(); 114 QDateTime fileTime = file.lastModified();
116 if (time.compare(fileTime.toString()) == 0) { 115 if (time.compare(fileTime.toString()) == 0) {
117 return false; 116 return false;
118 } else { 117 } else {
119 cfg.writeEntry("todolisttimestamp", fileTime.toString() ); 118 cfg.writeEntry("todolisttimestamp", fileTime.toString() );
120 cfg.write(); 119 cfg.write();
121 return true; 120 return true;
122 } 121 }
123} 122}
124 123
125 124
126void Today::init() { 125void Today::init() {
127 QDate date = QDate::currentDate(); 126 QDate date = QDate::currentDate();
128 QString time = (tr( date.toString()) ); 127 QString time = (tr( date.toString()) );
129// QString time = (tr( date.toString()) , white); 128// QString time = (tr( date.toString()) , white);
130 129
131 TextLabel1->setText(time); 130 TextLabel1->setText(time);
132 db = new DateBookDB; 131 db = new DateBookDB;
133 132
134 // read config 133 // read config
135 Config cfg("today"); 134 Config cfg("today");
136 cfg.setGroup("BaseConfig"); 135 cfg.setGroup("BaseConfig");
137 136
138 // how many lines should be showed in the task section 137 // how many lines should be showed in the task section
139 MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); 138 MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5);
140 // after how many chars should the be cut off on tasks and notes 139 // after how many chars should the be cut off on tasks and notes
141 MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30); 140 MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30);
142 // how many lines should be showed in the datebook section 141 // how many lines should be showed in the datebook section
143 MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); 142 MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5);
144 // If location is to be showed too, 1 to activate it. 143 // If location is to be showed too, 1 to activate it.
145 SHOW_LOCATION = cfg.readNumEntry("showlocation",1); 144 SHOW_LOCATION = cfg.readNumEntry("showlocation",1);
146 // if notes should be shown 145 // if notes should be shown
147 SHOW_NOTES = cfg.readNumEntry("shownotes",0); 146 SHOW_NOTES = cfg.readNumEntry("shownotes",0);
148 ONLY_LATER = cfg.readNumEntry("onlylater",1); 147 ONLY_LATER = cfg.readNumEntry("onlylater",1);
149 148
150} 149}
151 150
152void Today::startConfig() { 151void Today::startConfig() {
153 conf = new todayconfig ( this, "", true ); 152 conf = new todayconfig ( this, "", true );
154 153
155 154
156 //Config cfg = new Config("today"); 155 //Config cfg = new Config("today");
157 156
158 // read the config 157 // read the config
159 Config cfg("today"); 158 Config cfg("today");
160 cfg.setGroup("BaseConfig"); 159 cfg.setGroup("BaseConfig");
161 160
162 //init(); 161 //init();
163 162
164 conf->SpinBox1->setValue(MAX_LINES_MEET); 163 conf->SpinBox1->setValue(MAX_LINES_MEET);
165 // location show box 164 // location show box
166 conf->CheckBox1->setChecked(SHOW_LOCATION); 165 conf->CheckBox1->setChecked(SHOW_LOCATION);
167 // notes show box 166 // notes show box
168 conf->CheckBox2->setChecked(SHOW_NOTES); 167 conf->CheckBox2->setChecked(SHOW_NOTES);
169 // task lines 168 // task lines
170 conf->SpinBox2->setValue(MAX_LINES_TASK); 169 conf->SpinBox2->setValue(MAX_LINES_TASK);
171 // clip when? 170 // clip when?
172 conf->SpinBox7->setValue(MAX_CHAR_CLIP); 171 conf->SpinBox7->setValue(MAX_CHAR_CLIP);
173 // only later 172 // only later
174 conf->CheckBox3->setChecked(ONLY_LATER); 173 conf->CheckBox3->setChecked(ONLY_LATER);
175 174
176 conf->CheckBoxAuto->setChecked(AUTOSTART); 175 conf->CheckBoxAuto->setChecked(AUTOSTART);
177 176
178 conf->exec(); 177 conf->exec();
179 178
180 int maxlinestask = conf->SpinBox2->value(); 179 int maxlinestask = conf->SpinBox2->value();
181 int maxmeet = conf->SpinBox1->value(); 180 int maxmeet = conf->SpinBox1->value();
182 int location = conf->CheckBox1->isChecked(); 181 int location = conf->CheckBox1->isChecked();
183 int notes = conf->CheckBox2->isChecked(); 182 int notes = conf->CheckBox2->isChecked();
184 int maxcharclip = conf->SpinBox7->value(); 183 int maxcharclip = conf->SpinBox7->value();
185 int onlylater = conf->CheckBox3->isChecked(); 184 int onlylater = conf->CheckBox3->isChecked();
186 int autostart =conf->CheckBoxAuto->isChecked(); 185 int autostart =conf->CheckBoxAuto->isChecked();
187 186
188 cfg.writeEntry("maxlinestask",maxlinestask); 187 cfg.writeEntry("maxlinestask",maxlinestask);
189 cfg.writeEntry("maxcharclip", maxcharclip); 188 cfg.writeEntry("maxcharclip", maxcharclip);
190 cfg.writeEntry("maxlinesmeet",maxmeet); 189 cfg.writeEntry("maxlinesmeet",maxmeet);
191 cfg.writeEntry("showlocation",location); 190 cfg.writeEntry("showlocation",location);
192 cfg.writeEntry("shownotes", notes); 191 cfg.writeEntry("shownotes", notes);
193 cfg.writeEntry("onlylater", onlylater); 192 cfg.writeEntry("onlylater", onlylater);
194 cfg.setGroup("Autostart"); 193 cfg.setGroup("Autostart");
195 cfg.writeEntry("autostart", autostart); 194 cfg.writeEntry("autostart", autostart);
196 // sync it to "disk" 195 // sync it to "disk"
197 cfg.write(); 196 cfg.write();
197 NEW_START=1;
198 draw(); 198 draw();
199 autoStart(); 199 autoStart();
200} 200}
201 201
202 202
203/* 203/*
204 * Get all events that are in the datebook xml file for today 204 * Get all events that are in the datebook xml file for today
205 */ 205 */
206void Today::getDates() { 206void Today::getDates() {
207 QDate date = QDate::currentDate(); 207 QDate date = QDate::currentDate();
208 QWidget* AllDateBookEvents = new QWidget( ); 208
209 if (AllDateBookEvents) delete AllDateBookEvents;
210 AllDateBookEvents = new QWidget( );
209 QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); 211 QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents);
210 212
211 QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); 213 QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date);
212 214
215 qBubbleSort(list);
216 // printf("Get dates\n");
217
213 Config config( "qpe" ); 218 Config config( "qpe" );
214 // if 24 h format 219 // if 24 h format
215 //bool ampm = config.readBoolEntry( "AMPM", TRUE ); 220 //bool ampm = config.readBoolEntry( "AMPM", TRUE );
216 221
217 int count=0; 222 int count=0;
218 223
219 if ( list.count() > 0 ) { 224 if ( list.count() > 0 ) {
220 225
221 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); 226 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin();
222 it!=list.end(); ++it ) { 227 it!=list.end(); ++it ) {
223 228
224 count++;
225 229
226 if ( count <= MAX_LINES_MEET ) { 230 if ( count <= MAX_LINES_MEET ) {
227 231
228 QTime time = QTime::currentTime(); 232 QTime time = QTime::currentTime();
229 233
230 if (!ONLY_LATER) { 234 if (!ONLY_LATER) {
235 count++;
231 DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents); 236 DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents);
232 layoutDates->addWidget(l); 237 layoutDates->addWidget(l);
233 connect (l, SIGNAL(editEvent(const Event &)), 238 connect (l, SIGNAL(editEvent(const Event &)),
234 this, SIGNAL(editEvent(const Event &))); 239 this, SLOT(editEvent(const Event &)));
235 } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { 240 } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) {
241 count++;
242
236 // show only later appointments 243 // show only later appointments
237 DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents); 244 DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents);
238 layoutDates->addWidget(l); 245 layoutDates->addWidget(l);
239 connect (l, SIGNAL(editEvent(const Event &)), 246 connect (l, SIGNAL(editEvent(const Event &)),
240 this, SIGNAL(editEvent(const Event &))); 247 this, SLOT(editEvent(const Event &)));
241 } else { 248 }
242 QLabel* noMoreEvents = new QLabel(AllDateBookEvents);
243 noMoreEvents->setText("No more appointments today");
244 layoutDates->addWidget(noMoreEvents);
245 }
246 } 249 }
250 }
251 if (ONLY_LATER && count==0) {
252 QLabel* noMoreEvents = new QLabel(AllDateBookEvents);
253 noMoreEvents->setText("No more appointments today");
254 layoutDates->addWidget(noMoreEvents);
247 } 255 }
248 } else { 256 } else {
249 QLabel* noEvents = new QLabel(AllDateBookEvents); 257 QLabel* noEvents = new QLabel(AllDateBookEvents);
250 noEvents->setText("No appointments today"); 258 noEvents->setText("No appointments today");
251 layoutDates->addWidget(noEvents); 259 layoutDates->addWidget(noEvents);
252 } 260 }
253 261
254 layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); 262 layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
255 sv1->addChild(AllDateBookEvents); 263 sv1->addChild(AllDateBookEvents);
264 AllDateBookEvents->show();
256 265
257 266
258} 267}
259 268
260/* 269/*
261 * Parse in the todolist.xml 270 * Parse in the todolist.xml
262 */ 271 */
263QList<TodoItem> Today::loadTodo(const char *filename) { 272QList<TodoItem> Today::loadTodo(const char *filename) {
264 DOM *todo; 273 DOM *todo;
265 ELE *tasks; 274 ELE *tasks;
266 ELE **tasklist; 275 ELE **tasklist;
267 ATT **attlist; 276 ATT **attlist;
268 int i, j; 277 int i, j;
269 char *description; 278 char *description;
270 int completed; 279 int completed;
271 int priority; 280 int priority;
272 TodoItem *tmp; 281 TodoItem *tmp;
273 QList<TodoItem> loadtodolist; 282 QList<TodoItem> loadtodolist;
274 283
275 todo = minidom_load(filename); 284 todo = minidom_load(filename);
276 285
277 tasks = todo->el; 286 tasks = todo->el;
278 tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ 287 tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/
279 if(tasks) { 288 if(tasks) {
280 tasklist = tasks->el; 289 tasklist = tasks->el;
281 i = 0; 290 i = 0;
282 while((tasklist) && (tasklist[i])) { 291 while((tasklist) && (tasklist[i])) {
283 attlist = tasklist[i]->at; 292 attlist = tasklist[i]->at;
284 j = 0; 293 j = 0;
285 description = NULL; 294 description = NULL;
286 priority = -1; 295 priority = -1;
287 completed = -1; 296 completed = -1;
288 while((attlist) && (attlist[j])) { 297 while((attlist) && (attlist[j])) {
289 if(!attlist[j]->name) { 298 if(!attlist[j]->name) {
290 continue; 299 continue;
291 } 300 }
292 if(!strcmp(attlist[j]->name, "Description")) { 301 if(!strcmp(attlist[j]->name, "Description")) {
293 description = attlist[j]->value; 302 description = attlist[j]->value;
294 } 303 }
295 // get Completed tag (0 or 1) 304 // get Completed tag (0 or 1)
296 if(!strcmp(attlist[j]->name, "Completed")) { 305 if(!strcmp(attlist[j]->name, "Completed")) {
297 QString s = attlist[j]->name; 306 QString s = attlist[j]->name;
298 if(s == "Completed") { 307 if(s == "Completed") {
299 completed = QString(attlist[j]->value).toInt(); 308 completed = QString(attlist[j]->value).toInt();
300 } 309 }
301 } 310 }
302 // get Priority (1 to 5) 311 // get Priority (1 to 5)
303 if(!strcmp(attlist[j]->name, "Priority")) { 312 if(!strcmp(attlist[j]->name, "Priority")) {
304 QString s = attlist[j]->name; 313 QString s = attlist[j]->name;
305 if(s == "Priority") { 314 if(s == "Priority") {
306 priority = QString(attlist[j]->value).toInt(); 315 priority = QString(attlist[j]->value).toInt();
307 } 316 }
308 } 317 }
309 j++; 318 j++;
310 } 319 }
311 if(description) { 320 if(description) {
312 tmp = new TodoItem(description, completed, priority); 321 tmp = new TodoItem(description, completed, priority);
313 loadtodolist.append(tmp); 322 loadtodolist.append(tmp);
314 } 323 }
315 i++; 324 i++;
316 } 325 }
317 } 326 }
318 327
319 minidom_free(todo); 328 minidom_free(todo);
320 329
321 return loadtodolist; 330 return loadtodolist;
322} 331}
323 332
324 333
325void Today::getMail() { 334void Today::getMail() {
326 Config cfg("opiemail"); 335 Config cfg("opiemail");
327 cfg.setGroup("today"); 336 cfg.setGroup("today");
328 337
329 // how many lines should be showed in the task section 338 // how many lines should be showed in the task section
330 int NEW_MAILS = cfg.readNumEntry("newmails",0); 339 int NEW_MAILS = cfg.readNumEntry("newmails",0);
331 int OUTGOING = cfg.readNumEntry("outgoing",0); 340 int OUTGOING = cfg.readNumEntry("outgoing",0);
332 341
333 342
334 QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); 343 QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING);
335 344
336 345
337 MailField->setText(output); 346 MailField->setText(output);
338} 347}
339 348
340 349
341/* 350/*
342 * Get the todos 351 * Get the todos
343 * 352 *
344 */ 353 */
345void Today::getTodo() { 354void Today::getTodo() {
346 355
347 // if the todolist.xml file was not modified in between, do not parse it. 356 // if the todolist.xml file was not modified in between, do not parse it.
348 if (!checkIfModified() && !NEW_START) { 357 if (!checkIfModified() && !NEW_START) {
349 return; 358 return;
350 } 359 }
351 NEW_START=0; 360 NEW_START=0;
352 361
353 QString output; 362 QString output;
354 QString tmpout; 363 QString tmpout;
355 int count = 0; 364 int count = 0;
356 365
357 QDir dir; 366 QDir dir;
358 QString homedir = dir.homeDirPath (); 367 QString homedir = dir.homeDirPath ();
359 // see if todolist.xml does exist. 368 // see if todolist.xml does exist.
360 QFile f(homedir +"/Applications/todolist/todolist.xml"); 369 QFile f(homedir +"/Applications/todolist/todolist.xml");
361 if ( f.exists() ) { 370 if ( f.exists() ) {
362 QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); 371 QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml");
363 372
364 TodoItem *item; 373 TodoItem *item;
365 for( item = todolist.first(); item; item = todolist.next()) { 374 for( item = todolist.first(); item; item = todolist.next()) {
366 if (!(item->getCompleted() == 1) ) { 375 if (!(item->getCompleted() == 1) ) {
367 count++; 376 count++;
368 if (count <= MAX_LINES_TASK) { 377 if (count <= MAX_LINES_TASK) {
369 tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); 378 tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>")));
370 } 379 }
371 } 380 }
372 } 381 }
373 } 382 }
374 383
375 if (count > 0) { 384 if (count > 0) {
376 if( count == 1 ) { 385 if( count == 1 ) {
377 output = tr("There is <b> 1</b> active task: <br>" ); 386 output = tr("There is <b> 1</b> active task: <br>" );
378 } else { 387 } else {
379 output = tr("There are <b> %1</b> active tasks: <br>").arg(count); 388 output = tr("There are <b> %1</b> active tasks: <br>").arg(count);
380 } 389 }
381 output += tmpout; 390 output += tmpout;
382 } else { 391 } else {
383 output = tr("No active tasks"); 392 output = tr("No active tasks");
384 } 393 }
385 394
386 TodoField->setText(tr(output)); 395 TodoField->setText(tr(output));
387} 396}
388 397
389/* 398/*
390 * launches datebook 399 * launches datebook
391 */ 400 */
392void Today::startDatebook() { 401void Today::startDatebook() {
393 QCopEnvelope e("QPE/System", "execute(QString)"); 402 QCopEnvelope e("QPE/System", "execute(QString)");
394 e << QString("datebook"); 403 e << QString("datebook");
395} 404}
405void Today::editEvent(const Event &e) {
406 startDatebook();
407
408 //Dissabled for now as uid's not working properly
409 /*
410 while(!QCopChannel::isRegistered("QPE/Datebook")) sleep(1);
411 QCopEnvelope env("QPE/Datebook", "editEvent(int)");
412 env << e.uid();
413 */
414}
396 415
397/* 416/*
398 * launches todolist 417 * launches todolist
399 */ 418 */
400void Today::startTodo() { 419void Today::startTodo() {
401 QCopEnvelope e("QPE/System", "execute(QString)"); 420 QCopEnvelope e("QPE/System", "execute(QString)");
402 e << QString("todolist"); 421 e << QString("todolist");
403} 422}
404 423
405/* 424/*
406 * launch opiemail 425 * launch opiemail
407 */ 426 */
408void Today::startMail() { 427void Today::startMail() {
409 QCopEnvelope e("QPE/System", "execute(QString)"); 428 QCopEnvelope e("QPE/System", "execute(QString)");
410 e << QString("opiemail"); 429 e << QString("opiemail");
411} 430}
412 431
413/* 432/*
414 * Destroys the object and frees any allocated resources 433 * Destroys the object and frees any allocated resources
415 */ 434 */
416Today::~Today() { 435Today::~Today() {
417 // no need to delete child widgets, Qt does it all for us 436 // no need to delete child widgets, Qt does it all for us
418} 437}
419 438
420 439
421DateBookEvent::DateBookEvent(const EffectiveEvent &ev, 440DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
422 QWidget* parent = 0, 441 QWidget* parent = 0,
423 const char* name = 0, 442 const char* name = 0,
424 WFlags fl = 0) : 443 WFlags fl = 0) :
425 ClickableLabel(parent,name,fl), event(ev) { 444 ClickableLabel(parent,name,fl), event(ev) {
426 445
427 QString msg; 446 QString msg;
428 QTime time = QTime::currentTime(); 447 QTime time = QTime::currentTime();
429 448
430 if (!ONLY_LATER) { 449 if (!ONLY_LATER) {
431 msg += "<B>" + (ev).description() + "</B>"; 450 msg += "<B>" + (ev).description() + "</B>";
432 if ( (ev).event().hasAlarm() ) { 451 if ( (ev).event().hasAlarm() ) {
433 msg += " <b>[with alarm]</b>"; 452 msg += " <b>[with alarm]</b>";
434 } 453 }
435 // include location or not 454 // include location or not
436 if (SHOW_LOCATION == 1) { 455 if (SHOW_LOCATION == 1) {
437 msg += "<BR><i>" + (ev).location(); 456 msg += "<BR><i>" + (ev).location();
438 msg += "</i>"; 457 msg += "</i>";
439 } 458 }
440 459
441 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { 460 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) {
442 msg += "<br>All day"; 461 msg += "<br>All day";
443 } else { 462 } else {
444 // start time of event 463 // start time of event
445 msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) 464 msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) )
446 // end time of event 465 // end time of event
447 + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); 466 + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) );
448 } 467 }
449 // include possible note or not 468 // include possible note or not
450 if (SHOW_NOTES == 1) { 469 if (SHOW_NOTES == 1) {
451 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; 470 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>";
452 } 471 }
453 } 472 }
454 setText(msg); 473 setText(msg);
455 connect(this, SIGNAL(clicked()), this, SLOT(editMe())); 474 connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
456 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); 475 setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
457} 476}
458 477
459 478
460DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, 479DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
461 QWidget* parent = 0, 480 QWidget* parent = 0,
462 const char* name = 0, 481 const char* name = 0,
463 WFlags fl = 0) : 482 WFlags fl = 0) :
464 ClickableLabel(parent,name,fl), event(ev) { 483 ClickableLabel(parent,name,fl), event(ev) {
465 484
466 QString msg; 485 QString msg;
467 QTime time = QTime::currentTime(); 486 QTime time = QTime::currentTime();
468 487
469 if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { 488 if ((time.toString() <= TimeString::dateString((ev).event().end())) ) {
470 // show only later appointments 489 // show only later appointments
471 msg += "<B>" + (ev).description() + "</B>"; 490 msg += "<B>" + (ev).description() + "</B>";
472 if ( (ev).event().hasAlarm() ) { 491 if ( (ev).event().hasAlarm() ) {
473 msg += " <b>[with alarm]</b>"; 492 msg += " <b>[with alarm]</b>";
474 } 493 }
475 // include location or not 494 // include location or not
476 if (SHOW_LOCATION == 1) { 495 if (SHOW_LOCATION == 1) {
477 msg += "<BR><i>" + (ev).location(); 496 msg += "<BR><i>" + (ev).location();
478 msg += "</i>"; 497 msg += "</i>";
479 } 498 }
480 499
481 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { 500 if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) {
482 msg += "<br>All day"; 501 msg += "<br>All day";
483 } else { 502 } else {
484 // start time of event 503 // start time of event
485 msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) 504 msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) )
486 // end time of event 505 // end time of event
487 + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); 506 + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) );
488 } 507 }
489 // include possible note or not 508 // include possible note or not
490 if (SHOW_NOTES == 1) { 509 if (SHOW_NOTES == 1) {
491 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; 510 msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>";
diff --git a/core/pim/today/today.h b/core/pim/today/today.h
index b3f0654..0b4356c 100644
--- a/core/pim/today/today.h
+++ b/core/pim/today/today.h
@@ -1,98 +1,100 @@
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 <qdatetime.h> 27#include <qdatetime.h>
28#include <qlist.h> 28#include <qlist.h>
29 29
30#include "TodoItem.h" 30#include "TodoItem.h"
31#include "todayconfig.h" 31#include "todayconfig.h"
32#include "todaybase.h" 32#include "todaybase.h"
33#include "clickablelabel.h" 33#include "clickablelabel.h"
34 34
35class QVBoxLayout; 35class QVBoxLayout;
36 36
37class Today : public TodayBase { 37class Today : public TodayBase {
38 Q_OBJECT 38 Q_OBJECT
39 39
40 public: 40 public:
41 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 41 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
42 ~Today(); 42 ~Today();
43 43
44 private slots: 44 private slots:
45 void startConfig(); 45 void startConfig();
46 void startTodo(); 46 void startTodo();
47 void startDatebook(); 47 void startDatebook();
48 void startMail(); 48 void startMail();
49 void draw(); 49 void draw();
50 void editEvent(const Event &e);
50 private: 51 private:
51 void init(); 52 void init();
52 void getDates(); 53 void getDates();
53 void getTodo(); 54 void getTodo();
54 void getMail(); 55 void getMail();
55 void autoStart(); 56 void autoStart();
56 bool checkIfModified(); 57 bool checkIfModified();
57 QList<TodoItem> loadTodo(const char *filename); 58 QList<TodoItem> loadTodo(const char *filename);
58 private: 59 private:
59 DateBookDB *db; 60 DateBookDB *db;
60 todayconfig *conf; 61 todayconfig *conf;
62 QWidget* AllDateBookEvents;
61 //Config cfg; 63 //Config cfg;
62 int MAX_LINES_TASK; 64 int MAX_LINES_TASK;
63 int MAX_CHAR_CLIP; 65 int MAX_CHAR_CLIP;
64 int MAX_LINES_MEET; 66 int MAX_LINES_MEET;
65 int SHOW_LOCATION; 67 int SHOW_LOCATION;
66 int SHOW_NOTES; 68 int SHOW_NOTES;
67}; 69};
68 70
69class DateBookEvent: public ClickableLabel { 71class DateBookEvent: public ClickableLabel {
70 Q_OBJECT 72 Q_OBJECT
71public: 73public:
72 DateBookEvent(const EffectiveEvent &ev, 74 DateBookEvent(const EffectiveEvent &ev,
73 QWidget* parent = 0, const char* name = 0, 75 QWidget* parent = 0, const char* name = 0,
74 WFlags fl = 0); 76 WFlags fl = 0);
75signals: 77signals:
76 void editEvent(const Event &e); 78 void editEvent(const Event &e);
77private slots: 79private slots:
78 void editMe(); 80 void editMe();
79private: 81private:
80 const EffectiveEvent event; 82 const EffectiveEvent event;
81}; 83};
82 84
83class DateBookEventLater: public ClickableLabel { 85class DateBookEventLater: public ClickableLabel {
84 Q_OBJECT 86 Q_OBJECT
85public: 87public:
86 DateBookEventLater(const EffectiveEvent &ev, 88 DateBookEventLater(const EffectiveEvent &ev,
87 QWidget* parent = 0, const char* name = 0, 89 QWidget* parent = 0, const char* name = 0,
88 WFlags fl = 0); 90 WFlags fl = 0);
89signals: 91signals:
90 void editEvent(const Event &e); 92 void editEvent(const Event &e);
91private slots: 93private slots:
92 void editMe(); 94 void editMe();
93private: 95private:
94 const EffectiveEvent event; 96 const EffectiveEvent event;
95}; 97};
96 98
97#endif // TODAY_H 99#endif // TODAY_H
98 100