-rw-r--r-- | core/pim/today/today.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 51aba69..7cef035 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -54,48 +54,49 @@ int SHOW_NOTES; | |||
54 | // show only later dates | 54 | // show only later dates |
55 | int ONLY_LATER; | 55 | int ONLY_LATER; |
56 | int AUTOSTART; | 56 | int AUTOSTART; |
57 | int NEW_START=1; | 57 | int NEW_START=1; |
58 | 58 | ||
59 | /* | 59 | /* |
60 | * Constructs a Example which is a child of 'parent', with the | 60 | * Constructs a Example which is a child of 'parent', with the |
61 | * name 'name' and widget flags set to 'f' | 61 | * name 'name' and widget flags set to 'f' |
62 | */ | 62 | */ |
63 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 63 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
64 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { | 64 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { |
65 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); | 65 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); |
66 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); | 66 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); |
67 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); | 67 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); |
68 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); | 68 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); |
69 | 69 | ||
70 | #if defined(Q_WS_QWS) | 70 | #if defined(Q_WS_QWS) |
71 | #if !defined(QT_NO_COP) | 71 | #if !defined(QT_NO_COP) |
72 | QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); | 72 | QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); |
73 | connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 73 | connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
74 | this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); | 74 | this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); |
75 | #endif | 75 | #endif |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | db = NULL; | ||
78 | setOwnerField(); | 79 | setOwnerField(); |
79 | todo = new ToDoDB; | 80 | todo = new ToDoDB; |
80 | getTodo(); | 81 | getTodo(); |
81 | draw(); | 82 | draw(); |
82 | autoStart(); | 83 | autoStart(); |
83 | } | 84 | } |
84 | 85 | ||
85 | /* | 86 | /* |
86 | * Qcop receive method. | 87 | * Qcop receive method. |
87 | */ | 88 | */ |
88 | void Today::channelReceived(const QCString &msg, const QByteArray & data) { | 89 | void Today::channelReceived(const QCString &msg, const QByteArray & data) { |
89 | QDataStream stream(data, IO_ReadOnly ); | 90 | QDataStream stream(data, IO_ReadOnly ); |
90 | if ( msg == "message(QString)" ) { | 91 | if ( msg == "message(QString)" ) { |
91 | QString message; | 92 | QString message; |
92 | stream >> message; | 93 | stream >> message; |
93 | setOwnerField(message); | 94 | setOwnerField(message); |
94 | } | 95 | } |
95 | 96 | ||
96 | } | 97 | } |
97 | 98 | ||
98 | /* | 99 | /* |
99 | * Initialises the owner field with the default value, the username | 100 | * Initialises the owner field with the default value, the username |
100 | */ | 101 | */ |
101 | void Today::setOwnerField() { | 102 | void Today::setOwnerField() { |
@@ -188,49 +189,49 @@ bool Today::checkIfModified() { | |||
188 | void Today::init() { | 189 | void Today::init() { |
189 | QDate date = QDate::currentDate(); | 190 | QDate date = QDate::currentDate(); |
190 | QString time = (tr( date.toString()) ); | 191 | QString time = (tr( date.toString()) ); |
191 | 192 | ||
192 | TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); | 193 | TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); |
193 | 194 | ||
194 | // read config | 195 | // read config |
195 | Config cfg("today"); | 196 | Config cfg("today"); |
196 | cfg.setGroup("BaseConfig"); | 197 | cfg.setGroup("BaseConfig"); |
197 | 198 | ||
198 | // -- config file section -- | 199 | // -- config file section -- |
199 | // how many lines should be showed in the task section | 200 | // how many lines should be showed in the task section |
200 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); | 201 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); |
201 | // after how many chars should the be cut off on tasks and notes | 202 | // after how many chars should the be cut off on tasks and notes |
202 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40); | 203 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40); |
203 | // how many lines should be showed in the datebook section | 204 | // how many lines should be showed in the datebook section |
204 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); | 205 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); |
205 | // If location is to be showed too, 1 to activate it. | 206 | // If location is to be showed too, 1 to activate it. |
206 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); | 207 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); |
207 | // if notes should be shown | 208 | // if notes should be shown |
208 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); | 209 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); |
209 | // should only later appointments be shown or all for the current day. | 210 | // should only later appointments be shown or all for the current day. |
210 | ONLY_LATER = cfg.readNumEntry("onlylater",1); | 211 | ONLY_LATER = cfg.readNumEntry("onlylater",1); |
211 | 212 | ||
212 | db = new DateBookDB; | 213 | //db = new DateBookDB; |
213 | } | 214 | } |
214 | 215 | ||
215 | /* | 216 | /* |
216 | * The method for the configuration dialog. | 217 | * The method for the configuration dialog. |
217 | */ | 218 | */ |
218 | void Today::startConfig() { | 219 | void Today::startConfig() { |
219 | 220 | ||
220 | conf = new todayconfig ( this, "", true ); | 221 | conf = new todayconfig ( this, "", true ); |
221 | // read the config | 222 | // read the config |
222 | Config cfg("today"); | 223 | Config cfg("today"); |
223 | cfg.setGroup("BaseConfig"); | 224 | cfg.setGroup("BaseConfig"); |
224 | 225 | ||
225 | //init(); | 226 | //init(); |
226 | 227 | ||
227 | conf->SpinBox1->setValue(MAX_LINES_MEET); | 228 | conf->SpinBox1->setValue(MAX_LINES_MEET); |
228 | // location show box | 229 | // location show box |
229 | conf->CheckBox1->setChecked(SHOW_LOCATION); | 230 | conf->CheckBox1->setChecked(SHOW_LOCATION); |
230 | // notes show box | 231 | // notes show box |
231 | conf->CheckBox2->setChecked(SHOW_NOTES); | 232 | conf->CheckBox2->setChecked(SHOW_NOTES); |
232 | // task lines | 233 | // task lines |
233 | conf->SpinBox2->setValue(MAX_LINES_TASK); | 234 | conf->SpinBox2->setValue(MAX_LINES_TASK); |
234 | // clip when? | 235 | // clip when? |
235 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); | 236 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); |
236 | // only later | 237 | // only later |
@@ -253,49 +254,54 @@ void Today::startConfig() { | |||
253 | cfg.writeEntry("maxlinesmeet",maxmeet); | 254 | cfg.writeEntry("maxlinesmeet",maxmeet); |
254 | cfg.writeEntry("showlocation",location); | 255 | cfg.writeEntry("showlocation",location); |
255 | cfg.writeEntry("shownotes", notes); | 256 | cfg.writeEntry("shownotes", notes); |
256 | cfg.writeEntry("onlylater", onlylater); | 257 | cfg.writeEntry("onlylater", onlylater); |
257 | cfg.setGroup("Autostart"); | 258 | cfg.setGroup("Autostart"); |
258 | cfg.writeEntry("autostart", autostart); | 259 | cfg.writeEntry("autostart", autostart); |
259 | 260 | ||
260 | // sync it to "disk" | 261 | // sync it to "disk" |
261 | cfg.write(); | 262 | cfg.write(); |
262 | NEW_START=1; | 263 | NEW_START=1; |
263 | draw(); | 264 | draw(); |
264 | autoStart(); | 265 | autoStart(); |
265 | } | 266 | } |
266 | 267 | ||
267 | 268 | ||
268 | /* | 269 | /* |
269 | * Get all events that are in the datebook xml file for today | 270 | * Get all events that are in the datebook xml file for today |
270 | */ | 271 | */ |
271 | void Today::getDates() { | 272 | void Today::getDates() { |
272 | QDate date = QDate::currentDate(); | 273 | QDate date = QDate::currentDate(); |
273 | 274 | ||
274 | if (AllDateBookEvents) delete AllDateBookEvents; | 275 | if (AllDateBookEvents) delete AllDateBookEvents; |
275 | AllDateBookEvents = new QWidget( ); | 276 | AllDateBookEvents = new QWidget( ); |
276 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); | 277 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); |
277 | 278 | ||
279 | if (db) { | ||
280 | delete db; | ||
281 | } | ||
282 | db = new DateBookDB; | ||
283 | |||
278 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); | 284 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); |
279 | 285 | ||
280 | qBubbleSort(list); | 286 | qBubbleSort(list); |
281 | // printf("Get dates\n"); | 287 | // printf("Get dates\n"); |
282 | 288 | ||
283 | Config config( "qpe" ); | 289 | Config config( "qpe" ); |
284 | // if 24 h format | 290 | // if 24 h format |
285 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); | 291 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); |
286 | 292 | ||
287 | int count=0; | 293 | int count=0; |
288 | 294 | ||
289 | if ( list.count() > 0 ) { | 295 | if ( list.count() > 0 ) { |
290 | 296 | ||
291 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 297 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); |
292 | it!=list.end(); ++it ) { | 298 | it!=list.end(); ++it ) { |
293 | 299 | ||
294 | 300 | ||
295 | if ( count <= MAX_LINES_MEET ) { | 301 | if ( count <= MAX_LINES_MEET ) { |
296 | 302 | ||
297 | QTime time = QTime::currentTime(); | 303 | QTime time = QTime::currentTime(); |
298 | 304 | ||
299 | if (!ONLY_LATER) { | 305 | if (!ONLY_LATER) { |
300 | count++; | 306 | count++; |
301 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); | 307 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); |