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