-rw-r--r-- | core/pim/today/today.cpp | 6 | ||||
-rw-r--r-- | core/pim/today/todaybase.cpp | 165 |
2 files changed, 103 insertions, 68 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index bed3a74..9e5c27e 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,411 +1,409 @@ | |||
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 | 41 | ||
42 | //#include <iostream.h> | 42 | //#include <iostream.h> |
43 | //#include <unistd.h> | 43 | //#include <unistd.h> |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | 45 | ||
46 | int MAX_LINES_TASK; | 46 | int MAX_LINES_TASK; |
47 | int MAX_CHAR_CLIP; | 47 | int MAX_CHAR_CLIP; |
48 | int MAX_LINES_MEET; | 48 | int MAX_LINES_MEET; |
49 | int SHOW_LOCATION; | 49 | int SHOW_LOCATION; |
50 | int SHOW_NOTES; | 50 | int SHOW_NOTES; |
51 | // show only later dates | 51 | // show only later dates |
52 | int ONLY_LATER; | 52 | int ONLY_LATER; |
53 | /* | 53 | /* |
54 | * Constructs a Example which is a child of 'parent', with the | 54 | * Constructs a Example which is a child of 'parent', with the |
55 | * name 'name' and widget flags set to 'f' | 55 | * name 'name' and widget flags set to 'f' |
56 | */ | 56 | */ |
57 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 57 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
58 | : TodayBase( parent, name, fl ) | 58 | : TodayBase( parent, name, fl ) |
59 | { | 59 | { |
60 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); | 60 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); |
61 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); | 61 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); |
62 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); | 62 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); |
63 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); | 63 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); |
64 | 64 | ||
65 | draw(); | 65 | draw(); |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | void Today::draw() | 69 | void Today::draw() |
70 | { | 70 | { |
71 | init(); | 71 | init(); |
72 | getDates(); | 72 | getDates(); |
73 | getMail(); | 73 | getMail(); |
74 | getTodo(); | 74 | getTodo(); |
75 | // how often refresh | 75 | // how often refresh |
76 | QTimer::singleShot( 5*1000, this, SLOT(draw()) ); | 76 | QTimer::singleShot( 5*1000, this, SLOT(draw()) ); |
77 | 77 | ||
78 | } | 78 | } |
79 | 79 | ||
80 | void Today::init() | 80 | void Today::init() |
81 | { | 81 | { |
82 | QDate date = QDate::currentDate(); | 82 | QDate date = QDate::currentDate(); |
83 | QString time = (date.toString()); | 83 | QString time = (date.toString()); |
84 | 84 | ||
85 | TextLabel1->setText("<qt><font color=white>" +time + "<font></qt>"); | 85 | TextLabel1->setText("<qt><font color=white>" +time + "<font></qt>"); |
86 | db = new DateBookDB; | 86 | db = new DateBookDB; |
87 | 87 | ||
88 | // read config | 88 | // read config |
89 | Config cfg("today"); | 89 | Config cfg("today"); |
90 | cfg.setGroup("BaseConfig"); | 90 | cfg.setGroup("BaseConfig"); |
91 | 91 | ||
92 | // how many lines should be showed in the task section | 92 | // how many lines should be showed in the task section |
93 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); | 93 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); |
94 | // after how many chars should the be cut off on tasks and notes | 94 | // after how many chars should the be cut off on tasks and notes |
95 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30); | 95 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30); |
96 | // how many lines should be showed in the datebook section | 96 | // how many lines should be showed in the datebook section |
97 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); | 97 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); |
98 | // If location is to be showed too, 1 to activate it. | 98 | // If location is to be showed too, 1 to activate it. |
99 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); | 99 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); |
100 | // if notes should be shown | 100 | // if notes should be shown |
101 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); | 101 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); |
102 | ONLY_LATER = cfg.readNumEntry("onlylater",1); | 102 | ONLY_LATER = cfg.readNumEntry("onlylater",1); |
103 | 103 | ||
104 | } | 104 | } |
105 | 105 | ||
106 | void Today::startConfig() | 106 | void Today::startConfig() |
107 | { | 107 | { |
108 | conf = new todayconfig ( this, "", true ); | 108 | conf = new todayconfig ( this, "", true ); |
109 | 109 | ||
110 | 110 | ||
111 | //Config cfg = new Config("today"); | 111 | //Config cfg = new Config("today"); |
112 | 112 | ||
113 | // read the config | 113 | // read the config |
114 | Config cfg("today"); | 114 | Config cfg("today"); |
115 | cfg.setGroup("BaseConfig"); | 115 | cfg.setGroup("BaseConfig"); |
116 | 116 | ||
117 | //init(); | 117 | //init(); |
118 | 118 | ||
119 | conf->SpinBox1->setValue(MAX_LINES_MEET); | 119 | conf->SpinBox1->setValue(MAX_LINES_MEET); |
120 | // location show box | 120 | // location show box |
121 | conf->CheckBox1->setChecked(SHOW_LOCATION); | 121 | conf->CheckBox1->setChecked(SHOW_LOCATION); |
122 | // notes show box | 122 | // notes show box |
123 | conf->CheckBox2->setChecked(SHOW_NOTES); | 123 | conf->CheckBox2->setChecked(SHOW_NOTES); |
124 | // task lines | 124 | // task lines |
125 | conf->SpinBox2->setValue(MAX_LINES_TASK); | 125 | conf->SpinBox2->setValue(MAX_LINES_TASK); |
126 | // clip when? | 126 | // clip when? |
127 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); | 127 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); |
128 | // only later | 128 | // only later |
129 | conf->CheckBox3->setChecked(ONLY_LATER); | 129 | conf->CheckBox3->setChecked(ONLY_LATER); |
130 | 130 | ||
131 | conf->exec(); | 131 | conf->exec(); |
132 | 132 | ||
133 | int maxlinestask = conf->SpinBox2->value(); | 133 | int maxlinestask = conf->SpinBox2->value(); |
134 | int maxmeet = conf->SpinBox1->value(); | 134 | int maxmeet = conf->SpinBox1->value(); |
135 | int location = conf->CheckBox1->isChecked(); | 135 | int location = conf->CheckBox1->isChecked(); |
136 | int notes = conf->CheckBox2->isChecked(); | 136 | int notes = conf->CheckBox2->isChecked(); |
137 | int maxcharclip = conf->SpinBox7->value(); | 137 | int maxcharclip = conf->SpinBox7->value(); |
138 | int onlylater = conf->CheckBox3->isChecked(); | 138 | int onlylater = conf->CheckBox3->isChecked(); |
139 | 139 | ||
140 | cfg.writeEntry("maxlinestask",maxlinestask); | 140 | cfg.writeEntry("maxlinestask",maxlinestask); |
141 | cfg.writeEntry("maxcharclip", maxcharclip); | 141 | cfg.writeEntry("maxcharclip", maxcharclip); |
142 | cfg.writeEntry("maxlinesmeet",maxmeet); | 142 | cfg.writeEntry("maxlinesmeet",maxmeet); |
143 | cfg.writeEntry("showlocation",location); | 143 | cfg.writeEntry("showlocation",location); |
144 | cfg.writeEntry("shownotes", notes); | 144 | cfg.writeEntry("shownotes", notes); |
145 | cfg.writeEntry("onlylater", onlylater); | 145 | cfg.writeEntry("onlylater", onlylater); |
146 | // sync it to "disk" | 146 | // sync it to "disk" |
147 | cfg.write(); | 147 | cfg.write(); |
148 | 148 | ||
149 | draw(); | 149 | draw(); |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | |||
154 | /* | 153 | /* |
155 | * Get all events that are in the datebook xml file for today | 154 | * Get all events that are in the datebook xml file for today |
156 | */ | 155 | */ |
157 | void Today::getDates() | 156 | void Today::getDates() |
158 | { | 157 | { |
159 | QDate date = QDate::currentDate(); | 158 | QDate date = QDate::currentDate(); |
160 | QTime time = QTime::currentTime(); | 159 | QTime time = QTime::currentTime(); |
161 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); | 160 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); |
162 | 161 | ||
163 | Config config( "qpe" ); | 162 | Config config( "qpe" ); |
164 | // if 24 h format | 163 | // if 24 h format |
165 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); | 164 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); |
166 | 165 | ||
167 | int count=0; | 166 | int count=0; |
168 | 167 | ||
169 | if ( list.count() > 0 ) { | 168 | if ( list.count() > 0 ) { |
170 | QString msg; | 169 | QString msg; |
171 | 170 | ||
172 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 171 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); |
173 | it!=list.end(); ++it ) { | 172 | it!=list.end(); ++it ) { |
174 | 173 | ||
175 | count++; | 174 | count++; |
176 | 175 | ||
177 | if ( count <= MAX_LINES_MEET ) | 176 | if ( count <= MAX_LINES_MEET ) |
178 | { | 177 | { |
179 | //only get events past current time (start or end??) | ||
180 | //cout << time.toString() << endl; | 178 | //cout << time.toString() << endl; |
181 | //cout << TimeString::dateString((*it).event().end()) << endl; | 179 | //cout << TimeString::dateString((*it).event().end()) << endl; |
182 | // still some bug in here, 1 h off | 180 | |
183 | |||
184 | // decide if to get all day or only later appointments | 181 | // decide if to get all day or only later appointments |
185 | if (!ONLY_LATER) | 182 | if (!ONLY_LATER) |
186 | { | 183 | { |
187 | msg += "<B>" + (*it).description() + "</B>"; | 184 | msg += "<B>" + (*it).description() + "</B>"; |
188 | if ( (*it).event().hasAlarm() ) | 185 | if ( (*it).event().hasAlarm() ) |
189 | { | 186 | { |
190 | msg += " <b>[with alarm]</b>"; | 187 | msg += " <b>[with alarm]</b>"; |
191 | } | 188 | } |
192 | // include location or not | 189 | // include location or not |
193 | if (SHOW_LOCATION == 1) | 190 | if (SHOW_LOCATION == 1) |
194 | { | 191 | { |
195 | msg+= "<BR>" + (*it).location(); | 192 | msg+= "<BR>" + (*it).location(); |
196 | } | 193 | } |
197 | msg += "<BR>" | 194 | msg += "<BR>" |
195 | |||
198 | // start time of event | 196 | // start time of event |
199 | + TimeString::timeString(QTime((*it).event().start().time()) ) | 197 | + TimeString::timeString(QTime((*it).event().start().time()) ) |
200 | // end time of event | 198 | // end time of event |
201 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ) | 199 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ) |
202 | + "<BR>"; | 200 | + "<BR>"; |
203 | // include possible note or not | 201 | // include possible note or not |
204 | if (SHOW_NOTES == 1) | 202 | if (SHOW_NOTES == 1) |
205 | { | 203 | { |
206 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 204 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
207 | } | 205 | } |
208 | } | 206 | } |
209 | else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) | 207 | else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) |
210 | { | 208 | { |
211 | msg += "<B>" + (*it).description() + "</B>"; | 209 | msg += "<B>" + (*it).description() + "</B>"; |
212 | if ( (*it).event().hasAlarm() ) | 210 | if ( (*it).event().hasAlarm() ) |
213 | { | 211 | { |
214 | msg += " <b>[with alarm]</b>"; | 212 | msg += " <b>[with alarm]</b>"; |
215 | } | 213 | } |
216 | // include location or not | 214 | // include location or not |
217 | if (SHOW_LOCATION == 1) | 215 | if (SHOW_LOCATION == 1) |
218 | { | 216 | { |
219 | msg+= "<BR>" + (*it).location(); | 217 | msg+= "<BR>" + (*it).location(); |
220 | } | 218 | } |
221 | msg += "<BR>" | 219 | msg += "<BR>" |
222 | // start time of event | 220 | // start time of event |
223 | + TimeString::timeString(QTime((*it).event().start().time()) ) | 221 | + TimeString::timeString(QTime((*it).event().start().time()) ) |
224 | // end time of event | 222 | // end time of event |
225 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ) | 223 | + "<b> - </b>" + TimeString::timeString(QTime((*it).event().end().time()) ) |
226 | + "<BR>"; | 224 | + "<BR>"; |
227 | // include possible note or not | 225 | // include possible note or not |
228 | if (SHOW_NOTES == 1) | 226 | if (SHOW_NOTES == 1) |
229 | { | 227 | { |
230 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 228 | msg += " <i>note</i>:" +((*it).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
231 | } | 229 | } |
232 | } | 230 | } |
233 | } | 231 | } |
234 | } | 232 | } |
235 | if (msg.isEmpty()) | 233 | if (msg.isEmpty()) |
236 | { | 234 | { |
237 | msg = "No more appointments today"; | 235 | msg = "No more appointments today"; |
238 | } | 236 | } |
239 | DatesField->setText(msg); | 237 | DatesField->setText(msg); |
240 | } | 238 | } |
241 | } | 239 | } |
242 | 240 | ||
243 | /* | 241 | /* |
244 | * Parse in the todolist.xml | 242 | * Parse in the todolist.xml |
245 | */ | 243 | */ |
246 | QList<TodoItem> Today::loadTodo(const char *filename) | 244 | QList<TodoItem> Today::loadTodo(const char *filename) |
247 | { | 245 | { |
248 | DOM *todo; | 246 | DOM *todo; |
249 | ELE *tasks; | 247 | ELE *tasks; |
250 | ELE **tasklist; | 248 | ELE **tasklist; |
251 | ATT **attlist; | 249 | ATT **attlist; |
252 | int i, j; | 250 | int i, j; |
253 | char *description; | 251 | char *description; |
254 | int completed; | 252 | int completed; |
255 | int priority; | 253 | int priority; |
256 | TodoItem *tmp; | 254 | TodoItem *tmp; |
257 | QList<TodoItem> loadtodolist; | 255 | QList<TodoItem> loadtodolist; |
258 | 256 | ||
259 | todo = minidom_load(filename); | 257 | todo = minidom_load(filename); |
260 | 258 | ||
261 | tasks = todo->el; | 259 | tasks = todo->el; |
262 | tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ | 260 | tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ |
263 | if(tasks) | 261 | if(tasks) |
264 | { | 262 | { |
265 | tasklist = tasks->el; | 263 | tasklist = tasks->el; |
266 | i = 0; | 264 | i = 0; |
267 | while((tasklist) && (tasklist[i])) | 265 | while((tasklist) && (tasklist[i])) |
268 | { | 266 | { |
269 | attlist = tasklist[i]->at; | 267 | attlist = tasklist[i]->at; |
270 | j = 0; | 268 | j = 0; |
271 | description = NULL; | 269 | description = NULL; |
272 | priority = -1; | 270 | priority = -1; |
273 | completed = -1; | 271 | completed = -1; |
274 | while((attlist) && (attlist[j])) | 272 | while((attlist) && (attlist[j])) |
275 | { | 273 | { |
276 | // SEGFAULT HERE WITH MORE THAN 7 ENTRIES | 274 | // SEGFAULT HERE WITH MORE THAN 7 ENTRIES |
277 | if(!attlist[j]->name) continue; | 275 | if(!attlist[j]->name) continue; |
278 | if(!strcmp(attlist[j]->name, "Description")) | 276 | if(!strcmp(attlist[j]->name, "Description")) |
279 | { | 277 | { |
280 | description = attlist[j]->value; | 278 | description = attlist[j]->value; |
281 | } | 279 | } |
282 | // get Completed tag (0 or 1) | 280 | // get Completed tag (0 or 1) |
283 | if(!strcmp(attlist[j]->name, "Completed")) | 281 | if(!strcmp(attlist[j]->name, "Completed")) |
284 | { | 282 | { |
285 | QString s = attlist[j]->name; | 283 | QString s = attlist[j]->name; |
286 | if(s == "Completed") | 284 | if(s == "Completed") |
287 | { | 285 | { |
288 | completed = QString(attlist[j]->value).toInt(); | 286 | completed = QString(attlist[j]->value).toInt(); |
289 | } | 287 | } |
290 | } | 288 | } |
291 | // get Priority (1 to 5) | 289 | // get Priority (1 to 5) |
292 | if(!strcmp(attlist[j]->name, "Priority")) | 290 | if(!strcmp(attlist[j]->name, "Priority")) |
293 | { | 291 | { |
294 | QString s = attlist[j]->name; | 292 | QString s = attlist[j]->name; |
295 | if(s == "Priority") | 293 | if(s == "Priority") |
296 | { | 294 | { |
297 | priority = QString(attlist[j]->value).toInt(); | 295 | priority = QString(attlist[j]->value).toInt(); |
298 | } | 296 | } |
299 | } | 297 | } |
300 | j++; | 298 | j++; |
301 | } | 299 | } |
302 | if(description) | 300 | if(description) |
303 | { | 301 | { |
304 | tmp = new TodoItem(description, completed, priority); | 302 | tmp = new TodoItem(description, completed, priority); |
305 | loadtodolist.append(tmp); | 303 | loadtodolist.append(tmp); |
306 | } | 304 | } |
307 | i++; | 305 | i++; |
308 | } | 306 | } |
309 | } | 307 | } |
310 | 308 | ||
311 | minidom_free(todo); | 309 | minidom_free(todo); |
312 | 310 | ||
313 | return loadtodolist; | 311 | return loadtodolist; |
314 | } | 312 | } |
315 | 313 | ||
316 | 314 | ||
317 | void Today::getMail() | 315 | void Today::getMail() |
318 | { | 316 | { |
319 | Config cfg("opiemail"); | 317 | Config cfg("opiemail"); |
320 | cfg.setGroup("today"); | 318 | cfg.setGroup("today"); |
321 | 319 | ||
322 | // how many lines should be showed in the task section | 320 | // how many lines should be showed in the task section |
323 | int NEW_MAILS = cfg.readNumEntry("newmails",0); | 321 | int NEW_MAILS = cfg.readNumEntry("newmails",0); |
324 | int OUTGOING = cfg.readNumEntry("outgoing",0); | 322 | int OUTGOING = cfg.readNumEntry("outgoing",0); |
325 | 323 | ||
326 | QString output = tr("<b>%1</b> new mails, <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); | 324 | QString output = tr("<b>%1</b> new mails, <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); |
327 | 325 | ||
328 | 326 | ||
329 | MailField->setText(output); | 327 | MailField->setText(output); |
330 | } | 328 | } |
331 | 329 | ||
332 | 330 | ||
333 | /* | 331 | /* |
334 | * Get the todos | 332 | * Get the todos |
335 | * | 333 | * |
336 | */ | 334 | */ |
337 | void Today::getTodo() | 335 | void Today::getTodo() |
338 | { | 336 | { |
339 | QString output; | 337 | QString output; |
340 | QString tmpout; | 338 | QString tmpout; |
341 | int count = 0; | 339 | int count = 0; |
342 | 340 | ||
343 | QDir dir; | 341 | QDir dir; |
344 | QString homedir = dir.homeDirPath (); | 342 | QString homedir = dir.homeDirPath (); |
345 | // see if todolist.xml does exist. | 343 | // see if todolist.xml does exist. |
346 | QFile f(homedir +"/Applications/todolist/todolist.xml"); | 344 | QFile f(homedir +"/Applications/todolist/todolist.xml"); |
347 | if ( f.exists() ) | 345 | if ( f.exists() ) |
348 | { | 346 | { |
349 | QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); | 347 | QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); |
350 | 348 | ||
351 | TodoItem *item; | 349 | TodoItem *item; |
352 | for( item = todolist.first(); item; item = todolist.next()) | 350 | for( item = todolist.first(); item; item = todolist.next()) |
353 | { | 351 | { |
354 | if (!(item->getCompleted() == 1) ) | 352 | if (!(item->getCompleted() == 1) ) |
355 | { | 353 | { |
356 | count++; | 354 | count++; |
357 | if (count <= MAX_LINES_TASK) | 355 | if (count <= MAX_LINES_TASK) |
358 | { | 356 | { |
359 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); | 357 | tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); |
360 | } | 358 | } |
361 | } | 359 | } |
362 | } | 360 | } |
363 | } | 361 | } |
364 | 362 | ||
365 | if (count > 0) | 363 | if (count > 0) |
366 | { | 364 | { |
367 | output = QString("There are <b> %1</b> active tasks: <br>").arg(count); | 365 | output = QString("There are <b> %1</b> active tasks: <br>").arg(count); |
368 | output += tmpout; | 366 | output += tmpout; |
369 | } | 367 | } |
370 | else | 368 | else |
371 | { | 369 | { |
372 | output = ("No active tasks"); | 370 | output = ("No active tasks"); |
373 | } | 371 | } |
374 | 372 | ||
375 | TodoField->setText(output); | 373 | TodoField->setText(output); |
376 | } | 374 | } |
377 | 375 | ||
378 | /* | 376 | /* |
379 | * launches datebook | 377 | * launches datebook |
380 | */ | 378 | */ |
381 | void Today::startDatebook() | 379 | void Today::startDatebook() |
382 | { | 380 | { |
383 | QCopEnvelope e("QPE/System", "execute(QString)"); | 381 | QCopEnvelope e("QPE/System", "execute(QString)"); |
384 | e << QString("datebook"); | 382 | e << QString("datebook"); |
385 | } | 383 | } |
386 | 384 | ||
387 | /* | 385 | /* |
388 | * launches todolist | 386 | * launches todolist |
389 | */ | 387 | */ |
390 | void Today::startTodo() | 388 | void Today::startTodo() |
391 | { | 389 | { |
392 | QCopEnvelope e("QPE/System", "execute(QString)"); | 390 | QCopEnvelope e("QPE/System", "execute(QString)"); |
393 | e << QString("todolist"); | 391 | e << QString("todolist"); |
394 | } | 392 | } |
395 | 393 | ||
396 | /* | 394 | /* |
397 | * launch opiemail | 395 | * launch opiemail |
398 | */ | 396 | */ |
399 | void Today::startMail() | 397 | void Today::startMail() |
400 | { | 398 | { |
401 | QCopEnvelope e("QPE/System", "execute(QString)"); | 399 | QCopEnvelope e("QPE/System", "execute(QString)"); |
402 | e << QString("opiemail"); | 400 | e << QString("opiemail"); |
403 | } | 401 | } |
404 | 402 | ||
405 | /* | 403 | /* |
406 | * Destroys the object and frees any allocated resources | 404 | * Destroys the object and frees any allocated resources |
407 | */ | 405 | */ |
408 | Today::~Today() | 406 | Today::~Today() |
409 | { | 407 | { |
410 | // no need to delete child widgets, Qt does it all for us | 408 | // no need to delete child widgets, Qt does it all for us |
411 | } | 409 | } |
diff --git a/core/pim/today/todaybase.cpp b/core/pim/today/todaybase.cpp index 32b45f7..ff6001a 100644 --- a/core/pim/today/todaybase.cpp +++ b/core/pim/today/todaybase.cpp | |||
@@ -1,166 +1,203 @@ | |||
1 | /* | 1 | /* |
2 | * todaybase.cpp * | 2 | * todaybase.cpp * |
3 | * --------------------- | 3 | * --------------------- |
4 | * | 4 | * |
5 | * begin : Sun 10 17:20:00 CEST 2002 | 5 | * begin : Sun 10 17:20:00 CEST 2002 |
6 | * copyright : (c) 2002 by Maximilian Reiß | 6 | * copyright : (c) 2002 by Maximilian Reiß |
7 | * email : max.reiss@gmx.de | 7 | * email : max.reiss@gmx.de |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | #include "todaybase.h" | 19 | #include "todaybase.h" |
20 | 20 | ||
21 | #include <qframe.h> | 21 | #include <qframe.h> |
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qvariant.h> | 25 | #include <qvariant.h> |
26 | #include <qtooltip.h> | 26 | #include <qtooltip.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qimage.h> | 28 | #include <qimage.h> |
29 | #include <qpixmap.h> | 29 | #include <qpixmap.h> |
30 | #include <qscrollview.h> | 30 | #include <qscrollview.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qapplication.h> | ||
32 | 33 | ||
33 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
34 | 35 | ||
35 | /* | 36 | /* |
36 | * Constructs a TodayBase which is a child of 'parent', with the | 37 | * Constructs a TodayBase which is a child of 'parent', with the |
37 | * name 'name' and widget flags set to 'f' | 38 | * name 'name' and widget flags set to 'f' |
38 | */ | 39 | */ |
39 | TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) | 40 | TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) |
40 | : QWidget( parent, name, fl ) | 41 | : QWidget( parent, name, fl ) |
41 | { | 42 | { |
42 | // logo | 43 | QPixmap logo = Resource::loadPixmap( "today/today_logo"); // logo |
43 | QPixmap logo = Resource::loadPixmap( "today/today_logo"); | 44 | QPixmap datebook = Resource::loadPixmap("DateBook"); // datebook |
44 | // datebook | 45 | QPixmap todo = Resource::loadPixmap( "TodoList" ); // todo |
45 | QPixmap datebook = Resource::loadPixmap("DateBook"); | 46 | QPixmap config = Resource::loadPixmap( "today/config" ); // config icon |
46 | // todo | 47 | QPixmap mail = Resource::loadPixmap( "today/mail" ); // mail icon |
47 | QPixmap todo = Resource::loadPixmap( "TodoList" ); | ||
48 | // config icon | ||
49 | QPixmap config = Resource::loadPixmap( "today/config" ); | ||
50 | // mail icon | ||
51 | QPixmap mail = Resource::loadPixmap( "today/mail" ); | ||
52 | |||
53 | |||
54 | QPalette pal2; | ||
55 | QColorGroup cg; | ||
56 | cg.setColor( QColorGroup::Text, white ); | ||
57 | cg.setBrush( QColorGroup::Background, QBrush( QColor( 238, 238, 230), logo ) ); | ||
58 | pal2.setActive( cg ); | ||
59 | |||
60 | 48 | ||
61 | QPalette pal = this->palette(); | 49 | QPalette pal = this->palette(); |
62 | QColor col = pal.color(QPalette::Active, QColorGroup::Background); | 50 | QColor col = pal.color(QPalette::Active, QColorGroup::Background); |
63 | pal.setColor(QPalette::Active, QColorGroup::Button, col); | 51 | pal.setColor(QPalette::Active, QColorGroup::Button, col); |
64 | this->setPalette(pal); | 52 | this->setPalette(pal); |
65 | 53 | ||
66 | QVBoxLayout * layout = new QVBoxLayout(this); | 54 | QWidget *d = QApplication::desktop(); |
55 | int w=d->width(); | ||
56 | int h=d->height(); | ||
57 | resize( w , h ); // not good, what happens on rotation | ||
67 | 58 | ||
68 | Frame4 = new QFrame( this, "Frame4" ); | ||
69 | Frame4->setPalette( pal ); | ||
70 | Frame4->setFrameShape( QScrollView::StyledPanel ); | ||
71 | Frame4->setFrameShadow( QScrollView::Sunken ); | ||
72 | Frame4->setBackgroundOrigin( QScrollView::ParentOrigin ); | ||
73 | |||
74 | // hehe, qt is ... | 59 | // hehe, qt is ... |
75 | getridoffuckingstrippeldlinesbutton = new QPushButton (Frame4, "asdfsad" ); | 60 | getridoffuckingstrippeldlinesbutton = new QPushButton (this, "asdfsad" ); |
76 | getridoffuckingstrippeldlinesbutton->setGeometry( QRect( -5, 10, 0, 0 ) ); | 61 | getridoffuckingstrippeldlinesbutton->setGeometry( QRect( -5, 10, 0, 0 ) ); |
77 | 62 | ||
78 | DatesButton = new QPushButton (Frame4, "DatesButton" ); | ||
79 | DatesButton->setGeometry( QRect( 2, 4, 36, 32 ) ); | ||
80 | DatesButton->setBackgroundOrigin( QPushButton::WidgetOrigin ); | ||
81 | DatesButton->setPalette( pal ); | ||
82 | DatesButton->setPixmap( datebook ); | ||
83 | DatesButton->setFlat( TRUE ); | ||
84 | 63 | ||
85 | DatesField = new QLabel( Frame4, "DatesField" ); | ||
86 | DatesField->setGeometry( QRect( 40, 4, 203, 120 ) ); | ||
87 | DatesField->setText( tr( "No appointments today" ) ); | ||
88 | DatesField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) ); | ||
89 | 64 | ||
65 | QVBoxLayout * layout = new QVBoxLayout(this); | ||
66 | |||
67 | |||
68 | |||
69 | // --- logo Section --- | ||
70 | QPalette pal2; | ||
71 | QColorGroup cg; | ||
72 | cg.setColor( QColorGroup::Text, white ); | ||
73 | cg.setBrush( QColorGroup::Background, QBrush( QColor( 238, 238, 230), logo ) ); | ||
74 | pal2.setActive( cg ); | ||
90 | // today logo | 75 | // today logo |
91 | Frame = new QLabel( this, "Frame" ); | 76 | Frame = new QLabel( this, "Frame" ); |
92 | Frame->setPalette( pal2 ); | 77 | Frame->setPalette( pal2 ); |
93 | Frame->setFrameShape( QFrame::StyledPanel ); | 78 | Frame->setFrameShape( QFrame::StyledPanel ); |
94 | Frame->setFrameShadow( QFrame::Raised ); | 79 | Frame->setFrameShadow( QFrame::Raised ); |
95 | Frame->setLineWidth( 0 ); | 80 | Frame->setLineWidth( 0 ); |
96 | Frame->setMaximumHeight(50); | 81 | Frame->setMaximumHeight(50); |
97 | Frame->setMinimumHeight(50); | 82 | Frame->setMinimumHeight(50); |
98 | |||
99 | // date | 83 | // date |
100 | TextLabel1 = new QLabel( Frame, "TextLabel1" ); | 84 | TextLabel1 = new QLabel( Frame, "TextLabel1" ); |
101 | TextLabel1->setGeometry( QRect( 10, 35, 168, 12 ) ); | 85 | TextLabel1->setGeometry( QRect( 10, 35, 168, 12 ) ); |
102 | QFont TextLabel1_font( TextLabel1->font() ); | 86 | QFont TextLabel1_font( TextLabel1->font() ); |
103 | TextLabel1_font.setBold( TRUE ); | 87 | TextLabel1_font.setBold( TRUE ); |
104 | TextLabel1->setFont( TextLabel1_font ); | 88 | TextLabel1->setFont( TextLabel1_font ); |
105 | TextLabel1->setBackgroundOrigin( QLabel::ParentOrigin ); | 89 | TextLabel1->setBackgroundOrigin( QLabel::ParentOrigin ); |
106 | TextLabel1->setTextFormat( RichText ); | 90 | TextLabel1->setTextFormat( RichText ); |
107 | 91 | ||
108 | // todo | 92 | |
109 | Frame15 = new QFrame( this, "Frame15" ); | 93 | // --- dates section --- |
110 | Frame15->setFrameShape( QFrame::StyledPanel ); | 94 | Frame4 = new QFrame( this, "Frame4" ); |
111 | Frame15->setFrameShadow( QFrame::Sunken ); | 95 | Frame4->setPalette( pal ); |
96 | Frame4->setFrameShape( QScrollView::StyledPanel ); | ||
97 | Frame4->setFrameShadow( QScrollView::Sunken ); | ||
98 | Frame4->setBackgroundOrigin( QScrollView::ParentOrigin ); | ||
99 | Frame4->setFrameStyle( QFrame::NoFrame ); | ||
100 | Frame4->setGeometry (QRect( 0, 0, this->width() , this->height()) ); | ||
112 | 101 | ||
113 | TodoButton = new QPushButton (Frame15, "TodoButton" ); | 102 | QScrollView* sv1 = new QScrollView( Frame4 ); |
114 | TodoButton->setGeometry( QRect( 2, 4, 36, 32 ) ); | 103 | sv1->setResizePolicy(QScrollView::AutoOneFit); |
115 | TodoButton->setPalette( pal ); | 104 | sv1->setHScrollBarMode( QScrollView::AlwaysOff ); |
116 | TodoButton->setPixmap( todo ); | 105 | // need to find a better way!!! |
117 | TodoButton->setFlat( TRUE ); | 106 | sv1->setGeometry (QRect( 40, 2, Frame4->width()-40 , (Frame4->height()/3)+20 ) ); |
107 | sv1->setFrameShape(QFrame::NoFrame); | ||
108 | |||
109 | DatesButton = new QPushButton (Frame4, "DatesButton" ); | ||
110 | DatesButton->setGeometry( QRect( 2, 4, 36, 32 ) ); | ||
111 | DatesButton->setBackgroundOrigin( QPushButton::WidgetOrigin ); | ||
112 | DatesButton->setPalette( pal ); | ||
113 | DatesButton->setPixmap( datebook ); | ||
114 | DatesButton->setFlat( TRUE ); | ||
118 | 115 | ||
119 | TodoField = new QLabel( Frame15, "TodoField" ); | 116 | DatesField = new QLabel( sv1->viewport(), "DatesField" ); |
120 | TodoField->setGeometry( QRect( 40, 4, 196, 120 ) ); | 117 | sv1->addChild(DatesField); |
121 | TodoField->setFrameShadow( QLabel::Plain ); | 118 | DatesField->setText( tr( "No appointments today" ) ); |
122 | TodoField->setText( tr( "No current todos" ) ); | 119 | DatesField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) ); |
123 | TodoField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) ); | ||
124 | 120 | ||
125 | PushButton1 = new QPushButton (Frame15, "PushButton1" ); | ||
126 | PushButton1->setGeometry( QRect( 216, 68, 25, 21 ) ); | ||
127 | PushButton1->setPixmap( config ); | ||
128 | PushButton1->setPalette( pal ); | ||
129 | PushButton1->setAutoDefault( TRUE ); | ||
130 | PushButton1->setFlat( TRUE ); | ||
131 | 121 | ||
132 | 122 | // --- mail section --- | |
133 | MailFrame = new QFrame( this ,"MailFrame" ); | 123 | MailFrame = new QFrame( this ,"MailFrame" ); |
134 | MailFrame->setFrameShape( QScrollView::StyledPanel ); | 124 | //MailFrame->setPalette( pal ); |
135 | MailFrame->setFrameShadow( QScrollView::Sunken ); | 125 | MailFrame->setBackgroundOrigin( QScrollView::ParentOrigin ); |
126 | //MailFrame->setFrameShape( QScrollView::StyledPanel ); | ||
127 | //MailFrame->setFrameShadow( QScrollView::Sunken ); | ||
128 | MailFrame->setGeometry (QRect( 0, 0, this->width() , 15) ); | ||
129 | MailFrame->setFrameStyle( QFrame::NoFrame ); | ||
136 | 130 | ||
131 | QFrame* Line1 = new QFrame( MailFrame); | ||
132 | Line1->setGeometry( QRect( 0, 0, MailFrame->width(), 5 ) ); | ||
133 | Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | ||
134 | |||
137 | MailButton = new QPushButton (MailFrame, "MailButton" ); | 135 | MailButton = new QPushButton (MailFrame, "MailButton" ); |
138 | MailButton->setGeometry( QRect( 2, 3, 36, 19 ) ); | 136 | MailButton->setGeometry( QRect( 2, 3, 36, 19 ) ); |
139 | MailButton->setPalette( pal ); | 137 | MailButton->setPalette( pal ); |
140 | MailButton->setPixmap( mail ); | 138 | MailButton->setPixmap( mail ); |
141 | MailButton->setFlat( TRUE ); | 139 | MailButton->setFlat( TRUE ); |
142 | 140 | ||
143 | MailField = new QLabel( MailFrame, "DatesField" ); | 141 | MailField = new QLabel( MailFrame, "MailField" ); |
144 | MailField->setGeometry( QRect( 40, 4, 203, 120 ) ); | 142 | MailField->setGeometry( QRect( 40, 4, MailFrame->width(), 12) ); |
145 | MailField->setText( tr( "Opiemail not installed" ) ); | 143 | MailField->setText( tr( "Opiemail not installed" ) ); |
146 | MailField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) ); | 144 | MailField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) ); |
147 | MailField->setMaximumHeight(40); | 145 | MailField->setMaximumHeight(40); |
148 | MailField->setMinimumHeight(30); | 146 | MailField->setMinimumHeight(15); |
147 | |||
148 | |||
149 | // --- todo section -- | ||
150 | Frame15 = new QFrame( this, "Frame15" ); | ||
151 | //Frame15->setFrameShape( QFrame::StyledPanel ); | ||
152 | //Frame15->setFrameShadow( QFrame::Sunken ); | ||
153 | Frame15->setFrameStyle( QFrame::NoFrame ); | ||
154 | Frame15->setGeometry (QRect( 40, 3, this->width() , this->height()) ); | ||
155 | |||
156 | QFrame* Line2 = new QFrame( Frame15); | ||
157 | Line2->setGeometry( QRect( 0, 0, MailFrame->width(), 5 ) ); | ||
158 | Line2->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | ||
159 | |||
160 | TodoButton = new QPushButton (Frame15, "TodoButton" ); | ||
161 | TodoButton->setGeometry( QRect( 2, 4, 36, 32 ) ); | ||
162 | TodoButton->setPalette( pal ); | ||
163 | TodoButton->setPixmap( todo ); | ||
164 | TodoButton->setFlat( TRUE ); | ||
165 | |||
166 | QScrollView* sv2 = new QScrollView( Frame15 ); | ||
167 | sv2->setResizePolicy(QScrollView::AutoOneFit); | ||
168 | sv2->setHScrollBarMode( QScrollView::AlwaysOff ); | ||
169 | sv2->setGeometry (QRect( 40, 3, Frame15->width()-40 , (Frame15->height()/3) ) ); | ||
170 | sv2->setFrameShape(QFrame::NoFrame); | ||
171 | |||
172 | TodoField = new QLabel( sv2->viewport(), "TodoField" ); | ||
173 | sv2->addChild(TodoField); | ||
174 | //TodoField->setGeometry( QRect( 40, 4, 196, 120 ) ); | ||
175 | TodoField->setFrameShadow( QLabel::Plain ); | ||
176 | //TodoField->setText( tr( "No current todos" ) ); | ||
177 | TodoField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) ); | ||
178 | |||
179 | PushButton1 = new QPushButton (Frame15, "PushButton1" ); | ||
180 | PushButton1->setGeometry( QRect( 2, 68, 25, 21 ) ); | ||
181 | PushButton1->setPixmap( config ); | ||
182 | PushButton1->setPalette( pal ); | ||
183 | PushButton1->setAutoDefault( TRUE ); | ||
184 | PushButton1->setFlat( TRUE ); | ||
149 | 185 | ||
186 | // -- layout -- | ||
150 | layout->addWidget(Frame); | 187 | layout->addWidget(Frame); |
151 | layout->addWidget(Frame4); | 188 | layout->addWidget(Frame4); |
152 | layout->addWidget(MailFrame); | 189 | layout->addWidget(MailFrame); |
153 | layout->addWidget(Frame15); | 190 | layout->addWidget(Frame15); |
154 | 191 | ||
155 | layout->setStretchFactor(Frame4,5); | 192 | layout->setStretchFactor(Frame4,5); |
156 | layout->setStretchFactor(MailFrame,1); | 193 | layout->setStretchFactor(MailFrame,1); |
157 | layout->setStretchFactor(Frame15,4); | 194 | layout->setStretchFactor(Frame15,4); |
158 | } | 195 | } |
159 | 196 | ||
160 | /* | 197 | /* |
161 | * Destroys the object and frees any allocated resources | 198 | * Destroys the object and frees any allocated resources |
162 | */ | 199 | */ |
163 | TodayBase::~TodayBase() | 200 | TodayBase::~TodayBase() |
164 | { | 201 | { |
165 | } | 202 | } |
166 | 203 | ||