author | harlekin <harlekin> | 2002-04-27 17:06:35 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-04-27 17:06:35 (UTC) |
commit | 32f808191e255c82044f281f6032f336b75f2fc6 (patch) (unidiff) | |
tree | 26edc161e8c646325eef15a4b50a14baad6594c4 | |
parent | 0fb2ea5d51271cfad323b69c4c191c946f45a5a0 (diff) | |
download | opie-32f808191e255c82044f281f6032f336b75f2fc6.zip opie-32f808191e255c82044f281f6032f336b75f2fc6.tar.gz opie-32f808191e255c82044f281f6032f336b75f2fc6.tar.bz2 |
fixes for the logo part, looks better now on screen > 240 pixel width. Also now all the i18n guys can finally translate the Today string .-)
-rw-r--r-- | core/pim/today/today.cpp | 4 | ||||
-rw-r--r-- | core/pim/today/todaybase.cpp | 27 |
2 files changed, 21 insertions, 10 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 0ab7a2a..01d1a13 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,611 +1,613 @@ | |||
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 | 45 | ||
46 | //#include <iostream.h> | 46 | //#include <iostream.h> |
47 | #include <unistd.h> | 47 | #include <unistd.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | 49 | ||
50 | int MAX_LINES_TASK; | 50 | int MAX_LINES_TASK; |
51 | int MAX_CHAR_CLIP; | 51 | int MAX_CHAR_CLIP; |
52 | int MAX_LINES_MEET; | 52 | int MAX_LINES_MEET; |
53 | int SHOW_LOCATION; | 53 | int SHOW_LOCATION; |
54 | int SHOW_NOTES; | 54 | int SHOW_NOTES; |
55 | // show only later dates | 55 | // show only later dates |
56 | int ONLY_LATER; | 56 | int ONLY_LATER; |
57 | int AUTOSTART; | 57 | int AUTOSTART; |
58 | int NEW_START=1; | 58 | int NEW_START=1; |
59 | QString AUTOSTART_TIMER; | 59 | QString AUTOSTART_TIMER; |
60 | 60 | ||
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 | 80 | ||
81 | 81 | ||
82 | db = NULL; | 82 | db = NULL; |
83 | setOwnerField(); | 83 | setOwnerField(); |
84 | todo = new ToDoDB; | 84 | todo = new ToDoDB; |
85 | getTodo(); | 85 | getTodo(); |
86 | draw(); | 86 | draw(); |
87 | autoStart(); | 87 | autoStart(); |
88 | } | 88 | } |
89 | 89 | ||
90 | /* | 90 | /* |
91 | * Qcop receive method. | 91 | * Qcop receive method. |
92 | */ | 92 | */ |
93 | void Today::channelReceived(const QCString &msg, const QByteArray & data) { | 93 | void Today::channelReceived(const QCString &msg, const QByteArray & data) { |
94 | QDataStream stream(data, IO_ReadOnly ); | 94 | QDataStream stream(data, IO_ReadOnly ); |
95 | if ( msg == "message(QString)" ) { | 95 | if ( msg == "message(QString)" ) { |
96 | QString message; | 96 | QString message; |
97 | stream >> message; | 97 | stream >> message; |
98 | setOwnerField(message); | 98 | setOwnerField(message); |
99 | } | 99 | } |
100 | 100 | ||
101 | } | 101 | } |
102 | 102 | ||
103 | /* | 103 | /* |
104 | * Initialises the owner field with the default value, the username | 104 | * Initialises the owner field with the default value, the username |
105 | */ | 105 | */ |
106 | void Today::setOwnerField() { | 106 | void Today::setOwnerField() { |
107 | QString file = Global::applicationFileName("addressbook", "businesscard.vcf"); | 107 | QString file = Global::applicationFileName("addressbook", "businesscard.vcf"); |
108 | if (QFile::exists(file)) { | 108 | if (QFile::exists(file)) { |
109 | Contact cont = Contact::readVCard(file)[0]; | 109 | Contact cont = Contact::readVCard(file)[0]; |
110 | QString returnString = cont.fullName(); | 110 | QString returnString = cont.fullName(); |
111 | OwnerField->setText( "<b>" +tr ("Owned by ") + returnString + "</b>"); | 111 | OwnerField->setText( "<b>" +tr ("Owned by ") + returnString + "</b>"); |
112 | } else { | 112 | } else { |
113 | OwnerField->setText( "<b>" + tr ("Please fill out the business card")+" </b>"); | 113 | OwnerField->setText( "<b>" + tr ("Please fill out the business card")+" </b>"); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | /* | 117 | /* |
118 | * Set the owner field with a given QString, for example per qcop. | 118 | * Set the owner field with a given QString, for example per qcop. |
119 | */ | 119 | */ |
120 | void Today::setOwnerField(QString &message) { | 120 | void Today::setOwnerField(QString &message) { |
121 | if (!message.isEmpty()) { | 121 | if (!message.isEmpty()) { |
122 | OwnerField->setText("<b>" + message + "</b>"); | 122 | OwnerField->setText("<b>" + message + "</b>"); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | /* | 126 | /* |
127 | * Autostart, uses the new (opie only) autostart method in the launcher code. | 127 | * Autostart, uses the new (opie only) autostart method in the launcher code. |
128 | * If registered against that today ist started on each resume. | 128 | * If registered against that today ist started on each resume. |
129 | */ | 129 | */ |
130 | void Today::autoStart() { | 130 | void Today::autoStart() { |
131 | Config cfg("today"); | 131 | Config cfg("today"); |
132 | cfg.setGroup("Autostart"); | 132 | cfg.setGroup("Autostart"); |
133 | int AUTOSTART = cfg.readNumEntry("autostart",1); | 133 | int AUTOSTART = cfg.readNumEntry("autostart",1); |
134 | qDebug(QString("%1").arg(AUTOSTART)); | 134 | // qDebug(QString("%1").arg(AUTOSTART)); |
135 | if (AUTOSTART) { | 135 | if (AUTOSTART) { |
136 | QCopEnvelope e("QPE/System", "autoStart(QString, QString, QString)"); | 136 | QCopEnvelope e("QPE/System", "autoStart(QString, QString, QString)"); |
137 | e << QString("add"); | 137 | e << QString("add"); |
138 | e << QString("today"); | 138 | e << QString("today"); |
139 | e << AUTOSTART_TIMER; | 139 | e << AUTOSTART_TIMER; |
140 | } else { | 140 | } else { |
141 | qDebug("Nun in else bei autostart"); | 141 | qDebug("Nun in else bei autostart"); |
142 | QCopEnvelope e("QPE/System", "autoStart(QString, QString)"); | 142 | QCopEnvelope e("QPE/System", "autoStart(QString, QString)"); |
143 | e << QString("remove"); | 143 | e << QString("remove"); |
144 | e << QString("today"); | 144 | e << QString("today"); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | /* | 148 | /* |
149 | * Repaint method. Reread all fields. | 149 | * Repaint method. Reread all fields. |
150 | */ | 150 | */ |
151 | void Today::draw() { | 151 | void Today::draw() { |
152 | init(); | 152 | init(); |
153 | getDates(); | 153 | getDates(); |
154 | getMail(); | 154 | getMail(); |
155 | 155 | ||
156 | // if the todolist.xml file was not modified in between, do not parse it. | 156 | // if the todolist.xml file was not modified in between, do not parse it. |
157 | if (checkIfModified()) { | 157 | if (checkIfModified()) { |
158 | if (todo) delete todo; | 158 | if (todo) delete todo; |
159 | todo = new ToDoDB; | 159 | todo = new ToDoDB; |
160 | getTodo(); | 160 | getTodo(); |
161 | } | 161 | } |
162 | 162 | ||
163 | // how often refresh | 163 | // how often refresh |
164 | QTimer::singleShot( 20*1000, this, SLOT(draw() ) ); | 164 | QTimer::singleShot( 20*1000, this, SLOT(draw() ) ); |
165 | } | 165 | } |
166 | 166 | ||
167 | /* | 167 | /* |
168 | * Check if the todolist.xml was modified (if there are new entries. | 168 | * Check if the todolist.xml was modified (if there are new entries. |
169 | * Returns true if it was modified. | 169 | * Returns true if it was modified. |
170 | */ | 170 | */ |
171 | bool Today::checkIfModified() { | 171 | bool Today::checkIfModified() { |
172 | 172 | ||
173 | QDir dir; | 173 | QDir dir; |
174 | QString homedir = dir.homeDirPath (); | 174 | QString homedir = dir.homeDirPath (); |
175 | QString time; | 175 | QString time; |
176 | 176 | ||
177 | Config cfg("today"); | 177 | Config cfg("today"); |
178 | cfg.setGroup("Files"); | 178 | cfg.setGroup("Files"); |
179 | time = cfg.readEntry("todolisttimestamp", ""); | 179 | time = cfg.readEntry("todolisttimestamp", ""); |
180 | 180 | ||
181 | QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); | 181 | QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); |
182 | QDateTime fileTime = file.lastModified(); | 182 | QDateTime fileTime = file.lastModified(); |
183 | if (time.compare(fileTime.toString()) == 0) { | 183 | if (time.compare(fileTime.toString()) == 0) { |
184 | return false; | 184 | return false; |
185 | } else { | 185 | } else { |
186 | cfg.writeEntry("todolisttimestamp", fileTime.toString() ); | 186 | cfg.writeEntry("todolisttimestamp", fileTime.toString() ); |
187 | cfg.write(); | 187 | cfg.write(); |
188 | return true; | 188 | return true; |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | /* | 193 | /* |
194 | * Init stuff needed for today. Reads the config file. | 194 | * Init stuff needed for today. Reads the config file. |
195 | */ | 195 | */ |
196 | void Today::init() { | 196 | void Today::init() { |
197 | QDate date = QDate::currentDate(); | 197 | QDate date = QDate::currentDate(); |
198 | QString time = (tr( date.toString()) ); | 198 | QString time = (tr( date.toString()) ); |
199 | 199 | ||
200 | TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); | 200 | TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); |
201 | 201 | ||
202 | // read config | 202 | // read config |
203 | Config cfg("today"); | 203 | Config cfg("today"); |
204 | cfg.setGroup("BaseConfig"); | 204 | cfg.setGroup("BaseConfig"); |
205 | 205 | ||
206 | // -- config file section -- | 206 | // -- config file section -- |
207 | // how many lines should be showed in the task section | 207 | // how many lines should be showed in the task section |
208 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); | 208 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); |
209 | // after how many chars should the be cut off on tasks and notes | 209 | // after how many chars should the be cut off on tasks and notes |
210 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40); | 210 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40); |
211 | // how many lines should be showed in the datebook section | 211 | // how many lines should be showed in the datebook section |
212 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); | 212 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); |
213 | // If location is to be showed too, 1 to activate it. | 213 | // If location is to be showed too, 1 to activate it. |
214 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); | 214 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); |
215 | // if notes should be shown | 215 | // if notes should be shown |
216 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); | 216 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); |
217 | // should only later appointments be shown or all for the current day. | 217 | // should only later appointments be shown or all for the current day. |
218 | ONLY_LATER = cfg.readNumEntry("onlylater",1); | 218 | ONLY_LATER = cfg.readNumEntry("onlylater",1); |
219 | 219 | ||
220 | cfg.setGroup("Autostart"); | 220 | cfg.setGroup("Autostart"); |
221 | AUTOSTART = cfg.readNumEntry("autostart",1); | 221 | AUTOSTART = cfg.readNumEntry("autostart",1); |
222 | AUTOSTART_TIMER = cfg.readEntry("autostartdelay", "0"); | 222 | AUTOSTART_TIMER = cfg.readEntry("autostartdelay", "0"); |
223 | 223 | ||
224 | //db = new DateBookDB; | 224 | //db = new DateBookDB; |
225 | } | 225 | } |
226 | 226 | ||
227 | /* | 227 | /* |
228 | * The method for the configuration dialog. | 228 | * The method for the configuration dialog. |
229 | */ | 229 | */ |
230 | void Today::startConfig() { | 230 | void Today::startConfig() { |
231 | 231 | ||
232 | conf = new todayconfig ( this, "", true ); | 232 | conf = new todayconfig ( this, "", true ); |
233 | // read the config | 233 | // read the config |
234 | Config cfg("today"); | 234 | Config cfg("today"); |
235 | cfg.setGroup("BaseConfig"); | 235 | cfg.setGroup("BaseConfig"); |
236 | 236 | ||
237 | //init(); | 237 | //init(); |
238 | 238 | ||
239 | conf->SpinBox1->setValue(MAX_LINES_MEET); | 239 | conf->SpinBox1->setValue(MAX_LINES_MEET); |
240 | // location show box | 240 | // location show box |
241 | conf->CheckBox1->setChecked(SHOW_LOCATION); | 241 | conf->CheckBox1->setChecked(SHOW_LOCATION); |
242 | // notes show box | 242 | // notes show box |
243 | conf->CheckBox2->setChecked(SHOW_NOTES); | 243 | conf->CheckBox2->setChecked(SHOW_NOTES); |
244 | // task lines | 244 | // task lines |
245 | conf->SpinBox2->setValue(MAX_LINES_TASK); | 245 | conf->SpinBox2->setValue(MAX_LINES_TASK); |
246 | // clip when? | 246 | // clip when? |
247 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); | 247 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); |
248 | // only later | 248 | // only later |
249 | conf->CheckBox3->setChecked(ONLY_LATER); | 249 | conf->CheckBox3->setChecked(ONLY_LATER); |
250 | // if today should be autostarted | 250 | // if today should be autostarted |
251 | conf->CheckBoxAuto->setChecked(AUTOSTART); | 251 | conf->CheckBoxAuto->setChecked(AUTOSTART); |
252 | // autostart only if device has been suspended for X minutes | 252 | // autostart only if device has been suspended for X minutes |
253 | conf->SpinBoxTime->setValue( AUTOSTART_TIMER.toInt() ); | 253 | conf->SpinBoxTime->setValue( AUTOSTART_TIMER.toInt() ); |
254 | 254 | ||
255 | conf->exec(); | 255 | conf->exec(); |
256 | 256 | ||
257 | int maxlinestask = conf->SpinBox2->value(); | 257 | int maxlinestask = conf->SpinBox2->value(); |
258 | int maxmeet = conf->SpinBox1->value(); | 258 | int maxmeet = conf->SpinBox1->value(); |
259 | int location = conf->CheckBox1->isChecked(); | 259 | int location = conf->CheckBox1->isChecked(); |
260 | int notes = conf->CheckBox2->isChecked(); | 260 | int notes = conf->CheckBox2->isChecked(); |
261 | int maxcharclip = conf->SpinBox7->value(); | 261 | int maxcharclip = conf->SpinBox7->value(); |
262 | int onlylater = conf->CheckBox3->isChecked(); | 262 | int onlylater = conf->CheckBox3->isChecked(); |
263 | int autostart = conf->CheckBoxAuto->isChecked(); | 263 | int autostart = conf->CheckBoxAuto->isChecked(); |
264 | int autostartdelay = conf->SpinBoxTime->value(); | 264 | int autostartdelay = conf->SpinBoxTime->value(); |
265 | 265 | ||
266 | 266 | ||
267 | cfg.writeEntry("maxlinestask",maxlinestask); | 267 | cfg.writeEntry("maxlinestask",maxlinestask); |
268 | cfg.writeEntry("maxcharclip", maxcharclip); | 268 | cfg.writeEntry("maxcharclip", maxcharclip); |
269 | cfg.writeEntry("maxlinesmeet",maxmeet); | 269 | cfg.writeEntry("maxlinesmeet",maxmeet); |
270 | cfg.writeEntry("showlocation",location); | 270 | cfg.writeEntry("showlocation",location); |
271 | cfg.writeEntry("shownotes", notes); | 271 | cfg.writeEntry("shownotes", notes); |
272 | cfg.writeEntry("onlylater", onlylater); | 272 | cfg.writeEntry("onlylater", onlylater); |
273 | cfg.setGroup("Autostart"); | 273 | cfg.setGroup("Autostart"); |
274 | cfg.writeEntry("autostart", autostart); | 274 | cfg.writeEntry("autostart", autostart); |
275 | cfg.writeEntry("autostartdelay", autostartdelay); | 275 | cfg.writeEntry("autostartdelay", autostartdelay); |
276 | 276 | ||
277 | // sync it to "disk" | 277 | // sync it to "disk" |
278 | cfg.write(); | 278 | cfg.write(); |
279 | NEW_START=1; | 279 | NEW_START=1; |
280 | draw(); | 280 | draw(); |
281 | AUTOSTART=autostart; | 281 | AUTOSTART=autostart; |
282 | autoStart(); | 282 | autoStart(); |
283 | } | 283 | } |
284 | 284 | ||
285 | 285 | ||
286 | /* | 286 | /* |
287 | * Get all events that are in the datebook xml file for today | 287 | * Get all events that are in the datebook xml file for today |
288 | */ | 288 | */ |
289 | void Today::getDates() { | 289 | void Today::getDates() { |
290 | QDate date = QDate::currentDate(); | 290 | QDate date = QDate::currentDate(); |
291 | 291 | ||
292 | if (AllDateBookEvents) delete AllDateBookEvents; | 292 | if (AllDateBookEvents) delete AllDateBookEvents; |
293 | AllDateBookEvents = new QWidget( ); | 293 | AllDateBookEvents = new QWidget( ); |
294 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); | 294 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); |
295 | 295 | ||
296 | if (db) { | 296 | if (db) { |
297 | delete db; | 297 | delete db; |
298 | } | 298 | } |
299 | db = new DateBookDB; | 299 | db = new DateBookDB; |
300 | 300 | ||
301 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); | 301 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); |
302 | 302 | ||
303 | qBubbleSort(list); | 303 | qBubbleSort(list); |
304 | // printf("Get dates\n"); | 304 | // printf("Get dates\n"); |
305 | 305 | ||
306 | Config config( "qpe" ); | 306 | Config config( "qpe" ); |
307 | // if 24 h format | 307 | // if 24 h format |
308 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); | 308 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); |
309 | 309 | ||
310 | int count=0; | 310 | int count=0; |
311 | 311 | ||
312 | if ( list.count() > 0 ) { | 312 | if ( list.count() > 0 ) { |
313 | 313 | ||
314 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 314 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); |
315 | it!=list.end(); ++it ) { | 315 | it!=list.end(); ++it ) { |
316 | 316 | ||
317 | 317 | ||
318 | if ( count <= MAX_LINES_MEET ) { | 318 | if ( count <= MAX_LINES_MEET ) { |
319 | 319 | ||
320 | QTime time = QTime::currentTime(); | 320 | QTime time = QTime::currentTime(); |
321 | 321 | ||
322 | if (!ONLY_LATER) { | 322 | if (!ONLY_LATER) { |
323 | count++; | 323 | count++; |
324 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); | 324 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); |
325 | layoutDates->addWidget(l); | 325 | layoutDates->addWidget(l); |
326 | connect (l, SIGNAL(editEvent(const Event &)), | 326 | connect (l, SIGNAL(editEvent(const Event &)), |
327 | this, SLOT(editEvent(const Event &))); | 327 | this, SLOT(editEvent(const Event &))); |
328 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { | 328 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { |
329 | count++; | 329 | count++; |
330 | 330 | ||
331 | // show only later appointments | 331 | // show only later appointments |
332 | DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); | 332 | DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); |
333 | layoutDates->addWidget(l); | 333 | layoutDates->addWidget(l); |
334 | connect (l, SIGNAL(editEvent(const Event &)), | 334 | connect (l, SIGNAL(editEvent(const Event &)), |
335 | this, SLOT(editEvent(const Event &))); | 335 | this, SLOT(editEvent(const Event &))); |
336 | } | 336 | } |
337 | } | 337 | } |
338 | } | 338 | } |
339 | if (ONLY_LATER && count==0) { | 339 | if (ONLY_LATER && count==0) { |
340 | QLabel* noMoreEvents = new QLabel(AllDateBookEvents); | 340 | QLabel* noMoreEvents = new QLabel(AllDateBookEvents); |
341 | noMoreEvents->setText(tr("No more appointments today")); | 341 | noMoreEvents->setText(tr("No more appointments today")); |
342 | layoutDates->addWidget(noMoreEvents); | 342 | layoutDates->addWidget(noMoreEvents); |
343 | } | 343 | } |
344 | } else { | 344 | } else { |
345 | QLabel* noEvents = new QLabel(AllDateBookEvents); | 345 | QLabel* noEvents = new QLabel(AllDateBookEvents); |
346 | noEvents->setText(tr("No appointments today")); | 346 | noEvents->setText(tr("No appointments today")); |
347 | layoutDates->addWidget(noEvents); | 347 | layoutDates->addWidget(noEvents); |
348 | } | 348 | } |
349 | 349 | ||
350 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 350 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
351 | sv1->addChild(AllDateBookEvents); | 351 | sv1->addChild(AllDateBookEvents); |
352 | AllDateBookEvents->show(); | 352 | AllDateBookEvents->show(); |
353 | } | 353 | } |
354 | 354 | ||
355 | 355 | ||
356 | void Today::getMail() { | 356 | void Today::getMail() { |
357 | Config cfg("opiemail"); | 357 | Config cfg("opiemail"); |
358 | cfg.setGroup("today"); | 358 | cfg.setGroup("today"); |
359 | 359 | ||
360 | // how many lines should be showed in the task section | 360 | // how many lines should be showed in the task section |
361 | int NEW_MAILS = cfg.readNumEntry("newmails",0); | 361 | int NEW_MAILS = cfg.readNumEntry("newmails",0); |
362 | int OUTGOING = cfg.readNumEntry("outgoing",0); | 362 | int OUTGOING = cfg.readNumEntry("outgoing",0); |
363 | 363 | ||
364 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); | 364 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); |
365 | 365 | ||
366 | MailField->setText(output); | 366 | MailField->setText(output); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | /* | 370 | /* |
371 | * Get the todos | 371 | * Get the todos |
372 | */ | 372 | */ |
373 | void Today::getTodo() { | 373 | void Today::getTodo() { |
374 | 374 | ||
375 | QString output; | 375 | QString output; |
376 | QString tmpout; | 376 | QString tmpout; |
377 | int count = 0; | 377 | int count = 0; |
378 | int ammount = 0; | 378 | int ammount = 0; |
379 | 379 | ||
380 | // get overdue todos first | 380 | // get overdue todos first |
381 | QValueList<ToDoEvent> overDueList = todo->overDue(); | 381 | QValueList<ToDoEvent> overDueList = todo->overDue(); |
382 | qBubbleSort(overDueList); | 382 | qBubbleSort(overDueList); |
383 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); | 383 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); |
384 | it!=overDueList.end(); ++it ) { | 384 | it!=overDueList.end(); ++it ) { |
385 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { | 385 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { |
386 | tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; | 386 | tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; |
387 | ammount++; | 387 | ammount++; |
388 | } | 388 | } |
389 | } | 389 | } |
390 | 390 | ||
391 | // get total number of still open todos | 391 | // get total number of still open todos |
392 | QValueList<ToDoEvent> open = todo->rawToDos(); | 392 | QValueList<ToDoEvent> open = todo->rawToDos(); |
393 | qBubbleSort(open); | 393 | qBubbleSort(open); |
394 | for ( QValueList<ToDoEvent>::Iterator it=open.begin(); | 394 | for ( QValueList<ToDoEvent>::Iterator it=open.begin(); |
395 | it!=open.end(); ++it ) { | 395 | it!=open.end(); ++it ) { |
396 | if (!(*it).isCompleted()){ | 396 | if (!(*it).isCompleted()){ |
397 | count +=1; | 397 | count +=1; |
398 | // not the overdues, we allready got them, and not if we are | 398 | // not the overdues, we allready got them, and not if we are |
399 | // over the maxlines | 399 | // over the maxlines |
400 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { | 400 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { |
401 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 401 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
402 | ammount++; | 402 | ammount++; |
403 | } | 403 | } |
404 | } | 404 | } |
405 | } | 405 | } |
406 | 406 | ||
407 | 407 | ||
408 | if (count > 0) { | 408 | if (count > 0) { |
409 | if( count == 1 ) { | 409 | if( count == 1 ) { |
410 | output = tr("There is <b> 1</b> active task: <br>" ); | 410 | output = tr("There is <b> 1</b> active task: <br>" ); |
411 | } else { | 411 | } else { |
412 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); | 412 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); |
413 | } | 413 | } |
414 | output += tmpout; | 414 | output += tmpout; |
415 | } else { | 415 | } else { |
416 | output = tr("No active tasks"); | 416 | output = tr("No active tasks"); |
417 | } | 417 | } |
418 | 418 | ||
419 | TodoField->setText(tr(output)); | 419 | TodoField->setText(tr(output)); |
420 | } | 420 | } |
421 | 421 | ||
422 | /* | 422 | /* |
423 | * launches datebook | 423 | * launches datebook |
424 | */ | 424 | */ |
425 | void Today::startDatebook() { | 425 | void Today::startDatebook() { |
426 | QCopEnvelope e("QPE/System", "execute(QString)"); | 426 | QCopEnvelope e("QPE/System", "execute(QString)"); |
427 | e << QString("datebook"); | 427 | e << QString("datebook"); |
428 | } | 428 | } |
429 | 429 | ||
430 | /* | 430 | /* |
431 | * starts the edit dialog as known from datebook | 431 | * starts the edit dialog as known from datebook |
432 | */ | 432 | */ |
433 | 433 | ||
434 | extern QPEApplication *todayApp; | 434 | extern QPEApplication *todayApp; |
435 | 435 | ||
436 | void Today::editEvent(const Event &e) { | 436 | void Today::editEvent(const Event &e) { |
437 | startDatebook(); | 437 | startDatebook(); |
438 | 438 | ||
439 | while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); | 439 | while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); |
440 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); | 440 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); |
441 | env << e.uid(); | 441 | env << e.uid(); |
442 | } | 442 | } |
443 | 443 | ||
444 | /* | 444 | /* |
445 | * launches todolist | 445 | * launches todolist |
446 | */ | 446 | */ |
447 | void Today::startTodo() { | 447 | void Today::startTodo() { |
448 | QCopEnvelope e("QPE/System", "execute(QString)"); | 448 | QCopEnvelope e("QPE/System", "execute(QString)"); |
449 | e << QString("todolist"); | 449 | e << QString("todolist"); |
450 | } | 450 | } |
451 | 451 | ||
452 | /* | 452 | /* |
453 | * launch opiemail | 453 | * launch opiemail |
454 | */ | 454 | */ |
455 | void Today::startMail() { | 455 | void Today::startMail() { |
456 | QCopEnvelope e("QPE/System", "execute(QString)"); | 456 | QCopEnvelope e("QPE/System", "execute(QString)"); |
457 | e << QString("opiemail"); | 457 | e << QString("opiemail"); |
458 | //Right now start both, maybe decide which to rum via config file .. | 458 | //Right now start both, maybe decide which to rum via config file .. |
459 | QCopEnvelope f("QPE/System", "execute(QString)"); | 459 | QCopEnvelope f("QPE/System", "execute(QString)"); |
460 | f << QString("qtmail"); | 460 | f << QString("qtmail"); |
461 | } | 461 | } |
462 | 462 | ||
463 | 463 | ||
464 | Today::~Today() { | 464 | Today::~Today() { |
465 | } | 465 | } |
466 | 466 | ||
467 | /* | 467 | /* |
468 | * Gets the events for the current day, if it should get all dates | 468 | * Gets the events for the current day, if it should get all dates |
469 | */ | 469 | */ |
470 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | 470 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, |
471 | QWidget* parent = 0, | 471 | QWidget* parent = 0, |
472 | int SHOW_LOCATION = 0, | 472 | int SHOW_LOCATION = 0, |
473 | int SHOW_NOTES = 0, | 473 | int SHOW_NOTES = 0, |
474 | const char* name = 0, | 474 | const char* name = 0, |
475 | WFlags fl = 0) : | 475 | WFlags fl = 0) : |
476 | ClickableLabel(parent,name,fl), event(ev) { | 476 | ClickableLabel(parent,name,fl), event(ev) { |
477 | 477 | ||
478 | QString msg; | 478 | QString msg; |
479 | //QTime time = QTime::currentTime(); | 479 | //QTime time = QTime::currentTime(); |
480 | 480 | ||
481 | Config config( "qpe" ); | 481 | Config config( "qpe" ); |
482 | config.setGroup( "Time" ); | ||
482 | // if 24 h format | 483 | // if 24 h format |
483 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 484 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
484 | 485 | ||
485 | 486 | ||
486 | if (!ONLY_LATER) { | 487 | if (!ONLY_LATER) { |
487 | msg += "<B>" + (ev).description() + "</B>"; | 488 | msg += "<B>" + (ev).description() + "</B>"; |
488 | if ( (ev).event().hasAlarm() ) { | 489 | if ( (ev).event().hasAlarm() ) { |
489 | msg += " <b>[with alarm]</b>"; | 490 | msg += " <b>[with alarm]</b>"; |
490 | } | 491 | } |
491 | // include location or not | 492 | // include location or not |
492 | if (SHOW_LOCATION == 1) { | 493 | if (SHOW_LOCATION == 1) { |
493 | msg += "<BR><i>" + (ev).location() + "</i>"; | 494 | msg += "<BR><i>" + (ev).location() + "</i>"; |
494 | } | 495 | } |
495 | 496 | ||
496 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 497 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
497 | msg += "<br>All day"; | 498 | msg += "<br>All day"; |
498 | } else { | 499 | } else { |
499 | // start time of event | 500 | // start time of event |
500 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) | 501 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) |
501 | // end time of event | 502 | // end time of event |
502 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); | 503 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); |
503 | } | 504 | } |
504 | 505 | ||
505 | // include possible note or not | 506 | // include possible note or not |
506 | if (SHOW_NOTES == 1) { | 507 | if (SHOW_NOTES == 1) { |
507 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); | 508 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); |
508 | } | 509 | } |
509 | } | 510 | } |
510 | setText(msg); | 511 | setText(msg); |
511 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 512 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
512 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 513 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
513 | } | 514 | } |
514 | 515 | ||
515 | 516 | ||
516 | QString DateBookEvent::ampmTime(QTime tm) { | 517 | QString DateBookEvent::ampmTime(QTime tm) { |
517 | 518 | ||
518 | QString s; | 519 | QString s; |
519 | if( ampm ) { | 520 | if( ampm ) { |
520 | int hour = tm.hour(); | 521 | int hour = tm.hour(); |
521 | if (hour == 0) | 522 | if (hour == 0) |
522 | hour = 12; | 523 | hour = 12; |
523 | if (hour > 12) | 524 | if (hour > 12) |
524 | hour -= 12; | 525 | hour -= 12; |
525 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 526 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
526 | (tm.hour() >= 12) ? "PM" : "AM" ); | 527 | (tm.hour() >= 12) ? "PM" : "AM" ); |
527 | return s; | 528 | return s; |
528 | } else { | 529 | } else { |
529 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 530 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
530 | return s; | 531 | return s; |
531 | } | 532 | } |
532 | 533 | ||
533 | } | 534 | } |
534 | 535 | ||
535 | 536 | ||
536 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, | 537 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, |
537 | QWidget* parent = 0, | 538 | QWidget* parent = 0, |
538 | int SHOW_LOCATION = 0, | 539 | int SHOW_LOCATION = 0, |
539 | int SHOW_NOTES = 0, | 540 | int SHOW_NOTES = 0, |
540 | const char* name = 0, | 541 | const char* name = 0, |
541 | WFlags fl = 0) : | 542 | WFlags fl = 0) : |
542 | ClickableLabel(parent,name,fl), event(ev) { | 543 | ClickableLabel(parent,name,fl), event(ev) { |
543 | 544 | ||
544 | QString msg; | 545 | QString msg; |
545 | QTime time = QTime::currentTime(); | 546 | QTime time = QTime::currentTime(); |
546 | 547 | ||
547 | Config config( "qpe" ); | 548 | Config config( "qpe" ); |
549 | config.setGroup( "Time" ); | ||
548 | // if 24 h format | 550 | // if 24 h format |
549 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 551 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
550 | 552 | ||
551 | 553 | ||
552 | if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { | 554 | if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { |
553 | // show only later appointments | 555 | // show only later appointments |
554 | msg += "<B>" + (ev).description() + "</B>"; | 556 | msg += "<B>" + (ev).description() + "</B>"; |
555 | if ( (ev).event().hasAlarm() ) { | 557 | if ( (ev).event().hasAlarm() ) { |
556 | msg += " <b>[with alarm]</b>"; | 558 | msg += " <b>[with alarm]</b>"; |
557 | } | 559 | } |
558 | // include location or not | 560 | // include location or not |
559 | if (SHOW_LOCATION == 1) { | 561 | if (SHOW_LOCATION == 1) { |
560 | msg += "<BR><i>" + (ev).location() + "</i>"; | 562 | msg += "<BR><i>" + (ev).location() + "</i>"; |
561 | } | 563 | } |
562 | 564 | ||
563 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 565 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
564 | msg += "<br>All day"; | 566 | msg += "<br>All day"; |
565 | } else { | 567 | } else { |
566 | // start time of event | 568 | // start time of event |
567 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) | 569 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) |
568 | // end time of event | 570 | // end time of event |
569 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); | 571 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); |
570 | } | 572 | } |
571 | // include possible note or not | 573 | // include possible note or not |
572 | if (SHOW_NOTES == 1) { | 574 | if (SHOW_NOTES == 1) { |
573 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); | 575 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); |
574 | } | 576 | } |
575 | } | 577 | } |
576 | 578 | ||
577 | setText(msg); | 579 | setText(msg); |
578 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 580 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
579 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 581 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
580 | } | 582 | } |
581 | 583 | ||
582 | 584 | ||
583 | QString DateBookEventLater::ampmTime(QTime tm) { | 585 | QString DateBookEventLater::ampmTime(QTime tm) { |
584 | 586 | ||
585 | QString s; | 587 | QString s; |
586 | if( ampm ) { | 588 | if( ampm ) { |
587 | int hour = tm.hour(); | 589 | int hour = tm.hour(); |
588 | if (hour == 0) | 590 | if (hour == 0) |
589 | hour = 12; | 591 | hour = 12; |
590 | if (hour > 12) | 592 | if (hour > 12) |
591 | hour -= 12; | 593 | hour -= 12; |
592 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 594 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
593 | (tm.hour() >= 12) ? "PM" : "AM" ); | 595 | (tm.hour() >= 12) ? "PM" : "AM" ); |
594 | return s; | 596 | return s; |
595 | } else { | 597 | } else { |
596 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 598 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
597 | return s; | 599 | return s; |
598 | } | 600 | } |
599 | 601 | ||
600 | } | 602 | } |
601 | 603 | ||
602 | 604 | ||
603 | void DateBookEvent::editMe() { | 605 | void DateBookEvent::editMe() { |
604 | emit editEvent(event.event()); | 606 | emit editEvent(event.event()); |
605 | } | 607 | } |
606 | 608 | ||
607 | void DateBookEventLater::editMe() { | 609 | void DateBookEventLater::editMe() { |
608 | emit editEvent(event.event()); | 610 | emit editEvent(event.event()); |
609 | } | 611 | } |
610 | 612 | ||
611 | 613 | ||
diff --git a/core/pim/today/todaybase.cpp b/core/pim/today/todaybase.cpp index ae8763b..c6ea11f 100644 --- a/core/pim/today/todaybase.cpp +++ b/core/pim/today/todaybase.cpp | |||
@@ -1,194 +1,203 @@ | |||
1 | /* | 1 | /* |
2 | * todaybase.cpp * | 2 | * todaybase.cpp * |
3 | * --------------------- | 3 | * --------------------- |
4 | * | 4 | * |
5 | * begin : Sun 10 17:20:00 CEST 2002 | 5 | * begin : Sun 10 17:20:00 CEST 2002 |
6 | * copyright : (c) 2002 by Maximilian Reiß | 6 | * copyright : (c) 2002 by Maximilian Reiß |
7 | * email : max.reiss@gmx.de | 7 | * email : max.reiss@gmx.de |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | #include "todaybase.h" | 19 | #include "todaybase.h" |
20 | 20 | ||
21 | #include <qframe.h> | 21 | #include <qframe.h> |
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qvariant.h> | 25 | #include <qvariant.h> |
26 | #include <qwhatsthis.h> | 26 | #include <qwhatsthis.h> |
27 | #include <qimage.h> | 27 | #include <qimage.h> |
28 | #include <qpixmap.h> | 28 | #include <qpixmap.h> |
29 | #include <qscrollview.h> | 29 | #include <qscrollview.h> |
30 | #include <qvbox.h> | 30 | #include <qvbox.h> |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | 32 | ||
33 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * Constructs a TodayBase which is a child of 'parent', with the | 36 | * Constructs a TodayBase which is a child of 'parent', with the |
37 | * name 'name' and widget flags set to 'f' | 37 | * name 'name' and widget flags set to 'f' |
38 | */ | 38 | */ |
39 | TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) | 39 | TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) |
40 | : QWidget( parent, name, fl ) | 40 | : QWidget( parent, name, fl ) |
41 | { | 41 | { |
42 | QPixmap logo = Resource::loadPixmap( "today/today_logo"); // logo | 42 | QPixmap logo = Resource::loadPixmap( "today/today_logo"); // logo |
43 | QPixmap datebook = Resource::loadPixmap("DateBook"); // datebook | 43 | QPixmap datebook = Resource::loadPixmap("DateBook"); // datebook |
44 | QPixmap todo = Resource::loadPixmap( "TodoList" ); // todo | 44 | QPixmap todo = Resource::loadPixmap( "TodoList" ); // todo |
45 | QPixmap config = Resource::loadPixmap( "today/config" ); // config icon | 45 | QPixmap config = Resource::loadPixmap( "today/config" ); // config icon |
46 | QPixmap mail = Resource::loadPixmap( "today/mail" ); // mail icon | 46 | QPixmap mail = Resource::loadPixmap( "today/mail" ); // mail icon |
47 | 47 | QPixmap opiezilla = Resource::loadPixmap("today/opiezilla" ); //the opiezilla | |
48 | //QPalette pal = this->palette(); | ||
49 | // QColor col = pal.color(QPalette::Active, QColorGroup::Background); | ||
50 | //pal.setColor(QPalette::Active, QColorGroup::Button, col); | ||
51 | //pal.setColor(QPalette::Inactive, QColorGroup::Button, col); | ||
52 | //pal.setColor(QPalette::Normal, QColorGroup::Button, col); | ||
53 | //pal.setColor(QPalette::Disabled, QColorGroup::Button, col); | ||
54 | //this->setPalette(pal); | ||
55 | |||
56 | 48 | ||
57 | QWidget *d = QApplication::desktop(); | 49 | QWidget *d = QApplication::desktop(); |
58 | int w=d->width(); | 50 | int w=d->width(); |
59 | int h=d->height(); | 51 | int h=d->height(); |
60 | resize( w , h ); | 52 | resize( w , h ); |
61 | 53 | ||
62 | // hehe, qt is ... | 54 | // hehe, qt is ... |
63 | getridoffuckingstrippeldlinesbutton = new QPushButton (this, "asdfsad" ); | 55 | getridoffuckingstrippeldlinesbutton = new QPushButton (this, "asdfsad" ); |
64 | getridoffuckingstrippeldlinesbutton->setGeometry( QRect( -5, 10, 0, 0 ) ); | 56 | getridoffuckingstrippeldlinesbutton->setGeometry( QRect( -5, 10, 0, 0 ) ); |
65 | 57 | ||
66 | QVBoxLayout * layout = new QVBoxLayout(this); | 58 | QVBoxLayout * layout = new QVBoxLayout(this); |
67 | 59 | ||
68 | // --- logo Section --- | 60 | // --- logo Section --- |
69 | QPalette pal2; | 61 | QPalette pal2; |
70 | QColorGroup cg; | 62 | QColorGroup cg; |
71 | cg.setColor( QColorGroup::Text, white ); | 63 | cg.setColor( QColorGroup::Text, white ); |
72 | cg.setBrush( QColorGroup::Background, QBrush( QColor( 238, 238, 230), logo ) ); | 64 | cg.setBrush( QColorGroup::Background, QBrush( QColor( 238, 238, 230), logo ) ); |
73 | pal2.setActive( cg ); | 65 | pal2.setActive( cg ); |
74 | // today logo | 66 | // today logo |
75 | Frame = new QLabel( this, "Frame" ); | 67 | Frame = new QLabel( this, "Frame" ); |
76 | Frame->setPalette( pal2 ); | 68 | Frame->setPalette( pal2 ); |
77 | Frame->setFrameShape( QFrame::StyledPanel ); | 69 | Frame->setFrameShape( QFrame::StyledPanel ); |
78 | Frame->setFrameShadow( QFrame::Raised ); | 70 | Frame->setFrameShadow( QFrame::Raised ); |
79 | Frame->setLineWidth( 0 ); | 71 | Frame->setLineWidth( 0 ); |
80 | Frame->setMaximumHeight(50); | 72 | Frame->setMaximumHeight(50); |
81 | Frame->setMinimumHeight(50); | 73 | Frame->setMinimumHeight(50); |
74 | |||
75 | // Today text | ||
76 | QLabel* TodayLabel = new QLabel( Frame, "TodayText" ); | ||
77 | TodayLabel->setGeometry( QRect( 10, 0, 168, 40 ) ); | ||
78 | QFont TodayLabel_font( TodayLabel->font() ); | ||
79 | TodayLabel_font.setBold( TRUE ); | ||
80 | TodayLabel_font.setPointSize(40); | ||
81 | TodayLabel->setFont( TodayLabel_font ); | ||
82 | TodayLabel->setBackgroundOrigin( QLabel::ParentOrigin ); | ||
83 | TodayLabel->setText("<font color=#FFFFFF>" + tr("Today") +"</font>"); | ||
84 | |||
85 | // Opiezilla | ||
86 | QLabel* Opiezilla = new QLabel( Frame, "OpieZilla"); | ||
87 | Opiezilla->setPixmap( opiezilla ); | ||
88 | Opiezilla->setGeometry( this->width()-50 ,1, 45, 47); | ||
89 | Opiezilla->setBackgroundOrigin( QLabel::ParentOrigin ); | ||
90 | |||
82 | // date | 91 | // date |
83 | TextLabel1 = new QLabel( Frame, "TextLabel1" ); | 92 | TextLabel1 = new QLabel( Frame, "TextLabel1" ); |
84 | TextLabel1->setGeometry( QRect( 10, 35, 168, 12 ) ); | 93 | TextLabel1->setGeometry( QRect( 10, 35, 168, 12 ) ); |
85 | QFont TextLabel1_font( TextLabel1->font() ); | 94 | QFont TextLabel1_font( TextLabel1->font() ); |
86 | TextLabel1_font.setBold( TRUE ); | 95 | TextLabel1_font.setBold( TRUE ); |
87 | TextLabel1->setFont( TextLabel1_font ); | 96 | TextLabel1->setFont( TextLabel1_font ); |
88 | TextLabel1->setBackgroundOrigin( QLabel::ParentOrigin ); | 97 | TextLabel1->setBackgroundOrigin( QLabel::ParentOrigin ); |
89 | TextLabel1->setTextFormat( RichText ); | 98 | TextLabel1->setTextFormat( RichText ); |
90 | 99 | ||
91 | OwnerField = new QLabel(this , "Owner" ); | 100 | OwnerField = new QLabel(this , "Owner" ); |
92 | OwnerField->setGeometry(QRect(0,0, this->width(), 12 )); | 101 | OwnerField->setGeometry(QRect(0,0, this->width(), 12 )); |
93 | OwnerField->setAlignment(int (QLabel::AlignTop | QLabel::AlignLeft ) ); | 102 | OwnerField->setAlignment(int (QLabel::AlignTop | QLabel::AlignLeft ) ); |
94 | OwnerField->setMaximumHeight(12); | 103 | OwnerField->setMaximumHeight(12); |
95 | 104 | ||
96 | // --- dates section --- | 105 | // --- dates section --- |
97 | Frame4 = new QFrame( this, "Frame4" ); | 106 | Frame4 = new QFrame( this, "Frame4" ); |
98 | // Frame4->setPalette( pal ); | 107 | // Frame4->setPalette( pal ); |
99 | Frame4->setFrameShape( QScrollView::StyledPanel ); | 108 | Frame4->setFrameShape( QScrollView::StyledPanel ); |
100 | Frame4->setFrameShadow( QScrollView::Sunken ); | 109 | Frame4->setFrameShadow( QScrollView::Sunken ); |
101 | Frame4->setBackgroundOrigin( QScrollView::ParentOrigin ); | 110 | Frame4->setBackgroundOrigin( QScrollView::ParentOrigin ); |
102 | Frame4->setFrameStyle( QFrame::NoFrame ); | 111 | Frame4->setFrameStyle( QFrame::NoFrame ); |
103 | Frame4->setGeometry (QRect( 0, 8, this->width() , this->height()) ); | 112 | Frame4->setGeometry (QRect( 0, 8, this->width() , this->height()) ); |
104 | 113 | ||
105 | sv1 = new QScrollView( Frame4 ); | 114 | sv1 = new QScrollView( Frame4 ); |
106 | sv1->setResizePolicy(QScrollView::AutoOneFit); | 115 | sv1->setResizePolicy(QScrollView::AutoOneFit); |
107 | sv1->setHScrollBarMode( QScrollView::AlwaysOff ); | 116 | sv1->setHScrollBarMode( QScrollView::AlwaysOff ); |
108 | // need to find a better way!!! | 117 | // need to find a better way!!! |
109 | sv1->setGeometry (QRect( 40, 2, Frame4->width()-40 , (Frame4->height()/3)+20 ) ); | 118 | sv1->setGeometry (QRect( 40, 2, Frame4->width()-40 , (Frame4->height()/3)+20 ) ); |
110 | sv1->setFrameShape(QFrame::NoFrame); | 119 | sv1->setFrameShape(QFrame::NoFrame); |
111 | 120 | ||
112 | DatesButton = new QPushButton (Frame4, "DatesButton" ); | 121 | DatesButton = new QPushButton (Frame4, "DatesButton" ); |
113 | DatesButton->setGeometry( QRect( 2, 4, 36, 32 ) ); | 122 | DatesButton->setGeometry( QRect( 2, 4, 36, 32 ) ); |
114 | DatesButton->setBackgroundOrigin( QPushButton::WidgetOrigin ); | 123 | DatesButton->setBackgroundOrigin( QPushButton::WidgetOrigin ); |
115 | // DatesButton->setPalette( pal ); | 124 | // DatesButton->setPalette( pal ); |
116 | DatesButton->setPixmap( datebook ); | 125 | DatesButton->setPixmap( datebook ); |
117 | DatesButton->setFlat( TRUE ); | 126 | DatesButton->setFlat( TRUE ); |
118 | 127 | ||
119 | // --- mail section ---) | 128 | // --- mail section ---) |
120 | MailFrame = new QFrame( this ,"MailFrame" ); | 129 | MailFrame = new QFrame( this ,"MailFrame" ); |
121 | MailFrame->setBackgroundOrigin( QScrollView::ParentOrigin ); | 130 | MailFrame->setBackgroundOrigin( QScrollView::ParentOrigin ); |
122 | MailFrame->setGeometry (QRect( 0, 0, this->width() , 15) ); | 131 | MailFrame->setGeometry (QRect( 0, 0, this->width() , 15) ); |
123 | MailFrame->setFrameStyle( QFrame::NoFrame ); | 132 | MailFrame->setFrameStyle( QFrame::NoFrame ); |
124 | 133 | ||
125 | QFrame* Line1 = new QFrame( MailFrame); | 134 | QFrame* Line1 = new QFrame( MailFrame); |
126 | Line1->setGeometry( QRect( -5, 0, MailFrame->width()+5, 5 ) ); | 135 | Line1->setGeometry( QRect( -5, 0, MailFrame->width()+5, 5 ) ); |
127 | Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 136 | Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
128 | 137 | ||
129 | MailButton = new QPushButton (MailFrame, "MailButton" ); | 138 | MailButton = new QPushButton (MailFrame, "MailButton" ); |
130 | MailButton->setGeometry( QRect( 2, 3, 36, 19 ) ); | 139 | MailButton->setGeometry( QRect( 2, 3, 36, 19 ) ); |
131 | // MailButton->setPalette( pal ); | 140 | // MailButton->setPalette( pal ); |
132 | MailButton->setPixmap( mail ); | 141 | MailButton->setPixmap( mail ); |
133 | MailButton->setFlat( TRUE ); | 142 | MailButton->setFlat( TRUE ); |
134 | 143 | ||
135 | MailField = new QLabel( MailFrame, "MailField" ); | 144 | MailField = new QLabel( MailFrame, "MailField" ); |
136 | MailField->setGeometry( QRect( 40, 4, MailFrame->width(), 12) ); | 145 | MailField->setGeometry( QRect( 40, 4, MailFrame->width(), 12) ); |
137 | MailField->setText( tr( "Opiemail not installed" ) ); | 146 | MailField->setText( tr( "Opiemail not installed" ) ); |
138 | MailField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) ); | 147 | MailField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) ); |
139 | MailField->setMaximumHeight(40); | 148 | MailField->setMaximumHeight(40); |
140 | MailField->setMinimumHeight(15); | 149 | MailField->setMinimumHeight(15); |
141 | 150 | ||
142 | // --- todo section -- | 151 | // --- todo section -- |
143 | Frame15 = new QFrame( this, "Frame15" ); | 152 | Frame15 = new QFrame( this, "Frame15" ); |
144 | Frame15->setFrameStyle( QFrame::NoFrame ); | 153 | Frame15->setFrameStyle( QFrame::NoFrame ); |
145 | Frame15->setGeometry (QRect( 40, 3, this->width() , this->height()) ); | 154 | Frame15->setGeometry (QRect( 40, 3, this->width() , this->height()) ); |
146 | 155 | ||
147 | QFrame* Line2 = new QFrame( Frame15); | 156 | QFrame* Line2 = new QFrame( Frame15); |
148 | Line2->setGeometry( QRect( -5, 0, MailFrame->width()+5, 5 ) ); | 157 | Line2->setGeometry( QRect( -5, 0, MailFrame->width()+5, 5 ) ); |
149 | Line2->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 158 | Line2->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
150 | 159 | ||
151 | TodoButton = new QPushButton (Frame15, "TodoButton" ); | 160 | TodoButton = new QPushButton (Frame15, "TodoButton" ); |
152 | TodoButton->setGeometry( QRect( 2, 4, 36, 32 ) ); | 161 | TodoButton->setGeometry( QRect( 2, 4, 36, 32 ) ); |
153 | // TodoButton->setPalette( pal ); | 162 | // TodoButton->setPalette( pal ); |
154 | TodoButton->setPixmap( todo ); | 163 | TodoButton->setPixmap( todo ); |
155 | TodoButton->setFlat( TRUE ); | 164 | TodoButton->setFlat( TRUE ); |
156 | 165 | ||
157 | QScrollView* sv2 = new QScrollView( Frame15 ); | 166 | QScrollView* sv2 = new QScrollView( Frame15 ); |
158 | sv2->setResizePolicy(QScrollView::AutoOneFit); | 167 | sv2->setResizePolicy(QScrollView::AutoOneFit); |
159 | sv2->setHScrollBarMode( QScrollView::AlwaysOff ); | 168 | sv2->setHScrollBarMode( QScrollView::AlwaysOff ); |
160 | sv2->setGeometry (QRect( 40, 3, Frame15->width()-40 , (Frame15->height()/3) ) ); | 169 | sv2->setGeometry (QRect( 40, 3, Frame15->width()-40 , (Frame15->height()/3) ) ); |
161 | sv2->setFrameShape(QFrame::NoFrame); | 170 | sv2->setFrameShape(QFrame::NoFrame); |
162 | 171 | ||
163 | TodoField = new QLabel( sv2->viewport(), "TodoField" ); | 172 | TodoField = new QLabel( sv2->viewport(), "TodoField" ); |
164 | sv2->addChild(TodoField); | 173 | sv2->addChild(TodoField); |
165 | TodoField->setFrameShadow( QLabel::Plain ); | 174 | TodoField->setFrameShadow( QLabel::Plain ); |
166 | //TodoField->setText( tr( "No current todos" ) ); | 175 | //TodoField->setText( tr( "No current todos" ) ); |
167 | TodoField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) ); | 176 | TodoField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) ); |
168 | 177 | ||
169 | PushButton1 = new QPushButton (Frame15, "PushButton1" ); | 178 | PushButton1 = new QPushButton (Frame15, "PushButton1" ); |
170 | PushButton1->setGeometry( QRect( 2, 68, 25, 21 ) ); | 179 | PushButton1->setGeometry( QRect( 2, 68, 25, 21 ) ); |
171 | PushButton1->setPixmap( config ); | 180 | PushButton1->setPixmap( config ); |
172 | // PushButton1->setPalette( pal ); | 181 | // PushButton1->setPalette( pal ); |
173 | PushButton1->setAutoDefault( TRUE ); | 182 | PushButton1->setAutoDefault( TRUE ); |
174 | PushButton1->setFlat( TRUE ); | 183 | PushButton1->setFlat( TRUE ); |
175 | 184 | ||
176 | // -- layout -- | 185 | // -- layout -- |
177 | layout->addWidget(Frame); | 186 | layout->addWidget(Frame); |
178 | layout->addWidget(OwnerField); | 187 | layout->addWidget(OwnerField); |
179 | layout->addWidget(Frame4); | 188 | layout->addWidget(Frame4); |
180 | layout->addWidget(MailFrame); | 189 | layout->addWidget(MailFrame); |
181 | layout->addWidget(Frame15); | 190 | layout->addWidget(Frame15); |
182 | 191 | ||
183 | layout->setStretchFactor(Frame4,5); | 192 | layout->setStretchFactor(Frame4,5); |
184 | layout->setStretchFactor(MailFrame,1); | 193 | layout->setStretchFactor(MailFrame,1); |
185 | layout->setStretchFactor(Frame15,4); | 194 | layout->setStretchFactor(Frame15,4); |
186 | } | 195 | } |
187 | 196 | ||
188 | /* | 197 | /* |
189 | * Destroys the object and frees any allocated resources | 198 | * Destroys the object and frees any allocated resources |
190 | */ | 199 | */ |
191 | TodayBase::~TodayBase() | 200 | TodayBase::~TodayBase() |
192 | { | 201 | { |
193 | } | 202 | } |
194 | 203 | ||