author | zautrix <zautrix> | 2005-06-29 20:48:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-29 20:48:31 (UTC) |
commit | f55b992a98cc081207b23283aadcf2ecffc90a87 (patch) (unidiff) | |
tree | b0b54ac4f2a164ac7e7ca49bea78f62e4f58fa62 | |
parent | 8954bae7bb5afc9706e37e808e9c1e237399f214 (diff) | |
download | kdepimpi-f55b992a98cc081207b23283aadcf2ecffc90a87.zip kdepimpi-f55b992a98cc081207b23283aadcf2ecffc90a87.tar.gz kdepimpi-f55b992a98cc081207b23283aadcf2ecffc90a87.tar.bz2 |
fixxxx
-rw-r--r-- | korganizer/calendarview.cpp | 16 | ||||
-rw-r--r-- | korganizer/calendarview.h | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 776cdd3..623cf9d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4123 +1,4133 @@ | |||
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 | 371 | ||
372 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
373 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
374 | mViewManager = new KOViewManager( this ); | 374 | mViewManager = new KOViewManager( this ); |
375 | mDialogManager = new KODialogManager( this ); | 375 | mDialogManager = new KODialogManager( this ); |
376 | mEventViewerDialog = 0; | 376 | mEventViewerDialog = 0; |
377 | mModified = false; | 377 | mModified = false; |
378 | mReadOnly = false; | 378 | mReadOnly = false; |
379 | mSelectedIncidence = 0; | 379 | mSelectedIncidence = 0; |
380 | mCalPrinter = 0; | 380 | mCalPrinter = 0; |
381 | mFilters.setAutoDelete(true); | 381 | mFilters.setAutoDelete(true); |
382 | 382 | ||
383 | mCalendar->registerObserver( this ); | 383 | mCalendar->registerObserver( this ); |
384 | // TODO: Make sure that view is updated, when calendar is changed. | 384 | // TODO: Make sure that view is updated, when calendar is changed. |
385 | 385 | ||
386 | mStorage = new FileStorage( mCalendar ); | 386 | mStorage = new FileStorage( mCalendar ); |
387 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 387 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
388 | 388 | ||
389 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 389 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
390 | #ifndef KORG_NOSPLITTER | 390 | #ifndef KORG_NOSPLITTER |
391 | // create the main layout frames. | 391 | // create the main layout frames. |
392 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 392 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
393 | topLayout->addWidget(mPanner); | 393 | topLayout->addWidget(mPanner); |
394 | 394 | ||
395 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 395 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
396 | "CalendarView::LeftFrame"); | 396 | "CalendarView::LeftFrame"); |
397 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 397 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
398 | 398 | ||
399 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 399 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
400 | "CalendarView::DateNavigator" ); | 400 | "CalendarView::DateNavigator" ); |
401 | 401 | ||
402 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 402 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
403 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 403 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
404 | mTodoList->setNavigator( mNavigator ); | 404 | mTodoList->setNavigator( mNavigator ); |
405 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 405 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
406 | 406 | ||
407 | #ifdef KORG_NORESOURCEVIEW | 407 | #ifdef KORG_NORESOURCEVIEW |
408 | mResourceView = 0; | 408 | mResourceView = 0; |
409 | #else | 409 | #else |
410 | if ( mResourceManager ) { | 410 | if ( mResourceManager ) { |
411 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 411 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
412 | mResourceView->updateView(); | 412 | mResourceView->updateView(); |
413 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 413 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
414 | SLOT( updateView() ) ); | 414 | SLOT( updateView() ) ); |
415 | } else { | 415 | } else { |
416 | mResourceView = 0; | 416 | mResourceView = 0; |
417 | } | 417 | } |
418 | #endif | 418 | #endif |
419 | QWidget *rightBox = new QWidget( mPanner ); | 419 | QWidget *rightBox = new QWidget( mPanner ); |
420 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 420 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
421 | 421 | ||
422 | mRightFrame = new QWidgetStack( rightBox ); | 422 | mRightFrame = new QWidgetStack( rightBox ); |
423 | rightLayout->addWidget( mRightFrame, 1 ); | 423 | rightLayout->addWidget( mRightFrame, 1 ); |
424 | 424 | ||
425 | mLeftFrame = mLeftSplitter; | 425 | mLeftFrame = mLeftSplitter; |
426 | #else | 426 | #else |
427 | //QWidget *mainBox = new QWidget( this ); | 427 | //QWidget *mainBox = new QWidget( this ); |
428 | //QWidget *leftFrame = new QWidget( mainBox ); | 428 | //QWidget *leftFrame = new QWidget( mainBox ); |
429 | //QBoxLayout * mainBoxLayout; | 429 | //QBoxLayout * mainBoxLayout; |
430 | if ( KOPrefs::instance()->mVerticalScreen ) { | 430 | if ( KOPrefs::instance()->mVerticalScreen ) { |
431 | //mainBoxLayout = new QVBoxLayout(mainBox); | 431 | //mainBoxLayout = new QVBoxLayout(mainBox); |
432 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 432 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
433 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 433 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
434 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 434 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
435 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 435 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
436 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 436 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
437 | } else { | 437 | } else { |
438 | //mainBoxLayout = new QHBoxLayout(mainBox); | 438 | //mainBoxLayout = new QHBoxLayout(mainBox); |
439 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 439 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
440 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 440 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
441 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 441 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
442 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 442 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
443 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 443 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
444 | } | 444 | } |
445 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 445 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
446 | //QBoxLayout * leftFrameLayout; | 446 | //QBoxLayout * leftFrameLayout; |
447 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); | ||
448 | topLayout->addWidget( mMainFrame ); | 447 | topLayout->addWidget( mMainFrame ); |
449 | topLayout->addWidget( mDateScrollBar ); | 448 | #ifdef DESKTOP_VERSION |
449 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); | ||
450 | topLayout->addWidget( mDateScrollBar ); | ||
451 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | ||
452 | #endif | ||
450 | //mainBoxLayout->addWidget (mLeftFrame); | 453 | //mainBoxLayout->addWidget (mLeftFrame); |
451 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 454 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
452 | "CalendarView::DateNavigator" ); | 455 | "CalendarView::DateNavigator" ); |
453 | #if 0 | 456 | #if 0 |
454 | // FIXME | 457 | // FIXME |
455 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 458 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
456 | "CalendarView::DateNavigator", QDate::currentDate()); | 459 | "CalendarView::DateNavigator", QDate::currentDate()); |
457 | #endif | 460 | #endif |
458 | // mDateNavigator->blockSignals( true ); | 461 | // mDateNavigator->blockSignals( true ); |
459 | //leftFrameLayout->addWidget( mDateNavigator ); | 462 | //leftFrameLayout->addWidget( mDateNavigator ); |
460 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 463 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
461 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 464 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
462 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 465 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
463 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 466 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
464 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 467 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
465 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); | 468 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); |
466 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 469 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
467 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 470 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
468 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 471 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
469 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 472 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
470 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 473 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
471 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 474 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
472 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 475 | |
473 | mTodoList->setNavigator( mNavigator ); | 476 | mTodoList->setNavigator( mNavigator ); |
474 | #if 0 | 477 | #if 0 |
475 | if ( QApplication::desktop()->width() < 480 ) { | 478 | if ( QApplication::desktop()->width() < 480 ) { |
476 | leftFrameLayout->addWidget(mFilterView); | 479 | leftFrameLayout->addWidget(mFilterView); |
477 | leftFrameLayout->addWidget(mTodoList, 2 ); | 480 | leftFrameLayout->addWidget(mTodoList, 2 ); |
478 | 481 | ||
479 | } else { | 482 | } else { |
480 | leftFrameLayout->addWidget(mTodoList,2 ); | 483 | leftFrameLayout->addWidget(mTodoList,2 ); |
481 | leftFrameLayout->addWidget(mFilterView ); | 484 | leftFrameLayout->addWidget(mFilterView ); |
482 | } | 485 | } |
483 | #endif | 486 | #endif |
484 | mFilterView->hide(); | 487 | mFilterView->hide(); |
485 | mCalEditView->hide(); | 488 | mCalEditView->hide(); |
486 | QWidget *rightBox = new QWidget( mMainFrame ); | 489 | QWidget *rightBox = new QWidget( mMainFrame ); |
487 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 490 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
488 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 491 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
489 | mRightFrame = new QWidgetStack( rightBox ); | 492 | mRightFrame = new QWidgetStack( rightBox ); |
490 | rightLayout->addWidget( mRightFrame, 10 ); | 493 | rightLayout->addWidget( mRightFrame, 10 ); |
491 | 494 | ||
492 | //mLeftFrame = (QWidget *)leftFrame; | 495 | //mLeftFrame = (QWidget *)leftFrame; |
493 | if ( KOPrefs::instance()->mVerticalScreen ) { | 496 | if ( KOPrefs::instance()->mVerticalScreen ) { |
494 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 497 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
495 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 498 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
496 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 499 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
497 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 500 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
498 | } else { | 501 | } else { |
499 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 502 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
500 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 503 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
501 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 504 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
502 | } | 505 | } |
503 | if ( !KOPrefs::instance()->mShowDateNavigator) | 506 | if ( !KOPrefs::instance()->mShowDateNavigator) |
504 | mDateNavigator->hide(); | 507 | mDateNavigator->hide(); |
505 | //qDebug("Calendarview Size %d %d ", width(), height()); | 508 | //qDebug("Calendarview Size %d %d ", width(), height()); |
506 | #endif | 509 | #endif |
507 | 510 | ||
508 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 511 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
509 | SLOT( showDates( const KCal::DateList & ) ) ); | 512 | SLOT( showDates( const KCal::DateList & ) ) ); |
510 | 513 | ||
511 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 514 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
512 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 515 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
513 | 516 | ||
514 | 517 | ||
515 | 518 | ||
516 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 519 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
517 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 520 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
518 | 521 | ||
519 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 522 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
520 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 523 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
521 | 524 | ||
522 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 525 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
523 | mNavigator, SLOT( selectPreviousYear() ) ); | 526 | mNavigator, SLOT( selectPreviousYear() ) ); |
524 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 527 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
525 | mNavigator, SLOT( selectNextYear() ) ); | 528 | mNavigator, SLOT( selectNextYear() ) ); |
526 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 529 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
527 | mNavigator, SLOT( selectPreviousMonth() ) ); | 530 | mNavigator, SLOT( selectPreviousMonth() ) ); |
528 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 531 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
529 | mNavigator, SLOT( selectNextMonth() ) ); | 532 | mNavigator, SLOT( selectNextMonth() ) ); |
530 | 533 | ||
531 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
532 | mNavigator, SLOT( selectPrevious() ) ); | 535 | mNavigator, SLOT( selectPrevious() ) ); |
533 | connect( mDateNavigator, SIGNAL( goNext() ), | 536 | connect( mDateNavigator, SIGNAL( goNext() ), |
534 | mNavigator, SLOT( selectNext() ) ); | 537 | mNavigator, SLOT( selectNext() ) ); |
535 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 538 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
536 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 539 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
537 | 540 | ||
538 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 541 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
539 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 542 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
540 | #if 0 | 543 | #if 0 |
541 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 544 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
542 | SLOT( incidenceAdded( Incidence *) ) ); | 545 | SLOT( incidenceAdded( Incidence *) ) ); |
543 | #endif | 546 | #endif |
544 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 547 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
545 | 548 | ||
546 | connect( this, SIGNAL( configChanged() ), | 549 | connect( this, SIGNAL( configChanged() ), |
547 | mDateNavigator, SLOT( updateConfig() ) ); | 550 | mDateNavigator, SLOT( updateConfig() ) ); |
548 | 551 | ||
549 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 552 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
550 | SLOT( newTodo() ) ); | 553 | SLOT( newTodo() ) ); |
551 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 554 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
552 | SLOT( newSubTodo( Todo * ) ) ); | 555 | SLOT( newSubTodo( Todo * ) ) ); |
553 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 556 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
554 | SLOT( editTodo( Todo * ) ) ); | 557 | SLOT( editTodo( Todo * ) ) ); |
555 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 558 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
556 | SLOT( showTodo( Todo *) ) ); | 559 | SLOT( showTodo( Todo *) ) ); |
557 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 560 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
558 | SLOT( deleteTodo( Todo *) ) ); | 561 | SLOT( deleteTodo( Todo *) ) ); |
559 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 562 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
560 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 563 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
561 | SLOT( purgeCompleted() ) ); | 564 | SLOT( purgeCompleted() ) ); |
562 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 565 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
563 | SIGNAL( todoModified( Todo *, int ) ) ); | 566 | SIGNAL( todoModified( Todo *, int ) ) ); |
564 | 567 | ||
565 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 568 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
566 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 569 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
567 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 570 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
568 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 571 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
569 | 572 | ||
570 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
571 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 574 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
572 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
573 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 576 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
574 | 577 | ||
575 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 578 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
576 | this, SLOT ( todo_unsub( Todo * ) ) ); | 579 | this, SLOT ( todo_unsub( Todo * ) ) ); |
577 | 580 | ||
578 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 581 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
579 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 582 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
580 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 583 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
581 | SLOT( updateTodo( Todo *, int ) ) ); | 584 | SLOT( updateTodo( Todo *, int ) ) ); |
582 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 585 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
583 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 586 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
584 | 587 | ||
585 | 588 | ||
586 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 589 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
587 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 590 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
588 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 591 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
589 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 592 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
590 | 593 | ||
591 | 594 | ||
592 | 595 | ||
593 | 596 | ||
594 | 597 | ||
595 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 598 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
596 | SLOT(checkClipboard())); | 599 | SLOT(checkClipboard())); |
597 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 600 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
598 | SLOT( processTodoListSelection( Incidence * ) ) ); | 601 | SLOT( processTodoListSelection( Incidence * ) ) ); |
599 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 602 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
600 | 603 | ||
601 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 604 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
602 | 605 | ||
603 | mDateFrame = new QVBox(0,0,WType_Popup); | 606 | mDateFrame = new QVBox(0,0,WType_Popup); |
604 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 607 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
605 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 608 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
606 | mDateFrame->setLineWidth(3); | 609 | mDateFrame->setLineWidth(3); |
607 | mDateFrame->hide(); | 610 | mDateFrame->hide(); |
608 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 611 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
609 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 612 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
610 | 613 | ||
611 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 614 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
612 | 615 | ||
613 | mEventEditor = mDialogManager->getEventEditor(); | 616 | mEventEditor = mDialogManager->getEventEditor(); |
614 | mTodoEditor = mDialogManager->getTodoEditor(); | 617 | mTodoEditor = mDialogManager->getTodoEditor(); |
615 | 618 | ||
616 | mFlagEditDescription = false; | 619 | mFlagEditDescription = false; |
617 | 620 | ||
618 | mSuspendTimer = new QTimer( this ); | 621 | mSuspendTimer = new QTimer( this ); |
619 | mAlarmTimer = new QTimer( this ); | 622 | mAlarmTimer = new QTimer( this ); |
620 | mRecheckAlarmTimer = new QTimer( this ); | 623 | mRecheckAlarmTimer = new QTimer( this ); |
621 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 624 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
622 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 625 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
623 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 626 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
624 | mAlarmDialog = new AlarmDialog( this ); | 627 | mAlarmDialog = new AlarmDialog( this ); |
625 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 628 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
626 | mAlarmDialog->setServerNotification( false ); | 629 | mAlarmDialog->setServerNotification( false ); |
627 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 630 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
628 | 631 | ||
629 | 632 | ||
630 | #ifndef DESKTOP_VERSION | 633 | #ifndef DESKTOP_VERSION |
631 | //US listen for arriving address resultsets | 634 | //US listen for arriving address resultsets |
632 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 635 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
633 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 636 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
634 | #endif | 637 | #endif |
635 | mDateNavigator->setCalendar( mCalendar ); | 638 | mDateNavigator->setCalendar( mCalendar ); |
636 | } | 639 | } |
637 | 640 | ||
638 | 641 | ||
639 | CalendarView::~CalendarView() | 642 | CalendarView::~CalendarView() |
640 | { | 643 | { |
641 | // kdDebug() << "~CalendarView()" << endl; | 644 | // kdDebug() << "~CalendarView()" << endl; |
642 | //qDebug("CalendarView::~CalendarView() "); | 645 | //qDebug("CalendarView::~CalendarView() "); |
643 | delete mDialogManager; | 646 | delete mDialogManager; |
644 | delete mViewManager; | 647 | delete mViewManager; |
645 | delete mStorage; | 648 | delete mStorage; |
646 | delete mDateFrame ; | 649 | delete mDateFrame ; |
647 | delete mEventViewerDialog; | 650 | delete mEventViewerDialog; |
648 | //kdDebug() << "~CalendarView() done" << endl; | 651 | //kdDebug() << "~CalendarView() done" << endl; |
649 | } | 652 | } |
650 | void CalendarView::setScrollBarStep(int val ) | 653 | void CalendarView::setScrollBarStep(int val ) |
651 | { | 654 | { |
655 | #ifdef DESKTOP_VERSION | ||
652 | mDateScrollBar->setLineStep ( val ); | 656 | mDateScrollBar->setLineStep ( val ); |
657 | #endif | ||
653 | } | 658 | } |
654 | void CalendarView::scrollBarValue(int val ) | 659 | void CalendarView::scrollBarValue(int val ) |
655 | { | 660 | { |
661 | #ifdef DESKTOP_VERSION | ||
662 | if ( QApplication::desktop()->width() < 800 ) return; | ||
656 | static bool block = false; | 663 | static bool block = false; |
657 | if ( block ) return; | 664 | if ( block ) return; |
658 | block = true; | 665 | block = true; |
659 | val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 666 | val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
660 | //qDebug("VAL %d ",val ); | 667 | //qDebug("VAL %d ",val ); |
661 | int count = mNavigator->selectedDates().count(); | 668 | int count = mNavigator->selectedDates().count(); |
662 | int year = mNavigator->selectedDates().first().year(); | 669 | int year = mNavigator->selectedDates().first().year(); |
663 | int day = mNavigator->selectedDates().first().dayOfYear(); | 670 | int day = mNavigator->selectedDates().first().dayOfYear(); |
664 | if ( val == day -1 ) { | 671 | if ( val == day -1 ) { |
665 | block = false; | 672 | block = false; |
666 | return; | 673 | return; |
667 | } | 674 | } |
668 | QDate d ( year,1,1 ); | 675 | QDate d ( year,1,1 ); |
669 | mNavigator->selectDates( d.addDays( val ), count ); | 676 | mNavigator->selectDates( d.addDays( val ), count ); |
670 | block = false; | 677 | block = false; |
678 | #endif | ||
671 | 679 | ||
672 | } | 680 | } |
673 | 681 | ||
674 | void CalendarView::checkAlarms() | 682 | void CalendarView::checkAlarms() |
675 | { | 683 | { |
676 | KConfig *config = KOGlobals::config(); | 684 | KConfig *config = KOGlobals::config(); |
677 | config->setGroup( "AppRun" ); | 685 | config->setGroup( "AppRun" ); |
678 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 686 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
679 | int daysto = dt.daysTo( QDate::currentDate() ); | 687 | int daysto = dt.daysTo( QDate::currentDate() ); |
680 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 688 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
681 | dt = dt.addDays( days ); | 689 | dt = dt.addDays( days ); |
682 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 690 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
683 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 691 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
684 | //qDebug("KO: Reading program stop %d ", secs); | 692 | //qDebug("KO: Reading program stop %d ", secs); |
685 | //secs -= ( 3600 * 24*3 ); // debug only | 693 | //secs -= ( 3600 * 24*3 ); // debug only |
686 | QDateTime latest = dt.addSecs ( secs ); | 694 | QDateTime latest = dt.addSecs ( secs ); |
687 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 695 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
688 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 696 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
689 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 697 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
690 | QPtrList<Incidence> al; | 698 | QPtrList<Incidence> al; |
691 | Incidence* inL = el.first(); | 699 | Incidence* inL = el.first(); |
692 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 700 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
693 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 701 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
694 | while ( inL ) { | 702 | while ( inL ) { |
695 | bool ok = false; | 703 | bool ok = false; |
696 | int offset = 0; | 704 | int offset = 0; |
697 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 705 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
698 | if ( ok ) { | 706 | if ( ok ) { |
699 | //qDebug("OK %s",next.toString().latin1()); | 707 | //qDebug("OK %s",next.toString().latin1()); |
700 | if ( next < cur ) { | 708 | if ( next < cur ) { |
701 | al.append( inL ); | 709 | al.append( inL ); |
702 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 710 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
703 | } | 711 | } |
704 | } | 712 | } |
705 | inL = el.next(); | 713 | inL = el.next(); |
706 | } | 714 | } |
707 | if ( al.count() ) { | 715 | if ( al.count() ) { |
708 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 716 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
709 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 717 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
710 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 718 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
711 | lay->setSpacing( 0 ); | 719 | lay->setSpacing( 0 ); |
712 | lay->setMargin( 0 ); | 720 | lay->setMargin( 0 ); |
713 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 721 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
714 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 722 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
715 | lay->addWidget( matb ); | 723 | lay->addWidget( matb ); |
716 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 724 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
717 | int wid = 210; | 725 | int wid = 210; |
718 | int x = QApplication::desktop()->width() - wid - 7; | 726 | int x = QApplication::desktop()->width() - wid - 7; |
719 | int y = QApplication::desktop()->height() - wid - 70; | 727 | int y = QApplication::desktop()->height() - wid - 70; |
720 | dia->setGeometry ( x,y,wid,wid); | 728 | dia->setGeometry ( x,y,wid,wid); |
721 | } else { | 729 | } else { |
722 | int si = 220; | 730 | int si = 220; |
723 | if ( QApplication::desktop()->width() > 470 ) | 731 | if ( QApplication::desktop()->width() > 470 ) |
724 | si = 400; | 732 | si = 400; |
725 | dia->resize(si,si/2); | 733 | dia->resize(si,si/2); |
726 | } | 734 | } |
727 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 735 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
728 | dia->show(); | 736 | dia->show(); |
729 | 737 | ||
730 | } | 738 | } |
731 | } | 739 | } |
732 | void CalendarView::showDay( QDate d ) | 740 | void CalendarView::showDay( QDate d ) |
733 | { | 741 | { |
734 | dateNavigator()->blockSignals( true ); | 742 | dateNavigator()->blockSignals( true ); |
735 | dateNavigator()->selectDate( d ); | 743 | dateNavigator()->selectDate( d ); |
736 | dateNavigator()->blockSignals( false ); | 744 | dateNavigator()->blockSignals( false ); |
737 | mViewManager->showDayView(); | 745 | mViewManager->showDayView(); |
738 | //dateNavigator()->selectDate( d ); | 746 | //dateNavigator()->selectDate( d ); |
739 | } | 747 | } |
740 | void CalendarView::timerAlarm() | 748 | void CalendarView::timerAlarm() |
741 | { | 749 | { |
742 | //qDebug("CalendarView::timerAlarm() "); | 750 | //qDebug("CalendarView::timerAlarm() "); |
743 | computeAlarm(mAlarmNotification ); | 751 | computeAlarm(mAlarmNotification ); |
744 | } | 752 | } |
745 | 753 | ||
746 | void CalendarView::suspendAlarm() | 754 | void CalendarView::suspendAlarm() |
747 | { | 755 | { |
748 | //qDebug(" CalendarView::suspendAlarm() "); | 756 | //qDebug(" CalendarView::suspendAlarm() "); |
749 | computeAlarm(mSuspendAlarmNotification ); | 757 | computeAlarm(mSuspendAlarmNotification ); |
750 | 758 | ||
751 | } | 759 | } |
752 | 760 | ||
753 | void CalendarView::startAlarm( QString mess , QString filename) | 761 | void CalendarView::startAlarm( QString mess , QString filename) |
754 | { | 762 | { |
755 | 763 | ||
756 | topLevelWidget()->showNormal(); | 764 | topLevelWidget()->showNormal(); |
757 | topLevelWidget()->setActiveWindow(); | 765 | topLevelWidget()->setActiveWindow(); |
758 | topLevelWidget()->raise(); | 766 | topLevelWidget()->raise(); |
759 | 767 | ||
760 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 768 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
761 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 769 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
762 | 770 | ||
763 | } | 771 | } |
764 | 772 | ||
765 | void CalendarView::checkNextTimerAlarm() | 773 | void CalendarView::checkNextTimerAlarm() |
766 | { | 774 | { |
767 | mCalendar->checkAlarmForIncidence( 0, true ); | 775 | mCalendar->checkAlarmForIncidence( 0, true ); |
768 | } | 776 | } |
769 | 777 | ||
770 | void CalendarView::computeAlarm( QString msg ) | 778 | void CalendarView::computeAlarm( QString msg ) |
771 | { | 779 | { |
772 | 780 | ||
773 | QString mess = msg; | 781 | QString mess = msg; |
774 | QString mAlarmMessage = mess.mid( 9 ); | 782 | QString mAlarmMessage = mess.mid( 9 ); |
775 | QString filename = MainWindow::resourcePath(); | 783 | QString filename = MainWindow::resourcePath(); |
776 | filename += "koalarm.wav"; | 784 | filename += "koalarm.wav"; |
777 | QString tempfilename; | 785 | QString tempfilename; |
778 | if ( mess.left( 13 ) == "suspend_alarm") { | 786 | if ( mess.left( 13 ) == "suspend_alarm") { |
779 | bool error = false; | 787 | bool error = false; |
780 | int len = mess.mid( 13 ).find("+++"); | 788 | int len = mess.mid( 13 ).find("+++"); |
781 | if ( len < 2 ) | 789 | if ( len < 2 ) |
782 | error = true; | 790 | error = true; |
783 | else { | 791 | else { |
784 | tempfilename = mess.mid( 13, len ); | 792 | tempfilename = mess.mid( 13, len ); |
785 | if ( !QFile::exists( tempfilename ) ) | 793 | if ( !QFile::exists( tempfilename ) ) |
786 | error = true; | 794 | error = true; |
787 | } | 795 | } |
788 | if ( ! error ) { | 796 | if ( ! error ) { |
789 | filename = tempfilename; | 797 | filename = tempfilename; |
790 | } | 798 | } |
791 | mAlarmMessage = mess.mid( 13+len+3 ); | 799 | mAlarmMessage = mess.mid( 13+len+3 ); |
792 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 800 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
793 | startAlarm( mAlarmMessage, filename); | 801 | startAlarm( mAlarmMessage, filename); |
794 | return; | 802 | return; |
795 | } | 803 | } |
796 | if ( mess.left( 11 ) == "timer_alarm") { | 804 | if ( mess.left( 11 ) == "timer_alarm") { |
797 | //mTimerTime = 0; | 805 | //mTimerTime = 0; |
798 | startAlarm( mess.mid( 11 ), filename ); | 806 | startAlarm( mess.mid( 11 ), filename ); |
799 | return; | 807 | return; |
800 | } | 808 | } |
801 | if ( mess.left( 10 ) == "proc_alarm") { | 809 | if ( mess.left( 10 ) == "proc_alarm") { |
802 | bool error = false; | 810 | bool error = false; |
803 | int len = mess.mid( 10 ).find("+++"); | 811 | int len = mess.mid( 10 ).find("+++"); |
804 | if ( len < 2 ) | 812 | if ( len < 2 ) |
805 | error = true; | 813 | error = true; |
806 | else { | 814 | else { |
807 | tempfilename = mess.mid( 10, len ); | 815 | tempfilename = mess.mid( 10, len ); |
808 | if ( !QFile::exists( tempfilename ) ) | 816 | if ( !QFile::exists( tempfilename ) ) |
809 | error = true; | 817 | error = true; |
810 | } | 818 | } |
811 | if ( error ) { | 819 | if ( error ) { |
812 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 820 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
813 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 821 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
814 | } else { | 822 | } else { |
815 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 823 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
816 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 824 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
817 | #ifndef _WIN32_ | 825 | #ifndef _WIN32_ |
818 | if ( vfork () == 0 ) { | 826 | if ( vfork () == 0 ) { |
819 | execl ( tempfilename.latin1(), 0 ); | 827 | execl ( tempfilename.latin1(), 0 ); |
820 | return; | 828 | return; |
821 | } | 829 | } |
822 | #else | 830 | #else |
823 | QProcess* p = new QProcess(); | 831 | QProcess* p = new QProcess(); |
824 | p->addArgument( tempfilename.latin1() ); | 832 | p->addArgument( tempfilename.latin1() ); |
825 | p->start(); | 833 | p->start(); |
826 | return; | 834 | return; |
827 | #endif | 835 | #endif |
828 | 836 | ||
829 | return; | 837 | return; |
830 | } | 838 | } |
831 | 839 | ||
832 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 840 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
833 | } | 841 | } |
834 | if ( mess.left( 11 ) == "audio_alarm") { | 842 | if ( mess.left( 11 ) == "audio_alarm") { |
835 | bool error = false; | 843 | bool error = false; |
836 | int len = mess.mid( 11 ).find("+++"); | 844 | int len = mess.mid( 11 ).find("+++"); |
837 | if ( len < 2 ) | 845 | if ( len < 2 ) |
838 | error = true; | 846 | error = true; |
839 | else { | 847 | else { |
840 | tempfilename = mess.mid( 11, len ); | 848 | tempfilename = mess.mid( 11, len ); |
841 | if ( !QFile::exists( tempfilename ) ) | 849 | if ( !QFile::exists( tempfilename ) ) |
842 | error = true; | 850 | error = true; |
843 | } | 851 | } |
844 | if ( ! error ) { | 852 | if ( ! error ) { |
845 | filename = tempfilename; | 853 | filename = tempfilename; |
846 | } | 854 | } |
847 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 855 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
848 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 856 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
849 | } | 857 | } |
850 | if ( mess.left( 9 ) == "cal_alarm") { | 858 | if ( mess.left( 9 ) == "cal_alarm") { |
851 | mAlarmMessage = mess.mid( 9 ) ; | 859 | mAlarmMessage = mess.mid( 9 ) ; |
852 | } | 860 | } |
853 | 861 | ||
854 | startAlarm( mAlarmMessage, filename ); | 862 | startAlarm( mAlarmMessage, filename ); |
855 | 863 | ||
856 | 864 | ||
857 | } | 865 | } |
858 | 866 | ||
859 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 867 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
860 | { | 868 | { |
861 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 869 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
862 | 870 | ||
863 | mSuspendAlarmNotification = noti; | 871 | mSuspendAlarmNotification = noti; |
864 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 872 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
865 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 873 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
866 | mSuspendTimer->start( ms , true ); | 874 | mSuspendTimer->start( ms , true ); |
867 | 875 | ||
868 | } | 876 | } |
869 | 877 | ||
870 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 878 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
871 | { | 879 | { |
872 | mNextAlarmDateTime = qdt; | 880 | mNextAlarmDateTime = qdt; |
873 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 881 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
874 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 882 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
875 | #ifndef DESKTOP_VERSION | 883 | #ifndef DESKTOP_VERSION |
876 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 884 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
877 | #endif | 885 | #endif |
878 | return; | 886 | return; |
879 | } | 887 | } |
880 | int maxSec; | 888 | int maxSec; |
881 | //maxSec = 5; //testing only | 889 | //maxSec = 5; //testing only |
882 | maxSec = 86400+3600; // one day+1hour | 890 | maxSec = 86400+3600; // one day+1hour |
883 | mAlarmNotification = noti; | 891 | mAlarmNotification = noti; |
884 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 892 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
885 | if ( sec > maxSec ) { | 893 | if ( sec > maxSec ) { |
886 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 894 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
887 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 895 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
888 | return; | 896 | return; |
889 | } else { | 897 | } else { |
890 | mRecheckAlarmTimer->stop(); | 898 | mRecheckAlarmTimer->stop(); |
891 | } | 899 | } |
892 | //qDebug("Alarm timer started with secs: %d ", sec); | 900 | //qDebug("Alarm timer started with secs: %d ", sec); |
893 | mAlarmTimer->start( sec *1000 , true ); | 901 | mAlarmTimer->start( sec *1000 , true ); |
894 | 902 | ||
895 | } | 903 | } |
896 | // called by mRecheckAlarmTimer to get next alarm | 904 | // called by mRecheckAlarmTimer to get next alarm |
897 | // we need this, because a QTimer has only a max range of 25 days | 905 | // we need this, because a QTimer has only a max range of 25 days |
898 | void CalendarView::recheckTimerAlarm() | 906 | void CalendarView::recheckTimerAlarm() |
899 | { | 907 | { |
900 | mAlarmTimer->stop(); | 908 | mAlarmTimer->stop(); |
901 | mRecheckAlarmTimer->stop(); | 909 | mRecheckAlarmTimer->stop(); |
902 | mCalendar->checkAlarmForIncidence( 0, true ); | 910 | mCalendar->checkAlarmForIncidence( 0, true ); |
903 | } | 911 | } |
904 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 912 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
905 | { | 913 | { |
906 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 914 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
907 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 915 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
908 | #ifndef DESKTOP_VERSION | 916 | #ifndef DESKTOP_VERSION |
909 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 917 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
910 | #endif | 918 | #endif |
911 | return; | 919 | return; |
912 | } | 920 | } |
913 | mAlarmTimer->stop(); | 921 | mAlarmTimer->stop(); |
914 | } | 922 | } |
915 | void CalendarView::selectWeekNum ( int num ) | 923 | void CalendarView::selectWeekNum ( int num ) |
916 | { | 924 | { |
917 | dateNavigator()->blockSignals( true ); | 925 | dateNavigator()->blockSignals( true ); |
918 | dateNavigator()->selectWeek( num ); | 926 | dateNavigator()->selectWeek( num ); |
919 | dateNavigator()->blockSignals( false ); | 927 | dateNavigator()->blockSignals( false ); |
920 | mViewManager->showWeekView(); | 928 | mViewManager->showWeekView(); |
921 | } | 929 | } |
922 | KOViewManager *CalendarView::viewManager() | 930 | KOViewManager *CalendarView::viewManager() |
923 | { | 931 | { |
924 | return mViewManager; | 932 | return mViewManager; |
925 | } | 933 | } |
926 | 934 | ||
927 | KODialogManager *CalendarView::dialogManager() | 935 | KODialogManager *CalendarView::dialogManager() |
928 | { | 936 | { |
929 | return mDialogManager; | 937 | return mDialogManager; |
930 | } | 938 | } |
931 | 939 | ||
932 | QDate CalendarView::startDate() | 940 | QDate CalendarView::startDate() |
933 | { | 941 | { |
934 | DateList dates = mNavigator->selectedDates(); | 942 | DateList dates = mNavigator->selectedDates(); |
935 | 943 | ||
936 | return dates.first(); | 944 | return dates.first(); |
937 | } | 945 | } |
938 | 946 | ||
939 | QDate CalendarView::endDate() | 947 | QDate CalendarView::endDate() |
940 | { | 948 | { |
941 | DateList dates = mNavigator->selectedDates(); | 949 | DateList dates = mNavigator->selectedDates(); |
942 | 950 | ||
943 | return dates.last(); | 951 | return dates.last(); |
944 | } | 952 | } |
945 | 953 | ||
946 | 954 | ||
947 | void CalendarView::createPrinter() | 955 | void CalendarView::createPrinter() |
948 | { | 956 | { |
949 | #ifndef KORG_NOPRINTER | 957 | #ifndef KORG_NOPRINTER |
950 | if (!mCalPrinter) { | 958 | if (!mCalPrinter) { |
951 | mCalPrinter = new CalPrinter(this, mCalendar); | 959 | mCalPrinter = new CalPrinter(this, mCalendar); |
952 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 960 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
953 | } | 961 | } |
954 | #endif | 962 | #endif |
955 | } | 963 | } |
956 | 964 | ||
957 | 965 | ||
958 | //KOPrefs::instance()->mWriteBackFile | 966 | //KOPrefs::instance()->mWriteBackFile |
959 | //KOPrefs::instance()->mWriteBackExistingOnly | 967 | //KOPrefs::instance()->mWriteBackExistingOnly |
960 | 968 | ||
961 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 969 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
962 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 970 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
963 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 971 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
964 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 972 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
965 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 973 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
966 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 974 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
967 | 975 | ||
968 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 976 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
969 | { | 977 | { |
970 | 978 | ||
971 | // 0 equal | 979 | // 0 equal |
972 | // 1 take local | 980 | // 1 take local |
973 | // 2 take remote | 981 | // 2 take remote |
974 | // 3 cancel | 982 | // 3 cancel |
975 | QDateTime lastSync = mLastCalendarSync; | 983 | QDateTime lastSync = mLastCalendarSync; |
976 | QDateTime localMod = local->lastModified(); | 984 | QDateTime localMod = local->lastModified(); |
977 | QDateTime remoteMod = remote->lastModified(); | 985 | QDateTime remoteMod = remote->lastModified(); |
978 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 986 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
979 | bool remCh, locCh; | 987 | bool remCh, locCh; |
980 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 988 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
981 | //if ( remCh ) | 989 | //if ( remCh ) |
982 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 990 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
983 | locCh = ( localMod > mLastCalendarSync ); | 991 | locCh = ( localMod > mLastCalendarSync ); |
984 | if ( !remCh && ! locCh ) { | 992 | if ( !remCh && ! locCh ) { |
985 | //qDebug("both not changed "); | 993 | //qDebug("both not changed "); |
986 | lastSync = localMod.addDays(1); | 994 | lastSync = localMod.addDays(1); |
987 | if ( mode <= SYNC_PREF_ASK ) | 995 | if ( mode <= SYNC_PREF_ASK ) |
988 | return 0; | 996 | return 0; |
989 | } else { | 997 | } else { |
990 | if ( locCh ) { | 998 | if ( locCh ) { |
991 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 999 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
992 | lastSync = localMod.addDays( -1 ); | 1000 | lastSync = localMod.addDays( -1 ); |
993 | if ( !remCh ) | 1001 | if ( !remCh ) |
994 | remoteMod = ( lastSync.addDays( -1 ) ); | 1002 | remoteMod = ( lastSync.addDays( -1 ) ); |
995 | } else { | 1003 | } else { |
996 | //qDebug(" not loc changed "); | 1004 | //qDebug(" not loc changed "); |
997 | lastSync = localMod.addDays( 1 ); | 1005 | lastSync = localMod.addDays( 1 ); |
998 | if ( remCh ) | 1006 | if ( remCh ) |
999 | remoteMod =( lastSync.addDays( 1 ) ); | 1007 | remoteMod =( lastSync.addDays( 1 ) ); |
1000 | 1008 | ||
1001 | } | 1009 | } |
1002 | } | 1010 | } |
1003 | full = true; | 1011 | full = true; |
1004 | if ( mode < SYNC_PREF_ASK ) | 1012 | if ( mode < SYNC_PREF_ASK ) |
1005 | mode = SYNC_PREF_ASK; | 1013 | mode = SYNC_PREF_ASK; |
1006 | } else { | 1014 | } else { |
1007 | if ( localMod == remoteMod ) | 1015 | if ( localMod == remoteMod ) |
1008 | // if ( local->revision() == remote->revision() ) | 1016 | // if ( local->revision() == remote->revision() ) |
1009 | return 0; | 1017 | return 0; |
1010 | 1018 | ||
1011 | } | 1019 | } |
1012 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1020 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1013 | 1021 | ||
1014 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1022 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1015 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1023 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1016 | //full = true; //debug only | 1024 | //full = true; //debug only |
1017 | if ( full ) { | 1025 | if ( full ) { |
1018 | bool equ = false; | 1026 | bool equ = false; |
1019 | if ( local->typeID() == eventID ) { | 1027 | if ( local->typeID() == eventID ) { |
1020 | equ = (*((Event*) local) == *((Event*) remote)); | 1028 | equ = (*((Event*) local) == *((Event*) remote)); |
1021 | } | 1029 | } |
1022 | else if ( local->typeID() == todoID ) | 1030 | else if ( local->typeID() == todoID ) |
1023 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1031 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1024 | else if ( local->typeID() == journalID ) | 1032 | else if ( local->typeID() == journalID ) |
1025 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1033 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1026 | if ( equ ) { | 1034 | if ( equ ) { |
1027 | //qDebug("equal "); | 1035 | //qDebug("equal "); |
1028 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1036 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1029 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1037 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1030 | } | 1038 | } |
1031 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1039 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1032 | return 0; | 1040 | return 0; |
1033 | 1041 | ||
1034 | }//else //debug only | 1042 | }//else //debug only |
1035 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1043 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1036 | } | 1044 | } |
1037 | int result; | 1045 | int result; |
1038 | bool localIsNew; | 1046 | bool localIsNew; |
1039 | //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() ); | 1047 | //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() ); |
1040 | 1048 | ||
1041 | 1049 | ||
1042 | // ************************************************ | 1050 | // ************************************************ |
1043 | // ************************************************ | 1051 | // ************************************************ |
1044 | // ************************************************ | 1052 | // ************************************************ |
1045 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1053 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1046 | // BUT remoteMod != localMod | 1054 | // BUT remoteMod != localMod |
1047 | 1055 | ||
1048 | 1056 | ||
1049 | if ( full && mode < SYNC_PREF_NEWEST ) | 1057 | if ( full && mode < SYNC_PREF_NEWEST ) |
1050 | mode = SYNC_PREF_ASK; | 1058 | mode = SYNC_PREF_ASK; |
1051 | 1059 | ||
1052 | switch( mode ) { | 1060 | switch( mode ) { |
1053 | case SYNC_PREF_LOCAL: | 1061 | case SYNC_PREF_LOCAL: |
1054 | if ( lastSync > remoteMod ) | 1062 | if ( lastSync > remoteMod ) |
1055 | return 1; | 1063 | return 1; |
1056 | if ( lastSync > localMod ) | 1064 | if ( lastSync > localMod ) |
1057 | return 2; | 1065 | return 2; |
1058 | return 1; | 1066 | return 1; |
1059 | break; | 1067 | break; |
1060 | case SYNC_PREF_REMOTE: | 1068 | case SYNC_PREF_REMOTE: |
1061 | if ( lastSync > localMod ) | 1069 | if ( lastSync > localMod ) |
1062 | return 2; | 1070 | return 2; |
1063 | if ( lastSync > remoteMod ) | 1071 | if ( lastSync > remoteMod ) |
1064 | return 1; | 1072 | return 1; |
1065 | return 2; | 1073 | return 2; |
1066 | break; | 1074 | break; |
1067 | case SYNC_PREF_NEWEST: | 1075 | case SYNC_PREF_NEWEST: |
1068 | if ( localMod >= remoteMod ) | 1076 | if ( localMod >= remoteMod ) |
1069 | return 1; | 1077 | return 1; |
1070 | else | 1078 | else |
1071 | return 2; | 1079 | return 2; |
1072 | break; | 1080 | break; |
1073 | case SYNC_PREF_ASK: | 1081 | case SYNC_PREF_ASK: |
1074 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1082 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1075 | if ( lastSync > remoteMod && lastSync > localMod) | 1083 | if ( lastSync > remoteMod && lastSync > localMod) |
1076 | return 0; | 1084 | return 0; |
1077 | if ( lastSync > remoteMod ) | 1085 | if ( lastSync > remoteMod ) |
1078 | return 1; | 1086 | return 1; |
1079 | if ( lastSync > localMod ) | 1087 | if ( lastSync > localMod ) |
1080 | return 2; | 1088 | return 2; |
1081 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1089 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1082 | localIsNew = localMod >= remoteMod; | 1090 | localIsNew = localMod >= remoteMod; |
1083 | if ( localIsNew ) | 1091 | if ( localIsNew ) |
1084 | getEventViewerDialog()->setColorMode( 1 ); | 1092 | getEventViewerDialog()->setColorMode( 1 ); |
1085 | else | 1093 | else |
1086 | getEventViewerDialog()->setColorMode( 2 ); | 1094 | getEventViewerDialog()->setColorMode( 2 ); |
1087 | getEventViewerDialog()->setIncidence(local); | 1095 | getEventViewerDialog()->setIncidence(local); |
1088 | if ( localIsNew ) | 1096 | if ( localIsNew ) |
1089 | getEventViewerDialog()->setColorMode( 2 ); | 1097 | getEventViewerDialog()->setColorMode( 2 ); |
1090 | else | 1098 | else |
1091 | getEventViewerDialog()->setColorMode( 1 ); | 1099 | getEventViewerDialog()->setColorMode( 1 ); |
1092 | getEventViewerDialog()->addIncidence(remote); | 1100 | getEventViewerDialog()->addIncidence(remote); |
1093 | getEventViewerDialog()->setColorMode( 0 ); | 1101 | getEventViewerDialog()->setColorMode( 0 ); |
1094 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1102 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1095 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1103 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1096 | getEventViewerDialog()->showMe(); | 1104 | getEventViewerDialog()->showMe(); |
1097 | result = getEventViewerDialog()->executeS( localIsNew ); | 1105 | result = getEventViewerDialog()->executeS( localIsNew ); |
1098 | return result; | 1106 | return result; |
1099 | 1107 | ||
1100 | break; | 1108 | break; |
1101 | case SYNC_PREF_FORCE_LOCAL: | 1109 | case SYNC_PREF_FORCE_LOCAL: |
1102 | return 1; | 1110 | return 1; |
1103 | break; | 1111 | break; |
1104 | case SYNC_PREF_FORCE_REMOTE: | 1112 | case SYNC_PREF_FORCE_REMOTE: |
1105 | return 2; | 1113 | return 2; |
1106 | break; | 1114 | break; |
1107 | 1115 | ||
1108 | default: | 1116 | default: |
1109 | // SYNC_PREF_TAKE_BOTH not implemented | 1117 | // SYNC_PREF_TAKE_BOTH not implemented |
1110 | break; | 1118 | break; |
1111 | } | 1119 | } |
1112 | return 0; | 1120 | return 0; |
1113 | } | 1121 | } |
1114 | Event* CalendarView::getLastSyncEvent() | 1122 | Event* CalendarView::getLastSyncEvent() |
1115 | { | 1123 | { |
1116 | Event* lse; | 1124 | Event* lse; |
1117 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1125 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1118 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1126 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1119 | if (!lse) { | 1127 | if (!lse) { |
1120 | lse = new Event(); | 1128 | lse = new Event(); |
1121 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1129 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1122 | QString sum = ""; | 1130 | QString sum = ""; |
1123 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1131 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1124 | sum = "E: "; | 1132 | sum = "E: "; |
1125 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1133 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1126 | lse->setDtStart( mLastCalendarSync ); | 1134 | lse->setDtStart( mLastCalendarSync ); |
1127 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1135 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1128 | lse->setCategories( i18n("SyncEvent") ); | 1136 | lse->setCategories( i18n("SyncEvent") ); |
1129 | lse->setReadOnly( true ); | 1137 | lse->setReadOnly( true ); |
1130 | mCalendar->addEvent( lse ); | 1138 | mCalendar->addEvent( lse ); |
1131 | } | 1139 | } |
1132 | 1140 | ||
1133 | return lse; | 1141 | return lse; |
1134 | 1142 | ||
1135 | } | 1143 | } |
1136 | 1144 | ||
1137 | // we check, if the to delete event has a id for a profile | 1145 | // we check, if the to delete event has a id for a profile |
1138 | // if yes, we set this id in the profile to delete | 1146 | // if yes, we set this id in the profile to delete |
1139 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1147 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1140 | { | 1148 | { |
1141 | if ( lastSync.count() == 0 ) { | 1149 | if ( lastSync.count() == 0 ) { |
1142 | //qDebug(" lastSync.count() == 0"); | 1150 | //qDebug(" lastSync.count() == 0"); |
1143 | return; | 1151 | return; |
1144 | } | 1152 | } |
1145 | if ( toDelete->typeID() == journalID ) | 1153 | if ( toDelete->typeID() == journalID ) |
1146 | return; | 1154 | return; |
1147 | 1155 | ||
1148 | Event* eve = lastSync.first(); | 1156 | Event* eve = lastSync.first(); |
1149 | 1157 | ||
1150 | while ( eve ) { | 1158 | while ( eve ) { |
1151 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1159 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1152 | if ( !id.isEmpty() ) { | 1160 | if ( !id.isEmpty() ) { |
1153 | QString des = eve->description(); | 1161 | QString des = eve->description(); |
1154 | QString pref = "e"; | 1162 | QString pref = "e"; |
1155 | if ( toDelete->typeID() == todoID ) | 1163 | if ( toDelete->typeID() == todoID ) |
1156 | pref = "t"; | 1164 | pref = "t"; |
1157 | des += pref+ id + ","; | 1165 | des += pref+ id + ","; |
1158 | eve->setReadOnly( false ); | 1166 | eve->setReadOnly( false ); |
1159 | eve->setDescription( des ); | 1167 | eve->setDescription( des ); |
1160 | //qDebug("setdes %s ", des.latin1()); | 1168 | //qDebug("setdes %s ", des.latin1()); |
1161 | eve->setReadOnly( true ); | 1169 | eve->setReadOnly( true ); |
1162 | } | 1170 | } |
1163 | eve = lastSync.next(); | 1171 | eve = lastSync.next(); |
1164 | } | 1172 | } |
1165 | 1173 | ||
1166 | } | 1174 | } |
1167 | void CalendarView::checkExternalId( Incidence * inc ) | 1175 | void CalendarView::checkExternalId( Incidence * inc ) |
1168 | { | 1176 | { |
1169 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1177 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1170 | checkExternSyncEvent( lastSync, inc ); | 1178 | checkExternSyncEvent( lastSync, inc ); |
1171 | 1179 | ||
1172 | } | 1180 | } |
1173 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1181 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1174 | { | 1182 | { |
1175 | bool syncOK = true; | 1183 | bool syncOK = true; |
1176 | int addedEvent = 0; | 1184 | int addedEvent = 0; |
1177 | int addedEventR = 0; | 1185 | int addedEventR = 0; |
1178 | int deletedEventR = 0; | 1186 | int deletedEventR = 0; |
1179 | int deletedEventL = 0; | 1187 | int deletedEventL = 0; |
1180 | int changedLocal = 0; | 1188 | int changedLocal = 0; |
1181 | int changedRemote = 0; | 1189 | int changedRemote = 0; |
1182 | int filteredIN = 0; | 1190 | int filteredIN = 0; |
1183 | int filteredOUT = 0; | 1191 | int filteredOUT = 0; |
1184 | //QPtrList<Event> el = local->rawEvents(); | 1192 | //QPtrList<Event> el = local->rawEvents(); |
1185 | Event* eventR; | 1193 | Event* eventR; |
1186 | QString uid; | 1194 | QString uid; |
1187 | int take; | 1195 | int take; |
1188 | Event* eventL; | 1196 | Event* eventL; |
1189 | Event* eventRSync; | 1197 | Event* eventRSync; |
1190 | Event* eventLSync; | 1198 | Event* eventLSync; |
1191 | clearAllViews(); | 1199 | clearAllViews(); |
1192 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1200 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1193 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1201 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1194 | bool fullDateRange = false; | 1202 | bool fullDateRange = false; |
1195 | local->resetTempSyncStat(); | 1203 | local->resetTempSyncStat(); |
1196 | mLastCalendarSync = QDateTime::currentDateTime(); | 1204 | mLastCalendarSync = QDateTime::currentDateTime(); |
1197 | if ( mSyncManager->syncWithDesktop() ) { | 1205 | if ( mSyncManager->syncWithDesktop() ) { |
1198 | remote->resetPilotStat(1); | 1206 | remote->resetPilotStat(1); |
1199 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1207 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1200 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1208 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1201 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1209 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1202 | } else { | 1210 | } else { |
1203 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1211 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1204 | } | 1212 | } |
1205 | } | 1213 | } |
1206 | QDateTime modifiedCalendar = mLastCalendarSync; | 1214 | QDateTime modifiedCalendar = mLastCalendarSync; |
1207 | eventLSync = getLastSyncEvent(); | 1215 | eventLSync = getLastSyncEvent(); |
1208 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1216 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1209 | if ( eventR ) { | 1217 | if ( eventR ) { |
1210 | eventRSync = (Event*) eventR->clone(); | 1218 | eventRSync = (Event*) eventR->clone(); |
1211 | remote->deleteEvent(eventR ); | 1219 | remote->deleteEvent(eventR ); |
1212 | 1220 | ||
1213 | } else { | 1221 | } else { |
1214 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1222 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1215 | eventRSync = (Event*)eventLSync->clone(); | 1223 | eventRSync = (Event*)eventLSync->clone(); |
1216 | } else { | 1224 | } else { |
1217 | fullDateRange = true; | 1225 | fullDateRange = true; |
1218 | eventRSync = new Event(); | 1226 | eventRSync = new Event(); |
1219 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1227 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1220 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1228 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1221 | eventRSync->setDtStart( mLastCalendarSync ); | 1229 | eventRSync->setDtStart( mLastCalendarSync ); |
1222 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1230 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1223 | eventRSync->setCategories( i18n("SyncEvent") ); | 1231 | eventRSync->setCategories( i18n("SyncEvent") ); |
1224 | } | 1232 | } |
1225 | } | 1233 | } |
1226 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1234 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1227 | fullDateRange = true; | 1235 | fullDateRange = true; |
1228 | 1236 | ||
1229 | if ( ! fullDateRange ) { | 1237 | if ( ! fullDateRange ) { |
1230 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1238 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1231 | 1239 | ||
1232 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1240 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1233 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1241 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1234 | fullDateRange = true; | 1242 | fullDateRange = true; |
1235 | } | 1243 | } |
1236 | } | 1244 | } |
1237 | if ( mSyncManager->syncWithDesktop() ) { | 1245 | if ( mSyncManager->syncWithDesktop() ) { |
1238 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1246 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1239 | } | 1247 | } |
1240 | if ( fullDateRange ) | 1248 | if ( fullDateRange ) |
1241 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1249 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1242 | else | 1250 | else |
1243 | mLastCalendarSync = eventLSync->dtStart(); | 1251 | mLastCalendarSync = eventLSync->dtStart(); |
1244 | // for resyncing if own file has changed | 1252 | // for resyncing if own file has changed |
1245 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1253 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1246 | mLastCalendarSync = loadedFileVersion; | 1254 | mLastCalendarSync = loadedFileVersion; |
1247 | //qDebug("setting mLastCalendarSync "); | 1255 | //qDebug("setting mLastCalendarSync "); |
1248 | } | 1256 | } |
1249 | //qDebug("*************************** "); | 1257 | //qDebug("*************************** "); |
1250 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1258 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1251 | QPtrList<Incidence> er = remote->rawIncidences(); | 1259 | QPtrList<Incidence> er = remote->rawIncidences(); |
1252 | Incidence* inR = er.first(); | 1260 | Incidence* inR = er.first(); |
1253 | Incidence* inL; | 1261 | Incidence* inL; |
1254 | QProgressBar bar( er.count(),0 ); | 1262 | QProgressBar bar( er.count(),0 ); |
1255 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1263 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1256 | 1264 | ||
1257 | // ************** setting up filter ************* | 1265 | // ************** setting up filter ************* |
1258 | CalFilter *filterIN = 0; | 1266 | CalFilter *filterIN = 0; |
1259 | CalFilter *filterOUT = 0; | 1267 | CalFilter *filterOUT = 0; |
1260 | CalFilter *filter = mFilters.first(); | 1268 | CalFilter *filter = mFilters.first(); |
1261 | while(filter) { | 1269 | while(filter) { |
1262 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1270 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1263 | filterIN = filter; | 1271 | filterIN = filter; |
1264 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1272 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1265 | filterOUT = filter; | 1273 | filterOUT = filter; |
1266 | filter = mFilters.next(); | 1274 | filter = mFilters.next(); |
1267 | } | 1275 | } |
1268 | int w = 300; | 1276 | int w = 300; |
1269 | if ( QApplication::desktop()->width() < 320 ) | 1277 | if ( QApplication::desktop()->width() < 320 ) |
1270 | w = 220; | 1278 | w = 220; |
1271 | int h = bar.sizeHint().height() ; | 1279 | int h = bar.sizeHint().height() ; |
1272 | int dw = QApplication::desktop()->width(); | 1280 | int dw = QApplication::desktop()->width(); |
1273 | int dh = QApplication::desktop()->height(); | 1281 | int dh = QApplication::desktop()->height(); |
1274 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1282 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1275 | bar.show(); | 1283 | bar.show(); |
1276 | int modulo = (er.count()/10)+1; | 1284 | int modulo = (er.count()/10)+1; |
1277 | int incCounter = 0; | 1285 | int incCounter = 0; |
1278 | while ( inR ) { | 1286 | while ( inR ) { |
1279 | if ( ! bar.isVisible() ) | 1287 | if ( ! bar.isVisible() ) |
1280 | return false; | 1288 | return false; |
1281 | if ( incCounter % modulo == 0 ) | 1289 | if ( incCounter % modulo == 0 ) |
1282 | bar.setProgress( incCounter ); | 1290 | bar.setProgress( incCounter ); |
1283 | ++incCounter; | 1291 | ++incCounter; |
1284 | uid = inR->uid(); | 1292 | uid = inR->uid(); |
1285 | bool skipIncidence = false; | 1293 | bool skipIncidence = false; |
1286 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1294 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1287 | skipIncidence = true; | 1295 | skipIncidence = true; |
1288 | QString idS; | 1296 | QString idS; |
1289 | qApp->processEvents(); | 1297 | qApp->processEvents(); |
1290 | if ( !skipIncidence ) { | 1298 | if ( !skipIncidence ) { |
1291 | inL = local->incidence( uid ); | 1299 | inL = local->incidence( uid ); |
1292 | if ( inL ) { // maybe conflict - same uid in both calendars | 1300 | if ( inL ) { // maybe conflict - same uid in both calendars |
1293 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1301 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1294 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1302 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1295 | if ( take == 3 ) | 1303 | if ( take == 3 ) |
1296 | return false; | 1304 | return false; |
1297 | if ( take == 1 ) {// take local ********************** | 1305 | if ( take == 1 ) {// take local ********************** |
1298 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1306 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1299 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1307 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1300 | else | 1308 | else |
1301 | idS = inR->IDStr(); | 1309 | idS = inR->IDStr(); |
1302 | remote->deleteIncidence( inR ); | 1310 | remote->deleteIncidence( inR ); |
1303 | inR = inL->clone(); | 1311 | inR = inL->clone(); |
1304 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1312 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1305 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1313 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1306 | inR->setIDStr( idS ); | 1314 | inR->setIDStr( idS ); |
1307 | remote->addIncidence( inR ); | 1315 | remote->addIncidence( inR ); |
1308 | if ( mSyncManager->syncWithDesktop() ) | 1316 | if ( mSyncManager->syncWithDesktop() ) |
1309 | inR->setPilotId( 2 ); | 1317 | inR->setPilotId( 2 ); |
1310 | ++changedRemote; | 1318 | ++changedRemote; |
1311 | } else {// take remote ********************** | 1319 | } else {// take remote ********************** |
1312 | idS = inL->IDStr(); | 1320 | idS = inL->IDStr(); |
1313 | int pid = inL->pilotId(); | 1321 | int pid = inL->pilotId(); |
1314 | local->deleteIncidence( inL ); | 1322 | local->deleteIncidence( inL ); |
1315 | inL = inR->clone(); | 1323 | inL = inR->clone(); |
1316 | if ( mSyncManager->syncWithDesktop() ) | 1324 | if ( mSyncManager->syncWithDesktop() ) |
1317 | inL->setPilotId( pid ); | 1325 | inL->setPilotId( pid ); |
1318 | inL->setIDStr( idS ); | 1326 | inL->setIDStr( idS ); |
1319 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1327 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1320 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1328 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1321 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1329 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1322 | } | 1330 | } |
1323 | local->addIncidence( inL ); | 1331 | local->addIncidence( inL ); |
1324 | ++changedLocal; | 1332 | ++changedLocal; |
1325 | } | 1333 | } |
1326 | } | 1334 | } |
1327 | } else { // no conflict ********** add or delete remote | 1335 | } else { // no conflict ********** add or delete remote |
1328 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1336 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1329 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1337 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1330 | QString des = eventLSync->description(); | 1338 | QString des = eventLSync->description(); |
1331 | QString pref = "e"; | 1339 | QString pref = "e"; |
1332 | if ( inR->typeID() == todoID ) | 1340 | if ( inR->typeID() == todoID ) |
1333 | pref = "t"; | 1341 | pref = "t"; |
1334 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1342 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1335 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1343 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1336 | //remote->deleteIncidence( inR ); | 1344 | //remote->deleteIncidence( inR ); |
1337 | ++deletedEventR; | 1345 | ++deletedEventR; |
1338 | } else { | 1346 | } else { |
1339 | inR->setLastModified( modifiedCalendar ); | 1347 | inR->setLastModified( modifiedCalendar ); |
1340 | inL = inR->clone(); | 1348 | inL = inR->clone(); |
1341 | inL->setIDStr( ":" ); | 1349 | inL->setIDStr( ":" ); |
1342 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1350 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1343 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1351 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1344 | local->addIncidence( inL ); | 1352 | local->addIncidence( inL ); |
1345 | ++addedEvent; | 1353 | ++addedEvent; |
1346 | 1354 | ||
1347 | } | 1355 | } |
1348 | } else { | 1356 | } else { |
1349 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1357 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1350 | inR->setLastModified( modifiedCalendar ); | 1358 | inR->setLastModified( modifiedCalendar ); |
1351 | inL = inR->clone(); | 1359 | inL = inR->clone(); |
1352 | inL->setIDStr( ":" ); | 1360 | inL->setIDStr( ":" ); |
1353 | local->addIncidence( inL ); | 1361 | local->addIncidence( inL ); |
1354 | ++addedEvent; | 1362 | ++addedEvent; |
1355 | 1363 | ||
1356 | } else { | 1364 | } else { |
1357 | checkExternSyncEvent(eventRSyncSharp, inR); | 1365 | checkExternSyncEvent(eventRSyncSharp, inR); |
1358 | remote->deleteIncidence( inR ); | 1366 | remote->deleteIncidence( inR ); |
1359 | ++deletedEventR; | 1367 | ++deletedEventR; |
1360 | } | 1368 | } |
1361 | } | 1369 | } |
1362 | } else { | 1370 | } else { |
1363 | ++filteredIN; | 1371 | ++filteredIN; |
1364 | } | 1372 | } |
1365 | } | 1373 | } |
1366 | } | 1374 | } |
1367 | inR = er.next(); | 1375 | inR = er.next(); |
1368 | } | 1376 | } |
1369 | QPtrList<Incidence> el = local->rawIncidences(); | 1377 | QPtrList<Incidence> el = local->rawIncidences(); |
1370 | inL = el.first(); | 1378 | inL = el.first(); |
1371 | modulo = (el.count()/10)+1; | 1379 | modulo = (el.count()/10)+1; |
1372 | bar.setCaption (i18n("Add / remove events") ); | 1380 | bar.setCaption (i18n("Add / remove events") ); |
1373 | bar.setTotalSteps ( el.count() ) ; | 1381 | bar.setTotalSteps ( el.count() ) ; |
1374 | bar.show(); | 1382 | bar.show(); |
1375 | incCounter = 0; | 1383 | incCounter = 0; |
1376 | 1384 | ||
1377 | while ( inL ) { | 1385 | while ( inL ) { |
1378 | 1386 | ||
1379 | qApp->processEvents(); | 1387 | qApp->processEvents(); |
1380 | if ( ! bar.isVisible() ) | 1388 | if ( ! bar.isVisible() ) |
1381 | return false; | 1389 | return false; |
1382 | if ( incCounter % modulo == 0 ) | 1390 | if ( incCounter % modulo == 0 ) |
1383 | bar.setProgress( incCounter ); | 1391 | bar.setProgress( incCounter ); |
1384 | ++incCounter; | 1392 | ++incCounter; |
1385 | uid = inL->uid(); | 1393 | uid = inL->uid(); |
1386 | bool skipIncidence = false; | 1394 | bool skipIncidence = false; |
1387 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1395 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1388 | skipIncidence = true; | 1396 | skipIncidence = true; |
1389 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1397 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1390 | skipIncidence = true; | 1398 | skipIncidence = true; |
1391 | if ( !skipIncidence ) { | 1399 | if ( !skipIncidence ) { |
1392 | inR = remote->incidence( uid ); | 1400 | inR = remote->incidence( uid ); |
1393 | if ( ! inR ) { | 1401 | if ( ! inR ) { |
1394 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1402 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1395 | // no conflict ********** add or delete local | 1403 | // no conflict ********** add or delete local |
1396 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1404 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1397 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1405 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1398 | checkExternSyncEvent(eventLSyncSharp, inL); | 1406 | checkExternSyncEvent(eventLSyncSharp, inL); |
1399 | local->deleteIncidence( inL ); | 1407 | local->deleteIncidence( inL ); |
1400 | ++deletedEventL; | 1408 | ++deletedEventL; |
1401 | } else { | 1409 | } else { |
1402 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1410 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1403 | inL->removeID(mCurrentSyncDevice ); | 1411 | inL->removeID(mCurrentSyncDevice ); |
1404 | ++addedEventR; | 1412 | ++addedEventR; |
1405 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1413 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1406 | inL->setLastModified( modifiedCalendar ); | 1414 | inL->setLastModified( modifiedCalendar ); |
1407 | inR = inL->clone(); | 1415 | inR = inL->clone(); |
1408 | inR->setIDStr( ":" ); | 1416 | inR->setIDStr( ":" ); |
1409 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1417 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1410 | remote->addIncidence( inR ); | 1418 | remote->addIncidence( inR ); |
1411 | } | 1419 | } |
1412 | } | 1420 | } |
1413 | } else { | 1421 | } else { |
1414 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1422 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1415 | checkExternSyncEvent(eventLSyncSharp, inL); | 1423 | checkExternSyncEvent(eventLSyncSharp, inL); |
1416 | local->deleteIncidence( inL ); | 1424 | local->deleteIncidence( inL ); |
1417 | ++deletedEventL; | 1425 | ++deletedEventL; |
1418 | } else { | 1426 | } else { |
1419 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1427 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1420 | ++addedEventR; | 1428 | ++addedEventR; |
1421 | inL->setLastModified( modifiedCalendar ); | 1429 | inL->setLastModified( modifiedCalendar ); |
1422 | inR = inL->clone(); | 1430 | inR = inL->clone(); |
1423 | inR->setIDStr( ":" ); | 1431 | inR->setIDStr( ":" ); |
1424 | remote->addIncidence( inR ); | 1432 | remote->addIncidence( inR ); |
1425 | } | 1433 | } |
1426 | } | 1434 | } |
1427 | } | 1435 | } |
1428 | } else { | 1436 | } else { |
1429 | ++filteredOUT; | 1437 | ++filteredOUT; |
1430 | } | 1438 | } |
1431 | } | 1439 | } |
1432 | } | 1440 | } |
1433 | inL = el.next(); | 1441 | inL = el.next(); |
1434 | } | 1442 | } |
1435 | int delFut = 0; | 1443 | int delFut = 0; |
1436 | int remRem = 0; | 1444 | int remRem = 0; |
1437 | if ( mSyncManager->mWriteBackInFuture ) { | 1445 | if ( mSyncManager->mWriteBackInFuture ) { |
1438 | er = remote->rawIncidences(); | 1446 | er = remote->rawIncidences(); |
1439 | remRem = er.count(); | 1447 | remRem = er.count(); |
1440 | inR = er.first(); | 1448 | inR = er.first(); |
1441 | QDateTime dt; | 1449 | QDateTime dt; |
1442 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1450 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1443 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1451 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1444 | while ( inR ) { | 1452 | while ( inR ) { |
1445 | if ( inR->typeID() == todoID ) { | 1453 | if ( inR->typeID() == todoID ) { |
1446 | Todo * t = (Todo*)inR; | 1454 | Todo * t = (Todo*)inR; |
1447 | if ( t->hasDueDate() ) | 1455 | if ( t->hasDueDate() ) |
1448 | dt = t->dtDue(); | 1456 | dt = t->dtDue(); |
1449 | else | 1457 | else |
1450 | dt = cur.addSecs( 62 ); | 1458 | dt = cur.addSecs( 62 ); |
1451 | } | 1459 | } |
1452 | else if (inR->typeID() == eventID ) { | 1460 | else if (inR->typeID() == eventID ) { |
1453 | bool ok; | 1461 | bool ok; |
1454 | dt = inR->getNextOccurence( cur, &ok ); | 1462 | dt = inR->getNextOccurence( cur, &ok ); |
1455 | if ( !ok ) | 1463 | if ( !ok ) |
1456 | dt = cur.addSecs( -62 ); | 1464 | dt = cur.addSecs( -62 ); |
1457 | } | 1465 | } |
1458 | else | 1466 | else |
1459 | dt = inR->dtStart(); | 1467 | dt = inR->dtStart(); |
1460 | if ( dt < cur || dt > end ) { | 1468 | if ( dt < cur || dt > end ) { |
1461 | remote->deleteIncidence( inR ); | 1469 | remote->deleteIncidence( inR ); |
1462 | ++delFut; | 1470 | ++delFut; |
1463 | } | 1471 | } |
1464 | inR = er.next(); | 1472 | inR = er.next(); |
1465 | } | 1473 | } |
1466 | } | 1474 | } |
1467 | bar.hide(); | 1475 | bar.hide(); |
1468 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1476 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1469 | eventLSync->setReadOnly( false ); | 1477 | eventLSync->setReadOnly( false ); |
1470 | eventLSync->setDtStart( mLastCalendarSync ); | 1478 | eventLSync->setDtStart( mLastCalendarSync ); |
1471 | eventRSync->setDtStart( mLastCalendarSync ); | 1479 | eventRSync->setDtStart( mLastCalendarSync ); |
1472 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1480 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1473 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1481 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1474 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1482 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1475 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1483 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1476 | eventLSync->setReadOnly( true ); | 1484 | eventLSync->setReadOnly( true ); |
1477 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1485 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1478 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1486 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1479 | remote->addEvent( eventRSync ); | 1487 | remote->addEvent( eventRSync ); |
1480 | else | 1488 | else |
1481 | delete eventRSync; | 1489 | delete eventRSync; |
1482 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1490 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1483 | QString mes; | 1491 | QString mes; |
1484 | 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 ); | 1492 | 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 ); |
1485 | QString delmess; | 1493 | QString delmess; |
1486 | if ( delFut ) { | 1494 | if ( delFut ) { |
1487 | 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); | 1495 | 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); |
1488 | mes += delmess; | 1496 | mes += delmess; |
1489 | } | 1497 | } |
1490 | mes = i18n("Local calendar changed!\n") +mes; | 1498 | mes = i18n("Local calendar changed!\n") +mes; |
1491 | mCalendar->checkAlarmForIncidence( 0, true ); | 1499 | mCalendar->checkAlarmForIncidence( 0, true ); |
1492 | qDebug( mes ); | 1500 | qDebug( mes ); |
1493 | if ( mSyncManager->mShowSyncSummary ) { | 1501 | if ( mSyncManager->mShowSyncSummary ) { |
1494 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1502 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1495 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1503 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1496 | qDebug("KO: WB cancelled "); | 1504 | qDebug("KO: WB cancelled "); |
1497 | mSyncManager->mWriteBackFile = false; | 1505 | mSyncManager->mWriteBackFile = false; |
1498 | return syncOK; | 1506 | return syncOK; |
1499 | } | 1507 | } |
1500 | } | 1508 | } |
1501 | return syncOK; | 1509 | return syncOK; |
1502 | } | 1510 | } |
1503 | 1511 | ||
1504 | void CalendarView::setSyncDevice( QString s ) | 1512 | void CalendarView::setSyncDevice( QString s ) |
1505 | { | 1513 | { |
1506 | mCurrentSyncDevice= s; | 1514 | mCurrentSyncDevice= s; |
1507 | } | 1515 | } |
1508 | void CalendarView::setSyncName( QString s ) | 1516 | void CalendarView::setSyncName( QString s ) |
1509 | { | 1517 | { |
1510 | mCurrentSyncName= s; | 1518 | mCurrentSyncName= s; |
1511 | } | 1519 | } |
1512 | bool CalendarView::syncCalendar(QString filename, int mode) | 1520 | bool CalendarView::syncCalendar(QString filename, int mode) |
1513 | { | 1521 | { |
1514 | //qDebug("syncCalendar %s ", filename.latin1()); | 1522 | //qDebug("syncCalendar %s ", filename.latin1()); |
1515 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1523 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1516 | CalendarLocal* calendar = new CalendarLocal(); | 1524 | CalendarLocal* calendar = new CalendarLocal(); |
1517 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1525 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1518 | FileStorage* storage = new FileStorage( calendar ); | 1526 | FileStorage* storage = new FileStorage( calendar ); |
1519 | bool syncOK = false; | 1527 | bool syncOK = false; |
1520 | storage->setFileName( filename ); | 1528 | storage->setFileName( filename ); |
1521 | // qDebug("loading ... "); | 1529 | // qDebug("loading ... "); |
1522 | if ( storage->load() ) { | 1530 | if ( storage->load() ) { |
1523 | getEventViewerDialog()->setSyncMode( true ); | 1531 | getEventViewerDialog()->setSyncMode( true ); |
1524 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1532 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1525 | getEventViewerDialog()->setSyncMode( false ); | 1533 | getEventViewerDialog()->setSyncMode( false ); |
1526 | if ( syncOK ) { | 1534 | if ( syncOK ) { |
1527 | if ( mSyncManager->mWriteBackFile ) | 1535 | if ( mSyncManager->mWriteBackFile ) |
1528 | { | 1536 | { |
1529 | storage->setSaveFormat( new ICalFormat() ); | 1537 | storage->setSaveFormat( new ICalFormat() ); |
1530 | storage->save(); | 1538 | storage->save(); |
1531 | } | 1539 | } |
1532 | } | 1540 | } |
1533 | setModified( true ); | 1541 | setModified( true ); |
1534 | } | 1542 | } |
1535 | delete storage; | 1543 | delete storage; |
1536 | delete calendar; | 1544 | delete calendar; |
1537 | if ( syncOK ) | 1545 | if ( syncOK ) |
1538 | updateView(); | 1546 | updateView(); |
1539 | return syncOK; | 1547 | return syncOK; |
1540 | } | 1548 | } |
1541 | 1549 | ||
1542 | void CalendarView::syncExternal( int mode ) | 1550 | void CalendarView::syncExternal( int mode ) |
1543 | { | 1551 | { |
1544 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1552 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1545 | 1553 | ||
1546 | qApp->processEvents(); | 1554 | qApp->processEvents(); |
1547 | CalendarLocal* calendar = new CalendarLocal(); | 1555 | CalendarLocal* calendar = new CalendarLocal(); |
1548 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1556 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1549 | bool syncOK = false; | 1557 | bool syncOK = false; |
1550 | bool loadSuccess = false; | 1558 | bool loadSuccess = false; |
1551 | PhoneFormat* phoneFormat = 0; | 1559 | PhoneFormat* phoneFormat = 0; |
1552 | emit tempDisableBR(true); | 1560 | emit tempDisableBR(true); |
1553 | #ifndef DESKTOP_VERSION | 1561 | #ifndef DESKTOP_VERSION |
1554 | SharpFormat* sharpFormat = 0; | 1562 | SharpFormat* sharpFormat = 0; |
1555 | if ( mode == 0 ) { // sharp | 1563 | if ( mode == 0 ) { // sharp |
1556 | sharpFormat = new SharpFormat () ; | 1564 | sharpFormat = new SharpFormat () ; |
1557 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1565 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1558 | 1566 | ||
1559 | } else | 1567 | } else |
1560 | #endif | 1568 | #endif |
1561 | if ( mode == 1 ) { // phone | 1569 | if ( mode == 1 ) { // phone |
1562 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1570 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1563 | mSyncManager->mPhoneDevice, | 1571 | mSyncManager->mPhoneDevice, |
1564 | mSyncManager->mPhoneConnection, | 1572 | mSyncManager->mPhoneConnection, |
1565 | mSyncManager->mPhoneModel); | 1573 | mSyncManager->mPhoneModel); |
1566 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1574 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1567 | 1575 | ||
1568 | } else { | 1576 | } else { |
1569 | emit tempDisableBR(false); | 1577 | emit tempDisableBR(false); |
1570 | return; | 1578 | return; |
1571 | } | 1579 | } |
1572 | if ( loadSuccess ) { | 1580 | if ( loadSuccess ) { |
1573 | getEventViewerDialog()->setSyncMode( true ); | 1581 | getEventViewerDialog()->setSyncMode( true ); |
1574 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1582 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1575 | getEventViewerDialog()->setSyncMode( false ); | 1583 | getEventViewerDialog()->setSyncMode( false ); |
1576 | qApp->processEvents(); | 1584 | qApp->processEvents(); |
1577 | if ( syncOK ) { | 1585 | if ( syncOK ) { |
1578 | if ( mSyncManager->mWriteBackFile ) | 1586 | if ( mSyncManager->mWriteBackFile ) |
1579 | { | 1587 | { |
1580 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1588 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1581 | Incidence* inc = iL.first(); | 1589 | Incidence* inc = iL.first(); |
1582 | if ( phoneFormat ) { | 1590 | if ( phoneFormat ) { |
1583 | while ( inc ) { | 1591 | while ( inc ) { |
1584 | inc->removeID(mCurrentSyncDevice); | 1592 | inc->removeID(mCurrentSyncDevice); |
1585 | inc = iL.next(); | 1593 | inc = iL.next(); |
1586 | } | 1594 | } |
1587 | } | 1595 | } |
1588 | #ifndef DESKTOP_VERSION | 1596 | #ifndef DESKTOP_VERSION |
1589 | if ( sharpFormat ) | 1597 | if ( sharpFormat ) |
1590 | sharpFormat->save(calendar); | 1598 | sharpFormat->save(calendar); |
1591 | #endif | 1599 | #endif |
1592 | if ( phoneFormat ) | 1600 | if ( phoneFormat ) |
1593 | phoneFormat->save(calendar); | 1601 | phoneFormat->save(calendar); |
1594 | iL = calendar->rawIncidences(); | 1602 | iL = calendar->rawIncidences(); |
1595 | inc = iL.first(); | 1603 | inc = iL.first(); |
1596 | Incidence* loc; | 1604 | Incidence* loc; |
1597 | while ( inc ) { | 1605 | while ( inc ) { |
1598 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1606 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1599 | loc = mCalendar->incidence(inc->uid() ); | 1607 | loc = mCalendar->incidence(inc->uid() ); |
1600 | if ( loc ) { | 1608 | if ( loc ) { |
1601 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1609 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1602 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1610 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1603 | } | 1611 | } |
1604 | } | 1612 | } |
1605 | inc = iL.next(); | 1613 | inc = iL.next(); |
1606 | } | 1614 | } |
1607 | Incidence* lse = getLastSyncEvent(); | 1615 | Incidence* lse = getLastSyncEvent(); |
1608 | if ( lse ) { | 1616 | if ( lse ) { |
1609 | lse->setReadOnly( false ); | 1617 | lse->setReadOnly( false ); |
1610 | lse->setDescription( "" ); | 1618 | lse->setDescription( "" ); |
1611 | lse->setReadOnly( true ); | 1619 | lse->setReadOnly( true ); |
1612 | } | 1620 | } |
1613 | } | 1621 | } |
1614 | } else { | 1622 | } else { |
1615 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1623 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1616 | } | 1624 | } |
1617 | setModified( true ); | 1625 | setModified( true ); |
1618 | } else { | 1626 | } else { |
1619 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1627 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1620 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1628 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1621 | question, i18n("Ok")) ; | 1629 | question, i18n("Ok")) ; |
1622 | 1630 | ||
1623 | } | 1631 | } |
1624 | delete calendar; | 1632 | delete calendar; |
1625 | updateView(); | 1633 | updateView(); |
1626 | emit tempDisableBR(false); | 1634 | emit tempDisableBR(false); |
1627 | return ;//syncOK; | 1635 | return ;//syncOK; |
1628 | 1636 | ||
1629 | } | 1637 | } |
1630 | 1638 | ||
1631 | bool CalendarView::importBday() | 1639 | bool CalendarView::importBday() |
1632 | { | 1640 | { |
1633 | #ifndef KORG_NOKABC | 1641 | #ifndef KORG_NOKABC |
1634 | 1642 | ||
1635 | #ifdef DESKTOP_VERSION | 1643 | #ifdef DESKTOP_VERSION |
1636 | int curCal = mCalendar->defaultCalendar(); | 1644 | int curCal = mCalendar->defaultCalendar(); |
1637 | int bd = mCalEditView->getBirtdayID(); | 1645 | int bd = mCalEditView->getBirtdayID(); |
1638 | if ( bd == 0 ) | 1646 | if ( bd == 0 ) |
1639 | return false; | 1647 | return false; |
1640 | mCalendar->setDefaultCalendar( bd ); | 1648 | mCalendar->setDefaultCalendar( bd ); |
1641 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1649 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1642 | KABC::AddressBook::Iterator it; | 1650 | KABC::AddressBook::Iterator it; |
1643 | int count = 0; | 1651 | int count = 0; |
1644 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1652 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1645 | ++count; | 1653 | ++count; |
1646 | } | 1654 | } |
1647 | QProgressBar bar(count,0 ); | 1655 | QProgressBar bar(count,0 ); |
1648 | int w = 300; | 1656 | int w = 300; |
1649 | if ( QApplication::desktop()->width() < 320 ) | 1657 | if ( QApplication::desktop()->width() < 320 ) |
1650 | w = 220; | 1658 | w = 220; |
1651 | int h = bar.sizeHint().height() ; | 1659 | int h = bar.sizeHint().height() ; |
1652 | int dw = QApplication::desktop()->width(); | 1660 | int dw = QApplication::desktop()->width(); |
1653 | int dh = QApplication::desktop()->height(); | 1661 | int dh = QApplication::desktop()->height(); |
1654 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1662 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1655 | bar.show(); | 1663 | bar.show(); |
1656 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1664 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1657 | qApp->processEvents(); | 1665 | qApp->processEvents(); |
1658 | count = 0; | 1666 | count = 0; |
1659 | int addCount = 0; | 1667 | int addCount = 0; |
1660 | KCal::Attendee* a = 0; | 1668 | KCal::Attendee* a = 0; |
1661 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1669 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1662 | if ( ! bar.isVisible() ) | 1670 | if ( ! bar.isVisible() ) |
1663 | return false; | 1671 | return false; |
1664 | bar.setProgress( count++ ); | 1672 | bar.setProgress( count++ ); |
1665 | qApp->processEvents(); | 1673 | qApp->processEvents(); |
1666 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1674 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1667 | if ( (*it).birthday().date().isValid() ){ | 1675 | if ( (*it).birthday().date().isValid() ){ |
1668 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1676 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1669 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1677 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1670 | ++addCount; | 1678 | ++addCount; |
1671 | } | 1679 | } |
1672 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1680 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1673 | if ( anni.isValid() ){ | 1681 | if ( anni.isValid() ){ |
1674 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1682 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1675 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1683 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1676 | ++addCount; | 1684 | ++addCount; |
1677 | } | 1685 | } |
1678 | } | 1686 | } |
1679 | mCalendar->setDefaultCalendar( curCal ); | 1687 | mCalendar->setDefaultCalendar( curCal ); |
1680 | updateView(); | 1688 | updateView(); |
1681 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1689 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1682 | #else //DESKTOP_VERSION | 1690 | #else //DESKTOP_VERSION |
1683 | 1691 | ||
1684 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1692 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1685 | // the result should now arrive through method insertBirthdays | 1693 | // the result should now arrive through method insertBirthdays |
1686 | 1694 | ||
1687 | #endif //DESKTOP_VERSION | 1695 | #endif //DESKTOP_VERSION |
1688 | 1696 | ||
1689 | #endif //KORG_NOKABC | 1697 | #endif //KORG_NOKABC |
1690 | 1698 | ||
1691 | 1699 | ||
1692 | return true; | 1700 | return true; |
1693 | } | 1701 | } |
1694 | 1702 | ||
1695 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1703 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1696 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1704 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1697 | const QStringList& anniversaryList, const QStringList& realNameList, | 1705 | const QStringList& anniversaryList, const QStringList& realNameList, |
1698 | const QStringList& emailList, const QStringList& assembledNameList, | 1706 | const QStringList& emailList, const QStringList& assembledNameList, |
1699 | const QStringList& uidList) | 1707 | const QStringList& uidList) |
1700 | { | 1708 | { |
1701 | 1709 | ||
1702 | //qDebug("KO::CalendarView::insertBirthdays"); | 1710 | //qDebug("KO::CalendarView::insertBirthdays"); |
1703 | if (uid == this->name()) | 1711 | if (uid == this->name()) |
1704 | { | 1712 | { |
1705 | int curCal = mCalendar->defaultCalendar(); | 1713 | int curCal = mCalendar->defaultCalendar(); |
1706 | int bd = mCalEditView->getBirtdayID(); | 1714 | int bd = mCalEditView->getBirtdayID(); |
1707 | if ( bd == 0 ) | 1715 | if ( bd == 0 ) |
1708 | return; | 1716 | return; |
1709 | mCalendar->setDefaultCalendar( bd ); | 1717 | mCalendar->setDefaultCalendar( bd ); |
1710 | 1718 | ||
1711 | 1719 | ||
1712 | int count = birthdayList.count(); | 1720 | int count = birthdayList.count(); |
1713 | int addCount = 0; | 1721 | int addCount = 0; |
1714 | KCal::Attendee* a = 0; | 1722 | KCal::Attendee* a = 0; |
1715 | 1723 | ||
1716 | //qDebug("CalView 1 %i", count); | 1724 | //qDebug("CalView 1 %i", count); |
1717 | 1725 | ||
1718 | QProgressBar bar(count,0 ); | 1726 | QProgressBar bar(count,0 ); |
1719 | int w = 300; | 1727 | int w = 300; |
1720 | if ( QApplication::desktop()->width() < 320 ) | 1728 | if ( QApplication::desktop()->width() < 320 ) |
1721 | w = 220; | 1729 | w = 220; |
1722 | int h = bar.sizeHint().height() ; | 1730 | int h = bar.sizeHint().height() ; |
1723 | int dw = QApplication::desktop()->width(); | 1731 | int dw = QApplication::desktop()->width(); |
1724 | int dh = QApplication::desktop()->height(); | 1732 | int dh = QApplication::desktop()->height(); |
1725 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1733 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1726 | bar.show(); | 1734 | bar.show(); |
1727 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1735 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1728 | qApp->processEvents(); | 1736 | qApp->processEvents(); |
1729 | 1737 | ||
1730 | QDate birthday; | 1738 | QDate birthday; |
1731 | QDate anniversary; | 1739 | QDate anniversary; |
1732 | QString realName; | 1740 | QString realName; |
1733 | QString email; | 1741 | QString email; |
1734 | QString assembledName; | 1742 | QString assembledName; |
1735 | QString uid; | 1743 | QString uid; |
1736 | bool ok = true; | 1744 | bool ok = true; |
1737 | for ( int i = 0; i < count; i++) | 1745 | for ( int i = 0; i < count; i++) |
1738 | { | 1746 | { |
1739 | if ( ! bar.isVisible() ) | 1747 | if ( ! bar.isVisible() ) |
1740 | return; | 1748 | return; |
1741 | bar.setProgress( i ); | 1749 | bar.setProgress( i ); |
1742 | qApp->processEvents(); | 1750 | qApp->processEvents(); |
1743 | 1751 | ||
1744 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1752 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1745 | if (!ok) { | 1753 | if (!ok) { |
1746 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1754 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1747 | } | 1755 | } |
1748 | 1756 | ||
1749 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1757 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1750 | if (!ok) { | 1758 | if (!ok) { |
1751 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1759 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1752 | } | 1760 | } |
1753 | realName = realNameList[i]; | 1761 | realName = realNameList[i]; |
1754 | email = emailList[i]; | 1762 | email = emailList[i]; |
1755 | assembledName = assembledNameList[i]; | 1763 | assembledName = assembledNameList[i]; |
1756 | uid = uidList[i]; | 1764 | uid = uidList[i]; |
1757 | //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() ); | 1765 | //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() ); |
1758 | 1766 | ||
1759 | if ( birthday.isValid() ){ | 1767 | if ( birthday.isValid() ){ |
1760 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1768 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1761 | KCal::Attendee::ReqParticipant,uid) ; | 1769 | KCal::Attendee::ReqParticipant,uid) ; |
1762 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1770 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1763 | ++addCount; | 1771 | ++addCount; |
1764 | } | 1772 | } |
1765 | 1773 | ||
1766 | if ( anniversary.isValid() ){ | 1774 | if ( anniversary.isValid() ){ |
1767 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1775 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1768 | KCal::Attendee::ReqParticipant,uid) ; | 1776 | KCal::Attendee::ReqParticipant,uid) ; |
1769 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1777 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1770 | ++addCount; | 1778 | ++addCount; |
1771 | } | 1779 | } |
1772 | } | 1780 | } |
1773 | 1781 | ||
1774 | mCalendar->setDefaultCalendar( curCal ); | 1782 | mCalendar->setDefaultCalendar( curCal ); |
1775 | updateView(); | 1783 | updateView(); |
1776 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1784 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1777 | 1785 | ||
1778 | } | 1786 | } |
1779 | 1787 | ||
1780 | } | 1788 | } |
1781 | 1789 | ||
1782 | 1790 | ||
1783 | 1791 | ||
1784 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1792 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1785 | { | 1793 | { |
1786 | //qDebug("addAnni "); | 1794 | //qDebug("addAnni "); |
1787 | Event * ev = new Event(); | 1795 | Event * ev = new Event(); |
1788 | ev->setOrganizer(KOPrefs::instance()->email()); | 1796 | ev->setOrganizer(KOPrefs::instance()->email()); |
1789 | if ( a ) { | 1797 | if ( a ) { |
1790 | ev->addAttendee( a ); | 1798 | ev->addAttendee( a ); |
1791 | } | 1799 | } |
1792 | QString kind; | 1800 | QString kind; |
1793 | if ( birthday ) { | 1801 | if ( birthday ) { |
1794 | kind = i18n( "Birthday" ); | 1802 | kind = i18n( "Birthday" ); |
1795 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1803 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1796 | } | 1804 | } |
1797 | else { | 1805 | else { |
1798 | kind = i18n( "Anniversary" ); | 1806 | kind = i18n( "Anniversary" ); |
1799 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1807 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1800 | } | 1808 | } |
1801 | ev->setCategories( kind ); | 1809 | ev->setCategories( kind ); |
1802 | ev->setDtStart( QDateTime(date) ); | 1810 | ev->setDtStart( QDateTime(date) ); |
1803 | ev->setDtEnd( QDateTime(date) ); | 1811 | ev->setDtEnd( QDateTime(date) ); |
1804 | ev->setFloats( true ); | 1812 | ev->setFloats( true ); |
1805 | Recurrence * rec = ev->recurrence(); | 1813 | Recurrence * rec = ev->recurrence(); |
1806 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1814 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1807 | rec->addYearlyNum( date.month() ); | 1815 | rec->addYearlyNum( date.month() ); |
1808 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1816 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1809 | delete ev; | 1817 | delete ev; |
1810 | return false; | 1818 | return false; |
1811 | } | 1819 | } |
1812 | return true; | 1820 | return true; |
1813 | 1821 | ||
1814 | } | 1822 | } |
1815 | bool CalendarView::importQtopia( const QString &categories, | 1823 | bool CalendarView::importQtopia( const QString &categories, |
1816 | const QString &datebook, | 1824 | const QString &datebook, |
1817 | const QString &todolist ) | 1825 | const QString &todolist ) |
1818 | { | 1826 | { |
1819 | 1827 | ||
1820 | QtopiaFormat qtopiaFormat; | 1828 | QtopiaFormat qtopiaFormat; |
1821 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1829 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1822 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1830 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1823 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1831 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1824 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1832 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1825 | 1833 | ||
1826 | updateView(); | 1834 | updateView(); |
1827 | return true; | 1835 | return true; |
1828 | 1836 | ||
1829 | #if 0 | 1837 | #if 0 |
1830 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1838 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1831 | mCurrentSyncDevice = "qtopia-XML"; | 1839 | mCurrentSyncDevice = "qtopia-XML"; |
1832 | if ( mSyncManager->mAskForPreferences ) | 1840 | if ( mSyncManager->mAskForPreferences ) |
1833 | edit_sync_options(); | 1841 | edit_sync_options(); |
1834 | qApp->processEvents(); | 1842 | qApp->processEvents(); |
1835 | CalendarLocal* calendar = new CalendarLocal(); | 1843 | CalendarLocal* calendar = new CalendarLocal(); |
1836 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1844 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1837 | bool syncOK = false; | 1845 | bool syncOK = false; |
1838 | QtopiaFormat qtopiaFormat; | 1846 | QtopiaFormat qtopiaFormat; |
1839 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1847 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1840 | bool loadOk = true; | 1848 | bool loadOk = true; |
1841 | if ( !categories.isEmpty() ) | 1849 | if ( !categories.isEmpty() ) |
1842 | loadOk = qtopiaFormat.load( calendar, categories ); | 1850 | loadOk = qtopiaFormat.load( calendar, categories ); |
1843 | if ( loadOk && !datebook.isEmpty() ) | 1851 | if ( loadOk && !datebook.isEmpty() ) |
1844 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1852 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1845 | if ( loadOk && !todolist.isEmpty() ) | 1853 | if ( loadOk && !todolist.isEmpty() ) |
1846 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1854 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1847 | 1855 | ||
1848 | if ( loadOk ) { | 1856 | if ( loadOk ) { |
1849 | getEventViewerDialog()->setSyncMode( true ); | 1857 | getEventViewerDialog()->setSyncMode( true ); |
1850 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1858 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1851 | getEventViewerDialog()->setSyncMode( false ); | 1859 | getEventViewerDialog()->setSyncMode( false ); |
1852 | qApp->processEvents(); | 1860 | qApp->processEvents(); |
1853 | if ( syncOK ) { | 1861 | if ( syncOK ) { |
1854 | if ( mSyncManager->mWriteBackFile ) | 1862 | if ( mSyncManager->mWriteBackFile ) |
1855 | { | 1863 | { |
1856 | // write back XML file | 1864 | // write back XML file |
1857 | 1865 | ||
1858 | } | 1866 | } |
1859 | setModified( true ); | 1867 | setModified( true ); |
1860 | } | 1868 | } |
1861 | } else { | 1869 | } else { |
1862 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1870 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1863 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1871 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1864 | question, i18n("Ok")) ; | 1872 | question, i18n("Ok")) ; |
1865 | } | 1873 | } |
1866 | delete calendar; | 1874 | delete calendar; |
1867 | updateView(); | 1875 | updateView(); |
1868 | return syncOK; | 1876 | return syncOK; |
1869 | 1877 | ||
1870 | 1878 | ||
1871 | #endif | 1879 | #endif |
1872 | 1880 | ||
1873 | } | 1881 | } |
1874 | 1882 | ||
1875 | void CalendarView::setSyncEventsReadOnly() | 1883 | void CalendarView::setSyncEventsReadOnly() |
1876 | { | 1884 | { |
1877 | mCalendar->setSyncEventsReadOnly(); | 1885 | mCalendar->setSyncEventsReadOnly(); |
1878 | } | 1886 | } |
1879 | 1887 | ||
1880 | bool CalendarView::loadCalendars() | 1888 | bool CalendarView::loadCalendars() |
1881 | { | 1889 | { |
1882 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1890 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1883 | KopiCalendarFile * cal = calendars.first(); | 1891 | KopiCalendarFile * cal = calendars.first(); |
1884 | mCalendar->setDefaultCalendar( 1 ); | 1892 | mCalendar->setDefaultCalendar( 1 ); |
1885 | openCalendar( MainWindow::defaultFileName(), false ); | 1893 | openCalendar( MainWindow::defaultFileName(), false ); |
1886 | cal = calendars.next(); | 1894 | cal = calendars.next(); |
1887 | while ( cal ) { | 1895 | while ( cal ) { |
1888 | addCalendar( cal ); | 1896 | addCalendar( cal ); |
1889 | cal = calendars.next(); | 1897 | cal = calendars.next(); |
1890 | } | 1898 | } |
1891 | restoreCalendarSettings(); | 1899 | restoreCalendarSettings(); |
1892 | return true; | 1900 | return true; |
1893 | } | 1901 | } |
1894 | bool CalendarView::restoreCalendarSettings() | 1902 | bool CalendarView::restoreCalendarSettings() |
1895 | { | 1903 | { |
1896 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1904 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1897 | KopiCalendarFile * cal = calendars.first(); | 1905 | KopiCalendarFile * cal = calendars.first(); |
1898 | while ( cal ) { | 1906 | while ( cal ) { |
1899 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 1907 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
1900 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 1908 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
1901 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 1909 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
1902 | if ( cal->isStandard ) | 1910 | if ( cal->isStandard ) |
1903 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 1911 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
1904 | cal = calendars.next(); | 1912 | cal = calendars.next(); |
1905 | } | 1913 | } |
1906 | setSyncEventsReadOnly(); | 1914 | setSyncEventsReadOnly(); |
1907 | mCalendar->reInitAlarmSettings(); | 1915 | mCalendar->reInitAlarmSettings(); |
1908 | updateUnmanagedViews(); | 1916 | updateUnmanagedViews(); |
1909 | updateView(); | 1917 | updateView(); |
1910 | return true; | 1918 | return true; |
1911 | } | 1919 | } |
1912 | void CalendarView::addCalendarId( int id ) | 1920 | void CalendarView::addCalendarId( int id ) |
1913 | { | 1921 | { |
1914 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 1922 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
1915 | addCalendar( cal ); | 1923 | addCalendar( cal ); |
1916 | } | 1924 | } |
1917 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 1925 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
1918 | { | 1926 | { |
1919 | cal->mErrorOnLoad = false; | 1927 | cal->mErrorOnLoad = false; |
1920 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 1928 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
1921 | cal->mLoadDt = QDateTime::currentDateTime(); | 1929 | cal->mLoadDt = QDateTime::currentDateTime(); |
1922 | return true; | 1930 | return true; |
1923 | } | 1931 | } |
1924 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); | 1932 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); |
1925 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); | 1933 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); |
1926 | cal->mErrorOnLoad = true; | 1934 | cal->mErrorOnLoad = true; |
1927 | return false; | 1935 | return false; |
1928 | } | 1936 | } |
1929 | bool CalendarView::openCalendar(QString filename, bool merge) | 1937 | bool CalendarView::openCalendar(QString filename, bool merge) |
1930 | { | 1938 | { |
1931 | 1939 | ||
1932 | if (filename.isEmpty()) { | 1940 | if (filename.isEmpty()) { |
1933 | return false; | 1941 | return false; |
1934 | } | 1942 | } |
1935 | 1943 | ||
1936 | if (!QFile::exists(filename)) { | 1944 | if (!QFile::exists(filename)) { |
1937 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1945 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1938 | return false; | 1946 | return false; |
1939 | } | 1947 | } |
1940 | 1948 | ||
1941 | globalFlagBlockAgenda = 1; | 1949 | globalFlagBlockAgenda = 1; |
1942 | clearAllViews(); | 1950 | clearAllViews(); |
1943 | if (!merge) { | 1951 | if (!merge) { |
1944 | mViewManager->setDocumentId( filename ); | 1952 | mViewManager->setDocumentId( filename ); |
1945 | mCalendar->close(); | 1953 | mCalendar->close(); |
1946 | } | 1954 | } |
1947 | mStorage->setFileName( filename ); | 1955 | mStorage->setFileName( filename ); |
1948 | 1956 | ||
1949 | if ( mStorage->load() ) { | 1957 | if ( mStorage->load() ) { |
1950 | if ( merge ) ;//setModified( true ); | 1958 | if ( merge ) ;//setModified( true ); |
1951 | else { | 1959 | else { |
1952 | //setModified( true ); | 1960 | //setModified( true ); |
1953 | mViewManager->setDocumentId( filename ); | 1961 | mViewManager->setDocumentId( filename ); |
1954 | mDialogManager->setDocumentId( filename ); | 1962 | mDialogManager->setDocumentId( filename ); |
1955 | mTodoList->setDocumentId( filename ); | 1963 | mTodoList->setDocumentId( filename ); |
1956 | } | 1964 | } |
1957 | globalFlagBlockAgenda = 2; | 1965 | globalFlagBlockAgenda = 2; |
1958 | // if ( getLastSyncEvent() ) | 1966 | // if ( getLastSyncEvent() ) |
1959 | // getLastSyncEvent()->setReadOnly( true ); | 1967 | // getLastSyncEvent()->setReadOnly( true ); |
1960 | mCalendar->reInitAlarmSettings(); | 1968 | mCalendar->reInitAlarmSettings(); |
1961 | setSyncEventsReadOnly(); | 1969 | setSyncEventsReadOnly(); |
1962 | updateUnmanagedViews(); | 1970 | updateUnmanagedViews(); |
1963 | updateView(); | 1971 | updateView(); |
1964 | if ( filename != MainWindow::defaultFileName() ) { | 1972 | if ( filename != MainWindow::defaultFileName() ) { |
1965 | saveCalendar( MainWindow::defaultFileName() ); | 1973 | saveCalendar( MainWindow::defaultFileName() ); |
1966 | } else { | 1974 | } else { |
1967 | QFileInfo finf ( MainWindow::defaultFileName()); | 1975 | QFileInfo finf ( MainWindow::defaultFileName()); |
1968 | if ( finf.exists() ) { | 1976 | if ( finf.exists() ) { |
1969 | setLoadedFileVersion( finf.lastModified () ); | 1977 | setLoadedFileVersion( finf.lastModified () ); |
1970 | } | 1978 | } |
1971 | } | 1979 | } |
1972 | return true; | 1980 | return true; |
1973 | } else { | 1981 | } else { |
1974 | // while failing to load, the calendar object could | 1982 | // while failing to load, the calendar object could |
1975 | // have become partially populated. Clear it out. | 1983 | // have become partially populated. Clear it out. |
1976 | if ( !merge ) { | 1984 | if ( !merge ) { |
1977 | mCalendar->close(); | 1985 | mCalendar->close(); |
1978 | mViewManager->setDocumentId( filename ); | 1986 | mViewManager->setDocumentId( filename ); |
1979 | mDialogManager->setDocumentId( filename ); | 1987 | mDialogManager->setDocumentId( filename ); |
1980 | mTodoList->setDocumentId( filename ); | 1988 | mTodoList->setDocumentId( filename ); |
1981 | } | 1989 | } |
1982 | 1990 | ||
1983 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1991 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1984 | 1992 | ||
1985 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1993 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1986 | globalFlagBlockAgenda = 2; | 1994 | globalFlagBlockAgenda = 2; |
1987 | mCalendar->reInitAlarmSettings(); | 1995 | mCalendar->reInitAlarmSettings(); |
1988 | setSyncEventsReadOnly(); | 1996 | setSyncEventsReadOnly(); |
1989 | updateUnmanagedViews(); | 1997 | updateUnmanagedViews(); |
1990 | updateView(); | 1998 | updateView(); |
1991 | } | 1999 | } |
1992 | return false; | 2000 | return false; |
1993 | } | 2001 | } |
1994 | void CalendarView::showOpenError() | 2002 | void CalendarView::showOpenError() |
1995 | { | 2003 | { |
1996 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2004 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1997 | } | 2005 | } |
1998 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2006 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1999 | { | 2007 | { |
2000 | loadedFileVersion = dt; | 2008 | loadedFileVersion = dt; |
2001 | } | 2009 | } |
2002 | bool CalendarView::checkFileChanged(QString fn) | 2010 | bool CalendarView::checkFileChanged(QString fn) |
2003 | { | 2011 | { |
2004 | QFileInfo finf ( fn ); | 2012 | QFileInfo finf ( fn ); |
2005 | if ( !finf.exists() ) | 2013 | if ( !finf.exists() ) |
2006 | return true; | 2014 | return true; |
2007 | QDateTime dt = finf.lastModified (); | 2015 | QDateTime dt = finf.lastModified (); |
2008 | if ( dt <= loadedFileVersion ) | 2016 | if ( dt <= loadedFileVersion ) |
2009 | return false; | 2017 | return false; |
2010 | return true; | 2018 | return true; |
2011 | 2019 | ||
2012 | } | 2020 | } |
2013 | void CalendarView::watchSavedFile() | 2021 | void CalendarView::watchSavedFile() |
2014 | { | 2022 | { |
2015 | QFileInfo finf ( MainWindow::defaultFileName()); | 2023 | QFileInfo finf ( MainWindow::defaultFileName()); |
2016 | if ( !finf.exists() ) | 2024 | if ( !finf.exists() ) |
2017 | return; | 2025 | return; |
2018 | QDateTime dt = finf.lastModified (); | 2026 | QDateTime dt = finf.lastModified (); |
2019 | if ( dt < loadedFileVersion ) { | 2027 | if ( dt < loadedFileVersion ) { |
2020 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2028 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2021 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2029 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2022 | return; | 2030 | return; |
2023 | } | 2031 | } |
2024 | loadedFileVersion = dt; | 2032 | loadedFileVersion = dt; |
2025 | } | 2033 | } |
2026 | bool CalendarView::checkAllFileVersions() | 2034 | bool CalendarView::checkAllFileVersions() |
2027 | { | 2035 | { |
2028 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2036 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2029 | KopiCalendarFile * cal = calendars.first(); | 2037 | KopiCalendarFile * cal = calendars.first(); |
2030 | mCalendar->setDefaultCalendar( 1 ); | 2038 | mCalendar->setDefaultCalendar( 1 ); |
2031 | mCalendar->setDefaultCalendarEnabledOnly(); | 2039 | mCalendar->setDefaultCalendarEnabledOnly(); |
2032 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2040 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2033 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2041 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2034 | restoreCalendarSettings(); | 2042 | restoreCalendarSettings(); |
2035 | return false; | 2043 | return false; |
2036 | } | 2044 | } |
2037 | } | 2045 | } |
2038 | cal = calendars.next(); | 2046 | cal = calendars.next(); |
2039 | QDateTime storeTemp = loadedFileVersion; | 2047 | QDateTime storeTemp = loadedFileVersion; |
2040 | while ( cal ) { | 2048 | while ( cal ) { |
2041 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2049 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2042 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2050 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2043 | mCalendar->setDefaultCalendarEnabledOnly(); | 2051 | mCalendar->setDefaultCalendarEnabledOnly(); |
2044 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2052 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2045 | if ( !checkFileVersion(cal->mFileName )) { | 2053 | if ( !checkFileVersion(cal->mFileName )) { |
2046 | loadedFileVersion = storeTemp; | 2054 | loadedFileVersion = storeTemp; |
2047 | restoreCalendarSettings(); | 2055 | restoreCalendarSettings(); |
2048 | return false; | 2056 | return false; |
2049 | } | 2057 | } |
2050 | } | 2058 | } |
2051 | cal = calendars.next(); | 2059 | cal = calendars.next(); |
2052 | } | 2060 | } |
2053 | loadedFileVersion = storeTemp; | 2061 | loadedFileVersion = storeTemp; |
2054 | return true; | 2062 | return true; |
2055 | } | 2063 | } |
2056 | bool CalendarView::checkFileVersion(QString fn) | 2064 | bool CalendarView::checkFileVersion(QString fn) |
2057 | { | 2065 | { |
2058 | QFileInfo finf ( fn ); | 2066 | QFileInfo finf ( fn ); |
2059 | if ( !finf.exists() ) | 2067 | if ( !finf.exists() ) |
2060 | return true; | 2068 | return true; |
2061 | QDateTime dt = finf.lastModified (); | 2069 | QDateTime dt = finf.lastModified (); |
2062 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2070 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2063 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2071 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2064 | if ( dt <= loadedFileVersion ) | 2072 | if ( dt <= loadedFileVersion ) |
2065 | return true; | 2073 | return true; |
2066 | 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)) , | 2074 | 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)) , |
2067 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2075 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2068 | i18n("Sync+save")); | 2076 | i18n("Sync+save")); |
2069 | 2077 | ||
2070 | if ( km == KMessageBox::Cancel ) | 2078 | if ( km == KMessageBox::Cancel ) |
2071 | return false; | 2079 | return false; |
2072 | if ( km == KMessageBox::Yes ) | 2080 | if ( km == KMessageBox::Yes ) |
2073 | return true; | 2081 | return true; |
2074 | 2082 | ||
2075 | setSyncDevice("deleteaftersync" ); | 2083 | setSyncDevice("deleteaftersync" ); |
2076 | mSyncManager->mAskForPreferences = true; | 2084 | mSyncManager->mAskForPreferences = true; |
2077 | mSyncManager->mSyncAlgoPrefs = 3; | 2085 | mSyncManager->mSyncAlgoPrefs = 3; |
2078 | mSyncManager->mWriteBackFile = false; | 2086 | mSyncManager->mWriteBackFile = false; |
2079 | mSyncManager->mWriteBackExistingOnly = false; | 2087 | mSyncManager->mWriteBackExistingOnly = false; |
2080 | mSyncManager->mShowSyncSummary = false; | 2088 | mSyncManager->mShowSyncSummary = false; |
2081 | syncCalendar( fn, 3 ); | 2089 | syncCalendar( fn, 3 ); |
2082 | Event * e = getLastSyncEvent(); | 2090 | Event * e = getLastSyncEvent(); |
2083 | if ( e ) | 2091 | if ( e ) |
2084 | mCalendar->deleteEvent( e ); | 2092 | mCalendar->deleteEvent( e ); |
2085 | return true; | 2093 | return true; |
2086 | } | 2094 | } |
2087 | bool CalendarView::saveCalendars() | 2095 | bool CalendarView::saveCalendars() |
2088 | { | 2096 | { |
2089 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2097 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2090 | KopiCalendarFile * cal = calendars.first(); | 2098 | KopiCalendarFile * cal = calendars.first(); |
2091 | mCalendar->setDefaultCalendar( 1 ); | 2099 | mCalendar->setDefaultCalendar( 1 ); |
2092 | mCalendar->setDefaultCalendarEnabledOnly(); | 2100 | mCalendar->setDefaultCalendarEnabledOnly(); |
2093 | saveCalendar( MainWindow::defaultFileName() ); | 2101 | saveCalendar( MainWindow::defaultFileName() ); |
2094 | cal = calendars.next(); | 2102 | cal = calendars.next(); |
2095 | while ( cal ) { | 2103 | while ( cal ) { |
2096 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2104 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2097 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2105 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2098 | mCalendar->setDefaultCalendarEnabledOnly(); | 2106 | mCalendar->setDefaultCalendarEnabledOnly(); |
2099 | if ( saveCalendar( cal->mFileName ) ) | 2107 | if ( saveCalendar( cal->mFileName ) ) |
2100 | cal->mLoadDt = QDateTime::currentDateTime(); | 2108 | cal->mLoadDt = QDateTime::currentDateTime(); |
2101 | } | 2109 | } |
2102 | cal = calendars.next(); | 2110 | cal = calendars.next(); |
2103 | } | 2111 | } |
2104 | restoreCalendarSettings(); | 2112 | restoreCalendarSettings(); |
2105 | return true; | 2113 | return true; |
2106 | } | 2114 | } |
2107 | bool CalendarView::saveCalendar( QString filename ) | 2115 | bool CalendarView::saveCalendar( QString filename ) |
2108 | { | 2116 | { |
2109 | 2117 | ||
2110 | // Store back all unsaved data into calendar object | 2118 | // Store back all unsaved data into calendar object |
2111 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2119 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2112 | if ( mViewManager->currentView() ) | 2120 | if ( mViewManager->currentView() ) |
2113 | mViewManager->currentView()->flushView(); | 2121 | mViewManager->currentView()->flushView(); |
2114 | 2122 | ||
2115 | 2123 | ||
2116 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2124 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2117 | mStorage->setSaveFormat( new ICalFormat() ); | 2125 | mStorage->setSaveFormat( new ICalFormat() ); |
2118 | mStorage->setFileName( filename ); | 2126 | mStorage->setFileName( filename ); |
2119 | bool success; | 2127 | bool success; |
2120 | success = mStorage->save(); | 2128 | success = mStorage->save(); |
2121 | if ( !success ) { | 2129 | if ( !success ) { |
2122 | return false; | 2130 | return false; |
2123 | } | 2131 | } |
2124 | if ( filename == MainWindow::defaultFileName() ) { | 2132 | if ( filename == MainWindow::defaultFileName() ) { |
2125 | setLoadedFileVersion( lfv ); | 2133 | setLoadedFileVersion( lfv ); |
2126 | watchSavedFile(); | 2134 | watchSavedFile(); |
2127 | } | 2135 | } |
2128 | return true; | 2136 | return true; |
2129 | } | 2137 | } |
2130 | 2138 | ||
2131 | void CalendarView::closeCalendar() | 2139 | void CalendarView::closeCalendar() |
2132 | { | 2140 | { |
2133 | 2141 | ||
2134 | // child windows no longer valid | 2142 | // child windows no longer valid |
2135 | clearAllViews(); | 2143 | clearAllViews(); |
2136 | emit closingDown(); | 2144 | emit closingDown(); |
2137 | 2145 | ||
2138 | mCalendar->close(); | 2146 | mCalendar->close(); |
2139 | setModified(false); | 2147 | setModified(false); |
2140 | updateView(); | 2148 | updateView(); |
2141 | } | 2149 | } |
2142 | 2150 | ||
2143 | void CalendarView::archiveCalendar() | 2151 | void CalendarView::archiveCalendar() |
2144 | { | 2152 | { |
2145 | mDialogManager->showArchiveDialog(); | 2153 | mDialogManager->showArchiveDialog(); |
2146 | } | 2154 | } |
2147 | 2155 | ||
2148 | 2156 | ||
2149 | void CalendarView::readSettings() | 2157 | void CalendarView::readSettings() |
2150 | { | 2158 | { |
2151 | 2159 | ||
2152 | 2160 | ||
2153 | // mViewManager->showAgendaView(); | 2161 | // mViewManager->showAgendaView(); |
2154 | QString str; | 2162 | QString str; |
2155 | //qDebug("CalendarView::readSettings() "); | 2163 | //qDebug("CalendarView::readSettings() "); |
2156 | // read settings from the KConfig, supplying reasonable | 2164 | // read settings from the KConfig, supplying reasonable |
2157 | // defaults where none are to be found | 2165 | // defaults where none are to be found |
2158 | KConfig *config = KOGlobals::config(); | 2166 | KConfig *config = KOGlobals::config(); |
2159 | #ifndef KORG_NOSPLITTER | 2167 | #ifndef KORG_NOSPLITTER |
2160 | config->setGroup("KOrganizer Geometry"); | 2168 | config->setGroup("KOrganizer Geometry"); |
2161 | 2169 | ||
2162 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2170 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2163 | if (sizes.count() != 2) { | 2171 | if (sizes.count() != 2) { |
2164 | sizes << mDateNavigator->minimumSizeHint().width(); | 2172 | sizes << mDateNavigator->minimumSizeHint().width(); |
2165 | sizes << 300; | 2173 | sizes << 300; |
2166 | } | 2174 | } |
2167 | mPanner->setSizes(sizes); | 2175 | mPanner->setSizes(sizes); |
2168 | 2176 | ||
2169 | sizes = config->readIntListEntry("Separator2"); | 2177 | sizes = config->readIntListEntry("Separator2"); |
2170 | if ( ( mResourceView && sizes.count() == 4 ) || | 2178 | if ( ( mResourceView && sizes.count() == 4 ) || |
2171 | ( !mResourceView && sizes.count() == 3 ) ) { | 2179 | ( !mResourceView && sizes.count() == 3 ) ) { |
2172 | mLeftSplitter->setSizes(sizes); | 2180 | mLeftSplitter->setSizes(sizes); |
2173 | } | 2181 | } |
2174 | #endif | 2182 | #endif |
2175 | globalFlagBlockAgenda = 1; | 2183 | globalFlagBlockAgenda = 1; |
2176 | mViewManager->showAgendaView(); | 2184 | mViewManager->showAgendaView(); |
2177 | //mViewManager->readSettings( config ); | 2185 | //mViewManager->readSettings( config ); |
2178 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2186 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2179 | readFilterSettings(config); | 2187 | readFilterSettings(config); |
2180 | 2188 | ||
2181 | #ifdef DESKTOP_VERSION | 2189 | #ifdef DESKTOP_VERSION |
2182 | config->setGroup("WidgetLayout"); | 2190 | config->setGroup("WidgetLayout"); |
2183 | QStringList list; | 2191 | QStringList list; |
2184 | list = config->readListEntry("MainLayout"); | 2192 | list = config->readListEntry("MainLayout"); |
2185 | int x,y,w,h; | 2193 | int x,y,w,h; |
2186 | if ( ! list.isEmpty() ) { | 2194 | if ( ! list.isEmpty() ) { |
2187 | x = list[0].toInt(); | 2195 | x = list[0].toInt(); |
2188 | y = list[1].toInt(); | 2196 | y = list[1].toInt(); |
2189 | w = list[2].toInt(); | 2197 | w = list[2].toInt(); |
2190 | h = list[3].toInt(); | 2198 | h = list[3].toInt(); |
2191 | KApplication::testCoords( &x,&y,&w,&h ); | 2199 | KApplication::testCoords( &x,&y,&w,&h ); |
2192 | topLevelWidget()->setGeometry(x,y,w,h); | 2200 | topLevelWidget()->setGeometry(x,y,w,h); |
2193 | 2201 | ||
2194 | } else { | 2202 | } else { |
2195 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2203 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2196 | } | 2204 | } |
2197 | list = config->readListEntry("EditEventLayout"); | 2205 | list = config->readListEntry("EditEventLayout"); |
2198 | if ( ! list.isEmpty() ) { | 2206 | if ( ! list.isEmpty() ) { |
2199 | x = list[0].toInt(); | 2207 | x = list[0].toInt(); |
2200 | y = list[1].toInt(); | 2208 | y = list[1].toInt(); |
2201 | w = list[2].toInt(); | 2209 | w = list[2].toInt(); |
2202 | h = list[3].toInt(); | 2210 | h = list[3].toInt(); |
2203 | KApplication::testCoords( &x,&y,&w,&h ); | 2211 | KApplication::testCoords( &x,&y,&w,&h ); |
2204 | mEventEditor->setGeometry(x,y,w,h); | 2212 | mEventEditor->setGeometry(x,y,w,h); |
2205 | 2213 | ||
2206 | } | 2214 | } |
2207 | list = config->readListEntry("EditTodoLayout"); | 2215 | list = config->readListEntry("EditTodoLayout"); |
2208 | if ( ! list.isEmpty() ) { | 2216 | if ( ! list.isEmpty() ) { |
2209 | x = list[0].toInt(); | 2217 | x = list[0].toInt(); |
2210 | y = list[1].toInt(); | 2218 | y = list[1].toInt(); |
2211 | w = list[2].toInt(); | 2219 | w = list[2].toInt(); |
2212 | h = list[3].toInt(); | 2220 | h = list[3].toInt(); |
2213 | KApplication::testCoords( &x,&y,&w,&h ); | 2221 | KApplication::testCoords( &x,&y,&w,&h ); |
2214 | mTodoEditor->setGeometry(x,y,w,h); | 2222 | mTodoEditor->setGeometry(x,y,w,h); |
2215 | 2223 | ||
2216 | } | 2224 | } |
2217 | list = config->readListEntry("ViewerLayout"); | 2225 | list = config->readListEntry("ViewerLayout"); |
2218 | if ( ! list.isEmpty() ) { | 2226 | if ( ! list.isEmpty() ) { |
2219 | x = list[0].toInt(); | 2227 | x = list[0].toInt(); |
2220 | y = list[1].toInt(); | 2228 | y = list[1].toInt(); |
2221 | w = list[2].toInt(); | 2229 | w = list[2].toInt(); |
2222 | h = list[3].toInt(); | 2230 | h = list[3].toInt(); |
2223 | KApplication::testCoords( &x,&y,&w,&h ); | 2231 | KApplication::testCoords( &x,&y,&w,&h ); |
2224 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2232 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2225 | } | 2233 | } |
2226 | #endif | 2234 | #endif |
2227 | config->setGroup( "Views" ); | 2235 | config->setGroup( "Views" ); |
2228 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2236 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2229 | 2237 | ||
2230 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2238 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2231 | 2239 | ||
2232 | int resetval = 0; | 2240 | int resetval = 0; |
2233 | int maxVal = 0; | 2241 | int maxVal = 0; |
2234 | if (sizes.count() != 3) { | 2242 | if (sizes.count() != 3) { |
2235 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2243 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2236 | resetval = mDateNavigator->sizeHint().width()+2; | 2244 | resetval = mDateNavigator->sizeHint().width()+2; |
2237 | } else { | 2245 | } else { |
2238 | resetval = mDateNavigator->sizeHint().height()+2; | 2246 | resetval = mDateNavigator->sizeHint().height()+2; |
2239 | } | 2247 | } |
2240 | } | 2248 | } |
2241 | if ( resetval ) { | 2249 | if ( resetval ) { |
2242 | sizes.clear(); | 2250 | sizes.clear(); |
2243 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2251 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2244 | maxVal = QApplication::desktop()->width() -10; | 2252 | maxVal = QApplication::desktop()->width() -10; |
2245 | } else { | 2253 | } else { |
2246 | maxVal = QApplication::desktop()->height()-10; | 2254 | maxVal = QApplication::desktop()->height()-10; |
2247 | } | 2255 | } |
2248 | sizes << resetval; | 2256 | sizes << resetval; |
2249 | if ( maxVal < resetval + resetval) | 2257 | if ( maxVal < resetval + resetval) |
2250 | resetval = maxVal - resetval; | 2258 | resetval = maxVal - resetval; |
2251 | sizes << resetval; | 2259 | sizes << resetval; |
2252 | sizes << 100; | 2260 | sizes << 100; |
2253 | } | 2261 | } |
2254 | mLeftFrame->setSizes(sizes); | 2262 | mLeftFrame->setSizes(sizes); |
2255 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2263 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2256 | resetval = 0; | 2264 | resetval = 0; |
2257 | maxVal = 0; | 2265 | maxVal = 0; |
2258 | if (sizes.count() != 2) { | 2266 | if (sizes.count() != 2) { |
2259 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2267 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2260 | resetval = mDateNavigator->sizeHint().width()+2; | 2268 | resetval = mDateNavigator->sizeHint().width()+2; |
2261 | } else { | 2269 | } else { |
2262 | resetval = mDateNavigator->sizeHint().height()+2; | 2270 | resetval = mDateNavigator->sizeHint().height()+2; |
2263 | } | 2271 | } |
2264 | } | 2272 | } |
2265 | if ( resetval ) { | 2273 | if ( resetval ) { |
2266 | sizes.clear(); | 2274 | sizes.clear(); |
2267 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2275 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2268 | maxVal = QApplication::desktop()->width() -10; | 2276 | maxVal = QApplication::desktop()->width() -10; |
2269 | } else { | 2277 | } else { |
2270 | maxVal = QApplication::desktop()->height()-10; | 2278 | maxVal = QApplication::desktop()->height()-10; |
2271 | } | 2279 | } |
2272 | sizes << resetval; | 2280 | sizes << resetval; |
2273 | if ( maxVal < resetval + resetval) | 2281 | if ( maxVal < resetval + resetval) |
2274 | resetval = maxVal - resetval; | 2282 | resetval = maxVal - resetval; |
2275 | sizes << resetval; | 2283 | sizes << resetval; |
2276 | } | 2284 | } |
2277 | mMainFrame->setSizes(sizes); | 2285 | mMainFrame->setSizes(sizes); |
2278 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2286 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2279 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2287 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2280 | else mNavigator->selectDates( dateCount ); | 2288 | else mNavigator->selectDates( dateCount ); |
2281 | // mViewManager->readSettings( config ); | 2289 | // mViewManager->readSettings( config ); |
2282 | updateConfig(); | 2290 | updateConfig(); |
2283 | globalFlagBlockAgenda = 2; | 2291 | globalFlagBlockAgenda = 2; |
2284 | mViewManager->readSettings( config ); | 2292 | mViewManager->readSettings( config ); |
2285 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2293 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2286 | } | 2294 | } |
2287 | 2295 | ||
2288 | 2296 | ||
2289 | void CalendarView::writeSettings() | 2297 | void CalendarView::writeSettings() |
2290 | { | 2298 | { |
2291 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2299 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2292 | 2300 | ||
2293 | KConfig *config = KOGlobals::config(); | 2301 | KConfig *config = KOGlobals::config(); |
2294 | 2302 | ||
2295 | mViewManager->writeSettings( config ); | 2303 | mViewManager->writeSettings( config ); |
2296 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2304 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2297 | mDialogManager->writeSettings( config ); | 2305 | mDialogManager->writeSettings( config ); |
2298 | //KOPrefs::instance()->usrWriteConfig(); | 2306 | //KOPrefs::instance()->usrWriteConfig(); |
2299 | KOPrefs::instance()->writeConfig(); | 2307 | KOPrefs::instance()->writeConfig(); |
2300 | 2308 | ||
2301 | writeFilterSettings(config); | 2309 | writeFilterSettings(config); |
2302 | config->setGroup( "AppRun" ); | 2310 | config->setGroup( "AppRun" ); |
2303 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2311 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2304 | int days = dt.daysTo( QDate::currentDate() ); | 2312 | int days = dt.daysTo( QDate::currentDate() ); |
2305 | dt = dt.addDays( days ); | 2313 | dt = dt.addDays( days ); |
2306 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2314 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2307 | config->writeEntry( "LatestProgramStopDays", days ); | 2315 | config->writeEntry( "LatestProgramStopDays", days ); |
2308 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2316 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2309 | //qDebug("KO: Writing stop time: %d ", secs); | 2317 | //qDebug("KO: Writing stop time: %d ", secs); |
2310 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2318 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2311 | //QDateTime latest = dt.addSecs ( secs ); | 2319 | //QDateTime latest = dt.addSecs ( secs ); |
2312 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2320 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2313 | config->setGroup( "Views" ); | 2321 | config->setGroup( "Views" ); |
2314 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2322 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2315 | 2323 | ||
2316 | #if 0 | 2324 | #if 0 |
2317 | qDebug("********************* "); | 2325 | qDebug("********************* "); |
2318 | qDebug("Testcode secsto "); | 2326 | qDebug("Testcode secsto "); |
2319 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2327 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2320 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2328 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2321 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2329 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2322 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2330 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2323 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2331 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2324 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2332 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2325 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2333 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2326 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2334 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2327 | qDebug("********************* testcode end"); | 2335 | qDebug("********************* testcode end"); |
2328 | 2336 | ||
2329 | #endif | 2337 | #endif |
2330 | 2338 | ||
2331 | QValueList<int> listINT = mLeftFrame->sizes(); | 2339 | QValueList<int> listINT = mLeftFrame->sizes(); |
2332 | config->writeEntry("Left Splitter Frame",listINT); | 2340 | config->writeEntry("Left Splitter Frame",listINT); |
2333 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2341 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2334 | config->writeEntry("Main Splitter Frame",listINT2); | 2342 | config->writeEntry("Main Splitter Frame",listINT2); |
2335 | #ifdef DESKTOP_VERSION | 2343 | #ifdef DESKTOP_VERSION |
2336 | config->setGroup("WidgetLayout"); | 2344 | config->setGroup("WidgetLayout"); |
2337 | QStringList list ;//= config->readListEntry("MainLayout"); | 2345 | QStringList list ;//= config->readListEntry("MainLayout"); |
2338 | int x,y,w,h; | 2346 | int x,y,w,h; |
2339 | QWidget* wid; | 2347 | QWidget* wid; |
2340 | wid = topLevelWidget(); | 2348 | wid = topLevelWidget(); |
2341 | x = wid->geometry().x(); | 2349 | x = wid->geometry().x(); |
2342 | y = wid->geometry().y(); | 2350 | y = wid->geometry().y(); |
2343 | w = wid->width(); | 2351 | w = wid->width(); |
2344 | h = wid->height(); | 2352 | h = wid->height(); |
2345 | list.clear(); | 2353 | list.clear(); |
2346 | list << QString::number( x ); | 2354 | list << QString::number( x ); |
2347 | list << QString::number( y ); | 2355 | list << QString::number( y ); |
2348 | list << QString::number( w ); | 2356 | list << QString::number( w ); |
2349 | list << QString::number( h ); | 2357 | list << QString::number( h ); |
2350 | config->writeEntry("MainLayout",list ); | 2358 | config->writeEntry("MainLayout",list ); |
2351 | 2359 | ||
2352 | wid = mEventEditor; | 2360 | wid = mEventEditor; |
2353 | x = wid->geometry().x(); | 2361 | x = wid->geometry().x(); |
2354 | y = wid->geometry().y(); | 2362 | y = wid->geometry().y(); |
2355 | w = wid->width(); | 2363 | w = wid->width(); |
2356 | h = wid->height(); | 2364 | h = wid->height(); |
2357 | list.clear(); | 2365 | list.clear(); |
2358 | list << QString::number( x ); | 2366 | list << QString::number( x ); |
2359 | list << QString::number( y ); | 2367 | list << QString::number( y ); |
2360 | list << QString::number( w ); | 2368 | list << QString::number( w ); |
2361 | list << QString::number( h ); | 2369 | list << QString::number( h ); |
2362 | config->writeEntry("EditEventLayout",list ); | 2370 | config->writeEntry("EditEventLayout",list ); |
2363 | 2371 | ||
2364 | wid = mTodoEditor; | 2372 | wid = mTodoEditor; |
2365 | x = wid->geometry().x(); | 2373 | x = wid->geometry().x(); |
2366 | y = wid->geometry().y(); | 2374 | y = wid->geometry().y(); |
2367 | w = wid->width(); | 2375 | w = wid->width(); |
2368 | h = wid->height(); | 2376 | h = wid->height(); |
2369 | list.clear(); | 2377 | list.clear(); |
2370 | list << QString::number( x ); | 2378 | list << QString::number( x ); |
2371 | list << QString::number( y ); | 2379 | list << QString::number( y ); |
2372 | list << QString::number( w ); | 2380 | list << QString::number( w ); |
2373 | list << QString::number( h ); | 2381 | list << QString::number( h ); |
2374 | config->writeEntry("EditTodoLayout",list ); | 2382 | config->writeEntry("EditTodoLayout",list ); |
2375 | wid = getEventViewerDialog(); | 2383 | wid = getEventViewerDialog(); |
2376 | x = wid->geometry().x(); | 2384 | x = wid->geometry().x(); |
2377 | y = wid->geometry().y(); | 2385 | y = wid->geometry().y(); |
2378 | w = wid->width(); | 2386 | w = wid->width(); |
2379 | h = wid->height(); | 2387 | h = wid->height(); |
2380 | list.clear(); | 2388 | list.clear(); |
2381 | list << QString::number( x ); | 2389 | list << QString::number( x ); |
2382 | list << QString::number( y ); | 2390 | list << QString::number( y ); |
2383 | list << QString::number( w ); | 2391 | list << QString::number( w ); |
2384 | list << QString::number( h ); | 2392 | list << QString::number( h ); |
2385 | config->writeEntry("ViewerLayout",list ); | 2393 | config->writeEntry("ViewerLayout",list ); |
2386 | wid = mDialogManager->getSearchDialog(); | 2394 | wid = mDialogManager->getSearchDialog(); |
2387 | if ( wid ) { | 2395 | if ( wid ) { |
2388 | x = wid->geometry().x(); | 2396 | x = wid->geometry().x(); |
2389 | y = wid->geometry().y(); | 2397 | y = wid->geometry().y(); |
2390 | w = wid->width(); | 2398 | w = wid->width(); |
2391 | h = wid->height(); | 2399 | h = wid->height(); |
2392 | list.clear(); | 2400 | list.clear(); |
2393 | list << QString::number( x ); | 2401 | list << QString::number( x ); |
2394 | list << QString::number( y ); | 2402 | list << QString::number( y ); |
2395 | list << QString::number( w ); | 2403 | list << QString::number( w ); |
2396 | list << QString::number( h ); | 2404 | list << QString::number( h ); |
2397 | config->writeEntry("SearchLayout",list ); | 2405 | config->writeEntry("SearchLayout",list ); |
2398 | } | 2406 | } |
2399 | #endif | 2407 | #endif |
2400 | 2408 | ||
2401 | 2409 | ||
2402 | config->sync(); | 2410 | config->sync(); |
2403 | } | 2411 | } |
2404 | 2412 | ||
2405 | void CalendarView::readFilterSettings(KConfig *config) | 2413 | void CalendarView::readFilterSettings(KConfig *config) |
2406 | { | 2414 | { |
2407 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2415 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2408 | 2416 | ||
2409 | mFilters.clear(); | 2417 | mFilters.clear(); |
2410 | 2418 | ||
2411 | config->setGroup("General"); | 2419 | config->setGroup("General"); |
2412 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2420 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2413 | 2421 | ||
2414 | QStringList::ConstIterator it = filterList.begin(); | 2422 | QStringList::ConstIterator it = filterList.begin(); |
2415 | QStringList::ConstIterator end = filterList.end(); | 2423 | QStringList::ConstIterator end = filterList.end(); |
2416 | while(it != end) { | 2424 | while(it != end) { |
2417 | // kdDebug() << " filter: " << (*it) << endl; | 2425 | // kdDebug() << " filter: " << (*it) << endl; |
2418 | 2426 | ||
2419 | CalFilter *filter; | 2427 | CalFilter *filter; |
2420 | filter = new CalFilter(*it); | 2428 | filter = new CalFilter(*it); |
2421 | config->setGroup("Filter_" + (*it).utf8()); | 2429 | config->setGroup("Filter_" + (*it).utf8()); |
2422 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2430 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2423 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2431 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2424 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2432 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2425 | mFilters.append(filter); | 2433 | mFilters.append(filter); |
2426 | 2434 | ||
2427 | ++it; | 2435 | ++it; |
2428 | } | 2436 | } |
2429 | 2437 | ||
2430 | if (mFilters.count() == 0) { | 2438 | if (mFilters.count() == 0) { |
2431 | CalFilter *filter = new CalFilter(i18n("Default")); | 2439 | CalFilter *filter = new CalFilter(i18n("Default")); |
2432 | mFilters.append(filter); | 2440 | mFilters.append(filter); |
2433 | } | 2441 | } |
2434 | mFilterView->updateFilters(); | 2442 | mFilterView->updateFilters(); |
2435 | config->setGroup("FilterView"); | 2443 | config->setGroup("FilterView"); |
2436 | 2444 | ||
2437 | mFilterView->blockSignals(true); | 2445 | mFilterView->blockSignals(true); |
2438 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2446 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2439 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2447 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2440 | mFilterView->blockSignals(false); | 2448 | mFilterView->blockSignals(false); |
2441 | // We do it manually to avoid it being done twice by the above calls | 2449 | // We do it manually to avoid it being done twice by the above calls |
2442 | updateFilter(); | 2450 | updateFilter(); |
2443 | } | 2451 | } |
2444 | 2452 | ||
2445 | void CalendarView::writeFilterSettings(KConfig *config) | 2453 | void CalendarView::writeFilterSettings(KConfig *config) |
2446 | { | 2454 | { |
2447 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2455 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2448 | 2456 | ||
2449 | QStringList filterList; | 2457 | QStringList filterList; |
2450 | 2458 | ||
2451 | CalFilter *filter = mFilters.first(); | 2459 | CalFilter *filter = mFilters.first(); |
2452 | while(filter) { | 2460 | while(filter) { |
2453 | // kdDebug() << " fn: " << filter->name() << endl; | 2461 | // kdDebug() << " fn: " << filter->name() << endl; |
2454 | filterList << filter->name(); | 2462 | filterList << filter->name(); |
2455 | config->setGroup("Filter_" + filter->name().utf8()); | 2463 | config->setGroup("Filter_" + filter->name().utf8()); |
2456 | config->writeEntry("Criteria",filter->criteria()); | 2464 | config->writeEntry("Criteria",filter->criteria()); |
2457 | config->writeEntry("CategoryList",filter->categoryList()); | 2465 | config->writeEntry("CategoryList",filter->categoryList()); |
2458 | filter = mFilters.next(); | 2466 | filter = mFilters.next(); |
2459 | } | 2467 | } |
2460 | config->setGroup("General"); | 2468 | config->setGroup("General"); |
2461 | config->writeEntry("CalendarFilters",filterList); | 2469 | config->writeEntry("CalendarFilters",filterList); |
2462 | 2470 | ||
2463 | config->setGroup("FilterView"); | 2471 | config->setGroup("FilterView"); |
2464 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2472 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2465 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2473 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2466 | } | 2474 | } |
2467 | 2475 | ||
2468 | 2476 | ||
2469 | void CalendarView::goToday() | 2477 | void CalendarView::goToday() |
2470 | { | 2478 | { |
2471 | if ( mViewManager->currentView()->isMonthView() ) | 2479 | if ( mViewManager->currentView()->isMonthView() ) |
2472 | mNavigator->selectTodayMonth(); | 2480 | mNavigator->selectTodayMonth(); |
2473 | else | 2481 | else |
2474 | mNavigator->selectToday(); | 2482 | mNavigator->selectToday(); |
2475 | } | 2483 | } |
2476 | 2484 | ||
2477 | void CalendarView::goNext() | 2485 | void CalendarView::goNext() |
2478 | { | 2486 | { |
2479 | mNavigator->selectNext(); | 2487 | mNavigator->selectNext(); |
2480 | } | 2488 | } |
2481 | 2489 | ||
2482 | void CalendarView::goPrevious() | 2490 | void CalendarView::goPrevious() |
2483 | { | 2491 | { |
2484 | mNavigator->selectPrevious(); | 2492 | mNavigator->selectPrevious(); |
2485 | } | 2493 | } |
2486 | void CalendarView::goNextMonth() | 2494 | void CalendarView::goNextMonth() |
2487 | { | 2495 | { |
2488 | mNavigator->selectNextMonth(); | 2496 | mNavigator->selectNextMonth(); |
2489 | } | 2497 | } |
2490 | 2498 | ||
2491 | void CalendarView::goPreviousMonth() | 2499 | void CalendarView::goPreviousMonth() |
2492 | { | 2500 | { |
2493 | mNavigator->selectPreviousMonth(); | 2501 | mNavigator->selectPreviousMonth(); |
2494 | } | 2502 | } |
2495 | 2503 | ||
2496 | void CalendarView::updateConfig() | 2504 | void CalendarView::updateConfig() |
2497 | { | 2505 | { |
2498 | if ( KOPrefs::instance()->mUseAppColors ) | 2506 | if ( KOPrefs::instance()->mUseAppColors ) |
2499 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2507 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2500 | emit configChanged(); | 2508 | emit configChanged(); |
2501 | mTodoList->updateConfig(); | 2509 | mTodoList->updateConfig(); |
2502 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2510 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2503 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2511 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2504 | // To make the "fill window" configurations work | 2512 | // To make the "fill window" configurations work |
2505 | //mViewManager->raiseCurrentView(); | 2513 | //mViewManager->raiseCurrentView(); |
2506 | } | 2514 | } |
2507 | 2515 | ||
2508 | 2516 | ||
2509 | void CalendarView::eventChanged(Event *event) | 2517 | void CalendarView::eventChanged(Event *event) |
2510 | { | 2518 | { |
2511 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2519 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2512 | //updateUnmanagedViews(); | 2520 | //updateUnmanagedViews(); |
2513 | } | 2521 | } |
2514 | 2522 | ||
2515 | void CalendarView::eventAdded(Event *event) | 2523 | void CalendarView::eventAdded(Event *event) |
2516 | { | 2524 | { |
2517 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2525 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2518 | } | 2526 | } |
2519 | 2527 | ||
2520 | void CalendarView::eventToBeDeleted(Event *) | 2528 | void CalendarView::eventToBeDeleted(Event *) |
2521 | { | 2529 | { |
2522 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2530 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2523 | } | 2531 | } |
2524 | 2532 | ||
2525 | void CalendarView::eventDeleted() | 2533 | void CalendarView::eventDeleted() |
2526 | { | 2534 | { |
2527 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2535 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2528 | } | 2536 | } |
2529 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2537 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2530 | { | 2538 | { |
2531 | changeIncidenceDisplay((Incidence *)which, action); | 2539 | changeIncidenceDisplay((Incidence *)which, action); |
2532 | mDateNavigator->updateView(); //LR | 2540 | mDateNavigator->updateView(); //LR |
2533 | //mDialogManager->updateSearchDialog(); | 2541 | //mDialogManager->updateSearchDialog(); |
2534 | 2542 | ||
2535 | if (which) { | 2543 | if (which) { |
2536 | mViewManager->updateWNview(); | 2544 | mViewManager->updateWNview(); |
2537 | //mTodoList->updateView(); | 2545 | //mTodoList->updateView(); |
2538 | } | 2546 | } |
2539 | 2547 | ||
2540 | } | 2548 | } |
2541 | 2549 | ||
2542 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2550 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2543 | { | 2551 | { |
2544 | updateUnmanagedViews(); | 2552 | updateUnmanagedViews(); |
2545 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2553 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2546 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2554 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2547 | mCalendar->checkAlarmForIncidence( 0, true ); | 2555 | mCalendar->checkAlarmForIncidence( 0, true ); |
2548 | if ( mEventViewerDialog ) | 2556 | if ( mEventViewerDialog ) |
2549 | mEventViewerDialog->hide(); | 2557 | mEventViewerDialog->hide(); |
2550 | } | 2558 | } |
2551 | else | 2559 | else |
2552 | mCalendar->checkAlarmForIncidence( which , false ); | 2560 | mCalendar->checkAlarmForIncidence( which , false ); |
2553 | } | 2561 | } |
2554 | 2562 | ||
2555 | // most of the changeEventDisplays() right now just call the view's | 2563 | // most of the changeEventDisplays() right now just call the view's |
2556 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2564 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2557 | void CalendarView::changeEventDisplay(Event *which, int action) | 2565 | void CalendarView::changeEventDisplay(Event *which, int action) |
2558 | { | 2566 | { |
2559 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2567 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2560 | changeIncidenceDisplay((Incidence *)which, action); | 2568 | changeIncidenceDisplay((Incidence *)which, action); |
2561 | mDateNavigator->updateView(); | 2569 | mDateNavigator->updateView(); |
2562 | //mDialogManager->updateSearchDialog(); | 2570 | //mDialogManager->updateSearchDialog(); |
2563 | 2571 | ||
2564 | if (which) { | 2572 | if (which) { |
2565 | // If there is an event view visible update the display | 2573 | // If there is an event view visible update the display |
2566 | mViewManager->currentView()->changeEventDisplay(which,action); | 2574 | mViewManager->currentView()->changeEventDisplay(which,action); |
2567 | // TODO: check, if update needed | 2575 | // TODO: check, if update needed |
2568 | // if (which->getTodoStatus()) { | 2576 | // if (which->getTodoStatus()) { |
2569 | mTodoList->updateView(); | 2577 | mTodoList->updateView(); |
2570 | // } | 2578 | // } |
2571 | } else { | 2579 | } else { |
2572 | mViewManager->currentView()->updateView(); | 2580 | mViewManager->currentView()->updateView(); |
2573 | } | 2581 | } |
2574 | } | 2582 | } |
2575 | 2583 | ||
2576 | 2584 | ||
2577 | void CalendarView::updateTodoViews() | 2585 | void CalendarView::updateTodoViews() |
2578 | { | 2586 | { |
2579 | mTodoList->updateView(); | 2587 | mTodoList->updateView(); |
2580 | mViewManager->currentView()->updateView(); | 2588 | mViewManager->currentView()->updateView(); |
2581 | 2589 | ||
2582 | } | 2590 | } |
2583 | 2591 | ||
2584 | 2592 | ||
2585 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2593 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2586 | { | 2594 | { |
2595 | #ifdef DESKTOP_VERSION | ||
2587 | mDateScrollBar->setValue( start.dayOfYear()-1); | 2596 | mDateScrollBar->setValue( start.dayOfYear()-1); |
2597 | #endif | ||
2588 | mTodoList->updateView(); | 2598 | mTodoList->updateView(); |
2589 | mViewManager->updateView(start, end); | 2599 | mViewManager->updateView(start, end); |
2590 | //mDateNavigator->updateView(); | 2600 | //mDateNavigator->updateView(); |
2591 | } | 2601 | } |
2592 | 2602 | ||
2593 | void CalendarView::clearAllViews() | 2603 | void CalendarView::clearAllViews() |
2594 | { | 2604 | { |
2595 | mTodoList->clearList(); | 2605 | mTodoList->clearList(); |
2596 | mViewManager->clearAllViews(); | 2606 | mViewManager->clearAllViews(); |
2597 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2607 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2598 | if ( sd ) { | 2608 | if ( sd ) { |
2599 | KOListView* kol = sd->listview(); | 2609 | KOListView* kol = sd->listview(); |
2600 | if ( kol ) | 2610 | if ( kol ) |
2601 | kol->clearList(); | 2611 | kol->clearList(); |
2602 | } | 2612 | } |
2603 | } | 2613 | } |
2604 | void CalendarView::updateView() | 2614 | void CalendarView::updateView() |
2605 | { | 2615 | { |
2606 | DateList tmpList = mNavigator->selectedDates(); | 2616 | DateList tmpList = mNavigator->selectedDates(); |
2607 | 2617 | ||
2608 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2618 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2609 | mTodoList->updateView(); | 2619 | mTodoList->updateView(); |
2610 | // We assume that the navigator only selects consecutive days. | 2620 | // We assume that the navigator only selects consecutive days. |
2611 | updateView( tmpList.first(), tmpList.last() ); | 2621 | updateView( tmpList.first(), tmpList.last() ); |
2612 | } | 2622 | } |
2613 | 2623 | ||
2614 | void CalendarView::updateUnmanagedViews() | 2624 | void CalendarView::updateUnmanagedViews() |
2615 | { | 2625 | { |
2616 | mDateNavigator->updateDayMatrix(); | 2626 | mDateNavigator->updateDayMatrix(); |
2617 | } | 2627 | } |
2618 | 2628 | ||
2619 | int CalendarView::msgItemDelete(const QString name) | 2629 | int CalendarView::msgItemDelete(const QString name) |
2620 | { | 2630 | { |
2621 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2631 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2622 | i18n("This item will be\npermanently deleted."), | 2632 | i18n("This item will be\npermanently deleted."), |
2623 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2633 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2624 | } | 2634 | } |
2625 | 2635 | ||
2626 | 2636 | ||
2627 | void CalendarView::edit_cut() | 2637 | void CalendarView::edit_cut() |
2628 | { | 2638 | { |
2629 | Event *anEvent=0; | 2639 | Event *anEvent=0; |
2630 | 2640 | ||
2631 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2641 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2632 | 2642 | ||
2633 | if (mViewManager->currentView()->isEventView()) { | 2643 | if (mViewManager->currentView()->isEventView()) { |
2634 | if ( incidence && incidence->typeID() == eventID ) { | 2644 | if ( incidence && incidence->typeID() == eventID ) { |
2635 | anEvent = static_cast<Event *>(incidence); | 2645 | anEvent = static_cast<Event *>(incidence); |
2636 | } | 2646 | } |
2637 | } | 2647 | } |
2638 | 2648 | ||
2639 | if (!anEvent) { | 2649 | if (!anEvent) { |
2640 | KNotifyClient::beep(); | 2650 | KNotifyClient::beep(); |
2641 | return; | 2651 | return; |
2642 | } | 2652 | } |
2643 | DndFactory factory( mCalendar ); | 2653 | DndFactory factory( mCalendar ); |
2644 | factory.cutIncidence(anEvent); | 2654 | factory.cutIncidence(anEvent); |
2645 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2655 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2646 | } | 2656 | } |
2647 | 2657 | ||
2648 | void CalendarView::edit_copy() | 2658 | void CalendarView::edit_copy() |
2649 | { | 2659 | { |
2650 | Event *anEvent=0; | 2660 | Event *anEvent=0; |
2651 | 2661 | ||
2652 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2662 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2653 | 2663 | ||
2654 | if (mViewManager->currentView()->isEventView()) { | 2664 | if (mViewManager->currentView()->isEventView()) { |
2655 | if ( incidence && incidence->typeID() == eventID ) { | 2665 | if ( incidence && incidence->typeID() == eventID ) { |
2656 | anEvent = static_cast<Event *>(incidence); | 2666 | anEvent = static_cast<Event *>(incidence); |
2657 | } | 2667 | } |
2658 | } | 2668 | } |
2659 | 2669 | ||
2660 | if (!anEvent) { | 2670 | if (!anEvent) { |
2661 | KNotifyClient::beep(); | 2671 | KNotifyClient::beep(); |
2662 | return; | 2672 | return; |
2663 | } | 2673 | } |
2664 | DndFactory factory( mCalendar ); | 2674 | DndFactory factory( mCalendar ); |
2665 | factory.copyIncidence(anEvent); | 2675 | factory.copyIncidence(anEvent); |
2666 | } | 2676 | } |
2667 | 2677 | ||
2668 | void CalendarView::edit_paste() | 2678 | void CalendarView::edit_paste() |
2669 | { | 2679 | { |
2670 | QDate date = mNavigator->selectedDates().first(); | 2680 | QDate date = mNavigator->selectedDates().first(); |
2671 | 2681 | ||
2672 | DndFactory factory( mCalendar ); | 2682 | DndFactory factory( mCalendar ); |
2673 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2683 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2674 | 2684 | ||
2675 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2685 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2676 | } | 2686 | } |
2677 | void CalendarView::edit_global_options() | 2687 | void CalendarView::edit_global_options() |
2678 | { | 2688 | { |
2679 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2689 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2680 | emit save(); | 2690 | emit save(); |
2681 | emit saveStopTimer(); | 2691 | emit saveStopTimer(); |
2682 | mDialogManager->showGlobalOptionsDialog(); | 2692 | mDialogManager->showGlobalOptionsDialog(); |
2683 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2693 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2684 | emit saveStopTimer(); | 2694 | emit saveStopTimer(); |
2685 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2695 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2686 | i18n("Timezone settings"),i18n("Reload"))) { | 2696 | i18n("Timezone settings"),i18n("Reload"))) { |
2687 | qDebug("KO: TZ reload cancelled "); | 2697 | qDebug("KO: TZ reload cancelled "); |
2688 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2698 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2689 | return; | 2699 | return; |
2690 | } | 2700 | } |
2691 | qDebug("KO: Timezone change "); | 2701 | qDebug("KO: Timezone change "); |
2692 | loadCalendars(); | 2702 | loadCalendars(); |
2693 | setModified(true); | 2703 | setModified(true); |
2694 | } | 2704 | } |
2695 | else | 2705 | else |
2696 | qDebug("KO: No tz change "); | 2706 | qDebug("KO: No tz change "); |
2697 | } | 2707 | } |
2698 | void CalendarView::edit_options() | 2708 | void CalendarView::edit_options() |
2699 | { | 2709 | { |
2700 | mDialogManager->showOptionsDialog(); | 2710 | mDialogManager->showOptionsDialog(); |
2701 | } | 2711 | } |
2702 | 2712 | ||
2703 | 2713 | ||
2704 | void CalendarView::slotSelectPickerDate( QDate d) | 2714 | void CalendarView::slotSelectPickerDate( QDate d) |
2705 | { | 2715 | { |
2706 | mDateFrame->hide(); | 2716 | mDateFrame->hide(); |
2707 | if ( mDatePickerMode == 1 ) { | 2717 | if ( mDatePickerMode == 1 ) { |
2708 | mNavigator->slotDaySelect( d ); | 2718 | mNavigator->slotDaySelect( d ); |
2709 | } else if ( mDatePickerMode == 2 ) { | 2719 | } else if ( mDatePickerMode == 2 ) { |
2710 | if ( mMoveIncidence->typeID() == todoID ) { | 2720 | if ( mMoveIncidence->typeID() == todoID ) { |
2711 | Todo * to = (Todo *) mMoveIncidence; | 2721 | Todo * to = (Todo *) mMoveIncidence; |
2712 | QTime tim; | 2722 | QTime tim; |
2713 | int len = 0; | 2723 | int len = 0; |
2714 | if ( to->hasStartDate() && to->hasDueDate() ) | 2724 | if ( to->hasStartDate() && to->hasDueDate() ) |
2715 | len = to->dtStart().secsTo( to->dtDue()); | 2725 | len = to->dtStart().secsTo( to->dtDue()); |
2716 | if ( to->hasDueDate() ) | 2726 | if ( to->hasDueDate() ) |
2717 | tim = to->dtDue().time(); | 2727 | tim = to->dtDue().time(); |
2718 | else { | 2728 | else { |
2719 | tim = QTime ( 0,0,0 ); | 2729 | tim = QTime ( 0,0,0 ); |
2720 | to->setFloats( true ); | 2730 | to->setFloats( true ); |
2721 | to->setHasDueDate( true ); | 2731 | to->setHasDueDate( true ); |
2722 | } | 2732 | } |
2723 | QDateTime dt ( d,tim ); | 2733 | QDateTime dt ( d,tim ); |
2724 | to->setDtDue( dt ); | 2734 | to->setDtDue( dt ); |
2725 | 2735 | ||
2726 | if ( to->hasStartDate() ) { | 2736 | if ( to->hasStartDate() ) { |
2727 | if ( len>0 ) | 2737 | if ( len>0 ) |
2728 | to->setDtStart(to->dtDue().addSecs( -len )); | 2738 | to->setDtStart(to->dtDue().addSecs( -len )); |
2729 | else | 2739 | else |
2730 | if (to->dtStart() > to->dtDue() ) | 2740 | if (to->dtStart() > to->dtDue() ) |
2731 | to->setDtStart(to->dtDue().addDays( -3 )); | 2741 | to->setDtStart(to->dtDue().addDays( -3 )); |
2732 | } | 2742 | } |
2733 | 2743 | ||
2734 | todoChanged( to ); | 2744 | todoChanged( to ); |
2735 | } else { | 2745 | } else { |
2736 | if ( mMoveIncidence->doesRecur() ) { | 2746 | if ( mMoveIncidence->doesRecur() ) { |
2737 | #if 0 | 2747 | #if 0 |
2738 | // PENDING implement this | 2748 | // PENDING implement this |
2739 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2749 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2740 | mCalendar()->addIncidence( newInc ); | 2750 | mCalendar()->addIncidence( newInc ); |
2741 | if ( mMoveIncidence->typeID() == todoID ) | 2751 | if ( mMoveIncidence->typeID() == todoID ) |
2742 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2752 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2743 | else | 2753 | else |
2744 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2754 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2745 | mMoveIncidence = newInc; | 2755 | mMoveIncidence = newInc; |
2746 | 2756 | ||
2747 | #endif | 2757 | #endif |
2748 | } | 2758 | } |
2749 | QTime tim = mMoveIncidence->dtStart().time(); | 2759 | QTime tim = mMoveIncidence->dtStart().time(); |
2750 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2760 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2751 | QDateTime dt ( d,tim ); | 2761 | QDateTime dt ( d,tim ); |
2752 | mMoveIncidence->setDtStart( dt ); | 2762 | mMoveIncidence->setDtStart( dt ); |
2753 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2763 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2754 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2764 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2755 | } | 2765 | } |
2756 | 2766 | ||
2757 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2767 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2758 | } | 2768 | } |
2759 | } | 2769 | } |
2760 | 2770 | ||
2761 | void CalendarView::removeCategories() | 2771 | void CalendarView::removeCategories() |
2762 | { | 2772 | { |
2763 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2773 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2764 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2774 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2765 | QStringList catIncList; | 2775 | QStringList catIncList; |
2766 | QStringList newCatList; | 2776 | QStringList newCatList; |
2767 | Incidence* inc = incList.first(); | 2777 | Incidence* inc = incList.first(); |
2768 | int i; | 2778 | int i; |
2769 | int count = 0; | 2779 | int count = 0; |
2770 | while ( inc ) { | 2780 | while ( inc ) { |
2771 | newCatList.clear(); | 2781 | newCatList.clear(); |
2772 | catIncList = inc->categories() ; | 2782 | catIncList = inc->categories() ; |
2773 | for( i = 0; i< catIncList.count(); ++i ) { | 2783 | for( i = 0; i< catIncList.count(); ++i ) { |
2774 | if ( catList.contains (catIncList[i])) | 2784 | if ( catList.contains (catIncList[i])) |
2775 | newCatList.append( catIncList[i] ); | 2785 | newCatList.append( catIncList[i] ); |
2776 | } | 2786 | } |
2777 | newCatList.sort(); | 2787 | newCatList.sort(); |
2778 | inc->setCategories( newCatList.join(",") ); | 2788 | inc->setCategories( newCatList.join(",") ); |
2779 | inc = incList.next(); | 2789 | inc = incList.next(); |
2780 | } | 2790 | } |
2781 | } | 2791 | } |
2782 | 2792 | ||
2783 | int CalendarView::addCategories() | 2793 | int CalendarView::addCategories() |
2784 | { | 2794 | { |
2785 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2795 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2786 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2796 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2787 | QStringList catIncList; | 2797 | QStringList catIncList; |
2788 | Incidence* inc = incList.first(); | 2798 | Incidence* inc = incList.first(); |
2789 | int i; | 2799 | int i; |
2790 | int count = 0; | 2800 | int count = 0; |
2791 | while ( inc ) { | 2801 | while ( inc ) { |
2792 | catIncList = inc->categories() ; | 2802 | catIncList = inc->categories() ; |
2793 | for( i = 0; i< catIncList.count(); ++i ) { | 2803 | for( i = 0; i< catIncList.count(); ++i ) { |
2794 | if ( !catList.contains (catIncList[i])) { | 2804 | if ( !catList.contains (catIncList[i])) { |
2795 | catList.append( catIncList[i] ); | 2805 | catList.append( catIncList[i] ); |
2796 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2806 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2797 | ++count; | 2807 | ++count; |
2798 | } | 2808 | } |
2799 | } | 2809 | } |
2800 | inc = incList.next(); | 2810 | inc = incList.next(); |
2801 | } | 2811 | } |
2802 | catList.sort(); | 2812 | catList.sort(); |
2803 | KOPrefs::instance()->mCustomCategories = catList; | 2813 | KOPrefs::instance()->mCustomCategories = catList; |
2804 | return count; | 2814 | return count; |
2805 | } | 2815 | } |
2806 | 2816 | ||
2807 | void CalendarView::manageCategories() | 2817 | void CalendarView::manageCategories() |
2808 | { | 2818 | { |
2809 | KOCatPrefs* cp = new KOCatPrefs(); | 2819 | KOCatPrefs* cp = new KOCatPrefs(); |
2810 | cp->show(); | 2820 | cp->show(); |
2811 | int w =cp->sizeHint().width() ; | 2821 | int w =cp->sizeHint().width() ; |
2812 | int h = cp->sizeHint().height() ; | 2822 | int h = cp->sizeHint().height() ; |
2813 | int dw = QApplication::desktop()->width(); | 2823 | int dw = QApplication::desktop()->width(); |
2814 | int dh = QApplication::desktop()->height(); | 2824 | int dh = QApplication::desktop()->height(); |
2815 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2825 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2816 | if ( !cp->exec() ) { | 2826 | if ( !cp->exec() ) { |
2817 | delete cp; | 2827 | delete cp; |
2818 | return; | 2828 | return; |
2819 | } | 2829 | } |
2820 | int count = 0; | 2830 | int count = 0; |
2821 | if ( cp->addCat() ) { | 2831 | if ( cp->addCat() ) { |
2822 | count = addCategories(); | 2832 | count = addCategories(); |
2823 | if ( count ) { | 2833 | if ( count ) { |
2824 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2834 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2825 | writeSettings(); | 2835 | writeSettings(); |
2826 | } else | 2836 | } else |
2827 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2837 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2828 | } else { | 2838 | } else { |
2829 | removeCategories(); | 2839 | removeCategories(); |
2830 | updateView(); | 2840 | updateView(); |
2831 | } | 2841 | } |
2832 | delete cp; | 2842 | delete cp; |
2833 | } | 2843 | } |
2834 | 2844 | ||
2835 | void CalendarView::beamIncidence(Incidence * Inc) | 2845 | void CalendarView::beamIncidence(Incidence * Inc) |
2836 | { | 2846 | { |
2837 | QPtrList<Incidence> delSel ; | 2847 | QPtrList<Incidence> delSel ; |
2838 | delSel.append(Inc); | 2848 | delSel.append(Inc); |
2839 | beamIncidenceList( delSel ); | 2849 | beamIncidenceList( delSel ); |
2840 | } | 2850 | } |
2841 | void CalendarView::beamCalendar() | 2851 | void CalendarView::beamCalendar() |
2842 | { | 2852 | { |
2843 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2853 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2844 | //qDebug("beamCalendar() "); | 2854 | //qDebug("beamCalendar() "); |
2845 | beamIncidenceList( delSel ); | 2855 | beamIncidenceList( delSel ); |
2846 | } | 2856 | } |
2847 | void CalendarView::beamFilteredCalendar() | 2857 | void CalendarView::beamFilteredCalendar() |
2848 | { | 2858 | { |
2849 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2859 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2850 | //qDebug("beamFilteredCalendar() "); | 2860 | //qDebug("beamFilteredCalendar() "); |
2851 | beamIncidenceList( delSel ); | 2861 | beamIncidenceList( delSel ); |
2852 | } | 2862 | } |
2853 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2863 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2854 | { | 2864 | { |
2855 | 2865 | ||
2856 | KOBeamPrefs beamDialog; | 2866 | KOBeamPrefs beamDialog; |
2857 | if ( beamDialog.exec () == QDialog::Rejected ) | 2867 | if ( beamDialog.exec () == QDialog::Rejected ) |
2858 | return; | 2868 | return; |
2859 | #ifdef DESKTOP_VERSION | 2869 | #ifdef DESKTOP_VERSION |
2860 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2870 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2861 | #else | 2871 | #else |
2862 | QString fn = "/tmp/kopibeamfile"; | 2872 | QString fn = "/tmp/kopibeamfile"; |
2863 | #endif | 2873 | #endif |
2864 | QString mes; | 2874 | QString mes; |
2865 | bool createbup = true; | 2875 | bool createbup = true; |
2866 | if ( createbup ) { | 2876 | if ( createbup ) { |
2867 | QString description = "\n"; | 2877 | QString description = "\n"; |
2868 | CalendarLocal* cal = new CalendarLocal(); | 2878 | CalendarLocal* cal = new CalendarLocal(); |
2869 | if ( beamDialog.beamLocal() ) | 2879 | if ( beamDialog.beamLocal() ) |
2870 | cal->setLocalTime(); | 2880 | cal->setLocalTime(); |
2871 | else | 2881 | else |
2872 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2882 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2873 | Incidence *incidence = delSel.first(); | 2883 | Incidence *incidence = delSel.first(); |
2874 | bool addText = false; | 2884 | bool addText = false; |
2875 | if ( delSel.count() < 10 ) | 2885 | if ( delSel.count() < 10 ) |
2876 | addText = true; | 2886 | addText = true; |
2877 | else { | 2887 | else { |
2878 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2888 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2879 | } | 2889 | } |
2880 | while ( incidence ) { | 2890 | while ( incidence ) { |
2881 | Incidence *in = incidence->clone(); | 2891 | Incidence *in = incidence->clone(); |
2882 | if ( ! in->summary().isEmpty() ) { | 2892 | if ( ! in->summary().isEmpty() ) { |
2883 | in->setDescription(""); | 2893 | in->setDescription(""); |
2884 | } else { | 2894 | } else { |
2885 | in->setSummary( in->description().left(20)); | 2895 | in->setSummary( in->description().left(20)); |
2886 | in->setDescription(""); | 2896 | in->setDescription(""); |
2887 | } | 2897 | } |
2888 | if ( addText ) | 2898 | if ( addText ) |
2889 | description += in->summary() + "\n"; | 2899 | description += in->summary() + "\n"; |
2890 | cal->addIncidence( in ); | 2900 | cal->addIncidence( in ); |
2891 | incidence = delSel.next(); | 2901 | incidence = delSel.next(); |
2892 | } | 2902 | } |
2893 | if ( beamDialog.beamVcal() ) { | 2903 | if ( beamDialog.beamVcal() ) { |
2894 | fn += ".vcs"; | 2904 | fn += ".vcs"; |
2895 | FileStorage storage( cal, fn, new VCalFormat ); | 2905 | FileStorage storage( cal, fn, new VCalFormat ); |
2896 | storage.save(); | 2906 | storage.save(); |
2897 | } else { | 2907 | } else { |
2898 | fn += ".ics"; | 2908 | fn += ".ics"; |
2899 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2909 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2900 | storage.save(); | 2910 | storage.save(); |
2901 | } | 2911 | } |
2902 | delete cal; | 2912 | delete cal; |
2903 | mes = i18n("KO/Pi: Ready for beaming"); | 2913 | mes = i18n("KO/Pi: Ready for beaming"); |
2904 | topLevelWidget()->setCaption(mes); | 2914 | topLevelWidget()->setCaption(mes); |
2905 | KApplication::convert2latin1( fn ); | 2915 | KApplication::convert2latin1( fn ); |
2906 | #ifndef DESKTOP_VERSION | 2916 | #ifndef DESKTOP_VERSION |
2907 | Ir *ir = new Ir( this ); | 2917 | Ir *ir = new Ir( this ); |
2908 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2918 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2909 | ir->send( fn, description, "text/x-vCalendar" ); | 2919 | ir->send( fn, description, "text/x-vCalendar" ); |
2910 | #endif | 2920 | #endif |
2911 | } | 2921 | } |
2912 | } | 2922 | } |
2913 | void CalendarView::beamDone( Ir *ir ) | 2923 | void CalendarView::beamDone( Ir *ir ) |
2914 | { | 2924 | { |
2915 | #ifndef DESKTOP_VERSION | 2925 | #ifndef DESKTOP_VERSION |
2916 | delete ir; | 2926 | delete ir; |
2917 | #endif | 2927 | #endif |
2918 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2928 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2919 | topLevelWidget()->raise(); | 2929 | topLevelWidget()->raise(); |
2920 | } | 2930 | } |
2921 | 2931 | ||
2922 | void CalendarView::moveIncidence(Incidence * inc ) | 2932 | void CalendarView::moveIncidence(Incidence * inc ) |
2923 | { | 2933 | { |
2924 | if ( !inc ) return; | 2934 | if ( !inc ) return; |
2925 | showDatePickerPopup(); | 2935 | showDatePickerPopup(); |
2926 | mDatePickerMode = 2; | 2936 | mDatePickerMode = 2; |
2927 | mMoveIncidence = inc ; | 2937 | mMoveIncidence = inc ; |
2928 | QDate da; | 2938 | QDate da; |
2929 | if ( mMoveIncidence->typeID() == todoID ) { | 2939 | if ( mMoveIncidence->typeID() == todoID ) { |
2930 | Todo * to = (Todo *) mMoveIncidence; | 2940 | Todo * to = (Todo *) mMoveIncidence; |
2931 | if ( to->hasDueDate() ) | 2941 | if ( to->hasDueDate() ) |
2932 | da = to->dtDue().date(); | 2942 | da = to->dtDue().date(); |
2933 | else | 2943 | else |
2934 | da = QDate::currentDate(); | 2944 | da = QDate::currentDate(); |
2935 | } else { | 2945 | } else { |
2936 | da = mMoveIncidence->dtStart().date(); | 2946 | da = mMoveIncidence->dtStart().date(); |
2937 | } | 2947 | } |
2938 | //PENDING set date for recurring incidence to date of recurrence | 2948 | //PENDING set date for recurring incidence to date of recurrence |
2939 | //mMoveIncidenceOldDate; | 2949 | //mMoveIncidenceOldDate; |
2940 | mDatePicker->setDate( da ); | 2950 | mDatePicker->setDate( da ); |
2941 | } | 2951 | } |
2942 | void CalendarView::showDatePickerPopup() | 2952 | void CalendarView::showDatePickerPopup() |
2943 | { | 2953 | { |
2944 | if ( mDateFrame->isVisible() ) | 2954 | if ( mDateFrame->isVisible() ) |
2945 | mDateFrame->hide(); | 2955 | mDateFrame->hide(); |
2946 | else { | 2956 | else { |
2947 | int offX = 0, offY = 0; | 2957 | int offX = 0, offY = 0; |
2948 | #ifdef DESKTOP_VERSION | 2958 | #ifdef DESKTOP_VERSION |
2949 | int w =mDatePicker->sizeHint().width() ; | 2959 | int w =mDatePicker->sizeHint().width() ; |
2950 | int h = mDatePicker->sizeHint().height() ; | 2960 | int h = mDatePicker->sizeHint().height() ; |
2951 | int dw = topLevelWidget()->width(); | 2961 | int dw = topLevelWidget()->width(); |
2952 | int dh = topLevelWidget()->height(); | 2962 | int dh = topLevelWidget()->height(); |
2953 | offX = topLevelWidget()->x(); | 2963 | offX = topLevelWidget()->x(); |
2954 | offY = topLevelWidget()->y(); | 2964 | offY = topLevelWidget()->y(); |
2955 | #else | 2965 | #else |
2956 | int w =mDatePicker->sizeHint().width() ; | 2966 | int w =mDatePicker->sizeHint().width() ; |
2957 | int h = mDatePicker->sizeHint().height() ; | 2967 | int h = mDatePicker->sizeHint().height() ; |
2958 | int dw = QApplication::desktop()->width(); | 2968 | int dw = QApplication::desktop()->width(); |
2959 | int dh = QApplication::desktop()->height(); | 2969 | int dh = QApplication::desktop()->height(); |
2960 | #endif | 2970 | #endif |
2961 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2971 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2962 | mDateFrame->show(); | 2972 | mDateFrame->show(); |
2963 | } | 2973 | } |
2964 | } | 2974 | } |
2965 | void CalendarView::showDatePicker( ) | 2975 | void CalendarView::showDatePicker( ) |
2966 | { | 2976 | { |
2967 | showDatePickerPopup(); | 2977 | showDatePickerPopup(); |
2968 | mDatePickerMode = 1; | 2978 | mDatePickerMode = 1; |
2969 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2979 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2970 | } | 2980 | } |
2971 | 2981 | ||
2972 | void CalendarView::showEventEditor() | 2982 | void CalendarView::showEventEditor() |
2973 | { | 2983 | { |
2974 | #ifdef DESKTOP_VERSION | 2984 | #ifdef DESKTOP_VERSION |
2975 | int x,y,w,h; | 2985 | int x,y,w,h; |
2976 | x = mEventEditor->geometry().x(); | 2986 | x = mEventEditor->geometry().x(); |
2977 | y = mEventEditor->geometry().y(); | 2987 | y = mEventEditor->geometry().y(); |
2978 | w = mEventEditor->width(); | 2988 | w = mEventEditor->width(); |
2979 | h = mEventEditor->height(); | 2989 | h = mEventEditor->height(); |
2980 | mEventEditor->show(); | 2990 | mEventEditor->show(); |
2981 | mEventEditor->setGeometry(x,y,w,h); | 2991 | mEventEditor->setGeometry(x,y,w,h); |
2982 | #else | 2992 | #else |
2983 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2993 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2984 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2994 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2985 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2995 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2986 | qApp->processEvents(); | 2996 | qApp->processEvents(); |
2987 | delete mEventEditor; | 2997 | delete mEventEditor; |
2988 | mEventEditor = mDialogManager->getEventEditor(); | 2998 | mEventEditor = mDialogManager->getEventEditor(); |
2989 | topLevelWidget()->setCaption( i18n("") ); | 2999 | topLevelWidget()->setCaption( i18n("") ); |
2990 | } | 3000 | } |
2991 | mEventEditor->showMaximized(); | 3001 | mEventEditor->showMaximized(); |
2992 | #endif | 3002 | #endif |
2993 | } | 3003 | } |
2994 | void CalendarView::showTodoEditor() | 3004 | void CalendarView::showTodoEditor() |
2995 | { | 3005 | { |
2996 | #ifdef DESKTOP_VERSION | 3006 | #ifdef DESKTOP_VERSION |
2997 | int x,y,w,h; | 3007 | int x,y,w,h; |
2998 | x = mTodoEditor->geometry().x(); | 3008 | x = mTodoEditor->geometry().x(); |
2999 | y = mTodoEditor->geometry().y(); | 3009 | y = mTodoEditor->geometry().y(); |
3000 | w = mTodoEditor->width(); | 3010 | w = mTodoEditor->width(); |
3001 | h = mTodoEditor->height(); | 3011 | h = mTodoEditor->height(); |
3002 | mTodoEditor->show(); | 3012 | mTodoEditor->show(); |
3003 | mTodoEditor->setGeometry(x,y,w,h); | 3013 | mTodoEditor->setGeometry(x,y,w,h); |
3004 | #else | 3014 | #else |
3005 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3015 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3006 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3016 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3007 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3017 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3008 | qApp->processEvents(); | 3018 | qApp->processEvents(); |
3009 | delete mTodoEditor; | 3019 | delete mTodoEditor; |
3010 | mTodoEditor = mDialogManager->getTodoEditor(); | 3020 | mTodoEditor = mDialogManager->getTodoEditor(); |
3011 | topLevelWidget()->setCaption( i18n("") ); | 3021 | topLevelWidget()->setCaption( i18n("") ); |
3012 | } | 3022 | } |
3013 | mTodoEditor->showMaximized(); | 3023 | mTodoEditor->showMaximized(); |
3014 | #endif | 3024 | #endif |
3015 | } | 3025 | } |
3016 | 3026 | ||
3017 | void CalendarView::cloneIncidence() | 3027 | void CalendarView::cloneIncidence() |
3018 | { | 3028 | { |
3019 | Incidence *incidence = currentSelection(); | 3029 | Incidence *incidence = currentSelection(); |
3020 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3030 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3021 | if ( incidence ) { | 3031 | if ( incidence ) { |
3022 | cloneIncidence(incidence); | 3032 | cloneIncidence(incidence); |
3023 | } | 3033 | } |
3024 | } | 3034 | } |
3025 | void CalendarView::moveIncidence() | 3035 | void CalendarView::moveIncidence() |
3026 | { | 3036 | { |
3027 | Incidence *incidence = currentSelection(); | 3037 | Incidence *incidence = currentSelection(); |
3028 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3038 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3029 | if ( incidence ) { | 3039 | if ( incidence ) { |
3030 | moveIncidence(incidence); | 3040 | moveIncidence(incidence); |
3031 | } | 3041 | } |
3032 | } | 3042 | } |
3033 | void CalendarView::beamIncidence() | 3043 | void CalendarView::beamIncidence() |
3034 | { | 3044 | { |
3035 | Incidence *incidence = currentSelection(); | 3045 | Incidence *incidence = currentSelection(); |
3036 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3046 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3037 | if ( incidence ) { | 3047 | if ( incidence ) { |
3038 | beamIncidence(incidence); | 3048 | beamIncidence(incidence); |
3039 | } | 3049 | } |
3040 | } | 3050 | } |
3041 | void CalendarView::toggleCancelIncidence() | 3051 | void CalendarView::toggleCancelIncidence() |
3042 | { | 3052 | { |
3043 | Incidence *incidence = currentSelection(); | 3053 | Incidence *incidence = currentSelection(); |
3044 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3054 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3045 | if ( incidence ) { | 3055 | if ( incidence ) { |
3046 | cancelIncidence(incidence); | 3056 | cancelIncidence(incidence); |
3047 | } | 3057 | } |
3048 | } | 3058 | } |
3049 | 3059 | ||
3050 | 3060 | ||
3051 | void CalendarView::cancelIncidence(Incidence * inc ) | 3061 | void CalendarView::cancelIncidence(Incidence * inc ) |
3052 | { | 3062 | { |
3053 | inc->setCancelled( ! inc->cancelled() ); | 3063 | inc->setCancelled( ! inc->cancelled() ); |
3054 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3064 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3055 | updateView(); | 3065 | updateView(); |
3056 | } | 3066 | } |
3057 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3067 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3058 | { | 3068 | { |
3059 | Incidence * newInc = orgInc->clone(); | 3069 | Incidence * newInc = orgInc->clone(); |
3060 | newInc->recreate(); | 3070 | newInc->recreate(); |
3061 | 3071 | ||
3062 | if ( newInc->typeID() == todoID ) { | 3072 | if ( newInc->typeID() == todoID ) { |
3063 | Todo* t = (Todo*) newInc; | 3073 | Todo* t = (Todo*) newInc; |
3064 | bool cloneSub = false; | 3074 | bool cloneSub = false; |
3065 | if ( orgInc->relations().count() ) { | 3075 | if ( orgInc->relations().count() ) { |
3066 | int result = KMessageBox::warningYesNoCancel(this, | 3076 | int result = KMessageBox::warningYesNoCancel(this, |
3067 | 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 ) ), | 3077 | 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 ) ), |
3068 | i18n("Todo has subtodos"), | 3078 | i18n("Todo has subtodos"), |
3069 | i18n("Yes"), | 3079 | i18n("Yes"), |
3070 | i18n("No")); | 3080 | i18n("No")); |
3071 | 3081 | ||
3072 | if ( result == KMessageBox::Cancel ) { | 3082 | if ( result == KMessageBox::Cancel ) { |
3073 | delete t; | 3083 | delete t; |
3074 | return; | 3084 | return; |
3075 | } | 3085 | } |
3076 | if (result == KMessageBox::Yes) cloneSub = true; | 3086 | if (result == KMessageBox::Yes) cloneSub = true; |
3077 | } | 3087 | } |
3078 | showTodoEditor(); | 3088 | showTodoEditor(); |
3079 | mTodoEditor->editTodo( t ); | 3089 | mTodoEditor->editTodo( t ); |
3080 | if ( mTodoEditor->exec() ) { | 3090 | if ( mTodoEditor->exec() ) { |
3081 | if ( cloneSub ) { | 3091 | if ( cloneSub ) { |
3082 | orgInc->cloneRelations( t ); | 3092 | orgInc->cloneRelations( t ); |
3083 | mCalendar->addIncidenceBranch( t ); | 3093 | mCalendar->addIncidenceBranch( t ); |
3084 | updateView(); | 3094 | updateView(); |
3085 | 3095 | ||
3086 | } else { | 3096 | } else { |
3087 | mCalendar->addTodo( t ); | 3097 | mCalendar->addTodo( t ); |
3088 | updateView(); | 3098 | updateView(); |
3089 | } | 3099 | } |
3090 | } else { | 3100 | } else { |
3091 | delete t; | 3101 | delete t; |
3092 | } | 3102 | } |
3093 | } | 3103 | } |
3094 | else { | 3104 | else { |
3095 | Event* e = (Event*) newInc; | 3105 | Event* e = (Event*) newInc; |
3096 | showEventEditor(); | 3106 | showEventEditor(); |
3097 | mEventEditor->editEvent( e ); | 3107 | mEventEditor->editEvent( e ); |
3098 | if ( mEventEditor->exec() ) { | 3108 | if ( mEventEditor->exec() ) { |
3099 | mCalendar->addEvent( e ); | 3109 | mCalendar->addEvent( e ); |
3100 | updateView(); | 3110 | updateView(); |
3101 | } else { | 3111 | } else { |
3102 | delete e; | 3112 | delete e; |
3103 | } | 3113 | } |
3104 | } | 3114 | } |
3105 | setActiveWindow(); | 3115 | setActiveWindow(); |
3106 | } | 3116 | } |
3107 | 3117 | ||
3108 | void CalendarView::newEvent() | 3118 | void CalendarView::newEvent() |
3109 | { | 3119 | { |
3110 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3120 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3111 | KOAgendaView *aView = mViewManager->agendaView(); | 3121 | KOAgendaView *aView = mViewManager->agendaView(); |
3112 | if (aView) { | 3122 | if (aView) { |
3113 | if (aView->selectionStart().isValid()) { | 3123 | if (aView->selectionStart().isValid()) { |
3114 | if (aView->selectedIsAllDay()) { | 3124 | if (aView->selectedIsAllDay()) { |
3115 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3125 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3116 | } else { | 3126 | } else { |
3117 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3127 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3118 | } | 3128 | } |
3119 | return; | 3129 | return; |
3120 | } | 3130 | } |
3121 | } | 3131 | } |
3122 | 3132 | ||
3123 | QDate date = mNavigator->selectedDates().first(); | 3133 | QDate date = mNavigator->selectedDates().first(); |
3124 | QDateTime current = QDateTime::currentDateTime(); | 3134 | QDateTime current = QDateTime::currentDateTime(); |
3125 | if ( date <= current.date() ) { | 3135 | if ( date <= current.date() ) { |
3126 | int hour = current.time().hour() +1; | 3136 | int hour = current.time().hour() +1; |
3127 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3137 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3128 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3138 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3129 | } else | 3139 | } else |
3130 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3140 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3131 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3141 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3132 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3142 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3133 | } | 3143 | } |
3134 | 3144 | ||
3135 | void CalendarView::newEvent(QDateTime fh) | 3145 | void CalendarView::newEvent(QDateTime fh) |
3136 | { | 3146 | { |
3137 | newEvent(fh, | 3147 | newEvent(fh, |
3138 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3148 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3139 | } | 3149 | } |
3140 | 3150 | ||
3141 | void CalendarView::newEvent(QDate dt) | 3151 | void CalendarView::newEvent(QDate dt) |
3142 | { | 3152 | { |
3143 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3153 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3144 | QDateTime(dt, QTime(0,0,0)), true); | 3154 | QDateTime(dt, QTime(0,0,0)), true); |
3145 | } | 3155 | } |
3146 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3156 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3147 | { | 3157 | { |
3148 | newEvent(fromHint, toHint, false); | 3158 | newEvent(fromHint, toHint, false); |
3149 | } | 3159 | } |
3150 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3160 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3151 | { | 3161 | { |
3152 | 3162 | ||
3153 | showEventEditor(); | 3163 | showEventEditor(); |
3154 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3164 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3155 | if ( mFilterView->filtersEnabled() ) { | 3165 | if ( mFilterView->filtersEnabled() ) { |
3156 | CalFilter *filter = mFilterView->selectedFilter(); | 3166 | CalFilter *filter = mFilterView->selectedFilter(); |
3157 | if (filter && filter->showCategories()) { | 3167 | if (filter && filter->showCategories()) { |
3158 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3168 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3159 | } | 3169 | } |
3160 | if ( filter ) | 3170 | if ( filter ) |
3161 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3171 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3162 | } | 3172 | } |
3163 | mEventEditor->exec(); | 3173 | mEventEditor->exec(); |
3164 | setActiveWindow(); | 3174 | setActiveWindow(); |
3165 | } | 3175 | } |
3166 | void CalendarView::todoAdded(Todo * t) | 3176 | void CalendarView::todoAdded(Todo * t) |
3167 | { | 3177 | { |
3168 | 3178 | ||
3169 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3179 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3170 | updateTodoViews(); | 3180 | updateTodoViews(); |
3171 | } | 3181 | } |
3172 | void CalendarView::todoChanged(Todo * t) | 3182 | void CalendarView::todoChanged(Todo * t) |
3173 | { | 3183 | { |
3174 | emit todoModified( t, 4 ); | 3184 | emit todoModified( t, 4 ); |
3175 | // updateTodoViews(); | 3185 | // updateTodoViews(); |
3176 | } | 3186 | } |
3177 | void CalendarView::todoToBeDeleted(Todo *) | 3187 | void CalendarView::todoToBeDeleted(Todo *) |
3178 | { | 3188 | { |
3179 | //qDebug("todoToBeDeleted(Todo *) "); | 3189 | //qDebug("todoToBeDeleted(Todo *) "); |
3180 | updateTodoViews(); | 3190 | updateTodoViews(); |
3181 | } | 3191 | } |
3182 | void CalendarView::todoDeleted() | 3192 | void CalendarView::todoDeleted() |
3183 | { | 3193 | { |
3184 | //qDebug(" todoDeleted()"); | 3194 | //qDebug(" todoDeleted()"); |
3185 | updateTodoViews(); | 3195 | updateTodoViews(); |
3186 | } | 3196 | } |
3187 | 3197 | ||
3188 | 3198 | ||
3189 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3199 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3190 | { | 3200 | { |
3191 | showTodoEditor(); | 3201 | showTodoEditor(); |
3192 | mTodoEditor->newTodo(dt,0,allday); | 3202 | mTodoEditor->newTodo(dt,0,allday); |
3193 | if ( mFilterView->filtersEnabled() ) { | 3203 | if ( mFilterView->filtersEnabled() ) { |
3194 | CalFilter *filter = mFilterView->selectedFilter(); | 3204 | CalFilter *filter = mFilterView->selectedFilter(); |
3195 | if (filter && filter->showCategories()) { | 3205 | if (filter && filter->showCategories()) { |
3196 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3206 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3197 | } | 3207 | } |
3198 | if ( filter ) | 3208 | if ( filter ) |
3199 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3209 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3200 | } | 3210 | } |
3201 | mTodoEditor->exec(); | 3211 | mTodoEditor->exec(); |
3202 | setActiveWindow(); | 3212 | setActiveWindow(); |
3203 | } | 3213 | } |
3204 | 3214 | ||
3205 | void CalendarView::newTodo() | 3215 | void CalendarView::newTodo() |
3206 | { | 3216 | { |
3207 | newTodoDateTime( QDateTime(),true ); | 3217 | newTodoDateTime( QDateTime(),true ); |
3208 | } | 3218 | } |
3209 | 3219 | ||
3210 | void CalendarView::newSubTodo() | 3220 | void CalendarView::newSubTodo() |
3211 | { | 3221 | { |
3212 | Todo *todo = selectedTodo(); | 3222 | Todo *todo = selectedTodo(); |
3213 | if ( todo ) newSubTodo( todo ); | 3223 | if ( todo ) newSubTodo( todo ); |
3214 | } | 3224 | } |
3215 | 3225 | ||
3216 | void CalendarView::newSubTodo(Todo *parentEvent) | 3226 | void CalendarView::newSubTodo(Todo *parentEvent) |
3217 | { | 3227 | { |
3218 | 3228 | ||
3219 | showTodoEditor(); | 3229 | showTodoEditor(); |
3220 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3230 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3221 | mTodoEditor->exec(); | 3231 | mTodoEditor->exec(); |
3222 | setActiveWindow(); | 3232 | setActiveWindow(); |
3223 | } | 3233 | } |
3224 | 3234 | ||
3225 | void CalendarView::newFloatingEvent() | 3235 | void CalendarView::newFloatingEvent() |
3226 | { | 3236 | { |
3227 | DateList tmpList = mNavigator->selectedDates(); | 3237 | DateList tmpList = mNavigator->selectedDates(); |
3228 | QDate date = tmpList.first(); | 3238 | QDate date = tmpList.first(); |
3229 | 3239 | ||
3230 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3240 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3231 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3241 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3232 | } | 3242 | } |
3233 | 3243 | ||
3234 | 3244 | ||
3235 | void CalendarView::editEvent( Event *event ) | 3245 | void CalendarView::editEvent( Event *event ) |
3236 | { | 3246 | { |
3237 | 3247 | ||
3238 | if ( !event ) return; | 3248 | if ( !event ) return; |
3239 | if ( event->isReadOnly() ) { | 3249 | if ( event->isReadOnly() ) { |
3240 | showEvent( event ); | 3250 | showEvent( event ); |
3241 | return; | 3251 | return; |
3242 | } | 3252 | } |
3243 | showEventEditor(); | 3253 | showEventEditor(); |
3244 | mEventEditor->editEvent( event , mFlagEditDescription); | 3254 | mEventEditor->editEvent( event , mFlagEditDescription); |
3245 | mEventEditor->exec(); | 3255 | mEventEditor->exec(); |
3246 | setActiveWindow(); | 3256 | setActiveWindow(); |
3247 | 3257 | ||
3248 | } | 3258 | } |
3249 | void CalendarView::editJournal( Journal *jour ) | 3259 | void CalendarView::editJournal( Journal *jour ) |
3250 | { | 3260 | { |
3251 | if ( !jour ) return; | 3261 | if ( !jour ) return; |
3252 | mDialogManager->hideSearchDialog(); | 3262 | mDialogManager->hideSearchDialog(); |
3253 | mViewManager->showJournalView(); | 3263 | mViewManager->showJournalView(); |
3254 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3264 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3255 | } | 3265 | } |
3256 | void CalendarView::editTodo( Todo *todo ) | 3266 | void CalendarView::editTodo( Todo *todo ) |
3257 | { | 3267 | { |
3258 | if ( !todo ) return; | 3268 | if ( !todo ) return; |
3259 | 3269 | ||
3260 | if ( todo->isReadOnly() ) { | 3270 | if ( todo->isReadOnly() ) { |
3261 | showTodo( todo ); | 3271 | showTodo( todo ); |
3262 | return; | 3272 | return; |
3263 | } | 3273 | } |
3264 | showTodoEditor(); | 3274 | showTodoEditor(); |
3265 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3275 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3266 | mTodoEditor->exec(); | 3276 | mTodoEditor->exec(); |
3267 | setActiveWindow(); | 3277 | setActiveWindow(); |
3268 | 3278 | ||
3269 | } | 3279 | } |
3270 | 3280 | ||
3271 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3281 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3272 | { | 3282 | { |
3273 | if ( !mEventViewerDialog ) { | 3283 | if ( !mEventViewerDialog ) { |
3274 | mEventViewerDialog = new KOEventViewerDialog(0); | 3284 | mEventViewerDialog = new KOEventViewerDialog(0); |
3275 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3285 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3276 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3286 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3277 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3287 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3278 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3288 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3279 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3289 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3280 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3290 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3281 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3291 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3282 | this, SLOT( slotViewerClosed() ) ); | 3292 | this, SLOT( slotViewerClosed() ) ); |
3283 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3293 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3284 | this, SLOT( todoChanged(Todo *) ) ); | 3294 | this, SLOT( todoChanged(Todo *) ) ); |
3285 | mEventViewerDialog->resize( 640, 480 ); | 3295 | mEventViewerDialog->resize( 640, 480 ); |
3286 | 3296 | ||
3287 | } | 3297 | } |
3288 | return mEventViewerDialog; | 3298 | return mEventViewerDialog; |
3289 | } | 3299 | } |
3290 | void CalendarView::showEvent(Event *event) | 3300 | void CalendarView::showEvent(Event *event) |
3291 | { | 3301 | { |
3292 | getEventViewerDialog()->setEvent(event); | 3302 | getEventViewerDialog()->setEvent(event); |
3293 | getEventViewerDialog()->showMe(); | 3303 | getEventViewerDialog()->showMe(); |
3294 | } | 3304 | } |
3295 | 3305 | ||
3296 | void CalendarView::showTodo(Todo *event) | 3306 | void CalendarView::showTodo(Todo *event) |
3297 | { | 3307 | { |
3298 | getEventViewerDialog()->setTodo(event); | 3308 | getEventViewerDialog()->setTodo(event); |
3299 | getEventViewerDialog()->showMe(); | 3309 | getEventViewerDialog()->showMe(); |
3300 | } | 3310 | } |
3301 | void CalendarView::showJournal( Journal *jour ) | 3311 | void CalendarView::showJournal( Journal *jour ) |
3302 | { | 3312 | { |
3303 | getEventViewerDialog()->setJournal(jour); | 3313 | getEventViewerDialog()->setJournal(jour); |
3304 | getEventViewerDialog()->showMe(); | 3314 | getEventViewerDialog()->showMe(); |
3305 | 3315 | ||
3306 | } | 3316 | } |
3307 | // void CalendarView::todoModified (Todo *event, int changed) | 3317 | // void CalendarView::todoModified (Todo *event, int changed) |
3308 | // { | 3318 | // { |
3309 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3319 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3310 | // // kdDebug() << "Todo modified and open" << endl; | 3320 | // // kdDebug() << "Todo modified and open" << endl; |
3311 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3321 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3312 | // // temp->modified (changed); | 3322 | // // temp->modified (changed); |
3313 | 3323 | ||
3314 | // // } | 3324 | // // } |
3315 | 3325 | ||
3316 | // mViewManager->updateView(); | 3326 | // mViewManager->updateView(); |
3317 | // } | 3327 | // } |
3318 | 3328 | ||
3319 | void CalendarView::appointment_show() | 3329 | void CalendarView::appointment_show() |
3320 | { | 3330 | { |
3321 | Event *anEvent = 0; | 3331 | Event *anEvent = 0; |
3322 | 3332 | ||
3323 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3333 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3324 | 3334 | ||
3325 | if (mViewManager->currentView()->isEventView()) { | 3335 | if (mViewManager->currentView()->isEventView()) { |
3326 | if ( incidence && incidence->typeID() == eventID ) { | 3336 | if ( incidence && incidence->typeID() == eventID ) { |
3327 | anEvent = static_cast<Event *>(incidence); | 3337 | anEvent = static_cast<Event *>(incidence); |
3328 | } | 3338 | } |
3329 | } | 3339 | } |
3330 | 3340 | ||
3331 | if (!anEvent) { | 3341 | if (!anEvent) { |
3332 | KNotifyClient::beep(); | 3342 | KNotifyClient::beep(); |
3333 | return; | 3343 | return; |
3334 | } | 3344 | } |
3335 | 3345 | ||
3336 | showEvent(anEvent); | 3346 | showEvent(anEvent); |
3337 | } | 3347 | } |
3338 | 3348 | ||
3339 | void CalendarView::appointment_edit() | 3349 | void CalendarView::appointment_edit() |
3340 | { | 3350 | { |
3341 | Event *anEvent = 0; | 3351 | Event *anEvent = 0; |
3342 | 3352 | ||
3343 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3353 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3344 | 3354 | ||
3345 | if (mViewManager->currentView()->isEventView()) { | 3355 | if (mViewManager->currentView()->isEventView()) { |
3346 | if ( incidence && incidence->typeID() == eventID ) { | 3356 | if ( incidence && incidence->typeID() == eventID ) { |
3347 | anEvent = static_cast<Event *>(incidence); | 3357 | anEvent = static_cast<Event *>(incidence); |
3348 | } | 3358 | } |
3349 | } | 3359 | } |
3350 | 3360 | ||
3351 | if (!anEvent) { | 3361 | if (!anEvent) { |
3352 | KNotifyClient::beep(); | 3362 | KNotifyClient::beep(); |
3353 | return; | 3363 | return; |
3354 | } | 3364 | } |
3355 | 3365 | ||
3356 | editEvent(anEvent); | 3366 | editEvent(anEvent); |
3357 | } | 3367 | } |
3358 | 3368 | ||
3359 | void CalendarView::appointment_delete() | 3369 | void CalendarView::appointment_delete() |
3360 | { | 3370 | { |
3361 | Event *anEvent = 0; | 3371 | Event *anEvent = 0; |
3362 | 3372 | ||
3363 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3373 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3364 | 3374 | ||
3365 | if (mViewManager->currentView()->isEventView()) { | 3375 | if (mViewManager->currentView()->isEventView()) { |
3366 | if ( incidence && incidence->typeID() == eventID ) { | 3376 | if ( incidence && incidence->typeID() == eventID ) { |
3367 | anEvent = static_cast<Event *>(incidence); | 3377 | anEvent = static_cast<Event *>(incidence); |
3368 | } | 3378 | } |
3369 | } | 3379 | } |
3370 | 3380 | ||
3371 | if (!anEvent) { | 3381 | if (!anEvent) { |
3372 | KNotifyClient::beep(); | 3382 | KNotifyClient::beep(); |
3373 | return; | 3383 | return; |
3374 | } | 3384 | } |
3375 | 3385 | ||
3376 | deleteEvent(anEvent); | 3386 | deleteEvent(anEvent); |
3377 | } | 3387 | } |
3378 | 3388 | ||
3379 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3389 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3380 | { | 3390 | { |
3381 | if (!sub) return; | 3391 | if (!sub) return; |
3382 | if ( sub->relatedTo() == parent ) | 3392 | if ( sub->relatedTo() == parent ) |
3383 | return; | 3393 | return; |
3384 | sub->setRelatedTo(parent); | 3394 | sub->setRelatedTo(parent); |
3385 | sub->updated(); | 3395 | sub->updated(); |
3386 | setModified(true); | 3396 | setModified(true); |
3387 | updateView(); | 3397 | updateView(); |
3388 | } | 3398 | } |
3389 | void CalendarView::todo_unsub(Todo *anTodo ) | 3399 | void CalendarView::todo_unsub(Todo *anTodo ) |
3390 | { | 3400 | { |
3391 | todo_resub( 0, anTodo ); | 3401 | todo_resub( 0, anTodo ); |
3392 | } | 3402 | } |
3393 | 3403 | ||
3394 | void CalendarView::deleteTodo(Todo *todo) | 3404 | void CalendarView::deleteTodo(Todo *todo) |
3395 | { | 3405 | { |
3396 | if (!todo) { | 3406 | if (!todo) { |
3397 | KNotifyClient::beep(); | 3407 | KNotifyClient::beep(); |
3398 | return; | 3408 | return; |
3399 | } | 3409 | } |
3400 | if (KOPrefs::instance()->mConfirm) { | 3410 | if (KOPrefs::instance()->mConfirm) { |
3401 | QString text = todo->summary().left(20); | 3411 | QString text = todo->summary().left(20); |
3402 | if (!todo->relations().isEmpty()) { | 3412 | if (!todo->relations().isEmpty()) { |
3403 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3413 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3404 | 3414 | ||
3405 | } | 3415 | } |
3406 | switch (msgItemDelete(text)) { | 3416 | switch (msgItemDelete(text)) { |
3407 | case KMessageBox::Continue: // OK | 3417 | case KMessageBox::Continue: // OK |
3408 | bool deleteT = false; | 3418 | bool deleteT = false; |
3409 | if (!todo->relations().isEmpty()) { | 3419 | if (!todo->relations().isEmpty()) { |
3410 | deleteT = removeCompletedSubTodos( todo ); | 3420 | deleteT = removeCompletedSubTodos( todo ); |
3411 | } | 3421 | } |
3412 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3422 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3413 | if ( !deleteT ) { | 3423 | if ( !deleteT ) { |
3414 | checkExternalId( todo ); | 3424 | checkExternalId( todo ); |
3415 | calendar()->deleteTodo(todo); | 3425 | calendar()->deleteTodo(todo); |
3416 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3426 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3417 | updateView(); | 3427 | updateView(); |
3418 | } | 3428 | } |
3419 | break; | 3429 | break; |
3420 | } // switch | 3430 | } // switch |
3421 | } else { | 3431 | } else { |
3422 | checkExternalId( todo ); | 3432 | checkExternalId( todo ); |
3423 | mCalendar->deleteTodo(todo); | 3433 | mCalendar->deleteTodo(todo); |
3424 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3434 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3425 | updateView(); | 3435 | updateView(); |
3426 | } | 3436 | } |
3427 | 3437 | ||
3428 | emit updateSearchDialog(); | 3438 | emit updateSearchDialog(); |
3429 | } | 3439 | } |
3430 | void CalendarView::deleteJournal(Journal *jour) | 3440 | void CalendarView::deleteJournal(Journal *jour) |
3431 | { | 3441 | { |
3432 | if (!jour) { | 3442 | if (!jour) { |
3433 | KNotifyClient::beep(); | 3443 | KNotifyClient::beep(); |
3434 | return; | 3444 | return; |
3435 | } | 3445 | } |
3436 | if (KOPrefs::instance()->mConfirm) { | 3446 | if (KOPrefs::instance()->mConfirm) { |
3437 | switch (msgItemDelete( jour->description().left(20))) { | 3447 | switch (msgItemDelete( jour->description().left(20))) { |
3438 | case KMessageBox::Continue: // OK | 3448 | case KMessageBox::Continue: // OK |
3439 | calendar()->deleteJournal(jour); | 3449 | calendar()->deleteJournal(jour); |
3440 | updateView(); | 3450 | updateView(); |
3441 | break; | 3451 | break; |
3442 | } // switch | 3452 | } // switch |
3443 | } else { | 3453 | } else { |
3444 | calendar()->deleteJournal(jour);; | 3454 | calendar()->deleteJournal(jour);; |
3445 | updateView(); | 3455 | updateView(); |
3446 | } | 3456 | } |
3447 | emit updateSearchDialog(); | 3457 | emit updateSearchDialog(); |
3448 | } | 3458 | } |
3449 | 3459 | ||
3450 | void CalendarView::deleteEvent(Event *anEvent) | 3460 | void CalendarView::deleteEvent(Event *anEvent) |
3451 | { | 3461 | { |
3452 | if (!anEvent) { | 3462 | if (!anEvent) { |
3453 | KNotifyClient::beep(); | 3463 | KNotifyClient::beep(); |
3454 | return; | 3464 | return; |
3455 | } | 3465 | } |
3456 | 3466 | ||
3457 | if (anEvent->recurrence()->doesRecur()) { | 3467 | if (anEvent->recurrence()->doesRecur()) { |
3458 | QDate itemDate = mViewManager->currentSelectionDate(); | 3468 | QDate itemDate = mViewManager->currentSelectionDate(); |
3459 | int km; | 3469 | int km; |
3460 | if (!itemDate.isValid()) { | 3470 | if (!itemDate.isValid()) { |
3461 | //kdDebug() << "Date Not Valid" << endl; | 3471 | //kdDebug() << "Date Not Valid" << endl; |
3462 | if (KOPrefs::instance()->mConfirm) { | 3472 | if (KOPrefs::instance()->mConfirm) { |
3463 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3473 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3464 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3474 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3465 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3475 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3466 | if ( km == KMessageBox::Continue ) | 3476 | if ( km == KMessageBox::Continue ) |
3467 | km = KMessageBox::No; // No = all below | 3477 | km = KMessageBox::No; // No = all below |
3468 | } else | 3478 | } else |
3469 | km = KMessageBox::No; | 3479 | km = KMessageBox::No; |
3470 | } else { | 3480 | } else { |
3471 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3481 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3472 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3482 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3473 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3483 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3474 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3484 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3475 | i18n("All")); | 3485 | i18n("All")); |
3476 | } | 3486 | } |
3477 | switch(km) { | 3487 | switch(km) { |
3478 | 3488 | ||
3479 | case KMessageBox::No: // Continue // all | 3489 | case KMessageBox::No: // Continue // all |
3480 | //qDebug("KMessageBox::No "); | 3490 | //qDebug("KMessageBox::No "); |
3481 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3491 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3482 | schedule(Scheduler::Cancel,anEvent); | 3492 | schedule(Scheduler::Cancel,anEvent); |
3483 | 3493 | ||
3484 | checkExternalId( anEvent); | 3494 | checkExternalId( anEvent); |
3485 | mCalendar->deleteEvent(anEvent); | 3495 | mCalendar->deleteEvent(anEvent); |
3486 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3496 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3487 | break; | 3497 | break; |
3488 | 3498 | ||
3489 | // Disabled because it does not work | 3499 | // Disabled because it does not work |
3490 | //#if 0 | 3500 | //#if 0 |
3491 | case KMessageBox::Yes: // just this one | 3501 | case KMessageBox::Yes: // just this one |
3492 | //QDate qd = mNavigator->selectedDates().first(); | 3502 | //QDate qd = mNavigator->selectedDates().first(); |
3493 | //if (!qd.isValid()) { | 3503 | //if (!qd.isValid()) { |
3494 | // kdDebug() << "no date selected, or invalid date" << endl; | 3504 | // kdDebug() << "no date selected, or invalid date" << endl; |
3495 | // KNotifyClient::beep(); | 3505 | // KNotifyClient::beep(); |
3496 | // return; | 3506 | // return; |
3497 | //} | 3507 | //} |
3498 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3508 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3499 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3509 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3500 | anEvent->addExDate(itemDate); | 3510 | anEvent->addExDate(itemDate); |
3501 | int duration = anEvent->recurrence()->duration(); | 3511 | int duration = anEvent->recurrence()->duration(); |
3502 | if ( duration > 0 ) { | 3512 | if ( duration > 0 ) { |
3503 | anEvent->recurrence()->setDuration( duration - 1 ); | 3513 | anEvent->recurrence()->setDuration( duration - 1 ); |
3504 | } | 3514 | } |
3505 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3515 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3506 | } | 3516 | } |
3507 | break; | 3517 | break; |
3508 | //#endif | 3518 | //#endif |
3509 | } // switch | 3519 | } // switch |
3510 | } else { | 3520 | } else { |
3511 | if (KOPrefs::instance()->mConfirm) { | 3521 | if (KOPrefs::instance()->mConfirm) { |
3512 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3522 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3513 | i18n("\nAre you sure you want\nto delete this event?"), | 3523 | i18n("\nAre you sure you want\nto delete this event?"), |
3514 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3524 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3515 | case KMessageBox::Continue: // OK | 3525 | case KMessageBox::Continue: // OK |
3516 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3526 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3517 | schedule(Scheduler::Cancel,anEvent); | 3527 | schedule(Scheduler::Cancel,anEvent); |
3518 | checkExternalId( anEvent); | 3528 | checkExternalId( anEvent); |
3519 | mCalendar->deleteEvent(anEvent); | 3529 | mCalendar->deleteEvent(anEvent); |
3520 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3530 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3521 | break; | 3531 | break; |
3522 | } // switch | 3532 | } // switch |
3523 | } else { | 3533 | } else { |
3524 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3534 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3525 | schedule(Scheduler::Cancel,anEvent); | 3535 | schedule(Scheduler::Cancel,anEvent); |
3526 | checkExternalId( anEvent); | 3536 | checkExternalId( anEvent); |
3527 | mCalendar->deleteEvent(anEvent); | 3537 | mCalendar->deleteEvent(anEvent); |
3528 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3538 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3529 | } | 3539 | } |
3530 | } // if-else | 3540 | } // if-else |
3531 | emit updateSearchDialog(); | 3541 | emit updateSearchDialog(); |
3532 | } | 3542 | } |
3533 | 3543 | ||
3534 | bool CalendarView::deleteEvent(const QString &uid) | 3544 | bool CalendarView::deleteEvent(const QString &uid) |
3535 | { | 3545 | { |
3536 | Event *ev = mCalendar->event(uid); | 3546 | Event *ev = mCalendar->event(uid); |
3537 | if (ev) { | 3547 | if (ev) { |
3538 | deleteEvent(ev); | 3548 | deleteEvent(ev); |
3539 | return true; | 3549 | return true; |
3540 | } else { | 3550 | } else { |
3541 | return false; | 3551 | return false; |
3542 | } | 3552 | } |
3543 | } | 3553 | } |
3544 | 3554 | ||
3545 | /*****************************************************************************/ | 3555 | /*****************************************************************************/ |
3546 | 3556 | ||
3547 | void CalendarView::action_mail() | 3557 | void CalendarView::action_mail() |
3548 | { | 3558 | { |
3549 | #ifndef KORG_NOMAIL | 3559 | #ifndef KORG_NOMAIL |
3550 | KOMailClient mailClient; | 3560 | KOMailClient mailClient; |
3551 | 3561 | ||
3552 | Incidence *incidence = currentSelection(); | 3562 | Incidence *incidence = currentSelection(); |
3553 | 3563 | ||
3554 | if (!incidence) { | 3564 | if (!incidence) { |
3555 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3565 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3556 | return; | 3566 | return; |
3557 | } | 3567 | } |
3558 | if(incidence->attendeeCount() == 0 ) { | 3568 | if(incidence->attendeeCount() == 0 ) { |
3559 | KMessageBox::sorry(this, | 3569 | KMessageBox::sorry(this, |
3560 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3570 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3561 | return; | 3571 | return; |
3562 | } | 3572 | } |
3563 | 3573 | ||
3564 | CalendarLocal cal_tmp; | 3574 | CalendarLocal cal_tmp; |
3565 | Event *event = 0; | 3575 | Event *event = 0; |
3566 | Event *ev = 0; | 3576 | Event *ev = 0; |
3567 | if ( incidence && incidence->typeID() == eventID ) { | 3577 | if ( incidence && incidence->typeID() == eventID ) { |
3568 | event = static_cast<Event *>(incidence); | 3578 | event = static_cast<Event *>(incidence); |
3569 | ev = new Event(*event); | 3579 | ev = new Event(*event); |
3570 | cal_tmp.addEvent(ev); | 3580 | cal_tmp.addEvent(ev); |
3571 | } | 3581 | } |
3572 | ICalFormat mForm(); | 3582 | ICalFormat mForm(); |
3573 | QString attachment = mForm.toString( &cal_tmp ); | 3583 | QString attachment = mForm.toString( &cal_tmp ); |
3574 | if (ev) delete(ev); | 3584 | if (ev) delete(ev); |
3575 | 3585 | ||
3576 | mailClient.mailAttendees(currentSelection(), attachment); | 3586 | mailClient.mailAttendees(currentSelection(), attachment); |
3577 | 3587 | ||
3578 | #endif | 3588 | #endif |
3579 | 3589 | ||
3580 | #if 0 | 3590 | #if 0 |
3581 | Event *anEvent = 0; | 3591 | Event *anEvent = 0; |
3582 | if (mViewManager->currentView()->isEventView()) { | 3592 | if (mViewManager->currentView()->isEventView()) { |
3583 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3593 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3584 | } | 3594 | } |
3585 | 3595 | ||
3586 | if (!anEvent) { | 3596 | if (!anEvent) { |
3587 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3597 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3588 | return; | 3598 | return; |
3589 | } | 3599 | } |
3590 | if(anEvent->attendeeCount() == 0 ) { | 3600 | if(anEvent->attendeeCount() == 0 ) { |
3591 | KMessageBox::sorry(this, | 3601 | KMessageBox::sorry(this, |
3592 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3602 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3593 | return; | 3603 | return; |
3594 | } | 3604 | } |
3595 | 3605 | ||
3596 | mailobject.emailEvent(anEvent); | 3606 | mailobject.emailEvent(anEvent); |
3597 | #endif | 3607 | #endif |
3598 | } | 3608 | } |
3599 | 3609 | ||
3600 | 3610 | ||
3601 | void CalendarView::schedule_publish(Incidence *incidence) | 3611 | void CalendarView::schedule_publish(Incidence *incidence) |
3602 | { | 3612 | { |
3603 | Event *event = 0; | 3613 | Event *event = 0; |
3604 | Todo *todo = 0; | 3614 | Todo *todo = 0; |
3605 | 3615 | ||
3606 | if (incidence == 0) { | 3616 | if (incidence == 0) { |
3607 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3617 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3608 | if (incidence == 0) { | 3618 | if (incidence == 0) { |
3609 | incidence = mTodoList->selectedIncidences().first(); | 3619 | incidence = mTodoList->selectedIncidences().first(); |
3610 | } | 3620 | } |
3611 | } | 3621 | } |
3612 | if ( incidence && incidence->typeID() == eventID ) { | 3622 | if ( incidence && incidence->typeID() == eventID ) { |
3613 | event = static_cast<Event *>(incidence); | 3623 | event = static_cast<Event *>(incidence); |
3614 | } else { | 3624 | } else { |
3615 | if ( incidence && incidence->typeID() == todoID ) { | 3625 | if ( incidence && incidence->typeID() == todoID ) { |
3616 | todo = static_cast<Todo *>(incidence); | 3626 | todo = static_cast<Todo *>(incidence); |
3617 | } | 3627 | } |
3618 | } | 3628 | } |
3619 | 3629 | ||
3620 | if (!event && !todo) { | 3630 | if (!event && !todo) { |
3621 | KMessageBox::sorry(this,i18n("No event selected.")); | 3631 | KMessageBox::sorry(this,i18n("No event selected.")); |
3622 | return; | 3632 | return; |
3623 | } | 3633 | } |
3624 | 3634 | ||
3625 | PublishDialog *publishdlg = new PublishDialog(); | 3635 | PublishDialog *publishdlg = new PublishDialog(); |
3626 | if (incidence->attendeeCount()>0) { | 3636 | if (incidence->attendeeCount()>0) { |
3627 | QPtrList<Attendee> attendees = incidence->attendees(); | 3637 | QPtrList<Attendee> attendees = incidence->attendees(); |
3628 | attendees.first(); | 3638 | attendees.first(); |
3629 | while ( attendees.current()!=0 ) { | 3639 | while ( attendees.current()!=0 ) { |
3630 | publishdlg->addAttendee(attendees.current()); | 3640 | publishdlg->addAttendee(attendees.current()); |
3631 | attendees.next(); | 3641 | attendees.next(); |
3632 | } | 3642 | } |
3633 | } | 3643 | } |
3634 | bool send = true; | 3644 | bool send = true; |
3635 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3645 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3636 | if ( publishdlg->exec() != QDialog::Accepted ) | 3646 | if ( publishdlg->exec() != QDialog::Accepted ) |
3637 | send = false; | 3647 | send = false; |
3638 | } | 3648 | } |
3639 | if ( send ) { | 3649 | if ( send ) { |
3640 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3650 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3641 | if ( event ) { | 3651 | if ( event ) { |
3642 | Event *ev = new Event(*event); | 3652 | Event *ev = new Event(*event); |
3643 | ev->registerObserver(0); | 3653 | ev->registerObserver(0); |
3644 | ev->clearAttendees(); | 3654 | ev->clearAttendees(); |
3645 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3655 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3646 | delete(ev); | 3656 | delete(ev); |
3647 | } | 3657 | } |
3648 | } else { | 3658 | } else { |
3649 | if ( todo ) { | 3659 | if ( todo ) { |
3650 | Todo *ev = new Todo(*todo); | 3660 | Todo *ev = new Todo(*todo); |
3651 | ev->registerObserver(0); | 3661 | ev->registerObserver(0); |
3652 | ev->clearAttendees(); | 3662 | ev->clearAttendees(); |
3653 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3663 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3654 | delete(ev); | 3664 | delete(ev); |
3655 | } | 3665 | } |
3656 | } | 3666 | } |
3657 | } | 3667 | } |
3658 | } | 3668 | } |
3659 | delete publishdlg; | 3669 | delete publishdlg; |
3660 | } | 3670 | } |
3661 | 3671 | ||
3662 | void CalendarView::schedule_request(Incidence *incidence) | 3672 | void CalendarView::schedule_request(Incidence *incidence) |
3663 | { | 3673 | { |
3664 | schedule(Scheduler::Request,incidence); | 3674 | schedule(Scheduler::Request,incidence); |
3665 | } | 3675 | } |
3666 | 3676 | ||
3667 | void CalendarView::schedule_refresh(Incidence *incidence) | 3677 | void CalendarView::schedule_refresh(Incidence *incidence) |
3668 | { | 3678 | { |
3669 | schedule(Scheduler::Refresh,incidence); | 3679 | schedule(Scheduler::Refresh,incidence); |
3670 | } | 3680 | } |
3671 | 3681 | ||
3672 | void CalendarView::schedule_cancel(Incidence *incidence) | 3682 | void CalendarView::schedule_cancel(Incidence *incidence) |
3673 | { | 3683 | { |
3674 | schedule(Scheduler::Cancel,incidence); | 3684 | schedule(Scheduler::Cancel,incidence); |
3675 | } | 3685 | } |
3676 | 3686 | ||
3677 | void CalendarView::schedule_add(Incidence *incidence) | 3687 | void CalendarView::schedule_add(Incidence *incidence) |
3678 | { | 3688 | { |
3679 | schedule(Scheduler::Add,incidence); | 3689 | schedule(Scheduler::Add,incidence); |
3680 | } | 3690 | } |
3681 | 3691 | ||
3682 | void CalendarView::schedule_reply(Incidence *incidence) | 3692 | void CalendarView::schedule_reply(Incidence *incidence) |
3683 | { | 3693 | { |
3684 | schedule(Scheduler::Reply,incidence); | 3694 | schedule(Scheduler::Reply,incidence); |
3685 | } | 3695 | } |
3686 | 3696 | ||
3687 | void CalendarView::schedule_counter(Incidence *incidence) | 3697 | void CalendarView::schedule_counter(Incidence *incidence) |
3688 | { | 3698 | { |
3689 | schedule(Scheduler::Counter,incidence); | 3699 | schedule(Scheduler::Counter,incidence); |
3690 | } | 3700 | } |
3691 | 3701 | ||
3692 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3702 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3693 | { | 3703 | { |
3694 | schedule(Scheduler::Declinecounter,incidence); | 3704 | schedule(Scheduler::Declinecounter,incidence); |
3695 | } | 3705 | } |
3696 | 3706 | ||
3697 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3707 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3698 | { | 3708 | { |
3699 | QDateTime start = QDateTime::currentDateTime(); | 3709 | QDateTime start = QDateTime::currentDateTime(); |
3700 | QDateTime end = start.addDays(daysToPublish); | 3710 | QDateTime end = start.addDays(daysToPublish); |
3701 | 3711 | ||
3702 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3712 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3703 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3713 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3704 | 3714 | ||
3705 | 3715 | ||
3706 | PublishDialog *publishdlg = new PublishDialog(); | 3716 | PublishDialog *publishdlg = new PublishDialog(); |
3707 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3717 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3708 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3718 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3709 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3719 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3710 | delete(freebusy); | 3720 | delete(freebusy); |
3711 | } | 3721 | } |
3712 | } | 3722 | } |
3713 | delete publishdlg; | 3723 | delete publishdlg; |
3714 | } | 3724 | } |
3715 | 3725 | ||
3716 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3726 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3717 | { | 3727 | { |
3718 | Event *event = 0; | 3728 | Event *event = 0; |
3719 | Todo *todo = 0; | 3729 | Todo *todo = 0; |
3720 | 3730 | ||
3721 | if (incidence == 0) { | 3731 | if (incidence == 0) { |
3722 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3732 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3723 | if (incidence == 0) { | 3733 | if (incidence == 0) { |
3724 | incidence = mTodoList->selectedIncidences().first(); | 3734 | incidence = mTodoList->selectedIncidences().first(); |
3725 | } | 3735 | } |
3726 | } | 3736 | } |
3727 | if ( incidence && incidence->typeID() == eventID ) { | 3737 | if ( incidence && incidence->typeID() == eventID ) { |
3728 | event = static_cast<Event *>(incidence); | 3738 | event = static_cast<Event *>(incidence); |
3729 | } | 3739 | } |
3730 | if ( incidence && incidence->typeID() == todoID ) { | 3740 | if ( incidence && incidence->typeID() == todoID ) { |
3731 | todo = static_cast<Todo *>(incidence); | 3741 | todo = static_cast<Todo *>(incidence); |
3732 | } | 3742 | } |
3733 | 3743 | ||
3734 | if (!event && !todo) { | 3744 | if (!event && !todo) { |
3735 | KMessageBox::sorry(this,i18n("No event selected.")); | 3745 | KMessageBox::sorry(this,i18n("No event selected.")); |
3736 | return; | 3746 | return; |
3737 | } | 3747 | } |
3738 | 3748 | ||
3739 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3749 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3740 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3750 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3741 | return; | 3751 | return; |
3742 | } | 3752 | } |
3743 | 3753 | ||
3744 | Event *ev = 0; | 3754 | Event *ev = 0; |
3745 | if (event) ev = new Event(*event); | 3755 | if (event) ev = new Event(*event); |
3746 | Todo *to = 0; | 3756 | Todo *to = 0; |
3747 | if (todo) to = new Todo(*todo); | 3757 | if (todo) to = new Todo(*todo); |
3748 | 3758 | ||
3749 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3759 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3750 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3760 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3751 | if (!me) { | 3761 | if (!me) { |
3752 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3762 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3753 | return; | 3763 | return; |
3754 | } | 3764 | } |
3755 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3765 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3756 | StatusDialog *statdlg = new StatusDialog(this); | 3766 | StatusDialog *statdlg = new StatusDialog(this); |
3757 | if (!statdlg->exec()==QDialog::Accepted) return; | 3767 | if (!statdlg->exec()==QDialog::Accepted) return; |
3758 | me->setStatus( statdlg->status() ); | 3768 | me->setStatus( statdlg->status() ); |
3759 | delete(statdlg); | 3769 | delete(statdlg); |
3760 | } | 3770 | } |
3761 | Attendee *menew = new Attendee(*me); | 3771 | Attendee *menew = new Attendee(*me); |
3762 | if (ev) { | 3772 | if (ev) { |
3763 | ev->clearAttendees(); | 3773 | ev->clearAttendees(); |
3764 | ev->addAttendee(menew,false); | 3774 | ev->addAttendee(menew,false); |
3765 | } else { | 3775 | } else { |
3766 | if (to) { | 3776 | if (to) { |
3767 | todo->clearAttendees(); | 3777 | todo->clearAttendees(); |
3768 | todo->addAttendee(menew,false); | 3778 | todo->addAttendee(menew,false); |
3769 | } | 3779 | } |
3770 | } | 3780 | } |
3771 | } | 3781 | } |
3772 | 3782 | ||
3773 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3783 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3774 | if (ev) { | 3784 | if (ev) { |
3775 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3785 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3776 | } else { | 3786 | } else { |
3777 | if (to) { | 3787 | if (to) { |
3778 | if ( !dlg->addMessage(to,method) ) delete(to); | 3788 | if ( !dlg->addMessage(to,method) ) delete(to); |
3779 | } | 3789 | } |
3780 | } | 3790 | } |
3781 | } | 3791 | } |
3782 | 3792 | ||
3783 | void CalendarView::openAddressbook() | 3793 | void CalendarView::openAddressbook() |
3784 | { | 3794 | { |
3785 | KRun::runCommand("kaddressbook"); | 3795 | KRun::runCommand("kaddressbook"); |
3786 | } | 3796 | } |
3787 | 3797 | ||
3788 | void CalendarView::setModified(bool modified) | 3798 | void CalendarView::setModified(bool modified) |
3789 | { | 3799 | { |
3790 | if ( modified ) | 3800 | if ( modified ) |
3791 | emit signalmodified(); | 3801 | emit signalmodified(); |
3792 | if (mModified != modified) { | 3802 | if (mModified != modified) { |
3793 | mModified = modified; | 3803 | mModified = modified; |
3794 | emit modifiedChanged(mModified); | 3804 | emit modifiedChanged(mModified); |
3795 | } | 3805 | } |
3796 | } | 3806 | } |
3797 | 3807 | ||
3798 | bool CalendarView::isReadOnly() | 3808 | bool CalendarView::isReadOnly() |
3799 | { | 3809 | { |
3800 | return mReadOnly; | 3810 | return mReadOnly; |
3801 | } | 3811 | } |
3802 | 3812 | ||
3803 | void CalendarView::setReadOnly(bool readOnly) | 3813 | void CalendarView::setReadOnly(bool readOnly) |
3804 | { | 3814 | { |
3805 | if (mReadOnly != readOnly) { | 3815 | if (mReadOnly != readOnly) { |
3806 | mReadOnly = readOnly; | 3816 | mReadOnly = readOnly; |
3807 | emit readOnlyChanged(mReadOnly); | 3817 | emit readOnlyChanged(mReadOnly); |
3808 | } | 3818 | } |
3809 | } | 3819 | } |
3810 | 3820 | ||
3811 | bool CalendarView::isModified() | 3821 | bool CalendarView::isModified() |
3812 | { | 3822 | { |
3813 | return mModified; | 3823 | return mModified; |
3814 | } | 3824 | } |
3815 | void CalendarView::slotprintSelInc() | 3825 | void CalendarView::slotprintSelInc() |
3816 | { | 3826 | { |
3817 | if ( currentSelection() == 0 ) { | 3827 | if ( currentSelection() == 0 ) { |
3818 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 3828 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
3819 | return; | 3829 | return; |
3820 | } | 3830 | } |
3821 | showIncidence(); | 3831 | showIncidence(); |
3822 | getEventViewerDialog()->print(); | 3832 | getEventViewerDialog()->print(); |
3823 | 3833 | ||
3824 | } | 3834 | } |
3825 | void CalendarView::printSetup() | 3835 | void CalendarView::printSetup() |
3826 | { | 3836 | { |
3827 | #ifndef KORG_NOPRINTER | 3837 | #ifndef KORG_NOPRINTER |
3828 | createPrinter(); | 3838 | createPrinter(); |
3829 | 3839 | ||
3830 | mCalPrinter->setupPrinter(); | 3840 | mCalPrinter->setupPrinter(); |
3831 | #endif | 3841 | #endif |
3832 | } | 3842 | } |
3833 | 3843 | ||
3834 | void CalendarView::print() | 3844 | void CalendarView::print() |
3835 | { | 3845 | { |
3836 | #ifndef KORG_NOPRINTER | 3846 | #ifndef KORG_NOPRINTER |
3837 | createPrinter(); | 3847 | createPrinter(); |
3838 | 3848 | ||
3839 | DateList tmpDateList = mNavigator->selectedDates(); | 3849 | DateList tmpDateList = mNavigator->selectedDates(); |
3840 | mCalPrinter->print(CalPrinter::Month, | 3850 | mCalPrinter->print(CalPrinter::Month, |
3841 | tmpDateList.first(), tmpDateList.last()); | 3851 | tmpDateList.first(), tmpDateList.last()); |
3842 | #endif | 3852 | #endif |
3843 | } | 3853 | } |
3844 | 3854 | ||
3845 | void CalendarView::printPreview() | 3855 | void CalendarView::printPreview() |
3846 | { | 3856 | { |
3847 | #ifndef KORG_NOPRINTER | 3857 | #ifndef KORG_NOPRINTER |
3848 | kdDebug() << "CalendarView::printPreview()" << endl; | 3858 | kdDebug() << "CalendarView::printPreview()" << endl; |
3849 | 3859 | ||
3850 | createPrinter(); | 3860 | createPrinter(); |
3851 | 3861 | ||
3852 | DateList tmpDateList = mNavigator->selectedDates(); | 3862 | DateList tmpDateList = mNavigator->selectedDates(); |
3853 | 3863 | ||
3854 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3864 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3855 | tmpDateList.last()); | 3865 | tmpDateList.last()); |
3856 | #endif | 3866 | #endif |
3857 | } | 3867 | } |
3858 | 3868 | ||
3859 | void CalendarView::exportICalendar() | 3869 | void CalendarView::exportICalendar() |
3860 | { | 3870 | { |
3861 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3871 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3862 | 3872 | ||
3863 | // Force correct extension | 3873 | // Force correct extension |
3864 | if (filename.right(4) != ".ics") filename += ".ics"; | 3874 | if (filename.right(4) != ".ics") filename += ".ics"; |
3865 | 3875 | ||
3866 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3876 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3867 | storage.save(); | 3877 | storage.save(); |
3868 | } | 3878 | } |
3869 | 3879 | ||
3870 | bool CalendarView::exportVCalendar( QString filename ) | 3880 | bool CalendarView::exportVCalendar( QString filename ) |
3871 | { | 3881 | { |
3872 | if (mCalendar->journals().count() > 0) { | 3882 | if (mCalendar->journals().count() > 0) { |
3873 | int result = KMessageBox::warningContinueCancel(this, | 3883 | int result = KMessageBox::warningContinueCancel(this, |
3874 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3884 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3875 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3885 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3876 | true); | 3886 | true); |
3877 | if (result != KMessageBox::Continue) return false; | 3887 | if (result != KMessageBox::Continue) return false; |
3878 | } | 3888 | } |
3879 | 3889 | ||
3880 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3890 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3881 | 3891 | ||
3882 | // Force correct extension | 3892 | // Force correct extension |
3883 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3893 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3884 | 3894 | ||
3885 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3895 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3886 | return storage.save(); | 3896 | return storage.save(); |
3887 | 3897 | ||
3888 | } | 3898 | } |
3889 | 3899 | ||
3890 | void CalendarView::eventUpdated(Incidence *) | 3900 | void CalendarView::eventUpdated(Incidence *) |
3891 | { | 3901 | { |
3892 | setModified(); | 3902 | setModified(); |
3893 | // Don't call updateView here. The code, which has caused the update of the | 3903 | // Don't call updateView here. The code, which has caused the update of the |
3894 | // event is responsible for updating the view. | 3904 | // event is responsible for updating the view. |
3895 | // updateView(); | 3905 | // updateView(); |
3896 | } | 3906 | } |
3897 | 3907 | ||
3898 | void CalendarView::adaptNavigationUnits() | 3908 | void CalendarView::adaptNavigationUnits() |
3899 | { | 3909 | { |
3900 | if (mViewManager->currentView()->isEventView()) { | 3910 | if (mViewManager->currentView()->isEventView()) { |
3901 | int days = mViewManager->currentView()->currentDateCount(); | 3911 | int days = mViewManager->currentView()->currentDateCount(); |
3902 | if (days == 1) { | 3912 | if (days == 1) { |
3903 | emit changeNavStringPrev(i18n("&Previous Day")); | 3913 | emit changeNavStringPrev(i18n("&Previous Day")); |
3904 | emit changeNavStringNext(i18n("&Next Day")); | 3914 | emit changeNavStringNext(i18n("&Next Day")); |
3905 | } else { | 3915 | } else { |
3906 | emit changeNavStringPrev(i18n("&Previous Week")); | 3916 | emit changeNavStringPrev(i18n("&Previous Week")); |
3907 | emit changeNavStringNext(i18n("&Next Week")); | 3917 | emit changeNavStringNext(i18n("&Next Week")); |
3908 | } | 3918 | } |
3909 | } | 3919 | } |
3910 | } | 3920 | } |
3911 | 3921 | ||
3912 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3922 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3913 | { | 3923 | { |
3914 | if ( incidence ) mTodoList->clearSelection(); | 3924 | if ( incidence ) mTodoList->clearSelection(); |
3915 | processIncidenceSelection( incidence ); | 3925 | processIncidenceSelection( incidence ); |
3916 | } | 3926 | } |
3917 | 3927 | ||
3918 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3928 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3919 | { | 3929 | { |
3920 | if ( incidence && mViewManager->currentView() ) { | 3930 | if ( incidence && mViewManager->currentView() ) { |
3921 | mViewManager->currentView()->clearSelection(); | 3931 | mViewManager->currentView()->clearSelection(); |
3922 | } | 3932 | } |
3923 | processIncidenceSelection( incidence ); | 3933 | processIncidenceSelection( incidence ); |
3924 | } | 3934 | } |
3925 | 3935 | ||
3926 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3936 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3927 | { | 3937 | { |
3928 | if ( incidence == mSelectedIncidence ) return; | 3938 | if ( incidence == mSelectedIncidence ) return; |
3929 | 3939 | ||
3930 | mSelectedIncidence = incidence; | 3940 | mSelectedIncidence = incidence; |
3931 | 3941 | ||
3932 | emit incidenceSelected( mSelectedIncidence ); | 3942 | emit incidenceSelected( mSelectedIncidence ); |
3933 | 3943 | ||
3934 | if ( incidence && incidence->typeID() == eventID ) { | 3944 | if ( incidence && incidence->typeID() == eventID ) { |
3935 | Event *event = static_cast<Event *>( incidence ); | 3945 | Event *event = static_cast<Event *>( incidence ); |
3936 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3946 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3937 | emit organizerEventsSelected( true ); | 3947 | emit organizerEventsSelected( true ); |
3938 | } else { | 3948 | } else { |
3939 | emit organizerEventsSelected(false); | 3949 | emit organizerEventsSelected(false); |
3940 | } | 3950 | } |
3941 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3951 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3942 | KOPrefs::instance()->email() ) ) { | 3952 | KOPrefs::instance()->email() ) ) { |
3943 | emit groupEventsSelected( true ); | 3953 | emit groupEventsSelected( true ); |
3944 | } else { | 3954 | } else { |
3945 | emit groupEventsSelected(false); | 3955 | emit groupEventsSelected(false); |
3946 | } | 3956 | } |
3947 | return; | 3957 | return; |
3948 | } else { | 3958 | } else { |
3949 | if ( incidence && incidence->typeID() == todoID ) { | 3959 | if ( incidence && incidence->typeID() == todoID ) { |
3950 | emit todoSelected( true ); | 3960 | emit todoSelected( true ); |
3951 | Todo *event = static_cast<Todo *>( incidence ); | 3961 | Todo *event = static_cast<Todo *>( incidence ); |
3952 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3962 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3953 | emit organizerEventsSelected( true ); | 3963 | emit organizerEventsSelected( true ); |
3954 | } else { | 3964 | } else { |
3955 | emit organizerEventsSelected(false); | 3965 | emit organizerEventsSelected(false); |
3956 | } | 3966 | } |
3957 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3967 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3958 | KOPrefs::instance()->email() ) ) { | 3968 | KOPrefs::instance()->email() ) ) { |
3959 | emit groupEventsSelected( true ); | 3969 | emit groupEventsSelected( true ); |
3960 | } else { | 3970 | } else { |
3961 | emit groupEventsSelected(false); | 3971 | emit groupEventsSelected(false); |
3962 | } | 3972 | } |
3963 | return; | 3973 | return; |
3964 | } else { | 3974 | } else { |
3965 | emit todoSelected( false ); | 3975 | emit todoSelected( false ); |
3966 | emit organizerEventsSelected(false); | 3976 | emit organizerEventsSelected(false); |
3967 | emit groupEventsSelected(false); | 3977 | emit groupEventsSelected(false); |
3968 | } | 3978 | } |
3969 | return; | 3979 | return; |
3970 | } | 3980 | } |
3971 | 3981 | ||
3972 | /* if ( incidence && incidence->typeID() == todoID ) { | 3982 | /* if ( incidence && incidence->typeID() == todoID ) { |
3973 | emit todoSelected( true ); | 3983 | emit todoSelected( true ); |
3974 | } else { | 3984 | } else { |
3975 | emit todoSelected( false ); | 3985 | emit todoSelected( false ); |
3976 | }*/ | 3986 | }*/ |
3977 | } | 3987 | } |
3978 | 3988 | ||
3979 | 3989 | ||
3980 | void CalendarView::checkClipboard() | 3990 | void CalendarView::checkClipboard() |
3981 | { | 3991 | { |
3982 | #ifndef KORG_NODND | 3992 | #ifndef KORG_NODND |
3983 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3993 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3984 | emit pasteEnabled(true); | 3994 | emit pasteEnabled(true); |
3985 | } else { | 3995 | } else { |
3986 | emit pasteEnabled(false); | 3996 | emit pasteEnabled(false); |
3987 | } | 3997 | } |
3988 | #endif | 3998 | #endif |
3989 | } | 3999 | } |
3990 | 4000 | ||
3991 | void CalendarView::showDates(const DateList &selectedDates) | 4001 | void CalendarView::showDates(const DateList &selectedDates) |
3992 | { | 4002 | { |
3993 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4003 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3994 | 4004 | ||
3995 | 4005 | ||
3996 | if ( !mBlockShowDates ) { | 4006 | if ( !mBlockShowDates ) { |
3997 | if ( mViewManager->currentView() ) { | 4007 | if ( mViewManager->currentView() ) { |
3998 | updateView( selectedDates.first(), selectedDates.last() ); | 4008 | updateView( selectedDates.first(), selectedDates.last() ); |
3999 | } else { | 4009 | } else { |
4000 | mViewManager->showAgendaView(); | 4010 | mViewManager->showAgendaView(); |
4001 | } | 4011 | } |
4002 | } | 4012 | } |
4003 | 4013 | ||
4004 | QDate date = selectedDates.first(); | 4014 | QDate date = selectedDates.first(); |
4005 | if ( ! date.isValid() ) { | 4015 | if ( ! date.isValid() ) { |
4006 | topLevelWidget()->setCaption(""); | 4016 | topLevelWidget()->setCaption(""); |
4007 | return; | 4017 | return; |
4008 | } | 4018 | } |
4009 | 4019 | ||
4010 | QString selDates; | 4020 | QString selDates; |
4011 | selDates = KGlobal::locale()->formatDate( date, true); | 4021 | selDates = KGlobal::locale()->formatDate( date, true); |
4012 | if (selectedDates.first() < selectedDates.last() ) | 4022 | if (selectedDates.first() < selectedDates.last() ) |
4013 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4023 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4014 | else { | 4024 | else { |
4015 | QString addString; | 4025 | QString addString; |
4016 | if ( date == QDateTime::currentDateTime().date() ) | 4026 | if ( date == QDateTime::currentDateTime().date() ) |
4017 | addString = i18n("Today"); | 4027 | addString = i18n("Today"); |
4018 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4028 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4019 | addString = i18n("Tomorrow"); | 4029 | addString = i18n("Tomorrow"); |
4020 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4030 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4021 | addString = i18n("Yesterday"); | 4031 | addString = i18n("Yesterday"); |
4022 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4032 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4023 | addString = i18n("Day before yesterday"); | 4033 | addString = i18n("Day before yesterday"); |
4024 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4034 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4025 | addString = i18n("Day after tomorrow"); | 4035 | addString = i18n("Day after tomorrow"); |
4026 | if ( !addString.isEmpty() ) { | 4036 | if ( !addString.isEmpty() ) { |
4027 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4037 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4028 | return; | 4038 | return; |
4029 | } | 4039 | } |
4030 | } | 4040 | } |
4031 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4041 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4032 | 4042 | ||
4033 | } | 4043 | } |
4034 | 4044 | ||
4035 | QPtrList<CalFilter> CalendarView::filters() | 4045 | QPtrList<CalFilter> CalendarView::filters() |
4036 | { | 4046 | { |
4037 | return mFilters; | 4047 | return mFilters; |
4038 | 4048 | ||
4039 | } | 4049 | } |
4040 | void CalendarView::editFilters() | 4050 | void CalendarView::editFilters() |
4041 | { | 4051 | { |
4042 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4052 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4043 | 4053 | ||
4044 | CalFilter *filter = mFilters.first(); | 4054 | CalFilter *filter = mFilters.first(); |
4045 | while(filter) { | 4055 | while(filter) { |
4046 | filter = mFilters.next(); | 4056 | filter = mFilters.next(); |
4047 | } | 4057 | } |
4048 | 4058 | ||
4049 | mDialogManager->showFilterEditDialog(&mFilters); | 4059 | mDialogManager->showFilterEditDialog(&mFilters); |
4050 | updateFilter(); | 4060 | updateFilter(); |
4051 | } | 4061 | } |
4052 | void CalendarView::toggleFilter() | 4062 | void CalendarView::toggleFilter() |
4053 | { | 4063 | { |
4054 | if ( mLeftFrame->isHidden() ) { | 4064 | if ( mLeftFrame->isHidden() ) { |
4055 | toggleExpand(); | 4065 | toggleExpand(); |
4056 | showFilter( true ); | 4066 | showFilter( true ); |
4057 | } else | 4067 | } else |
4058 | showFilter(! mCalEditView->isVisible()); | 4068 | showFilter(! mCalEditView->isVisible()); |
4059 | } | 4069 | } |
4060 | 4070 | ||
4061 | KOFilterView *CalendarView::filterView() | 4071 | KOFilterView *CalendarView::filterView() |
4062 | { | 4072 | { |
4063 | return mFilterView; | 4073 | return mFilterView; |
4064 | } | 4074 | } |
4065 | void CalendarView::selectFilter( int fil ) | 4075 | void CalendarView::selectFilter( int fil ) |
4066 | { | 4076 | { |
4067 | mFilterView->setSelectedFilter( fil ); | 4077 | mFilterView->setSelectedFilter( fil ); |
4068 | updateUnmanagedViews(); | 4078 | updateUnmanagedViews(); |
4069 | } | 4079 | } |
4070 | void CalendarView::showFilter(bool visible) | 4080 | void CalendarView::showFilter(bool visible) |
4071 | { | 4081 | { |
4072 | #if 1 | 4082 | #if 1 |
4073 | if (visible) { | 4083 | if (visible) { |
4074 | mCalEditView->readConfig(); | 4084 | mCalEditView->readConfig(); |
4075 | mCalEditView->show(); | 4085 | mCalEditView->show(); |
4076 | QValueList<int> sizes; | 4086 | QValueList<int> sizes; |
4077 | sizes = mLeftFrame->sizes(); | 4087 | sizes = mLeftFrame->sizes(); |
4078 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4088 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4079 | sizes.clear(); | 4089 | sizes.clear(); |
4080 | sizes << 100; | 4090 | sizes << 100; |
4081 | sizes << 0; | 4091 | sizes << 0; |
4082 | sizes << 0; | 4092 | sizes << 0; |
4083 | sizes << 100; | 4093 | sizes << 100; |
4084 | mLeftFrame->setSizes(sizes); | 4094 | mLeftFrame->setSizes(sizes); |
4085 | } | 4095 | } |
4086 | #if 0 | 4096 | #if 0 |
4087 | sizes = mLeftFrame->sizes(); | 4097 | sizes = mLeftFrame->sizes(); |
4088 | int ccc = 0; | 4098 | int ccc = 0; |
4089 | while ( ccc < sizes.count()) { | 4099 | while ( ccc < sizes.count()) { |
4090 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4100 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4091 | ++ccc; | 4101 | ++ccc; |
4092 | } | 4102 | } |
4093 | #endif | 4103 | #endif |
4094 | 4104 | ||
4095 | } | 4105 | } |
4096 | else { | 4106 | else { |
4097 | mCalEditView->hide(); | 4107 | mCalEditView->hide(); |
4098 | } | 4108 | } |
4099 | #else | 4109 | #else |
4100 | if (visible) mFilterView->show(); | 4110 | if (visible) mFilterView->show(); |
4101 | else mFilterView->hide(); | 4111 | else mFilterView->hide(); |
4102 | #endif | 4112 | #endif |
4103 | } | 4113 | } |
4104 | void CalendarView::toggleFilerEnabled( ) | 4114 | void CalendarView::toggleFilerEnabled( ) |
4105 | { | 4115 | { |
4106 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4116 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4107 | if ( !mFilterView->filtersEnabled() ) | 4117 | if ( !mFilterView->filtersEnabled() ) |
4108 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4118 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4109 | updateUnmanagedViews(); | 4119 | updateUnmanagedViews(); |
4110 | 4120 | ||
4111 | } | 4121 | } |
4112 | void CalendarView::updateFilter() | 4122 | void CalendarView::updateFilter() |
4113 | { | 4123 | { |
4114 | CalFilter *filter = mFilterView->selectedFilter(); | 4124 | CalFilter *filter = mFilterView->selectedFilter(); |
4115 | if (filter) { | 4125 | if (filter) { |
4116 | QString mess; | 4126 | QString mess; |
4117 | if (mFilterView->filtersEnabled()) { | 4127 | if (mFilterView->filtersEnabled()) { |
4118 | mess = i18n("Filter selected: ")+filter->name(); | 4128 | mess = i18n("Filter selected: ")+filter->name(); |
4119 | filter->setEnabled(true); | 4129 | filter->setEnabled(true); |
4120 | } | 4130 | } |
4121 | else filter->setEnabled(false); | 4131 | else filter->setEnabled(false); |
4122 | mCalendar->setFilter(filter); | 4132 | mCalendar->setFilter(filter); |
4123 | updateView(); | 4133 | updateView(); |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index c89bbf7..f7e5366 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,655 +1,657 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #include <qscrollbar.h> | 33 | #include <qscrollbar.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qtopia/ir.h> | 35 | #include <qtopia/ir.h> |
36 | #else | 36 | #else |
37 | #define Ir char | 37 | #define Ir char |
38 | #endif | 38 | #endif |
39 | #include <libkcal/calendar.h> | 39 | #include <libkcal/calendar.h> |
40 | #include <libkcal/scheduler.h> | 40 | #include <libkcal/scheduler.h> |
41 | #include <libkcal/calendarresources.h> | 41 | #include <libkcal/calendarresources.h> |
42 | #include <libkcal/resourcecalendar.h> | 42 | #include <libkcal/resourcecalendar.h> |
43 | #include <KDGanttMinimizeSplitter.h> | 43 | #include <KDGanttMinimizeSplitter.h> |
44 | 44 | ||
45 | #include <korganizer/calendarviewbase.h> | 45 | #include <korganizer/calendarviewbase.h> |
46 | 46 | ||
47 | #include <ksyncmanager.h> | 47 | #include <ksyncmanager.h> |
48 | //#include <koprefs.h> | 48 | //#include <koprefs.h> |
49 | 49 | ||
50 | class QWidgetStack; | 50 | class QWidgetStack; |
51 | class QSplitter; | 51 | class QSplitter; |
52 | class KopiCalendarFile; | 52 | class KopiCalendarFile; |
53 | class CalPrinter; | 53 | class CalPrinter; |
54 | class KOFilterView; | 54 | class KOFilterView; |
55 | class KOCalEditView; | 55 | class KOCalEditView; |
56 | class KOViewManager; | 56 | class KOViewManager; |
57 | class KODialogManager; | 57 | class KODialogManager; |
58 | class KOTodoView; | 58 | class KOTodoView; |
59 | class KDateNavigator; | 59 | class KDateNavigator; |
60 | class DateNavigatorContainer; | 60 | class DateNavigatorContainer; |
61 | class DateNavigator; | 61 | class DateNavigator; |
62 | class KOIncidenceEditor; | 62 | class KOIncidenceEditor; |
63 | class KDatePicker; | 63 | class KDatePicker; |
64 | class ResourceView; | 64 | class ResourceView; |
65 | class KOEventEditor; | 65 | class KOEventEditor; |
66 | class KOTodoEditor ; | 66 | class KOTodoEditor ; |
67 | class KOEventViewerDialog; | 67 | class KOEventViewerDialog; |
68 | class KOBeamPrefs; | 68 | class KOBeamPrefs; |
69 | class KSyncProfile; | 69 | class KSyncProfile; |
70 | class AlarmDialog; | 70 | class AlarmDialog; |
71 | class KCal::Attendee; | 71 | class KCal::Attendee; |
72 | 72 | ||
73 | namespace KCal { class FileStorage; } | 73 | namespace KCal { class FileStorage; } |
74 | 74 | ||
75 | using namespace KCal; | 75 | using namespace KCal; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | This is the main calendar widget. It provides the different vies on t he | 78 | This is the main calendar widget. It provides the different vies on t he |
79 | calendar data as well as the date navigator. It also handles synchronisation | 79 | calendar data as well as the date navigator. It also handles synchronisation |
80 | of the different views and controls the different dialogs like preferences, | 80 | of the different views and controls the different dialogs like preferences, |
81 | event editor, search dialog etc. | 81 | event editor, search dialog etc. |
82 | 82 | ||
83 | @short main calendar view widget | 83 | @short main calendar view widget |
84 | @author Cornelius Schumacher | 84 | @author Cornelius Schumacher |
85 | */ | 85 | */ |
86 | 86 | ||
87 | #include <qtextbrowser.h> | 87 | #include <qtextbrowser.h> |
88 | #include <qtextcodec.h> | 88 | #include <qtextcodec.h> |
89 | 89 | ||
90 | class MissedAlarmTextBrowser : public QTextBrowser { | 90 | class MissedAlarmTextBrowser : public QTextBrowser { |
91 | Q_OBJECT | 91 | Q_OBJECT |
92 | public: | 92 | public: |
93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); | 93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); |
94 | ~MissedAlarmTextBrowser(); | 94 | ~MissedAlarmTextBrowser(); |
95 | void setSource(const QString & n); | 95 | void setSource(const QString & n); |
96 | 96 | ||
97 | private: | 97 | private: |
98 | Incidence * getNextInc(QDateTime start ); | 98 | Incidence * getNextInc(QDateTime start ); |
99 | QPtrList<Incidence> mAlarms; | 99 | QPtrList<Incidence> mAlarms; |
100 | signals: | 100 | signals: |
101 | void showIncidence( QString uid); | 101 | void showIncidence( QString uid); |
102 | }; | 102 | }; |
103 | 103 | ||
104 | 104 | ||
105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
106 | { | 106 | { |
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | public: | 108 | public: |
109 | /** | 109 | /** |
110 | Constructs a new calendar view widget. | 110 | Constructs a new calendar view widget. |
111 | 111 | ||
112 | @param calendar calendar document | 112 | @param calendar calendar document |
113 | @param parent parent window | 113 | @param parent parent window |
114 | @param name Qt internal widget object name | 114 | @param name Qt internal widget object name |
115 | */ | 115 | */ |
116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
117 | const char *name = 0 ); | 117 | const char *name = 0 ); |
118 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 118 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
119 | const char *name = 0 ); | 119 | const char *name = 0 ); |
120 | virtual ~CalendarView(); | 120 | virtual ~CalendarView(); |
121 | 121 | ||
122 | Calendar *calendar() { return mCalendar; } | 122 | Calendar *calendar() { return mCalendar; } |
123 | 123 | ||
124 | KOViewManager *viewManager(); | 124 | KOViewManager *viewManager(); |
125 | KODialogManager *dialogManager(); | 125 | KODialogManager *dialogManager(); |
126 | 126 | ||
127 | QDate startDate(); | 127 | QDate startDate(); |
128 | QDate endDate(); | 128 | QDate endDate(); |
129 | 129 | ||
130 | QWidgetStack *viewStack(); | 130 | QWidgetStack *viewStack(); |
131 | QWidget *leftFrame(); | 131 | QWidget *leftFrame(); |
132 | 132 | ||
133 | DateNavigator *dateNavigator(); | 133 | DateNavigator *dateNavigator(); |
134 | KDateNavigator *dateNavigatorWidget(); | 134 | KDateNavigator *dateNavigatorWidget(); |
135 | 135 | ||
136 | void addView(KOrg::BaseView *); | 136 | void addView(KOrg::BaseView *); |
137 | void showView(KOrg::BaseView *); | 137 | void showView(KOrg::BaseView *); |
138 | KOEventViewerDialog* getEventViewerDialog(); | 138 | KOEventViewerDialog* getEventViewerDialog(); |
139 | Incidence *currentSelection(); | 139 | Incidence *currentSelection(); |
140 | 140 | ||
141 | signals: | 141 | signals: |
142 | void save (); | 142 | void save (); |
143 | void saveStopTimer (); | 143 | void saveStopTimer (); |
144 | void tempDisableBR(bool); | 144 | void tempDisableBR(bool); |
145 | /** This todo has been modified */ | 145 | /** This todo has been modified */ |
146 | void todoModified(Todo *, int); | 146 | void todoModified(Todo *, int); |
147 | 147 | ||
148 | /** when change is made to options dialog, the topwidget will catch this | 148 | /** when change is made to options dialog, the topwidget will catch this |
149 | * and emit this signal which notifies all widgets which have registered | 149 | * and emit this signal which notifies all widgets which have registered |
150 | * for notification to update their settings. */ | 150 | * for notification to update their settings. */ |
151 | void configChanged(); | 151 | void configChanged(); |
152 | /** emitted when the topwidget is closing down, so that any attached | 152 | /** emitted when the topwidget is closing down, so that any attached |
153 | child windows can also close. */ | 153 | child windows can also close. */ |
154 | void closingDown(); | 154 | void closingDown(); |
155 | /** emitted right before we die */ | 155 | /** emitted right before we die */ |
156 | void closed(QWidget *); | 156 | void closed(QWidget *); |
157 | 157 | ||
158 | /** Emitted when state of modified flag changes */ | 158 | /** Emitted when state of modified flag changes */ |
159 | void modifiedChanged(bool); | 159 | void modifiedChanged(bool); |
160 | void signalmodified(); | 160 | void signalmodified(); |
161 | 161 | ||
162 | /** Emitted when state of read-only flag changes */ | 162 | /** Emitted when state of read-only flag changes */ |
163 | void readOnlyChanged(bool); | 163 | void readOnlyChanged(bool); |
164 | 164 | ||
165 | /** Emitted when the unit of navigation changes */ | 165 | /** Emitted when the unit of navigation changes */ |
166 | void changeNavStringPrev(const QString &); | 166 | void changeNavStringPrev(const QString &); |
167 | void changeNavStringNext(const QString &); | 167 | void changeNavStringNext(const QString &); |
168 | 168 | ||
169 | /** Emitted when state of events selection has changed and user is organizer*/ | 169 | /** Emitted when state of events selection has changed and user is organizer*/ |
170 | void organizerEventsSelected(bool); | 170 | void organizerEventsSelected(bool); |
171 | /** Emitted when state of events selection has changed and user is attendee*/ | 171 | /** Emitted when state of events selection has changed and user is attendee*/ |
172 | void groupEventsSelected(bool); | 172 | void groupEventsSelected(bool); |
173 | /** | 173 | /** |
174 | Emitted when an incidence gets selected. If the selection is cleared the | 174 | Emitted when an incidence gets selected. If the selection is cleared the |
175 | signal is emitted with 0 as argument. | 175 | signal is emitted with 0 as argument. |
176 | */ | 176 | */ |
177 | void incidenceSelected( Incidence * ); | 177 | void incidenceSelected( Incidence * ); |
178 | /** Emitted, when a todoitem is selected or deselected. */ | 178 | /** Emitted, when a todoitem is selected or deselected. */ |
179 | void todoSelected( bool ); | 179 | void todoSelected( bool ); |
180 | 180 | ||
181 | /** | 181 | /** |
182 | Emitted, when clipboard content changes. Parameter indicates if paste | 182 | Emitted, when clipboard content changes. Parameter indicates if paste |
183 | is possible or not. | 183 | is possible or not. |
184 | */ | 184 | */ |
185 | void pasteEnabled(bool); | 185 | void pasteEnabled(bool); |
186 | 186 | ||
187 | /** Emitted, when the number of incoming messages has changed. */ | 187 | /** Emitted, when the number of incoming messages has changed. */ |
188 | void numIncomingChanged(int); | 188 | void numIncomingChanged(int); |
189 | 189 | ||
190 | /** Emitted, when the number of outgoing messages has changed. */ | 190 | /** Emitted, when the number of outgoing messages has changed. */ |
191 | void numOutgoingChanged(int); | 191 | void numOutgoingChanged(int); |
192 | 192 | ||
193 | /** Send status message, which can e.g. be displayed in the status bar. */ | 193 | /** Send status message, which can e.g. be displayed in the status bar. */ |
194 | void statusMessage(const QString &); | 194 | void statusMessage(const QString &); |
195 | 195 | ||
196 | void calendarViewExpanded( bool ); | 196 | void calendarViewExpanded( bool ); |
197 | void updateSearchDialog(); | 197 | void updateSearchDialog(); |
198 | void filtersUpdated(); | 198 | void filtersUpdated(); |
199 | 199 | ||
200 | 200 | ||
201 | public slots: | 201 | public slots: |
202 | void checkAlarms(); | 202 | void checkAlarms(); |
203 | void slotprintSelInc(); | 203 | void slotprintSelInc(); |
204 | void showNextAlarms(); | 204 | void showNextAlarms(); |
205 | void showOpenError(); | 205 | void showOpenError(); |
206 | void watchSavedFile(); | 206 | void watchSavedFile(); |
207 | void recheckTimerAlarm(); | 207 | void recheckTimerAlarm(); |
208 | void checkNextTimerAlarm(); | 208 | void checkNextTimerAlarm(); |
209 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 209 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
210 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 210 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
211 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 211 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
212 | 212 | ||
213 | /** options dialog made a changed to the configuration. we catch this | 213 | /** options dialog made a changed to the configuration. we catch this |
214 | * and notify all widgets which need to update their configuration. */ | 214 | * and notify all widgets which need to update their configuration. */ |
215 | void updateConfig(); | 215 | void updateConfig(); |
216 | 216 | ||
217 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 217 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
218 | const QStringList& anniversaryList, const QStringList& realNameList, | 218 | const QStringList& anniversaryList, const QStringList& realNameList, |
219 | const QStringList& emailList, const QStringList& assembledNameList, | 219 | const QStringList& emailList, const QStringList& assembledNameList, |
220 | const QStringList& uidList); | 220 | const QStringList& uidList); |
221 | 221 | ||
222 | /** | 222 | /** |
223 | Load calendar from file \a filename. If \a merge is true, load | 223 | Load calendar from file \a filename. If \a merge is true, load |
224 | calendar into existing one, if it is false, clear calendar, before | 224 | calendar into existing one, if it is false, clear calendar, before |
225 | loading. Return true, if calendar could be successfully loaded. | 225 | loading. Return true, if calendar could be successfully loaded. |
226 | */ | 226 | */ |
227 | bool openCalendar(QString filename, bool merge=false); | 227 | bool openCalendar(QString filename, bool merge=false); |
228 | bool loadCalendars(); | 228 | bool loadCalendars(); |
229 | bool saveCalendars(); | 229 | bool saveCalendars(); |
230 | bool restoreCalendarSettings(); | 230 | bool restoreCalendarSettings(); |
231 | bool addCalendar( KopiCalendarFile * ); | 231 | bool addCalendar( KopiCalendarFile * ); |
232 | void addCalendarId( int id ); | 232 | void addCalendarId( int id ); |
233 | bool syncCalendar(QString filename,int mode = 0 ); | 233 | bool syncCalendar(QString filename,int mode = 0 ); |
234 | 234 | ||
235 | /** | 235 | /** |
236 | Save calendar data to file. Return true if calendar could be | 236 | Save calendar data to file. Return true if calendar could be |
237 | successfully saved. | 237 | successfully saved. |
238 | */ | 238 | */ |
239 | bool saveCalendar(QString filename); | 239 | bool saveCalendar(QString filename); |
240 | 240 | ||
241 | /** | 241 | /** |
242 | Close calendar. Clear calendar data and reset views to display an empty | 242 | Close calendar. Clear calendar data and reset views to display an empty |
243 | calendar. | 243 | calendar. |
244 | */ | 244 | */ |
245 | void closeCalendar(); | 245 | void closeCalendar(); |
246 | 246 | ||
247 | /** Archive old events of calendar */ | 247 | /** Archive old events of calendar */ |
248 | void archiveCalendar(); | 248 | void archiveCalendar(); |
249 | 249 | ||
250 | void showIncidence(); | 250 | void showIncidence(); |
251 | void editIncidence(); | 251 | void editIncidence(); |
252 | void editIncidenceDescription(); | 252 | void editIncidenceDescription(); |
253 | void deleteIncidence(); | 253 | void deleteIncidence(); |
254 | void cloneIncidence(); | 254 | void cloneIncidence(); |
255 | void moveIncidence(); | 255 | void moveIncidence(); |
256 | void beamIncidence(); | 256 | void beamIncidence(); |
257 | void toggleCancelIncidence(); | 257 | void toggleCancelIncidence(); |
258 | 258 | ||
259 | /** create an editeventwin with supplied date/time, and if bool is true, | 259 | /** create an editeventwin with supplied date/time, and if bool is true, |
260 | * make the event take all day. */ | 260 | * make the event take all day. */ |
261 | void newEvent(QDateTime, QDateTime, bool allDay ); | 261 | void newEvent(QDateTime, QDateTime, bool allDay ); |
262 | void newEvent(QDateTime, QDateTime); | 262 | void newEvent(QDateTime, QDateTime); |
263 | void newEvent(QDateTime fh); | 263 | void newEvent(QDateTime fh); |
264 | void newEvent(QDate dt); | 264 | void newEvent(QDate dt); |
265 | /** create new event without having a date hint. Takes current date as | 265 | /** create new event without having a date hint. Takes current date as |
266 | default hint. */ | 266 | default hint. */ |
267 | void newEvent(); | 267 | void newEvent(); |
268 | void newFloatingEvent(); | 268 | void newFloatingEvent(); |
269 | 269 | ||
270 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 270 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
271 | void showIncidence(Incidence *); | 271 | void showIncidence(Incidence *); |
272 | void showIncidence(QString uid); | 272 | void showIncidence(QString uid); |
273 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 273 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
274 | void editIncidence(Incidence *); | 274 | void editIncidence(Incidence *); |
275 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 275 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
276 | void deleteIncidence(Incidence *); | 276 | void deleteIncidence(Incidence *); |
277 | void cloneIncidence(Incidence *); | 277 | void cloneIncidence(Incidence *); |
278 | void cancelIncidence(Incidence *); | 278 | void cancelIncidence(Incidence *); |
279 | /** Create an editor for the supplied event. */ | 279 | /** Create an editor for the supplied event. */ |
280 | void editEvent(Event *); | 280 | void editEvent(Event *); |
281 | /** Delete the supplied event. */ | 281 | /** Delete the supplied event. */ |
282 | void deleteEvent(Event *); | 282 | void deleteEvent(Event *); |
283 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 283 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
284 | found. */ | 284 | found. */ |
285 | bool deleteEvent(const QString &uid); | 285 | bool deleteEvent(const QString &uid); |
286 | /** Create a read-only viewer dialog for the supplied event. */ | 286 | /** Create a read-only viewer dialog for the supplied event. */ |
287 | void showEvent(Event *); | 287 | void showEvent(Event *); |
288 | 288 | ||
289 | void editJournal(Journal *); | 289 | void editJournal(Journal *); |
290 | void showJournal(Journal *); | 290 | void showJournal(Journal *); |
291 | void deleteJournal(Journal *); | 291 | void deleteJournal(Journal *); |
292 | /** Create an editor dialog for a todo */ | 292 | /** Create an editor dialog for a todo */ |
293 | void editTodo(Todo *); | 293 | void editTodo(Todo *); |
294 | /** Create a read-only viewer dialog for the supplied todo */ | 294 | /** Create a read-only viewer dialog for the supplied todo */ |
295 | void showTodo(Todo *); | 295 | void showTodo(Todo *); |
296 | /** create new todo */ | 296 | /** create new todo */ |
297 | void newTodo(); | 297 | void newTodo(); |
298 | void newTodoDateTime(QDateTime, bool allday); | 298 | void newTodoDateTime(QDateTime, bool allday); |
299 | /** create new todo with a parent todo */ | 299 | /** create new todo with a parent todo */ |
300 | void newSubTodo(); | 300 | void newSubTodo(); |
301 | /** create new todo with a parent todo */ | 301 | /** create new todo with a parent todo */ |
302 | void newSubTodo(Todo *); | 302 | void newSubTodo(Todo *); |
303 | /** Delete todo */ | 303 | /** Delete todo */ |
304 | void deleteTodo(Todo *); | 304 | void deleteTodo(Todo *); |
305 | 305 | ||
306 | 306 | ||
307 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 307 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
308 | * emitted as result. */ | 308 | * emitted as result. */ |
309 | void checkClipboard(); | 309 | void checkClipboard(); |
310 | 310 | ||
311 | /** using the KConfig associated with the kapp variable, read in the | 311 | /** using the KConfig associated with the kapp variable, read in the |
312 | * settings from the config file. | 312 | * settings from the config file. |
313 | */ | 313 | */ |
314 | void readSettings(); | 314 | void readSettings(); |
315 | 315 | ||
316 | /** write current state to config file. */ | 316 | /** write current state to config file. */ |
317 | void writeSettings(); | 317 | void writeSettings(); |
318 | 318 | ||
319 | /** read settings for calendar filters */ | 319 | /** read settings for calendar filters */ |
320 | void readFilterSettings(KConfig *config); | 320 | void readFilterSettings(KConfig *config); |
321 | 321 | ||
322 | /** write settings for calendar filters */ | 322 | /** write settings for calendar filters */ |
323 | void writeFilterSettings(KConfig *config); | 323 | void writeFilterSettings(KConfig *config); |
324 | 324 | ||
325 | /** passes on the message that an event has changed to the currently | 325 | /** passes on the message that an event has changed to the currently |
326 | * activated view so that it can make appropriate display changes. */ | 326 | * activated view so that it can make appropriate display changes. */ |
327 | void changeEventDisplay(Event *, int); | 327 | void changeEventDisplay(Event *, int); |
328 | void changeIncidenceDisplay(Incidence *, int); | 328 | void changeIncidenceDisplay(Incidence *, int); |
329 | void changeTodoDisplay(Todo *, int); | 329 | void changeTodoDisplay(Todo *, int); |
330 | 330 | ||
331 | void eventAdded(Event *); | 331 | void eventAdded(Event *); |
332 | void eventChanged(Event *); | 332 | void eventChanged(Event *); |
333 | void eventToBeDeleted(Event *); | 333 | void eventToBeDeleted(Event *); |
334 | void eventDeleted(); | 334 | void eventDeleted(); |
335 | 335 | ||
336 | void todoAdded(Todo *); | 336 | void todoAdded(Todo *); |
337 | void todoChanged(Todo *); | 337 | void todoChanged(Todo *); |
338 | void todoToBeDeleted(Todo *); | 338 | void todoToBeDeleted(Todo *); |
339 | void todoDeleted(); | 339 | void todoDeleted(); |
340 | 340 | ||
341 | void updateView(const QDate &start, const QDate &end); | 341 | void updateView(const QDate &start, const QDate &end); |
342 | void updateView(); | 342 | void updateView(); |
343 | void clearAllViews(); | 343 | void clearAllViews(); |
344 | 344 | ||
345 | /** Full update of visible todo views */ | 345 | /** Full update of visible todo views */ |
346 | void updateTodoViews(); | 346 | void updateTodoViews(); |
347 | 347 | ||
348 | void updateUnmanagedViews(); | 348 | void updateUnmanagedViews(); |
349 | 349 | ||
350 | /** cut the current appointment to the clipboard */ | 350 | /** cut the current appointment to the clipboard */ |
351 | void edit_cut(); | 351 | void edit_cut(); |
352 | 352 | ||
353 | /** copy the current appointment(s) to the clipboard */ | 353 | /** copy the current appointment(s) to the clipboard */ |
354 | void edit_copy(); | 354 | void edit_copy(); |
355 | 355 | ||
356 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 356 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
357 | void edit_paste(); | 357 | void edit_paste(); |
358 | 358 | ||
359 | /** edit viewing and configuration options. */ | 359 | /** edit viewing and configuration options. */ |
360 | void edit_options(); | 360 | void edit_options(); |
361 | void edit_global_options(); | 361 | void edit_global_options(); |
362 | /** | 362 | /** |
363 | Functions for printing, previewing a print, and setting up printing | 363 | Functions for printing, previewing a print, and setting up printing |
364 | parameters. | 364 | parameters. |
365 | */ | 365 | */ |
366 | void print(); | 366 | void print(); |
367 | void printSetup(); | 367 | void printSetup(); |
368 | void printPreview(); | 368 | void printPreview(); |
369 | 369 | ||
370 | /** Export as iCalendar file */ | 370 | /** Export as iCalendar file */ |
371 | void exportICalendar(); | 371 | void exportICalendar(); |
372 | 372 | ||
373 | /** Export as vCalendar file */ | 373 | /** Export as vCalendar file */ |
374 | bool exportVCalendar( QString fn); | 374 | bool exportVCalendar( QString fn); |
375 | 375 | ||
376 | /** pop up a dialog to show an existing appointment. */ | 376 | /** pop up a dialog to show an existing appointment. */ |
377 | void appointment_show(); | 377 | void appointment_show(); |
378 | /** | 378 | /** |
379 | * pop up an Appointment Dialog to edit an existing appointment.Get | 379 | * pop up an Appointment Dialog to edit an existing appointment.Get |
380 | * information on the appointment from the list of unique IDs that is | 380 | * information on the appointment from the list of unique IDs that is |
381 | * currently in the View, called currIds. | 381 | * currently in the View, called currIds. |
382 | */ | 382 | */ |
383 | void appointment_edit(); | 383 | void appointment_edit(); |
384 | /** | 384 | /** |
385 | * pop up dialog confirming deletion of currently selected event in the | 385 | * pop up dialog confirming deletion of currently selected event in the |
386 | * View. | 386 | * View. |
387 | */ | 387 | */ |
388 | void appointment_delete(); | 388 | void appointment_delete(); |
389 | 389 | ||
390 | /** mails the currently selected event to a particular user as a vCalendar | 390 | /** mails the currently selected event to a particular user as a vCalendar |
391 | attachment. */ | 391 | attachment. */ |
392 | void action_mail(); | 392 | void action_mail(); |
393 | 393 | ||
394 | /* frees a subtodo from it's relation */ | 394 | /* frees a subtodo from it's relation */ |
395 | void todo_unsub( Todo * ); | 395 | void todo_unsub( Todo * ); |
396 | void todo_resub( Todo * parent, Todo * sub ); | 396 | void todo_resub( Todo * parent, Todo * sub ); |
397 | 397 | ||
398 | /** Take ownership of selected event. */ | 398 | /** Take ownership of selected event. */ |
399 | void takeOverEvent(); | 399 | void takeOverEvent(); |
400 | 400 | ||
401 | /** Take ownership of all events in calendar. */ | 401 | /** Take ownership of all events in calendar. */ |
402 | void takeOverCalendar(); | 402 | void takeOverCalendar(); |
403 | 403 | ||
404 | /** query whether or not the calendar is "dirty". */ | 404 | /** query whether or not the calendar is "dirty". */ |
405 | bool isModified(); | 405 | bool isModified(); |
406 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 406 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
407 | void setModified(bool modified=true); | 407 | void setModified(bool modified=true); |
408 | 408 | ||
409 | /** query if the calendar is read-only. */ | 409 | /** query if the calendar is read-only. */ |
410 | bool isReadOnly(); | 410 | bool isReadOnly(); |
411 | /** set state of calendar to read-only */ | 411 | /** set state of calendar to read-only */ |
412 | void setReadOnly(bool readOnly=true); | 412 | void setReadOnly(bool readOnly=true); |
413 | 413 | ||
414 | void eventUpdated(Incidence *); | 414 | void eventUpdated(Incidence *); |
415 | 415 | ||
416 | /* iTIP scheduling actions */ | 416 | /* iTIP scheduling actions */ |
417 | void schedule_publish(Incidence *incidence = 0); | 417 | void schedule_publish(Incidence *incidence = 0); |
418 | void schedule_request(Incidence *incidence = 0); | 418 | void schedule_request(Incidence *incidence = 0); |
419 | void schedule_refresh(Incidence *incidence = 0); | 419 | void schedule_refresh(Incidence *incidence = 0); |
420 | void schedule_cancel(Incidence *incidence = 0); | 420 | void schedule_cancel(Incidence *incidence = 0); |
421 | void schedule_add(Incidence *incidence = 0); | 421 | void schedule_add(Incidence *incidence = 0); |
422 | void schedule_reply(Incidence *incidence = 0); | 422 | void schedule_reply(Incidence *incidence = 0); |
423 | void schedule_counter(Incidence *incidence = 0); | 423 | void schedule_counter(Incidence *incidence = 0); |
424 | void schedule_declinecounter(Incidence *incidence = 0); | 424 | void schedule_declinecounter(Incidence *incidence = 0); |
425 | void schedule_publish_freebusy(int daysToPublish = 30); | 425 | void schedule_publish_freebusy(int daysToPublish = 30); |
426 | 426 | ||
427 | void openAddressbook(); | 427 | void openAddressbook(); |
428 | 428 | ||
429 | void editFilters(); | 429 | void editFilters(); |
430 | void toggleFilerEnabled(); | 430 | void toggleFilerEnabled(); |
431 | QPtrList<CalFilter> filters(); | 431 | QPtrList<CalFilter> filters(); |
432 | void toggleFilter(); | 432 | void toggleFilter(); |
433 | void showFilter(bool visible); | 433 | void showFilter(bool visible); |
434 | void updateFilter(); | 434 | void updateFilter(); |
435 | void filterEdited(); | 435 | void filterEdited(); |
436 | void selectFilter( int ); | 436 | void selectFilter( int ); |
437 | KOFilterView *filterView(); | 437 | KOFilterView *filterView(); |
438 | 438 | ||
439 | void showIntro(); | 439 | void showIntro(); |
440 | 440 | ||
441 | /** Move the curdatepient view date to today */ | 441 | /** Move the curdatepient view date to today */ |
442 | void goToday(); | 442 | void goToday(); |
443 | 443 | ||
444 | /** Move to the next date(s) in the current view */ | 444 | /** Move to the next date(s) in the current view */ |
445 | void goNext(); | 445 | void goNext(); |
446 | 446 | ||
447 | /** Move to the previous date(s) in the current view */ | 447 | /** Move to the previous date(s) in the current view */ |
448 | void goPrevious(); | 448 | void goPrevious(); |
449 | /** Move to the next date(s) in the current view */ | 449 | /** Move to the next date(s) in the current view */ |
450 | void goNextMonth(); | 450 | void goNextMonth(); |
451 | 451 | ||
452 | /** Move to the previous date(s) in the current view */ | 452 | /** Move to the previous date(s) in the current view */ |
453 | void goPreviousMonth(); | 453 | void goPreviousMonth(); |
454 | 454 | ||
455 | void toggleExpand(); | 455 | void toggleExpand(); |
456 | void toggleDateNavigatorWidget(); | 456 | void toggleDateNavigatorWidget(); |
457 | void toggleAllDaySize(); | 457 | void toggleAllDaySize(); |
458 | void dialogClosing(Incidence *); | 458 | void dialogClosing(Incidence *); |
459 | 459 | ||
460 | /** Look for new messages in the inbox */ | 460 | /** Look for new messages in the inbox */ |
461 | void lookForIncomingMessages(); | 461 | void lookForIncomingMessages(); |
462 | /** Look for new messages in the outbox */ | 462 | /** Look for new messages in the outbox */ |
463 | void lookForOutgoingMessages(); | 463 | void lookForOutgoingMessages(); |
464 | 464 | ||
465 | void processMainViewSelection( Incidence * ); | 465 | void processMainViewSelection( Incidence * ); |
466 | void processTodoListSelection( Incidence * ); | 466 | void processTodoListSelection( Incidence * ); |
467 | 467 | ||
468 | void processIncidenceSelection( Incidence * ); | 468 | void processIncidenceSelection( Incidence * ); |
469 | 469 | ||
470 | void purgeCompleted(); | 470 | void purgeCompleted(); |
471 | bool removeCompletedSubTodos( Todo* ); | 471 | bool removeCompletedSubTodos( Todo* ); |
472 | void slotCalendarChanged(); | 472 | void slotCalendarChanged(); |
473 | bool importBday(); | 473 | bool importBday(); |
474 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 474 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
475 | bool importQtopia( const QString &categoriesFile, | 475 | bool importQtopia( const QString &categoriesFile, |
476 | const QString &datebookFile, | 476 | const QString &datebookFile, |
477 | const QString &tasklistFile ); | 477 | const QString &tasklistFile ); |
478 | void syncExternal( int mode ); | 478 | void syncExternal( int mode ); |
479 | void slotSelectPickerDate( QDate ) ; | 479 | void slotSelectPickerDate( QDate ) ; |
480 | void showDatePicker() ; | 480 | void showDatePicker() ; |
481 | void showDatePickerPopup() ; | 481 | void showDatePickerPopup() ; |
482 | void moveIncidence(Incidence *) ; | 482 | void moveIncidence(Incidence *) ; |
483 | void beamIncidence(Incidence *) ; | 483 | void beamIncidence(Incidence *) ; |
484 | void beamCalendar() ; | 484 | void beamCalendar() ; |
485 | void beamFilteredCalendar() ; | 485 | void beamFilteredCalendar() ; |
486 | void beamIncidenceList(QPtrList<Incidence>) ; | 486 | void beamIncidenceList(QPtrList<Incidence>) ; |
487 | void manageCategories(); | 487 | void manageCategories(); |
488 | int addCategories(); | 488 | int addCategories(); |
489 | void removeCategories(); | 489 | void removeCategories(); |
490 | void setSyncDevice( QString ); | 490 | void setSyncDevice( QString ); |
491 | void setSyncName( QString ); | 491 | void setSyncName( QString ); |
492 | void showDay( QDate ); | 492 | void showDay( QDate ); |
493 | void undo_delete(); | 493 | void undo_delete(); |
494 | protected slots: | 494 | protected slots: |
495 | void resetFocus(); | 495 | void resetFocus(); |
496 | void scrollBarValue(int); | 496 | void scrollBarValue(int); |
497 | void slotViewerClosed(); | 497 | void slotViewerClosed(); |
498 | void timerAlarm(); | 498 | void timerAlarm(); |
499 | void suspendAlarm(); | 499 | void suspendAlarm(); |
500 | void beamDone( Ir *ir ); | 500 | void beamDone( Ir *ir ); |
501 | /** Select a view or adapt the current view to display the specified dates. */ | 501 | /** Select a view or adapt the current view to display the specified dates. */ |
502 | void showDates( const KCal::DateList & ); | 502 | void showDates( const KCal::DateList & ); |
503 | void selectWeekNum ( int ); | 503 | void selectWeekNum ( int ); |
504 | 504 | ||
505 | public: | 505 | public: |
506 | // show a standard warning | 506 | // show a standard warning |
507 | // returns KMsgBox::yesNoCancel() | 507 | // returns KMsgBox::yesNoCancel() |
508 | int msgCalModified(); | 508 | int msgCalModified(); |
509 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 509 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
510 | 510 | ||
511 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 511 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
512 | virtual void removeSyncInfo( QString syncProfile); | 512 | virtual void removeSyncInfo( QString syncProfile); |
513 | void setSyncManager(KSyncManager* manager); | 513 | void setSyncManager(KSyncManager* manager); |
514 | void setLoadedFileVersion(QDateTime); | 514 | void setLoadedFileVersion(QDateTime); |
515 | bool checkFileVersion(QString fn); | 515 | bool checkFileVersion(QString fn); |
516 | bool checkAllFileVersions(); | 516 | bool checkAllFileVersions(); |
517 | bool checkFileChanged(QString fn); | 517 | bool checkFileChanged(QString fn); |
518 | Event* getLastSyncEvent(); | 518 | Event* getLastSyncEvent(); |
519 | /** Adapt navigation units correpsonding to step size of navigation of the | 519 | /** Adapt navigation units correpsonding to step size of navigation of the |
520 | * current view. | 520 | * current view. |
521 | */ | 521 | */ |
522 | void adaptNavigationUnits(); | 522 | void adaptNavigationUnits(); |
523 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 523 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
524 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 524 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
525 | //Attendee* getYourAttendee(Event *event); | 525 | //Attendee* getYourAttendee(Event *event); |
526 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 526 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
527 | void setScrollBarStep(int val ); | 527 | void setScrollBarStep(int val ); |
528 | 528 | ||
529 | protected: | 529 | protected: |
530 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 530 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
531 | 531 | ||
532 | // returns KMsgBox::OKCandel() | 532 | // returns KMsgBox::OKCandel() |
533 | int msgItemDelete(const QString name); | 533 | int msgItemDelete(const QString name); |
534 | void showEventEditor(); | 534 | void showEventEditor(); |
535 | void showTodoEditor(); | 535 | void showTodoEditor(); |
536 | Todo *selectedTodo(); | 536 | Todo *selectedTodo(); |
537 | private: | 537 | private: |
538 | #ifdef DESKTOP_VERSION | ||
538 | QScrollBar * mDateScrollBar; | 539 | QScrollBar * mDateScrollBar; |
540 | #endif | ||
539 | QDateTime mNextAlarmDateTime; | 541 | QDateTime mNextAlarmDateTime; |
540 | bool mViewerCallerIsSearchDialog; | 542 | bool mViewerCallerIsSearchDialog; |
541 | bool mBlockShowDates; | 543 | bool mBlockShowDates; |
542 | KSyncManager* mSyncManager; | 544 | KSyncManager* mSyncManager; |
543 | AlarmDialog * mAlarmDialog; | 545 | AlarmDialog * mAlarmDialog; |
544 | QString mAlarmNotification; | 546 | QString mAlarmNotification; |
545 | QString mSuspendAlarmNotification; | 547 | QString mSuspendAlarmNotification; |
546 | QTimer* mSuspendTimer; | 548 | QTimer* mSuspendTimer; |
547 | QTimer* mAlarmTimer; | 549 | QTimer* mAlarmTimer; |
548 | QTimer* mRecheckAlarmTimer; | 550 | QTimer* mRecheckAlarmTimer; |
549 | void computeAlarm( QString ); | 551 | void computeAlarm( QString ); |
550 | void startAlarm( QString, QString ); | 552 | void startAlarm( QString, QString ); |
551 | void setSyncEventsReadOnly(); | 553 | void setSyncEventsReadOnly(); |
552 | 554 | ||
553 | QDateTime loadedFileVersion; | 555 | QDateTime loadedFileVersion; |
554 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 556 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
555 | void checkExternalId( Incidence * inc ); | 557 | void checkExternalId( Incidence * inc ); |
556 | int mGlobalSyncMode; | 558 | int mGlobalSyncMode; |
557 | QString mCurrentSyncDevice; | 559 | QString mCurrentSyncDevice; |
558 | QString mCurrentSyncName; | 560 | QString mCurrentSyncName; |
559 | void init(); | 561 | void init(); |
560 | int mDatePickerMode; | 562 | int mDatePickerMode; |
561 | bool mFlagEditDescription; | 563 | bool mFlagEditDescription; |
562 | QDateTime mLastCalendarSync; | 564 | QDateTime mLastCalendarSync; |
563 | void createPrinter(); | 565 | void createPrinter(); |
564 | 566 | ||
565 | void calendarModified( bool, Calendar * ); | 567 | void calendarModified( bool, Calendar * ); |
566 | 568 | ||
567 | CalPrinter *mCalPrinter; | 569 | CalPrinter *mCalPrinter; |
568 | 570 | ||
569 | QSplitter *mPanner; | 571 | QSplitter *mPanner; |
570 | QSplitter *mLeftSplitter; | 572 | QSplitter *mLeftSplitter; |
571 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; | 573 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; |
572 | QWidgetStack *mRightFrame; | 574 | QWidgetStack *mRightFrame; |
573 | 575 | ||
574 | KDatePicker* mDatePicker; | 576 | KDatePicker* mDatePicker; |
575 | QVBox* mDateFrame; | 577 | QVBox* mDateFrame; |
576 | 578 | ||
577 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. | 579 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. |
578 | 580 | ||
579 | KOFilterView *mFilterView; | 581 | KOFilterView *mFilterView; |
580 | KOCalEditView *mCalEditView; | 582 | KOCalEditView *mCalEditView; |
581 | 583 | ||
582 | ResourceView *mResourceView; | 584 | ResourceView *mResourceView; |
583 | 585 | ||
584 | // calendar object for this viewing instance | 586 | // calendar object for this viewing instance |
585 | Calendar *mCalendar; | 587 | Calendar *mCalendar; |
586 | 588 | ||
587 | CalendarResourceManager *mResourceManager; | 589 | CalendarResourceManager *mResourceManager; |
588 | 590 | ||
589 | FileStorage *mStorage; | 591 | FileStorage *mStorage; |
590 | 592 | ||
591 | DateNavigator *mNavigator; | 593 | DateNavigator *mNavigator; |
592 | 594 | ||
593 | KOViewManager *mViewManager; | 595 | KOViewManager *mViewManager; |
594 | KODialogManager *mDialogManager; | 596 | KODialogManager *mDialogManager; |
595 | 597 | ||
596 | // Calendar filters | 598 | // Calendar filters |
597 | QPtrList<CalFilter> mFilters; | 599 | QPtrList<CalFilter> mFilters; |
598 | 600 | ||
599 | // various housekeeping variables. | 601 | // various housekeeping variables. |
600 | bool mModified; // flag indicating if calendar is modified | 602 | bool mModified; // flag indicating if calendar is modified |
601 | bool mReadOnly; // flag indicating if calendar is read-only | 603 | bool mReadOnly; // flag indicating if calendar is read-only |
602 | QDate mSaveSingleDate; | 604 | QDate mSaveSingleDate; |
603 | 605 | ||
604 | Incidence *mSelectedIncidence; | 606 | Incidence *mSelectedIncidence; |
605 | Incidence *mMoveIncidence; | 607 | Incidence *mMoveIncidence; |
606 | QDate mMoveIncidenceOldDate; | 608 | QDate mMoveIncidenceOldDate; |
607 | KOTodoView *mTodoList; | 609 | KOTodoView *mTodoList; |
608 | KOEventEditor * mEventEditor; | 610 | KOEventEditor * mEventEditor; |
609 | KOTodoEditor * mTodoEditor; | 611 | KOTodoEditor * mTodoEditor; |
610 | KOEventViewerDialog * mEventViewerDialog; | 612 | KOEventViewerDialog * mEventViewerDialog; |
611 | void keyPressEvent ( QKeyEvent *e) ; | 613 | void keyPressEvent ( QKeyEvent *e) ; |
612 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 614 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
613 | }; | 615 | }; |
614 | 616 | ||
615 | 617 | ||
616 | class CalendarViewVisitor : public Incidence::Visitor | 618 | class CalendarViewVisitor : public Incidence::Visitor |
617 | { | 619 | { |
618 | public: | 620 | public: |
619 | CalendarViewVisitor() : mView( 0 ) {} | 621 | CalendarViewVisitor() : mView( 0 ) {} |
620 | 622 | ||
621 | bool act( Incidence *incidence, CalendarView *view ) | 623 | bool act( Incidence *incidence, CalendarView *view ) |
622 | { | 624 | { |
623 | mView = view; | 625 | mView = view; |
624 | return incidence->accept( *this ); | 626 | return incidence->accept( *this ); |
625 | } | 627 | } |
626 | 628 | ||
627 | protected: | 629 | protected: |
628 | CalendarView *mView; | 630 | CalendarView *mView; |
629 | }; | 631 | }; |
630 | 632 | ||
631 | class ShowIncidenceVisitor : public CalendarViewVisitor | 633 | class ShowIncidenceVisitor : public CalendarViewVisitor |
632 | { | 634 | { |
633 | protected: | 635 | protected: |
634 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 636 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
635 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 637 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
636 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 638 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
637 | }; | 639 | }; |
638 | 640 | ||
639 | class EditIncidenceVisitor : public CalendarViewVisitor | 641 | class EditIncidenceVisitor : public CalendarViewVisitor |
640 | { | 642 | { |
641 | protected: | 643 | protected: |
642 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 644 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
643 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 645 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
644 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 646 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
645 | }; | 647 | }; |
646 | 648 | ||
647 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 649 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
648 | { | 650 | { |
649 | protected: | 651 | protected: |
650 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 652 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
651 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 653 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
652 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 654 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
653 | }; | 655 | }; |
654 | 656 | ||
655 | #endif | 657 | #endif |