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