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