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 /korganizer | |
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,4520 +1,4521 @@ | |||
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 ) |
981 | // if ( local->revision() == remote->revision() ) | 982 | // if ( local->revision() == remote->revision() ) |
982 | return 0; | 983 | return 0; |
983 | 984 | ||
984 | } | 985 | } |
985 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 986 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
986 | 987 | ||
987 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 988 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
988 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 989 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
989 | //full = true; //debug only | 990 | //full = true; //debug only |
990 | if ( full ) { | 991 | if ( full ) { |
991 | bool equ = false; | 992 | bool equ = false; |
992 | if ( local->typeID() == eventID ) { | 993 | if ( local->typeID() == eventID ) { |
993 | equ = (*((Event*) local) == *((Event*) remote)); | 994 | equ = (*((Event*) local) == *((Event*) remote)); |
994 | } | 995 | } |
995 | else if ( local->typeID() == todoID ) | 996 | else if ( local->typeID() == todoID ) |
996 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 997 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
997 | else if ( local->typeID() == journalID ) | 998 | else if ( local->typeID() == journalID ) |
998 | equ = (*((Journal*) local) == *((Journal*) remote)); | 999 | equ = (*((Journal*) local) == *((Journal*) remote)); |
999 | if ( equ ) { | 1000 | if ( equ ) { |
1000 | //qDebug("equal "); | 1001 | //qDebug("equal "); |
1001 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1002 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1002 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1003 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1003 | } | 1004 | } |
1004 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1005 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1005 | return 0; | 1006 | return 0; |
1006 | 1007 | ||
1007 | }//else //debug only | 1008 | }//else //debug only |
1008 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1009 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1009 | } | 1010 | } |
1010 | int result; | 1011 | int result; |
1011 | bool localIsNew; | 1012 | bool localIsNew; |
1012 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 1013 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
1013 | 1014 | ||
1014 | 1015 | ||
1015 | // ************************************************ | 1016 | // ************************************************ |
1016 | // ************************************************ | 1017 | // ************************************************ |
1017 | // ************************************************ | 1018 | // ************************************************ |
1018 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1019 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1019 | // BUT remoteMod != localMod | 1020 | // BUT remoteMod != localMod |
1020 | 1021 | ||
1021 | 1022 | ||
1022 | if ( full && mode < SYNC_PREF_NEWEST ) | 1023 | if ( full && mode < SYNC_PREF_NEWEST ) |
1023 | mode = SYNC_PREF_ASK; | 1024 | mode = SYNC_PREF_ASK; |
1024 | 1025 | ||
1025 | switch( mode ) { | 1026 | switch( mode ) { |
1026 | case SYNC_PREF_LOCAL: | 1027 | case SYNC_PREF_LOCAL: |
1027 | if ( lastSync > remoteMod ) | 1028 | if ( lastSync > remoteMod ) |
1028 | return 1; | 1029 | return 1; |
1029 | if ( lastSync > localMod ) | 1030 | if ( lastSync > localMod ) |
1030 | return 2; | 1031 | return 2; |
1031 | return 1; | 1032 | return 1; |
1032 | break; | 1033 | break; |
1033 | case SYNC_PREF_REMOTE: | 1034 | case SYNC_PREF_REMOTE: |
1034 | if ( lastSync > localMod ) | 1035 | if ( lastSync > localMod ) |
1035 | return 2; | 1036 | return 2; |
1036 | if ( lastSync > remoteMod ) | 1037 | if ( lastSync > remoteMod ) |
1037 | return 1; | 1038 | return 1; |
1038 | return 2; | 1039 | return 2; |
1039 | break; | 1040 | break; |
1040 | case SYNC_PREF_NEWEST: | 1041 | case SYNC_PREF_NEWEST: |
1041 | if ( localMod >= remoteMod ) | 1042 | if ( localMod >= remoteMod ) |
1042 | return 1; | 1043 | return 1; |
1043 | else | 1044 | else |
1044 | return 2; | 1045 | return 2; |
1045 | break; | 1046 | break; |
1046 | case SYNC_PREF_ASK: | 1047 | case SYNC_PREF_ASK: |
1047 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1048 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1048 | if ( lastSync > remoteMod && lastSync > localMod) | 1049 | if ( lastSync > remoteMod && lastSync > localMod) |
1049 | return 0; | 1050 | return 0; |
1050 | if ( lastSync > remoteMod ) | 1051 | if ( lastSync > remoteMod ) |
1051 | return 1; | 1052 | return 1; |
1052 | if ( lastSync > localMod ) | 1053 | if ( lastSync > localMod ) |
1053 | return 2; | 1054 | return 2; |
1054 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1055 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1055 | localIsNew = localMod >= remoteMod; | 1056 | localIsNew = localMod >= remoteMod; |
1056 | if ( localIsNew ) | 1057 | if ( localIsNew ) |
1057 | getEventViewerDialog()->setColorMode( 1 ); | 1058 | getEventViewerDialog()->setColorMode( 1 ); |
1058 | else | 1059 | else |
1059 | getEventViewerDialog()->setColorMode( 2 ); | 1060 | getEventViewerDialog()->setColorMode( 2 ); |
1060 | getEventViewerDialog()->setIncidence(local); | 1061 | getEventViewerDialog()->setIncidence(local); |
1061 | if ( localIsNew ) | 1062 | if ( localIsNew ) |
1062 | getEventViewerDialog()->setColorMode( 2 ); | 1063 | getEventViewerDialog()->setColorMode( 2 ); |
1063 | else | 1064 | else |
1064 | getEventViewerDialog()->setColorMode( 1 ); | 1065 | getEventViewerDialog()->setColorMode( 1 ); |
1065 | getEventViewerDialog()->addIncidence(remote); | 1066 | getEventViewerDialog()->addIncidence(remote); |
1066 | getEventViewerDialog()->setColorMode( 0 ); | 1067 | getEventViewerDialog()->setColorMode( 0 ); |
1067 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1068 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1068 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1069 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1069 | getEventViewerDialog()->showMe(); | 1070 | getEventViewerDialog()->showMe(); |
1070 | result = getEventViewerDialog()->executeS( localIsNew ); | 1071 | result = getEventViewerDialog()->executeS( localIsNew ); |
1071 | return result; | 1072 | return result; |
1072 | 1073 | ||
1073 | break; | 1074 | break; |
1074 | case SYNC_PREF_FORCE_LOCAL: | 1075 | case SYNC_PREF_FORCE_LOCAL: |
1075 | return 1; | 1076 | return 1; |
1076 | break; | 1077 | break; |
1077 | case SYNC_PREF_FORCE_REMOTE: | 1078 | case SYNC_PREF_FORCE_REMOTE: |
1078 | return 2; | 1079 | return 2; |
1079 | break; | 1080 | break; |
1080 | 1081 | ||
1081 | default: | 1082 | default: |
1082 | // SYNC_PREF_TAKE_BOTH not implemented | 1083 | // SYNC_PREF_TAKE_BOTH not implemented |
1083 | break; | 1084 | break; |
1084 | } | 1085 | } |
1085 | return 0; | 1086 | return 0; |
1086 | } | 1087 | } |
1087 | Event* CalendarView::getLastSyncEvent() | 1088 | Event* CalendarView::getLastSyncEvent() |
1088 | { | 1089 | { |
1089 | Event* lse; | 1090 | Event* lse; |
1090 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1091 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1091 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1092 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1092 | if (!lse) { | 1093 | if (!lse) { |
1093 | lse = new Event(); | 1094 | lse = new Event(); |
1094 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1095 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1095 | QString sum = ""; | 1096 | QString sum = ""; |
1096 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1097 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1097 | sum = "E: "; | 1098 | sum = "E: "; |
1098 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1099 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1099 | lse->setDtStart( mLastCalendarSync ); | 1100 | lse->setDtStart( mLastCalendarSync ); |
1100 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1101 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1101 | lse->setCategories( i18n("SyncEvent") ); | 1102 | lse->setCategories( i18n("SyncEvent") ); |
1102 | lse->setReadOnly( true ); | 1103 | lse->setReadOnly( true ); |
1103 | mCalendar->addEvent( lse ); | 1104 | mCalendar->addEvent( lse ); |
1104 | } | 1105 | } |
1105 | 1106 | ||
1106 | return lse; | 1107 | return lse; |
1107 | 1108 | ||
1108 | } | 1109 | } |
1109 | 1110 | ||
1110 | // we check, if the to delete event has a id for a profile | 1111 | // we check, if the to delete event has a id for a profile |
1111 | // if yes, we set this id in the profile to delete | 1112 | // if yes, we set this id in the profile to delete |
1112 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1113 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1113 | { | 1114 | { |
1114 | if ( lastSync.count() == 0 ) { | 1115 | if ( lastSync.count() == 0 ) { |
1115 | //qDebug(" lastSync.count() == 0"); | 1116 | //qDebug(" lastSync.count() == 0"); |
1116 | return; | 1117 | return; |
1117 | } | 1118 | } |
1118 | if ( toDelete->typeID() == journalID ) | 1119 | if ( toDelete->typeID() == journalID ) |
1119 | return; | 1120 | return; |
1120 | 1121 | ||
1121 | Event* eve = lastSync.first(); | 1122 | Event* eve = lastSync.first(); |
1122 | 1123 | ||
1123 | while ( eve ) { | 1124 | while ( eve ) { |
1124 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1125 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1125 | if ( !id.isEmpty() ) { | 1126 | if ( !id.isEmpty() ) { |
1126 | QString des = eve->description(); | 1127 | QString des = eve->description(); |
1127 | QString pref = "e"; | 1128 | QString pref = "e"; |
1128 | if ( toDelete->typeID() == todoID ) | 1129 | if ( toDelete->typeID() == todoID ) |
1129 | pref = "t"; | 1130 | pref = "t"; |
1130 | des += pref+ id + ","; | 1131 | des += pref+ id + ","; |
1131 | eve->setReadOnly( false ); | 1132 | eve->setReadOnly( false ); |
1132 | eve->setDescription( des ); | 1133 | eve->setDescription( des ); |
1133 | //qDebug("setdes %s ", des.latin1()); | 1134 | //qDebug("setdes %s ", des.latin1()); |
1134 | eve->setReadOnly( true ); | 1135 | eve->setReadOnly( true ); |
1135 | } | 1136 | } |
1136 | eve = lastSync.next(); | 1137 | eve = lastSync.next(); |
1137 | } | 1138 | } |
1138 | 1139 | ||
1139 | } | 1140 | } |
1140 | void CalendarView::checkExternalId( Incidence * inc ) | 1141 | void CalendarView::checkExternalId( Incidence * inc ) |
1141 | { | 1142 | { |
1142 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1143 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1143 | checkExternSyncEvent( lastSync, inc ); | 1144 | checkExternSyncEvent( lastSync, inc ); |
1144 | 1145 | ||
1145 | } | 1146 | } |
1146 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1147 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1147 | { | 1148 | { |
1148 | bool syncOK = true; | 1149 | bool syncOK = true; |
1149 | int addedEvent = 0; | 1150 | int addedEvent = 0; |
1150 | int addedEventR = 0; | 1151 | int addedEventR = 0; |
1151 | int deletedEventR = 0; | 1152 | int deletedEventR = 0; |
1152 | int deletedEventL = 0; | 1153 | int deletedEventL = 0; |
1153 | int changedLocal = 0; | 1154 | int changedLocal = 0; |
1154 | int changedRemote = 0; | 1155 | int changedRemote = 0; |
1155 | int filteredIN = 0; | 1156 | int filteredIN = 0; |
1156 | int filteredOUT = 0; | 1157 | int filteredOUT = 0; |
1157 | //QPtrList<Event> el = local->rawEvents(); | 1158 | //QPtrList<Event> el = local->rawEvents(); |
1158 | Event* eventR; | 1159 | Event* eventR; |
1159 | QString uid; | 1160 | QString uid; |
1160 | int take; | 1161 | int take; |
1161 | Event* eventL; | 1162 | Event* eventL; |
1162 | Event* eventRSync; | 1163 | Event* eventRSync; |
1163 | Event* eventLSync; | 1164 | Event* eventLSync; |
1164 | clearAllViews(); | 1165 | clearAllViews(); |
1165 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1166 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1166 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1167 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1167 | bool fullDateRange = false; | 1168 | bool fullDateRange = false; |
1168 | local->resetTempSyncStat(); | 1169 | local->resetTempSyncStat(); |
1169 | mLastCalendarSync = QDateTime::currentDateTime(); | 1170 | mLastCalendarSync = QDateTime::currentDateTime(); |
1170 | if ( mSyncManager->syncWithDesktop() ) { | 1171 | if ( mSyncManager->syncWithDesktop() ) { |
1171 | remote->resetPilotStat(1); | 1172 | remote->resetPilotStat(1); |
1172 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1173 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1173 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1174 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1174 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1175 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1175 | } else { | 1176 | } else { |
1176 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1177 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1177 | } | 1178 | } |
1178 | } | 1179 | } |
1179 | QDateTime modifiedCalendar = mLastCalendarSync; | 1180 | QDateTime modifiedCalendar = mLastCalendarSync; |
1180 | eventLSync = getLastSyncEvent(); | 1181 | eventLSync = getLastSyncEvent(); |
1181 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1182 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1182 | if ( eventR ) { | 1183 | if ( eventR ) { |
1183 | eventRSync = (Event*) eventR->clone(); | 1184 | eventRSync = (Event*) eventR->clone(); |
1184 | remote->deleteEvent(eventR ); | 1185 | remote->deleteEvent(eventR ); |
1185 | 1186 | ||
1186 | } else { | 1187 | } else { |
1187 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1188 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1188 | eventRSync = (Event*)eventLSync->clone(); | 1189 | eventRSync = (Event*)eventLSync->clone(); |
1189 | } else { | 1190 | } else { |
1190 | fullDateRange = true; | 1191 | fullDateRange = true; |
1191 | eventRSync = new Event(); | 1192 | eventRSync = new Event(); |
1192 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1193 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1193 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1194 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1194 | eventRSync->setDtStart( mLastCalendarSync ); | 1195 | eventRSync->setDtStart( mLastCalendarSync ); |
1195 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1196 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1196 | eventRSync->setCategories( i18n("SyncEvent") ); | 1197 | eventRSync->setCategories( i18n("SyncEvent") ); |
1197 | } | 1198 | } |
1198 | } | 1199 | } |
1199 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1200 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1200 | fullDateRange = true; | 1201 | fullDateRange = true; |
1201 | 1202 | ||
1202 | if ( ! fullDateRange ) { | 1203 | if ( ! fullDateRange ) { |
1203 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1204 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1204 | 1205 | ||
1205 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1206 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1206 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1207 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1207 | fullDateRange = true; | 1208 | fullDateRange = true; |
1208 | } | 1209 | } |
1209 | } | 1210 | } |
1210 | if ( mSyncManager->syncWithDesktop() ) { | 1211 | if ( mSyncManager->syncWithDesktop() ) { |
1211 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1212 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1212 | } | 1213 | } |
1213 | if ( fullDateRange ) | 1214 | if ( fullDateRange ) |
1214 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1215 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1215 | else | 1216 | else |
1216 | mLastCalendarSync = eventLSync->dtStart(); | 1217 | mLastCalendarSync = eventLSync->dtStart(); |
1217 | // for resyncing if own file has changed | 1218 | // for resyncing if own file has changed |
1218 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1219 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1219 | mLastCalendarSync = loadedFileVersion; | 1220 | mLastCalendarSync = loadedFileVersion; |
1220 | //qDebug("setting mLastCalendarSync "); | 1221 | //qDebug("setting mLastCalendarSync "); |
1221 | } | 1222 | } |
1222 | //qDebug("*************************** "); | 1223 | //qDebug("*************************** "); |
1223 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1224 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1224 | QPtrList<Incidence> er = remote->rawIncidences(); | 1225 | QPtrList<Incidence> er = remote->rawIncidences(); |
1225 | Incidence* inR = er.first(); | 1226 | Incidence* inR = er.first(); |
1226 | Incidence* inL; | 1227 | Incidence* inL; |
1227 | QProgressBar bar( er.count(),0 ); | 1228 | QProgressBar bar( er.count(),0 ); |
1228 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1229 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1229 | 1230 | ||
1230 | // ************** setting up filter ************* | 1231 | // ************** setting up filter ************* |
1231 | CalFilter *filterIN = 0; | 1232 | CalFilter *filterIN = 0; |
1232 | CalFilter *filterOUT = 0; | 1233 | CalFilter *filterOUT = 0; |
1233 | CalFilter *filter = mFilters.first(); | 1234 | CalFilter *filter = mFilters.first(); |
1234 | while(filter) { | 1235 | while(filter) { |
1235 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1236 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1236 | filterIN = filter; | 1237 | filterIN = filter; |
1237 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1238 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1238 | filterOUT = filter; | 1239 | filterOUT = filter; |
1239 | filter = mFilters.next(); | 1240 | filter = mFilters.next(); |
1240 | } | 1241 | } |
1241 | int w = 300; | 1242 | int w = 300; |
1242 | if ( QApplication::desktop()->width() < 320 ) | 1243 | if ( QApplication::desktop()->width() < 320 ) |
1243 | w = 220; | 1244 | w = 220; |
1244 | int h = bar.sizeHint().height() ; | 1245 | int h = bar.sizeHint().height() ; |
1245 | int dw = QApplication::desktop()->width(); | 1246 | int dw = QApplication::desktop()->width(); |
1246 | int dh = QApplication::desktop()->height(); | 1247 | int dh = QApplication::desktop()->height(); |
1247 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1248 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1248 | bar.show(); | 1249 | bar.show(); |
1249 | int modulo = (er.count()/10)+1; | 1250 | int modulo = (er.count()/10)+1; |
1250 | int incCounter = 0; | 1251 | int incCounter = 0; |
1251 | while ( inR ) { | 1252 | while ( inR ) { |
1252 | if ( ! bar.isVisible() ) | 1253 | if ( ! bar.isVisible() ) |
1253 | return false; | 1254 | return false; |
1254 | if ( incCounter % modulo == 0 ) | 1255 | if ( incCounter % modulo == 0 ) |
1255 | bar.setProgress( incCounter ); | 1256 | bar.setProgress( incCounter ); |
1256 | ++incCounter; | 1257 | ++incCounter; |
1257 | uid = inR->uid(); | 1258 | uid = inR->uid(); |
1258 | bool skipIncidence = false; | 1259 | bool skipIncidence = false; |
1259 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1260 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1260 | skipIncidence = true; | 1261 | skipIncidence = true; |
1261 | QString idS; | 1262 | QString idS; |
1262 | qApp->processEvents(); | 1263 | qApp->processEvents(); |
1263 | if ( !skipIncidence ) { | 1264 | if ( !skipIncidence ) { |
1264 | inL = local->incidence( uid ); | 1265 | inL = local->incidence( uid ); |
1265 | if ( inL ) { // maybe conflict - same uid in both calendars | 1266 | if ( inL ) { // maybe conflict - same uid in both calendars |
1266 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1267 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1267 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1268 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1268 | if ( take == 3 ) | 1269 | if ( take == 3 ) |
1269 | return false; | 1270 | return false; |
1270 | if ( take == 1 ) {// take local ********************** | 1271 | if ( take == 1 ) {// take local ********************** |
1271 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1272 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1272 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1273 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1273 | else | 1274 | else |
1274 | idS = inR->IDStr(); | 1275 | idS = inR->IDStr(); |
1275 | remote->deleteIncidence( inR ); | 1276 | remote->deleteIncidence( inR ); |
1276 | inR = inL->clone(); | 1277 | inR = inL->clone(); |
1277 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1278 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1278 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1279 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1279 | inR->setIDStr( idS ); | 1280 | inR->setIDStr( idS ); |
1280 | remote->addIncidence( inR ); | 1281 | remote->addIncidence( inR ); |
1281 | if ( mSyncManager->syncWithDesktop() ) | 1282 | if ( mSyncManager->syncWithDesktop() ) |
1282 | inR->setPilotId( 2 ); | 1283 | inR->setPilotId( 2 ); |
1283 | ++changedRemote; | 1284 | ++changedRemote; |
1284 | } else {// take remote ********************** | 1285 | } else {// take remote ********************** |
1285 | idS = inL->IDStr(); | 1286 | idS = inL->IDStr(); |
1286 | int pid = inL->pilotId(); | 1287 | int pid = inL->pilotId(); |
1287 | local->deleteIncidence( inL ); | 1288 | local->deleteIncidence( inL ); |
1288 | inL = inR->clone(); | 1289 | inL = inR->clone(); |
1289 | if ( mSyncManager->syncWithDesktop() ) | 1290 | if ( mSyncManager->syncWithDesktop() ) |
1290 | inL->setPilotId( pid ); | 1291 | inL->setPilotId( pid ); |
1291 | inL->setIDStr( idS ); | 1292 | inL->setIDStr( idS ); |
1292 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1293 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1293 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1294 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1294 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1295 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1295 | } | 1296 | } |
1296 | local->addIncidence( inL ); | 1297 | local->addIncidence( inL ); |
1297 | ++changedLocal; | 1298 | ++changedLocal; |
1298 | } | 1299 | } |
1299 | } | 1300 | } |
1300 | } else { // no conflict ********** add or delete remote | 1301 | } else { // no conflict ********** add or delete remote |
1301 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1302 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1302 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1303 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1303 | QString des = eventLSync->description(); | 1304 | QString des = eventLSync->description(); |
1304 | QString pref = "e"; | 1305 | QString pref = "e"; |
1305 | if ( inR->typeID() == todoID ) | 1306 | if ( inR->typeID() == todoID ) |
1306 | pref = "t"; | 1307 | pref = "t"; |
1307 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1308 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1308 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1309 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1309 | //remote->deleteIncidence( inR ); | 1310 | //remote->deleteIncidence( inR ); |
1310 | ++deletedEventR; | 1311 | ++deletedEventR; |
1311 | } else { | 1312 | } else { |
1312 | inR->setLastModified( modifiedCalendar ); | 1313 | inR->setLastModified( modifiedCalendar ); |
1313 | inL = inR->clone(); | 1314 | inL = inR->clone(); |
1314 | inL->setIDStr( ":" ); | 1315 | inL->setIDStr( ":" ); |
1315 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1316 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1316 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1317 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1317 | local->addIncidence( inL ); | 1318 | local->addIncidence( inL ); |
1318 | ++addedEvent; | 1319 | ++addedEvent; |
1319 | 1320 | ||
1320 | } | 1321 | } |
1321 | } else { | 1322 | } else { |
1322 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1323 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1323 | inR->setLastModified( modifiedCalendar ); | 1324 | inR->setLastModified( modifiedCalendar ); |
1324 | inL = inR->clone(); | 1325 | inL = inR->clone(); |
1325 | inL->setIDStr( ":" ); | 1326 | inL->setIDStr( ":" ); |
1326 | local->addIncidence( inL ); | 1327 | local->addIncidence( inL ); |
1327 | ++addedEvent; | 1328 | ++addedEvent; |
1328 | 1329 | ||
1329 | } else { | 1330 | } else { |
1330 | checkExternSyncEvent(eventRSyncSharp, inR); | 1331 | checkExternSyncEvent(eventRSyncSharp, inR); |
1331 | remote->deleteIncidence( inR ); | 1332 | remote->deleteIncidence( inR ); |
1332 | ++deletedEventR; | 1333 | ++deletedEventR; |
1333 | } | 1334 | } |
1334 | } | 1335 | } |
1335 | } else { | 1336 | } else { |
1336 | ++filteredIN; | 1337 | ++filteredIN; |
1337 | } | 1338 | } |
1338 | } | 1339 | } |
1339 | } | 1340 | } |
1340 | inR = er.next(); | 1341 | inR = er.next(); |
1341 | } | 1342 | } |
1342 | QPtrList<Incidence> el = local->rawIncidences(); | 1343 | QPtrList<Incidence> el = local->rawIncidences(); |
1343 | inL = el.first(); | 1344 | inL = el.first(); |
1344 | modulo = (el.count()/10)+1; | 1345 | modulo = (el.count()/10)+1; |
1345 | bar.setCaption (i18n("Add / remove events") ); | 1346 | bar.setCaption (i18n("Add / remove events") ); |
1346 | bar.setTotalSteps ( el.count() ) ; | 1347 | bar.setTotalSteps ( el.count() ) ; |
1347 | bar.show(); | 1348 | bar.show(); |
1348 | incCounter = 0; | 1349 | incCounter = 0; |
1349 | 1350 | ||
1350 | while ( inL ) { | 1351 | while ( inL ) { |
1351 | 1352 | ||
1352 | qApp->processEvents(); | 1353 | qApp->processEvents(); |
1353 | if ( ! bar.isVisible() ) | 1354 | if ( ! bar.isVisible() ) |
1354 | return false; | 1355 | return false; |
1355 | if ( incCounter % modulo == 0 ) | 1356 | if ( incCounter % modulo == 0 ) |
1356 | bar.setProgress( incCounter ); | 1357 | bar.setProgress( incCounter ); |
1357 | ++incCounter; | 1358 | ++incCounter; |
1358 | uid = inL->uid(); | 1359 | uid = inL->uid(); |
1359 | bool skipIncidence = false; | 1360 | bool skipIncidence = false; |
1360 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1361 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1361 | skipIncidence = true; | 1362 | skipIncidence = true; |
1362 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1363 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1363 | skipIncidence = true; | 1364 | skipIncidence = true; |
1364 | if ( !skipIncidence ) { | 1365 | if ( !skipIncidence ) { |
1365 | inR = remote->incidence( uid ); | 1366 | inR = remote->incidence( uid ); |
1366 | if ( ! inR ) { | 1367 | if ( ! inR ) { |
1367 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1368 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1368 | // no conflict ********** add or delete local | 1369 | // no conflict ********** add or delete local |
1369 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1370 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1370 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1371 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1371 | checkExternSyncEvent(eventLSyncSharp, inL); | 1372 | checkExternSyncEvent(eventLSyncSharp, inL); |
1372 | local->deleteIncidence( inL ); | 1373 | local->deleteIncidence( inL ); |
1373 | ++deletedEventL; | 1374 | ++deletedEventL; |
1374 | } else { | 1375 | } else { |
1375 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1376 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1376 | inL->removeID(mCurrentSyncDevice ); | 1377 | inL->removeID(mCurrentSyncDevice ); |
1377 | ++addedEventR; | 1378 | ++addedEventR; |
1378 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1379 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1379 | inL->setLastModified( modifiedCalendar ); | 1380 | inL->setLastModified( modifiedCalendar ); |
1380 | inR = inL->clone(); | 1381 | inR = inL->clone(); |
1381 | inR->setIDStr( ":" ); | 1382 | inR->setIDStr( ":" ); |
1382 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1383 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1383 | remote->addIncidence( inR ); | 1384 | remote->addIncidence( inR ); |
1384 | } | 1385 | } |
1385 | } | 1386 | } |
1386 | } else { | 1387 | } else { |
1387 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1388 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1388 | checkExternSyncEvent(eventLSyncSharp, inL); | 1389 | checkExternSyncEvent(eventLSyncSharp, inL); |
1389 | local->deleteIncidence( inL ); | 1390 | local->deleteIncidence( inL ); |
1390 | ++deletedEventL; | 1391 | ++deletedEventL; |
1391 | } else { | 1392 | } else { |
1392 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1393 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1393 | ++addedEventR; | 1394 | ++addedEventR; |
1394 | inL->setLastModified( modifiedCalendar ); | 1395 | inL->setLastModified( modifiedCalendar ); |
1395 | inR = inL->clone(); | 1396 | inR = inL->clone(); |
1396 | inR->setIDStr( ":" ); | 1397 | inR->setIDStr( ":" ); |
1397 | remote->addIncidence( inR ); | 1398 | remote->addIncidence( inR ); |
1398 | } | 1399 | } |
1399 | } | 1400 | } |
1400 | } | 1401 | } |
1401 | } else { | 1402 | } else { |
1402 | ++filteredOUT; | 1403 | ++filteredOUT; |
1403 | } | 1404 | } |
1404 | } | 1405 | } |
1405 | } | 1406 | } |
1406 | inL = el.next(); | 1407 | inL = el.next(); |
1407 | } | 1408 | } |
1408 | int delFut = 0; | 1409 | int delFut = 0; |
1409 | int remRem = 0; | 1410 | int remRem = 0; |
1410 | if ( mSyncManager->mWriteBackInFuture ) { | 1411 | if ( mSyncManager->mWriteBackInFuture ) { |
1411 | er = remote->rawIncidences(); | 1412 | er = remote->rawIncidences(); |
1412 | remRem = er.count(); | 1413 | remRem = er.count(); |
1413 | inR = er.first(); | 1414 | inR = er.first(); |
1414 | QDateTime dt; | 1415 | QDateTime dt; |
1415 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1416 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1416 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1417 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1417 | while ( inR ) { | 1418 | while ( inR ) { |
1418 | if ( inR->typeID() == todoID ) { | 1419 | if ( inR->typeID() == todoID ) { |
1419 | Todo * t = (Todo*)inR; | 1420 | Todo * t = (Todo*)inR; |
1420 | if ( t->hasDueDate() ) | 1421 | if ( t->hasDueDate() ) |
1421 | dt = t->dtDue(); | 1422 | dt = t->dtDue(); |
1422 | else | 1423 | else |
1423 | dt = cur.addSecs( 62 ); | 1424 | dt = cur.addSecs( 62 ); |
1424 | } | 1425 | } |
1425 | else if (inR->typeID() == eventID ) { | 1426 | else if (inR->typeID() == eventID ) { |
1426 | bool ok; | 1427 | bool ok; |
1427 | dt = inR->getNextOccurence( cur, &ok ); | 1428 | dt = inR->getNextOccurence( cur, &ok ); |
1428 | if ( !ok ) | 1429 | if ( !ok ) |
1429 | dt = cur.addSecs( -62 ); | 1430 | dt = cur.addSecs( -62 ); |
1430 | } | 1431 | } |
1431 | else | 1432 | else |
1432 | dt = inR->dtStart(); | 1433 | dt = inR->dtStart(); |
1433 | if ( dt < cur || dt > end ) { | 1434 | if ( dt < cur || dt > end ) { |
1434 | remote->deleteIncidence( inR ); | 1435 | remote->deleteIncidence( inR ); |
1435 | ++delFut; | 1436 | ++delFut; |
1436 | } | 1437 | } |
1437 | inR = er.next(); | 1438 | inR = er.next(); |
1438 | } | 1439 | } |
1439 | } | 1440 | } |
1440 | bar.hide(); | 1441 | bar.hide(); |
1441 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1442 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1442 | eventLSync->setReadOnly( false ); | 1443 | eventLSync->setReadOnly( false ); |
1443 | eventLSync->setDtStart( mLastCalendarSync ); | 1444 | eventLSync->setDtStart( mLastCalendarSync ); |
1444 | eventRSync->setDtStart( mLastCalendarSync ); | 1445 | eventRSync->setDtStart( mLastCalendarSync ); |
1445 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1446 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1446 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1447 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1447 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1448 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1448 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1449 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1449 | eventLSync->setReadOnly( true ); | 1450 | eventLSync->setReadOnly( true ); |
1450 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1451 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1451 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1452 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1452 | remote->addEvent( eventRSync ); | 1453 | remote->addEvent( eventRSync ); |
1453 | else | 1454 | else |
1454 | delete eventRSync; | 1455 | delete eventRSync; |
1455 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1456 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1456 | QString mes; | 1457 | QString mes; |
1457 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1458 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1458 | QString delmess; | 1459 | QString delmess; |
1459 | if ( delFut ) { | 1460 | if ( delFut ) { |
1460 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1461 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1461 | mes += delmess; | 1462 | mes += delmess; |
1462 | } | 1463 | } |
1463 | mes = i18n("Local calendar changed!\n") +mes; | 1464 | mes = i18n("Local calendar changed!\n") +mes; |
1464 | mCalendar->checkAlarmForIncidence( 0, true ); | 1465 | mCalendar->checkAlarmForIncidence( 0, true ); |
1465 | qDebug( mes ); | 1466 | qDebug( mes ); |
1466 | if ( mSyncManager->mShowSyncSummary ) { | 1467 | if ( mSyncManager->mShowSyncSummary ) { |
1467 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1468 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1468 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1469 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1469 | qDebug("KO: WB cancelled "); | 1470 | qDebug("KO: WB cancelled "); |
1470 | mSyncManager->mWriteBackFile = false; | 1471 | mSyncManager->mWriteBackFile = false; |
1471 | return syncOK; | 1472 | return syncOK; |
1472 | } | 1473 | } |
1473 | } | 1474 | } |
1474 | return syncOK; | 1475 | return syncOK; |
1475 | } | 1476 | } |
1476 | 1477 | ||
1477 | void CalendarView::setSyncDevice( QString s ) | 1478 | void CalendarView::setSyncDevice( QString s ) |
1478 | { | 1479 | { |
1479 | mCurrentSyncDevice= s; | 1480 | mCurrentSyncDevice= s; |
1480 | } | 1481 | } |
1481 | void CalendarView::setSyncName( QString s ) | 1482 | void CalendarView::setSyncName( QString s ) |
1482 | { | 1483 | { |
1483 | mCurrentSyncName= s; | 1484 | mCurrentSyncName= s; |
1484 | } | 1485 | } |
1485 | bool CalendarView::syncCalendar(QString filename, int mode) | 1486 | bool CalendarView::syncCalendar(QString filename, int mode) |
1486 | { | 1487 | { |
1487 | //qDebug("syncCalendar %s ", filename.latin1()); | 1488 | //qDebug("syncCalendar %s ", filename.latin1()); |
1488 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1489 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1489 | CalendarLocal* calendar = new CalendarLocal(); | 1490 | CalendarLocal* calendar = new CalendarLocal(); |
1490 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1491 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1491 | FileStorage* storage = new FileStorage( calendar ); | 1492 | FileStorage* storage = new FileStorage( calendar ); |
1492 | bool syncOK = false; | 1493 | bool syncOK = false; |
1493 | storage->setFileName( filename ); | 1494 | storage->setFileName( filename ); |
1494 | // qDebug("loading ... "); | 1495 | // qDebug("loading ... "); |
1495 | if ( storage->load() ) { | 1496 | if ( storage->load() ) { |
1496 | getEventViewerDialog()->setSyncMode( true ); | 1497 | getEventViewerDialog()->setSyncMode( true ); |
1497 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1498 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1498 | getEventViewerDialog()->setSyncMode( false ); | 1499 | getEventViewerDialog()->setSyncMode( false ); |
1499 | if ( syncOK ) { | 1500 | if ( syncOK ) { |
1500 | if ( mSyncManager->mWriteBackFile ) | 1501 | if ( mSyncManager->mWriteBackFile ) |
1501 | { | 1502 | { |
1502 | storage->setSaveFormat( new ICalFormat() ); | 1503 | storage->setSaveFormat( new ICalFormat() ); |
1503 | storage->save(); | 1504 | storage->save(); |
1504 | } | 1505 | } |
1505 | } | 1506 | } |
1506 | setModified( true ); | 1507 | setModified( true ); |
1507 | } | 1508 | } |
1508 | delete storage; | 1509 | delete storage; |
1509 | delete calendar; | 1510 | delete calendar; |
1510 | if ( syncOK ) | 1511 | if ( syncOK ) |
1511 | updateView(); | 1512 | updateView(); |
1512 | return syncOK; | 1513 | return syncOK; |
1513 | } | 1514 | } |
1514 | 1515 | ||
1515 | void CalendarView::syncExternal( int mode ) | 1516 | void CalendarView::syncExternal( int mode ) |
1516 | { | 1517 | { |
1517 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1518 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1518 | 1519 | ||
1519 | qApp->processEvents(); | 1520 | qApp->processEvents(); |
1520 | CalendarLocal* calendar = new CalendarLocal(); | 1521 | CalendarLocal* calendar = new CalendarLocal(); |
1521 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1522 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1522 | bool syncOK = false; | 1523 | bool syncOK = false; |
1523 | bool loadSuccess = false; | 1524 | bool loadSuccess = false; |
1524 | PhoneFormat* phoneFormat = 0; | 1525 | PhoneFormat* phoneFormat = 0; |
1525 | emit tempDisableBR(true); | 1526 | emit tempDisableBR(true); |
1526 | #ifndef DESKTOP_VERSION | 1527 | #ifndef DESKTOP_VERSION |
1527 | SharpFormat* sharpFormat = 0; | 1528 | SharpFormat* sharpFormat = 0; |
1528 | if ( mode == 0 ) { // sharp | 1529 | if ( mode == 0 ) { // sharp |
1529 | sharpFormat = new SharpFormat () ; | 1530 | sharpFormat = new SharpFormat () ; |
1530 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1531 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1531 | 1532 | ||
1532 | } else | 1533 | } else |
1533 | #endif | 1534 | #endif |
1534 | if ( mode == 1 ) { // phone | 1535 | if ( mode == 1 ) { // phone |
1535 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1536 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1536 | mSyncManager->mPhoneDevice, | 1537 | mSyncManager->mPhoneDevice, |
1537 | mSyncManager->mPhoneConnection, | 1538 | mSyncManager->mPhoneConnection, |
1538 | mSyncManager->mPhoneModel); | 1539 | mSyncManager->mPhoneModel); |
1539 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1540 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1540 | 1541 | ||
1541 | } else { | 1542 | } else { |
1542 | emit tempDisableBR(false); | 1543 | emit tempDisableBR(false); |
1543 | return; | 1544 | return; |
1544 | } | 1545 | } |
1545 | if ( loadSuccess ) { | 1546 | if ( loadSuccess ) { |
1546 | getEventViewerDialog()->setSyncMode( true ); | 1547 | getEventViewerDialog()->setSyncMode( true ); |
1547 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1548 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1548 | getEventViewerDialog()->setSyncMode( false ); | 1549 | getEventViewerDialog()->setSyncMode( false ); |
1549 | qApp->processEvents(); | 1550 | qApp->processEvents(); |
1550 | if ( syncOK ) { | 1551 | if ( syncOK ) { |
1551 | if ( mSyncManager->mWriteBackFile ) | 1552 | if ( mSyncManager->mWriteBackFile ) |
1552 | { | 1553 | { |
1553 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1554 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1554 | Incidence* inc = iL.first(); | 1555 | Incidence* inc = iL.first(); |
1555 | if ( phoneFormat ) { | 1556 | if ( phoneFormat ) { |
1556 | while ( inc ) { | 1557 | while ( inc ) { |
1557 | inc->removeID(mCurrentSyncDevice); | 1558 | inc->removeID(mCurrentSyncDevice); |
1558 | inc = iL.next(); | 1559 | inc = iL.next(); |
1559 | } | 1560 | } |
1560 | } | 1561 | } |
1561 | #ifndef DESKTOP_VERSION | 1562 | #ifndef DESKTOP_VERSION |
1562 | if ( sharpFormat ) | 1563 | if ( sharpFormat ) |
1563 | sharpFormat->save(calendar); | 1564 | sharpFormat->save(calendar); |
1564 | #endif | 1565 | #endif |
1565 | if ( phoneFormat ) | 1566 | if ( phoneFormat ) |
1566 | phoneFormat->save(calendar); | 1567 | phoneFormat->save(calendar); |
1567 | iL = calendar->rawIncidences(); | 1568 | iL = calendar->rawIncidences(); |
1568 | inc = iL.first(); | 1569 | inc = iL.first(); |
1569 | Incidence* loc; | 1570 | Incidence* loc; |
1570 | while ( inc ) { | 1571 | while ( inc ) { |
1571 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1572 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1572 | loc = mCalendar->incidence(inc->uid() ); | 1573 | loc = mCalendar->incidence(inc->uid() ); |
1573 | if ( loc ) { | 1574 | if ( loc ) { |
1574 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1575 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1575 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1576 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1576 | } | 1577 | } |
1577 | } | 1578 | } |
1578 | inc = iL.next(); | 1579 | inc = iL.next(); |
1579 | } | 1580 | } |
1580 | Incidence* lse = getLastSyncEvent(); | 1581 | Incidence* lse = getLastSyncEvent(); |
1581 | if ( lse ) { | 1582 | if ( lse ) { |
1582 | lse->setReadOnly( false ); | 1583 | lse->setReadOnly( false ); |
1583 | lse->setDescription( "" ); | 1584 | lse->setDescription( "" ); |
1584 | lse->setReadOnly( true ); | 1585 | lse->setReadOnly( true ); |
1585 | } | 1586 | } |
1586 | } | 1587 | } |
1587 | } else { | 1588 | } else { |
1588 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1589 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1589 | } | 1590 | } |
1590 | setModified( true ); | 1591 | setModified( true ); |
1591 | } else { | 1592 | } else { |
1592 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1593 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1593 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1594 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1594 | question, i18n("Ok")) ; | 1595 | question, i18n("Ok")) ; |
1595 | 1596 | ||
1596 | } | 1597 | } |
1597 | delete calendar; | 1598 | delete calendar; |
1598 | updateView(); | 1599 | updateView(); |
1599 | emit tempDisableBR(false); | 1600 | emit tempDisableBR(false); |
1600 | return ;//syncOK; | 1601 | return ;//syncOK; |
1601 | 1602 | ||
1602 | } | 1603 | } |
1603 | 1604 | ||
1604 | bool CalendarView::importBday() | 1605 | bool CalendarView::importBday() |
1605 | { | 1606 | { |
1606 | #ifndef KORG_NOKABC | 1607 | #ifndef KORG_NOKABC |
1607 | 1608 | ||
1608 | #ifdef DESKTOP_VERSION | 1609 | #ifdef DESKTOP_VERSION |
1609 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1610 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1610 | KABC::AddressBook::Iterator it; | 1611 | KABC::AddressBook::Iterator it; |
1611 | int count = 0; | 1612 | int count = 0; |
1612 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1613 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1613 | ++count; | 1614 | ++count; |
1614 | } | 1615 | } |
1615 | QProgressBar bar(count,0 ); | 1616 | QProgressBar bar(count,0 ); |
1616 | int w = 300; | 1617 | int w = 300; |
1617 | if ( QApplication::desktop()->width() < 320 ) | 1618 | if ( QApplication::desktop()->width() < 320 ) |
1618 | w = 220; | 1619 | w = 220; |
1619 | int h = bar.sizeHint().height() ; | 1620 | int h = bar.sizeHint().height() ; |
1620 | int dw = QApplication::desktop()->width(); | 1621 | int dw = QApplication::desktop()->width(); |
1621 | int dh = QApplication::desktop()->height(); | 1622 | int dh = QApplication::desktop()->height(); |
1622 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1623 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1623 | bar.show(); | 1624 | bar.show(); |
1624 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1625 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1625 | qApp->processEvents(); | 1626 | qApp->processEvents(); |
1626 | count = 0; | 1627 | count = 0; |
1627 | int addCount = 0; | 1628 | int addCount = 0; |
1628 | KCal::Attendee* a = 0; | 1629 | KCal::Attendee* a = 0; |
1629 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1630 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1630 | if ( ! bar.isVisible() ) | 1631 | if ( ! bar.isVisible() ) |
1631 | return false; | 1632 | return false; |
1632 | bar.setProgress( count++ ); | 1633 | bar.setProgress( count++ ); |
1633 | qApp->processEvents(); | 1634 | qApp->processEvents(); |
1634 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1635 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1635 | if ( (*it).birthday().date().isValid() ){ | 1636 | if ( (*it).birthday().date().isValid() ){ |
1636 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1637 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1637 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1638 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1638 | ++addCount; | 1639 | ++addCount; |
1639 | } | 1640 | } |
1640 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1641 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1641 | if ( anni.isValid() ){ | 1642 | if ( anni.isValid() ){ |
1642 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1643 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1643 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1644 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1644 | ++addCount; | 1645 | ++addCount; |
1645 | } | 1646 | } |
1646 | } | 1647 | } |
1647 | updateView(); | 1648 | updateView(); |
1648 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1649 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1649 | #else //DESKTOP_VERSION | 1650 | #else //DESKTOP_VERSION |
1650 | 1651 | ||
1651 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1652 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1652 | // the result should now arrive through method insertBirthdays | 1653 | // the result should now arrive through method insertBirthdays |
1653 | 1654 | ||
1654 | #endif //DESKTOP_VERSION | 1655 | #endif //DESKTOP_VERSION |
1655 | 1656 | ||
1656 | #endif //KORG_NOKABC | 1657 | #endif //KORG_NOKABC |
1657 | 1658 | ||
1658 | 1659 | ||
1659 | return true; | 1660 | return true; |
1660 | } | 1661 | } |
1661 | 1662 | ||
1662 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1663 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1663 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1664 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1664 | const QStringList& anniversaryList, const QStringList& realNameList, | 1665 | const QStringList& anniversaryList, const QStringList& realNameList, |
1665 | const QStringList& emailList, const QStringList& assembledNameList, | 1666 | const QStringList& emailList, const QStringList& assembledNameList, |
1666 | const QStringList& uidList) | 1667 | const QStringList& uidList) |
1667 | { | 1668 | { |
1668 | //qDebug("KO::CalendarView::insertBirthdays"); | 1669 | //qDebug("KO::CalendarView::insertBirthdays"); |
1669 | if (uid == this->name()) | 1670 | if (uid == this->name()) |
1670 | { | 1671 | { |
1671 | int count = birthdayList.count(); | 1672 | int count = birthdayList.count(); |
1672 | int addCount = 0; | 1673 | int addCount = 0; |
1673 | KCal::Attendee* a = 0; | 1674 | KCal::Attendee* a = 0; |
1674 | 1675 | ||
1675 | //qDebug("CalView 1 %i", count); | 1676 | //qDebug("CalView 1 %i", count); |
1676 | 1677 | ||
1677 | QProgressBar bar(count,0 ); | 1678 | QProgressBar bar(count,0 ); |
1678 | int w = 300; | 1679 | int w = 300; |
1679 | if ( QApplication::desktop()->width() < 320 ) | 1680 | if ( QApplication::desktop()->width() < 320 ) |
1680 | w = 220; | 1681 | w = 220; |
1681 | int h = bar.sizeHint().height() ; | 1682 | int h = bar.sizeHint().height() ; |
1682 | int dw = QApplication::desktop()->width(); | 1683 | int dw = QApplication::desktop()->width(); |
1683 | int dh = QApplication::desktop()->height(); | 1684 | int dh = QApplication::desktop()->height(); |
1684 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1685 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1685 | bar.show(); | 1686 | bar.show(); |
1686 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1687 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1687 | qApp->processEvents(); | 1688 | qApp->processEvents(); |
1688 | 1689 | ||
1689 | QDate birthday; | 1690 | QDate birthday; |
1690 | QDate anniversary; | 1691 | QDate anniversary; |
1691 | QString realName; | 1692 | QString realName; |
1692 | QString email; | 1693 | QString email; |
1693 | QString assembledName; | 1694 | QString assembledName; |
1694 | QString uid; | 1695 | QString uid; |
1695 | bool ok = true; | 1696 | bool ok = true; |
1696 | for ( int i = 0; i < count; i++) | 1697 | for ( int i = 0; i < count; i++) |
1697 | { | 1698 | { |
1698 | if ( ! bar.isVisible() ) | 1699 | if ( ! bar.isVisible() ) |
1699 | return; | 1700 | return; |
1700 | bar.setProgress( i ); | 1701 | bar.setProgress( i ); |
1701 | qApp->processEvents(); | 1702 | qApp->processEvents(); |
1702 | 1703 | ||
1703 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1704 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1704 | if (!ok) { | 1705 | if (!ok) { |
1705 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1706 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1706 | } | 1707 | } |
1707 | 1708 | ||
1708 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1709 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1709 | if (!ok) { | 1710 | if (!ok) { |
1710 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1711 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1711 | } | 1712 | } |
1712 | realName = realNameList[i]; | 1713 | realName = realNameList[i]; |
1713 | email = emailList[i]; | 1714 | email = emailList[i]; |
1714 | assembledName = assembledNameList[i]; | 1715 | assembledName = assembledNameList[i]; |
1715 | uid = uidList[i]; | 1716 | uid = uidList[i]; |
1716 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1717 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1717 | 1718 | ||
1718 | if ( birthday.isValid() ){ | 1719 | if ( birthday.isValid() ){ |
1719 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1720 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1720 | KCal::Attendee::ReqParticipant,uid) ; | 1721 | KCal::Attendee::ReqParticipant,uid) ; |
1721 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1722 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1722 | ++addCount; | 1723 | ++addCount; |
1723 | } | 1724 | } |
1724 | 1725 | ||
1725 | if ( anniversary.isValid() ){ | 1726 | if ( anniversary.isValid() ){ |
1726 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1727 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1727 | KCal::Attendee::ReqParticipant,uid) ; | 1728 | KCal::Attendee::ReqParticipant,uid) ; |
1728 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1729 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1729 | ++addCount; | 1730 | ++addCount; |
1730 | } | 1731 | } |
1731 | } | 1732 | } |
1732 | 1733 | ||
1733 | updateView(); | 1734 | updateView(); |
1734 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1735 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1735 | 1736 | ||
1736 | } | 1737 | } |
1737 | 1738 | ||
1738 | } | 1739 | } |
1739 | 1740 | ||
1740 | 1741 | ||
1741 | 1742 | ||
1742 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1743 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1743 | { | 1744 | { |
1744 | //qDebug("addAnni "); | 1745 | //qDebug("addAnni "); |
1745 | Event * ev = new Event(); | 1746 | Event * ev = new Event(); |
1746 | ev->setOrganizer(KOPrefs::instance()->email()); | 1747 | ev->setOrganizer(KOPrefs::instance()->email()); |
1747 | if ( a ) { | 1748 | if ( a ) { |
1748 | ev->addAttendee( a ); | 1749 | ev->addAttendee( a ); |
1749 | } | 1750 | } |
1750 | QString kind; | 1751 | QString kind; |
1751 | if ( birthday ) { | 1752 | if ( birthday ) { |
1752 | kind = i18n( "Birthday" ); | 1753 | kind = i18n( "Birthday" ); |
1753 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1754 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1754 | } | 1755 | } |
1755 | else { | 1756 | else { |
1756 | kind = i18n( "Anniversary" ); | 1757 | kind = i18n( "Anniversary" ); |
1757 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1758 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1758 | } | 1759 | } |
1759 | ev->setCategories( kind ); | 1760 | ev->setCategories( kind ); |
1760 | ev->setDtStart( QDateTime(date) ); | 1761 | ev->setDtStart( QDateTime(date) ); |
1761 | ev->setDtEnd( QDateTime(date) ); | 1762 | ev->setDtEnd( QDateTime(date) ); |
1762 | ev->setFloats( true ); | 1763 | ev->setFloats( true ); |
1763 | Recurrence * rec = ev->recurrence(); | 1764 | Recurrence * rec = ev->recurrence(); |
1764 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1765 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1765 | rec->addYearlyNum( date.month() ); | 1766 | rec->addYearlyNum( date.month() ); |
1766 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1767 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1767 | delete ev; | 1768 | delete ev; |
1768 | return false; | 1769 | return false; |
1769 | } | 1770 | } |
1770 | return true; | 1771 | return true; |
1771 | 1772 | ||
1772 | } | 1773 | } |
1773 | bool CalendarView::importQtopia( const QString &categories, | 1774 | bool CalendarView::importQtopia( const QString &categories, |
1774 | const QString &datebook, | 1775 | const QString &datebook, |
1775 | const QString &todolist ) | 1776 | const QString &todolist ) |
1776 | { | 1777 | { |
1777 | 1778 | ||
1778 | QtopiaFormat qtopiaFormat; | 1779 | QtopiaFormat qtopiaFormat; |
1779 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1780 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1780 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1781 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1781 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1782 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1782 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1783 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1783 | 1784 | ||
1784 | updateView(); | 1785 | updateView(); |
1785 | return true; | 1786 | return true; |
1786 | 1787 | ||
1787 | #if 0 | 1788 | #if 0 |
1788 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1789 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1789 | mCurrentSyncDevice = "qtopia-XML"; | 1790 | mCurrentSyncDevice = "qtopia-XML"; |
1790 | if ( mSyncManager->mAskForPreferences ) | 1791 | if ( mSyncManager->mAskForPreferences ) |
1791 | edit_sync_options(); | 1792 | edit_sync_options(); |
1792 | qApp->processEvents(); | 1793 | qApp->processEvents(); |
1793 | CalendarLocal* calendar = new CalendarLocal(); | 1794 | CalendarLocal* calendar = new CalendarLocal(); |
1794 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1795 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1795 | bool syncOK = false; | 1796 | bool syncOK = false; |
1796 | QtopiaFormat qtopiaFormat; | 1797 | QtopiaFormat qtopiaFormat; |
1797 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1798 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1798 | bool loadOk = true; | 1799 | bool loadOk = true; |
1799 | if ( !categories.isEmpty() ) | 1800 | if ( !categories.isEmpty() ) |
1800 | loadOk = qtopiaFormat.load( calendar, categories ); | 1801 | loadOk = qtopiaFormat.load( calendar, categories ); |
1801 | if ( loadOk && !datebook.isEmpty() ) | 1802 | if ( loadOk && !datebook.isEmpty() ) |
1802 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1803 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1803 | if ( loadOk && !todolist.isEmpty() ) | 1804 | if ( loadOk && !todolist.isEmpty() ) |
1804 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1805 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1805 | 1806 | ||
1806 | if ( loadOk ) { | 1807 | if ( loadOk ) { |
1807 | getEventViewerDialog()->setSyncMode( true ); | 1808 | getEventViewerDialog()->setSyncMode( true ); |
1808 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1809 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1809 | getEventViewerDialog()->setSyncMode( false ); | 1810 | getEventViewerDialog()->setSyncMode( false ); |
1810 | qApp->processEvents(); | 1811 | qApp->processEvents(); |
1811 | if ( syncOK ) { | 1812 | if ( syncOK ) { |
1812 | if ( mSyncManager->mWriteBackFile ) | 1813 | if ( mSyncManager->mWriteBackFile ) |
1813 | { | 1814 | { |
1814 | // write back XML file | 1815 | // write back XML file |
1815 | 1816 | ||
1816 | } | 1817 | } |
1817 | setModified( true ); | 1818 | setModified( true ); |
1818 | } | 1819 | } |
1819 | } else { | 1820 | } else { |
1820 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1821 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1821 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1822 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1822 | question, i18n("Ok")) ; | 1823 | question, i18n("Ok")) ; |
1823 | } | 1824 | } |
1824 | delete calendar; | 1825 | delete calendar; |
1825 | updateView(); | 1826 | updateView(); |
1826 | return syncOK; | 1827 | return syncOK; |
1827 | 1828 | ||
1828 | 1829 | ||
1829 | #endif | 1830 | #endif |
1830 | 1831 | ||
1831 | } | 1832 | } |
1832 | 1833 | ||
1833 | void CalendarView::setSyncEventsReadOnly() | 1834 | void CalendarView::setSyncEventsReadOnly() |
1834 | { | 1835 | { |
1835 | Event * ev; | 1836 | Event * ev; |
1836 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1837 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1837 | ev = eL.first(); | 1838 | ev = eL.first(); |
1838 | while ( ev ) { | 1839 | while ( ev ) { |
1839 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1840 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1840 | ev->setReadOnly( true ); | 1841 | ev->setReadOnly( true ); |
1841 | ev = eL.next(); | 1842 | ev = eL.next(); |
1842 | } | 1843 | } |
1843 | } | 1844 | } |
1844 | 1845 | ||
1845 | bool CalendarView::loadCalendars() | 1846 | bool CalendarView::loadCalendars() |
1846 | { | 1847 | { |
1847 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1848 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1848 | KopiCalendarFile * cal = calendars.first(); | 1849 | KopiCalendarFile * cal = calendars.first(); |
1849 | mCalendar->setDefaultCalendar( 1 ); | 1850 | mCalendar->setDefaultCalendar( 1 ); |
1850 | openCalendar( MainWindow::defaultFileName(), false ); | 1851 | openCalendar( MainWindow::defaultFileName(), false ); |
1851 | cal = calendars.next(); | 1852 | cal = calendars.next(); |
1852 | while ( cal ) { | 1853 | while ( cal ) { |
1853 | addCalendar( cal ); | 1854 | addCalendar( cal ); |
1854 | cal = calendars.next(); | 1855 | cal = calendars.next(); |
1855 | } | 1856 | } |
1856 | restoreCalendarSettings(); | 1857 | restoreCalendarSettings(); |
1857 | mCalendar->reInitAlarmSettings(); | 1858 | mCalendar->reInitAlarmSettings(); |
1858 | setSyncEventsReadOnly(); | 1859 | setSyncEventsReadOnly(); |
1859 | updateUnmanagedViews(); | 1860 | updateUnmanagedViews(); |
1860 | updateView(); | 1861 | updateView(); |
1861 | return true; | 1862 | return true; |
1862 | } | 1863 | } |
1863 | bool CalendarView::restoreCalendarSettings() | 1864 | bool CalendarView::restoreCalendarSettings() |
1864 | { | 1865 | { |
1865 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1866 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1866 | KopiCalendarFile * cal = calendars.first(); | 1867 | KopiCalendarFile * cal = calendars.first(); |
1867 | while ( cal ) { | 1868 | while ( cal ) { |
1868 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 1869 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
1869 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 1870 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
1870 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 1871 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
1871 | if ( cal->isStandard ) | 1872 | if ( cal->isStandard ) |
1872 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 1873 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
1873 | cal = calendars.next(); | 1874 | cal = calendars.next(); |
1874 | } | 1875 | } |
1875 | return true; | 1876 | return true; |
1876 | } | 1877 | } |
1877 | void CalendarView::addCalendarId( int id ) | 1878 | void CalendarView::addCalendarId( int id ) |
1878 | { | 1879 | { |
1879 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 1880 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
1880 | addCalendar( cal ); | 1881 | addCalendar( cal ); |
1881 | } | 1882 | } |
1882 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 1883 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
1883 | { | 1884 | { |
1884 | cal->mErrorOnLoad = false; | 1885 | cal->mErrorOnLoad = false; |
1885 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 1886 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
1886 | cal->mLoadDt = QDateTime::currentDateTime(); | 1887 | cal->mLoadDt = QDateTime::currentDateTime(); |
1887 | return true; | 1888 | return true; |
1888 | } | 1889 | } |
1889 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); | 1890 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); |
1890 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); | 1891 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); |
1891 | cal->mErrorOnLoad = true; | 1892 | cal->mErrorOnLoad = true; |
1892 | return false; | 1893 | return false; |
1893 | } | 1894 | } |
1894 | bool CalendarView::openCalendar(QString filename, bool merge) | 1895 | bool CalendarView::openCalendar(QString filename, bool merge) |
1895 | { | 1896 | { |
1896 | 1897 | ||
1897 | if (filename.isEmpty()) { | 1898 | if (filename.isEmpty()) { |
1898 | return false; | 1899 | return false; |
1899 | } | 1900 | } |
1900 | 1901 | ||
1901 | if (!QFile::exists(filename)) { | 1902 | if (!QFile::exists(filename)) { |
1902 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1903 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1903 | return false; | 1904 | return false; |
1904 | } | 1905 | } |
1905 | 1906 | ||
1906 | globalFlagBlockAgenda = 1; | 1907 | globalFlagBlockAgenda = 1; |
1907 | clearAllViews(); | 1908 | clearAllViews(); |
1908 | if (!merge) { | 1909 | if (!merge) { |
1909 | mViewManager->setDocumentId( filename ); | 1910 | mViewManager->setDocumentId( filename ); |
1910 | mCalendar->close(); | 1911 | mCalendar->close(); |
1911 | } | 1912 | } |
1912 | mStorage->setFileName( filename ); | 1913 | mStorage->setFileName( filename ); |
1913 | 1914 | ||
1914 | if ( mStorage->load() ) { | 1915 | if ( mStorage->load() ) { |
1915 | if ( merge ) ;//setModified( true ); | 1916 | if ( merge ) ;//setModified( true ); |
1916 | else { | 1917 | else { |
1917 | //setModified( true ); | 1918 | //setModified( true ); |
1918 | mViewManager->setDocumentId( filename ); | 1919 | mViewManager->setDocumentId( filename ); |
1919 | mDialogManager->setDocumentId( filename ); | 1920 | mDialogManager->setDocumentId( filename ); |
1920 | mTodoList->setDocumentId( filename ); | 1921 | mTodoList->setDocumentId( filename ); |
1921 | } | 1922 | } |
1922 | globalFlagBlockAgenda = 2; | 1923 | globalFlagBlockAgenda = 2; |
1923 | // if ( getLastSyncEvent() ) | 1924 | // if ( getLastSyncEvent() ) |
1924 | // getLastSyncEvent()->setReadOnly( true ); | 1925 | // getLastSyncEvent()->setReadOnly( true ); |
1925 | mCalendar->reInitAlarmSettings(); | 1926 | mCalendar->reInitAlarmSettings(); |
1926 | setSyncEventsReadOnly(); | 1927 | setSyncEventsReadOnly(); |
1927 | updateUnmanagedViews(); | 1928 | updateUnmanagedViews(); |
1928 | updateView(); | 1929 | updateView(); |
1929 | if ( filename != MainWindow::defaultFileName() ) { | 1930 | if ( filename != MainWindow::defaultFileName() ) { |
1930 | saveCalendar( MainWindow::defaultFileName() ); | 1931 | saveCalendar( MainWindow::defaultFileName() ); |
1931 | } else { | 1932 | } else { |
1932 | QFileInfo finf ( MainWindow::defaultFileName()); | 1933 | QFileInfo finf ( MainWindow::defaultFileName()); |
1933 | if ( finf.exists() ) { | 1934 | if ( finf.exists() ) { |
1934 | setLoadedFileVersion( finf.lastModified () ); | 1935 | setLoadedFileVersion( finf.lastModified () ); |
1935 | } | 1936 | } |
1936 | } | 1937 | } |
1937 | return true; | 1938 | return true; |
1938 | } else { | 1939 | } else { |
1939 | // while failing to load, the calendar object could | 1940 | // while failing to load, the calendar object could |
1940 | // have become partially populated. Clear it out. | 1941 | // have become partially populated. Clear it out. |
1941 | if ( !merge ) { | 1942 | if ( !merge ) { |
1942 | mCalendar->close(); | 1943 | mCalendar->close(); |
1943 | mViewManager->setDocumentId( filename ); | 1944 | mViewManager->setDocumentId( filename ); |
1944 | mDialogManager->setDocumentId( filename ); | 1945 | mDialogManager->setDocumentId( filename ); |
1945 | mTodoList->setDocumentId( filename ); | 1946 | mTodoList->setDocumentId( filename ); |
1946 | } | 1947 | } |
1947 | 1948 | ||
1948 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1949 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1949 | 1950 | ||
1950 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1951 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1951 | globalFlagBlockAgenda = 2; | 1952 | globalFlagBlockAgenda = 2; |
1952 | mCalendar->reInitAlarmSettings(); | 1953 | mCalendar->reInitAlarmSettings(); |
1953 | setSyncEventsReadOnly(); | 1954 | setSyncEventsReadOnly(); |
1954 | updateUnmanagedViews(); | 1955 | updateUnmanagedViews(); |
1955 | updateView(); | 1956 | updateView(); |
1956 | } | 1957 | } |
1957 | return false; | 1958 | return false; |
1958 | } | 1959 | } |
1959 | void CalendarView::showOpenError() | 1960 | void CalendarView::showOpenError() |
1960 | { | 1961 | { |
1961 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1962 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1962 | } | 1963 | } |
1963 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1964 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1964 | { | 1965 | { |
1965 | loadedFileVersion = dt; | 1966 | loadedFileVersion = dt; |
1966 | } | 1967 | } |
1967 | bool CalendarView::checkFileChanged(QString fn) | 1968 | bool CalendarView::checkFileChanged(QString fn) |
1968 | { | 1969 | { |
1969 | QFileInfo finf ( fn ); | 1970 | QFileInfo finf ( fn ); |
1970 | if ( !finf.exists() ) | 1971 | if ( !finf.exists() ) |
1971 | return true; | 1972 | return true; |
1972 | QDateTime dt = finf.lastModified (); | 1973 | QDateTime dt = finf.lastModified (); |
1973 | if ( dt <= loadedFileVersion ) | 1974 | if ( dt <= loadedFileVersion ) |
1974 | return false; | 1975 | return false; |
1975 | return true; | 1976 | return true; |
1976 | 1977 | ||
1977 | } | 1978 | } |
1978 | void CalendarView::watchSavedFile() | 1979 | void CalendarView::watchSavedFile() |
1979 | { | 1980 | { |
1980 | QFileInfo finf ( MainWindow::defaultFileName()); | 1981 | QFileInfo finf ( MainWindow::defaultFileName()); |
1981 | if ( !finf.exists() ) | 1982 | if ( !finf.exists() ) |
1982 | return; | 1983 | return; |
1983 | QDateTime dt = finf.lastModified (); | 1984 | QDateTime dt = finf.lastModified (); |
1984 | if ( dt < loadedFileVersion ) { | 1985 | if ( dt < loadedFileVersion ) { |
1985 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1986 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1986 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1987 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1987 | return; | 1988 | return; |
1988 | } | 1989 | } |
1989 | loadedFileVersion = dt; | 1990 | loadedFileVersion = dt; |
1990 | } | 1991 | } |
1991 | bool CalendarView::checkAllFileVersions() | 1992 | bool CalendarView::checkAllFileVersions() |
1992 | { | 1993 | { |
1993 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1994 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1994 | KopiCalendarFile * cal = calendars.first(); | 1995 | KopiCalendarFile * cal = calendars.first(); |
1995 | mCalendar->setDefaultCalendar( 1 ); | 1996 | mCalendar->setDefaultCalendar( 1 ); |
1996 | mCalendar->setDefaultCalendarEnabledOnly(); | 1997 | mCalendar->setDefaultCalendarEnabledOnly(); |
1997 | if ( !checkFileVersion(MainWindow::defaultFileName())) | 1998 | if ( !checkFileVersion(MainWindow::defaultFileName())) |
1998 | return false; | 1999 | return false; |
1999 | cal = calendars.next(); | 2000 | cal = calendars.next(); |
2000 | QDateTime storeTemp = loadedFileVersion; | 2001 | QDateTime storeTemp = loadedFileVersion; |
2001 | while ( cal ) { | 2002 | while ( cal ) { |
2002 | if ( !cal->mErrorOnLoad ) { | 2003 | if ( !cal->mErrorOnLoad ) { |
2003 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2004 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2004 | mCalendar->setDefaultCalendarEnabledOnly(); | 2005 | mCalendar->setDefaultCalendarEnabledOnly(); |
2005 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2006 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2006 | if ( !checkFileVersion(cal->mFileName )) { | 2007 | if ( !checkFileVersion(cal->mFileName )) { |
2007 | loadedFileVersion = storeTemp; | 2008 | loadedFileVersion = storeTemp; |
2008 | updateView(); | 2009 | updateView(); |
2009 | return false; | 2010 | return false; |
2010 | } | 2011 | } |
2011 | } | 2012 | } |
2012 | cal = calendars.next(); | 2013 | cal = calendars.next(); |
2013 | } | 2014 | } |
2014 | loadedFileVersion = storeTemp; | 2015 | loadedFileVersion = storeTemp; |
2015 | updateView(); | 2016 | updateView(); |
2016 | return true; | 2017 | return true; |
2017 | } | 2018 | } |
2018 | bool CalendarView::checkFileVersion(QString fn) | 2019 | bool CalendarView::checkFileVersion(QString fn) |
2019 | { | 2020 | { |
2020 | QFileInfo finf ( fn ); | 2021 | QFileInfo finf ( fn ); |
2021 | if ( !finf.exists() ) | 2022 | if ( !finf.exists() ) |
2022 | return true; | 2023 | return true; |
2023 | QDateTime dt = finf.lastModified (); | 2024 | QDateTime dt = finf.lastModified (); |
2024 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 2025 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
2025 | //qDebug("file on disk version %s",dt.toString().latin1()); | 2026 | //qDebug("file on disk version %s",dt.toString().latin1()); |
2026 | if ( dt <= loadedFileVersion ) | 2027 | if ( dt <= loadedFileVersion ) |
2027 | return true; | 2028 | return true; |
2028 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2029 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2029 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2030 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2030 | i18n("Sync+save")); | 2031 | i18n("Sync+save")); |
2031 | 2032 | ||
2032 | if ( km == KMessageBox::Cancel ) | 2033 | if ( km == KMessageBox::Cancel ) |
2033 | return false; | 2034 | return false; |
2034 | if ( km == KMessageBox::Yes ) | 2035 | if ( km == KMessageBox::Yes ) |
2035 | return true; | 2036 | return true; |
2036 | 2037 | ||
2037 | setSyncDevice("deleteaftersync" ); | 2038 | setSyncDevice("deleteaftersync" ); |
2038 | mSyncManager->mAskForPreferences = true; | 2039 | mSyncManager->mAskForPreferences = true; |
2039 | mSyncManager->mSyncAlgoPrefs = 3; | 2040 | mSyncManager->mSyncAlgoPrefs = 3; |
2040 | mSyncManager->mWriteBackFile = false; | 2041 | mSyncManager->mWriteBackFile = false; |
2041 | mSyncManager->mWriteBackExistingOnly = false; | 2042 | mSyncManager->mWriteBackExistingOnly = false; |
2042 | mSyncManager->mShowSyncSummary = false; | 2043 | mSyncManager->mShowSyncSummary = false; |
2043 | syncCalendar( fn, 3 ); | 2044 | syncCalendar( fn, 3 ); |
2044 | Event * e = getLastSyncEvent(); | 2045 | Event * e = getLastSyncEvent(); |
2045 | if ( e ) | 2046 | if ( e ) |
2046 | mCalendar->deleteEvent( e ); | 2047 | mCalendar->deleteEvent( e ); |
2047 | return true; | 2048 | return true; |
2048 | } | 2049 | } |
2049 | bool CalendarView::saveCalendars() | 2050 | bool CalendarView::saveCalendars() |
2050 | { | 2051 | { |
2051 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2052 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2052 | KopiCalendarFile * cal = calendars.first(); | 2053 | KopiCalendarFile * cal = calendars.first(); |
2053 | mCalendar->setDefaultCalendar( 1 ); | 2054 | mCalendar->setDefaultCalendar( 1 ); |
2054 | mCalendar->setDefaultCalendarEnabledOnly(); | 2055 | mCalendar->setDefaultCalendarEnabledOnly(); |
2055 | saveCalendar( MainWindow::defaultFileName() ); | 2056 | saveCalendar( MainWindow::defaultFileName() ); |
2056 | cal = calendars.next(); | 2057 | cal = calendars.next(); |
2057 | while ( cal ) { | 2058 | while ( cal ) { |
2058 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2059 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2059 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2060 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2060 | mCalendar->setDefaultCalendarEnabledOnly(); | 2061 | mCalendar->setDefaultCalendarEnabledOnly(); |
2061 | if ( saveCalendar( cal->mFileName ) ) | 2062 | if ( saveCalendar( cal->mFileName ) ) |
2062 | cal->mLoadDt = QDateTime::currentDateTime(); | 2063 | cal->mLoadDt = QDateTime::currentDateTime(); |
2063 | } | 2064 | } |
2064 | cal = calendars.next(); | 2065 | cal = calendars.next(); |
2065 | } | 2066 | } |
2066 | restoreCalendarSettings(); | 2067 | restoreCalendarSettings(); |
2067 | return true; | 2068 | return true; |
2068 | } | 2069 | } |
2069 | bool CalendarView::saveCalendar( QString filename ) | 2070 | bool CalendarView::saveCalendar( QString filename ) |
2070 | { | 2071 | { |
2071 | 2072 | ||
2072 | // Store back all unsaved data into calendar object | 2073 | // Store back all unsaved data into calendar object |
2073 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2074 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2074 | if ( mViewManager->currentView() ) | 2075 | if ( mViewManager->currentView() ) |
2075 | mViewManager->currentView()->flushView(); | 2076 | mViewManager->currentView()->flushView(); |
2076 | 2077 | ||
2077 | 2078 | ||
2078 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2079 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2079 | mStorage->setSaveFormat( new ICalFormat() ); | 2080 | mStorage->setSaveFormat( new ICalFormat() ); |
2080 | mStorage->setFileName( filename ); | 2081 | mStorage->setFileName( filename ); |
2081 | bool success; | 2082 | bool success; |
2082 | success = mStorage->save(); | 2083 | success = mStorage->save(); |
2083 | if ( !success ) { | 2084 | if ( !success ) { |
2084 | return false; | 2085 | return false; |
2085 | } | 2086 | } |
2086 | if ( filename == MainWindow::defaultFileName() ) { | 2087 | if ( filename == MainWindow::defaultFileName() ) { |
2087 | setLoadedFileVersion( lfv ); | 2088 | setLoadedFileVersion( lfv ); |
2088 | watchSavedFile(); | 2089 | watchSavedFile(); |
2089 | } | 2090 | } |
2090 | return true; | 2091 | return true; |
2091 | } | 2092 | } |
2092 | 2093 | ||
2093 | void CalendarView::closeCalendar() | 2094 | void CalendarView::closeCalendar() |
2094 | { | 2095 | { |
2095 | 2096 | ||
2096 | // child windows no longer valid | 2097 | // child windows no longer valid |
2097 | clearAllViews(); | 2098 | clearAllViews(); |
2098 | emit closingDown(); | 2099 | emit closingDown(); |
2099 | 2100 | ||
2100 | mCalendar->close(); | 2101 | mCalendar->close(); |
2101 | setModified(false); | 2102 | setModified(false); |
2102 | updateView(); | 2103 | updateView(); |
2103 | } | 2104 | } |
2104 | 2105 | ||
2105 | void CalendarView::archiveCalendar() | 2106 | void CalendarView::archiveCalendar() |
2106 | { | 2107 | { |
2107 | mDialogManager->showArchiveDialog(); | 2108 | mDialogManager->showArchiveDialog(); |
2108 | } | 2109 | } |
2109 | 2110 | ||
2110 | 2111 | ||
2111 | void CalendarView::readSettings() | 2112 | void CalendarView::readSettings() |
2112 | { | 2113 | { |
2113 | 2114 | ||
2114 | 2115 | ||
2115 | // mViewManager->showAgendaView(); | 2116 | // mViewManager->showAgendaView(); |
2116 | QString str; | 2117 | QString str; |
2117 | //qDebug("CalendarView::readSettings() "); | 2118 | //qDebug("CalendarView::readSettings() "); |
2118 | // read settings from the KConfig, supplying reasonable | 2119 | // read settings from the KConfig, supplying reasonable |
2119 | // defaults where none are to be found | 2120 | // defaults where none are to be found |
2120 | KConfig *config = KOGlobals::config(); | 2121 | KConfig *config = KOGlobals::config(); |
2121 | #ifndef KORG_NOSPLITTER | 2122 | #ifndef KORG_NOSPLITTER |
2122 | config->setGroup("KOrganizer Geometry"); | 2123 | config->setGroup("KOrganizer Geometry"); |
2123 | 2124 | ||
2124 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2125 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2125 | if (sizes.count() != 2) { | 2126 | if (sizes.count() != 2) { |
2126 | sizes << mDateNavigator->minimumSizeHint().width(); | 2127 | sizes << mDateNavigator->minimumSizeHint().width(); |
2127 | sizes << 300; | 2128 | sizes << 300; |
2128 | } | 2129 | } |
2129 | mPanner->setSizes(sizes); | 2130 | mPanner->setSizes(sizes); |
2130 | 2131 | ||
2131 | sizes = config->readIntListEntry("Separator2"); | 2132 | sizes = config->readIntListEntry("Separator2"); |
2132 | if ( ( mResourceView && sizes.count() == 4 ) || | 2133 | if ( ( mResourceView && sizes.count() == 4 ) || |
2133 | ( !mResourceView && sizes.count() == 3 ) ) { | 2134 | ( !mResourceView && sizes.count() == 3 ) ) { |
2134 | mLeftSplitter->setSizes(sizes); | 2135 | mLeftSplitter->setSizes(sizes); |
2135 | } | 2136 | } |
2136 | #endif | 2137 | #endif |
2137 | globalFlagBlockAgenda = 1; | 2138 | globalFlagBlockAgenda = 1; |
2138 | mViewManager->showAgendaView(); | 2139 | mViewManager->showAgendaView(); |
2139 | //mViewManager->readSettings( config ); | 2140 | //mViewManager->readSettings( config ); |
2140 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2141 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2141 | readFilterSettings(config); | 2142 | readFilterSettings(config); |
2142 | 2143 | ||
2143 | #ifdef DESKTOP_VERSION | 2144 | #ifdef DESKTOP_VERSION |
2144 | config->setGroup("WidgetLayout"); | 2145 | config->setGroup("WidgetLayout"); |
2145 | QStringList list; | 2146 | QStringList list; |
2146 | list = config->readListEntry("MainLayout"); | 2147 | list = config->readListEntry("MainLayout"); |
2147 | int x,y,w,h; | 2148 | int x,y,w,h; |
2148 | if ( ! list.isEmpty() ) { | 2149 | if ( ! list.isEmpty() ) { |
2149 | x = list[0].toInt(); | 2150 | x = list[0].toInt(); |
2150 | y = list[1].toInt(); | 2151 | y = list[1].toInt(); |
2151 | w = list[2].toInt(); | 2152 | w = list[2].toInt(); |
2152 | h = list[3].toInt(); | 2153 | h = list[3].toInt(); |
2153 | KApplication::testCoords( &x,&y,&w,&h ); | 2154 | KApplication::testCoords( &x,&y,&w,&h ); |
2154 | topLevelWidget()->setGeometry(x,y,w,h); | 2155 | topLevelWidget()->setGeometry(x,y,w,h); |
2155 | 2156 | ||
2156 | } else { | 2157 | } else { |
2157 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2158 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2158 | } | 2159 | } |
2159 | list = config->readListEntry("EditEventLayout"); | 2160 | list = config->readListEntry("EditEventLayout"); |
2160 | if ( ! list.isEmpty() ) { | 2161 | if ( ! list.isEmpty() ) { |
2161 | x = list[0].toInt(); | 2162 | x = list[0].toInt(); |
2162 | y = list[1].toInt(); | 2163 | y = list[1].toInt(); |
2163 | w = list[2].toInt(); | 2164 | w = list[2].toInt(); |
2164 | h = list[3].toInt(); | 2165 | h = list[3].toInt(); |
2165 | KApplication::testCoords( &x,&y,&w,&h ); | 2166 | KApplication::testCoords( &x,&y,&w,&h ); |
2166 | mEventEditor->setGeometry(x,y,w,h); | 2167 | mEventEditor->setGeometry(x,y,w,h); |
2167 | 2168 | ||
2168 | } | 2169 | } |
2169 | list = config->readListEntry("EditTodoLayout"); | 2170 | list = config->readListEntry("EditTodoLayout"); |
2170 | if ( ! list.isEmpty() ) { | 2171 | if ( ! list.isEmpty() ) { |
2171 | x = list[0].toInt(); | 2172 | x = list[0].toInt(); |
2172 | y = list[1].toInt(); | 2173 | y = list[1].toInt(); |
2173 | w = list[2].toInt(); | 2174 | w = list[2].toInt(); |
2174 | h = list[3].toInt(); | 2175 | h = list[3].toInt(); |
2175 | KApplication::testCoords( &x,&y,&w,&h ); | 2176 | KApplication::testCoords( &x,&y,&w,&h ); |
2176 | mTodoEditor->setGeometry(x,y,w,h); | 2177 | mTodoEditor->setGeometry(x,y,w,h); |
2177 | 2178 | ||
2178 | } | 2179 | } |
2179 | list = config->readListEntry("ViewerLayout"); | 2180 | list = config->readListEntry("ViewerLayout"); |
2180 | if ( ! list.isEmpty() ) { | 2181 | if ( ! list.isEmpty() ) { |
2181 | x = list[0].toInt(); | 2182 | x = list[0].toInt(); |
2182 | y = list[1].toInt(); | 2183 | y = list[1].toInt(); |
2183 | w = list[2].toInt(); | 2184 | w = list[2].toInt(); |
2184 | h = list[3].toInt(); | 2185 | h = list[3].toInt(); |
2185 | KApplication::testCoords( &x,&y,&w,&h ); | 2186 | KApplication::testCoords( &x,&y,&w,&h ); |
2186 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2187 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2187 | } | 2188 | } |
2188 | #endif | 2189 | #endif |
2189 | config->setGroup( "Views" ); | 2190 | config->setGroup( "Views" ); |
2190 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2191 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2191 | 2192 | ||
2192 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2193 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2193 | 2194 | ||
2194 | int resetval = 0; | 2195 | int resetval = 0; |
2195 | int maxVal = 0; | 2196 | int maxVal = 0; |
2196 | if (sizes.count() != 3) { | 2197 | if (sizes.count() != 3) { |
2197 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2198 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2198 | resetval = mDateNavigator->sizeHint().width()+2; | 2199 | resetval = mDateNavigator->sizeHint().width()+2; |
2199 | } else { | 2200 | } else { |
2200 | resetval = mDateNavigator->sizeHint().height()+2; | 2201 | resetval = mDateNavigator->sizeHint().height()+2; |
2201 | } | 2202 | } |
2202 | } | 2203 | } |
2203 | if ( resetval ) { | 2204 | if ( resetval ) { |
2204 | sizes.clear(); | 2205 | sizes.clear(); |
2205 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2206 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2206 | maxVal = QApplication::desktop()->width() -10; | 2207 | maxVal = QApplication::desktop()->width() -10; |
2207 | } else { | 2208 | } else { |
2208 | maxVal = QApplication::desktop()->height()-10; | 2209 | maxVal = QApplication::desktop()->height()-10; |
2209 | } | 2210 | } |
2210 | sizes << resetval; | 2211 | sizes << resetval; |
2211 | if ( maxVal < resetval + resetval) | 2212 | if ( maxVal < resetval + resetval) |
2212 | resetval = maxVal - resetval; | 2213 | resetval = maxVal - resetval; |
2213 | sizes << resetval; | 2214 | sizes << resetval; |
2214 | sizes << 100; | 2215 | sizes << 100; |
2215 | } | 2216 | } |
2216 | mLeftFrame->setSizes(sizes); | 2217 | mLeftFrame->setSizes(sizes); |
2217 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2218 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2218 | resetval = 0; | 2219 | resetval = 0; |
2219 | maxVal = 0; | 2220 | maxVal = 0; |
2220 | if (sizes.count() != 2) { | 2221 | if (sizes.count() != 2) { |
2221 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2222 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2222 | resetval = mDateNavigator->sizeHint().width()+2; | 2223 | resetval = mDateNavigator->sizeHint().width()+2; |
2223 | } else { | 2224 | } else { |
2224 | resetval = mDateNavigator->sizeHint().height()+2; | 2225 | resetval = mDateNavigator->sizeHint().height()+2; |
2225 | } | 2226 | } |
2226 | } | 2227 | } |
2227 | if ( resetval ) { | 2228 | if ( resetval ) { |
2228 | sizes.clear(); | 2229 | sizes.clear(); |
2229 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2230 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2230 | maxVal = QApplication::desktop()->width() -10; | 2231 | maxVal = QApplication::desktop()->width() -10; |
2231 | } else { | 2232 | } else { |
2232 | maxVal = QApplication::desktop()->height()-10; | 2233 | maxVal = QApplication::desktop()->height()-10; |
2233 | } | 2234 | } |
2234 | sizes << resetval; | 2235 | sizes << resetval; |
2235 | if ( maxVal < resetval + resetval) | 2236 | if ( maxVal < resetval + resetval) |
2236 | resetval = maxVal - resetval; | 2237 | resetval = maxVal - resetval; |
2237 | sizes << resetval; | 2238 | sizes << resetval; |
2238 | } | 2239 | } |
2239 | mMainFrame->setSizes(sizes); | 2240 | mMainFrame->setSizes(sizes); |
2240 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2241 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2241 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2242 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2242 | else mNavigator->selectDates( dateCount ); | 2243 | else mNavigator->selectDates( dateCount ); |
2243 | // mViewManager->readSettings( config ); | 2244 | // mViewManager->readSettings( config ); |
2244 | updateConfig(); | 2245 | updateConfig(); |
2245 | globalFlagBlockAgenda = 2; | 2246 | globalFlagBlockAgenda = 2; |
2246 | mViewManager->readSettings( config ); | 2247 | mViewManager->readSettings( config ); |
2247 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2248 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2248 | } | 2249 | } |
2249 | 2250 | ||
2250 | 2251 | ||
2251 | void CalendarView::writeSettings() | 2252 | void CalendarView::writeSettings() |
2252 | { | 2253 | { |
2253 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2254 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2254 | 2255 | ||
2255 | KConfig *config = KOGlobals::config(); | 2256 | KConfig *config = KOGlobals::config(); |
2256 | 2257 | ||
2257 | mViewManager->writeSettings( config ); | 2258 | mViewManager->writeSettings( config ); |
2258 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2259 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2259 | mDialogManager->writeSettings( config ); | 2260 | mDialogManager->writeSettings( config ); |
2260 | //KOPrefs::instance()->usrWriteConfig(); | 2261 | //KOPrefs::instance()->usrWriteConfig(); |
2261 | KOPrefs::instance()->writeConfig(); | 2262 | KOPrefs::instance()->writeConfig(); |
2262 | 2263 | ||
2263 | writeFilterSettings(config); | 2264 | writeFilterSettings(config); |
2264 | config->setGroup( "AppRun" ); | 2265 | config->setGroup( "AppRun" ); |
2265 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2266 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2266 | int days = dt.daysTo( QDate::currentDate() ); | 2267 | int days = dt.daysTo( QDate::currentDate() ); |
2267 | dt = dt.addDays( days ); | 2268 | dt = dt.addDays( days ); |
2268 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2269 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2269 | config->writeEntry( "LatestProgramStopDays", days ); | 2270 | config->writeEntry( "LatestProgramStopDays", days ); |
2270 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2271 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2271 | //qDebug("KO: Writing stop time: %d ", secs); | 2272 | //qDebug("KO: Writing stop time: %d ", secs); |
2272 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2273 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2273 | //QDateTime latest = dt.addSecs ( secs ); | 2274 | //QDateTime latest = dt.addSecs ( secs ); |
2274 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2275 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2275 | config->setGroup( "Views" ); | 2276 | config->setGroup( "Views" ); |
2276 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2277 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2277 | 2278 | ||
2278 | #if 0 | 2279 | #if 0 |
2279 | qDebug("********************* "); | 2280 | qDebug("********************* "); |
2280 | qDebug("Testcode secsto "); | 2281 | qDebug("Testcode secsto "); |
2281 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2282 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2282 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2283 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2283 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2284 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2284 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2285 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2285 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2286 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2286 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2287 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2287 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2288 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2288 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2289 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2289 | qDebug("********************* testcode end"); | 2290 | qDebug("********************* testcode end"); |
2290 | 2291 | ||
2291 | #endif | 2292 | #endif |
2292 | 2293 | ||
2293 | QValueList<int> listINT = mLeftFrame->sizes(); | 2294 | QValueList<int> listINT = mLeftFrame->sizes(); |
2294 | config->writeEntry("Left Splitter Frame",listINT); | 2295 | config->writeEntry("Left Splitter Frame",listINT); |
2295 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2296 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2296 | config->writeEntry("Main Splitter Frame",listINT2); | 2297 | config->writeEntry("Main Splitter Frame",listINT2); |
2297 | #ifdef DESKTOP_VERSION | 2298 | #ifdef DESKTOP_VERSION |
2298 | config->setGroup("WidgetLayout"); | 2299 | config->setGroup("WidgetLayout"); |
2299 | QStringList list ;//= config->readListEntry("MainLayout"); | 2300 | QStringList list ;//= config->readListEntry("MainLayout"); |
2300 | int x,y,w,h; | 2301 | int x,y,w,h; |
2301 | QWidget* wid; | 2302 | QWidget* wid; |
2302 | wid = topLevelWidget(); | 2303 | wid = topLevelWidget(); |
2303 | x = wid->geometry().x(); | 2304 | x = wid->geometry().x(); |
2304 | y = wid->geometry().y(); | 2305 | y = wid->geometry().y(); |
2305 | w = wid->width(); | 2306 | w = wid->width(); |
2306 | h = wid->height(); | 2307 | h = wid->height(); |
2307 | list.clear(); | 2308 | list.clear(); |
2308 | list << QString::number( x ); | 2309 | list << QString::number( x ); |
2309 | list << QString::number( y ); | 2310 | list << QString::number( y ); |
2310 | list << QString::number( w ); | 2311 | list << QString::number( w ); |
2311 | list << QString::number( h ); | 2312 | list << QString::number( h ); |
2312 | config->writeEntry("MainLayout",list ); | 2313 | config->writeEntry("MainLayout",list ); |
2313 | 2314 | ||
2314 | wid = mEventEditor; | 2315 | wid = mEventEditor; |
2315 | x = wid->geometry().x(); | 2316 | x = wid->geometry().x(); |
2316 | y = wid->geometry().y(); | 2317 | y = wid->geometry().y(); |
2317 | w = wid->width(); | 2318 | w = wid->width(); |
2318 | h = wid->height(); | 2319 | h = wid->height(); |
2319 | list.clear(); | 2320 | list.clear(); |
2320 | list << QString::number( x ); | 2321 | list << QString::number( x ); |
2321 | list << QString::number( y ); | 2322 | list << QString::number( y ); |
2322 | list << QString::number( w ); | 2323 | list << QString::number( w ); |
2323 | list << QString::number( h ); | 2324 | list << QString::number( h ); |
2324 | config->writeEntry("EditEventLayout",list ); | 2325 | config->writeEntry("EditEventLayout",list ); |
2325 | 2326 | ||
2326 | wid = mTodoEditor; | 2327 | wid = mTodoEditor; |
2327 | x = wid->geometry().x(); | 2328 | x = wid->geometry().x(); |
2328 | y = wid->geometry().y(); | 2329 | y = wid->geometry().y(); |
2329 | w = wid->width(); | 2330 | w = wid->width(); |
2330 | h = wid->height(); | 2331 | h = wid->height(); |
2331 | list.clear(); | 2332 | list.clear(); |
2332 | list << QString::number( x ); | 2333 | list << QString::number( x ); |
2333 | list << QString::number( y ); | 2334 | list << QString::number( y ); |
2334 | list << QString::number( w ); | 2335 | list << QString::number( w ); |
2335 | list << QString::number( h ); | 2336 | list << QString::number( h ); |
2336 | config->writeEntry("EditTodoLayout",list ); | 2337 | config->writeEntry("EditTodoLayout",list ); |
2337 | wid = getEventViewerDialog(); | 2338 | wid = getEventViewerDialog(); |
2338 | x = wid->geometry().x(); | 2339 | x = wid->geometry().x(); |
2339 | y = wid->geometry().y(); | 2340 | y = wid->geometry().y(); |
2340 | w = wid->width(); | 2341 | w = wid->width(); |
2341 | h = wid->height(); | 2342 | h = wid->height(); |
2342 | list.clear(); | 2343 | list.clear(); |
2343 | list << QString::number( x ); | 2344 | list << QString::number( x ); |
2344 | list << QString::number( y ); | 2345 | list << QString::number( y ); |
2345 | list << QString::number( w ); | 2346 | list << QString::number( w ); |
2346 | list << QString::number( h ); | 2347 | list << QString::number( h ); |
2347 | config->writeEntry("ViewerLayout",list ); | 2348 | config->writeEntry("ViewerLayout",list ); |
2348 | wid = mDialogManager->getSearchDialog(); | 2349 | wid = mDialogManager->getSearchDialog(); |
2349 | if ( wid ) { | 2350 | if ( wid ) { |
2350 | x = wid->geometry().x(); | 2351 | x = wid->geometry().x(); |
2351 | y = wid->geometry().y(); | 2352 | y = wid->geometry().y(); |
2352 | w = wid->width(); | 2353 | w = wid->width(); |
2353 | h = wid->height(); | 2354 | h = wid->height(); |
2354 | list.clear(); | 2355 | list.clear(); |
2355 | list << QString::number( x ); | 2356 | list << QString::number( x ); |
2356 | list << QString::number( y ); | 2357 | list << QString::number( y ); |
2357 | list << QString::number( w ); | 2358 | list << QString::number( w ); |
2358 | list << QString::number( h ); | 2359 | list << QString::number( h ); |
2359 | config->writeEntry("SearchLayout",list ); | 2360 | config->writeEntry("SearchLayout",list ); |
2360 | } | 2361 | } |
2361 | #endif | 2362 | #endif |
2362 | 2363 | ||
2363 | 2364 | ||
2364 | config->sync(); | 2365 | config->sync(); |
2365 | } | 2366 | } |
2366 | 2367 | ||
2367 | void CalendarView::readFilterSettings(KConfig *config) | 2368 | void CalendarView::readFilterSettings(KConfig *config) |
2368 | { | 2369 | { |
2369 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2370 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2370 | 2371 | ||
2371 | mFilters.clear(); | 2372 | mFilters.clear(); |
2372 | 2373 | ||
2373 | config->setGroup("General"); | 2374 | config->setGroup("General"); |
2374 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2375 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2375 | 2376 | ||
2376 | QStringList::ConstIterator it = filterList.begin(); | 2377 | QStringList::ConstIterator it = filterList.begin(); |
2377 | QStringList::ConstIterator end = filterList.end(); | 2378 | QStringList::ConstIterator end = filterList.end(); |
2378 | while(it != end) { | 2379 | while(it != end) { |
2379 | // kdDebug() << " filter: " << (*it) << endl; | 2380 | // kdDebug() << " filter: " << (*it) << endl; |
2380 | 2381 | ||
2381 | CalFilter *filter; | 2382 | CalFilter *filter; |
2382 | filter = new CalFilter(*it); | 2383 | filter = new CalFilter(*it); |
2383 | config->setGroup("Filter_" + (*it).utf8()); | 2384 | config->setGroup("Filter_" + (*it).utf8()); |
2384 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2385 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2385 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2386 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2386 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2387 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2387 | mFilters.append(filter); | 2388 | mFilters.append(filter); |
2388 | 2389 | ||
2389 | ++it; | 2390 | ++it; |
2390 | } | 2391 | } |
2391 | 2392 | ||
2392 | if (mFilters.count() == 0) { | 2393 | if (mFilters.count() == 0) { |
2393 | CalFilter *filter = new CalFilter(i18n("Default")); | 2394 | CalFilter *filter = new CalFilter(i18n("Default")); |
2394 | mFilters.append(filter); | 2395 | mFilters.append(filter); |
2395 | } | 2396 | } |
2396 | mFilterView->updateFilters(); | 2397 | mFilterView->updateFilters(); |
2397 | config->setGroup("FilterView"); | 2398 | config->setGroup("FilterView"); |
2398 | 2399 | ||
2399 | mFilterView->blockSignals(true); | 2400 | mFilterView->blockSignals(true); |
2400 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2401 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2401 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2402 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2402 | mFilterView->blockSignals(false); | 2403 | mFilterView->blockSignals(false); |
2403 | // We do it manually to avoid it being done twice by the above calls | 2404 | // We do it manually to avoid it being done twice by the above calls |
2404 | updateFilter(); | 2405 | updateFilter(); |
2405 | } | 2406 | } |
2406 | 2407 | ||
2407 | void CalendarView::writeFilterSettings(KConfig *config) | 2408 | void CalendarView::writeFilterSettings(KConfig *config) |
2408 | { | 2409 | { |
2409 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2410 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2410 | 2411 | ||
2411 | QStringList filterList; | 2412 | QStringList filterList; |
2412 | 2413 | ||
2413 | CalFilter *filter = mFilters.first(); | 2414 | CalFilter *filter = mFilters.first(); |
2414 | while(filter) { | 2415 | while(filter) { |
2415 | // kdDebug() << " fn: " << filter->name() << endl; | 2416 | // kdDebug() << " fn: " << filter->name() << endl; |
2416 | filterList << filter->name(); | 2417 | filterList << filter->name(); |
2417 | config->setGroup("Filter_" + filter->name().utf8()); | 2418 | config->setGroup("Filter_" + filter->name().utf8()); |
2418 | config->writeEntry("Criteria",filter->criteria()); | 2419 | config->writeEntry("Criteria",filter->criteria()); |
2419 | config->writeEntry("CategoryList",filter->categoryList()); | 2420 | config->writeEntry("CategoryList",filter->categoryList()); |
2420 | filter = mFilters.next(); | 2421 | filter = mFilters.next(); |
2421 | } | 2422 | } |
2422 | config->setGroup("General"); | 2423 | config->setGroup("General"); |
2423 | config->writeEntry("CalendarFilters",filterList); | 2424 | config->writeEntry("CalendarFilters",filterList); |
2424 | 2425 | ||
2425 | config->setGroup("FilterView"); | 2426 | config->setGroup("FilterView"); |
2426 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2427 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2427 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2428 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2428 | } | 2429 | } |
2429 | 2430 | ||
2430 | 2431 | ||
2431 | void CalendarView::goToday() | 2432 | void CalendarView::goToday() |
2432 | { | 2433 | { |
2433 | if ( mViewManager->currentView()->isMonthView() ) | 2434 | if ( mViewManager->currentView()->isMonthView() ) |
2434 | mNavigator->selectTodayMonth(); | 2435 | mNavigator->selectTodayMonth(); |
2435 | else | 2436 | else |
2436 | mNavigator->selectToday(); | 2437 | mNavigator->selectToday(); |
2437 | } | 2438 | } |
2438 | 2439 | ||
2439 | void CalendarView::goNext() | 2440 | void CalendarView::goNext() |
2440 | { | 2441 | { |
2441 | mNavigator->selectNext(); | 2442 | mNavigator->selectNext(); |
2442 | } | 2443 | } |
2443 | 2444 | ||
2444 | void CalendarView::goPrevious() | 2445 | void CalendarView::goPrevious() |
2445 | { | 2446 | { |
2446 | mNavigator->selectPrevious(); | 2447 | mNavigator->selectPrevious(); |
2447 | } | 2448 | } |
2448 | void CalendarView::goNextMonth() | 2449 | void CalendarView::goNextMonth() |
2449 | { | 2450 | { |
2450 | mNavigator->selectNextMonth(); | 2451 | mNavigator->selectNextMonth(); |
2451 | } | 2452 | } |
2452 | 2453 | ||
2453 | void CalendarView::goPreviousMonth() | 2454 | void CalendarView::goPreviousMonth() |
2454 | { | 2455 | { |
2455 | mNavigator->selectPreviousMonth(); | 2456 | mNavigator->selectPreviousMonth(); |
2456 | } | 2457 | } |
2457 | void CalendarView::writeLocale() | 2458 | void CalendarView::writeLocale() |
2458 | { | 2459 | { |
2459 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2460 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2460 | #if 0 | 2461 | #if 0 |
2461 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2462 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2462 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2463 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2463 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2464 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2464 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2465 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2465 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2466 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2466 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2467 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2467 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2468 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2468 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2469 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2469 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2470 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2470 | KOPrefs::instance()->mDaylightsavingStart, | 2471 | KOPrefs::instance()->mDaylightsavingStart, |
2471 | KOPrefs::instance()->mDaylightsavingEnd ); | 2472 | KOPrefs::instance()->mDaylightsavingEnd ); |
2472 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2473 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2473 | #endif | 2474 | #endif |
2474 | } | 2475 | } |
2475 | void CalendarView::updateConfig() | 2476 | void CalendarView::updateConfig() |
2476 | { | 2477 | { |
2477 | writeLocale(); | 2478 | writeLocale(); |
2478 | if ( KOPrefs::instance()->mUseAppColors ) | 2479 | if ( KOPrefs::instance()->mUseAppColors ) |
2479 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2480 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2480 | emit configChanged(); | 2481 | emit configChanged(); |
2481 | mTodoList->updateConfig(); | 2482 | mTodoList->updateConfig(); |
2482 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2483 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2483 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2484 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2484 | // To make the "fill window" configurations work | 2485 | // To make the "fill window" configurations work |
2485 | //mViewManager->raiseCurrentView(); | 2486 | //mViewManager->raiseCurrentView(); |
2486 | } | 2487 | } |
2487 | 2488 | ||
2488 | 2489 | ||
2489 | void CalendarView::eventChanged(Event *event) | 2490 | void CalendarView::eventChanged(Event *event) |
2490 | { | 2491 | { |
2491 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2492 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2492 | //updateUnmanagedViews(); | 2493 | //updateUnmanagedViews(); |
2493 | } | 2494 | } |
2494 | 2495 | ||
2495 | void CalendarView::eventAdded(Event *event) | 2496 | void CalendarView::eventAdded(Event *event) |
2496 | { | 2497 | { |
2497 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2498 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2498 | } | 2499 | } |
2499 | 2500 | ||
2500 | void CalendarView::eventToBeDeleted(Event *) | 2501 | void CalendarView::eventToBeDeleted(Event *) |
2501 | { | 2502 | { |
2502 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2503 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2503 | } | 2504 | } |
2504 | 2505 | ||
2505 | void CalendarView::eventDeleted() | 2506 | void CalendarView::eventDeleted() |
2506 | { | 2507 | { |
2507 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2508 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2508 | } | 2509 | } |
2509 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2510 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2510 | { | 2511 | { |
2511 | changeIncidenceDisplay((Incidence *)which, action); | 2512 | changeIncidenceDisplay((Incidence *)which, action); |
2512 | mDateNavigator->updateView(); //LR | 2513 | mDateNavigator->updateView(); //LR |
2513 | //mDialogManager->updateSearchDialog(); | 2514 | //mDialogManager->updateSearchDialog(); |
2514 | 2515 | ||
2515 | if (which) { | 2516 | if (which) { |
2516 | mViewManager->updateWNview(); | 2517 | mViewManager->updateWNview(); |
2517 | //mTodoList->updateView(); | 2518 | //mTodoList->updateView(); |
2518 | } | 2519 | } |
2519 | 2520 | ||
2520 | } | 2521 | } |
2521 | 2522 | ||
2522 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2523 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2523 | { | 2524 | { |
2524 | updateUnmanagedViews(); | 2525 | updateUnmanagedViews(); |
2525 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2526 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2526 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2527 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2527 | mCalendar->checkAlarmForIncidence( 0, true ); | 2528 | mCalendar->checkAlarmForIncidence( 0, true ); |
2528 | if ( mEventViewerDialog ) | 2529 | if ( mEventViewerDialog ) |
2529 | mEventViewerDialog->hide(); | 2530 | mEventViewerDialog->hide(); |
2530 | } | 2531 | } |
2531 | else | 2532 | else |
2532 | mCalendar->checkAlarmForIncidence( which , false ); | 2533 | mCalendar->checkAlarmForIncidence( which , false ); |
2533 | } | 2534 | } |
2534 | 2535 | ||
2535 | // most of the changeEventDisplays() right now just call the view's | 2536 | // most of the changeEventDisplays() right now just call the view's |
2536 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2537 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2537 | void CalendarView::changeEventDisplay(Event *which, int action) | 2538 | void CalendarView::changeEventDisplay(Event *which, int action) |
2538 | { | 2539 | { |
2539 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2540 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2540 | changeIncidenceDisplay((Incidence *)which, action); | 2541 | changeIncidenceDisplay((Incidence *)which, action); |
2541 | mDateNavigator->updateView(); | 2542 | mDateNavigator->updateView(); |
2542 | //mDialogManager->updateSearchDialog(); | 2543 | //mDialogManager->updateSearchDialog(); |
2543 | 2544 | ||
2544 | if (which) { | 2545 | if (which) { |
2545 | // If there is an event view visible update the display | 2546 | // If there is an event view visible update the display |
2546 | mViewManager->currentView()->changeEventDisplay(which,action); | 2547 | mViewManager->currentView()->changeEventDisplay(which,action); |
2547 | // TODO: check, if update needed | 2548 | // TODO: check, if update needed |
2548 | // if (which->getTodoStatus()) { | 2549 | // if (which->getTodoStatus()) { |
2549 | mTodoList->updateView(); | 2550 | mTodoList->updateView(); |
2550 | // } | 2551 | // } |
2551 | } else { | 2552 | } else { |
2552 | mViewManager->currentView()->updateView(); | 2553 | mViewManager->currentView()->updateView(); |
2553 | } | 2554 | } |
2554 | } | 2555 | } |
2555 | 2556 | ||
2556 | 2557 | ||
2557 | void CalendarView::updateTodoViews() | 2558 | void CalendarView::updateTodoViews() |
2558 | { | 2559 | { |
2559 | mTodoList->updateView(); | 2560 | mTodoList->updateView(); |
2560 | mViewManager->currentView()->updateView(); | 2561 | mViewManager->currentView()->updateView(); |
2561 | 2562 | ||
2562 | } | 2563 | } |
2563 | 2564 | ||
2564 | 2565 | ||
2565 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2566 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2566 | { | 2567 | { |
2567 | mTodoList->updateView(); | 2568 | mTodoList->updateView(); |
2568 | mViewManager->updateView(start, end); | 2569 | mViewManager->updateView(start, end); |
2569 | //mDateNavigator->updateView(); | 2570 | //mDateNavigator->updateView(); |
2570 | } | 2571 | } |
2571 | 2572 | ||
2572 | void CalendarView::clearAllViews() | 2573 | void CalendarView::clearAllViews() |
2573 | { | 2574 | { |
2574 | mTodoList->clearList(); | 2575 | mTodoList->clearList(); |
2575 | mViewManager->clearAllViews(); | 2576 | mViewManager->clearAllViews(); |
2576 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2577 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2577 | if ( sd ) { | 2578 | if ( sd ) { |
2578 | KOListView* kol = sd->listview(); | 2579 | KOListView* kol = sd->listview(); |
2579 | if ( kol ) | 2580 | if ( kol ) |
2580 | kol->clearList(); | 2581 | kol->clearList(); |
2581 | } | 2582 | } |
2582 | } | 2583 | } |
2583 | void CalendarView::updateView() | 2584 | void CalendarView::updateView() |
2584 | { | 2585 | { |
2585 | DateList tmpList = mNavigator->selectedDates(); | 2586 | DateList tmpList = mNavigator->selectedDates(); |
2586 | 2587 | ||
2587 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2588 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2588 | mTodoList->updateView(); | 2589 | mTodoList->updateView(); |
2589 | // We assume that the navigator only selects consecutive days. | 2590 | // We assume that the navigator only selects consecutive days. |
2590 | updateView( tmpList.first(), tmpList.last() ); | 2591 | updateView( tmpList.first(), tmpList.last() ); |
2591 | } | 2592 | } |
2592 | 2593 | ||
2593 | void CalendarView::updateUnmanagedViews() | 2594 | void CalendarView::updateUnmanagedViews() |
2594 | { | 2595 | { |
2595 | mDateNavigator->updateDayMatrix(); | 2596 | mDateNavigator->updateDayMatrix(); |
2596 | } | 2597 | } |
2597 | 2598 | ||
2598 | int CalendarView::msgItemDelete(const QString name) | 2599 | int CalendarView::msgItemDelete(const QString name) |
2599 | { | 2600 | { |
2600 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2601 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2601 | i18n("This item will be\npermanently deleted."), | 2602 | i18n("This item will be\npermanently deleted."), |
2602 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2603 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2603 | } | 2604 | } |
2604 | 2605 | ||
2605 | 2606 | ||
2606 | void CalendarView::edit_cut() | 2607 | void CalendarView::edit_cut() |
2607 | { | 2608 | { |
2608 | Event *anEvent=0; | 2609 | Event *anEvent=0; |
2609 | 2610 | ||
2610 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2611 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2611 | 2612 | ||
2612 | if (mViewManager->currentView()->isEventView()) { | 2613 | if (mViewManager->currentView()->isEventView()) { |
2613 | if ( incidence && incidence->typeID() == eventID ) { | 2614 | if ( incidence && incidence->typeID() == eventID ) { |
2614 | anEvent = static_cast<Event *>(incidence); | 2615 | anEvent = static_cast<Event *>(incidence); |
2615 | } | 2616 | } |
2616 | } | 2617 | } |
2617 | 2618 | ||
2618 | if (!anEvent) { | 2619 | if (!anEvent) { |
2619 | KNotifyClient::beep(); | 2620 | KNotifyClient::beep(); |
2620 | return; | 2621 | return; |
2621 | } | 2622 | } |
2622 | DndFactory factory( mCalendar ); | 2623 | DndFactory factory( mCalendar ); |
2623 | factory.cutIncidence(anEvent); | 2624 | factory.cutIncidence(anEvent); |
2624 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2625 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2625 | } | 2626 | } |
2626 | 2627 | ||
2627 | void CalendarView::edit_copy() | 2628 | void CalendarView::edit_copy() |
2628 | { | 2629 | { |
2629 | Event *anEvent=0; | 2630 | Event *anEvent=0; |
2630 | 2631 | ||
2631 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2632 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2632 | 2633 | ||
2633 | if (mViewManager->currentView()->isEventView()) { | 2634 | if (mViewManager->currentView()->isEventView()) { |
2634 | if ( incidence && incidence->typeID() == eventID ) { | 2635 | if ( incidence && incidence->typeID() == eventID ) { |
2635 | anEvent = static_cast<Event *>(incidence); | 2636 | anEvent = static_cast<Event *>(incidence); |
2636 | } | 2637 | } |
2637 | } | 2638 | } |
2638 | 2639 | ||
2639 | if (!anEvent) { | 2640 | if (!anEvent) { |
2640 | KNotifyClient::beep(); | 2641 | KNotifyClient::beep(); |
2641 | return; | 2642 | return; |
2642 | } | 2643 | } |
2643 | DndFactory factory( mCalendar ); | 2644 | DndFactory factory( mCalendar ); |
2644 | factory.copyIncidence(anEvent); | 2645 | factory.copyIncidence(anEvent); |
2645 | } | 2646 | } |
2646 | 2647 | ||
2647 | void CalendarView::edit_paste() | 2648 | void CalendarView::edit_paste() |
2648 | { | 2649 | { |
2649 | QDate date = mNavigator->selectedDates().first(); | 2650 | QDate date = mNavigator->selectedDates().first(); |
2650 | 2651 | ||
2651 | DndFactory factory( mCalendar ); | 2652 | DndFactory factory( mCalendar ); |
2652 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2653 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2653 | 2654 | ||
2654 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2655 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2655 | } | 2656 | } |
2656 | void CalendarView::edit_global_options() | 2657 | void CalendarView::edit_global_options() |
2657 | { | 2658 | { |
2658 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2659 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2659 | emit save(); | 2660 | emit save(); |
2660 | emit saveStopTimer(); | 2661 | emit saveStopTimer(); |
2661 | mDialogManager->showGlobalOptionsDialog(); | 2662 | mDialogManager->showGlobalOptionsDialog(); |
2662 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2663 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2663 | emit saveStopTimer(); | 2664 | emit saveStopTimer(); |
2664 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2665 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2665 | i18n("Timezone settings"),i18n("Reload"))) { | 2666 | i18n("Timezone settings"),i18n("Reload"))) { |
2666 | qDebug("KO: TZ reload cancelled "); | 2667 | qDebug("KO: TZ reload cancelled "); |
2667 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2668 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2668 | return; | 2669 | return; |
2669 | } | 2670 | } |
2670 | qDebug("KO: Timezone change "); | 2671 | qDebug("KO: Timezone change "); |
2671 | openCalendar( MainWindow::defaultFileName() ); | 2672 | openCalendar( MainWindow::defaultFileName() ); |
2672 | setModified(true); | 2673 | setModified(true); |
2673 | } | 2674 | } |
2674 | else | 2675 | else |
2675 | qDebug("KO: No tz change "); | 2676 | qDebug("KO: No tz change "); |
2676 | } | 2677 | } |
2677 | void CalendarView::edit_options() | 2678 | void CalendarView::edit_options() |
2678 | { | 2679 | { |
2679 | mDialogManager->showOptionsDialog(); | 2680 | mDialogManager->showOptionsDialog(); |
2680 | } | 2681 | } |
2681 | 2682 | ||
2682 | 2683 | ||
2683 | void CalendarView::slotSelectPickerDate( QDate d) | 2684 | void CalendarView::slotSelectPickerDate( QDate d) |
2684 | { | 2685 | { |
2685 | mDateFrame->hide(); | 2686 | mDateFrame->hide(); |
2686 | if ( mDatePickerMode == 1 ) { | 2687 | if ( mDatePickerMode == 1 ) { |
2687 | mNavigator->slotDaySelect( d ); | 2688 | mNavigator->slotDaySelect( d ); |
2688 | } else if ( mDatePickerMode == 2 ) { | 2689 | } else if ( mDatePickerMode == 2 ) { |
2689 | if ( mMoveIncidence->typeID() == todoID ) { | 2690 | if ( mMoveIncidence->typeID() == todoID ) { |
2690 | Todo * to = (Todo *) mMoveIncidence; | 2691 | Todo * to = (Todo *) mMoveIncidence; |
2691 | QTime tim; | 2692 | QTime tim; |
2692 | int len = 0; | 2693 | int len = 0; |
2693 | if ( to->hasStartDate() && to->hasDueDate() ) | 2694 | if ( to->hasStartDate() && to->hasDueDate() ) |
2694 | len = to->dtStart().secsTo( to->dtDue()); | 2695 | len = to->dtStart().secsTo( to->dtDue()); |
2695 | if ( to->hasDueDate() ) | 2696 | if ( to->hasDueDate() ) |
2696 | tim = to->dtDue().time(); | 2697 | tim = to->dtDue().time(); |
2697 | else { | 2698 | else { |
2698 | tim = QTime ( 0,0,0 ); | 2699 | tim = QTime ( 0,0,0 ); |
2699 | to->setFloats( true ); | 2700 | to->setFloats( true ); |
2700 | to->setHasDueDate( true ); | 2701 | to->setHasDueDate( true ); |
2701 | } | 2702 | } |
2702 | QDateTime dt ( d,tim ); | 2703 | QDateTime dt ( d,tim ); |
2703 | to->setDtDue( dt ); | 2704 | to->setDtDue( dt ); |
2704 | 2705 | ||
2705 | if ( to->hasStartDate() ) { | 2706 | if ( to->hasStartDate() ) { |
2706 | if ( len>0 ) | 2707 | if ( len>0 ) |
2707 | to->setDtStart(to->dtDue().addSecs( -len )); | 2708 | to->setDtStart(to->dtDue().addSecs( -len )); |
2708 | else | 2709 | else |
2709 | if (to->dtStart() > to->dtDue() ) | 2710 | if (to->dtStart() > to->dtDue() ) |
2710 | to->setDtStart(to->dtDue().addDays( -3 )); | 2711 | to->setDtStart(to->dtDue().addDays( -3 )); |
2711 | } | 2712 | } |
2712 | 2713 | ||
2713 | todoChanged( to ); | 2714 | todoChanged( to ); |
2714 | } else { | 2715 | } else { |
2715 | if ( mMoveIncidence->doesRecur() ) { | 2716 | if ( mMoveIncidence->doesRecur() ) { |
2716 | #if 0 | 2717 | #if 0 |
2717 | // PENDING implement this | 2718 | // PENDING implement this |
2718 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2719 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2719 | mCalendar()->addIncidence( newInc ); | 2720 | mCalendar()->addIncidence( newInc ); |
2720 | if ( mMoveIncidence->typeID() == todoID ) | 2721 | if ( mMoveIncidence->typeID() == todoID ) |
2721 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2722 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2722 | else | 2723 | else |
2723 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2724 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2724 | mMoveIncidence = newInc; | 2725 | mMoveIncidence = newInc; |
2725 | 2726 | ||
2726 | #endif | 2727 | #endif |
2727 | } | 2728 | } |
2728 | QTime tim = mMoveIncidence->dtStart().time(); | 2729 | QTime tim = mMoveIncidence->dtStart().time(); |
2729 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2730 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2730 | QDateTime dt ( d,tim ); | 2731 | QDateTime dt ( d,tim ); |
2731 | mMoveIncidence->setDtStart( dt ); | 2732 | mMoveIncidence->setDtStart( dt ); |
2732 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2733 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2733 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2734 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2734 | } | 2735 | } |
2735 | 2736 | ||
2736 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2737 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2737 | } | 2738 | } |
2738 | } | 2739 | } |
2739 | 2740 | ||
2740 | void CalendarView::removeCategories() | 2741 | void CalendarView::removeCategories() |
2741 | { | 2742 | { |
2742 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2743 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2743 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2744 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2744 | QStringList catIncList; | 2745 | QStringList catIncList; |
2745 | QStringList newCatList; | 2746 | QStringList newCatList; |
2746 | Incidence* inc = incList.first(); | 2747 | Incidence* inc = incList.first(); |
2747 | int i; | 2748 | int i; |
2748 | int count = 0; | 2749 | int count = 0; |
2749 | while ( inc ) { | 2750 | while ( inc ) { |
2750 | newCatList.clear(); | 2751 | newCatList.clear(); |
2751 | catIncList = inc->categories() ; | 2752 | catIncList = inc->categories() ; |
2752 | for( i = 0; i< catIncList.count(); ++i ) { | 2753 | for( i = 0; i< catIncList.count(); ++i ) { |
2753 | if ( catList.contains (catIncList[i])) | 2754 | if ( catList.contains (catIncList[i])) |
2754 | newCatList.append( catIncList[i] ); | 2755 | newCatList.append( catIncList[i] ); |
2755 | } | 2756 | } |
2756 | newCatList.sort(); | 2757 | newCatList.sort(); |
2757 | inc->setCategories( newCatList.join(",") ); | 2758 | inc->setCategories( newCatList.join(",") ); |
2758 | inc = incList.next(); | 2759 | inc = incList.next(); |
2759 | } | 2760 | } |
2760 | } | 2761 | } |
2761 | 2762 | ||
2762 | int CalendarView::addCategories() | 2763 | int CalendarView::addCategories() |
2763 | { | 2764 | { |
2764 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2765 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2765 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2766 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2766 | QStringList catIncList; | 2767 | QStringList catIncList; |
2767 | Incidence* inc = incList.first(); | 2768 | Incidence* inc = incList.first(); |
2768 | int i; | 2769 | int i; |
2769 | int count = 0; | 2770 | int count = 0; |
2770 | while ( inc ) { | 2771 | while ( inc ) { |
2771 | catIncList = inc->categories() ; | 2772 | catIncList = inc->categories() ; |
2772 | for( i = 0; i< catIncList.count(); ++i ) { | 2773 | for( i = 0; i< catIncList.count(); ++i ) { |
2773 | if ( !catList.contains (catIncList[i])) { | 2774 | if ( !catList.contains (catIncList[i])) { |
2774 | catList.append( catIncList[i] ); | 2775 | catList.append( catIncList[i] ); |
2775 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2776 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2776 | ++count; | 2777 | ++count; |
2777 | } | 2778 | } |
2778 | } | 2779 | } |
2779 | inc = incList.next(); | 2780 | inc = incList.next(); |
2780 | } | 2781 | } |
2781 | catList.sort(); | 2782 | catList.sort(); |
2782 | KOPrefs::instance()->mCustomCategories = catList; | 2783 | KOPrefs::instance()->mCustomCategories = catList; |
2783 | return count; | 2784 | return count; |
2784 | } | 2785 | } |
2785 | 2786 | ||
2786 | void CalendarView::manageCategories() | 2787 | void CalendarView::manageCategories() |
2787 | { | 2788 | { |
2788 | KOCatPrefs* cp = new KOCatPrefs(); | 2789 | KOCatPrefs* cp = new KOCatPrefs(); |
2789 | cp->show(); | 2790 | cp->show(); |
2790 | int w =cp->sizeHint().width() ; | 2791 | int w =cp->sizeHint().width() ; |
2791 | int h = cp->sizeHint().height() ; | 2792 | int h = cp->sizeHint().height() ; |
2792 | int dw = QApplication::desktop()->width(); | 2793 | int dw = QApplication::desktop()->width(); |
2793 | int dh = QApplication::desktop()->height(); | 2794 | int dh = QApplication::desktop()->height(); |
2794 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2795 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2795 | if ( !cp->exec() ) { | 2796 | if ( !cp->exec() ) { |
2796 | delete cp; | 2797 | delete cp; |
2797 | return; | 2798 | return; |
2798 | } | 2799 | } |
2799 | int count = 0; | 2800 | int count = 0; |
2800 | if ( cp->addCat() ) { | 2801 | if ( cp->addCat() ) { |
2801 | count = addCategories(); | 2802 | count = addCategories(); |
2802 | if ( count ) { | 2803 | if ( count ) { |
2803 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2804 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2804 | writeSettings(); | 2805 | writeSettings(); |
2805 | } else | 2806 | } else |
2806 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2807 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2807 | } else { | 2808 | } else { |
2808 | removeCategories(); | 2809 | removeCategories(); |
2809 | updateView(); | 2810 | updateView(); |
2810 | } | 2811 | } |
2811 | delete cp; | 2812 | delete cp; |
2812 | } | 2813 | } |
2813 | 2814 | ||
2814 | void CalendarView::beamIncidence(Incidence * Inc) | 2815 | void CalendarView::beamIncidence(Incidence * Inc) |
2815 | { | 2816 | { |
2816 | QPtrList<Incidence> delSel ; | 2817 | QPtrList<Incidence> delSel ; |
2817 | delSel.append(Inc); | 2818 | delSel.append(Inc); |
2818 | beamIncidenceList( delSel ); | 2819 | beamIncidenceList( delSel ); |
2819 | } | 2820 | } |
2820 | void CalendarView::beamCalendar() | 2821 | void CalendarView::beamCalendar() |
2821 | { | 2822 | { |
2822 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2823 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2823 | //qDebug("beamCalendar() "); | 2824 | //qDebug("beamCalendar() "); |
2824 | beamIncidenceList( delSel ); | 2825 | beamIncidenceList( delSel ); |
2825 | } | 2826 | } |
2826 | void CalendarView::beamFilteredCalendar() | 2827 | void CalendarView::beamFilteredCalendar() |
2827 | { | 2828 | { |
2828 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2829 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2829 | //qDebug("beamFilteredCalendar() "); | 2830 | //qDebug("beamFilteredCalendar() "); |
2830 | beamIncidenceList( delSel ); | 2831 | beamIncidenceList( delSel ); |
2831 | } | 2832 | } |
2832 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2833 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2833 | { | 2834 | { |
2834 | if ( beamDialog->exec () == QDialog::Rejected ) | 2835 | if ( beamDialog->exec () == QDialog::Rejected ) |
2835 | return; | 2836 | return; |
2836 | #ifdef DESKTOP_VERSION | 2837 | #ifdef DESKTOP_VERSION |
2837 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2838 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2838 | #else | 2839 | #else |
2839 | QString fn = "/tmp/kopibeamfile"; | 2840 | QString fn = "/tmp/kopibeamfile"; |
2840 | #endif | 2841 | #endif |
2841 | QString mes; | 2842 | QString mes; |
2842 | bool createbup = true; | 2843 | bool createbup = true; |
2843 | if ( createbup ) { | 2844 | if ( createbup ) { |
2844 | QString description = "\n"; | 2845 | QString description = "\n"; |
2845 | CalendarLocal* cal = new CalendarLocal(); | 2846 | CalendarLocal* cal = new CalendarLocal(); |
2846 | if ( beamDialog->beamLocal() ) | 2847 | if ( beamDialog->beamLocal() ) |
2847 | cal->setLocalTime(); | 2848 | cal->setLocalTime(); |
2848 | else | 2849 | else |
2849 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2850 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2850 | Incidence *incidence = delSel.first(); | 2851 | Incidence *incidence = delSel.first(); |
2851 | bool addText = false; | 2852 | bool addText = false; |
2852 | if ( delSel.count() < 10 ) | 2853 | if ( delSel.count() < 10 ) |
2853 | addText = true; | 2854 | addText = true; |
2854 | else { | 2855 | else { |
2855 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2856 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2856 | } | 2857 | } |
2857 | while ( incidence ) { | 2858 | while ( incidence ) { |
2858 | Incidence *in = incidence->clone(); | 2859 | Incidence *in = incidence->clone(); |
2859 | if ( ! in->summary().isEmpty() ) { | 2860 | if ( ! in->summary().isEmpty() ) { |
2860 | in->setDescription(""); | 2861 | in->setDescription(""); |
2861 | } else { | 2862 | } else { |
2862 | in->setSummary( in->description().left(20)); | 2863 | in->setSummary( in->description().left(20)); |
2863 | in->setDescription(""); | 2864 | in->setDescription(""); |
2864 | } | 2865 | } |
2865 | if ( addText ) | 2866 | if ( addText ) |
2866 | description += in->summary() + "\n"; | 2867 | description += in->summary() + "\n"; |
2867 | cal->addIncidence( in ); | 2868 | cal->addIncidence( in ); |
2868 | incidence = delSel.next(); | 2869 | incidence = delSel.next(); |
2869 | } | 2870 | } |
2870 | if ( beamDialog->beamVcal() ) { | 2871 | if ( beamDialog->beamVcal() ) { |
2871 | fn += ".vcs"; | 2872 | fn += ".vcs"; |
2872 | FileStorage storage( cal, fn, new VCalFormat ); | 2873 | FileStorage storage( cal, fn, new VCalFormat ); |
2873 | storage.save(); | 2874 | storage.save(); |
2874 | } else { | 2875 | } else { |
2875 | fn += ".ics"; | 2876 | fn += ".ics"; |
2876 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2877 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2877 | storage.save(); | 2878 | storage.save(); |
2878 | } | 2879 | } |
2879 | delete cal; | 2880 | delete cal; |
2880 | mes = i18n("KO/Pi: Ready for beaming"); | 2881 | mes = i18n("KO/Pi: Ready for beaming"); |
2881 | topLevelWidget()->setCaption(mes); | 2882 | topLevelWidget()->setCaption(mes); |
2882 | KApplication::convert2latin1( fn ); | 2883 | KApplication::convert2latin1( fn ); |
2883 | #ifndef DESKTOP_VERSION | 2884 | #ifndef DESKTOP_VERSION |
2884 | Ir *ir = new Ir( this ); | 2885 | Ir *ir = new Ir( this ); |
2885 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2886 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2886 | ir->send( fn, description, "text/x-vCalendar" ); | 2887 | ir->send( fn, description, "text/x-vCalendar" ); |
2887 | #endif | 2888 | #endif |
2888 | } | 2889 | } |
2889 | } | 2890 | } |
2890 | void CalendarView::beamDone( Ir *ir ) | 2891 | void CalendarView::beamDone( Ir *ir ) |
2891 | { | 2892 | { |
2892 | #ifndef DESKTOP_VERSION | 2893 | #ifndef DESKTOP_VERSION |
2893 | delete ir; | 2894 | delete ir; |
2894 | #endif | 2895 | #endif |
2895 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2896 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2896 | topLevelWidget()->raise(); | 2897 | topLevelWidget()->raise(); |
2897 | } | 2898 | } |
2898 | 2899 | ||
2899 | void CalendarView::moveIncidence(Incidence * inc ) | 2900 | void CalendarView::moveIncidence(Incidence * inc ) |
2900 | { | 2901 | { |
2901 | if ( !inc ) return; | 2902 | if ( !inc ) return; |
2902 | showDatePickerPopup(); | 2903 | showDatePickerPopup(); |
2903 | mDatePickerMode = 2; | 2904 | mDatePickerMode = 2; |
2904 | mMoveIncidence = inc ; | 2905 | mMoveIncidence = inc ; |
2905 | QDate da; | 2906 | QDate da; |
2906 | if ( mMoveIncidence->typeID() == todoID ) { | 2907 | if ( mMoveIncidence->typeID() == todoID ) { |
2907 | Todo * to = (Todo *) mMoveIncidence; | 2908 | Todo * to = (Todo *) mMoveIncidence; |
2908 | if ( to->hasDueDate() ) | 2909 | if ( to->hasDueDate() ) |
2909 | da = to->dtDue().date(); | 2910 | da = to->dtDue().date(); |
2910 | else | 2911 | else |
2911 | da = QDate::currentDate(); | 2912 | da = QDate::currentDate(); |
2912 | } else { | 2913 | } else { |
2913 | da = mMoveIncidence->dtStart().date(); | 2914 | da = mMoveIncidence->dtStart().date(); |
2914 | } | 2915 | } |
2915 | //PENDING set date for recurring incidence to date of recurrence | 2916 | //PENDING set date for recurring incidence to date of recurrence |
2916 | //mMoveIncidenceOldDate; | 2917 | //mMoveIncidenceOldDate; |
2917 | mDatePicker->setDate( da ); | 2918 | mDatePicker->setDate( da ); |
2918 | } | 2919 | } |
2919 | void CalendarView::showDatePickerPopup() | 2920 | void CalendarView::showDatePickerPopup() |
2920 | { | 2921 | { |
2921 | if ( mDateFrame->isVisible() ) | 2922 | if ( mDateFrame->isVisible() ) |
2922 | mDateFrame->hide(); | 2923 | mDateFrame->hide(); |
2923 | else { | 2924 | else { |
2924 | int offX = 0, offY = 0; | 2925 | int offX = 0, offY = 0; |
2925 | #ifdef DESKTOP_VERSION | 2926 | #ifdef DESKTOP_VERSION |
2926 | int w =mDatePicker->sizeHint().width() ; | 2927 | int w =mDatePicker->sizeHint().width() ; |
2927 | int h = mDatePicker->sizeHint().height() ; | 2928 | int h = mDatePicker->sizeHint().height() ; |
2928 | int dw = topLevelWidget()->width(); | 2929 | int dw = topLevelWidget()->width(); |
2929 | int dh = topLevelWidget()->height(); | 2930 | int dh = topLevelWidget()->height(); |
2930 | offX = topLevelWidget()->x(); | 2931 | offX = topLevelWidget()->x(); |
2931 | offY = topLevelWidget()->y(); | 2932 | offY = topLevelWidget()->y(); |
2932 | #else | 2933 | #else |
2933 | int w =mDatePicker->sizeHint().width() ; | 2934 | int w =mDatePicker->sizeHint().width() ; |
2934 | int h = mDatePicker->sizeHint().height() ; | 2935 | int h = mDatePicker->sizeHint().height() ; |
2935 | int dw = QApplication::desktop()->width(); | 2936 | int dw = QApplication::desktop()->width(); |
2936 | int dh = QApplication::desktop()->height(); | 2937 | int dh = QApplication::desktop()->height(); |
2937 | #endif | 2938 | #endif |
2938 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2939 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2939 | mDateFrame->show(); | 2940 | mDateFrame->show(); |
2940 | } | 2941 | } |
2941 | } | 2942 | } |
2942 | void CalendarView::showDatePicker( ) | 2943 | void CalendarView::showDatePicker( ) |
2943 | { | 2944 | { |
2944 | showDatePickerPopup(); | 2945 | showDatePickerPopup(); |
2945 | mDatePickerMode = 1; | 2946 | mDatePickerMode = 1; |
2946 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2947 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2947 | } | 2948 | } |
2948 | 2949 | ||
2949 | void CalendarView::showEventEditor() | 2950 | void CalendarView::showEventEditor() |
2950 | { | 2951 | { |
2951 | #ifdef DESKTOP_VERSION | 2952 | #ifdef DESKTOP_VERSION |
2952 | int x,y,w,h; | 2953 | int x,y,w,h; |
2953 | x = mEventEditor->geometry().x(); | 2954 | x = mEventEditor->geometry().x(); |
2954 | y = mEventEditor->geometry().y(); | 2955 | y = mEventEditor->geometry().y(); |
2955 | w = mEventEditor->width(); | 2956 | w = mEventEditor->width(); |
2956 | h = mEventEditor->height(); | 2957 | h = mEventEditor->height(); |
2957 | mEventEditor->show(); | 2958 | mEventEditor->show(); |
2958 | mEventEditor->setGeometry(x,y,w,h); | 2959 | mEventEditor->setGeometry(x,y,w,h); |
2959 | #else | 2960 | #else |
2960 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2961 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2961 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2962 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2962 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2963 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2963 | qApp->processEvents(); | 2964 | qApp->processEvents(); |
2964 | delete mEventEditor; | 2965 | delete mEventEditor; |
2965 | mEventEditor = mDialogManager->getEventEditor(); | 2966 | mEventEditor = mDialogManager->getEventEditor(); |
2966 | topLevelWidget()->setCaption( i18n("") ); | 2967 | topLevelWidget()->setCaption( i18n("") ); |
2967 | } | 2968 | } |
2968 | mEventEditor->showMaximized(); | 2969 | mEventEditor->showMaximized(); |
2969 | #endif | 2970 | #endif |
2970 | } | 2971 | } |
2971 | void CalendarView::showTodoEditor() | 2972 | void CalendarView::showTodoEditor() |
2972 | { | 2973 | { |
2973 | #ifdef DESKTOP_VERSION | 2974 | #ifdef DESKTOP_VERSION |
2974 | int x,y,w,h; | 2975 | int x,y,w,h; |
2975 | x = mTodoEditor->geometry().x(); | 2976 | x = mTodoEditor->geometry().x(); |
2976 | y = mTodoEditor->geometry().y(); | 2977 | y = mTodoEditor->geometry().y(); |
2977 | w = mTodoEditor->width(); | 2978 | w = mTodoEditor->width(); |
2978 | h = mTodoEditor->height(); | 2979 | h = mTodoEditor->height(); |
2979 | mTodoEditor->show(); | 2980 | mTodoEditor->show(); |
2980 | mTodoEditor->setGeometry(x,y,w,h); | 2981 | mTodoEditor->setGeometry(x,y,w,h); |
2981 | #else | 2982 | #else |
2982 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2983 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2983 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2984 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2984 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2985 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2985 | qApp->processEvents(); | 2986 | qApp->processEvents(); |
2986 | delete mTodoEditor; | 2987 | delete mTodoEditor; |
2987 | mTodoEditor = mDialogManager->getTodoEditor(); | 2988 | mTodoEditor = mDialogManager->getTodoEditor(); |
2988 | topLevelWidget()->setCaption( i18n("") ); | 2989 | topLevelWidget()->setCaption( i18n("") ); |
2989 | } | 2990 | } |
2990 | mTodoEditor->showMaximized(); | 2991 | mTodoEditor->showMaximized(); |
2991 | #endif | 2992 | #endif |
2992 | } | 2993 | } |
2993 | 2994 | ||
2994 | void CalendarView::cloneIncidence() | 2995 | void CalendarView::cloneIncidence() |
2995 | { | 2996 | { |
2996 | Incidence *incidence = currentSelection(); | 2997 | Incidence *incidence = currentSelection(); |
2997 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2998 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2998 | if ( incidence ) { | 2999 | if ( incidence ) { |
2999 | cloneIncidence(incidence); | 3000 | cloneIncidence(incidence); |
3000 | } | 3001 | } |
3001 | } | 3002 | } |
3002 | void CalendarView::moveIncidence() | 3003 | void CalendarView::moveIncidence() |
3003 | { | 3004 | { |
3004 | Incidence *incidence = currentSelection(); | 3005 | Incidence *incidence = currentSelection(); |
3005 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3006 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3006 | if ( incidence ) { | 3007 | if ( incidence ) { |
3007 | moveIncidence(incidence); | 3008 | moveIncidence(incidence); |
3008 | } | 3009 | } |
3009 | } | 3010 | } |
3010 | void CalendarView::beamIncidence() | 3011 | void CalendarView::beamIncidence() |
3011 | { | 3012 | { |
3012 | Incidence *incidence = currentSelection(); | 3013 | Incidence *incidence = currentSelection(); |
3013 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3014 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3014 | if ( incidence ) { | 3015 | if ( incidence ) { |
3015 | beamIncidence(incidence); | 3016 | beamIncidence(incidence); |
3016 | } | 3017 | } |
3017 | } | 3018 | } |
3018 | void CalendarView::toggleCancelIncidence() | 3019 | void CalendarView::toggleCancelIncidence() |
3019 | { | 3020 | { |
3020 | Incidence *incidence = currentSelection(); | 3021 | Incidence *incidence = currentSelection(); |
3021 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3022 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3022 | if ( incidence ) { | 3023 | if ( incidence ) { |
3023 | cancelIncidence(incidence); | 3024 | cancelIncidence(incidence); |
3024 | } | 3025 | } |
3025 | } | 3026 | } |
3026 | 3027 | ||
3027 | 3028 | ||
3028 | void CalendarView::cancelIncidence(Incidence * inc ) | 3029 | void CalendarView::cancelIncidence(Incidence * inc ) |
3029 | { | 3030 | { |
3030 | inc->setCancelled( ! inc->cancelled() ); | 3031 | inc->setCancelled( ! inc->cancelled() ); |
3031 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3032 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3032 | updateView(); | 3033 | updateView(); |
3033 | } | 3034 | } |
3034 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3035 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3035 | { | 3036 | { |
3036 | Incidence * newInc = orgInc->clone(); | 3037 | Incidence * newInc = orgInc->clone(); |
3037 | newInc->recreate(); | 3038 | newInc->recreate(); |
3038 | 3039 | ||
3039 | if ( newInc->typeID() == todoID ) { | 3040 | if ( newInc->typeID() == todoID ) { |
3040 | Todo* t = (Todo*) newInc; | 3041 | Todo* t = (Todo*) newInc; |
3041 | bool cloneSub = false; | 3042 | bool cloneSub = false; |
3042 | if ( orgInc->relations().count() ) { | 3043 | if ( orgInc->relations().count() ) { |
3043 | int result = KMessageBox::warningYesNoCancel(this, | 3044 | int result = KMessageBox::warningYesNoCancel(this, |
3044 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), | 3045 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), |
3045 | i18n("Todo has subtodos"), | 3046 | i18n("Todo has subtodos"), |
3046 | i18n("Yes"), | 3047 | i18n("Yes"), |
3047 | i18n("No")); | 3048 | i18n("No")); |
3048 | 3049 | ||
3049 | if ( result == KMessageBox::Cancel ) { | 3050 | if ( result == KMessageBox::Cancel ) { |
3050 | delete t; | 3051 | delete t; |
3051 | return; | 3052 | return; |
3052 | } | 3053 | } |
3053 | if (result == KMessageBox::Yes) cloneSub = true; | 3054 | if (result == KMessageBox::Yes) cloneSub = true; |
3054 | } | 3055 | } |
3055 | showTodoEditor(); | 3056 | showTodoEditor(); |
3056 | mTodoEditor->editTodo( t ); | 3057 | mTodoEditor->editTodo( t ); |
3057 | if ( mTodoEditor->exec() ) { | 3058 | if ( mTodoEditor->exec() ) { |
3058 | if ( cloneSub ) { | 3059 | if ( cloneSub ) { |
3059 | orgInc->cloneRelations( t ); | 3060 | orgInc->cloneRelations( t ); |
3060 | mCalendar->addIncidenceBranch( t ); | 3061 | mCalendar->addIncidenceBranch( t ); |
3061 | updateView(); | 3062 | updateView(); |
3062 | 3063 | ||
3063 | } else { | 3064 | } else { |
3064 | mCalendar->addTodo( t ); | 3065 | mCalendar->addTodo( t ); |
3065 | updateView(); | 3066 | updateView(); |
3066 | } | 3067 | } |
3067 | } else { | 3068 | } else { |
3068 | delete t; | 3069 | delete t; |
3069 | } | 3070 | } |
3070 | } | 3071 | } |
3071 | else { | 3072 | else { |
3072 | Event* e = (Event*) newInc; | 3073 | Event* e = (Event*) newInc; |
3073 | showEventEditor(); | 3074 | showEventEditor(); |
3074 | mEventEditor->editEvent( e ); | 3075 | mEventEditor->editEvent( e ); |
3075 | if ( mEventEditor->exec() ) { | 3076 | if ( mEventEditor->exec() ) { |
3076 | mCalendar->addEvent( e ); | 3077 | mCalendar->addEvent( e ); |
3077 | updateView(); | 3078 | updateView(); |
3078 | } else { | 3079 | } else { |
3079 | delete e; | 3080 | delete e; |
3080 | } | 3081 | } |
3081 | } | 3082 | } |
3082 | setActiveWindow(); | 3083 | setActiveWindow(); |
3083 | } | 3084 | } |
3084 | 3085 | ||
3085 | void CalendarView::newEvent() | 3086 | void CalendarView::newEvent() |
3086 | { | 3087 | { |
3087 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3088 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3088 | KOAgendaView *aView = mViewManager->agendaView(); | 3089 | KOAgendaView *aView = mViewManager->agendaView(); |
3089 | if (aView) { | 3090 | if (aView) { |
3090 | if (aView->selectionStart().isValid()) { | 3091 | if (aView->selectionStart().isValid()) { |
3091 | if (aView->selectedIsAllDay()) { | 3092 | if (aView->selectedIsAllDay()) { |
3092 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3093 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3093 | } else { | 3094 | } else { |
3094 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3095 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3095 | } | 3096 | } |
3096 | return; | 3097 | return; |
3097 | } | 3098 | } |
3098 | } | 3099 | } |
3099 | 3100 | ||
3100 | QDate date = mNavigator->selectedDates().first(); | 3101 | QDate date = mNavigator->selectedDates().first(); |
3101 | QDateTime current = QDateTime::currentDateTime(); | 3102 | QDateTime current = QDateTime::currentDateTime(); |
3102 | if ( date <= current.date() ) { | 3103 | if ( date <= current.date() ) { |
3103 | int hour = current.time().hour() +1; | 3104 | int hour = current.time().hour() +1; |
3104 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3105 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3105 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3106 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3106 | } else | 3107 | } else |
3107 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3108 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3108 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3109 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3109 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3110 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3110 | } | 3111 | } |
3111 | 3112 | ||
3112 | void CalendarView::newEvent(QDateTime fh) | 3113 | void CalendarView::newEvent(QDateTime fh) |
3113 | { | 3114 | { |
3114 | newEvent(fh, | 3115 | newEvent(fh, |
3115 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3116 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3116 | } | 3117 | } |
3117 | 3118 | ||
3118 | void CalendarView::newEvent(QDate dt) | 3119 | void CalendarView::newEvent(QDate dt) |
3119 | { | 3120 | { |
3120 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3121 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3121 | QDateTime(dt, QTime(0,0,0)), true); | 3122 | QDateTime(dt, QTime(0,0,0)), true); |
3122 | } | 3123 | } |
3123 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3124 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3124 | { | 3125 | { |
3125 | newEvent(fromHint, toHint, false); | 3126 | newEvent(fromHint, toHint, false); |
3126 | } | 3127 | } |
3127 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3128 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3128 | { | 3129 | { |
3129 | 3130 | ||
3130 | showEventEditor(); | 3131 | showEventEditor(); |
3131 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3132 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3132 | if ( mFilterView->filtersEnabled() ) { | 3133 | if ( mFilterView->filtersEnabled() ) { |
3133 | CalFilter *filter = mFilterView->selectedFilter(); | 3134 | CalFilter *filter = mFilterView->selectedFilter(); |
3134 | if (filter && filter->showCategories()) { | 3135 | if (filter && filter->showCategories()) { |
3135 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3136 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3136 | } | 3137 | } |
3137 | if ( filter ) | 3138 | if ( filter ) |
3138 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3139 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3139 | } | 3140 | } |
3140 | mEventEditor->exec(); | 3141 | mEventEditor->exec(); |
3141 | setActiveWindow(); | 3142 | setActiveWindow(); |
3142 | } | 3143 | } |
3143 | void CalendarView::todoAdded(Todo * t) | 3144 | void CalendarView::todoAdded(Todo * t) |
3144 | { | 3145 | { |
3145 | 3146 | ||
3146 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3147 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3147 | updateTodoViews(); | 3148 | updateTodoViews(); |
3148 | } | 3149 | } |
3149 | void CalendarView::todoChanged(Todo * t) | 3150 | void CalendarView::todoChanged(Todo * t) |
3150 | { | 3151 | { |
3151 | emit todoModified( t, 4 ); | 3152 | emit todoModified( t, 4 ); |
3152 | // updateTodoViews(); | 3153 | // updateTodoViews(); |
3153 | } | 3154 | } |
3154 | void CalendarView::todoToBeDeleted(Todo *) | 3155 | void CalendarView::todoToBeDeleted(Todo *) |
3155 | { | 3156 | { |
3156 | //qDebug("todoToBeDeleted(Todo *) "); | 3157 | //qDebug("todoToBeDeleted(Todo *) "); |
3157 | updateTodoViews(); | 3158 | updateTodoViews(); |
3158 | } | 3159 | } |
3159 | void CalendarView::todoDeleted() | 3160 | void CalendarView::todoDeleted() |
3160 | { | 3161 | { |
3161 | //qDebug(" todoDeleted()"); | 3162 | //qDebug(" todoDeleted()"); |
3162 | updateTodoViews(); | 3163 | updateTodoViews(); |
3163 | } | 3164 | } |
3164 | 3165 | ||
3165 | 3166 | ||
3166 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3167 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3167 | { | 3168 | { |
3168 | showTodoEditor(); | 3169 | showTodoEditor(); |
3169 | mTodoEditor->newTodo(dt,0,allday); | 3170 | mTodoEditor->newTodo(dt,0,allday); |
3170 | if ( mFilterView->filtersEnabled() ) { | 3171 | if ( mFilterView->filtersEnabled() ) { |
3171 | CalFilter *filter = mFilterView->selectedFilter(); | 3172 | CalFilter *filter = mFilterView->selectedFilter(); |
3172 | if (filter && filter->showCategories()) { | 3173 | if (filter && filter->showCategories()) { |
3173 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3174 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3174 | } | 3175 | } |
3175 | if ( filter ) | 3176 | if ( filter ) |
3176 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3177 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3177 | } | 3178 | } |
3178 | mTodoEditor->exec(); | 3179 | mTodoEditor->exec(); |
3179 | setActiveWindow(); | 3180 | setActiveWindow(); |
3180 | } | 3181 | } |
3181 | 3182 | ||
3182 | void CalendarView::newTodo() | 3183 | void CalendarView::newTodo() |
3183 | { | 3184 | { |
3184 | newTodoDateTime( QDateTime(),true ); | 3185 | newTodoDateTime( QDateTime(),true ); |
3185 | } | 3186 | } |
3186 | 3187 | ||
3187 | void CalendarView::newSubTodo() | 3188 | void CalendarView::newSubTodo() |
3188 | { | 3189 | { |
3189 | Todo *todo = selectedTodo(); | 3190 | Todo *todo = selectedTodo(); |
3190 | if ( todo ) newSubTodo( todo ); | 3191 | if ( todo ) newSubTodo( todo ); |
3191 | } | 3192 | } |
3192 | 3193 | ||
3193 | void CalendarView::newSubTodo(Todo *parentEvent) | 3194 | void CalendarView::newSubTodo(Todo *parentEvent) |
3194 | { | 3195 | { |
3195 | 3196 | ||
3196 | showTodoEditor(); | 3197 | showTodoEditor(); |
3197 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3198 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3198 | mTodoEditor->exec(); | 3199 | mTodoEditor->exec(); |
3199 | setActiveWindow(); | 3200 | setActiveWindow(); |
3200 | } | 3201 | } |
3201 | 3202 | ||
3202 | void CalendarView::newFloatingEvent() | 3203 | void CalendarView::newFloatingEvent() |
3203 | { | 3204 | { |
3204 | DateList tmpList = mNavigator->selectedDates(); | 3205 | DateList tmpList = mNavigator->selectedDates(); |
3205 | QDate date = tmpList.first(); | 3206 | QDate date = tmpList.first(); |
3206 | 3207 | ||
3207 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3208 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3208 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3209 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3209 | } | 3210 | } |
3210 | 3211 | ||
3211 | 3212 | ||
3212 | void CalendarView::editEvent( Event *event ) | 3213 | void CalendarView::editEvent( Event *event ) |
3213 | { | 3214 | { |
3214 | 3215 | ||
3215 | if ( !event ) return; | 3216 | if ( !event ) return; |
3216 | if ( event->isReadOnly() ) { | 3217 | if ( event->isReadOnly() ) { |
3217 | showEvent( event ); | 3218 | showEvent( event ); |
3218 | return; | 3219 | return; |
3219 | } | 3220 | } |
3220 | showEventEditor(); | 3221 | showEventEditor(); |
3221 | mEventEditor->editEvent( event , mFlagEditDescription); | 3222 | mEventEditor->editEvent( event , mFlagEditDescription); |
3222 | mEventEditor->exec(); | 3223 | mEventEditor->exec(); |
3223 | setActiveWindow(); | 3224 | setActiveWindow(); |
3224 | 3225 | ||
3225 | } | 3226 | } |
3226 | void CalendarView::editJournal( Journal *jour ) | 3227 | void CalendarView::editJournal( Journal *jour ) |
3227 | { | 3228 | { |
3228 | if ( !jour ) return; | 3229 | if ( !jour ) return; |
3229 | mDialogManager->hideSearchDialog(); | 3230 | mDialogManager->hideSearchDialog(); |
3230 | mViewManager->showJournalView(); | 3231 | mViewManager->showJournalView(); |
3231 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3232 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3232 | } | 3233 | } |
3233 | void CalendarView::editTodo( Todo *todo ) | 3234 | void CalendarView::editTodo( Todo *todo ) |
3234 | { | 3235 | { |
3235 | if ( !todo ) return; | 3236 | if ( !todo ) return; |
3236 | 3237 | ||
3237 | if ( todo->isReadOnly() ) { | 3238 | if ( todo->isReadOnly() ) { |
3238 | showTodo( todo ); | 3239 | showTodo( todo ); |
3239 | return; | 3240 | return; |
3240 | } | 3241 | } |
3241 | showTodoEditor(); | 3242 | showTodoEditor(); |
3242 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3243 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3243 | mTodoEditor->exec(); | 3244 | mTodoEditor->exec(); |
3244 | setActiveWindow(); | 3245 | setActiveWindow(); |
3245 | 3246 | ||
3246 | } | 3247 | } |
3247 | 3248 | ||
3248 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3249 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3249 | { | 3250 | { |
3250 | if ( !mEventViewerDialog ) { | 3251 | if ( !mEventViewerDialog ) { |
3251 | mEventViewerDialog = new KOEventViewerDialog(0); | 3252 | mEventViewerDialog = new KOEventViewerDialog(0); |
3252 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3253 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3253 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3254 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3254 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3255 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3255 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3256 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3256 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3257 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3257 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3258 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3258 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3259 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3259 | this, SLOT( slotViewerClosed() ) ); | 3260 | this, SLOT( slotViewerClosed() ) ); |
3260 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3261 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3261 | this, SLOT( todoChanged(Todo *) ) ); | 3262 | this, SLOT( todoChanged(Todo *) ) ); |
3262 | mEventViewerDialog->resize( 640, 480 ); | 3263 | mEventViewerDialog->resize( 640, 480 ); |
3263 | 3264 | ||
3264 | } | 3265 | } |
3265 | return mEventViewerDialog; | 3266 | return mEventViewerDialog; |
3266 | } | 3267 | } |
3267 | void CalendarView::showEvent(Event *event) | 3268 | void CalendarView::showEvent(Event *event) |
3268 | { | 3269 | { |
3269 | getEventViewerDialog()->setEvent(event); | 3270 | getEventViewerDialog()->setEvent(event); |
3270 | getEventViewerDialog()->showMe(); | 3271 | getEventViewerDialog()->showMe(); |
3271 | } | 3272 | } |
3272 | 3273 | ||
3273 | void CalendarView::showTodo(Todo *event) | 3274 | void CalendarView::showTodo(Todo *event) |
3274 | { | 3275 | { |
3275 | getEventViewerDialog()->setTodo(event); | 3276 | getEventViewerDialog()->setTodo(event); |
3276 | getEventViewerDialog()->showMe(); | 3277 | getEventViewerDialog()->showMe(); |
3277 | } | 3278 | } |
3278 | void CalendarView::showJournal( Journal *jour ) | 3279 | void CalendarView::showJournal( Journal *jour ) |
3279 | { | 3280 | { |
3280 | getEventViewerDialog()->setJournal(jour); | 3281 | getEventViewerDialog()->setJournal(jour); |
3281 | getEventViewerDialog()->showMe(); | 3282 | getEventViewerDialog()->showMe(); |
3282 | 3283 | ||
3283 | } | 3284 | } |
3284 | // void CalendarView::todoModified (Todo *event, int changed) | 3285 | // void CalendarView::todoModified (Todo *event, int changed) |
3285 | // { | 3286 | // { |
3286 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3287 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3287 | // // kdDebug() << "Todo modified and open" << endl; | 3288 | // // kdDebug() << "Todo modified and open" << endl; |
3288 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3289 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3289 | // // temp->modified (changed); | 3290 | // // temp->modified (changed); |
3290 | 3291 | ||
3291 | // // } | 3292 | // // } |
3292 | 3293 | ||
3293 | // mViewManager->updateView(); | 3294 | // mViewManager->updateView(); |
3294 | // } | 3295 | // } |
3295 | 3296 | ||
3296 | void CalendarView::appointment_show() | 3297 | void CalendarView::appointment_show() |
3297 | { | 3298 | { |
3298 | Event *anEvent = 0; | 3299 | Event *anEvent = 0; |
3299 | 3300 | ||
3300 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3301 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3301 | 3302 | ||
3302 | if (mViewManager->currentView()->isEventView()) { | 3303 | if (mViewManager->currentView()->isEventView()) { |
3303 | if ( incidence && incidence->typeID() == eventID ) { | 3304 | if ( incidence && incidence->typeID() == eventID ) { |
3304 | anEvent = static_cast<Event *>(incidence); | 3305 | anEvent = static_cast<Event *>(incidence); |
3305 | } | 3306 | } |
3306 | } | 3307 | } |
3307 | 3308 | ||
3308 | if (!anEvent) { | 3309 | if (!anEvent) { |
3309 | KNotifyClient::beep(); | 3310 | KNotifyClient::beep(); |
3310 | return; | 3311 | return; |
3311 | } | 3312 | } |
3312 | 3313 | ||
3313 | showEvent(anEvent); | 3314 | showEvent(anEvent); |
3314 | } | 3315 | } |
3315 | 3316 | ||
3316 | void CalendarView::appointment_edit() | 3317 | void CalendarView::appointment_edit() |
3317 | { | 3318 | { |
3318 | Event *anEvent = 0; | 3319 | Event *anEvent = 0; |
3319 | 3320 | ||
3320 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3321 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3321 | 3322 | ||
3322 | if (mViewManager->currentView()->isEventView()) { | 3323 | if (mViewManager->currentView()->isEventView()) { |
3323 | if ( incidence && incidence->typeID() == eventID ) { | 3324 | if ( incidence && incidence->typeID() == eventID ) { |
3324 | anEvent = static_cast<Event *>(incidence); | 3325 | anEvent = static_cast<Event *>(incidence); |
3325 | } | 3326 | } |
3326 | } | 3327 | } |
3327 | 3328 | ||
3328 | if (!anEvent) { | 3329 | if (!anEvent) { |
3329 | KNotifyClient::beep(); | 3330 | KNotifyClient::beep(); |
3330 | return; | 3331 | return; |
3331 | } | 3332 | } |
3332 | 3333 | ||
3333 | editEvent(anEvent); | 3334 | editEvent(anEvent); |
3334 | } | 3335 | } |
3335 | 3336 | ||
3336 | void CalendarView::appointment_delete() | 3337 | void CalendarView::appointment_delete() |
3337 | { | 3338 | { |
3338 | Event *anEvent = 0; | 3339 | Event *anEvent = 0; |
3339 | 3340 | ||
3340 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3341 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3341 | 3342 | ||
3342 | if (mViewManager->currentView()->isEventView()) { | 3343 | if (mViewManager->currentView()->isEventView()) { |
3343 | if ( incidence && incidence->typeID() == eventID ) { | 3344 | if ( incidence && incidence->typeID() == eventID ) { |
3344 | anEvent = static_cast<Event *>(incidence); | 3345 | anEvent = static_cast<Event *>(incidence); |
3345 | } | 3346 | } |
3346 | } | 3347 | } |
3347 | 3348 | ||
3348 | if (!anEvent) { | 3349 | if (!anEvent) { |
3349 | KNotifyClient::beep(); | 3350 | KNotifyClient::beep(); |
3350 | return; | 3351 | return; |
3351 | } | 3352 | } |
3352 | 3353 | ||
3353 | deleteEvent(anEvent); | 3354 | deleteEvent(anEvent); |
3354 | } | 3355 | } |
3355 | 3356 | ||
3356 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3357 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3357 | { | 3358 | { |
3358 | if (!sub) return; | 3359 | if (!sub) return; |
3359 | if ( sub->relatedTo() == parent ) | 3360 | if ( sub->relatedTo() == parent ) |
3360 | return; | 3361 | return; |
3361 | sub->setRelatedTo(parent); | 3362 | sub->setRelatedTo(parent); |
3362 | sub->updated(); | 3363 | sub->updated(); |
3363 | setModified(true); | 3364 | setModified(true); |
3364 | updateView(); | 3365 | updateView(); |
3365 | } | 3366 | } |
3366 | void CalendarView::todo_unsub(Todo *anTodo ) | 3367 | void CalendarView::todo_unsub(Todo *anTodo ) |
3367 | { | 3368 | { |
3368 | todo_resub( 0, anTodo ); | 3369 | todo_resub( 0, anTodo ); |
3369 | } | 3370 | } |
3370 | 3371 | ||
3371 | void CalendarView::deleteTodo(Todo *todo) | 3372 | void CalendarView::deleteTodo(Todo *todo) |
3372 | { | 3373 | { |
3373 | if (!todo) { | 3374 | if (!todo) { |
3374 | KNotifyClient::beep(); | 3375 | KNotifyClient::beep(); |
3375 | return; | 3376 | return; |
3376 | } | 3377 | } |
3377 | if (KOPrefs::instance()->mConfirm) { | 3378 | if (KOPrefs::instance()->mConfirm) { |
3378 | QString text = todo->summary().left(20); | 3379 | QString text = todo->summary().left(20); |
3379 | if (!todo->relations().isEmpty()) { | 3380 | if (!todo->relations().isEmpty()) { |
3380 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3381 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3381 | 3382 | ||
3382 | } | 3383 | } |
3383 | switch (msgItemDelete(text)) { | 3384 | switch (msgItemDelete(text)) { |
3384 | case KMessageBox::Continue: // OK | 3385 | case KMessageBox::Continue: // OK |
3385 | bool deleteT = false; | 3386 | bool deleteT = false; |
3386 | if (!todo->relations().isEmpty()) { | 3387 | if (!todo->relations().isEmpty()) { |
3387 | deleteT = removeCompletedSubTodos( todo ); | 3388 | deleteT = removeCompletedSubTodos( todo ); |
3388 | } | 3389 | } |
3389 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3390 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3390 | if ( !deleteT ) { | 3391 | if ( !deleteT ) { |
3391 | checkExternalId( todo ); | 3392 | checkExternalId( todo ); |
3392 | calendar()->deleteTodo(todo); | 3393 | calendar()->deleteTodo(todo); |
3393 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3394 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3394 | updateView(); | 3395 | updateView(); |
3395 | } | 3396 | } |
3396 | break; | 3397 | break; |
3397 | } // switch | 3398 | } // switch |
3398 | } else { | 3399 | } else { |
3399 | checkExternalId( todo ); | 3400 | checkExternalId( todo ); |
3400 | mCalendar->deleteTodo(todo); | 3401 | mCalendar->deleteTodo(todo); |
3401 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3402 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3402 | updateView(); | 3403 | updateView(); |
3403 | } | 3404 | } |
3404 | 3405 | ||
3405 | emit updateSearchDialog(); | 3406 | emit updateSearchDialog(); |
3406 | } | 3407 | } |
3407 | void CalendarView::deleteJournal(Journal *jour) | 3408 | void CalendarView::deleteJournal(Journal *jour) |
3408 | { | 3409 | { |
3409 | if (!jour) { | 3410 | if (!jour) { |
3410 | KNotifyClient::beep(); | 3411 | KNotifyClient::beep(); |
3411 | return; | 3412 | return; |
3412 | } | 3413 | } |
3413 | if (KOPrefs::instance()->mConfirm) { | 3414 | if (KOPrefs::instance()->mConfirm) { |
3414 | switch (msgItemDelete( jour->description().left(20))) { | 3415 | switch (msgItemDelete( jour->description().left(20))) { |
3415 | case KMessageBox::Continue: // OK | 3416 | case KMessageBox::Continue: // OK |
3416 | calendar()->deleteJournal(jour); | 3417 | calendar()->deleteJournal(jour); |
3417 | updateView(); | 3418 | updateView(); |
3418 | break; | 3419 | break; |
3419 | } // switch | 3420 | } // switch |
3420 | } else { | 3421 | } else { |
3421 | calendar()->deleteJournal(jour);; | 3422 | calendar()->deleteJournal(jour);; |
3422 | updateView(); | 3423 | updateView(); |
3423 | } | 3424 | } |
3424 | emit updateSearchDialog(); | 3425 | emit updateSearchDialog(); |
3425 | } | 3426 | } |
3426 | 3427 | ||
3427 | void CalendarView::deleteEvent(Event *anEvent) | 3428 | void CalendarView::deleteEvent(Event *anEvent) |
3428 | { | 3429 | { |
3429 | if (!anEvent) { | 3430 | if (!anEvent) { |
3430 | KNotifyClient::beep(); | 3431 | KNotifyClient::beep(); |
3431 | return; | 3432 | return; |
3432 | } | 3433 | } |
3433 | 3434 | ||
3434 | if (anEvent->recurrence()->doesRecur()) { | 3435 | if (anEvent->recurrence()->doesRecur()) { |
3435 | QDate itemDate = mViewManager->currentSelectionDate(); | 3436 | QDate itemDate = mViewManager->currentSelectionDate(); |
3436 | int km; | 3437 | int km; |
3437 | if (!itemDate.isValid()) { | 3438 | if (!itemDate.isValid()) { |
3438 | //kdDebug() << "Date Not Valid" << endl; | 3439 | //kdDebug() << "Date Not Valid" << endl; |
3439 | if (KOPrefs::instance()->mConfirm) { | 3440 | if (KOPrefs::instance()->mConfirm) { |
3440 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3441 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3441 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3442 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3442 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3443 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3443 | if ( km == KMessageBox::Continue ) | 3444 | if ( km == KMessageBox::Continue ) |
3444 | km = KMessageBox::No; // No = all below | 3445 | km = KMessageBox::No; // No = all below |
3445 | } else | 3446 | } else |
3446 | km = KMessageBox::No; | 3447 | km = KMessageBox::No; |
3447 | } else { | 3448 | } else { |
3448 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3449 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3449 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3450 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3450 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3451 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3451 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3452 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3452 | i18n("All")); | 3453 | i18n("All")); |
3453 | } | 3454 | } |
3454 | switch(km) { | 3455 | switch(km) { |
3455 | 3456 | ||
3456 | case KMessageBox::No: // Continue // all | 3457 | case KMessageBox::No: // Continue // all |
3457 | //qDebug("KMessageBox::No "); | 3458 | //qDebug("KMessageBox::No "); |
3458 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3459 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3459 | schedule(Scheduler::Cancel,anEvent); | 3460 | schedule(Scheduler::Cancel,anEvent); |
3460 | 3461 | ||
3461 | checkExternalId( anEvent); | 3462 | checkExternalId( anEvent); |
3462 | mCalendar->deleteEvent(anEvent); | 3463 | mCalendar->deleteEvent(anEvent); |
3463 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3464 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3464 | break; | 3465 | break; |
3465 | 3466 | ||
3466 | // Disabled because it does not work | 3467 | // Disabled because it does not work |
3467 | //#if 0 | 3468 | //#if 0 |
3468 | case KMessageBox::Yes: // just this one | 3469 | case KMessageBox::Yes: // just this one |
3469 | //QDate qd = mNavigator->selectedDates().first(); | 3470 | //QDate qd = mNavigator->selectedDates().first(); |
3470 | //if (!qd.isValid()) { | 3471 | //if (!qd.isValid()) { |
3471 | // kdDebug() << "no date selected, or invalid date" << endl; | 3472 | // kdDebug() << "no date selected, or invalid date" << endl; |
3472 | // KNotifyClient::beep(); | 3473 | // KNotifyClient::beep(); |
3473 | // return; | 3474 | // return; |
3474 | //} | 3475 | //} |
3475 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3476 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3476 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3477 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3477 | anEvent->addExDate(itemDate); | 3478 | anEvent->addExDate(itemDate); |
3478 | int duration = anEvent->recurrence()->duration(); | 3479 | int duration = anEvent->recurrence()->duration(); |
3479 | if ( duration > 0 ) { | 3480 | if ( duration > 0 ) { |
3480 | anEvent->recurrence()->setDuration( duration - 1 ); | 3481 | anEvent->recurrence()->setDuration( duration - 1 ); |
3481 | } | 3482 | } |
3482 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3483 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3483 | } | 3484 | } |
3484 | break; | 3485 | break; |
3485 | //#endif | 3486 | //#endif |
3486 | } // switch | 3487 | } // switch |
3487 | } else { | 3488 | } else { |
3488 | if (KOPrefs::instance()->mConfirm) { | 3489 | if (KOPrefs::instance()->mConfirm) { |
3489 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3490 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3490 | i18n("\nAre you sure you want\nto delete this event?"), | 3491 | i18n("\nAre you sure you want\nto delete this event?"), |
3491 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3492 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3492 | case KMessageBox::Continue: // OK | 3493 | case KMessageBox::Continue: // OK |
3493 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3494 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3494 | schedule(Scheduler::Cancel,anEvent); | 3495 | schedule(Scheduler::Cancel,anEvent); |
3495 | checkExternalId( anEvent); | 3496 | checkExternalId( anEvent); |
3496 | mCalendar->deleteEvent(anEvent); | 3497 | mCalendar->deleteEvent(anEvent); |
3497 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3498 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3498 | break; | 3499 | break; |
3499 | } // switch | 3500 | } // switch |
3500 | } else { | 3501 | } else { |
3501 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3502 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3502 | schedule(Scheduler::Cancel,anEvent); | 3503 | schedule(Scheduler::Cancel,anEvent); |
3503 | checkExternalId( anEvent); | 3504 | checkExternalId( anEvent); |
3504 | mCalendar->deleteEvent(anEvent); | 3505 | mCalendar->deleteEvent(anEvent); |
3505 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3506 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3506 | } | 3507 | } |
3507 | } // if-else | 3508 | } // if-else |
3508 | emit updateSearchDialog(); | 3509 | emit updateSearchDialog(); |
3509 | } | 3510 | } |
3510 | 3511 | ||
3511 | bool CalendarView::deleteEvent(const QString &uid) | 3512 | bool CalendarView::deleteEvent(const QString &uid) |
3512 | { | 3513 | { |
3513 | Event *ev = mCalendar->event(uid); | 3514 | Event *ev = mCalendar->event(uid); |
3514 | if (ev) { | 3515 | if (ev) { |
3515 | deleteEvent(ev); | 3516 | deleteEvent(ev); |
3516 | return true; | 3517 | return true; |
3517 | } else { | 3518 | } else { |
3518 | return false; | 3519 | return false; |
3519 | } | 3520 | } |
3520 | } | 3521 | } |
3521 | 3522 | ||
3522 | /*****************************************************************************/ | 3523 | /*****************************************************************************/ |
3523 | 3524 | ||
3524 | void CalendarView::action_mail() | 3525 | void CalendarView::action_mail() |
3525 | { | 3526 | { |
3526 | #ifndef KORG_NOMAIL | 3527 | #ifndef KORG_NOMAIL |
3527 | KOMailClient mailClient; | 3528 | KOMailClient mailClient; |
3528 | 3529 | ||
3529 | Incidence *incidence = currentSelection(); | 3530 | Incidence *incidence = currentSelection(); |
3530 | 3531 | ||
3531 | if (!incidence) { | 3532 | if (!incidence) { |
3532 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3533 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3533 | return; | 3534 | return; |
3534 | } | 3535 | } |
3535 | if(incidence->attendeeCount() == 0 ) { | 3536 | if(incidence->attendeeCount() == 0 ) { |
3536 | KMessageBox::sorry(this, | 3537 | KMessageBox::sorry(this, |
3537 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3538 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3538 | return; | 3539 | return; |
3539 | } | 3540 | } |
3540 | 3541 | ||
3541 | CalendarLocal cal_tmp; | 3542 | CalendarLocal cal_tmp; |
3542 | Event *event = 0; | 3543 | Event *event = 0; |
3543 | Event *ev = 0; | 3544 | Event *ev = 0; |
3544 | if ( incidence && incidence->typeID() == eventID ) { | 3545 | if ( incidence && incidence->typeID() == eventID ) { |
3545 | event = static_cast<Event *>(incidence); | 3546 | event = static_cast<Event *>(incidence); |
3546 | ev = new Event(*event); | 3547 | ev = new Event(*event); |
3547 | cal_tmp.addEvent(ev); | 3548 | cal_tmp.addEvent(ev); |
3548 | } | 3549 | } |
3549 | ICalFormat mForm(); | 3550 | ICalFormat mForm(); |
3550 | QString attachment = mForm.toString( &cal_tmp ); | 3551 | QString attachment = mForm.toString( &cal_tmp ); |
3551 | if (ev) delete(ev); | 3552 | if (ev) delete(ev); |
3552 | 3553 | ||
3553 | mailClient.mailAttendees(currentSelection(), attachment); | 3554 | mailClient.mailAttendees(currentSelection(), attachment); |
3554 | 3555 | ||
3555 | #endif | 3556 | #endif |
3556 | 3557 | ||
3557 | #if 0 | 3558 | #if 0 |
3558 | Event *anEvent = 0; | 3559 | Event *anEvent = 0; |
3559 | if (mViewManager->currentView()->isEventView()) { | 3560 | if (mViewManager->currentView()->isEventView()) { |
3560 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3561 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3561 | } | 3562 | } |
3562 | 3563 | ||
3563 | if (!anEvent) { | 3564 | if (!anEvent) { |
3564 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3565 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3565 | return; | 3566 | return; |
3566 | } | 3567 | } |
3567 | if(anEvent->attendeeCount() == 0 ) { | 3568 | if(anEvent->attendeeCount() == 0 ) { |
3568 | KMessageBox::sorry(this, | 3569 | KMessageBox::sorry(this, |
3569 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3570 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3570 | return; | 3571 | return; |
3571 | } | 3572 | } |
3572 | 3573 | ||
3573 | mailobject.emailEvent(anEvent); | 3574 | mailobject.emailEvent(anEvent); |
3574 | #endif | 3575 | #endif |
3575 | } | 3576 | } |
3576 | 3577 | ||
3577 | 3578 | ||
3578 | void CalendarView::schedule_publish(Incidence *incidence) | 3579 | void CalendarView::schedule_publish(Incidence *incidence) |
3579 | { | 3580 | { |
3580 | Event *event = 0; | 3581 | Event *event = 0; |
3581 | Todo *todo = 0; | 3582 | Todo *todo = 0; |
3582 | 3583 | ||
3583 | if (incidence == 0) { | 3584 | if (incidence == 0) { |
3584 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3585 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3585 | if (incidence == 0) { | 3586 | if (incidence == 0) { |
3586 | incidence = mTodoList->selectedIncidences().first(); | 3587 | incidence = mTodoList->selectedIncidences().first(); |
3587 | } | 3588 | } |
3588 | } | 3589 | } |
3589 | if ( incidence && incidence->typeID() == eventID ) { | 3590 | if ( incidence && incidence->typeID() == eventID ) { |
3590 | event = static_cast<Event *>(incidence); | 3591 | event = static_cast<Event *>(incidence); |
3591 | } else { | 3592 | } else { |
3592 | if ( incidence && incidence->typeID() == todoID ) { | 3593 | if ( incidence && incidence->typeID() == todoID ) { |
3593 | todo = static_cast<Todo *>(incidence); | 3594 | todo = static_cast<Todo *>(incidence); |
3594 | } | 3595 | } |
3595 | } | 3596 | } |
3596 | 3597 | ||
3597 | if (!event && !todo) { | 3598 | if (!event && !todo) { |
3598 | KMessageBox::sorry(this,i18n("No event selected.")); | 3599 | KMessageBox::sorry(this,i18n("No event selected.")); |
3599 | return; | 3600 | return; |
3600 | } | 3601 | } |
3601 | 3602 | ||
3602 | PublishDialog *publishdlg = new PublishDialog(); | 3603 | PublishDialog *publishdlg = new PublishDialog(); |
3603 | if (incidence->attendeeCount()>0) { | 3604 | if (incidence->attendeeCount()>0) { |
3604 | QPtrList<Attendee> attendees = incidence->attendees(); | 3605 | QPtrList<Attendee> attendees = incidence->attendees(); |
3605 | attendees.first(); | 3606 | attendees.first(); |
3606 | while ( attendees.current()!=0 ) { | 3607 | while ( attendees.current()!=0 ) { |
3607 | publishdlg->addAttendee(attendees.current()); | 3608 | publishdlg->addAttendee(attendees.current()); |
3608 | attendees.next(); | 3609 | attendees.next(); |
3609 | } | 3610 | } |
3610 | } | 3611 | } |
3611 | bool send = true; | 3612 | bool send = true; |
3612 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3613 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3613 | if ( publishdlg->exec() != QDialog::Accepted ) | 3614 | if ( publishdlg->exec() != QDialog::Accepted ) |
3614 | send = false; | 3615 | send = false; |
3615 | } | 3616 | } |
3616 | if ( send ) { | 3617 | if ( send ) { |
3617 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3618 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3618 | if ( event ) { | 3619 | if ( event ) { |
3619 | Event *ev = new Event(*event); | 3620 | Event *ev = new Event(*event); |
3620 | ev->registerObserver(0); | 3621 | ev->registerObserver(0); |
3621 | ev->clearAttendees(); | 3622 | ev->clearAttendees(); |
3622 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3623 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3623 | delete(ev); | 3624 | delete(ev); |
3624 | } | 3625 | } |
3625 | } else { | 3626 | } else { |
3626 | if ( todo ) { | 3627 | if ( todo ) { |
3627 | Todo *ev = new Todo(*todo); | 3628 | Todo *ev = new Todo(*todo); |
3628 | ev->registerObserver(0); | 3629 | ev->registerObserver(0); |
3629 | ev->clearAttendees(); | 3630 | ev->clearAttendees(); |
3630 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3631 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3631 | delete(ev); | 3632 | delete(ev); |
3632 | } | 3633 | } |
3633 | } | 3634 | } |
3634 | } | 3635 | } |
3635 | } | 3636 | } |
3636 | delete publishdlg; | 3637 | delete publishdlg; |
3637 | } | 3638 | } |
3638 | 3639 | ||
3639 | void CalendarView::schedule_request(Incidence *incidence) | 3640 | void CalendarView::schedule_request(Incidence *incidence) |
3640 | { | 3641 | { |
3641 | schedule(Scheduler::Request,incidence); | 3642 | schedule(Scheduler::Request,incidence); |
3642 | } | 3643 | } |
3643 | 3644 | ||
3644 | void CalendarView::schedule_refresh(Incidence *incidence) | 3645 | void CalendarView::schedule_refresh(Incidence *incidence) |
3645 | { | 3646 | { |
3646 | schedule(Scheduler::Refresh,incidence); | 3647 | schedule(Scheduler::Refresh,incidence); |
3647 | } | 3648 | } |
3648 | 3649 | ||
3649 | void CalendarView::schedule_cancel(Incidence *incidence) | 3650 | void CalendarView::schedule_cancel(Incidence *incidence) |
3650 | { | 3651 | { |
3651 | schedule(Scheduler::Cancel,incidence); | 3652 | schedule(Scheduler::Cancel,incidence); |
3652 | } | 3653 | } |
3653 | 3654 | ||
3654 | void CalendarView::schedule_add(Incidence *incidence) | 3655 | void CalendarView::schedule_add(Incidence *incidence) |
3655 | { | 3656 | { |
3656 | schedule(Scheduler::Add,incidence); | 3657 | schedule(Scheduler::Add,incidence); |
3657 | } | 3658 | } |
3658 | 3659 | ||
3659 | void CalendarView::schedule_reply(Incidence *incidence) | 3660 | void CalendarView::schedule_reply(Incidence *incidence) |
3660 | { | 3661 | { |
3661 | schedule(Scheduler::Reply,incidence); | 3662 | schedule(Scheduler::Reply,incidence); |
3662 | } | 3663 | } |
3663 | 3664 | ||
3664 | void CalendarView::schedule_counter(Incidence *incidence) | 3665 | void CalendarView::schedule_counter(Incidence *incidence) |
3665 | { | 3666 | { |
3666 | schedule(Scheduler::Counter,incidence); | 3667 | schedule(Scheduler::Counter,incidence); |
3667 | } | 3668 | } |
3668 | 3669 | ||
3669 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3670 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3670 | { | 3671 | { |
3671 | schedule(Scheduler::Declinecounter,incidence); | 3672 | schedule(Scheduler::Declinecounter,incidence); |
3672 | } | 3673 | } |
3673 | 3674 | ||
3674 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3675 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3675 | { | 3676 | { |
3676 | QDateTime start = QDateTime::currentDateTime(); | 3677 | QDateTime start = QDateTime::currentDateTime(); |
3677 | QDateTime end = start.addDays(daysToPublish); | 3678 | QDateTime end = start.addDays(daysToPublish); |
3678 | 3679 | ||
3679 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3680 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3680 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3681 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3681 | 3682 | ||
3682 | 3683 | ||
3683 | PublishDialog *publishdlg = new PublishDialog(); | 3684 | PublishDialog *publishdlg = new PublishDialog(); |
3684 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3685 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3685 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3686 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3686 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3687 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3687 | delete(freebusy); | 3688 | delete(freebusy); |
3688 | } | 3689 | } |
3689 | } | 3690 | } |
3690 | delete publishdlg; | 3691 | delete publishdlg; |
3691 | } | 3692 | } |
3692 | 3693 | ||
3693 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3694 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3694 | { | 3695 | { |
3695 | Event *event = 0; | 3696 | Event *event = 0; |
3696 | Todo *todo = 0; | 3697 | Todo *todo = 0; |
3697 | 3698 | ||
3698 | if (incidence == 0) { | 3699 | if (incidence == 0) { |
3699 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3700 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3700 | if (incidence == 0) { | 3701 | if (incidence == 0) { |
3701 | incidence = mTodoList->selectedIncidences().first(); | 3702 | incidence = mTodoList->selectedIncidences().first(); |
3702 | } | 3703 | } |
3703 | } | 3704 | } |
3704 | if ( incidence && incidence->typeID() == eventID ) { | 3705 | if ( incidence && incidence->typeID() == eventID ) { |
3705 | event = static_cast<Event *>(incidence); | 3706 | event = static_cast<Event *>(incidence); |
3706 | } | 3707 | } |
3707 | if ( incidence && incidence->typeID() == todoID ) { | 3708 | if ( incidence && incidence->typeID() == todoID ) { |
3708 | todo = static_cast<Todo *>(incidence); | 3709 | todo = static_cast<Todo *>(incidence); |
3709 | } | 3710 | } |
3710 | 3711 | ||
3711 | if (!event && !todo) { | 3712 | if (!event && !todo) { |
3712 | KMessageBox::sorry(this,i18n("No event selected.")); | 3713 | KMessageBox::sorry(this,i18n("No event selected.")); |
3713 | return; | 3714 | return; |
3714 | } | 3715 | } |
3715 | 3716 | ||
3716 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3717 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3717 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3718 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3718 | return; | 3719 | return; |
3719 | } | 3720 | } |
3720 | 3721 | ||
3721 | Event *ev = 0; | 3722 | Event *ev = 0; |
3722 | if (event) ev = new Event(*event); | 3723 | if (event) ev = new Event(*event); |
3723 | Todo *to = 0; | 3724 | Todo *to = 0; |
3724 | if (todo) to = new Todo(*todo); | 3725 | if (todo) to = new Todo(*todo); |
3725 | 3726 | ||
3726 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3727 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3727 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3728 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3728 | if (!me) { | 3729 | if (!me) { |
3729 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3730 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3730 | return; | 3731 | return; |
3731 | } | 3732 | } |
3732 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3733 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3733 | StatusDialog *statdlg = new StatusDialog(this); | 3734 | StatusDialog *statdlg = new StatusDialog(this); |
3734 | if (!statdlg->exec()==QDialog::Accepted) return; | 3735 | if (!statdlg->exec()==QDialog::Accepted) return; |
3735 | me->setStatus( statdlg->status() ); | 3736 | me->setStatus( statdlg->status() ); |
3736 | delete(statdlg); | 3737 | delete(statdlg); |
3737 | } | 3738 | } |
3738 | Attendee *menew = new Attendee(*me); | 3739 | Attendee *menew = new Attendee(*me); |
3739 | if (ev) { | 3740 | if (ev) { |
3740 | ev->clearAttendees(); | 3741 | ev->clearAttendees(); |
3741 | ev->addAttendee(menew,false); | 3742 | ev->addAttendee(menew,false); |
3742 | } else { | 3743 | } else { |
3743 | if (to) { | 3744 | if (to) { |
3744 | todo->clearAttendees(); | 3745 | todo->clearAttendees(); |
3745 | todo->addAttendee(menew,false); | 3746 | todo->addAttendee(menew,false); |
3746 | } | 3747 | } |
3747 | } | 3748 | } |
3748 | } | 3749 | } |
3749 | 3750 | ||
3750 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3751 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3751 | if (ev) { | 3752 | if (ev) { |
3752 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3753 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3753 | } else { | 3754 | } else { |
3754 | if (to) { | 3755 | if (to) { |
3755 | if ( !dlg->addMessage(to,method) ) delete(to); | 3756 | if ( !dlg->addMessage(to,method) ) delete(to); |
3756 | } | 3757 | } |
3757 | } | 3758 | } |
3758 | } | 3759 | } |
3759 | 3760 | ||
3760 | void CalendarView::openAddressbook() | 3761 | void CalendarView::openAddressbook() |
3761 | { | 3762 | { |
3762 | KRun::runCommand("kaddressbook"); | 3763 | KRun::runCommand("kaddressbook"); |
3763 | } | 3764 | } |
3764 | 3765 | ||
3765 | void CalendarView::setModified(bool modified) | 3766 | void CalendarView::setModified(bool modified) |
3766 | { | 3767 | { |
3767 | if ( modified ) | 3768 | if ( modified ) |
3768 | emit signalmodified(); | 3769 | emit signalmodified(); |
3769 | if (mModified != modified) { | 3770 | if (mModified != modified) { |
3770 | mModified = modified; | 3771 | mModified = modified; |
3771 | emit modifiedChanged(mModified); | 3772 | emit modifiedChanged(mModified); |
3772 | } | 3773 | } |
3773 | } | 3774 | } |
3774 | 3775 | ||
3775 | bool CalendarView::isReadOnly() | 3776 | bool CalendarView::isReadOnly() |
3776 | { | 3777 | { |
3777 | return mReadOnly; | 3778 | return mReadOnly; |
3778 | } | 3779 | } |
3779 | 3780 | ||
3780 | void CalendarView::setReadOnly(bool readOnly) | 3781 | void CalendarView::setReadOnly(bool readOnly) |
3781 | { | 3782 | { |
3782 | if (mReadOnly != readOnly) { | 3783 | if (mReadOnly != readOnly) { |
3783 | mReadOnly = readOnly; | 3784 | mReadOnly = readOnly; |
3784 | emit readOnlyChanged(mReadOnly); | 3785 | emit readOnlyChanged(mReadOnly); |
3785 | } | 3786 | } |
3786 | } | 3787 | } |
3787 | 3788 | ||
3788 | bool CalendarView::isModified() | 3789 | bool CalendarView::isModified() |
3789 | { | 3790 | { |
3790 | return mModified; | 3791 | return mModified; |
3791 | } | 3792 | } |
3792 | void CalendarView::slotprintSelInc() | 3793 | void CalendarView::slotprintSelInc() |
3793 | { | 3794 | { |
3794 | if ( currentSelection() == 0 ) { | 3795 | if ( currentSelection() == 0 ) { |
3795 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 3796 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
3796 | return; | 3797 | return; |
3797 | } | 3798 | } |
3798 | showIncidence(); | 3799 | showIncidence(); |
3799 | getEventViewerDialog()->print(); | 3800 | getEventViewerDialog()->print(); |
3800 | 3801 | ||
3801 | } | 3802 | } |
3802 | void CalendarView::printSetup() | 3803 | void CalendarView::printSetup() |
3803 | { | 3804 | { |
3804 | #ifndef KORG_NOPRINTER | 3805 | #ifndef KORG_NOPRINTER |
3805 | createPrinter(); | 3806 | createPrinter(); |
3806 | 3807 | ||
3807 | mCalPrinter->setupPrinter(); | 3808 | mCalPrinter->setupPrinter(); |
3808 | #endif | 3809 | #endif |
3809 | } | 3810 | } |
3810 | 3811 | ||
3811 | void CalendarView::print() | 3812 | void CalendarView::print() |
3812 | { | 3813 | { |
3813 | #ifndef KORG_NOPRINTER | 3814 | #ifndef KORG_NOPRINTER |
3814 | createPrinter(); | 3815 | createPrinter(); |
3815 | 3816 | ||
3816 | DateList tmpDateList = mNavigator->selectedDates(); | 3817 | DateList tmpDateList = mNavigator->selectedDates(); |
3817 | mCalPrinter->print(CalPrinter::Month, | 3818 | mCalPrinter->print(CalPrinter::Month, |
3818 | tmpDateList.first(), tmpDateList.last()); | 3819 | tmpDateList.first(), tmpDateList.last()); |
3819 | #endif | 3820 | #endif |
3820 | } | 3821 | } |
3821 | 3822 | ||
3822 | void CalendarView::printPreview() | 3823 | void CalendarView::printPreview() |
3823 | { | 3824 | { |
3824 | #ifndef KORG_NOPRINTER | 3825 | #ifndef KORG_NOPRINTER |
3825 | kdDebug() << "CalendarView::printPreview()" << endl; | 3826 | kdDebug() << "CalendarView::printPreview()" << endl; |
3826 | 3827 | ||
3827 | createPrinter(); | 3828 | createPrinter(); |
3828 | 3829 | ||
3829 | DateList tmpDateList = mNavigator->selectedDates(); | 3830 | DateList tmpDateList = mNavigator->selectedDates(); |
3830 | 3831 | ||
3831 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3832 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3832 | tmpDateList.last()); | 3833 | tmpDateList.last()); |
3833 | #endif | 3834 | #endif |
3834 | } | 3835 | } |
3835 | 3836 | ||
3836 | void CalendarView::exportICalendar() | 3837 | void CalendarView::exportICalendar() |
3837 | { | 3838 | { |
3838 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3839 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3839 | 3840 | ||
3840 | // Force correct extension | 3841 | // Force correct extension |
3841 | if (filename.right(4) != ".ics") filename += ".ics"; | 3842 | if (filename.right(4) != ".ics") filename += ".ics"; |
3842 | 3843 | ||
3843 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3844 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3844 | storage.save(); | 3845 | storage.save(); |
3845 | } | 3846 | } |
3846 | 3847 | ||
3847 | bool CalendarView::exportVCalendar( QString filename ) | 3848 | bool CalendarView::exportVCalendar( QString filename ) |
3848 | { | 3849 | { |
3849 | if (mCalendar->journals().count() > 0) { | 3850 | if (mCalendar->journals().count() > 0) { |
3850 | int result = KMessageBox::warningContinueCancel(this, | 3851 | int result = KMessageBox::warningContinueCancel(this, |
3851 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3852 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3852 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3853 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3853 | true); | 3854 | true); |
3854 | if (result != KMessageBox::Continue) return false; | 3855 | if (result != KMessageBox::Continue) return false; |
3855 | } | 3856 | } |
3856 | 3857 | ||
3857 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3858 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3858 | 3859 | ||
3859 | // Force correct extension | 3860 | // Force correct extension |
3860 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3861 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3861 | 3862 | ||
3862 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3863 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3863 | return storage.save(); | 3864 | return storage.save(); |
3864 | 3865 | ||
3865 | } | 3866 | } |
3866 | 3867 | ||
3867 | void CalendarView::eventUpdated(Incidence *) | 3868 | void CalendarView::eventUpdated(Incidence *) |
3868 | { | 3869 | { |
3869 | setModified(); | 3870 | setModified(); |
3870 | // Don't call updateView here. The code, which has caused the update of the | 3871 | // Don't call updateView here. The code, which has caused the update of the |
3871 | // event is responsible for updating the view. | 3872 | // event is responsible for updating the view. |
3872 | // updateView(); | 3873 | // updateView(); |
3873 | } | 3874 | } |
3874 | 3875 | ||
3875 | void CalendarView::adaptNavigationUnits() | 3876 | void CalendarView::adaptNavigationUnits() |
3876 | { | 3877 | { |
3877 | if (mViewManager->currentView()->isEventView()) { | 3878 | if (mViewManager->currentView()->isEventView()) { |
3878 | int days = mViewManager->currentView()->currentDateCount(); | 3879 | int days = mViewManager->currentView()->currentDateCount(); |
3879 | if (days == 1) { | 3880 | if (days == 1) { |
3880 | emit changeNavStringPrev(i18n("&Previous Day")); | 3881 | emit changeNavStringPrev(i18n("&Previous Day")); |
3881 | emit changeNavStringNext(i18n("&Next Day")); | 3882 | emit changeNavStringNext(i18n("&Next Day")); |
3882 | } else { | 3883 | } else { |
3883 | emit changeNavStringPrev(i18n("&Previous Week")); | 3884 | emit changeNavStringPrev(i18n("&Previous Week")); |
3884 | emit changeNavStringNext(i18n("&Next Week")); | 3885 | emit changeNavStringNext(i18n("&Next Week")); |
3885 | } | 3886 | } |
3886 | } | 3887 | } |
3887 | } | 3888 | } |
3888 | 3889 | ||
3889 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3890 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3890 | { | 3891 | { |
3891 | if ( incidence ) mTodoList->clearSelection(); | 3892 | if ( incidence ) mTodoList->clearSelection(); |
3892 | processIncidenceSelection( incidence ); | 3893 | processIncidenceSelection( incidence ); |
3893 | } | 3894 | } |
3894 | 3895 | ||
3895 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3896 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3896 | { | 3897 | { |
3897 | if ( incidence && mViewManager->currentView() ) { | 3898 | if ( incidence && mViewManager->currentView() ) { |
3898 | mViewManager->currentView()->clearSelection(); | 3899 | mViewManager->currentView()->clearSelection(); |
3899 | } | 3900 | } |
3900 | processIncidenceSelection( incidence ); | 3901 | processIncidenceSelection( incidence ); |
3901 | } | 3902 | } |
3902 | 3903 | ||
3903 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3904 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3904 | { | 3905 | { |
3905 | if ( incidence == mSelectedIncidence ) return; | 3906 | if ( incidence == mSelectedIncidence ) return; |
3906 | 3907 | ||
3907 | mSelectedIncidence = incidence; | 3908 | mSelectedIncidence = incidence; |
3908 | 3909 | ||
3909 | emit incidenceSelected( mSelectedIncidence ); | 3910 | emit incidenceSelected( mSelectedIncidence ); |
3910 | 3911 | ||
3911 | if ( incidence && incidence->typeID() == eventID ) { | 3912 | if ( incidence && incidence->typeID() == eventID ) { |
3912 | Event *event = static_cast<Event *>( incidence ); | 3913 | Event *event = static_cast<Event *>( incidence ); |
3913 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3914 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3914 | emit organizerEventsSelected( true ); | 3915 | emit organizerEventsSelected( true ); |
3915 | } else { | 3916 | } else { |
3916 | emit organizerEventsSelected(false); | 3917 | emit organizerEventsSelected(false); |
3917 | } | 3918 | } |
3918 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3919 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3919 | KOPrefs::instance()->email() ) ) { | 3920 | KOPrefs::instance()->email() ) ) { |
3920 | emit groupEventsSelected( true ); | 3921 | emit groupEventsSelected( true ); |
3921 | } else { | 3922 | } else { |
3922 | emit groupEventsSelected(false); | 3923 | emit groupEventsSelected(false); |
3923 | } | 3924 | } |
3924 | return; | 3925 | return; |
3925 | } else { | 3926 | } else { |
3926 | if ( incidence && incidence->typeID() == todoID ) { | 3927 | if ( incidence && incidence->typeID() == todoID ) { |
3927 | emit todoSelected( true ); | 3928 | emit todoSelected( true ); |
3928 | Todo *event = static_cast<Todo *>( incidence ); | 3929 | Todo *event = static_cast<Todo *>( incidence ); |
3929 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3930 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3930 | emit organizerEventsSelected( true ); | 3931 | emit organizerEventsSelected( true ); |
3931 | } else { | 3932 | } else { |
3932 | emit organizerEventsSelected(false); | 3933 | emit organizerEventsSelected(false); |
3933 | } | 3934 | } |
3934 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3935 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3935 | KOPrefs::instance()->email() ) ) { | 3936 | KOPrefs::instance()->email() ) ) { |
3936 | emit groupEventsSelected( true ); | 3937 | emit groupEventsSelected( true ); |
3937 | } else { | 3938 | } else { |
3938 | emit groupEventsSelected(false); | 3939 | emit groupEventsSelected(false); |
3939 | } | 3940 | } |
3940 | return; | 3941 | return; |
3941 | } else { | 3942 | } else { |
3942 | emit todoSelected( false ); | 3943 | emit todoSelected( false ); |
3943 | emit organizerEventsSelected(false); | 3944 | emit organizerEventsSelected(false); |
3944 | emit groupEventsSelected(false); | 3945 | emit groupEventsSelected(false); |
3945 | } | 3946 | } |
3946 | return; | 3947 | return; |
3947 | } | 3948 | } |
3948 | 3949 | ||
3949 | /* if ( incidence && incidence->typeID() == todoID ) { | 3950 | /* if ( incidence && incidence->typeID() == todoID ) { |
3950 | emit todoSelected( true ); | 3951 | emit todoSelected( true ); |
3951 | } else { | 3952 | } else { |
3952 | emit todoSelected( false ); | 3953 | emit todoSelected( false ); |
3953 | }*/ | 3954 | }*/ |
3954 | } | 3955 | } |
3955 | 3956 | ||
3956 | 3957 | ||
3957 | void CalendarView::checkClipboard() | 3958 | void CalendarView::checkClipboard() |
3958 | { | 3959 | { |
3959 | #ifndef KORG_NODND | 3960 | #ifndef KORG_NODND |
3960 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3961 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3961 | emit pasteEnabled(true); | 3962 | emit pasteEnabled(true); |
3962 | } else { | 3963 | } else { |
3963 | emit pasteEnabled(false); | 3964 | emit pasteEnabled(false); |
3964 | } | 3965 | } |
3965 | #endif | 3966 | #endif |
3966 | } | 3967 | } |
3967 | 3968 | ||
3968 | void CalendarView::showDates(const DateList &selectedDates) | 3969 | void CalendarView::showDates(const DateList &selectedDates) |
3969 | { | 3970 | { |
3970 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3971 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3971 | 3972 | ||
3972 | 3973 | ||
3973 | if ( !mBlockShowDates ) { | 3974 | if ( !mBlockShowDates ) { |
3974 | if ( mViewManager->currentView() ) { | 3975 | if ( mViewManager->currentView() ) { |
3975 | updateView( selectedDates.first(), selectedDates.last() ); | 3976 | updateView( selectedDates.first(), selectedDates.last() ); |
3976 | } else { | 3977 | } else { |
3977 | mViewManager->showAgendaView(); | 3978 | mViewManager->showAgendaView(); |
3978 | } | 3979 | } |
3979 | } | 3980 | } |
3980 | 3981 | ||
3981 | QDate date = selectedDates.first(); | 3982 | QDate date = selectedDates.first(); |
3982 | if ( ! date.isValid() ) { | 3983 | if ( ! date.isValid() ) { |
3983 | topLevelWidget()->setCaption(""); | 3984 | topLevelWidget()->setCaption(""); |
3984 | return; | 3985 | return; |
3985 | } | 3986 | } |
3986 | 3987 | ||
3987 | QString selDates; | 3988 | QString selDates; |
3988 | selDates = KGlobal::locale()->formatDate( date, true); | 3989 | selDates = KGlobal::locale()->formatDate( date, true); |
3989 | if (selectedDates.first() < selectedDates.last() ) | 3990 | if (selectedDates.first() < selectedDates.last() ) |
3990 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3991 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3991 | else { | 3992 | else { |
3992 | QString addString; | 3993 | QString addString; |
3993 | if ( date == QDateTime::currentDateTime().date() ) | 3994 | if ( date == QDateTime::currentDateTime().date() ) |
3994 | addString = i18n("Today"); | 3995 | addString = i18n("Today"); |
3995 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 3996 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
3996 | addString = i18n("Tomorrow"); | 3997 | addString = i18n("Tomorrow"); |
3997 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 3998 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
3998 | addString = i18n("Yesterday"); | 3999 | addString = i18n("Yesterday"); |
3999 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4000 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4000 | addString = i18n("Day before yesterday"); | 4001 | addString = i18n("Day before yesterday"); |
4001 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4002 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4002 | addString = i18n("Day after tomorrow"); | 4003 | addString = i18n("Day after tomorrow"); |
4003 | if ( !addString.isEmpty() ) { | 4004 | if ( !addString.isEmpty() ) { |
4004 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4005 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4005 | return; | 4006 | return; |
4006 | } | 4007 | } |
4007 | } | 4008 | } |
4008 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4009 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4009 | 4010 | ||
4010 | } | 4011 | } |
4011 | 4012 | ||
4012 | QPtrList<CalFilter> CalendarView::filters() | 4013 | QPtrList<CalFilter> CalendarView::filters() |
4013 | { | 4014 | { |
4014 | return mFilters; | 4015 | return mFilters; |
4015 | 4016 | ||
4016 | } | 4017 | } |
4017 | void CalendarView::editFilters() | 4018 | void CalendarView::editFilters() |
4018 | { | 4019 | { |
4019 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4020 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4020 | 4021 | ||
4021 | CalFilter *filter = mFilters.first(); | 4022 | CalFilter *filter = mFilters.first(); |
4022 | while(filter) { | 4023 | while(filter) { |
4023 | kdDebug() << " Filter: " << filter->name() << endl; | 4024 | kdDebug() << " Filter: " << filter->name() << endl; |
4024 | filter = mFilters.next(); | 4025 | filter = mFilters.next(); |
4025 | } | 4026 | } |
4026 | 4027 | ||
4027 | mDialogManager->showFilterEditDialog(&mFilters); | 4028 | mDialogManager->showFilterEditDialog(&mFilters); |
4028 | } | 4029 | } |
4029 | void CalendarView::toggleFilter() | 4030 | void CalendarView::toggleFilter() |
4030 | { | 4031 | { |
4031 | showFilter(! mCalEditView->isVisible()); | 4032 | showFilter(! mCalEditView->isVisible()); |
4032 | } | 4033 | } |
4033 | 4034 | ||
4034 | KOFilterView *CalendarView::filterView() | 4035 | KOFilterView *CalendarView::filterView() |
4035 | { | 4036 | { |
4036 | return mFilterView; | 4037 | return mFilterView; |
4037 | } | 4038 | } |
4038 | void CalendarView::selectFilter( int fil ) | 4039 | void CalendarView::selectFilter( int fil ) |
4039 | { | 4040 | { |
4040 | mFilterView->setSelectedFilter( fil ); | 4041 | mFilterView->setSelectedFilter( fil ); |
4041 | } | 4042 | } |
4042 | void CalendarView::showFilter(bool visible) | 4043 | void CalendarView::showFilter(bool visible) |
4043 | { | 4044 | { |
4044 | #if 1 | 4045 | #if 1 |
4045 | if (visible) { | 4046 | if (visible) { |
4046 | mCalEditView->readConfig(); | 4047 | mCalEditView->readConfig(); |
4047 | mCalEditView->show(); | 4048 | mCalEditView->show(); |
4048 | QValueList<int> sizes; | 4049 | QValueList<int> sizes; |
4049 | sizes = mLeftFrame->sizes(); | 4050 | sizes = mLeftFrame->sizes(); |
4050 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4051 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4051 | sizes.clear(); | 4052 | sizes.clear(); |
4052 | sizes << 100; | 4053 | sizes << 100; |
4053 | sizes << 0; | 4054 | sizes << 0; |
4054 | sizes << 0; | 4055 | sizes << 0; |
4055 | sizes << 100; | 4056 | sizes << 100; |
4056 | mLeftFrame->setSizes(sizes); | 4057 | mLeftFrame->setSizes(sizes); |
4057 | } | 4058 | } |
4058 | #if 0 | 4059 | #if 0 |
4059 | sizes = mLeftFrame->sizes(); | 4060 | sizes = mLeftFrame->sizes(); |
4060 | int ccc = 0; | 4061 | int ccc = 0; |
4061 | while ( ccc < sizes.count()) { | 4062 | while ( ccc < sizes.count()) { |
4062 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4063 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4063 | ++ccc; | 4064 | ++ccc; |
4064 | } | 4065 | } |
4065 | #endif | 4066 | #endif |
4066 | 4067 | ||
4067 | } | 4068 | } |
4068 | else { | 4069 | else { |
4069 | mCalEditView->hide(); | 4070 | mCalEditView->hide(); |
4070 | } | 4071 | } |
4071 | #else | 4072 | #else |
4072 | if (visible) mFilterView->show(); | 4073 | if (visible) mFilterView->show(); |
4073 | else mFilterView->hide(); | 4074 | else mFilterView->hide(); |
4074 | #endif | 4075 | #endif |
4075 | } | 4076 | } |
4076 | void CalendarView::toggleFilerEnabled( ) | 4077 | void CalendarView::toggleFilerEnabled( ) |
4077 | { | 4078 | { |
4078 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4079 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4079 | if ( !mFilterView->filtersEnabled() ) | 4080 | if ( !mFilterView->filtersEnabled() ) |
4080 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4081 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4081 | 4082 | ||
4082 | } | 4083 | } |
4083 | void CalendarView::updateFilter() | 4084 | void CalendarView::updateFilter() |
4084 | { | 4085 | { |
4085 | CalFilter *filter = mFilterView->selectedFilter(); | 4086 | CalFilter *filter = mFilterView->selectedFilter(); |
4086 | if (filter) { | 4087 | if (filter) { |
4087 | QString mess; | 4088 | QString mess; |
4088 | if (mFilterView->filtersEnabled()) { | 4089 | if (mFilterView->filtersEnabled()) { |
4089 | mess = i18n("Filter selected: ")+filter->name(); | 4090 | mess = i18n("Filter selected: ")+filter->name(); |
4090 | filter->setEnabled(true); | 4091 | filter->setEnabled(true); |
4091 | } | 4092 | } |
4092 | else filter->setEnabled(false); | 4093 | else filter->setEnabled(false); |
4093 | mCalendar->setFilter(filter); | 4094 | mCalendar->setFilter(filter); |
4094 | updateView(); | 4095 | updateView(); |
4095 | if ( !mess.isEmpty() ) | 4096 | if ( !mess.isEmpty() ) |
4096 | topLevelWidget()->setCaption( mess ); | 4097 | topLevelWidget()->setCaption( mess ); |
4097 | 4098 | ||
4098 | } | 4099 | } |
4099 | } | 4100 | } |
4100 | 4101 | ||
4101 | void CalendarView::filterEdited() | 4102 | void CalendarView::filterEdited() |
4102 | { | 4103 | { |
4103 | mFilterView->updateFilters(); | 4104 | mFilterView->updateFilters(); |
4104 | updateFilter(); | 4105 | updateFilter(); |
4105 | writeSettings(); | 4106 | writeSettings(); |
4106 | } | 4107 | } |
4107 | 4108 | ||
4108 | 4109 | ||
4109 | void CalendarView::takeOverEvent() | 4110 | void CalendarView::takeOverEvent() |
4110 | { | 4111 | { |
4111 | Incidence *incidence = currentSelection(); | 4112 | Incidence *incidence = currentSelection(); |
4112 | 4113 | ||
4113 | if (!incidence) return; | 4114 | if (!incidence) return; |
4114 | 4115 | ||
4115 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4116 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4116 | incidence->recreate(); | 4117 | incidence->recreate(); |
4117 | incidence->setReadOnly(false); | 4118 | incidence->setReadOnly(false); |
4118 | 4119 | ||
4119 | updateView(); | 4120 | updateView(); |
4120 | } | 4121 | } |
4121 | 4122 | ||
4122 | void CalendarView::takeOverCalendar() | 4123 | void CalendarView::takeOverCalendar() |
4123 | { | 4124 | { |
4124 | // TODO: Create Calendar::allIncidences() function and use it here | 4125 | // TODO: Create Calendar::allIncidences() function and use it here |
4125 | 4126 | ||
4126 | clearAllViews(); | 4127 | clearAllViews(); |
4127 | QPtrList<Event> events = mCalendar->events(); | 4128 | QPtrList<Event> events = mCalendar->events(); |
4128 | for(uint i=0; i<events.count(); ++i) { | 4129 | for(uint i=0; i<events.count(); ++i) { |
4129 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4130 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4130 | events.at(i)->recreate(); | 4131 | events.at(i)->recreate(); |
4131 | events.at(i)->setReadOnly(false); | 4132 | events.at(i)->setReadOnly(false); |
4132 | } | 4133 | } |
4133 | 4134 | ||
4134 | QPtrList<Todo> todos = mCalendar->todos(); | 4135 | QPtrList<Todo> todos = mCalendar->todos(); |
4135 | for(uint i=0; i<todos.count(); ++i) { | 4136 | for(uint i=0; i<todos.count(); ++i) { |
4136 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4137 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4137 | todos.at(i)->recreate(); | 4138 | todos.at(i)->recreate(); |
4138 | todos.at(i)->setReadOnly(false); | 4139 | todos.at(i)->setReadOnly(false); |
4139 | } | 4140 | } |
4140 | 4141 | ||
4141 | QPtrList<Journal> journals = mCalendar->journals(); | 4142 | QPtrList<Journal> journals = mCalendar->journals(); |
4142 | for(uint i=0; i<journals.count(); ++i) { | 4143 | for(uint i=0; i<journals.count(); ++i) { |
4143 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4144 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4144 | journals.at(i)->recreate(); | 4145 | journals.at(i)->recreate(); |
4145 | journals.at(i)->setReadOnly(false); | 4146 | journals.at(i)->setReadOnly(false); |
4146 | } | 4147 | } |
4147 | 4148 | ||
4148 | updateView(); | 4149 | updateView(); |
4149 | } | 4150 | } |
4150 | 4151 | ||
4151 | void CalendarView::showIntro() | 4152 | void CalendarView::showIntro() |
4152 | { | 4153 | { |
4153 | kdDebug() << "To be implemented." << endl; | 4154 | kdDebug() << "To be implemented." << endl; |
4154 | } | 4155 | } |
4155 | 4156 | ||
4156 | QWidgetStack *CalendarView::viewStack() | 4157 | QWidgetStack *CalendarView::viewStack() |
4157 | { | 4158 | { |
4158 | return mRightFrame; | 4159 | return mRightFrame; |
4159 | } | 4160 | } |
4160 | 4161 | ||
4161 | QWidget *CalendarView::leftFrame() | 4162 | QWidget *CalendarView::leftFrame() |
4162 | { | 4163 | { |
4163 | return ( QWidget *)mLeftFrame; | 4164 | return ( QWidget *)mLeftFrame; |
4164 | } | 4165 | } |
4165 | 4166 | ||
4166 | DateNavigator *CalendarView::dateNavigator() | 4167 | DateNavigator *CalendarView::dateNavigator() |
4167 | { | 4168 | { |
4168 | return mNavigator; | 4169 | return mNavigator; |
4169 | } | 4170 | } |
4170 | 4171 | ||
4171 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4172 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4172 | { | 4173 | { |
4173 | return mDateNavigator->navigatorView(); | 4174 | return mDateNavigator->navigatorView(); |
4174 | } | 4175 | } |
4175 | void CalendarView::toggleDateNavigatorWidget() | 4176 | void CalendarView::toggleDateNavigatorWidget() |
4176 | { | 4177 | { |
4177 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4178 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4178 | 4179 | ||
4179 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4180 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4180 | mDateNavigator->hide(); | 4181 | mDateNavigator->hide(); |
4181 | else | 4182 | else |
4182 | mDateNavigator->show(); | 4183 | mDateNavigator->show(); |
4183 | } | 4184 | } |
4184 | void CalendarView::addView(KOrg::BaseView *view) | 4185 | void CalendarView::addView(KOrg::BaseView *view) |
4185 | { | 4186 | { |
4186 | mViewManager->addView(view); | 4187 | mViewManager->addView(view); |
4187 | } | 4188 | } |
4188 | 4189 | ||
4189 | void CalendarView::showView(KOrg::BaseView *view) | 4190 | void CalendarView::showView(KOrg::BaseView *view) |
4190 | { | 4191 | { |
4191 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4192 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4192 | } | 4193 | } |
4193 | 4194 | ||
4194 | Incidence *CalendarView::currentSelection() | 4195 | Incidence *CalendarView::currentSelection() |
4195 | { | 4196 | { |
4196 | return mViewManager->currentSelection(); | 4197 | return mViewManager->currentSelection(); |
4197 | } | 4198 | } |
4198 | void CalendarView::toggleAllDaySize() | 4199 | void CalendarView::toggleAllDaySize() |
4199 | { | 4200 | { |
4200 | /* | 4201 | /* |
4201 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4202 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4202 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4203 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4203 | else | 4204 | else |
4204 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4205 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4205 | */ | 4206 | */ |
4206 | viewManager()->agendaView()->toggleAllDay(); | 4207 | viewManager()->agendaView()->toggleAllDay(); |
4207 | } | 4208 | } |
4208 | void CalendarView::toggleExpand() | 4209 | void CalendarView::toggleExpand() |
4209 | { | 4210 | { |
4210 | // if ( mLeftFrame->isHidden() ) { | 4211 | // if ( mLeftFrame->isHidden() ) { |
4211 | // mLeftFrame->show(); | 4212 | // mLeftFrame->show(); |
4212 | // emit calendarViewExpanded( false ); | 4213 | // emit calendarViewExpanded( false ); |
4213 | // } else { | 4214 | // } else { |
4214 | // mLeftFrame->hide(); | 4215 | // mLeftFrame->hide(); |
4215 | // emit calendarViewExpanded( true ); | 4216 | // emit calendarViewExpanded( true ); |
4216 | // } | 4217 | // } |
4217 | //qDebug(" CalendarView::toggleExpand()"); | 4218 | //qDebug(" CalendarView::toggleExpand()"); |
4218 | globalFlagBlockAgenda = 1; | 4219 | globalFlagBlockAgenda = 1; |
4219 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4220 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4220 | globalFlagBlockAgenda = 5; | 4221 | globalFlagBlockAgenda = 5; |
4221 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4222 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4222 | //mViewManager->showView( 0, true ); | 4223 | //mViewManager->showView( 0, true ); |
4223 | } | 4224 | } |
4224 | 4225 | ||
4225 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4226 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4226 | { | 4227 | { |
4227 | setModified( modified ); | 4228 | setModified( modified ); |
4228 | } | 4229 | } |
4229 | 4230 | ||
4230 | Todo *CalendarView::selectedTodo() | 4231 | Todo *CalendarView::selectedTodo() |
4231 | { | 4232 | { |
4232 | Incidence *incidence = currentSelection(); | 4233 | Incidence *incidence = currentSelection(); |
4233 | if ( incidence && incidence->typeID() == todoID ) { | 4234 | if ( incidence && incidence->typeID() == todoID ) { |
4234 | return static_cast<Todo *>( incidence ); | 4235 | return static_cast<Todo *>( incidence ); |
4235 | } | 4236 | } |
4236 | 4237 | ||
4237 | incidence = mTodoList->selectedIncidences().first(); | 4238 | incidence = mTodoList->selectedIncidences().first(); |
4238 | if ( incidence && incidence->typeID() == todoID ) { | 4239 | if ( incidence && incidence->typeID() == todoID ) { |
4239 | return static_cast<Todo *>( incidence ); | 4240 | return static_cast<Todo *>( incidence ); |
4240 | } | 4241 | } |
4241 | 4242 | ||
4242 | return 0; | 4243 | return 0; |
4243 | } | 4244 | } |
4244 | 4245 | ||
4245 | void CalendarView::dialogClosing(Incidence *in) | 4246 | void CalendarView::dialogClosing(Incidence *in) |
4246 | { | 4247 | { |
4247 | // mDialogList.remove(in); | 4248 | // mDialogList.remove(in); |
4248 | } | 4249 | } |
4249 | 4250 | ||
4250 | void CalendarView::showIncidence() | 4251 | void CalendarView::showIncidence() |
4251 | { | 4252 | { |
4252 | mViewerCallerIsSearchDialog = false; | 4253 | mViewerCallerIsSearchDialog = false; |
4253 | Incidence *incidence = currentSelection(); | 4254 | Incidence *incidence = currentSelection(); |
4254 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4255 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4255 | if ( incidence ) { | 4256 | if ( incidence ) { |
4256 | ShowIncidenceVisitor v; | 4257 | ShowIncidenceVisitor v; |
4257 | v.act( incidence, this ); | 4258 | v.act( incidence, this ); |
4258 | } | 4259 | } |
4259 | } | 4260 | } |
4260 | void CalendarView::editIncidenceDescription() | 4261 | void CalendarView::editIncidenceDescription() |
4261 | { | 4262 | { |
4262 | mFlagEditDescription = true; | 4263 | mFlagEditDescription = true; |
4263 | editIncidence(); | 4264 | editIncidence(); |
4264 | mFlagEditDescription = false; | 4265 | mFlagEditDescription = false; |
4265 | } | 4266 | } |
4266 | void CalendarView::editIncidence() | 4267 | void CalendarView::editIncidence() |
4267 | { | 4268 | { |
4268 | // qDebug("editIncidence() "); | 4269 | // qDebug("editIncidence() "); |
4269 | Incidence *incidence = currentSelection(); | 4270 | Incidence *incidence = currentSelection(); |
4270 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4271 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4271 | if ( incidence ) { | 4272 | if ( incidence ) { |
4272 | EditIncidenceVisitor v; | 4273 | EditIncidenceVisitor v; |
4273 | v.act( incidence, this ); | 4274 | v.act( incidence, this ); |
4274 | } | 4275 | } |
4275 | } | 4276 | } |
4276 | 4277 | ||
4277 | void CalendarView::deleteIncidence() | 4278 | void CalendarView::deleteIncidence() |
4278 | { | 4279 | { |
4279 | Incidence *incidence = currentSelection(); | 4280 | Incidence *incidence = currentSelection(); |
4280 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4281 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4281 | if ( incidence ) { | 4282 | if ( incidence ) { |
4282 | deleteIncidence(incidence); | 4283 | deleteIncidence(incidence); |
4283 | } | 4284 | } |
4284 | } | 4285 | } |
4285 | void CalendarView::showIncidence(QString uid) | 4286 | void CalendarView::showIncidence(QString uid) |
4286 | { | 4287 | { |
4287 | Incidence *inc = mCalendar->incidence( uid ); | 4288 | Incidence *inc = mCalendar->incidence( uid ); |
4288 | if ( inc ) | 4289 | if ( inc ) |
4289 | showIncidence( inc ); | 4290 | showIncidence( inc ); |
4290 | } | 4291 | } |
4291 | void CalendarView::showIncidence(Incidence *incidence) | 4292 | void CalendarView::showIncidence(Incidence *incidence) |
4292 | { | 4293 | { |
4293 | mViewerCallerIsSearchDialog = false; | 4294 | mViewerCallerIsSearchDialog = false; |
4294 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4295 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4295 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4296 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4296 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4297 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4297 | mViewerCallerIsSearchDialog = true; | 4298 | mViewerCallerIsSearchDialog = true; |
4298 | } | 4299 | } |
4299 | } | 4300 | } |
4300 | if ( incidence ) { | 4301 | if ( incidence ) { |
4301 | ShowIncidenceVisitor v; | 4302 | ShowIncidenceVisitor v; |
4302 | v.act( incidence, this ); | 4303 | v.act( incidence, this ); |
4303 | } | 4304 | } |
4304 | } | 4305 | } |
4305 | 4306 | ||
4306 | void CalendarView::editIncidence(Incidence *incidence) | 4307 | void CalendarView::editIncidence(Incidence *incidence) |
4307 | { | 4308 | { |
4308 | if ( incidence ) { | 4309 | if ( incidence ) { |
4309 | 4310 | ||
4310 | EditIncidenceVisitor v; | 4311 | EditIncidenceVisitor v; |
4311 | v.act( incidence, this ); | 4312 | v.act( incidence, this ); |
4312 | 4313 | ||
4313 | } | 4314 | } |
4314 | } | 4315 | } |
4315 | 4316 | ||
4316 | void CalendarView::deleteIncidence(Incidence *incidence) | 4317 | void CalendarView::deleteIncidence(Incidence *incidence) |
4317 | { | 4318 | { |
4318 | //qDebug(" CalendarView::deleteIncidence "); | 4319 | //qDebug(" CalendarView::deleteIncidence "); |
4319 | if ( incidence ) { | 4320 | if ( incidence ) { |
4320 | DeleteIncidenceVisitor v; | 4321 | DeleteIncidenceVisitor v; |
4321 | v.act( incidence, this ); | 4322 | v.act( incidence, this ); |
4322 | } | 4323 | } |
4323 | } | 4324 | } |
4324 | 4325 | ||
4325 | 4326 | ||
4326 | void CalendarView::lookForOutgoingMessages() | 4327 | void CalendarView::lookForOutgoingMessages() |
4327 | { | 4328 | { |
4328 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4329 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4329 | ogd->loadMessages(); | 4330 | ogd->loadMessages(); |
4330 | } | 4331 | } |
4331 | 4332 | ||
4332 | void CalendarView::lookForIncomingMessages() | 4333 | void CalendarView::lookForIncomingMessages() |
4333 | { | 4334 | { |
4334 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4335 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4335 | icd->retrieve(); | 4336 | icd->retrieve(); |
4336 | } | 4337 | } |
4337 | 4338 | ||
4338 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4339 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4339 | { | 4340 | { |
4340 | bool deleteTodo = true; | 4341 | bool deleteTodo = true; |
4341 | QPtrList<Incidence> subTodos; | 4342 | QPtrList<Incidence> subTodos; |
4342 | Incidence *aTodo; | 4343 | Incidence *aTodo; |
4343 | subTodos = t->relations(); | 4344 | subTodos = t->relations(); |
4344 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4345 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4345 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4346 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4346 | deleteTodo = false; | 4347 | deleteTodo = false; |
4347 | } | 4348 | } |
4348 | if ( deleteTodo ) { | 4349 | if ( deleteTodo ) { |
4349 | if ( t->isCompleted() && !t->doesRecur()) { | 4350 | if ( t->isCompleted() && !t->doesRecur()) { |
4350 | checkExternalId( t ); | 4351 | checkExternalId( t ); |
4351 | mCalendar->deleteTodo( t ); | 4352 | mCalendar->deleteTodo( t ); |
4352 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4353 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4353 | } | 4354 | } |
4354 | else | 4355 | else |
4355 | deleteTodo = false; | 4356 | deleteTodo = false; |
4356 | } | 4357 | } |
4357 | return deleteTodo; | 4358 | return deleteTodo; |
4358 | 4359 | ||
4359 | } | 4360 | } |
4360 | void CalendarView::purgeCompleted() | 4361 | void CalendarView::purgeCompleted() |
4361 | { | 4362 | { |
4362 | int result = KMessageBox::warningContinueCancel(this, | 4363 | int result = KMessageBox::warningContinueCancel(this, |
4363 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4364 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4364 | 4365 | ||
4365 | if (result == KMessageBox::Continue) { | 4366 | if (result == KMessageBox::Continue) { |
4366 | 4367 | ||
4367 | QPtrList<Todo> todoCal; | 4368 | QPtrList<Todo> todoCal; |
4368 | QPtrList<Todo> rootTodos; | 4369 | QPtrList<Todo> rootTodos; |
4369 | //QPtrList<Incidence> rel; | 4370 | //QPtrList<Incidence> rel; |
4370 | Todo *aTodo;//, *rTodo; | 4371 | Todo *aTodo;//, *rTodo; |
4371 | Incidence *rIncidence; | 4372 | Incidence *rIncidence; |
4372 | bool childDelete = false; | 4373 | bool childDelete = false; |
4373 | bool deletedOne = true; | 4374 | bool deletedOne = true; |
4374 | todoCal = calendar()->todos(); | 4375 | todoCal = calendar()->todos(); |
4375 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4376 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4376 | if ( !aTodo->relatedTo() ) | 4377 | if ( !aTodo->relatedTo() ) |
4377 | rootTodos.append( aTodo ); | 4378 | rootTodos.append( aTodo ); |
4378 | } | 4379 | } |
4379 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4380 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4380 | removeCompletedSubTodos( aTodo ); | 4381 | removeCompletedSubTodos( aTodo ); |
4381 | } | 4382 | } |
4382 | 4383 | ||
4383 | updateView(); | 4384 | updateView(); |
4384 | } | 4385 | } |
4385 | } | 4386 | } |
4386 | 4387 | ||
4387 | void CalendarView::slotCalendarChanged() | 4388 | void CalendarView::slotCalendarChanged() |
4388 | { | 4389 | { |
4389 | ; | 4390 | ; |
4390 | } | 4391 | } |
4391 | 4392 | ||
4392 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4393 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4393 | { | 4394 | { |
4394 | //qDebug(" alendarView::keyPressEvent "); | 4395 | //qDebug(" alendarView::keyPressEvent "); |
4395 | e->ignore(); | 4396 | e->ignore(); |
4396 | } | 4397 | } |
4397 | 4398 | ||
4398 | 4399 | ||
4399 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4400 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4400 | { | 4401 | { |
4401 | // mSyncManager = manager; | 4402 | // mSyncManager = manager; |
4402 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4403 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4403 | qDebug("KO: SyncKDE request detected!"); | 4404 | qDebug("KO: SyncKDE request detected!"); |
4404 | } | 4405 | } |
4405 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4406 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4406 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4407 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4407 | return syncCalendar( filename, mode ); | 4408 | return syncCalendar( filename, mode ); |
4408 | } | 4409 | } |
4409 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4410 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4410 | { | 4411 | { |
4411 | //mSyncManager = manager; | 4412 | //mSyncManager = manager; |
4412 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4413 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4413 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4414 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4414 | if ( resource == "sharp" ) | 4415 | if ( resource == "sharp" ) |
4415 | syncExternal( 0 ); | 4416 | syncExternal( 0 ); |
4416 | if ( resource == "phone" ) | 4417 | if ( resource == "phone" ) |
4417 | syncExternal( 1 ); | 4418 | syncExternal( 1 ); |
4418 | // pending setmodified | 4419 | // pending setmodified |
4419 | return true; | 4420 | return true; |
4420 | } | 4421 | } |
4421 | void CalendarView::setSyncManager(KSyncManager* manager) | 4422 | void CalendarView::setSyncManager(KSyncManager* manager) |
4422 | { | 4423 | { |
4423 | mSyncManager = manager; | 4424 | mSyncManager = manager; |
4424 | } | 4425 | } |
4425 | 4426 | ||
4426 | void CalendarView::removeSyncInfo( QString syncProfile) | 4427 | void CalendarView::removeSyncInfo( QString syncProfile) |
4427 | { | 4428 | { |
4428 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4429 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4429 | mCalendar->removeSyncInfo( syncProfile ); | 4430 | mCalendar->removeSyncInfo( syncProfile ); |
4430 | 4431 | ||
4431 | } | 4432 | } |
4432 | 4433 | ||
4433 | void CalendarView::undo_delete() | 4434 | void CalendarView::undo_delete() |
4434 | { | 4435 | { |
4435 | //qDebug("undo_delete() "); | 4436 | //qDebug("undo_delete() "); |
4436 | Incidence* undo = mCalendar->undoIncidence(); | 4437 | Incidence* undo = mCalendar->undoIncidence(); |
4437 | if ( !undo ) { | 4438 | if ( !undo ) { |
4438 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4439 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4439 | i18n("KO/Pi")); | 4440 | i18n("KO/Pi")); |
4440 | return; | 4441 | return; |
4441 | } | 4442 | } |
4442 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 4443 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
4443 | i18n("\nAre you sure you want\nto restore this?"), | 4444 | i18n("\nAre you sure you want\nto restore this?"), |
4444 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4445 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4445 | mCalendar->undoDeleteIncidence(); | 4446 | mCalendar->undoDeleteIncidence(); |
4446 | updateView(); | 4447 | updateView(); |
4447 | } | 4448 | } |
4448 | } | 4449 | } |
4449 | 4450 | ||
4450 | void CalendarView::slotViewerClosed() | 4451 | void CalendarView::slotViewerClosed() |
4451 | { | 4452 | { |
4452 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4453 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4453 | } | 4454 | } |
4454 | 4455 | ||
4455 | void CalendarView::resetFocus() | 4456 | void CalendarView::resetFocus() |
4456 | { | 4457 | { |
4457 | if ( mViewerCallerIsSearchDialog ) { | 4458 | if ( mViewerCallerIsSearchDialog ) { |
4458 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4459 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4459 | mDialogManager->getSearchDialog()->raise(); | 4460 | mDialogManager->getSearchDialog()->raise(); |
4460 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4461 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4461 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4462 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4462 | } else | 4463 | } else |
4463 | mViewerCallerIsSearchDialog = false; | 4464 | mViewerCallerIsSearchDialog = false; |
4464 | } | 4465 | } |
4465 | if ( !mViewerCallerIsSearchDialog ) { | 4466 | if ( !mViewerCallerIsSearchDialog ) { |
4466 | //mViewManager->currentView()->setFocus(); | 4467 | //mViewManager->currentView()->setFocus(); |
4467 | //qDebug("sssssssssssssssset focus "); | 4468 | //qDebug("sssssssssssssssset focus "); |
4468 | topLevelWidget()->raise(); | 4469 | topLevelWidget()->raise(); |
4469 | setActiveWindow(); | 4470 | setActiveWindow(); |
4470 | //setFocus(); | 4471 | //setFocus(); |
4471 | } | 4472 | } |
4472 | mViewerCallerIsSearchDialog = false; | 4473 | mViewerCallerIsSearchDialog = false; |
4473 | } | 4474 | } |
4474 | 4475 | ||
4475 | void CalendarView::showNextAlarms() | 4476 | void CalendarView::showNextAlarms() |
4476 | { | 4477 | { |
4477 | QString message; | 4478 | QString message; |
4478 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4479 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4479 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4480 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4480 | QString sum = mCalendar->nextSummary(); | 4481 | QString sum = mCalendar->nextSummary(); |
4481 | QDateTime nextA = mNextAlarmDateTime; | 4482 | QDateTime nextA = mNextAlarmDateTime; |
4482 | QDateTime cur = QDateTime::currentDateTime(); | 4483 | QDateTime cur = QDateTime::currentDateTime(); |
4483 | int secs = cur.secsTo( nextA ); | 4484 | int secs = cur.secsTo( nextA ); |
4484 | int min = secs /60; | 4485 | int min = secs /60; |
4485 | int hours = min /60; | 4486 | int hours = min /60; |
4486 | min = min % 60; | 4487 | min = min % 60; |
4487 | int days = hours /24; | 4488 | int days = hours /24; |
4488 | hours = hours % 24; | 4489 | hours = hours % 24; |
4489 | 4490 | ||
4490 | //message = i18n("The next alarm is in:\n"); | 4491 | //message = i18n("The next alarm is in:\n"); |
4491 | if ( days > 1 ) | 4492 | if ( days > 1 ) |
4492 | message += i18n("%1 days\n").arg( days ); | 4493 | message += i18n("%1 days\n").arg( days ); |
4493 | else if ( days == 1 ) | 4494 | else if ( days == 1 ) |
4494 | message += i18n("1 day\n"); | 4495 | message += i18n("1 day\n"); |
4495 | if ( hours > 1 ) | 4496 | if ( hours > 1 ) |
4496 | message += i18n("%1 hours\n").arg( hours ); | 4497 | message += i18n("%1 hours\n").arg( hours ); |
4497 | else if ( hours == 1 ) | 4498 | else if ( hours == 1 ) |
4498 | message += i18n("1 hour\n"); | 4499 | message += i18n("1 hour\n"); |
4499 | if ( min > 1 ) | 4500 | if ( min > 1 ) |
4500 | message += i18n("%1 minutes\n").arg( min ); | 4501 | message += i18n("%1 minutes\n").arg( min ); |
4501 | else if ( min == 1 ) | 4502 | else if ( min == 1 ) |
4502 | message += i18n("1 minute\n"); | 4503 | message += i18n("1 minute\n"); |
4503 | if ( message.isEmpty() ) | 4504 | if ( message.isEmpty() ) |
4504 | message = i18n("The next alarm is in\nless than one minute!"); | 4505 | message = i18n("The next alarm is in\nless than one minute!"); |
4505 | else | 4506 | else |
4506 | message = i18n("The next alarm is in:\n") + message; | 4507 | message = i18n("The next alarm is in:\n") + message; |
4507 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4508 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4508 | } else { | 4509 | } else { |
4509 | message = i18n("There is no next alarm."); | 4510 | message = i18n("There is no next alarm."); |
4510 | 4511 | ||
4511 | } | 4512 | } |
4512 | #ifdef DESKTOP_VERSION | 4513 | #ifdef DESKTOP_VERSION |
4513 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4514 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4514 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4515 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4515 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4516 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4516 | } | 4517 | } |
4517 | 4518 | ||
4518 | #endif | 4519 | #endif |
4519 | KMessageBox::information( this, message); | 4520 | KMessageBox::information( this, message); |
4520 | } | 4521 | } |
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 | } |