author | harlekin <harlekin> | 2002-03-11 21:33:49 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-03-11 21:33:49 (UTC) |
commit | 3c5feb8676f75f4e218ea0278f02d225e8985301 (patch) (unidiff) | |
tree | a57765d4e72a73e3310eaa91fa9cce2e51a6710a | |
parent | 990d0ad3664c24e8909027ae4d3839f4e318ea00 (diff) | |
download | opie-3c5feb8676f75f4e218ea0278f02d225e8985301.zip opie-3c5feb8676f75f4e218ea0278f02d225e8985301.tar.gz opie-3c5feb8676f75f4e218ea0278f02d225e8985301.tar.bz2 |
brown paperbag I
-rw-r--r-- | core/pim/today/today.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 69bcb68..d10082f 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,478 +1,477 @@ | |||
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 | 43 | ||
44 | //#include <iostream.h> | 44 | //#include <iostream.h> |
45 | //#include <unistd.h> | 45 | //#include <unistd.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | 47 | ||
48 | 48 | ||
49 | 49 | ||
50 | int MAX_LINES_TASK; | 50 | int MAX_LINES_TASK; |
51 | int MAX_CHAR_CLIP; | 51 | int MAX_CHAR_CLIP; |
52 | int MAX_LINES_MEET; | 52 | int MAX_LINES_MEET; |
53 | int SHOW_LOCATION; | 53 | int SHOW_LOCATION; |
54 | int SHOW_NOTES; | 54 | int SHOW_NOTES; |
55 | // show only later dates | 55 | // show only later dates |
56 | int ONLY_LATER; | 56 | int ONLY_LATER; |
57 | int AUTOSTART; | 57 | int AUTOSTART; |
58 | 58 | ||
59 | int NEW_START=1; | 59 | int NEW_START=1; |
60 | /* | 60 | /* |
61 | * Constructs a Example which is a child of 'parent', with the | 61 | * Constructs a Example which is a child of 'parent', with the |
62 | * name 'name' and widget flags set to 'f' | 62 | * name 'name' and widget flags set to 'f' |
63 | */ | 63 | */ |
64 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 64 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
65 | : TodayBase( parent, name, fl ) { | 65 | : TodayBase( parent, name, fl ) { |
66 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); | 66 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); |
67 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); | 67 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); |
68 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); | 68 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); |
69 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); | 69 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); |
70 | 70 | ||
71 | 71 | ||
72 | autoStart(); | 72 | autoStart(); |
73 | draw(); | 73 | draw(); |
74 | } | 74 | } |
75 | 75 | ||
76 | void Today::autoStart() { | 76 | void Today::autoStart() { |
77 | Config cfg("today"); | 77 | Config cfg("today"); |
78 | cfg.setGroup("Autostart"); | 78 | cfg.setGroup("Autostart"); |
79 | AUTOSTART = cfg.readNumEntry("autostart",1); | 79 | AUTOSTART = cfg.readNumEntry("autostart",1); |
80 | if (AUTOSTART) { | 80 | if (AUTOSTART) { |
81 | QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); | 81 | QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); |
82 | e << QString("add"); | 82 | e << QString("add"); |
83 | e << QString("today"); | 83 | e << QString("today"); |
84 | } else { | 84 | } else { |
85 | QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); | 85 | QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); |
86 | e << QString("remove"); | 86 | e << QString("remove"); |
87 | e << QString("today"); | 87 | e << QString("today"); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void Today::draw() { | 91 | void Today::draw() { |
92 | init(); | 92 | init(); |
93 | getDates(); | 93 | getDates(); |
94 | getMail(); | 94 | getMail(); |
95 | getTodo(); | 95 | getTodo(); |
96 | // how often refresh | 96 | // how often refresh |
97 | QTimer::singleShot( 30*1000, this, SLOT(draw()) ); | 97 | QTimer::singleShot( 30*1000, this, SLOT(draw()) ); |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | /* | 101 | /* |
102 | * Check if the todolist.xml was modified (if there are new entries. | 102 | * Check if the todolist.xml was modified (if there are new entries. |
103 | * Returns true if it was modified. | 103 | * Returns true if it was modified. |
104 | */ | 104 | */ |
105 | bool Today::checkIfModified() { | 105 | bool Today::checkIfModified() { |
106 | 106 | ||
107 | QDir dir; | 107 | QDir dir; |
108 | QString homedir = dir.homeDirPath (); | 108 | QString homedir = dir.homeDirPath (); |
109 | QString time; | 109 | QString time; |
110 | 110 | ||
111 | Config cfg("today"); | 111 | Config cfg("today"); |
112 | cfg.setGroup("Files"); | 112 | cfg.setGroup("Files"); |
113 | time = cfg.readEntry("todolisttimestamp", ""); | 113 | time = cfg.readEntry("todolisttimestamp", ""); |
114 | 114 | ||
115 | QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); | 115 | QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); |
116 | QDateTime fileTime = file.lastModified(); | 116 | QDateTime fileTime = file.lastModified(); |
117 | if (time.compare(fileTime.toString()) == 0) { | 117 | if (time.compare(fileTime.toString()) == 0) { |
118 | return false; | 118 | return false; |
119 | } else { | 119 | } else { |
120 | cfg.writeEntry("todolisttimestamp", fileTime.toString() ); | 120 | cfg.writeEntry("todolisttimestamp", fileTime.toString() ); |
121 | cfg.write(); | 121 | cfg.write(); |
122 | return true; | 122 | return true; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | 126 | ||
127 | void Today::init() { | 127 | void Today::init() { |
128 | QDate date = QDate::currentDate(); | 128 | QDate date = QDate::currentDate(); |
129 | QString time = (tr( date.toString()) ); | 129 | QString time = (tr( date.toString()) ); |
130 | // QString time = (tr( date.toString()) , white); | 130 | // QString time = (tr( date.toString()) , white); |
131 | 131 | ||
132 | TextLabel1->setText(time); | 132 | TextLabel1->setText(time); |
133 | db = new DateBookDB; | 133 | db = new DateBookDB; |
134 | 134 | ||
135 | // read config | 135 | // read config |
136 | Config cfg("today"); | 136 | Config cfg("today"); |
137 | cfg.setGroup("BaseConfig"); | 137 | cfg.setGroup("BaseConfig"); |
138 | 138 | ||
139 | // how many lines should be showed in the task section | 139 | // how many lines should be showed in the task section |
140 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); | 140 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); |
141 | // after how many chars should the be cut off on tasks and notes | 141 | // after how many chars should the be cut off on tasks and notes |
142 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30); | 142 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30); |
143 | // how many lines should be showed in the datebook section | 143 | // how many lines should be showed in the datebook section |
144 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); | 144 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); |
145 | // If location is to be showed too, 1 to activate it. | 145 | // If location is to be showed too, 1 to activate it. |
146 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); | 146 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); |
147 | // if notes should be shown | 147 | // if notes should be shown |
148 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); | 148 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); |
149 | ONLY_LATER = cfg.readNumEntry("onlylater",1); | 149 | ONLY_LATER = cfg.readNumEntry("onlylater",1); |
150 | 150 | ||
151 | } | 151 | } |
152 | 152 | ||
153 | void Today::startConfig() { | 153 | void Today::startConfig() { |
154 | conf = new todayconfig ( this, "", true ); | 154 | conf = new todayconfig ( this, "", true ); |
155 | 155 | ||
156 | 156 | ||
157 | //Config cfg = new Config("today"); | 157 | //Config cfg = new Config("today"); |
158 | 158 | ||
159 | // read the config | 159 | // read the config |
160 | Config cfg("today"); | 160 | Config cfg("today"); |
161 | cfg.setGroup("BaseConfig"); | 161 | cfg.setGroup("BaseConfig"); |
162 | 162 | ||
163 | //init(); | 163 | //init(); |
164 | 164 | ||
165 | conf->SpinBox1->setValue(MAX_LINES_MEET); | 165 | conf->SpinBox1->setValue(MAX_LINES_MEET); |
166 | // location show box | 166 | // location show box |
167 | conf->CheckBox1->setChecked(SHOW_LOCATION); | 167 | conf->CheckBox1->setChecked(SHOW_LOCATION); |
168 | // notes show box | 168 | // notes show box |
169 | conf->CheckBox2->setChecked(SHOW_NOTES); | 169 | conf->CheckBox2->setChecked(SHOW_NOTES); |
170 | // task lines | 170 | // task lines |
171 | conf->SpinBox2->setValue(MAX_LINES_TASK); | 171 | conf->SpinBox2->setValue(MAX_LINES_TASK); |
172 | // clip when? | 172 | // clip when? |
173 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); | 173 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); |
174 | // only later | 174 | // only later |
175 | conf->CheckBox3->setChecked(ONLY_LATER); | 175 | conf->CheckBox3->setChecked(ONLY_LATER); |
176 | 176 | ||
177 | conf->CheckBoxAuto->setChecked(AUTOSTART); | 177 | conf->CheckBoxAuto->setChecked(AUTOSTART); |
178 | 178 | ||
179 | conf->exec(); | 179 | conf->exec(); |
180 | 180 | ||
181 | int maxlinestask = conf->SpinBox2->value(); | 181 | int maxlinestask = conf->SpinBox2->value(); |
182 | int maxmeet = conf->SpinBox1->value(); | 182 | int maxmeet = conf->SpinBox1->value(); |
183 | int location = conf->CheckBox1->isChecked(); | 183 | int location = conf->CheckBox1->isChecked(); |
184 | int notes = conf->CheckBox2->isChecked(); | 184 | int notes = conf->CheckBox2->isChecked(); |
185 | int maxcharclip = conf->SpinBox7->value(); | 185 | int maxcharclip = conf->SpinBox7->value(); |
186 | int onlylater = conf->CheckBox3->isChecked(); | 186 | int onlylater = conf->CheckBox3->isChecked(); |
187 | int autostart =conf->CheckBoxAuto->isChecked(); | 187 | int autostart =conf->CheckBoxAuto->isChecked(); |
188 | 188 | ||
189 | cfg.writeEntry("maxlinestask",maxlinestask); | 189 | cfg.writeEntry("maxlinestask",maxlinestask); |
190 | cfg.writeEntry("maxcharclip", maxcharclip); | 190 | cfg.writeEntry("maxcharclip", maxcharclip); |
191 | cfg.writeEntry("maxlinesmeet",maxmeet); | 191 | cfg.writeEntry("maxlinesmeet",maxmeet); |
192 | cfg.writeEntry("showlocation",location); | 192 | cfg.writeEntry("showlocation",location); |
193 | cfg.writeEntry("shownotes", notes); | 193 | cfg.writeEntry("shownotes", notes); |
194 | cfg.writeEntry("onlylater", onlylater); | 194 | cfg.writeEntry("onlylater", onlylater); |
195 | cfg.setGroup("Autostart"); | 195 | cfg.setGroup("Autostart"); |
196 | cfg.writeEntry("autostart", autostart); | 196 | cfg.writeEntry("autostart", autostart); |
197 | // sync it to "disk" | 197 | // sync it to "disk" |
198 | cfg.write(); | 198 | cfg.write(); |
199 | autoStart(); | 199 | autoStart(); |
200 | draw(); | 200 | draw(); |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | /* | 204 | /* |
205 | * Get all events that are in the datebook xml file for today | 205 | * Get all events that are in the datebook xml file for today |
206 | */ | 206 | */ |
207 | void Today::getDates() { | 207 | void Today::getDates() { |
208 | QDate date = QDate::currentDate(); | 208 | QDate date = QDate::currentDate(); |
209 | QWidget* AllDateBookEvents = new QWidget( ); | 209 | QWidget* AllDateBookEvents = new QWidget( ); |
210 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); | 210 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); |
211 | //QTime time = QTime::currentTime(); | 211 | //QTime time = QTime::currentTime(); |
212 | 212 | ||
213 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); | 213 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); |
214 | 214 | ||
215 | Config config( "qpe" ); | 215 | Config config( "qpe" ); |
216 | // if 24 h format | 216 | // if 24 h format |
217 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); | 217 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); |
218 | 218 | ||
219 | int count=0; | 219 | int count=0; |
220 | 220 | ||
221 | if ( list.count() > 0 ) { | 221 | if ( list.count() > 0 ) { |
222 | QString msg; | 222 | QString msg; |
223 | 223 | ||
224 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 224 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); |
225 | it!=list.end(); ++it ) { | 225 | it!=list.end(); ++it ) { |
226 | 226 | ||
227 | count++; | 227 | count++; |
228 | 228 | ||
229 | if ( count <= MAX_LINES_MEET ) { | 229 | if ( count <= MAX_LINES_MEET ) { |
230 | 230 | ||
231 | 231 | ||
232 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents); | 232 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents); |
233 | layoutDates->addWidget(l); | 233 | layoutDates->addWidget(l); |
234 | connect (l, SIGNAL(editEvent(const Event &)), | 234 | connect (l, SIGNAL(editEvent(const Event &)), |
235 | this, SIGNAL(editEvent(const Event &))); | 235 | this, SIGNAL(editEvent(const Event &))); |
236 | } | 236 | } |
237 | 237 | ||
238 | } | 238 | } |
239 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 239 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
240 | sv1->addChild(AllDateBookEvents); | 240 | sv1->addChild(AllDateBookEvents); |
241 | 241 | ||
242 | //if (msg.isEmpty()) { | 242 | //if (msg.isEmpty()) { |
243 | // msg = tr("No more appointments today"); | 243 | // msg = tr("No more appointments today"); |
244 | //} | 244 | //} |
245 | //DatesField->setText(msg); | 245 | //DatesField->setText(msg); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | /* | 249 | /* |
250 | * Parse in the todolist.xml | 250 | * Parse in the todolist.xml |
251 | */ | 251 | */ |
252 | QList<TodoItem> Today::loadTodo(const char *filename) { | 252 | QList<TodoItem> Today::loadTodo(const char *filename) { |
253 | DOM *todo; | 253 | DOM *todo; |
254 | ELE *tasks; | 254 | ELE *tasks; |
255 | ELE **tasklist; | 255 | ELE **tasklist; |
256 | ATT **attlist; | 256 | ATT **attlist; |
257 | int i, j; | 257 | int i, j; |
258 | char *description; | 258 | char *description; |
259 | int completed; | 259 | int completed; |
260 | int priority; | 260 | int priority; |
261 | TodoItem *tmp; | 261 | TodoItem *tmp; |
262 | QList<TodoItem> loadtodolist; | 262 | QList<TodoItem> loadtodolist; |
263 | 263 | ||
264 | todo = minidom_load(filename); | 264 | todo = minidom_load(filename); |
265 | 265 | ||
266 | tasks = todo->el; | 266 | tasks = todo->el; |
267 | tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ | 267 | tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ |
268 | if(tasks) { | 268 | if(tasks) { |
269 | tasklist = tasks->el; | 269 | tasklist = tasks->el; |
270 | i = 0; | 270 | i = 0; |
271 | while((tasklist) && (tasklist[i])) { | 271 | while((tasklist) && (tasklist[i])) { |
272 | attlist = tasklist[i]->at; | 272 | attlist = tasklist[i]->at; |
273 | j = 0; | 273 | j = 0; |
274 | description = NULL; | 274 | description = NULL; |
275 | priority = -1; | 275 | priority = -1; |
276 | completed = -1; | 276 | completed = -1; |
277 | while((attlist) && (attlist[j])) { | 277 | while((attlist) && (attlist[j])) { |
278 | if(!attlist[j]->name) { | 278 | if(!attlist[j]->name) { |
279 | continue; | 279 | continue; |
280 | } | 280 | } |
281 | if(!strcmp(attlist[j]->name, "Description")) { | 281 | if(!strcmp(attlist[j]->name, "Description")) { |
282 | description = attlist[j]->value; | 282 | description = attlist[j]->value; |
283 | } | 283 | } |
284 | // get Completed tag (0 or 1) | 284 | // get Completed tag (0 or 1) |
285 | if(!strcmp(attlist[j]->name, "Completed")) { | 285 | if(!strcmp(attlist[j]->name, "Completed")) { |
286 | QString s = attlist[j]->name; | 286 | QString s = attlist[j]->name; |
287 | if(s == "Completed") { | 287 | if(s == "Completed") { |
288 | completed = QString(attlist[j]->value).toInt(); | 288 | completed = QString(attlist[j]->value).toInt(); |
289 | } | 289 | } |
290 | } | 290 | } |
291 | // get Priority (1 to 5) | 291 | // get Priority (1 to 5) |
292 | if(!strcmp(attlist[j]->name, "Priority")) { | 292 | if(!strcmp(attlist[j]->name, "Priority")) { |
293 | QString s = attlist[j]->name; | 293 | QString s = attlist[j]->name; |
294 | if(s == "Priority") { | 294 | if(s == "Priority") { |
295 | priority = QString(attlist[j]->value).toInt(); | 295 | priority = QString(attlist[j]->value).toInt(); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | j++; | 298 | j++; |
299 | } | 299 | } |
300 | if(description) { | 300 | if(description) { |
301 | tmp = new TodoItem(description, completed, priority); | 301 | tmp = new TodoItem(description, completed, priority); |
302 | loadtodolist.append(tmp); | 302 | loadtodolist.append(tmp); |
303 | } | 303 | } |
304 | i++; | 304 | i++; |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | minidom_free(todo); | 308 | minidom_free(todo); |
309 | 309 | ||
310 | return loadtodolist; | 310 | return loadtodolist; |
311 | } | 311 | } |
312 | 312 | ||
313 | 313 | ||
314 | void Today::getMail() { | 314 | void Today::getMail() { |
315 | Config cfg("opiemail"); | 315 | Config cfg("opiemail"); |
316 | cfg.setGroup("today"); | 316 | cfg.setGroup("today"); |
317 | 317 | ||
318 | // how many lines should be showed in the task section | 318 | // how many lines should be showed in the task section |
319 | int NEW_MAILS = cfg.readNumEntry("newmails",0); | 319 | int NEW_MAILS = cfg.readNumEntry("newmails",0); |
320 | int OUTGOING = cfg.readNumEntry("outgoing",0); | 320 | int OUTGOING = cfg.readNumEntry("outgoing",0); |
321 | 321 | ||
322 | 322 | ||
323 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); | 323 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); |
324 | 324 | ||
325 | 325 | ||
326 | MailField->setText(output); | 326 | MailField->setText(output); |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | /* | 330 | /* |
331 | * Get the todos | 331 | * Get the todos |
332 | * | 332 | * |
333 | */ | 333 | */ |
334 | void Today::getTodo() { | 334 | void Today::getTodo() { |
335 | 335 | ||
336 | // if the todolist.xml file was not modified in between, do not parse it. | 336 | // if the todolist.xml file was not modified in between, do not parse it. |
337 | if (!checkIfModified() && !NEW_START) { | 337 | if (!checkIfModified() && !NEW_START) { |
338 | return; | 338 | return; |
339 | } | 339 | } |
340 | NEW_START=0; | 340 | NEW_START=0; |
341 | 341 | ||
342 | QString output; | 342 | QString output; |
343 | QString tmpout; | 343 | QString tmpout; |
344 | int count = 0; | 344 | int count = 0; |
345 | 345 | ||
346 | QDir dir; | 346 | QDir dir; |
347 | QString homedir = dir.homeDirPath (); | 347 | QString homedir = dir.homeDirPath (); |
348 | // see if todolist.xml does exist. | 348 | // see if todolist.xml does exist. |
349 | QFile f(homedir +"/Applications/todolist/todolist.xml"); | 349 | QFile f(homedir +"/Applications/todolist/todolist.xml"); |
350 | if ( f.exists() ) { | 350 | if ( f.exists() ) { |
351 | QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); | 351 | QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); |
352 | 352 | ||
353 | TodoItem *item; | 353 | TodoItem *item; |
354 | for( item = todolist.first(); item; item = todolist.next()) { | 354 | for( item = todolist.first(); item; item = todolist.next()) { |
355 | if (!(item->getCompleted() == 1) ) { | 355 | if (!(item->getCompleted() == 1) ) { |
356 | count++; | 356 | count++; |
357 | if (count <= MAX_LINES_TASK) { | 357 | if (count <= MAX_LINES_TASK) { |
358 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); | 358 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); |
359 | } | 359 | } |
360 | } | 360 | } |
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | ||
364 | if (count > 0) { | 364 | if (count > 0) { |
365 | if( count == 1 ) { | 365 | if( count == 1 ) { |
366 | output = tr("There is <b> 1</b> active task: <br>" ); | 366 | output = tr("There is <b> 1</b> active task: <br>" ); |
367 | } else { | 367 | } else { |
368 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); | 368 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); |
369 | } | 369 | } |
370 | output += tmpout; | 370 | output += tmpout; |
371 | } else { | 371 | } else { |
372 | output = tr("No active tasks"); | 372 | output = tr("No active tasks"); |
373 | } | 373 | } |
374 | 374 | ||
375 | TodoField->setText(tr(output)); | 375 | TodoField->setText(tr(output)); |
376 | } | 376 | } |
377 | 377 | ||
378 | /* | 378 | /* |
379 | * launches datebook | 379 | * launches datebook |
380 | */ | 380 | */ |
381 | void Today::startDatebook() { | 381 | void Today::startDatebook() { |
382 | QCopEnvelope e("QPE/System", "execute(QString)"); | 382 | QCopEnvelope e("QPE/System", "execute(QString)"); |
383 | e << QString("datebook"); | 383 | e << QString("datebook"); |
384 | } | 384 | } |
385 | 385 | ||
386 | /* | 386 | /* |
387 | * launches todolist | 387 | * launches todolist |
388 | */ | 388 | */ |
389 | void Today::startTodo() { | 389 | void Today::startTodo() { |
390 | QCopEnvelope e("QPE/System", "execute(QString)"); | 390 | QCopEnvelope e("QPE/System", "execute(QString)"); |
391 | e << QString("todolist"); | 391 | e << QString("todolist"); |
392 | } | 392 | } |
393 | 393 | ||
394 | /* | 394 | /* |
395 | * launch opiemail | 395 | * launch opiemail |
396 | */ | 396 | */ |
397 | void Today::startMail() { | 397 | void Today::startMail() { |
398 | QCopEnvelope e("QPE/System", "execute(QString)"); | 398 | QCopEnvelope e("QPE/System", "execute(QString)"); |
399 | e << QString("opiemail"); | 399 | e << QString("opiemail"); |
400 | } | 400 | } |
401 | 401 | ||
402 | /* | 402 | /* |
403 | * Destroys the object and frees any allocated resources | 403 | * Destroys the object and frees any allocated resources |
404 | */ | 404 | */ |
405 | Today::~Today() { | 405 | Today::~Today() { |
406 | // no need to delete child widgets, Qt does it all for us | 406 | // no need to delete child widgets, Qt does it all for us |
407 | } | 407 | } |
408 | 408 | ||
409 | 409 | ||
410 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | 410 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, |
411 | QWidget* parent = 0, | 411 | QWidget* parent = 0, |
412 | const char* name = 0, | 412 | const char* name = 0, |
413 | WFlags fl = 0) : | 413 | WFlags fl = 0) : |
414 | ClickableLabel(parent,name,fl), event(ev) { | 414 | ClickableLabel(parent,name,fl), event(ev) { |
415 | 415 | ||
416 | QString msg; | 416 | QString msg; |
417 | QTime time = QTime::currentTime(); | 417 | QTime time = QTime::currentTime(); |
418 | 418 | ||
419 | if (!ONLY_LATER) { | 419 | if (!ONLY_LATER) { |
420 | msg += "<B>" + (ev).description() + "</B>"; | 420 | msg += "<B>" + (ev).description() + "</B>"; |
421 | if ( (ev).event().hasAlarm() ) { | 421 | if ( (ev).event().hasAlarm() ) { |
422 | msg += " <b>[with alarm]</b>"; | 422 | msg += " <b>[with alarm]</b>"; |
423 | } | 423 | } |
424 | // include location or not | 424 | // include location or not |
425 | if (SHOW_LOCATION == 1) { | 425 | if (SHOW_LOCATION == 1) { |
426 | msg += "<BR><i>" + (ev).location(); | 426 | msg += "<BR><i>" + (ev).location(); |
427 | msg += "</i>"; | 427 | msg += "</i>"; |
428 | } | 428 | } |
429 | 429 | ||
430 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 430 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
431 | msg += "<br>All day"; | 431 | msg += "<br>All day"; |
432 | } else { | 432 | } else { |
433 | // start time of event | 433 | // start time of event |
434 | msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) | 434 | msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) |
435 | // end time of event | 435 | // end time of event |
436 | + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); | 436 | + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); |
437 | } | 437 | } |
438 | msg += "<BR>"; | ||
439 | // include possible note or not | 438 | // include possible note or not |
440 | if (SHOW_NOTES == 1) { | 439 | if (SHOW_NOTES == 1) { |
441 | msg += " <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 440 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
442 | } | 441 | } |
443 | } else if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { | 442 | } else if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { |
444 | msg += "<B>" + (ev).description() + "</B>"; | 443 | msg += "<B>" + (ev).description() + "</B>"; |
445 | if ( (ev).event().hasAlarm() ) { | 444 | if ( (ev).event().hasAlarm() ) { |
446 | msg += " <b>[with alarm]</b>"; | 445 | msg += " <b>[with alarm]</b>"; |
447 | } | 446 | } |
448 | // include location or not | 447 | // include location or not |
449 | if (SHOW_LOCATION == 1) { | 448 | if (SHOW_LOCATION == 1) { |
450 | msg+= "<BR><i>" + (ev).location(); | 449 | msg += "<BR><i>" + (ev).location(); |
451 | msg += "</i>"; | 450 | msg += "</i>"; |
452 | } | 451 | } |
453 | 452 | ||
454 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 453 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
455 | msg += "<br>All day"; | 454 | msg += "<br>All day"; |
456 | } else { | 455 | } else { |
457 | // start time of event | 456 | // start time of event |
458 | msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) | 457 | msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) ) |
459 | // end time of event | 458 | // end time of event |
460 | + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); | 459 | + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); |
461 | } | 460 | } |
462 | // include possible note or not | 461 | // include possible note or not |
463 | if (SHOW_NOTES == 1) { | 462 | if (SHOW_NOTES == 1) { |
464 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 463 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
465 | } | 464 | } |
466 | } | 465 | } |
467 | 466 | ||
468 | setText(msg); | 467 | setText(msg); |
469 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 468 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
470 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 469 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
471 | } | 470 | } |
472 | 471 | ||
473 | void DateBookEvent::editMe() { | 472 | void DateBookEvent::editMe() { |
474 | emit editEvent(event.event()); | 473 | emit editEvent(event.event()); |
475 | } | 474 | } |
476 | 475 | ||
477 | 476 | ||
478 | 477 | ||