author | zautrix <zautrix> | 2005-06-15 09:06:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-15 09:06:25 (UTC) |
commit | 820a1285559d0bb5859f634ebc6865f3a85a93ab (patch) (unidiff) | |
tree | 35278bfc95f131b4577d2f1d09c5915b5336e01a | |
parent | c50dea673d7bf65614e042a0e3c0c53c73c705a0 (diff) | |
download | kdepimpi-820a1285559d0bb5859f634ebc6865f3a85a93ab.zip kdepimpi-820a1285559d0bb5859f634ebc6865f3a85a93ab.tar.gz kdepimpi-820a1285559d0bb5859f634ebc6865f3a85a93ab.tar.bz2 |
color fixes
-rw-r--r-- | korganizer/calendarview.cpp | 1 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 7 |
2 files changed, 6 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index dd4ea41..1338224 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,980 +1,981 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
142 | 142 | ||
143 | { | 143 | { |
144 | mAlarms = alarms; | 144 | mAlarms = alarms; |
145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
146 | QString mText = "<table width=\"100%\">\n"; | 146 | QString mText = "<table width=\"100%\">\n"; |
147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
148 | #ifdef DESKTOP_VERSION | 148 | #ifdef DESKTOP_VERSION |
149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
150 | #else | 150 | #else |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
152 | #endif | 152 | #endif |
153 | // mText += "<img src=\""; | 153 | // mText += "<img src=\""; |
154 | // mText += ipath; | 154 | // mText += ipath; |
155 | // mText += "\">"; | 155 | // mText += "\">"; |
156 | //mEventDate = QDate::currentDate(); | 156 | //mEventDate = QDate::currentDate(); |
157 | #ifdef DESKTOP_VERSION | 157 | #ifdef DESKTOP_VERSION |
158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
159 | #else | 159 | #else |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
161 | #endif | 161 | #endif |
162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
163 | 163 | ||
164 | Incidence * inc = getNextInc( start ); | 164 | Incidence * inc = getNextInc( start ); |
165 | int time = 0; | 165 | int time = 0; |
166 | //mText += "<table>"; | 166 | //mText += "<table>"; |
167 | while ( inc ) { | 167 | while ( inc ) { |
168 | QDateTime dt ; | 168 | QDateTime dt ; |
169 | QString tempText = "<a "; | 169 | QString tempText = "<a "; |
170 | bool ok; | 170 | bool ok; |
171 | dt = inc->getNextOccurence( start, &ok ); | 171 | dt = inc->getNextOccurence( start, &ok ); |
172 | if ( !ok ) continue; | 172 | if ( !ok ) continue; |
173 | if ( inc->typeID() == eventID ) { | 173 | if ( inc->typeID() == eventID ) { |
174 | tempText += "href=\"event:"; | 174 | tempText += "href=\"event:"; |
175 | } else if ( inc->typeID() == todoID ) { | 175 | } else if ( inc->typeID() == todoID ) { |
176 | tempText += "href=\"todo:"; | 176 | tempText += "href=\"todo:"; |
177 | } | 177 | } |
178 | tempText += inc->uid() + "\">"; | 178 | tempText += inc->uid() + "\">"; |
179 | if ( inc->typeID() == todoID ) | 179 | if ( inc->typeID() == todoID ) |
180 | tempText += i18n("Todo: "); | 180 | tempText += i18n("Todo: "); |
181 | if ( inc->summary().length() > 0 ) | 181 | if ( inc->summary().length() > 0 ) |
182 | tempText += inc->summary(); | 182 | tempText += inc->summary(); |
183 | else | 183 | else |
184 | tempText += i18n("-no summary-"); | 184 | tempText += i18n("-no summary-"); |
185 | QString timestr; | 185 | QString timestr; |
186 | if (!inc->doesFloat()) | 186 | if (!inc->doesFloat()) |
187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
188 | else | 188 | else |
189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
192 | mText += "<table>"; | 192 | mText += "<table>"; |
193 | time = 1; | 193 | time = 1; |
194 | } | 194 | } |
195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
196 | if ( time > 0 ) | 196 | if ( time > 0 ) |
197 | mText +="</table>"; | 197 | mText +="</table>"; |
198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
199 | mText += "<table>"; | 199 | mText += "<table>"; |
200 | time = 2; | 200 | time = 2; |
201 | 201 | ||
202 | } | 202 | } |
203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
204 | if ( time > 0 ) | 204 | if ( time > 0 ) |
205 | mText +="</table>"; | 205 | mText +="</table>"; |
206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
207 | mText += "<table>"; | 207 | mText += "<table>"; |
208 | time = 3; | 208 | time = 3; |
209 | } | 209 | } |
210 | mText +="<tr><td><b>"; | 210 | mText +="<tr><td><b>"; |
211 | mText += timestr; | 211 | mText += timestr; |
212 | mText += "</b></td><td>"; | 212 | mText += "</b></td><td>"; |
213 | mText += tempText; | 213 | mText += tempText; |
214 | mText += "</td></tr>\n"; | 214 | mText += "</td></tr>\n"; |
215 | inc = getNextInc( start ); | 215 | inc = getNextInc( start ); |
216 | } | 216 | } |
217 | mText +="</table>"; | 217 | mText +="</table>"; |
218 | setText( mText ); | 218 | setText( mText ); |
219 | } | 219 | } |
220 | 220 | ||
221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
222 | { | 222 | { |
223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
224 | } | 224 | } |
225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
226 | { | 226 | { |
227 | QDateTime dt ; | 227 | QDateTime dt ; |
228 | Incidence * retInc; | 228 | Incidence * retInc; |
229 | Incidence * inc = mAlarms.first(); | 229 | Incidence * inc = mAlarms.first(); |
230 | if ( inc == 0 ) | 230 | if ( inc == 0 ) |
231 | return 0; | 231 | return 0; |
232 | bool ok; | 232 | bool ok; |
233 | dt = inc->getNextOccurence( start, &ok ); | 233 | dt = inc->getNextOccurence( start, &ok ); |
234 | if ( ! ok ) return 0; | 234 | if ( ! ok ) return 0; |
235 | QDateTime dtn ; | 235 | QDateTime dtn ; |
236 | retInc = inc; | 236 | retInc = inc; |
237 | inc = mAlarms.next(); | 237 | inc = mAlarms.next(); |
238 | while ( inc ) { | 238 | while ( inc ) { |
239 | dtn = inc->getNextOccurence( start, &ok ); | 239 | dtn = inc->getNextOccurence( start, &ok ); |
240 | if ( ! ok ) return 0; | 240 | if ( ! ok ) return 0; |
241 | if ( dtn < dt ) { | 241 | if ( dtn < dt ) { |
242 | dt = dtn; | 242 | dt = dtn; |
243 | retInc = inc; | 243 | retInc = inc; |
244 | } | 244 | } |
245 | inc = mAlarms.next(); | 245 | inc = mAlarms.next(); |
246 | } | 246 | } |
247 | mAlarms.remove( retInc ); | 247 | mAlarms.remove( retInc ); |
248 | return retInc; | 248 | return retInc; |
249 | 249 | ||
250 | } | 250 | } |
251 | void MissedAlarmTextBrowser::setSource(const QString & n) | 251 | void MissedAlarmTextBrowser::setSource(const QString & n) |
252 | { | 252 | { |
253 | if (n.startsWith("event:")) { | 253 | if (n.startsWith("event:")) { |
254 | #ifdef DESKTOP_VERSION | 254 | #ifdef DESKTOP_VERSION |
255 | emit showIncidence(n.mid(8)); | 255 | emit showIncidence(n.mid(8)); |
256 | #else | 256 | #else |
257 | emit showIncidence(n.mid(6)); | 257 | emit showIncidence(n.mid(6)); |
258 | #endif | 258 | #endif |
259 | return; | 259 | return; |
260 | } else if (n.startsWith("todo:")) { | 260 | } else if (n.startsWith("todo:")) { |
261 | #ifdef DESKTOP_VERSION | 261 | #ifdef DESKTOP_VERSION |
262 | emit showIncidence(n.mid(7)); | 262 | emit showIncidence(n.mid(7)); |
263 | #else | 263 | #else |
264 | emit showIncidence(n.mid(5)); | 264 | emit showIncidence(n.mid(5)); |
265 | #endif | 265 | #endif |
266 | return; | 266 | return; |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | class KOBeamPrefs : public QDialog | 271 | class KOBeamPrefs : public QDialog |
272 | { | 272 | { |
273 | public: | 273 | public: |
274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
275 | QDialog( parent, name, true ) | 275 | QDialog( parent, name, true ) |
276 | { | 276 | { |
277 | setCaption( i18n("Beam Options") ); | 277 | setCaption( i18n("Beam Options") ); |
278 | QVBoxLayout* lay = new QVBoxLayout( this ); | 278 | QVBoxLayout* lay = new QVBoxLayout( this ); |
279 | lay->setSpacing( 3 ); | 279 | lay->setSpacing( 3 ); |
280 | lay->setMargin( 3 ); | 280 | lay->setMargin( 3 ); |
281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
282 | lay->addWidget( format ); | 282 | lay->addWidget( format ); |
283 | format->setExclusive ( true ) ; | 283 | format->setExclusive ( true ) ; |
284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
285 | lay->addWidget( time ); time->setExclusive ( true ) ; | 285 | lay->addWidget( time ); time->setExclusive ( true ) ; |
286 | vcal = new QRadioButton(" vCalendar ", format ); | 286 | vcal = new QRadioButton(" vCalendar ", format ); |
287 | ical = new QRadioButton(" iCalendar ", format ); | 287 | ical = new QRadioButton(" iCalendar ", format ); |
288 | vcal->setChecked( true ); | 288 | vcal->setChecked( true ); |
289 | tz = new QRadioButton(i18n(" With timezone "), time ); | 289 | tz = new QRadioButton(i18n(" With timezone "), time ); |
290 | local = new QRadioButton(i18n(" Local time "), time ); | 290 | local = new QRadioButton(i18n(" Local time "), time ); |
291 | tz->setChecked( true ); | 291 | tz->setChecked( true ); |
292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
293 | lay->addWidget( ok ); | 293 | lay->addWidget( ok ); |
294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
295 | lay->addWidget( cancel ); | 295 | lay->addWidget( cancel ); |
296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
298 | resize( 200, 200 ); | 298 | resize( 200, 200 ); |
299 | } | 299 | } |
300 | 300 | ||
301 | bool beamVcal() { return vcal->isChecked(); } | 301 | bool beamVcal() { return vcal->isChecked(); } |
302 | bool beamLocal() { return local->isChecked(); } | 302 | bool beamLocal() { return local->isChecked(); } |
303 | private: | 303 | private: |
304 | QRadioButton* vcal, *ical, *local, *tz; | 304 | QRadioButton* vcal, *ical, *local, *tz; |
305 | }; | 305 | }; |
306 | class KOCatPrefs : public QDialog | 306 | class KOCatPrefs : public QDialog |
307 | { | 307 | { |
308 | public: | 308 | public: |
309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
310 | QDialog( parent, name, true ) | 310 | QDialog( parent, name, true ) |
311 | { | 311 | { |
312 | setCaption( i18n("Manage new Categories") ); | 312 | setCaption( i18n("Manage new Categories") ); |
313 | QVBoxLayout* lay = new QVBoxLayout( this ); | 313 | QVBoxLayout* lay = new QVBoxLayout( this ); |
314 | lay->setSpacing( 3 ); | 314 | lay->setSpacing( 3 ); |
315 | lay->setMargin( 3 ); | 315 | lay->setMargin( 3 ); |
316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
317 | lay->addWidget( lab ); | 317 | lay->addWidget( lab ); |
318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
319 | lay->addWidget( format ); | 319 | lay->addWidget( format ); |
320 | format->setExclusive ( true ) ; | 320 | format->setExclusive ( true ) ; |
321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
323 | addCatBut->setChecked( true ); | 323 | addCatBut->setChecked( true ); |
324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
325 | lay->addWidget( ok ); | 325 | lay->addWidget( ok ); |
326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
327 | lay->addWidget( cancel ); | 327 | lay->addWidget( cancel ); |
328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
330 | resize( 200, 200 ); | 330 | resize( 200, 200 ); |
331 | } | 331 | } |
332 | 332 | ||
333 | bool addCat() { return addCatBut->isChecked(); } | 333 | bool addCat() { return addCatBut->isChecked(); } |
334 | private: | 334 | private: |
335 | QRadioButton* addCatBut; | 335 | QRadioButton* addCatBut; |
336 | }; | 336 | }; |
337 | 337 | ||
338 | 338 | ||
339 | 339 | ||
340 | CalendarView::CalendarView( CalendarResources *calendar, | 340 | CalendarView::CalendarView( CalendarResources *calendar, |
341 | QWidget *parent, const char *name ) | 341 | QWidget *parent, const char *name ) |
342 | : CalendarViewBase( parent, name ), | 342 | : CalendarViewBase( parent, name ), |
343 | mCalendar( calendar ), | 343 | mCalendar( calendar ), |
344 | mResourceManager( calendar->resourceManager() ) | 344 | mResourceManager( calendar->resourceManager() ) |
345 | { | 345 | { |
346 | 346 | ||
347 | mEventEditor = 0; | 347 | mEventEditor = 0; |
348 | mTodoEditor = 0; | 348 | mTodoEditor = 0; |
349 | 349 | ||
350 | init(); | 350 | init(); |
351 | } | 351 | } |
352 | 352 | ||
353 | CalendarView::CalendarView( Calendar *calendar, | 353 | CalendarView::CalendarView( Calendar *calendar, |
354 | QWidget *parent, const char *name ) | 354 | QWidget *parent, const char *name ) |
355 | : CalendarViewBase( parent, name ), | 355 | : CalendarViewBase( parent, name ), |
356 | mCalendar( calendar ), | 356 | mCalendar( calendar ), |
357 | mResourceManager( 0 ) | 357 | mResourceManager( 0 ) |
358 | { | 358 | { |
359 | 359 | ||
360 | mEventEditor = 0; | 360 | mEventEditor = 0; |
361 | mTodoEditor = 0; | 361 | mTodoEditor = 0; |
362 | init(); | 362 | init(); |
363 | } | 363 | } |
364 | 364 | ||
365 | void CalendarView::init() | 365 | void CalendarView::init() |
366 | { | 366 | { |
367 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 367 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
368 | setFocusPolicy ( NoFocus ); | 368 | setFocusPolicy ( NoFocus ); |
369 | mViewerCallerIsSearchDialog = false; | 369 | mViewerCallerIsSearchDialog = false; |
370 | mBlockShowDates = false; | 370 | mBlockShowDates = false; |
371 | beamDialog = new KOBeamPrefs(); | 371 | beamDialog = new KOBeamPrefs(); |
372 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
373 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
374 | writeLocale(); | 374 | writeLocale(); |
375 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
378 | mModified = false; | 378 | mModified = false; |
379 | mReadOnly = false; | 379 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
383 | 383 | ||
384 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 386 | ||
387 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 389 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 392 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
395 | 395 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 399 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
402 | 402 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 407 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 409 | mResourceView = 0; |
410 | #else | 410 | #else |
411 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
416 | } else { | 416 | } else { |
417 | mResourceView = 0; | 417 | mResourceView = 0; |
418 | } | 418 | } |
419 | #endif | 419 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 422 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 425 | ||
426 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
427 | #else | 427 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 438 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 445 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
449 | //mainBoxLayout->addWidget (mLeftFrame); | 449 | //mainBoxLayout->addWidget (mLeftFrame); |
450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
451 | "CalendarView::DateNavigator" ); | 451 | "CalendarView::DateNavigator" ); |
452 | #if 0 | 452 | #if 0 |
453 | // FIXME | 453 | // FIXME |
454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
455 | "CalendarView::DateNavigator", QDate::currentDate()); | 455 | "CalendarView::DateNavigator", QDate::currentDate()); |
456 | #endif | 456 | #endif |
457 | // mDateNavigator->blockSignals( true ); | 457 | // mDateNavigator->blockSignals( true ); |
458 | //leftFrameLayout->addWidget( mDateNavigator ); | 458 | //leftFrameLayout->addWidget( mDateNavigator ); |
459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
462 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 462 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
463 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 463 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
464 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); | 464 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); |
465 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 465 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
466 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 466 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
467 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 467 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
468 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 468 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
469 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | ||
469 | mTodoList->setNavigator( mNavigator ); | 470 | mTodoList->setNavigator( mNavigator ); |
470 | #if 0 | 471 | #if 0 |
471 | if ( QApplication::desktop()->width() < 480 ) { | 472 | if ( QApplication::desktop()->width() < 480 ) { |
472 | leftFrameLayout->addWidget(mFilterView); | 473 | leftFrameLayout->addWidget(mFilterView); |
473 | leftFrameLayout->addWidget(mTodoList, 2 ); | 474 | leftFrameLayout->addWidget(mTodoList, 2 ); |
474 | 475 | ||
475 | } else { | 476 | } else { |
476 | leftFrameLayout->addWidget(mTodoList,2 ); | 477 | leftFrameLayout->addWidget(mTodoList,2 ); |
477 | leftFrameLayout->addWidget(mFilterView ); | 478 | leftFrameLayout->addWidget(mFilterView ); |
478 | } | 479 | } |
479 | #endif | 480 | #endif |
480 | mFilterView->hide(); | 481 | mFilterView->hide(); |
481 | mCalEditView->hide(); | 482 | mCalEditView->hide(); |
482 | QWidget *rightBox = new QWidget( mMainFrame ); | 483 | QWidget *rightBox = new QWidget( mMainFrame ); |
483 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 484 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
484 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 485 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
485 | mRightFrame = new QWidgetStack( rightBox ); | 486 | mRightFrame = new QWidgetStack( rightBox ); |
486 | rightLayout->addWidget( mRightFrame, 10 ); | 487 | rightLayout->addWidget( mRightFrame, 10 ); |
487 | 488 | ||
488 | //mLeftFrame = (QWidget *)leftFrame; | 489 | //mLeftFrame = (QWidget *)leftFrame; |
489 | if ( KOPrefs::instance()->mVerticalScreen ) { | 490 | if ( KOPrefs::instance()->mVerticalScreen ) { |
490 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 491 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
491 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 492 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
492 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 493 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
493 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 494 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
494 | } else { | 495 | } else { |
495 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 496 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
496 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 497 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
497 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 498 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
498 | } | 499 | } |
499 | if ( !KOPrefs::instance()->mShowDateNavigator) | 500 | if ( !KOPrefs::instance()->mShowDateNavigator) |
500 | mDateNavigator->hide(); | 501 | mDateNavigator->hide(); |
501 | //qDebug("Calendarview Size %d %d ", width(), height()); | 502 | //qDebug("Calendarview Size %d %d ", width(), height()); |
502 | #endif | 503 | #endif |
503 | 504 | ||
504 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 505 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
505 | SLOT( showDates( const KCal::DateList & ) ) ); | 506 | SLOT( showDates( const KCal::DateList & ) ) ); |
506 | 507 | ||
507 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 508 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
508 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 509 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
509 | 510 | ||
510 | 511 | ||
511 | 512 | ||
512 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 513 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
513 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 514 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
514 | 515 | ||
515 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 516 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
516 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 517 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
517 | 518 | ||
518 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 519 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
519 | mNavigator, SLOT( selectPreviousYear() ) ); | 520 | mNavigator, SLOT( selectPreviousYear() ) ); |
520 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 521 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
521 | mNavigator, SLOT( selectNextYear() ) ); | 522 | mNavigator, SLOT( selectNextYear() ) ); |
522 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 523 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
523 | mNavigator, SLOT( selectPreviousMonth() ) ); | 524 | mNavigator, SLOT( selectPreviousMonth() ) ); |
524 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 525 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
525 | mNavigator, SLOT( selectNextMonth() ) ); | 526 | mNavigator, SLOT( selectNextMonth() ) ); |
526 | 527 | ||
527 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 528 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
528 | mNavigator, SLOT( selectPrevious() ) ); | 529 | mNavigator, SLOT( selectPrevious() ) ); |
529 | connect( mDateNavigator, SIGNAL( goNext() ), | 530 | connect( mDateNavigator, SIGNAL( goNext() ), |
530 | mNavigator, SLOT( selectNext() ) ); | 531 | mNavigator, SLOT( selectNext() ) ); |
531 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 532 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
532 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 533 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
533 | 534 | ||
534 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 535 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
535 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 536 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
536 | #if 0 | 537 | #if 0 |
537 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 538 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
538 | SLOT( incidenceAdded( Incidence *) ) ); | 539 | SLOT( incidenceAdded( Incidence *) ) ); |
539 | #endif | 540 | #endif |
540 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 541 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
541 | 542 | ||
542 | connect( this, SIGNAL( configChanged() ), | 543 | connect( this, SIGNAL( configChanged() ), |
543 | mDateNavigator, SLOT( updateConfig() ) ); | 544 | mDateNavigator, SLOT( updateConfig() ) ); |
544 | 545 | ||
545 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 546 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
546 | SLOT( newTodo() ) ); | 547 | SLOT( newTodo() ) ); |
547 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 548 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
548 | SLOT( newSubTodo( Todo * ) ) ); | 549 | SLOT( newSubTodo( Todo * ) ) ); |
549 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 550 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
550 | SLOT( editTodo( Todo * ) ) ); | 551 | SLOT( editTodo( Todo * ) ) ); |
551 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 552 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
552 | SLOT( showTodo( Todo *) ) ); | 553 | SLOT( showTodo( Todo *) ) ); |
553 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 554 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
554 | SLOT( deleteTodo( Todo *) ) ); | 555 | SLOT( deleteTodo( Todo *) ) ); |
555 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 556 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
556 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 557 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
557 | SLOT( purgeCompleted() ) ); | 558 | SLOT( purgeCompleted() ) ); |
558 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 559 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
559 | SIGNAL( todoModified( Todo *, int ) ) ); | 560 | SIGNAL( todoModified( Todo *, int ) ) ); |
560 | 561 | ||
561 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 562 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
562 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 563 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
563 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 564 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
564 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 565 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
565 | 566 | ||
566 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 567 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
567 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 568 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
568 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 569 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
569 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 570 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
570 | 571 | ||
571 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 572 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
572 | this, SLOT ( todo_unsub( Todo * ) ) ); | 573 | this, SLOT ( todo_unsub( Todo * ) ) ); |
573 | 574 | ||
574 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 575 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
575 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 576 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
576 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 577 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
577 | SLOT( updateTodo( Todo *, int ) ) ); | 578 | SLOT( updateTodo( Todo *, int ) ) ); |
578 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 579 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
579 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 580 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
580 | 581 | ||
581 | 582 | ||
582 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 583 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
583 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 584 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
584 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 585 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
585 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 586 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
586 | 587 | ||
587 | 588 | ||
588 | 589 | ||
589 | 590 | ||
590 | 591 | ||
591 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 592 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
592 | SLOT(checkClipboard())); | 593 | SLOT(checkClipboard())); |
593 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 594 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
594 | SLOT( processTodoListSelection( Incidence * ) ) ); | 595 | SLOT( processTodoListSelection( Incidence * ) ) ); |
595 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 596 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
596 | 597 | ||
597 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 598 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
598 | 599 | ||
599 | mDateFrame = new QVBox(0,0,WType_Popup); | 600 | mDateFrame = new QVBox(0,0,WType_Popup); |
600 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 601 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
601 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 602 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
602 | mDateFrame->setLineWidth(3); | 603 | mDateFrame->setLineWidth(3); |
603 | mDateFrame->hide(); | 604 | mDateFrame->hide(); |
604 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 605 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
605 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 606 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
606 | 607 | ||
607 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 608 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
608 | 609 | ||
609 | mEventEditor = mDialogManager->getEventEditor(); | 610 | mEventEditor = mDialogManager->getEventEditor(); |
610 | mTodoEditor = mDialogManager->getTodoEditor(); | 611 | mTodoEditor = mDialogManager->getTodoEditor(); |
611 | 612 | ||
612 | mFlagEditDescription = false; | 613 | mFlagEditDescription = false; |
613 | 614 | ||
614 | mSuspendTimer = new QTimer( this ); | 615 | mSuspendTimer = new QTimer( this ); |
615 | mAlarmTimer = new QTimer( this ); | 616 | mAlarmTimer = new QTimer( this ); |
616 | mRecheckAlarmTimer = new QTimer( this ); | 617 | mRecheckAlarmTimer = new QTimer( this ); |
617 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 618 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
618 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 619 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
619 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 620 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
620 | mAlarmDialog = new AlarmDialog( this ); | 621 | mAlarmDialog = new AlarmDialog( this ); |
621 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 622 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
622 | mAlarmDialog->setServerNotification( false ); | 623 | mAlarmDialog->setServerNotification( false ); |
623 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 624 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
624 | 625 | ||
625 | 626 | ||
626 | #ifndef DESKTOP_VERSION | 627 | #ifndef DESKTOP_VERSION |
627 | //US listen for arriving address resultsets | 628 | //US listen for arriving address resultsets |
628 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 629 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
629 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 630 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
630 | #endif | 631 | #endif |
631 | mDateNavigator->setCalendar( mCalendar ); | 632 | mDateNavigator->setCalendar( mCalendar ); |
632 | } | 633 | } |
633 | 634 | ||
634 | 635 | ||
635 | CalendarView::~CalendarView() | 636 | CalendarView::~CalendarView() |
636 | { | 637 | { |
637 | // kdDebug() << "~CalendarView()" << endl; | 638 | // kdDebug() << "~CalendarView()" << endl; |
638 | //qDebug("CalendarView::~CalendarView() "); | 639 | //qDebug("CalendarView::~CalendarView() "); |
639 | delete mDialogManager; | 640 | delete mDialogManager; |
640 | delete mViewManager; | 641 | delete mViewManager; |
641 | delete mStorage; | 642 | delete mStorage; |
642 | delete mDateFrame ; | 643 | delete mDateFrame ; |
643 | delete beamDialog; | 644 | delete beamDialog; |
644 | delete mEventViewerDialog; | 645 | delete mEventViewerDialog; |
645 | //kdDebug() << "~CalendarView() done" << endl; | 646 | //kdDebug() << "~CalendarView() done" << endl; |
646 | } | 647 | } |
647 | void CalendarView::checkAlarms() | 648 | void CalendarView::checkAlarms() |
648 | { | 649 | { |
649 | KConfig *config = KOGlobals::config(); | 650 | KConfig *config = KOGlobals::config(); |
650 | config->setGroup( "AppRun" ); | 651 | config->setGroup( "AppRun" ); |
651 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 652 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
652 | int daysto = dt.daysTo( QDate::currentDate() ); | 653 | int daysto = dt.daysTo( QDate::currentDate() ); |
653 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 654 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
654 | dt = dt.addDays( days ); | 655 | dt = dt.addDays( days ); |
655 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 656 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
656 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 657 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
657 | //qDebug("KO: Reading program stop %d ", secs); | 658 | //qDebug("KO: Reading program stop %d ", secs); |
658 | //secs -= ( 3600 * 24*3 ); // debug only | 659 | //secs -= ( 3600 * 24*3 ); // debug only |
659 | QDateTime latest = dt.addSecs ( secs ); | 660 | QDateTime latest = dt.addSecs ( secs ); |
660 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 661 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
661 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 662 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
662 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 663 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
663 | QPtrList<Incidence> al; | 664 | QPtrList<Incidence> al; |
664 | Incidence* inL = el.first(); | 665 | Incidence* inL = el.first(); |
665 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 666 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
666 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 667 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
667 | while ( inL ) { | 668 | while ( inL ) { |
668 | bool ok = false; | 669 | bool ok = false; |
669 | int offset = 0; | 670 | int offset = 0; |
670 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 671 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
671 | if ( ok ) { | 672 | if ( ok ) { |
672 | //qDebug("OK %s",next.toString().latin1()); | 673 | //qDebug("OK %s",next.toString().latin1()); |
673 | if ( next < cur ) { | 674 | if ( next < cur ) { |
674 | al.append( inL ); | 675 | al.append( inL ); |
675 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 676 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
676 | } | 677 | } |
677 | } | 678 | } |
678 | inL = el.next(); | 679 | inL = el.next(); |
679 | } | 680 | } |
680 | if ( al.count() ) { | 681 | if ( al.count() ) { |
681 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 682 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
682 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 683 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
683 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 684 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
684 | lay->setSpacing( 0 ); | 685 | lay->setSpacing( 0 ); |
685 | lay->setMargin( 0 ); | 686 | lay->setMargin( 0 ); |
686 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 687 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
687 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 688 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
688 | lay->addWidget( matb ); | 689 | lay->addWidget( matb ); |
689 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 690 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
690 | int wid = 210; | 691 | int wid = 210; |
691 | int x = QApplication::desktop()->width() - wid - 7; | 692 | int x = QApplication::desktop()->width() - wid - 7; |
692 | int y = QApplication::desktop()->height() - wid - 70; | 693 | int y = QApplication::desktop()->height() - wid - 70; |
693 | dia->setGeometry ( x,y,wid,wid); | 694 | dia->setGeometry ( x,y,wid,wid); |
694 | } else { | 695 | } else { |
695 | int si = 220; | 696 | int si = 220; |
696 | if ( QApplication::desktop()->width() > 470 ) | 697 | if ( QApplication::desktop()->width() > 470 ) |
697 | si = 400; | 698 | si = 400; |
698 | dia->resize(si,si/2); | 699 | dia->resize(si,si/2); |
699 | } | 700 | } |
700 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 701 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
701 | dia->show(); | 702 | dia->show(); |
702 | 703 | ||
703 | } | 704 | } |
704 | } | 705 | } |
705 | void CalendarView::showDay( QDate d ) | 706 | void CalendarView::showDay( QDate d ) |
706 | { | 707 | { |
707 | dateNavigator()->blockSignals( true ); | 708 | dateNavigator()->blockSignals( true ); |
708 | dateNavigator()->selectDate( d ); | 709 | dateNavigator()->selectDate( d ); |
709 | dateNavigator()->blockSignals( false ); | 710 | dateNavigator()->blockSignals( false ); |
710 | mViewManager->showDayView(); | 711 | mViewManager->showDayView(); |
711 | //dateNavigator()->selectDate( d ); | 712 | //dateNavigator()->selectDate( d ); |
712 | } | 713 | } |
713 | void CalendarView::timerAlarm() | 714 | void CalendarView::timerAlarm() |
714 | { | 715 | { |
715 | //qDebug("CalendarView::timerAlarm() "); | 716 | //qDebug("CalendarView::timerAlarm() "); |
716 | computeAlarm(mAlarmNotification ); | 717 | computeAlarm(mAlarmNotification ); |
717 | } | 718 | } |
718 | 719 | ||
719 | void CalendarView::suspendAlarm() | 720 | void CalendarView::suspendAlarm() |
720 | { | 721 | { |
721 | //qDebug(" CalendarView::suspendAlarm() "); | 722 | //qDebug(" CalendarView::suspendAlarm() "); |
722 | computeAlarm(mSuspendAlarmNotification ); | 723 | computeAlarm(mSuspendAlarmNotification ); |
723 | 724 | ||
724 | } | 725 | } |
725 | 726 | ||
726 | void CalendarView::startAlarm( QString mess , QString filename) | 727 | void CalendarView::startAlarm( QString mess , QString filename) |
727 | { | 728 | { |
728 | 729 | ||
729 | topLevelWidget()->showNormal(); | 730 | topLevelWidget()->showNormal(); |
730 | topLevelWidget()->setActiveWindow(); | 731 | topLevelWidget()->setActiveWindow(); |
731 | topLevelWidget()->raise(); | 732 | topLevelWidget()->raise(); |
732 | 733 | ||
733 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 734 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
734 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 735 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
735 | 736 | ||
736 | } | 737 | } |
737 | 738 | ||
738 | void CalendarView::checkNextTimerAlarm() | 739 | void CalendarView::checkNextTimerAlarm() |
739 | { | 740 | { |
740 | mCalendar->checkAlarmForIncidence( 0, true ); | 741 | mCalendar->checkAlarmForIncidence( 0, true ); |
741 | } | 742 | } |
742 | 743 | ||
743 | void CalendarView::computeAlarm( QString msg ) | 744 | void CalendarView::computeAlarm( QString msg ) |
744 | { | 745 | { |
745 | 746 | ||
746 | QString mess = msg; | 747 | QString mess = msg; |
747 | QString mAlarmMessage = mess.mid( 9 ); | 748 | QString mAlarmMessage = mess.mid( 9 ); |
748 | QString filename = MainWindow::resourcePath(); | 749 | QString filename = MainWindow::resourcePath(); |
749 | filename += "koalarm.wav"; | 750 | filename += "koalarm.wav"; |
750 | QString tempfilename; | 751 | QString tempfilename; |
751 | if ( mess.left( 13 ) == "suspend_alarm") { | 752 | if ( mess.left( 13 ) == "suspend_alarm") { |
752 | bool error = false; | 753 | bool error = false; |
753 | int len = mess.mid( 13 ).find("+++"); | 754 | int len = mess.mid( 13 ).find("+++"); |
754 | if ( len < 2 ) | 755 | if ( len < 2 ) |
755 | error = true; | 756 | error = true; |
756 | else { | 757 | else { |
757 | tempfilename = mess.mid( 13, len ); | 758 | tempfilename = mess.mid( 13, len ); |
758 | if ( !QFile::exists( tempfilename ) ) | 759 | if ( !QFile::exists( tempfilename ) ) |
759 | error = true; | 760 | error = true; |
760 | } | 761 | } |
761 | if ( ! error ) { | 762 | if ( ! error ) { |
762 | filename = tempfilename; | 763 | filename = tempfilename; |
763 | } | 764 | } |
764 | mAlarmMessage = mess.mid( 13+len+3 ); | 765 | mAlarmMessage = mess.mid( 13+len+3 ); |
765 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 766 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
766 | startAlarm( mAlarmMessage, filename); | 767 | startAlarm( mAlarmMessage, filename); |
767 | return; | 768 | return; |
768 | } | 769 | } |
769 | if ( mess.left( 11 ) == "timer_alarm") { | 770 | if ( mess.left( 11 ) == "timer_alarm") { |
770 | //mTimerTime = 0; | 771 | //mTimerTime = 0; |
771 | startAlarm( mess.mid( 11 ), filename ); | 772 | startAlarm( mess.mid( 11 ), filename ); |
772 | return; | 773 | return; |
773 | } | 774 | } |
774 | if ( mess.left( 10 ) == "proc_alarm") { | 775 | if ( mess.left( 10 ) == "proc_alarm") { |
775 | bool error = false; | 776 | bool error = false; |
776 | int len = mess.mid( 10 ).find("+++"); | 777 | int len = mess.mid( 10 ).find("+++"); |
777 | if ( len < 2 ) | 778 | if ( len < 2 ) |
778 | error = true; | 779 | error = true; |
779 | else { | 780 | else { |
780 | tempfilename = mess.mid( 10, len ); | 781 | tempfilename = mess.mid( 10, len ); |
781 | if ( !QFile::exists( tempfilename ) ) | 782 | if ( !QFile::exists( tempfilename ) ) |
782 | error = true; | 783 | error = true; |
783 | } | 784 | } |
784 | if ( error ) { | 785 | if ( error ) { |
785 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 786 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
786 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 787 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
787 | } else { | 788 | } else { |
788 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 789 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
789 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 790 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
790 | #ifndef _WIN32_ | 791 | #ifndef _WIN32_ |
791 | if ( vfork () == 0 ) { | 792 | if ( vfork () == 0 ) { |
792 | execl ( tempfilename.latin1(), 0 ); | 793 | execl ( tempfilename.latin1(), 0 ); |
793 | return; | 794 | return; |
794 | } | 795 | } |
795 | #else | 796 | #else |
796 | QProcess* p = new QProcess(); | 797 | QProcess* p = new QProcess(); |
797 | p->addArgument( tempfilename.latin1() ); | 798 | p->addArgument( tempfilename.latin1() ); |
798 | p->start(); | 799 | p->start(); |
799 | return; | 800 | return; |
800 | #endif | 801 | #endif |
801 | 802 | ||
802 | return; | 803 | return; |
803 | } | 804 | } |
804 | 805 | ||
805 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 806 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
806 | } | 807 | } |
807 | if ( mess.left( 11 ) == "audio_alarm") { | 808 | if ( mess.left( 11 ) == "audio_alarm") { |
808 | bool error = false; | 809 | bool error = false; |
809 | int len = mess.mid( 11 ).find("+++"); | 810 | int len = mess.mid( 11 ).find("+++"); |
810 | if ( len < 2 ) | 811 | if ( len < 2 ) |
811 | error = true; | 812 | error = true; |
812 | else { | 813 | else { |
813 | tempfilename = mess.mid( 11, len ); | 814 | tempfilename = mess.mid( 11, len ); |
814 | if ( !QFile::exists( tempfilename ) ) | 815 | if ( !QFile::exists( tempfilename ) ) |
815 | error = true; | 816 | error = true; |
816 | } | 817 | } |
817 | if ( ! error ) { | 818 | if ( ! error ) { |
818 | filename = tempfilename; | 819 | filename = tempfilename; |
819 | } | 820 | } |
820 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 821 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
821 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 822 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
822 | } | 823 | } |
823 | if ( mess.left( 9 ) == "cal_alarm") { | 824 | if ( mess.left( 9 ) == "cal_alarm") { |
824 | mAlarmMessage = mess.mid( 9 ) ; | 825 | mAlarmMessage = mess.mid( 9 ) ; |
825 | } | 826 | } |
826 | 827 | ||
827 | startAlarm( mAlarmMessage, filename ); | 828 | startAlarm( mAlarmMessage, filename ); |
828 | 829 | ||
829 | 830 | ||
830 | } | 831 | } |
831 | 832 | ||
832 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 833 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
833 | { | 834 | { |
834 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 835 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
835 | 836 | ||
836 | mSuspendAlarmNotification = noti; | 837 | mSuspendAlarmNotification = noti; |
837 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 838 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
838 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 839 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
839 | mSuspendTimer->start( ms , true ); | 840 | mSuspendTimer->start( ms , true ); |
840 | 841 | ||
841 | } | 842 | } |
842 | 843 | ||
843 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 844 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
844 | { | 845 | { |
845 | mNextAlarmDateTime = qdt; | 846 | mNextAlarmDateTime = qdt; |
846 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 847 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
847 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 848 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
848 | #ifndef DESKTOP_VERSION | 849 | #ifndef DESKTOP_VERSION |
849 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 850 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
850 | #endif | 851 | #endif |
851 | return; | 852 | return; |
852 | } | 853 | } |
853 | int maxSec; | 854 | int maxSec; |
854 | //maxSec = 5; //testing only | 855 | //maxSec = 5; //testing only |
855 | maxSec = 86400+3600; // one day+1hour | 856 | maxSec = 86400+3600; // one day+1hour |
856 | mAlarmNotification = noti; | 857 | mAlarmNotification = noti; |
857 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 858 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
858 | if ( sec > maxSec ) { | 859 | if ( sec > maxSec ) { |
859 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 860 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
860 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 861 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
861 | return; | 862 | return; |
862 | } else { | 863 | } else { |
863 | mRecheckAlarmTimer->stop(); | 864 | mRecheckAlarmTimer->stop(); |
864 | } | 865 | } |
865 | //qDebug("Alarm timer started with secs: %d ", sec); | 866 | //qDebug("Alarm timer started with secs: %d ", sec); |
866 | mAlarmTimer->start( sec *1000 , true ); | 867 | mAlarmTimer->start( sec *1000 , true ); |
867 | 868 | ||
868 | } | 869 | } |
869 | // called by mRecheckAlarmTimer to get next alarm | 870 | // called by mRecheckAlarmTimer to get next alarm |
870 | // we need this, because a QTimer has only a max range of 25 days | 871 | // we need this, because a QTimer has only a max range of 25 days |
871 | void CalendarView::recheckTimerAlarm() | 872 | void CalendarView::recheckTimerAlarm() |
872 | { | 873 | { |
873 | mAlarmTimer->stop(); | 874 | mAlarmTimer->stop(); |
874 | mRecheckAlarmTimer->stop(); | 875 | mRecheckAlarmTimer->stop(); |
875 | mCalendar->checkAlarmForIncidence( 0, true ); | 876 | mCalendar->checkAlarmForIncidence( 0, true ); |
876 | } | 877 | } |
877 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 878 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
878 | { | 879 | { |
879 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 880 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
880 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 881 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
881 | #ifndef DESKTOP_VERSION | 882 | #ifndef DESKTOP_VERSION |
882 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 883 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
883 | #endif | 884 | #endif |
884 | return; | 885 | return; |
885 | } | 886 | } |
886 | mAlarmTimer->stop(); | 887 | mAlarmTimer->stop(); |
887 | } | 888 | } |
888 | void CalendarView::selectWeekNum ( int num ) | 889 | void CalendarView::selectWeekNum ( int num ) |
889 | { | 890 | { |
890 | dateNavigator()->blockSignals( true ); | 891 | dateNavigator()->blockSignals( true ); |
891 | dateNavigator()->selectWeek( num ); | 892 | dateNavigator()->selectWeek( num ); |
892 | dateNavigator()->blockSignals( false ); | 893 | dateNavigator()->blockSignals( false ); |
893 | mViewManager->showWeekView(); | 894 | mViewManager->showWeekView(); |
894 | } | 895 | } |
895 | KOViewManager *CalendarView::viewManager() | 896 | KOViewManager *CalendarView::viewManager() |
896 | { | 897 | { |
897 | return mViewManager; | 898 | return mViewManager; |
898 | } | 899 | } |
899 | 900 | ||
900 | KODialogManager *CalendarView::dialogManager() | 901 | KODialogManager *CalendarView::dialogManager() |
901 | { | 902 | { |
902 | return mDialogManager; | 903 | return mDialogManager; |
903 | } | 904 | } |
904 | 905 | ||
905 | QDate CalendarView::startDate() | 906 | QDate CalendarView::startDate() |
906 | { | 907 | { |
907 | DateList dates = mNavigator->selectedDates(); | 908 | DateList dates = mNavigator->selectedDates(); |
908 | 909 | ||
909 | return dates.first(); | 910 | return dates.first(); |
910 | } | 911 | } |
911 | 912 | ||
912 | QDate CalendarView::endDate() | 913 | QDate CalendarView::endDate() |
913 | { | 914 | { |
914 | DateList dates = mNavigator->selectedDates(); | 915 | DateList dates = mNavigator->selectedDates(); |
915 | 916 | ||
916 | return dates.last(); | 917 | return dates.last(); |
917 | } | 918 | } |
918 | 919 | ||
919 | 920 | ||
920 | void CalendarView::createPrinter() | 921 | void CalendarView::createPrinter() |
921 | { | 922 | { |
922 | #ifndef KORG_NOPRINTER | 923 | #ifndef KORG_NOPRINTER |
923 | if (!mCalPrinter) { | 924 | if (!mCalPrinter) { |
924 | mCalPrinter = new CalPrinter(this, mCalendar); | 925 | mCalPrinter = new CalPrinter(this, mCalendar); |
925 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 926 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
926 | } | 927 | } |
927 | #endif | 928 | #endif |
928 | } | 929 | } |
929 | 930 | ||
930 | 931 | ||
931 | //KOPrefs::instance()->mWriteBackFile | 932 | //KOPrefs::instance()->mWriteBackFile |
932 | //KOPrefs::instance()->mWriteBackExistingOnly | 933 | //KOPrefs::instance()->mWriteBackExistingOnly |
933 | 934 | ||
934 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 935 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
935 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 936 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
936 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 937 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
937 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 938 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
938 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 939 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
939 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 940 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
940 | 941 | ||
941 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 942 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
942 | { | 943 | { |
943 | 944 | ||
944 | // 0 equal | 945 | // 0 equal |
945 | // 1 take local | 946 | // 1 take local |
946 | // 2 take remote | 947 | // 2 take remote |
947 | // 3 cancel | 948 | // 3 cancel |
948 | QDateTime lastSync = mLastCalendarSync; | 949 | QDateTime lastSync = mLastCalendarSync; |
949 | QDateTime localMod = local->lastModified(); | 950 | QDateTime localMod = local->lastModified(); |
950 | QDateTime remoteMod = remote->lastModified(); | 951 | QDateTime remoteMod = remote->lastModified(); |
951 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 952 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
952 | bool remCh, locCh; | 953 | bool remCh, locCh; |
953 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 954 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
954 | //if ( remCh ) | 955 | //if ( remCh ) |
955 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 956 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
956 | locCh = ( localMod > mLastCalendarSync ); | 957 | locCh = ( localMod > mLastCalendarSync ); |
957 | if ( !remCh && ! locCh ) { | 958 | if ( !remCh && ! locCh ) { |
958 | //qDebug("both not changed "); | 959 | //qDebug("both not changed "); |
959 | lastSync = localMod.addDays(1); | 960 | lastSync = localMod.addDays(1); |
960 | if ( mode <= SYNC_PREF_ASK ) | 961 | if ( mode <= SYNC_PREF_ASK ) |
961 | return 0; | 962 | return 0; |
962 | } else { | 963 | } else { |
963 | if ( locCh ) { | 964 | if ( locCh ) { |
964 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 965 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
965 | lastSync = localMod.addDays( -1 ); | 966 | lastSync = localMod.addDays( -1 ); |
966 | if ( !remCh ) | 967 | if ( !remCh ) |
967 | remoteMod = ( lastSync.addDays( -1 ) ); | 968 | remoteMod = ( lastSync.addDays( -1 ) ); |
968 | } else { | 969 | } else { |
969 | //qDebug(" not loc changed "); | 970 | //qDebug(" not loc changed "); |
970 | lastSync = localMod.addDays( 1 ); | 971 | lastSync = localMod.addDays( 1 ); |
971 | if ( remCh ) | 972 | if ( remCh ) |
972 | remoteMod =( lastSync.addDays( 1 ) ); | 973 | remoteMod =( lastSync.addDays( 1 ) ); |
973 | 974 | ||
974 | } | 975 | } |
975 | } | 976 | } |
976 | full = true; | 977 | full = true; |
977 | if ( mode < SYNC_PREF_ASK ) | 978 | if ( mode < SYNC_PREF_ASK ) |
978 | mode = SYNC_PREF_ASK; | 979 | mode = SYNC_PREF_ASK; |
979 | } else { | 980 | } else { |
980 | if ( localMod == remoteMod ) | 981 | if ( localMod == remoteMod ) |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index f987b63..748f3e4 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -1,522 +1,525 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <qapp.h> | 22 | #include <qapp.h> |
23 | #include <kglobal.h> | 23 | #include <kglobal.h> |
24 | 24 | ||
25 | #include <kiconloader.h> | 25 | #include <kiconloader.h> |
26 | #include "kotodoviewitem.h" | 26 | #include "kotodoviewitem.h" |
27 | #include "kotodoview.h" | 27 | #include "kotodoview.h" |
28 | #include "koprefs.h" | 28 | #include "koprefs.h" |
29 | 29 | ||
30 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) | 30 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) |
31 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 31 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
32 | { | 32 | { |
33 | construct(); | 33 | construct(); |
34 | } | 34 | } |
35 | 35 | ||
36 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) | 36 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) |
37 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 37 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
38 | { | 38 | { |
39 | construct(); | 39 | construct(); |
40 | } | 40 | } |
41 | 41 | ||
42 | QString KOTodoViewItem::key(int column,bool) const | 42 | QString KOTodoViewItem::key(int column,bool) const |
43 | { | 43 | { |
44 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); | 44 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); |
45 | if (it == mKeyMap.end()) { | 45 | if (it == mKeyMap.end()) { |
46 | return text(column).lower(); | 46 | return text(column).lower(); |
47 | } else { | 47 | } else { |
48 | return *it; | 48 | return *it; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void KOTodoViewItem:: setup() | 52 | void KOTodoViewItem:: setup() |
53 | { | 53 | { |
54 | 54 | ||
55 | int h = 20; | 55 | int h = 20; |
56 | if ( listView () ) { | 56 | if ( listView () ) { |
57 | QFontMetrics fm ( listView ()->font () ); | 57 | QFontMetrics fm ( listView ()->font () ); |
58 | h = fm.height(); | 58 | h = fm.height(); |
59 | } | 59 | } |
60 | setHeight( h ); | 60 | setHeight( h ); |
61 | 61 | ||
62 | } | 62 | } |
63 | void KOTodoViewItem::setSortKey(int column,const QString &key) | 63 | void KOTodoViewItem::setSortKey(int column,const QString &key) |
64 | { | 64 | { |
65 | mKeyMap.insert(column,key); | 65 | mKeyMap.insert(column,key); |
66 | } | 66 | } |
67 | 67 | ||
68 | #if QT_VERSION >= 0x030000 | 68 | #if QT_VERSION >= 0x030000 |
69 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, | 69 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, |
70 | int y,int h) | 70 | int y,int h) |
71 | { | 71 | { |
72 | QListViewItem::paintBranches(p,cg,w,y,h); | 72 | QListViewItem::paintBranches(p,cg,w,y,h); |
73 | } | 73 | } |
74 | #else | 74 | #else |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | void KOTodoViewItem::construct() | 77 | void KOTodoViewItem::construct() |
78 | { | 78 | { |
79 | // qDebug("KOTodoViewItem::construct() "); | 79 | // qDebug("KOTodoViewItem::construct() "); |
80 | m_init = true; | 80 | m_init = true; |
81 | QString keyd = "=="; | 81 | QString keyd = "=="; |
82 | QString keyt = "=="; | 82 | QString keyt = "=="; |
83 | QString skeyd = "=="; | 83 | QString skeyd = "=="; |
84 | QString skeyt = "=="; | 84 | QString skeyt = "=="; |
85 | 85 | ||
86 | setOn(mTodo->isCompleted()); | 86 | setOn(mTodo->isCompleted()); |
87 | setText(0,mTodo->summary()); | 87 | setText(0,mTodo->summary()); |
88 | setText(1,QString::number(mTodo->priority())); | 88 | setText(1,QString::number(mTodo->priority())); |
89 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 89 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
90 | if (mTodo->percentComplete()<100) { | 90 | if (mTodo->percentComplete()<100) { |
91 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 91 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
92 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 92 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
93 | } | 93 | } |
94 | else { | 94 | else { |
95 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 95 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
96 | else setSortKey(2,QString::number(99)); | 96 | else setSortKey(2,QString::number(99)); |
97 | } | 97 | } |
98 | if (mTodo->hasDueDate()) { | 98 | if (mTodo->hasDueDate()) { |
99 | setText(3, mTodo->dtDueDateStr()); | 99 | setText(3, mTodo->dtDueDateStr()); |
100 | QDate d = mTodo->dtDue().date(); | 100 | QDate d = mTodo->dtDue().date(); |
101 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 101 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
102 | // setSortKey(3,keyd); | 102 | // setSortKey(3,keyd); |
103 | if (mTodo->doesFloat()) { | 103 | if (mTodo->doesFloat()) { |
104 | setText(4,""); | 104 | setText(4,""); |
105 | } | 105 | } |
106 | else { | 106 | else { |
107 | setText(4,mTodo->dtDueTimeStr()); | 107 | setText(4,mTodo->dtDueTimeStr()); |
108 | QTime t = mTodo->dtDue().time(); | 108 | QTime t = mTodo->dtDue().time(); |
109 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 109 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
110 | //setSortKey(4,keyt); | 110 | //setSortKey(4,keyt); |
111 | } | 111 | } |
112 | } else { | 112 | } else { |
113 | setText(3,""); | 113 | setText(3,""); |
114 | setText(4,""); | 114 | setText(4,""); |
115 | } | 115 | } |
116 | setSortKey(3,keyd); | 116 | setSortKey(3,keyd); |
117 | setSortKey(4,keyt); | 117 | setSortKey(4,keyt); |
118 | 118 | ||
119 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); | 119 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); |
120 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 120 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
121 | 121 | ||
122 | 122 | ||
123 | 123 | ||
124 | keyd = ""; | 124 | keyd = ""; |
125 | keyt = ""; | 125 | keyt = ""; |
126 | 126 | ||
127 | if (mTodo->isRunning() ) { | 127 | if (mTodo->isRunning() ) { |
128 | QDate d = mTodo->runStart().date(); | 128 | QDate d = mTodo->runStart().date(); |
129 | QTime t = mTodo->runStart().time(); | 129 | QTime t = mTodo->runStart().time(); |
130 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 130 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
131 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 131 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
132 | keyd = KGlobal::locale()->formatDate( d , true); | 132 | keyd = KGlobal::locale()->formatDate( d , true); |
133 | keyt = KGlobal::locale()->formatTime( t ); | 133 | keyt = KGlobal::locale()->formatTime( t ); |
134 | 134 | ||
135 | } else { | 135 | } else { |
136 | 136 | ||
137 | if (mTodo->hasStartDate()) { | 137 | if (mTodo->hasStartDate()) { |
138 | keyd = mTodo->dtStartDateStr(); | 138 | keyd = mTodo->dtStartDateStr(); |
139 | QDate d = mTodo->dtStart().date(); | 139 | QDate d = mTodo->dtStart().date(); |
140 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 140 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
141 | 141 | ||
142 | if ( !mTodo->doesFloat()) { | 142 | if ( !mTodo->doesFloat()) { |
143 | keyt = mTodo->dtStartTimeStr(); | 143 | keyt = mTodo->dtStartTimeStr(); |
144 | QTime t = mTodo->dtStart().time(); | 144 | QTime t = mTodo->dtStart().time(); |
145 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 145 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
146 | 146 | ||
147 | } | 147 | } |
148 | 148 | ||
149 | } | 149 | } |
150 | } | 150 | } |
151 | setText(5,keyd); | 151 | setText(5,keyd); |
152 | setText(6,keyt); | 152 | setText(6,keyt); |
153 | setSortKey(5,skeyd); | 153 | setSortKey(5,skeyd); |
154 | setSortKey(6,skeyt); | 154 | setSortKey(6,skeyt); |
155 | 155 | ||
156 | setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); | 156 | setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); |
157 | setText(8,mTodo->categoriesStr()); | 157 | setText(8,mTodo->categoriesStr()); |
158 | 158 | ||
159 | #if 0 | 159 | #if 0 |
160 | // Find sort id in description. It's the text behind the last '#' character | 160 | // Find sort id in description. It's the text behind the last '#' character |
161 | // found in the description. White spaces are removed from beginning and end | 161 | // found in the description. White spaces are removed from beginning and end |
162 | // of sort id. | 162 | // of sort id. |
163 | int pos = mTodo->description().findRev('#'); | 163 | int pos = mTodo->description().findRev('#'); |
164 | if (pos < 0) { | 164 | if (pos < 0) { |
165 | setText(6,""); | 165 | setText(6,""); |
166 | } else { | 166 | } else { |
167 | QString str = mTodo->description().mid(pos+1); | 167 | QString str = mTodo->description().mid(pos+1); |
168 | str.stripWhiteSpace(); | 168 | str.stripWhiteSpace(); |
169 | setText(6,str); | 169 | setText(6,str); |
170 | } | 170 | } |
171 | #endif | 171 | #endif |
172 | 172 | ||
173 | m_known = false; | 173 | m_known = false; |
174 | m_init = false; | 174 | m_init = false; |
175 | 175 | ||
176 | setMyPixmap(); | 176 | setMyPixmap(); |
177 | 177 | ||
178 | } | 178 | } |
179 | void KOTodoViewItem::setMyPixmap() | 179 | void KOTodoViewItem::setMyPixmap() |
180 | { | 180 | { |
181 | int size = 5; | 181 | int size = 5; |
182 | QPixmap pixi = QPixmap( 1, 1 ); | 182 | QPixmap pixi = QPixmap( 1, 1 ); |
183 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { | 183 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { |
184 | // pixi = SmallIcon("redcross16"); | 184 | // pixi = SmallIcon("redcross16"); |
185 | // } else { | 185 | // } else { |
186 | QPainter p; | 186 | QPainter p; |
187 | 187 | ||
188 | int pixSize = 0; | 188 | int pixSize = 0; |
189 | QPixmap pPix = QPixmap( size, size ); | 189 | QPixmap pPix = QPixmap( size, size ); |
190 | if ( mTodo->description().length() > 0 ) { | 190 | if ( mTodo->description().length() > 0 ) { |
191 | pixi.resize(size, pixSize+size); | 191 | pixi.resize(size, pixSize+size); |
192 | pPix.fill( Qt::darkGreen ); | 192 | pPix.fill( Qt::darkGreen ); |
193 | p.begin( &pixi ); | 193 | p.begin( &pixi ); |
194 | p. drawPixmap ( 0, pixSize, pPix); | 194 | p. drawPixmap ( 0, pixSize, pPix); |
195 | p.end(); | 195 | p.end(); |
196 | pixSize += size; | 196 | pixSize += size; |
197 | } | 197 | } |
198 | if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { | 198 | if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { |
199 | pixi.resize(size, pixSize+size); | 199 | pixi.resize(size, pixSize+size); |
200 | pPix.fill( Qt::red ); | 200 | pPix.fill( Qt::red ); |
201 | p.begin( &pixi ); | 201 | p.begin( &pixi ); |
202 | p. drawPixmap ( 0, pixSize, pPix); | 202 | p. drawPixmap ( 0, pixSize, pPix); |
203 | p.end(); | 203 | p.end(); |
204 | pixSize += size; | 204 | pixSize += size; |
205 | } | 205 | } |
206 | if ( mTodo->doesRecur() ) { | 206 | if ( mTodo->doesRecur() ) { |
207 | pixi.resize(size, pixSize+size); | 207 | pixi.resize(size, pixSize+size); |
208 | pPix.fill( Qt::blue ); | 208 | pPix.fill( Qt::blue ); |
209 | p.begin( &pixi ); | 209 | p.begin( &pixi ); |
210 | p. drawPixmap ( 0, pixSize, pPix); | 210 | p. drawPixmap ( 0, pixSize, pPix); |
211 | p.end(); | 211 | p.end(); |
212 | pixSize += size; | 212 | pixSize += size; |
213 | } | 213 | } |
214 | // } | 214 | // } |
215 | if ( pixi.width() > 1 ) { | 215 | if ( pixi.width() > 1 ) { |
216 | setPixmap ( 0,pixi ) ; | 216 | setPixmap ( 0,pixi ) ; |
217 | } else { | 217 | } else { |
218 | setPixmap ( 0,QPixmap() ) ; | 218 | setPixmap ( 0,QPixmap() ) ; |
219 | } | 219 | } |
220 | } | 220 | } |
221 | void KOTodoViewItem::stateChange(bool state) | 221 | void KOTodoViewItem::stateChange(bool state) |
222 | { | 222 | { |
223 | // qDebug("KOTodoViewItem::stateChange %d ", state); | 223 | // qDebug("KOTodoViewItem::stateChange %d ", state); |
224 | // do not change setting on startup | 224 | // do not change setting on startup |
225 | if ( m_init ) return; | 225 | if ( m_init ) return; |
226 | if (isOn()!=state) { | 226 | if (isOn()!=state) { |
227 | setOn(state); | 227 | setOn(state); |
228 | //qDebug("SETON "); | 228 | //qDebug("SETON "); |
229 | return; | 229 | return; |
230 | } | 230 | } |
231 | if ( mTodo->isCompleted() == state ) { | 231 | if ( mTodo->isCompleted() == state ) { |
232 | //qDebug("STATECHANGE:nothing to do "); | 232 | //qDebug("STATECHANGE:nothing to do "); |
233 | return; | 233 | return; |
234 | } | 234 | } |
235 | QString keyd = "=="; | 235 | QString keyd = "=="; |
236 | QString keyt = "=="; | 236 | QString keyt = "=="; |
237 | //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); | 237 | //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); |
238 | if ( mTodo->doesRecur() ){ | 238 | if ( mTodo->doesRecur() ){ |
239 | QDateTime start = mTodo->dtStart(); | 239 | QDateTime start = mTodo->dtStart(); |
240 | mTodo->setCompleted(state); | 240 | mTodo->setCompleted(state); |
241 | if ( start != mTodo->dtStart() ) { | 241 | if ( start != mTodo->dtStart() ) { |
242 | if ( state && !mTodo->isCompleted() ) { | 242 | if ( state && !mTodo->isCompleted() ) { |
243 | setOn( false ); | 243 | setOn( false ); |
244 | state = false; | 244 | state = false; |
245 | } | 245 | } |
246 | } | 246 | } |
247 | } else | 247 | } else |
248 | mTodo->setCompleted(state); | 248 | mTodo->setCompleted(state); |
249 | 249 | ||
250 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); | 250 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); |
251 | 251 | ||
252 | if (mTodo->hasDueDate()) { | 252 | if (mTodo->hasDueDate()) { |
253 | setText(3, mTodo->dtDueDateStr()); | 253 | setText(3, mTodo->dtDueDateStr()); |
254 | QDate d = mTodo->dtDue().date(); | 254 | QDate d = mTodo->dtDue().date(); |
255 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 255 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
256 | setSortKey(3,keyd); | 256 | setSortKey(3,keyd); |
257 | if (mTodo->doesFloat()) { | 257 | if (mTodo->doesFloat()) { |
258 | setText(4,""); | 258 | setText(4,""); |
259 | } | 259 | } |
260 | else { | 260 | else { |
261 | setText(4,mTodo->dtDueTimeStr()); | 261 | setText(4,mTodo->dtDueTimeStr()); |
262 | QTime t = mTodo->dtDue().time(); | 262 | QTime t = mTodo->dtDue().time(); |
263 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 263 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
264 | setSortKey(4,keyt); | 264 | setSortKey(4,keyt); |
265 | } | 265 | } |
266 | } | 266 | } |
267 | if (mTodo->hasStartDate()) { | 267 | if (mTodo->hasStartDate()) { |
268 | QString skeyt = "=="; | 268 | QString skeyt = "=="; |
269 | QString skeyd = "=="; | 269 | QString skeyd = "=="; |
270 | setText(5, mTodo->dtStartDateStr()); | 270 | setText(5, mTodo->dtStartDateStr()); |
271 | QDate d = mTodo->dtStart().date(); | 271 | QDate d = mTodo->dtStart().date(); |
272 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 272 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
273 | 273 | ||
274 | if (mTodo->doesFloat()) { | 274 | if (mTodo->doesFloat()) { |
275 | setText(6,""); | 275 | setText(6,""); |
276 | } | 276 | } |
277 | else { | 277 | else { |
278 | setText(6,mTodo->dtStartTimeStr()); | 278 | setText(6,mTodo->dtStartTimeStr()); |
279 | QTime t = mTodo->dtStart().time(); | 279 | QTime t = mTodo->dtStart().time(); |
280 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 280 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
281 | 281 | ||
282 | } | 282 | } |
283 | setSortKey(5,skeyd); | 283 | setSortKey(5,skeyd); |
284 | setSortKey(6,skeyt); | 284 | setSortKey(6,skeyt); |
285 | } | 285 | } |
286 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); | 286 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); |
287 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 287 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
288 | 288 | ||
289 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 289 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
290 | if (mTodo->percentComplete()<100) { | 290 | if (mTodo->percentComplete()<100) { |
291 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 291 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
292 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 292 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
293 | } | 293 | } |
294 | else { | 294 | else { |
295 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 295 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
296 | else setSortKey(2,QString::number(99)); | 296 | else setSortKey(2,QString::number(99)); |
297 | } | 297 | } |
298 | if ( state ) { | 298 | if ( state ) { |
299 | QListViewItem * myChild = firstChild(); | 299 | QListViewItem * myChild = firstChild(); |
300 | KOTodoViewItem *item; | 300 | KOTodoViewItem *item; |
301 | while( myChild ) { | 301 | while( myChild ) { |
302 | //qDebug("stateCH "); | 302 | //qDebug("stateCH "); |
303 | item = static_cast<KOTodoViewItem*>(myChild); | 303 | item = static_cast<KOTodoViewItem*>(myChild); |
304 | item->stateChange(state); | 304 | item->stateChange(state); |
305 | myChild = myChild->nextSibling(); | 305 | myChild = myChild->nextSibling(); |
306 | } | 306 | } |
307 | } else { | 307 | } else { |
308 | QListViewItem * myChild = parent(); | 308 | QListViewItem * myChild = parent(); |
309 | if ( myChild ) | 309 | if ( myChild ) |
310 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); | 310 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); |
311 | } | 311 | } |
312 | mTodoView->modified(true); | 312 | mTodoView->modified(true); |
313 | setMyPixmap(); | 313 | setMyPixmap(); |
314 | mTodoView->setTodoModified( mTodo ); | 314 | mTodoView->setTodoModified( mTodo ); |
315 | } | 315 | } |
316 | 316 | ||
317 | bool KOTodoViewItem::isAlternate() | 317 | bool KOTodoViewItem::isAlternate() |
318 | { | 318 | { |
319 | 319 | ||
320 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 320 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
321 | if (lv && lv->alternateBackground().isValid()) | 321 | if (lv && lv->alternateBackground().isValid()) |
322 | { | 322 | { |
323 | KOTodoViewItem *above = 0; | 323 | KOTodoViewItem *above = 0; |
324 | above = static_cast<KOTodoViewItem *>(itemAbove()); | 324 | above = static_cast<KOTodoViewItem *>(itemAbove()); |
325 | m_known = above ? above->m_known : true; | 325 | m_known = above ? above->m_known : true; |
326 | if (m_known) | 326 | if (m_known) |
327 | { | 327 | { |
328 | m_odd = above ? !above->m_odd : false; | 328 | m_odd = above ? !above->m_odd : false; |
329 | } | 329 | } |
330 | else | 330 | else |
331 | { | 331 | { |
332 | KOTodoViewItem *item; | 332 | KOTodoViewItem *item; |
333 | bool previous = true; | 333 | bool previous = true; |
334 | if (QListViewItem::parent()) | 334 | if (QListViewItem::parent()) |
335 | { | 335 | { |
336 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); | 336 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); |
337 | if (item) | 337 | if (item) |
338 | previous = item->m_odd; | 338 | previous = item->m_odd; |
339 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); | 339 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); |
340 | } | 340 | } |
341 | else | 341 | else |
342 | { | 342 | { |
343 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); | 343 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); |
344 | } | 344 | } |
345 | 345 | ||
346 | while(item) | 346 | while(item) |
347 | { | 347 | { |
348 | item->m_odd = previous = !previous; | 348 | item->m_odd = previous = !previous; |
349 | item->m_known = true; | 349 | item->m_known = true; |
350 | item = static_cast<KOTodoViewItem *>(item->nextSibling()); | 350 | item = static_cast<KOTodoViewItem *>(item->nextSibling()); |
351 | } | 351 | } |
352 | } | 352 | } |
353 | return m_odd; | 353 | return m_odd; |
354 | } | 354 | } |
355 | return false; | 355 | return false; |
356 | } | 356 | } |
357 | 357 | ||
358 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 358 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
359 | { | 359 | { |
360 | QColorGroup _cg = cg; | 360 | QColorGroup _cg = cg; |
361 | QColorGroup::ColorRole role; | 361 | QColorGroup::ColorRole role; |
362 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) | 362 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) |
363 | role = QColorGroup::Text; | 363 | role = QColorGroup::Text; |
364 | else | 364 | else |
365 | role = QColorGroup::Base; | 365 | role = QColorGroup::Base; |
366 | //#ifndef KORG_NOLVALTERNATION | 366 | //#ifndef KORG_NOLVALTERNATION |
367 | if (isAlternate()) | 367 | if (isAlternate()) |
368 | _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); | 368 | _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); |
369 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; | 369 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; |
370 | QColor colorToSet; | 370 | QColor colorToSet; |
371 | if ( setColor ) { | 371 | if ( column == 0 && mTodo->calID() > 1 ) { |
372 | setColor = true; | ||
373 | colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() ); | ||
374 | } else if ( setColor ) { | ||
372 | QStringList categories = mTodo->categories(); | 375 | QStringList categories = mTodo->categories(); |
373 | QString cat = categories.first(); | 376 | QString cat = categories.first(); |
374 | if ( !cat.isEmpty()) { | 377 | if ( !cat.isEmpty()) { |
375 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); | 378 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); |
376 | } else | 379 | } else |
377 | setColor = false; | 380 | setColor = false; |
378 | } | 381 | } |
379 | bool openMode = !isOpen(); | 382 | bool openMode = !isOpen(); |
380 | // maybe we are in flat-display-mode | 383 | // maybe we are in flat-display-mode |
381 | if ( !firstChild() ) | 384 | if ( !firstChild() ) |
382 | openMode = false; | 385 | openMode = false; |
383 | bool colorRunning = mTodo->isRunning(); | 386 | bool colorRunning = mTodo->isRunning(); |
384 | if ( ! colorRunning && openMode ) | 387 | if ( ! colorRunning && openMode ) |
385 | colorRunning = mTodo->hasRunningSub(); | 388 | colorRunning = mTodo->hasRunningSub(); |
386 | if ( colorRunning ) { | 389 | if ( colorRunning ) { |
387 | setColor = true; | 390 | setColor = true; |
388 | colorToSet = KOPrefs::instance()->mTodoRunColor; | 391 | colorToSet = KOPrefs::instance()->mTodoRunColor; |
389 | } else { | 392 | } else { |
390 | int odue = mTodo->hasDueSubTodo( openMode ); | 393 | int odue = mTodo->hasDueSubTodo( openMode ); |
391 | if (odue == 2) { | 394 | if (odue == 2) { |
392 | colorToSet = KOPrefs::instance()->mTodoOverdueColor; | 395 | colorToSet = KOPrefs::instance()->mTodoOverdueColor; |
393 | setColor = true; | 396 | setColor = true; |
394 | } else if ( odue == 1 ) { | 397 | } else if ( odue == 1 ) { |
395 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; | 398 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; |
396 | setColor = true; | 399 | setColor = true; |
397 | } | 400 | } |
398 | } | 401 | } |
399 | 402 | ||
400 | 403 | ||
401 | if ( setColor ) { | 404 | if ( setColor ) { |
402 | _cg.setColor(role,colorToSet ); | 405 | _cg.setColor(role,colorToSet ); |
403 | if ( role == QColorGroup::Base) { | 406 | if ( role == QColorGroup::Base) { |
404 | int rgb = colorToSet.red(); | 407 | int rgb = colorToSet.red(); |
405 | rgb += colorToSet.blue()/2; | 408 | rgb += colorToSet.blue()/2; |
406 | rgb += colorToSet.green(); | 409 | rgb += colorToSet.green(); |
407 | if ( rgb < 200 ) | 410 | if ( rgb < 200 ) |
408 | _cg.setColor(QColorGroup::Text,Qt::white ); | 411 | _cg.setColor(QColorGroup::Text,Qt::white ); |
409 | } | 412 | } |
410 | } | 413 | } |
411 | //#endif | 414 | //#endif |
412 | if ( column > 0 ){ | 415 | if ( column > 0 ){ |
413 | if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { | 416 | if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { |
414 | p->save(); | 417 | p->save(); |
415 | int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); | 418 | int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); |
416 | 419 | ||
417 | p->fillRect( 0, 0, width, height(), _cg.base() ); // background | 420 | p->fillRect( 0, 0, width, height(), _cg.base() ); // background |
418 | // p->setPen(Qt::black ); //border | 421 | // p->setPen(Qt::black ); //border |
419 | // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling | 422 | // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling |
420 | QColor fc = KOPrefs::instance()->mHighlightColor; | 423 | QColor fc = KOPrefs::instance()->mHighlightColor; |
421 | if ( mTodo->percentComplete() == 100 ) | 424 | if ( mTodo->percentComplete() == 100 ) |
422 | fc = darkGreen; | 425 | fc = darkGreen; |
423 | p->drawRect( 2, 2, width-4, height()-4); | 426 | p->drawRect( 2, 2, width-4, height()-4); |
424 | p->fillRect( 3, 3, progress, height()-6, | 427 | p->fillRect( 3, 3, progress, height()-6, |
425 | fc ); | 428 | fc ); |
426 | p->restore(); | 429 | p->restore(); |
427 | } else { | 430 | } else { |
428 | QCheckListItem::paintCell(p, _cg, column, width, alignment); | 431 | QCheckListItem::paintCell(p, _cg, column, width, alignment); |
429 | } | 432 | } |
430 | return; | 433 | return; |
431 | } | 434 | } |
432 | 435 | ||
433 | int align = alignment; | 436 | int align = alignment; |
434 | 437 | ||
435 | if ( !p ) | 438 | if ( !p ) |
436 | return; | 439 | return; |
437 | 440 | ||
438 | p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); | 441 | p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); |
439 | 442 | ||
440 | QListView *lv = listView(); | 443 | QListView *lv = listView(); |
441 | if ( !lv ) | 444 | if ( !lv ) |
442 | return; | 445 | return; |
443 | int marg = 2;//lv->itemMargin(); | 446 | int marg = 2;//lv->itemMargin(); |
444 | int r = 0; | 447 | int r = 0; |
445 | QCheckListItem::Type myType = QCheckListItem::CheckBox; | 448 | QCheckListItem::Type myType = QCheckListItem::CheckBox; |
446 | int BoxSize = 20; | 449 | int BoxSize = 20; |
447 | int boxOffset = 2; | 450 | int boxOffset = 2; |
448 | int xOffset = 2; | 451 | int xOffset = 2; |
449 | if (qApp->desktop()->width() < 300 ) { | 452 | if (qApp->desktop()->width() < 300 ) { |
450 | BoxSize = 14; | 453 | BoxSize = 14; |
451 | boxOffset = -1; | 454 | boxOffset = -1; |
452 | xOffset = 1; | 455 | xOffset = 1; |
453 | // marg = 0; | 456 | // marg = 0; |
454 | } | 457 | } |
455 | if ( height() < BoxSize ) { | 458 | if ( height() < BoxSize ) { |
456 | boxOffset = boxOffset - ((BoxSize - height())/2) ; | 459 | boxOffset = boxOffset - ((BoxSize - height())/2) ; |
457 | // qDebug("boxOffset %d height %d", boxOffset, height() ); | 460 | // qDebug("boxOffset %d height %d", boxOffset, height() ); |
458 | BoxSize = height(); | 461 | BoxSize = height(); |
459 | 462 | ||
460 | } | 463 | } |
461 | //bool winStyle = lv->style() == WindowsStyle; | 464 | //bool winStyle = lv->style() == WindowsStyle; |
462 | 465 | ||
463 | int lineStart = 5; | 466 | int lineStart = 5; |
464 | if ( myType == Controller ) { | 467 | if ( myType == Controller ) { |
465 | if ( !pixmap( 0 ) ) | 468 | if ( !pixmap( 0 ) ) |
466 | r += BoxSize + 4; | 469 | r += BoxSize + 4; |
467 | } else { | 470 | } else { |
468 | ASSERT( lv ); //### | 471 | ASSERT( lv ); //### |
469 | //QFontMetrics fm( lv->font() ); | 472 | //QFontMetrics fm( lv->font() ); |
470 | //int d = fm.height(); | 473 | //int d = fm.height(); |
471 | int x = 0; | 474 | int x = 0; |
472 | int y = (height() - BoxSize) / 2; | 475 | int y = (height() - BoxSize) / 2; |
473 | //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); | 476 | //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); |
474 | if ( myType == CheckBox ) { | 477 | if ( myType == CheckBox ) { |
475 | if ( isEnabled() ) | 478 | if ( isEnabled() ) |
476 | p->setPen( QPen( _cg.text(), 1 ) ); | 479 | p->setPen( QPen( _cg.text(), 1 ) ); |
477 | else | 480 | else |
478 | p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); | 481 | p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); |
479 | p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); | 482 | p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); |
480 | lineStart = x+marg; | 483 | lineStart = x+marg; |
481 | ///////////////////// | 484 | ///////////////////// |
482 | x++; | 485 | x++; |
483 | y++; | 486 | y++; |
484 | if ( isOn() ) { | 487 | if ( isOn() ) { |
485 | QPointArray a( 7*2 ); | 488 | QPointArray a( 7*2 ); |
486 | int i, xx, yy; | 489 | int i, xx, yy; |
487 | xx = x+xOffset+marg+(boxOffset/2); | 490 | xx = x+xOffset+marg+(boxOffset/2); |
488 | yy = y+5+boxOffset; | 491 | yy = y+5+boxOffset; |
489 | for ( i=0; i<3; i++ ) { | 492 | for ( i=0; i<3; i++ ) { |
490 | a.setPoint( 2*i, xx, yy ); | 493 | a.setPoint( 2*i, xx, yy ); |
491 | a.setPoint( 2*i+1, xx, yy+2 ); | 494 | a.setPoint( 2*i+1, xx, yy+2 ); |
492 | // qDebug(" "); | 495 | // qDebug(" "); |
493 | xx++; yy++; | 496 | xx++; yy++; |
494 | } | 497 | } |
495 | yy -= 2; | 498 | yy -= 2; |
496 | for ( i=3; i<7; i++ ) { | 499 | for ( i=3; i<7; i++ ) { |
497 | a.setPoint( 2*i, xx, yy ); | 500 | a.setPoint( 2*i, xx, yy ); |
498 | a.setPoint( 2*i+1, xx, yy+2 ); | 501 | a.setPoint( 2*i+1, xx, yy+2 ); |
499 | xx++; yy--; | 502 | xx++; yy--; |
500 | } | 503 | } |
501 | p->setPen( darkGreen ); | 504 | p->setPen( darkGreen ); |
502 | p->drawLineSegments( a ); | 505 | p->drawLineSegments( a ); |
503 | } | 506 | } |
504 | //////////////////////// | 507 | //////////////////////// |
505 | } | 508 | } |
506 | r += BoxSize + 4; | 509 | r += BoxSize + 4; |
507 | } | 510 | } |
508 | 511 | ||
509 | p->translate( r, 0 ); | 512 | p->translate( r, 0 ); |
510 | p->setPen( QPen( _cg.text() ) ); | 513 | p->setPen( QPen( _cg.text() ) ); |
511 | QListViewItem::paintCell( p, _cg, column, width - r, align ); | 514 | QListViewItem::paintCell( p, _cg, column, width - r, align ); |
512 | if ( mTodo->cancelled () ) { | 515 | if ( mTodo->cancelled () ) { |
513 | p->setPen( black ); | 516 | p->setPen( black ); |
514 | QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); | 517 | QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); |
515 | int wid = br.width() +lineStart; | 518 | int wid = br.width() +lineStart; |
516 | if ( wid > width-3 ) | 519 | if ( wid > width-3 ) |
517 | wid = width-3; | 520 | wid = width-3; |
518 | p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); | 521 | p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); |
519 | 522 | ||
520 | } | 523 | } |
521 | 524 | ||
522 | } | 525 | } |