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