-rw-r--r-- | korganizer/calendarview.cpp | 7 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 35 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 2 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 8 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 1 |
6 files changed, 41 insertions, 13 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index ccacc52..a350c3b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4817 +1,4818 @@ | |||
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 "koagenda.h" | 107 | #include "koagenda.h" |
108 | #include "kodialogmanager.h" | 108 | #include "kodialogmanager.h" |
109 | #include "outgoingdialog.h" | 109 | #include "outgoingdialog.h" |
110 | #include "incomingdialog.h" | 110 | #include "incomingdialog.h" |
111 | #include "datenavigatorcontainer.h" | 111 | #include "datenavigatorcontainer.h" |
112 | #include "statusdialog.h" | 112 | #include "statusdialog.h" |
113 | #include "kdatenavigator.h" | 113 | #include "kdatenavigator.h" |
114 | #include "kotodoview.h" | 114 | #include "kotodoview.h" |
115 | #include "datenavigator.h" | 115 | #include "datenavigator.h" |
116 | #include "resourceview.h" | 116 | #include "resourceview.h" |
117 | #include "navigatorbar.h" | 117 | #include "navigatorbar.h" |
118 | #include "searchdialog.h" | 118 | #include "searchdialog.h" |
119 | #include "mainwindow.h" | 119 | #include "mainwindow.h" |
120 | #include "categoryeditdialog.h" | 120 | #include "categoryeditdialog.h" |
121 | 121 | ||
122 | #include "calendarview.h" | 122 | #include "calendarview.h" |
123 | #ifndef DESKTOP_VERSION | 123 | #ifndef DESKTOP_VERSION |
124 | #include <qtopia/alarmserver.h> | 124 | #include <qtopia/alarmserver.h> |
125 | #endif | 125 | #endif |
126 | #ifndef _WIN32_ | 126 | #ifndef _WIN32_ |
127 | #include <stdlib.h> | 127 | #include <stdlib.h> |
128 | #include <stdio.h> | 128 | #include <stdio.h> |
129 | #include <unistd.h> | 129 | #include <unistd.h> |
130 | #else | 130 | #else |
131 | #include <qprocess.h> | 131 | #include <qprocess.h> |
132 | #endif | 132 | #endif |
133 | 133 | ||
134 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
135 | #include <kabc/stdaddressbook.h> | 135 | #include <kabc/stdaddressbook.h> |
136 | #endif | 136 | #endif |
137 | using namespace KOrg; | 137 | using namespace KOrg; |
138 | using namespace KCal; | 138 | using namespace KCal; |
139 | extern int globalFlagBlockAgenda; | 139 | extern int globalFlagBlockAgenda; |
140 | extern int globalFlagBlockStartup; | 140 | extern int globalFlagBlockStartup; |
141 | 141 | ||
142 | 142 | ||
143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
144 | 144 | ||
145 | { | 145 | { |
146 | mAlarms = alarms; | 146 | mAlarms = alarms; |
147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
148 | QString mText = "<table width=\"100%\">\n"; | 148 | QString mText = "<table width=\"100%\">\n"; |
149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
150 | #ifdef DESKTOP_VERSION | 150 | #ifdef DESKTOP_VERSION |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
152 | #else | 152 | #else |
153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
154 | #endif | 154 | #endif |
155 | // mText += "<img src=\""; | 155 | // mText += "<img src=\""; |
156 | // mText += ipath; | 156 | // mText += ipath; |
157 | // mText += "\">"; | 157 | // mText += "\">"; |
158 | //mEventDate = QDate::currentDate(); | 158 | //mEventDate = QDate::currentDate(); |
159 | #ifdef DESKTOP_VERSION | 159 | #ifdef DESKTOP_VERSION |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
161 | #else | 161 | #else |
162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
163 | #endif | 163 | #endif |
164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
165 | 165 | ||
166 | Incidence * inc = getNextInc( start ); | 166 | Incidence * inc = getNextInc( start ); |
167 | int time = 0; | 167 | int time = 0; |
168 | //mText += "<table>"; | 168 | //mText += "<table>"; |
169 | while ( inc ) { | 169 | while ( inc ) { |
170 | QDateTime dt ; | 170 | QDateTime dt ; |
171 | QString tempText = "<a "; | 171 | QString tempText = "<a "; |
172 | bool ok; | 172 | bool ok; |
173 | dt = inc->getNextOccurence( start, &ok ); | 173 | dt = inc->getNextOccurence( start, &ok ); |
174 | if ( !ok ) continue; | 174 | if ( !ok ) continue; |
175 | if ( inc->typeID() == eventID ) { | 175 | if ( inc->typeID() == eventID ) { |
176 | tempText += "href=\"event:"; | 176 | tempText += "href=\"event:"; |
177 | } else if ( inc->typeID() == todoID ) { | 177 | } else if ( inc->typeID() == todoID ) { |
178 | tempText += "href=\"todo:"; | 178 | tempText += "href=\"todo:"; |
179 | } | 179 | } |
180 | tempText += inc->uid() + "\">"; | 180 | tempText += inc->uid() + "\">"; |
181 | if ( inc->typeID() == todoID ) | 181 | if ( inc->typeID() == todoID ) |
182 | tempText += i18n("Todo: "); | 182 | tempText += i18n("Todo: "); |
183 | if ( inc->summary().length() > 0 ) | 183 | if ( inc->summary().length() > 0 ) |
184 | tempText += inc->summary(); | 184 | tempText += inc->summary(); |
185 | else | 185 | else |
186 | tempText += i18n("-no summary-"); | 186 | tempText += i18n("-no summary-"); |
187 | QString timestr; | 187 | QString timestr; |
188 | if (!inc->doesFloat()) | 188 | if (!inc->doesFloat()) |
189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | else | 190 | else |
191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
194 | mText += "<table>"; | 194 | mText += "<table>"; |
195 | time = 1; | 195 | time = 1; |
196 | } | 196 | } |
197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
198 | if ( time > 0 ) | 198 | if ( time > 0 ) |
199 | mText +="</table>"; | 199 | mText +="</table>"; |
200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
201 | mText += "<table>"; | 201 | mText += "<table>"; |
202 | time = 2; | 202 | time = 2; |
203 | 203 | ||
204 | } | 204 | } |
205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
206 | if ( time > 0 ) | 206 | if ( time > 0 ) |
207 | mText +="</table>"; | 207 | mText +="</table>"; |
208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
209 | mText += "<table>"; | 209 | mText += "<table>"; |
210 | time = 3; | 210 | time = 3; |
211 | } | 211 | } |
212 | mText +="<tr><td><b>"; | 212 | mText +="<tr><td><b>"; |
213 | mText += timestr; | 213 | mText += timestr; |
214 | mText += "</b></td><td>"; | 214 | mText += "</b></td><td>"; |
215 | mText += tempText; | 215 | mText += tempText; |
216 | mText += "</td></tr>\n"; | 216 | mText += "</td></tr>\n"; |
217 | inc = getNextInc( start ); | 217 | inc = getNextInc( start ); |
218 | } | 218 | } |
219 | mText +="</table>"; | 219 | mText +="</table>"; |
220 | setText( mText ); | 220 | setText( mText ); |
221 | } | 221 | } |
222 | 222 | ||
223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
224 | { | 224 | { |
225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
226 | } | 226 | } |
227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
228 | { | 228 | { |
229 | QDateTime dt ; | 229 | QDateTime dt ; |
230 | Incidence * retInc; | 230 | Incidence * retInc; |
231 | Incidence * inc = mAlarms.first(); | 231 | Incidence * inc = mAlarms.first(); |
232 | if ( inc == 0 ) | 232 | if ( inc == 0 ) |
233 | return 0; | 233 | return 0; |
234 | bool ok; | 234 | bool ok; |
235 | dt = inc->getNextOccurence( start, &ok ); | 235 | dt = inc->getNextOccurence( start, &ok ); |
236 | if ( ! ok ) return 0; | 236 | if ( ! ok ) return 0; |
237 | QDateTime dtn ; | 237 | QDateTime dtn ; |
238 | retInc = inc; | 238 | retInc = inc; |
239 | inc = mAlarms.next(); | 239 | inc = mAlarms.next(); |
240 | while ( inc ) { | 240 | while ( inc ) { |
241 | dtn = inc->getNextOccurence( start, &ok ); | 241 | dtn = inc->getNextOccurence( start, &ok ); |
242 | if ( ! ok ) return 0; | 242 | if ( ! ok ) return 0; |
243 | if ( dtn < dt ) { | 243 | if ( dtn < dt ) { |
244 | dt = dtn; | 244 | dt = dtn; |
245 | retInc = inc; | 245 | retInc = inc; |
246 | } | 246 | } |
247 | inc = mAlarms.next(); | 247 | inc = mAlarms.next(); |
248 | } | 248 | } |
249 | mAlarms.remove( retInc ); | 249 | mAlarms.remove( retInc ); |
250 | return retInc; | 250 | return retInc; |
251 | 251 | ||
252 | } | 252 | } |
253 | void MissedAlarmTextBrowser::setSource(const QString & n) | 253 | void MissedAlarmTextBrowser::setSource(const QString & n) |
254 | { | 254 | { |
255 | if (n.startsWith("event:")) { | 255 | if (n.startsWith("event:")) { |
256 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
257 | emit showIncidence(n.mid(8)); | 257 | emit showIncidence(n.mid(8)); |
258 | #else | 258 | #else |
259 | emit showIncidence(n.mid(6)); | 259 | emit showIncidence(n.mid(6)); |
260 | #endif | 260 | #endif |
261 | return; | 261 | return; |
262 | } else if (n.startsWith("todo:")) { | 262 | } else if (n.startsWith("todo:")) { |
263 | #ifdef DESKTOP_VERSION | 263 | #ifdef DESKTOP_VERSION |
264 | emit showIncidence(n.mid(7)); | 264 | emit showIncidence(n.mid(7)); |
265 | #else | 265 | #else |
266 | emit showIncidence(n.mid(5)); | 266 | emit showIncidence(n.mid(5)); |
267 | #endif | 267 | #endif |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | class KOBeamPrefs : public QDialog | 273 | class KOBeamPrefs : public QDialog |
274 | { | 274 | { |
275 | public: | 275 | public: |
276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
277 | QDialog( parent, name, true ) | 277 | QDialog( parent, name, true ) |
278 | { | 278 | { |
279 | setCaption( i18n("Beam Options") ); | 279 | setCaption( i18n("Beam Options") ); |
280 | QVBoxLayout* lay = new QVBoxLayout( this ); | 280 | QVBoxLayout* lay = new QVBoxLayout( this ); |
281 | lay->setSpacing( 3 ); | 281 | lay->setSpacing( 3 ); |
282 | lay->setMargin( 3 ); | 282 | lay->setMargin( 3 ); |
283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
284 | lay->addWidget( format ); | 284 | lay->addWidget( format ); |
285 | format->setExclusive ( true ) ; | 285 | format->setExclusive ( true ) ; |
286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
287 | lay->addWidget( time ); time->setExclusive ( true ) ; | 287 | lay->addWidget( time ); time->setExclusive ( true ) ; |
288 | vcal = new QRadioButton(" vCalendar ", format ); | 288 | vcal = new QRadioButton(" vCalendar ", format ); |
289 | ical = new QRadioButton(" iCalendar ", format ); | 289 | ical = new QRadioButton(" iCalendar ", format ); |
290 | vcal->setChecked( true ); | 290 | vcal->setChecked( true ); |
291 | tz = new QRadioButton(i18n(" With timezone "), time ); | 291 | tz = new QRadioButton(i18n(" With timezone "), time ); |
292 | local = new QRadioButton(i18n(" Local time "), time ); | 292 | local = new QRadioButton(i18n(" Local time "), time ); |
293 | tz->setChecked( true ); | 293 | tz->setChecked( true ); |
294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
295 | lay->addWidget( ok ); | 295 | lay->addWidget( ok ); |
296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
297 | lay->addWidget( cancel ); | 297 | lay->addWidget( cancel ); |
298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
300 | resize( 200, 200 ); | 300 | resize( 200, 200 ); |
301 | } | 301 | } |
302 | 302 | ||
303 | bool beamVcal() { return vcal->isChecked(); } | 303 | bool beamVcal() { return vcal->isChecked(); } |
304 | bool beamLocal() { return local->isChecked(); } | 304 | bool beamLocal() { return local->isChecked(); } |
305 | private: | 305 | private: |
306 | QRadioButton* vcal, *ical, *local, *tz; | 306 | QRadioButton* vcal, *ical, *local, *tz; |
307 | }; | 307 | }; |
308 | class KOCatPrefs : public QDialog | 308 | class KOCatPrefs : public QDialog |
309 | { | 309 | { |
310 | public: | 310 | public: |
311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
312 | QDialog( parent, name, true ) | 312 | QDialog( parent, name, true ) |
313 | { | 313 | { |
314 | setCaption( i18n("Manage new Categories") ); | 314 | setCaption( i18n("Manage new Categories") ); |
315 | QVBoxLayout* lay = new QVBoxLayout( this ); | 315 | QVBoxLayout* lay = new QVBoxLayout( this ); |
316 | lay->setSpacing( 3 ); | 316 | lay->setSpacing( 3 ); |
317 | lay->setMargin( 3 ); | 317 | lay->setMargin( 3 ); |
318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); | 318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); |
319 | lay->addWidget( lab ); | 319 | lay->addWidget( lab ); |
320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
321 | lay->addWidget( format ); | 321 | lay->addWidget( format ); |
322 | format->setExclusive ( true ) ; | 322 | format->setExclusive ( true ) ; |
323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
325 | addCatBut->setChecked( true ); | 325 | addCatBut->setChecked( true ); |
326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
327 | lay->addWidget( ok ); | 327 | lay->addWidget( ok ); |
328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
329 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
332 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
333 | } | 333 | } |
334 | 334 | ||
335 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
336 | private: | 336 | private: |
337 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | 340 | ||
341 | 341 | ||
342 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
343 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
344 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
345 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
346 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
347 | { | 347 | { |
348 | 348 | ||
349 | mEventEditor = 0; | 349 | mEventEditor = 0; |
350 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
351 | 351 | ||
352 | init(); | 352 | init(); |
353 | } | 353 | } |
354 | 354 | ||
355 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
356 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
357 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
358 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
359 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
360 | { | 360 | { |
361 | 361 | ||
362 | mEventEditor = 0; | 362 | mEventEditor = 0; |
363 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
364 | init(); | 364 | init(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void CalendarView::init() | 367 | void CalendarView::init() |
368 | { | 368 | { |
369 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 369 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
370 | setFocusPolicy ( NoFocus ); | 370 | setFocusPolicy ( NoFocus ); |
371 | mViewerCallerIsSearchDialog = false; | 371 | mViewerCallerIsSearchDialog = false; |
372 | mBlockShowDates = false; | 372 | mBlockShowDates = false; |
373 | 373 | ||
374 | mDatePickerMode = 0; | 374 | mDatePickerMode = 0; |
375 | mCurrentSyncDevice = ""; | 375 | mCurrentSyncDevice = ""; |
376 | mViewManager = new KOViewManager( this ); | 376 | mViewManager = new KOViewManager( this ); |
377 | mDialogManager = new KODialogManager( this ); | 377 | mDialogManager = new KODialogManager( this ); |
378 | mEventViewerDialog = 0; | 378 | mEventViewerDialog = 0; |
379 | mModified = false; | 379 | mModified = false; |
380 | mReadOnly = false; | 380 | mReadOnly = false; |
381 | mSelectedIncidence = 0; | 381 | mSelectedIncidence = 0; |
382 | mCalPrinter = 0; | 382 | mCalPrinter = 0; |
383 | mFilters.setAutoDelete(true); | 383 | mFilters.setAutoDelete(true); |
384 | 384 | ||
385 | mCalendar->registerObserver( this ); | 385 | mCalendar->registerObserver( this ); |
386 | // TODO: Make sure that view is updated, when calendar is changed. | 386 | // TODO: Make sure that view is updated, when calendar is changed. |
387 | 387 | ||
388 | mStorage = new FileStorage( mCalendar ); | 388 | mStorage = new FileStorage( mCalendar ); |
389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
390 | 390 | ||
391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
392 | #ifndef KORG_NOSPLITTER | 392 | #ifndef KORG_NOSPLITTER |
393 | // create the main layout frames. | 393 | // create the main layout frames. |
394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
395 | topLayout->addWidget(mPanner); | 395 | topLayout->addWidget(mPanner); |
396 | 396 | ||
397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
398 | "CalendarView::LeftFrame"); | 398 | "CalendarView::LeftFrame"); |
399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
400 | 400 | ||
401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
402 | "CalendarView::DateNavigator" ); | 402 | "CalendarView::DateNavigator" ); |
403 | 403 | ||
404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
406 | mTodoList->setNavigator( mNavigator ); | 406 | mTodoList->setNavigator( mNavigator ); |
407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
408 | 408 | ||
409 | #ifdef KORG_NORESOURCEVIEW | 409 | #ifdef KORG_NORESOURCEVIEW |
410 | mResourceView = 0; | 410 | mResourceView = 0; |
411 | #else | 411 | #else |
412 | if ( mResourceManager ) { | 412 | if ( mResourceManager ) { |
413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
414 | mResourceView->updateView(); | 414 | mResourceView->updateView(); |
415 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 415 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
416 | SLOT( updateView() ) ); | 416 | SLOT( updateView() ) ); |
417 | } else { | 417 | } else { |
418 | mResourceView = 0; | 418 | mResourceView = 0; |
419 | } | 419 | } |
420 | #endif | 420 | #endif |
421 | QWidget *rightBox = new QWidget( mPanner ); | 421 | QWidget *rightBox = new QWidget( mPanner ); |
422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
423 | 423 | ||
424 | mRightFrame = new QWidgetStack( rightBox ); | 424 | mRightFrame = new QWidgetStack( rightBox ); |
425 | rightLayout->addWidget( mRightFrame, 1 ); | 425 | rightLayout->addWidget( mRightFrame, 1 ); |
426 | 426 | ||
427 | mLeftFrame = mLeftSplitter; | 427 | mLeftFrame = mLeftSplitter; |
428 | #else | 428 | #else |
429 | //QWidget *mainBox = new QWidget( this ); | 429 | //QWidget *mainBox = new QWidget( this ); |
430 | //QWidget *leftFrame = new QWidget( mainBox ); | 430 | //QWidget *leftFrame = new QWidget( mainBox ); |
431 | //QBoxLayout * mainBoxLayout; | 431 | //QBoxLayout * mainBoxLayout; |
432 | if ( KOPrefs::instance()->mVerticalScreen ) { | 432 | if ( KOPrefs::instance()->mVerticalScreen ) { |
433 | //mainBoxLayout = new QVBoxLayout(mainBox); | 433 | //mainBoxLayout = new QVBoxLayout(mainBox); |
434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
439 | } else { | 439 | } else { |
440 | //mainBoxLayout = new QHBoxLayout(mainBox); | 440 | //mainBoxLayout = new QHBoxLayout(mainBox); |
441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
446 | } | 446 | } |
447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
448 | //QBoxLayout * leftFrameLayout; | 448 | //QBoxLayout * leftFrameLayout; |
449 | topLayout->addWidget( mMainFrame ); | 449 | topLayout->addWidget( mMainFrame ); |
450 | #ifdef DESKTOP_VERSION | 450 | #ifdef DESKTOP_VERSION |
451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
452 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
454 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
455 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
456 | #endif | 456 | #endif |
457 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
459 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
460 | #if 0 | 460 | #if 0 |
461 | // FIXME | 461 | // FIXME |
462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
463 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
464 | #endif | 464 | #endif |
465 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
466 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
480 | 480 | ||
481 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
482 | #if 0 | 482 | #if 0 |
483 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
484 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
485 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
486 | 486 | ||
487 | } else { | 487 | } else { |
488 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
489 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
490 | } | 490 | } |
491 | #endif | 491 | #endif |
492 | mFilterView->hide(); | 492 | mFilterView->hide(); |
493 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
494 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
495 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
497 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
498 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
499 | 499 | ||
500 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
501 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
506 | } else { | 506 | } else { |
507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
510 | } | 510 | } |
511 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
512 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
513 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
517 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
518 | 518 | ||
519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
521 | 521 | ||
522 | 522 | ||
523 | 523 | ||
524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
529 | 529 | ||
530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
531 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
532 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
533 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
535 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
537 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
538 | 538 | ||
539 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
540 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
541 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
542 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
545 | 545 | ||
546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
548 | #if 0 | 548 | #if 0 |
549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
550 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
551 | #endif | 551 | #endif |
552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
553 | 553 | ||
554 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
555 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
558 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
560 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
562 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
564 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
566 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
569 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
571 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
572 | 572 | ||
573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
576 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
577 | 577 | ||
578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
579 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
581 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
582 | 582 | ||
583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
584 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
585 | 585 | ||
586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
589 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
592 | 592 | ||
593 | 593 | ||
594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | 602 | ||
603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
604 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
606 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
608 | 608 | ||
609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
610 | 610 | ||
611 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
614 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
615 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
616 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
618 | 618 | ||
619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
620 | 620 | ||
621 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
622 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
623 | 623 | ||
624 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
625 | 625 | ||
626 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
627 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
628 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
632 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
634 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
636 | 636 | ||
637 | 637 | ||
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
642 | #endif | 642 | #endif |
643 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
648 | { | 648 | { |
649 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
650 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
651 | delete mDialogManager; | 651 | delete mDialogManager; |
652 | delete mViewManager; | 652 | delete mViewManager; |
653 | delete mStorage; | 653 | delete mStorage; |
654 | delete mDateFrame ; | 654 | delete mDateFrame ; |
655 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
656 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
657 | } | 657 | } |
658 | void CalendarView::nextConflict( bool all, bool allday ) | 658 | void CalendarView::nextConflict( bool all, bool allday ) |
659 | { | 659 | { |
660 | 660 | ||
661 | QPtrList<Event> testlist = mCalendar->events(); | 661 | QPtrList<Event> testlist = mCalendar->events(); |
662 | Event * test = testlist.first(); | 662 | Event * test = testlist.first(); |
663 | while ( test ) { | 663 | while ( test ) { |
664 | test->setTagged( false ); | 664 | test->setTagged( false ); |
665 | test = testlist.next(); | 665 | test = testlist.next(); |
666 | } | 666 | } |
667 | QTime st ( 0,0,0); | 667 | QTime st ( 0,0,0); |
668 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 668 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
669 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 669 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
670 | //qDebug("time %s ", st.toString().latin1()); | 670 | //qDebug("time %s ", st.toString().latin1()); |
671 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 671 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
672 | QDateTime conflict; | 672 | QDateTime conflict; |
673 | QDateTime retVal; | 673 | QDateTime retVal; |
674 | bool found = false; | 674 | bool found = false; |
675 | Event * cE = 0; | 675 | Event * cE = 0; |
676 | Event * cE2 = 0; | 676 | Event * cE2 = 0; |
677 | QPtrList<Event> testlist2 = testlist; | 677 | QPtrList<Event> testlist2 = testlist; |
678 | test = testlist.first(); | 678 | test = testlist.first(); |
679 | bool skip = false; | 679 | bool skip = false; |
680 | while ( test ) { | 680 | while ( test ) { |
681 | skip = false; | 681 | skip = false; |
682 | if ( !all ) skip = ( allday != test->doesFloat() ); | 682 | if ( !all ) skip = ( allday != test->doesFloat() ); |
683 | if ( !skip ) { | 683 | if ( !skip ) { |
684 | Event * test2 = testlist2.first(); | 684 | Event * test2 = testlist2.first(); |
685 | while ( test2 ) { | 685 | while ( test2 ) { |
686 | skip = false; | 686 | skip = false; |
687 | if ( !all ) skip = ( allday != test2->doesFloat() ); | 687 | if ( !all ) skip = ( allday != test2->doesFloat() ); |
688 | if ( !skip ) { | 688 | if ( !skip ) { |
689 | if ( !test2->isTagged() ) { | 689 | if ( !test2->isTagged() ) { |
690 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 690 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
691 | //qDebug("overlap "); | 691 | //qDebug("overlap "); |
692 | if ( ! found ) { | 692 | if ( ! found ) { |
693 | if ( retVal >= startDT ) { | 693 | if ( retVal >= startDT ) { |
694 | conflict = retVal; | 694 | conflict = retVal; |
695 | cE = test; | 695 | cE = test; |
696 | cE2 = test2; | 696 | cE2 = test2; |
697 | found = true; | 697 | found = true; |
698 | } | 698 | } |
699 | } else { | 699 | } else { |
700 | if ( retVal >= startDT && retVal < conflict ) { | 700 | if ( retVal >= startDT && retVal < conflict ) { |
701 | conflict = retVal; | 701 | conflict = retVal; |
702 | cE = test; | 702 | cE = test; |
703 | cE2 = test2; | 703 | cE2 = test2; |
704 | } | 704 | } |
705 | } | 705 | } |
706 | } | 706 | } |
707 | } | 707 | } |
708 | } | 708 | } |
709 | test2 = testlist2.next(); | 709 | test2 = testlist2.next(); |
710 | } | 710 | } |
711 | } | 711 | } |
712 | test->setTagged( true ); | 712 | test->setTagged( true ); |
713 | test = testlist.next(); | 713 | test = testlist.next(); |
714 | } | 714 | } |
715 | if ( found ) { | 715 | if ( found ) { |
716 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 716 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
717 | mViewManager->showDayView(); | 717 | mViewManager->showDayView(); |
718 | mNavigator->slotDaySelect( conflict.date() ); | 718 | mNavigator->slotDaySelect( conflict.date() ); |
719 | int hour = conflict.time().hour(); | 719 | int hour = conflict.time().hour(); |
720 | mViewManager->agendaView()->setStartHour( hour ); | 720 | mViewManager->agendaView()->setStartHour( hour ); |
721 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 721 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
722 | return; | 722 | return; |
723 | } | 723 | } |
724 | 724 | ||
725 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 725 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
726 | qDebug("No conflict found "); | 726 | qDebug("No conflict found "); |
727 | return; | 727 | return; |
728 | } | 728 | } |
729 | 729 | ||
730 | void CalendarView::conflictAll() | 730 | void CalendarView::conflictAll() |
731 | { | 731 | { |
732 | nextConflict ( true, true ); | 732 | nextConflict ( true, true ); |
733 | } | 733 | } |
734 | void CalendarView::conflictAllday() | 734 | void CalendarView::conflictAllday() |
735 | { | 735 | { |
736 | nextConflict ( false, true ); | 736 | nextConflict ( false, true ); |
737 | } | 737 | } |
738 | void CalendarView::conflictNotAll() | 738 | void CalendarView::conflictNotAll() |
739 | { | 739 | { |
740 | nextConflict ( false, false ); | 740 | nextConflict ( false, false ); |
741 | } | 741 | } |
742 | 742 | ||
743 | void CalendarView::setCalReadOnly( int id, bool readO ) | 743 | void CalendarView::setCalReadOnly( int id, bool readO ) |
744 | { | 744 | { |
745 | if ( readO ) { | 745 | if ( readO ) { |
746 | emit save(); | 746 | emit save(); |
747 | } | 747 | } |
748 | mCalendar->setReadOnly( id, readO ); | 748 | mCalendar->setReadOnly( id, readO ); |
749 | } | 749 | } |
750 | void CalendarView::setScrollBarStep(int val ) | 750 | void CalendarView::setScrollBarStep(int val ) |
751 | { | 751 | { |
752 | #ifdef DESKTOP_VERSION | 752 | #ifdef DESKTOP_VERSION |
753 | mDateScrollBar->setLineStep ( val ); | 753 | mDateScrollBar->setLineStep ( val ); |
754 | #endif | 754 | #endif |
755 | } | 755 | } |
756 | void CalendarView::scrollBarValue(int val ) | 756 | void CalendarView::scrollBarValue(int val ) |
757 | { | 757 | { |
758 | #ifdef DESKTOP_VERSION | 758 | #ifdef DESKTOP_VERSION |
759 | if ( QApplication::desktop()->width() < 800 ) return; | 759 | if ( QApplication::desktop()->width() < 800 ) return; |
760 | static bool block = false; | 760 | static bool block = false; |
761 | if ( block ) return; | 761 | if ( block ) return; |
762 | block = true; | 762 | block = true; |
763 | int count = mNavigator->selectedDates().count(); | 763 | int count = mNavigator->selectedDates().count(); |
764 | int day = mNavigator->selectedDates().first().dayOfYear(); | 764 | int day = mNavigator->selectedDates().first().dayOfYear(); |
765 | int stepdays = val; | 765 | int stepdays = val; |
766 | if ( mDateScrollBar->lineStep () <= count ) { | 766 | if ( mDateScrollBar->lineStep () <= count ) { |
767 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 767 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
768 | //qDebug("VAL %d ",val ); | 768 | //qDebug("VAL %d ",val ); |
769 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 769 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
770 | stepdays = day+stepdays; | 770 | stepdays = day+stepdays; |
771 | if ( stepdays < 0 ) stepdays = 0; | 771 | if ( stepdays < 0 ) stepdays = 0; |
772 | } | 772 | } |
773 | if ( stepdays == day ) { | 773 | if ( stepdays == day ) { |
774 | block = false; | 774 | block = false; |
775 | return; | 775 | return; |
776 | } | 776 | } |
777 | int year = mNavigator->selectedDates().first().year(); | 777 | int year = mNavigator->selectedDates().first().year(); |
778 | QDate d ( year,1,1 ); | 778 | QDate d ( year,1,1 ); |
779 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 779 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
780 | block = false; | 780 | block = false; |
781 | #endif | 781 | #endif |
782 | 782 | ||
783 | } | 783 | } |
784 | void CalendarView::updateView(const QDate &start, const QDate &end) | 784 | void CalendarView::updateView(const QDate &start, const QDate &end) |
785 | { | 785 | { |
786 | #ifdef DESKTOP_VERSION | 786 | #ifdef DESKTOP_VERSION |
787 | if ( ! mDateScrollBar->draggingSlider () ) { | 787 | if ( ! mDateScrollBar->draggingSlider () ) { |
788 | int dof = start.dayOfYear(); | 788 | int dof = start.dayOfYear(); |
789 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 789 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
790 | if ( dof != mDateScrollBar->value() ) { | 790 | if ( dof != mDateScrollBar->value() ) { |
791 | mDateScrollBar->blockSignals( true ); | 791 | mDateScrollBar->blockSignals( true ); |
792 | mDateScrollBar->setValue( start.dayOfYear()); | 792 | mDateScrollBar->setValue( start.dayOfYear()); |
793 | mDateScrollBar->blockSignals( false ); | 793 | mDateScrollBar->blockSignals( false ); |
794 | } | 794 | } |
795 | } | 795 | } |
796 | #endif | 796 | #endif |
797 | mTodoList->updateView(); | 797 | mTodoList->updateView(); |
798 | mViewManager->updateView(start, end); | 798 | mViewManager->updateView(start, end); |
799 | //mDateNavigator->updateView(); | 799 | //mDateNavigator->updateView(); |
800 | } | 800 | } |
801 | 801 | ||
802 | 802 | ||
803 | 803 | ||
804 | void CalendarView::checkFiles() | 804 | void CalendarView::checkFiles() |
805 | { | 805 | { |
806 | QString message; | 806 | QString message; |
807 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 807 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
808 | KopiCalendarFile * cal = calendars.first(); | 808 | KopiCalendarFile * cal = calendars.first(); |
809 | while ( cal ) { | 809 | while ( cal ) { |
810 | if ( cal->mErrorOnLoad ) { | 810 | if ( cal->mErrorOnLoad ) { |
811 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 811 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
812 | } | 812 | } |
813 | cal = calendars.next(); | 813 | cal = calendars.next(); |
814 | } | 814 | } |
815 | if ( !message.isEmpty() ) { | 815 | if ( !message.isEmpty() ) { |
816 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); | 816 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
817 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 817 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
818 | } | 818 | } |
819 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 819 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
820 | } | 820 | } |
821 | void CalendarView::checkAlarms() | 821 | void CalendarView::checkAlarms() |
822 | { | 822 | { |
823 | 823 | ||
824 | 824 | ||
825 | KConfig *config = KOGlobals::config(); | 825 | KConfig *config = KOGlobals::config(); |
826 | config->setGroup( "AppRun" ); | 826 | config->setGroup( "AppRun" ); |
827 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 827 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
828 | int daysto = dt.daysTo( QDate::currentDate() ); | 828 | int daysto = dt.daysTo( QDate::currentDate() ); |
829 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 829 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
830 | dt = dt.addDays( days ); | 830 | dt = dt.addDays( days ); |
831 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 831 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
832 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 832 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
833 | //qDebug("KO: Reading program stop %d ", secs); | 833 | //qDebug("KO: Reading program stop %d ", secs); |
834 | //secs -= ( 3600 * 24*3 ); // debug only | 834 | //secs -= ( 3600 * 24*3 ); // debug only |
835 | QDateTime latest = dt.addSecs ( secs ); | 835 | QDateTime latest = dt.addSecs ( secs ); |
836 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 836 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
837 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 837 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
838 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 838 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
839 | QPtrList<Incidence> al; | 839 | QPtrList<Incidence> al; |
840 | Incidence* inL = el.first(); | 840 | Incidence* inL = el.first(); |
841 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 841 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
842 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 842 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
843 | while ( inL ) { | 843 | while ( inL ) { |
844 | bool ok = false; | 844 | bool ok = false; |
845 | int offset = 0; | 845 | int offset = 0; |
846 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 846 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
847 | if ( ok ) { | 847 | if ( ok ) { |
848 | //qDebug("OK %s",next.toString().latin1()); | 848 | //qDebug("OK %s",next.toString().latin1()); |
849 | if ( next < cur ) { | 849 | if ( next < cur ) { |
850 | al.append( inL ); | 850 | al.append( inL ); |
851 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 851 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
852 | } | 852 | } |
853 | } | 853 | } |
854 | inL = el.next(); | 854 | inL = el.next(); |
855 | } | 855 | } |
856 | if ( al.count() ) { | 856 | if ( al.count() ) { |
857 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 857 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
858 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 858 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
859 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 859 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
860 | lay->setSpacing( 0 ); | 860 | lay->setSpacing( 0 ); |
861 | lay->setMargin( 0 ); | 861 | lay->setMargin( 0 ); |
862 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 862 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
863 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 863 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
864 | lay->addWidget( matb ); | 864 | lay->addWidget( matb ); |
865 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 865 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
866 | int wid = 210; | 866 | int wid = 210; |
867 | int x = QApplication::desktop()->width() - wid - 7; | 867 | int x = QApplication::desktop()->width() - wid - 7; |
868 | int y = QApplication::desktop()->height() - wid - 70; | 868 | int y = QApplication::desktop()->height() - wid - 70; |
869 | dia->setGeometry ( x,y,wid,wid); | 869 | dia->setGeometry ( x,y,wid,wid); |
870 | } else { | 870 | } else { |
871 | int si = 220; | 871 | int si = 220; |
872 | if ( QApplication::desktop()->width() > 470 ) | 872 | if ( QApplication::desktop()->width() > 470 ) |
873 | si = 400; | 873 | si = 400; |
874 | dia->resize(si,si/2); | 874 | dia->resize(si,si/2); |
875 | } | 875 | } |
876 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 876 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
877 | dia->show(); | 877 | dia->show(); |
878 | 878 | ||
879 | } | 879 | } |
880 | } | 880 | } |
881 | void CalendarView::showDay( QDate d ) | 881 | void CalendarView::showDay( QDate d ) |
882 | { | 882 | { |
883 | dateNavigator()->blockSignals( true ); | 883 | dateNavigator()->blockSignals( true ); |
884 | dateNavigator()->selectDate( d ); | 884 | dateNavigator()->selectDate( d ); |
885 | dateNavigator()->blockSignals( false ); | 885 | dateNavigator()->blockSignals( false ); |
886 | mViewManager->showDayView(); | 886 | mViewManager->showDayView(); |
887 | //dateNavigator()->selectDate( d ); | 887 | //dateNavigator()->selectDate( d ); |
888 | } | 888 | } |
889 | void CalendarView::timerAlarm() | 889 | void CalendarView::timerAlarm() |
890 | { | 890 | { |
891 | //qDebug("CalendarView::timerAlarm() "); | 891 | //qDebug("CalendarView::timerAlarm() "); |
892 | computeAlarm(mAlarmNotification ); | 892 | computeAlarm(mAlarmNotification ); |
893 | } | 893 | } |
894 | 894 | ||
895 | void CalendarView::suspendAlarm() | 895 | void CalendarView::suspendAlarm() |
896 | { | 896 | { |
897 | //qDebug(" CalendarView::suspendAlarm() "); | 897 | //qDebug(" CalendarView::suspendAlarm() "); |
898 | computeAlarm(mSuspendAlarmNotification ); | 898 | computeAlarm(mSuspendAlarmNotification ); |
899 | 899 | ||
900 | } | 900 | } |
901 | 901 | ||
902 | void CalendarView::startAlarm( QString mess , QString filename) | 902 | void CalendarView::startAlarm( QString mess , QString filename) |
903 | { | 903 | { |
904 | 904 | ||
905 | topLevelWidget()->showNormal(); | 905 | topLevelWidget()->showNormal(); |
906 | topLevelWidget()->setActiveWindow(); | 906 | topLevelWidget()->setActiveWindow(); |
907 | topLevelWidget()->raise(); | 907 | topLevelWidget()->raise(); |
908 | 908 | ||
909 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 909 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
910 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 910 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
911 | 911 | ||
912 | } | 912 | } |
913 | 913 | ||
914 | void CalendarView::checkNextTimerAlarm() | 914 | void CalendarView::checkNextTimerAlarm() |
915 | { | 915 | { |
916 | mCalendar->checkAlarmForIncidence( 0, true ); | 916 | mCalendar->checkAlarmForIncidence( 0, true ); |
917 | } | 917 | } |
918 | 918 | ||
919 | void CalendarView::computeAlarm( QString msg ) | 919 | void CalendarView::computeAlarm( QString msg ) |
920 | { | 920 | { |
921 | 921 | ||
922 | QString mess = msg; | 922 | QString mess = msg; |
923 | QString mAlarmMessage = mess.mid( 9 ); | 923 | QString mAlarmMessage = mess.mid( 9 ); |
924 | QString filename = MainWindow::resourcePath(); | 924 | QString filename = MainWindow::resourcePath(); |
925 | filename += "koalarm.wav"; | 925 | filename += "koalarm.wav"; |
926 | QString tempfilename; | 926 | QString tempfilename; |
927 | if ( mess.left( 13 ) == "suspend_alarm") { | 927 | if ( mess.left( 13 ) == "suspend_alarm") { |
928 | bool error = false; | 928 | bool error = false; |
929 | int len = mess.mid( 13 ).find("+++"); | 929 | int len = mess.mid( 13 ).find("+++"); |
930 | if ( len < 2 ) | 930 | if ( len < 2 ) |
931 | error = true; | 931 | error = true; |
932 | else { | 932 | else { |
933 | tempfilename = mess.mid( 13, len ); | 933 | tempfilename = mess.mid( 13, len ); |
934 | if ( !QFile::exists( tempfilename ) ) | 934 | if ( !QFile::exists( tempfilename ) ) |
935 | error = true; | 935 | error = true; |
936 | } | 936 | } |
937 | if ( ! error ) { | 937 | if ( ! error ) { |
938 | filename = tempfilename; | 938 | filename = tempfilename; |
939 | } | 939 | } |
940 | mAlarmMessage = mess.mid( 13+len+3 ); | 940 | mAlarmMessage = mess.mid( 13+len+3 ); |
941 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 941 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
942 | startAlarm( mAlarmMessage, filename); | 942 | startAlarm( mAlarmMessage, filename); |
943 | return; | 943 | return; |
944 | } | 944 | } |
945 | if ( mess.left( 11 ) == "timer_alarm") { | 945 | if ( mess.left( 11 ) == "timer_alarm") { |
946 | //mTimerTime = 0; | 946 | //mTimerTime = 0; |
947 | startAlarm( mess.mid( 11 ), filename ); | 947 | startAlarm( mess.mid( 11 ), filename ); |
948 | return; | 948 | return; |
949 | } | 949 | } |
950 | if ( mess.left( 10 ) == "proc_alarm") { | 950 | if ( mess.left( 10 ) == "proc_alarm") { |
951 | bool error = false; | 951 | bool error = false; |
952 | int len = mess.mid( 10 ).find("+++"); | 952 | int len = mess.mid( 10 ).find("+++"); |
953 | if ( len < 2 ) | 953 | if ( len < 2 ) |
954 | error = true; | 954 | error = true; |
955 | else { | 955 | else { |
956 | tempfilename = mess.mid( 10, len ); | 956 | tempfilename = mess.mid( 10, len ); |
957 | if ( !QFile::exists( tempfilename ) ) | 957 | if ( !QFile::exists( tempfilename ) ) |
958 | error = true; | 958 | error = true; |
959 | } | 959 | } |
960 | if ( error ) { | 960 | if ( error ) { |
961 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 961 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
962 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 962 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
963 | } else { | 963 | } else { |
964 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 964 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
965 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 965 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
966 | #ifndef _WIN32_ | 966 | #ifndef _WIN32_ |
967 | if ( vfork () == 0 ) { | 967 | if ( vfork () == 0 ) { |
968 | execl ( tempfilename.latin1(), 0 ); | 968 | execl ( tempfilename.latin1(), 0 ); |
969 | return; | 969 | return; |
970 | } | 970 | } |
971 | #else | 971 | #else |
972 | QProcess* p = new QProcess(); | 972 | QProcess* p = new QProcess(); |
973 | p->addArgument( tempfilename.latin1() ); | 973 | p->addArgument( tempfilename.latin1() ); |
974 | p->start(); | 974 | p->start(); |
975 | return; | 975 | return; |
976 | #endif | 976 | #endif |
977 | 977 | ||
978 | return; | 978 | return; |
979 | } | 979 | } |
980 | 980 | ||
981 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 981 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
982 | } | 982 | } |
983 | if ( mess.left( 11 ) == "audio_alarm") { | 983 | if ( mess.left( 11 ) == "audio_alarm") { |
984 | bool error = false; | 984 | bool error = false; |
985 | int len = mess.mid( 11 ).find("+++"); | 985 | int len = mess.mid( 11 ).find("+++"); |
986 | if ( len < 2 ) | 986 | if ( len < 2 ) |
987 | error = true; | 987 | error = true; |
988 | else { | 988 | else { |
989 | tempfilename = mess.mid( 11, len ); | 989 | tempfilename = mess.mid( 11, len ); |
990 | if ( !QFile::exists( tempfilename ) ) | 990 | if ( !QFile::exists( tempfilename ) ) |
991 | error = true; | 991 | error = true; |
992 | } | 992 | } |
993 | if ( ! error ) { | 993 | if ( ! error ) { |
994 | filename = tempfilename; | 994 | filename = tempfilename; |
995 | } | 995 | } |
996 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 996 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
997 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 997 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
998 | } | 998 | } |
999 | if ( mess.left( 9 ) == "cal_alarm") { | 999 | if ( mess.left( 9 ) == "cal_alarm") { |
1000 | mAlarmMessage = mess.mid( 9 ) ; | 1000 | mAlarmMessage = mess.mid( 9 ) ; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | startAlarm( mAlarmMessage, filename ); | 1003 | startAlarm( mAlarmMessage, filename ); |
1004 | 1004 | ||
1005 | 1005 | ||
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1008 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1009 | { | 1009 | { |
1010 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1010 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1011 | 1011 | ||
1012 | mSuspendAlarmNotification = noti; | 1012 | mSuspendAlarmNotification = noti; |
1013 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1013 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1014 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1014 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1015 | mSuspendTimer->start( ms , true ); | 1015 | mSuspendTimer->start( ms , true ); |
1016 | 1016 | ||
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1019 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1020 | { | 1020 | { |
1021 | mNextAlarmDateTime = qdt; | 1021 | mNextAlarmDateTime = qdt; |
1022 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1022 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1023 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1023 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1024 | #ifndef DESKTOP_VERSION | 1024 | #ifndef DESKTOP_VERSION |
1025 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1025 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1026 | #endif | 1026 | #endif |
1027 | return; | 1027 | return; |
1028 | } | 1028 | } |
1029 | int maxSec; | 1029 | int maxSec; |
1030 | //maxSec = 5; //testing only | 1030 | //maxSec = 5; //testing only |
1031 | maxSec = 86400+3600; // one day+1hour | 1031 | maxSec = 86400+3600; // one day+1hour |
1032 | mAlarmNotification = noti; | 1032 | mAlarmNotification = noti; |
1033 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1033 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1034 | if ( sec > maxSec ) { | 1034 | if ( sec > maxSec ) { |
1035 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1035 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1036 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1036 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1037 | return; | 1037 | return; |
1038 | } else { | 1038 | } else { |
1039 | mRecheckAlarmTimer->stop(); | 1039 | mRecheckAlarmTimer->stop(); |
1040 | } | 1040 | } |
1041 | //qDebug("Alarm timer started with secs: %d ", sec); | 1041 | //qDebug("Alarm timer started with secs: %d ", sec); |
1042 | mAlarmTimer->start( sec *1000 , true ); | 1042 | mAlarmTimer->start( sec *1000 , true ); |
1043 | 1043 | ||
1044 | } | 1044 | } |
1045 | // called by mRecheckAlarmTimer to get next alarm | 1045 | // called by mRecheckAlarmTimer to get next alarm |
1046 | // we need this, because a QTimer has only a max range of 25 days | 1046 | // we need this, because a QTimer has only a max range of 25 days |
1047 | void CalendarView::recheckTimerAlarm() | 1047 | void CalendarView::recheckTimerAlarm() |
1048 | { | 1048 | { |
1049 | mAlarmTimer->stop(); | 1049 | mAlarmTimer->stop(); |
1050 | mRecheckAlarmTimer->stop(); | 1050 | mRecheckAlarmTimer->stop(); |
1051 | mCalendar->checkAlarmForIncidence( 0, true ); | 1051 | mCalendar->checkAlarmForIncidence( 0, true ); |
1052 | } | 1052 | } |
1053 | #ifndef DESKTOP_VERSION | 1053 | #ifndef DESKTOP_VERSION |
1054 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1054 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1055 | #else | 1055 | #else |
1056 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1056 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1057 | #endif | 1057 | #endif |
1058 | { | 1058 | { |
1059 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1059 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1060 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1060 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1061 | #ifndef DESKTOP_VERSION | 1061 | #ifndef DESKTOP_VERSION |
1062 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1062 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1063 | #endif | 1063 | #endif |
1064 | return; | 1064 | return; |
1065 | } | 1065 | } |
1066 | mAlarmTimer->stop(); | 1066 | mAlarmTimer->stop(); |
1067 | } | 1067 | } |
1068 | void CalendarView::selectWeekNum ( int num ) | 1068 | void CalendarView::selectWeekNum ( int num ) |
1069 | { | 1069 | { |
1070 | dateNavigator()->blockSignals( true ); | 1070 | dateNavigator()->blockSignals( true ); |
1071 | dateNavigator()->selectWeek( num ); | 1071 | dateNavigator()->selectWeek( num ); |
1072 | dateNavigator()->blockSignals( false ); | 1072 | dateNavigator()->blockSignals( false ); |
1073 | mViewManager->showWeekView(); | 1073 | mViewManager->showWeekView(); |
1074 | } | 1074 | } |
1075 | KOViewManager *CalendarView::viewManager() | 1075 | KOViewManager *CalendarView::viewManager() |
1076 | { | 1076 | { |
1077 | return mViewManager; | 1077 | return mViewManager; |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | KODialogManager *CalendarView::dialogManager() | 1080 | KODialogManager *CalendarView::dialogManager() |
1081 | { | 1081 | { |
1082 | return mDialogManager; | 1082 | return mDialogManager; |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | QDate CalendarView::startDate() | 1085 | QDate CalendarView::startDate() |
1086 | { | 1086 | { |
1087 | DateList dates = mNavigator->selectedDates(); | 1087 | DateList dates = mNavigator->selectedDates(); |
1088 | 1088 | ||
1089 | return dates.first(); | 1089 | return dates.first(); |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | QDate CalendarView::endDate() | 1092 | QDate CalendarView::endDate() |
1093 | { | 1093 | { |
1094 | DateList dates = mNavigator->selectedDates(); | 1094 | DateList dates = mNavigator->selectedDates(); |
1095 | 1095 | ||
1096 | return dates.last(); | 1096 | return dates.last(); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | 1099 | ||
1100 | void CalendarView::createPrinter() | 1100 | void CalendarView::createPrinter() |
1101 | { | 1101 | { |
1102 | #ifndef KORG_NOPRINTER | 1102 | #ifndef KORG_NOPRINTER |
1103 | if (!mCalPrinter) { | 1103 | if (!mCalPrinter) { |
1104 | mCalPrinter = new CalPrinter(this, mCalendar); | 1104 | mCalPrinter = new CalPrinter(this, mCalendar); |
1105 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1105 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1106 | } | 1106 | } |
1107 | #endif | 1107 | #endif |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | 1110 | ||
1111 | //KOPrefs::instance()->mWriteBackFile | 1111 | //KOPrefs::instance()->mWriteBackFile |
1112 | //KOPrefs::instance()->mWriteBackExistingOnly | 1112 | //KOPrefs::instance()->mWriteBackExistingOnly |
1113 | 1113 | ||
1114 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1114 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1115 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1115 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1116 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1116 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1117 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1117 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1118 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1118 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1119 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1119 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1120 | 1120 | ||
1121 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1121 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1122 | { | 1122 | { |
1123 | 1123 | ||
1124 | // 0 equal | 1124 | // 0 equal |
1125 | // 1 take local | 1125 | // 1 take local |
1126 | // 2 take remote | 1126 | // 2 take remote |
1127 | // 3 cancel | 1127 | // 3 cancel |
1128 | QDateTime lastSync = mLastCalendarSync; | 1128 | QDateTime lastSync = mLastCalendarSync; |
1129 | QDateTime localMod = local->lastModified(); | 1129 | QDateTime localMod = local->lastModified(); |
1130 | QDateTime remoteMod = remote->lastModified(); | 1130 | QDateTime remoteMod = remote->lastModified(); |
1131 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1131 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1132 | bool remCh, locCh; | 1132 | bool remCh, locCh; |
1133 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1133 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1134 | //if ( remCh ) | 1134 | //if ( remCh ) |
1135 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1135 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1136 | locCh = ( localMod > mLastCalendarSync ); | 1136 | locCh = ( localMod > mLastCalendarSync ); |
1137 | if ( !remCh && ! locCh ) { | 1137 | if ( !remCh && ! locCh ) { |
1138 | //qDebug("both not changed "); | 1138 | //qDebug("both not changed "); |
1139 | lastSync = localMod.addDays(1); | 1139 | lastSync = localMod.addDays(1); |
1140 | if ( mode <= SYNC_PREF_ASK ) | 1140 | if ( mode <= SYNC_PREF_ASK ) |
1141 | return 0; | 1141 | return 0; |
1142 | } else { | 1142 | } else { |
1143 | if ( locCh ) { | 1143 | if ( locCh ) { |
1144 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1144 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1145 | lastSync = localMod.addDays( -1 ); | 1145 | lastSync = localMod.addDays( -1 ); |
1146 | if ( !remCh ) | 1146 | if ( !remCh ) |
1147 | remoteMod = ( lastSync.addDays( -1 ) ); | 1147 | remoteMod = ( lastSync.addDays( -1 ) ); |
1148 | } else { | 1148 | } else { |
1149 | //qDebug(" not loc changed "); | 1149 | //qDebug(" not loc changed "); |
1150 | lastSync = localMod.addDays( 1 ); | 1150 | lastSync = localMod.addDays( 1 ); |
1151 | if ( remCh ) | 1151 | if ( remCh ) |
1152 | remoteMod =( lastSync.addDays( 1 ) ); | 1152 | remoteMod =( lastSync.addDays( 1 ) ); |
1153 | 1153 | ||
1154 | } | 1154 | } |
1155 | } | 1155 | } |
1156 | full = true; | 1156 | full = true; |
1157 | if ( mode < SYNC_PREF_ASK ) | 1157 | if ( mode < SYNC_PREF_ASK ) |
1158 | mode = SYNC_PREF_ASK; | 1158 | mode = SYNC_PREF_ASK; |
1159 | } else { | 1159 | } else { |
1160 | if ( localMod == remoteMod ) | 1160 | if ( localMod == remoteMod ) |
1161 | // if ( local->revision() == remote->revision() ) | 1161 | // if ( local->revision() == remote->revision() ) |
1162 | return 0; | 1162 | return 0; |
1163 | 1163 | ||
1164 | } | 1164 | } |
1165 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1165 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1166 | 1166 | ||
1167 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1167 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1168 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1168 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1169 | //full = true; //debug only | 1169 | //full = true; //debug only |
1170 | if ( full ) { | 1170 | if ( full ) { |
1171 | bool equ = false; | 1171 | bool equ = false; |
1172 | if ( local->typeID() == eventID ) { | 1172 | if ( local->typeID() == eventID ) { |
1173 | equ = (*((Event*) local) == *((Event*) remote)); | 1173 | equ = (*((Event*) local) == *((Event*) remote)); |
1174 | } | 1174 | } |
1175 | else if ( local->typeID() == todoID ) | 1175 | else if ( local->typeID() == todoID ) |
1176 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1176 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1177 | else if ( local->typeID() == journalID ) | 1177 | else if ( local->typeID() == journalID ) |
1178 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1178 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1179 | if ( equ ) { | 1179 | if ( equ ) { |
1180 | //qDebug("equal "); | 1180 | //qDebug("equal "); |
1181 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1181 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1182 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1182 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1183 | } | 1183 | } |
1184 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1184 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1185 | return 0; | 1185 | return 0; |
1186 | 1186 | ||
1187 | }//else //debug only | 1187 | }//else //debug only |
1188 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1188 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1189 | } | 1189 | } |
1190 | int result; | 1190 | int result; |
1191 | bool localIsNew; | 1191 | bool localIsNew; |
1192 | //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() ); | 1192 | //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() ); |
1193 | 1193 | ||
1194 | 1194 | ||
1195 | // ************************************************ | 1195 | // ************************************************ |
1196 | // ************************************************ | 1196 | // ************************************************ |
1197 | // ************************************************ | 1197 | // ************************************************ |
1198 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1198 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1199 | // BUT remoteMod != localMod | 1199 | // BUT remoteMod != localMod |
1200 | 1200 | ||
1201 | 1201 | ||
1202 | if ( full && mode < SYNC_PREF_NEWEST ) | 1202 | if ( full && mode < SYNC_PREF_NEWEST ) |
1203 | mode = SYNC_PREF_ASK; | 1203 | mode = SYNC_PREF_ASK; |
1204 | 1204 | ||
1205 | switch( mode ) { | 1205 | switch( mode ) { |
1206 | case SYNC_PREF_LOCAL: | 1206 | case SYNC_PREF_LOCAL: |
1207 | if ( lastSync > remoteMod ) | 1207 | if ( lastSync > remoteMod ) |
1208 | return 1; | 1208 | return 1; |
1209 | if ( lastSync > localMod ) | 1209 | if ( lastSync > localMod ) |
1210 | return 2; | 1210 | return 2; |
1211 | return 1; | 1211 | return 1; |
1212 | break; | 1212 | break; |
1213 | case SYNC_PREF_REMOTE: | 1213 | case SYNC_PREF_REMOTE: |
1214 | if ( lastSync > localMod ) | 1214 | if ( lastSync > localMod ) |
1215 | return 2; | 1215 | return 2; |
1216 | if ( lastSync > remoteMod ) | 1216 | if ( lastSync > remoteMod ) |
1217 | return 1; | 1217 | return 1; |
1218 | return 2; | 1218 | return 2; |
1219 | break; | 1219 | break; |
1220 | case SYNC_PREF_NEWEST: | 1220 | case SYNC_PREF_NEWEST: |
1221 | if ( localMod >= remoteMod ) | 1221 | if ( localMod >= remoteMod ) |
1222 | return 1; | 1222 | return 1; |
1223 | else | 1223 | else |
1224 | return 2; | 1224 | return 2; |
1225 | break; | 1225 | break; |
1226 | case SYNC_PREF_ASK: | 1226 | case SYNC_PREF_ASK: |
1227 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1227 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1228 | if ( lastSync > remoteMod && lastSync > localMod) | 1228 | if ( lastSync > remoteMod && lastSync > localMod) |
1229 | return 0; | 1229 | return 0; |
1230 | if ( lastSync > remoteMod ) | 1230 | if ( lastSync > remoteMod ) |
1231 | return 1; | 1231 | return 1; |
1232 | if ( lastSync > localMod ) | 1232 | if ( lastSync > localMod ) |
1233 | return 2; | 1233 | return 2; |
1234 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1234 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1235 | localIsNew = localMod >= remoteMod; | 1235 | localIsNew = localMod >= remoteMod; |
1236 | if ( localIsNew ) | 1236 | if ( localIsNew ) |
1237 | getEventViewerDialog()->setColorMode( 1 ); | 1237 | getEventViewerDialog()->setColorMode( 1 ); |
1238 | else | 1238 | else |
1239 | getEventViewerDialog()->setColorMode( 2 ); | 1239 | getEventViewerDialog()->setColorMode( 2 ); |
1240 | getEventViewerDialog()->setIncidence(local); | 1240 | getEventViewerDialog()->setIncidence(local); |
1241 | if ( localIsNew ) | 1241 | if ( localIsNew ) |
1242 | getEventViewerDialog()->setColorMode( 2 ); | 1242 | getEventViewerDialog()->setColorMode( 2 ); |
1243 | else | 1243 | else |
1244 | getEventViewerDialog()->setColorMode( 1 ); | 1244 | getEventViewerDialog()->setColorMode( 1 ); |
1245 | getEventViewerDialog()->addIncidence(remote); | 1245 | getEventViewerDialog()->addIncidence(remote); |
1246 | getEventViewerDialog()->setColorMode( 0 ); | 1246 | getEventViewerDialog()->setColorMode( 0 ); |
1247 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1247 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1248 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1248 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1249 | getEventViewerDialog()->showMe(); | 1249 | getEventViewerDialog()->showMe(); |
1250 | result = getEventViewerDialog()->executeS( localIsNew ); | 1250 | result = getEventViewerDialog()->executeS( localIsNew ); |
1251 | return result; | 1251 | return result; |
1252 | 1252 | ||
1253 | break; | 1253 | break; |
1254 | case SYNC_PREF_FORCE_LOCAL: | 1254 | case SYNC_PREF_FORCE_LOCAL: |
1255 | return 1; | 1255 | return 1; |
1256 | break; | 1256 | break; |
1257 | case SYNC_PREF_FORCE_REMOTE: | 1257 | case SYNC_PREF_FORCE_REMOTE: |
1258 | return 2; | 1258 | return 2; |
1259 | break; | 1259 | break; |
1260 | 1260 | ||
1261 | default: | 1261 | default: |
1262 | // SYNC_PREF_TAKE_BOTH not implemented | 1262 | // SYNC_PREF_TAKE_BOTH not implemented |
1263 | break; | 1263 | break; |
1264 | } | 1264 | } |
1265 | return 0; | 1265 | return 0; |
1266 | } | 1266 | } |
1267 | Event* CalendarView::getLastSyncEvent() | 1267 | Event* CalendarView::getLastSyncEvent() |
1268 | { | 1268 | { |
1269 | Event* lse; | 1269 | Event* lse; |
1270 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1270 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1271 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1271 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1272 | if (!lse) { | 1272 | if (!lse) { |
1273 | lse = new Event(); | 1273 | lse = new Event(); |
1274 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1274 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1275 | QString sum = ""; | 1275 | QString sum = ""; |
1276 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1276 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1277 | sum = "E: "; | 1277 | sum = "E: "; |
1278 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1278 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1279 | lse->setDtStart( mLastCalendarSync ); | 1279 | lse->setDtStart( mLastCalendarSync ); |
1280 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1280 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1281 | lse->setCategories( i18n("SyncEvent") ); | 1281 | lse->setCategories( i18n("SyncEvent") ); |
1282 | lse->setReadOnly( true ); | 1282 | lse->setReadOnly( true ); |
1283 | mCalendar->addEvent( lse ); | 1283 | mCalendar->addEvent( lse ); |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | return lse; | 1286 | return lse; |
1287 | 1287 | ||
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | // we check, if the to delete event has a id for a profile | 1290 | // we check, if the to delete event has a id for a profile |
1291 | // if yes, we set this id in the profile to delete | 1291 | // if yes, we set this id in the profile to delete |
1292 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1292 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1293 | { | 1293 | { |
1294 | if ( lastSync.count() == 0 ) { | 1294 | if ( lastSync.count() == 0 ) { |
1295 | //qDebug(" lastSync.count() == 0"); | 1295 | //qDebug(" lastSync.count() == 0"); |
1296 | return; | 1296 | return; |
1297 | } | 1297 | } |
1298 | if ( toDelete->typeID() == journalID ) | 1298 | if ( toDelete->typeID() == journalID ) |
1299 | return; | 1299 | return; |
1300 | 1300 | ||
1301 | Event* eve = lastSync.first(); | 1301 | Event* eve = lastSync.first(); |
1302 | 1302 | ||
1303 | while ( eve ) { | 1303 | while ( eve ) { |
1304 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1304 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1305 | if ( !id.isEmpty() ) { | 1305 | if ( !id.isEmpty() ) { |
1306 | QString des = eve->description(); | 1306 | QString des = eve->description(); |
1307 | QString pref = "e"; | 1307 | QString pref = "e"; |
1308 | if ( toDelete->typeID() == todoID ) | 1308 | if ( toDelete->typeID() == todoID ) |
1309 | pref = "t"; | 1309 | pref = "t"; |
1310 | des += pref+ id + ","; | 1310 | des += pref+ id + ","; |
1311 | eve->setReadOnly( false ); | 1311 | eve->setReadOnly( false ); |
1312 | eve->setDescription( des ); | 1312 | eve->setDescription( des ); |
1313 | //qDebug("setdes %s ", des.latin1()); | 1313 | //qDebug("setdes %s ", des.latin1()); |
1314 | eve->setReadOnly( true ); | 1314 | eve->setReadOnly( true ); |
1315 | } | 1315 | } |
1316 | eve = lastSync.next(); | 1316 | eve = lastSync.next(); |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | } | 1319 | } |
1320 | void CalendarView::checkExternalId( Incidence * inc ) | 1320 | void CalendarView::checkExternalId( Incidence * inc ) |
1321 | { | 1321 | { |
1322 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1322 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1323 | checkExternSyncEvent( lastSync, inc ); | 1323 | checkExternSyncEvent( lastSync, inc ); |
1324 | 1324 | ||
1325 | } | 1325 | } |
1326 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1326 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1327 | { | 1327 | { |
1328 | bool syncOK = true; | 1328 | bool syncOK = true; |
1329 | int addedEvent = 0; | 1329 | int addedEvent = 0; |
1330 | int addedEventR = 0; | 1330 | int addedEventR = 0; |
1331 | int deletedEventR = 0; | 1331 | int deletedEventR = 0; |
1332 | int deletedEventL = 0; | 1332 | int deletedEventL = 0; |
1333 | int changedLocal = 0; | 1333 | int changedLocal = 0; |
1334 | int changedRemote = 0; | 1334 | int changedRemote = 0; |
1335 | int filteredIN = 0; | 1335 | int filteredIN = 0; |
1336 | int filteredOUT = 0; | 1336 | int filteredOUT = 0; |
1337 | //QPtrList<Event> el = local->rawEvents(); | 1337 | //QPtrList<Event> el = local->rawEvents(); |
1338 | Event* eventR; | 1338 | Event* eventR; |
1339 | QString uid; | 1339 | QString uid; |
1340 | int take; | 1340 | int take; |
1341 | Event* eventRSync; | 1341 | Event* eventRSync; |
1342 | Event* eventLSync; | 1342 | Event* eventLSync; |
1343 | clearAllViews(); | 1343 | clearAllViews(); |
1344 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1344 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1345 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1345 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1346 | bool fullDateRange = false; | 1346 | bool fullDateRange = false; |
1347 | local->resetTempSyncStat(); | 1347 | local->resetTempSyncStat(); |
1348 | mLastCalendarSync = QDateTime::currentDateTime(); | 1348 | mLastCalendarSync = QDateTime::currentDateTime(); |
1349 | if ( mSyncManager->syncWithDesktop() ) { | 1349 | if ( mSyncManager->syncWithDesktop() ) { |
1350 | remote->resetPilotStat(1); | 1350 | remote->resetPilotStat(1); |
1351 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1351 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1352 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1352 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1353 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1353 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1354 | } else { | 1354 | } else { |
1355 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1355 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1356 | } | 1356 | } |
1357 | } | 1357 | } |
1358 | QDateTime modifiedCalendar = mLastCalendarSync; | 1358 | QDateTime modifiedCalendar = mLastCalendarSync; |
1359 | eventLSync = getLastSyncEvent(); | 1359 | eventLSync = getLastSyncEvent(); |
1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1361 | if ( eventR ) { | 1361 | if ( eventR ) { |
1362 | qDebug("last-syncEvent on remote found "); | ||
1362 | eventRSync = (Event*) eventR->clone(); | 1363 | eventRSync = (Event*) eventR->clone(); |
1363 | remote->deleteEvent(eventR ); | 1364 | remote->deleteEvent(eventR ); |
1364 | 1365 | ||
1365 | } else { | 1366 | } else { |
1366 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1367 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1367 | eventRSync = (Event*)eventLSync->clone(); | 1368 | eventRSync = (Event*)eventLSync->clone(); |
1368 | } else { | 1369 | } else { |
1369 | fullDateRange = true; | 1370 | fullDateRange = true; |
1370 | eventRSync = new Event(); | 1371 | eventRSync = new Event(); |
1371 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1372 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1372 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1373 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1373 | eventRSync->setDtStart( mLastCalendarSync ); | 1374 | eventRSync->setDtStart( mLastCalendarSync ); |
1374 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1375 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1375 | eventRSync->setCategories( i18n("SyncEvent") ); | 1376 | eventRSync->setCategories( i18n("SyncEvent") ); |
1376 | } | 1377 | } |
1377 | } | 1378 | } |
1378 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1379 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1379 | fullDateRange = true; | 1380 | fullDateRange = true; |
1380 | 1381 | ||
1381 | if ( ! fullDateRange ) { | 1382 | if ( ! fullDateRange ) { |
1382 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1383 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1383 | 1384 | ||
1384 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1385 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1385 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1386 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1386 | fullDateRange = true; | 1387 | fullDateRange = true; |
1387 | } | 1388 | } |
1388 | } | 1389 | } |
1389 | if ( mSyncManager->syncWithDesktop() ) { | 1390 | if ( mSyncManager->syncWithDesktop() ) { |
1390 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1391 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1391 | } | 1392 | } |
1392 | if ( fullDateRange ) | 1393 | if ( fullDateRange ) |
1393 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1394 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1394 | else | 1395 | else |
1395 | mLastCalendarSync = eventLSync->dtStart(); | 1396 | mLastCalendarSync = eventLSync->dtStart(); |
1396 | // for resyncing if own file has changed | 1397 | // for resyncing if own file has changed |
1397 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1398 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1398 | mLastCalendarSync = loadedFileVersion; | 1399 | mLastCalendarSync = loadedFileVersion; |
1399 | //qDebug("setting mLastCalendarSync "); | 1400 | //qDebug("setting mLastCalendarSync "); |
1400 | } | 1401 | } |
1401 | //qDebug("*************************** "); | 1402 | //qDebug("*************************** "); |
1402 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1403 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1403 | QPtrList<Incidence> er = remote->rawIncidences(); | 1404 | QPtrList<Incidence> er = remote->rawIncidences(); |
1404 | Incidence* inR = er.first(); | 1405 | Incidence* inR = er.first(); |
1405 | Incidence* inL; | 1406 | Incidence* inL; |
1406 | QProgressBar bar( er.count(),0 ); | 1407 | QProgressBar bar( er.count(),0 ); |
1407 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1408 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1408 | 1409 | ||
1409 | // ************** setting up filter ************* | 1410 | // ************** setting up filter ************* |
1410 | CalFilter *filterIN = 0; | 1411 | CalFilter *filterIN = 0; |
1411 | CalFilter *filterOUT = 0; | 1412 | CalFilter *filterOUT = 0; |
1412 | CalFilter *filter = mFilters.first(); | 1413 | CalFilter *filter = mFilters.first(); |
1413 | while(filter) { | 1414 | while(filter) { |
1414 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1415 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1415 | filterIN = filter; | 1416 | filterIN = filter; |
1416 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1417 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1417 | filterOUT = filter; | 1418 | filterOUT = filter; |
1418 | filter = mFilters.next(); | 1419 | filter = mFilters.next(); |
1419 | } | 1420 | } |
1420 | int w = 300; | 1421 | int w = 300; |
1421 | if ( QApplication::desktop()->width() < 320 ) | 1422 | if ( QApplication::desktop()->width() < 320 ) |
1422 | w = 220; | 1423 | w = 220; |
1423 | int h = bar.sizeHint().height() ; | 1424 | int h = bar.sizeHint().height() ; |
1424 | int dw = QApplication::desktop()->width(); | 1425 | int dw = QApplication::desktop()->width(); |
1425 | int dh = QApplication::desktop()->height(); | 1426 | int dh = QApplication::desktop()->height(); |
1426 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1427 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1427 | bar.show(); | 1428 | bar.show(); |
1428 | int modulo = (er.count()/10)+1; | 1429 | int modulo = (er.count()/10)+1; |
1429 | int incCounter = 0; | 1430 | int incCounter = 0; |
1430 | while ( inR ) { | 1431 | while ( inR ) { |
1431 | if ( ! bar.isVisible() ) | 1432 | if ( ! bar.isVisible() ) |
1432 | return false; | 1433 | return false; |
1433 | if ( incCounter % modulo == 0 ) | 1434 | if ( incCounter % modulo == 0 ) |
1434 | bar.setProgress( incCounter ); | 1435 | bar.setProgress( incCounter ); |
1435 | ++incCounter; | 1436 | ++incCounter; |
1436 | uid = inR->uid(); | 1437 | uid = inR->uid(); |
1437 | bool skipIncidence = false; | 1438 | bool skipIncidence = false; |
1438 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1439 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1439 | skipIncidence = true; | 1440 | skipIncidence = true; |
1440 | QString idS; | 1441 | QString idS; |
1441 | qApp->processEvents(); | 1442 | qApp->processEvents(); |
1442 | if ( !skipIncidence ) { | 1443 | if ( !skipIncidence ) { |
1443 | inL = local->incidence( uid ); | 1444 | inL = local->incidence( uid ); |
1444 | if ( inL ) { // maybe conflict - same uid in both calendars | 1445 | if ( inL ) { // maybe conflict - same uid in both calendars |
1445 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1446 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1446 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1447 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1447 | if ( take == 3 ) | 1448 | if ( take == 3 ) |
1448 | return false; | 1449 | return false; |
1449 | if ( take == 1 ) {// take local ********************** | 1450 | if ( take == 1 ) {// take local ********************** |
1450 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1451 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1451 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1452 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1452 | else | 1453 | else |
1453 | idS = inR->IDStr(); | 1454 | idS = inR->IDStr(); |
1454 | int calID = inR->calID(); | 1455 | int calID = inR->calID(); |
1455 | remote->deleteIncidence( inR ); | 1456 | remote->deleteIncidence( inR ); |
1456 | inR = inL->clone(); | 1457 | inR = inL->clone(); |
1457 | inR->setCalID( calID ); | 1458 | inR->setCalID( calID ); |
1458 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1459 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1459 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1460 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1460 | inR->setIDStr( idS ); | 1461 | inR->setIDStr( idS ); |
1461 | remote->addIncidence( inR ); | 1462 | remote->addIncidence( inR ); |
1462 | if ( mSyncManager->syncWithDesktop() ) | 1463 | if ( mSyncManager->syncWithDesktop() ) |
1463 | inR->setPilotId( 2 ); | 1464 | inR->setPilotId( 2 ); |
1464 | ++changedRemote; | 1465 | ++changedRemote; |
1465 | } else {// take remote ********************** | 1466 | } else {// take remote ********************** |
1466 | idS = inL->IDStr(); | 1467 | idS = inL->IDStr(); |
1467 | int pid = inL->pilotId(); | 1468 | int pid = inL->pilotId(); |
1468 | int calID = inL->calID(); | 1469 | int calID = inL->calID(); |
1469 | local->deleteIncidence( inL ); | 1470 | local->deleteIncidence( inL ); |
1470 | inL = inR->clone(); | 1471 | inL = inR->clone(); |
1471 | inL->setCalID( calID ); | 1472 | inL->setCalID( calID ); |
1472 | if ( mSyncManager->syncWithDesktop() ) | 1473 | if ( mSyncManager->syncWithDesktop() ) |
1473 | inL->setPilotId( pid ); | 1474 | inL->setPilotId( pid ); |
1474 | inL->setIDStr( idS ); | 1475 | inL->setIDStr( idS ); |
1475 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1476 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1476 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1477 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1477 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1478 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1478 | } | 1479 | } |
1479 | local->addIncidence( inL ); | 1480 | local->addIncidence( inL ); |
1480 | ++changedLocal; | 1481 | ++changedLocal; |
1481 | } | 1482 | } |
1482 | } | 1483 | } |
1483 | } else { // no conflict ********** add or delete remote | 1484 | } else { // no conflict ********** add or delete remote |
1484 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1485 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1485 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1486 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1486 | QString des = eventLSync->description(); | 1487 | QString des = eventLSync->description(); |
1487 | QString pref = "e"; | 1488 | QString pref = "e"; |
1488 | if ( inR->typeID() == todoID ) | 1489 | if ( inR->typeID() == todoID ) |
1489 | pref = "t"; | 1490 | pref = "t"; |
1490 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1491 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1491 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1492 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1492 | //remote->deleteIncidence( inR ); | 1493 | //remote->deleteIncidence( inR ); |
1493 | ++deletedEventR; | 1494 | ++deletedEventR; |
1494 | } else { | 1495 | } else { |
1495 | inR->setLastModified( modifiedCalendar ); | 1496 | inR->setLastModified( modifiedCalendar ); |
1496 | inL = inR->clone(); | 1497 | inL = inR->clone(); |
1497 | inL->setIDStr( ":" ); | 1498 | inL->setIDStr( ":" ); |
1498 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1499 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1499 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1500 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1500 | 1501 | ||
1501 | inL->setCalID( 0 );// add to default cal | 1502 | inL->setCalID( 0 );// add to default cal |
1502 | local->addIncidence( inL ); | 1503 | local->addIncidence( inL ); |
1503 | ++addedEvent; | 1504 | ++addedEvent; |
1504 | 1505 | ||
1505 | } | 1506 | } |
1506 | } else { | 1507 | } else { |
1507 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1508 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1508 | inR->setLastModified( modifiedCalendar ); | 1509 | inR->setLastModified( modifiedCalendar ); |
1509 | inL = inR->clone(); | 1510 | inL = inR->clone(); |
1510 | inL->setIDStr( ":" ); | 1511 | inL->setIDStr( ":" ); |
1511 | inL->setCalID( 0 );// add to default cal | 1512 | inL->setCalID( 0 );// add to default cal |
1512 | local->addIncidence( inL ); | 1513 | local->addIncidence( inL ); |
1513 | ++addedEvent; | 1514 | ++addedEvent; |
1514 | 1515 | ||
1515 | } else { | 1516 | } else { |
1516 | checkExternSyncEvent(eventRSyncSharp, inR); | 1517 | checkExternSyncEvent(eventRSyncSharp, inR); |
1517 | remote->deleteIncidence( inR ); | 1518 | remote->deleteIncidence( inR ); |
1518 | ++deletedEventR; | 1519 | ++deletedEventR; |
1519 | } | 1520 | } |
1520 | } | 1521 | } |
1521 | } else { | 1522 | } else { |
1522 | ++filteredIN; | 1523 | ++filteredIN; |
1523 | } | 1524 | } |
1524 | } | 1525 | } |
1525 | } | 1526 | } |
1526 | inR = er.next(); | 1527 | inR = er.next(); |
1527 | } | 1528 | } |
1528 | QPtrList<Incidence> el = local->rawIncidences(); | 1529 | QPtrList<Incidence> el = local->rawIncidences(); |
1529 | inL = el.first(); | 1530 | inL = el.first(); |
1530 | modulo = (el.count()/10)+1; | 1531 | modulo = (el.count()/10)+1; |
1531 | bar.setCaption (i18n("Add / remove events") ); | 1532 | bar.setCaption (i18n("Add / remove events") ); |
1532 | bar.setTotalSteps ( el.count() ) ; | 1533 | bar.setTotalSteps ( el.count() ) ; |
1533 | bar.show(); | 1534 | bar.show(); |
1534 | incCounter = 0; | 1535 | incCounter = 0; |
1535 | 1536 | ||
1536 | while ( inL ) { | 1537 | while ( inL ) { |
1537 | 1538 | ||
1538 | qApp->processEvents(); | 1539 | qApp->processEvents(); |
1539 | if ( ! bar.isVisible() ) | 1540 | if ( ! bar.isVisible() ) |
1540 | return false; | 1541 | return false; |
1541 | if ( incCounter % modulo == 0 ) | 1542 | if ( incCounter % modulo == 0 ) |
1542 | bar.setProgress( incCounter ); | 1543 | bar.setProgress( incCounter ); |
1543 | ++incCounter; | 1544 | ++incCounter; |
1544 | uid = inL->uid(); | 1545 | uid = inL->uid(); |
1545 | bool skipIncidence = false; | 1546 | bool skipIncidence = false; |
1546 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1547 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1547 | skipIncidence = true; | 1548 | skipIncidence = true; |
1548 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1549 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1549 | skipIncidence = true; | 1550 | skipIncidence = true; |
1550 | if ( !skipIncidence ) { | 1551 | if ( !skipIncidence ) { |
1551 | inR = remote->incidence( uid ); | 1552 | inR = remote->incidence( uid ); |
1552 | if ( ! inR ) { | 1553 | if ( ! inR ) { |
1553 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1554 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1554 | // no conflict ********** add or delete local | 1555 | // no conflict ********** add or delete local |
1555 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1556 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1556 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1557 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1557 | checkExternSyncEvent(eventLSyncSharp, inL); | 1558 | checkExternSyncEvent(eventLSyncSharp, inL); |
1558 | local->deleteIncidence( inL ); | 1559 | local->deleteIncidence( inL ); |
1559 | ++deletedEventL; | 1560 | ++deletedEventL; |
1560 | } else { | 1561 | } else { |
1561 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1562 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1562 | inL->removeID(mCurrentSyncDevice ); | 1563 | inL->removeID(mCurrentSyncDevice ); |
1563 | ++addedEventR; | 1564 | ++addedEventR; |
1564 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1565 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1565 | inL->setLastModified( modifiedCalendar ); | 1566 | inL->setLastModified( modifiedCalendar ); |
1566 | inR = inL->clone(); | 1567 | inR = inL->clone(); |
1567 | inR->setIDStr( ":" ); | 1568 | inR->setIDStr( ":" ); |
1568 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1569 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1569 | inR->setCalID( 0 );// add to default cal | 1570 | inR->setCalID( 0 );// add to default cal |
1570 | remote->addIncidence( inR ); | 1571 | remote->addIncidence( inR ); |
1571 | } | 1572 | } |
1572 | } | 1573 | } |
1573 | } else { | 1574 | } else { |
1574 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1575 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1575 | checkExternSyncEvent(eventLSyncSharp, inL); | 1576 | checkExternSyncEvent(eventLSyncSharp, inL); |
1576 | local->deleteIncidence( inL ); | 1577 | local->deleteIncidence( inL ); |
1577 | ++deletedEventL; | 1578 | ++deletedEventL; |
1578 | } else { | 1579 | } else { |
1579 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1580 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1580 | ++addedEventR; | 1581 | ++addedEventR; |
1581 | inL->setLastModified( modifiedCalendar ); | 1582 | inL->setLastModified( modifiedCalendar ); |
1582 | inR = inL->clone(); | 1583 | inR = inL->clone(); |
1583 | inR->setIDStr( ":" ); | 1584 | inR->setIDStr( ":" ); |
1584 | inR->setCalID( 0 );// add to default cal | 1585 | inR->setCalID( 0 );// add to default cal |
1585 | remote->addIncidence( inR ); | 1586 | remote->addIncidence( inR ); |
1586 | } | 1587 | } |
1587 | } | 1588 | } |
1588 | } | 1589 | } |
1589 | } else { | 1590 | } else { |
1590 | ++filteredOUT; | 1591 | ++filteredOUT; |
1591 | } | 1592 | } |
1592 | } | 1593 | } |
1593 | } | 1594 | } |
1594 | inL = el.next(); | 1595 | inL = el.next(); |
1595 | } | 1596 | } |
1596 | int delFut = 0; | 1597 | int delFut = 0; |
1597 | int remRem = 0; | 1598 | int remRem = 0; |
1598 | if ( mSyncManager->mWriteBackInFuture ) { | 1599 | if ( mSyncManager->mWriteBackInFuture ) { |
1599 | er = remote->rawIncidences(); | 1600 | er = remote->rawIncidences(); |
1600 | remRem = er.count(); | 1601 | remRem = er.count(); |
1601 | inR = er.first(); | 1602 | inR = er.first(); |
1602 | QDateTime dt; | 1603 | QDateTime dt; |
1603 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1604 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1604 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1605 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1605 | while ( inR ) { | 1606 | while ( inR ) { |
1606 | if ( inR->typeID() == todoID ) { | 1607 | if ( inR->typeID() == todoID ) { |
1607 | Todo * t = (Todo*)inR; | 1608 | Todo * t = (Todo*)inR; |
1608 | if ( t->hasDueDate() ) | 1609 | if ( t->hasDueDate() ) |
1609 | dt = t->dtDue(); | 1610 | dt = t->dtDue(); |
1610 | else | 1611 | else |
1611 | dt = cur.addSecs( 62 ); | 1612 | dt = cur.addSecs( 62 ); |
1612 | } | 1613 | } |
1613 | else if (inR->typeID() == eventID ) { | 1614 | else if (inR->typeID() == eventID ) { |
1614 | bool ok; | 1615 | bool ok; |
1615 | dt = inR->getNextOccurence( cur, &ok ); | 1616 | dt = inR->getNextOccurence( cur, &ok ); |
1616 | if ( !ok ) | 1617 | if ( !ok ) |
1617 | dt = cur.addSecs( -62 ); | 1618 | dt = cur.addSecs( -62 ); |
1618 | } | 1619 | } |
1619 | else | 1620 | else |
1620 | dt = inR->dtStart(); | 1621 | dt = inR->dtStart(); |
1621 | if ( dt < cur || dt > end ) { | 1622 | if ( dt < cur || dt > end ) { |
1622 | remote->deleteIncidence( inR ); | 1623 | remote->deleteIncidence( inR ); |
1623 | ++delFut; | 1624 | ++delFut; |
1624 | } | 1625 | } |
1625 | inR = er.next(); | 1626 | inR = er.next(); |
1626 | } | 1627 | } |
1627 | } | 1628 | } |
1628 | bar.hide(); | 1629 | bar.hide(); |
1629 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1630 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1630 | eventLSync->setReadOnly( false ); | 1631 | eventLSync->setReadOnly( false ); |
1631 | eventLSync->setDtStart( mLastCalendarSync ); | 1632 | eventLSync->setDtStart( mLastCalendarSync ); |
1632 | eventRSync->setDtStart( mLastCalendarSync ); | 1633 | eventRSync->setDtStart( mLastCalendarSync ); |
1633 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1634 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1634 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1635 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1635 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1636 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1636 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1637 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1637 | eventLSync->setReadOnly( true ); | 1638 | eventLSync->setReadOnly( true ); |
1638 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1639 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1639 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1640 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1640 | remote->addEvent( eventRSync ); | 1641 | remote->addEvent( eventRSync ); |
1641 | else | 1642 | else |
1642 | delete eventRSync; | 1643 | delete eventRSync; |
1643 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1644 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1644 | QString mes; | 1645 | QString mes; |
1645 | 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 ); | 1646 | 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 ); |
1646 | QString delmess; | 1647 | QString delmess; |
1647 | if ( delFut ) { | 1648 | if ( delFut ) { |
1648 | 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); | 1649 | 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); |
1649 | mes += delmess; | 1650 | mes += delmess; |
1650 | } | 1651 | } |
1651 | mes = i18n("Local calendar changed!\n") +mes; | 1652 | mes = i18n("Local calendar changed!\n") +mes; |
1652 | mCalendar->checkAlarmForIncidence( 0, true ); | 1653 | mCalendar->checkAlarmForIncidence( 0, true ); |
1653 | qDebug( mes ); | 1654 | qDebug( mes ); |
1654 | if ( mSyncManager->mShowSyncSummary ) { | 1655 | if ( mSyncManager->mShowSyncSummary ) { |
1655 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1656 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1656 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1657 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1657 | qDebug("KO: WB cancelled "); | 1658 | qDebug("KO: WB cancelled "); |
1658 | mSyncManager->mWriteBackFile = false; | 1659 | mSyncManager->mWriteBackFile = false; |
1659 | return syncOK; | 1660 | return syncOK; |
1660 | } | 1661 | } |
1661 | } | 1662 | } |
1662 | return syncOK; | 1663 | return syncOK; |
1663 | } | 1664 | } |
1664 | 1665 | ||
1665 | void CalendarView::setSyncDevice( QString s ) | 1666 | void CalendarView::setSyncDevice( QString s ) |
1666 | { | 1667 | { |
1667 | mCurrentSyncDevice= s; | 1668 | mCurrentSyncDevice= s; |
1668 | } | 1669 | } |
1669 | void CalendarView::setSyncName( QString s ) | 1670 | void CalendarView::setSyncName( QString s ) |
1670 | { | 1671 | { |
1671 | mCurrentSyncName= s; | 1672 | mCurrentSyncName= s; |
1672 | } | 1673 | } |
1673 | bool CalendarView::syncCalendar(QString filename, int mode) | 1674 | bool CalendarView::syncCalendar(QString filename, int mode) |
1674 | { | 1675 | { |
1675 | //qDebug("syncCalendar %s ", filename.latin1()); | 1676 | //qDebug("syncCalendar %s ", filename.latin1()); |
1676 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1677 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1677 | CalendarLocal* calendar = new CalendarLocal(); | 1678 | CalendarLocal* calendar = new CalendarLocal(); |
1678 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1679 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1679 | FileStorage* storage = new FileStorage( calendar ); | 1680 | FileStorage* storage = new FileStorage( calendar ); |
1680 | bool syncOK = false; | 1681 | bool syncOK = false; |
1681 | storage->setFileName( filename ); | 1682 | storage->setFileName( filename ); |
1682 | // qDebug("loading ... "); | 1683 | // qDebug("loading ... "); |
1683 | if ( storage->load() ) { | 1684 | if ( storage->load() ) { |
1684 | getEventViewerDialog()->setSyncMode( true ); | 1685 | getEventViewerDialog()->setSyncMode( true ); |
1685 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1686 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1686 | getEventViewerDialog()->setSyncMode( false ); | 1687 | getEventViewerDialog()->setSyncMode( false ); |
1687 | if ( syncOK ) { | 1688 | if ( syncOK ) { |
1688 | if ( mSyncManager->mWriteBackFile ) | 1689 | if ( mSyncManager->mWriteBackFile ) |
1689 | { | 1690 | { |
1690 | storage->setSaveFormat( new ICalFormat() ); | 1691 | storage->setSaveFormat( new ICalFormat() ); |
1691 | storage->save(); | 1692 | storage->save(); |
1692 | } | 1693 | } |
1693 | } | 1694 | } |
1694 | setModified( true ); | 1695 | setModified( true ); |
1695 | } | 1696 | } |
1696 | delete storage; | 1697 | delete storage; |
1697 | delete calendar; | 1698 | delete calendar; |
1698 | if ( syncOK ) | 1699 | if ( syncOK ) |
1699 | updateView(); | 1700 | updateView(); |
1700 | return syncOK; | 1701 | return syncOK; |
1701 | } | 1702 | } |
1702 | 1703 | ||
1703 | void CalendarView::syncExternal( int mode ) | 1704 | void CalendarView::syncExternal( int mode ) |
1704 | { | 1705 | { |
1705 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1706 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1706 | 1707 | ||
1707 | qApp->processEvents(); | 1708 | qApp->processEvents(); |
1708 | CalendarLocal* calendar = new CalendarLocal(); | 1709 | CalendarLocal* calendar = new CalendarLocal(); |
1709 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1710 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1710 | bool syncOK = false; | 1711 | bool syncOK = false; |
1711 | bool loadSuccess = false; | 1712 | bool loadSuccess = false; |
1712 | PhoneFormat* phoneFormat = 0; | 1713 | PhoneFormat* phoneFormat = 0; |
1713 | emit tempDisableBR(true); | 1714 | emit tempDisableBR(true); |
1714 | #ifndef DESKTOP_VERSION | 1715 | #ifndef DESKTOP_VERSION |
1715 | SharpFormat* sharpFormat = 0; | 1716 | SharpFormat* sharpFormat = 0; |
1716 | if ( mode == 0 ) { // sharp | 1717 | if ( mode == 0 ) { // sharp |
1717 | sharpFormat = new SharpFormat () ; | 1718 | sharpFormat = new SharpFormat () ; |
1718 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1719 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1719 | 1720 | ||
1720 | } else | 1721 | } else |
1721 | #endif | 1722 | #endif |
1722 | if ( mode == 1 ) { // phone | 1723 | if ( mode == 1 ) { // phone |
1723 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1724 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1724 | mSyncManager->mPhoneDevice, | 1725 | mSyncManager->mPhoneDevice, |
1725 | mSyncManager->mPhoneConnection, | 1726 | mSyncManager->mPhoneConnection, |
1726 | mSyncManager->mPhoneModel); | 1727 | mSyncManager->mPhoneModel); |
1727 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1728 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1728 | 1729 | ||
1729 | } else { | 1730 | } else { |
1730 | emit tempDisableBR(false); | 1731 | emit tempDisableBR(false); |
1731 | return; | 1732 | return; |
1732 | } | 1733 | } |
1733 | if ( loadSuccess ) { | 1734 | if ( loadSuccess ) { |
1734 | getEventViewerDialog()->setSyncMode( true ); | 1735 | getEventViewerDialog()->setSyncMode( true ); |
1735 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1736 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1736 | getEventViewerDialog()->setSyncMode( false ); | 1737 | getEventViewerDialog()->setSyncMode( false ); |
1737 | qApp->processEvents(); | 1738 | qApp->processEvents(); |
1738 | if ( syncOK ) { | 1739 | if ( syncOK ) { |
1739 | if ( mSyncManager->mWriteBackFile ) | 1740 | if ( mSyncManager->mWriteBackFile ) |
1740 | { | 1741 | { |
1741 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1742 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1742 | Incidence* inc = iL.first(); | 1743 | Incidence* inc = iL.first(); |
1743 | if ( phoneFormat ) { | 1744 | if ( phoneFormat ) { |
1744 | while ( inc ) { | 1745 | while ( inc ) { |
1745 | inc->removeID(mCurrentSyncDevice); | 1746 | inc->removeID(mCurrentSyncDevice); |
1746 | inc = iL.next(); | 1747 | inc = iL.next(); |
1747 | } | 1748 | } |
1748 | } | 1749 | } |
1749 | #ifndef DESKTOP_VERSION | 1750 | #ifndef DESKTOP_VERSION |
1750 | if ( sharpFormat ) | 1751 | if ( sharpFormat ) |
1751 | sharpFormat->save(calendar); | 1752 | sharpFormat->save(calendar); |
1752 | #endif | 1753 | #endif |
1753 | if ( phoneFormat ) | 1754 | if ( phoneFormat ) |
1754 | phoneFormat->save(calendar); | 1755 | phoneFormat->save(calendar); |
1755 | iL = calendar->rawIncidences(); | 1756 | iL = calendar->rawIncidences(); |
1756 | inc = iL.first(); | 1757 | inc = iL.first(); |
1757 | Incidence* loc; | 1758 | Incidence* loc; |
1758 | while ( inc ) { | 1759 | while ( inc ) { |
1759 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1760 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1760 | loc = mCalendar->incidence(inc->uid() ); | 1761 | loc = mCalendar->incidence(inc->uid() ); |
1761 | if ( loc ) { | 1762 | if ( loc ) { |
1762 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1763 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1763 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1764 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1764 | } | 1765 | } |
1765 | } | 1766 | } |
1766 | inc = iL.next(); | 1767 | inc = iL.next(); |
1767 | } | 1768 | } |
1768 | Incidence* lse = getLastSyncEvent(); | 1769 | Incidence* lse = getLastSyncEvent(); |
1769 | if ( lse ) { | 1770 | if ( lse ) { |
1770 | lse->setReadOnly( false ); | 1771 | lse->setReadOnly( false ); |
1771 | lse->setDescription( "" ); | 1772 | lse->setDescription( "" ); |
1772 | lse->setReadOnly( true ); | 1773 | lse->setReadOnly( true ); |
1773 | } | 1774 | } |
1774 | } | 1775 | } |
1775 | } else { | 1776 | } else { |
1776 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1777 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1777 | } | 1778 | } |
1778 | setModified( true ); | 1779 | setModified( true ); |
1779 | } else { | 1780 | } else { |
1780 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1781 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1781 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1782 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1782 | question, i18n("Ok")) ; | 1783 | question, i18n("Ok")) ; |
1783 | 1784 | ||
1784 | } | 1785 | } |
1785 | delete calendar; | 1786 | delete calendar; |
1786 | updateView(); | 1787 | updateView(); |
1787 | emit tempDisableBR(false); | 1788 | emit tempDisableBR(false); |
1788 | return ;//syncOK; | 1789 | return ;//syncOK; |
1789 | 1790 | ||
1790 | } | 1791 | } |
1791 | 1792 | ||
1792 | bool CalendarView::importBday() | 1793 | bool CalendarView::importBday() |
1793 | { | 1794 | { |
1794 | #ifndef KORG_NOKABC | 1795 | #ifndef KORG_NOKABC |
1795 | 1796 | ||
1796 | #ifdef DESKTOP_VERSION | 1797 | #ifdef DESKTOP_VERSION |
1797 | int curCal = mCalendar->defaultCalendar(); | 1798 | int curCal = mCalendar->defaultCalendar(); |
1798 | int bd = mCalEditView->getBirtdayID(); | 1799 | int bd = mCalEditView->getBirtdayID(); |
1799 | if ( bd == 0 ) | 1800 | if ( bd == 0 ) |
1800 | return false; | 1801 | return false; |
1801 | mCalendar->setDefaultCalendar( bd ); | 1802 | mCalendar->setDefaultCalendar( bd ); |
1802 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1803 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1803 | KABC::AddressBook::Iterator it; | 1804 | KABC::AddressBook::Iterator it; |
1804 | int count = 0; | 1805 | int count = 0; |
1805 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1806 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1806 | ++count; | 1807 | ++count; |
1807 | } | 1808 | } |
1808 | QProgressBar bar(count,0 ); | 1809 | QProgressBar bar(count,0 ); |
1809 | int w = 300; | 1810 | int w = 300; |
1810 | if ( QApplication::desktop()->width() < 320 ) | 1811 | if ( QApplication::desktop()->width() < 320 ) |
1811 | w = 220; | 1812 | w = 220; |
1812 | int h = bar.sizeHint().height() ; | 1813 | int h = bar.sizeHint().height() ; |
1813 | int dw = QApplication::desktop()->width(); | 1814 | int dw = QApplication::desktop()->width(); |
1814 | int dh = QApplication::desktop()->height(); | 1815 | int dh = QApplication::desktop()->height(); |
1815 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1816 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1816 | bar.show(); | 1817 | bar.show(); |
1817 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1818 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1818 | qApp->processEvents(); | 1819 | qApp->processEvents(); |
1819 | count = 0; | 1820 | count = 0; |
1820 | int addCount = 0; | 1821 | int addCount = 0; |
1821 | KCal::Attendee* a = 0; | 1822 | KCal::Attendee* a = 0; |
1822 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1823 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1823 | if ( ! bar.isVisible() ) | 1824 | if ( ! bar.isVisible() ) |
1824 | return false; | 1825 | return false; |
1825 | bar.setProgress( count++ ); | 1826 | bar.setProgress( count++ ); |
1826 | qApp->processEvents(); | 1827 | qApp->processEvents(); |
1827 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1828 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1828 | if ( (*it).birthday().date().isValid() ){ | 1829 | if ( (*it).birthday().date().isValid() ){ |
1829 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1830 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1830 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1831 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1831 | ++addCount; | 1832 | ++addCount; |
1832 | } | 1833 | } |
1833 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1834 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1834 | if ( anni.isValid() ){ | 1835 | if ( anni.isValid() ){ |
1835 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1836 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1836 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1837 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1837 | ++addCount; | 1838 | ++addCount; |
1838 | } | 1839 | } |
1839 | } | 1840 | } |
1840 | mCalendar->setDefaultCalendar( curCal ); | 1841 | mCalendar->setDefaultCalendar( curCal ); |
1841 | updateView(); | 1842 | updateView(); |
1842 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1843 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1843 | #else //DESKTOP_VERSION | 1844 | #else //DESKTOP_VERSION |
1844 | 1845 | ||
1845 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1846 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1846 | // the result should now arrive through method insertBirthdays | 1847 | // the result should now arrive through method insertBirthdays |
1847 | 1848 | ||
1848 | #endif //DESKTOP_VERSION | 1849 | #endif //DESKTOP_VERSION |
1849 | 1850 | ||
1850 | #endif //KORG_NOKABC | 1851 | #endif //KORG_NOKABC |
1851 | 1852 | ||
1852 | 1853 | ||
1853 | return true; | 1854 | return true; |
1854 | } | 1855 | } |
1855 | 1856 | ||
1856 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1857 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1857 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1858 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1858 | const QStringList& anniversaryList, const QStringList& realNameList, | 1859 | const QStringList& anniversaryList, const QStringList& realNameList, |
1859 | const QStringList& emailList, const QStringList& assembledNameList, | 1860 | const QStringList& emailList, const QStringList& assembledNameList, |
1860 | const QStringList& uidList) | 1861 | const QStringList& uidList) |
1861 | { | 1862 | { |
1862 | 1863 | ||
1863 | //qDebug("KO::CalendarView::insertBirthdays"); | 1864 | //qDebug("KO::CalendarView::insertBirthdays"); |
1864 | if (uid == this->name()) | 1865 | if (uid == this->name()) |
1865 | { | 1866 | { |
1866 | int curCal = mCalendar->defaultCalendar(); | 1867 | int curCal = mCalendar->defaultCalendar(); |
1867 | int bd = mCalEditView->getBirtdayID(); | 1868 | int bd = mCalEditView->getBirtdayID(); |
1868 | if ( bd == 0 ) | 1869 | if ( bd == 0 ) |
1869 | return; | 1870 | return; |
1870 | mCalendar->setDefaultCalendar( bd ); | 1871 | mCalendar->setDefaultCalendar( bd ); |
1871 | 1872 | ||
1872 | 1873 | ||
1873 | int count = birthdayList.count(); | 1874 | int count = birthdayList.count(); |
1874 | int addCount = 0; | 1875 | int addCount = 0; |
1875 | KCal::Attendee* a = 0; | 1876 | KCal::Attendee* a = 0; |
1876 | 1877 | ||
1877 | //qDebug("CalView 1 %i", count); | 1878 | //qDebug("CalView 1 %i", count); |
1878 | 1879 | ||
1879 | QProgressBar bar(count,0 ); | 1880 | QProgressBar bar(count,0 ); |
1880 | int w = 300; | 1881 | int w = 300; |
1881 | if ( QApplication::desktop()->width() < 320 ) | 1882 | if ( QApplication::desktop()->width() < 320 ) |
1882 | w = 220; | 1883 | w = 220; |
1883 | int h = bar.sizeHint().height() ; | 1884 | int h = bar.sizeHint().height() ; |
1884 | int dw = QApplication::desktop()->width(); | 1885 | int dw = QApplication::desktop()->width(); |
1885 | int dh = QApplication::desktop()->height(); | 1886 | int dh = QApplication::desktop()->height(); |
1886 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1887 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1887 | bar.show(); | 1888 | bar.show(); |
1888 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1889 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1889 | qApp->processEvents(); | 1890 | qApp->processEvents(); |
1890 | 1891 | ||
1891 | QDate birthday; | 1892 | QDate birthday; |
1892 | QDate anniversary; | 1893 | QDate anniversary; |
1893 | QString realName; | 1894 | QString realName; |
1894 | QString email; | 1895 | QString email; |
1895 | QString assembledName; | 1896 | QString assembledName; |
1896 | QString uid; | 1897 | QString uid; |
1897 | bool ok = true; | 1898 | bool ok = true; |
1898 | for ( int i = 0; i < count; i++) | 1899 | for ( int i = 0; i < count; i++) |
1899 | { | 1900 | { |
1900 | if ( ! bar.isVisible() ) | 1901 | if ( ! bar.isVisible() ) |
1901 | return; | 1902 | return; |
1902 | bar.setProgress( i ); | 1903 | bar.setProgress( i ); |
1903 | qApp->processEvents(); | 1904 | qApp->processEvents(); |
1904 | 1905 | ||
1905 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1906 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1906 | if (!ok) { | 1907 | if (!ok) { |
1907 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1908 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1908 | } | 1909 | } |
1909 | 1910 | ||
1910 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1911 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1911 | if (!ok) { | 1912 | if (!ok) { |
1912 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1913 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1913 | } | 1914 | } |
1914 | realName = realNameList[i]; | 1915 | realName = realNameList[i]; |
1915 | email = emailList[i]; | 1916 | email = emailList[i]; |
1916 | assembledName = assembledNameList[i]; | 1917 | assembledName = assembledNameList[i]; |
1917 | uid = uidList[i]; | 1918 | uid = uidList[i]; |
1918 | //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() ); | 1919 | //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() ); |
1919 | 1920 | ||
1920 | if ( birthday.isValid() ){ | 1921 | if ( birthday.isValid() ){ |
1921 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1922 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1922 | KCal::Attendee::ReqParticipant,uid) ; | 1923 | KCal::Attendee::ReqParticipant,uid) ; |
1923 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1924 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1924 | ++addCount; | 1925 | ++addCount; |
1925 | } | 1926 | } |
1926 | 1927 | ||
1927 | if ( anniversary.isValid() ){ | 1928 | if ( anniversary.isValid() ){ |
1928 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1929 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1929 | KCal::Attendee::ReqParticipant,uid) ; | 1930 | KCal::Attendee::ReqParticipant,uid) ; |
1930 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1931 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1931 | ++addCount; | 1932 | ++addCount; |
1932 | } | 1933 | } |
1933 | } | 1934 | } |
1934 | 1935 | ||
1935 | mCalendar->setDefaultCalendar( curCal ); | 1936 | mCalendar->setDefaultCalendar( curCal ); |
1936 | updateView(); | 1937 | updateView(); |
1937 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1938 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1938 | 1939 | ||
1939 | } | 1940 | } |
1940 | 1941 | ||
1941 | } | 1942 | } |
1942 | 1943 | ||
1943 | 1944 | ||
1944 | 1945 | ||
1945 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1946 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1946 | { | 1947 | { |
1947 | //qDebug("addAnni "); | 1948 | //qDebug("addAnni "); |
1948 | Event * ev = new Event(); | 1949 | Event * ev = new Event(); |
1949 | ev->setOrganizer(KOPrefs::instance()->email()); | 1950 | ev->setOrganizer(KOPrefs::instance()->email()); |
1950 | if ( a ) { | 1951 | if ( a ) { |
1951 | ev->addAttendee( a ); | 1952 | ev->addAttendee( a ); |
1952 | } | 1953 | } |
1953 | QString kind; | 1954 | QString kind; |
1954 | if ( birthday ) { | 1955 | if ( birthday ) { |
1955 | kind = i18n( "Birthday" ); | 1956 | kind = i18n( "Birthday" ); |
1956 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1957 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1957 | } | 1958 | } |
1958 | else { | 1959 | else { |
1959 | kind = i18n( "Anniversary" ); | 1960 | kind = i18n( "Anniversary" ); |
1960 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1961 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1961 | } | 1962 | } |
1962 | ev->setCategories( kind ); | 1963 | ev->setCategories( kind ); |
1963 | ev->setDtStart( QDateTime(date) ); | 1964 | ev->setDtStart( QDateTime(date) ); |
1964 | ev->setDtEnd( QDateTime(date) ); | 1965 | ev->setDtEnd( QDateTime(date) ); |
1965 | ev->setFloats( true ); | 1966 | ev->setFloats( true ); |
1966 | Recurrence * rec = ev->recurrence(); | 1967 | Recurrence * rec = ev->recurrence(); |
1967 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1968 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1968 | rec->addYearlyNum( date.month() ); | 1969 | rec->addYearlyNum( date.month() ); |
1969 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1970 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1970 | delete ev; | 1971 | delete ev; |
1971 | return false; | 1972 | return false; |
1972 | } | 1973 | } |
1973 | return true; | 1974 | return true; |
1974 | 1975 | ||
1975 | } | 1976 | } |
1976 | bool CalendarView::importQtopia( const QString &categories, | 1977 | bool CalendarView::importQtopia( const QString &categories, |
1977 | const QString &datebook, | 1978 | const QString &datebook, |
1978 | const QString &todolist ) | 1979 | const QString &todolist ) |
1979 | { | 1980 | { |
1980 | 1981 | ||
1981 | QtopiaFormat qtopiaFormat; | 1982 | QtopiaFormat qtopiaFormat; |
1982 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1983 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1983 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1984 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1984 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1985 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1985 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1986 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1986 | 1987 | ||
1987 | updateView(); | 1988 | updateView(); |
1988 | return true; | 1989 | return true; |
1989 | 1990 | ||
1990 | #if 0 | 1991 | #if 0 |
1991 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1992 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1992 | mCurrentSyncDevice = "qtopia-XML"; | 1993 | mCurrentSyncDevice = "qtopia-XML"; |
1993 | if ( mSyncManager->mAskForPreferences ) | 1994 | if ( mSyncManager->mAskForPreferences ) |
1994 | edit_sync_options(); | 1995 | edit_sync_options(); |
1995 | qApp->processEvents(); | 1996 | qApp->processEvents(); |
1996 | CalendarLocal* calendar = new CalendarLocal(); | 1997 | CalendarLocal* calendar = new CalendarLocal(); |
1997 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1998 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1998 | bool syncOK = false; | 1999 | bool syncOK = false; |
1999 | QtopiaFormat qtopiaFormat; | 2000 | QtopiaFormat qtopiaFormat; |
2000 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2001 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2001 | bool loadOk = true; | 2002 | bool loadOk = true; |
2002 | if ( !categories.isEmpty() ) | 2003 | if ( !categories.isEmpty() ) |
2003 | loadOk = qtopiaFormat.load( calendar, categories ); | 2004 | loadOk = qtopiaFormat.load( calendar, categories ); |
2004 | if ( loadOk && !datebook.isEmpty() ) | 2005 | if ( loadOk && !datebook.isEmpty() ) |
2005 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2006 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2006 | if ( loadOk && !todolist.isEmpty() ) | 2007 | if ( loadOk && !todolist.isEmpty() ) |
2007 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2008 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2008 | 2009 | ||
2009 | if ( loadOk ) { | 2010 | if ( loadOk ) { |
2010 | getEventViewerDialog()->setSyncMode( true ); | 2011 | getEventViewerDialog()->setSyncMode( true ); |
2011 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2012 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2012 | getEventViewerDialog()->setSyncMode( false ); | 2013 | getEventViewerDialog()->setSyncMode( false ); |
2013 | qApp->processEvents(); | 2014 | qApp->processEvents(); |
2014 | if ( syncOK ) { | 2015 | if ( syncOK ) { |
2015 | if ( mSyncManager->mWriteBackFile ) | 2016 | if ( mSyncManager->mWriteBackFile ) |
2016 | { | 2017 | { |
2017 | // write back XML file | 2018 | // write back XML file |
2018 | 2019 | ||
2019 | } | 2020 | } |
2020 | setModified( true ); | 2021 | setModified( true ); |
2021 | } | 2022 | } |
2022 | } else { | 2023 | } else { |
2023 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2024 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2024 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2025 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2025 | question, i18n("Ok")) ; | 2026 | question, i18n("Ok")) ; |
2026 | } | 2027 | } |
2027 | delete calendar; | 2028 | delete calendar; |
2028 | updateView(); | 2029 | updateView(); |
2029 | return syncOK; | 2030 | return syncOK; |
2030 | 2031 | ||
2031 | 2032 | ||
2032 | #endif | 2033 | #endif |
2033 | 2034 | ||
2034 | } | 2035 | } |
2035 | 2036 | ||
2036 | void CalendarView::setSyncEventsReadOnly() | 2037 | void CalendarView::setSyncEventsReadOnly() |
2037 | { | 2038 | { |
2038 | mCalendar->setSyncEventsReadOnly(); | 2039 | mCalendar->setSyncEventsReadOnly(); |
2039 | } | 2040 | } |
2040 | 2041 | ||
2041 | bool CalendarView::loadCalendars() | 2042 | bool CalendarView::loadCalendars() |
2042 | { | 2043 | { |
2043 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2044 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2044 | KopiCalendarFile * cal = calendars.first(); | 2045 | KopiCalendarFile * cal = calendars.first(); |
2045 | mCalendar->setDefaultCalendar( 1 ); | 2046 | mCalendar->setDefaultCalendar( 1 ); |
2046 | openCalendar( MainWindow::defaultFileName(), false ); | 2047 | openCalendar( MainWindow::defaultFileName(), false ); |
2047 | cal = calendars.next(); | 2048 | cal = calendars.next(); |
2048 | while ( cal ) { | 2049 | while ( cal ) { |
2049 | addCalendar( cal ); | 2050 | addCalendar( cal ); |
2050 | cal = calendars.next(); | 2051 | cal = calendars.next(); |
2051 | } | 2052 | } |
2052 | restoreCalendarSettings(); | 2053 | restoreCalendarSettings(); |
2053 | return true; | 2054 | return true; |
2054 | } | 2055 | } |
2055 | bool CalendarView::restoreCalendarSettings() | 2056 | bool CalendarView::restoreCalendarSettings() |
2056 | { | 2057 | { |
2057 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2058 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2058 | KopiCalendarFile * cal = calendars.first(); | 2059 | KopiCalendarFile * cal = calendars.first(); |
2059 | while ( cal ) { | 2060 | while ( cal ) { |
2060 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2061 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2061 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2062 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2062 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2063 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2063 | if ( cal->isStandard ) | 2064 | if ( cal->isStandard ) |
2064 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2065 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2065 | cal = calendars.next(); | 2066 | cal = calendars.next(); |
2066 | } | 2067 | } |
2067 | setSyncEventsReadOnly(); | 2068 | setSyncEventsReadOnly(); |
2068 | mCalendar->reInitAlarmSettings(); | 2069 | mCalendar->reInitAlarmSettings(); |
2069 | updateUnmanagedViews(); | 2070 | updateUnmanagedViews(); |
2070 | updateView(); | 2071 | updateView(); |
2071 | return true; | 2072 | return true; |
2072 | } | 2073 | } |
2073 | void CalendarView::addCalendarId( int id ) | 2074 | void CalendarView::addCalendarId( int id ) |
2074 | { | 2075 | { |
2075 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2076 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2076 | if ( cal ) | 2077 | if ( cal ) |
2077 | addCalendar( cal ); | 2078 | addCalendar( cal ); |
2078 | } | 2079 | } |
2079 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2080 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2080 | { | 2081 | { |
2081 | cal->mErrorOnLoad = false; | 2082 | cal->mErrorOnLoad = false; |
2082 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2083 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2083 | cal->mLoadDt = QDateTime::currentDateTime(); | 2084 | cal->mLoadDt = QDateTime::currentDateTime(); |
2084 | return true; | 2085 | return true; |
2085 | } | 2086 | } |
2086 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2087 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2087 | cal->mErrorOnLoad = true; | 2088 | cal->mErrorOnLoad = true; |
2088 | return false; | 2089 | return false; |
2089 | } | 2090 | } |
2090 | bool CalendarView::openCalendar(QString filename, bool merge) | 2091 | bool CalendarView::openCalendar(QString filename, bool merge) |
2091 | { | 2092 | { |
2092 | 2093 | ||
2093 | if (filename.isEmpty()) { | 2094 | if (filename.isEmpty()) { |
2094 | return false; | 2095 | return false; |
2095 | } | 2096 | } |
2096 | 2097 | ||
2097 | if (!QFile::exists(filename)) { | 2098 | if (!QFile::exists(filename)) { |
2098 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2099 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2099 | return false; | 2100 | return false; |
2100 | } | 2101 | } |
2101 | 2102 | ||
2102 | globalFlagBlockAgenda = 1; | 2103 | globalFlagBlockAgenda = 1; |
2103 | clearAllViews(); | 2104 | clearAllViews(); |
2104 | if (!merge) { | 2105 | if (!merge) { |
2105 | mViewManager->setDocumentId( filename ); | 2106 | mViewManager->setDocumentId( filename ); |
2106 | mCalendar->close(); | 2107 | mCalendar->close(); |
2107 | } | 2108 | } |
2108 | mStorage->setFileName( filename ); | 2109 | mStorage->setFileName( filename ); |
2109 | 2110 | ||
2110 | if ( mStorage->load() ) { | 2111 | if ( mStorage->load() ) { |
2111 | if ( merge ) ;//setModified( true ); | 2112 | if ( merge ) ;//setModified( true ); |
2112 | else { | 2113 | else { |
2113 | //setModified( true ); | 2114 | //setModified( true ); |
2114 | mViewManager->setDocumentId( filename ); | 2115 | mViewManager->setDocumentId( filename ); |
2115 | mDialogManager->setDocumentId( filename ); | 2116 | mDialogManager->setDocumentId( filename ); |
2116 | mTodoList->setDocumentId( filename ); | 2117 | mTodoList->setDocumentId( filename ); |
2117 | } | 2118 | } |
2118 | globalFlagBlockAgenda = 2; | 2119 | globalFlagBlockAgenda = 2; |
2119 | // if ( getLastSyncEvent() ) | 2120 | // if ( getLastSyncEvent() ) |
2120 | // getLastSyncEvent()->setReadOnly( true ); | 2121 | // getLastSyncEvent()->setReadOnly( true ); |
2121 | mCalendar->reInitAlarmSettings(); | 2122 | mCalendar->reInitAlarmSettings(); |
2122 | setSyncEventsReadOnly(); | 2123 | setSyncEventsReadOnly(); |
2123 | updateUnmanagedViews(); | 2124 | updateUnmanagedViews(); |
2124 | updateView(); | 2125 | updateView(); |
2125 | if ( filename != MainWindow::defaultFileName() ) { | 2126 | if ( filename != MainWindow::defaultFileName() ) { |
2126 | saveCalendar( MainWindow::defaultFileName() ); | 2127 | saveCalendar( MainWindow::defaultFileName() ); |
2127 | } else { | 2128 | } else { |
2128 | QFileInfo finf ( MainWindow::defaultFileName()); | 2129 | QFileInfo finf ( MainWindow::defaultFileName()); |
2129 | if ( finf.exists() ) { | 2130 | if ( finf.exists() ) { |
2130 | setLoadedFileVersion( finf.lastModified () ); | 2131 | setLoadedFileVersion( finf.lastModified () ); |
2131 | } | 2132 | } |
2132 | } | 2133 | } |
2133 | return true; | 2134 | return true; |
2134 | } else { | 2135 | } else { |
2135 | // while failing to load, the calendar object could | 2136 | // while failing to load, the calendar object could |
2136 | // have become partially populated. Clear it out. | 2137 | // have become partially populated. Clear it out. |
2137 | if ( !merge ) { | 2138 | if ( !merge ) { |
2138 | mCalendar->close(); | 2139 | mCalendar->close(); |
2139 | mViewManager->setDocumentId( filename ); | 2140 | mViewManager->setDocumentId( filename ); |
2140 | mDialogManager->setDocumentId( filename ); | 2141 | mDialogManager->setDocumentId( filename ); |
2141 | mTodoList->setDocumentId( filename ); | 2142 | mTodoList->setDocumentId( filename ); |
2142 | } | 2143 | } |
2143 | 2144 | ||
2144 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2145 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2145 | 2146 | ||
2146 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2147 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2147 | globalFlagBlockAgenda = 2; | 2148 | globalFlagBlockAgenda = 2; |
2148 | mCalendar->reInitAlarmSettings(); | 2149 | mCalendar->reInitAlarmSettings(); |
2149 | setSyncEventsReadOnly(); | 2150 | setSyncEventsReadOnly(); |
2150 | updateUnmanagedViews(); | 2151 | updateUnmanagedViews(); |
2151 | updateView(); | 2152 | updateView(); |
2152 | } | 2153 | } |
2153 | return false; | 2154 | return false; |
2154 | } | 2155 | } |
2155 | void CalendarView::mergeFile( QString fn ) | 2156 | void CalendarView::mergeFile( QString fn ) |
2156 | { | 2157 | { |
2157 | clearAllViews(); | 2158 | clearAllViews(); |
2158 | mCalendar->mergeCalendarFile( fn ); | 2159 | mCalendar->mergeCalendarFile( fn ); |
2159 | mCalendar->reInitAlarmSettings(); | 2160 | mCalendar->reInitAlarmSettings(); |
2160 | setSyncEventsReadOnly(); | 2161 | setSyncEventsReadOnly(); |
2161 | updateUnmanagedViews(); | 2162 | updateUnmanagedViews(); |
2162 | updateView(); | 2163 | updateView(); |
2163 | } | 2164 | } |
2164 | void CalendarView::showOpenError() | 2165 | void CalendarView::showOpenError() |
2165 | { | 2166 | { |
2166 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2167 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2167 | } | 2168 | } |
2168 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2169 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2169 | { | 2170 | { |
2170 | loadedFileVersion = dt; | 2171 | loadedFileVersion = dt; |
2171 | } | 2172 | } |
2172 | bool CalendarView::checkFileChanged(QString fn) | 2173 | bool CalendarView::checkFileChanged(QString fn) |
2173 | { | 2174 | { |
2174 | QFileInfo finf ( fn ); | 2175 | QFileInfo finf ( fn ); |
2175 | if ( !finf.exists() ) | 2176 | if ( !finf.exists() ) |
2176 | return true; | 2177 | return true; |
2177 | QDateTime dt = finf.lastModified (); | 2178 | QDateTime dt = finf.lastModified (); |
2178 | if ( dt <= loadedFileVersion ) | 2179 | if ( dt <= loadedFileVersion ) |
2179 | return false; | 2180 | return false; |
2180 | return true; | 2181 | return true; |
2181 | 2182 | ||
2182 | } | 2183 | } |
2183 | void CalendarView::watchSavedFile() | 2184 | void CalendarView::watchSavedFile() |
2184 | { | 2185 | { |
2185 | QFileInfo finf ( MainWindow::defaultFileName()); | 2186 | QFileInfo finf ( MainWindow::defaultFileName()); |
2186 | if ( !finf.exists() ) | 2187 | if ( !finf.exists() ) |
2187 | return; | 2188 | return; |
2188 | QDateTime dt = finf.lastModified (); | 2189 | QDateTime dt = finf.lastModified (); |
2189 | if ( dt < loadedFileVersion ) { | 2190 | if ( dt < loadedFileVersion ) { |
2190 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2191 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2191 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2192 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2192 | return; | 2193 | return; |
2193 | } | 2194 | } |
2194 | loadedFileVersion = dt; | 2195 | loadedFileVersion = dt; |
2195 | } | 2196 | } |
2196 | bool CalendarView::checkAllFileVersions() | 2197 | bool CalendarView::checkAllFileVersions() |
2197 | { | 2198 | { |
2198 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2199 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2199 | KopiCalendarFile * cal = calendars.first(); | 2200 | KopiCalendarFile * cal = calendars.first(); |
2200 | mCalendar->setDefaultCalendar( 1 ); | 2201 | mCalendar->setDefaultCalendar( 1 ); |
2201 | mCalendar->setDefaultCalendarEnabledOnly(); | 2202 | mCalendar->setDefaultCalendarEnabledOnly(); |
2202 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2203 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2203 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2204 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2204 | restoreCalendarSettings(); | 2205 | restoreCalendarSettings(); |
2205 | return false; | 2206 | return false; |
2206 | } | 2207 | } |
2207 | } | 2208 | } |
2208 | cal = calendars.next(); | 2209 | cal = calendars.next(); |
2209 | QDateTime storeTemp = loadedFileVersion; | 2210 | QDateTime storeTemp = loadedFileVersion; |
2210 | while ( cal ) { | 2211 | while ( cal ) { |
2211 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2212 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2212 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2213 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2213 | mCalendar->setDefaultCalendarEnabledOnly(); | 2214 | mCalendar->setDefaultCalendarEnabledOnly(); |
2214 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2215 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2215 | if ( !checkFileVersion(cal->mFileName )) { | 2216 | if ( !checkFileVersion(cal->mFileName )) { |
2216 | loadedFileVersion = storeTemp; | 2217 | loadedFileVersion = storeTemp; |
2217 | restoreCalendarSettings(); | 2218 | restoreCalendarSettings(); |
2218 | return false; | 2219 | return false; |
2219 | } | 2220 | } |
2220 | } | 2221 | } |
2221 | cal = calendars.next(); | 2222 | cal = calendars.next(); |
2222 | } | 2223 | } |
2223 | loadedFileVersion = storeTemp; | 2224 | loadedFileVersion = storeTemp; |
2224 | return true; | 2225 | return true; |
2225 | } | 2226 | } |
2226 | bool CalendarView::checkFileVersion(QString fn) | 2227 | bool CalendarView::checkFileVersion(QString fn) |
2227 | { | 2228 | { |
2228 | QFileInfo finf ( fn ); | 2229 | QFileInfo finf ( fn ); |
2229 | if ( !finf.exists() ) | 2230 | if ( !finf.exists() ) |
2230 | return true; | 2231 | return true; |
2231 | QDateTime dt = finf.lastModified (); | 2232 | QDateTime dt = finf.lastModified (); |
2232 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2233 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2233 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2234 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2234 | if ( dt <= loadedFileVersion ) | 2235 | if ( dt <= loadedFileVersion ) |
2235 | return true; | 2236 | return true; |
2236 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non 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(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2237 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non 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(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2237 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2238 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2238 | i18n("Sync+save")); | 2239 | i18n("Sync+save")); |
2239 | 2240 | ||
2240 | if ( km == KMessageBox::Cancel ) | 2241 | if ( km == KMessageBox::Cancel ) |
2241 | return false; | 2242 | return false; |
2242 | if ( km == KMessageBox::Yes ) | 2243 | if ( km == KMessageBox::Yes ) |
2243 | return true; | 2244 | return true; |
2244 | 2245 | ||
2245 | setSyncDevice("deleteaftersync" ); | 2246 | setSyncDevice("deleteaftersync" ); |
2246 | mSyncManager->mAskForPreferences = true; | 2247 | mSyncManager->mAskForPreferences = true; |
2247 | mSyncManager->mSyncAlgoPrefs = 3; | 2248 | mSyncManager->mSyncAlgoPrefs = 3; |
2248 | mSyncManager->mWriteBackFile = false; | 2249 | mSyncManager->mWriteBackFile = false; |
2249 | mSyncManager->mWriteBackExistingOnly = false; | 2250 | mSyncManager->mWriteBackExistingOnly = false; |
2250 | mSyncManager->mShowSyncSummary = false; | 2251 | mSyncManager->mShowSyncSummary = false; |
2251 | syncCalendar( fn, 3 ); | 2252 | syncCalendar( fn, 3 ); |
2252 | Event * e = getLastSyncEvent(); | 2253 | Event * e = getLastSyncEvent(); |
2253 | if ( e ) | 2254 | if ( e ) |
2254 | mCalendar->deleteEvent( e ); | 2255 | mCalendar->deleteEvent( e ); |
2255 | return true; | 2256 | return true; |
2256 | } | 2257 | } |
2257 | bool CalendarView::saveCalendars() | 2258 | bool CalendarView::saveCalendars() |
2258 | { | 2259 | { |
2259 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2260 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2260 | KopiCalendarFile * cal = calendars.first(); | 2261 | KopiCalendarFile * cal = calendars.first(); |
2261 | mCalendar->setDefaultCalendar( 1 ); | 2262 | mCalendar->setDefaultCalendar( 1 ); |
2262 | mCalendar->setDefaultCalendarEnabledOnly(); | 2263 | mCalendar->setDefaultCalendarEnabledOnly(); |
2263 | saveCalendar( MainWindow::defaultFileName() ); | 2264 | saveCalendar( MainWindow::defaultFileName() ); |
2264 | cal = calendars.next(); | 2265 | cal = calendars.next(); |
2265 | while ( cal ) { | 2266 | while ( cal ) { |
2266 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2267 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2267 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2268 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2268 | mCalendar->setDefaultCalendarEnabledOnly(); | 2269 | mCalendar->setDefaultCalendarEnabledOnly(); |
2269 | if ( saveCalendar( cal->mFileName ) ) | 2270 | if ( saveCalendar( cal->mFileName ) ) |
2270 | cal->mLoadDt = QDateTime::currentDateTime(); | 2271 | cal->mLoadDt = QDateTime::currentDateTime(); |
2271 | } | 2272 | } |
2272 | cal = calendars.next(); | 2273 | cal = calendars.next(); |
2273 | } | 2274 | } |
2274 | restoreCalendarSettings(); | 2275 | restoreCalendarSettings(); |
2275 | return true; | 2276 | return true; |
2276 | } | 2277 | } |
2277 | bool CalendarView::saveCalendar( QString filename ) | 2278 | bool CalendarView::saveCalendar( QString filename ) |
2278 | { | 2279 | { |
2279 | 2280 | ||
2280 | // Store back all unsaved data into calendar object | 2281 | // Store back all unsaved data into calendar object |
2281 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2282 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2282 | if ( mViewManager->currentView() ) | 2283 | if ( mViewManager->currentView() ) |
2283 | mViewManager->currentView()->flushView(); | 2284 | mViewManager->currentView()->flushView(); |
2284 | 2285 | ||
2285 | 2286 | ||
2286 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2287 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2287 | mStorage->setSaveFormat( new ICalFormat() ); | 2288 | mStorage->setSaveFormat( new ICalFormat() ); |
2288 | mStorage->setFileName( filename ); | 2289 | mStorage->setFileName( filename ); |
2289 | bool success; | 2290 | bool success; |
2290 | success = mStorage->save(); | 2291 | success = mStorage->save(); |
2291 | if ( !success ) { | 2292 | if ( !success ) { |
2292 | return false; | 2293 | return false; |
2293 | } | 2294 | } |
2294 | if ( filename == MainWindow::defaultFileName() ) { | 2295 | if ( filename == MainWindow::defaultFileName() ) { |
2295 | setLoadedFileVersion( lfv ); | 2296 | setLoadedFileVersion( lfv ); |
2296 | watchSavedFile(); | 2297 | watchSavedFile(); |
2297 | } | 2298 | } |
2298 | return true; | 2299 | return true; |
2299 | } | 2300 | } |
2300 | 2301 | ||
2301 | void CalendarView::closeCalendar() | 2302 | void CalendarView::closeCalendar() |
2302 | { | 2303 | { |
2303 | 2304 | ||
2304 | // child windows no longer valid | 2305 | // child windows no longer valid |
2305 | clearAllViews(); | 2306 | clearAllViews(); |
2306 | emit closingDown(); | 2307 | emit closingDown(); |
2307 | 2308 | ||
2308 | mCalendar->close(); | 2309 | mCalendar->close(); |
2309 | setModified(false); | 2310 | setModified(false); |
2310 | updateView(); | 2311 | updateView(); |
2311 | } | 2312 | } |
2312 | 2313 | ||
2313 | void CalendarView::archiveCalendar() | 2314 | void CalendarView::archiveCalendar() |
2314 | { | 2315 | { |
2315 | mDialogManager->showArchiveDialog(); | 2316 | mDialogManager->showArchiveDialog(); |
2316 | } | 2317 | } |
2317 | 2318 | ||
2318 | 2319 | ||
2319 | void CalendarView::readSettings() | 2320 | void CalendarView::readSettings() |
2320 | { | 2321 | { |
2321 | 2322 | ||
2322 | 2323 | ||
2323 | // mViewManager->showAgendaView(); | 2324 | // mViewManager->showAgendaView(); |
2324 | QString str; | 2325 | QString str; |
2325 | //qDebug("CalendarView::readSettings() "); | 2326 | //qDebug("CalendarView::readSettings() "); |
2326 | // read settings from the KConfig, supplying reasonable | 2327 | // read settings from the KConfig, supplying reasonable |
2327 | // defaults where none are to be found | 2328 | // defaults where none are to be found |
2328 | KConfig *config = KOGlobals::config(); | 2329 | KConfig *config = KOGlobals::config(); |
2329 | #ifndef KORG_NOSPLITTER | 2330 | #ifndef KORG_NOSPLITTER |
2330 | config->setGroup("KOrganizer Geometry"); | 2331 | config->setGroup("KOrganizer Geometry"); |
2331 | 2332 | ||
2332 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2333 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2333 | if (sizes.count() != 2) { | 2334 | if (sizes.count() != 2) { |
2334 | sizes << mDateNavigator->minimumSizeHint().width(); | 2335 | sizes << mDateNavigator->minimumSizeHint().width(); |
2335 | sizes << 300; | 2336 | sizes << 300; |
2336 | } | 2337 | } |
2337 | mPanner->setSizes(sizes); | 2338 | mPanner->setSizes(sizes); |
2338 | 2339 | ||
2339 | sizes = config->readIntListEntry("Separator2"); | 2340 | sizes = config->readIntListEntry("Separator2"); |
2340 | if ( ( mResourceView && sizes.count() == 4 ) || | 2341 | if ( ( mResourceView && sizes.count() == 4 ) || |
2341 | ( !mResourceView && sizes.count() == 3 ) ) { | 2342 | ( !mResourceView && sizes.count() == 3 ) ) { |
2342 | mLeftSplitter->setSizes(sizes); | 2343 | mLeftSplitter->setSizes(sizes); |
2343 | } | 2344 | } |
2344 | #endif | 2345 | #endif |
2345 | globalFlagBlockAgenda = 1; | 2346 | globalFlagBlockAgenda = 1; |
2346 | mViewManager->showAgendaView(); | 2347 | mViewManager->showAgendaView(); |
2347 | //mViewManager->readSettings( config ); | 2348 | //mViewManager->readSettings( config ); |
2348 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2349 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2349 | readFilterSettings(config); | 2350 | readFilterSettings(config); |
2350 | 2351 | ||
2351 | #ifdef DESKTOP_VERSION | 2352 | #ifdef DESKTOP_VERSION |
2352 | config->setGroup("WidgetLayout"); | 2353 | config->setGroup("WidgetLayout"); |
2353 | QStringList list; | 2354 | QStringList list; |
2354 | list = config->readListEntry("MainLayout"); | 2355 | list = config->readListEntry("MainLayout"); |
2355 | int x,y,w,h; | 2356 | int x,y,w,h; |
2356 | if ( ! list.isEmpty() ) { | 2357 | if ( ! list.isEmpty() ) { |
2357 | x = list[0].toInt(); | 2358 | x = list[0].toInt(); |
2358 | y = list[1].toInt(); | 2359 | y = list[1].toInt(); |
2359 | w = list[2].toInt(); | 2360 | w = list[2].toInt(); |
2360 | h = list[3].toInt(); | 2361 | h = list[3].toInt(); |
2361 | KApplication::testCoords( &x,&y,&w,&h ); | 2362 | KApplication::testCoords( &x,&y,&w,&h ); |
2362 | topLevelWidget()->setGeometry(x,y,w,h); | 2363 | topLevelWidget()->setGeometry(x,y,w,h); |
2363 | 2364 | ||
2364 | } else { | 2365 | } else { |
2365 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2366 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2366 | } | 2367 | } |
2367 | list = config->readListEntry("EditEventLayout"); | 2368 | list = config->readListEntry("EditEventLayout"); |
2368 | if ( ! list.isEmpty() ) { | 2369 | if ( ! list.isEmpty() ) { |
2369 | x = list[0].toInt(); | 2370 | x = list[0].toInt(); |
2370 | y = list[1].toInt(); | 2371 | y = list[1].toInt(); |
2371 | w = list[2].toInt(); | 2372 | w = list[2].toInt(); |
2372 | h = list[3].toInt(); | 2373 | h = list[3].toInt(); |
2373 | KApplication::testCoords( &x,&y,&w,&h ); | 2374 | KApplication::testCoords( &x,&y,&w,&h ); |
2374 | mEventEditor->setGeometry(x,y,w,h); | 2375 | mEventEditor->setGeometry(x,y,w,h); |
2375 | 2376 | ||
2376 | } | 2377 | } |
2377 | list = config->readListEntry("EditTodoLayout"); | 2378 | list = config->readListEntry("EditTodoLayout"); |
2378 | if ( ! list.isEmpty() ) { | 2379 | if ( ! list.isEmpty() ) { |
2379 | x = list[0].toInt(); | 2380 | x = list[0].toInt(); |
2380 | y = list[1].toInt(); | 2381 | y = list[1].toInt(); |
2381 | w = list[2].toInt(); | 2382 | w = list[2].toInt(); |
2382 | h = list[3].toInt(); | 2383 | h = list[3].toInt(); |
2383 | KApplication::testCoords( &x,&y,&w,&h ); | 2384 | KApplication::testCoords( &x,&y,&w,&h ); |
2384 | mTodoEditor->setGeometry(x,y,w,h); | 2385 | mTodoEditor->setGeometry(x,y,w,h); |
2385 | 2386 | ||
2386 | } | 2387 | } |
2387 | list = config->readListEntry("ViewerLayout"); | 2388 | list = config->readListEntry("ViewerLayout"); |
2388 | if ( ! list.isEmpty() ) { | 2389 | if ( ! list.isEmpty() ) { |
2389 | x = list[0].toInt(); | 2390 | x = list[0].toInt(); |
2390 | y = list[1].toInt(); | 2391 | y = list[1].toInt(); |
2391 | w = list[2].toInt(); | 2392 | w = list[2].toInt(); |
2392 | h = list[3].toInt(); | 2393 | h = list[3].toInt(); |
2393 | KApplication::testCoords( &x,&y,&w,&h ); | 2394 | KApplication::testCoords( &x,&y,&w,&h ); |
2394 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2395 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2395 | } | 2396 | } |
2396 | #endif | 2397 | #endif |
2397 | config->setGroup( "Views" ); | 2398 | config->setGroup( "Views" ); |
2398 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2399 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2399 | 2400 | ||
2400 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2401 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2401 | 2402 | ||
2402 | int resetval = 0; | 2403 | int resetval = 0; |
2403 | int maxVal = 0; | 2404 | int maxVal = 0; |
2404 | if (sizes.count() != 3) { | 2405 | if (sizes.count() != 3) { |
2405 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2406 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2406 | resetval = mDateNavigator->sizeHint().width()+2; | 2407 | resetval = mDateNavigator->sizeHint().width()+2; |
2407 | } else { | 2408 | } else { |
2408 | resetval = mDateNavigator->sizeHint().height()+2; | 2409 | resetval = mDateNavigator->sizeHint().height()+2; |
2409 | } | 2410 | } |
2410 | } | 2411 | } |
2411 | if ( resetval ) { | 2412 | if ( resetval ) { |
2412 | sizes.clear(); | 2413 | sizes.clear(); |
2413 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2414 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2414 | maxVal = QApplication::desktop()->width() -10; | 2415 | maxVal = QApplication::desktop()->width() -10; |
2415 | } else { | 2416 | } else { |
2416 | maxVal = QApplication::desktop()->height()-10; | 2417 | maxVal = QApplication::desktop()->height()-10; |
2417 | } | 2418 | } |
2418 | sizes << resetval; | 2419 | sizes << resetval; |
2419 | if ( maxVal < resetval + resetval) | 2420 | if ( maxVal < resetval + resetval) |
2420 | resetval = maxVal - resetval; | 2421 | resetval = maxVal - resetval; |
2421 | sizes << resetval; | 2422 | sizes << resetval; |
2422 | sizes << 100; | 2423 | sizes << 100; |
2423 | } | 2424 | } |
2424 | mLeftFrame->setSizes(sizes); | 2425 | mLeftFrame->setSizes(sizes); |
2425 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2426 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2426 | resetval = 0; | 2427 | resetval = 0; |
2427 | maxVal = 0; | 2428 | maxVal = 0; |
2428 | if (sizes.count() != 2) { | 2429 | if (sizes.count() != 2) { |
2429 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2430 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2430 | resetval = mDateNavigator->sizeHint().width()+2; | 2431 | resetval = mDateNavigator->sizeHint().width()+2; |
2431 | } else { | 2432 | } else { |
2432 | resetval = mDateNavigator->sizeHint().height()+2; | 2433 | resetval = mDateNavigator->sizeHint().height()+2; |
2433 | } | 2434 | } |
2434 | } | 2435 | } |
2435 | if ( resetval ) { | 2436 | if ( resetval ) { |
2436 | sizes.clear(); | 2437 | sizes.clear(); |
2437 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2438 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2438 | maxVal = QApplication::desktop()->width() -10; | 2439 | maxVal = QApplication::desktop()->width() -10; |
2439 | } else { | 2440 | } else { |
2440 | maxVal = QApplication::desktop()->height()-10; | 2441 | maxVal = QApplication::desktop()->height()-10; |
2441 | } | 2442 | } |
2442 | sizes << resetval; | 2443 | sizes << resetval; |
2443 | if ( maxVal < resetval + resetval) | 2444 | if ( maxVal < resetval + resetval) |
2444 | resetval = maxVal - resetval; | 2445 | resetval = maxVal - resetval; |
2445 | sizes << resetval; | 2446 | sizes << resetval; |
2446 | } | 2447 | } |
2447 | mMainFrame->setSizes(sizes); | 2448 | mMainFrame->setSizes(sizes); |
2448 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2449 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2449 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2450 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2450 | else mNavigator->selectDates( dateCount ); | 2451 | else mNavigator->selectDates( dateCount ); |
2451 | // mViewManager->readSettings( config ); | 2452 | // mViewManager->readSettings( config ); |
2452 | updateConfig(); | 2453 | updateConfig(); |
2453 | globalFlagBlockAgenda = 2; | 2454 | globalFlagBlockAgenda = 2; |
2454 | mViewManager->readSettings( config ); | 2455 | mViewManager->readSettings( config ); |
2455 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2456 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2456 | } | 2457 | } |
2457 | 2458 | ||
2458 | void CalendarView::checkSuspendAlarm() | 2459 | void CalendarView::checkSuspendAlarm() |
2459 | { | 2460 | { |
2460 | if ( mSuspendTimer->isActive() ) { | 2461 | if ( mSuspendTimer->isActive() ) { |
2461 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2462 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2462 | } | 2463 | } |
2463 | } | 2464 | } |
2464 | void CalendarView::writeSettings() | 2465 | void CalendarView::writeSettings() |
2465 | { | 2466 | { |
2466 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2467 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2467 | 2468 | ||
2468 | KConfig *config = KOGlobals::config(); | 2469 | KConfig *config = KOGlobals::config(); |
2469 | 2470 | ||
2470 | mViewManager->writeSettings( config ); | 2471 | mViewManager->writeSettings( config ); |
2471 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2472 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2472 | mDialogManager->writeSettings( config ); | 2473 | mDialogManager->writeSettings( config ); |
2473 | //KOPrefs::instance()->usrWriteConfig(); | 2474 | //KOPrefs::instance()->usrWriteConfig(); |
2474 | KOPrefs::instance()->writeConfig(); | 2475 | KOPrefs::instance()->writeConfig(); |
2475 | 2476 | ||
2476 | writeFilterSettings(config); | 2477 | writeFilterSettings(config); |
2477 | config->setGroup( "AppRun" ); | 2478 | config->setGroup( "AppRun" ); |
2478 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2479 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2479 | int days = dt.daysTo( QDate::currentDate() ); | 2480 | int days = dt.daysTo( QDate::currentDate() ); |
2480 | dt = dt.addDays( days ); | 2481 | dt = dt.addDays( days ); |
2481 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2482 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2482 | config->writeEntry( "LatestProgramStopDays", days ); | 2483 | config->writeEntry( "LatestProgramStopDays", days ); |
2483 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2484 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2484 | //qDebug("KO: Writing stop time: %d ", secs); | 2485 | //qDebug("KO: Writing stop time: %d ", secs); |
2485 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2486 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2486 | //QDateTime latest = dt.addSecs ( secs ); | 2487 | //QDateTime latest = dt.addSecs ( secs ); |
2487 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2488 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2488 | config->setGroup( "Views" ); | 2489 | config->setGroup( "Views" ); |
2489 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2490 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2490 | 2491 | ||
2491 | #if 0 | 2492 | #if 0 |
2492 | qDebug("********************* "); | 2493 | qDebug("********************* "); |
2493 | qDebug("Testcode secsto "); | 2494 | qDebug("Testcode secsto "); |
2494 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2495 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2495 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2496 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2496 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2497 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2497 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2498 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2498 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2499 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2499 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2500 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2500 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2501 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2501 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2502 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2502 | qDebug("********************* testcode end"); | 2503 | qDebug("********************* testcode end"); |
2503 | 2504 | ||
2504 | #endif | 2505 | #endif |
2505 | 2506 | ||
2506 | QValueList<int> listINT = mLeftFrame->sizes(); | 2507 | QValueList<int> listINT = mLeftFrame->sizes(); |
2507 | config->writeEntry("Left Splitter Frame",listINT); | 2508 | config->writeEntry("Left Splitter Frame",listINT); |
2508 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2509 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2509 | config->writeEntry("Main Splitter Frame",listINT2); | 2510 | config->writeEntry("Main Splitter Frame",listINT2); |
2510 | #ifdef DESKTOP_VERSION | 2511 | #ifdef DESKTOP_VERSION |
2511 | config->setGroup("WidgetLayout"); | 2512 | config->setGroup("WidgetLayout"); |
2512 | QStringList list ;//= config->readListEntry("MainLayout"); | 2513 | QStringList list ;//= config->readListEntry("MainLayout"); |
2513 | int x,y,w,h; | 2514 | int x,y,w,h; |
2514 | QWidget* wid; | 2515 | QWidget* wid; |
2515 | wid = topLevelWidget(); | 2516 | wid = topLevelWidget(); |
2516 | x = wid->geometry().x(); | 2517 | x = wid->geometry().x(); |
2517 | y = wid->geometry().y(); | 2518 | y = wid->geometry().y(); |
2518 | w = wid->width(); | 2519 | w = wid->width(); |
2519 | h = wid->height(); | 2520 | h = wid->height(); |
2520 | list.clear(); | 2521 | list.clear(); |
2521 | list << QString::number( x ); | 2522 | list << QString::number( x ); |
2522 | list << QString::number( y ); | 2523 | list << QString::number( y ); |
2523 | list << QString::number( w ); | 2524 | list << QString::number( w ); |
2524 | list << QString::number( h ); | 2525 | list << QString::number( h ); |
2525 | config->writeEntry("MainLayout",list ); | 2526 | config->writeEntry("MainLayout",list ); |
2526 | 2527 | ||
2527 | wid = mEventEditor; | 2528 | wid = mEventEditor; |
2528 | x = wid->geometry().x(); | 2529 | x = wid->geometry().x(); |
2529 | y = wid->geometry().y(); | 2530 | y = wid->geometry().y(); |
2530 | w = wid->width(); | 2531 | w = wid->width(); |
2531 | h = wid->height(); | 2532 | h = wid->height(); |
2532 | list.clear(); | 2533 | list.clear(); |
2533 | list << QString::number( x ); | 2534 | list << QString::number( x ); |
2534 | list << QString::number( y ); | 2535 | list << QString::number( y ); |
2535 | list << QString::number( w ); | 2536 | list << QString::number( w ); |
2536 | list << QString::number( h ); | 2537 | list << QString::number( h ); |
2537 | config->writeEntry("EditEventLayout",list ); | 2538 | config->writeEntry("EditEventLayout",list ); |
2538 | 2539 | ||
2539 | wid = mTodoEditor; | 2540 | wid = mTodoEditor; |
2540 | x = wid->geometry().x(); | 2541 | x = wid->geometry().x(); |
2541 | y = wid->geometry().y(); | 2542 | y = wid->geometry().y(); |
2542 | w = wid->width(); | 2543 | w = wid->width(); |
2543 | h = wid->height(); | 2544 | h = wid->height(); |
2544 | list.clear(); | 2545 | list.clear(); |
2545 | list << QString::number( x ); | 2546 | list << QString::number( x ); |
2546 | list << QString::number( y ); | 2547 | list << QString::number( y ); |
2547 | list << QString::number( w ); | 2548 | list << QString::number( w ); |
2548 | list << QString::number( h ); | 2549 | list << QString::number( h ); |
2549 | config->writeEntry("EditTodoLayout",list ); | 2550 | config->writeEntry("EditTodoLayout",list ); |
2550 | wid = getEventViewerDialog(); | 2551 | wid = getEventViewerDialog(); |
2551 | x = wid->geometry().x(); | 2552 | x = wid->geometry().x(); |
2552 | y = wid->geometry().y(); | 2553 | y = wid->geometry().y(); |
2553 | w = wid->width(); | 2554 | w = wid->width(); |
2554 | h = wid->height(); | 2555 | h = wid->height(); |
2555 | list.clear(); | 2556 | list.clear(); |
2556 | list << QString::number( x ); | 2557 | list << QString::number( x ); |
2557 | list << QString::number( y ); | 2558 | list << QString::number( y ); |
2558 | list << QString::number( w ); | 2559 | list << QString::number( w ); |
2559 | list << QString::number( h ); | 2560 | list << QString::number( h ); |
2560 | config->writeEntry("ViewerLayout",list ); | 2561 | config->writeEntry("ViewerLayout",list ); |
2561 | wid = mDialogManager->getSearchDialog(); | 2562 | wid = mDialogManager->getSearchDialog(); |
2562 | if ( wid ) { | 2563 | if ( wid ) { |
2563 | x = wid->geometry().x(); | 2564 | x = wid->geometry().x(); |
2564 | y = wid->geometry().y(); | 2565 | y = wid->geometry().y(); |
2565 | w = wid->width(); | 2566 | w = wid->width(); |
2566 | h = wid->height(); | 2567 | h = wid->height(); |
2567 | list.clear(); | 2568 | list.clear(); |
2568 | list << QString::number( x ); | 2569 | list << QString::number( x ); |
2569 | list << QString::number( y ); | 2570 | list << QString::number( y ); |
2570 | list << QString::number( w ); | 2571 | list << QString::number( w ); |
2571 | list << QString::number( h ); | 2572 | list << QString::number( h ); |
2572 | config->writeEntry("SearchLayout",list ); | 2573 | config->writeEntry("SearchLayout",list ); |
2573 | } | 2574 | } |
2574 | #endif | 2575 | #endif |
2575 | 2576 | ||
2576 | 2577 | ||
2577 | config->sync(); | 2578 | config->sync(); |
2578 | } | 2579 | } |
2579 | 2580 | ||
2580 | void CalendarView::readFilterSettings(KConfig *config) | 2581 | void CalendarView::readFilterSettings(KConfig *config) |
2581 | { | 2582 | { |
2582 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2583 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2583 | 2584 | ||
2584 | mFilters.clear(); | 2585 | mFilters.clear(); |
2585 | 2586 | ||
2586 | config->setGroup("General"); | 2587 | config->setGroup("General"); |
2587 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2588 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2588 | 2589 | ||
2589 | QStringList::ConstIterator it = filterList.begin(); | 2590 | QStringList::ConstIterator it = filterList.begin(); |
2590 | QStringList::ConstIterator end = filterList.end(); | 2591 | QStringList::ConstIterator end = filterList.end(); |
2591 | while(it != end) { | 2592 | while(it != end) { |
2592 | // kdDebug() << " filter: " << (*it) << endl; | 2593 | // kdDebug() << " filter: " << (*it) << endl; |
2593 | 2594 | ||
2594 | CalFilter *filter; | 2595 | CalFilter *filter; |
2595 | filter = new CalFilter(*it); | 2596 | filter = new CalFilter(*it); |
2596 | config->setGroup("Filter_" + (*it).utf8()); | 2597 | config->setGroup("Filter_" + (*it).utf8()); |
2597 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2598 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2598 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2599 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2599 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2600 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2600 | mFilters.append(filter); | 2601 | mFilters.append(filter); |
2601 | 2602 | ||
2602 | ++it; | 2603 | ++it; |
2603 | } | 2604 | } |
2604 | 2605 | ||
2605 | if (mFilters.count() == 0) { | 2606 | if (mFilters.count() == 0) { |
2606 | CalFilter *filter = new CalFilter(i18n("Default")); | 2607 | CalFilter *filter = new CalFilter(i18n("Default")); |
2607 | mFilters.append(filter); | 2608 | mFilters.append(filter); |
2608 | } | 2609 | } |
2609 | mFilterView->updateFilters(); | 2610 | mFilterView->updateFilters(); |
2610 | config->setGroup("FilterView"); | 2611 | config->setGroup("FilterView"); |
2611 | 2612 | ||
2612 | mFilterView->blockSignals(true); | 2613 | mFilterView->blockSignals(true); |
2613 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2614 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2614 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2615 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2615 | mFilterView->blockSignals(false); | 2616 | mFilterView->blockSignals(false); |
2616 | // We do it manually to avoid it being done twice by the above calls | 2617 | // We do it manually to avoid it being done twice by the above calls |
2617 | updateFilter(); | 2618 | updateFilter(); |
2618 | } | 2619 | } |
2619 | 2620 | ||
2620 | void CalendarView::writeFilterSettings(KConfig *config) | 2621 | void CalendarView::writeFilterSettings(KConfig *config) |
2621 | { | 2622 | { |
2622 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2623 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2623 | 2624 | ||
2624 | QStringList filterList; | 2625 | QStringList filterList; |
2625 | 2626 | ||
2626 | CalFilter *filter = mFilters.first(); | 2627 | CalFilter *filter = mFilters.first(); |
2627 | while(filter) { | 2628 | while(filter) { |
2628 | // kdDebug() << " fn: " << filter->name() << endl; | 2629 | // kdDebug() << " fn: " << filter->name() << endl; |
2629 | filterList << filter->name(); | 2630 | filterList << filter->name(); |
2630 | config->setGroup("Filter_" + filter->name().utf8()); | 2631 | config->setGroup("Filter_" + filter->name().utf8()); |
2631 | config->writeEntry("Criteria",filter->criteria()); | 2632 | config->writeEntry("Criteria",filter->criteria()); |
2632 | config->writeEntry("CategoryList",filter->categoryList()); | 2633 | config->writeEntry("CategoryList",filter->categoryList()); |
2633 | filter = mFilters.next(); | 2634 | filter = mFilters.next(); |
2634 | } | 2635 | } |
2635 | config->setGroup("General"); | 2636 | config->setGroup("General"); |
2636 | config->writeEntry("CalendarFilters",filterList); | 2637 | config->writeEntry("CalendarFilters",filterList); |
2637 | 2638 | ||
2638 | config->setGroup("FilterView"); | 2639 | config->setGroup("FilterView"); |
2639 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2640 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2640 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2641 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2641 | } | 2642 | } |
2642 | 2643 | ||
2643 | 2644 | ||
2644 | void CalendarView::goToday() | 2645 | void CalendarView::goToday() |
2645 | { | 2646 | { |
2646 | if ( mViewManager->currentView()->isMonthView() ) | 2647 | if ( mViewManager->currentView()->isMonthView() ) |
2647 | mNavigator->selectTodayMonth(); | 2648 | mNavigator->selectTodayMonth(); |
2648 | else | 2649 | else |
2649 | mNavigator->selectToday(); | 2650 | mNavigator->selectToday(); |
2650 | } | 2651 | } |
2651 | 2652 | ||
2652 | void CalendarView::goNext() | 2653 | void CalendarView::goNext() |
2653 | { | 2654 | { |
2654 | mNavigator->selectNext(); | 2655 | mNavigator->selectNext(); |
2655 | } | 2656 | } |
2656 | 2657 | ||
2657 | void CalendarView::goPrevious() | 2658 | void CalendarView::goPrevious() |
2658 | { | 2659 | { |
2659 | mNavigator->selectPrevious(); | 2660 | mNavigator->selectPrevious(); |
2660 | } | 2661 | } |
2661 | void CalendarView::goNextMonth() | 2662 | void CalendarView::goNextMonth() |
2662 | { | 2663 | { |
2663 | mNavigator->selectNextMonth(); | 2664 | mNavigator->selectNextMonth(); |
2664 | } | 2665 | } |
2665 | 2666 | ||
2666 | void CalendarView::goPreviousMonth() | 2667 | void CalendarView::goPreviousMonth() |
2667 | { | 2668 | { |
2668 | mNavigator->selectPreviousMonth(); | 2669 | mNavigator->selectPreviousMonth(); |
2669 | } | 2670 | } |
2670 | 2671 | ||
2671 | void CalendarView::updateConfig() | 2672 | void CalendarView::updateConfig() |
2672 | { | 2673 | { |
2673 | if ( KOPrefs::instance()->mUseAppColors ) | 2674 | if ( KOPrefs::instance()->mUseAppColors ) |
2674 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2675 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2675 | emit configChanged(); | 2676 | emit configChanged(); |
2676 | mTodoList->updateConfig(); | 2677 | mTodoList->updateConfig(); |
2677 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2678 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2678 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2679 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2679 | // To make the "fill window" configurations work | 2680 | // To make the "fill window" configurations work |
2680 | //mViewManager->raiseCurrentView(); | 2681 | //mViewManager->raiseCurrentView(); |
2681 | } | 2682 | } |
2682 | 2683 | ||
2683 | 2684 | ||
2684 | void CalendarView::eventChanged(Event *event) | 2685 | void CalendarView::eventChanged(Event *event) |
2685 | { | 2686 | { |
2686 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2687 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2687 | //updateUnmanagedViews(); | 2688 | //updateUnmanagedViews(); |
2688 | } | 2689 | } |
2689 | 2690 | ||
2690 | void CalendarView::eventAdded(Event *event) | 2691 | void CalendarView::eventAdded(Event *event) |
2691 | { | 2692 | { |
2692 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2693 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2693 | } | 2694 | } |
2694 | 2695 | ||
2695 | void CalendarView::eventToBeDeleted(Event *) | 2696 | void CalendarView::eventToBeDeleted(Event *) |
2696 | { | 2697 | { |
2697 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2698 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2698 | } | 2699 | } |
2699 | 2700 | ||
2700 | void CalendarView::eventDeleted() | 2701 | void CalendarView::eventDeleted() |
2701 | { | 2702 | { |
2702 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2703 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2703 | } | 2704 | } |
2704 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2705 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2705 | { | 2706 | { |
2706 | changeIncidenceDisplay((Incidence *)which, action); | 2707 | changeIncidenceDisplay((Incidence *)which, action); |
2707 | mDateNavigator->updateView(); //LR | 2708 | mDateNavigator->updateView(); //LR |
2708 | //mDialogManager->updateSearchDialog(); | 2709 | //mDialogManager->updateSearchDialog(); |
2709 | 2710 | ||
2710 | if (which) { | 2711 | if (which) { |
2711 | mViewManager->updateWNview(); | 2712 | mViewManager->updateWNview(); |
2712 | //mTodoList->updateView(); | 2713 | //mTodoList->updateView(); |
2713 | } | 2714 | } |
2714 | 2715 | ||
2715 | } | 2716 | } |
2716 | 2717 | ||
2717 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2718 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2718 | { | 2719 | { |
2719 | updateUnmanagedViews(); | 2720 | updateUnmanagedViews(); |
2720 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2721 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2721 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2722 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2722 | mCalendar->checkAlarmForIncidence( 0, true ); | 2723 | mCalendar->checkAlarmForIncidence( 0, true ); |
2723 | if ( mEventViewerDialog ) | 2724 | if ( mEventViewerDialog ) |
2724 | mEventViewerDialog->hide(); | 2725 | mEventViewerDialog->hide(); |
2725 | } | 2726 | } |
2726 | else | 2727 | else |
2727 | mCalendar->checkAlarmForIncidence( which , false ); | 2728 | mCalendar->checkAlarmForIncidence( which , false ); |
2728 | } | 2729 | } |
2729 | 2730 | ||
2730 | // most of the changeEventDisplays() right now just call the view's | 2731 | // most of the changeEventDisplays() right now just call the view's |
2731 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2732 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2732 | void CalendarView::changeEventDisplay(Event *which, int action) | 2733 | void CalendarView::changeEventDisplay(Event *which, int action) |
2733 | { | 2734 | { |
2734 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2735 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2735 | changeIncidenceDisplay((Incidence *)which, action); | 2736 | changeIncidenceDisplay((Incidence *)which, action); |
2736 | static bool clearallviews = false; | 2737 | static bool clearallviews = false; |
2737 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2738 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2738 | if ( clearallviews ) { | 2739 | if ( clearallviews ) { |
2739 | clearAllViews(); | 2740 | clearAllViews(); |
2740 | clearallviews = false; | 2741 | clearallviews = false; |
2741 | } | 2742 | } |
2742 | return; | 2743 | return; |
2743 | } | 2744 | } |
2744 | clearallviews = true; | 2745 | clearallviews = true; |
2745 | mDateNavigator->updateView(); | 2746 | mDateNavigator->updateView(); |
2746 | //mDialogManager->updateSearchDialog(); | 2747 | //mDialogManager->updateSearchDialog(); |
2747 | if (which) { | 2748 | if (which) { |
2748 | // If there is an event view visible update the display | 2749 | // If there is an event view visible update the display |
2749 | mViewManager->currentView()->changeEventDisplay(which,action); | 2750 | mViewManager->currentView()->changeEventDisplay(which,action); |
2750 | // TODO: check, if update needed | 2751 | // TODO: check, if update needed |
2751 | // if (which->getTodoStatus()) { | 2752 | // if (which->getTodoStatus()) { |
2752 | mTodoList->updateView(); | 2753 | mTodoList->updateView(); |
2753 | if ( action != KOGlobals::EVENTDELETED ) { | 2754 | if ( action != KOGlobals::EVENTDELETED ) { |
2754 | mConflictingEvent = which ; | 2755 | mConflictingEvent = which ; |
2755 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); | 2756 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); |
2756 | } | 2757 | } |
2757 | // } | 2758 | // } |
2758 | } else { | 2759 | } else { |
2759 | mViewManager->currentView()->updateView(); | 2760 | mViewManager->currentView()->updateView(); |
2760 | } | 2761 | } |
2761 | } | 2762 | } |
2762 | void CalendarView::checkConflictForEvent() | 2763 | void CalendarView::checkConflictForEvent() |
2763 | { | 2764 | { |
2764 | 2765 | ||
2765 | if (!KOPrefs::instance()->mConfirm) | 2766 | if (!KOPrefs::instance()->mConfirm) |
2766 | return; | 2767 | return; |
2767 | if ( ! mConflictingEvent ) return; | 2768 | if ( ! mConflictingEvent ) return; |
2768 | if ( mConflictingEvent->isHoliday() || mConflictingEvent->isBirthday() || mConflictingEvent->isAnniversary() ) { | 2769 | if ( mConflictingEvent->isHoliday() || mConflictingEvent->isBirthday() || mConflictingEvent->isAnniversary() ) { |
2769 | mConflictingEvent = 0; | 2770 | mConflictingEvent = 0; |
2770 | return; | 2771 | return; |
2771 | } | 2772 | } |
2772 | QPtrList<Event> testlist = mCalendar->events(); | 2773 | QPtrList<Event> testlist = mCalendar->events(); |
2773 | Event * test = testlist.first(); | 2774 | Event * test = testlist.first(); |
2774 | QDateTime conflict; | 2775 | QDateTime conflict; |
2775 | QDateTime retVal; | 2776 | QDateTime retVal; |
2776 | bool found = false; | 2777 | bool found = false; |
2777 | Event * cE = 0; | 2778 | Event * cE = 0; |
2778 | QDateTime current = QDateTime::currentDateTime(); | 2779 | QDateTime current = QDateTime::currentDateTime(); |
2779 | while ( test ) { | 2780 | while ( test ) { |
2780 | if ( !test->doesFloat() ) { | 2781 | if ( !test->doesFloat() ) { |
2781 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 2782 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
2782 | if ( ! found ) { | 2783 | if ( ! found ) { |
2783 | conflict = retVal; | 2784 | conflict = retVal; |
2784 | cE = test; | 2785 | cE = test; |
2785 | } else { | 2786 | } else { |
2786 | if ( retVal < conflict ) { | 2787 | if ( retVal < conflict ) { |
2787 | conflict = retVal; | 2788 | conflict = retVal; |
2788 | cE = test; | 2789 | cE = test; |
2789 | } | 2790 | } |
2790 | } | 2791 | } |
2791 | found = true; | 2792 | found = true; |
2792 | } | 2793 | } |
2793 | } | 2794 | } |
2794 | test = testlist.next(); | 2795 | test = testlist.next(); |
2795 | } | 2796 | } |
2796 | if ( found ) { | 2797 | if ( found ) { |
2797 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 2798 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
2798 | qApp->processEvents(); | 2799 | qApp->processEvents(); |
2799 | int km = KMessageBox::warningContinueCancel(this,mess, | 2800 | int km = KMessageBox::warningContinueCancel(this,mess, |
2800 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | 2801 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); |
2801 | if ( km != KMessageBox::Continue ) | 2802 | if ( km != KMessageBox::Continue ) |
2802 | return; | 2803 | return; |
2803 | 2804 | ||
2804 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 2805 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
2805 | mViewManager->showDayView(); | 2806 | mViewManager->showDayView(); |
2806 | mNavigator->slotDaySelect( conflict.date() ); | 2807 | mNavigator->slotDaySelect( conflict.date() ); |
2807 | int hour = conflict.time().hour(); | 2808 | int hour = conflict.time().hour(); |
2808 | mViewManager->agendaView()->setStartHour( hour ); | 2809 | mViewManager->agendaView()->setStartHour( hour ); |
2809 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 2810 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
2810 | } | 2811 | } |
2811 | mConflictingEvent = 0; | 2812 | mConflictingEvent = 0; |
2812 | return; | 2813 | return; |
2813 | 2814 | ||
2814 | } | 2815 | } |
2815 | 2816 | ||
2816 | void CalendarView::updateTodoViews() | 2817 | void CalendarView::updateTodoViews() |
2817 | { | 2818 | { |
2818 | mTodoList->updateView(); | 2819 | mTodoList->updateView(); |
2819 | mViewManager->currentView()->updateView(); | 2820 | mViewManager->currentView()->updateView(); |
2820 | 2821 | ||
2821 | } | 2822 | } |
2822 | 2823 | ||
2823 | 2824 | ||
2824 | 2825 | ||
2825 | void CalendarView::clearAllViews() | 2826 | void CalendarView::clearAllViews() |
2826 | { | 2827 | { |
2827 | mTodoList->clearList(); | 2828 | mTodoList->clearList(); |
2828 | mViewManager->clearAllViews(); | 2829 | mViewManager->clearAllViews(); |
2829 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2830 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2830 | if ( sd ) { | 2831 | if ( sd ) { |
2831 | KOListView* kol = sd->listview(); | 2832 | KOListView* kol = sd->listview(); |
2832 | if ( kol ) | 2833 | if ( kol ) |
2833 | kol->clearList(); | 2834 | kol->clearList(); |
2834 | } | 2835 | } |
2835 | } | 2836 | } |
2836 | void CalendarView::updateView() | 2837 | void CalendarView::updateView() |
2837 | { | 2838 | { |
2838 | static bool clearallviews = false; | 2839 | static bool clearallviews = false; |
2839 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2840 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2840 | if ( clearallviews ) { | 2841 | if ( clearallviews ) { |
2841 | clearAllViews(); | 2842 | clearAllViews(); |
2842 | clearallviews = false; | 2843 | clearallviews = false; |
2843 | } | 2844 | } |
2844 | return; | 2845 | return; |
2845 | } | 2846 | } |
2846 | clearallviews = true; | 2847 | clearallviews = true; |
2847 | DateList tmpList = mNavigator->selectedDates(); | 2848 | DateList tmpList = mNavigator->selectedDates(); |
2848 | 2849 | ||
2849 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2850 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2850 | mTodoList->updateView(); | 2851 | mTodoList->updateView(); |
2851 | // We assume that the navigator only selects consecutive days. | 2852 | // We assume that the navigator only selects consecutive days. |
2852 | updateView( tmpList.first(), tmpList.last() ); | 2853 | updateView( tmpList.first(), tmpList.last() ); |
2853 | } | 2854 | } |
2854 | 2855 | ||
2855 | void CalendarView::updateUnmanagedViews() | 2856 | void CalendarView::updateUnmanagedViews() |
2856 | { | 2857 | { |
2857 | mDateNavigator->updateDayMatrix(); | 2858 | mDateNavigator->updateDayMatrix(); |
2858 | } | 2859 | } |
2859 | 2860 | ||
2860 | int CalendarView::msgItemDelete(const QString name) | 2861 | int CalendarView::msgItemDelete(const QString name) |
2861 | { | 2862 | { |
2862 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2863 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2863 | i18n("This item will be\npermanently deleted."), | 2864 | i18n("This item will be\npermanently deleted."), |
2864 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2865 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2865 | } | 2866 | } |
2866 | 2867 | ||
2867 | 2868 | ||
2868 | void CalendarView::edit_cut() | 2869 | void CalendarView::edit_cut() |
2869 | { | 2870 | { |
2870 | Event *anEvent=0; | 2871 | Event *anEvent=0; |
2871 | 2872 | ||
2872 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2873 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2873 | 2874 | ||
2874 | if (mViewManager->currentView()->isEventView()) { | 2875 | if (mViewManager->currentView()->isEventView()) { |
2875 | if ( incidence && incidence->typeID() == eventID ) { | 2876 | if ( incidence && incidence->typeID() == eventID ) { |
2876 | anEvent = static_cast<Event *>(incidence); | 2877 | anEvent = static_cast<Event *>(incidence); |
2877 | } | 2878 | } |
2878 | } | 2879 | } |
2879 | 2880 | ||
2880 | if (!anEvent) { | 2881 | if (!anEvent) { |
2881 | KNotifyClient::beep(); | 2882 | KNotifyClient::beep(); |
2882 | return; | 2883 | return; |
2883 | } | 2884 | } |
2884 | DndFactory factory( mCalendar ); | 2885 | DndFactory factory( mCalendar ); |
2885 | factory.cutIncidence(anEvent); | 2886 | factory.cutIncidence(anEvent); |
2886 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2887 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2887 | } | 2888 | } |
2888 | 2889 | ||
2889 | void CalendarView::edit_copy() | 2890 | void CalendarView::edit_copy() |
2890 | { | 2891 | { |
2891 | Event *anEvent=0; | 2892 | Event *anEvent=0; |
2892 | 2893 | ||
2893 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2894 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2894 | 2895 | ||
2895 | if (mViewManager->currentView()->isEventView()) { | 2896 | if (mViewManager->currentView()->isEventView()) { |
2896 | if ( incidence && incidence->typeID() == eventID ) { | 2897 | if ( incidence && incidence->typeID() == eventID ) { |
2897 | anEvent = static_cast<Event *>(incidence); | 2898 | anEvent = static_cast<Event *>(incidence); |
2898 | } | 2899 | } |
2899 | } | 2900 | } |
2900 | 2901 | ||
2901 | if (!anEvent) { | 2902 | if (!anEvent) { |
2902 | KNotifyClient::beep(); | 2903 | KNotifyClient::beep(); |
2903 | return; | 2904 | return; |
2904 | } | 2905 | } |
2905 | DndFactory factory( mCalendar ); | 2906 | DndFactory factory( mCalendar ); |
2906 | factory.copyIncidence(anEvent); | 2907 | factory.copyIncidence(anEvent); |
2907 | } | 2908 | } |
2908 | 2909 | ||
2909 | void CalendarView::edit_paste() | 2910 | void CalendarView::edit_paste() |
2910 | { | 2911 | { |
2911 | QDate date = mNavigator->selectedDates().first(); | 2912 | QDate date = mNavigator->selectedDates().first(); |
2912 | 2913 | ||
2913 | DndFactory factory( mCalendar ); | 2914 | DndFactory factory( mCalendar ); |
2914 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2915 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2915 | 2916 | ||
2916 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2917 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2917 | } | 2918 | } |
2918 | void CalendarView::edit_global_options() | 2919 | void CalendarView::edit_global_options() |
2919 | { | 2920 | { |
2920 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2921 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2921 | emit save(); | 2922 | emit save(); |
2922 | emit saveStopTimer(); | 2923 | emit saveStopTimer(); |
2923 | mDialogManager->showGlobalOptionsDialog(); | 2924 | mDialogManager->showGlobalOptionsDialog(); |
2924 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2925 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2925 | emit saveStopTimer(); | 2926 | emit saveStopTimer(); |
2926 | 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!"), | 2927 | 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!"), |
2927 | i18n("Timezone settings"),i18n("Reload"))) { | 2928 | i18n("Timezone settings"),i18n("Reload"))) { |
2928 | qDebug("KO: TZ reload cancelled "); | 2929 | qDebug("KO: TZ reload cancelled "); |
2929 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2930 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2930 | return; | 2931 | return; |
2931 | } | 2932 | } |
2932 | qDebug("KO: Timezone change "); | 2933 | qDebug("KO: Timezone change "); |
2933 | loadCalendars(); | 2934 | loadCalendars(); |
2934 | setModified(true); | 2935 | setModified(true); |
2935 | } | 2936 | } |
2936 | else | 2937 | else |
2937 | qDebug("KO: No tz change "); | 2938 | qDebug("KO: No tz change "); |
2938 | } | 2939 | } |
2939 | void CalendarView::edit_options() | 2940 | void CalendarView::edit_options() |
2940 | { | 2941 | { |
2941 | mDialogManager->showOptionsDialog(); | 2942 | mDialogManager->showOptionsDialog(); |
2942 | } | 2943 | } |
2943 | 2944 | ||
2944 | 2945 | ||
2945 | void CalendarView::slotSelectPickerDate( QDate d) | 2946 | void CalendarView::slotSelectPickerDate( QDate d) |
2946 | { | 2947 | { |
2947 | mDateFrame->hide(); | 2948 | mDateFrame->hide(); |
2948 | if ( mDatePickerMode == 1 ) { | 2949 | if ( mDatePickerMode == 1 ) { |
2949 | mNavigator->slotDaySelect( d ); | 2950 | mNavigator->slotDaySelect( d ); |
2950 | } else if ( mDatePickerMode == 2 ) { | 2951 | } else if ( mDatePickerMode == 2 ) { |
2951 | if ( mMoveIncidence->typeID() == todoID ) { | 2952 | if ( mMoveIncidence->typeID() == todoID ) { |
2952 | Todo * to = (Todo *) mMoveIncidence; | 2953 | Todo * to = (Todo *) mMoveIncidence; |
2953 | QTime tim; | 2954 | QTime tim; |
2954 | int len = 0; | 2955 | int len = 0; |
2955 | if ( to->hasStartDate() && to->hasDueDate() ) | 2956 | if ( to->hasStartDate() && to->hasDueDate() ) |
2956 | len = to->dtStart().secsTo( to->dtDue()); | 2957 | len = to->dtStart().secsTo( to->dtDue()); |
2957 | if ( to->hasDueDate() ) | 2958 | if ( to->hasDueDate() ) |
2958 | tim = to->dtDue().time(); | 2959 | tim = to->dtDue().time(); |
2959 | else { | 2960 | else { |
2960 | tim = QTime ( 0,0,0 ); | 2961 | tim = QTime ( 0,0,0 ); |
2961 | to->setFloats( true ); | 2962 | to->setFloats( true ); |
2962 | to->setHasDueDate( true ); | 2963 | to->setHasDueDate( true ); |
2963 | } | 2964 | } |
2964 | QDateTime dt ( d,tim ); | 2965 | QDateTime dt ( d,tim ); |
2965 | to->setDtDue( dt ); | 2966 | to->setDtDue( dt ); |
2966 | 2967 | ||
2967 | if ( to->hasStartDate() ) { | 2968 | if ( to->hasStartDate() ) { |
2968 | if ( len>0 ) | 2969 | if ( len>0 ) |
2969 | to->setDtStart(to->dtDue().addSecs( -len )); | 2970 | to->setDtStart(to->dtDue().addSecs( -len )); |
2970 | else | 2971 | else |
2971 | if (to->dtStart() > to->dtDue() ) | 2972 | if (to->dtStart() > to->dtDue() ) |
2972 | to->setDtStart(to->dtDue().addDays( -3 )); | 2973 | to->setDtStart(to->dtDue().addDays( -3 )); |
2973 | } | 2974 | } |
2974 | 2975 | ||
2975 | todoChanged( to ); | 2976 | todoChanged( to ); |
2976 | } else if ( mMoveIncidence->typeID() == eventID ) { | 2977 | } else if ( mMoveIncidence->typeID() == eventID ) { |
2977 | if ( mMoveIncidence->doesRecur() ) { | 2978 | if ( mMoveIncidence->doesRecur() ) { |
2978 | #if 0 | 2979 | #if 0 |
2979 | // PENDING implement this | 2980 | // PENDING implement this |
2980 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2981 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2981 | mCalendar()->addIncidence( newInc ); | 2982 | mCalendar()->addIncidence( newInc ); |
2982 | if ( mMoveIncidence->typeID() == todoID ) | 2983 | if ( mMoveIncidence->typeID() == todoID ) |
2983 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2984 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2984 | else | 2985 | else |
2985 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2986 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2986 | mMoveIncidence = newInc; | 2987 | mMoveIncidence = newInc; |
2987 | 2988 | ||
2988 | #endif | 2989 | #endif |
2989 | } | 2990 | } |
2990 | QTime tim = mMoveIncidence->dtStart().time(); | 2991 | QTime tim = mMoveIncidence->dtStart().time(); |
2991 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2992 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2992 | QDateTime dt ( d,tim ); | 2993 | QDateTime dt ( d,tim ); |
2993 | mMoveIncidence->setDtStart( dt ); | 2994 | mMoveIncidence->setDtStart( dt ); |
2994 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2995 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2995 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2996 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2996 | } else if ( mMoveIncidence->typeID() == journalID ) { | 2997 | } else if ( mMoveIncidence->typeID() == journalID ) { |
2997 | QTime tim = mMoveIncidence->dtStart().time(); | 2998 | QTime tim = mMoveIncidence->dtStart().time(); |
2998 | QDateTime dt ( d,tim ); | 2999 | QDateTime dt ( d,tim ); |
2999 | mMoveIncidence->setDtStart( dt ); | 3000 | mMoveIncidence->setDtStart( dt ); |
3000 | updateView(); | 3001 | updateView(); |
3001 | } | 3002 | } |
3002 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3003 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3003 | } | 3004 | } |
3004 | } | 3005 | } |
3005 | 3006 | ||
3006 | void CalendarView::removeCategories() | 3007 | void CalendarView::removeCategories() |
3007 | { | 3008 | { |
3008 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3009 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3009 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3010 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3010 | QStringList catIncList; | 3011 | QStringList catIncList; |
3011 | QStringList newCatList; | 3012 | QStringList newCatList; |
3012 | Incidence* inc = incList.first(); | 3013 | Incidence* inc = incList.first(); |
3013 | uint i; | 3014 | uint i; |
3014 | while ( inc ) { | 3015 | while ( inc ) { |
3015 | newCatList.clear(); | 3016 | newCatList.clear(); |
3016 | catIncList = inc->categories() ; | 3017 | catIncList = inc->categories() ; |
3017 | for( i = 0; i< catIncList.count(); ++i ) { | 3018 | for( i = 0; i< catIncList.count(); ++i ) { |
3018 | if ( catList.contains (catIncList[i])) | 3019 | if ( catList.contains (catIncList[i])) |
3019 | newCatList.append( catIncList[i] ); | 3020 | newCatList.append( catIncList[i] ); |
3020 | } | 3021 | } |
3021 | newCatList.sort(); | 3022 | newCatList.sort(); |
3022 | inc->setCategories( newCatList.join(",") ); | 3023 | inc->setCategories( newCatList.join(",") ); |
3023 | inc = incList.next(); | 3024 | inc = incList.next(); |
3024 | } | 3025 | } |
3025 | } | 3026 | } |
3026 | 3027 | ||
3027 | int CalendarView::addCategories() | 3028 | int CalendarView::addCategories() |
3028 | { | 3029 | { |
3029 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3030 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3030 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3031 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3031 | QStringList catIncList; | 3032 | QStringList catIncList; |
3032 | Incidence* inc = incList.first(); | 3033 | Incidence* inc = incList.first(); |
3033 | uint i; | 3034 | uint i; |
3034 | int count = 0; | 3035 | int count = 0; |
3035 | while ( inc ) { | 3036 | while ( inc ) { |
3036 | catIncList = inc->categories() ; | 3037 | catIncList = inc->categories() ; |
3037 | for( i = 0; i< catIncList.count(); ++i ) { | 3038 | for( i = 0; i< catIncList.count(); ++i ) { |
3038 | if ( !catList.contains (catIncList[i])) { | 3039 | if ( !catList.contains (catIncList[i])) { |
3039 | catList.append( catIncList[i] ); | 3040 | catList.append( catIncList[i] ); |
3040 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3041 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3041 | ++count; | 3042 | ++count; |
3042 | } | 3043 | } |
3043 | } | 3044 | } |
3044 | inc = incList.next(); | 3045 | inc = incList.next(); |
3045 | } | 3046 | } |
3046 | catList.sort(); | 3047 | catList.sort(); |
3047 | KOPrefs::instance()->mCustomCategories = catList; | 3048 | KOPrefs::instance()->mCustomCategories = catList; |
3048 | return count; | 3049 | return count; |
3049 | } | 3050 | } |
3050 | 3051 | ||
3051 | void CalendarView::editCategories() | 3052 | void CalendarView::editCategories() |
3052 | { | 3053 | { |
3053 | qDebug("CalendarView::editCategories() "); | 3054 | qDebug("CalendarView::editCategories() "); |
3054 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3055 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3055 | ced.exec(); | 3056 | ced.exec(); |
3056 | } | 3057 | } |
3057 | void CalendarView::manageCategories() | 3058 | void CalendarView::manageCategories() |
3058 | { | 3059 | { |
3059 | KOCatPrefs* cp = new KOCatPrefs(); | 3060 | KOCatPrefs* cp = new KOCatPrefs(); |
3060 | cp->show(); | 3061 | cp->show(); |
3061 | int w =cp->sizeHint().width() ; | 3062 | int w =cp->sizeHint().width() ; |
3062 | int h = cp->sizeHint().height() ; | 3063 | int h = cp->sizeHint().height() ; |
3063 | int dw = QApplication::desktop()->width(); | 3064 | int dw = QApplication::desktop()->width(); |
3064 | int dh = QApplication::desktop()->height(); | 3065 | int dh = QApplication::desktop()->height(); |
3065 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3066 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3066 | if ( !cp->exec() ) { | 3067 | if ( !cp->exec() ) { |
3067 | delete cp; | 3068 | delete cp; |
3068 | return; | 3069 | return; |
3069 | } | 3070 | } |
3070 | int count = 0; | 3071 | int count = 0; |
3071 | if ( cp->addCat() ) { | 3072 | if ( cp->addCat() ) { |
3072 | count = addCategories(); | 3073 | count = addCategories(); |
3073 | if ( count ) { | 3074 | if ( count ) { |
3074 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3075 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3075 | writeSettings(); | 3076 | writeSettings(); |
3076 | } else | 3077 | } else |
3077 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3078 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3078 | } else { | 3079 | } else { |
3079 | removeCategories(); | 3080 | removeCategories(); |
3080 | updateView(); | 3081 | updateView(); |
3081 | } | 3082 | } |
3082 | delete cp; | 3083 | delete cp; |
3083 | } | 3084 | } |
3084 | 3085 | ||
3085 | void CalendarView::beamIncidence(Incidence * Inc) | 3086 | void CalendarView::beamIncidence(Incidence * Inc) |
3086 | { | 3087 | { |
3087 | QPtrList<Incidence> delSel ; | 3088 | QPtrList<Incidence> delSel ; |
3088 | delSel.append(Inc); | 3089 | delSel.append(Inc); |
3089 | beamIncidenceList( delSel ); | 3090 | beamIncidenceList( delSel ); |
3090 | } | 3091 | } |
3091 | void CalendarView::beamCalendar() | 3092 | void CalendarView::beamCalendar() |
3092 | { | 3093 | { |
3093 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3094 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3094 | //qDebug("beamCalendar() "); | 3095 | //qDebug("beamCalendar() "); |
3095 | beamIncidenceList( delSel ); | 3096 | beamIncidenceList( delSel ); |
3096 | } | 3097 | } |
3097 | void CalendarView::beamFilteredCalendar() | 3098 | void CalendarView::beamFilteredCalendar() |
3098 | { | 3099 | { |
3099 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3100 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3100 | //qDebug("beamFilteredCalendar() "); | 3101 | //qDebug("beamFilteredCalendar() "); |
3101 | beamIncidenceList( delSel ); | 3102 | beamIncidenceList( delSel ); |
3102 | } | 3103 | } |
3103 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3104 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3104 | { | 3105 | { |
3105 | 3106 | ||
3106 | KOBeamPrefs beamDialog; | 3107 | KOBeamPrefs beamDialog; |
3107 | if ( beamDialog.exec () == QDialog::Rejected ) | 3108 | if ( beamDialog.exec () == QDialog::Rejected ) |
3108 | return; | 3109 | return; |
3109 | #ifdef DESKTOP_VERSION | 3110 | #ifdef DESKTOP_VERSION |
3110 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3111 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3111 | #else | 3112 | #else |
3112 | QString fn = "/tmp/kopibeamfile"; | 3113 | QString fn = "/tmp/kopibeamfile"; |
3113 | #endif | 3114 | #endif |
3114 | QString mes; | 3115 | QString mes; |
3115 | bool createbup = true; | 3116 | bool createbup = true; |
3116 | if ( createbup ) { | 3117 | if ( createbup ) { |
3117 | QString description = "\n"; | 3118 | QString description = "\n"; |
3118 | CalendarLocal* cal = new CalendarLocal(); | 3119 | CalendarLocal* cal = new CalendarLocal(); |
3119 | if ( beamDialog.beamLocal() ) | 3120 | if ( beamDialog.beamLocal() ) |
3120 | cal->setLocalTime(); | 3121 | cal->setLocalTime(); |
3121 | else | 3122 | else |
3122 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3123 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3123 | Incidence *incidence = delSel.first(); | 3124 | Incidence *incidence = delSel.first(); |
3124 | bool addText = false; | 3125 | bool addText = false; |
3125 | if ( delSel.count() < 10 ) | 3126 | if ( delSel.count() < 10 ) |
3126 | addText = true; | 3127 | addText = true; |
3127 | else { | 3128 | else { |
3128 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3129 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3129 | } | 3130 | } |
3130 | while ( incidence ) { | 3131 | while ( incidence ) { |
3131 | Incidence *in = incidence->clone(); | 3132 | Incidence *in = incidence->clone(); |
3132 | if ( ! in->summary().isEmpty() ) { | 3133 | if ( ! in->summary().isEmpty() ) { |
3133 | in->setDescription(""); | 3134 | in->setDescription(""); |
3134 | } else { | 3135 | } else { |
3135 | in->setSummary( in->description().left(20)); | 3136 | in->setSummary( in->description().left(20)); |
3136 | in->setDescription(""); | 3137 | in->setDescription(""); |
3137 | } | 3138 | } |
3138 | if ( addText ) | 3139 | if ( addText ) |
3139 | description += in->summary() + "\n"; | 3140 | description += in->summary() + "\n"; |
3140 | cal->addIncidence( in ); | 3141 | cal->addIncidence( in ); |
3141 | incidence = delSel.next(); | 3142 | incidence = delSel.next(); |
3142 | } | 3143 | } |
3143 | if ( beamDialog.beamVcal() ) { | 3144 | if ( beamDialog.beamVcal() ) { |
3144 | fn += ".vcs"; | 3145 | fn += ".vcs"; |
3145 | FileStorage storage( cal, fn, new VCalFormat ); | 3146 | FileStorage storage( cal, fn, new VCalFormat ); |
3146 | storage.save(); | 3147 | storage.save(); |
3147 | } else { | 3148 | } else { |
3148 | fn += ".ics"; | 3149 | fn += ".ics"; |
3149 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3150 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3150 | storage.save(); | 3151 | storage.save(); |
3151 | } | 3152 | } |
3152 | delete cal; | 3153 | delete cal; |
3153 | mes = i18n("KO/Pi: Ready for beaming"); | 3154 | mes = i18n("KO/Pi: Ready for beaming"); |
3154 | topLevelWidget()->setCaption(mes); | 3155 | topLevelWidget()->setCaption(mes); |
3155 | KApplication::convert2latin1( fn ); | 3156 | KApplication::convert2latin1( fn ); |
3156 | #ifndef DESKTOP_VERSION | 3157 | #ifndef DESKTOP_VERSION |
3157 | Ir *ir = new Ir( this ); | 3158 | Ir *ir = new Ir( this ); |
3158 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3159 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3159 | ir->send( fn, description, "text/x-vCalendar" ); | 3160 | ir->send( fn, description, "text/x-vCalendar" ); |
3160 | #endif | 3161 | #endif |
3161 | } | 3162 | } |
3162 | } | 3163 | } |
3163 | 3164 | ||
3164 | #ifndef DESKTOP_VERSION | 3165 | #ifndef DESKTOP_VERSION |
3165 | void CalendarView::beamDone( Ir *ir ) | 3166 | void CalendarView::beamDone( Ir *ir ) |
3166 | { | 3167 | { |
3167 | delete ir; | 3168 | delete ir; |
3168 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3169 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3169 | topLevelWidget()->raise(); | 3170 | topLevelWidget()->raise(); |
3170 | } | 3171 | } |
3171 | #else | 3172 | #else |
3172 | void CalendarView::beamDone( Ir *){;} | 3173 | void CalendarView::beamDone( Ir *){;} |
3173 | #endif | 3174 | #endif |
3174 | void CalendarView::moveIncidence(Incidence * inc ) | 3175 | void CalendarView::moveIncidence(Incidence * inc ) |
3175 | { | 3176 | { |
3176 | if ( !inc ) return; | 3177 | if ( !inc ) return; |
3177 | showDatePickerPopup(); | 3178 | showDatePickerPopup(); |
3178 | mDatePickerMode = 2; | 3179 | mDatePickerMode = 2; |
3179 | mMoveIncidence = inc ; | 3180 | mMoveIncidence = inc ; |
3180 | QDate da; | 3181 | QDate da; |
3181 | if ( mMoveIncidence->typeID() == todoID ) { | 3182 | if ( mMoveIncidence->typeID() == todoID ) { |
3182 | Todo * to = (Todo *) mMoveIncidence; | 3183 | Todo * to = (Todo *) mMoveIncidence; |
3183 | if ( to->hasDueDate() ) | 3184 | if ( to->hasDueDate() ) |
3184 | da = to->dtDue().date(); | 3185 | da = to->dtDue().date(); |
3185 | else | 3186 | else |
3186 | da = QDate::currentDate(); | 3187 | da = QDate::currentDate(); |
3187 | } else { | 3188 | } else { |
3188 | da = mMoveIncidence->dtStart().date(); | 3189 | da = mMoveIncidence->dtStart().date(); |
3189 | } | 3190 | } |
3190 | //PENDING set date for recurring incidence to date of recurrence | 3191 | //PENDING set date for recurring incidence to date of recurrence |
3191 | //mMoveIncidenceOldDate; | 3192 | //mMoveIncidenceOldDate; |
3192 | mDatePicker->setDate( da ); | 3193 | mDatePicker->setDate( da ); |
3193 | } | 3194 | } |
3194 | void CalendarView::showDatePickerPopup() | 3195 | void CalendarView::showDatePickerPopup() |
3195 | { | 3196 | { |
3196 | if ( mDateFrame->isVisible() ) | 3197 | if ( mDateFrame->isVisible() ) |
3197 | mDateFrame->hide(); | 3198 | mDateFrame->hide(); |
3198 | else { | 3199 | else { |
3199 | int offX = 0, offY = 0; | 3200 | int offX = 0, offY = 0; |
3200 | #ifdef DESKTOP_VERSION | 3201 | #ifdef DESKTOP_VERSION |
3201 | int w =mDatePicker->sizeHint().width() ; | 3202 | int w =mDatePicker->sizeHint().width() ; |
3202 | int h = mDatePicker->sizeHint().height() ; | 3203 | int h = mDatePicker->sizeHint().height() ; |
3203 | int dw = topLevelWidget()->width(); | 3204 | int dw = topLevelWidget()->width(); |
3204 | int dh = topLevelWidget()->height(); | 3205 | int dh = topLevelWidget()->height(); |
3205 | offX = topLevelWidget()->x(); | 3206 | offX = topLevelWidget()->x(); |
3206 | offY = topLevelWidget()->y(); | 3207 | offY = topLevelWidget()->y(); |
3207 | #else | 3208 | #else |
3208 | int w =mDatePicker->sizeHint().width() ; | 3209 | int w =mDatePicker->sizeHint().width() ; |
3209 | int h = mDatePicker->sizeHint().height() ; | 3210 | int h = mDatePicker->sizeHint().height() ; |
3210 | int dw = QApplication::desktop()->width(); | 3211 | int dw = QApplication::desktop()->width(); |
3211 | int dh = QApplication::desktop()->height(); | 3212 | int dh = QApplication::desktop()->height(); |
3212 | #endif | 3213 | #endif |
3213 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3214 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3214 | mDateFrame->show(); | 3215 | mDateFrame->show(); |
3215 | } | 3216 | } |
3216 | } | 3217 | } |
3217 | void CalendarView::showDatePicker( ) | 3218 | void CalendarView::showDatePicker( ) |
3218 | { | 3219 | { |
3219 | showDatePickerPopup(); | 3220 | showDatePickerPopup(); |
3220 | mDatePickerMode = 1; | 3221 | mDatePickerMode = 1; |
3221 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3222 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3222 | } | 3223 | } |
3223 | 3224 | ||
3224 | void CalendarView::showEventEditor() | 3225 | void CalendarView::showEventEditor() |
3225 | { | 3226 | { |
3226 | #ifdef DESKTOP_VERSION | 3227 | #ifdef DESKTOP_VERSION |
3227 | int x,y,w,h; | 3228 | int x,y,w,h; |
3228 | x = mEventEditor->geometry().x(); | 3229 | x = mEventEditor->geometry().x(); |
3229 | y = mEventEditor->geometry().y(); | 3230 | y = mEventEditor->geometry().y(); |
3230 | w = mEventEditor->width(); | 3231 | w = mEventEditor->width(); |
3231 | h = mEventEditor->height(); | 3232 | h = mEventEditor->height(); |
3232 | mEventEditor->show(); | 3233 | mEventEditor->show(); |
3233 | mEventEditor->setGeometry(x,y,w,h); | 3234 | mEventEditor->setGeometry(x,y,w,h); |
3234 | #else | 3235 | #else |
3235 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3236 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3236 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3237 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3237 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3238 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3238 | qApp->processEvents(); | 3239 | qApp->processEvents(); |
3239 | delete mEventEditor; | 3240 | delete mEventEditor; |
3240 | mEventEditor = mDialogManager->getEventEditor(); | 3241 | mEventEditor = mDialogManager->getEventEditor(); |
3241 | topLevelWidget()->setCaption( i18n("") ); | 3242 | topLevelWidget()->setCaption( i18n("") ); |
3242 | } | 3243 | } |
3243 | mEventEditor->showMaximized(); | 3244 | mEventEditor->showMaximized(); |
3244 | #endif | 3245 | #endif |
3245 | } | 3246 | } |
3246 | void CalendarView::showTodoEditor() | 3247 | void CalendarView::showTodoEditor() |
3247 | { | 3248 | { |
3248 | #ifdef DESKTOP_VERSION | 3249 | #ifdef DESKTOP_VERSION |
3249 | int x,y,w,h; | 3250 | int x,y,w,h; |
3250 | x = mTodoEditor->geometry().x(); | 3251 | x = mTodoEditor->geometry().x(); |
3251 | y = mTodoEditor->geometry().y(); | 3252 | y = mTodoEditor->geometry().y(); |
3252 | w = mTodoEditor->width(); | 3253 | w = mTodoEditor->width(); |
3253 | h = mTodoEditor->height(); | 3254 | h = mTodoEditor->height(); |
3254 | mTodoEditor->show(); | 3255 | mTodoEditor->show(); |
3255 | mTodoEditor->setGeometry(x,y,w,h); | 3256 | mTodoEditor->setGeometry(x,y,w,h); |
3256 | #else | 3257 | #else |
3257 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3258 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3258 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3259 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3259 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3260 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3260 | qApp->processEvents(); | 3261 | qApp->processEvents(); |
3261 | delete mTodoEditor; | 3262 | delete mTodoEditor; |
3262 | mTodoEditor = mDialogManager->getTodoEditor(); | 3263 | mTodoEditor = mDialogManager->getTodoEditor(); |
3263 | topLevelWidget()->setCaption( i18n("") ); | 3264 | topLevelWidget()->setCaption( i18n("") ); |
3264 | } | 3265 | } |
3265 | mTodoEditor->showMaximized(); | 3266 | mTodoEditor->showMaximized(); |
3266 | #endif | 3267 | #endif |
3267 | } | 3268 | } |
3268 | 3269 | ||
3269 | void CalendarView::cloneIncidence() | 3270 | void CalendarView::cloneIncidence() |
3270 | { | 3271 | { |
3271 | Incidence *incidence = currentSelection(); | 3272 | Incidence *incidence = currentSelection(); |
3272 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3273 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3273 | if ( incidence ) { | 3274 | if ( incidence ) { |
3274 | cloneIncidence(incidence); | 3275 | cloneIncidence(incidence); |
3275 | } | 3276 | } |
3276 | } | 3277 | } |
3277 | void CalendarView::moveIncidence() | 3278 | void CalendarView::moveIncidence() |
3278 | { | 3279 | { |
3279 | Incidence *incidence = currentSelection(); | 3280 | Incidence *incidence = currentSelection(); |
3280 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3281 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3281 | if ( incidence ) { | 3282 | if ( incidence ) { |
3282 | moveIncidence(incidence); | 3283 | moveIncidence(incidence); |
3283 | } | 3284 | } |
3284 | } | 3285 | } |
3285 | void CalendarView::beamIncidence() | 3286 | void CalendarView::beamIncidence() |
3286 | { | 3287 | { |
3287 | Incidence *incidence = currentSelection(); | 3288 | Incidence *incidence = currentSelection(); |
3288 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3289 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3289 | if ( incidence ) { | 3290 | if ( incidence ) { |
3290 | beamIncidence(incidence); | 3291 | beamIncidence(incidence); |
3291 | } | 3292 | } |
3292 | } | 3293 | } |
3293 | void CalendarView::toggleCancelIncidence() | 3294 | void CalendarView::toggleCancelIncidence() |
3294 | { | 3295 | { |
3295 | Incidence *incidence = currentSelection(); | 3296 | Incidence *incidence = currentSelection(); |
3296 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3297 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3297 | if ( incidence ) { | 3298 | if ( incidence ) { |
3298 | cancelIncidence(incidence); | 3299 | cancelIncidence(incidence); |
3299 | } | 3300 | } |
3300 | } | 3301 | } |
3301 | 3302 | ||
3302 | 3303 | ||
3303 | void CalendarView::cancelIncidence(Incidence * inc ) | 3304 | void CalendarView::cancelIncidence(Incidence * inc ) |
3304 | { | 3305 | { |
3305 | inc->setCancelled( ! inc->cancelled() ); | 3306 | inc->setCancelled( ! inc->cancelled() ); |
3306 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3307 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3307 | updateView(); | 3308 | updateView(); |
3308 | } | 3309 | } |
3309 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3310 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3310 | { | 3311 | { |
3311 | Incidence * newInc = orgInc->clone(); | 3312 | Incidence * newInc = orgInc->clone(); |
3312 | newInc->recreate(); | 3313 | newInc->recreate(); |
3313 | 3314 | ||
3314 | if ( newInc->typeID() == todoID ) { | 3315 | if ( newInc->typeID() == todoID ) { |
3315 | Todo* t = (Todo*) newInc; | 3316 | Todo* t = (Todo*) newInc; |
3316 | bool cloneSub = false; | 3317 | bool cloneSub = false; |
3317 | if ( orgInc->relations().count() ) { | 3318 | if ( orgInc->relations().count() ) { |
3318 | int result = KMessageBox::warningYesNoCancel(this, | 3319 | int result = KMessageBox::warningYesNoCancel(this, |
3319 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), | 3320 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), |
3320 | i18n("Todo has subtodos"), | 3321 | i18n("Todo has subtodos"), |
3321 | i18n("Yes"), | 3322 | i18n("Yes"), |
3322 | i18n("No")); | 3323 | i18n("No")); |
3323 | 3324 | ||
3324 | if ( result == KMessageBox::Cancel ) { | 3325 | if ( result == KMessageBox::Cancel ) { |
3325 | delete t; | 3326 | delete t; |
3326 | return; | 3327 | return; |
3327 | } | 3328 | } |
3328 | if (result == KMessageBox::Yes) cloneSub = true; | 3329 | if (result == KMessageBox::Yes) cloneSub = true; |
3329 | } | 3330 | } |
3330 | showTodoEditor(); | 3331 | showTodoEditor(); |
3331 | mTodoEditor->editTodo( t ); | 3332 | mTodoEditor->editTodo( t ); |
3332 | if ( mTodoEditor->exec() ) { | 3333 | if ( mTodoEditor->exec() ) { |
3333 | if ( cloneSub ) { | 3334 | if ( cloneSub ) { |
3334 | orgInc->cloneRelations( t ); | 3335 | orgInc->cloneRelations( t ); |
3335 | mCalendar->addIncidenceBranch( t ); | 3336 | mCalendar->addIncidenceBranch( t ); |
3336 | updateView(); | 3337 | updateView(); |
3337 | 3338 | ||
3338 | } else { | 3339 | } else { |
3339 | mCalendar->addTodo( t ); | 3340 | mCalendar->addTodo( t ); |
3340 | updateView(); | 3341 | updateView(); |
3341 | } | 3342 | } |
3342 | } else { | 3343 | } else { |
3343 | delete t; | 3344 | delete t; |
3344 | } | 3345 | } |
3345 | } | 3346 | } |
3346 | else if ( newInc->typeID() == eventID ) { | 3347 | else if ( newInc->typeID() == eventID ) { |
3347 | Event* e = (Event*) newInc; | 3348 | Event* e = (Event*) newInc; |
3348 | showEventEditor(); | 3349 | showEventEditor(); |
3349 | mEventEditor->editEvent( e ); | 3350 | mEventEditor->editEvent( e ); |
3350 | if ( mEventEditor->exec() ) { | 3351 | if ( mEventEditor->exec() ) { |
3351 | mCalendar->addEvent( e ); | 3352 | mCalendar->addEvent( e ); |
3352 | updateView(); | 3353 | updateView(); |
3353 | } else { | 3354 | } else { |
3354 | delete e; | 3355 | delete e; |
3355 | } | 3356 | } |
3356 | } if ( newInc->typeID() == journalID ) { | 3357 | } if ( newInc->typeID() == journalID ) { |
3357 | mCalendar->addJournal( (Journal*) newInc ); | 3358 | mCalendar->addJournal( (Journal*) newInc ); |
3358 | editJournal( (Journal*) newInc ); | 3359 | editJournal( (Journal*) newInc ); |
3359 | } | 3360 | } |
3360 | setActiveWindow(); | 3361 | setActiveWindow(); |
3361 | } | 3362 | } |
3362 | 3363 | ||
3363 | void CalendarView::newEvent() | 3364 | void CalendarView::newEvent() |
3364 | { | 3365 | { |
3365 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3366 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3366 | KOAgendaView *aView = mViewManager->agendaView(); | 3367 | KOAgendaView *aView = mViewManager->agendaView(); |
3367 | if (aView) { | 3368 | if (aView) { |
3368 | if (aView->selectionStart().isValid()) { | 3369 | if (aView->selectionStart().isValid()) { |
3369 | if (aView->selectedIsAllDay()) { | 3370 | if (aView->selectedIsAllDay()) { |
3370 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3371 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3371 | } else { | 3372 | } else { |
3372 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3373 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3373 | } | 3374 | } |
3374 | return; | 3375 | return; |
3375 | } | 3376 | } |
3376 | } | 3377 | } |
3377 | 3378 | ||
3378 | QDate date = mNavigator->selectedDates().first(); | 3379 | QDate date = mNavigator->selectedDates().first(); |
3379 | #if 0 | 3380 | #if 0 |
3380 | QDateTime current = QDateTime::currentDateTime(); | 3381 | QDateTime current = QDateTime::currentDateTime(); |
3381 | if ( date <= current.date() ) { | 3382 | if ( date <= current.date() ) { |
3382 | int hour = current.time().hour() +1; | 3383 | int hour = current.time().hour() +1; |
3383 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3384 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3384 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3385 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3385 | } else | 3386 | } else |
3386 | #endif | 3387 | #endif |
3387 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3388 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3388 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3389 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3389 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3390 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3390 | } | 3391 | } |
3391 | 3392 | ||
3392 | void CalendarView::newEvent(QDateTime fh) | 3393 | void CalendarView::newEvent(QDateTime fh) |
3393 | { | 3394 | { |
3394 | newEvent(fh, | 3395 | newEvent(fh, |
3395 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3396 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3396 | } | 3397 | } |
3397 | 3398 | ||
3398 | void CalendarView::newEvent(QDate dt) | 3399 | void CalendarView::newEvent(QDate dt) |
3399 | { | 3400 | { |
3400 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3401 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3401 | QDateTime(dt, QTime(0,0,0)), true); | 3402 | QDateTime(dt, QTime(0,0,0)), true); |
3402 | } | 3403 | } |
3403 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3404 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3404 | { | 3405 | { |
3405 | newEvent(fromHint, toHint, false); | 3406 | newEvent(fromHint, toHint, false); |
3406 | } | 3407 | } |
3407 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3408 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3408 | { | 3409 | { |
3409 | 3410 | ||
3410 | showEventEditor(); | 3411 | showEventEditor(); |
3411 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3412 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3412 | if ( mFilterView->filtersEnabled() ) { | 3413 | if ( mFilterView->filtersEnabled() ) { |
3413 | CalFilter *filter = mFilterView->selectedFilter(); | 3414 | CalFilter *filter = mFilterView->selectedFilter(); |
3414 | if (filter && filter->showCategories()) { | 3415 | if (filter && filter->showCategories()) { |
3415 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3416 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3416 | } | 3417 | } |
3417 | if ( filter ) | 3418 | if ( filter ) |
3418 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3419 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3419 | } | 3420 | } |
3420 | mEventEditor->exec(); | 3421 | mEventEditor->exec(); |
3421 | setActiveWindow(); | 3422 | setActiveWindow(); |
3422 | } | 3423 | } |
3423 | void CalendarView::todoAdded(Todo * t) | 3424 | void CalendarView::todoAdded(Todo * t) |
3424 | { | 3425 | { |
3425 | 3426 | ||
3426 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3427 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3427 | updateTodoViews(); | 3428 | updateTodoViews(); |
3428 | } | 3429 | } |
3429 | void CalendarView::todoChanged(Todo * t) | 3430 | void CalendarView::todoChanged(Todo * t) |
3430 | { | 3431 | { |
3431 | emit todoModified( t, 4 ); | 3432 | emit todoModified( t, 4 ); |
3432 | // updateTodoViews(); | 3433 | // updateTodoViews(); |
3433 | } | 3434 | } |
3434 | void CalendarView::todoToBeDeleted(Todo *) | 3435 | void CalendarView::todoToBeDeleted(Todo *) |
3435 | { | 3436 | { |
3436 | //qDebug("todoToBeDeleted(Todo *) "); | 3437 | //qDebug("todoToBeDeleted(Todo *) "); |
3437 | updateTodoViews(); | 3438 | updateTodoViews(); |
3438 | } | 3439 | } |
3439 | void CalendarView::todoDeleted() | 3440 | void CalendarView::todoDeleted() |
3440 | { | 3441 | { |
3441 | //qDebug(" todoDeleted()"); | 3442 | //qDebug(" todoDeleted()"); |
3442 | updateTodoViews(); | 3443 | updateTodoViews(); |
3443 | } | 3444 | } |
3444 | 3445 | ||
3445 | 3446 | ||
3446 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3447 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3447 | { | 3448 | { |
3448 | showTodoEditor(); | 3449 | showTodoEditor(); |
3449 | mTodoEditor->newTodo(dt,0,allday); | 3450 | mTodoEditor->newTodo(dt,0,allday); |
3450 | if ( mFilterView->filtersEnabled() ) { | 3451 | if ( mFilterView->filtersEnabled() ) { |
3451 | CalFilter *filter = mFilterView->selectedFilter(); | 3452 | CalFilter *filter = mFilterView->selectedFilter(); |
3452 | if (filter && filter->showCategories()) { | 3453 | if (filter && filter->showCategories()) { |
3453 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3454 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3454 | } | 3455 | } |
3455 | if ( filter ) | 3456 | if ( filter ) |
3456 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3457 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3457 | } | 3458 | } |
3458 | mTodoEditor->exec(); | 3459 | mTodoEditor->exec(); |
3459 | setActiveWindow(); | 3460 | setActiveWindow(); |
3460 | } | 3461 | } |
3461 | 3462 | ||
3462 | void CalendarView::newTodo() | 3463 | void CalendarView::newTodo() |
3463 | { | 3464 | { |
3464 | newTodoDateTime( QDateTime(),true ); | 3465 | newTodoDateTime( QDateTime(),true ); |
3465 | } | 3466 | } |
3466 | 3467 | ||
3467 | void CalendarView::newSubTodo() | 3468 | void CalendarView::newSubTodo() |
3468 | { | 3469 | { |
3469 | Todo *todo = selectedTodo(); | 3470 | Todo *todo = selectedTodo(); |
3470 | if ( todo ) newSubTodo( todo ); | 3471 | if ( todo ) newSubTodo( todo ); |
3471 | } | 3472 | } |
3472 | 3473 | ||
3473 | void CalendarView::newSubTodo(Todo *parentEvent) | 3474 | void CalendarView::newSubTodo(Todo *parentEvent) |
3474 | { | 3475 | { |
3475 | 3476 | ||
3476 | showTodoEditor(); | 3477 | showTodoEditor(); |
3477 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3478 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3478 | mTodoEditor->exec(); | 3479 | mTodoEditor->exec(); |
3479 | setActiveWindow(); | 3480 | setActiveWindow(); |
3480 | } | 3481 | } |
3481 | 3482 | ||
3482 | void CalendarView::newFloatingEvent() | 3483 | void CalendarView::newFloatingEvent() |
3483 | { | 3484 | { |
3484 | DateList tmpList = mNavigator->selectedDates(); | 3485 | DateList tmpList = mNavigator->selectedDates(); |
3485 | QDate date = tmpList.first(); | 3486 | QDate date = tmpList.first(); |
3486 | 3487 | ||
3487 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3488 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3488 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3489 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3489 | } | 3490 | } |
3490 | 3491 | ||
3491 | 3492 | ||
3492 | void CalendarView::editEvent( Event *event ) | 3493 | void CalendarView::editEvent( Event *event ) |
3493 | { | 3494 | { |
3494 | 3495 | ||
3495 | if ( !event ) return; | 3496 | if ( !event ) return; |
3496 | if ( event->isReadOnly() ) { | 3497 | if ( event->isReadOnly() ) { |
3497 | showEvent( event ); | 3498 | showEvent( event ); |
3498 | return; | 3499 | return; |
3499 | } | 3500 | } |
3500 | showEventEditor(); | 3501 | showEventEditor(); |
3501 | mEventEditor->editEvent( event , mFlagEditDescription); | 3502 | mEventEditor->editEvent( event , mFlagEditDescription); |
3502 | mEventEditor->exec(); | 3503 | mEventEditor->exec(); |
3503 | setActiveWindow(); | 3504 | setActiveWindow(); |
3504 | 3505 | ||
3505 | } | 3506 | } |
3506 | void CalendarView::editJournal( Journal *jour ) | 3507 | void CalendarView::editJournal( Journal *jour ) |
3507 | { | 3508 | { |
3508 | if ( !jour ) return; | 3509 | if ( !jour ) return; |
3509 | mDialogManager->hideSearchDialog(); | 3510 | mDialogManager->hideSearchDialog(); |
3510 | mViewManager->showJournalView(); | 3511 | mViewManager->showJournalView(); |
3511 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3512 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3512 | } | 3513 | } |
3513 | void CalendarView::editTodo( Todo *todo ) | 3514 | void CalendarView::editTodo( Todo *todo ) |
3514 | { | 3515 | { |
3515 | if ( !todo ) return; | 3516 | if ( !todo ) return; |
3516 | 3517 | ||
3517 | if ( todo->isReadOnly() ) { | 3518 | if ( todo->isReadOnly() ) { |
3518 | showTodo( todo ); | 3519 | showTodo( todo ); |
3519 | return; | 3520 | return; |
3520 | } | 3521 | } |
3521 | showTodoEditor(); | 3522 | showTodoEditor(); |
3522 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3523 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3523 | mTodoEditor->exec(); | 3524 | mTodoEditor->exec(); |
3524 | setActiveWindow(); | 3525 | setActiveWindow(); |
3525 | 3526 | ||
3526 | } | 3527 | } |
3527 | 3528 | ||
3528 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3529 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3529 | { | 3530 | { |
3530 | if ( !mEventViewerDialog ) { | 3531 | if ( !mEventViewerDialog ) { |
3531 | mEventViewerDialog = new KOEventViewerDialog(0); | 3532 | mEventViewerDialog = new KOEventViewerDialog(0); |
3532 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3533 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3533 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3534 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3534 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3535 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3535 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3536 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3536 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3537 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3537 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3538 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3538 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3539 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3539 | this, SLOT( slotViewerClosed() ) ); | 3540 | this, SLOT( slotViewerClosed() ) ); |
3540 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3541 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3541 | this, SLOT( todoChanged(Todo *) ) ); | 3542 | this, SLOT( todoChanged(Todo *) ) ); |
3542 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3543 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3543 | mEventViewerDialog->resize( 640, 480 ); | 3544 | mEventViewerDialog->resize( 640, 480 ); |
3544 | 3545 | ||
3545 | } | 3546 | } |
3546 | return mEventViewerDialog; | 3547 | return mEventViewerDialog; |
3547 | } | 3548 | } |
3548 | void CalendarView::showEvent(Event *event) | 3549 | void CalendarView::showEvent(Event *event) |
3549 | { | 3550 | { |
3550 | getEventViewerDialog()->setEvent(event); | 3551 | getEventViewerDialog()->setEvent(event); |
3551 | getEventViewerDialog()->showMe(); | 3552 | getEventViewerDialog()->showMe(); |
3552 | } | 3553 | } |
3553 | 3554 | ||
3554 | void CalendarView::showTodo(Todo *event) | 3555 | void CalendarView::showTodo(Todo *event) |
3555 | { | 3556 | { |
3556 | getEventViewerDialog()->setTodo(event); | 3557 | getEventViewerDialog()->setTodo(event); |
3557 | getEventViewerDialog()->showMe(); | 3558 | getEventViewerDialog()->showMe(); |
3558 | } | 3559 | } |
3559 | void CalendarView::showJournal( Journal *jour ) | 3560 | void CalendarView::showJournal( Journal *jour ) |
3560 | { | 3561 | { |
3561 | getEventViewerDialog()->setJournal(jour); | 3562 | getEventViewerDialog()->setJournal(jour); |
3562 | getEventViewerDialog()->showMe(); | 3563 | getEventViewerDialog()->showMe(); |
3563 | 3564 | ||
3564 | } | 3565 | } |
3565 | // void CalendarView::todoModified (Todo *event, int changed) | 3566 | // void CalendarView::todoModified (Todo *event, int changed) |
3566 | // { | 3567 | // { |
3567 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3568 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3568 | // // kdDebug() << "Todo modified and open" << endl; | 3569 | // // kdDebug() << "Todo modified and open" << endl; |
3569 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3570 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3570 | // // temp->modified (changed); | 3571 | // // temp->modified (changed); |
3571 | 3572 | ||
3572 | // // } | 3573 | // // } |
3573 | 3574 | ||
3574 | // mViewManager->updateView(); | 3575 | // mViewManager->updateView(); |
3575 | // } | 3576 | // } |
3576 | 3577 | ||
3577 | void CalendarView::appointment_show() | 3578 | void CalendarView::appointment_show() |
3578 | { | 3579 | { |
3579 | Event *anEvent = 0; | 3580 | Event *anEvent = 0; |
3580 | 3581 | ||
3581 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3582 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3582 | 3583 | ||
3583 | if (mViewManager->currentView()->isEventView()) { | 3584 | if (mViewManager->currentView()->isEventView()) { |
3584 | if ( incidence && incidence->typeID() == eventID ) { | 3585 | if ( incidence && incidence->typeID() == eventID ) { |
3585 | anEvent = static_cast<Event *>(incidence); | 3586 | anEvent = static_cast<Event *>(incidence); |
3586 | } | 3587 | } |
3587 | } | 3588 | } |
3588 | 3589 | ||
3589 | if (!anEvent) { | 3590 | if (!anEvent) { |
3590 | KNotifyClient::beep(); | 3591 | KNotifyClient::beep(); |
3591 | return; | 3592 | return; |
3592 | } | 3593 | } |
3593 | 3594 | ||
3594 | showEvent(anEvent); | 3595 | showEvent(anEvent); |
3595 | } | 3596 | } |
3596 | 3597 | ||
3597 | void CalendarView::appointment_edit() | 3598 | void CalendarView::appointment_edit() |
3598 | { | 3599 | { |
3599 | Event *anEvent = 0; | 3600 | Event *anEvent = 0; |
3600 | 3601 | ||
3601 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3602 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3602 | 3603 | ||
3603 | if (mViewManager->currentView()->isEventView()) { | 3604 | if (mViewManager->currentView()->isEventView()) { |
3604 | if ( incidence && incidence->typeID() == eventID ) { | 3605 | if ( incidence && incidence->typeID() == eventID ) { |
3605 | anEvent = static_cast<Event *>(incidence); | 3606 | anEvent = static_cast<Event *>(incidence); |
3606 | } | 3607 | } |
3607 | } | 3608 | } |
3608 | 3609 | ||
3609 | if (!anEvent) { | 3610 | if (!anEvent) { |
3610 | KNotifyClient::beep(); | 3611 | KNotifyClient::beep(); |
3611 | return; | 3612 | return; |
3612 | } | 3613 | } |
3613 | 3614 | ||
3614 | editEvent(anEvent); | 3615 | editEvent(anEvent); |
3615 | } | 3616 | } |
3616 | 3617 | ||
3617 | void CalendarView::appointment_delete() | 3618 | void CalendarView::appointment_delete() |
3618 | { | 3619 | { |
3619 | Event *anEvent = 0; | 3620 | Event *anEvent = 0; |
3620 | 3621 | ||
3621 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3622 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3622 | 3623 | ||
3623 | if (mViewManager->currentView()->isEventView()) { | 3624 | if (mViewManager->currentView()->isEventView()) { |
3624 | if ( incidence && incidence->typeID() == eventID ) { | 3625 | if ( incidence && incidence->typeID() == eventID ) { |
3625 | anEvent = static_cast<Event *>(incidence); | 3626 | anEvent = static_cast<Event *>(incidence); |
3626 | } | 3627 | } |
3627 | } | 3628 | } |
3628 | 3629 | ||
3629 | if (!anEvent) { | 3630 | if (!anEvent) { |
3630 | KNotifyClient::beep(); | 3631 | KNotifyClient::beep(); |
3631 | return; | 3632 | return; |
3632 | } | 3633 | } |
3633 | 3634 | ||
3634 | deleteEvent(anEvent); | 3635 | deleteEvent(anEvent); |
3635 | } | 3636 | } |
3636 | 3637 | ||
3637 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3638 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3638 | { | 3639 | { |
3639 | if (!sub) return; | 3640 | if (!sub) return; |
3640 | if ( sub->relatedTo() == parent ) | 3641 | if ( sub->relatedTo() == parent ) |
3641 | return; | 3642 | return; |
3642 | sub->setRelatedTo(parent); | 3643 | sub->setRelatedTo(parent); |
3643 | sub->updated(); | 3644 | sub->updated(); |
3644 | setModified(true); | 3645 | setModified(true); |
3645 | updateView(); | 3646 | updateView(); |
3646 | } | 3647 | } |
3647 | void CalendarView::todo_unsub(Todo *anTodo ) | 3648 | void CalendarView::todo_unsub(Todo *anTodo ) |
3648 | { | 3649 | { |
3649 | todo_resub( 0, anTodo ); | 3650 | todo_resub( 0, anTodo ); |
3650 | } | 3651 | } |
3651 | 3652 | ||
3652 | void CalendarView::deleteTodo(Todo *todo) | 3653 | void CalendarView::deleteTodo(Todo *todo) |
3653 | { | 3654 | { |
3654 | if (!todo) { | 3655 | if (!todo) { |
3655 | KNotifyClient::beep(); | 3656 | KNotifyClient::beep(); |
3656 | return; | 3657 | return; |
3657 | } | 3658 | } |
3658 | if (KOPrefs::instance()->mConfirm) { | 3659 | if (KOPrefs::instance()->mConfirm) { |
3659 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3660 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3660 | if (!todo->relations().isEmpty()) { | 3661 | if (!todo->relations().isEmpty()) { |
3661 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3662 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3662 | 3663 | ||
3663 | } | 3664 | } |
3664 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3665 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3665 | case KMessageBox::Continue: // OK | 3666 | case KMessageBox::Continue: // OK |
3666 | bool deleteT = false; | 3667 | bool deleteT = false; |
3667 | if (!todo->relations().isEmpty()) { | 3668 | if (!todo->relations().isEmpty()) { |
3668 | deleteT = removeCompletedSubTodos( todo ); | 3669 | deleteT = removeCompletedSubTodos( todo ); |
3669 | } | 3670 | } |
3670 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3671 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3671 | if ( !deleteT ) { | 3672 | if ( !deleteT ) { |
3672 | checkExternalId( todo ); | 3673 | checkExternalId( todo ); |
3673 | calendar()->deleteTodo(todo); | 3674 | calendar()->deleteTodo(todo); |
3674 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3675 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3675 | updateView(); | 3676 | updateView(); |
3676 | } | 3677 | } |
3677 | break; | 3678 | break; |
3678 | } // switch | 3679 | } // switch |
3679 | } else { | 3680 | } else { |
3680 | checkExternalId( todo ); | 3681 | checkExternalId( todo ); |
3681 | mCalendar->deleteTodo(todo); | 3682 | mCalendar->deleteTodo(todo); |
3682 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3683 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3683 | updateView(); | 3684 | updateView(); |
3684 | } | 3685 | } |
3685 | 3686 | ||
3686 | emit updateSearchDialog(); | 3687 | emit updateSearchDialog(); |
3687 | } | 3688 | } |
3688 | void CalendarView::deleteJournal(Journal *jour) | 3689 | void CalendarView::deleteJournal(Journal *jour) |
3689 | { | 3690 | { |
3690 | if (!jour) { | 3691 | if (!jour) { |
3691 | KNotifyClient::beep(); | 3692 | KNotifyClient::beep(); |
3692 | return; | 3693 | return; |
3693 | } | 3694 | } |
3694 | if (KOPrefs::instance()->mConfirm) { | 3695 | if (KOPrefs::instance()->mConfirm) { |
3695 | 3696 | ||
3696 | QString des; | 3697 | QString des; |
3697 | if ( !jour->summary().isEmpty() ) { | 3698 | if ( !jour->summary().isEmpty() ) { |
3698 | des = jour->summary(); | 3699 | des = jour->summary(); |
3699 | } else { | 3700 | } else { |
3700 | des = jour->description().left(30); | 3701 | des = jour->description().left(30); |
3701 | des = des.simplifyWhiteSpace (); | 3702 | des = des.simplifyWhiteSpace (); |
3702 | des.replace (QRegExp ("\\n"),"" ); | 3703 | des.replace (QRegExp ("\\n"),"" ); |
3703 | des.replace (QRegExp ("\\r"),"" ); | 3704 | des.replace (QRegExp ("\\r"),"" ); |
3704 | } | 3705 | } |
3705 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 3706 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3706 | case KMessageBox::Continue: // OK | 3707 | case KMessageBox::Continue: // OK |
3707 | calendar()->deleteJournal(jour); | 3708 | calendar()->deleteJournal(jour); |
3708 | updateView(); | 3709 | updateView(); |
3709 | break; | 3710 | break; |
3710 | } // switch | 3711 | } // switch |
3711 | } else { | 3712 | } else { |
3712 | calendar()->deleteJournal(jour);; | 3713 | calendar()->deleteJournal(jour);; |
3713 | updateView(); | 3714 | updateView(); |
3714 | } | 3715 | } |
3715 | emit updateSearchDialog(); | 3716 | emit updateSearchDialog(); |
3716 | } | 3717 | } |
3717 | 3718 | ||
3718 | void CalendarView::deleteEvent(Event *anEvent) | 3719 | void CalendarView::deleteEvent(Event *anEvent) |
3719 | { | 3720 | { |
3720 | if (!anEvent) { | 3721 | if (!anEvent) { |
3721 | KNotifyClient::beep(); | 3722 | KNotifyClient::beep(); |
3722 | return; | 3723 | return; |
3723 | } | 3724 | } |
3724 | 3725 | ||
3725 | if (anEvent->recurrence()->doesRecur()) { | 3726 | if (anEvent->recurrence()->doesRecur()) { |
3726 | QDate itemDate = mViewManager->currentSelectionDate(); | 3727 | QDate itemDate = mViewManager->currentSelectionDate(); |
3727 | int km; | 3728 | int km; |
3728 | if (!itemDate.isValid()) { | 3729 | if (!itemDate.isValid()) { |
3729 | //kdDebug() << "Date Not Valid" << endl; | 3730 | //kdDebug() << "Date Not Valid" << endl; |
3730 | if (KOPrefs::instance()->mConfirm) { | 3731 | if (KOPrefs::instance()->mConfirm) { |
3731 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3732 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3732 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3733 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3733 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3734 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3734 | if ( km == KMessageBox::Continue ) | 3735 | if ( km == KMessageBox::Continue ) |
3735 | km = KMessageBox::No; // No = all below | 3736 | km = KMessageBox::No; // No = all below |
3736 | } else | 3737 | } else |
3737 | km = KMessageBox::No; | 3738 | km = KMessageBox::No; |
3738 | } else { | 3739 | } else { |
3739 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3740 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3740 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3741 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3741 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3742 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3742 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3743 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3743 | i18n("All")); | 3744 | i18n("All")); |
3744 | } | 3745 | } |
3745 | switch(km) { | 3746 | switch(km) { |
3746 | 3747 | ||
3747 | case KMessageBox::No: // Continue // all | 3748 | case KMessageBox::No: // Continue // all |
3748 | //qDebug("KMessageBox::No "); | 3749 | //qDebug("KMessageBox::No "); |
3749 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3750 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3750 | schedule(Scheduler::Cancel,anEvent); | 3751 | schedule(Scheduler::Cancel,anEvent); |
3751 | 3752 | ||
3752 | checkExternalId( anEvent); | 3753 | checkExternalId( anEvent); |
3753 | mCalendar->deleteEvent(anEvent); | 3754 | mCalendar->deleteEvent(anEvent); |
3754 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3755 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3755 | break; | 3756 | break; |
3756 | 3757 | ||
3757 | // Disabled because it does not work | 3758 | // Disabled because it does not work |
3758 | //#if 0 | 3759 | //#if 0 |
3759 | case KMessageBox::Yes: // just this one | 3760 | case KMessageBox::Yes: // just this one |
3760 | //QDate qd = mNavigator->selectedDates().first(); | 3761 | //QDate qd = mNavigator->selectedDates().first(); |
3761 | //if (!qd.isValid()) { | 3762 | //if (!qd.isValid()) { |
3762 | // kdDebug() << "no date selected, or invalid date" << endl; | 3763 | // kdDebug() << "no date selected, or invalid date" << endl; |
3763 | // KNotifyClient::beep(); | 3764 | // KNotifyClient::beep(); |
3764 | // return; | 3765 | // return; |
3765 | //} | 3766 | //} |
3766 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3767 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3767 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3768 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3768 | anEvent->addExDate(itemDate); | 3769 | anEvent->addExDate(itemDate); |
3769 | int duration = anEvent->recurrence()->duration(); | 3770 | int duration = anEvent->recurrence()->duration(); |
3770 | if ( duration > 0 ) { | 3771 | if ( duration > 0 ) { |
3771 | anEvent->recurrence()->setDuration( duration - 1 ); | 3772 | anEvent->recurrence()->setDuration( duration - 1 ); |
3772 | } | 3773 | } |
3773 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3774 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3774 | } | 3775 | } |
3775 | break; | 3776 | break; |
3776 | //#endif | 3777 | //#endif |
3777 | } // switch | 3778 | } // switch |
3778 | } else { | 3779 | } else { |
3779 | if (KOPrefs::instance()->mConfirm) { | 3780 | if (KOPrefs::instance()->mConfirm) { |
3780 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3781 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3781 | i18n("\nAre you sure you want\nto delete this event?"), | 3782 | i18n("\nAre you sure you want\nto delete this event?"), |
3782 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3783 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3783 | case KMessageBox::Continue: // OK | 3784 | case KMessageBox::Continue: // OK |
3784 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3785 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3785 | schedule(Scheduler::Cancel,anEvent); | 3786 | schedule(Scheduler::Cancel,anEvent); |
3786 | checkExternalId( anEvent); | 3787 | checkExternalId( anEvent); |
3787 | mCalendar->deleteEvent(anEvent); | 3788 | mCalendar->deleteEvent(anEvent); |
3788 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3789 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3789 | break; | 3790 | break; |
3790 | } // switch | 3791 | } // switch |
3791 | } else { | 3792 | } else { |
3792 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3793 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3793 | schedule(Scheduler::Cancel,anEvent); | 3794 | schedule(Scheduler::Cancel,anEvent); |
3794 | checkExternalId( anEvent); | 3795 | checkExternalId( anEvent); |
3795 | mCalendar->deleteEvent(anEvent); | 3796 | mCalendar->deleteEvent(anEvent); |
3796 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3797 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3797 | } | 3798 | } |
3798 | } // if-else | 3799 | } // if-else |
3799 | emit updateSearchDialog(); | 3800 | emit updateSearchDialog(); |
3800 | } | 3801 | } |
3801 | 3802 | ||
3802 | bool CalendarView::deleteEvent(const QString &uid) | 3803 | bool CalendarView::deleteEvent(const QString &uid) |
3803 | { | 3804 | { |
3804 | Event *ev = mCalendar->event(uid); | 3805 | Event *ev = mCalendar->event(uid); |
3805 | if (ev) { | 3806 | if (ev) { |
3806 | deleteEvent(ev); | 3807 | deleteEvent(ev); |
3807 | return true; | 3808 | return true; |
3808 | } else { | 3809 | } else { |
3809 | return false; | 3810 | return false; |
3810 | } | 3811 | } |
3811 | } | 3812 | } |
3812 | 3813 | ||
3813 | /*****************************************************************************/ | 3814 | /*****************************************************************************/ |
3814 | 3815 | ||
3815 | void CalendarView::action_mail() | 3816 | void CalendarView::action_mail() |
3816 | { | 3817 | { |
3817 | #ifndef KORG_NOMAIL | 3818 | #ifndef KORG_NOMAIL |
3818 | KOMailClient mailClient; | 3819 | KOMailClient mailClient; |
3819 | 3820 | ||
3820 | Incidence *incidence = currentSelection(); | 3821 | Incidence *incidence = currentSelection(); |
3821 | 3822 | ||
3822 | if (!incidence) { | 3823 | if (!incidence) { |
3823 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3824 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3824 | return; | 3825 | return; |
3825 | } | 3826 | } |
3826 | if(incidence->attendeeCount() == 0 ) { | 3827 | if(incidence->attendeeCount() == 0 ) { |
3827 | KMessageBox::sorry(this, | 3828 | KMessageBox::sorry(this, |
3828 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3829 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3829 | return; | 3830 | return; |
3830 | } | 3831 | } |
3831 | 3832 | ||
3832 | CalendarLocal cal_tmp; | 3833 | CalendarLocal cal_tmp; |
3833 | Event *event = 0; | 3834 | Event *event = 0; |
3834 | Event *ev = 0; | 3835 | Event *ev = 0; |
3835 | if ( incidence && incidence->typeID() == eventID ) { | 3836 | if ( incidence && incidence->typeID() == eventID ) { |
3836 | event = static_cast<Event *>(incidence); | 3837 | event = static_cast<Event *>(incidence); |
3837 | ev = new Event(*event); | 3838 | ev = new Event(*event); |
3838 | cal_tmp.addEvent(ev); | 3839 | cal_tmp.addEvent(ev); |
3839 | } | 3840 | } |
3840 | ICalFormat mForm(); | 3841 | ICalFormat mForm(); |
3841 | QString attachment = mForm.toString( &cal_tmp ); | 3842 | QString attachment = mForm.toString( &cal_tmp ); |
3842 | if (ev) delete(ev); | 3843 | if (ev) delete(ev); |
3843 | 3844 | ||
3844 | mailClient.mailAttendees(currentSelection(), attachment); | 3845 | mailClient.mailAttendees(currentSelection(), attachment); |
3845 | 3846 | ||
3846 | #endif | 3847 | #endif |
3847 | 3848 | ||
3848 | #if 0 | 3849 | #if 0 |
3849 | Event *anEvent = 0; | 3850 | Event *anEvent = 0; |
3850 | if (mViewManager->currentView()->isEventView()) { | 3851 | if (mViewManager->currentView()->isEventView()) { |
3851 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3852 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3852 | } | 3853 | } |
3853 | 3854 | ||
3854 | if (!anEvent) { | 3855 | if (!anEvent) { |
3855 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3856 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3856 | return; | 3857 | return; |
3857 | } | 3858 | } |
3858 | if(anEvent->attendeeCount() == 0 ) { | 3859 | if(anEvent->attendeeCount() == 0 ) { |
3859 | KMessageBox::sorry(this, | 3860 | KMessageBox::sorry(this, |
3860 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3861 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3861 | return; | 3862 | return; |
3862 | } | 3863 | } |
3863 | 3864 | ||
3864 | mailobject.emailEvent(anEvent); | 3865 | mailobject.emailEvent(anEvent); |
3865 | #endif | 3866 | #endif |
3866 | } | 3867 | } |
3867 | 3868 | ||
3868 | 3869 | ||
3869 | void CalendarView::schedule_publish(Incidence *incidence) | 3870 | void CalendarView::schedule_publish(Incidence *incidence) |
3870 | { | 3871 | { |
3871 | Event *event = 0; | 3872 | Event *event = 0; |
3872 | Todo *todo = 0; | 3873 | Todo *todo = 0; |
3873 | 3874 | ||
3874 | if (incidence == 0) { | 3875 | if (incidence == 0) { |
3875 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3876 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3876 | if (incidence == 0) { | 3877 | if (incidence == 0) { |
3877 | incidence = mTodoList->selectedIncidences().first(); | 3878 | incidence = mTodoList->selectedIncidences().first(); |
3878 | } | 3879 | } |
3879 | } | 3880 | } |
3880 | if ( incidence && incidence->typeID() == eventID ) { | 3881 | if ( incidence && incidence->typeID() == eventID ) { |
3881 | event = static_cast<Event *>(incidence); | 3882 | event = static_cast<Event *>(incidence); |
3882 | } else { | 3883 | } else { |
3883 | if ( incidence && incidence->typeID() == todoID ) { | 3884 | if ( incidence && incidence->typeID() == todoID ) { |
3884 | todo = static_cast<Todo *>(incidence); | 3885 | todo = static_cast<Todo *>(incidence); |
3885 | } | 3886 | } |
3886 | } | 3887 | } |
3887 | 3888 | ||
3888 | if (!event && !todo) { | 3889 | if (!event && !todo) { |
3889 | KMessageBox::sorry(this,i18n("No event selected.")); | 3890 | KMessageBox::sorry(this,i18n("No event selected.")); |
3890 | return; | 3891 | return; |
3891 | } | 3892 | } |
3892 | 3893 | ||
3893 | PublishDialog *publishdlg = new PublishDialog(); | 3894 | PublishDialog *publishdlg = new PublishDialog(); |
3894 | if (incidence->attendeeCount()>0) { | 3895 | if (incidence->attendeeCount()>0) { |
3895 | QPtrList<Attendee> attendees = incidence->attendees(); | 3896 | QPtrList<Attendee> attendees = incidence->attendees(); |
3896 | attendees.first(); | 3897 | attendees.first(); |
3897 | while ( attendees.current()!=0 ) { | 3898 | while ( attendees.current()!=0 ) { |
3898 | publishdlg->addAttendee(attendees.current()); | 3899 | publishdlg->addAttendee(attendees.current()); |
3899 | attendees.next(); | 3900 | attendees.next(); |
3900 | } | 3901 | } |
3901 | } | 3902 | } |
3902 | bool send = true; | 3903 | bool send = true; |
3903 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3904 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3904 | if ( publishdlg->exec() != QDialog::Accepted ) | 3905 | if ( publishdlg->exec() != QDialog::Accepted ) |
3905 | send = false; | 3906 | send = false; |
3906 | } | 3907 | } |
3907 | if ( send ) { | 3908 | if ( send ) { |
3908 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3909 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3909 | if ( event ) { | 3910 | if ( event ) { |
3910 | Event *ev = new Event(*event); | 3911 | Event *ev = new Event(*event); |
3911 | ev->registerObserver(0); | 3912 | ev->registerObserver(0); |
3912 | ev->clearAttendees(); | 3913 | ev->clearAttendees(); |
3913 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3914 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3914 | delete(ev); | 3915 | delete(ev); |
3915 | } | 3916 | } |
3916 | } else { | 3917 | } else { |
3917 | if ( todo ) { | 3918 | if ( todo ) { |
3918 | Todo *ev = new Todo(*todo); | 3919 | Todo *ev = new Todo(*todo); |
3919 | ev->registerObserver(0); | 3920 | ev->registerObserver(0); |
3920 | ev->clearAttendees(); | 3921 | ev->clearAttendees(); |
3921 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3922 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3922 | delete(ev); | 3923 | delete(ev); |
3923 | } | 3924 | } |
3924 | } | 3925 | } |
3925 | } | 3926 | } |
3926 | } | 3927 | } |
3927 | delete publishdlg; | 3928 | delete publishdlg; |
3928 | } | 3929 | } |
3929 | 3930 | ||
3930 | void CalendarView::schedule_request(Incidence *incidence) | 3931 | void CalendarView::schedule_request(Incidence *incidence) |
3931 | { | 3932 | { |
3932 | schedule(Scheduler::Request,incidence); | 3933 | schedule(Scheduler::Request,incidence); |
3933 | } | 3934 | } |
3934 | 3935 | ||
3935 | void CalendarView::schedule_refresh(Incidence *incidence) | 3936 | void CalendarView::schedule_refresh(Incidence *incidence) |
3936 | { | 3937 | { |
3937 | schedule(Scheduler::Refresh,incidence); | 3938 | schedule(Scheduler::Refresh,incidence); |
3938 | } | 3939 | } |
3939 | 3940 | ||
3940 | void CalendarView::schedule_cancel(Incidence *incidence) | 3941 | void CalendarView::schedule_cancel(Incidence *incidence) |
3941 | { | 3942 | { |
3942 | schedule(Scheduler::Cancel,incidence); | 3943 | schedule(Scheduler::Cancel,incidence); |
3943 | } | 3944 | } |
3944 | 3945 | ||
3945 | void CalendarView::schedule_add(Incidence *incidence) | 3946 | void CalendarView::schedule_add(Incidence *incidence) |
3946 | { | 3947 | { |
3947 | schedule(Scheduler::Add,incidence); | 3948 | schedule(Scheduler::Add,incidence); |
3948 | } | 3949 | } |
3949 | 3950 | ||
3950 | void CalendarView::schedule_reply(Incidence *incidence) | 3951 | void CalendarView::schedule_reply(Incidence *incidence) |
3951 | { | 3952 | { |
3952 | schedule(Scheduler::Reply,incidence); | 3953 | schedule(Scheduler::Reply,incidence); |
3953 | } | 3954 | } |
3954 | 3955 | ||
3955 | void CalendarView::schedule_counter(Incidence *incidence) | 3956 | void CalendarView::schedule_counter(Incidence *incidence) |
3956 | { | 3957 | { |
3957 | schedule(Scheduler::Counter,incidence); | 3958 | schedule(Scheduler::Counter,incidence); |
3958 | } | 3959 | } |
3959 | 3960 | ||
3960 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3961 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3961 | { | 3962 | { |
3962 | schedule(Scheduler::Declinecounter,incidence); | 3963 | schedule(Scheduler::Declinecounter,incidence); |
3963 | } | 3964 | } |
3964 | 3965 | ||
3965 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3966 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3966 | { | 3967 | { |
3967 | QDateTime start = QDateTime::currentDateTime(); | 3968 | QDateTime start = QDateTime::currentDateTime(); |
3968 | QDateTime end = start.addDays(daysToPublish); | 3969 | QDateTime end = start.addDays(daysToPublish); |
3969 | 3970 | ||
3970 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3971 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3971 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3972 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3972 | 3973 | ||
3973 | 3974 | ||
3974 | PublishDialog *publishdlg = new PublishDialog(); | 3975 | PublishDialog *publishdlg = new PublishDialog(); |
3975 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3976 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3976 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3977 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3977 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3978 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3978 | delete(freebusy); | 3979 | delete(freebusy); |
3979 | } | 3980 | } |
3980 | } | 3981 | } |
3981 | delete publishdlg; | 3982 | delete publishdlg; |
3982 | } | 3983 | } |
3983 | 3984 | ||
3984 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3985 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3985 | { | 3986 | { |
3986 | Event *event = 0; | 3987 | Event *event = 0; |
3987 | Todo *todo = 0; | 3988 | Todo *todo = 0; |
3988 | 3989 | ||
3989 | if (incidence == 0) { | 3990 | if (incidence == 0) { |
3990 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3991 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3991 | if (incidence == 0) { | 3992 | if (incidence == 0) { |
3992 | incidence = mTodoList->selectedIncidences().first(); | 3993 | incidence = mTodoList->selectedIncidences().first(); |
3993 | } | 3994 | } |
3994 | } | 3995 | } |
3995 | if ( incidence && incidence->typeID() == eventID ) { | 3996 | if ( incidence && incidence->typeID() == eventID ) { |
3996 | event = static_cast<Event *>(incidence); | 3997 | event = static_cast<Event *>(incidence); |
3997 | } | 3998 | } |
3998 | if ( incidence && incidence->typeID() == todoID ) { | 3999 | if ( incidence && incidence->typeID() == todoID ) { |
3999 | todo = static_cast<Todo *>(incidence); | 4000 | todo = static_cast<Todo *>(incidence); |
4000 | } | 4001 | } |
4001 | 4002 | ||
4002 | if (!event && !todo) { | 4003 | if (!event && !todo) { |
4003 | KMessageBox::sorry(this,i18n("No event selected.")); | 4004 | KMessageBox::sorry(this,i18n("No event selected.")); |
4004 | return; | 4005 | return; |
4005 | } | 4006 | } |
4006 | 4007 | ||
4007 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4008 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4008 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4009 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4009 | return; | 4010 | return; |
4010 | } | 4011 | } |
4011 | 4012 | ||
4012 | Event *ev = 0; | 4013 | Event *ev = 0; |
4013 | if (event) ev = new Event(*event); | 4014 | if (event) ev = new Event(*event); |
4014 | Todo *to = 0; | 4015 | Todo *to = 0; |
4015 | if (todo) to = new Todo(*todo); | 4016 | if (todo) to = new Todo(*todo); |
4016 | 4017 | ||
4017 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4018 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4018 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4019 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4019 | if (!me) { | 4020 | if (!me) { |
4020 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4021 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4021 | return; | 4022 | return; |
4022 | } | 4023 | } |
4023 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4024 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4024 | StatusDialog *statdlg = new StatusDialog(this); | 4025 | StatusDialog *statdlg = new StatusDialog(this); |
4025 | if (!statdlg->exec()==QDialog::Accepted) return; | 4026 | if (!statdlg->exec()==QDialog::Accepted) return; |
4026 | me->setStatus( statdlg->status() ); | 4027 | me->setStatus( statdlg->status() ); |
4027 | delete(statdlg); | 4028 | delete(statdlg); |
4028 | } | 4029 | } |
4029 | Attendee *menew = new Attendee(*me); | 4030 | Attendee *menew = new Attendee(*me); |
4030 | if (ev) { | 4031 | if (ev) { |
4031 | ev->clearAttendees(); | 4032 | ev->clearAttendees(); |
4032 | ev->addAttendee(menew,false); | 4033 | ev->addAttendee(menew,false); |
4033 | } else { | 4034 | } else { |
4034 | if (to) { | 4035 | if (to) { |
4035 | todo->clearAttendees(); | 4036 | todo->clearAttendees(); |
4036 | todo->addAttendee(menew,false); | 4037 | todo->addAttendee(menew,false); |
4037 | } | 4038 | } |
4038 | } | 4039 | } |
4039 | } | 4040 | } |
4040 | 4041 | ||
4041 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4042 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4042 | if (ev) { | 4043 | if (ev) { |
4043 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4044 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4044 | } else { | 4045 | } else { |
4045 | if (to) { | 4046 | if (to) { |
4046 | if ( !dlg->addMessage(to,method) ) delete(to); | 4047 | if ( !dlg->addMessage(to,method) ) delete(to); |
4047 | } | 4048 | } |
4048 | } | 4049 | } |
4049 | } | 4050 | } |
4050 | 4051 | ||
4051 | void CalendarView::openAddressbook() | 4052 | void CalendarView::openAddressbook() |
4052 | { | 4053 | { |
4053 | KRun::runCommand("kaddressbook"); | 4054 | KRun::runCommand("kaddressbook"); |
4054 | } | 4055 | } |
4055 | 4056 | ||
4056 | void CalendarView::setModified(bool modified) | 4057 | void CalendarView::setModified(bool modified) |
4057 | { | 4058 | { |
4058 | if ( modified ) | 4059 | if ( modified ) |
4059 | emit signalmodified(); | 4060 | emit signalmodified(); |
4060 | if (mModified != modified) { | 4061 | if (mModified != modified) { |
4061 | mModified = modified; | 4062 | mModified = modified; |
4062 | emit modifiedChanged(mModified); | 4063 | emit modifiedChanged(mModified); |
4063 | } | 4064 | } |
4064 | } | 4065 | } |
4065 | 4066 | ||
4066 | bool CalendarView::isReadOnly() | 4067 | bool CalendarView::isReadOnly() |
4067 | { | 4068 | { |
4068 | return mReadOnly; | 4069 | return mReadOnly; |
4069 | } | 4070 | } |
4070 | 4071 | ||
4071 | void CalendarView::setReadOnly(bool readOnly) | 4072 | void CalendarView::setReadOnly(bool readOnly) |
4072 | { | 4073 | { |
4073 | if (mReadOnly != readOnly) { | 4074 | if (mReadOnly != readOnly) { |
4074 | mReadOnly = readOnly; | 4075 | mReadOnly = readOnly; |
4075 | emit readOnlyChanged(mReadOnly); | 4076 | emit readOnlyChanged(mReadOnly); |
4076 | } | 4077 | } |
4077 | } | 4078 | } |
4078 | 4079 | ||
4079 | bool CalendarView::isModified() | 4080 | bool CalendarView::isModified() |
4080 | { | 4081 | { |
4081 | return mModified; | 4082 | return mModified; |
4082 | } | 4083 | } |
4083 | void CalendarView::slotprintSelInc() | 4084 | void CalendarView::slotprintSelInc() |
4084 | { | 4085 | { |
4085 | if ( currentSelection() == 0 ) { | 4086 | if ( currentSelection() == 0 ) { |
4086 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4087 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4087 | return; | 4088 | return; |
4088 | } | 4089 | } |
4089 | showIncidence(); | 4090 | showIncidence(); |
4090 | getEventViewerDialog()->print(); | 4091 | getEventViewerDialog()->print(); |
4091 | 4092 | ||
4092 | } | 4093 | } |
4093 | void CalendarView::printSetup() | 4094 | void CalendarView::printSetup() |
4094 | { | 4095 | { |
4095 | #ifndef KORG_NOPRINTER | 4096 | #ifndef KORG_NOPRINTER |
4096 | createPrinter(); | 4097 | createPrinter(); |
4097 | 4098 | ||
4098 | mCalPrinter->setupPrinter(); | 4099 | mCalPrinter->setupPrinter(); |
4099 | #endif | 4100 | #endif |
4100 | } | 4101 | } |
4101 | 4102 | ||
4102 | void CalendarView::print() | 4103 | void CalendarView::print() |
4103 | { | 4104 | { |
4104 | #ifndef KORG_NOPRINTER | 4105 | #ifndef KORG_NOPRINTER |
4105 | createPrinter(); | 4106 | createPrinter(); |
4106 | 4107 | ||
4107 | DateList tmpDateList = mNavigator->selectedDates(); | 4108 | DateList tmpDateList = mNavigator->selectedDates(); |
4108 | mCalPrinter->print(CalPrinter::Month, | 4109 | mCalPrinter->print(CalPrinter::Month, |
4109 | tmpDateList.first(), tmpDateList.last()); | 4110 | tmpDateList.first(), tmpDateList.last()); |
4110 | #endif | 4111 | #endif |
4111 | } | 4112 | } |
4112 | 4113 | ||
4113 | void CalendarView::printPreview() | 4114 | void CalendarView::printPreview() |
4114 | { | 4115 | { |
4115 | #ifndef KORG_NOPRINTER | 4116 | #ifndef KORG_NOPRINTER |
4116 | kdDebug() << "CalendarView::printPreview()" << endl; | 4117 | kdDebug() << "CalendarView::printPreview()" << endl; |
4117 | 4118 | ||
4118 | createPrinter(); | 4119 | createPrinter(); |
4119 | 4120 | ||
4120 | DateList tmpDateList = mNavigator->selectedDates(); | 4121 | DateList tmpDateList = mNavigator->selectedDates(); |
4121 | 4122 | ||
4122 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4123 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4123 | tmpDateList.last()); | 4124 | tmpDateList.last()); |
4124 | #endif | 4125 | #endif |
4125 | } | 4126 | } |
4126 | 4127 | ||
4127 | void CalendarView::exportICalendar() | 4128 | void CalendarView::exportICalendar() |
4128 | { | 4129 | { |
4129 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 4130 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
4130 | 4131 | ||
4131 | // Force correct extension | 4132 | // Force correct extension |
4132 | if (filename.right(4) != ".ics") filename += ".ics"; | 4133 | if (filename.right(4) != ".ics") filename += ".ics"; |
4133 | 4134 | ||
4134 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4135 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4135 | storage.save(); | 4136 | storage.save(); |
4136 | } | 4137 | } |
4137 | 4138 | ||
4138 | bool CalendarView::exportVCalendar( QString filename ) | 4139 | bool CalendarView::exportVCalendar( QString filename ) |
4139 | { | 4140 | { |
4140 | if (mCalendar->journals().count() > 0) { | 4141 | if (mCalendar->journals().count() > 0) { |
4141 | int result = KMessageBox::warningContinueCancel(this, | 4142 | int result = KMessageBox::warningContinueCancel(this, |
4142 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4143 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4143 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4144 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4144 | true); | 4145 | true); |
4145 | if (result != KMessageBox::Continue) return false; | 4146 | if (result != KMessageBox::Continue) return false; |
4146 | } | 4147 | } |
4147 | 4148 | ||
4148 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4149 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4149 | 4150 | ||
4150 | // Force correct extension | 4151 | // Force correct extension |
4151 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4152 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4152 | 4153 | ||
4153 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4154 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4154 | return storage.save(); | 4155 | return storage.save(); |
4155 | 4156 | ||
4156 | } | 4157 | } |
4157 | 4158 | ||
4158 | void CalendarView::eventUpdated(Incidence *) | 4159 | void CalendarView::eventUpdated(Incidence *) |
4159 | { | 4160 | { |
4160 | setModified(); | 4161 | setModified(); |
4161 | // Don't call updateView here. The code, which has caused the update of the | 4162 | // Don't call updateView here. The code, which has caused the update of the |
4162 | // event is responsible for updating the view. | 4163 | // event is responsible for updating the view. |
4163 | // updateView(); | 4164 | // updateView(); |
4164 | } | 4165 | } |
4165 | 4166 | ||
4166 | void CalendarView::adaptNavigationUnits() | 4167 | void CalendarView::adaptNavigationUnits() |
4167 | { | 4168 | { |
4168 | if (mViewManager->currentView()->isEventView()) { | 4169 | if (mViewManager->currentView()->isEventView()) { |
4169 | int days = mViewManager->currentView()->currentDateCount(); | 4170 | int days = mViewManager->currentView()->currentDateCount(); |
4170 | if (days == 1) { | 4171 | if (days == 1) { |
4171 | emit changeNavStringPrev(i18n("&Previous Day")); | 4172 | emit changeNavStringPrev(i18n("&Previous Day")); |
4172 | emit changeNavStringNext(i18n("&Next Day")); | 4173 | emit changeNavStringNext(i18n("&Next Day")); |
4173 | } else { | 4174 | } else { |
4174 | emit changeNavStringPrev(i18n("&Previous Week")); | 4175 | emit changeNavStringPrev(i18n("&Previous Week")); |
4175 | emit changeNavStringNext(i18n("&Next Week")); | 4176 | emit changeNavStringNext(i18n("&Next Week")); |
4176 | } | 4177 | } |
4177 | } | 4178 | } |
4178 | } | 4179 | } |
4179 | 4180 | ||
4180 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4181 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4181 | { | 4182 | { |
4182 | if ( incidence ) mTodoList->clearSelection(); | 4183 | if ( incidence ) mTodoList->clearSelection(); |
4183 | processIncidenceSelection( incidence ); | 4184 | processIncidenceSelection( incidence ); |
4184 | } | 4185 | } |
4185 | 4186 | ||
4186 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4187 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4187 | { | 4188 | { |
4188 | if ( incidence && mViewManager->currentView() ) { | 4189 | if ( incidence && mViewManager->currentView() ) { |
4189 | mViewManager->currentView()->clearSelection(); | 4190 | mViewManager->currentView()->clearSelection(); |
4190 | } | 4191 | } |
4191 | processIncidenceSelection( incidence ); | 4192 | processIncidenceSelection( incidence ); |
4192 | } | 4193 | } |
4193 | 4194 | ||
4194 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4195 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4195 | { | 4196 | { |
4196 | emit incidenceSelected( incidence ); | 4197 | emit incidenceSelected( incidence ); |
4197 | if ( incidence == mSelectedIncidence ) return; | 4198 | if ( incidence == mSelectedIncidence ) return; |
4198 | mSelectedIncidence = incidence; | 4199 | mSelectedIncidence = incidence; |
4199 | 4200 | ||
4200 | if ( incidence && incidence->typeID() == eventID ) { | 4201 | if ( incidence && incidence->typeID() == eventID ) { |
4201 | Event *event = static_cast<Event *>( incidence ); | 4202 | Event *event = static_cast<Event *>( incidence ); |
4202 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4203 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4203 | emit organizerEventsSelected( true ); | 4204 | emit organizerEventsSelected( true ); |
4204 | } else { | 4205 | } else { |
4205 | emit organizerEventsSelected(false); | 4206 | emit organizerEventsSelected(false); |
4206 | } | 4207 | } |
4207 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4208 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4208 | KOPrefs::instance()->email() ) ) { | 4209 | KOPrefs::instance()->email() ) ) { |
4209 | emit groupEventsSelected( true ); | 4210 | emit groupEventsSelected( true ); |
4210 | } else { | 4211 | } else { |
4211 | emit groupEventsSelected(false); | 4212 | emit groupEventsSelected(false); |
4212 | } | 4213 | } |
4213 | return; | 4214 | return; |
4214 | } else { | 4215 | } else { |
4215 | if ( incidence && incidence->typeID() == todoID ) { | 4216 | if ( incidence && incidence->typeID() == todoID ) { |
4216 | emit todoSelected( true ); | 4217 | emit todoSelected( true ); |
4217 | Todo *event = static_cast<Todo *>( incidence ); | 4218 | Todo *event = static_cast<Todo *>( incidence ); |
4218 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4219 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4219 | emit organizerEventsSelected( true ); | 4220 | emit organizerEventsSelected( true ); |
4220 | } else { | 4221 | } else { |
4221 | emit organizerEventsSelected(false); | 4222 | emit organizerEventsSelected(false); |
4222 | } | 4223 | } |
4223 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4224 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4224 | KOPrefs::instance()->email() ) ) { | 4225 | KOPrefs::instance()->email() ) ) { |
4225 | emit groupEventsSelected( true ); | 4226 | emit groupEventsSelected( true ); |
4226 | } else { | 4227 | } else { |
4227 | emit groupEventsSelected(false); | 4228 | emit groupEventsSelected(false); |
4228 | } | 4229 | } |
4229 | return; | 4230 | return; |
4230 | } else { | 4231 | } else { |
4231 | emit todoSelected( false ); | 4232 | emit todoSelected( false ); |
4232 | emit organizerEventsSelected(false); | 4233 | emit organizerEventsSelected(false); |
4233 | emit groupEventsSelected(false); | 4234 | emit groupEventsSelected(false); |
4234 | } | 4235 | } |
4235 | return; | 4236 | return; |
4236 | } | 4237 | } |
4237 | 4238 | ||
4238 | /* if ( incidence && incidence->typeID() == todoID ) { | 4239 | /* if ( incidence && incidence->typeID() == todoID ) { |
4239 | emit todoSelected( true ); | 4240 | emit todoSelected( true ); |
4240 | } else { | 4241 | } else { |
4241 | emit todoSelected( false ); | 4242 | emit todoSelected( false ); |
4242 | }*/ | 4243 | }*/ |
4243 | } | 4244 | } |
4244 | 4245 | ||
4245 | 4246 | ||
4246 | void CalendarView::checkClipboard() | 4247 | void CalendarView::checkClipboard() |
4247 | { | 4248 | { |
4248 | #ifndef KORG_NODND | 4249 | #ifndef KORG_NODND |
4249 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4250 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4250 | emit pasteEnabled(true); | 4251 | emit pasteEnabled(true); |
4251 | } else { | 4252 | } else { |
4252 | emit pasteEnabled(false); | 4253 | emit pasteEnabled(false); |
4253 | } | 4254 | } |
4254 | #endif | 4255 | #endif |
4255 | } | 4256 | } |
4256 | 4257 | ||
4257 | void CalendarView::showDates(const DateList &selectedDates) | 4258 | void CalendarView::showDates(const DateList &selectedDates) |
4258 | { | 4259 | { |
4259 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4260 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4260 | 4261 | ||
4261 | 4262 | ||
4262 | if ( !mBlockShowDates ) { | 4263 | if ( !mBlockShowDates ) { |
4263 | if ( mViewManager->currentView() ) { | 4264 | if ( mViewManager->currentView() ) { |
4264 | updateView( selectedDates.first(), selectedDates.last() ); | 4265 | updateView( selectedDates.first(), selectedDates.last() ); |
4265 | } else { | 4266 | } else { |
4266 | mViewManager->showAgendaView(); | 4267 | mViewManager->showAgendaView(); |
4267 | } | 4268 | } |
4268 | } | 4269 | } |
4269 | 4270 | ||
4270 | QDate date = selectedDates.first(); | 4271 | QDate date = selectedDates.first(); |
4271 | if ( ! date.isValid() ) { | 4272 | if ( ! date.isValid() ) { |
4272 | topLevelWidget()->setCaption(""); | 4273 | topLevelWidget()->setCaption(""); |
4273 | return; | 4274 | return; |
4274 | } | 4275 | } |
4275 | 4276 | ||
4276 | QString selDates; | 4277 | QString selDates; |
4277 | selDates = KGlobal::locale()->formatDate( date, true); | 4278 | selDates = KGlobal::locale()->formatDate( date, true); |
4278 | if (selectedDates.first() < selectedDates.last() ) | 4279 | if (selectedDates.first() < selectedDates.last() ) |
4279 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4280 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4280 | else { | 4281 | else { |
4281 | QString addString; | 4282 | QString addString; |
4282 | if ( date == QDateTime::currentDateTime().date() ) | 4283 | if ( date == QDateTime::currentDateTime().date() ) |
4283 | addString = i18n("Today"); | 4284 | addString = i18n("Today"); |
4284 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4285 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4285 | addString = i18n("Tomorrow"); | 4286 | addString = i18n("Tomorrow"); |
4286 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4287 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4287 | addString = i18n("Yesterday"); | 4288 | addString = i18n("Yesterday"); |
4288 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4289 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4289 | addString = i18n("Day before yesterday"); | 4290 | addString = i18n("Day before yesterday"); |
4290 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4291 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4291 | addString = i18n("Day after tomorrow"); | 4292 | addString = i18n("Day after tomorrow"); |
4292 | if ( !addString.isEmpty() ) { | 4293 | if ( !addString.isEmpty() ) { |
4293 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4294 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4294 | return; | 4295 | return; |
4295 | } | 4296 | } |
4296 | } | 4297 | } |
4297 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4298 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4298 | 4299 | ||
4299 | } | 4300 | } |
4300 | 4301 | ||
4301 | QPtrList<CalFilter> CalendarView::filters() | 4302 | QPtrList<CalFilter> CalendarView::filters() |
4302 | { | 4303 | { |
4303 | return mFilters; | 4304 | return mFilters; |
4304 | 4305 | ||
4305 | } | 4306 | } |
4306 | void CalendarView::editFilters() | 4307 | void CalendarView::editFilters() |
4307 | { | 4308 | { |
4308 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4309 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4309 | 4310 | ||
4310 | CalFilter *filter = mFilters.first(); | 4311 | CalFilter *filter = mFilters.first(); |
4311 | while(filter) { | 4312 | while(filter) { |
4312 | filter = mFilters.next(); | 4313 | filter = mFilters.next(); |
4313 | } | 4314 | } |
4314 | 4315 | ||
4315 | mDialogManager->showFilterEditDialog(&mFilters); | 4316 | mDialogManager->showFilterEditDialog(&mFilters); |
4316 | updateFilter(); | 4317 | updateFilter(); |
4317 | } | 4318 | } |
4318 | void CalendarView::toggleFilter() | 4319 | void CalendarView::toggleFilter() |
4319 | { | 4320 | { |
4320 | if ( mLeftFrame->isHidden() ) { | 4321 | if ( mLeftFrame->isHidden() ) { |
4321 | toggleExpand(); | 4322 | toggleExpand(); |
4322 | showFilter( true ); | 4323 | showFilter( true ); |
4323 | } else | 4324 | } else |
4324 | showFilter(! mCalEditView->isVisible()); | 4325 | showFilter(! mCalEditView->isVisible()); |
4325 | } | 4326 | } |
4326 | 4327 | ||
4327 | KOFilterView *CalendarView::filterView() | 4328 | KOFilterView *CalendarView::filterView() |
4328 | { | 4329 | { |
4329 | return mFilterView; | 4330 | return mFilterView; |
4330 | } | 4331 | } |
4331 | void CalendarView::selectFilter( int fil ) | 4332 | void CalendarView::selectFilter( int fil ) |
4332 | { | 4333 | { |
4333 | mFilterView->setSelectedFilter( fil ); | 4334 | mFilterView->setSelectedFilter( fil ); |
4334 | updateUnmanagedViews(); | 4335 | updateUnmanagedViews(); |
4335 | } | 4336 | } |
4336 | void CalendarView::showFilter(bool visible) | 4337 | void CalendarView::showFilter(bool visible) |
4337 | { | 4338 | { |
4338 | #if 1 | 4339 | #if 1 |
4339 | if (visible) { | 4340 | if (visible) { |
4340 | mCalEditView->readConfig(); | 4341 | mCalEditView->readConfig(); |
4341 | mCalEditView->show(); | 4342 | mCalEditView->show(); |
4342 | QValueList<int> sizes; | 4343 | QValueList<int> sizes; |
4343 | sizes = mLeftFrame->sizes(); | 4344 | sizes = mLeftFrame->sizes(); |
4344 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4345 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4345 | sizes.clear(); | 4346 | sizes.clear(); |
4346 | sizes << 100; | 4347 | sizes << 100; |
4347 | sizes << 0; | 4348 | sizes << 0; |
4348 | sizes << 0; | 4349 | sizes << 0; |
4349 | sizes << 100; | 4350 | sizes << 100; |
4350 | mLeftFrame->setSizes(sizes); | 4351 | mLeftFrame->setSizes(sizes); |
4351 | } | 4352 | } |
4352 | #if 0 | 4353 | #if 0 |
4353 | sizes = mLeftFrame->sizes(); | 4354 | sizes = mLeftFrame->sizes(); |
4354 | int ccc = 0; | 4355 | int ccc = 0; |
4355 | while ( ccc < sizes.count()) { | 4356 | while ( ccc < sizes.count()) { |
4356 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4357 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4357 | ++ccc; | 4358 | ++ccc; |
4358 | } | 4359 | } |
4359 | #endif | 4360 | #endif |
4360 | 4361 | ||
4361 | } | 4362 | } |
4362 | else { | 4363 | else { |
4363 | mCalEditView->hide(); | 4364 | mCalEditView->hide(); |
4364 | } | 4365 | } |
4365 | #else | 4366 | #else |
4366 | if (visible) mFilterView->show(); | 4367 | if (visible) mFilterView->show(); |
4367 | else mFilterView->hide(); | 4368 | else mFilterView->hide(); |
4368 | #endif | 4369 | #endif |
4369 | } | 4370 | } |
4370 | void CalendarView::toggleFilerEnabled( ) | 4371 | void CalendarView::toggleFilerEnabled( ) |
4371 | { | 4372 | { |
4372 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4373 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4373 | if ( !mFilterView->filtersEnabled() ) | 4374 | if ( !mFilterView->filtersEnabled() ) |
4374 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4375 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4375 | updateUnmanagedViews(); | 4376 | updateUnmanagedViews(); |
4376 | 4377 | ||
4377 | } | 4378 | } |
4378 | void CalendarView::updateFilter() | 4379 | void CalendarView::updateFilter() |
4379 | { | 4380 | { |
4380 | CalFilter *filter = mFilterView->selectedFilter(); | 4381 | CalFilter *filter = mFilterView->selectedFilter(); |
4381 | if (filter) { | 4382 | if (filter) { |
4382 | QString mess; | 4383 | QString mess; |
4383 | if (mFilterView->filtersEnabled()) { | 4384 | if (mFilterView->filtersEnabled()) { |
4384 | mess = i18n("Filter selected: ")+filter->name(); | 4385 | mess = i18n("Filter selected: ")+filter->name(); |
4385 | filter->setEnabled(true); | 4386 | filter->setEnabled(true); |
4386 | } | 4387 | } |
4387 | else filter->setEnabled(false); | 4388 | else filter->setEnabled(false); |
4388 | mCalendar->setFilter(filter); | 4389 | mCalendar->setFilter(filter); |
4389 | updateView(); | 4390 | updateView(); |
4390 | if ( !mess.isEmpty() ) | 4391 | if ( !mess.isEmpty() ) |
4391 | topLevelWidget()->setCaption( mess ); | 4392 | topLevelWidget()->setCaption( mess ); |
4392 | 4393 | ||
4393 | } | 4394 | } |
4394 | emit filtersUpdated(); | 4395 | emit filtersUpdated(); |
4395 | } | 4396 | } |
4396 | 4397 | ||
4397 | void CalendarView::filterEdited() | 4398 | void CalendarView::filterEdited() |
4398 | { | 4399 | { |
4399 | mFilterView->updateFilters(); | 4400 | mFilterView->updateFilters(); |
4400 | updateFilter(); | 4401 | updateFilter(); |
4401 | writeSettings(); | 4402 | writeSettings(); |
4402 | } | 4403 | } |
4403 | 4404 | ||
4404 | 4405 | ||
4405 | void CalendarView::takeOverEvent() | 4406 | void CalendarView::takeOverEvent() |
4406 | { | 4407 | { |
4407 | Incidence *incidence = currentSelection(); | 4408 | Incidence *incidence = currentSelection(); |
4408 | 4409 | ||
4409 | if (!incidence) return; | 4410 | if (!incidence) return; |
4410 | 4411 | ||
4411 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4412 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4412 | incidence->recreate(); | 4413 | incidence->recreate(); |
4413 | incidence->setReadOnly(false); | 4414 | incidence->setReadOnly(false); |
4414 | 4415 | ||
4415 | updateView(); | 4416 | updateView(); |
4416 | } | 4417 | } |
4417 | 4418 | ||
4418 | void CalendarView::takeOverCalendar() | 4419 | void CalendarView::takeOverCalendar() |
4419 | { | 4420 | { |
4420 | // TODO: Create Calendar::allIncidences() function and use it here | 4421 | // TODO: Create Calendar::allIncidences() function and use it here |
4421 | 4422 | ||
4422 | clearAllViews(); | 4423 | clearAllViews(); |
4423 | QPtrList<Event> events = mCalendar->events(); | 4424 | QPtrList<Event> events = mCalendar->events(); |
4424 | for(uint i=0; i<events.count(); ++i) { | 4425 | for(uint i=0; i<events.count(); ++i) { |
4425 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4426 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4426 | events.at(i)->recreate(); | 4427 | events.at(i)->recreate(); |
4427 | events.at(i)->setReadOnly(false); | 4428 | events.at(i)->setReadOnly(false); |
4428 | } | 4429 | } |
4429 | 4430 | ||
4430 | QPtrList<Todo> todos = mCalendar->todos(); | 4431 | QPtrList<Todo> todos = mCalendar->todos(); |
4431 | for(uint i=0; i<todos.count(); ++i) { | 4432 | for(uint i=0; i<todos.count(); ++i) { |
4432 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4433 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4433 | todos.at(i)->recreate(); | 4434 | todos.at(i)->recreate(); |
4434 | todos.at(i)->setReadOnly(false); | 4435 | todos.at(i)->setReadOnly(false); |
4435 | } | 4436 | } |
4436 | 4437 | ||
4437 | QPtrList<Journal> journals = mCalendar->journals(); | 4438 | QPtrList<Journal> journals = mCalendar->journals(); |
4438 | for(uint i=0; i<journals.count(); ++i) { | 4439 | for(uint i=0; i<journals.count(); ++i) { |
4439 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4440 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4440 | journals.at(i)->recreate(); | 4441 | journals.at(i)->recreate(); |
4441 | journals.at(i)->setReadOnly(false); | 4442 | journals.at(i)->setReadOnly(false); |
4442 | } | 4443 | } |
4443 | 4444 | ||
4444 | updateView(); | 4445 | updateView(); |
4445 | } | 4446 | } |
4446 | 4447 | ||
4447 | void CalendarView::showIntro() | 4448 | void CalendarView::showIntro() |
4448 | { | 4449 | { |
4449 | kdDebug() << "To be implemented." << endl; | 4450 | kdDebug() << "To be implemented." << endl; |
4450 | } | 4451 | } |
4451 | 4452 | ||
4452 | QWidgetStack *CalendarView::viewStack() | 4453 | QWidgetStack *CalendarView::viewStack() |
4453 | { | 4454 | { |
4454 | return mRightFrame; | 4455 | return mRightFrame; |
4455 | } | 4456 | } |
4456 | 4457 | ||
4457 | QWidget *CalendarView::leftFrame() | 4458 | QWidget *CalendarView::leftFrame() |
4458 | { | 4459 | { |
4459 | return ( QWidget *)mLeftFrame; | 4460 | return ( QWidget *)mLeftFrame; |
4460 | } | 4461 | } |
4461 | 4462 | ||
4462 | DateNavigator *CalendarView::dateNavigator() | 4463 | DateNavigator *CalendarView::dateNavigator() |
4463 | { | 4464 | { |
4464 | return mNavigator; | 4465 | return mNavigator; |
4465 | } | 4466 | } |
4466 | 4467 | ||
4467 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4468 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4468 | { | 4469 | { |
4469 | return mDateNavigator->navigatorView(); | 4470 | return mDateNavigator->navigatorView(); |
4470 | } | 4471 | } |
4471 | void CalendarView::toggleDateNavigatorWidget() | 4472 | void CalendarView::toggleDateNavigatorWidget() |
4472 | { | 4473 | { |
4473 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4474 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4474 | 4475 | ||
4475 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4476 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4476 | mDateNavigator->hide(); | 4477 | mDateNavigator->hide(); |
4477 | else | 4478 | else |
4478 | mDateNavigator->show(); | 4479 | mDateNavigator->show(); |
4479 | } | 4480 | } |
4480 | void CalendarView::addView(KOrg::BaseView *view) | 4481 | void CalendarView::addView(KOrg::BaseView *view) |
4481 | { | 4482 | { |
4482 | mViewManager->addView(view); | 4483 | mViewManager->addView(view); |
4483 | } | 4484 | } |
4484 | 4485 | ||
4485 | void CalendarView::showView(KOrg::BaseView *view) | 4486 | void CalendarView::showView(KOrg::BaseView *view) |
4486 | { | 4487 | { |
4487 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4488 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4488 | } | 4489 | } |
4489 | 4490 | ||
4490 | Incidence *CalendarView::currentSelection() | 4491 | Incidence *CalendarView::currentSelection() |
4491 | { | 4492 | { |
4492 | return mViewManager->currentSelection(); | 4493 | return mViewManager->currentSelection(); |
4493 | } | 4494 | } |
4494 | void CalendarView::toggleAllDaySize() | 4495 | void CalendarView::toggleAllDaySize() |
4495 | { | 4496 | { |
4496 | /* | 4497 | /* |
4497 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4498 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4498 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4499 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4499 | else | 4500 | else |
4500 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4501 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4501 | */ | 4502 | */ |
4502 | viewManager()->agendaView()->toggleAllDay(); | 4503 | viewManager()->agendaView()->toggleAllDay(); |
4503 | } | 4504 | } |
4504 | void CalendarView::toggleExpand() | 4505 | void CalendarView::toggleExpand() |
4505 | { | 4506 | { |
4506 | // if ( mLeftFrame->isHidden() ) { | 4507 | // if ( mLeftFrame->isHidden() ) { |
4507 | // mLeftFrame->show(); | 4508 | // mLeftFrame->show(); |
4508 | // emit calendarViewExpanded( false ); | 4509 | // emit calendarViewExpanded( false ); |
4509 | // } else { | 4510 | // } else { |
4510 | // mLeftFrame->hide(); | 4511 | // mLeftFrame->hide(); |
4511 | // emit calendarViewExpanded( true ); | 4512 | // emit calendarViewExpanded( true ); |
4512 | // } | 4513 | // } |
4513 | //qDebug(" CalendarView::toggleExpand()"); | 4514 | //qDebug(" CalendarView::toggleExpand()"); |
4514 | globalFlagBlockAgenda = 1; | 4515 | globalFlagBlockAgenda = 1; |
4515 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4516 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4516 | globalFlagBlockAgenda = 5; | 4517 | globalFlagBlockAgenda = 5; |
4517 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4518 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4518 | //mViewManager->showView( 0, true ); | 4519 | //mViewManager->showView( 0, true ); |
4519 | } | 4520 | } |
4520 | 4521 | ||
4521 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4522 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4522 | { | 4523 | { |
4523 | setModified( modified ); | 4524 | setModified( modified ); |
4524 | } | 4525 | } |
4525 | 4526 | ||
4526 | Todo *CalendarView::selectedTodo() | 4527 | Todo *CalendarView::selectedTodo() |
4527 | { | 4528 | { |
4528 | Incidence *incidence = currentSelection(); | 4529 | Incidence *incidence = currentSelection(); |
4529 | if ( incidence && incidence->typeID() == todoID ) { | 4530 | if ( incidence && incidence->typeID() == todoID ) { |
4530 | return static_cast<Todo *>( incidence ); | 4531 | return static_cast<Todo *>( incidence ); |
4531 | } | 4532 | } |
4532 | 4533 | ||
4533 | incidence = mTodoList->selectedIncidences().first(); | 4534 | incidence = mTodoList->selectedIncidences().first(); |
4534 | if ( incidence && incidence->typeID() == todoID ) { | 4535 | if ( incidence && incidence->typeID() == todoID ) { |
4535 | return static_cast<Todo *>( incidence ); | 4536 | return static_cast<Todo *>( incidence ); |
4536 | } | 4537 | } |
4537 | 4538 | ||
4538 | return 0; | 4539 | return 0; |
4539 | } | 4540 | } |
4540 | 4541 | ||
4541 | void CalendarView::showIncidence() | 4542 | void CalendarView::showIncidence() |
4542 | { | 4543 | { |
4543 | mViewerCallerIsSearchDialog = false; | 4544 | mViewerCallerIsSearchDialog = false; |
4544 | Incidence *incidence = currentSelection(); | 4545 | Incidence *incidence = currentSelection(); |
4545 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4546 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4546 | if ( incidence ) { | 4547 | if ( incidence ) { |
4547 | ShowIncidenceVisitor v; | 4548 | ShowIncidenceVisitor v; |
4548 | v.act( incidence, this ); | 4549 | v.act( incidence, this ); |
4549 | } | 4550 | } |
4550 | } | 4551 | } |
4551 | void CalendarView::editIncidenceDescription() | 4552 | void CalendarView::editIncidenceDescription() |
4552 | { | 4553 | { |
4553 | mFlagEditDescription = true; | 4554 | mFlagEditDescription = true; |
4554 | editIncidence(); | 4555 | editIncidence(); |
4555 | mFlagEditDescription = false; | 4556 | mFlagEditDescription = false; |
4556 | } | 4557 | } |
4557 | void CalendarView::editIncidence() | 4558 | void CalendarView::editIncidence() |
4558 | { | 4559 | { |
4559 | // qDebug("editIncidence() "); | 4560 | // qDebug("editIncidence() "); |
4560 | Incidence *incidence = currentSelection(); | 4561 | Incidence *incidence = currentSelection(); |
4561 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4562 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4562 | if ( incidence ) { | 4563 | if ( incidence ) { |
4563 | EditIncidenceVisitor v; | 4564 | EditIncidenceVisitor v; |
4564 | v.act( incidence, this ); | 4565 | v.act( incidence, this ); |
4565 | } | 4566 | } |
4566 | } | 4567 | } |
4567 | 4568 | ||
4568 | void CalendarView::deleteIncidence() | 4569 | void CalendarView::deleteIncidence() |
4569 | { | 4570 | { |
4570 | Incidence *incidence = currentSelection(); | 4571 | Incidence *incidence = currentSelection(); |
4571 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4572 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4572 | if ( incidence ) { | 4573 | if ( incidence ) { |
4573 | deleteIncidence(incidence); | 4574 | deleteIncidence(incidence); |
4574 | } | 4575 | } |
4575 | } | 4576 | } |
4576 | void CalendarView::showIncidence(QString uid) | 4577 | void CalendarView::showIncidence(QString uid) |
4577 | { | 4578 | { |
4578 | Incidence *inc = mCalendar->incidence( uid ); | 4579 | Incidence *inc = mCalendar->incidence( uid ); |
4579 | if ( inc ) | 4580 | if ( inc ) |
4580 | showIncidence( inc ); | 4581 | showIncidence( inc ); |
4581 | } | 4582 | } |
4582 | void CalendarView::showIncidence(Incidence *incidence) | 4583 | void CalendarView::showIncidence(Incidence *incidence) |
4583 | { | 4584 | { |
4584 | mViewerCallerIsSearchDialog = false; | 4585 | mViewerCallerIsSearchDialog = false; |
4585 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4586 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4586 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4587 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4587 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4588 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4588 | mViewerCallerIsSearchDialog = true; | 4589 | mViewerCallerIsSearchDialog = true; |
4589 | } | 4590 | } |
4590 | } | 4591 | } |
4591 | if ( incidence ) { | 4592 | if ( incidence ) { |
4592 | ShowIncidenceVisitor v; | 4593 | ShowIncidenceVisitor v; |
4593 | v.act( incidence, this ); | 4594 | v.act( incidence, this ); |
4594 | } | 4595 | } |
4595 | } | 4596 | } |
4596 | 4597 | ||
4597 | void CalendarView::editIncidence(Incidence *incidence) | 4598 | void CalendarView::editIncidence(Incidence *incidence) |
4598 | { | 4599 | { |
4599 | if ( incidence ) { | 4600 | if ( incidence ) { |
4600 | 4601 | ||
4601 | EditIncidenceVisitor v; | 4602 | EditIncidenceVisitor v; |
4602 | v.act( incidence, this ); | 4603 | v.act( incidence, this ); |
4603 | 4604 | ||
4604 | } | 4605 | } |
4605 | } | 4606 | } |
4606 | 4607 | ||
4607 | void CalendarView::deleteIncidence(Incidence *incidence) | 4608 | void CalendarView::deleteIncidence(Incidence *incidence) |
4608 | { | 4609 | { |
4609 | //qDebug(" CalendarView::deleteIncidence "); | 4610 | //qDebug(" CalendarView::deleteIncidence "); |
4610 | if ( incidence == 0 ) { | 4611 | if ( incidence == 0 ) { |
4611 | updateView(); | 4612 | updateView(); |
4612 | emit updateSearchDialog(); | 4613 | emit updateSearchDialog(); |
4613 | return; | 4614 | return; |
4614 | } | 4615 | } |
4615 | if ( incidence ) { | 4616 | if ( incidence ) { |
4616 | DeleteIncidenceVisitor v; | 4617 | DeleteIncidenceVisitor v; |
4617 | v.act( incidence, this ); | 4618 | v.act( incidence, this ); |
4618 | } | 4619 | } |
4619 | } | 4620 | } |
4620 | 4621 | ||
4621 | 4622 | ||
4622 | void CalendarView::lookForOutgoingMessages() | 4623 | void CalendarView::lookForOutgoingMessages() |
4623 | { | 4624 | { |
4624 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4625 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4625 | ogd->loadMessages(); | 4626 | ogd->loadMessages(); |
4626 | } | 4627 | } |
4627 | 4628 | ||
4628 | void CalendarView::lookForIncomingMessages() | 4629 | void CalendarView::lookForIncomingMessages() |
4629 | { | 4630 | { |
4630 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4631 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4631 | icd->retrieve(); | 4632 | icd->retrieve(); |
4632 | } | 4633 | } |
4633 | 4634 | ||
4634 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4635 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4635 | { | 4636 | { |
4636 | bool deleteTodo = true; | 4637 | bool deleteTodo = true; |
4637 | QPtrList<Incidence> subTodos; | 4638 | QPtrList<Incidence> subTodos; |
4638 | Incidence *aTodo; | 4639 | Incidence *aTodo; |
4639 | subTodos = t->relations(); | 4640 | subTodos = t->relations(); |
4640 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4641 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4641 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4642 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4642 | deleteTodo = false; | 4643 | deleteTodo = false; |
4643 | } | 4644 | } |
4644 | if ( deleteTodo ) { | 4645 | if ( deleteTodo ) { |
4645 | if ( t->isCompleted() && !t->doesRecur()) { | 4646 | if ( t->isCompleted() && !t->doesRecur()) { |
4646 | checkExternalId( t ); | 4647 | checkExternalId( t ); |
4647 | mCalendar->deleteTodo( t ); | 4648 | mCalendar->deleteTodo( t ); |
4648 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4649 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4649 | } | 4650 | } |
4650 | else | 4651 | else |
4651 | deleteTodo = false; | 4652 | deleteTodo = false; |
4652 | } | 4653 | } |
4653 | return deleteTodo; | 4654 | return deleteTodo; |
4654 | 4655 | ||
4655 | } | 4656 | } |
4656 | void CalendarView::purgeCompleted() | 4657 | void CalendarView::purgeCompleted() |
4657 | { | 4658 | { |
4658 | int result = KMessageBox::warningContinueCancel(this, | 4659 | int result = KMessageBox::warningContinueCancel(this, |
4659 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4660 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4660 | 4661 | ||
4661 | if (result == KMessageBox::Continue) { | 4662 | if (result == KMessageBox::Continue) { |
4662 | 4663 | ||
4663 | QPtrList<Todo> todoCal; | 4664 | QPtrList<Todo> todoCal; |
4664 | QPtrList<Todo> rootTodos; | 4665 | QPtrList<Todo> rootTodos; |
4665 | //QPtrList<Incidence> rel; | 4666 | //QPtrList<Incidence> rel; |
4666 | Todo *aTodo; | 4667 | Todo *aTodo; |
4667 | todoCal = calendar()->todos(); | 4668 | todoCal = calendar()->todos(); |
4668 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4669 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4669 | if ( !aTodo->relatedTo() ) | 4670 | if ( !aTodo->relatedTo() ) |
4670 | rootTodos.append( aTodo ); | 4671 | rootTodos.append( aTodo ); |
4671 | } | 4672 | } |
4672 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4673 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4673 | removeCompletedSubTodos( aTodo ); | 4674 | removeCompletedSubTodos( aTodo ); |
4674 | } | 4675 | } |
4675 | 4676 | ||
4676 | updateView(); | 4677 | updateView(); |
4677 | } | 4678 | } |
4678 | } | 4679 | } |
4679 | 4680 | ||
4680 | void CalendarView::slotCalendarChanged() | 4681 | void CalendarView::slotCalendarChanged() |
4681 | { | 4682 | { |
4682 | ; | 4683 | ; |
4683 | } | 4684 | } |
4684 | 4685 | ||
4685 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4686 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4686 | { | 4687 | { |
4687 | //qDebug(" alendarView::keyPressEvent "); | 4688 | //qDebug(" alendarView::keyPressEvent "); |
4688 | e->ignore(); | 4689 | e->ignore(); |
4689 | } | 4690 | } |
4690 | 4691 | ||
4691 | 4692 | ||
4692 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4693 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4693 | { | 4694 | { |
4694 | 4695 | ||
4695 | if ( manager != mSyncManager) | 4696 | if ( manager != mSyncManager) |
4696 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 4697 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
4697 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4698 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4698 | qDebug("KO: SyncKDE request detected!"); | 4699 | qDebug("KO: SyncKDE request detected!"); |
4699 | } | 4700 | } |
4700 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4701 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4701 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4702 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4702 | return syncCalendar( filename, mode ); | 4703 | return syncCalendar( filename, mode ); |
4703 | } | 4704 | } |
4704 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4705 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4705 | { | 4706 | { |
4706 | //mSyncManager = manager; | 4707 | //mSyncManager = manager; |
4707 | if ( manager != mSyncManager) | 4708 | if ( manager != mSyncManager) |
4708 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 4709 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
4709 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4710 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4710 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4711 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4711 | if ( resource == "sharp" ) | 4712 | if ( resource == "sharp" ) |
4712 | syncExternal( 0 ); | 4713 | syncExternal( 0 ); |
4713 | if ( resource == "phone" ) | 4714 | if ( resource == "phone" ) |
4714 | syncExternal( 1 ); | 4715 | syncExternal( 1 ); |
4715 | // pending setmodified | 4716 | // pending setmodified |
4716 | return true; | 4717 | return true; |
4717 | } | 4718 | } |
4718 | void CalendarView::setSyncManager(KSyncManager* manager) | 4719 | void CalendarView::setSyncManager(KSyncManager* manager) |
4719 | { | 4720 | { |
4720 | mSyncManager = manager; | 4721 | mSyncManager = manager; |
4721 | } | 4722 | } |
4722 | 4723 | ||
4723 | void CalendarView::removeSyncInfo( QString syncProfile) | 4724 | void CalendarView::removeSyncInfo( QString syncProfile) |
4724 | { | 4725 | { |
4725 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4726 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4726 | mCalendar->removeSyncInfo( syncProfile ); | 4727 | mCalendar->removeSyncInfo( syncProfile ); |
4727 | 4728 | ||
4728 | } | 4729 | } |
4729 | 4730 | ||
4730 | void CalendarView::undo_delete() | 4731 | void CalendarView::undo_delete() |
4731 | { | 4732 | { |
4732 | //qDebug("undo_delete() "); | 4733 | //qDebug("undo_delete() "); |
4733 | Incidence* undo = mCalendar->undoIncidence(); | 4734 | Incidence* undo = mCalendar->undoIncidence(); |
4734 | if ( !undo ) { | 4735 | if ( !undo ) { |
4735 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4736 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4736 | i18n("KO/Pi")); | 4737 | i18n("KO/Pi")); |
4737 | return; | 4738 | return; |
4738 | } | 4739 | } |
4739 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 4740 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
4740 | i18n("\nAre you sure you want\nto restore this?"), | 4741 | i18n("\nAre you sure you want\nto restore this?"), |
4741 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4742 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4742 | mCalendar->undoDeleteIncidence(); | 4743 | mCalendar->undoDeleteIncidence(); |
4743 | updateView(); | 4744 | updateView(); |
4744 | } | 4745 | } |
4745 | } | 4746 | } |
4746 | 4747 | ||
4747 | void CalendarView::slotViewerClosed() | 4748 | void CalendarView::slotViewerClosed() |
4748 | { | 4749 | { |
4749 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4750 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4750 | } | 4751 | } |
4751 | 4752 | ||
4752 | void CalendarView::resetFocus() | 4753 | void CalendarView::resetFocus() |
4753 | { | 4754 | { |
4754 | if ( mViewerCallerIsSearchDialog ) { | 4755 | if ( mViewerCallerIsSearchDialog ) { |
4755 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4756 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4756 | mDialogManager->getSearchDialog()->raise(); | 4757 | mDialogManager->getSearchDialog()->raise(); |
4757 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4758 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4758 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4759 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4759 | } else | 4760 | } else |
4760 | mViewerCallerIsSearchDialog = false; | 4761 | mViewerCallerIsSearchDialog = false; |
4761 | } | 4762 | } |
4762 | if ( !mViewerCallerIsSearchDialog ) { | 4763 | if ( !mViewerCallerIsSearchDialog ) { |
4763 | //mViewManager->currentView()->setFocus(); | 4764 | //mViewManager->currentView()->setFocus(); |
4764 | //qDebug("sssssssssssssssset focus "); | 4765 | //qDebug("sssssssssssssssset focus "); |
4765 | topLevelWidget()->raise(); | 4766 | topLevelWidget()->raise(); |
4766 | setActiveWindow(); | 4767 | setActiveWindow(); |
4767 | //setFocus(); | 4768 | //setFocus(); |
4768 | } | 4769 | } |
4769 | mViewerCallerIsSearchDialog = false; | 4770 | mViewerCallerIsSearchDialog = false; |
4770 | } | 4771 | } |
4771 | 4772 | ||
4772 | void CalendarView::showNextAlarms() | 4773 | void CalendarView::showNextAlarms() |
4773 | { | 4774 | { |
4774 | QString message; | 4775 | QString message; |
4775 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4776 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4776 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4777 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4777 | QString sum = mCalendar->nextSummary(); | 4778 | QString sum = mCalendar->nextSummary(); |
4778 | QDateTime nextA = mNextAlarmDateTime; | 4779 | QDateTime nextA = mNextAlarmDateTime; |
4779 | QDateTime cur = QDateTime::currentDateTime(); | 4780 | QDateTime cur = QDateTime::currentDateTime(); |
4780 | int secs = cur.secsTo( nextA ); | 4781 | int secs = cur.secsTo( nextA ); |
4781 | int min = secs /60; | 4782 | int min = secs /60; |
4782 | int hours = min /60; | 4783 | int hours = min /60; |
4783 | min = min % 60; | 4784 | min = min % 60; |
4784 | int days = hours /24; | 4785 | int days = hours /24; |
4785 | hours = hours % 24; | 4786 | hours = hours % 24; |
4786 | 4787 | ||
4787 | //message = i18n("The next alarm is in:\n"); | 4788 | //message = i18n("The next alarm is in:\n"); |
4788 | if ( days > 1 ) | 4789 | if ( days > 1 ) |
4789 | message += i18n("%1 days\n").arg( days ); | 4790 | message += i18n("%1 days\n").arg( days ); |
4790 | else if ( days == 1 ) | 4791 | else if ( days == 1 ) |
4791 | message += i18n("1 day\n"); | 4792 | message += i18n("1 day\n"); |
4792 | if ( hours > 1 ) | 4793 | if ( hours > 1 ) |
4793 | message += i18n("%1 hours\n").arg( hours ); | 4794 | message += i18n("%1 hours\n").arg( hours ); |
4794 | else if ( hours == 1 ) | 4795 | else if ( hours == 1 ) |
4795 | message += i18n("1 hour\n"); | 4796 | message += i18n("1 hour\n"); |
4796 | if ( min > 1 ) | 4797 | if ( min > 1 ) |
4797 | message += i18n("%1 minutes\n").arg( min ); | 4798 | message += i18n("%1 minutes\n").arg( min ); |
4798 | else if ( min == 1 ) | 4799 | else if ( min == 1 ) |
4799 | message += i18n("1 minute\n"); | 4800 | message += i18n("1 minute\n"); |
4800 | if ( message.isEmpty() ) | 4801 | if ( message.isEmpty() ) |
4801 | message = i18n("The next alarm is in\nless than one minute!"); | 4802 | message = i18n("The next alarm is in\nless than one minute!"); |
4802 | else | 4803 | else |
4803 | message = i18n("The next alarm is in:\n") + message; | 4804 | message = i18n("The next alarm is in:\n") + message; |
4804 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4805 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4805 | } else { | 4806 | } else { |
4806 | message = i18n("There is no next alarm."); | 4807 | message = i18n("There is no next alarm."); |
4807 | 4808 | ||
4808 | } | 4809 | } |
4809 | #ifdef DESKTOP_VERSION | 4810 | #ifdef DESKTOP_VERSION |
4810 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4811 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4811 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4812 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4812 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4813 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4813 | } | 4814 | } |
4814 | 4815 | ||
4815 | #endif | 4816 | #endif |
4816 | KMessageBox::information( this, message); | 4817 | KMessageBox::information( this, message); |
4817 | } | 4818 | } |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 14a1a45..95477cd 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,378 +1,379 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library 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 GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef CALENDAR_H | 22 | #ifndef CALENDAR_H |
23 | #define CALENDAR_H | 23 | #define CALENDAR_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qptrlist.h> | 28 | #include <qptrlist.h> |
29 | #include <qdict.h> | 29 | #include <qdict.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "event.h" | 32 | #include "event.h" |
33 | #include "todo.h" | 33 | #include "todo.h" |
34 | #include "journal.h" | 34 | #include "journal.h" |
35 | #include "calfilter.h" | 35 | #include "calfilter.h" |
36 | 36 | ||
37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ | 37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ |
38 | 38 | ||
39 | class KConfig; | 39 | class KConfig; |
40 | 40 | ||
41 | namespace KCal { | 41 | namespace KCal { |
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | This is the main "calendar" object class for KOrganizer. It holds | 45 | This is the main "calendar" object class for KOrganizer. It holds |
46 | information like all appointments/events, user information, etc. etc. | 46 | information like all appointments/events, user information, etc. etc. |
47 | one calendar is associated with each CalendarView (@see calendarview.h). | 47 | one calendar is associated with each CalendarView (@see calendarview.h). |
48 | This is an abstract base class defining the interface to a calendar. It is | 48 | This is an abstract base class defining the interface to a calendar. It is |
49 | implemented by subclasses like @see CalendarLocal, which use different | 49 | implemented by subclasses like @see CalendarLocal, which use different |
50 | methods to store and access the data. | 50 | methods to store and access the data. |
51 | 51 | ||
52 | Ownership of events etc. is handled by the following policy: As soon as an | 52 | Ownership of events etc. is handled by the following policy: As soon as an |
53 | event (or any other subclass of IncidenceBase) object is added to the | 53 | event (or any other subclass of IncidenceBase) object is added to the |
54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes | 54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes |
55 | care of deleting it. All Events returned by the query functions are returned | 55 | care of deleting it. All Events returned by the query functions are returned |
56 | as pointers, that means all changes to the returned events are immediately | 56 | as pointers, that means all changes to the returned events are immediately |
57 | visible in the Calendar. You shouldn't delete any Event object you get from | 57 | visible in the Calendar. You shouldn't delete any Event object you get from |
58 | Calendar. | 58 | Calendar. |
59 | */ | 59 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | Calendar(); | 65 | Calendar(); |
66 | Calendar(const QString &timeZoneId); | 66 | Calendar(const QString &timeZoneId); |
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | Incidence * undoIncidence() { return mUndoIncidence; }; | 68 | Incidence * undoIncidence() { return mUndoIncidence; }; |
69 | bool undoDeleteIncidence(); | 69 | bool undoDeleteIncidence(); |
70 | void deleteIncidence(Incidence *in); | 70 | void deleteIncidence(Incidence *in); |
71 | void resetTempSyncStat(); | 71 | void resetTempSyncStat(); |
72 | void resetPilotStat(int id); | 72 | void resetPilotStat(int id); |
73 | /** | 73 | /** |
74 | Clears out the current calendar, freeing all used memory etc. | 74 | Clears out the current calendar, freeing all used memory etc. |
75 | */ | 75 | */ |
76 | virtual void close() = 0; | 76 | virtual void close() = 0; |
77 | virtual void addCalendar( Calendar* ) = 0; | 77 | virtual void addCalendar( Calendar* ) = 0; |
78 | virtual bool addCalendarFile( QString name, int id ) = 0; | 78 | virtual bool addCalendarFile( QString name, int id ) = 0; |
79 | virtual bool mergeCalendarFile( QString name ) = 0; | 79 | virtual bool mergeCalendarFile( QString name ) = 0; |
80 | virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0; | ||
80 | virtual void setSyncEventsReadOnly() = 0; | 81 | virtual void setSyncEventsReadOnly() = 0; |
81 | virtual void stopAllTodos() = 0; | 82 | virtual void stopAllTodos() = 0; |
82 | 83 | ||
83 | /** | 84 | /** |
84 | Sync changes in memory to persistant storage. | 85 | Sync changes in memory to persistant storage. |
85 | */ | 86 | */ |
86 | virtual void save() = 0; | 87 | virtual void save() = 0; |
87 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 88 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
88 | virtual void removeSyncInfo( QString syncProfile) = 0; | 89 | virtual void removeSyncInfo( QString syncProfile) = 0; |
89 | virtual bool isSaving() { return false; } | 90 | virtual bool isSaving() { return false; } |
90 | 91 | ||
91 | /** | 92 | /** |
92 | Return the owner of the calendar's full name. | 93 | Return the owner of the calendar's full name. |
93 | */ | 94 | */ |
94 | const QString &getOwner() const; | 95 | const QString &getOwner() const; |
95 | /** | 96 | /** |
96 | Set the owner of the calendar. Should be owner's full name. | 97 | Set the owner of the calendar. Should be owner's full name. |
97 | */ | 98 | */ |
98 | void setOwner( const QString &os ); | 99 | void setOwner( const QString &os ); |
99 | /** | 100 | /** |
100 | Return the email address of the calendar owner. | 101 | Return the email address of the calendar owner. |
101 | */ | 102 | */ |
102 | const QString &getEmail(); | 103 | const QString &getEmail(); |
103 | /** | 104 | /** |
104 | Set the email address of the calendar owner. | 105 | Set the email address of the calendar owner. |
105 | */ | 106 | */ |
106 | void setEmail( const QString & ); | 107 | void setEmail( const QString & ); |
107 | 108 | ||
108 | /** | 109 | /** |
109 | Set time zone from a timezone string (e.g. -2:00) | 110 | Set time zone from a timezone string (e.g. -2:00) |
110 | */ | 111 | */ |
111 | void setTimeZone( const QString &tz ); | 112 | void setTimeZone( const QString &tz ); |
112 | /** | 113 | /** |
113 | Set time zone from a minutes value (e.g. -60) | 114 | Set time zone from a minutes value (e.g. -60) |
114 | */ | 115 | */ |
115 | void setTimeZone( int tz ); | 116 | void setTimeZone( int tz ); |
116 | /** | 117 | /** |
117 | Return time zone as offest in minutes. | 118 | Return time zone as offest in minutes. |
118 | */ | 119 | */ |
119 | int getTimeZone() const; | 120 | int getTimeZone() const; |
120 | /** | 121 | /** |
121 | Compute an ISO 8601 format string from the time zone. | 122 | Compute an ISO 8601 format string from the time zone. |
122 | */ | 123 | */ |
123 | QString getTimeZoneStr() const; | 124 | QString getTimeZoneStr() const; |
124 | /** | 125 | /** |
125 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 126 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
126 | values). | 127 | values). |
127 | */ | 128 | */ |
128 | void setTimeZoneId( const QString & ); | 129 | void setTimeZoneId( const QString & ); |
129 | /** | 130 | /** |
130 | Return time zone id. | 131 | Return time zone id. |
131 | */ | 132 | */ |
132 | QString timeZoneId() const; | 133 | QString timeZoneId() const; |
133 | /** | 134 | /** |
134 | Use local time, not UTC or a time zone. | 135 | Use local time, not UTC or a time zone. |
135 | */ | 136 | */ |
136 | void setLocalTime(); | 137 | void setLocalTime(); |
137 | /** | 138 | /** |
138 | Return whether local time is being used. | 139 | Return whether local time is being used. |
139 | */ | 140 | */ |
140 | bool isLocalTime() const; | 141 | bool isLocalTime() const; |
141 | 142 | ||
142 | /** | 143 | /** |
143 | Add an incidence to calendar. | 144 | Add an incidence to calendar. |
144 | 145 | ||
145 | @return true on success, false on error. | 146 | @return true on success, false on error. |
146 | */ | 147 | */ |
147 | virtual bool addIncidence( Incidence * ); | 148 | virtual bool addIncidence( Incidence * ); |
148 | 149 | ||
149 | // Adds an incidence and all relatedto incidences to the cal | 150 | // Adds an incidence and all relatedto incidences to the cal |
150 | void addIncidenceBranch( Incidence * ); | 151 | void addIncidenceBranch( Incidence * ); |
151 | /** | 152 | /** |
152 | Return filtered list of all incidences of this calendar. | 153 | Return filtered list of all incidences of this calendar. |
153 | */ | 154 | */ |
154 | virtual QPtrList<Incidence> incidences(); | 155 | virtual QPtrList<Incidence> incidences(); |
155 | 156 | ||
156 | /** | 157 | /** |
157 | Return unfiltered list of all incidences of this calendar. | 158 | Return unfiltered list of all incidences of this calendar. |
158 | */ | 159 | */ |
159 | virtual QPtrList<Incidence> rawIncidences(); | 160 | virtual QPtrList<Incidence> rawIncidences(); |
160 | 161 | ||
161 | /** | 162 | /** |
162 | Adds a Event to this calendar object. | 163 | Adds a Event to this calendar object. |
163 | @param anEvent a pointer to the event to add | 164 | @param anEvent a pointer to the event to add |
164 | 165 | ||
165 | @return true on success, false on error. | 166 | @return true on success, false on error. |
166 | */ | 167 | */ |
167 | virtual bool addEventNoDup( Event *event ) = 0; | 168 | virtual bool addEventNoDup( Event *event ) = 0; |
168 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 169 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
169 | virtual bool addEvent( Event *anEvent ) = 0; | 170 | virtual bool addEvent( Event *anEvent ) = 0; |
170 | /** | 171 | /** |
171 | Delete event from calendar. | 172 | Delete event from calendar. |
172 | */ | 173 | */ |
173 | virtual void deleteEvent( Event * ) = 0; | 174 | virtual void deleteEvent( Event * ) = 0; |
174 | /** | 175 | /** |
175 | Retrieves an event on the basis of the unique string ID. | 176 | Retrieves an event on the basis of the unique string ID. |
176 | */ | 177 | */ |
177 | virtual Event *event( const QString &UniqueStr ) = 0; | 178 | virtual Event *event( const QString &UniqueStr ) = 0; |
178 | virtual Event *event( QString, QString ) = 0; | 179 | virtual Event *event( QString, QString ) = 0; |
179 | /** | 180 | /** |
180 | Builds and then returns a list of all events that match for the | 181 | Builds and then returns a list of all events that match for the |
181 | date specified. useful for dayView, etc. etc. | 182 | date specified. useful for dayView, etc. etc. |
182 | The calendar filter is applied. | 183 | The calendar filter is applied. |
183 | */ | 184 | */ |
184 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 185 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
185 | /** | 186 | /** |
186 | Get events, which occur on the given date. | 187 | Get events, which occur on the given date. |
187 | The calendar filter is applied. | 188 | The calendar filter is applied. |
188 | */ | 189 | */ |
189 | QPtrList<Event> events( const QDateTime &qdt ); | 190 | QPtrList<Event> events( const QDateTime &qdt ); |
190 | /** | 191 | /** |
191 | Get events in a range of dates. If inclusive is set to true, only events | 192 | Get events in a range of dates. If inclusive is set to true, only events |
192 | are returned, which are completely included in the range. | 193 | are returned, which are completely included in the range. |
193 | The calendar filter is applied. | 194 | The calendar filter is applied. |
194 | */ | 195 | */ |
195 | QPtrList<Event> events( const QDate &start, const QDate &end, | 196 | QPtrList<Event> events( const QDate &start, const QDate &end, |
196 | bool inclusive = false); | 197 | bool inclusive = false); |
197 | /** | 198 | /** |
198 | Return filtered list of all events in calendar. | 199 | Return filtered list of all events in calendar. |
199 | */ | 200 | */ |
200 | virtual QPtrList<Event> events(); | 201 | virtual QPtrList<Event> events(); |
201 | /** | 202 | /** |
202 | Return unfiltered list of all events in calendar. | 203 | Return unfiltered list of all events in calendar. |
203 | */ | 204 | */ |
204 | virtual QPtrList<Event> rawEvents() = 0; | 205 | virtual QPtrList<Event> rawEvents() = 0; |
205 | 206 | ||
206 | /** | 207 | /** |
207 | Add a todo to the todolist. | 208 | Add a todo to the todolist. |
208 | 209 | ||
209 | @return true on success, false on error. | 210 | @return true on success, false on error. |
210 | */ | 211 | */ |
211 | virtual bool addTodo( Todo *todo ) = 0; | 212 | virtual bool addTodo( Todo *todo ) = 0; |
212 | virtual bool addTodoNoDup( Todo *todo ) = 0; | 213 | virtual bool addTodoNoDup( Todo *todo ) = 0; |
213 | /** | 214 | /** |
214 | Remove a todo from the todolist. | 215 | Remove a todo from the todolist. |
215 | */ | 216 | */ |
216 | virtual void deleteTodo( Todo * ) = 0; | 217 | virtual void deleteTodo( Todo * ) = 0; |
217 | virtual void deleteJournal( Journal * ) = 0; | 218 | virtual void deleteJournal( Journal * ) = 0; |
218 | /** | 219 | /** |
219 | Return filterd list of todos. | 220 | Return filterd list of todos. |
220 | */ | 221 | */ |
221 | virtual QPtrList<Todo> todos(); | 222 | virtual QPtrList<Todo> todos(); |
222 | /** | 223 | /** |
223 | Searches todolist for an event with this unique string identifier, | 224 | Searches todolist for an event with this unique string identifier, |
224 | returns a pointer or null. | 225 | returns a pointer or null. |
225 | */ | 226 | */ |
226 | virtual Todo *todo( const QString &uid ) = 0; | 227 | virtual Todo *todo( const QString &uid ) = 0; |
227 | virtual Todo *todo( QString, QString ) = 0; | 228 | virtual Todo *todo( QString, QString ) = 0; |
228 | /** | 229 | /** |
229 | Returns list of todos due on the specified date. | 230 | Returns list of todos due on the specified date. |
230 | */ | 231 | */ |
231 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; | 232 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; |
232 | /** | 233 | /** |
233 | Return unfiltered list of todos. | 234 | Return unfiltered list of todos. |
234 | */ | 235 | */ |
235 | virtual QPtrList<Todo> rawTodos() = 0; | 236 | virtual QPtrList<Todo> rawTodos() = 0; |
236 | 237 | ||
237 | /** | 238 | /** |
238 | Add a Journal entry to calendar. | 239 | Add a Journal entry to calendar. |
239 | 240 | ||
240 | @return true on success, false on error. | 241 | @return true on success, false on error. |
241 | */ | 242 | */ |
242 | virtual bool addJournal( Journal * ) = 0; | 243 | virtual bool addJournal( Journal * ) = 0; |
243 | /** | 244 | /** |
244 | Return Journal for given date. | 245 | Return Journal for given date. |
245 | */ | 246 | */ |
246 | virtual Journal *journal( const QDate & ) = 0; | 247 | virtual Journal *journal( const QDate & ) = 0; |
247 | virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; | 248 | virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; |
248 | /** | 249 | /** |
249 | Return Journal with given UID. | 250 | Return Journal with given UID. |
250 | */ | 251 | */ |
251 | virtual Journal *journal( const QString &UID ) = 0; | 252 | virtual Journal *journal( const QString &UID ) = 0; |
252 | /** | 253 | /** |
253 | Return list of all Journal entries. | 254 | Return list of all Journal entries. |
254 | */ | 255 | */ |
255 | virtual QPtrList<Journal> journals() = 0; | 256 | virtual QPtrList<Journal> journals() = 0; |
256 | 257 | ||
257 | /** | 258 | /** |
258 | Searches all incidence types for an incidence with this unique | 259 | Searches all incidence types for an incidence with this unique |
259 | string identifier, returns a pointer or null. | 260 | string identifier, returns a pointer or null. |
260 | */ | 261 | */ |
261 | Incidence* incidence( const QString&UID ); | 262 | Incidence* incidence( const QString&UID ); |
262 | 263 | ||
263 | /** | 264 | /** |
264 | Setup relations for an incidence. | 265 | Setup relations for an incidence. |
265 | */ | 266 | */ |
266 | virtual void setupRelations( Incidence * ); | 267 | virtual void setupRelations( Incidence * ); |
267 | /** | 268 | /** |
268 | Remove all relations to an incidence | 269 | Remove all relations to an incidence |
269 | */ | 270 | */ |
270 | virtual void removeRelations( Incidence * ); | 271 | virtual void removeRelations( Incidence * ); |
271 | 272 | ||
272 | /** | 273 | /** |
273 | Set calendar filter, which filters events for the events() functions. | 274 | Set calendar filter, which filters events for the events() functions. |
274 | The Filter object is owned by the caller. | 275 | The Filter object is owned by the caller. |
275 | */ | 276 | */ |
276 | void setFilter( CalFilter * ); | 277 | void setFilter( CalFilter * ); |
277 | /** | 278 | /** |
278 | Return calendar filter. | 279 | Return calendar filter. |
279 | */ | 280 | */ |
280 | CalFilter *filter(); | 281 | CalFilter *filter(); |
281 | virtual QDateTime nextAlarm( int daysTo ) = 0; | 282 | virtual QDateTime nextAlarm( int daysTo ) = 0; |
282 | virtual QString nextSummary( ) const = 0; | 283 | virtual QString nextSummary( ) const = 0; |
283 | virtual void reInitAlarmSettings() = 0; | 284 | virtual void reInitAlarmSettings() = 0; |
284 | virtual QDateTime nextAlarmEventDateTime() const = 0; | 285 | virtual QDateTime nextAlarmEventDateTime() const = 0; |
285 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; | 286 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; |
286 | /** | 287 | /** |
287 | Return all alarms, which ocur in the given time interval. | 288 | Return all alarms, which ocur in the given time interval. |
288 | */ | 289 | */ |
289 | virtual Alarm::List alarms( const QDateTime &from, | 290 | virtual Alarm::List alarms( const QDateTime &from, |
290 | const QDateTime &to ) = 0; | 291 | const QDateTime &to ) = 0; |
291 | 292 | ||
292 | class Observer { | 293 | class Observer { |
293 | public: | 294 | public: |
294 | virtual void calendarModified( bool, Calendar * ) = 0; | 295 | virtual void calendarModified( bool, Calendar * ) = 0; |
295 | }; | 296 | }; |
296 | 297 | ||
297 | void registerObserver( Observer * ); | 298 | void registerObserver( Observer * ); |
298 | 299 | ||
299 | void setModified( bool ); | 300 | void setModified( bool ); |
300 | 301 | ||
301 | /** | 302 | /** |
302 | Set product id returned by loadedProductId(). This function is only | 303 | Set product id returned by loadedProductId(). This function is only |
303 | useful for the calendar loading code. | 304 | useful for the calendar loading code. |
304 | */ | 305 | */ |
305 | void setLoadedProductId( const QString & ); | 306 | void setLoadedProductId( const QString & ); |
306 | /** | 307 | /** |
307 | Return product id taken from file that has been loaded. Returns | 308 | Return product id taken from file that has been loaded. Returns |
308 | QString::null, if no calendar has been loaded. | 309 | QString::null, if no calendar has been loaded. |
309 | */ | 310 | */ |
310 | QString loadedProductId(); | 311 | QString loadedProductId(); |
311 | int defaultCalendar(); | 312 | int defaultCalendar(); |
312 | void setDontDeleteIncidencesOnClose (); | 313 | void setDontDeleteIncidencesOnClose (); |
313 | public slots: | 314 | public slots: |
314 | void setDefaultCalendar( int ); | 315 | void setDefaultCalendar( int ); |
315 | virtual void setCalendarEnabled( int id, bool enable ) = 0; | 316 | virtual void setCalendarEnabled( int id, bool enable ) = 0; |
316 | virtual void setAlarmEnabled( int id, bool enable ) = 0; | 317 | virtual void setAlarmEnabled( int id, bool enable ) = 0; |
317 | virtual void setReadOnly( int id, bool enable ) = 0; | 318 | virtual void setReadOnly( int id, bool enable ) = 0; |
318 | virtual void setDefaultCalendarEnabledOnly() = 0; | 319 | virtual void setDefaultCalendarEnabledOnly() = 0; |
319 | virtual void setCalendarRemove( int id ) = 0; | 320 | virtual void setCalendarRemove( int id ) = 0; |
320 | signals: | 321 | signals: |
321 | void calendarChanged(); | 322 | void calendarChanged(); |
322 | void calendarSaved(); | 323 | void calendarSaved(); |
323 | void calendarLoaded(); | 324 | void calendarLoaded(); |
324 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 325 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
325 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 326 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
326 | 327 | ||
327 | protected: | 328 | protected: |
328 | /** | 329 | /** |
329 | Get unfiltered events, which occur on the given date. | 330 | Get unfiltered events, which occur on the given date. |
330 | */ | 331 | */ |
331 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; | 332 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; |
332 | /** | 333 | /** |
333 | Get unfiltered events, which occur on the given date. | 334 | Get unfiltered events, which occur on the given date. |
334 | */ | 335 | */ |
335 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, | 336 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, |
336 | bool sorted = false ) = 0; | 337 | bool sorted = false ) = 0; |
337 | /** | 338 | /** |
338 | Get events in a range of dates. If inclusive is set to true, only events | 339 | Get events in a range of dates. If inclusive is set to true, only events |
339 | are returned, which are completely included in the range. | 340 | are returned, which are completely included in the range. |
340 | */ | 341 | */ |
341 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 342 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
342 | bool inclusive = false ) = 0; | 343 | bool inclusive = false ) = 0; |
343 | 344 | ||
344 | Incidence *mNextAlarmIncidence; | 345 | Incidence *mNextAlarmIncidence; |
345 | Incidence *mUndoIncidence; | 346 | Incidence *mUndoIncidence; |
346 | int mDefaultCalendar; | 347 | int mDefaultCalendar; |
347 | bool mDeleteIncidencesOnClose; | 348 | bool mDeleteIncidencesOnClose; |
348 | 349 | ||
349 | private: | 350 | private: |
350 | void init(); | 351 | void init(); |
351 | 352 | ||
352 | QString mOwner; // who the calendar belongs to | 353 | QString mOwner; // who the calendar belongs to |
353 | QString mOwnerEmail; // email address of the owner | 354 | QString mOwnerEmail; // email address of the owner |
354 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) | 355 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) |
355 | bool mLocalTime; // use local time, not UTC or a time zone | 356 | bool mLocalTime; // use local time, not UTC or a time zone |
356 | 357 | ||
357 | 358 | ||
358 | CalFilter *mFilter; | 359 | CalFilter *mFilter; |
359 | CalFilter *mDefaultFilter; | 360 | CalFilter *mDefaultFilter; |
360 | 361 | ||
361 | 362 | ||
362 | QString mTimeZoneId; | 363 | QString mTimeZoneId; |
363 | 364 | ||
364 | Observer *mObserver; | 365 | Observer *mObserver; |
365 | bool mNewObserver; | 366 | bool mNewObserver; |
366 | 367 | ||
367 | bool mModified; | 368 | bool mModified; |
368 | 369 | ||
369 | QString mLoadedProductId; | 370 | QString mLoadedProductId; |
370 | 371 | ||
371 | // This list is used to put together related todos | 372 | // This list is used to put together related todos |
372 | QDict<Incidence> mOrphans; | 373 | QDict<Incidence> mOrphans; |
373 | QDict<Incidence> mOrphanUids; | 374 | QDict<Incidence> mOrphanUids; |
374 | }; | 375 | }; |
375 | 376 | ||
376 | } | 377 | } |
377 | 378 | ||
378 | #endif | 379 | #endif |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 3e42ec0..e37a7ad 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -1,1005 +1,1024 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | 31 | ||
32 | #include "vcaldrag.h" | 32 | #include "vcaldrag.h" |
33 | #include "vcalformat.h" | 33 | #include "vcalformat.h" |
34 | #include "icalformat.h" | 34 | #include "icalformat.h" |
35 | #include "exceptions.h" | 35 | #include "exceptions.h" |
36 | #include "incidence.h" | 36 | #include "incidence.h" |
37 | #include "journal.h" | 37 | #include "journal.h" |
38 | #include "filestorage.h" | 38 | #include "filestorage.h" |
39 | #include "calfilter.h" | 39 | #include "calfilter.h" |
40 | 40 | ||
41 | #include "calendarlocal.h" | 41 | #include "calendarlocal.h" |
42 | 42 | ||
43 | // #ifndef DESKTOP_VERSION | 43 | // #ifndef DESKTOP_VERSION |
44 | // #include <qtopia/alarmserver.h> | 44 | // #include <qtopia/alarmserver.h> |
45 | // #endif | 45 | // #endif |
46 | using namespace KCal; | 46 | using namespace KCal; |
47 | 47 | ||
48 | CalendarLocal::CalendarLocal() | 48 | CalendarLocal::CalendarLocal() |
49 | : Calendar() | 49 | : Calendar() |
50 | { | 50 | { |
51 | init(); | 51 | init(); |
52 | } | 52 | } |
53 | 53 | ||
54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) | 54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) |
55 | : Calendar(timeZoneId) | 55 | : Calendar(timeZoneId) |
56 | { | 56 | { |
57 | init(); | 57 | init(); |
58 | } | 58 | } |
59 | 59 | ||
60 | void CalendarLocal::init() | 60 | void CalendarLocal::init() |
61 | { | 61 | { |
62 | mNextAlarmIncidence = 0; | 62 | mNextAlarmIncidence = 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | CalendarLocal::~CalendarLocal() | 66 | CalendarLocal::~CalendarLocal() |
67 | { | 67 | { |
68 | if ( mDeleteIncidencesOnClose ) | 68 | if ( mDeleteIncidencesOnClose ) |
69 | close(); | 69 | close(); |
70 | } | 70 | } |
71 | bool CalendarLocal::mergeCalendarFile( QString name ) | 71 | bool CalendarLocal::mergeCalendarFile( QString name ) |
72 | { | 72 | { |
73 | CalendarLocal calendar( timeZoneId() ); | 73 | CalendarLocal calendar( timeZoneId() ); |
74 | calendar.setDefaultCalendar( 1 ); | 74 | calendar.setDefaultCalendar( 1 ); |
75 | if ( calendar.load( name ) ) { | 75 | if ( calendar.load( name ) ) { |
76 | mergeCalendar( &calendar ); | 76 | mergeCalendar( &calendar ); |
77 | return true; | 77 | return true; |
78 | } | 78 | } |
79 | return false; | 79 | return false; |
80 | } | 80 | } |
81 | 81 | ||
82 | Incidence* CalendarLocal::incidenceForUid( const QString& uid ) | 82 | Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates) |
83 | { | 83 | { |
84 | Todo *todo;; | 84 | Todo *todo;; |
85 | Incidence *retVal = 0; | 85 | Incidence *retVal = 0; |
86 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 86 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
87 | if ( todo->uid() == uid ) { | 87 | if ( todo->uid() == uid ) { |
88 | if ( doNotCheckDuplicates ) return todo; | ||
88 | if ( retVal ) { | 89 | if ( retVal ) { |
89 | if ( retVal->calID() > todo->calID() ) { | 90 | if ( retVal->calID() > todo->calID() ) { |
90 | retVal = todo; | 91 | retVal = todo; |
91 | } | 92 | } |
92 | } else { | 93 | } else { |
93 | retVal = todo; | 94 | retVal = todo; |
94 | } | 95 | } |
95 | } | 96 | } |
96 | } | 97 | } |
97 | if ( retVal ) return retVal; | 98 | if ( retVal ) return retVal; |
98 | Event *event; | 99 | Event *event; |
99 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 100 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
100 | if ( event->uid() == uid ) { | 101 | if ( event->uid() == uid ) { |
102 | if ( doNotCheckDuplicates ) return event; | ||
101 | if ( retVal ) { | 103 | if ( retVal ) { |
102 | if ( retVal->calID() > event->calID() ) { | 104 | if ( retVal->calID() > event->calID() ) { |
103 | retVal = event; | 105 | retVal = event; |
104 | } | 106 | } |
105 | } else { | 107 | } else { |
106 | retVal = event; | 108 | retVal = event; |
107 | } | 109 | } |
108 | } | 110 | } |
109 | } | 111 | } |
110 | if ( retVal ) return retVal; | 112 | if ( retVal ) return retVal; |
111 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 113 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
112 | if ( it->uid() == uid ) { | 114 | if ( it->uid() == uid ) { |
115 | if ( doNotCheckDuplicates ) return it; | ||
113 | if ( retVal ) { | 116 | if ( retVal ) { |
114 | if ( retVal->calID() > it->calID() ) { | 117 | if ( retVal->calID() > it->calID() ) { |
115 | retVal = it; | 118 | retVal = it; |
116 | } | 119 | } |
117 | } else { | 120 | } else { |
118 | retVal = it; | 121 | retVal = it; |
119 | } | 122 | } |
120 | } | 123 | } |
121 | return retVal; | 124 | return retVal; |
122 | } | 125 | } |
123 | 126 | ||
124 | bool CalendarLocal::mergeCalendar( Calendar* remote ) | 127 | bool CalendarLocal::mergeCalendar( Calendar* remote ) |
125 | { | 128 | { |
129 | // 1 look for raw inc in local | ||
130 | // if inc not in remote, delete in local | ||
131 | // 2 look for raw inc in remote | ||
132 | // if inc in local, replace it | ||
133 | // if not in local, add it to default calendar | ||
134 | QPtrList<Incidence> localInc = rawIncidences(); | ||
135 | Incidence* inL = localInc.first(); | ||
136 | while ( inL ) { | ||
137 | if ( ! inL->isReadOnly () ) | ||
138 | if ( !remote->incidenceForUid( inL->uid(), true )) | ||
139 | deleteIncidence( inL ); | ||
140 | inL = localInc.next(); | ||
141 | } | ||
126 | QPtrList<Incidence> er = remote->rawIncidences(); | 142 | QPtrList<Incidence> er = remote->rawIncidences(); |
127 | Incidence* inR = er.first(); | 143 | Incidence* inR = er.first(); |
128 | Incidence* inL; | ||
129 | while ( inR ) { | 144 | while ( inR ) { |
130 | inL = incidenceForUid( inR->uid() ); | 145 | inL = incidenceForUid( inR->uid(),false ); |
131 | if ( inL ) { | 146 | if ( inL ) { |
132 | int calID = inL->calID(); | 147 | if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { |
133 | deleteIncidence( inL ); | 148 | int calID = inL->calID(); |
134 | inL = inR->clone(); | 149 | deleteIncidence( inL ); |
135 | inL->setCalID( calID ); | 150 | inL = inR->clone(); |
136 | addIncidence( inL ); | 151 | inL->setCalID( calID ); |
152 | addIncidence( inL ); | ||
153 | } | ||
137 | } else { | 154 | } else { |
138 | inL = inR->clone(); | 155 | inL = inR->clone(); |
139 | inL->setCalID( 0 );// add to default cal | 156 | inL->setCalID( 0 );// add to default cal |
140 | addIncidence( inL ); | 157 | addIncidence( inL ); |
141 | } | 158 | } |
142 | inR = er.next(); | 159 | inR = er.next(); |
143 | } | 160 | } |
144 | return true; | 161 | return true; |
145 | } | 162 | } |
163 | |||
164 | |||
146 | bool CalendarLocal::addCalendarFile( QString name, int id ) | 165 | bool CalendarLocal::addCalendarFile( QString name, int id ) |
147 | { | 166 | { |
148 | CalendarLocal calendar( timeZoneId() ); | 167 | CalendarLocal calendar( timeZoneId() ); |
149 | calendar.setDefaultCalendar( id ); | 168 | calendar.setDefaultCalendar( id ); |
150 | if ( calendar.load( name ) ) { | 169 | if ( calendar.load( name ) ) { |
151 | addCalendar( &calendar ); | 170 | addCalendar( &calendar ); |
152 | return true; | 171 | return true; |
153 | } | 172 | } |
154 | return false; | 173 | return false; |
155 | } | 174 | } |
156 | void CalendarLocal::setSyncEventsReadOnly() | 175 | void CalendarLocal::setSyncEventsReadOnly() |
157 | { | 176 | { |
158 | Event * ev; | 177 | Event * ev; |
159 | ev = mEventList.first(); | 178 | ev = mEventList.first(); |
160 | while ( ev ) { | 179 | while ( ev ) { |
161 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 180 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
162 | ev->setReadOnly( true ); | 181 | ev->setReadOnly( true ); |
163 | ev = mEventList.next(); | 182 | ev = mEventList.next(); |
164 | } | 183 | } |
165 | } | 184 | } |
166 | void CalendarLocal::addCalendar( Calendar* cal ) | 185 | void CalendarLocal::addCalendar( Calendar* cal ) |
167 | { | 186 | { |
168 | cal->setDontDeleteIncidencesOnClose(); | 187 | cal->setDontDeleteIncidencesOnClose(); |
169 | { | 188 | { |
170 | QPtrList<Event> EventList = cal->rawEvents(); | 189 | QPtrList<Event> EventList = cal->rawEvents(); |
171 | Event * ev = EventList.first(); | 190 | Event * ev = EventList.first(); |
172 | while ( ev ) { | 191 | while ( ev ) { |
173 | ev->unRegisterObserver( cal ); | 192 | ev->unRegisterObserver( cal ); |
174 | ev->registerObserver( this ); | 193 | ev->registerObserver( this ); |
175 | mEventList.append( ev ); | 194 | mEventList.append( ev ); |
176 | ev = EventList.next(); | 195 | ev = EventList.next(); |
177 | } | 196 | } |
178 | } | 197 | } |
179 | { | 198 | { |
180 | 199 | ||
181 | QPtrList<Todo> TodoList = cal->rawTodos(); | 200 | QPtrList<Todo> TodoList = cal->rawTodos(); |
182 | Todo * ev = TodoList.first(); | 201 | Todo * ev = TodoList.first(); |
183 | while ( ev ) { | 202 | while ( ev ) { |
184 | QString rel = ev->relatedToUid(); | 203 | QString rel = ev->relatedToUid(); |
185 | if ( !rel.isEmpty() ){ | 204 | if ( !rel.isEmpty() ){ |
186 | ev->setRelatedTo ( 0 ); | 205 | ev->setRelatedTo ( 0 ); |
187 | ev->setRelatedToUid( rel ); | 206 | ev->setRelatedToUid( rel ); |
188 | } | 207 | } |
189 | ev = TodoList.next(); | 208 | ev = TodoList.next(); |
190 | } | 209 | } |
191 | //TodoList = cal->rawTodos(); | 210 | //TodoList = cal->rawTodos(); |
192 | ev = TodoList.first(); | 211 | ev = TodoList.first(); |
193 | while ( ev ) { | 212 | while ( ev ) { |
194 | ev->unRegisterObserver( cal ); | 213 | ev->unRegisterObserver( cal ); |
195 | ev->registerObserver( this ); | 214 | ev->registerObserver( this ); |
196 | mTodoList.append( ev ); | 215 | mTodoList.append( ev ); |
197 | setupRelations( ev ); | 216 | setupRelations( ev ); |
198 | ev = TodoList.next(); | 217 | ev = TodoList.next(); |
199 | } | 218 | } |
200 | } | 219 | } |
201 | { | 220 | { |
202 | QPtrList<Journal> JournalList = cal->journals(); | 221 | QPtrList<Journal> JournalList = cal->journals(); |
203 | Journal * ev = JournalList.first(); | 222 | Journal * ev = JournalList.first(); |
204 | while ( ev ) { | 223 | while ( ev ) { |
205 | ev->unRegisterObserver( cal ); | 224 | ev->unRegisterObserver( cal ); |
206 | ev->registerObserver( this ); | 225 | ev->registerObserver( this ); |
207 | mJournalList.append( ev ); | 226 | mJournalList.append( ev ); |
208 | ev = JournalList.next(); | 227 | ev = JournalList.next(); |
209 | } | 228 | } |
210 | } | 229 | } |
211 | setModified( true ); | 230 | setModified( true ); |
212 | } | 231 | } |
213 | bool CalendarLocal::load( const QString &fileName ) | 232 | bool CalendarLocal::load( const QString &fileName ) |
214 | { | 233 | { |
215 | FileStorage storage( this, fileName ); | 234 | FileStorage storage( this, fileName ); |
216 | return storage.load(); | 235 | return storage.load(); |
217 | } | 236 | } |
218 | 237 | ||
219 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) | 238 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) |
220 | { | 239 | { |
221 | FileStorage storage( this, fileName, format ); | 240 | FileStorage storage( this, fileName, format ); |
222 | return storage.save(); | 241 | return storage.save(); |
223 | } | 242 | } |
224 | 243 | ||
225 | void CalendarLocal::stopAllTodos() | 244 | void CalendarLocal::stopAllTodos() |
226 | { | 245 | { |
227 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 246 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
228 | it->setRunning( false ); | 247 | it->setRunning( false ); |
229 | 248 | ||
230 | } | 249 | } |
231 | void CalendarLocal::close() | 250 | void CalendarLocal::close() |
232 | { | 251 | { |
233 | 252 | ||
234 | Todo * i; | 253 | Todo * i; |
235 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); | 254 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); |
236 | 255 | ||
237 | mEventList.setAutoDelete( true ); | 256 | mEventList.setAutoDelete( true ); |
238 | mTodoList.setAutoDelete( true ); | 257 | mTodoList.setAutoDelete( true ); |
239 | mJournalList.setAutoDelete( false ); | 258 | mJournalList.setAutoDelete( false ); |
240 | 259 | ||
241 | mEventList.clear(); | 260 | mEventList.clear(); |
242 | mTodoList.clear(); | 261 | mTodoList.clear(); |
243 | mJournalList.clear(); | 262 | mJournalList.clear(); |
244 | 263 | ||
245 | mEventList.setAutoDelete( false ); | 264 | mEventList.setAutoDelete( false ); |
246 | mTodoList.setAutoDelete( false ); | 265 | mTodoList.setAutoDelete( false ); |
247 | mJournalList.setAutoDelete( false ); | 266 | mJournalList.setAutoDelete( false ); |
248 | 267 | ||
249 | setModified( false ); | 268 | setModified( false ); |
250 | } | 269 | } |
251 | 270 | ||
252 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | 271 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) |
253 | { | 272 | { |
254 | QString cat; | 273 | QString cat; |
255 | bool isBirthday = true; | 274 | bool isBirthday = true; |
256 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { | 275 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { |
257 | isBirthday = false; | 276 | isBirthday = false; |
258 | cat = i18n( "Anniversary" ); | 277 | cat = i18n( "Anniversary" ); |
259 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { | 278 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { |
260 | isBirthday = true; | 279 | isBirthday = true; |
261 | cat = i18n( "Birthday" ); | 280 | cat = i18n( "Birthday" ); |
262 | } else { | 281 | } else { |
263 | qDebug("addAnniversaryNoDup called without fitting category! "); | 282 | qDebug("addAnniversaryNoDup called without fitting category! "); |
264 | return false; | 283 | return false; |
265 | } | 284 | } |
266 | Event * eve; | 285 | Event * eve; |
267 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 286 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
268 | if ( !(eve->categories().contains( cat ) )) | 287 | if ( !(eve->categories().contains( cat ) )) |
269 | continue; | 288 | continue; |
270 | // now we have an event with fitting category | 289 | // now we have an event with fitting category |
271 | if ( eve->dtStart().date() != event->dtStart().date() ) | 290 | if ( eve->dtStart().date() != event->dtStart().date() ) |
272 | continue; | 291 | continue; |
273 | // now we have an event with fitting category+date | 292 | // now we have an event with fitting category+date |
274 | if ( eve->summary() != event->summary() ) | 293 | if ( eve->summary() != event->summary() ) |
275 | continue; | 294 | continue; |
276 | // now we have an event with fitting category+date+summary | 295 | // now we have an event with fitting category+date+summary |
277 | return false; | 296 | return false; |
278 | } | 297 | } |
279 | return addEvent( event ); | 298 | return addEvent( event ); |
280 | 299 | ||
281 | } | 300 | } |
282 | bool CalendarLocal::addEventNoDup( Event *event ) | 301 | bool CalendarLocal::addEventNoDup( Event *event ) |
283 | { | 302 | { |
284 | Event * eve; | 303 | Event * eve; |
285 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 304 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
286 | if ( *eve == *event ) { | 305 | if ( *eve == *event ) { |
287 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 306 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
288 | return false; | 307 | return false; |
289 | } | 308 | } |
290 | } | 309 | } |
291 | return addEvent( event ); | 310 | return addEvent( event ); |
292 | } | 311 | } |
293 | 312 | ||
294 | bool CalendarLocal::addEvent( Event *event ) | 313 | bool CalendarLocal::addEvent( Event *event ) |
295 | { | 314 | { |
296 | insertEvent( event ); | 315 | insertEvent( event ); |
297 | 316 | ||
298 | event->registerObserver( this ); | 317 | event->registerObserver( this ); |
299 | 318 | ||
300 | setModified( true ); | 319 | setModified( true ); |
301 | if ( event->calID() == 0 ) | 320 | if ( event->calID() == 0 ) |
302 | event->setCalID( mDefaultCalendar ); | 321 | event->setCalID( mDefaultCalendar ); |
303 | event->setCalEnabled( true ); | 322 | event->setCalEnabled( true ); |
304 | 323 | ||
305 | return true; | 324 | return true; |
306 | } | 325 | } |
307 | 326 | ||
308 | void CalendarLocal::deleteEvent( Event *event ) | 327 | void CalendarLocal::deleteEvent( Event *event ) |
309 | { | 328 | { |
310 | if ( mUndoIncidence ) delete mUndoIncidence; | 329 | if ( mUndoIncidence ) delete mUndoIncidence; |
311 | mUndoIncidence = event->clone(); | 330 | mUndoIncidence = event->clone(); |
312 | if ( mEventList.removeRef( event ) ) { | 331 | if ( mEventList.removeRef( event ) ) { |
313 | setModified( true ); | 332 | setModified( true ); |
314 | } | 333 | } |
315 | } | 334 | } |
316 | 335 | ||
317 | 336 | ||
318 | Event *CalendarLocal::event( const QString &uid ) | 337 | Event *CalendarLocal::event( const QString &uid ) |
319 | { | 338 | { |
320 | Event *event; | 339 | Event *event; |
321 | Event *retVal = 0; | 340 | Event *retVal = 0; |
322 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 341 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
323 | if ( event->calEnabled() && event->uid() == uid ) { | 342 | if ( event->calEnabled() && event->uid() == uid ) { |
324 | if ( retVal ) { | 343 | if ( retVal ) { |
325 | if ( retVal->calID() > event->calID() ) { | 344 | if ( retVal->calID() > event->calID() ) { |
326 | retVal = event; | 345 | retVal = event; |
327 | } | 346 | } |
328 | } else { | 347 | } else { |
329 | retVal = event; | 348 | retVal = event; |
330 | } | 349 | } |
331 | } | 350 | } |
332 | } | 351 | } |
333 | return retVal; | 352 | return retVal; |
334 | } | 353 | } |
335 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 354 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
336 | { | 355 | { |
337 | Todo * eve; | 356 | Todo * eve; |
338 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 357 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
339 | if ( *eve == *todo ) { | 358 | if ( *eve == *todo ) { |
340 | //qDebug("duplicate todo found! not inserted! "); | 359 | //qDebug("duplicate todo found! not inserted! "); |
341 | return false; | 360 | return false; |
342 | } | 361 | } |
343 | } | 362 | } |
344 | return addTodo( todo ); | 363 | return addTodo( todo ); |
345 | } | 364 | } |
346 | bool CalendarLocal::addTodo( Todo *todo ) | 365 | bool CalendarLocal::addTodo( Todo *todo ) |
347 | { | 366 | { |
348 | mTodoList.append( todo ); | 367 | mTodoList.append( todo ); |
349 | 368 | ||
350 | todo->registerObserver( this ); | 369 | todo->registerObserver( this ); |
351 | 370 | ||
352 | // Set up subtask relations | 371 | // Set up subtask relations |
353 | setupRelations( todo ); | 372 | setupRelations( todo ); |
354 | 373 | ||
355 | setModified( true ); | 374 | setModified( true ); |
356 | if ( todo->calID() == 0 ) | 375 | if ( todo->calID() == 0 ) |
357 | todo->setCalID( mDefaultCalendar ); | 376 | todo->setCalID( mDefaultCalendar ); |
358 | todo->setCalEnabled( true ); | 377 | todo->setCalEnabled( true ); |
359 | return true; | 378 | return true; |
360 | } | 379 | } |
361 | 380 | ||
362 | void CalendarLocal::deleteTodo( Todo *todo ) | 381 | void CalendarLocal::deleteTodo( Todo *todo ) |
363 | { | 382 | { |
364 | // Handle orphaned children | 383 | // Handle orphaned children |
365 | if ( mUndoIncidence ) delete mUndoIncidence; | 384 | if ( mUndoIncidence ) delete mUndoIncidence; |
366 | removeRelations( todo ); | 385 | removeRelations( todo ); |
367 | mUndoIncidence = todo->clone(); | 386 | mUndoIncidence = todo->clone(); |
368 | 387 | ||
369 | if ( mTodoList.removeRef( todo ) ) { | 388 | if ( mTodoList.removeRef( todo ) ) { |
370 | setModified( true ); | 389 | setModified( true ); |
371 | } | 390 | } |
372 | } | 391 | } |
373 | 392 | ||
374 | QPtrList<Todo> CalendarLocal::rawTodos() | 393 | QPtrList<Todo> CalendarLocal::rawTodos() |
375 | { | 394 | { |
376 | QPtrList<Todo> el; | 395 | QPtrList<Todo> el; |
377 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 396 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
378 | if ( it->calEnabled() ) el.append( it ); | 397 | if ( it->calEnabled() ) el.append( it ); |
379 | return el; | 398 | return el; |
380 | } | 399 | } |
381 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 400 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
382 | { | 401 | { |
383 | Todo *todo; | 402 | Todo *todo; |
384 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 403 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
385 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; | 404 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
386 | } | 405 | } |
387 | 406 | ||
388 | return 0; | 407 | return 0; |
389 | } | 408 | } |
390 | void CalendarLocal::removeSyncInfo( QString syncProfile) | 409 | void CalendarLocal::removeSyncInfo( QString syncProfile) |
391 | { | 410 | { |
392 | QPtrList<Incidence> all = rawIncidences() ; | 411 | QPtrList<Incidence> all = rawIncidences() ; |
393 | Incidence *inc; | 412 | Incidence *inc; |
394 | for ( inc = all.first(); inc; inc = all.next() ) { | 413 | for ( inc = all.first(); inc; inc = all.next() ) { |
395 | inc->removeID( syncProfile ); | 414 | inc->removeID( syncProfile ); |
396 | } | 415 | } |
397 | if ( syncProfile.isEmpty() ) { | 416 | if ( syncProfile.isEmpty() ) { |
398 | QPtrList<Event> el; | 417 | QPtrList<Event> el; |
399 | Event *todo; | 418 | Event *todo; |
400 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 419 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
401 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 420 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
402 | el.append( todo ); | 421 | el.append( todo ); |
403 | } | 422 | } |
404 | for ( todo = el.first(); todo; todo = el.next() ) { | 423 | for ( todo = el.first(); todo; todo = el.next() ) { |
405 | deleteIncidence ( todo ); | 424 | deleteIncidence ( todo ); |
406 | } | 425 | } |
407 | } else { | 426 | } else { |
408 | Event *lse = event( "last-syncEvent-"+ syncProfile); | 427 | Event *lse = event( "last-syncEvent-"+ syncProfile); |
409 | if ( lse ) | 428 | if ( lse ) |
410 | deleteIncidence ( lse ); | 429 | deleteIncidence ( lse ); |
411 | } | 430 | } |
412 | } | 431 | } |
413 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 432 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
414 | { | 433 | { |
415 | QPtrList<Event> el; | 434 | QPtrList<Event> el; |
416 | Event *todo; | 435 | Event *todo; |
417 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 436 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
418 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 437 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
419 | if ( todo->summary().left(3) == "E: " ) | 438 | if ( todo->summary().left(3) == "E: " ) |
420 | el.append( todo ); | 439 | el.append( todo ); |
421 | } | 440 | } |
422 | 441 | ||
423 | return el; | 442 | return el; |
424 | 443 | ||
425 | } | 444 | } |
426 | Event *CalendarLocal::event( QString syncProf, QString id ) | 445 | Event *CalendarLocal::event( QString syncProf, QString id ) |
427 | { | 446 | { |
428 | Event *todo; | 447 | Event *todo; |
429 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 448 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
430 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; | 449 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
431 | } | 450 | } |
432 | 451 | ||
433 | return 0; | 452 | return 0; |
434 | } | 453 | } |
435 | Todo *CalendarLocal::todo( const QString &uid ) | 454 | Todo *CalendarLocal::todo( const QString &uid ) |
436 | { | 455 | { |
437 | Todo *todo;; | 456 | Todo *todo;; |
438 | Todo *retVal = 0; | 457 | Todo *retVal = 0; |
439 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 458 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
440 | if ( todo->calEnabled() && todo->uid() == uid ) { | 459 | if ( todo->calEnabled() && todo->uid() == uid ) { |
441 | if ( retVal ) { | 460 | if ( retVal ) { |
442 | if ( retVal->calID() > todo->calID() ) { | 461 | if ( retVal->calID() > todo->calID() ) { |
443 | retVal = todo; | 462 | retVal = todo; |
444 | } | 463 | } |
445 | } else { | 464 | } else { |
446 | retVal = todo; | 465 | retVal = todo; |
447 | } | 466 | } |
448 | } | 467 | } |
449 | } | 468 | } |
450 | return retVal; | 469 | return retVal; |
451 | } | 470 | } |
452 | QString CalendarLocal::nextSummary() const | 471 | QString CalendarLocal::nextSummary() const |
453 | { | 472 | { |
454 | return mNextSummary; | 473 | return mNextSummary; |
455 | } | 474 | } |
456 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 475 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
457 | { | 476 | { |
458 | return mNextAlarmEventDateTime; | 477 | return mNextAlarmEventDateTime; |
459 | } | 478 | } |
460 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 479 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
461 | { | 480 | { |
462 | //mNextAlarmIncidence | 481 | //mNextAlarmIncidence |
463 | //mNextAlarmDateTime | 482 | //mNextAlarmDateTime |
464 | //return mNextSummary; | 483 | //return mNextSummary; |
465 | //return mNextAlarmEventDateTime; | 484 | //return mNextAlarmEventDateTime; |
466 | bool newNextAlarm = false; | 485 | bool newNextAlarm = false; |
467 | bool computeNextAlarm = false; | 486 | bool computeNextAlarm = false; |
468 | bool ok; | 487 | bool ok; |
469 | int offset; | 488 | int offset; |
470 | QDateTime nextA; | 489 | QDateTime nextA; |
471 | // QString nextSum; | 490 | // QString nextSum; |
472 | //QDateTime nextEvent; | 491 | //QDateTime nextEvent; |
473 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 492 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
474 | computeNextAlarm = true; | 493 | computeNextAlarm = true; |
475 | } else { | 494 | } else { |
476 | if ( ! deleted ) { | 495 | if ( ! deleted ) { |
477 | nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 496 | nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
478 | if ( ok ) { | 497 | if ( ok ) { |
479 | if ( nextA < mNextAlarmDateTime ) { | 498 | if ( nextA < mNextAlarmDateTime ) { |
480 | deRegisterAlarm(); | 499 | deRegisterAlarm(); |
481 | mNextAlarmDateTime = nextA; | 500 | mNextAlarmDateTime = nextA; |
482 | mNextSummary = incidence->summary(); | 501 | mNextSummary = incidence->summary(); |
483 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; | 502 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; |
484 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 503 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
485 | newNextAlarm = true; | 504 | newNextAlarm = true; |
486 | mNextAlarmIncidence = incidence; | 505 | mNextAlarmIncidence = incidence; |
487 | } else { | 506 | } else { |
488 | if ( incidence == mNextAlarmIncidence ) { | 507 | if ( incidence == mNextAlarmIncidence ) { |
489 | computeNextAlarm = true; | 508 | computeNextAlarm = true; |
490 | } | 509 | } |
491 | } | 510 | } |
492 | } else { | 511 | } else { |
493 | if ( mNextAlarmIncidence == incidence ) { | 512 | if ( mNextAlarmIncidence == incidence ) { |
494 | computeNextAlarm = true; | 513 | computeNextAlarm = true; |
495 | } | 514 | } |
496 | } | 515 | } |
497 | } else { // deleted | 516 | } else { // deleted |
498 | if ( incidence == mNextAlarmIncidence ) { | 517 | if ( incidence == mNextAlarmIncidence ) { |
499 | computeNextAlarm = true; | 518 | computeNextAlarm = true; |
500 | } | 519 | } |
501 | } | 520 | } |
502 | } | 521 | } |
503 | if ( computeNextAlarm ) { | 522 | if ( computeNextAlarm ) { |
504 | deRegisterAlarm(); | 523 | deRegisterAlarm(); |
505 | nextA = nextAlarm( 1000 ); | 524 | nextA = nextAlarm( 1000 ); |
506 | if (! mNextAlarmIncidence ) { | 525 | if (! mNextAlarmIncidence ) { |
507 | return; | 526 | return; |
508 | } | 527 | } |
509 | newNextAlarm = true; | 528 | newNextAlarm = true; |
510 | } | 529 | } |
511 | if ( newNextAlarm ) | 530 | if ( newNextAlarm ) |
512 | registerAlarm(); | 531 | registerAlarm(); |
513 | } | 532 | } |
514 | QString CalendarLocal:: getAlarmNotification() | 533 | QString CalendarLocal:: getAlarmNotification() |
515 | { | 534 | { |
516 | QString ret; | 535 | QString ret; |
517 | // this should not happen | 536 | // this should not happen |
518 | if (! mNextAlarmIncidence ) | 537 | if (! mNextAlarmIncidence ) |
519 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; | 538 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; |
520 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); | 539 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); |
521 | if ( alarm->type() == Alarm::Procedure ) { | 540 | if ( alarm->type() == Alarm::Procedure ) { |
522 | ret = "proc_alarm" + alarm->programFile()+"+++"; | 541 | ret = "proc_alarm" + alarm->programFile()+"+++"; |
523 | } else { | 542 | } else { |
524 | ret = "audio_alarm" +alarm->audioFile() +"+++"; | 543 | ret = "audio_alarm" +alarm->audioFile() +"+++"; |
525 | } | 544 | } |
526 | ret += "cal_alarm"+ mNextSummary.left( 25 ); | 545 | ret += "cal_alarm"+ mNextSummary.left( 25 ); |
527 | if ( mNextSummary.length() > 25 ) | 546 | if ( mNextSummary.length() > 25 ) |
528 | ret += "\n" + mNextSummary.mid(25, 25 ); | 547 | ret += "\n" + mNextSummary.mid(25, 25 ); |
529 | ret+= "\n"+mNextAlarmEventDateTimeString; | 548 | ret+= "\n"+mNextAlarmEventDateTimeString; |
530 | return ret; | 549 | return ret; |
531 | } | 550 | } |
532 | void CalendarLocal::registerAlarm() | 551 | void CalendarLocal::registerAlarm() |
533 | { | 552 | { |
534 | mLastAlarmNotificationString = getAlarmNotification(); | 553 | mLastAlarmNotificationString = getAlarmNotification(); |
535 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); | 554 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); |
536 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 555 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
537 | // #ifndef DESKTOP_VERSION | 556 | // #ifndef DESKTOP_VERSION |
538 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); | 557 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); |
539 | // #endif | 558 | // #endif |
540 | } | 559 | } |
541 | void CalendarLocal::deRegisterAlarm() | 560 | void CalendarLocal::deRegisterAlarm() |
542 | { | 561 | { |
543 | if ( mLastAlarmNotificationString.isNull() ) | 562 | if ( mLastAlarmNotificationString.isNull() ) |
544 | return; | 563 | return; |
545 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); | 564 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); |
546 | 565 | ||
547 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 566 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
548 | mNextAlarmEventDateTime = QDateTime(); | 567 | mNextAlarmEventDateTime = QDateTime(); |
549 | // #ifndef DESKTOP_VERSION | 568 | // #ifndef DESKTOP_VERSION |
550 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); | 569 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); |
551 | // #endif | 570 | // #endif |
552 | } | 571 | } |
553 | 572 | ||
554 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) | 573 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) |
555 | { | 574 | { |
556 | QPtrList<Todo> todos; | 575 | QPtrList<Todo> todos; |
557 | 576 | ||
558 | Todo *todo; | 577 | Todo *todo; |
559 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 578 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
560 | if ( !todo->calEnabled() ) continue; | 579 | if ( !todo->calEnabled() ) continue; |
561 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { | 580 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { |
562 | todos.append( todo ); | 581 | todos.append( todo ); |
563 | } | 582 | } |
564 | } | 583 | } |
565 | 584 | ||
566 | filter()->apply( &todos ); | 585 | filter()->apply( &todos ); |
567 | return todos; | 586 | return todos; |
568 | } | 587 | } |
569 | void CalendarLocal::reInitAlarmSettings() | 588 | void CalendarLocal::reInitAlarmSettings() |
570 | { | 589 | { |
571 | if ( !mNextAlarmIncidence ) { | 590 | if ( !mNextAlarmIncidence ) { |
572 | nextAlarm( 1000 ); | 591 | nextAlarm( 1000 ); |
573 | } | 592 | } |
574 | deRegisterAlarm(); | 593 | deRegisterAlarm(); |
575 | mNextAlarmIncidence = 0; | 594 | mNextAlarmIncidence = 0; |
576 | checkAlarmForIncidence( 0, false ); | 595 | checkAlarmForIncidence( 0, false ); |
577 | 596 | ||
578 | } | 597 | } |
579 | 598 | ||
580 | 599 | ||
581 | 600 | ||
582 | QDateTime CalendarLocal::nextAlarm( int daysTo ) | 601 | QDateTime CalendarLocal::nextAlarm( int daysTo ) |
583 | { | 602 | { |
584 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); | 603 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); |
585 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); | 604 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); |
586 | QDateTime next; | 605 | QDateTime next; |
587 | Event *e; | 606 | Event *e; |
588 | bool ok; | 607 | bool ok; |
589 | bool found = false; | 608 | bool found = false; |
590 | int offset; | 609 | int offset; |
591 | mNextAlarmIncidence = 0; | 610 | mNextAlarmIncidence = 0; |
592 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 611 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
593 | if ( !e->calEnabled() ) continue; | 612 | if ( !e->calEnabled() ) continue; |
594 | next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 613 | next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
595 | if ( ok ) { | 614 | if ( ok ) { |
596 | if ( next < nextA ) { | 615 | if ( next < nextA ) { |
597 | nextA = next; | 616 | nextA = next; |
598 | found = true; | 617 | found = true; |
599 | mNextSummary = e->summary(); | 618 | mNextSummary = e->summary(); |
600 | mNextAlarmEventDateTime = next.addSecs(offset ) ; | 619 | mNextAlarmEventDateTime = next.addSecs(offset ) ; |
601 | mNextAlarmIncidence = (Incidence *) e; | 620 | mNextAlarmIncidence = (Incidence *) e; |
602 | } | 621 | } |
603 | } | 622 | } |
604 | } | 623 | } |
605 | Todo *t; | 624 | Todo *t; |
606 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 625 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
607 | if ( !t->calEnabled() ) continue; | 626 | if ( !t->calEnabled() ) continue; |
608 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 627 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
609 | if ( ok ) { | 628 | if ( ok ) { |
610 | if ( next < nextA ) { | 629 | if ( next < nextA ) { |
611 | nextA = next; | 630 | nextA = next; |
612 | found = true; | 631 | found = true; |
613 | mNextSummary = t->summary(); | 632 | mNextSummary = t->summary(); |
614 | mNextAlarmEventDateTime = next.addSecs(offset ); | 633 | mNextAlarmEventDateTime = next.addSecs(offset ); |
615 | mNextAlarmIncidence = (Incidence *) t; | 634 | mNextAlarmIncidence = (Incidence *) t; |
616 | } | 635 | } |
617 | } | 636 | } |
618 | } | 637 | } |
619 | if ( mNextAlarmIncidence ) { | 638 | if ( mNextAlarmIncidence ) { |
620 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 639 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
621 | mNextAlarmDateTime = nextA; | 640 | mNextAlarmDateTime = nextA; |
622 | } | 641 | } |
623 | return nextA; | 642 | return nextA; |
624 | } | 643 | } |
625 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) | 644 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) |
626 | { | 645 | { |
627 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); | 646 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); |
628 | } | 647 | } |
629 | 648 | ||
630 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) | 649 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) |
631 | { | 650 | { |
632 | 651 | ||
633 | Alarm::List alarms; | 652 | Alarm::List alarms; |
634 | 653 | ||
635 | Event *e; | 654 | Event *e; |
636 | 655 | ||
637 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 656 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
638 | if ( !e->calEnabled() ) continue; | 657 | if ( !e->calEnabled() ) continue; |
639 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); | 658 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); |
640 | else appendAlarms( alarms, e, from, to ); | 659 | else appendAlarms( alarms, e, from, to ); |
641 | } | 660 | } |
642 | 661 | ||
643 | Todo *t; | 662 | Todo *t; |
644 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 663 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
645 | if ( !t->calEnabled() ) continue; | 664 | if ( !t->calEnabled() ) continue; |
646 | appendAlarms( alarms, t, from, to ); | 665 | appendAlarms( alarms, t, from, to ); |
647 | } | 666 | } |
648 | 667 | ||
649 | return alarms; | 668 | return alarms; |
650 | } | 669 | } |
651 | 670 | ||
652 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, | 671 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, |
653 | const QDateTime &from, const QDateTime &to ) | 672 | const QDateTime &from, const QDateTime &to ) |
654 | { | 673 | { |
655 | QPtrList<Alarm> alarmList = incidence->alarms(); | 674 | QPtrList<Alarm> alarmList = incidence->alarms(); |
656 | Alarm *alarm; | 675 | Alarm *alarm; |
657 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 676 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
658 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() | 677 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() |
659 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; | 678 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; |
660 | if ( alarm->enabled() ) { | 679 | if ( alarm->enabled() ) { |
661 | if ( alarm->time() >= from && alarm->time() <= to ) { | 680 | if ( alarm->time() >= from && alarm->time() <= to ) { |
662 | alarms.append( alarm ); | 681 | alarms.append( alarm ); |
663 | } | 682 | } |
664 | } | 683 | } |
665 | } | 684 | } |
666 | } | 685 | } |
667 | 686 | ||
668 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | 687 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, |
669 | Incidence *incidence, | 688 | Incidence *incidence, |
670 | const QDateTime &from, | 689 | const QDateTime &from, |
671 | const QDateTime &to ) | 690 | const QDateTime &to ) |
672 | { | 691 | { |
673 | 692 | ||
674 | QPtrList<Alarm> alarmList = incidence->alarms(); | 693 | QPtrList<Alarm> alarmList = incidence->alarms(); |
675 | Alarm *alarm; | 694 | Alarm *alarm; |
676 | QDateTime qdt; | 695 | QDateTime qdt; |
677 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 696 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
678 | if (incidence->recursOn(from.date())) { | 697 | if (incidence->recursOn(from.date())) { |
679 | qdt.setTime(alarm->time().time()); | 698 | qdt.setTime(alarm->time().time()); |
680 | qdt.setDate(from.date()); | 699 | qdt.setDate(from.date()); |
681 | } | 700 | } |
682 | else qdt = alarm->time(); | 701 | else qdt = alarm->time(); |
683 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); | 702 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); |
684 | if ( alarm->enabled() ) { | 703 | if ( alarm->enabled() ) { |
685 | if ( qdt >= from && qdt <= to ) { | 704 | if ( qdt >= from && qdt <= to ) { |
686 | alarms.append( alarm ); | 705 | alarms.append( alarm ); |
687 | } | 706 | } |
688 | } | 707 | } |
689 | } | 708 | } |
690 | } | 709 | } |
691 | 710 | ||
692 | 711 | ||
693 | /****************************** PROTECTED METHODS ****************************/ | 712 | /****************************** PROTECTED METHODS ****************************/ |
694 | 713 | ||
695 | // after changes are made to an event, this should be called. | 714 | // after changes are made to an event, this should be called. |
696 | void CalendarLocal::update( IncidenceBase *incidence ) | 715 | void CalendarLocal::update( IncidenceBase *incidence ) |
697 | { | 716 | { |
698 | incidence->setSyncStatus( Event::SYNCMOD ); | 717 | incidence->setSyncStatus( Event::SYNCMOD ); |
699 | incidence->setLastModified( QDateTime::currentDateTime() ); | 718 | incidence->setLastModified( QDateTime::currentDateTime() ); |
700 | // we should probably update the revision number here, | 719 | // we should probably update the revision number here, |
701 | // or internally in the Event itself when certain things change. | 720 | // or internally in the Event itself when certain things change. |
702 | // need to verify with ical documentation. | 721 | // need to verify with ical documentation. |
703 | 722 | ||
704 | setModified( true ); | 723 | setModified( true ); |
705 | } | 724 | } |
706 | 725 | ||
707 | void CalendarLocal::insertEvent( Event *event ) | 726 | void CalendarLocal::insertEvent( Event *event ) |
708 | { | 727 | { |
709 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); | 728 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); |
710 | } | 729 | } |
711 | 730 | ||
712 | 731 | ||
713 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | 732 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) |
714 | { | 733 | { |
715 | QPtrList<Event> eventList; | 734 | QPtrList<Event> eventList; |
716 | 735 | ||
717 | Event *event; | 736 | Event *event; |
718 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 737 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
719 | if ( !event->calEnabled() ) continue; | 738 | if ( !event->calEnabled() ) continue; |
720 | if ( event->doesRecur() ) { | 739 | if ( event->doesRecur() ) { |
721 | if ( event->isMultiDay() ) { | 740 | if ( event->isMultiDay() ) { |
722 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); | 741 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); |
723 | int i; | 742 | int i; |
724 | for ( i = 0; i <= extraDays; i++ ) { | 743 | for ( i = 0; i <= extraDays; i++ ) { |
725 | if ( event->recursOn( qd.addDays( -i ) ) ) { | 744 | if ( event->recursOn( qd.addDays( -i ) ) ) { |
726 | eventList.append( event ); | 745 | eventList.append( event ); |
727 | break; | 746 | break; |
728 | } | 747 | } |
729 | } | 748 | } |
730 | } else { | 749 | } else { |
731 | if ( event->recursOn( qd ) ) | 750 | if ( event->recursOn( qd ) ) |
732 | eventList.append( event ); | 751 | eventList.append( event ); |
733 | } | 752 | } |
734 | } else { | 753 | } else { |
735 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 754 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
736 | eventList.append( event ); | 755 | eventList.append( event ); |
737 | } | 756 | } |
738 | } | 757 | } |
739 | } | 758 | } |
740 | 759 | ||
741 | if ( !sorted ) { | 760 | if ( !sorted ) { |
742 | return eventList; | 761 | return eventList; |
743 | } | 762 | } |
744 | 763 | ||
745 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 764 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
746 | // now, we have to sort it based on dtStart.time() | 765 | // now, we have to sort it based on dtStart.time() |
747 | QPtrList<Event> eventListSorted; | 766 | QPtrList<Event> eventListSorted; |
748 | Event *sortEvent; | 767 | Event *sortEvent; |
749 | for ( event = eventList.first(); event; event = eventList.next() ) { | 768 | for ( event = eventList.first(); event; event = eventList.next() ) { |
750 | sortEvent = eventListSorted.first(); | 769 | sortEvent = eventListSorted.first(); |
751 | int i = 0; | 770 | int i = 0; |
752 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 771 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
753 | { | 772 | { |
754 | i++; | 773 | i++; |
755 | sortEvent = eventListSorted.next(); | 774 | sortEvent = eventListSorted.next(); |
756 | } | 775 | } |
757 | eventListSorted.insert( i, event ); | 776 | eventListSorted.insert( i, event ); |
758 | } | 777 | } |
759 | return eventListSorted; | 778 | return eventListSorted; |
760 | } | 779 | } |
761 | 780 | ||
762 | 781 | ||
763 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 782 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
764 | bool inclusive ) | 783 | bool inclusive ) |
765 | { | 784 | { |
766 | Event *event = 0; | 785 | Event *event = 0; |
767 | 786 | ||
768 | QPtrList<Event> eventList; | 787 | QPtrList<Event> eventList; |
769 | 788 | ||
770 | // Get non-recurring events | 789 | // Get non-recurring events |
771 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 790 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
772 | if ( !event->calEnabled() ) continue; | 791 | if ( !event->calEnabled() ) continue; |
773 | if ( event->doesRecur() ) { | 792 | if ( event->doesRecur() ) { |
774 | QDate rStart = event->dtStart().date(); | 793 | QDate rStart = event->dtStart().date(); |
775 | bool found = false; | 794 | bool found = false; |
776 | if ( inclusive ) { | 795 | if ( inclusive ) { |
777 | if ( rStart >= start && rStart <= end ) { | 796 | if ( rStart >= start && rStart <= end ) { |
778 | // Start date of event is in range. Now check for end date. | 797 | // Start date of event is in range. Now check for end date. |
779 | // if duration is negative, event recurs forever, so do not include it. | 798 | // if duration is negative, event recurs forever, so do not include it. |
780 | if ( event->recurrence()->duration() == 0 ) { // End date set | 799 | if ( event->recurrence()->duration() == 0 ) { // End date set |
781 | QDate rEnd = event->recurrence()->endDate(); | 800 | QDate rEnd = event->recurrence()->endDate(); |
782 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 801 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
783 | found = true; | 802 | found = true; |
784 | } | 803 | } |
785 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 804 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
786 | // TODO: Calculate end date from duration. Should be done in Event | 805 | // TODO: Calculate end date from duration. Should be done in Event |
787 | // For now exclude all events with a duration. | 806 | // For now exclude all events with a duration. |
788 | } | 807 | } |
789 | } | 808 | } |
790 | } else { | 809 | } else { |
791 | bool founOne; | 810 | bool founOne; |
792 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 811 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
793 | if ( founOne ) { | 812 | if ( founOne ) { |
794 | if ( next <= end ) { | 813 | if ( next <= end ) { |
795 | found = true; | 814 | found = true; |
796 | } | 815 | } |
797 | } | 816 | } |
798 | 817 | ||
799 | /* | 818 | /* |
800 | // crap !!! | 819 | // crap !!! |
801 | if ( rStart <= end ) { // Start date not after range | 820 | if ( rStart <= end ) { // Start date not after range |
802 | if ( rStart >= start ) { // Start date within range | 821 | if ( rStart >= start ) { // Start date within range |
803 | found = true; | 822 | found = true; |
804 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 823 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
805 | found = true; | 824 | found = true; |
806 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 825 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
807 | QDate rEnd = event->recurrence()->endDate(); | 826 | QDate rEnd = event->recurrence()->endDate(); |
808 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 827 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
809 | found = true; | 828 | found = true; |
810 | } | 829 | } |
811 | } else { // Duration set | 830 | } else { // Duration set |
812 | // TODO: Calculate end date from duration. Should be done in Event | 831 | // TODO: Calculate end date from duration. Should be done in Event |
813 | // For now include all events with a duration. | 832 | // For now include all events with a duration. |
814 | found = true; | 833 | found = true; |
815 | } | 834 | } |
816 | } | 835 | } |
817 | */ | 836 | */ |
818 | 837 | ||
819 | } | 838 | } |
820 | 839 | ||
821 | if ( found ) eventList.append( event ); | 840 | if ( found ) eventList.append( event ); |
822 | } else { | 841 | } else { |
823 | QDate s = event->dtStart().date(); | 842 | QDate s = event->dtStart().date(); |
824 | QDate e = event->dtEnd().date(); | 843 | QDate e = event->dtEnd().date(); |
825 | 844 | ||
826 | if ( inclusive ) { | 845 | if ( inclusive ) { |
827 | if ( s >= start && e <= end ) { | 846 | if ( s >= start && e <= end ) { |
828 | eventList.append( event ); | 847 | eventList.append( event ); |
829 | } | 848 | } |
830 | } else { | 849 | } else { |
831 | if ( ( e >= start && s <= end ) ) { | 850 | if ( ( e >= start && s <= end ) ) { |
832 | eventList.append( event ); | 851 | eventList.append( event ); |
833 | } | 852 | } |
834 | } | 853 | } |
835 | } | 854 | } |
836 | } | 855 | } |
837 | 856 | ||
838 | return eventList; | 857 | return eventList; |
839 | } | 858 | } |
840 | 859 | ||
841 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 860 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
842 | { | 861 | { |
843 | return rawEventsForDate( qdt.date() ); | 862 | return rawEventsForDate( qdt.date() ); |
844 | } | 863 | } |
845 | 864 | ||
846 | QPtrList<Event> CalendarLocal::rawEvents() | 865 | QPtrList<Event> CalendarLocal::rawEvents() |
847 | { | 866 | { |
848 | QPtrList<Event> el; | 867 | QPtrList<Event> el; |
849 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 868 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
850 | if ( it->calEnabled() ) el.append( it ); | 869 | if ( it->calEnabled() ) el.append( it ); |
851 | return el; | 870 | return el; |
852 | } | 871 | } |
853 | 872 | ||
854 | bool CalendarLocal::addJournal(Journal *journal) | 873 | bool CalendarLocal::addJournal(Journal *journal) |
855 | { | 874 | { |
856 | mJournalList.append(journal); | 875 | mJournalList.append(journal); |
857 | 876 | ||
858 | journal->registerObserver( this ); | 877 | journal->registerObserver( this ); |
859 | 878 | ||
860 | setModified( true ); | 879 | setModified( true ); |
861 | if ( journal->calID() == 0 ) | 880 | if ( journal->calID() == 0 ) |
862 | journal->setCalID( mDefaultCalendar ); | 881 | journal->setCalID( mDefaultCalendar ); |
863 | journal->setCalEnabled( true ); | 882 | journal->setCalEnabled( true ); |
864 | return true; | 883 | return true; |
865 | } | 884 | } |
866 | 885 | ||
867 | void CalendarLocal::deleteJournal( Journal *journal ) | 886 | void CalendarLocal::deleteJournal( Journal *journal ) |
868 | { | 887 | { |
869 | if ( mUndoIncidence ) delete mUndoIncidence; | 888 | if ( mUndoIncidence ) delete mUndoIncidence; |
870 | mUndoIncidence = journal->clone(); | 889 | mUndoIncidence = journal->clone(); |
871 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); | 890 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); |
872 | if ( mJournalList.removeRef(journal) ) { | 891 | if ( mJournalList.removeRef(journal) ) { |
873 | setModified( true ); | 892 | setModified( true ); |
874 | } | 893 | } |
875 | } | 894 | } |
876 | 895 | ||
877 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) | 896 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) |
878 | { | 897 | { |
879 | QPtrList<Journal> el; | 898 | QPtrList<Journal> el; |
880 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 899 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
881 | if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); | 900 | if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); |
882 | return el; | 901 | return el; |
883 | } | 902 | } |
884 | Journal *CalendarLocal::journal( const QDate &date ) | 903 | Journal *CalendarLocal::journal( const QDate &date ) |
885 | { | 904 | { |
886 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 905 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
887 | 906 | ||
888 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 907 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
889 | if ( it->calEnabled() && it->dtStart().date() == date ) | 908 | if ( it->calEnabled() && it->dtStart().date() == date ) |
890 | return it; | 909 | return it; |
891 | 910 | ||
892 | return 0; | 911 | return 0; |
893 | } | 912 | } |
894 | 913 | ||
895 | Journal *CalendarLocal::journal( const QString &uid ) | 914 | Journal *CalendarLocal::journal( const QString &uid ) |
896 | { | 915 | { |
897 | Journal * retVal = 0; | 916 | Journal * retVal = 0; |
898 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 917 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
899 | if ( it->calEnabled() && it->uid() == uid ) { | 918 | if ( it->calEnabled() && it->uid() == uid ) { |
900 | if ( retVal ) { | 919 | if ( retVal ) { |
901 | if ( retVal->calID() > it->calID() ) { | 920 | if ( retVal->calID() > it->calID() ) { |
902 | retVal = it; | 921 | retVal = it; |
903 | } | 922 | } |
904 | } else { | 923 | } else { |
905 | retVal = it; | 924 | retVal = it; |
906 | } | 925 | } |
907 | } | 926 | } |
908 | return retVal; | 927 | return retVal; |
909 | } | 928 | } |
910 | 929 | ||
911 | QPtrList<Journal> CalendarLocal::journals() | 930 | QPtrList<Journal> CalendarLocal::journals() |
912 | { | 931 | { |
913 | QPtrList<Journal> el; | 932 | QPtrList<Journal> el; |
914 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 933 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
915 | if ( it->calEnabled() ) el.append( it ); | 934 | if ( it->calEnabled() ) el.append( it ); |
916 | return el; | 935 | return el; |
917 | } | 936 | } |
918 | void CalendarLocal::setCalendarRemove( int id ) | 937 | void CalendarLocal::setCalendarRemove( int id ) |
919 | { | 938 | { |
920 | 939 | ||
921 | { | 940 | { |
922 | QPtrList<Event> EventList = mEventList; | 941 | QPtrList<Event> EventList = mEventList; |
923 | Event * ev = EventList.first(); | 942 | Event * ev = EventList.first(); |
924 | while ( ev ) { | 943 | while ( ev ) { |
925 | if ( ev->calID() == id ) | 944 | if ( ev->calID() == id ) |
926 | deleteEvent( ev ); | 945 | deleteEvent( ev ); |
927 | ev = EventList.next(); | 946 | ev = EventList.next(); |
928 | } | 947 | } |
929 | } | 948 | } |
930 | { | 949 | { |
931 | 950 | ||
932 | QPtrList<Todo> TodoList = mTodoList; | 951 | QPtrList<Todo> TodoList = mTodoList; |
933 | Todo * ev = TodoList.first(); | 952 | Todo * ev = TodoList.first(); |
934 | while ( ev ) { | 953 | while ( ev ) { |
935 | if ( ev->calID() == id ) | 954 | if ( ev->calID() == id ) |
936 | deleteTodo( ev ); | 955 | deleteTodo( ev ); |
937 | ev = TodoList.next(); | 956 | ev = TodoList.next(); |
938 | } | 957 | } |
939 | } | 958 | } |
940 | { | 959 | { |
941 | QPtrList<Journal> JournalList = mJournalList; | 960 | QPtrList<Journal> JournalList = mJournalList; |
942 | Journal * ev = JournalList.first(); | 961 | Journal * ev = JournalList.first(); |
943 | while ( ev ) { | 962 | while ( ev ) { |
944 | if ( ev->calID() == id ) | 963 | if ( ev->calID() == id ) |
945 | deleteJournal( ev ); | 964 | deleteJournal( ev ); |
946 | ev = JournalList.next(); | 965 | ev = JournalList.next(); |
947 | } | 966 | } |
948 | } | 967 | } |
949 | 968 | ||
950 | if ( mUndoIncidence ) delete mUndoIncidence; | 969 | if ( mUndoIncidence ) delete mUndoIncidence; |
951 | mUndoIncidence = 0; | 970 | mUndoIncidence = 0; |
952 | 971 | ||
953 | } | 972 | } |
954 | 973 | ||
955 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) | 974 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) |
956 | { | 975 | { |
957 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 976 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
958 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 977 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
959 | 978 | ||
960 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 979 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
961 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 980 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
962 | 981 | ||
963 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 982 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
964 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 983 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
965 | 984 | ||
966 | } | 985 | } |
967 | 986 | ||
968 | void CalendarLocal::setReadOnly( int id, bool enable ) | 987 | void CalendarLocal::setReadOnly( int id, bool enable ) |
969 | { | 988 | { |
970 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 989 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
971 | if ( it->calID() == id ) it->setReadOnly( enable ); | 990 | if ( it->calID() == id ) it->setReadOnly( enable ); |
972 | 991 | ||
973 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 992 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
974 | if ( it->calID() == id ) it->setReadOnly( enable ); | 993 | if ( it->calID() == id ) it->setReadOnly( enable ); |
975 | 994 | ||
976 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 995 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
977 | if ( it->calID() == id ) it->setReadOnly( enable ); | 996 | if ( it->calID() == id ) it->setReadOnly( enable ); |
978 | 997 | ||
979 | } | 998 | } |
980 | 999 | ||
981 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) | 1000 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) |
982 | { | 1001 | { |
983 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1002 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
984 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 1003 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
985 | 1004 | ||
986 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1005 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
987 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 1006 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
988 | 1007 | ||
989 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1008 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
990 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 1009 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
991 | reInitAlarmSettings(); | 1010 | reInitAlarmSettings(); |
992 | 1011 | ||
993 | } | 1012 | } |
994 | void CalendarLocal::setDefaultCalendarEnabledOnly() | 1013 | void CalendarLocal::setDefaultCalendarEnabledOnly() |
995 | { | 1014 | { |
996 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1015 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
997 | it->setCalEnabled( it->calID() == mDefaultCalendar ); | 1016 | it->setCalEnabled( it->calID() == mDefaultCalendar ); |
998 | 1017 | ||
999 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1018 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1000 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 1019 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
1001 | 1020 | ||
1002 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1021 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1003 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 1022 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
1004 | 1023 | ||
1005 | } | 1024 | } |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 23b0542..a7a85c8 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -1,230 +1,230 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | #ifndef KCAL_CALENDARLOCAL_H | 22 | #ifndef KCAL_CALENDARLOCAL_H |
23 | #define KCAL_CALENDARLOCAL_H | 23 | #define KCAL_CALENDARLOCAL_H |
24 | 24 | ||
25 | #include "calendar.h" | 25 | #include "calendar.h" |
26 | 26 | ||
27 | namespace KCal { | 27 | namespace KCal { |
28 | 28 | ||
29 | class CalFormat; | 29 | class CalFormat; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | This class provides a calendar stored as a local file. | 32 | This class provides a calendar stored as a local file. |
33 | */ | 33 | */ |
34 | class CalendarLocal : public Calendar | 34 | class CalendarLocal : public Calendar |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | /** | 37 | /** |
38 | Constructs a new calendar, with variables initialized to sane values. | 38 | Constructs a new calendar, with variables initialized to sane values. |
39 | */ | 39 | */ |
40 | CalendarLocal(); | 40 | CalendarLocal(); |
41 | /** | 41 | /** |
42 | Constructs a new calendar, with variables initialized to sane values. | 42 | Constructs a new calendar, with variables initialized to sane values. |
43 | */ | 43 | */ |
44 | CalendarLocal( const QString &timeZoneId ); | 44 | CalendarLocal( const QString &timeZoneId ); |
45 | ~CalendarLocal(); | 45 | ~CalendarLocal(); |
46 | void addCalendar( Calendar* ); | 46 | void addCalendar( Calendar* ); |
47 | bool addCalendarFile( QString name, int id ); | 47 | bool addCalendarFile( QString name, int id ); |
48 | bool mergeCalendarFile( QString name ); | 48 | bool mergeCalendarFile( QString name ); |
49 | bool mergeCalendar( Calendar* cal ); | 49 | bool mergeCalendar( Calendar* cal ); |
50 | Incidence* incidenceForUid( const QString& uid ); | 50 | Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); |
51 | void setSyncEventsReadOnly(); | 51 | void setSyncEventsReadOnly(); |
52 | void stopAllTodos(); | 52 | void stopAllTodos(); |
53 | /** | 53 | /** |
54 | Loads a calendar on disk in vCalendar or iCalendar format into the current | 54 | Loads a calendar on disk in vCalendar or iCalendar format into the current |
55 | calendar. Any information already present is lost. | 55 | calendar. Any information already present is lost. |
56 | @return true, if successfull, false on error. | 56 | @return true, if successfull, false on error. |
57 | @param fileName the name of the calendar on disk. | 57 | @param fileName the name of the calendar on disk. |
58 | */ | 58 | */ |
59 | bool load( const QString &fileName ); | 59 | bool load( const QString &fileName ); |
60 | /** | 60 | /** |
61 | Writes out the calendar to disk in the specified \a format. | 61 | Writes out the calendar to disk in the specified \a format. |
62 | CalendarLocal takes ownership of the CalFormat object. | 62 | CalendarLocal takes ownership of the CalFormat object. |
63 | @return true, if successfull, false on error. | 63 | @return true, if successfull, false on error. |
64 | @param fileName the name of the file | 64 | @param fileName the name of the file |
65 | */ | 65 | */ |
66 | bool save( const QString &fileName, CalFormat *format = 0 ); | 66 | bool save( const QString &fileName, CalFormat *format = 0 ); |
67 | 67 | ||
68 | /** | 68 | /** |
69 | Clears out the current calendar, freeing all used memory etc. etc. | 69 | Clears out the current calendar, freeing all used memory etc. etc. |
70 | */ | 70 | */ |
71 | void close(); | 71 | void close(); |
72 | 72 | ||
73 | void save() {} | 73 | void save() {} |
74 | 74 | ||
75 | /** | 75 | /** |
76 | Add Event to calendar. | 76 | Add Event to calendar. |
77 | */ | 77 | */ |
78 | void removeSyncInfo( QString syncProfile); | 78 | void removeSyncInfo( QString syncProfile); |
79 | bool addAnniversaryNoDup( Event *event ); | 79 | bool addAnniversaryNoDup( Event *event ); |
80 | bool addEventNoDup( Event *event ); | 80 | bool addEventNoDup( Event *event ); |
81 | bool addEvent( Event *event ); | 81 | bool addEvent( Event *event ); |
82 | /** | 82 | /** |
83 | Deletes an event from this calendar. | 83 | Deletes an event from this calendar. |
84 | */ | 84 | */ |
85 | void deleteEvent( Event *event ); | 85 | void deleteEvent( Event *event ); |
86 | 86 | ||
87 | /** | 87 | /** |
88 | Retrieves an event on the basis of the unique string ID. | 88 | Retrieves an event on the basis of the unique string ID. |
89 | */ | 89 | */ |
90 | Event *event( const QString &uid ); | 90 | Event *event( const QString &uid ); |
91 | /** | 91 | /** |
92 | Return unfiltered list of all events in calendar. | 92 | Return unfiltered list of all events in calendar. |
93 | */ | 93 | */ |
94 | QPtrList<Event> rawEvents(); | 94 | QPtrList<Event> rawEvents(); |
95 | QPtrList<Event> getExternLastSyncEvents(); | 95 | QPtrList<Event> getExternLastSyncEvents(); |
96 | /** | 96 | /** |
97 | Add a todo to the todolist. | 97 | Add a todo to the todolist. |
98 | */ | 98 | */ |
99 | bool addTodo( Todo *todo ); | 99 | bool addTodo( Todo *todo ); |
100 | bool addTodoNoDup( Todo *todo ); | 100 | bool addTodoNoDup( Todo *todo ); |
101 | /** | 101 | /** |
102 | Remove a todo from the todolist. | 102 | Remove a todo from the todolist. |
103 | */ | 103 | */ |
104 | void deleteTodo( Todo * ); | 104 | void deleteTodo( Todo * ); |
105 | /** | 105 | /** |
106 | Searches todolist for an event with this unique string identifier, | 106 | Searches todolist for an event with this unique string identifier, |
107 | returns a pointer or null. | 107 | returns a pointer or null. |
108 | */ | 108 | */ |
109 | Todo *todo( const QString &uid ); | 109 | Todo *todo( const QString &uid ); |
110 | /** | 110 | /** |
111 | Return list of all todos. | 111 | Return list of all todos. |
112 | */ | 112 | */ |
113 | QPtrList<Todo> rawTodos(); | 113 | QPtrList<Todo> rawTodos(); |
114 | /** | 114 | /** |
115 | Returns list of todos due on the specified date. | 115 | Returns list of todos due on the specified date. |
116 | */ | 116 | */ |
117 | QPtrList<Todo> todos( const QDate &date ); | 117 | QPtrList<Todo> todos( const QDate &date ); |
118 | /** | 118 | /** |
119 | Return list of all todos. | 119 | Return list of all todos. |
120 | 120 | ||
121 | Workaround because compiler does not recognize function of base class. | 121 | Workaround because compiler does not recognize function of base class. |
122 | */ | 122 | */ |
123 | QPtrList<Todo> todos() { return Calendar::todos(); } | 123 | QPtrList<Todo> todos() { return Calendar::todos(); } |
124 | 124 | ||
125 | /** | 125 | /** |
126 | Add a Journal entry to calendar. | 126 | Add a Journal entry to calendar. |
127 | */ | 127 | */ |
128 | bool addJournal( Journal * ); | 128 | bool addJournal( Journal * ); |
129 | /** | 129 | /** |
130 | Remove a Journal from the calendar. | 130 | Remove a Journal from the calendar. |
131 | */ | 131 | */ |
132 | void deleteJournal( Journal * ); | 132 | void deleteJournal( Journal * ); |
133 | /** | 133 | /** |
134 | Return Journal for given date. | 134 | Return Journal for given date. |
135 | */ | 135 | */ |
136 | Journal *journal( const QDate & ); | 136 | Journal *journal( const QDate & ); |
137 | QPtrList<Journal> journals4Date( const QDate & ); | 137 | QPtrList<Journal> journals4Date( const QDate & ); |
138 | /** | 138 | /** |
139 | Return Journal with given UID. | 139 | Return Journal with given UID. |
140 | */ | 140 | */ |
141 | Journal *journal( const QString &uid ); | 141 | Journal *journal( const QString &uid ); |
142 | /** | 142 | /** |
143 | Return list of all Journals stored in calendar. | 143 | Return list of all Journals stored in calendar. |
144 | */ | 144 | */ |
145 | QPtrList<Journal> journals(); | 145 | QPtrList<Journal> journals(); |
146 | 146 | ||
147 | /** | 147 | /** |
148 | Return all alarms, which ocur in the given time interval. | 148 | Return all alarms, which ocur in the given time interval. |
149 | */ | 149 | */ |
150 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); | 150 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); |
151 | 151 | ||
152 | /** | 152 | /** |
153 | Return all alarms, which ocur before given date. | 153 | Return all alarms, which ocur before given date. |
154 | */ | 154 | */ |
155 | Alarm::List alarmsTo( const QDateTime &to ); | 155 | Alarm::List alarmsTo( const QDateTime &to ); |
156 | 156 | ||
157 | QDateTime nextAlarm( int daysTo ) ; | 157 | QDateTime nextAlarm( int daysTo ) ; |
158 | QDateTime nextAlarmEventDateTime() const; | 158 | QDateTime nextAlarmEventDateTime() const; |
159 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; | 159 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; |
160 | void registerAlarm(); | 160 | void registerAlarm(); |
161 | void deRegisterAlarm(); | 161 | void deRegisterAlarm(); |
162 | QString getAlarmNotification(); | 162 | QString getAlarmNotification(); |
163 | QString nextSummary() const ; | 163 | QString nextSummary() const ; |
164 | /** | 164 | /** |
165 | This method should be called whenever a Event is modified directly | 165 | This method should be called whenever a Event is modified directly |
166 | via it's pointer. It makes sure that the calendar is internally | 166 | via it's pointer. It makes sure that the calendar is internally |
167 | consistent. | 167 | consistent. |
168 | */ | 168 | */ |
169 | void update( IncidenceBase *incidence ); | 169 | void update( IncidenceBase *incidence ); |
170 | 170 | ||
171 | /** | 171 | /** |
172 | Builds and then returns a list of all events that match for the | 172 | Builds and then returns a list of all events that match for the |
173 | date specified. useful for dayView, etc. etc. | 173 | date specified. useful for dayView, etc. etc. |
174 | */ | 174 | */ |
175 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); | 175 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); |
176 | /** | 176 | /** |
177 | Get unfiltered events for date \a qdt. | 177 | Get unfiltered events for date \a qdt. |
178 | */ | 178 | */ |
179 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); | 179 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); |
180 | /** | 180 | /** |
181 | Get unfiltered events in a range of dates. If inclusive is set to true, | 181 | Get unfiltered events in a range of dates. If inclusive is set to true, |
182 | only events are returned, which are completely included in the range. | 182 | only events are returned, which are completely included in the range. |
183 | */ | 183 | */ |
184 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 184 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
185 | bool inclusive = false ); | 185 | bool inclusive = false ); |
186 | Todo *todo( QString, QString ); | 186 | Todo *todo( QString, QString ); |
187 | Event *event( QString, QString ); | 187 | Event *event( QString, QString ); |
188 | 188 | ||
189 | public slots: | 189 | public slots: |
190 | void setCalendarEnabled( int id, bool enable ); | 190 | void setCalendarEnabled( int id, bool enable ); |
191 | void setAlarmEnabled( int id, bool enable ); | 191 | void setAlarmEnabled( int id, bool enable ); |
192 | void setReadOnly( int id, bool enable ); | 192 | void setReadOnly( int id, bool enable ); |
193 | void setDefaultCalendarEnabledOnly(); | 193 | void setDefaultCalendarEnabledOnly(); |
194 | void setCalendarRemove( int id ); | 194 | void setCalendarRemove( int id ); |
195 | 195 | ||
196 | protected: | 196 | protected: |
197 | 197 | ||
198 | // Event* mNextAlarmEvent; | 198 | // Event* mNextAlarmEvent; |
199 | QString mNextSummary; | 199 | QString mNextSummary; |
200 | QString mNextAlarmEventDateTimeString; | 200 | QString mNextAlarmEventDateTimeString; |
201 | QString mLastAlarmNotificationString; | 201 | QString mLastAlarmNotificationString; |
202 | QDateTime mNextAlarmEventDateTime; | 202 | QDateTime mNextAlarmEventDateTime; |
203 | QDateTime mNextAlarmDateTime; | 203 | QDateTime mNextAlarmDateTime; |
204 | void reInitAlarmSettings(); | 204 | void reInitAlarmSettings(); |
205 | 205 | ||
206 | /** Notification function of IncidenceBase::Observer. */ | 206 | /** Notification function of IncidenceBase::Observer. */ |
207 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } | 207 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } |
208 | 208 | ||
209 | /** inserts an event into its "proper place" in the calendar. */ | 209 | /** inserts an event into its "proper place" in the calendar. */ |
210 | void insertEvent( Event *event ); | 210 | void insertEvent( Event *event ); |
211 | 211 | ||
212 | /** Append alarms of incidence in interval to list of alarms. */ | 212 | /** Append alarms of incidence in interval to list of alarms. */ |
213 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, | 213 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, |
214 | const QDateTime &from, const QDateTime &to ); | 214 | const QDateTime &from, const QDateTime &to ); |
215 | 215 | ||
216 | /** Append alarms of recurring events in interval to list of alarms. */ | 216 | /** Append alarms of recurring events in interval to list of alarms. */ |
217 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, | 217 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, |
218 | const QDateTime &from, const QDateTime &to ); | 218 | const QDateTime &from, const QDateTime &to ); |
219 | 219 | ||
220 | private: | 220 | private: |
221 | void init(); | 221 | void init(); |
222 | 222 | ||
223 | QPtrList<Event> mEventList; | 223 | QPtrList<Event> mEventList; |
224 | QPtrList<Todo> mTodoList; | 224 | QPtrList<Todo> mTodoList; |
225 | QPtrList<Journal> mJournalList; | 225 | QPtrList<Journal> mJournalList; |
226 | }; | 226 | }; |
227 | 227 | ||
228 | } | 228 | } |
229 | 229 | ||
230 | #endif | 230 | #endif |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index dcead02..1a19f3e 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -1,472 +1,478 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | #include <kidmanager.h> | 24 | #include <kidmanager.h> |
25 | 25 | ||
26 | #include "calformat.h" | 26 | #include "calformat.h" |
27 | #include "syncdefines.h" | 27 | #include "syncdefines.h" |
28 | 28 | ||
29 | #include "incidencebase.h" | 29 | #include "incidencebase.h" |
30 | 30 | ||
31 | using namespace KCal; | 31 | using namespace KCal; |
32 | 32 | ||
33 | IncidenceBase::IncidenceBase() : | 33 | IncidenceBase::IncidenceBase() : |
34 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), | 34 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), |
35 | mPilotId(0), mSyncStatus(SYNCMOD) | 35 | mPilotId(0), mSyncStatus(SYNCMOD) |
36 | { | 36 | { |
37 | blockLastModified = false; | ||
37 | setUid(CalFormat::createUniqueId()); | 38 | setUid(CalFormat::createUniqueId()); |
38 | mOrganizer = ""; | 39 | mOrganizer = ""; |
39 | mFloats = false; | 40 | mFloats = false; |
40 | mDuration = 0; | 41 | mDuration = 0; |
41 | mHasDuration = false; | 42 | mHasDuration = false; |
42 | mPilotId = 0; | 43 | mPilotId = 0; |
43 | mExternalId = ":"; | 44 | mExternalId = ":"; |
44 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 45 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
45 | mSyncStatus = 0; | 46 | mSyncStatus = 0; |
46 | mAttendees.setAutoDelete( true ); | 47 | mAttendees.setAutoDelete( true ); |
47 | mCalEnabled = true; | 48 | mCalEnabled = true; |
48 | mAlarmEnabled = true; | 49 | mAlarmEnabled = true; |
49 | mCalID = 0; | 50 | mCalID = 0; |
50 | } | 51 | } |
51 | 52 | ||
52 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 53 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
53 | CustomProperties( i ) | 54 | CustomProperties( i ) |
54 | { | 55 | { |
55 | 56 | ||
57 | blockLastModified = false; | ||
56 | mReadOnly = i.mReadOnly; | 58 | mReadOnly = i.mReadOnly; |
57 | mDtStart = i.mDtStart; | 59 | mDtStart = i.mDtStart; |
58 | mDuration = i.mDuration; | 60 | mDuration = i.mDuration; |
59 | mHasDuration = i.mHasDuration; | 61 | mHasDuration = i.mHasDuration; |
60 | mOrganizer = i.mOrganizer; | 62 | mOrganizer = i.mOrganizer; |
61 | mUid = i.mUid; | 63 | mUid = i.mUid; |
62 | mCalEnabled = i.mCalEnabled; | 64 | mCalEnabled = i.mCalEnabled; |
63 | mAlarmEnabled = i.mAlarmEnabled; | 65 | mAlarmEnabled = i.mAlarmEnabled; |
64 | mCalID = i.mCalID; | 66 | mCalID = i.mCalID; |
65 | QPtrList<Attendee> attendees = i.attendees(); | 67 | QPtrList<Attendee> attendees = i.attendees(); |
66 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { | 68 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { |
67 | mAttendees.append( new Attendee( *a ) ); | 69 | mAttendees.append( new Attendee( *a ) ); |
68 | } | 70 | } |
69 | mFloats = i.mFloats; | 71 | mFloats = i.mFloats; |
70 | mLastModified = i.mLastModified; | 72 | mLastModified = i.mLastModified; |
71 | mPilotId = i.mPilotId; | 73 | mPilotId = i.mPilotId; |
72 | mTempSyncStat = i.mTempSyncStat; | 74 | mTempSyncStat = i.mTempSyncStat; |
73 | mSyncStatus = i.mSyncStatus; | 75 | mSyncStatus = i.mSyncStatus; |
74 | mExternalId = i.mExternalId; | 76 | mExternalId = i.mExternalId; |
75 | // The copied object is a new one, so it isn't observed by the observer | 77 | // The copied object is a new one, so it isn't observed by the observer |
76 | // of the original object. | 78 | // of the original object. |
77 | mObservers.clear(); | 79 | mObservers.clear(); |
78 | 80 | ||
79 | mAttendees.setAutoDelete( true ); | 81 | mAttendees.setAutoDelete( true ); |
80 | } | 82 | } |
81 | 83 | ||
82 | IncidenceBase::~IncidenceBase() | 84 | IncidenceBase::~IncidenceBase() |
83 | { | 85 | { |
84 | } | 86 | } |
85 | 87 | ||
86 | 88 | ||
87 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 89 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
88 | { | 90 | { |
89 | // do not compare mSyncStatus and mExternalId | 91 | // do not compare mSyncStatus and mExternalId |
90 | if( i1.attendees().count() != i2.attendees().count() ) { | 92 | if( i1.attendees().count() != i2.attendees().count() ) { |
91 | return false; // no need to check further | 93 | return false; // no need to check further |
92 | } | 94 | } |
93 | if ( i1.attendees().count() > 0 ) { | 95 | if ( i1.attendees().count() > 0 ) { |
94 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; | 96 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; |
95 | while ( a1 ) { | 97 | while ( a1 ) { |
96 | if ( !( (*a1) == (*a2)) ) | 98 | if ( !( (*a1) == (*a2)) ) |
97 | { | 99 | { |
98 | //qDebug("Attendee not equal "); | 100 | //qDebug("Attendee not equal "); |
99 | return false; | 101 | return false; |
100 | } | 102 | } |
101 | a1 = i1.attendees().next(); | 103 | a1 = i1.attendees().next(); |
102 | a2 = i2.attendees().next(); | 104 | a2 = i2.attendees().next(); |
103 | } | 105 | } |
104 | } | 106 | } |
105 | //if ( i1.dtStart() != i2.dtStart() ) | 107 | //if ( i1.dtStart() != i2.dtStart() ) |
106 | // return false; | 108 | // return false; |
107 | #if 0 | 109 | #if 0 |
108 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); | 110 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); |
109 | qDebug("1 %d ",i1.duration() == i2.duration() ); | 111 | qDebug("1 %d ",i1.duration() == i2.duration() ); |
110 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); | 112 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); |
111 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); | 113 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); |
112 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); | 114 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); |
113 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); | 115 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); |
114 | 116 | ||
115 | #endif | 117 | #endif |
116 | if ( i1.hasDuration() == i2.hasDuration() ) { | 118 | if ( i1.hasDuration() == i2.hasDuration() ) { |
117 | if ( i1.hasDuration() ) { | 119 | if ( i1.hasDuration() ) { |
118 | if ( i1.duration() != i2.duration() ) | 120 | if ( i1.duration() != i2.duration() ) |
119 | return false; | 121 | return false; |
120 | } | 122 | } |
121 | } else { | 123 | } else { |
122 | return false; | 124 | return false; |
123 | } | 125 | } |
124 | 126 | ||
125 | return ( i1.organizer() == i2.organizer() && | 127 | return ( i1.organizer() == i2.organizer() && |
126 | // i1.uid() == i2.uid() && | 128 | // i1.uid() == i2.uid() && |
127 | // Don't compare lastModified, otherwise the operator is not | 129 | // Don't compare lastModified, otherwise the operator is not |
128 | // of much use. We are not comparing for identity, after all. | 130 | // of much use. We are not comparing for identity, after all. |
129 | i1.doesFloat() == i2.doesFloat() && | 131 | i1.doesFloat() == i2.doesFloat() && |
130 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); | 132 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); |
131 | // no need to compare mObserver | 133 | // no need to compare mObserver |
132 | } | 134 | } |
133 | 135 | ||
134 | 136 | ||
135 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) | 137 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) |
136 | { | 138 | { |
137 | QTime t = dt.time(); | 139 | QTime t = dt.time(); |
138 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 140 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
139 | return dt; | 141 | return dt; |
140 | } | 142 | } |
141 | 143 | ||
142 | bool IncidenceBase::isTagged() const | 144 | bool IncidenceBase::isTagged() const |
143 | { | 145 | { |
144 | return mIsTagged; | 146 | return mIsTagged; |
145 | } | 147 | } |
146 | void IncidenceBase::setTagged( bool b) | 148 | void IncidenceBase::setTagged( bool b) |
147 | { | 149 | { |
148 | mIsTagged = b; | 150 | mIsTagged = b; |
149 | } | 151 | } |
150 | void IncidenceBase::setCalID( int id ) | 152 | void IncidenceBase::setCalID( int id ) |
151 | { | 153 | { |
152 | if ( mCalID > 0 ) | 154 | if ( mCalID > 0 ) { |
155 | blockLastModified = true; | ||
153 | updated(); | 156 | updated(); |
157 | blockLastModified = false; | ||
158 | } | ||
154 | mCalID = id; | 159 | mCalID = id; |
155 | } | 160 | } |
156 | int IncidenceBase::calID() const | 161 | int IncidenceBase::calID() const |
157 | { | 162 | { |
158 | return mCalID; | 163 | return mCalID; |
159 | } | 164 | } |
160 | void IncidenceBase::setCalEnabled( bool b ) | 165 | void IncidenceBase::setCalEnabled( bool b ) |
161 | { | 166 | { |
162 | mCalEnabled = b; | 167 | mCalEnabled = b; |
163 | } | 168 | } |
164 | bool IncidenceBase::calEnabled() const | 169 | bool IncidenceBase::calEnabled() const |
165 | { | 170 | { |
166 | return mCalEnabled; | 171 | return mCalEnabled; |
167 | } | 172 | } |
168 | 173 | ||
169 | void IncidenceBase::setAlarmEnabled( bool b ) | 174 | void IncidenceBase::setAlarmEnabled( bool b ) |
170 | { | 175 | { |
171 | mAlarmEnabled = b; | 176 | mAlarmEnabled = b; |
172 | } | 177 | } |
173 | bool IncidenceBase::alarmEnabled() const | 178 | bool IncidenceBase::alarmEnabled() const |
174 | { | 179 | { |
175 | return mAlarmEnabled; | 180 | return mAlarmEnabled; |
176 | } | 181 | } |
177 | 182 | ||
178 | 183 | ||
179 | void IncidenceBase::setUid(const QString &uid) | 184 | void IncidenceBase::setUid(const QString &uid) |
180 | { | 185 | { |
181 | mUid = uid; | 186 | mUid = uid; |
182 | updated(); | 187 | updated(); |
183 | } | 188 | } |
184 | 189 | ||
185 | QString IncidenceBase::uid() const | 190 | QString IncidenceBase::uid() const |
186 | { | 191 | { |
187 | return mUid; | 192 | return mUid; |
188 | } | 193 | } |
189 | 194 | ||
190 | void IncidenceBase::setLastModified(const QDateTime &lm) | 195 | void IncidenceBase::setLastModified(const QDateTime &lm) |
191 | { | 196 | { |
197 | if ( blockLastModified ) return; | ||
192 | // DON'T! updated() because we call this from | 198 | // DON'T! updated() because we call this from |
193 | // Calendar::updateEvent(). | 199 | // Calendar::updateEvent(). |
194 | mLastModified = getEvenTime(lm); | 200 | mLastModified = getEvenTime(lm); |
195 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); | 201 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); |
196 | } | 202 | } |
197 | 203 | ||
198 | QDateTime IncidenceBase::lastModified() const | 204 | QDateTime IncidenceBase::lastModified() const |
199 | { | 205 | { |
200 | return mLastModified; | 206 | return mLastModified; |
201 | } | 207 | } |
202 | 208 | ||
203 | void IncidenceBase::setOrganizer(const QString &o) | 209 | void IncidenceBase::setOrganizer(const QString &o) |
204 | { | 210 | { |
205 | // we don't check for readonly here, because it is | 211 | // we don't check for readonly here, because it is |
206 | // possible that by setting the organizer we are changing | 212 | // possible that by setting the organizer we are changing |
207 | // the event's readonly status... | 213 | // the event's readonly status... |
208 | mOrganizer = o; | 214 | mOrganizer = o; |
209 | if (mOrganizer.left(7).upper() == "MAILTO:") | 215 | if (mOrganizer.left(7).upper() == "MAILTO:") |
210 | mOrganizer = mOrganizer.remove(0,7); | 216 | mOrganizer = mOrganizer.remove(0,7); |
211 | 217 | ||
212 | updated(); | 218 | updated(); |
213 | } | 219 | } |
214 | 220 | ||
215 | QString IncidenceBase::organizer() const | 221 | QString IncidenceBase::organizer() const |
216 | { | 222 | { |
217 | return mOrganizer; | 223 | return mOrganizer; |
218 | } | 224 | } |
219 | 225 | ||
220 | void IncidenceBase::setReadOnly( bool readOnly ) | 226 | void IncidenceBase::setReadOnly( bool readOnly ) |
221 | { | 227 | { |
222 | mReadOnly = readOnly; | 228 | mReadOnly = readOnly; |
223 | } | 229 | } |
224 | 230 | ||
225 | void IncidenceBase::setDtStart(const QDateTime &dtStart) | 231 | void IncidenceBase::setDtStart(const QDateTime &dtStart) |
226 | { | 232 | { |
227 | // if (mReadOnly) return; | 233 | // if (mReadOnly) return; |
228 | mDtStart = getEvenTime(dtStart); | 234 | mDtStart = getEvenTime(dtStart); |
229 | updated(); | 235 | updated(); |
230 | } | 236 | } |
231 | 237 | ||
232 | 238 | ||
233 | QDateTime IncidenceBase::dtStart() const | 239 | QDateTime IncidenceBase::dtStart() const |
234 | { | 240 | { |
235 | return mDtStart; | 241 | return mDtStart; |
236 | } | 242 | } |
237 | 243 | ||
238 | QString IncidenceBase::dtStartTimeStr() const | 244 | QString IncidenceBase::dtStartTimeStr() const |
239 | { | 245 | { |
240 | return KGlobal::locale()->formatTime(dtStart().time()); | 246 | return KGlobal::locale()->formatTime(dtStart().time()); |
241 | } | 247 | } |
242 | 248 | ||
243 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const | 249 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const |
244 | { | 250 | { |
245 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 251 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
246 | } | 252 | } |
247 | 253 | ||
248 | QString IncidenceBase::dtStartStr(bool shortfmt) const | 254 | QString IncidenceBase::dtStartStr(bool shortfmt) const |
249 | { | 255 | { |
250 | if ( doesFloat() ) | 256 | if ( doesFloat() ) |
251 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 257 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
252 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); | 258 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); |
253 | } | 259 | } |
254 | 260 | ||
255 | 261 | ||
256 | bool IncidenceBase::doesFloat() const | 262 | bool IncidenceBase::doesFloat() const |
257 | { | 263 | { |
258 | return mFloats; | 264 | return mFloats; |
259 | } | 265 | } |
260 | 266 | ||
261 | void IncidenceBase::setFloats(bool f) | 267 | void IncidenceBase::setFloats(bool f) |
262 | { | 268 | { |
263 | if (mReadOnly) return; | 269 | if (mReadOnly) return; |
264 | mFloats = f; | 270 | mFloats = f; |
265 | updated(); | 271 | updated(); |
266 | } | 272 | } |
267 | 273 | ||
268 | 274 | ||
269 | bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) | 275 | bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) |
270 | { | 276 | { |
271 | if (mReadOnly) return false; | 277 | if (mReadOnly) return false; |
272 | if (a->name().left(7).upper() == "MAILTO:") | 278 | if (a->name().left(7).upper() == "MAILTO:") |
273 | a->setName(a->name().remove(0,7)); | 279 | a->setName(a->name().remove(0,7)); |
274 | 280 | ||
275 | QPtrListIterator<Attendee> qli(mAttendees); | 281 | QPtrListIterator<Attendee> qli(mAttendees); |
276 | 282 | ||
277 | qli.toFirst(); | 283 | qli.toFirst(); |
278 | while (qli) { | 284 | while (qli) { |
279 | if (*qli.current() == *a) | 285 | if (*qli.current() == *a) |
280 | return false; | 286 | return false; |
281 | ++qli; | 287 | ++qli; |
282 | } | 288 | } |
283 | mAttendees.append(a); | 289 | mAttendees.append(a); |
284 | if (doupdate) updated(); | 290 | if (doupdate) updated(); |
285 | return true; | 291 | return true; |
286 | } | 292 | } |
287 | 293 | ||
288 | #if 0 | 294 | #if 0 |
289 | void IncidenceBase::removeAttendee(Attendee *a) | 295 | void IncidenceBase::removeAttendee(Attendee *a) |
290 | { | 296 | { |
291 | if (mReadOnly) return; | 297 | if (mReadOnly) return; |
292 | mAttendees.removeRef(a); | 298 | mAttendees.removeRef(a); |
293 | updated(); | 299 | updated(); |
294 | } | 300 | } |
295 | 301 | ||
296 | void IncidenceBase::removeAttendee(const char *n) | 302 | void IncidenceBase::removeAttendee(const char *n) |
297 | { | 303 | { |
298 | Attendee *a; | 304 | Attendee *a; |
299 | 305 | ||
300 | if (mReadOnly) return; | 306 | if (mReadOnly) return; |
301 | for (a = mAttendees.first(); a; a = mAttendees.next()) | 307 | for (a = mAttendees.first(); a; a = mAttendees.next()) |
302 | if (a->getName() == n) { | 308 | if (a->getName() == n) { |
303 | mAttendees.remove(); | 309 | mAttendees.remove(); |
304 | break; | 310 | break; |
305 | } | 311 | } |
306 | } | 312 | } |
307 | #endif | 313 | #endif |
308 | 314 | ||
309 | void IncidenceBase::clearAttendees() | 315 | void IncidenceBase::clearAttendees() |
310 | { | 316 | { |
311 | if (mReadOnly) return; | 317 | if (mReadOnly) return; |
312 | mAttendees.clear(); | 318 | mAttendees.clear(); |
313 | } | 319 | } |
314 | 320 | ||
315 | #if 0 | 321 | #if 0 |
316 | Attendee *IncidenceBase::getAttendee(const char *n) const | 322 | Attendee *IncidenceBase::getAttendee(const char *n) const |
317 | { | 323 | { |
318 | QPtrListIterator<Attendee> qli(mAttendees); | 324 | QPtrListIterator<Attendee> qli(mAttendees); |
319 | 325 | ||
320 | qli.toFirst(); | 326 | qli.toFirst(); |
321 | while (qli) { | 327 | while (qli) { |
322 | if (qli.current()->getName() == n) | 328 | if (qli.current()->getName() == n) |
323 | return qli.current(); | 329 | return qli.current(); |
324 | ++qli; | 330 | ++qli; |
325 | } | 331 | } |
326 | return 0L; | 332 | return 0L; |
327 | } | 333 | } |
328 | #endif | 334 | #endif |
329 | 335 | ||
330 | Attendee *IncidenceBase::attendeeByMail(const QString &email) | 336 | Attendee *IncidenceBase::attendeeByMail(const QString &email) |
331 | { | 337 | { |
332 | QPtrListIterator<Attendee> qli(mAttendees); | 338 | QPtrListIterator<Attendee> qli(mAttendees); |
333 | 339 | ||
334 | qli.toFirst(); | 340 | qli.toFirst(); |
335 | while (qli) { | 341 | while (qli) { |
336 | if (qli.current()->email().lower() == email.lower()) | 342 | if (qli.current()->email().lower() == email.lower()) |
337 | return qli.current(); | 343 | return qli.current(); |
338 | ++qli; | 344 | ++qli; |
339 | } | 345 | } |
340 | return 0L; | 346 | return 0L; |
341 | } | 347 | } |
342 | 348 | ||
343 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) | 349 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) |
344 | { | 350 | { |
345 | QPtrListIterator<Attendee> qli(mAttendees); | 351 | QPtrListIterator<Attendee> qli(mAttendees); |
346 | 352 | ||
347 | QStringList mails = emails; | 353 | QStringList mails = emails; |
348 | if (!email.isEmpty()) { | 354 | if (!email.isEmpty()) { |
349 | mails.append(email); | 355 | mails.append(email); |
350 | } | 356 | } |
351 | qli.toFirst(); | 357 | qli.toFirst(); |
352 | while (qli) { | 358 | while (qli) { |
353 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { | 359 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { |
354 | if (qli.current()->email().lower() == (*it).lower()) | 360 | if (qli.current()->email().lower() == (*it).lower()) |
355 | return qli.current(); | 361 | return qli.current(); |
356 | } | 362 | } |
357 | 363 | ||
358 | ++qli; | 364 | ++qli; |
359 | } | 365 | } |
360 | return 0L; | 366 | return 0L; |
361 | } | 367 | } |
362 | 368 | ||
363 | void IncidenceBase::setDuration(int seconds) | 369 | void IncidenceBase::setDuration(int seconds) |
364 | { | 370 | { |
365 | mDuration = seconds; | 371 | mDuration = seconds; |
366 | setHasDuration(true); | 372 | setHasDuration(true); |
367 | } | 373 | } |
368 | 374 | ||
369 | int IncidenceBase::duration() const | 375 | int IncidenceBase::duration() const |
370 | { | 376 | { |
371 | return mDuration; | 377 | return mDuration; |
372 | } | 378 | } |
373 | 379 | ||
374 | void IncidenceBase::setHasDuration(bool b) | 380 | void IncidenceBase::setHasDuration(bool b) |
375 | { | 381 | { |
376 | mHasDuration = b; | 382 | mHasDuration = b; |
377 | } | 383 | } |
378 | 384 | ||
379 | bool IncidenceBase::hasDuration() const | 385 | bool IncidenceBase::hasDuration() const |
380 | { | 386 | { |
381 | return mHasDuration; | 387 | return mHasDuration; |
382 | } | 388 | } |
383 | 389 | ||
384 | void IncidenceBase::setSyncStatus(int stat) | 390 | void IncidenceBase::setSyncStatus(int stat) |
385 | { | 391 | { |
386 | if (mReadOnly) return; | 392 | if (mReadOnly) return; |
387 | mSyncStatus = stat; | 393 | mSyncStatus = stat; |
388 | } | 394 | } |
389 | 395 | ||
390 | int IncidenceBase::syncStatus() const | 396 | int IncidenceBase::syncStatus() const |
391 | { | 397 | { |
392 | return mSyncStatus; | 398 | return mSyncStatus; |
393 | } | 399 | } |
394 | 400 | ||
395 | void IncidenceBase::setPilotId( int id ) | 401 | void IncidenceBase::setPilotId( int id ) |
396 | { | 402 | { |
397 | if (mReadOnly) return; | 403 | if (mReadOnly) return; |
398 | mPilotId = id; | 404 | mPilotId = id; |
399 | } | 405 | } |
400 | 406 | ||
401 | int IncidenceBase::pilotId() const | 407 | int IncidenceBase::pilotId() const |
402 | { | 408 | { |
403 | return mPilotId; | 409 | return mPilotId; |
404 | } | 410 | } |
405 | 411 | ||
406 | int IncidenceBase::tempSyncStat() const | 412 | int IncidenceBase::tempSyncStat() const |
407 | { | 413 | { |
408 | return mTempSyncStat; | 414 | return mTempSyncStat; |
409 | } | 415 | } |
410 | void IncidenceBase::setTempSyncStat( int id ) | 416 | void IncidenceBase::setTempSyncStat( int id ) |
411 | { | 417 | { |
412 | if (mReadOnly) return; | 418 | if (mReadOnly) return; |
413 | mTempSyncStat = id; | 419 | mTempSyncStat = id; |
414 | } | 420 | } |
415 | 421 | ||
416 | void IncidenceBase::removeID(const QString &prof) | 422 | void IncidenceBase::removeID(const QString &prof) |
417 | { | 423 | { |
418 | if ( prof.isEmpty() ) | 424 | if ( prof.isEmpty() ) |
419 | mExternalId = ":"; | 425 | mExternalId = ":"; |
420 | else | 426 | else |
421 | mExternalId = KIdManager::removeId ( mExternalId, prof); | 427 | mExternalId = KIdManager::removeId ( mExternalId, prof); |
422 | 428 | ||
423 | } | 429 | } |
424 | void IncidenceBase::setID( const QString & prof , const QString & id ) | 430 | void IncidenceBase::setID( const QString & prof , const QString & id ) |
425 | { | 431 | { |
426 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); | 432 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); |
427 | } | 433 | } |
428 | QString IncidenceBase::getID( const QString & prof) | 434 | QString IncidenceBase::getID( const QString & prof) |
429 | { | 435 | { |
430 | return KIdManager::getId ( mExternalId, prof ); | 436 | return KIdManager::getId ( mExternalId, prof ); |
431 | } | 437 | } |
432 | 438 | ||
433 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: | 439 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: |
434 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 | 440 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 |
435 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) | 441 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) |
436 | { | 442 | { |
437 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); | 443 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); |
438 | } | 444 | } |
439 | QString IncidenceBase::getCsum( const QString & prof) | 445 | QString IncidenceBase::getCsum( const QString & prof) |
440 | { | 446 | { |
441 | return KIdManager::getCsum ( mExternalId, prof ); | 447 | return KIdManager::getCsum ( mExternalId, prof ); |
442 | } | 448 | } |
443 | 449 | ||
444 | void IncidenceBase::setIDStr( const QString & s ) | 450 | void IncidenceBase::setIDStr( const QString & s ) |
445 | { | 451 | { |
446 | if (mReadOnly) return; | 452 | if (mReadOnly) return; |
447 | mExternalId = s; | 453 | mExternalId = s; |
448 | } | 454 | } |
449 | 455 | ||
450 | QString IncidenceBase::IDStr() const | 456 | QString IncidenceBase::IDStr() const |
451 | { | 457 | { |
452 | return mExternalId ; | 458 | return mExternalId ; |
453 | } | 459 | } |
454 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) | 460 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) |
455 | { | 461 | { |
456 | if( !mObservers.contains(observer) ) mObservers.append( observer ); | 462 | if( !mObservers.contains(observer) ) mObservers.append( observer ); |
457 | } | 463 | } |
458 | 464 | ||
459 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) | 465 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) |
460 | { | 466 | { |
461 | mObservers.remove( observer ); | 467 | mObservers.remove( observer ); |
462 | } | 468 | } |
463 | 469 | ||
464 | void IncidenceBase::updated() | 470 | void IncidenceBase::updated() |
465 | { | 471 | { |
466 | QPtrListIterator<Observer> it(mObservers); | 472 | QPtrListIterator<Observer> it(mObservers); |
467 | while( it.current() ) { | 473 | while( it.current() ) { |
468 | Observer *o = it.current(); | 474 | Observer *o = it.current(); |
469 | ++it; | 475 | ++it; |
470 | o->incidenceUpdated( this ); | 476 | o->incidenceUpdated( this ); |
471 | } | 477 | } |
472 | } | 478 | } |
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index bccf287..bed73db 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -1,185 +1,186 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef KCAL_INCIDENCEBASE_H | 20 | #ifndef KCAL_INCIDENCEBASE_H |
21 | #define KCAL_INCIDENCEBASE_H | 21 | #define KCAL_INCIDENCEBASE_H |
22 | // | 22 | // |
23 | // Incidence - base class of calendaring components | 23 | // Incidence - base class of calendaring components |
24 | // | 24 | // |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | #include <qptrlist.h> | 29 | #include <qptrlist.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "attendee.h" | 32 | #include "attendee.h" |
33 | 33 | ||
34 | namespace KCal { | 34 | namespace KCal { |
35 | 35 | ||
36 | typedef QValueList<QDate> DateList; | 36 | typedef QValueList<QDate> DateList; |
37 | enum IncTypeID { eventID,todoID,journalID,freebusyID }; | 37 | enum IncTypeID { eventID,todoID,journalID,freebusyID }; |
38 | 38 | ||
39 | /** | 39 | /** |
40 | This class provides the base class common to all calendar components. | 40 | This class provides the base class common to all calendar components. |
41 | */ | 41 | */ |
42 | class IncidenceBase : public CustomProperties | 42 | class IncidenceBase : public CustomProperties |
43 | { | 43 | { |
44 | public: | 44 | public: |
45 | class Observer { | 45 | class Observer { |
46 | public: | 46 | public: |
47 | virtual void incidenceUpdated( IncidenceBase * ) = 0; | 47 | virtual void incidenceUpdated( IncidenceBase * ) = 0; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | IncidenceBase(); | 50 | IncidenceBase(); |
51 | IncidenceBase(const IncidenceBase &); | 51 | IncidenceBase(const IncidenceBase &); |
52 | virtual ~IncidenceBase(); | 52 | virtual ~IncidenceBase(); |
53 | 53 | ||
54 | virtual QCString type() const = 0; | 54 | virtual QCString type() const = 0; |
55 | virtual IncTypeID typeID() const = 0; | 55 | virtual IncTypeID typeID() const = 0; |
56 | 56 | ||
57 | /** Set the unique id for the event */ | 57 | /** Set the unique id for the event */ |
58 | void setUid(const QString &); | 58 | void setUid(const QString &); |
59 | /** Return the unique id for the event */ | 59 | /** Return the unique id for the event */ |
60 | QString uid() const; | 60 | QString uid() const; |
61 | 61 | ||
62 | /** Sets the time the incidence was last modified. */ | 62 | /** Sets the time the incidence was last modified. */ |
63 | void setLastModified(const QDateTime &lm); | 63 | void setLastModified(const QDateTime &lm); |
64 | /** Return the time the incidence was last modified. */ | 64 | /** Return the time the incidence was last modified. */ |
65 | QDateTime lastModified() const; | 65 | QDateTime lastModified() const; |
66 | 66 | ||
67 | /** sets the organizer for the event */ | 67 | /** sets the organizer for the event */ |
68 | void setOrganizer(const QString &o); | 68 | void setOrganizer(const QString &o); |
69 | QString organizer() const; | 69 | QString organizer() const; |
70 | 70 | ||
71 | /** Set readonly status. */ | 71 | /** Set readonly status. */ |
72 | virtual void setReadOnly( bool ); | 72 | virtual void setReadOnly( bool ); |
73 | /** Return if the object is read-only. */ | 73 | /** Return if the object is read-only. */ |
74 | bool isReadOnly() const { return mReadOnly; } | 74 | bool isReadOnly() const { return mReadOnly; } |
75 | 75 | ||
76 | /** for setting the event's starting date/time with a QDateTime. */ | 76 | /** for setting the event's starting date/time with a QDateTime. */ |
77 | virtual void setDtStart(const QDateTime &dtStart); | 77 | virtual void setDtStart(const QDateTime &dtStart); |
78 | /** returns an event's starting date/time as a QDateTime. */ | 78 | /** returns an event's starting date/time as a QDateTime. */ |
79 | virtual QDateTime dtStart() const; | 79 | virtual QDateTime dtStart() const; |
80 | /** returns an event's starting time as a string formatted according to the | 80 | /** returns an event's starting time as a string formatted according to the |
81 | users locale settings */ | 81 | users locale settings */ |
82 | QString dtStartTimeStr() const; | 82 | QString dtStartTimeStr() const; |
83 | /** returns an event's starting date as a string formatted according to the | 83 | /** returns an event's starting date as a string formatted according to the |
84 | users locale settings */ | 84 | users locale settings */ |
85 | QString dtStartDateStr(bool shortfmt=true) const; | 85 | QString dtStartDateStr(bool shortfmt=true) const; |
86 | /** returns an event's starting date and time as a string formatted according | 86 | /** returns an event's starting date and time as a string formatted according |
87 | to the users locale settings */ | 87 | to the users locale settings */ |
88 | QString dtStartStr(bool shortfmt=true) const; | 88 | QString dtStartStr(bool shortfmt=true) const; |
89 | 89 | ||
90 | virtual void setDuration(int seconds); | 90 | virtual void setDuration(int seconds); |
91 | int duration() const; | 91 | int duration() const; |
92 | void setHasDuration(bool); | 92 | void setHasDuration(bool); |
93 | bool hasDuration() const; | 93 | bool hasDuration() const; |
94 | 94 | ||
95 | /** Return true or false depending on whether the incidence "floats," | 95 | /** Return true or false depending on whether the incidence "floats," |
96 | * i.e. has a date but no time attached to it. */ | 96 | * i.e. has a date but no time attached to it. */ |
97 | bool doesFloat() const; | 97 | bool doesFloat() const; |
98 | /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ | 98 | /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ |
99 | void setFloats(bool f); | 99 | void setFloats(bool f); |
100 | 100 | ||
101 | /** | 101 | /** |
102 | Add Attendee to this incidence. IncidenceBase takes ownership of the | 102 | Add Attendee to this incidence. IncidenceBase takes ownership of the |
103 | Attendee object. | 103 | Attendee object. |
104 | */ | 104 | */ |
105 | bool addAttendee(Attendee *a, bool doupdate=true ); | 105 | bool addAttendee(Attendee *a, bool doupdate=true ); |
106 | // void removeAttendee(Attendee *a); | 106 | // void removeAttendee(Attendee *a); |
107 | // void removeAttendee(const char *n); | 107 | // void removeAttendee(const char *n); |
108 | /** Remove all Attendees. */ | 108 | /** Remove all Attendees. */ |
109 | void clearAttendees(); | 109 | void clearAttendees(); |
110 | /** Return list of attendees. */ | 110 | /** Return list of attendees. */ |
111 | QPtrList<Attendee> attendees() const { return mAttendees; }; | 111 | QPtrList<Attendee> attendees() const { return mAttendees; }; |
112 | /** Return number of attendees. */ | 112 | /** Return number of attendees. */ |
113 | int attendeeCount() const { return mAttendees.count(); }; | 113 | int attendeeCount() const { return mAttendees.count(); }; |
114 | /** Return the Attendee with this email */ | 114 | /** Return the Attendee with this email */ |
115 | Attendee* attendeeByMail(const QString &); | 115 | Attendee* attendeeByMail(const QString &); |
116 | /** Return first Attendee with one of this emails */ | 116 | /** Return first Attendee with one of this emails */ |
117 | Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); | 117 | Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); |
118 | 118 | ||
119 | /** pilot syncronization states */ | 119 | /** pilot syncronization states */ |
120 | enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; | 120 | enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; |
121 | /** Set synchronisation satus. */ | 121 | /** Set synchronisation satus. */ |
122 | void setSyncStatus(int stat); | 122 | void setSyncStatus(int stat); |
123 | /** Return synchronisation status. */ | 123 | /** Return synchronisation status. */ |
124 | int syncStatus() const; | 124 | int syncStatus() const; |
125 | 125 | ||
126 | /** Set Pilot Id. */ | 126 | /** Set Pilot Id. */ |
127 | void setPilotId(int id); | 127 | void setPilotId(int id); |
128 | /** Return Pilot Id. */ | 128 | /** Return Pilot Id. */ |
129 | int pilotId() const; | 129 | int pilotId() const; |
130 | 130 | ||
131 | void setTempSyncStat(int id); | 131 | void setTempSyncStat(int id); |
132 | int tempSyncStat() const; | 132 | int tempSyncStat() const; |
133 | void setIDStr( const QString & ); | 133 | void setIDStr( const QString & ); |
134 | QString IDStr() const; | 134 | QString IDStr() const; |
135 | void setID( const QString &, const QString & ); | 135 | void setID( const QString &, const QString & ); |
136 | QString getID( const QString & ); | 136 | QString getID( const QString & ); |
137 | void setCsum( const QString &, const QString & ); | 137 | void setCsum( const QString &, const QString & ); |
138 | QString getCsum( const QString & ); | 138 | QString getCsum( const QString & ); |
139 | void removeID(const QString &); | 139 | void removeID(const QString &); |
140 | 140 | ||
141 | void registerObserver( Observer * ); | 141 | void registerObserver( Observer * ); |
142 | void unRegisterObserver( Observer * ); | 142 | void unRegisterObserver( Observer * ); |
143 | void updated(); | 143 | void updated(); |
144 | void setCalID( int id ); | 144 | void setCalID( int id ); |
145 | int calID() const; | 145 | int calID() const; |
146 | void setCalEnabled( bool ); | 146 | void setCalEnabled( bool ); |
147 | bool calEnabled() const; | 147 | bool calEnabled() const; |
148 | void setAlarmEnabled( bool ); | 148 | void setAlarmEnabled( bool ); |
149 | bool alarmEnabled() const; | 149 | bool alarmEnabled() const; |
150 | bool isTagged() const; | 150 | bool isTagged() const; |
151 | void setTagged( bool ); | 151 | void setTagged( bool ); |
152 | protected: | 152 | protected: |
153 | bool blockLastModified; | ||
153 | bool mIsTagged; | 154 | bool mIsTagged; |
154 | QDateTime mDtStart; | 155 | QDateTime mDtStart; |
155 | bool mReadOnly; | 156 | bool mReadOnly; |
156 | QDateTime getEvenTime( QDateTime ); | 157 | QDateTime getEvenTime( QDateTime ); |
157 | 158 | ||
158 | private: | 159 | private: |
159 | // base components | 160 | // base components |
160 | QString mOrganizer; | 161 | QString mOrganizer; |
161 | QString mUid; | 162 | QString mUid; |
162 | int mCalID; | 163 | int mCalID; |
163 | bool mCalEnabled; | 164 | bool mCalEnabled; |
164 | bool mAlarmEnabled; | 165 | bool mAlarmEnabled; |
165 | QDateTime mLastModified; | 166 | QDateTime mLastModified; |
166 | QPtrList<Attendee> mAttendees; | 167 | QPtrList<Attendee> mAttendees; |
167 | 168 | ||
168 | bool mFloats; | 169 | bool mFloats; |
169 | 170 | ||
170 | int mDuration; | 171 | int mDuration; |
171 | bool mHasDuration; | 172 | bool mHasDuration; |
172 | QString mExternalId; | 173 | QString mExternalId; |
173 | int mTempSyncStat; | 174 | int mTempSyncStat; |
174 | 175 | ||
175 | // PILOT SYNCHRONIZATION STUFF | 176 | // PILOT SYNCHRONIZATION STUFF |
176 | int mPilotId; // unique id for pilot sync | 177 | int mPilotId; // unique id for pilot sync |
177 | int mSyncStatus; // status (for sync) | 178 | int mSyncStatus; // status (for sync) |
178 | 179 | ||
179 | QPtrList<Observer> mObservers; | 180 | QPtrList<Observer> mObservers; |
180 | }; | 181 | }; |
181 | 182 | ||
182 | bool operator==( const IncidenceBase&, const IncidenceBase& ); | 183 | bool operator==( const IncidenceBase&, const IncidenceBase& ); |
183 | } | 184 | } |
184 | 185 | ||
185 | #endif | 186 | #endif |