author | harlekin <harlekin> | 2002-05-13 21:56:32 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-05-13 21:56:32 (UTC) |
commit | 654f18b7201655379a515d12e30e06de4ae2e564 (patch) (unidiff) | |
tree | 7faec6092629ab4a9387c7d9b9633ae6ea6e6115 | |
parent | addcce2881f07c1f04113e4df2ec7e4186d4cee4 (diff) | |
download | opie-654f18b7201655379a515d12e30e06de4ae2e564.zip opie-654f18b7201655379a515d12e30e06de4ae2e564.tar.gz opie-654f18b7201655379a515d12e30e06de4ae2e564.tar.bz2 |
serveral bugfixes regarding todo section
-rw-r--r-- | core/pim/today/changelog | 4 | ||||
-rw-r--r-- | core/pim/today/opie-today.control | 2 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 12 |
3 files changed, 11 insertions, 7 deletions
diff --git a/core/pim/today/changelog b/core/pim/today/changelog index c687cea..93bbcac 100644 --- a/core/pim/today/changelog +++ b/core/pim/today/changelog | |||
@@ -1,92 +1,96 @@ | |||
1 | 0.3.4 | ||
2 | |||
3 | * Several bugfixes regarding todo section. | ||
4 | |||
1 | 0.3.3 | 5 | 0.3.3 |
2 | 6 | ||
3 | * Changed the logo so it better scales to bigger display and also | 7 | * Changed the logo so it better scales to bigger display and also |
4 | made the "Today" string translatable. | 8 | made the "Today" string translatable. |
5 | * some am/pm fixes | 9 | * some am/pm fixes |
6 | * clickable labels now in libopie | 10 | * clickable labels now in libopie |
7 | 11 | ||
8 | 0.3.2 | 12 | 0.3.2 |
9 | 13 | ||
10 | * Autostart is now more configurable. You can decide how long | 14 | * Autostart is now more configurable. You can decide how long |
11 | the ipaq has to has been suspended, before autostart is triggered.(Opie | 15 | the ipaq has to has been suspended, before autostart is triggered.(Opie |
12 | only) | 16 | only) |
13 | * am/pm time optinal (autodetect) | 17 | * am/pm time optinal (autodetect) |
14 | 18 | ||
15 | 0.3.1 | 19 | 0.3.1 |
16 | 20 | ||
17 | * fixed the wrong color of the buttons | 21 | * fixed the wrong color of the buttons |
18 | * better translation (thanks carsten and others) | 22 | * better translation (thanks carsten and others) |
19 | * fixes memory leaks | 23 | * fixes memory leaks |
20 | * bugfixes in calendar part, now location and note are working again. | 24 | * bugfixes in calendar part, now location and note are working again. |
21 | 25 | ||
22 | 0.3.0 | 26 | 0.3.0 |
23 | 27 | ||
24 | * today uses now tododb from libopie. So major changes in the todo part: | 28 | * today uses now tododb from libopie. So major changes in the todo part: |
25 | - overdue items on top | 29 | - overdue items on top |
26 | - then sorted by date, then by priority | 30 | - then sorted by date, then by priority |
27 | * some cleanups | 31 | * some cleanups |
28 | * speed optimisations | 32 | * speed optimisations |
29 | 33 | ||
30 | 0.2.9 | 34 | 0.2.9 |
31 | 35 | ||
32 | * Many bugfixes. | 36 | * Many bugfixes. |
33 | * Today now apparently sorts the dates _allways_ right, i would assume it | 37 | * Today now apparently sorts the dates _allways_ right, i would assume it |
34 | to be a qt bug | 38 | to be a qt bug |
35 | 39 | ||
36 | 0.2.8 | 40 | 0.2.8 |
37 | 41 | ||
38 | * Appointments are now clickable (connection to datebook still missing) | 42 | * Appointments are now clickable (connection to datebook still missing) |
39 | * autostart support (opie only) | 43 | * autostart support (opie only) |
40 | 44 | ||
41 | 0.2.7 | 45 | 0.2.7 |
42 | 46 | ||
43 | * check if todolist.xml was changed before parsing it | 47 | * check if todolist.xml was changed before parsing it |
44 | * check only every 30 sec for changes. | 48 | * check only every 30 sec for changes. |
45 | * some visual stuff | 49 | * some visual stuff |
46 | * as usual many little improvements .-) | 50 | * as usual many little improvements .-) |
47 | 51 | ||
48 | 0.2.6 | 52 | 0.2.6 |
49 | 53 | ||
50 | * added scrollbars to dates and todo | 54 | * added scrollbars to dates and todo |
51 | * all day detection | 55 | * all day detection |
52 | * some smaller bugfixes | 56 | * some smaller bugfixes |
53 | 57 | ||
54 | 0.2.5 | 58 | 0.2.5 |
55 | 59 | ||
56 | * some other minor fixes regarding autoupdate | 60 | * some other minor fixes regarding autoupdate |
57 | * fixed segfault with todolist > 7 entries | 61 | * fixed segfault with todolist > 7 entries |
58 | * fixed the "ugly grey border around buttons" issue | 62 | * fixed the "ugly grey border around buttons" issue |
59 | * fixed the "empty calendar field" "bug" | 63 | * fixed the "empty calendar field" "bug" |
60 | * shown only later appointments as option | 64 | * shown only later appointments as option |
61 | 65 | ||
62 | 66 | ||
63 | 0.2.4 | 67 | 0.2.4 |
64 | 68 | ||
65 | * added support for email | 69 | * added support for email |
66 | * autoupdates after 1 min | 70 | * autoupdates after 1 min |
67 | * QCopEnvelope instead of system() | 71 | * QCopEnvelope instead of system() |
68 | * starting to use qvbox in gui | 72 | * starting to use qvbox in gui |
69 | 73 | ||
70 | 74 | ||
71 | 0.2.3 | 75 | 0.2.3 |
72 | 76 | ||
73 | * the 4 am release | 77 | * the 4 am release |
74 | * several bugfixes | 78 | * several bugfixes |
75 | 79 | ||
76 | 80 | ||
77 | 0.2.2 | 81 | 0.2.2 |
78 | 82 | ||
79 | * started working on calling other apps | 83 | * started working on calling other apps |
80 | * and finished it | 84 | * and finished it |
81 | 85 | ||
82 | 0.2.1 | 86 | 0.2.1 |
83 | 87 | ||
84 | * images no more inline | 88 | * images no more inline |
85 | * config dialog | 89 | * config dialog |
86 | 90 | ||
87 | 0.1.1 | 91 | 0.1.1 |
88 | 92 | ||
89 | * started changelog. | 93 | * started changelog. |
90 | * fixed segfault on empty/nonexistant todolist.xml | 94 | * fixed segfault on empty/nonexistant todolist.xml |
91 | * better handling for file location | 95 | * better handling for file location |
92 | 96 | ||
diff --git a/core/pim/today/opie-today.control b/core/pim/today/opie-today.control index da9d9fa..46c0d71 100644 --- a/core/pim/today/opie-today.control +++ b/core/pim/today/opie-today.control | |||
@@ -1,16 +1,16 @@ | |||
1 | Files: bin/today apps/Applications/today.desktop pics/today/* | 1 | Files: bin/today apps/Applications/today.desktop pics/today/* |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/applications | 3 | Section: opie/applications |
4 | Maintainer: Maximilian Reiß <max.reiss@gmx.de> | 4 | Maintainer: Maximilian Reiß <max.reiss@gmx.de> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: 0.3.3-$SUB_VERSION | 6 | Version: 0.3.4-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION), libopie ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION), libopie ($QPE_VERSION) |
8 | License: GPL | 8 | License: GPL |
9 | Description: today screen | 9 | Description: today screen |
10 | This today screen app gives an overview of appointments | 10 | This today screen app gives an overview of appointments |
11 | and todos. | 11 | and todos. |
12 | It also shows incoming and outgoing mails from opiemail. | 12 | It also shows incoming and outgoing mails from opiemail. |
13 | When using Opie (opie.handhelds.org) today can be autostarted | 13 | When using Opie (opie.handhelds.org) today can be autostarted |
14 | on resume. | 14 | on resume. |
15 | It is highly configurable. | 15 | It is highly configurable. |
16 | 16 | ||
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 0f4cbdb..4368201 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,587 +1,587 @@ | |||
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(); | ||
86 | draw(); | 85 | draw(); |
86 | getTodo(); | ||
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() || NEW_START==1) { |
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> openTodo = todo->rawToDos(); |
393 | qBubbleSort(open); | 393 | qBubbleSort(openTodo); |
394 | for ( QValueList<ToDoEvent>::Iterator it=open.begin(); | 394 | for ( QValueList<ToDoEvent>::Iterator it=openTodo.begin(); |
395 | it!=open.end(); ++it ) { | 395 | it!=openTodo.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, | 471 | QWidget* parent, |
472 | int SHOW_LOCATION, | 472 | int SHOW_LOCATION, |
473 | int SHOW_NOTES, | 473 | int SHOW_NOTES, |
474 | const char* name, | 474 | const char* name, |
475 | WFlags fl) : | 475 | WFlags fl) : |
476 | OClickableLabel(parent,name,fl), event(ev) { | 476 | OClickableLabel(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 | config.setGroup( "Time" ); |
483 | // if 24 h format | 483 | // if 24 h format |
484 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 484 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
485 | 485 | ||
486 | 486 | ||
487 | if (!ONLY_LATER) { | 487 | if (!ONLY_LATER) { |
488 | msg += "<B>" + (ev).description() + "</B>"; | 488 | msg += "<B>" + (ev).description() + "</B>"; |
489 | if ( (ev).event().hasAlarm() ) { | 489 | if ( (ev).event().hasAlarm() ) { |
490 | msg += " <b>[with alarm]</b>"; | 490 | msg += " <b>[with alarm]</b>"; |
491 | } | 491 | } |
492 | // include location or not | 492 | // include location or not |
493 | if (SHOW_LOCATION == 1) { | 493 | if (SHOW_LOCATION == 1) { |
494 | msg += "<BR><i>" + (ev).location() + "</i>"; | 494 | msg += "<BR><i>" + (ev).location() + "</i>"; |
495 | } | 495 | } |
496 | 496 | ||
497 | 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") ) { |
498 | msg += "<br>All day"; | 498 | msg += "<br>All day"; |
499 | } else { | 499 | } else { |
500 | // start time of event | 500 | // start time of event |
501 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) | 501 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) |
502 | // end time of event | 502 | // end time of event |
503 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); | 503 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); |
504 | } | 504 | } |
505 | 505 | ||
506 | // include possible note or not | 506 | // include possible note or not |
507 | if (SHOW_NOTES == 1) { | 507 | if (SHOW_NOTES == 1) { |
508 | 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); |
509 | } | 509 | } |
510 | } | 510 | } |
511 | setText(msg); | 511 | setText(msg); |
512 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 512 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
513 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 513 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
514 | } | 514 | } |
515 | 515 | ||
516 | 516 | ||
517 | QString DateBookEvent::ampmTime(QTime tm) { | 517 | QString DateBookEvent::ampmTime(QTime tm) { |
518 | 518 | ||
519 | QString s; | 519 | QString s; |
520 | if( ampm ) { | 520 | if( ampm ) { |
521 | int hour = tm.hour(); | 521 | int hour = tm.hour(); |
522 | if (hour == 0) | 522 | if (hour == 0) |
523 | hour = 12; | 523 | hour = 12; |
524 | if (hour > 12) | 524 | if (hour > 12) |
525 | hour -= 12; | 525 | hour -= 12; |
526 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 526 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
527 | (tm.hour() >= 12) ? "PM" : "AM" ); | 527 | (tm.hour() >= 12) ? "PM" : "AM" ); |
528 | return s; | 528 | return s; |
529 | } else { | 529 | } else { |
530 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 530 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
531 | return s; | 531 | return s; |
532 | } | 532 | } |
533 | 533 | ||
534 | } | 534 | } |
535 | 535 | ||
536 | 536 | ||
537 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, | 537 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, |
538 | QWidget* parent, | 538 | QWidget* parent, |
539 | int SHOW_LOCATION, | 539 | int SHOW_LOCATION, |
540 | int SHOW_NOTES, | 540 | int SHOW_NOTES, |
541 | const char* name, | 541 | const char* name, |
542 | WFlags fl) : | 542 | WFlags fl) : |
543 | OClickableLabel(parent,name,fl), event(ev) { | 543 | OClickableLabel(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 | Config config( "qpe" ); | 548 | Config config( "qpe" ); |
549 | config.setGroup( "Time" ); | 549 | config.setGroup( "Time" ); |
550 | // if 24 h format | 550 | // if 24 h format |
551 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 551 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
552 | 552 | ||
553 | 553 | ||
554 | if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { | 554 | if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { |
555 | // show only later appointments | 555 | // show only later appointments |
556 | msg += "<B>" + (ev).description() + "</B>"; | 556 | msg += "<B>" + (ev).description() + "</B>"; |
557 | if ( (ev).event().hasAlarm() ) { | 557 | if ( (ev).event().hasAlarm() ) { |
558 | msg += " <b>[with alarm]</b>"; | 558 | msg += " <b>[with alarm]</b>"; |
559 | } | 559 | } |
560 | // include location or not | 560 | // include location or not |
561 | if (SHOW_LOCATION == 1) { | 561 | if (SHOW_LOCATION == 1) { |
562 | msg += "<BR><i>" + (ev).location() + "</i>"; | 562 | msg += "<BR><i>" + (ev).location() + "</i>"; |
563 | } | 563 | } |
564 | 564 | ||
565 | 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") ) { |
566 | msg += "<br>All day"; | 566 | msg += "<br>All day"; |
567 | } else { | 567 | } else { |
568 | // start time of event | 568 | // start time of event |
569 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) | 569 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) |
570 | // end time of event | 570 | // end time of event |
571 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); | 571 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); |
572 | } | 572 | } |
573 | // include possible note or not | 573 | // include possible note or not |
574 | if (SHOW_NOTES == 1) { | 574 | if (SHOW_NOTES == 1) { |
575 | 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); |
576 | } | 576 | } |
577 | } | 577 | } |
578 | 578 | ||
579 | setText(msg); | 579 | setText(msg); |
580 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 580 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
581 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 581 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
582 | } | 582 | } |
583 | 583 | ||
584 | 584 | ||
585 | QString DateBookEventLater::ampmTime(QTime tm) { | 585 | QString DateBookEventLater::ampmTime(QTime tm) { |
586 | 586 | ||
587 | QString s; | 587 | QString s; |