author | zautrix <zautrix> | 2005-11-28 01:23:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-28 01:23:02 (UTC) |
commit | e08811c2246f63b2b63f9db6b65701344460f3d7 (patch) (unidiff) | |
tree | d450f486a9472d80eb86f605237b828a0e7ffae6 | |
parent | 854d4a0c686962cd73ac7418b5fbf4b2d73adab7 (diff) | |
download | kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.zip kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.tar.gz kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.tar.bz2 |
ync
-rw-r--r-- | korganizer/calendarview.cpp | 17 | ||||
-rw-r--r-- | libkcal/calendar.cpp | 9 | ||||
-rw-r--r-- | libkcal/calendar.h | 3 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 81 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 3 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 6 | ||||
-rw-r--r-- | libkcal/incidence.h | 1 |
7 files changed, 99 insertions, 21 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8d024c1..1800cf2 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,5258 +1,5273 @@ | |||
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) savecale1997, 1998, 1999 | 7 | Copyright (c) savecale1997, 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 | mMultiResourceSync = false; | 369 | mMultiResourceSync = false; |
370 | flag_blockConflict = false; | 370 | flag_blockConflict = false; |
371 | flag_blockScrollBar = false; | 371 | flag_blockScrollBar = false; |
372 | flag_checkFileFirsttime = true; | 372 | flag_checkFileFirsttime = true; |
373 | flag_clearallviewsEventDisplay = false; | 373 | flag_clearallviewsEventDisplay = false; |
374 | flag_clearallviewsupdateView = false; | 374 | flag_clearallviewsupdateView = false; |
375 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 375 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
376 | setFocusPolicy (NoFocus ); | 376 | setFocusPolicy (NoFocus ); |
377 | mViewerCallerIsSearchDialog = false; | 377 | mViewerCallerIsSearchDialog = false; |
378 | mBlockShowDates = false; | 378 | mBlockShowDates = false; |
379 | mConflictingEvent = 0; | 379 | mConflictingEvent = 0; |
380 | mDatePickerMode = 0; | 380 | mDatePickerMode = 0; |
381 | mCurrentSyncDevice = ""; | 381 | mCurrentSyncDevice = ""; |
382 | mViewManager = new KOViewManager( this ); | 382 | mViewManager = new KOViewManager( this ); |
383 | mDialogManager = new KODialogManager( this ); | 383 | mDialogManager = new KODialogManager( this ); |
384 | mEventViewerDialog = 0; | 384 | mEventViewerDialog = 0; |
385 | mModified = false; | 385 | mModified = false; |
386 | mReadOnly = false; | 386 | mReadOnly = false; |
387 | mSelectedIncidence = 0; | 387 | mSelectedIncidence = 0; |
388 | mCalPrinter = 0; | 388 | mCalPrinter = 0; |
389 | mFilters.setAutoDelete(true); | 389 | mFilters.setAutoDelete(true); |
390 | 390 | ||
391 | mCalendar->registerObserver( this ); | 391 | mCalendar->registerObserver( this ); |
392 | // TODO: Make sure that view is updated, when calendar is changed. | 392 | // TODO: Make sure that view is updated, when calendar is changed. |
393 | 393 | ||
394 | mStorage = new FileStorage( mCalendar ); | 394 | mStorage = new FileStorage( mCalendar ); |
395 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 395 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
396 | 396 | ||
397 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 397 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
398 | #ifndef KORG_NOSPLITTER | 398 | #ifndef KORG_NOSPLITTER |
399 | // create the main layout frames. | 399 | // create the main layout frames. |
400 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 400 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
401 | topLayout->addWidget(mPanner); | 401 | topLayout->addWidget(mPanner); |
402 | 402 | ||
403 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 403 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
404 | "CalendarView::LeftFrame"); | 404 | "CalendarView::LeftFrame"); |
405 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 405 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
406 | 406 | ||
407 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 407 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
408 | "CalendarView::DateNavigator" ); | 408 | "CalendarView::DateNavigator" ); |
409 | 409 | ||
410 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 410 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
411 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 411 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
412 | mTodoList->setNavigator( mNavigator ); | 412 | mTodoList->setNavigator( mNavigator ); |
413 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 413 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
414 | 414 | ||
415 | #ifdef KORG_NORESOURCEVIEW | 415 | #ifdef KORG_NORESOURCEVIEW |
416 | mResourceView = 0; | 416 | mResourceView = 0; |
417 | #else | 417 | #else |
418 | if ( mResourceManager ) { | 418 | if ( mResourceManager ) { |
419 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 419 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
420 | mResourceView->updateView(); | 420 | mResourceView->updateView(); |
421 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 421 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
422 | SLOT( updateView() ) ); | 422 | SLOT( updateView() ) ); |
423 | } else { | 423 | } else { |
424 | mResourceView = 0; | 424 | mResourceView = 0; |
425 | } | 425 | } |
426 | #endif | 426 | #endif |
427 | QWidget *rightBox = new QWidget( mPanner ); | 427 | QWidget *rightBox = new QWidget( mPanner ); |
428 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 428 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
429 | 429 | ||
430 | mRightFrame = new QWidgetStack( rightBox ); | 430 | mRightFrame = new QWidgetStack( rightBox ); |
431 | rightLayout->addWidget( mRightFrame, 1 ); | 431 | rightLayout->addWidget( mRightFrame, 1 ); |
432 | 432 | ||
433 | mLeftFrame = mLeftSplitter; | 433 | mLeftFrame = mLeftSplitter; |
434 | #else | 434 | #else |
435 | //QWidget *mainBox = new QWidget( this ); | 435 | //QWidget *mainBox = new QWidget( this ); |
436 | //QWidget *leftFrame = new QWidget( mainBox ); | 436 | //QWidget *leftFrame = new QWidget( mainBox ); |
437 | //QBoxLayout * mainBoxLayout; | 437 | //QBoxLayout * mainBoxLayout; |
438 | if ( KOPrefs::instance()->mVerticalScreen ) { | 438 | if ( KOPrefs::instance()->mVerticalScreen ) { |
439 | //mainBoxLayout = new QVBoxLayout(mainBox); | 439 | //mainBoxLayout = new QVBoxLayout(mainBox); |
440 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
445 | } else { | 445 | } else { |
446 | //mainBoxLayout = new QHBoxLayout(mainBox); | 446 | //mainBoxLayout = new QHBoxLayout(mainBox); |
447 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 447 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
448 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 448 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
449 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 449 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
450 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 450 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
451 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 451 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
452 | } | 452 | } |
453 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 453 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
454 | //QBoxLayout * leftFrameLayout; | 454 | //QBoxLayout * leftFrameLayout; |
455 | topLayout->addWidget( mMainFrame ); | 455 | topLayout->addWidget( mMainFrame ); |
456 | #ifdef DESKTOP_VERSION | 456 | #ifdef DESKTOP_VERSION |
457 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 457 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
458 | topLayout->addWidget( mDateScrollBar ); | 458 | topLayout->addWidget( mDateScrollBar ); |
459 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 459 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
460 | if ( QApplication::desktop()->width() < 800 ) | 460 | if ( QApplication::desktop()->width() < 800 ) |
461 | mDateScrollBar->hide(); | 461 | mDateScrollBar->hide(); |
462 | #endif | 462 | #endif |
463 | //mainBoxLayout->addWidget (mLeftFrame); | 463 | //mainBoxLayout->addWidget (mLeftFrame); |
464 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 464 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
465 | "CalendarView::DateNavigator" ); | 465 | "CalendarView::DateNavigator" ); |
466 | #if 0 | 466 | #if 0 |
467 | // FIXME | 467 | // FIXME |
468 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 468 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
469 | "CalendarView::DateNavigator", QDate::currentDate()); | 469 | "CalendarView::DateNavigator", QDate::currentDate()); |
470 | #endif | 470 | #endif |
471 | // mDateNavigator->blockSignals( true ); | 471 | // mDateNavigator->blockSignals( true ); |
472 | //leftFrameLayout->addWidget( mDateNavigator ); | 472 | //leftFrameLayout->addWidget( mDateNavigator ); |
473 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 473 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
474 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 474 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
475 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 475 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
476 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 476 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
477 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 477 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
478 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 478 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
479 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 479 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
480 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 480 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
481 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 481 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
482 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 482 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
483 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 483 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
484 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 484 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
485 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 485 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
486 | connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); | 486 | connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); |
487 | 487 | ||
488 | 488 | ||
489 | mTodoList->setNavigator( mNavigator ); | 489 | mTodoList->setNavigator( mNavigator ); |
490 | #if 0 | 490 | #if 0 |
491 | if ( QApplication::desktop()->width() < 480 ) { | 491 | if ( QApplication::desktop()->width() < 480 ) { |
492 | leftFrameLayout->addWidget(mFilterView); | 492 | leftFrameLayout->addWidget(mFilterView); |
493 | leftFrameLayout->addWidget(mTodoList, 2 ); | 493 | leftFrameLayout->addWidget(mTodoList, 2 ); |
494 | 494 | ||
495 | } else { | 495 | } else { |
496 | leftFrameLayout->addWidget(mTodoList,2 ); | 496 | leftFrameLayout->addWidget(mTodoList,2 ); |
497 | leftFrameLayout->addWidget(mFilterView ); | 497 | leftFrameLayout->addWidget(mFilterView ); |
498 | } | 498 | } |
499 | #endif | 499 | #endif |
500 | mFilterView->hide(); | 500 | mFilterView->hide(); |
501 | mCalEditView->hide(); | 501 | mCalEditView->hide(); |
502 | QWidget *rightBox = new QWidget( mMainFrame ); | 502 | QWidget *rightBox = new QWidget( mMainFrame ); |
503 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 503 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
504 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 504 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
505 | mRightFrame = new QWidgetStack( rightBox ); | 505 | mRightFrame = new QWidgetStack( rightBox ); |
506 | rightLayout->addWidget( mRightFrame, 10 ); | 506 | rightLayout->addWidget( mRightFrame, 10 ); |
507 | 507 | ||
508 | //mLeftFrame = (QWidget *)leftFrame; | 508 | //mLeftFrame = (QWidget *)leftFrame; |
509 | if ( KOPrefs::instance()->mVerticalScreen ) { | 509 | if ( KOPrefs::instance()->mVerticalScreen ) { |
510 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 510 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
511 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 511 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
512 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 512 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
513 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 513 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
514 | } else { | 514 | } else { |
515 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 515 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
516 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 516 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
517 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 517 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
518 | } | 518 | } |
519 | if ( !KOPrefs::instance()->mShowDateNavigator) | 519 | if ( !KOPrefs::instance()->mShowDateNavigator) |
520 | mDateNavigator->hide(); | 520 | mDateNavigator->hide(); |
521 | //qDebug("Calendarview Size %d %d ", width(), height()); | 521 | //qDebug("Calendarview Size %d %d ", width(), height()); |
522 | #endif | 522 | #endif |
523 | 523 | ||
524 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 524 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
525 | SLOT( showDates( const KCal::DateList & ) ) ); | 525 | SLOT( showDates( const KCal::DateList & ) ) ); |
526 | 526 | ||
527 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 527 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
528 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 528 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
529 | 529 | ||
530 | 530 | ||
531 | 531 | ||
532 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 532 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
533 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 533 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
534 | 534 | ||
535 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 535 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
536 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 536 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
537 | 537 | ||
538 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 538 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
539 | mNavigator, SLOT( selectPreviousYear() ) ); | 539 | mNavigator, SLOT( selectPreviousYear() ) ); |
540 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 540 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
541 | mNavigator, SLOT( selectNextYear() ) ); | 541 | mNavigator, SLOT( selectNextYear() ) ); |
542 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 542 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
543 | mNavigator, SLOT( selectPreviousMonth() ) ); | 543 | mNavigator, SLOT( selectPreviousMonth() ) ); |
544 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 544 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
545 | mNavigator, SLOT( selectNextMonth() ) ); | 545 | mNavigator, SLOT( selectNextMonth() ) ); |
546 | 546 | ||
547 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 547 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
548 | mNavigator, SLOT( selectPrevious() ) ); | 548 | mNavigator, SLOT( selectPrevious() ) ); |
549 | connect( mDateNavigator, SIGNAL( goNext() ), | 549 | connect( mDateNavigator, SIGNAL( goNext() ), |
550 | mNavigator, SLOT( selectNext() ) ); | 550 | mNavigator, SLOT( selectNext() ) ); |
551 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 551 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
552 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 552 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
553 | 553 | ||
554 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 554 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
555 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 555 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
556 | #if 0 | 556 | #if 0 |
557 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 557 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
558 | SLOT( incidenceAdded( Incidence *) ) ); | 558 | SLOT( incidenceAdded( Incidence *) ) ); |
559 | #endif | 559 | #endif |
560 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 560 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
561 | 561 | ||
562 | connect( this, SIGNAL( configChanged() ), | 562 | connect( this, SIGNAL( configChanged() ), |
563 | mDateNavigator, SLOT( updateConfig() ) ); | 563 | mDateNavigator, SLOT( updateConfig() ) ); |
564 | 564 | ||
565 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 565 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
566 | SLOT( newTodo() ) ); | 566 | SLOT( newTodo() ) ); |
567 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 567 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
568 | SLOT( newSubTodo( Todo * ) ) ); | 568 | SLOT( newSubTodo( Todo * ) ) ); |
569 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 569 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
570 | SLOT( editTodo( Todo * ) ) ); | 570 | SLOT( editTodo( Todo * ) ) ); |
571 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 571 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
572 | SLOT( showTodo( Todo *) ) ); | 572 | SLOT( showTodo( Todo *) ) ); |
573 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 573 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
574 | SLOT( deleteTodo( Todo *) ) ); | 574 | SLOT( deleteTodo( Todo *) ) ); |
575 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 575 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
576 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 576 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
577 | SLOT( purgeCompleted() ) ); | 577 | SLOT( purgeCompleted() ) ); |
578 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 578 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
579 | SIGNAL( todoModified( Todo *, int ) ) ); | 579 | SIGNAL( todoModified( Todo *, int ) ) ); |
580 | 580 | ||
581 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 581 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
582 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 582 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
583 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 583 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
584 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 584 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
585 | 585 | ||
586 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 586 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
587 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 587 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
588 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 588 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
589 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 589 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
590 | 590 | ||
591 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 591 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
592 | this, SLOT ( todo_unsub( Todo * ) ) ); | 592 | this, SLOT ( todo_unsub( Todo * ) ) ); |
593 | 593 | ||
594 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 594 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
595 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 595 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
596 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 596 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
597 | SLOT( updateTodo( Todo *, int ) ) ); | 597 | SLOT( updateTodo( Todo *, int ) ) ); |
598 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 598 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
599 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 599 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
600 | 600 | ||
601 | 601 | ||
602 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 602 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
603 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 603 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
604 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 604 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
605 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 605 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
606 | 606 | ||
607 | 607 | ||
608 | 608 | ||
609 | 609 | ||
610 | 610 | ||
611 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 611 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
612 | SLOT(checkClipboard())); | 612 | SLOT(checkClipboard())); |
613 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 613 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
614 | SLOT( processTodoListSelection( Incidence * ) ) ); | 614 | SLOT( processTodoListSelection( Incidence * ) ) ); |
615 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 615 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
616 | 616 | ||
617 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 617 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
618 | 618 | ||
619 | mDateFrame = new QVBox(0,0,WType_Popup); | 619 | mDateFrame = new QVBox(0,0,WType_Popup); |
620 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 620 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
621 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 621 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
622 | mDateFrame->setLineWidth(3); | 622 | mDateFrame->setLineWidth(3); |
623 | mDateFrame->hide(); | 623 | mDateFrame->hide(); |
624 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 624 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
625 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 625 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
626 | 626 | ||
627 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 627 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
628 | 628 | ||
629 | mEventEditor = mDialogManager->getEventEditor(); | 629 | mEventEditor = mDialogManager->getEventEditor(); |
630 | mTodoEditor = mDialogManager->getTodoEditor(); | 630 | mTodoEditor = mDialogManager->getTodoEditor(); |
631 | 631 | ||
632 | mFlagEditDescription = false; | 632 | mFlagEditDescription = false; |
633 | 633 | ||
634 | mSuspendTimer = new QTimer( this ); | 634 | mSuspendTimer = new QTimer( this ); |
635 | mAlarmTimer = new QTimer( this ); | 635 | mAlarmTimer = new QTimer( this ); |
636 | mRecheckAlarmTimer = new QTimer( this ); | 636 | mRecheckAlarmTimer = new QTimer( this ); |
637 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 637 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
638 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 638 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
639 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 639 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
640 | mAlarmDialog = new AlarmDialog( this ); | 640 | mAlarmDialog = new AlarmDialog( this ); |
641 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 641 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
642 | mAlarmDialog->setServerNotification( false ); | 642 | mAlarmDialog->setServerNotification( false ); |
643 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 643 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
644 | 644 | ||
645 | 645 | ||
646 | #ifndef DESKTOP_VERSION | 646 | #ifndef DESKTOP_VERSION |
647 | //US listen for arriving address resultsets | 647 | //US listen for arriving address resultsets |
648 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 648 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
649 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 649 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
650 | #endif | 650 | #endif |
651 | mDateNavigator->setCalendar( mCalendar ); | 651 | mDateNavigator->setCalendar( mCalendar ); |
652 | } | 652 | } |
653 | 653 | ||
654 | 654 | ||
655 | CalendarView::~CalendarView() | 655 | CalendarView::~CalendarView() |
656 | { | 656 | { |
657 | // kdDebug() << "~CalendarView()" << endl; | 657 | // kdDebug() << "~CalendarView()" << endl; |
658 | //qDebug("CalendarView::~CalendarView() "); | 658 | //qDebug("CalendarView::~CalendarView() "); |
659 | delete mDialogManager; | 659 | delete mDialogManager; |
660 | delete mViewManager; | 660 | delete mViewManager; |
661 | delete mStorage; | 661 | delete mStorage; |
662 | delete mDateFrame ; | 662 | delete mDateFrame ; |
663 | delete mEventViewerDialog; | 663 | delete mEventViewerDialog; |
664 | //kdDebug() << "~CalendarView() done" << endl; | 664 | //kdDebug() << "~CalendarView() done" << endl; |
665 | } | 665 | } |
666 | 666 | ||
667 | 667 | ||
668 | void CalendarView::nextConflict( bool all, bool allday ) | 668 | void CalendarView::nextConflict( bool all, bool allday ) |
669 | { | 669 | { |
670 | if ( flag_blockConflict ) return; | 670 | if ( flag_blockConflict ) return; |
671 | flag_blockConflict = true; | 671 | flag_blockConflict = true; |
672 | QPtrList<Event> testlist = mCalendar->events(); | 672 | QPtrList<Event> testlist = mCalendar->events(); |
673 | Event * test = testlist.first(); | 673 | Event * test = testlist.first(); |
674 | while ( test ) { | 674 | while ( test ) { |
675 | test->setTagged( false ); | 675 | test->setTagged( false ); |
676 | test = testlist.next(); | 676 | test = testlist.next(); |
677 | } | 677 | } |
678 | QTime st ( 0,0,0); | 678 | QTime st ( 0,0,0); |
679 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 679 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
680 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 680 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
681 | //qDebug("time %s ", st.toString().latin1()); | 681 | //qDebug("time %s ", st.toString().latin1()); |
682 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 682 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
683 | QDateTime conflict; | 683 | QDateTime conflict; |
684 | QDateTime retVal; | 684 | QDateTime retVal; |
685 | bool found = false; | 685 | bool found = false; |
686 | Event * cE = 0; | 686 | Event * cE = 0; |
687 | Event * cE2 = 0; | 687 | Event * cE2 = 0; |
688 | QPtrList<Event> testlist2 = testlist; | 688 | QPtrList<Event> testlist2 = testlist; |
689 | test = testlist.first(); | 689 | test = testlist.first(); |
690 | bool skip = false; | 690 | bool skip = false; |
691 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 691 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
692 | //QTime tm; | 692 | //QTime tm; |
693 | //tm.start(); | 693 | //tm.start(); |
694 | while ( test ) { | 694 | while ( test ) { |
695 | qApp->processEvents(); | 695 | qApp->processEvents(); |
696 | skip = false; | 696 | skip = false; |
697 | if ( !all ) skip = ( allday != test->doesFloat() ); | 697 | if ( !all ) skip = ( allday != test->doesFloat() ); |
698 | if ( !skip ) { | 698 | if ( !skip ) { |
699 | if ( found ) | 699 | if ( found ) |
700 | skip = !test->matchTime( &startDT, &conflict ); | 700 | skip = !test->matchTime( &startDT, &conflict ); |
701 | else | 701 | else |
702 | skip = !test->matchTime( &startDT, 0 ); | 702 | skip = !test->matchTime( &startDT, 0 ); |
703 | } | 703 | } |
704 | if ( !skip ) { | 704 | if ( !skip ) { |
705 | Event * test2 = testlist2.first(); | 705 | Event * test2 = testlist2.first(); |
706 | while ( test2 ) { | 706 | while ( test2 ) { |
707 | skip = test2->isTagged(); | 707 | skip = test2->isTagged(); |
708 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); | 708 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); |
709 | if ( !skip ) { | 709 | if ( !skip ) { |
710 | if ( found ) | 710 | if ( found ) |
711 | skip = !test2->matchTime( &startDT, &conflict ); | 711 | skip = !test2->matchTime( &startDT, &conflict ); |
712 | else | 712 | else |
713 | skip = !test2->matchTime( &startDT, 0 ); | 713 | skip = !test2->matchTime( &startDT, 0 ); |
714 | } | 714 | } |
715 | if ( !skip ) { | 715 | if ( !skip ) { |
716 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 716 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
717 | //qDebug("overlap "); | 717 | //qDebug("overlap "); |
718 | if ( ! found ) { | 718 | if ( ! found ) { |
719 | if ( retVal >= startDT ) { | 719 | if ( retVal >= startDT ) { |
720 | conflict = retVal; | 720 | conflict = retVal; |
721 | cE = test; | 721 | cE = test; |
722 | cE2 = test2; | 722 | cE2 = test2; |
723 | found = true; | 723 | found = true; |
724 | } | 724 | } |
725 | } else { | 725 | } else { |
726 | if ( retVal >= startDT && retVal < conflict ) { | 726 | if ( retVal >= startDT && retVal < conflict ) { |
727 | conflict = retVal; | 727 | conflict = retVal; |
728 | cE = test; | 728 | cE = test; |
729 | cE2 = test2; | 729 | cE2 = test2; |
730 | } | 730 | } |
731 | } | 731 | } |
732 | } | 732 | } |
733 | } | 733 | } |
734 | test2 = testlist2.next(); | 734 | test2 = testlist2.next(); |
735 | } | 735 | } |
736 | } | 736 | } |
737 | test->setTagged( true ); | 737 | test->setTagged( true ); |
738 | test = testlist.next(); | 738 | test = testlist.next(); |
739 | } | 739 | } |
740 | //qDebug("Search time : %d", tm.elapsed()); | 740 | //qDebug("Search time : %d", tm.elapsed()); |
741 | if ( found ) { | 741 | if ( found ) { |
742 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 742 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
743 | mViewManager->showDayView(); | 743 | mViewManager->showDayView(); |
744 | mNavigator->slotDaySelect( conflict.date() ); | 744 | mNavigator->slotDaySelect( conflict.date() ); |
745 | int hour = conflict.time().hour(); | 745 | int hour = conflict.time().hour(); |
746 | mViewManager->agendaView()->setStartHour( hour ); | 746 | mViewManager->agendaView()->setStartHour( hour ); |
747 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 747 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
748 | flag_blockConflict = false; | 748 | flag_blockConflict = false; |
749 | return; | 749 | return; |
750 | } | 750 | } |
751 | 751 | ||
752 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 752 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
753 | //qDebug("No conflict found "); | 753 | //qDebug("No conflict found "); |
754 | flag_blockConflict = false; | 754 | flag_blockConflict = false; |
755 | return; | 755 | return; |
756 | } | 756 | } |
757 | 757 | ||
758 | void CalendarView::conflictAll() | 758 | void CalendarView::conflictAll() |
759 | { | 759 | { |
760 | nextConflict ( true, true ); | 760 | nextConflict ( true, true ); |
761 | } | 761 | } |
762 | void CalendarView::conflictAllday() | 762 | void CalendarView::conflictAllday() |
763 | { | 763 | { |
764 | nextConflict ( false, true ); | 764 | nextConflict ( false, true ); |
765 | } | 765 | } |
766 | void CalendarView::conflictNotAll() | 766 | void CalendarView::conflictNotAll() |
767 | { | 767 | { |
768 | nextConflict ( false, false ); | 768 | nextConflict ( false, false ); |
769 | } | 769 | } |
770 | 770 | ||
771 | void CalendarView::setCalReadOnly( int id, bool readO ) | 771 | void CalendarView::setCalReadOnly( int id, bool readO ) |
772 | { | 772 | { |
773 | if ( readO ) { | 773 | if ( readO ) { |
774 | emit save(); | 774 | emit save(); |
775 | } | 775 | } |
776 | mCalendar->setReadOnly( id, readO ); | 776 | mCalendar->setReadOnly( id, readO ); |
777 | } | 777 | } |
778 | void CalendarView::setScrollBarStep(int val ) | 778 | void CalendarView::setScrollBarStep(int val ) |
779 | { | 779 | { |
780 | #ifdef DESKTOP_VERSION | 780 | #ifdef DESKTOP_VERSION |
781 | mDateScrollBar->setLineStep ( val ); | 781 | mDateScrollBar->setLineStep ( val ); |
782 | #else | 782 | #else |
783 | Q_UNUSED( val ); | 783 | Q_UNUSED( val ); |
784 | #endif | 784 | #endif |
785 | } | 785 | } |
786 | void CalendarView::scrollBarValue(int val ) | 786 | void CalendarView::scrollBarValue(int val ) |
787 | { | 787 | { |
788 | #ifdef DESKTOP_VERSION | 788 | #ifdef DESKTOP_VERSION |
789 | if ( QApplication::desktop()->width() < 800 ) return; | 789 | if ( QApplication::desktop()->width() < 800 ) return; |
790 | if ( flag_blockScrollBar ) return; | 790 | if ( flag_blockScrollBar ) return; |
791 | flag_blockScrollBar = true; | 791 | flag_blockScrollBar = true; |
792 | int count = mNavigator->selectedDates().count(); | 792 | int count = mNavigator->selectedDates().count(); |
793 | int day = mNavigator->selectedDates().first().dayOfYear(); | 793 | int day = mNavigator->selectedDates().first().dayOfYear(); |
794 | int stepdays = val; | 794 | int stepdays = val; |
795 | if ( mDateScrollBar->lineStep () <= count ) { | 795 | if ( mDateScrollBar->lineStep () <= count ) { |
796 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 796 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
797 | //qDebug("VAL %d ",val ); | 797 | //qDebug("VAL %d ",val ); |
798 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 798 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
799 | stepdays = day+stepdays; | 799 | stepdays = day+stepdays; |
800 | if ( stepdays < 0 ) stepdays = 0; | 800 | if ( stepdays < 0 ) stepdays = 0; |
801 | } | 801 | } |
802 | if ( stepdays == day ) { | 802 | if ( stepdays == day ) { |
803 | flag_blockScrollBar = false; | 803 | flag_blockScrollBar = false; |
804 | return; | 804 | return; |
805 | } | 805 | } |
806 | int year = mNavigator->selectedDates().first().year(); | 806 | int year = mNavigator->selectedDates().first().year(); |
807 | QDate d ( year,1,1 ); | 807 | QDate d ( year,1,1 ); |
808 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 808 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
809 | flag_blockScrollBar = false; | 809 | flag_blockScrollBar = false; |
810 | #else | 810 | #else |
811 | Q_UNUSED( val ); | 811 | Q_UNUSED( val ); |
812 | #endif | 812 | #endif |
813 | 813 | ||
814 | } | 814 | } |
815 | void CalendarView::updateView(const QDate &start, const QDate &end) | 815 | void CalendarView::updateView(const QDate &start, const QDate &end) |
816 | { | 816 | { |
817 | #ifdef DESKTOP_VERSION | 817 | #ifdef DESKTOP_VERSION |
818 | if ( ! mDateScrollBar->draggingSlider () ) { | 818 | if ( ! mDateScrollBar->draggingSlider () ) { |
819 | int dof = start.dayOfYear(); | 819 | int dof = start.dayOfYear(); |
820 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 820 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
821 | if ( dof != mDateScrollBar->value() ) { | 821 | if ( dof != mDateScrollBar->value() ) { |
822 | mDateScrollBar->blockSignals( true ); | 822 | mDateScrollBar->blockSignals( true ); |
823 | mDateScrollBar->setValue( start.dayOfYear()); | 823 | mDateScrollBar->setValue( start.dayOfYear()); |
824 | mDateScrollBar->blockSignals( false ); | 824 | mDateScrollBar->blockSignals( false ); |
825 | } | 825 | } |
826 | } | 826 | } |
827 | #endif | 827 | #endif |
828 | mTodoList->updateView(); | 828 | mTodoList->updateView(); |
829 | mViewManager->updateView(start, end); | 829 | mViewManager->updateView(start, end); |
830 | //mDateNavigator->updateView(); | 830 | //mDateNavigator->updateView(); |
831 | } | 831 | } |
832 | 832 | ||
833 | 833 | ||
834 | 834 | ||
835 | void CalendarView::checkFiles() | 835 | void CalendarView::checkFiles() |
836 | { | 836 | { |
837 | QString message; | 837 | QString message; |
838 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 838 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
839 | KopiCalendarFile * cal = calendars.first(); | 839 | KopiCalendarFile * cal = calendars.first(); |
840 | while ( cal ) { | 840 | while ( cal ) { |
841 | if ( cal->mErrorOnLoad ) { | 841 | if ( cal->mErrorOnLoad ) { |
842 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 842 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
843 | } | 843 | } |
844 | cal = calendars.next(); | 844 | cal = calendars.next(); |
845 | } | 845 | } |
846 | if ( !message.isEmpty() ) { | 846 | if ( !message.isEmpty() ) { |
847 | 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); | 847 | 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); |
848 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); | 848 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); |
849 | } | 849 | } |
850 | if ( flag_checkFileFirsttime ) { | 850 | if ( flag_checkFileFirsttime ) { |
851 | flag_checkFileFirsttime = false; | 851 | flag_checkFileFirsttime = false; |
852 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 852 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
853 | } | 853 | } |
854 | } | 854 | } |
855 | void CalendarView::checkAlarms() | 855 | void CalendarView::checkAlarms() |
856 | { | 856 | { |
857 | KConfig *config = KOGlobals::config(); | 857 | KConfig *config = KOGlobals::config(); |
858 | config->setGroup( "AppRun" ); | 858 | config->setGroup( "AppRun" ); |
859 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 859 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
860 | int daysto = dt.daysTo( QDate::currentDate() ); | 860 | int daysto = dt.daysTo( QDate::currentDate() ); |
861 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 861 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
862 | dt = dt.addDays( days ); | 862 | dt = dt.addDays( days ); |
863 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 863 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
864 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 864 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
865 | //qDebug("KO: Reading program stop %d ", secs); | 865 | //qDebug("KO: Reading program stop %d ", secs); |
866 | //secs -= ( 3600 * 24*3 ); // debug only | 866 | //secs -= ( 3600 * 24*3 ); // debug only |
867 | QDateTime latest = dt.addSecs ( secs ); | 867 | QDateTime latest = dt.addSecs ( secs ); |
868 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 868 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
869 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 869 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
870 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 870 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
871 | QPtrList<Incidence> al; | 871 | QPtrList<Incidence> al; |
872 | Incidence* inL = el.first(); | 872 | Incidence* inL = el.first(); |
873 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 873 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
874 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 874 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
875 | while ( inL ) { | 875 | while ( inL ) { |
876 | bool ok = false; | 876 | bool ok = false; |
877 | int offset = 0; | 877 | int offset = 0; |
878 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 878 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
879 | if ( ok ) { | 879 | if ( ok ) { |
880 | //qDebug("OK %s",next.toString().latin1()); | 880 | //qDebug("OK %s",next.toString().latin1()); |
881 | if ( next < cur ) { | 881 | if ( next < cur ) { |
882 | al.append( inL ); | 882 | al.append( inL ); |
883 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 883 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
884 | } | 884 | } |
885 | } | 885 | } |
886 | inL = el.next(); | 886 | inL = el.next(); |
887 | } | 887 | } |
888 | if ( al.count() ) { | 888 | if ( al.count() ) { |
889 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 889 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
890 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 890 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
891 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 891 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
892 | lay->setSpacing( 0 ); | 892 | lay->setSpacing( 0 ); |
893 | lay->setMargin( 0 ); | 893 | lay->setMargin( 0 ); |
894 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 894 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
895 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 895 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
896 | lay->addWidget( matb ); | 896 | lay->addWidget( matb ); |
897 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 897 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
898 | int wid = 210; | 898 | int wid = 210; |
899 | int x = QApplication::desktop()->width() - wid - 7; | 899 | int x = QApplication::desktop()->width() - wid - 7; |
900 | int y = QApplication::desktop()->height() - wid - 70; | 900 | int y = QApplication::desktop()->height() - wid - 70; |
901 | dia->setGeometry ( x,y,wid,wid); | 901 | dia->setGeometry ( x,y,wid,wid); |
902 | } else { | 902 | } else { |
903 | int si = 220; | 903 | int si = 220; |
904 | if ( QApplication::desktop()->width() > 470 ) | 904 | if ( QApplication::desktop()->width() > 470 ) |
905 | si = 400; | 905 | si = 400; |
906 | dia->resize(si,si/2); | 906 | dia->resize(si,si/2); |
907 | } | 907 | } |
908 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 908 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
909 | dia->show(); | 909 | dia->show(); |
910 | 910 | ||
911 | } | 911 | } |
912 | #if 0 | 912 | #if 0 |
913 | // for creating timetracker test data | 913 | // for creating timetracker test data |
914 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); | 914 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); |
915 | Todo * nt; | 915 | Todo * nt; |
916 | mCalendar->close(); | 916 | mCalendar->close(); |
917 | { | 917 | { |
918 | Todo * root1 = new Todo; | 918 | Todo * root1 = new Todo; |
919 | mCalendar->addTodo( root1 ); | 919 | mCalendar->addTodo( root1 ); |
920 | root1->setSummary( "Project1"); | 920 | root1->setSummary( "Project1"); |
921 | root1->setPriority( 1 ); | 921 | root1->setPriority( 1 ); |
922 | root1->setCategories( QString( "Cat_Pro1") ); | 922 | root1->setCategories( QString( "Cat_Pro1") ); |
923 | root1->setDescription( "This is a test description of a root Project" ); | 923 | root1->setDescription( "This is a test description of a root Project" ); |
924 | root1->setPercentComplete( 20 ); | 924 | root1->setPercentComplete( 20 ); |
925 | updateView(); | 925 | updateView(); |
926 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 926 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
927 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 927 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
928 | 928 | ||
929 | nt = new Todo; | 929 | nt = new Todo; |
930 | mCalendar->addTodo( nt ); | 930 | mCalendar->addTodo( nt ); |
931 | nt->setSummary( "Planning Project1"); | 931 | nt->setSummary( "Planning Project1"); |
932 | nt->setPriority( 1 ); | 932 | nt->setPriority( 1 ); |
933 | nt->setDescription( "This is a test description of Planning Project1" ); | 933 | nt->setDescription( "This is a test description of Planning Project1" ); |
934 | nt->setPercentComplete( 20 ); | 934 | nt->setPercentComplete( 20 ); |
935 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); | 935 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); |
936 | 936 | ||
937 | 937 | ||
938 | Todo * sub1 = nt; | 938 | Todo * sub1 = nt; |
939 | sub1->setRelatedTo( root1 ); | 939 | sub1->setRelatedTo( root1 ); |
940 | 940 | ||
941 | nt = new Todo; | 941 | nt = new Todo; |
942 | mCalendar->addTodo( nt ); | 942 | mCalendar->addTodo( nt ); |
943 | nt->setSummary( "Planning Project1: Lutz"); | 943 | nt->setSummary( "Planning Project1: Lutz"); |
944 | nt->setPriority( 1 ); | 944 | nt->setPriority( 1 ); |
945 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 945 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
946 | nt->setPercentComplete( 20 ); | 946 | nt->setPercentComplete( 20 ); |
947 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); | 947 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); |
948 | Todo * workLutz11 = nt; | 948 | Todo * workLutz11 = nt; |
949 | workLutz11->setRelatedTo( sub1 ); | 949 | workLutz11->setRelatedTo( sub1 ); |
950 | 950 | ||
951 | nt = new Todo; | 951 | nt = new Todo; |
952 | mCalendar->addTodo( nt ); | 952 | mCalendar->addTodo( nt ); |
953 | nt->setSummary( "Planning Project1: Norbert"); | 953 | nt->setSummary( "Planning Project1: Norbert"); |
954 | nt->setPriority( 1 ); | 954 | nt->setPriority( 1 ); |
955 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 955 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
956 | nt->setPercentComplete( 20 ); | 956 | nt->setPercentComplete( 20 ); |
957 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); | 957 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); |
958 | Todo * workNorbert11 = nt; | 958 | Todo * workNorbert11 = nt; |
959 | workNorbert11->setRelatedTo( sub1 ); | 959 | workNorbert11->setRelatedTo( sub1 ); |
960 | 960 | ||
961 | nt = new Todo; | 961 | nt = new Todo; |
962 | mCalendar->addTodo( nt ); | 962 | mCalendar->addTodo( nt ); |
963 | nt->setSummary( "Work on 1"); | 963 | nt->setSummary( "Work on 1"); |
964 | nt->setPriority( 1 ); | 964 | nt->setPriority( 1 ); |
965 | nt->setDescription( "This is a test description of Work Project_1" ); | 965 | nt->setDescription( "This is a test description of Work Project_1" ); |
966 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); | 966 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); |
967 | nt->setPercentComplete( 20 ); | 967 | nt->setPercentComplete( 20 ); |
968 | 968 | ||
969 | Todo * sub2 = nt; | 969 | Todo * sub2 = nt; |
970 | sub2->setRelatedTo( root1 ); | 970 | sub2->setRelatedTo( root1 ); |
971 | 971 | ||
972 | 972 | ||
973 | nt = new Todo; | 973 | nt = new Todo; |
974 | mCalendar->addTodo( nt ); | 974 | mCalendar->addTodo( nt ); |
975 | nt->setSummary( "Work on 1: Lutz"); | 975 | nt->setSummary( "Work on 1: Lutz"); |
976 | nt->setPriority( 1 ); | 976 | nt->setPriority( 1 ); |
977 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 977 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
978 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); | 978 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); |
979 | nt->setPercentComplete( 20 ); | 979 | nt->setPercentComplete( 20 ); |
980 | Todo * workLutz12 = nt; | 980 | Todo * workLutz12 = nt; |
981 | workLutz12->setRelatedTo( sub2 ); | 981 | workLutz12->setRelatedTo( sub2 ); |
982 | 982 | ||
983 | nt = new Todo; | 983 | nt = new Todo; |
984 | mCalendar->addTodo( nt ); | 984 | mCalendar->addTodo( nt ); |
985 | nt->setSummary( "Work on 1: Norbert"); | 985 | nt->setSummary( "Work on 1: Norbert"); |
986 | nt->setPriority( 1 ); | 986 | nt->setPriority( 1 ); |
987 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 987 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
988 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); | 988 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); |
989 | nt->setPercentComplete( 20 ); | 989 | nt->setPercentComplete( 20 ); |
990 | Todo * workNorbert12 = nt; | 990 | Todo * workNorbert12 = nt; |
991 | workNorbert12->setRelatedTo( sub2 ); | 991 | workNorbert12->setRelatedTo( sub2 ); |
992 | 992 | ||
993 | int secLenRunning = 7200; | 993 | int secLenRunning = 7200; |
994 | int secLenPausing = 3600 * 3; | 994 | int secLenPausing = 3600 * 3; |
995 | int dayInterval = 1; | 995 | int dayInterval = 1; |
996 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); | 996 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); |
997 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); | 997 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); |
998 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); | 998 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); |
999 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); | 999 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); |
1000 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); | 1000 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); |
1001 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); | 1001 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); |
1002 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); | 1002 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); |
1003 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); | 1003 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); |
1004 | 1004 | ||
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | { | 1007 | { |
1008 | Todo * root1 = new Todo; | 1008 | Todo * root1 = new Todo; |
1009 | mCalendar->addTodo( root1 ); | 1009 | mCalendar->addTodo( root1 ); |
1010 | root1->setSummary( "Project2"); | 1010 | root1->setSummary( "Project2"); |
1011 | root1->setPriority( 1 ); | 1011 | root1->setPriority( 1 ); |
1012 | root1->setDescription( "This is a test description of a root Project 2" ); | 1012 | root1->setDescription( "This is a test description of a root Project 2" ); |
1013 | root1->setPercentComplete( 20 ); | 1013 | root1->setPercentComplete( 20 ); |
1014 | root1->setCategories( QString( "Cat_Pro2") ); | 1014 | root1->setCategories( QString( "Cat_Pro2") ); |
1015 | updateView(); | 1015 | updateView(); |
1016 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 1016 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
1017 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 1017 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
1018 | int secLenRunning = 7200; | 1018 | int secLenRunning = 7200; |
1019 | int secLenPausing = 3600 * 3; | 1019 | int secLenPausing = 3600 * 3; |
1020 | int dayInterval = 1; | 1020 | int dayInterval = 1; |
1021 | 1021 | ||
1022 | nt = new Todo; | 1022 | nt = new Todo; |
1023 | mCalendar->addTodo( nt ); | 1023 | mCalendar->addTodo( nt ); |
1024 | nt->setSummary( "Planning Project2"); | 1024 | nt->setSummary( "Planning Project2"); |
1025 | nt->setPriority( 1 ); | 1025 | nt->setPriority( 1 ); |
1026 | nt->setDescription( "This is a test description of Planning_Project_2" ); | 1026 | nt->setDescription( "This is a test description of Planning_Project_2" ); |
1027 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); | 1027 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); |
1028 | nt->setPercentComplete( 20 ); | 1028 | nt->setPercentComplete( 20 ); |
1029 | 1029 | ||
1030 | 1030 | ||
1031 | Todo * sub1 = nt; | 1031 | Todo * sub1 = nt; |
1032 | sub1->setRelatedTo( root1 ); | 1032 | sub1->setRelatedTo( root1 ); |
1033 | 1033 | ||
1034 | nt = new Todo; | 1034 | nt = new Todo; |
1035 | mCalendar->addTodo( nt ); | 1035 | mCalendar->addTodo( nt ); |
1036 | nt->setSummary( "Planning Project2: Lutz"); | 1036 | nt->setSummary( "Planning Project2: Lutz"); |
1037 | nt->setPriority( 1 ); | 1037 | nt->setPriority( 1 ); |
1038 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1038 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1039 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); | 1039 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); |
1040 | nt->setPercentComplete( 20 ); | 1040 | nt->setPercentComplete( 20 ); |
1041 | Todo * workLutz11 = nt; | 1041 | Todo * workLutz11 = nt; |
1042 | workLutz11->setRelatedTo( sub1 ); | 1042 | workLutz11->setRelatedTo( sub1 ); |
1043 | 1043 | ||
1044 | nt = new Todo; | 1044 | nt = new Todo; |
1045 | mCalendar->addTodo( nt ); | 1045 | mCalendar->addTodo( nt ); |
1046 | nt->setSummary( "Planning Project2: Norbert"); | 1046 | nt->setSummary( "Planning Project2: Norbert"); |
1047 | nt->setPriority( 1 ); | 1047 | nt->setPriority( 1 ); |
1048 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1048 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1049 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); | 1049 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); |
1050 | nt->setPercentComplete( 20 ); | 1050 | nt->setPercentComplete( 20 ); |
1051 | Todo * workNorbert11 = nt; | 1051 | Todo * workNorbert11 = nt; |
1052 | workNorbert11->setRelatedTo( sub1 ); | 1052 | workNorbert11->setRelatedTo( sub1 ); |
1053 | 1053 | ||
1054 | nt = new Todo; | 1054 | nt = new Todo; |
1055 | mCalendar->addTodo( nt ); | 1055 | mCalendar->addTodo( nt ); |
1056 | nt->setSummary( "Work on 2"); | 1056 | nt->setSummary( "Work on 2"); |
1057 | nt->setPriority( 1 ); | 1057 | nt->setPriority( 1 ); |
1058 | nt->setDescription( "This is a test description of Work Project_2" ); | 1058 | nt->setDescription( "This is a test description of Work Project_2" ); |
1059 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); | 1059 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); |
1060 | nt->setPercentComplete( 20 ); | 1060 | nt->setPercentComplete( 20 ); |
1061 | 1061 | ||
1062 | Todo * sub2 = nt; | 1062 | Todo * sub2 = nt; |
1063 | sub2->setRelatedTo( root1 ); | 1063 | sub2->setRelatedTo( root1 ); |
1064 | 1064 | ||
1065 | 1065 | ||
1066 | nt = new Todo; | 1066 | nt = new Todo; |
1067 | mCalendar->addTodo( nt ); | 1067 | mCalendar->addTodo( nt ); |
1068 | nt->setSummary( "Work on 2: Lutz"); | 1068 | nt->setSummary( "Work on 2: Lutz"); |
1069 | nt->setPriority( 1 ); | 1069 | nt->setPriority( 1 ); |
1070 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1070 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1071 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); | 1071 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); |
1072 | nt->setPercentComplete( 20 ); | 1072 | nt->setPercentComplete( 20 ); |
1073 | Todo * workLutz12 = nt; | 1073 | Todo * workLutz12 = nt; |
1074 | workLutz12->setRelatedTo( sub2 ); | 1074 | workLutz12->setRelatedTo( sub2 ); |
1075 | 1075 | ||
1076 | nt = new Todo; | 1076 | nt = new Todo; |
1077 | mCalendar->addTodo( nt ); | 1077 | mCalendar->addTodo( nt ); |
1078 | nt->setSummary( "Work on 2: Norbert"); | 1078 | nt->setSummary( "Work on 2: Norbert"); |
1079 | nt->setPriority( 1 ); | 1079 | nt->setPriority( 1 ); |
1080 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1080 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1081 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); | 1081 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); |
1082 | nt->setPercentComplete( 20 ); | 1082 | nt->setPercentComplete( 20 ); |
1083 | Todo * workNorbert12 = nt; | 1083 | Todo * workNorbert12 = nt; |
1084 | workNorbert12->setRelatedTo( sub2 ); | 1084 | workNorbert12->setRelatedTo( sub2 ); |
1085 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); | 1085 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); |
1086 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); | 1086 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); |
1087 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); | 1087 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); |
1088 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); | 1088 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); |
1089 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); | 1089 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); |
1090 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); | 1090 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); |
1091 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); | 1091 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); |
1092 | } | 1092 | } |
1093 | updateView(); | 1093 | updateView(); |
1094 | #endif | 1094 | #endif |
1095 | 1095 | ||
1096 | } | 1096 | } |
1097 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) | 1097 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) |
1098 | { | 1098 | { |
1099 | static int ccc = 0; | 1099 | static int ccc = 0; |
1100 | ++ccc; | 1100 | ++ccc; |
1101 | QDateTime t_start = start; | 1101 | QDateTime t_start = start; |
1102 | runT->setPriority( 5 ); | 1102 | runT->setPriority( 5 ); |
1103 | runT->setPercentComplete( 0 ); | 1103 | runT->setPercentComplete( 0 ); |
1104 | int count = 0; | 1104 | int count = 0; |
1105 | int prio = 5; | 1105 | int prio = 5; |
1106 | int complete = 0; | 1106 | int complete = 0; |
1107 | while ( t_start < end ) { | 1107 | while ( t_start < end ) { |
1108 | ++count; | 1108 | ++count; |
1109 | if ( count > ccc ) { | 1109 | if ( count > ccc ) { |
1110 | count = 0; | 1110 | count = 0; |
1111 | --prio; | 1111 | --prio; |
1112 | if ( prio == 0 ) prio = 5; | 1112 | if ( prio == 0 ) prio = 5; |
1113 | complete += 20; | 1113 | complete += 20; |
1114 | if ( complete > 100 ) complete = 0; | 1114 | if ( complete > 100 ) complete = 0; |
1115 | runT->setPriority( prio ); | 1115 | runT->setPriority( prio ); |
1116 | runT->setPercentComplete( complete ); | 1116 | runT->setPercentComplete( complete ); |
1117 | } | 1117 | } |
1118 | runT->setRunning( true ); | 1118 | runT->setRunning( true ); |
1119 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); | 1119 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); |
1120 | if ( dayInterval ) | 1120 | if ( dayInterval ) |
1121 | t_start = t_start.addDays( dayInterval ); | 1121 | t_start = t_start.addDays( dayInterval ); |
1122 | else { | 1122 | else { |
1123 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); | 1123 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); |
1124 | } | 1124 | } |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | void CalendarView::showDay( QDate d ) | 1128 | void CalendarView::showDay( QDate d ) |
1129 | { | 1129 | { |
1130 | dateNavigator()->blockSignals( true ); | 1130 | dateNavigator()->blockSignals( true ); |
1131 | dateNavigator()->selectDate( d ); | 1131 | dateNavigator()->selectDate( d ); |
1132 | dateNavigator()->blockSignals( false ); | 1132 | dateNavigator()->blockSignals( false ); |
1133 | mViewManager->showDayView(); | 1133 | mViewManager->showDayView(); |
1134 | //dateNavigator()->selectDate( d ); | 1134 | //dateNavigator()->selectDate( d ); |
1135 | } | 1135 | } |
1136 | void CalendarView::timerAlarm() | 1136 | void CalendarView::timerAlarm() |
1137 | { | 1137 | { |
1138 | //qDebug("CalendarView::timerAlarm() "); | 1138 | //qDebug("CalendarView::timerAlarm() "); |
1139 | computeAlarm(mAlarmNotification ); | 1139 | computeAlarm(mAlarmNotification ); |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | void CalendarView::suspendAlarm() | 1142 | void CalendarView::suspendAlarm() |
1143 | { | 1143 | { |
1144 | //qDebug(" CalendarView::suspendAlarm() "); | 1144 | //qDebug(" CalendarView::suspendAlarm() "); |
1145 | computeAlarm(mSuspendAlarmNotification ); | 1145 | computeAlarm(mSuspendAlarmNotification ); |
1146 | 1146 | ||
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | void CalendarView::startAlarm( QString mess , QString filename) | 1149 | void CalendarView::startAlarm( QString mess , QString filename) |
1150 | { | 1150 | { |
1151 | 1151 | ||
1152 | topLevelWidget()->showNormal(); | 1152 | topLevelWidget()->showNormal(); |
1153 | topLevelWidget()->setActiveWindow(); | 1153 | topLevelWidget()->setActiveWindow(); |
1154 | topLevelWidget()->raise(); | 1154 | topLevelWidget()->raise(); |
1155 | 1155 | ||
1156 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 1156 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
1157 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 1157 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
1158 | 1158 | ||
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | void CalendarView::checkNextTimerAlarm() | 1161 | void CalendarView::checkNextTimerAlarm() |
1162 | { | 1162 | { |
1163 | mCalendar->checkAlarmForIncidence( 0, true ); | 1163 | mCalendar->checkAlarmForIncidence( 0, true ); |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | void CalendarView::computeAlarm( QString msg ) | 1166 | void CalendarView::computeAlarm( QString msg ) |
1167 | { | 1167 | { |
1168 | 1168 | ||
1169 | QString mess = msg; | 1169 | QString mess = msg; |
1170 | QString mAlarmMessage = mess.mid( 9 ); | 1170 | QString mAlarmMessage = mess.mid( 9 ); |
1171 | QString filename = MainWindow::resourcePath(); | 1171 | QString filename = MainWindow::resourcePath(); |
1172 | filename += "koalarm.wav"; | 1172 | filename += "koalarm.wav"; |
1173 | QString tempfilename; | 1173 | QString tempfilename; |
1174 | if ( mess.left( 13 ) == "suspend_alarm") { | 1174 | if ( mess.left( 13 ) == "suspend_alarm") { |
1175 | bool error = false; | 1175 | bool error = false; |
1176 | int len = mess.mid( 13 ).find("+++"); | 1176 | int len = mess.mid( 13 ).find("+++"); |
1177 | if ( len < 2 ) | 1177 | if ( len < 2 ) |
1178 | error = true; | 1178 | error = true; |
1179 | else { | 1179 | else { |
1180 | tempfilename = mess.mid( 13, len ); | 1180 | tempfilename = mess.mid( 13, len ); |
1181 | if ( !QFile::exists( tempfilename ) ) | 1181 | if ( !QFile::exists( tempfilename ) ) |
1182 | error = true; | 1182 | error = true; |
1183 | } | 1183 | } |
1184 | if ( ! error ) { | 1184 | if ( ! error ) { |
1185 | filename = tempfilename; | 1185 | filename = tempfilename; |
1186 | } | 1186 | } |
1187 | mAlarmMessage = mess.mid( 13+len+3 ); | 1187 | mAlarmMessage = mess.mid( 13+len+3 ); |
1188 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 1188 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
1189 | startAlarm( mAlarmMessage, filename); | 1189 | startAlarm( mAlarmMessage, filename); |
1190 | return; | 1190 | return; |
1191 | } | 1191 | } |
1192 | if ( mess.left( 11 ) == "timer_alarm") { | 1192 | if ( mess.left( 11 ) == "timer_alarm") { |
1193 | //mTimerTime = 0; | 1193 | //mTimerTime = 0; |
1194 | startAlarm( mess.mid( 11 ), filename ); | 1194 | startAlarm( mess.mid( 11 ), filename ); |
1195 | return; | 1195 | return; |
1196 | } | 1196 | } |
1197 | if ( mess.left( 10 ) == "proc_alarm") { | 1197 | if ( mess.left( 10 ) == "proc_alarm") { |
1198 | bool error = false; | 1198 | bool error = false; |
1199 | int len = mess.mid( 10 ).find("+++"); | 1199 | int len = mess.mid( 10 ).find("+++"); |
1200 | if ( len < 2 ) | 1200 | if ( len < 2 ) |
1201 | error = true; | 1201 | error = true; |
1202 | else { | 1202 | else { |
1203 | tempfilename = mess.mid( 10, len ); | 1203 | tempfilename = mess.mid( 10, len ); |
1204 | if ( !QFile::exists( tempfilename ) ) | 1204 | if ( !QFile::exists( tempfilename ) ) |
1205 | error = true; | 1205 | error = true; |
1206 | } | 1206 | } |
1207 | if ( error ) { | 1207 | if ( error ) { |
1208 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 1208 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1209 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 1209 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1210 | } else { | 1210 | } else { |
1211 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 1211 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1212 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 1212 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1213 | #ifndef _WIN32_ | 1213 | #ifndef _WIN32_ |
1214 | if ( vfork () == 0 ) { | 1214 | if ( vfork () == 0 ) { |
1215 | execl ( tempfilename.latin1(), 0 ); | 1215 | execl ( tempfilename.latin1(), 0 ); |
1216 | return; | 1216 | return; |
1217 | } | 1217 | } |
1218 | #else | 1218 | #else |
1219 | QProcess* p = new QProcess(); | 1219 | QProcess* p = new QProcess(); |
1220 | p->addArgument( tempfilename.latin1() ); | 1220 | p->addArgument( tempfilename.latin1() ); |
1221 | p->start(); | 1221 | p->start(); |
1222 | return; | 1222 | return; |
1223 | #endif | 1223 | #endif |
1224 | 1224 | ||
1225 | return; | 1225 | return; |
1226 | } | 1226 | } |
1227 | 1227 | ||
1228 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1228 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1229 | } | 1229 | } |
1230 | if ( mess.left( 11 ) == "audio_alarm") { | 1230 | if ( mess.left( 11 ) == "audio_alarm") { |
1231 | bool error = false; | 1231 | bool error = false; |
1232 | int len = mess.mid( 11 ).find("+++"); | 1232 | int len = mess.mid( 11 ).find("+++"); |
1233 | if ( len < 2 ) | 1233 | if ( len < 2 ) |
1234 | error = true; | 1234 | error = true; |
1235 | else { | 1235 | else { |
1236 | tempfilename = mess.mid( 11, len ); | 1236 | tempfilename = mess.mid( 11, len ); |
1237 | if ( !QFile::exists( tempfilename ) ) | 1237 | if ( !QFile::exists( tempfilename ) ) |
1238 | error = true; | 1238 | error = true; |
1239 | } | 1239 | } |
1240 | if ( ! error ) { | 1240 | if ( ! error ) { |
1241 | filename = tempfilename; | 1241 | filename = tempfilename; |
1242 | } | 1242 | } |
1243 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1243 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1244 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1244 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1245 | } | 1245 | } |
1246 | if ( mess.left( 9 ) == "cal_alarm") { | 1246 | if ( mess.left( 9 ) == "cal_alarm") { |
1247 | mAlarmMessage = mess.mid( 9 ) ; | 1247 | mAlarmMessage = mess.mid( 9 ) ; |
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | startAlarm( mAlarmMessage, filename ); | 1250 | startAlarm( mAlarmMessage, filename ); |
1251 | 1251 | ||
1252 | 1252 | ||
1253 | } | 1253 | } |
1254 | 1254 | ||
1255 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1255 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1256 | { | 1256 | { |
1257 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1257 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1258 | 1258 | ||
1259 | mSuspendAlarmNotification = noti; | 1259 | mSuspendAlarmNotification = noti; |
1260 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1260 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1261 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1261 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1262 | mSuspendTimer->start( ms , true ); | 1262 | mSuspendTimer->start( ms , true ); |
1263 | #ifdef DESKTOP_VERSION | 1263 | #ifdef DESKTOP_VERSION |
1264 | if ( QApplication::desktop()->width() < 1024 ) { | 1264 | if ( QApplication::desktop()->width() < 1024 ) { |
1265 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1265 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1266 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); | 1266 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); |
1267 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; | 1267 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; |
1268 | QFile file( fn ); | 1268 | QFile file( fn ); |
1269 | if (!file.open( IO_WriteOnly ) ) { | 1269 | if (!file.open( IO_WriteOnly ) ) { |
1270 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1270 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1271 | } else { | 1271 | } else { |
1272 | QTextStream ts( &file ); | 1272 | QTextStream ts( &file ); |
1273 | ts << mess; | 1273 | ts << mess; |
1274 | file.close(); | 1274 | file.close(); |
1275 | } | 1275 | } |
1276 | } | 1276 | } |
1277 | #endif | 1277 | #endif |
1278 | 1278 | ||
1279 | } | 1279 | } |
1280 | 1280 | ||
1281 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1281 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1282 | { | 1282 | { |
1283 | mNextAlarmDateTime = qdt; | 1283 | mNextAlarmDateTime = qdt; |
1284 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1284 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1285 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1285 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1286 | #ifndef DESKTOP_VERSION | 1286 | #ifndef DESKTOP_VERSION |
1287 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1287 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1288 | #endif | 1288 | #endif |
1289 | return; | 1289 | return; |
1290 | } | 1290 | } |
1291 | #ifdef DESKTOP_VERSION | 1291 | #ifdef DESKTOP_VERSION |
1292 | if ( QApplication::desktop()->width() < 1024 ) { | 1292 | if ( QApplication::desktop()->width() < 1024 ) { |
1293 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1293 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1294 | //qDebug("nextalarm = \n%s ",mess.latin1() ); | 1294 | //qDebug("nextalarm = \n%s ",mess.latin1() ); |
1295 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; | 1295 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; |
1296 | QFile file( fn ); | 1296 | QFile file( fn ); |
1297 | if (!file.open( IO_WriteOnly ) ) { | 1297 | if (!file.open( IO_WriteOnly ) ) { |
1298 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1298 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1299 | } else { | 1299 | } else { |
1300 | QTextStream ts( &file ); | 1300 | QTextStream ts( &file ); |
1301 | ts << mess; | 1301 | ts << mess; |
1302 | file.close(); | 1302 | file.close(); |
1303 | } | 1303 | } |
1304 | } | 1304 | } |
1305 | #endif | 1305 | #endif |
1306 | int maxSec; | 1306 | int maxSec; |
1307 | //maxSec = 5; //testing only | 1307 | //maxSec = 5; //testing only |
1308 | maxSec = 86400+3600; // one day+1hour | 1308 | maxSec = 86400+3600; // one day+1hour |
1309 | mAlarmNotification = noti; | 1309 | mAlarmNotification = noti; |
1310 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1310 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1311 | if ( sec > maxSec ) { | 1311 | if ( sec > maxSec ) { |
1312 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1312 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1313 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1313 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1314 | return; | 1314 | return; |
1315 | } else { | 1315 | } else { |
1316 | mRecheckAlarmTimer->stop(); | 1316 | mRecheckAlarmTimer->stop(); |
1317 | } | 1317 | } |
1318 | //qDebug("Alarm timer started with secs: %d ", sec); | 1318 | //qDebug("Alarm timer started with secs: %d ", sec); |
1319 | mAlarmTimer->start( sec * 1000 , true ); | 1319 | mAlarmTimer->start( sec * 1000 , true ); |
1320 | 1320 | ||
1321 | } | 1321 | } |
1322 | // called by mRecheckAlarmTimer to get next alarm | 1322 | // called by mRecheckAlarmTimer to get next alarm |
1323 | // we need this, because a QTimer has only a max range of 25 days | 1323 | // we need this, because a QTimer has only a max range of 25 days |
1324 | void CalendarView::recheckTimerAlarm() | 1324 | void CalendarView::recheckTimerAlarm() |
1325 | { | 1325 | { |
1326 | mAlarmTimer->stop(); | 1326 | mAlarmTimer->stop(); |
1327 | mRecheckAlarmTimer->stop(); | 1327 | mRecheckAlarmTimer->stop(); |
1328 | mCalendar->checkAlarmForIncidence( 0, true ); | 1328 | mCalendar->checkAlarmForIncidence( 0, true ); |
1329 | } | 1329 | } |
1330 | #ifndef DESKTOP_VERSION | 1330 | #ifndef DESKTOP_VERSION |
1331 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1331 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1332 | #else | 1332 | #else |
1333 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1333 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1334 | #endif | 1334 | #endif |
1335 | { | 1335 | { |
1336 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1336 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1337 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1337 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1338 | #ifndef DESKTOP_VERSION | 1338 | #ifndef DESKTOP_VERSION |
1339 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1339 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1340 | #endif | 1340 | #endif |
1341 | return; | 1341 | return; |
1342 | } | 1342 | } |
1343 | mAlarmTimer->stop(); | 1343 | mAlarmTimer->stop(); |
1344 | } | 1344 | } |
1345 | void CalendarView::selectWeekNum ( int num ) | 1345 | void CalendarView::selectWeekNum ( int num ) |
1346 | { | 1346 | { |
1347 | dateNavigator()->blockSignals( true ); | 1347 | dateNavigator()->blockSignals( true ); |
1348 | dateNavigator()->selectWeek( num ); | 1348 | dateNavigator()->selectWeek( num ); |
1349 | dateNavigator()->blockSignals( false ); | 1349 | dateNavigator()->blockSignals( false ); |
1350 | mViewManager->showWeekView(); | 1350 | mViewManager->showWeekView(); |
1351 | } | 1351 | } |
1352 | KOViewManager *CalendarView::viewManager() | 1352 | KOViewManager *CalendarView::viewManager() |
1353 | { | 1353 | { |
1354 | return mViewManager; | 1354 | return mViewManager; |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | KODialogManager *CalendarView::dialogManager() | 1357 | KODialogManager *CalendarView::dialogManager() |
1358 | { | 1358 | { |
1359 | return mDialogManager; | 1359 | return mDialogManager; |
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | QDate CalendarView::startDate() | 1362 | QDate CalendarView::startDate() |
1363 | { | 1363 | { |
1364 | DateList dates = mNavigator->selectedDates(); | 1364 | DateList dates = mNavigator->selectedDates(); |
1365 | 1365 | ||
1366 | return dates.first(); | 1366 | return dates.first(); |
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | QDate CalendarView::endDate() | 1369 | QDate CalendarView::endDate() |
1370 | { | 1370 | { |
1371 | DateList dates = mNavigator->selectedDates(); | 1371 | DateList dates = mNavigator->selectedDates(); |
1372 | 1372 | ||
1373 | return dates.last(); | 1373 | return dates.last(); |
1374 | } | 1374 | } |
1375 | 1375 | ||
1376 | 1376 | ||
1377 | void CalendarView::createPrinter() | 1377 | void CalendarView::createPrinter() |
1378 | { | 1378 | { |
1379 | #ifndef KORG_NOPRINTER | 1379 | #ifndef KORG_NOPRINTER |
1380 | if (!mCalPrinter) { | 1380 | if (!mCalPrinter) { |
1381 | mCalPrinter = new CalPrinter(this, mCalendar); | 1381 | mCalPrinter = new CalPrinter(this, mCalendar); |
1382 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1382 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1383 | } | 1383 | } |
1384 | #endif | 1384 | #endif |
1385 | } | 1385 | } |
1386 | 1386 | ||
1387 | 1387 | ||
1388 | //KOPrefs::instance()->mWriteBackFile | 1388 | //KOPrefs::instance()->mWriteBackFile |
1389 | //KOPrefs::instance()->mWriteBackExistingOnly | 1389 | //KOPrefs::instance()->mWriteBackExistingOnly |
1390 | 1390 | ||
1391 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1391 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1392 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1392 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1393 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1393 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1394 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1394 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1395 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1395 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1396 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1396 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1397 | 1397 | ||
1398 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1398 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1399 | { | 1399 | { |
1400 | 1400 | ||
1401 | // 0 equal | 1401 | // 0 equal |
1402 | // 1 take local | 1402 | // 1 take local |
1403 | // 2 take remote | 1403 | // 2 take remote |
1404 | // 3 cancel | 1404 | // 3 cancel |
1405 | QDateTime lastSync = mLastCalendarSync; | 1405 | QDateTime lastSync = mLastCalendarSync; |
1406 | QDateTime localMod = local->lastModified(); | 1406 | QDateTime localMod = local->lastModified(); |
1407 | QDateTime remoteMod = remote->lastModified(); | 1407 | QDateTime remoteMod = remote->lastModified(); |
1408 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1408 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1409 | bool remCh, locCh; | 1409 | bool remCh, locCh; |
1410 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1410 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1411 | //if ( remCh ) | 1411 | //if ( remCh ) |
1412 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1412 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1413 | locCh = ( localMod > mLastCalendarSync ); | 1413 | locCh = ( localMod > mLastCalendarSync ); |
1414 | if ( !remCh && ! locCh ) { | 1414 | if ( !remCh && ! locCh ) { |
1415 | //qDebug("both not changed "); | 1415 | //qDebug("both not changed "); |
1416 | lastSync = localMod.addDays(1); | 1416 | lastSync = localMod.addDays(1); |
1417 | if ( mode <= SYNC_PREF_ASK ) | 1417 | if ( mode <= SYNC_PREF_ASK ) |
1418 | return 0; | 1418 | return 0; |
1419 | } else { | 1419 | } else { |
1420 | if ( locCh ) { | 1420 | if ( locCh ) { |
1421 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1421 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1422 | lastSync = localMod.addDays( -1 ); | 1422 | lastSync = localMod.addDays( -1 ); |
1423 | if ( !remCh ) | 1423 | if ( !remCh ) |
1424 | remoteMod = ( lastSync.addDays( -1 ) ); | 1424 | remoteMod = ( lastSync.addDays( -1 ) ); |
1425 | } else { | 1425 | } else { |
1426 | //qDebug(" not loc changed "); | 1426 | //qDebug(" not loc changed "); |
1427 | lastSync = localMod.addDays( 1 ); | 1427 | lastSync = localMod.addDays( 1 ); |
1428 | if ( remCh ) | 1428 | if ( remCh ) |
1429 | remoteMod =( lastSync.addDays( 1 ) ); | 1429 | remoteMod =( lastSync.addDays( 1 ) ); |
1430 | 1430 | ||
1431 | } | 1431 | } |
1432 | } | 1432 | } |
1433 | full = true; | 1433 | full = true; |
1434 | if ( mode < SYNC_PREF_ASK ) | 1434 | if ( mode < SYNC_PREF_ASK ) |
1435 | mode = SYNC_PREF_ASK; | 1435 | mode = SYNC_PREF_ASK; |
1436 | } else { | 1436 | } else { |
1437 | if ( localMod == remoteMod ) | 1437 | if ( localMod == remoteMod ) |
1438 | // if ( local->revision() == remote->revision() ) | 1438 | // if ( local->revision() == remote->revision() ) |
1439 | return 0; | 1439 | return 0; |
1440 | 1440 | ||
1441 | } | 1441 | } |
1442 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1442 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1443 | 1443 | ||
1444 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1444 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1445 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1445 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1446 | //full = true; //debug only | 1446 | //full = true; //debug only |
1447 | if ( full ) { | 1447 | if ( full ) { |
1448 | bool equ = false; | 1448 | bool equ = false; |
1449 | if ( local->typeID() == eventID ) { | 1449 | if ( local->typeID() == eventID ) { |
1450 | equ = (*((Event*) local) == *((Event*) remote)); | 1450 | equ = (*((Event*) local) == *((Event*) remote)); |
1451 | } | 1451 | } |
1452 | else if ( local->typeID() == todoID ) | 1452 | else if ( local->typeID() == todoID ) |
1453 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1453 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1454 | else if ( local->typeID() == journalID ) | 1454 | else if ( local->typeID() == journalID ) |
1455 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1455 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1456 | if ( equ ) { | 1456 | if ( equ ) { |
1457 | //qDebug("equal "); | 1457 | //qDebug("equal "); |
1458 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1458 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1459 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1459 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1460 | } | 1460 | } |
1461 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1461 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1462 | return 0; | 1462 | return 0; |
1463 | 1463 | ||
1464 | }//else //debug only | 1464 | }//else //debug only |
1465 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1465 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1466 | } | 1466 | } |
1467 | int result; | 1467 | int result; |
1468 | bool localIsNew; | 1468 | bool localIsNew; |
1469 | //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() ); | 1469 | //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() ); |
1470 | 1470 | ||
1471 | 1471 | ||
1472 | // ************************************************ | 1472 | // ************************************************ |
1473 | // ************************************************ | 1473 | // ************************************************ |
1474 | // ************************************************ | 1474 | // ************************************************ |
1475 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1475 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1476 | // BUT remoteMod != localMod | 1476 | // BUT remoteMod != localMod |
1477 | 1477 | ||
1478 | 1478 | ||
1479 | if ( full && mode < SYNC_PREF_NEWEST ) | 1479 | if ( full && mode < SYNC_PREF_NEWEST ) |
1480 | mode = SYNC_PREF_ASK; | 1480 | mode = SYNC_PREF_ASK; |
1481 | 1481 | ||
1482 | switch( mode ) { | 1482 | switch( mode ) { |
1483 | case SYNC_PREF_LOCAL: | 1483 | case SYNC_PREF_LOCAL: |
1484 | if ( lastSync > remoteMod ) | 1484 | if ( lastSync > remoteMod ) |
1485 | return 1; | 1485 | return 1; |
1486 | if ( lastSync > localMod ) | 1486 | if ( lastSync > localMod ) |
1487 | return 2; | 1487 | return 2; |
1488 | return 1; | 1488 | return 1; |
1489 | break; | 1489 | break; |
1490 | case SYNC_PREF_REMOTE: | 1490 | case SYNC_PREF_REMOTE: |
1491 | if ( lastSync > localMod ) | 1491 | if ( lastSync > localMod ) |
1492 | return 2; | 1492 | return 2; |
1493 | if ( lastSync > remoteMod ) | 1493 | if ( lastSync > remoteMod ) |
1494 | return 1; | 1494 | return 1; |
1495 | return 2; | 1495 | return 2; |
1496 | break; | 1496 | break; |
1497 | case SYNC_PREF_NEWEST: | 1497 | case SYNC_PREF_NEWEST: |
1498 | if ( localMod >= remoteMod ) | 1498 | if ( localMod >= remoteMod ) |
1499 | return 1; | 1499 | return 1; |
1500 | else | 1500 | else |
1501 | return 2; | 1501 | return 2; |
1502 | break; | 1502 | break; |
1503 | case SYNC_PREF_ASK: | 1503 | case SYNC_PREF_ASK: |
1504 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1504 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1505 | if ( lastSync > remoteMod && lastSync > localMod) | 1505 | if ( lastSync > remoteMod && lastSync > localMod) |
1506 | return 0; | 1506 | return 0; |
1507 | if ( lastSync > remoteMod ) | 1507 | if ( lastSync > remoteMod ) |
1508 | return 1; | 1508 | return 1; |
1509 | if ( lastSync > localMod ) | 1509 | if ( lastSync > localMod ) |
1510 | return 2; | 1510 | return 2; |
1511 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1511 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1512 | localIsNew = localMod >= remoteMod; | 1512 | localIsNew = localMod >= remoteMod; |
1513 | if ( localIsNew ) | 1513 | if ( localIsNew ) |
1514 | getEventViewerDialog()->setColorMode( 1 ); | 1514 | getEventViewerDialog()->setColorMode( 1 ); |
1515 | else | 1515 | else |
1516 | getEventViewerDialog()->setColorMode( 2 ); | 1516 | getEventViewerDialog()->setColorMode( 2 ); |
1517 | getEventViewerDialog()->setIncidence(local); | 1517 | getEventViewerDialog()->setIncidence(local); |
1518 | if ( localIsNew ) | 1518 | if ( localIsNew ) |
1519 | getEventViewerDialog()->setColorMode( 2 ); | 1519 | getEventViewerDialog()->setColorMode( 2 ); |
1520 | else | 1520 | else |
1521 | getEventViewerDialog()->setColorMode( 1 ); | 1521 | getEventViewerDialog()->setColorMode( 1 ); |
1522 | getEventViewerDialog()->addIncidence(remote); | 1522 | getEventViewerDialog()->addIncidence(remote); |
1523 | getEventViewerDialog()->setColorMode( 0 ); | 1523 | getEventViewerDialog()->setColorMode( 0 ); |
1524 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1524 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1525 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1525 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1526 | getEventViewerDialog()->showMe(); | 1526 | getEventViewerDialog()->showMe(); |
1527 | result = getEventViewerDialog()->executeS( localIsNew ); | 1527 | result = getEventViewerDialog()->executeS( localIsNew ); |
1528 | return result; | 1528 | return result; |
1529 | 1529 | ||
1530 | break; | 1530 | break; |
1531 | case SYNC_PREF_FORCE_LOCAL: | 1531 | case SYNC_PREF_FORCE_LOCAL: |
1532 | return 1; | 1532 | return 1; |
1533 | break; | 1533 | break; |
1534 | case SYNC_PREF_FORCE_REMOTE: | 1534 | case SYNC_PREF_FORCE_REMOTE: |
1535 | return 2; | 1535 | return 2; |
1536 | break; | 1536 | break; |
1537 | 1537 | ||
1538 | default: | 1538 | default: |
1539 | // SYNC_PREF_TAKE_BOTH not implemented | 1539 | // SYNC_PREF_TAKE_BOTH not implemented |
1540 | break; | 1540 | break; |
1541 | } | 1541 | } |
1542 | return 0; | 1542 | return 0; |
1543 | } | 1543 | } |
1544 | Event* CalendarView::getLastSyncEvent() | 1544 | Event* CalendarView::getLastSyncEvent() |
1545 | { | 1545 | { |
1546 | Event* lse; | 1546 | Event* lse; |
1547 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1547 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1548 | mCalendar->setSyncEventsEnabled(); | 1548 | mCalendar->setSyncEventsEnabled(); |
1549 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1549 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1550 | if (!lse) { | 1550 | if (!lse) { |
1551 | qDebug("KO: New last Syncevent created for local: %s",mCurrentSyncDevice.latin1() ); | 1551 | qDebug("KO: New last Syncevent created for local: %s",mCurrentSyncDevice.latin1() ); |
1552 | lse = new Event(); | 1552 | lse = new Event(); |
1553 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1553 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1554 | QString sum = ""; | 1554 | QString sum = ""; |
1555 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1555 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1556 | sum = "E: "; | 1556 | sum = "E: "; |
1557 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1557 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1558 | lse->setDtStart( mLastCalendarSync ); | 1558 | lse->setDtStart( mLastCalendarSync ); |
1559 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1559 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1560 | lse->setCategories( i18n("SyncEvent") ); | 1560 | lse->setCategories( i18n("SyncEvent") ); |
1561 | lse->setReadOnly( true ); | 1561 | lse->setReadOnly( true ); |
1562 | lse->setCalID( 1 ); | 1562 | lse->setCalID( 1 ); |
1563 | mCalendar->addEvent( lse ); | 1563 | mCalendar->addEvent( lse ); |
1564 | } else | 1564 | } else |
1565 | qDebug("KO: Last Syncevent on local found"); | 1565 | qDebug("KO: Last Syncevent on local found"); |
1566 | 1566 | ||
1567 | return lse; | 1567 | return lse; |
1568 | 1568 | ||
1569 | } | 1569 | } |
1570 | 1570 | ||
1571 | // we check, if the to delete event has a id for a profile | 1571 | // we check, if the to delete event has a id for a profile |
1572 | // if yes, we set this id in the profile to delete | 1572 | // if yes, we set this id in the profile to delete |
1573 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1573 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1574 | { | 1574 | { |
1575 | if ( lastSync.count() == 0 ) { | 1575 | if ( lastSync.count() == 0 ) { |
1576 | //qDebug(" lastSync.count() == 0"); | 1576 | //qDebug(" lastSync.count() == 0"); |
1577 | return; | 1577 | return; |
1578 | } | 1578 | } |
1579 | if ( toDelete->typeID() == journalID ) | 1579 | if ( toDelete->typeID() == journalID ) |
1580 | return; | 1580 | return; |
1581 | 1581 | ||
1582 | Event* eve = lastSync.first(); | 1582 | Event* eve = lastSync.first(); |
1583 | 1583 | ||
1584 | while ( eve ) { | 1584 | while ( eve ) { |
1585 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1585 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1586 | if ( !id.isEmpty() ) { | 1586 | if ( !id.isEmpty() ) { |
1587 | QString des = eve->description(); | 1587 | QString des = eve->description(); |
1588 | QString pref = "e"; | 1588 | QString pref = "e"; |
1589 | if ( toDelete->typeID() == todoID ) | 1589 | if ( toDelete->typeID() == todoID ) |
1590 | pref = "t"; | 1590 | pref = "t"; |
1591 | des += pref+ id + ","; | 1591 | des += pref+ id + ","; |
1592 | eve->setReadOnly( false ); | 1592 | eve->setReadOnly( false ); |
1593 | eve->setDescription( des ); | 1593 | eve->setDescription( des ); |
1594 | //qDebug("setdes %s ", des.latin1()); | 1594 | //qDebug("setdes %s ", des.latin1()); |
1595 | eve->setReadOnly( true ); | 1595 | eve->setReadOnly( true ); |
1596 | } | 1596 | } |
1597 | eve = lastSync.next(); | 1597 | eve = lastSync.next(); |
1598 | } | 1598 | } |
1599 | 1599 | ||
1600 | } | 1600 | } |
1601 | void CalendarView::checkExternalId( Incidence * inc ) | 1601 | void CalendarView::checkExternalId( Incidence * inc ) |
1602 | { | 1602 | { |
1603 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1603 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1604 | checkExternSyncEvent( lastSync, inc ); | 1604 | checkExternSyncEvent( lastSync, inc ); |
1605 | 1605 | ||
1606 | } | 1606 | } |
1607 | // SSSSSSSSSSSSSSSSSSSSSS | ||
1607 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1608 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1608 | { | 1609 | { |
1609 | 1610 | ||
1610 | bool syncOK = true; | 1611 | bool syncOK = true; |
1611 | int addedEvent = 0; | 1612 | int addedEvent = 0; |
1612 | int addedEventR = 0; | 1613 | int addedEventR = 0; |
1613 | int deletedEventR = 0; | 1614 | int deletedEventR = 0; |
1614 | int deletedEventL = 0; | 1615 | int deletedEventL = 0; |
1615 | int changedLocal = 0; | 1616 | int changedLocal = 0; |
1616 | int changedRemote = 0; | 1617 | int changedRemote = 0; |
1617 | int filteredIN = 0; | 1618 | int filteredIN = 0; |
1618 | int filteredOUT = 0; | 1619 | int filteredOUT = 0; |
1619 | //QPtrList<Event> el = local->rawEvents(); | 1620 | //QPtrList<Event> el = local->rawEvents(); |
1620 | Event* eventR; | 1621 | Event* eventR; |
1621 | QString uid; | 1622 | QString uid; |
1622 | int take; | 1623 | int take; |
1623 | Event* eventRSync; | 1624 | Event* eventRSync; |
1624 | Event* eventLSync; | 1625 | Event* eventLSync; |
1625 | clearAllViews(); | 1626 | clearAllViews(); |
1626 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1627 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1627 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1628 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1628 | bool fullDateRange = false; | 1629 | bool fullDateRange = false; |
1629 | local->resetTempSyncStat(); | 1630 | local->resetTempSyncStat(); |
1630 | mLastCalendarSync = QDateTime::currentDateTime(); | 1631 | mLastCalendarSync = QDateTime::currentDateTime(); |
1631 | if ( mSyncManager->syncWithDesktop() ) { | 1632 | if ( mSyncManager->syncWithDesktop() ) { |
1632 | remote->resetPilotStat(1); | 1633 | remote->resetPilotStat(1); |
1633 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1634 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1634 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1635 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1635 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1636 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1636 | } else { | 1637 | } else { |
1637 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1638 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1638 | } | 1639 | } |
1639 | } | 1640 | } |
1640 | QDateTime modifiedCalendar = mLastCalendarSync; | 1641 | QDateTime modifiedCalendar = mLastCalendarSync; |
1641 | eventLSync = getLastSyncEvent(); | 1642 | eventLSync = getLastSyncEvent(); |
1642 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1643 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1643 | if ( eventR ) { | 1644 | if ( eventR ) { |
1644 | qDebug("KO: Last-syncEvent on remote found "); | 1645 | qDebug("KO: Last-syncEvent on remote found "); |
1645 | eventRSync = (Event*) eventR->clone(); | 1646 | eventRSync = (Event*) eventR->clone(); |
1646 | remote->deleteEvent(eventR ); | 1647 | remote->deleteEvent(eventR ); |
1647 | 1648 | ||
1648 | } else { | 1649 | } else { |
1649 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1650 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1650 | eventRSync = (Event*)eventLSync->clone(); | 1651 | eventRSync = (Event*)eventLSync->clone(); |
1651 | } else { | 1652 | } else { |
1652 | fullDateRange = true; | 1653 | fullDateRange = true; |
1653 | eventRSync = new Event(); | 1654 | eventRSync = new Event(); |
1654 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1655 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1655 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1656 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1656 | eventRSync->setDtStart( mLastCalendarSync ); | 1657 | eventRSync->setDtStart( mLastCalendarSync ); |
1657 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1658 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1658 | eventRSync->setCategories( i18n("SyncEvent") ); | 1659 | eventRSync->setCategories( i18n("SyncEvent") ); |
1659 | } | 1660 | } |
1660 | } | 1661 | } |
1661 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1662 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1662 | fullDateRange = true; | 1663 | fullDateRange = true; |
1663 | 1664 | ||
1664 | if ( ! fullDateRange ) { | 1665 | if ( ! fullDateRange ) { |
1665 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1666 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1666 | 1667 | ||
1667 | qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1668 | qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1668 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1669 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1669 | fullDateRange = true; | 1670 | fullDateRange = true; |
1670 | } | 1671 | } |
1671 | } | 1672 | } |
1672 | if ( mSyncManager->syncWithDesktop() ) { | 1673 | if ( mSyncManager->syncWithDesktop() ) { |
1673 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1674 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1674 | } | 1675 | } |
1675 | if ( fullDateRange ) | 1676 | if ( fullDateRange ) |
1676 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1677 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1677 | else | 1678 | else |
1678 | mLastCalendarSync = eventLSync->dtStart(); | 1679 | mLastCalendarSync = eventLSync->dtStart(); |
1679 | // for resyncing if own file has changed | 1680 | // for resyncing if own file has changed |
1680 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1681 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1681 | mLastCalendarSync = loadedFileVersion; | 1682 | mLastCalendarSync = loadedFileVersion; |
1682 | //qDebug("setting mLastCalendarSync "); | 1683 | //qDebug("setting mLastCalendarSync "); |
1683 | } | 1684 | } |
1684 | //qDebug("*************************** "); | 1685 | //qDebug("*************************** "); |
1685 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1686 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1686 | QPtrList<Incidence> er = remote->rawIncidences(); | 1687 | QPtrList<Incidence> er = remote->rawIncidences(); |
1687 | Incidence* inR = er.first(); | 1688 | Incidence* inR = er.first(); |
1688 | Incidence* inL; | 1689 | Incidence* inL; |
1689 | QProgressBar bar( er.count(),0 ); | 1690 | QProgressBar bar( er.count(),0 ); |
1690 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1691 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1691 | 1692 | ||
1692 | // ************** setting up filter ************* | 1693 | // ************** setting up filter ************* |
1693 | CalFilter *filterIN = 0; | 1694 | CalFilter *filterIN = 0; |
1694 | CalFilter *filterOUT = 0; | 1695 | CalFilter *filterOUT = 0; |
1695 | CalFilter *filter = mFilters.first(); | 1696 | CalFilter *filter = mFilters.first(); |
1696 | while(filter) { | 1697 | while(filter) { |
1697 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1698 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1698 | filterIN = filter; | 1699 | filterIN = filter; |
1699 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1700 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1700 | filterOUT = filter; | 1701 | filterOUT = filter; |
1701 | filter = mFilters.next(); | 1702 | filter = mFilters.next(); |
1702 | } | 1703 | } |
1703 | int w = 300; | 1704 | int w = 300; |
1704 | if ( QApplication::desktop()->width() < 320 ) | 1705 | if ( QApplication::desktop()->width() < 320 ) |
1705 | w = 220; | 1706 | w = 220; |
1706 | int h = bar.sizeHint().height() ; | 1707 | int h = bar.sizeHint().height() ; |
1707 | int dw = QApplication::desktop()->width(); | 1708 | int dw = QApplication::desktop()->width(); |
1708 | int dh = QApplication::desktop()->height(); | 1709 | int dh = QApplication::desktop()->height(); |
1709 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1710 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1710 | bar.show(); | 1711 | bar.show(); |
1711 | int modulo = (er.count()/10)+1; | 1712 | int modulo = (er.count()/10)+1; |
1712 | int incCounter = 0; | 1713 | int incCounter = 0; |
1713 | while ( inR ) { | 1714 | while ( inR ) { |
1714 | if ( ! bar.isVisible() ) | 1715 | if ( ! bar.isVisible() ) |
1715 | return false; | 1716 | return false; |
1716 | if ( incCounter % modulo == 0 ) | 1717 | if ( incCounter % modulo == 0 ) |
1717 | bar.setProgress( incCounter ); | 1718 | bar.setProgress( incCounter ); |
1718 | ++incCounter; | 1719 | ++incCounter; |
1719 | uid = inR->uid(); | 1720 | uid = inR->uid(); |
1720 | bool skipIncidence = false; | 1721 | bool skipIncidence = false; |
1721 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1722 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1722 | skipIncidence = true; | 1723 | skipIncidence = true; |
1723 | QString idS; | 1724 | QString idS; |
1724 | qApp->processEvents(); | 1725 | qApp->processEvents(); |
1725 | if ( !skipIncidence ) { | 1726 | if ( !skipIncidence ) { |
1726 | inL = local->incidenceForUid( uid , false , true ); | 1727 | int hasCalId = 0; |
1728 | inL = local->incidenceForUid( uid , false , true, &hasCalId ); | ||
1729 | if ( hasCalId && !inL ) | ||
1730 | inL = local->incidenceForUid( uid , false , true, &hasCalId ); | ||
1731 | else | ||
1732 | hasCalId = 0; | ||
1727 | if ( inL ) { // maybe conflict - same uid in both calendars | 1733 | if ( inL ) { // maybe conflict - same uid in both calendars |
1734 | if ( hasCalId ) | ||
1735 | qDebug("KO: Cal id %d conflict detected: %s ", hasCalId, inL->summary().latin1()); | ||
1728 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1736 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1729 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1737 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1730 | if ( take == 3 ) | 1738 | if ( take == 3 ) |
1731 | return false; | 1739 | return false; |
1732 | if ( take == 1 ) {// take local ********************** | 1740 | if ( take == 1 ) {// take local ********************** |
1733 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1741 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1734 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1742 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1735 | else | 1743 | else |
1736 | idS = inR->IDStr(); | 1744 | idS = inR->IDStr(); |
1737 | int calID = inR->calID(); | 1745 | int calID = inR->calID(); |
1738 | remote->deleteIncidence( inR ); | 1746 | remote->deleteIncidence( inR ); |
1739 | inR = inL->clone(); | 1747 | inR = inL->clone(); |
1740 | inR->setCalID_block( calID ); | 1748 | inR->setCalID_block( calID ); |
1741 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1749 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1742 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1750 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1743 | inR->setIDStr( idS ); | 1751 | inR->setIDStr( idS ); |
1744 | remote->addIncidence( inR ); | 1752 | remote->addIncidence( inR ); |
1745 | if ( mSyncManager->syncWithDesktop() ) | 1753 | if ( mSyncManager->syncWithDesktop() ) |
1746 | inR->setPilotId( 2 ); | 1754 | inR->setPilotId( 2 ); |
1747 | ++changedRemote; | 1755 | ++changedRemote; |
1748 | } else {// take remote ********************** | 1756 | } else {// take remote ********************** |
1749 | if ( !inL->isReadOnly() ) { | 1757 | if ( !inL->isReadOnly() ) { |
1750 | idS = inL->IDStr(); | 1758 | idS = inL->IDStr(); |
1751 | int pid = inL->pilotId(); | 1759 | int pid = inL->pilotId(); |
1752 | int calID = inL->calID(); | 1760 | int calID = inL->calID(); |
1761 | if ( hasCalId ) | ||
1762 | calID = hasCalId; | ||
1753 | local->deleteIncidence( inL ); | 1763 | local->deleteIncidence( inL ); |
1754 | inL = inR->clone(); | 1764 | inL = inR->clone(); |
1755 | inL->setCalID_block( calID ); | 1765 | inL->setCalID_block( calID ); |
1756 | if ( mSyncManager->syncWithDesktop() ) | 1766 | if ( mSyncManager->syncWithDesktop() ) |
1757 | inL->setPilotId( pid ); | 1767 | inL->setPilotId( pid ); |
1758 | inL->setIDStr( idS ); | 1768 | inL->setIDStr( idS ); |
1759 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1769 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1760 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1770 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1761 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1771 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1762 | } | 1772 | } |
1763 | local->addIncidence( inL ); | 1773 | local->addIncidence( inL ); |
1764 | ++changedLocal; | 1774 | ++changedLocal; |
1765 | } | 1775 | } |
1766 | } | 1776 | } |
1777 | } else { | ||
1778 | // take == 0; events equal | ||
1779 | if ( hasCalId ) | ||
1780 | qDebug("EV EQUALLLL **************************** "); | ||
1781 | |||
1767 | } | 1782 | } |
1768 | } else { // no conflict ********** add or delete remote | 1783 | } else { // no conflict ********** add or delete remote |
1769 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1784 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1770 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1785 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1771 | QString des = eventLSync->description(); | 1786 | QString des = eventLSync->description(); |
1772 | QString pref = "e"; | 1787 | QString pref = "e"; |
1773 | if ( inR->typeID() == todoID ) | 1788 | if ( inR->typeID() == todoID ) |
1774 | pref = "t"; | 1789 | pref = "t"; |
1775 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1790 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1776 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1791 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1777 | //remote->deleteIncidence( inR ); | 1792 | //remote->deleteIncidence( inR ); |
1778 | ++deletedEventR; | 1793 | ++deletedEventR; |
1779 | } else { | 1794 | } else { |
1780 | inR->setLastModified( modifiedCalendar ); | 1795 | inR->setLastModified( modifiedCalendar ); |
1781 | inL = inR->clone(); | 1796 | inL = inR->clone(); |
1782 | inL->setIDStr( ":" ); | 1797 | inL->setIDStr( ":" ); |
1783 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1798 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1784 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1799 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1785 | 1800 | ||
1786 | inL->setCalID_block( 0 );// add to default cal | 1801 | inL->setCalID_block( 0 );// add to default cal |
1787 | local->addIncidence( inL ); | 1802 | local->addIncidence( inL ); |
1788 | ++addedEvent; | 1803 | ++addedEvent; |
1789 | 1804 | ||
1790 | } | 1805 | } |
1791 | } else { | 1806 | } else { |
1792 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1807 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1793 | inR->setLastModified( modifiedCalendar ); | 1808 | inR->setLastModified( modifiedCalendar ); |
1794 | inL = inR->clone(); | 1809 | inL = inR->clone(); |
1795 | inL->setIDStr( ":" ); | 1810 | inL->setIDStr( ":" ); |
1796 | inL->setCalID_block( 0 );// add to default cal | 1811 | inL->setCalID_block( 0 );// add to default cal |
1797 | local->addIncidence( inL ); | 1812 | local->addIncidence( inL ); |
1798 | ++addedEvent; | 1813 | ++addedEvent; |
1799 | 1814 | ||
1800 | } else { | 1815 | } else { |
1801 | checkExternSyncEvent(eventRSyncSharp, inR); | 1816 | checkExternSyncEvent(eventRSyncSharp, inR); |
1802 | remote->deleteIncidence( inR ); | 1817 | remote->deleteIncidence( inR ); |
1803 | ++deletedEventR; | 1818 | ++deletedEventR; |
1804 | } | 1819 | } |
1805 | } | 1820 | } |
1806 | } else { | 1821 | } else { |
1807 | ++filteredIN; | 1822 | ++filteredIN; |
1808 | } | 1823 | } |
1809 | } | 1824 | } |
1810 | } | 1825 | } |
1811 | inR = er.next(); | 1826 | inR = er.next(); |
1812 | } | 1827 | } |
1813 | QPtrList<Incidence> el = local->rawIncidences(); | 1828 | QPtrList<Incidence> el = local->rawIncidences(); |
1814 | inL = el.first(); | 1829 | inL = el.first(); |
1815 | modulo = (el.count()/10)+1; | 1830 | modulo = (el.count()/10)+1; |
1816 | bar.setCaption (i18n("Add / remove events") ); | 1831 | bar.setCaption (i18n("Add / remove events") ); |
1817 | bar.setTotalSteps ( el.count() ) ; | 1832 | bar.setTotalSteps ( el.count() ) ; |
1818 | bar.show(); | 1833 | bar.show(); |
1819 | incCounter = 0; | 1834 | incCounter = 0; |
1820 | 1835 | ||
1821 | while ( inL ) { | 1836 | while ( inL ) { |
1822 | 1837 | ||
1823 | qApp->processEvents(); | 1838 | qApp->processEvents(); |
1824 | if ( ! bar.isVisible() ) | 1839 | if ( ! bar.isVisible() ) |
1825 | return false; | 1840 | return false; |
1826 | if ( incCounter % modulo == 0 ) | 1841 | if ( incCounter % modulo == 0 ) |
1827 | bar.setProgress( incCounter ); | 1842 | bar.setProgress( incCounter ); |
1828 | ++incCounter; | 1843 | ++incCounter; |
1829 | uid = inL->uid(); | 1844 | uid = inL->uid(); |
1830 | bool skipIncidence = false; | 1845 | bool skipIncidence = false; |
1831 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1846 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1832 | skipIncidence = true; | 1847 | skipIncidence = true; |
1833 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1848 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1834 | skipIncidence = true; | 1849 | skipIncidence = true; |
1835 | if ( !skipIncidence ) { | 1850 | if ( !skipIncidence ) { |
1836 | inR = remote->incidenceForUid( uid , true, true ); | 1851 | inR = remote->incidenceForUid( uid , true, true ); |
1837 | if ( ! inR ) { | 1852 | if ( ! inR ) { |
1838 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1853 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1839 | // no conflict ********** add or delete local | 1854 | // no conflict ********** add or delete local |
1840 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1855 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1841 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1856 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1842 | checkExternSyncEvent(eventLSyncSharp, inL); | 1857 | checkExternSyncEvent(eventLSyncSharp, inL); |
1843 | local->deleteIncidence( inL ); | 1858 | local->deleteIncidence( inL ); |
1844 | ++deletedEventL; | 1859 | ++deletedEventL; |
1845 | } else { | 1860 | } else { |
1846 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1861 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1847 | inL->removeID(mCurrentSyncDevice ); | 1862 | inL->removeID(mCurrentSyncDevice ); |
1848 | ++addedEventR; | 1863 | ++addedEventR; |
1849 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1864 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1850 | inL->setLastModified( modifiedCalendar ); | 1865 | inL->setLastModified( modifiedCalendar ); |
1851 | inR = inL->clone(); | 1866 | inR = inL->clone(); |
1852 | inR->setIDStr( ":" ); | 1867 | inR->setIDStr( ":" ); |
1853 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1868 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1854 | inR->setCalID_block( 0 );// add to default cal | 1869 | inR->setCalID_block( 0 );// add to default cal |
1855 | remote->addIncidence( inR ); | 1870 | remote->addIncidence( inR ); |
1856 | } | 1871 | } |
1857 | } | 1872 | } |
1858 | } else { | 1873 | } else { |
1859 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1874 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1860 | checkExternSyncEvent(eventLSyncSharp, inL); | 1875 | checkExternSyncEvent(eventLSyncSharp, inL); |
1861 | local->deleteIncidence( inL ); | 1876 | local->deleteIncidence( inL ); |
1862 | ++deletedEventL; | 1877 | ++deletedEventL; |
1863 | } else { | 1878 | } else { |
1864 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1879 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1865 | ++addedEventR; | 1880 | ++addedEventR; |
1866 | inL->setLastModified( modifiedCalendar ); | 1881 | inL->setLastModified( modifiedCalendar ); |
1867 | inR = inL->clone(); | 1882 | inR = inL->clone(); |
1868 | inR->setIDStr( ":" ); | 1883 | inR->setIDStr( ":" ); |
1869 | inR->setCalID_block( 0 );// add to default cal | 1884 | inR->setCalID_block( 0 );// add to default cal |
1870 | remote->addIncidence( inR ); | 1885 | remote->addIncidence( inR ); |
1871 | } | 1886 | } |
1872 | } | 1887 | } |
1873 | } | 1888 | } |
1874 | } else { | 1889 | } else { |
1875 | ++filteredOUT; | 1890 | ++filteredOUT; |
1876 | } | 1891 | } |
1877 | } | 1892 | } |
1878 | } | 1893 | } |
1879 | inL = el.next(); | 1894 | inL = el.next(); |
1880 | } | 1895 | } |
1881 | int delFut = 0; | 1896 | int delFut = 0; |
1882 | int remRem = 0; | 1897 | int remRem = 0; |
1883 | if ( mSyncManager->mWriteBackInFuture ) { | 1898 | if ( mSyncManager->mWriteBackInFuture ) { |
1884 | er = remote->rawIncidences(); | 1899 | er = remote->rawIncidences(); |
1885 | remRem = er.count(); | 1900 | remRem = er.count(); |
1886 | inR = er.first(); | 1901 | inR = er.first(); |
1887 | QDateTime dt; | 1902 | QDateTime dt; |
1888 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1903 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1889 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1904 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1890 | while ( inR ) { | 1905 | while ( inR ) { |
1891 | if ( inR->typeID() == todoID ) { | 1906 | if ( inR->typeID() == todoID ) { |
1892 | Todo * t = (Todo*)inR; | 1907 | Todo * t = (Todo*)inR; |
1893 | if ( t->hasDueDate() ) | 1908 | if ( t->hasDueDate() ) |
1894 | dt = t->dtDue(); | 1909 | dt = t->dtDue(); |
1895 | else | 1910 | else |
1896 | dt = cur.addSecs( 62 ); | 1911 | dt = cur.addSecs( 62 ); |
1897 | } | 1912 | } |
1898 | else if (inR->typeID() == eventID ) { | 1913 | else if (inR->typeID() == eventID ) { |
1899 | bool ok; | 1914 | bool ok; |
1900 | dt = inR->getNextOccurence( cur, &ok ); | 1915 | dt = inR->getNextOccurence( cur, &ok ); |
1901 | if ( !ok ) | 1916 | if ( !ok ) |
1902 | dt = cur.addSecs( -62 ); | 1917 | dt = cur.addSecs( -62 ); |
1903 | } | 1918 | } |
1904 | else | 1919 | else |
1905 | dt = inR->dtStart(); | 1920 | dt = inR->dtStart(); |
1906 | if ( dt < cur || dt > end ) { | 1921 | if ( dt < cur || dt > end ) { |
1907 | remote->deleteIncidence( inR ); | 1922 | remote->deleteIncidence( inR ); |
1908 | ++delFut; | 1923 | ++delFut; |
1909 | } | 1924 | } |
1910 | inR = er.next(); | 1925 | inR = er.next(); |
1911 | } | 1926 | } |
1912 | } | 1927 | } |
1913 | bar.hide(); | 1928 | bar.hide(); |
1914 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1929 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1915 | if ( mMultiResourceSync ) { | 1930 | if ( mMultiResourceSync ) { |
1916 | remote->removeSyncInfo( "" ); //all | 1931 | remote->removeSyncInfo( "" ); //all |
1917 | qDebug("KO: Remoing all sync info on remote "); | 1932 | qDebug("KO: Remoing all sync info on remote "); |
1918 | } else { | 1933 | } else { |
1919 | eventLSync->setReadOnly( false ); | 1934 | eventLSync->setReadOnly( false ); |
1920 | eventLSync->setDtStart( mLastCalendarSync ); | 1935 | eventLSync->setDtStart( mLastCalendarSync ); |
1921 | eventRSync->setDtStart( mLastCalendarSync ); | 1936 | eventRSync->setDtStart( mLastCalendarSync ); |
1922 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1937 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1923 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1938 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1924 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1939 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1925 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1940 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1926 | eventLSync->setReadOnly( true ); | 1941 | eventLSync->setReadOnly( true ); |
1927 | } | 1942 | } |
1928 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1943 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1929 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal... | 1944 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal... |
1930 | remote->addEvent( eventRSync ); | 1945 | remote->addEvent( eventRSync ); |
1931 | else | 1946 | else |
1932 | delete eventRSync; | 1947 | delete eventRSync; |
1933 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1948 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1934 | QString mes; | 1949 | QString mes; |
1935 | 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 ); | 1950 | 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 ); |
1936 | QString delmess; | 1951 | QString delmess; |
1937 | if ( delFut ) { | 1952 | if ( delFut ) { |
1938 | 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); | 1953 | 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); |
1939 | mes += delmess; | 1954 | mes += delmess; |
1940 | } | 1955 | } |
1941 | mes = i18n("Local calendar changed!\n") +mes; | 1956 | mes = i18n("Local calendar changed!\n") +mes; |
1942 | mCalendar->checkAlarmForIncidence( 0, true ); | 1957 | mCalendar->checkAlarmForIncidence( 0, true ); |
1943 | qDebug( mes ); | 1958 | qDebug( mes ); |
1944 | if ( mSyncManager->mShowSyncSummary ) { | 1959 | if ( mSyncManager->mShowSyncSummary ) { |
1945 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1960 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1946 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1961 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1947 | qDebug("KO: WB cancelled "); | 1962 | qDebug("KO: WB cancelled "); |
1948 | mSyncManager->mWriteBackFile = false; | 1963 | mSyncManager->mWriteBackFile = false; |
1949 | return syncOK; | 1964 | return syncOK; |
1950 | } | 1965 | } |
1951 | } | 1966 | } |
1952 | return syncOK; | 1967 | return syncOK; |
1953 | } | 1968 | } |
1954 | 1969 | ||
1955 | void CalendarView::setSyncDevice( QString s ) | 1970 | void CalendarView::setSyncDevice( QString s ) |
1956 | { | 1971 | { |
1957 | mCurrentSyncDevice= s; | 1972 | mCurrentSyncDevice= s; |
1958 | } | 1973 | } |
1959 | void CalendarView::setSyncName( QString s ) | 1974 | void CalendarView::setSyncName( QString s ) |
1960 | { | 1975 | { |
1961 | mCurrentSyncName= s; | 1976 | mCurrentSyncName= s; |
1962 | } | 1977 | } |
1963 | bool CalendarView::syncCalendar(QString filename, int mode) | 1978 | bool CalendarView::syncCalendar(QString filename, int mode) |
1964 | { | 1979 | { |
1965 | //qDebug("syncCalendar %s ", filename.latin1()); | 1980 | //qDebug("syncCalendar %s ", filename.latin1()); |
1966 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1981 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1967 | CalendarLocal* calendar = new CalendarLocal(); | 1982 | CalendarLocal* calendar = new CalendarLocal(); |
1968 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1983 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1969 | FileStorage* storage = new FileStorage( calendar ); | 1984 | FileStorage* storage = new FileStorage( calendar ); |
1970 | bool syncOK = false; | 1985 | bool syncOK = false; |
1971 | storage->setFileName( filename ); | 1986 | storage->setFileName( filename ); |
1972 | // qDebug("loading ... "); | 1987 | // qDebug("loading ... "); |
1973 | if ( storage->load() ) { | 1988 | if ( storage->load() ) { |
1974 | getEventViewerDialog()->setSyncMode( true ); | 1989 | getEventViewerDialog()->setSyncMode( true ); |
1975 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1990 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1976 | getEventViewerDialog()->setSyncMode( false ); | 1991 | getEventViewerDialog()->setSyncMode( false ); |
1977 | if ( syncOK ) { | 1992 | if ( syncOK ) { |
1978 | if ( mSyncManager->mWriteBackFile ) | 1993 | if ( mSyncManager->mWriteBackFile ) |
1979 | { | 1994 | { |
1980 | storage->setSaveFormat( new ICalFormat() ); | 1995 | storage->setSaveFormat( new ICalFormat() ); |
1981 | storage->save(); | 1996 | storage->save(); |
1982 | } | 1997 | } |
1983 | } | 1998 | } |
1984 | setModified( true ); | 1999 | setModified( true ); |
1985 | } | 2000 | } |
1986 | delete storage; | 2001 | delete storage; |
1987 | delete calendar; | 2002 | delete calendar; |
1988 | if ( syncOK ) | 2003 | if ( syncOK ) |
1989 | updateView(); | 2004 | updateView(); |
1990 | return syncOK; | 2005 | return syncOK; |
1991 | } | 2006 | } |
1992 | 2007 | ||
1993 | void CalendarView::syncExternal( int mode ) | 2008 | void CalendarView::syncExternal( int mode ) |
1994 | { | 2009 | { |
1995 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2010 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1996 | qApp->processEvents(); | 2011 | qApp->processEvents(); |
1997 | CalendarLocal* calendar = new CalendarLocal(); | 2012 | CalendarLocal* calendar = new CalendarLocal(); |
1998 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2013 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1999 | bool syncOK = false; | 2014 | bool syncOK = false; |
2000 | bool loadSuccess = false; | 2015 | bool loadSuccess = false; |
2001 | PhoneFormat* phoneFormat = 0; | 2016 | PhoneFormat* phoneFormat = 0; |
2002 | emit tempDisableBR(true); | 2017 | emit tempDisableBR(true); |
2003 | #ifndef DESKTOP_VERSION | 2018 | #ifndef DESKTOP_VERSION |
2004 | SharpFormat* sharpFormat = 0; | 2019 | SharpFormat* sharpFormat = 0; |
2005 | if ( mode == 0 ) { // sharp | 2020 | if ( mode == 0 ) { // sharp |
2006 | sharpFormat = new SharpFormat () ; | 2021 | sharpFormat = new SharpFormat () ; |
2007 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 2022 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
2008 | 2023 | ||
2009 | } else | 2024 | } else |
2010 | #endif | 2025 | #endif |
2011 | if ( mode == 1 ) { // phone | 2026 | if ( mode == 1 ) { // phone |
2012 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 2027 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
2013 | mSyncManager->mPhoneDevice, | 2028 | mSyncManager->mPhoneDevice, |
2014 | mSyncManager->mPhoneConnection, | 2029 | mSyncManager->mPhoneConnection, |
2015 | mSyncManager->mPhoneModel); | 2030 | mSyncManager->mPhoneModel); |
2016 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 2031 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
2017 | 2032 | ||
2018 | } else { | 2033 | } else { |
2019 | emit tempDisableBR(false); | 2034 | emit tempDisableBR(false); |
2020 | return; | 2035 | return; |
2021 | } | 2036 | } |
2022 | if ( loadSuccess ) { | 2037 | if ( loadSuccess ) { |
2023 | getEventViewerDialog()->setSyncMode( true ); | 2038 | getEventViewerDialog()->setSyncMode( true ); |
2024 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2039 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2025 | getEventViewerDialog()->setSyncMode( false ); | 2040 | getEventViewerDialog()->setSyncMode( false ); |
2026 | qApp->processEvents(); | 2041 | qApp->processEvents(); |
2027 | if ( syncOK ) { | 2042 | if ( syncOK ) { |
2028 | if ( mSyncManager->mWriteBackFile ) | 2043 | if ( mSyncManager->mWriteBackFile ) |
2029 | { | 2044 | { |
2030 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 2045 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
2031 | Incidence* inc = iL.first(); | 2046 | Incidence* inc = iL.first(); |
2032 | if ( phoneFormat ) { | 2047 | if ( phoneFormat ) { |
2033 | while ( inc ) { | 2048 | while ( inc ) { |
2034 | inc->removeID(mCurrentSyncDevice); | 2049 | inc->removeID(mCurrentSyncDevice); |
2035 | inc = iL.next(); | 2050 | inc = iL.next(); |
2036 | } | 2051 | } |
2037 | } | 2052 | } |
2038 | #ifndef DESKTOP_VERSION | 2053 | #ifndef DESKTOP_VERSION |
2039 | if ( sharpFormat ) | 2054 | if ( sharpFormat ) |
2040 | sharpFormat->save(calendar); | 2055 | sharpFormat->save(calendar); |
2041 | #endif | 2056 | #endif |
2042 | if ( phoneFormat ) | 2057 | if ( phoneFormat ) |
2043 | phoneFormat->save(calendar); | 2058 | phoneFormat->save(calendar); |
2044 | iL = calendar->rawIncidences(); | 2059 | iL = calendar->rawIncidences(); |
2045 | inc = iL.first(); | 2060 | inc = iL.first(); |
2046 | Incidence* loc; | 2061 | Incidence* loc; |
2047 | while ( inc ) { | 2062 | while ( inc ) { |
2048 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 2063 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
2049 | loc = mCalendar->incidence(inc->uid() ); | 2064 | loc = mCalendar->incidence(inc->uid() ); |
2050 | if ( loc ) { | 2065 | if ( loc ) { |
2051 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 2066 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
2052 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 2067 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
2053 | } | 2068 | } |
2054 | } | 2069 | } |
2055 | inc = iL.next(); | 2070 | inc = iL.next(); |
2056 | } | 2071 | } |
2057 | Incidence* lse = getLastSyncEvent(); | 2072 | Incidence* lse = getLastSyncEvent(); |
2058 | if ( lse ) { | 2073 | if ( lse ) { |
2059 | lse->setReadOnly( false ); | 2074 | lse->setReadOnly( false ); |
2060 | lse->setDescription( "" ); | 2075 | lse->setDescription( "" ); |
2061 | lse->setReadOnly( true ); | 2076 | lse->setReadOnly( true ); |
2062 | } | 2077 | } |
2063 | } | 2078 | } |
2064 | } else { | 2079 | } else { |
2065 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 2080 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
2066 | } | 2081 | } |
2067 | setModified( true ); | 2082 | setModified( true ); |
2068 | } else { | 2083 | } else { |
2069 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 2084 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
2070 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 2085 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
2071 | question, i18n("Ok")) ; | 2086 | question, i18n("Ok")) ; |
2072 | 2087 | ||
2073 | } | 2088 | } |
2074 | delete calendar; | 2089 | delete calendar; |
2075 | updateView(); | 2090 | updateView(); |
2076 | emit tempDisableBR(false); | 2091 | emit tempDisableBR(false); |
2077 | return ;//syncOK; | 2092 | return ;//syncOK; |
2078 | 2093 | ||
2079 | } | 2094 | } |
2080 | 2095 | ||
2081 | bool CalendarView::importBday() | 2096 | bool CalendarView::importBday() |
2082 | { | 2097 | { |
2083 | #ifndef KORG_NOKABC | 2098 | #ifndef KORG_NOKABC |
2084 | 2099 | ||
2085 | #ifdef DESKTOP_VERSION | 2100 | #ifdef DESKTOP_VERSION |
2086 | int curCal = mCalendar->defaultCalendar(); | 2101 | int curCal = mCalendar->defaultCalendar(); |
2087 | int bd = mCalEditView->getBirtdayID(); | 2102 | int bd = mCalEditView->getBirtdayID(); |
2088 | if ( bd == 0 ) | 2103 | if ( bd == 0 ) |
2089 | return false; | 2104 | return false; |
2090 | mCalendar->setDefaultCalendar( bd ); | 2105 | mCalendar->setDefaultCalendar( bd ); |
2091 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 2106 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
2092 | KABC::AddressBook::Iterator it; | 2107 | KABC::AddressBook::Iterator it; |
2093 | int count = 0; | 2108 | int count = 0; |
2094 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2109 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2095 | ++count; | 2110 | ++count; |
2096 | } | 2111 | } |
2097 | QProgressBar bar(count,0 ); | 2112 | QProgressBar bar(count,0 ); |
2098 | int w = 300; | 2113 | int w = 300; |
2099 | if ( QApplication::desktop()->width() < 320 ) | 2114 | if ( QApplication::desktop()->width() < 320 ) |
2100 | w = 220; | 2115 | w = 220; |
2101 | int h = bar.sizeHint().height() ; | 2116 | int h = bar.sizeHint().height() ; |
2102 | int dw = QApplication::desktop()->width(); | 2117 | int dw = QApplication::desktop()->width(); |
2103 | int dh = QApplication::desktop()->height(); | 2118 | int dh = QApplication::desktop()->height(); |
2104 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2119 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2105 | bar.show(); | 2120 | bar.show(); |
2106 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 2121 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
2107 | qApp->processEvents(); | 2122 | qApp->processEvents(); |
2108 | count = 0; | 2123 | count = 0; |
2109 | int addCount = 0; | 2124 | int addCount = 0; |
2110 | KCal::Attendee* a = 0; | 2125 | KCal::Attendee* a = 0; |
2111 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2126 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2112 | if ( ! bar.isVisible() ) | 2127 | if ( ! bar.isVisible() ) |
2113 | return false; | 2128 | return false; |
2114 | bar.setProgress( count++ ); | 2129 | bar.setProgress( count++ ); |
2115 | qApp->processEvents(); | 2130 | qApp->processEvents(); |
2116 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 2131 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
2117 | if ( (*it).birthday().date().isValid() ){ | 2132 | if ( (*it).birthday().date().isValid() ){ |
2118 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2133 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2119 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 2134 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
2120 | ++addCount; | 2135 | ++addCount; |
2121 | } | 2136 | } |
2122 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 2137 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
2123 | if ( anni.isValid() ){ | 2138 | if ( anni.isValid() ){ |
2124 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2139 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2125 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 2140 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
2126 | ++addCount; | 2141 | ++addCount; |
2127 | } | 2142 | } |
2128 | } | 2143 | } |
2129 | mCalendar->setDefaultCalendar( curCal ); | 2144 | mCalendar->setDefaultCalendar( curCal ); |
2130 | updateView(); | 2145 | updateView(); |
2131 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2146 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2132 | #else //DESKTOP_VERSION | 2147 | #else //DESKTOP_VERSION |
2133 | 2148 | ||
2134 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 2149 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
2135 | // the result should now arrive through method insertBirthdays | 2150 | // the result should now arrive through method insertBirthdays |
2136 | 2151 | ||
2137 | #endif //DESKTOP_VERSION | 2152 | #endif //DESKTOP_VERSION |
2138 | 2153 | ||
2139 | #endif //KORG_NOKABC | 2154 | #endif //KORG_NOKABC |
2140 | 2155 | ||
2141 | 2156 | ||
2142 | return true; | 2157 | return true; |
2143 | } | 2158 | } |
2144 | 2159 | ||
2145 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 2160 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
2146 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 2161 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
2147 | const QStringList& anniversaryList, const QStringList& realNameList, | 2162 | const QStringList& anniversaryList, const QStringList& realNameList, |
2148 | const QStringList& emailList, const QStringList& assembledNameList, | 2163 | const QStringList& emailList, const QStringList& assembledNameList, |
2149 | const QStringList& uidList) | 2164 | const QStringList& uidList) |
2150 | { | 2165 | { |
2151 | 2166 | ||
2152 | //qDebug("KO::CalendarView::insertBirthdays"); | 2167 | //qDebug("KO::CalendarView::insertBirthdays"); |
2153 | if (uid == this->name()) | 2168 | if (uid == this->name()) |
2154 | { | 2169 | { |
2155 | int curCal = mCalendar->defaultCalendar(); | 2170 | int curCal = mCalendar->defaultCalendar(); |
2156 | int bd = mCalEditView->getBirtdayID(); | 2171 | int bd = mCalEditView->getBirtdayID(); |
2157 | if ( bd == 0 ) | 2172 | if ( bd == 0 ) |
2158 | return; | 2173 | return; |
2159 | mCalendar->setDefaultCalendar( bd ); | 2174 | mCalendar->setDefaultCalendar( bd ); |
2160 | 2175 | ||
2161 | 2176 | ||
2162 | int count = birthdayList.count(); | 2177 | int count = birthdayList.count(); |
2163 | int addCount = 0; | 2178 | int addCount = 0; |
2164 | KCal::Attendee* a = 0; | 2179 | KCal::Attendee* a = 0; |
2165 | 2180 | ||
2166 | //qDebug("CalView 1 %i", count); | 2181 | //qDebug("CalView 1 %i", count); |
2167 | 2182 | ||
2168 | QProgressBar bar(count,0 ); | 2183 | QProgressBar bar(count,0 ); |
2169 | int w = 300; | 2184 | int w = 300; |
2170 | if ( QApplication::desktop()->width() < 320 ) | 2185 | if ( QApplication::desktop()->width() < 320 ) |
2171 | w = 220; | 2186 | w = 220; |
2172 | int h = bar.sizeHint().height() ; | 2187 | int h = bar.sizeHint().height() ; |
2173 | int dw = QApplication::desktop()->width(); | 2188 | int dw = QApplication::desktop()->width(); |
2174 | int dh = QApplication::desktop()->height(); | 2189 | int dh = QApplication::desktop()->height(); |
2175 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2190 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2176 | bar.show(); | 2191 | bar.show(); |
2177 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 2192 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
2178 | qApp->processEvents(); | 2193 | qApp->processEvents(); |
2179 | 2194 | ||
2180 | QDate birthday; | 2195 | QDate birthday; |
2181 | QDate anniversary; | 2196 | QDate anniversary; |
2182 | QString realName; | 2197 | QString realName; |
2183 | QString email; | 2198 | QString email; |
2184 | QString assembledName; | 2199 | QString assembledName; |
2185 | QString uid; | 2200 | QString uid; |
2186 | bool ok = true; | 2201 | bool ok = true; |
2187 | for ( int i = 0; i < count; i++) | 2202 | for ( int i = 0; i < count; i++) |
2188 | { | 2203 | { |
2189 | if ( ! bar.isVisible() ) | 2204 | if ( ! bar.isVisible() ) |
2190 | return; | 2205 | return; |
2191 | bar.setProgress( i ); | 2206 | bar.setProgress( i ); |
2192 | qApp->processEvents(); | 2207 | qApp->processEvents(); |
2193 | 2208 | ||
2194 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 2209 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
2195 | if (!ok) { | 2210 | if (!ok) { |
2196 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 2211 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
2197 | } | 2212 | } |
2198 | 2213 | ||
2199 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 2214 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
2200 | if (!ok) { | 2215 | if (!ok) { |
2201 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 2216 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
2202 | } | 2217 | } |
2203 | realName = realNameList[i]; | 2218 | realName = realNameList[i]; |
2204 | email = emailList[i]; | 2219 | email = emailList[i]; |
2205 | assembledName = assembledNameList[i]; | 2220 | assembledName = assembledNameList[i]; |
2206 | uid = uidList[i]; | 2221 | uid = uidList[i]; |
2207 | //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() ); | 2222 | //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() ); |
2208 | 2223 | ||
2209 | if ( birthday.isValid() ){ | 2224 | if ( birthday.isValid() ){ |
2210 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2225 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2211 | KCal::Attendee::ReqParticipant,uid) ; | 2226 | KCal::Attendee::ReqParticipant,uid) ; |
2212 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 2227 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
2213 | ++addCount; | 2228 | ++addCount; |
2214 | } | 2229 | } |
2215 | 2230 | ||
2216 | if ( anniversary.isValid() ){ | 2231 | if ( anniversary.isValid() ){ |
2217 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2232 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2218 | KCal::Attendee::ReqParticipant,uid) ; | 2233 | KCal::Attendee::ReqParticipant,uid) ; |
2219 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 2234 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
2220 | ++addCount; | 2235 | ++addCount; |
2221 | } | 2236 | } |
2222 | } | 2237 | } |
2223 | 2238 | ||
2224 | mCalendar->setDefaultCalendar( curCal ); | 2239 | mCalendar->setDefaultCalendar( curCal ); |
2225 | updateView(); | 2240 | updateView(); |
2226 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2241 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2227 | 2242 | ||
2228 | } | 2243 | } |
2229 | 2244 | ||
2230 | } | 2245 | } |
2231 | 2246 | ||
2232 | 2247 | ||
2233 | 2248 | ||
2234 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 2249 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
2235 | { | 2250 | { |
2236 | //qDebug("addAnni "); | 2251 | //qDebug("addAnni "); |
2237 | Event * ev = new Event(); | 2252 | Event * ev = new Event(); |
2238 | ev->setOrganizer(KOPrefs::instance()->email()); | 2253 | ev->setOrganizer(KOPrefs::instance()->email()); |
2239 | if ( a ) { | 2254 | if ( a ) { |
2240 | ev->addAttendee( a ); | 2255 | ev->addAttendee( a ); |
2241 | } | 2256 | } |
2242 | QString kind; | 2257 | QString kind; |
2243 | if ( birthday ) { | 2258 | if ( birthday ) { |
2244 | kind = i18n( "Birthday" ); | 2259 | kind = i18n( "Birthday" ); |
2245 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 2260 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
2246 | } | 2261 | } |
2247 | else { | 2262 | else { |
2248 | kind = i18n( "Anniversary" ); | 2263 | kind = i18n( "Anniversary" ); |
2249 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 2264 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
2250 | } | 2265 | } |
2251 | ev->setCategories( kind ); | 2266 | ev->setCategories( kind ); |
2252 | ev->setDtStart( QDateTime(date) ); | 2267 | ev->setDtStart( QDateTime(date) ); |
2253 | ev->setDtEnd( QDateTime(date) ); | 2268 | ev->setDtEnd( QDateTime(date) ); |
2254 | ev->setFloats( true ); | 2269 | ev->setFloats( true ); |
2255 | Recurrence * rec = ev->recurrence(); | 2270 | Recurrence * rec = ev->recurrence(); |
2256 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 2271 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
2257 | rec->addYearlyNum( date.month() ); | 2272 | rec->addYearlyNum( date.month() ); |
2258 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 2273 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
2259 | delete ev; | 2274 | delete ev; |
2260 | return false; | 2275 | return false; |
2261 | } | 2276 | } |
2262 | return true; | 2277 | return true; |
2263 | 2278 | ||
2264 | } | 2279 | } |
2265 | bool CalendarView::importQtopia( const QString &categories, | 2280 | bool CalendarView::importQtopia( const QString &categories, |
2266 | const QString &datebook, | 2281 | const QString &datebook, |
2267 | const QString &todolist ) | 2282 | const QString &todolist ) |
2268 | { | 2283 | { |
2269 | 2284 | ||
2270 | QtopiaFormat qtopiaFormat; | 2285 | QtopiaFormat qtopiaFormat; |
2271 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2286 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2272 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2287 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2273 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2288 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2274 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2289 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2275 | 2290 | ||
2276 | updateView(); | 2291 | updateView(); |
2277 | return true; | 2292 | return true; |
2278 | 2293 | ||
2279 | #if 0 | 2294 | #if 0 |
2280 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2295 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2281 | mCurrentSyncDevice = "qtopia-XML"; | 2296 | mCurrentSyncDevice = "qtopia-XML"; |
2282 | if ( mSyncManager->mAskForPreferences ) | 2297 | if ( mSyncManager->mAskForPreferences ) |
2283 | edit_sync_options(); | 2298 | edit_sync_options(); |
2284 | qApp->processEvents(); | 2299 | qApp->processEvents(); |
2285 | CalendarLocal* calendar = new CalendarLocal(); | 2300 | CalendarLocal* calendar = new CalendarLocal(); |
2286 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2301 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2287 | bool syncOK = false; | 2302 | bool syncOK = false; |
2288 | QtopiaFormat qtopiaFormat; | 2303 | QtopiaFormat qtopiaFormat; |
2289 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2304 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2290 | bool loadOk = true; | 2305 | bool loadOk = true; |
2291 | if ( !categories.isEmpty() ) | 2306 | if ( !categories.isEmpty() ) |
2292 | loadOk = qtopiaFormat.load( calendar, categories ); | 2307 | loadOk = qtopiaFormat.load( calendar, categories ); |
2293 | if ( loadOk && !datebook.isEmpty() ) | 2308 | if ( loadOk && !datebook.isEmpty() ) |
2294 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2309 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2295 | if ( loadOk && !todolist.isEmpty() ) | 2310 | if ( loadOk && !todolist.isEmpty() ) |
2296 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2311 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2297 | 2312 | ||
2298 | if ( loadOk ) { | 2313 | if ( loadOk ) { |
2299 | getEventViewerDialog()->setSyncMode( true ); | 2314 | getEventViewerDialog()->setSyncMode( true ); |
2300 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2315 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2301 | getEventViewerDialog()->setSyncMode( false ); | 2316 | getEventViewerDialog()->setSyncMode( false ); |
2302 | qApp->processEvents(); | 2317 | qApp->processEvents(); |
2303 | if ( syncOK ) { | 2318 | if ( syncOK ) { |
2304 | if ( mSyncManager->mWriteBackFile ) | 2319 | if ( mSyncManager->mWriteBackFile ) |
2305 | { | 2320 | { |
2306 | // write back XML file | 2321 | // write back XML file |
2307 | 2322 | ||
2308 | } | 2323 | } |
2309 | setModified( true ); | 2324 | setModified( true ); |
2310 | } | 2325 | } |
2311 | } else { | 2326 | } else { |
2312 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2327 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2313 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2328 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2314 | question, i18n("Ok")) ; | 2329 | question, i18n("Ok")) ; |
2315 | } | 2330 | } |
2316 | delete calendar; | 2331 | delete calendar; |
2317 | updateView(); | 2332 | updateView(); |
2318 | return syncOK; | 2333 | return syncOK; |
2319 | 2334 | ||
2320 | 2335 | ||
2321 | #endif | 2336 | #endif |
2322 | 2337 | ||
2323 | } | 2338 | } |
2324 | 2339 | ||
2325 | void CalendarView::setSyncEventsReadOnly() | 2340 | void CalendarView::setSyncEventsReadOnly() |
2326 | { | 2341 | { |
2327 | mCalendar->setSyncEventsReadOnly(); | 2342 | mCalendar->setSyncEventsReadOnly(); |
2328 | } | 2343 | } |
2329 | 2344 | ||
2330 | bool CalendarView::loadCalendars() | 2345 | bool CalendarView::loadCalendars() |
2331 | { | 2346 | { |
2332 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2347 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2333 | KopiCalendarFile * cal = calendars.first(); | 2348 | KopiCalendarFile * cal = calendars.first(); |
2334 | mCalendar->setDefaultCalendar( 1 ); | 2349 | mCalendar->setDefaultCalendar( 1 ); |
2335 | openCalendar( MainWindow::defaultFileName(), false ); | 2350 | openCalendar( MainWindow::defaultFileName(), false ); |
2336 | cal = calendars.next(); | 2351 | cal = calendars.next(); |
2337 | while ( cal ) { | 2352 | while ( cal ) { |
2338 | addCalendar( cal ); | 2353 | addCalendar( cal ); |
2339 | cal = calendars.next(); | 2354 | cal = calendars.next(); |
2340 | } | 2355 | } |
2341 | restoreCalendarSettings(); | 2356 | restoreCalendarSettings(); |
2342 | return true; | 2357 | return true; |
2343 | } | 2358 | } |
2344 | bool CalendarView::restoreCalendarSettings() | 2359 | bool CalendarView::restoreCalendarSettings() |
2345 | { | 2360 | { |
2346 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2361 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2347 | KopiCalendarFile * cal = calendars.first(); | 2362 | KopiCalendarFile * cal = calendars.first(); |
2348 | while ( cal ) { | 2363 | while ( cal ) { |
2349 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2364 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2350 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2365 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2351 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2366 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2352 | if ( cal->isStandard ) | 2367 | if ( cal->isStandard ) |
2353 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2368 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2354 | cal = calendars.next(); | 2369 | cal = calendars.next(); |
2355 | } | 2370 | } |
2356 | setSyncEventsReadOnly(); | 2371 | setSyncEventsReadOnly(); |
2357 | mCalendar->reInitAlarmSettings(); | 2372 | mCalendar->reInitAlarmSettings(); |
2358 | updateUnmanagedViews(); | 2373 | updateUnmanagedViews(); |
2359 | updateView(); | 2374 | updateView(); |
2360 | return true; | 2375 | return true; |
2361 | } | 2376 | } |
2362 | void CalendarView::addCalendarId( int id ) | 2377 | void CalendarView::addCalendarId( int id ) |
2363 | { | 2378 | { |
2364 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2379 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2365 | if ( cal ) | 2380 | if ( cal ) |
2366 | addCalendar( cal ); | 2381 | addCalendar( cal ); |
2367 | } | 2382 | } |
2368 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2383 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2369 | { | 2384 | { |
2370 | cal->mErrorOnLoad = false; | 2385 | cal->mErrorOnLoad = false; |
2371 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2386 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2372 | cal->mLoadDt = QDateTime::currentDateTime(); | 2387 | cal->mLoadDt = QDateTime::currentDateTime(); |
2373 | return true; | 2388 | return true; |
2374 | } | 2389 | } |
2375 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2390 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2376 | cal->mErrorOnLoad = true; | 2391 | cal->mErrorOnLoad = true; |
2377 | return false; | 2392 | return false; |
2378 | } | 2393 | } |
2379 | bool CalendarView::openCalendar(QString filename, bool merge) | 2394 | bool CalendarView::openCalendar(QString filename, bool merge) |
2380 | { | 2395 | { |
2381 | 2396 | ||
2382 | if (filename.isEmpty()) { | 2397 | if (filename.isEmpty()) { |
2383 | return false; | 2398 | return false; |
2384 | } | 2399 | } |
2385 | 2400 | ||
2386 | if (!QFile::exists(filename)) { | 2401 | if (!QFile::exists(filename)) { |
2387 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2402 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2388 | return false; | 2403 | return false; |
2389 | } | 2404 | } |
2390 | 2405 | ||
2391 | globalFlagBlockAgenda = 1; | 2406 | globalFlagBlockAgenda = 1; |
2392 | clearAllViews(); | 2407 | clearAllViews(); |
2393 | if (!merge) { | 2408 | if (!merge) { |
2394 | mViewManager->setDocumentId( filename ); | 2409 | mViewManager->setDocumentId( filename ); |
2395 | mCalendar->close(); | 2410 | mCalendar->close(); |
2396 | } | 2411 | } |
2397 | mStorage->setFileName( filename ); | 2412 | mStorage->setFileName( filename ); |
2398 | 2413 | ||
2399 | if ( mStorage->load() ) { | 2414 | if ( mStorage->load() ) { |
2400 | if ( merge ) ;//setModified( true ); | 2415 | if ( merge ) ;//setModified( true ); |
2401 | else { | 2416 | else { |
2402 | //setModified( true ); | 2417 | //setModified( true ); |
2403 | mViewManager->setDocumentId( filename ); | 2418 | mViewManager->setDocumentId( filename ); |
2404 | mDialogManager->setDocumentId( filename ); | 2419 | mDialogManager->setDocumentId( filename ); |
2405 | mTodoList->setDocumentId( filename ); | 2420 | mTodoList->setDocumentId( filename ); |
2406 | } | 2421 | } |
2407 | globalFlagBlockAgenda = 2; | 2422 | globalFlagBlockAgenda = 2; |
2408 | // if ( getLastSyncEvent() ) | 2423 | // if ( getLastSyncEvent() ) |
2409 | // getLastSyncEvent()->setReadOnly( true ); | 2424 | // getLastSyncEvent()->setReadOnly( true ); |
2410 | mCalendar->reInitAlarmSettings(); | 2425 | mCalendar->reInitAlarmSettings(); |
2411 | setSyncEventsReadOnly(); | 2426 | setSyncEventsReadOnly(); |
2412 | //updateUnmanagedViews(); | 2427 | //updateUnmanagedViews(); |
2413 | //updateView(); | 2428 | //updateView(); |
2414 | if ( filename != MainWindow::defaultFileName() ) { | 2429 | if ( filename != MainWindow::defaultFileName() ) { |
2415 | saveCalendar( MainWindow::defaultFileName() ); | 2430 | saveCalendar( MainWindow::defaultFileName() ); |
2416 | } else { | 2431 | } else { |
2417 | QFileInfo finf ( MainWindow::defaultFileName()); | 2432 | QFileInfo finf ( MainWindow::defaultFileName()); |
2418 | if ( finf.exists() ) { | 2433 | if ( finf.exists() ) { |
2419 | setLoadedFileVersion( finf.lastModified () ); | 2434 | setLoadedFileVersion( finf.lastModified () ); |
2420 | } | 2435 | } |
2421 | } | 2436 | } |
2422 | return true; | 2437 | return true; |
2423 | } else { | 2438 | } else { |
2424 | // while failing to load, the calendar object could | 2439 | // while failing to load, the calendar object could |
2425 | // have become partially populated. Clear it out. | 2440 | // have become partially populated. Clear it out. |
2426 | if ( !merge ) { | 2441 | if ( !merge ) { |
2427 | mCalendar->close(); | 2442 | mCalendar->close(); |
2428 | mViewManager->setDocumentId( filename ); | 2443 | mViewManager->setDocumentId( filename ); |
2429 | mDialogManager->setDocumentId( filename ); | 2444 | mDialogManager->setDocumentId( filename ); |
2430 | mTodoList->setDocumentId( filename ); | 2445 | mTodoList->setDocumentId( filename ); |
2431 | } | 2446 | } |
2432 | 2447 | ||
2433 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2448 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2434 | 2449 | ||
2435 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2450 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2436 | globalFlagBlockAgenda = 2; | 2451 | globalFlagBlockAgenda = 2; |
2437 | mCalendar->reInitAlarmSettings(); | 2452 | mCalendar->reInitAlarmSettings(); |
2438 | setSyncEventsReadOnly(); | 2453 | setSyncEventsReadOnly(); |
2439 | updateUnmanagedViews(); | 2454 | updateUnmanagedViews(); |
2440 | updateView(); | 2455 | updateView(); |
2441 | } | 2456 | } |
2442 | return false; | 2457 | return false; |
2443 | } | 2458 | } |
2444 | void CalendarView::mergeFile( QString fn ) | 2459 | void CalendarView::mergeFile( QString fn ) |
2445 | { | 2460 | { |
2446 | clearAllViews(); | 2461 | clearAllViews(); |
2447 | mCalendar->mergeCalendarFile( fn ); | 2462 | mCalendar->mergeCalendarFile( fn ); |
2448 | mCalendar->reInitAlarmSettings(); | 2463 | mCalendar->reInitAlarmSettings(); |
2449 | setSyncEventsReadOnly(); | 2464 | setSyncEventsReadOnly(); |
2450 | updateUnmanagedViews(); | 2465 | updateUnmanagedViews(); |
2451 | updateView(); | 2466 | updateView(); |
2452 | } | 2467 | } |
2453 | void CalendarView::mergeFileResource( QString fn ,QString resource ) | 2468 | void CalendarView::mergeFileResource( QString fn ,QString resource ) |
2454 | { | 2469 | { |
2455 | 2470 | ||
2456 | if ( resource == "ALL" ) { | 2471 | if ( resource == "ALL" ) { |
2457 | mCalendar->setAllCalendarEnabled( true ); | 2472 | mCalendar->setAllCalendarEnabled( true ); |
2458 | mergeFile( fn ); | 2473 | mergeFile( fn ); |
2459 | restoreCalendarSettings(); | 2474 | restoreCalendarSettings(); |
2460 | return; | 2475 | return; |
2461 | } | 2476 | } |
2462 | 2477 | ||
2463 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | 2478 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); |
2464 | if ( !exclusiveResource ) { | 2479 | if ( !exclusiveResource ) { |
2465 | qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() ); | 2480 | qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() ); |
2466 | return; | 2481 | return; |
2467 | } | 2482 | } |
2468 | clearAllViews(); | 2483 | clearAllViews(); |
2469 | mCalendar->setCalendarRemove( exclusiveResource ); | 2484 | mCalendar->setCalendarRemove( exclusiveResource ); |
2470 | int def = mCalendar->defaultCalendar(); | 2485 | int def = mCalendar->defaultCalendar(); |
2471 | mCalendar->setDefaultCalendar(exclusiveResource); | 2486 | mCalendar->setDefaultCalendar(exclusiveResource); |
2472 | if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) { | 2487 | if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) { |
2473 | qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() ); | 2488 | qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() ); |
2474 | } | 2489 | } |
2475 | mCalendar->setDefaultCalendar( def ); | 2490 | mCalendar->setDefaultCalendar( def ); |
2476 | mCalendar->reInitAlarmSettings(); | 2491 | mCalendar->reInitAlarmSettings(); |
2477 | setSyncEventsReadOnly(); | 2492 | setSyncEventsReadOnly(); |
2478 | updateUnmanagedViews(); | 2493 | updateUnmanagedViews(); |
2479 | updateView(); | 2494 | updateView(); |
2480 | } | 2495 | } |
2481 | void CalendarView::showOpenError() | 2496 | void CalendarView::showOpenError() |
2482 | { | 2497 | { |
2483 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2498 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2484 | } | 2499 | } |
2485 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2500 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2486 | { | 2501 | { |
2487 | loadedFileVersion = dt; | 2502 | loadedFileVersion = dt; |
2488 | } | 2503 | } |
2489 | bool CalendarView::checkFileChanged(QString fn) | 2504 | bool CalendarView::checkFileChanged(QString fn) |
2490 | { | 2505 | { |
2491 | QFileInfo finf ( fn ); | 2506 | QFileInfo finf ( fn ); |
2492 | if ( !finf.exists() ) | 2507 | if ( !finf.exists() ) |
2493 | return true; | 2508 | return true; |
2494 | QDateTime dt = finf.lastModified (); | 2509 | QDateTime dt = finf.lastModified (); |
2495 | if ( dt <= loadedFileVersion ) | 2510 | if ( dt <= loadedFileVersion ) |
2496 | return false; | 2511 | return false; |
2497 | return true; | 2512 | return true; |
2498 | 2513 | ||
2499 | } | 2514 | } |
2500 | void CalendarView::watchSavedFile() | 2515 | void CalendarView::watchSavedFile() |
2501 | { | 2516 | { |
2502 | QFileInfo finf ( MainWindow::defaultFileName()); | 2517 | QFileInfo finf ( MainWindow::defaultFileName()); |
2503 | if ( !finf.exists() ) | 2518 | if ( !finf.exists() ) |
2504 | return; | 2519 | return; |
2505 | QDateTime dt = finf.lastModified (); | 2520 | QDateTime dt = finf.lastModified (); |
2506 | if ( dt < loadedFileVersion ) { | 2521 | if ( dt < loadedFileVersion ) { |
2507 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2522 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2508 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2523 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2509 | return; | 2524 | return; |
2510 | } | 2525 | } |
2511 | loadedFileVersion = dt; | 2526 | loadedFileVersion = dt; |
2512 | } | 2527 | } |
2513 | bool CalendarView::checkAllFileVersions() | 2528 | bool CalendarView::checkAllFileVersions() |
2514 | { | 2529 | { |
2515 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2530 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2516 | KopiCalendarFile * cal = calendars.first(); | 2531 | KopiCalendarFile * cal = calendars.first(); |
2517 | mCalendar->setDefaultCalendar( 1 ); | 2532 | mCalendar->setDefaultCalendar( 1 ); |
2518 | mCalendar->setDefaultCalendarEnabledOnly(); | 2533 | mCalendar->setDefaultCalendarEnabledOnly(); |
2519 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2534 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2520 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2535 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2521 | restoreCalendarSettings(); | 2536 | restoreCalendarSettings(); |
2522 | return false; | 2537 | return false; |
2523 | } | 2538 | } |
2524 | } | 2539 | } |
2525 | cal = calendars.next(); | 2540 | cal = calendars.next(); |
2526 | QDateTime storeTemp = loadedFileVersion; | 2541 | QDateTime storeTemp = loadedFileVersion; |
2527 | while ( cal ) { | 2542 | while ( cal ) { |
2528 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2543 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2529 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2544 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2530 | mCalendar->setDefaultCalendarEnabledOnly(); | 2545 | mCalendar->setDefaultCalendarEnabledOnly(); |
2531 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2546 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2532 | if ( !checkFileVersion(cal->mFileName )) { | 2547 | if ( !checkFileVersion(cal->mFileName )) { |
2533 | loadedFileVersion = storeTemp; | 2548 | loadedFileVersion = storeTemp; |
2534 | restoreCalendarSettings(); | 2549 | restoreCalendarSettings(); |
2535 | return false; | 2550 | return false; |
2536 | } | 2551 | } |
2537 | } | 2552 | } |
2538 | cal = calendars.next(); | 2553 | cal = calendars.next(); |
2539 | } | 2554 | } |
2540 | loadedFileVersion = storeTemp; | 2555 | loadedFileVersion = storeTemp; |
2541 | return true; | 2556 | return true; |
2542 | } | 2557 | } |
2543 | bool CalendarView::checkFileVersion(QString fn) | 2558 | bool CalendarView::checkFileVersion(QString fn) |
2544 | { | 2559 | { |
2545 | QFileInfo finf ( fn ); | 2560 | QFileInfo finf ( fn ); |
2546 | if ( !finf.exists() ) | 2561 | if ( !finf.exists() ) |
2547 | return true; | 2562 | return true; |
2548 | QDateTime dt = finf.lastModified (); | 2563 | QDateTime dt = finf.lastModified (); |
2549 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2564 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2550 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2565 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2551 | if ( dt <= loadedFileVersion ) | 2566 | if ( dt <= loadedFileVersion ) |
2552 | return true; | 2567 | return true; |
2553 | 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)) , | 2568 | 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)) , |
2554 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2569 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2555 | i18n("Sync+save")); | 2570 | i18n("Sync+save")); |
2556 | 2571 | ||
2557 | if ( km == KMessageBox::Cancel ) | 2572 | if ( km == KMessageBox::Cancel ) |
2558 | return false; | 2573 | return false; |
2559 | if ( km == KMessageBox::Yes ) | 2574 | if ( km == KMessageBox::Yes ) |
2560 | return true; | 2575 | return true; |
2561 | 2576 | ||
2562 | setSyncDevice("deleteaftersync" ); | 2577 | setSyncDevice("deleteaftersync" ); |
2563 | mSyncManager->mAskForPreferences = true; | 2578 | mSyncManager->mAskForPreferences = true; |
2564 | mSyncManager->mSyncAlgoPrefs = 3; | 2579 | mSyncManager->mSyncAlgoPrefs = 3; |
2565 | mSyncManager->mWriteBackFile = false; | 2580 | mSyncManager->mWriteBackFile = false; |
2566 | mSyncManager->mWriteBackExistingOnly = false; | 2581 | mSyncManager->mWriteBackExistingOnly = false; |
2567 | mSyncManager->mShowSyncSummary = false; | 2582 | mSyncManager->mShowSyncSummary = false; |
2568 | mMultiResourceSync = false; | 2583 | mMultiResourceSync = false; |
2569 | syncCalendar( fn, 3 ); | 2584 | syncCalendar( fn, 3 ); |
2570 | Event * e = getLastSyncEvent(); | 2585 | Event * e = getLastSyncEvent(); |
2571 | if ( e ) | 2586 | if ( e ) |
2572 | mCalendar->deleteEvent( e ); | 2587 | mCalendar->deleteEvent( e ); |
2573 | return true; | 2588 | return true; |
2574 | } | 2589 | } |
2575 | bool CalendarView::saveCalendars() | 2590 | bool CalendarView::saveCalendars() |
2576 | { | 2591 | { |
2577 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2592 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2578 | KopiCalendarFile * cal = calendars.first(); | 2593 | KopiCalendarFile * cal = calendars.first(); |
2579 | mCalendar->setDefaultCalendar( 1 ); | 2594 | mCalendar->setDefaultCalendar( 1 ); |
2580 | mCalendar->setDefaultCalendarEnabledOnly(); | 2595 | mCalendar->setDefaultCalendarEnabledOnly(); |
2581 | QString saveError; | 2596 | QString saveError; |
2582 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) | 2597 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) |
2583 | saveError = cal->mName +"\n"; | 2598 | saveError = cal->mName +"\n"; |
2584 | cal = calendars.next(); | 2599 | cal = calendars.next(); |
2585 | while ( cal ) { | 2600 | while ( cal ) { |
2586 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2601 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2587 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2602 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2588 | mCalendar->setDefaultCalendarEnabledOnly(); | 2603 | mCalendar->setDefaultCalendarEnabledOnly(); |
2589 | if ( saveCalendar( cal->mFileName ) ) | 2604 | if ( saveCalendar( cal->mFileName ) ) |
2590 | cal->mLoadDt = QDateTime::currentDateTime(); | 2605 | cal->mLoadDt = QDateTime::currentDateTime(); |
2591 | else | 2606 | else |
2592 | saveError += cal->mName + "\n"; | 2607 | saveError += cal->mName + "\n"; |
2593 | } | 2608 | } |
2594 | cal = calendars.next(); | 2609 | cal = calendars.next(); |
2595 | } | 2610 | } |
2596 | restoreCalendarSettings(); | 2611 | restoreCalendarSettings(); |
2597 | //saveError = "test error"; | 2612 | //saveError = "test error"; |
2598 | if ( !saveError.isEmpty() ) { | 2613 | if ( !saveError.isEmpty() ) { |
2599 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; | 2614 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; |
2600 | KMessageBox::error(this, saveError, i18n("Error saving data")); | 2615 | KMessageBox::error(this, saveError, i18n("Error saving data")); |
2601 | return false; | 2616 | return false; |
2602 | } | 2617 | } |
2603 | return true; | 2618 | return true; |
2604 | } | 2619 | } |
2605 | bool CalendarView::saveCalendarResource(QString filename, QString resource) | 2620 | bool CalendarView::saveCalendarResource(QString filename, QString resource) |
2606 | { | 2621 | { |
2607 | if ( resource == "ALL" ) { | 2622 | if ( resource == "ALL" ) { |
2608 | mCalendar->setAllCalendarEnabled( true ); | 2623 | mCalendar->setAllCalendarEnabled( true ); |
2609 | bool retval = saveCalendar( filename ); | 2624 | bool retval = saveCalendar( filename ); |
2610 | restoreCalendarSettings(); | 2625 | restoreCalendarSettings(); |
2611 | return retval; | 2626 | return retval; |
2612 | } | 2627 | } |
2613 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | 2628 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); |
2614 | if ( !exclusiveResource ) { | 2629 | if ( !exclusiveResource ) { |
2615 | qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() ); | 2630 | qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() ); |
2616 | return false; | 2631 | return false; |
2617 | } | 2632 | } |
2618 | mCalendar->setDefaultCalendar( exclusiveResource ); | 2633 | mCalendar->setDefaultCalendar( exclusiveResource ); |
2619 | mCalendar->setDefaultCalendarEnabledOnly(); | 2634 | mCalendar->setDefaultCalendarEnabledOnly(); |
2620 | mCalendar->setSyncEventsEnabled(); | 2635 | mCalendar->setSyncEventsEnabled(); |
2621 | bool res = saveCalendar( filename ); | 2636 | bool res = saveCalendar( filename ); |
2622 | restoreCalendarSettings(); | 2637 | restoreCalendarSettings(); |
2623 | return res; | 2638 | return res; |
2624 | 2639 | ||
2625 | } | 2640 | } |
2626 | bool CalendarView::saveCalendar( QString filename ) | 2641 | bool CalendarView::saveCalendar( QString filename ) |
2627 | { | 2642 | { |
2628 | 2643 | ||
2629 | // Store back all unsaved data into calendar object | 2644 | // Store back all unsaved data into calendar object |
2630 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2645 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2631 | if ( mViewManager->currentView() ) | 2646 | if ( mViewManager->currentView() ) |
2632 | mViewManager->currentView()->flushView(); | 2647 | mViewManager->currentView()->flushView(); |
2633 | 2648 | ||
2634 | 2649 | ||
2635 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2650 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2636 | mStorage->setSaveFormat( new ICalFormat() ); | 2651 | mStorage->setSaveFormat( new ICalFormat() ); |
2637 | mStorage->setFileName( filename ); | 2652 | mStorage->setFileName( filename ); |
2638 | bool success; | 2653 | bool success; |
2639 | success = mStorage->save(); | 2654 | success = mStorage->save(); |
2640 | if ( !success ) { | 2655 | if ( !success ) { |
2641 | return false; | 2656 | return false; |
2642 | } | 2657 | } |
2643 | if ( filename == MainWindow::defaultFileName() ) { | 2658 | if ( filename == MainWindow::defaultFileName() ) { |
2644 | setLoadedFileVersion( lfv ); | 2659 | setLoadedFileVersion( lfv ); |
2645 | watchSavedFile(); | 2660 | watchSavedFile(); |
2646 | } | 2661 | } |
2647 | return true; | 2662 | return true; |
2648 | } | 2663 | } |
2649 | 2664 | ||
2650 | void CalendarView::closeCalendar() | 2665 | void CalendarView::closeCalendar() |
2651 | { | 2666 | { |
2652 | 2667 | ||
2653 | // child windows no longer valid | 2668 | // child windows no longer valid |
2654 | clearAllViews(); | 2669 | clearAllViews(); |
2655 | emit closingDown(); | 2670 | emit closingDown(); |
2656 | 2671 | ||
2657 | mCalendar->close(); | 2672 | mCalendar->close(); |
2658 | setModified(false); | 2673 | setModified(false); |
2659 | updateView(); | 2674 | updateView(); |
2660 | } | 2675 | } |
2661 | 2676 | ||
2662 | void CalendarView::archiveCalendar() | 2677 | void CalendarView::archiveCalendar() |
2663 | { | 2678 | { |
2664 | mDialogManager->showArchiveDialog(); | 2679 | mDialogManager->showArchiveDialog(); |
2665 | } | 2680 | } |
2666 | 2681 | ||
2667 | 2682 | ||
2668 | void CalendarView::readSettings() | 2683 | void CalendarView::readSettings() |
2669 | { | 2684 | { |
2670 | 2685 | ||
2671 | 2686 | ||
2672 | // mViewManager->showAgendaView(); | 2687 | // mViewManager->showAgendaView(); |
2673 | QString str; | 2688 | QString str; |
2674 | //qDebug("CalendarView::readSettings() "); | 2689 | //qDebug("CalendarView::readSettings() "); |
2675 | // read settings from the KConfig, supplying reasonable | 2690 | // read settings from the KConfig, supplying reasonable |
2676 | // defaults where none are to be found | 2691 | // defaults where none are to be found |
2677 | KConfig *config = KOGlobals::config(); | 2692 | KConfig *config = KOGlobals::config(); |
2678 | #ifndef KORG_NOSPLITTER | 2693 | #ifndef KORG_NOSPLITTER |
2679 | config->setGroup("KOrganizer Geometry"); | 2694 | config->setGroup("KOrganizer Geometry"); |
2680 | 2695 | ||
2681 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2696 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2682 | if (sizes.count() != 2) { | 2697 | if (sizes.count() != 2) { |
2683 | sizes << mDateNavigator->minimumSizeHint().width(); | 2698 | sizes << mDateNavigator->minimumSizeHint().width(); |
2684 | sizes << 300; | 2699 | sizes << 300; |
2685 | } | 2700 | } |
2686 | mPanner->setSizes(sizes); | 2701 | mPanner->setSizes(sizes); |
2687 | 2702 | ||
2688 | sizes = config->readIntListEntry("Separator2"); | 2703 | sizes = config->readIntListEntry("Separator2"); |
2689 | if ( ( mResourceView && sizes.count() == 4 ) || | 2704 | if ( ( mResourceView && sizes.count() == 4 ) || |
2690 | ( !mResourceView && sizes.count() == 3 ) ) { | 2705 | ( !mResourceView && sizes.count() == 3 ) ) { |
2691 | mLeftSplitter->setSizes(sizes); | 2706 | mLeftSplitter->setSizes(sizes); |
2692 | } | 2707 | } |
2693 | #endif | 2708 | #endif |
2694 | globalFlagBlockAgenda = 1; | 2709 | globalFlagBlockAgenda = 1; |
2695 | mViewManager->showAgendaView(); | 2710 | mViewManager->showAgendaView(); |
2696 | //mViewManager->readSettings( config ); | 2711 | //mViewManager->readSettings( config ); |
2697 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2712 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2698 | readFilterSettings(config); | 2713 | readFilterSettings(config); |
2699 | 2714 | ||
2700 | #ifdef DESKTOP_VERSION | 2715 | #ifdef DESKTOP_VERSION |
2701 | config->setGroup("WidgetLayout"); | 2716 | config->setGroup("WidgetLayout"); |
2702 | QStringList list; | 2717 | QStringList list; |
2703 | list = config->readListEntry("MainLayout"); | 2718 | list = config->readListEntry("MainLayout"); |
2704 | int x,y,w,h; | 2719 | int x,y,w,h; |
2705 | if ( ! list.isEmpty() ) { | 2720 | if ( ! list.isEmpty() ) { |
2706 | x = list[0].toInt(); | 2721 | x = list[0].toInt(); |
2707 | y = list[1].toInt(); | 2722 | y = list[1].toInt(); |
2708 | w = list[2].toInt(); | 2723 | w = list[2].toInt(); |
2709 | h = list[3].toInt(); | 2724 | h = list[3].toInt(); |
2710 | KApplication::testCoords( &x,&y,&w,&h ); | 2725 | KApplication::testCoords( &x,&y,&w,&h ); |
2711 | topLevelWidget()->setGeometry(x,y,w,h); | 2726 | topLevelWidget()->setGeometry(x,y,w,h); |
2712 | 2727 | ||
2713 | } else { | 2728 | } else { |
2714 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2729 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2715 | } | 2730 | } |
2716 | list = config->readListEntry("EditEventLayout"); | 2731 | list = config->readListEntry("EditEventLayout"); |
2717 | if ( ! list.isEmpty() ) { | 2732 | if ( ! list.isEmpty() ) { |
2718 | x = list[0].toInt(); | 2733 | x = list[0].toInt(); |
2719 | y = list[1].toInt(); | 2734 | y = list[1].toInt(); |
2720 | w = list[2].toInt(); | 2735 | w = list[2].toInt(); |
2721 | h = list[3].toInt(); | 2736 | h = list[3].toInt(); |
2722 | KApplication::testCoords( &x,&y,&w,&h ); | 2737 | KApplication::testCoords( &x,&y,&w,&h ); |
2723 | mEventEditor->setGeometry(x,y,w,h); | 2738 | mEventEditor->setGeometry(x,y,w,h); |
2724 | 2739 | ||
2725 | } | 2740 | } |
2726 | list = config->readListEntry("EditTodoLayout"); | 2741 | list = config->readListEntry("EditTodoLayout"); |
2727 | if ( ! list.isEmpty() ) { | 2742 | if ( ! list.isEmpty() ) { |
2728 | x = list[0].toInt(); | 2743 | x = list[0].toInt(); |
2729 | y = list[1].toInt(); | 2744 | y = list[1].toInt(); |
2730 | w = list[2].toInt(); | 2745 | w = list[2].toInt(); |
2731 | h = list[3].toInt(); | 2746 | h = list[3].toInt(); |
2732 | KApplication::testCoords( &x,&y,&w,&h ); | 2747 | KApplication::testCoords( &x,&y,&w,&h ); |
2733 | mTodoEditor->setGeometry(x,y,w,h); | 2748 | mTodoEditor->setGeometry(x,y,w,h); |
2734 | 2749 | ||
2735 | } | 2750 | } |
2736 | list = config->readListEntry("ViewerLayout"); | 2751 | list = config->readListEntry("ViewerLayout"); |
2737 | if ( ! list.isEmpty() ) { | 2752 | if ( ! list.isEmpty() ) { |
2738 | x = list[0].toInt(); | 2753 | x = list[0].toInt(); |
2739 | y = list[1].toInt(); | 2754 | y = list[1].toInt(); |
2740 | w = list[2].toInt(); | 2755 | w = list[2].toInt(); |
2741 | h = list[3].toInt(); | 2756 | h = list[3].toInt(); |
2742 | KApplication::testCoords( &x,&y,&w,&h ); | 2757 | KApplication::testCoords( &x,&y,&w,&h ); |
2743 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2758 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2744 | } | 2759 | } |
2745 | #endif | 2760 | #endif |
2746 | config->setGroup( "Views" ); | 2761 | config->setGroup( "Views" ); |
2747 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2762 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2748 | 2763 | ||
2749 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2764 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2750 | 2765 | ||
2751 | int resetval = 0; | 2766 | int resetval = 0; |
2752 | int maxVal = 0; | 2767 | int maxVal = 0; |
2753 | if (sizes.count() != 3) { | 2768 | if (sizes.count() != 3) { |
2754 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2769 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2755 | resetval = mDateNavigator->sizeHint().width()+2; | 2770 | resetval = mDateNavigator->sizeHint().width()+2; |
2756 | } else { | 2771 | } else { |
2757 | resetval = mDateNavigator->sizeHint().height()+2; | 2772 | resetval = mDateNavigator->sizeHint().height()+2; |
2758 | } | 2773 | } |
2759 | } | 2774 | } |
2760 | if ( resetval ) { | 2775 | if ( resetval ) { |
2761 | sizes.clear(); | 2776 | sizes.clear(); |
2762 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2777 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2763 | maxVal = QApplication::desktop()->width() -10; | 2778 | maxVal = QApplication::desktop()->width() -10; |
2764 | } else { | 2779 | } else { |
2765 | maxVal = QApplication::desktop()->height()-10; | 2780 | maxVal = QApplication::desktop()->height()-10; |
2766 | } | 2781 | } |
2767 | sizes << resetval; | 2782 | sizes << resetval; |
2768 | if ( maxVal < resetval + resetval) | 2783 | if ( maxVal < resetval + resetval) |
2769 | resetval = maxVal - resetval; | 2784 | resetval = maxVal - resetval; |
2770 | sizes << resetval; | 2785 | sizes << resetval; |
2771 | sizes << 100; | 2786 | sizes << 100; |
2772 | } | 2787 | } |
2773 | mLeftFrame->setSizes(sizes); | 2788 | mLeftFrame->setSizes(sizes); |
2774 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2789 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2775 | resetval = 0; | 2790 | resetval = 0; |
2776 | maxVal = 0; | 2791 | maxVal = 0; |
2777 | if (sizes.count() != 2) { | 2792 | if (sizes.count() != 2) { |
2778 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2793 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2779 | resetval = mDateNavigator->sizeHint().width()+2; | 2794 | resetval = mDateNavigator->sizeHint().width()+2; |
2780 | } else { | 2795 | } else { |
2781 | resetval = mDateNavigator->sizeHint().height()+2; | 2796 | resetval = mDateNavigator->sizeHint().height()+2; |
2782 | } | 2797 | } |
2783 | } | 2798 | } |
2784 | if ( resetval ) { | 2799 | if ( resetval ) { |
2785 | sizes.clear(); | 2800 | sizes.clear(); |
2786 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2801 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2787 | maxVal = QApplication::desktop()->width() -10; | 2802 | maxVal = QApplication::desktop()->width() -10; |
2788 | } else { | 2803 | } else { |
2789 | maxVal = QApplication::desktop()->height()-10; | 2804 | maxVal = QApplication::desktop()->height()-10; |
2790 | } | 2805 | } |
2791 | sizes << resetval; | 2806 | sizes << resetval; |
2792 | if ( maxVal < resetval + resetval) | 2807 | if ( maxVal < resetval + resetval) |
2793 | resetval = maxVal - resetval; | 2808 | resetval = maxVal - resetval; |
2794 | sizes << resetval; | 2809 | sizes << resetval; |
2795 | } | 2810 | } |
2796 | mMainFrame->setSizes(sizes); | 2811 | mMainFrame->setSizes(sizes); |
2797 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2812 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2798 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2813 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2799 | else mNavigator->selectDates( dateCount ); | 2814 | else mNavigator->selectDates( dateCount ); |
2800 | // mViewManager->readSettings( config ); | 2815 | // mViewManager->readSettings( config ); |
2801 | updateConfig(); | 2816 | updateConfig(); |
2802 | globalFlagBlockAgenda = 2; | 2817 | globalFlagBlockAgenda = 2; |
2803 | mViewManager->readSettings( config ); | 2818 | mViewManager->readSettings( config ); |
2804 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2819 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2805 | } | 2820 | } |
2806 | 2821 | ||
2807 | void CalendarView::checkSuspendAlarm() | 2822 | void CalendarView::checkSuspendAlarm() |
2808 | { | 2823 | { |
2809 | if ( mSuspendTimer->isActive() ) { | 2824 | if ( mSuspendTimer->isActive() ) { |
2810 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2825 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2811 | } | 2826 | } |
2812 | } | 2827 | } |
2813 | void CalendarView::writeSettings() | 2828 | void CalendarView::writeSettings() |
2814 | { | 2829 | { |
2815 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2830 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2816 | 2831 | ||
2817 | KConfig *config = KOGlobals::config(); | 2832 | KConfig *config = KOGlobals::config(); |
2818 | 2833 | ||
2819 | mViewManager->writeSettings( config ); | 2834 | mViewManager->writeSettings( config ); |
2820 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2835 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2821 | mDialogManager->writeSettings( config ); | 2836 | mDialogManager->writeSettings( config ); |
2822 | //KOPrefs::instance()->usrWriteConfig(); | 2837 | //KOPrefs::instance()->usrWriteConfig(); |
2823 | KOPrefs::instance()->writeConfig(); | 2838 | KOPrefs::instance()->writeConfig(); |
2824 | 2839 | ||
2825 | writeFilterSettings(config); | 2840 | writeFilterSettings(config); |
2826 | config->setGroup( "AppRun" ); | 2841 | config->setGroup( "AppRun" ); |
2827 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2842 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2828 | int days = dt.daysTo( QDate::currentDate() ); | 2843 | int days = dt.daysTo( QDate::currentDate() ); |
2829 | dt = dt.addDays( days ); | 2844 | dt = dt.addDays( days ); |
2830 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2845 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2831 | config->writeEntry( "LatestProgramStopDays", days ); | 2846 | config->writeEntry( "LatestProgramStopDays", days ); |
2832 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2847 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2833 | //qDebug("KO: Writing stop time: %d ", secs); | 2848 | //qDebug("KO: Writing stop time: %d ", secs); |
2834 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2849 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2835 | //QDateTime latest = dt.addSecs ( secs ); | 2850 | //QDateTime latest = dt.addSecs ( secs ); |
2836 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2851 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2837 | config->setGroup( "Views" ); | 2852 | config->setGroup( "Views" ); |
2838 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2853 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2839 | 2854 | ||
2840 | #if 0 | 2855 | #if 0 |
2841 | qDebug("********************* "); | 2856 | qDebug("********************* "); |
2842 | qDebug("Testcode secsto "); | 2857 | qDebug("Testcode secsto "); |
2843 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2858 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2844 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2859 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2845 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2860 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2846 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2861 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2847 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2862 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2848 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2863 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2849 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2864 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2850 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2865 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2851 | qDebug("********************* testcode end"); | 2866 | qDebug("********************* testcode end"); |
2852 | 2867 | ||
2853 | #endif | 2868 | #endif |
2854 | 2869 | ||
2855 | QValueList<int> listINT = mLeftFrame->sizes(); | 2870 | QValueList<int> listINT = mLeftFrame->sizes(); |
2856 | config->writeEntry("Left Splitter Frame",listINT); | 2871 | config->writeEntry("Left Splitter Frame",listINT); |
2857 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2872 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2858 | config->writeEntry("Main Splitter Frame",listINT2); | 2873 | config->writeEntry("Main Splitter Frame",listINT2); |
2859 | #ifdef DESKTOP_VERSION | 2874 | #ifdef DESKTOP_VERSION |
2860 | config->setGroup("WidgetLayout"); | 2875 | config->setGroup("WidgetLayout"); |
2861 | QStringList list ;//= config->readListEntry("MainLayout"); | 2876 | QStringList list ;//= config->readListEntry("MainLayout"); |
2862 | int x,y,w,h; | 2877 | int x,y,w,h; |
2863 | QWidget* wid; | 2878 | QWidget* wid; |
2864 | wid = topLevelWidget(); | 2879 | wid = topLevelWidget(); |
2865 | x = wid->geometry().x(); | 2880 | x = wid->geometry().x(); |
2866 | y = wid->geometry().y(); | 2881 | y = wid->geometry().y(); |
2867 | w = wid->width(); | 2882 | w = wid->width(); |
2868 | h = wid->height(); | 2883 | h = wid->height(); |
2869 | list.clear(); | 2884 | list.clear(); |
2870 | list << QString::number( x ); | 2885 | list << QString::number( x ); |
2871 | list << QString::number( y ); | 2886 | list << QString::number( y ); |
2872 | list << QString::number( w ); | 2887 | list << QString::number( w ); |
2873 | list << QString::number( h ); | 2888 | list << QString::number( h ); |
2874 | config->writeEntry("MainLayout",list ); | 2889 | config->writeEntry("MainLayout",list ); |
2875 | 2890 | ||
2876 | wid = mEventEditor; | 2891 | wid = mEventEditor; |
2877 | x = wid->geometry().x(); | 2892 | x = wid->geometry().x(); |
2878 | y = wid->geometry().y(); | 2893 | y = wid->geometry().y(); |
2879 | w = wid->width(); | 2894 | w = wid->width(); |
2880 | h = wid->height(); | 2895 | h = wid->height(); |
2881 | list.clear(); | 2896 | list.clear(); |
2882 | list << QString::number( x ); | 2897 | list << QString::number( x ); |
2883 | list << QString::number( y ); | 2898 | list << QString::number( y ); |
2884 | list << QString::number( w ); | 2899 | list << QString::number( w ); |
2885 | list << QString::number( h ); | 2900 | list << QString::number( h ); |
2886 | config->writeEntry("EditEventLayout",list ); | 2901 | config->writeEntry("EditEventLayout",list ); |
2887 | 2902 | ||
2888 | wid = mTodoEditor; | 2903 | wid = mTodoEditor; |
2889 | x = wid->geometry().x(); | 2904 | x = wid->geometry().x(); |
2890 | y = wid->geometry().y(); | 2905 | y = wid->geometry().y(); |
2891 | w = wid->width(); | 2906 | w = wid->width(); |
2892 | h = wid->height(); | 2907 | h = wid->height(); |
2893 | list.clear(); | 2908 | list.clear(); |
2894 | list << QString::number( x ); | 2909 | list << QString::number( x ); |
2895 | list << QString::number( y ); | 2910 | list << QString::number( y ); |
2896 | list << QString::number( w ); | 2911 | list << QString::number( w ); |
2897 | list << QString::number( h ); | 2912 | list << QString::number( h ); |
2898 | config->writeEntry("EditTodoLayout",list ); | 2913 | config->writeEntry("EditTodoLayout",list ); |
2899 | wid = getEventViewerDialog(); | 2914 | wid = getEventViewerDialog(); |
2900 | x = wid->geometry().x(); | 2915 | x = wid->geometry().x(); |
2901 | y = wid->geometry().y(); | 2916 | y = wid->geometry().y(); |
2902 | w = wid->width(); | 2917 | w = wid->width(); |
2903 | h = wid->height(); | 2918 | h = wid->height(); |
2904 | list.clear(); | 2919 | list.clear(); |
2905 | list << QString::number( x ); | 2920 | list << QString::number( x ); |
2906 | list << QString::number( y ); | 2921 | list << QString::number( y ); |
2907 | list << QString::number( w ); | 2922 | list << QString::number( w ); |
2908 | list << QString::number( h ); | 2923 | list << QString::number( h ); |
2909 | config->writeEntry("ViewerLayout",list ); | 2924 | config->writeEntry("ViewerLayout",list ); |
2910 | wid = mDialogManager->getSearchDialog(); | 2925 | wid = mDialogManager->getSearchDialog(); |
2911 | if ( wid ) { | 2926 | if ( wid ) { |
2912 | x = wid->geometry().x(); | 2927 | x = wid->geometry().x(); |
2913 | y = wid->geometry().y(); | 2928 | y = wid->geometry().y(); |
2914 | w = wid->width(); | 2929 | w = wid->width(); |
2915 | h = wid->height(); | 2930 | h = wid->height(); |
2916 | list.clear(); | 2931 | list.clear(); |
2917 | list << QString::number( x ); | 2932 | list << QString::number( x ); |
2918 | list << QString::number( y ); | 2933 | list << QString::number( y ); |
2919 | list << QString::number( w ); | 2934 | list << QString::number( w ); |
2920 | list << QString::number( h ); | 2935 | list << QString::number( h ); |
2921 | config->writeEntry("SearchLayout",list ); | 2936 | config->writeEntry("SearchLayout",list ); |
2922 | } | 2937 | } |
2923 | #endif | 2938 | #endif |
2924 | 2939 | ||
2925 | 2940 | ||
2926 | config->sync(); | 2941 | config->sync(); |
2927 | } | 2942 | } |
2928 | 2943 | ||
2929 | void CalendarView::readFilterSettings(KConfig *config) | 2944 | void CalendarView::readFilterSettings(KConfig *config) |
2930 | { | 2945 | { |
2931 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2946 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2932 | 2947 | ||
2933 | mFilters.clear(); | 2948 | mFilters.clear(); |
2934 | 2949 | ||
2935 | config->setGroup("General"); | 2950 | config->setGroup("General"); |
2936 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2951 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2937 | 2952 | ||
2938 | QStringList::ConstIterator it = filterList.begin(); | 2953 | QStringList::ConstIterator it = filterList.begin(); |
2939 | QStringList::ConstIterator end = filterList.end(); | 2954 | QStringList::ConstIterator end = filterList.end(); |
2940 | while(it != end) { | 2955 | while(it != end) { |
2941 | // kdDebug() << " filter: " << (*it) << endl; | 2956 | // kdDebug() << " filter: " << (*it) << endl; |
2942 | 2957 | ||
2943 | CalFilter *filter; | 2958 | CalFilter *filter; |
2944 | filter = new CalFilter(*it); | 2959 | filter = new CalFilter(*it); |
2945 | config->setGroup("Filter_" + (*it).utf8()); | 2960 | config->setGroup("Filter_" + (*it).utf8()); |
2946 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2961 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2947 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2962 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2948 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2963 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2949 | mFilters.append(filter); | 2964 | mFilters.append(filter); |
2950 | 2965 | ||
2951 | ++it; | 2966 | ++it; |
2952 | } | 2967 | } |
2953 | 2968 | ||
2954 | if (mFilters.count() == 0) { | 2969 | if (mFilters.count() == 0) { |
2955 | CalFilter *filter = new CalFilter(i18n("Default")); | 2970 | CalFilter *filter = new CalFilter(i18n("Default")); |
2956 | mFilters.append(filter); | 2971 | mFilters.append(filter); |
2957 | } | 2972 | } |
2958 | mFilterView->updateFilters(); | 2973 | mFilterView->updateFilters(); |
2959 | config->setGroup("FilterView"); | 2974 | config->setGroup("FilterView"); |
2960 | 2975 | ||
2961 | mFilterView->blockSignals(true); | 2976 | mFilterView->blockSignals(true); |
2962 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2977 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2963 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2978 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2964 | mFilterView->blockSignals(false); | 2979 | mFilterView->blockSignals(false); |
2965 | // We do it manually to avoid it being done twice by the above calls | 2980 | // We do it manually to avoid it being done twice by the above calls |
2966 | updateFilter(); | 2981 | updateFilter(); |
2967 | } | 2982 | } |
2968 | 2983 | ||
2969 | void CalendarView::writeFilterSettings(KConfig *config) | 2984 | void CalendarView::writeFilterSettings(KConfig *config) |
2970 | { | 2985 | { |
2971 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2986 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2972 | 2987 | ||
2973 | QStringList filterList; | 2988 | QStringList filterList; |
2974 | 2989 | ||
2975 | CalFilter *filter = mFilters.first(); | 2990 | CalFilter *filter = mFilters.first(); |
2976 | while(filter) { | 2991 | while(filter) { |
2977 | // kdDebug() << " fn: " << filter->name() << endl; | 2992 | // kdDebug() << " fn: " << filter->name() << endl; |
2978 | filterList << filter->name(); | 2993 | filterList << filter->name(); |
2979 | config->setGroup("Filter_" + filter->name().utf8()); | 2994 | config->setGroup("Filter_" + filter->name().utf8()); |
2980 | config->writeEntry("Criteria",filter->criteria()); | 2995 | config->writeEntry("Criteria",filter->criteria()); |
2981 | config->writeEntry("CategoryList",filter->categoryList()); | 2996 | config->writeEntry("CategoryList",filter->categoryList()); |
2982 | filter = mFilters.next(); | 2997 | filter = mFilters.next(); |
2983 | } | 2998 | } |
2984 | config->setGroup("General"); | 2999 | config->setGroup("General"); |
2985 | config->writeEntry("CalendarFilters",filterList); | 3000 | config->writeEntry("CalendarFilters",filterList); |
2986 | 3001 | ||
2987 | config->setGroup("FilterView"); | 3002 | config->setGroup("FilterView"); |
2988 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 3003 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2989 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 3004 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2990 | } | 3005 | } |
2991 | 3006 | ||
2992 | 3007 | ||
2993 | void CalendarView::goToday() | 3008 | void CalendarView::goToday() |
2994 | { | 3009 | { |
2995 | if ( mViewManager->currentView()->isMonthView() ) | 3010 | if ( mViewManager->currentView()->isMonthView() ) |
2996 | mNavigator->selectTodayMonth(); | 3011 | mNavigator->selectTodayMonth(); |
2997 | else | 3012 | else |
2998 | mNavigator->selectToday(); | 3013 | mNavigator->selectToday(); |
2999 | } | 3014 | } |
3000 | 3015 | ||
3001 | void CalendarView::goNext() | 3016 | void CalendarView::goNext() |
3002 | { | 3017 | { |
3003 | mNavigator->selectNext(); | 3018 | mNavigator->selectNext(); |
3004 | } | 3019 | } |
3005 | 3020 | ||
3006 | void CalendarView::goPrevious() | 3021 | void CalendarView::goPrevious() |
3007 | { | 3022 | { |
3008 | mNavigator->selectPrevious(); | 3023 | mNavigator->selectPrevious(); |
3009 | } | 3024 | } |
3010 | void CalendarView::goNextMonth() | 3025 | void CalendarView::goNextMonth() |
3011 | { | 3026 | { |
3012 | mNavigator->selectNextMonth(); | 3027 | mNavigator->selectNextMonth(); |
3013 | } | 3028 | } |
3014 | 3029 | ||
3015 | void CalendarView::goPreviousMonth() | 3030 | void CalendarView::goPreviousMonth() |
3016 | { | 3031 | { |
3017 | mNavigator->selectPreviousMonth(); | 3032 | mNavigator->selectPreviousMonth(); |
3018 | } | 3033 | } |
3019 | 3034 | ||
3020 | void CalendarView::updateConfig() | 3035 | void CalendarView::updateConfig() |
3021 | { | 3036 | { |
3022 | if ( KOPrefs::instance()->mUseAppColors ) | 3037 | if ( KOPrefs::instance()->mUseAppColors ) |
3023 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 3038 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
3024 | emit configChanged(); | 3039 | emit configChanged(); |
3025 | mTodoList->updateConfig(); | 3040 | mTodoList->updateConfig(); |
3026 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 3041 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
3027 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3042 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3028 | // To make the "fill window" configurations work | 3043 | // To make the "fill window" configurations work |
3029 | //mViewManager->raiseCurrentView(); | 3044 | //mViewManager->raiseCurrentView(); |
3030 | } | 3045 | } |
3031 | 3046 | ||
3032 | 3047 | ||
3033 | void CalendarView::eventChanged(Event *event) | 3048 | void CalendarView::eventChanged(Event *event) |
3034 | { | 3049 | { |
3035 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 3050 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
3036 | //updateUnmanagedViews(); | 3051 | //updateUnmanagedViews(); |
3037 | } | 3052 | } |
3038 | 3053 | ||
3039 | void CalendarView::eventAdded(Event *event) | 3054 | void CalendarView::eventAdded(Event *event) |
3040 | { | 3055 | { |
3041 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 3056 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
3042 | } | 3057 | } |
3043 | 3058 | ||
3044 | void CalendarView::eventToBeDeleted(Event *) | 3059 | void CalendarView::eventToBeDeleted(Event *) |
3045 | { | 3060 | { |
3046 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 3061 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
3047 | } | 3062 | } |
3048 | 3063 | ||
3049 | void CalendarView::eventDeleted() | 3064 | void CalendarView::eventDeleted() |
3050 | { | 3065 | { |
3051 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 3066 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
3052 | } | 3067 | } |
3053 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 3068 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
3054 | { | 3069 | { |
3055 | changeIncidenceDisplay((Incidence *)which, action); | 3070 | changeIncidenceDisplay((Incidence *)which, action); |
3056 | mDateNavigator->updateView(); //LR | 3071 | mDateNavigator->updateView(); //LR |
3057 | //mDialogManager->updateSearchDialog(); | 3072 | //mDialogManager->updateSearchDialog(); |
3058 | 3073 | ||
3059 | if (which) { | 3074 | if (which) { |
3060 | mViewManager->updateWNview(); | 3075 | mViewManager->updateWNview(); |
3061 | //mTodoList->updateView(); | 3076 | //mTodoList->updateView(); |
3062 | } | 3077 | } |
3063 | 3078 | ||
3064 | } | 3079 | } |
3065 | 3080 | ||
3066 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 3081 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
3067 | { | 3082 | { |
3068 | updateUnmanagedViews(); | 3083 | updateUnmanagedViews(); |
3069 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 3084 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
3070 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 3085 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
3071 | mCalendar->checkAlarmForIncidence( 0, true ); | 3086 | mCalendar->checkAlarmForIncidence( 0, true ); |
3072 | if ( mEventViewerDialog ) | 3087 | if ( mEventViewerDialog ) |
3073 | mEventViewerDialog->hide(); | 3088 | mEventViewerDialog->hide(); |
3074 | } | 3089 | } |
3075 | else | 3090 | else |
3076 | mCalendar->checkAlarmForIncidence( which , false ); | 3091 | mCalendar->checkAlarmForIncidence( which , false ); |
3077 | } | 3092 | } |
3078 | 3093 | ||
3079 | // most of the changeEventDisplays() right now just call the view's | 3094 | // most of the changeEventDisplays() right now just call the view's |
3080 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 3095 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
3081 | void CalendarView::changeEventDisplay(Event *which, int action) | 3096 | void CalendarView::changeEventDisplay(Event *which, int action) |
3082 | { | 3097 | { |
3083 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 3098 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
3084 | changeIncidenceDisplay((Incidence *)which, action); | 3099 | changeIncidenceDisplay((Incidence *)which, action); |
3085 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 3100 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
3086 | if ( flag_clearallviewsEventDisplay ) { | 3101 | if ( flag_clearallviewsEventDisplay ) { |
3087 | clearAllViews(); | 3102 | clearAllViews(); |
3088 | flag_clearallviewsEventDisplay = false; | 3103 | flag_clearallviewsEventDisplay = false; |
3089 | } | 3104 | } |
3090 | return; | 3105 | return; |
3091 | } | 3106 | } |
3092 | flag_clearallviewsEventDisplay = true; | 3107 | flag_clearallviewsEventDisplay = true; |
3093 | mDateNavigator->updateView(); | 3108 | mDateNavigator->updateView(); |
3094 | //mDialogManager->updateSearchDialog(); | 3109 | //mDialogManager->updateSearchDialog(); |
3095 | if (which) { | 3110 | if (which) { |
3096 | // If there is an event view visible update the display | 3111 | // If there is an event view visible update the display |
3097 | mViewManager->currentView()->changeEventDisplay(which,action); | 3112 | mViewManager->currentView()->changeEventDisplay(which,action); |
3098 | // TODO: check, if update needed | 3113 | // TODO: check, if update needed |
3099 | // if (which->getTodoStatus()) { | 3114 | // if (which->getTodoStatus()) { |
3100 | mTodoList->updateView(); | 3115 | mTodoList->updateView(); |
3101 | if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { | 3116 | if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { |
3102 | mConflictingEvent = which ; | 3117 | mConflictingEvent = which ; |
3103 | int time = 1000; | 3118 | int time = 1000; |
3104 | #ifdef DESKTOP_VERSION | 3119 | #ifdef DESKTOP_VERSION |
3105 | time = 500; | 3120 | time = 500; |
3106 | #endif | 3121 | #endif |
3107 | bool checkC = false; | 3122 | bool checkC = false; |
3108 | if ( mConflictingEvent->doesFloat() ) { | 3123 | if ( mConflictingEvent->doesFloat() ) { |
3109 | checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay | 3124 | checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay |
3110 | || KOPrefs::instance()->mCheckConflictsAllDayNonAD; | 3125 | || KOPrefs::instance()->mCheckConflictsAllDayNonAD; |
3111 | } else { | 3126 | } else { |
3112 | checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay | 3127 | checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay |
3113 | || KOPrefs::instance()->mCheckConflictsNonADNonAD; | 3128 | || KOPrefs::instance()->mCheckConflictsNonADNonAD; |
3114 | } | 3129 | } |
3115 | if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) | 3130 | if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) |
3116 | checkC = false; | 3131 | checkC = false; |
3117 | if ( checkC ) | 3132 | if ( checkC ) |
3118 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); | 3133 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); |
3119 | } | 3134 | } |
3120 | // } | 3135 | // } |
3121 | } else { | 3136 | } else { |
3122 | mViewManager->currentView()->updateView(); | 3137 | mViewManager->currentView()->updateView(); |
3123 | } | 3138 | } |
3124 | } | 3139 | } |
3125 | void CalendarView::checkConflictForEvent() | 3140 | void CalendarView::checkConflictForEvent() |
3126 | { | 3141 | { |
3127 | 3142 | ||
3128 | if (!KOPrefs::instance()->mConfirm) | 3143 | if (!KOPrefs::instance()->mConfirm) |
3129 | return; | 3144 | return; |
3130 | if ( ! mConflictingEvent ) return; | 3145 | if ( ! mConflictingEvent ) return; |
3131 | Event * conflictingEvent = mConflictingEvent; | 3146 | Event * conflictingEvent = mConflictingEvent; |
3132 | mConflictingEvent = 0; | 3147 | mConflictingEvent = 0; |
3133 | QDateTime current = QDateTime::currentDateTime(); | 3148 | QDateTime current = QDateTime::currentDateTime(); |
3134 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { | 3149 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { |
3135 | return; | 3150 | return; |
3136 | } | 3151 | } |
3137 | CalFilter *filterIN = 0; | 3152 | CalFilter *filterIN = 0; |
3138 | CalFilter *filterALL = 0; | 3153 | CalFilter *filterALL = 0; |
3139 | CalFilter *filter = mFilters.first(); | 3154 | CalFilter *filter = mFilters.first(); |
3140 | while(filter) { | 3155 | while(filter) { |
3141 | if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) | 3156 | if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) |
3142 | filterIN = filter; | 3157 | filterIN = filter; |
3143 | if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) | 3158 | if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) |
3144 | filterALL = filter; | 3159 | filterALL = filter; |
3145 | filter = mFilters.next(); | 3160 | filter = mFilters.next(); |
3146 | } | 3161 | } |
3147 | if ( filterIN ) { | 3162 | if ( filterIN ) { |
3148 | if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { | 3163 | if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { |
3149 | return; | 3164 | return; |
3150 | } | 3165 | } |
3151 | } | 3166 | } |
3152 | QPtrList<Event> testlist = mCalendar->events(); | 3167 | QPtrList<Event> testlist = mCalendar->events(); |
3153 | Event * test = testlist.first(); | 3168 | Event * test = testlist.first(); |
3154 | QDateTime conflict; | 3169 | QDateTime conflict; |
3155 | QDateTime retVal; | 3170 | QDateTime retVal; |
3156 | bool found = false; | 3171 | bool found = false; |
3157 | Event * cE = 0; | 3172 | Event * cE = 0; |
3158 | bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; | 3173 | bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; |
3159 | bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; | 3174 | bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; |
3160 | if ( !conflictingEvent->doesFloat() ) { | 3175 | if ( !conflictingEvent->doesFloat() ) { |
3161 | chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; | 3176 | chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; |
3162 | chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; | 3177 | chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; |
3163 | } | 3178 | } |
3164 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 3179 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
3165 | while ( test ) { | 3180 | while ( test ) { |
3166 | qApp->processEvents(); | 3181 | qApp->processEvents(); |
3167 | bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); | 3182 | bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); |
3168 | 3183 | ||
3169 | if ( !skip ) { | 3184 | if ( !skip ) { |
3170 | if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) | 3185 | if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) |
3171 | skip = true; | 3186 | skip = true; |
3172 | } | 3187 | } |
3173 | if ( !skip ) { | 3188 | if ( !skip ) { |
3174 | if ( filterALL ) { | 3189 | if ( filterALL ) { |
3175 | if ( !filterALL->filterCalendarItem( test ) ) { | 3190 | if ( !filterALL->filterCalendarItem( test ) ) { |
3176 | skip = true; | 3191 | skip = true; |
3177 | } | 3192 | } |
3178 | } | 3193 | } |
3179 | if ( !skip ) { | 3194 | if ( !skip ) { |
3180 | if ( found ) | 3195 | if ( found ) |
3181 | skip = !test->matchTime( ¤t, &conflict ); | 3196 | skip = !test->matchTime( ¤t, &conflict ); |
3182 | else | 3197 | else |
3183 | skip = !test->matchTime( ¤t, 0 ); | 3198 | skip = !test->matchTime( ¤t, 0 ); |
3184 | if ( !skip ) { | 3199 | if ( !skip ) { |
3185 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 3200 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
3186 | if ( ! found ) { | 3201 | if ( ! found ) { |
3187 | conflict = retVal; | 3202 | conflict = retVal; |
3188 | cE = test; | 3203 | cE = test; |
3189 | } else { | 3204 | } else { |
3190 | if ( retVal < conflict ) { | 3205 | if ( retVal < conflict ) { |
3191 | conflict = retVal; | 3206 | conflict = retVal; |
3192 | cE = test; | 3207 | cE = test; |
3193 | } | 3208 | } |
3194 | } | 3209 | } |
3195 | found = true; | 3210 | found = true; |
3196 | } | 3211 | } |
3197 | } | 3212 | } |
3198 | } | 3213 | } |
3199 | } | 3214 | } |
3200 | test = testlist.next(); | 3215 | test = testlist.next(); |
3201 | } | 3216 | } |
3202 | topLevelWidget()->setCaption( i18n("KO/Pi") ); | 3217 | topLevelWidget()->setCaption( i18n("KO/Pi") ); |
3203 | if ( found ) { | 3218 | if ( found ) { |
3204 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 3219 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
3205 | qApp->processEvents(); | 3220 | qApp->processEvents(); |
3206 | int km = KMessageBox::warningContinueCancel(this,mess, | 3221 | int km = KMessageBox::warningContinueCancel(this,mess, |
3207 | i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); | 3222 | i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); |
3208 | if ( km != KMessageBox::Continue ) { | 3223 | if ( km != KMessageBox::Continue ) { |
3209 | return; | 3224 | return; |
3210 | } | 3225 | } |
3211 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 3226 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
3212 | mViewManager->showDayView(); | 3227 | mViewManager->showDayView(); |
3213 | mNavigator->slotDaySelect( conflict.date() ); | 3228 | mNavigator->slotDaySelect( conflict.date() ); |
3214 | int hour = conflict.time().hour(); | 3229 | int hour = conflict.time().hour(); |
3215 | mViewManager->agendaView()->setStartHour( hour ); | 3230 | mViewManager->agendaView()->setStartHour( hour ); |
3216 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 3231 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
3217 | } else | 3232 | } else |
3218 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 3233 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
3219 | return; | 3234 | return; |
3220 | 3235 | ||
3221 | } | 3236 | } |
3222 | 3237 | ||
3223 | void CalendarView::updateTodoViews() | 3238 | void CalendarView::updateTodoViews() |
3224 | { | 3239 | { |
3225 | mTodoList->updateView(); | 3240 | mTodoList->updateView(); |
3226 | mViewManager->currentView()->updateView(); | 3241 | mViewManager->currentView()->updateView(); |
3227 | 3242 | ||
3228 | } | 3243 | } |
3229 | 3244 | ||
3230 | 3245 | ||
3231 | 3246 | ||
3232 | void CalendarView::clearAllViews() | 3247 | void CalendarView::clearAllViews() |
3233 | { | 3248 | { |
3234 | mTodoList->clearList(); | 3249 | mTodoList->clearList(); |
3235 | mViewManager->clearAllViews(); | 3250 | mViewManager->clearAllViews(); |
3236 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 3251 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
3237 | if ( sd ) { | 3252 | if ( sd ) { |
3238 | KOListView* kol = sd->listview(); | 3253 | KOListView* kol = sd->listview(); |
3239 | if ( kol ) | 3254 | if ( kol ) |
3240 | kol->clearList(); | 3255 | kol->clearList(); |
3241 | } | 3256 | } |
3242 | } | 3257 | } |
3243 | void CalendarView::updateView() | 3258 | void CalendarView::updateView() |
3244 | { | 3259 | { |
3245 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 3260 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
3246 | if ( flag_clearallviewsupdateView ) { | 3261 | if ( flag_clearallviewsupdateView ) { |
3247 | clearAllViews(); | 3262 | clearAllViews(); |
3248 | flag_clearallviewsupdateView = false; | 3263 | flag_clearallviewsupdateView = false; |
3249 | } | 3264 | } |
3250 | return; | 3265 | return; |
3251 | } | 3266 | } |
3252 | flag_clearallviewsupdateView = true; | 3267 | flag_clearallviewsupdateView = true; |
3253 | DateList tmpList = mNavigator->selectedDates(); | 3268 | DateList tmpList = mNavigator->selectedDates(); |
3254 | 3269 | ||
3255 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 3270 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
3256 | mTodoList->updateView(); | 3271 | mTodoList->updateView(); |
3257 | // We assume that the navigator only selects consecutive days. | 3272 | // We assume that the navigator only selects consecutive days. |
3258 | updateView( tmpList.first(), tmpList.last() ); | 3273 | updateView( tmpList.first(), tmpList.last() ); |
3259 | } | 3274 | } |
3260 | 3275 | ||
3261 | void CalendarView::updateUnmanagedViews() | 3276 | void CalendarView::updateUnmanagedViews() |
3262 | { | 3277 | { |
3263 | mDateNavigator->updateDayMatrix(); | 3278 | mDateNavigator->updateDayMatrix(); |
3264 | } | 3279 | } |
3265 | 3280 | ||
3266 | int CalendarView::msgItemDelete(const QString name) | 3281 | int CalendarView::msgItemDelete(const QString name) |
3267 | { | 3282 | { |
3268 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 3283 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
3269 | i18n("This item will be\npermanently deleted."), | 3284 | i18n("This item will be\npermanently deleted."), |
3270 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 3285 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
3271 | } | 3286 | } |
3272 | 3287 | ||
3273 | 3288 | ||
3274 | void CalendarView::edit_cut() | 3289 | void CalendarView::edit_cut() |
3275 | { | 3290 | { |
3276 | Event *anEvent=0; | 3291 | Event *anEvent=0; |
3277 | 3292 | ||
3278 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3293 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3279 | 3294 | ||
3280 | if (mViewManager->currentView()->isEventView()) { | 3295 | if (mViewManager->currentView()->isEventView()) { |
3281 | if ( incidence && incidence->typeID() == eventID ) { | 3296 | if ( incidence && incidence->typeID() == eventID ) { |
3282 | anEvent = static_cast<Event *>(incidence); | 3297 | anEvent = static_cast<Event *>(incidence); |
3283 | } | 3298 | } |
3284 | } | 3299 | } |
3285 | 3300 | ||
3286 | if (!anEvent) { | 3301 | if (!anEvent) { |
3287 | KNotifyClient::beep(); | 3302 | KNotifyClient::beep(); |
3288 | return; | 3303 | return; |
3289 | } | 3304 | } |
3290 | DndFactory factory( mCalendar ); | 3305 | DndFactory factory( mCalendar ); |
3291 | factory.cutIncidence(anEvent); | 3306 | factory.cutIncidence(anEvent); |
3292 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3307 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3293 | } | 3308 | } |
3294 | 3309 | ||
3295 | void CalendarView::edit_copy() | 3310 | void CalendarView::edit_copy() |
3296 | { | 3311 | { |
3297 | Event *anEvent=0; | 3312 | Event *anEvent=0; |
3298 | 3313 | ||
3299 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3314 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3300 | 3315 | ||
3301 | if (mViewManager->currentView()->isEventView()) { | 3316 | if (mViewManager->currentView()->isEventView()) { |
3302 | if ( incidence && incidence->typeID() == eventID ) { | 3317 | if ( incidence && incidence->typeID() == eventID ) { |
3303 | anEvent = static_cast<Event *>(incidence); | 3318 | anEvent = static_cast<Event *>(incidence); |
3304 | } | 3319 | } |
3305 | } | 3320 | } |
3306 | 3321 | ||
3307 | if (!anEvent) { | 3322 | if (!anEvent) { |
3308 | KNotifyClient::beep(); | 3323 | KNotifyClient::beep(); |
3309 | return; | 3324 | return; |
3310 | } | 3325 | } |
3311 | DndFactory factory( mCalendar ); | 3326 | DndFactory factory( mCalendar ); |
3312 | factory.copyIncidence(anEvent); | 3327 | factory.copyIncidence(anEvent); |
3313 | } | 3328 | } |
3314 | 3329 | ||
3315 | void CalendarView::edit_paste() | 3330 | void CalendarView::edit_paste() |
3316 | { | 3331 | { |
3317 | QDate date = mNavigator->selectedDates().first(); | 3332 | QDate date = mNavigator->selectedDates().first(); |
3318 | 3333 | ||
3319 | DndFactory factory( mCalendar ); | 3334 | DndFactory factory( mCalendar ); |
3320 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 3335 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
3321 | 3336 | ||
3322 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 3337 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
3323 | } | 3338 | } |
3324 | void CalendarView::edit_global_options() | 3339 | void CalendarView::edit_global_options() |
3325 | { | 3340 | { |
3326 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 3341 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
3327 | emit save(); | 3342 | emit save(); |
3328 | emit saveStopTimer(); | 3343 | emit saveStopTimer(); |
3329 | mDialogManager->showGlobalOptionsDialog(); | 3344 | mDialogManager->showGlobalOptionsDialog(); |
3330 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 3345 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
3331 | emit saveStopTimer(); | 3346 | emit saveStopTimer(); |
3332 | 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!"), | 3347 | 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!"), |
3333 | i18n("Timezone settings"),i18n("Reload"))) { | 3348 | i18n("Timezone settings"),i18n("Reload"))) { |
3334 | qDebug("KO: TZ reload cancelled "); | 3349 | qDebug("KO: TZ reload cancelled "); |
3335 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3350 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3336 | return; | 3351 | return; |
3337 | } | 3352 | } |
3338 | qDebug("KO: Timezone change "); | 3353 | qDebug("KO: Timezone change "); |
3339 | loadCalendars(); | 3354 | loadCalendars(); |
3340 | setModified(true); | 3355 | setModified(true); |
3341 | } | 3356 | } |
3342 | else | 3357 | else |
3343 | qDebug("KO: No tz change "); | 3358 | qDebug("KO: No tz change "); |
3344 | } | 3359 | } |
3345 | void CalendarView::edit_options() | 3360 | void CalendarView::edit_options() |
3346 | { | 3361 | { |
3347 | mDialogManager->showOptionsDialog(); | 3362 | mDialogManager->showOptionsDialog(); |
3348 | } | 3363 | } |
3349 | 3364 | ||
3350 | 3365 | ||
3351 | void CalendarView::slotSelectPickerDate( QDate d) | 3366 | void CalendarView::slotSelectPickerDate( QDate d) |
3352 | { | 3367 | { |
3353 | mDateFrame->hide(); | 3368 | mDateFrame->hide(); |
3354 | if ( mDatePickerMode == 1 ) { | 3369 | if ( mDatePickerMode == 1 ) { |
3355 | mNavigator->slotDaySelect( d ); | 3370 | mNavigator->slotDaySelect( d ); |
3356 | } else if ( mDatePickerMode == 2 ) { | 3371 | } else if ( mDatePickerMode == 2 ) { |
3357 | if ( mMoveIncidence->typeID() == todoID ) { | 3372 | if ( mMoveIncidence->typeID() == todoID ) { |
3358 | Todo * to = (Todo *) mMoveIncidence; | 3373 | Todo * to = (Todo *) mMoveIncidence; |
3359 | QTime tim; | 3374 | QTime tim; |
3360 | int len = 0; | 3375 | int len = 0; |
3361 | if ( to->hasStartDate() && to->hasDueDate() ) | 3376 | if ( to->hasStartDate() && to->hasDueDate() ) |
3362 | len = to->dtStart().secsTo( to->dtDue()); | 3377 | len = to->dtStart().secsTo( to->dtDue()); |
3363 | if ( to->hasDueDate() ) | 3378 | if ( to->hasDueDate() ) |
3364 | tim = to->dtDue().time(); | 3379 | tim = to->dtDue().time(); |
3365 | else { | 3380 | else { |
3366 | tim = QTime ( 0,0,0 ); | 3381 | tim = QTime ( 0,0,0 ); |
3367 | to->setFloats( true ); | 3382 | to->setFloats( true ); |
3368 | to->setHasDueDate( true ); | 3383 | to->setHasDueDate( true ); |
3369 | } | 3384 | } |
3370 | QDateTime dt ( d,tim ); | 3385 | QDateTime dt ( d,tim ); |
3371 | to->setDtDue( dt ); | 3386 | to->setDtDue( dt ); |
3372 | 3387 | ||
3373 | if ( to->hasStartDate() ) { | 3388 | if ( to->hasStartDate() ) { |
3374 | if ( len>0 ) | 3389 | if ( len>0 ) |
3375 | to->setDtStart(to->dtDue().addSecs( -len )); | 3390 | to->setDtStart(to->dtDue().addSecs( -len )); |
3376 | else | 3391 | else |
3377 | if (to->dtStart() > to->dtDue() ) | 3392 | if (to->dtStart() > to->dtDue() ) |
3378 | to->setDtStart(to->dtDue().addDays( -3 )); | 3393 | to->setDtStart(to->dtDue().addDays( -3 )); |
3379 | } | 3394 | } |
3380 | 3395 | ||
3381 | todoChanged( to ); | 3396 | todoChanged( to ); |
3382 | } else if ( mMoveIncidence->typeID() == eventID ) { | 3397 | } else if ( mMoveIncidence->typeID() == eventID ) { |
3383 | if ( mMoveIncidence->doesRecur() ) { | 3398 | if ( mMoveIncidence->doesRecur() ) { |
3384 | #if 0 | 3399 | #if 0 |
3385 | // PENDING implement this | 3400 | // PENDING implement this |
3386 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 3401 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3387 | mCalendar()->addIncidence( newInc ); | 3402 | mCalendar()->addIncidence( newInc ); |
3388 | if ( mMoveIncidence->typeID() == todoID ) | 3403 | if ( mMoveIncidence->typeID() == todoID ) |
3389 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 3404 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3390 | else | 3405 | else |
3391 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 3406 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3392 | mMoveIncidence = newInc; | 3407 | mMoveIncidence = newInc; |
3393 | 3408 | ||
3394 | #endif | 3409 | #endif |
3395 | } | 3410 | } |
3396 | QTime tim = mMoveIncidence->dtStart().time(); | 3411 | QTime tim = mMoveIncidence->dtStart().time(); |
3397 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 3412 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3398 | QDateTime dt ( d,tim ); | 3413 | QDateTime dt ( d,tim ); |
3399 | mMoveIncidence->setDtStart( dt ); | 3414 | mMoveIncidence->setDtStart( dt ); |
3400 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 3415 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3401 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 3416 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3402 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3417 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3403 | QTime tim = mMoveIncidence->dtStart().time(); | 3418 | QTime tim = mMoveIncidence->dtStart().time(); |
3404 | QDateTime dt ( d,tim ); | 3419 | QDateTime dt ( d,tim ); |
3405 | mMoveIncidence->setDtStart( dt ); | 3420 | mMoveIncidence->setDtStart( dt ); |
3406 | updateView(); | 3421 | updateView(); |
3407 | } | 3422 | } |
3408 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3423 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3409 | } | 3424 | } |
3410 | } | 3425 | } |
3411 | 3426 | ||
3412 | void CalendarView::removeCategories() | 3427 | void CalendarView::removeCategories() |
3413 | { | 3428 | { |
3414 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3429 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3415 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3430 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3416 | QStringList catIncList; | 3431 | QStringList catIncList; |
3417 | QStringList newCatList; | 3432 | QStringList newCatList; |
3418 | Incidence* inc = incList.first(); | 3433 | Incidence* inc = incList.first(); |
3419 | uint i; | 3434 | uint i; |
3420 | while ( inc ) { | 3435 | while ( inc ) { |
3421 | newCatList.clear(); | 3436 | newCatList.clear(); |
3422 | catIncList = inc->categories() ; | 3437 | catIncList = inc->categories() ; |
3423 | for( i = 0; i< catIncList.count(); ++i ) { | 3438 | for( i = 0; i< catIncList.count(); ++i ) { |
3424 | if ( catList.contains (catIncList[i])) | 3439 | if ( catList.contains (catIncList[i])) |
3425 | newCatList.append( catIncList[i] ); | 3440 | newCatList.append( catIncList[i] ); |
3426 | } | 3441 | } |
3427 | newCatList.sort(); | 3442 | newCatList.sort(); |
3428 | inc->setCategories( newCatList.join(",") ); | 3443 | inc->setCategories( newCatList.join(",") ); |
3429 | inc = incList.next(); | 3444 | inc = incList.next(); |
3430 | } | 3445 | } |
3431 | } | 3446 | } |
3432 | 3447 | ||
3433 | int CalendarView::addCategories() | 3448 | int CalendarView::addCategories() |
3434 | { | 3449 | { |
3435 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3450 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3436 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3451 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3437 | QStringList catIncList; | 3452 | QStringList catIncList; |
3438 | Incidence* inc = incList.first(); | 3453 | Incidence* inc = incList.first(); |
3439 | uint i; | 3454 | uint i; |
3440 | int count = 0; | 3455 | int count = 0; |
3441 | while ( inc ) { | 3456 | while ( inc ) { |
3442 | catIncList = inc->categories() ; | 3457 | catIncList = inc->categories() ; |
3443 | for( i = 0; i< catIncList.count(); ++i ) { | 3458 | for( i = 0; i< catIncList.count(); ++i ) { |
3444 | if ( !catList.contains (catIncList[i])) { | 3459 | if ( !catList.contains (catIncList[i])) { |
3445 | catList.append( catIncList[i] ); | 3460 | catList.append( catIncList[i] ); |
3446 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3461 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3447 | ++count; | 3462 | ++count; |
3448 | } | 3463 | } |
3449 | } | 3464 | } |
3450 | inc = incList.next(); | 3465 | inc = incList.next(); |
3451 | } | 3466 | } |
3452 | catList.sort(); | 3467 | catList.sort(); |
3453 | KOPrefs::instance()->mCustomCategories = catList; | 3468 | KOPrefs::instance()->mCustomCategories = catList; |
3454 | return count; | 3469 | return count; |
3455 | } | 3470 | } |
3456 | 3471 | ||
3457 | void CalendarView::editCategories() | 3472 | void CalendarView::editCategories() |
3458 | { | 3473 | { |
3459 | qDebug("CalendarView::editCategories() "); | 3474 | qDebug("CalendarView::editCategories() "); |
3460 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3475 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3461 | ced.exec(); | 3476 | ced.exec(); |
3462 | } | 3477 | } |
3463 | void CalendarView::manageCategories() | 3478 | void CalendarView::manageCategories() |
3464 | { | 3479 | { |
3465 | KOCatPrefs* cp = new KOCatPrefs(); | 3480 | KOCatPrefs* cp = new KOCatPrefs(); |
3466 | cp->show(); | 3481 | cp->show(); |
3467 | int w =cp->sizeHint().width() ; | 3482 | int w =cp->sizeHint().width() ; |
3468 | int h = cp->sizeHint().height() ; | 3483 | int h = cp->sizeHint().height() ; |
3469 | int dw = QApplication::desktop()->width(); | 3484 | int dw = QApplication::desktop()->width(); |
3470 | int dh = QApplication::desktop()->height(); | 3485 | int dh = QApplication::desktop()->height(); |
3471 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3486 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3472 | if ( !cp->exec() ) { | 3487 | if ( !cp->exec() ) { |
3473 | delete cp; | 3488 | delete cp; |
3474 | return; | 3489 | return; |
3475 | } | 3490 | } |
3476 | int count = 0; | 3491 | int count = 0; |
3477 | if ( cp->addCat() ) { | 3492 | if ( cp->addCat() ) { |
3478 | count = addCategories(); | 3493 | count = addCategories(); |
3479 | if ( count ) { | 3494 | if ( count ) { |
3480 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3495 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3481 | writeSettings(); | 3496 | writeSettings(); |
3482 | } else | 3497 | } else |
3483 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3498 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3484 | } else { | 3499 | } else { |
3485 | removeCategories(); | 3500 | removeCategories(); |
3486 | updateView(); | 3501 | updateView(); |
3487 | } | 3502 | } |
3488 | delete cp; | 3503 | delete cp; |
3489 | } | 3504 | } |
3490 | 3505 | ||
3491 | void CalendarView::beamIncidence(Incidence * Inc) | 3506 | void CalendarView::beamIncidence(Incidence * Inc) |
3492 | { | 3507 | { |
3493 | QPtrList<Incidence> delSel ; | 3508 | QPtrList<Incidence> delSel ; |
3494 | delSel.append(Inc); | 3509 | delSel.append(Inc); |
3495 | beamIncidenceList( delSel ); | 3510 | beamIncidenceList( delSel ); |
3496 | } | 3511 | } |
3497 | void CalendarView::beamCalendar() | 3512 | void CalendarView::beamCalendar() |
3498 | { | 3513 | { |
3499 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3514 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3500 | //qDebug("beamCalendar() "); | 3515 | //qDebug("beamCalendar() "); |
3501 | beamIncidenceList( delSel ); | 3516 | beamIncidenceList( delSel ); |
3502 | } | 3517 | } |
3503 | void CalendarView::beamFilteredCalendar() | 3518 | void CalendarView::beamFilteredCalendar() |
3504 | { | 3519 | { |
3505 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3520 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3506 | //qDebug("beamFilteredCalendar() "); | 3521 | //qDebug("beamFilteredCalendar() "); |
3507 | beamIncidenceList( delSel ); | 3522 | beamIncidenceList( delSel ); |
3508 | } | 3523 | } |
3509 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3524 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3510 | { | 3525 | { |
3511 | 3526 | ||
3512 | KOBeamPrefs beamDialog; | 3527 | KOBeamPrefs beamDialog; |
3513 | if ( beamDialog.exec () == QDialog::Rejected ) | 3528 | if ( beamDialog.exec () == QDialog::Rejected ) |
3514 | return; | 3529 | return; |
3515 | #ifdef DESKTOP_VERSION | 3530 | #ifdef DESKTOP_VERSION |
3516 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3531 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3517 | #else | 3532 | #else |
3518 | QString fn = "/tmp/kopibeamfile"; | 3533 | QString fn = "/tmp/kopibeamfile"; |
3519 | #endif | 3534 | #endif |
3520 | QString mes; | 3535 | QString mes; |
3521 | bool createbup = true; | 3536 | bool createbup = true; |
3522 | if ( createbup ) { | 3537 | if ( createbup ) { |
3523 | QString description = "\n"; | 3538 | QString description = "\n"; |
3524 | CalendarLocal* cal = new CalendarLocal(); | 3539 | CalendarLocal* cal = new CalendarLocal(); |
3525 | if ( beamDialog.beamLocal() ) | 3540 | if ( beamDialog.beamLocal() ) |
3526 | cal->setLocalTime(); | 3541 | cal->setLocalTime(); |
3527 | else | 3542 | else |
3528 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3543 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3529 | Incidence *incidence = delSel.first(); | 3544 | Incidence *incidence = delSel.first(); |
3530 | bool addText = false; | 3545 | bool addText = false; |
3531 | if ( delSel.count() < 10 ) | 3546 | if ( delSel.count() < 10 ) |
3532 | addText = true; | 3547 | addText = true; |
3533 | else { | 3548 | else { |
3534 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3549 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3535 | } | 3550 | } |
3536 | while ( incidence ) { | 3551 | while ( incidence ) { |
3537 | Incidence *in = incidence->clone(); | 3552 | Incidence *in = incidence->clone(); |
3538 | if ( ! in->summary().isEmpty() ) { | 3553 | if ( ! in->summary().isEmpty() ) { |
3539 | in->setDescription(""); | 3554 | in->setDescription(""); |
3540 | } else { | 3555 | } else { |
3541 | in->setSummary( in->description().left(20)); | 3556 | in->setSummary( in->description().left(20)); |
3542 | in->setDescription(""); | 3557 | in->setDescription(""); |
3543 | } | 3558 | } |
3544 | if ( addText ) | 3559 | if ( addText ) |
3545 | description += in->summary() + "\n"; | 3560 | description += in->summary() + "\n"; |
3546 | cal->addIncidence( in ); | 3561 | cal->addIncidence( in ); |
3547 | incidence = delSel.next(); | 3562 | incidence = delSel.next(); |
3548 | } | 3563 | } |
3549 | if ( beamDialog.beamVcal() ) { | 3564 | if ( beamDialog.beamVcal() ) { |
3550 | fn += ".vcs"; | 3565 | fn += ".vcs"; |
3551 | FileStorage storage( cal, fn, new VCalFormat ); | 3566 | FileStorage storage( cal, fn, new VCalFormat ); |
3552 | storage.save(); | 3567 | storage.save(); |
3553 | } else { | 3568 | } else { |
3554 | fn += ".ics"; | 3569 | fn += ".ics"; |
3555 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3570 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3556 | storage.save(); | 3571 | storage.save(); |
3557 | } | 3572 | } |
3558 | delete cal; | 3573 | delete cal; |
3559 | mes = i18n("KO/Pi: Ready for beaming"); | 3574 | mes = i18n("KO/Pi: Ready for beaming"); |
3560 | topLevelWidget()->setCaption(mes); | 3575 | topLevelWidget()->setCaption(mes); |
3561 | KApplication::convert2latin1( fn ); | 3576 | KApplication::convert2latin1( fn ); |
3562 | #ifndef DESKTOP_VERSION | 3577 | #ifndef DESKTOP_VERSION |
3563 | Ir *ir = new Ir( this ); | 3578 | Ir *ir = new Ir( this ); |
3564 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3579 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3565 | ir->send( fn, description, "text/x-vCalendar" ); | 3580 | ir->send( fn, description, "text/x-vCalendar" ); |
3566 | #endif | 3581 | #endif |
3567 | } | 3582 | } |
3568 | } | 3583 | } |
3569 | 3584 | ||
3570 | #ifndef DESKTOP_VERSION | 3585 | #ifndef DESKTOP_VERSION |
3571 | void CalendarView::beamDone( Ir *ir ) | 3586 | void CalendarView::beamDone( Ir *ir ) |
3572 | { | 3587 | { |
3573 | delete ir; | 3588 | delete ir; |
3574 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3589 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3575 | topLevelWidget()->raise(); | 3590 | topLevelWidget()->raise(); |
3576 | } | 3591 | } |
3577 | #else | 3592 | #else |
3578 | void CalendarView::beamDone( Ir *){;} | 3593 | void CalendarView::beamDone( Ir *){;} |
3579 | #endif | 3594 | #endif |
3580 | void CalendarView::moveIncidence(Incidence * inc ) | 3595 | void CalendarView::moveIncidence(Incidence * inc ) |
3581 | { | 3596 | { |
3582 | if ( !inc ) return; | 3597 | if ( !inc ) return; |
3583 | showDatePickerPopup(); | 3598 | showDatePickerPopup(); |
3584 | mDatePickerMode = 2; | 3599 | mDatePickerMode = 2; |
3585 | mMoveIncidence = inc ; | 3600 | mMoveIncidence = inc ; |
3586 | QDate da; | 3601 | QDate da; |
3587 | if ( mMoveIncidence->typeID() == todoID ) { | 3602 | if ( mMoveIncidence->typeID() == todoID ) { |
3588 | Todo * to = (Todo *) mMoveIncidence; | 3603 | Todo * to = (Todo *) mMoveIncidence; |
3589 | if ( to->hasDueDate() ) | 3604 | if ( to->hasDueDate() ) |
3590 | da = to->dtDue().date(); | 3605 | da = to->dtDue().date(); |
3591 | else | 3606 | else |
3592 | da = QDate::currentDate(); | 3607 | da = QDate::currentDate(); |
3593 | } else { | 3608 | } else { |
3594 | da = mMoveIncidence->dtStart().date(); | 3609 | da = mMoveIncidence->dtStart().date(); |
3595 | } | 3610 | } |
3596 | //PENDING set date for recurring incidence to date of recurrence | 3611 | //PENDING set date for recurring incidence to date of recurrence |
3597 | //mMoveIncidenceOldDate; | 3612 | //mMoveIncidenceOldDate; |
3598 | mDatePicker->setDate( da ); | 3613 | mDatePicker->setDate( da ); |
3599 | } | 3614 | } |
3600 | void CalendarView::showDatePickerPopup() | 3615 | void CalendarView::showDatePickerPopup() |
3601 | { | 3616 | { |
3602 | if ( mDateFrame->isVisible() ) | 3617 | if ( mDateFrame->isVisible() ) |
3603 | mDateFrame->hide(); | 3618 | mDateFrame->hide(); |
3604 | else { | 3619 | else { |
3605 | int offX = 0, offY = 0; | 3620 | int offX = 0, offY = 0; |
3606 | #ifdef DESKTOP_VERSION | 3621 | #ifdef DESKTOP_VERSION |
3607 | int w =mDatePicker->sizeHint().width() ; | 3622 | int w =mDatePicker->sizeHint().width() ; |
3608 | int h = mDatePicker->sizeHint().height() ; | 3623 | int h = mDatePicker->sizeHint().height() ; |
3609 | int dw = topLevelWidget()->width(); | 3624 | int dw = topLevelWidget()->width(); |
3610 | int dh = topLevelWidget()->height(); | 3625 | int dh = topLevelWidget()->height(); |
3611 | offX = topLevelWidget()->x(); | 3626 | offX = topLevelWidget()->x(); |
3612 | offY = topLevelWidget()->y(); | 3627 | offY = topLevelWidget()->y(); |
3613 | #else | 3628 | #else |
3614 | int w =mDatePicker->sizeHint().width() ; | 3629 | int w =mDatePicker->sizeHint().width() ; |
3615 | int h = mDatePicker->sizeHint().height() ; | 3630 | int h = mDatePicker->sizeHint().height() ; |
3616 | int dw = QApplication::desktop()->width(); | 3631 | int dw = QApplication::desktop()->width(); |
3617 | int dh = QApplication::desktop()->height(); | 3632 | int dh = QApplication::desktop()->height(); |
3618 | #endif | 3633 | #endif |
3619 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3634 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3620 | mDateFrame->show(); | 3635 | mDateFrame->show(); |
3621 | } | 3636 | } |
3622 | } | 3637 | } |
3623 | void CalendarView::showDatePicker( ) | 3638 | void CalendarView::showDatePicker( ) |
3624 | { | 3639 | { |
3625 | showDatePickerPopup(); | 3640 | showDatePickerPopup(); |
3626 | mDatePickerMode = 1; | 3641 | mDatePickerMode = 1; |
3627 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3642 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3628 | } | 3643 | } |
3629 | 3644 | ||
3630 | void CalendarView::showEventEditor() | 3645 | void CalendarView::showEventEditor() |
3631 | { | 3646 | { |
3632 | #ifdef DESKTOP_VERSION | 3647 | #ifdef DESKTOP_VERSION |
3633 | int x,y,w,h; | 3648 | int x,y,w,h; |
3634 | x = mEventEditor->geometry().x(); | 3649 | x = mEventEditor->geometry().x(); |
3635 | y = mEventEditor->geometry().y(); | 3650 | y = mEventEditor->geometry().y(); |
3636 | w = mEventEditor->width(); | 3651 | w = mEventEditor->width(); |
3637 | h = mEventEditor->height(); | 3652 | h = mEventEditor->height(); |
3638 | mEventEditor->show(); | 3653 | mEventEditor->show(); |
3639 | mEventEditor->setGeometry(x,y,w,h); | 3654 | mEventEditor->setGeometry(x,y,w,h); |
3640 | #else | 3655 | #else |
3641 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3656 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3642 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3657 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3643 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3658 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3644 | qApp->processEvents(); | 3659 | qApp->processEvents(); |
3645 | delete mEventEditor; | 3660 | delete mEventEditor; |
3646 | mEventEditor = mDialogManager->getEventEditor(); | 3661 | mEventEditor = mDialogManager->getEventEditor(); |
3647 | topLevelWidget()->setCaption( i18n("") ); | 3662 | topLevelWidget()->setCaption( i18n("") ); |
3648 | } | 3663 | } |
3649 | mEventEditor->showMaximized(); | 3664 | mEventEditor->showMaximized(); |
3650 | #endif | 3665 | #endif |
3651 | } | 3666 | } |
3652 | void CalendarView::showTodoEditor() | 3667 | void CalendarView::showTodoEditor() |
3653 | { | 3668 | { |
3654 | #ifdef DESKTOP_VERSION | 3669 | #ifdef DESKTOP_VERSION |
3655 | int x,y,w,h; | 3670 | int x,y,w,h; |
3656 | x = mTodoEditor->geometry().x(); | 3671 | x = mTodoEditor->geometry().x(); |
3657 | y = mTodoEditor->geometry().y(); | 3672 | y = mTodoEditor->geometry().y(); |
3658 | w = mTodoEditor->width(); | 3673 | w = mTodoEditor->width(); |
3659 | h = mTodoEditor->height(); | 3674 | h = mTodoEditor->height(); |
3660 | mTodoEditor->show(); | 3675 | mTodoEditor->show(); |
3661 | mTodoEditor->setGeometry(x,y,w,h); | 3676 | mTodoEditor->setGeometry(x,y,w,h); |
3662 | #else | 3677 | #else |
3663 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3678 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3664 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3679 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3665 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3680 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3666 | qApp->processEvents(); | 3681 | qApp->processEvents(); |
3667 | delete mTodoEditor; | 3682 | delete mTodoEditor; |
3668 | mTodoEditor = mDialogManager->getTodoEditor(); | 3683 | mTodoEditor = mDialogManager->getTodoEditor(); |
3669 | topLevelWidget()->setCaption( i18n("") ); | 3684 | topLevelWidget()->setCaption( i18n("") ); |
3670 | } | 3685 | } |
3671 | mTodoEditor->showMaximized(); | 3686 | mTodoEditor->showMaximized(); |
3672 | #endif | 3687 | #endif |
3673 | } | 3688 | } |
3674 | 3689 | ||
3675 | void CalendarView::cloneIncidence() | 3690 | void CalendarView::cloneIncidence() |
3676 | { | 3691 | { |
3677 | Incidence *incidence = currentSelection(); | 3692 | Incidence *incidence = currentSelection(); |
3678 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3693 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3679 | if ( incidence ) { | 3694 | if ( incidence ) { |
3680 | cloneIncidence(incidence); | 3695 | cloneIncidence(incidence); |
3681 | } | 3696 | } |
3682 | } | 3697 | } |
3683 | void CalendarView::moveIncidence() | 3698 | void CalendarView::moveIncidence() |
3684 | { | 3699 | { |
3685 | Incidence *incidence = currentSelection(); | 3700 | Incidence *incidence = currentSelection(); |
3686 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3701 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3687 | if ( incidence ) { | 3702 | if ( incidence ) { |
3688 | moveIncidence(incidence); | 3703 | moveIncidence(incidence); |
3689 | } | 3704 | } |
3690 | } | 3705 | } |
3691 | void CalendarView::beamIncidence() | 3706 | void CalendarView::beamIncidence() |
3692 | { | 3707 | { |
3693 | Incidence *incidence = currentSelection(); | 3708 | Incidence *incidence = currentSelection(); |
3694 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3709 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3695 | if ( incidence ) { | 3710 | if ( incidence ) { |
3696 | beamIncidence(incidence); | 3711 | beamIncidence(incidence); |
3697 | } | 3712 | } |
3698 | } | 3713 | } |
3699 | void CalendarView::toggleCancelIncidence() | 3714 | void CalendarView::toggleCancelIncidence() |
3700 | { | 3715 | { |
3701 | Incidence *incidence = currentSelection(); | 3716 | Incidence *incidence = currentSelection(); |
3702 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3717 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3703 | if ( incidence ) { | 3718 | if ( incidence ) { |
3704 | cancelIncidence(incidence); | 3719 | cancelIncidence(incidence); |
3705 | } | 3720 | } |
3706 | } | 3721 | } |
3707 | 3722 | ||
3708 | 3723 | ||
3709 | void CalendarView::cancelIncidence(Incidence * inc ) | 3724 | void CalendarView::cancelIncidence(Incidence * inc ) |
3710 | { | 3725 | { |
3711 | inc->setCancelled( ! inc->cancelled() ); | 3726 | inc->setCancelled( ! inc->cancelled() ); |
3712 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3727 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3713 | updateView(); | 3728 | updateView(); |
3714 | } | 3729 | } |
3715 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3730 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3716 | { | 3731 | { |
3717 | Incidence * newInc = orgInc->clone(); | 3732 | Incidence * newInc = orgInc->clone(); |
3718 | newInc->recreate(); | 3733 | newInc->recreate(); |
3719 | 3734 | ||
3720 | if ( newInc->typeID() == todoID ) { | 3735 | if ( newInc->typeID() == todoID ) { |
3721 | Todo* t = (Todo*) newInc; | 3736 | Todo* t = (Todo*) newInc; |
3722 | bool cloneSub = false; | 3737 | bool cloneSub = false; |
3723 | if ( orgInc->relations().count() ) { | 3738 | if ( orgInc->relations().count() ) { |
3724 | int result = KMessageBox::warningYesNoCancel(this, | 3739 | int result = KMessageBox::warningYesNoCancel(this, |
3725 | 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 ) ), | 3740 | 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 ) ), |
3726 | i18n("Todo has subtodos"), | 3741 | i18n("Todo has subtodos"), |
3727 | i18n("Yes"), | 3742 | i18n("Yes"), |
3728 | i18n("No")); | 3743 | i18n("No")); |
3729 | 3744 | ||
3730 | if ( result == KMessageBox::Cancel ) { | 3745 | if ( result == KMessageBox::Cancel ) { |
3731 | delete t; | 3746 | delete t; |
3732 | return; | 3747 | return; |
3733 | } | 3748 | } |
3734 | if (result == KMessageBox::Yes) cloneSub = true; | 3749 | if (result == KMessageBox::Yes) cloneSub = true; |
3735 | } | 3750 | } |
3736 | showTodoEditor(); | 3751 | showTodoEditor(); |
3737 | mTodoEditor->editTodo( t ); | 3752 | mTodoEditor->editTodo( t ); |
3738 | if ( mTodoEditor->exec() ) { | 3753 | if ( mTodoEditor->exec() ) { |
3739 | if ( cloneSub ) { | 3754 | if ( cloneSub ) { |
3740 | orgInc->cloneRelations( t ); | 3755 | orgInc->cloneRelations( t ); |
3741 | mCalendar->addIncidenceBranch( t ); | 3756 | mCalendar->addIncidenceBranch( t ); |
3742 | updateView(); | 3757 | updateView(); |
3743 | 3758 | ||
3744 | } else { | 3759 | } else { |
3745 | mCalendar->addTodo( t ); | 3760 | mCalendar->addTodo( t ); |
3746 | updateView(); | 3761 | updateView(); |
3747 | } | 3762 | } |
3748 | } else { | 3763 | } else { |
3749 | delete t; | 3764 | delete t; |
3750 | } | 3765 | } |
3751 | } | 3766 | } |
3752 | else if ( newInc->typeID() == eventID ) { | 3767 | else if ( newInc->typeID() == eventID ) { |
3753 | Event* e = (Event*) newInc; | 3768 | Event* e = (Event*) newInc; |
3754 | showEventEditor(); | 3769 | showEventEditor(); |
3755 | mEventEditor->editEvent( e ); | 3770 | mEventEditor->editEvent( e ); |
3756 | if ( mEventEditor->exec() ) { | 3771 | if ( mEventEditor->exec() ) { |
3757 | mCalendar->addEvent( e ); | 3772 | mCalendar->addEvent( e ); |
3758 | updateView(); | 3773 | updateView(); |
3759 | } else { | 3774 | } else { |
3760 | delete e; | 3775 | delete e; |
3761 | } | 3776 | } |
3762 | } else if ( newInc->typeID() == journalID ) { | 3777 | } else if ( newInc->typeID() == journalID ) { |
3763 | mCalendar->addJournal( (Journal*) newInc ); | 3778 | mCalendar->addJournal( (Journal*) newInc ); |
3764 | editJournal( (Journal*) newInc ); | 3779 | editJournal( (Journal*) newInc ); |
3765 | } | 3780 | } |
3766 | setActiveWindow(); | 3781 | setActiveWindow(); |
3767 | } | 3782 | } |
3768 | 3783 | ||
3769 | void CalendarView::newEvent() | 3784 | void CalendarView::newEvent() |
3770 | { | 3785 | { |
3771 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3786 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3772 | KOAgendaView *aView = mViewManager->agendaView(); | 3787 | KOAgendaView *aView = mViewManager->agendaView(); |
3773 | if (aView) { | 3788 | if (aView) { |
3774 | if (aView->selectionStart().isValid()) { | 3789 | if (aView->selectionStart().isValid()) { |
3775 | if (aView->selectedIsAllDay()) { | 3790 | if (aView->selectedIsAllDay()) { |
3776 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3791 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3777 | } else { | 3792 | } else { |
3778 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3793 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3779 | } | 3794 | } |
3780 | return; | 3795 | return; |
3781 | } | 3796 | } |
3782 | } | 3797 | } |
3783 | 3798 | ||
3784 | QDate date = mNavigator->selectedDates().first(); | 3799 | QDate date = mNavigator->selectedDates().first(); |
3785 | #if 0 | 3800 | #if 0 |
3786 | QDateTime current = QDateTime::currentDateTime(); | 3801 | QDateTime current = QDateTime::currentDateTime(); |
3787 | if ( date <= current.date() ) { | 3802 | if ( date <= current.date() ) { |
3788 | int hour = current.time().hour() +1; | 3803 | int hour = current.time().hour() +1; |
3789 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3804 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3790 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3805 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3791 | } else | 3806 | } else |
3792 | #endif | 3807 | #endif |
3793 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3808 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3794 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3809 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3795 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3810 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3796 | } | 3811 | } |
3797 | 3812 | ||
3798 | void CalendarView::newEvent(QDateTime fh) | 3813 | void CalendarView::newEvent(QDateTime fh) |
3799 | { | 3814 | { |
3800 | newEvent(fh, | 3815 | newEvent(fh, |
3801 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3816 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3802 | } | 3817 | } |
3803 | 3818 | ||
3804 | void CalendarView::newEvent(QDate dt) | 3819 | void CalendarView::newEvent(QDate dt) |
3805 | { | 3820 | { |
3806 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3821 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3807 | QDateTime(dt, QTime(0,0,0)), true); | 3822 | QDateTime(dt, QTime(0,0,0)), true); |
3808 | } | 3823 | } |
3809 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3824 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3810 | { | 3825 | { |
3811 | newEvent(fromHint, toHint, false); | 3826 | newEvent(fromHint, toHint, false); |
3812 | } | 3827 | } |
3813 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3828 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3814 | { | 3829 | { |
3815 | 3830 | ||
3816 | showEventEditor(); | 3831 | showEventEditor(); |
3817 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3832 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3818 | if ( mFilterView->filtersEnabled() ) { | 3833 | if ( mFilterView->filtersEnabled() ) { |
3819 | CalFilter *filter = mFilterView->selectedFilter(); | 3834 | CalFilter *filter = mFilterView->selectedFilter(); |
3820 | if (filter && filter->showCategories()) { | 3835 | if (filter && filter->showCategories()) { |
3821 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3836 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3822 | } | 3837 | } |
3823 | if ( filter ) | 3838 | if ( filter ) |
3824 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3839 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3825 | } | 3840 | } |
3826 | mEventEditor->exec(); | 3841 | mEventEditor->exec(); |
3827 | setActiveWindow(); | 3842 | setActiveWindow(); |
3828 | } | 3843 | } |
3829 | void CalendarView::todoAdded(Todo * t) | 3844 | void CalendarView::todoAdded(Todo * t) |
3830 | { | 3845 | { |
3831 | 3846 | ||
3832 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3847 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3833 | updateTodoViews(); | 3848 | updateTodoViews(); |
3834 | } | 3849 | } |
3835 | void CalendarView::todoChanged(Todo * t) | 3850 | void CalendarView::todoChanged(Todo * t) |
3836 | { | 3851 | { |
3837 | emit todoModified( t, 4 ); | 3852 | emit todoModified( t, 4 ); |
3838 | // updateTodoViews(); | 3853 | // updateTodoViews(); |
3839 | } | 3854 | } |
3840 | void CalendarView::todoToBeDeleted(Todo *) | 3855 | void CalendarView::todoToBeDeleted(Todo *) |
3841 | { | 3856 | { |
3842 | //qDebug("todoToBeDeleted(Todo *) "); | 3857 | //qDebug("todoToBeDeleted(Todo *) "); |
3843 | updateTodoViews(); | 3858 | updateTodoViews(); |
3844 | } | 3859 | } |
3845 | void CalendarView::todoDeleted() | 3860 | void CalendarView::todoDeleted() |
3846 | { | 3861 | { |
3847 | //qDebug(" todoDeleted()"); | 3862 | //qDebug(" todoDeleted()"); |
3848 | updateTodoViews(); | 3863 | updateTodoViews(); |
3849 | } | 3864 | } |
3850 | 3865 | ||
3851 | 3866 | ||
3852 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3867 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3853 | { | 3868 | { |
3854 | showTodoEditor(); | 3869 | showTodoEditor(); |
3855 | mTodoEditor->newTodo(dt,0,allday); | 3870 | mTodoEditor->newTodo(dt,0,allday); |
3856 | if ( mFilterView->filtersEnabled() ) { | 3871 | if ( mFilterView->filtersEnabled() ) { |
3857 | CalFilter *filter = mFilterView->selectedFilter(); | 3872 | CalFilter *filter = mFilterView->selectedFilter(); |
3858 | if (filter && filter->showCategories()) { | 3873 | if (filter && filter->showCategories()) { |
3859 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3874 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3860 | } | 3875 | } |
3861 | if ( filter ) | 3876 | if ( filter ) |
3862 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3877 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3863 | } | 3878 | } |
3864 | mTodoEditor->exec(); | 3879 | mTodoEditor->exec(); |
3865 | setActiveWindow(); | 3880 | setActiveWindow(); |
3866 | } | 3881 | } |
3867 | 3882 | ||
3868 | void CalendarView::newTodo() | 3883 | void CalendarView::newTodo() |
3869 | { | 3884 | { |
3870 | newTodoDateTime( QDateTime(),true ); | 3885 | newTodoDateTime( QDateTime(),true ); |
3871 | } | 3886 | } |
3872 | 3887 | ||
3873 | void CalendarView::newSubTodo() | 3888 | void CalendarView::newSubTodo() |
3874 | { | 3889 | { |
3875 | Todo *todo = selectedTodo(); | 3890 | Todo *todo = selectedTodo(); |
3876 | if ( todo ) newSubTodo( todo ); | 3891 | if ( todo ) newSubTodo( todo ); |
3877 | } | 3892 | } |
3878 | 3893 | ||
3879 | void CalendarView::newSubTodo(Todo *parentEvent) | 3894 | void CalendarView::newSubTodo(Todo *parentEvent) |
3880 | { | 3895 | { |
3881 | 3896 | ||
3882 | showTodoEditor(); | 3897 | showTodoEditor(); |
3883 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3898 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3884 | mTodoEditor->exec(); | 3899 | mTodoEditor->exec(); |
3885 | setActiveWindow(); | 3900 | setActiveWindow(); |
3886 | } | 3901 | } |
3887 | 3902 | ||
3888 | void CalendarView::newFloatingEvent() | 3903 | void CalendarView::newFloatingEvent() |
3889 | { | 3904 | { |
3890 | DateList tmpList = mNavigator->selectedDates(); | 3905 | DateList tmpList = mNavigator->selectedDates(); |
3891 | QDate date = tmpList.first(); | 3906 | QDate date = tmpList.first(); |
3892 | 3907 | ||
3893 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3908 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3894 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3909 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3895 | } | 3910 | } |
3896 | 3911 | ||
3897 | 3912 | ||
3898 | void CalendarView::editEvent( Event *event ) | 3913 | void CalendarView::editEvent( Event *event ) |
3899 | { | 3914 | { |
3900 | 3915 | ||
3901 | if ( !event ) return; | 3916 | if ( !event ) return; |
3902 | if ( event->isReadOnly() ) { | 3917 | if ( event->isReadOnly() ) { |
3903 | showEvent( event ); | 3918 | showEvent( event ); |
3904 | return; | 3919 | return; |
3905 | } | 3920 | } |
3906 | showEventEditor(); | 3921 | showEventEditor(); |
3907 | mEventEditor->editEvent( event , mFlagEditDescription); | 3922 | mEventEditor->editEvent( event , mFlagEditDescription); |
3908 | mEventEditor->exec(); | 3923 | mEventEditor->exec(); |
3909 | setActiveWindow(); | 3924 | setActiveWindow(); |
3910 | 3925 | ||
3911 | } | 3926 | } |
3912 | void CalendarView::editJournal( Journal *jour ) | 3927 | void CalendarView::editJournal( Journal *jour ) |
3913 | { | 3928 | { |
3914 | if ( !jour ) return; | 3929 | if ( !jour ) return; |
3915 | mDialogManager->hideSearchDialog(); | 3930 | mDialogManager->hideSearchDialog(); |
3916 | mViewManager->showJournalView(); | 3931 | mViewManager->showJournalView(); |
3917 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3932 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3918 | } | 3933 | } |
3919 | void CalendarView::editTodo( Todo *todo ) | 3934 | void CalendarView::editTodo( Todo *todo ) |
3920 | { | 3935 | { |
3921 | if ( !todo ) return; | 3936 | if ( !todo ) return; |
3922 | 3937 | ||
3923 | if ( todo->isReadOnly() ) { | 3938 | if ( todo->isReadOnly() ) { |
3924 | showTodo( todo ); | 3939 | showTodo( todo ); |
3925 | return; | 3940 | return; |
3926 | } | 3941 | } |
3927 | showTodoEditor(); | 3942 | showTodoEditor(); |
3928 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3943 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3929 | mTodoEditor->exec(); | 3944 | mTodoEditor->exec(); |
3930 | setActiveWindow(); | 3945 | setActiveWindow(); |
3931 | 3946 | ||
3932 | } | 3947 | } |
3933 | 3948 | ||
3934 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3949 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3935 | { | 3950 | { |
3936 | if ( !mEventViewerDialog ) { | 3951 | if ( !mEventViewerDialog ) { |
3937 | mEventViewerDialog = new KOEventViewerDialog(0); | 3952 | mEventViewerDialog = new KOEventViewerDialog(0); |
3938 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3953 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3939 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3954 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3940 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3955 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3941 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3956 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3942 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3957 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3943 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3958 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3944 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3959 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3945 | this, SLOT( slotViewerClosed() ) ); | 3960 | this, SLOT( slotViewerClosed() ) ); |
3946 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3961 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3947 | this, SLOT( todoChanged(Todo *) ) ); | 3962 | this, SLOT( todoChanged(Todo *) ) ); |
3948 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3963 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3949 | mEventViewerDialog->resize( 640, 480 ); | 3964 | mEventViewerDialog->resize( 640, 480 ); |
3950 | 3965 | ||
3951 | } | 3966 | } |
3952 | return mEventViewerDialog; | 3967 | return mEventViewerDialog; |
3953 | } | 3968 | } |
3954 | void CalendarView::showEvent(Event *event) | 3969 | void CalendarView::showEvent(Event *event) |
3955 | { | 3970 | { |
3956 | getEventViewerDialog()->setEvent(event); | 3971 | getEventViewerDialog()->setEvent(event); |
3957 | getEventViewerDialog()->showMe(); | 3972 | getEventViewerDialog()->showMe(); |
3958 | } | 3973 | } |
3959 | 3974 | ||
3960 | void CalendarView::showTodo(Todo *event) | 3975 | void CalendarView::showTodo(Todo *event) |
3961 | { | 3976 | { |
3962 | getEventViewerDialog()->setTodo(event); | 3977 | getEventViewerDialog()->setTodo(event); |
3963 | getEventViewerDialog()->showMe(); | 3978 | getEventViewerDialog()->showMe(); |
3964 | } | 3979 | } |
3965 | void CalendarView::showJournal( Journal *jour ) | 3980 | void CalendarView::showJournal( Journal *jour ) |
3966 | { | 3981 | { |
3967 | getEventViewerDialog()->setJournal(jour); | 3982 | getEventViewerDialog()->setJournal(jour); |
3968 | getEventViewerDialog()->showMe(); | 3983 | getEventViewerDialog()->showMe(); |
3969 | 3984 | ||
3970 | } | 3985 | } |
3971 | // void CalendarView::todoModified (Todo *event, int changed) | 3986 | // void CalendarView::todoModified (Todo *event, int changed) |
3972 | // { | 3987 | // { |
3973 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3988 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3974 | // // kdDebug() << "Todo modified and open" << endl; | 3989 | // // kdDebug() << "Todo modified and open" << endl; |
3975 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3990 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3976 | // // temp->modified (changed); | 3991 | // // temp->modified (changed); |
3977 | 3992 | ||
3978 | // // } | 3993 | // // } |
3979 | 3994 | ||
3980 | // mViewManager->updateView(); | 3995 | // mViewManager->updateView(); |
3981 | // } | 3996 | // } |
3982 | 3997 | ||
3983 | void CalendarView::appointment_show() | 3998 | void CalendarView::appointment_show() |
3984 | { | 3999 | { |
3985 | Event *anEvent = 0; | 4000 | Event *anEvent = 0; |
3986 | 4001 | ||
3987 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 4002 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3988 | 4003 | ||
3989 | if (mViewManager->currentView()->isEventView()) { | 4004 | if (mViewManager->currentView()->isEventView()) { |
3990 | if ( incidence && incidence->typeID() == eventID ) { | 4005 | if ( incidence && incidence->typeID() == eventID ) { |
3991 | anEvent = static_cast<Event *>(incidence); | 4006 | anEvent = static_cast<Event *>(incidence); |
3992 | } | 4007 | } |
3993 | } | 4008 | } |
3994 | 4009 | ||
3995 | if (!anEvent) { | 4010 | if (!anEvent) { |
3996 | KNotifyClient::beep(); | 4011 | KNotifyClient::beep(); |
3997 | return; | 4012 | return; |
3998 | } | 4013 | } |
3999 | 4014 | ||
4000 | showEvent(anEvent); | 4015 | showEvent(anEvent); |
4001 | } | 4016 | } |
4002 | 4017 | ||
4003 | void CalendarView::appointment_edit() | 4018 | void CalendarView::appointment_edit() |
4004 | { | 4019 | { |
4005 | Event *anEvent = 0; | 4020 | Event *anEvent = 0; |
4006 | 4021 | ||
4007 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 4022 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
4008 | 4023 | ||
4009 | if (mViewManager->currentView()->isEventView()) { | 4024 | if (mViewManager->currentView()->isEventView()) { |
4010 | if ( incidence && incidence->typeID() == eventID ) { | 4025 | if ( incidence && incidence->typeID() == eventID ) { |
4011 | anEvent = static_cast<Event *>(incidence); | 4026 | anEvent = static_cast<Event *>(incidence); |
4012 | } | 4027 | } |
4013 | } | 4028 | } |
4014 | 4029 | ||
4015 | if (!anEvent) { | 4030 | if (!anEvent) { |
4016 | KNotifyClient::beep(); | 4031 | KNotifyClient::beep(); |
4017 | return; | 4032 | return; |
4018 | } | 4033 | } |
4019 | 4034 | ||
4020 | editEvent(anEvent); | 4035 | editEvent(anEvent); |
4021 | } | 4036 | } |
4022 | 4037 | ||
4023 | void CalendarView::appointment_delete() | 4038 | void CalendarView::appointment_delete() |
4024 | { | 4039 | { |
4025 | Event *anEvent = 0; | 4040 | Event *anEvent = 0; |
4026 | 4041 | ||
4027 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 4042 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
4028 | 4043 | ||
4029 | if (mViewManager->currentView()->isEventView()) { | 4044 | if (mViewManager->currentView()->isEventView()) { |
4030 | if ( incidence && incidence->typeID() == eventID ) { | 4045 | if ( incidence && incidence->typeID() == eventID ) { |
4031 | anEvent = static_cast<Event *>(incidence); | 4046 | anEvent = static_cast<Event *>(incidence); |
4032 | } | 4047 | } |
4033 | } | 4048 | } |
4034 | 4049 | ||
4035 | if (!anEvent) { | 4050 | if (!anEvent) { |
4036 | KNotifyClient::beep(); | 4051 | KNotifyClient::beep(); |
4037 | return; | 4052 | return; |
4038 | } | 4053 | } |
4039 | 4054 | ||
4040 | deleteEvent(anEvent); | 4055 | deleteEvent(anEvent); |
4041 | } | 4056 | } |
4042 | 4057 | ||
4043 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 4058 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
4044 | { | 4059 | { |
4045 | if (!sub) return; | 4060 | if (!sub) return; |
4046 | if ( sub->relatedTo() == parent ) | 4061 | if ( sub->relatedTo() == parent ) |
4047 | return; | 4062 | return; |
4048 | sub->setRelatedTo(parent); | 4063 | sub->setRelatedTo(parent); |
4049 | sub->updated(); | 4064 | sub->updated(); |
4050 | setModified(true); | 4065 | setModified(true); |
4051 | updateView(); | 4066 | updateView(); |
4052 | } | 4067 | } |
4053 | void CalendarView::todo_unsub(Todo *anTodo ) | 4068 | void CalendarView::todo_unsub(Todo *anTodo ) |
4054 | { | 4069 | { |
4055 | todo_resub( 0, anTodo ); | 4070 | todo_resub( 0, anTodo ); |
4056 | } | 4071 | } |
4057 | 4072 | ||
4058 | void CalendarView::deleteTodo(Todo *todo) | 4073 | void CalendarView::deleteTodo(Todo *todo) |
4059 | { | 4074 | { |
4060 | if (!todo) { | 4075 | if (!todo) { |
4061 | KNotifyClient::beep(); | 4076 | KNotifyClient::beep(); |
4062 | return; | 4077 | return; |
4063 | } | 4078 | } |
4064 | if (KOPrefs::instance()->mConfirm) { | 4079 | if (KOPrefs::instance()->mConfirm) { |
4065 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 4080 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
4066 | if (!todo->relations().isEmpty()) { | 4081 | if (!todo->relations().isEmpty()) { |
4067 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 4082 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
4068 | 4083 | ||
4069 | } | 4084 | } |
4070 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 4085 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
4071 | case KMessageBox::Continue: // OK | 4086 | case KMessageBox::Continue: // OK |
4072 | bool deleteT = false; | 4087 | bool deleteT = false; |
4073 | if (!todo->relations().isEmpty()) { | 4088 | if (!todo->relations().isEmpty()) { |
4074 | deleteT = removeCompletedSubTodos( todo ); | 4089 | deleteT = removeCompletedSubTodos( todo ); |
4075 | } | 4090 | } |
4076 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 4091 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
4077 | if ( !deleteT ) { | 4092 | if ( !deleteT ) { |
4078 | checkExternalId( todo ); | 4093 | checkExternalId( todo ); |
4079 | calendar()->deleteTodo(todo); | 4094 | calendar()->deleteTodo(todo); |
4080 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4095 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4081 | } | 4096 | } |
4082 | updateView(); | 4097 | updateView(); |
4083 | break; | 4098 | break; |
4084 | } // switch | 4099 | } // switch |
4085 | } else { | 4100 | } else { |
4086 | checkExternalId( todo ); | 4101 | checkExternalId( todo ); |
4087 | mCalendar->deleteTodo(todo); | 4102 | mCalendar->deleteTodo(todo); |
4088 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4103 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4089 | updateView(); | 4104 | updateView(); |
4090 | } | 4105 | } |
4091 | 4106 | ||
4092 | emit updateSearchDialog(); | 4107 | emit updateSearchDialog(); |
4093 | } | 4108 | } |
4094 | void CalendarView::deleteJournal(Journal *jour) | 4109 | void CalendarView::deleteJournal(Journal *jour) |
4095 | { | 4110 | { |
4096 | if (!jour) { | 4111 | if (!jour) { |
4097 | KNotifyClient::beep(); | 4112 | KNotifyClient::beep(); |
4098 | return; | 4113 | return; |
4099 | } | 4114 | } |
4100 | if (KOPrefs::instance()->mConfirm) { | 4115 | if (KOPrefs::instance()->mConfirm) { |
4101 | 4116 | ||
4102 | QString des; | 4117 | QString des; |
4103 | if ( !jour->summary().isEmpty() ) { | 4118 | if ( !jour->summary().isEmpty() ) { |
4104 | des = jour->summary(); | 4119 | des = jour->summary(); |
4105 | } else { | 4120 | } else { |
4106 | des = jour->description().left(30); | 4121 | des = jour->description().left(30); |
4107 | des = des.simplifyWhiteSpace (); | 4122 | des = des.simplifyWhiteSpace (); |
4108 | des.replace (QRegExp ("\\n"),"" ); | 4123 | des.replace (QRegExp ("\\n"),"" ); |
4109 | des.replace (QRegExp ("\\r"),"" ); | 4124 | des.replace (QRegExp ("\\r"),"" ); |
4110 | } | 4125 | } |
4111 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 4126 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
4112 | case KMessageBox::Continue: // OK | 4127 | case KMessageBox::Continue: // OK |
4113 | calendar()->deleteJournal(jour); | 4128 | calendar()->deleteJournal(jour); |
4114 | updateView(); | 4129 | updateView(); |
4115 | break; | 4130 | break; |
4116 | } // switch | 4131 | } // switch |
4117 | } else { | 4132 | } else { |
4118 | calendar()->deleteJournal(jour);; | 4133 | calendar()->deleteJournal(jour);; |
4119 | updateView(); | 4134 | updateView(); |
4120 | } | 4135 | } |
4121 | emit updateSearchDialog(); | 4136 | emit updateSearchDialog(); |
4122 | } | 4137 | } |
4123 | 4138 | ||
4124 | void CalendarView::deleteEvent(Event *anEvent) | 4139 | void CalendarView::deleteEvent(Event *anEvent) |
4125 | { | 4140 | { |
4126 | if (!anEvent) { | 4141 | if (!anEvent) { |
4127 | KNotifyClient::beep(); | 4142 | KNotifyClient::beep(); |
4128 | return; | 4143 | return; |
4129 | } | 4144 | } |
4130 | 4145 | ||
4131 | if (anEvent->doesRecur()) { | 4146 | if (anEvent->doesRecur()) { |
4132 | QDate itemDate = mViewManager->currentSelectionDate(); | 4147 | QDate itemDate = mViewManager->currentSelectionDate(); |
4133 | int km; | 4148 | int km; |
4134 | if (!itemDate.isValid()) { | 4149 | if (!itemDate.isValid()) { |
4135 | //kdDebug() << "Date Not Valid" << endl; | 4150 | //kdDebug() << "Date Not Valid" << endl; |
4136 | if (KOPrefs::instance()->mConfirm) { | 4151 | if (KOPrefs::instance()->mConfirm) { |
4137 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4152 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4138 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 4153 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
4139 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 4154 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
4140 | if ( km == KMessageBox::Continue ) | 4155 | if ( km == KMessageBox::Continue ) |
4141 | km = KMessageBox::No; // No = all below | 4156 | km = KMessageBox::No; // No = all below |
4142 | } else | 4157 | } else |
4143 | km = KMessageBox::No; | 4158 | km = KMessageBox::No; |
4144 | } else { | 4159 | } else { |
4145 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4160 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4146 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 4161 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
4147 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 4162 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
4148 | i18n("KO/Pi Confirmation"),i18n("Current"), | 4163 | i18n("KO/Pi Confirmation"),i18n("Current"), |
4149 | i18n("All")); | 4164 | i18n("All")); |
4150 | } | 4165 | } |
4151 | switch(km) { | 4166 | switch(km) { |
4152 | 4167 | ||
4153 | case KMessageBox::No: // Continue // all | 4168 | case KMessageBox::No: // Continue // all |
4154 | //qDebug("KMessageBox::No "); | 4169 | //qDebug("KMessageBox::No "); |
4155 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4170 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4156 | schedule(Scheduler::Cancel,anEvent); | 4171 | schedule(Scheduler::Cancel,anEvent); |
4157 | 4172 | ||
4158 | checkExternalId( anEvent); | 4173 | checkExternalId( anEvent); |
4159 | mCalendar->deleteEvent(anEvent); | 4174 | mCalendar->deleteEvent(anEvent); |
4160 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 4175 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
4161 | break; | 4176 | break; |
4162 | 4177 | ||
4163 | // Disabled because it does not work | 4178 | // Disabled because it does not work |
4164 | //#if 0 | 4179 | //#if 0 |
4165 | case KMessageBox::Yes: // just this one | 4180 | case KMessageBox::Yes: // just this one |
4166 | //QDate qd = mNavigator->selectedDates().first(); | 4181 | //QDate qd = mNavigator->selectedDates().first(); |
4167 | //if (!qd.isValid()) { | 4182 | //if (!qd.isValid()) { |
4168 | // kdDebug() << "no date selected, or invalid date" << endl; | 4183 | // kdDebug() << "no date selected, or invalid date" << endl; |
4169 | // KNotifyClient::beep(); | 4184 | // KNotifyClient::beep(); |
4170 | // return; | 4185 | // return; |
4171 | //} | 4186 | //} |
4172 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 4187 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
4173 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 4188 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
4174 | anEvent->addExDate(itemDate); | 4189 | anEvent->addExDate(itemDate); |
4175 | int duration = anEvent->recurrence()->duration(); | 4190 | int duration = anEvent->recurrence()->duration(); |
4176 | if ( duration > 0 ) { | 4191 | if ( duration > 0 ) { |
4177 | anEvent->recurrence()->setDuration( duration - 1 ); | 4192 | anEvent->recurrence()->setDuration( duration - 1 ); |
4178 | } | 4193 | } |
4179 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 4194 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
4180 | } | 4195 | } |
4181 | break; | 4196 | break; |
4182 | //#endif | 4197 | //#endif |
4183 | } // switch | 4198 | } // switch |
4184 | } else { | 4199 | } else { |
4185 | if (KOPrefs::instance()->mConfirm) { | 4200 | if (KOPrefs::instance()->mConfirm) { |
4186 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4201 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4187 | i18n("\nAre you sure you want\nto delete this event?"), | 4202 | i18n("\nAre you sure you want\nto delete this event?"), |
4188 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 4203 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
4189 | case KMessageBox::Continue: // OK | 4204 | case KMessageBox::Continue: // OK |
4190 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4205 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4191 | schedule(Scheduler::Cancel,anEvent); | 4206 | schedule(Scheduler::Cancel,anEvent); |
4192 | checkExternalId( anEvent); | 4207 | checkExternalId( anEvent); |
4193 | mCalendar->deleteEvent(anEvent); | 4208 | mCalendar->deleteEvent(anEvent); |
4194 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4209 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4195 | break; | 4210 | break; |
4196 | } // switch | 4211 | } // switch |
4197 | } else { | 4212 | } else { |
4198 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4213 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4199 | schedule(Scheduler::Cancel,anEvent); | 4214 | schedule(Scheduler::Cancel,anEvent); |
4200 | checkExternalId( anEvent); | 4215 | checkExternalId( anEvent); |
4201 | mCalendar->deleteEvent(anEvent); | 4216 | mCalendar->deleteEvent(anEvent); |
4202 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4217 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4203 | } | 4218 | } |
4204 | } // if-else | 4219 | } // if-else |
4205 | emit updateSearchDialog(); | 4220 | emit updateSearchDialog(); |
4206 | } | 4221 | } |
4207 | 4222 | ||
4208 | bool CalendarView::deleteEvent(const QString &uid) | 4223 | bool CalendarView::deleteEvent(const QString &uid) |
4209 | { | 4224 | { |
4210 | Event *ev = mCalendar->event(uid); | 4225 | Event *ev = mCalendar->event(uid); |
4211 | if (ev) { | 4226 | if (ev) { |
4212 | deleteEvent(ev); | 4227 | deleteEvent(ev); |
4213 | return true; | 4228 | return true; |
4214 | } else { | 4229 | } else { |
4215 | return false; | 4230 | return false; |
4216 | } | 4231 | } |
4217 | } | 4232 | } |
4218 | 4233 | ||
4219 | /*****************************************************************************/ | 4234 | /*****************************************************************************/ |
4220 | 4235 | ||
4221 | void CalendarView::action_mail() | 4236 | void CalendarView::action_mail() |
4222 | { | 4237 | { |
4223 | #ifndef KORG_NOMAIL | 4238 | #ifndef KORG_NOMAIL |
4224 | KOMailClient mailClient; | 4239 | KOMailClient mailClient; |
4225 | 4240 | ||
4226 | Incidence *incidence = currentSelection(); | 4241 | Incidence *incidence = currentSelection(); |
4227 | 4242 | ||
4228 | if (!incidence) { | 4243 | if (!incidence) { |
4229 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4244 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4230 | return; | 4245 | return; |
4231 | } | 4246 | } |
4232 | if(incidence->attendeeCount() == 0 ) { | 4247 | if(incidence->attendeeCount() == 0 ) { |
4233 | KMessageBox::sorry(this, | 4248 | KMessageBox::sorry(this, |
4234 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4249 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4235 | return; | 4250 | return; |
4236 | } | 4251 | } |
4237 | 4252 | ||
4238 | CalendarLocal cal_tmp; | 4253 | CalendarLocal cal_tmp; |
4239 | Event *event = 0; | 4254 | Event *event = 0; |
4240 | Event *ev = 0; | 4255 | Event *ev = 0; |
4241 | if ( incidence && incidence->typeID() == eventID ) { | 4256 | if ( incidence && incidence->typeID() == eventID ) { |
4242 | event = static_cast<Event *>(incidence); | 4257 | event = static_cast<Event *>(incidence); |
4243 | ev = new Event(*event); | 4258 | ev = new Event(*event); |
4244 | cal_tmp.addEvent(ev); | 4259 | cal_tmp.addEvent(ev); |
4245 | } | 4260 | } |
4246 | ICalFormat mForm(); | 4261 | ICalFormat mForm(); |
4247 | QString attachment = mForm.toString( &cal_tmp ); | 4262 | QString attachment = mForm.toString( &cal_tmp ); |
4248 | if (ev) delete(ev); | 4263 | if (ev) delete(ev); |
4249 | 4264 | ||
4250 | mailClient.mailAttendees(currentSelection(), attachment); | 4265 | mailClient.mailAttendees(currentSelection(), attachment); |
4251 | 4266 | ||
4252 | #endif | 4267 | #endif |
4253 | 4268 | ||
4254 | #if 0 | 4269 | #if 0 |
4255 | Event *anEvent = 0; | 4270 | Event *anEvent = 0; |
4256 | if (mViewManager->currentView()->isEventView()) { | 4271 | if (mViewManager->currentView()->isEventView()) { |
4257 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 4272 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
4258 | } | 4273 | } |
4259 | 4274 | ||
4260 | if (!anEvent) { | 4275 | if (!anEvent) { |
4261 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4276 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4262 | return; | 4277 | return; |
4263 | } | 4278 | } |
4264 | if(anEvent->attendeeCount() == 0 ) { | 4279 | if(anEvent->attendeeCount() == 0 ) { |
4265 | KMessageBox::sorry(this, | 4280 | KMessageBox::sorry(this, |
4266 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4281 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4267 | return; | 4282 | return; |
4268 | } | 4283 | } |
4269 | 4284 | ||
4270 | mailobject.emailEvent(anEvent); | 4285 | mailobject.emailEvent(anEvent); |
4271 | #endif | 4286 | #endif |
4272 | } | 4287 | } |
4273 | 4288 | ||
4274 | 4289 | ||
4275 | void CalendarView::schedule_publish(Incidence *incidence) | 4290 | void CalendarView::schedule_publish(Incidence *incidence) |
4276 | { | 4291 | { |
4277 | Event *event = 0; | 4292 | Event *event = 0; |
4278 | Todo *todo = 0; | 4293 | Todo *todo = 0; |
4279 | 4294 | ||
4280 | if (incidence == 0) { | 4295 | if (incidence == 0) { |
4281 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4296 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4282 | if (incidence == 0) { | 4297 | if (incidence == 0) { |
4283 | incidence = mTodoList->selectedIncidences().first(); | 4298 | incidence = mTodoList->selectedIncidences().first(); |
4284 | } | 4299 | } |
4285 | } | 4300 | } |
4286 | if ( incidence && incidence->typeID() == eventID ) { | 4301 | if ( incidence && incidence->typeID() == eventID ) { |
4287 | event = static_cast<Event *>(incidence); | 4302 | event = static_cast<Event *>(incidence); |
4288 | } else { | 4303 | } else { |
4289 | if ( incidence && incidence->typeID() == todoID ) { | 4304 | if ( incidence && incidence->typeID() == todoID ) { |
4290 | todo = static_cast<Todo *>(incidence); | 4305 | todo = static_cast<Todo *>(incidence); |
4291 | } | 4306 | } |
4292 | } | 4307 | } |
4293 | 4308 | ||
4294 | if (!event && !todo) { | 4309 | if (!event && !todo) { |
4295 | KMessageBox::sorry(this,i18n("No event selected.")); | 4310 | KMessageBox::sorry(this,i18n("No event selected.")); |
4296 | return; | 4311 | return; |
4297 | } | 4312 | } |
4298 | 4313 | ||
4299 | PublishDialog *publishdlg = new PublishDialog(); | 4314 | PublishDialog *publishdlg = new PublishDialog(); |
4300 | if (incidence->attendeeCount()>0) { | 4315 | if (incidence->attendeeCount()>0) { |
4301 | QPtrList<Attendee> attendees = incidence->attendees(); | 4316 | QPtrList<Attendee> attendees = incidence->attendees(); |
4302 | attendees.first(); | 4317 | attendees.first(); |
4303 | while ( attendees.current()!=0 ) { | 4318 | while ( attendees.current()!=0 ) { |
4304 | publishdlg->addAttendee(attendees.current()); | 4319 | publishdlg->addAttendee(attendees.current()); |
4305 | attendees.next(); | 4320 | attendees.next(); |
4306 | } | 4321 | } |
4307 | } | 4322 | } |
4308 | bool send = true; | 4323 | bool send = true; |
4309 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 4324 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
4310 | if ( publishdlg->exec() != QDialog::Accepted ) | 4325 | if ( publishdlg->exec() != QDialog::Accepted ) |
4311 | send = false; | 4326 | send = false; |
4312 | } | 4327 | } |
4313 | if ( send ) { | 4328 | if ( send ) { |
4314 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4329 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4315 | if ( event ) { | 4330 | if ( event ) { |
4316 | Event *ev = new Event(*event); | 4331 | Event *ev = new Event(*event); |
4317 | ev->registerObserver(0); | 4332 | ev->registerObserver(0); |
4318 | ev->clearAttendees(); | 4333 | ev->clearAttendees(); |
4319 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4334 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4320 | delete(ev); | 4335 | delete(ev); |
4321 | } | 4336 | } |
4322 | } else { | 4337 | } else { |
4323 | if ( todo ) { | 4338 | if ( todo ) { |
4324 | Todo *ev = new Todo(*todo); | 4339 | Todo *ev = new Todo(*todo); |
4325 | ev->registerObserver(0); | 4340 | ev->registerObserver(0); |
4326 | ev->clearAttendees(); | 4341 | ev->clearAttendees(); |
4327 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4342 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4328 | delete(ev); | 4343 | delete(ev); |
4329 | } | 4344 | } |
4330 | } | 4345 | } |
4331 | } | 4346 | } |
4332 | } | 4347 | } |
4333 | delete publishdlg; | 4348 | delete publishdlg; |
4334 | } | 4349 | } |
4335 | 4350 | ||
4336 | void CalendarView::schedule_request(Incidence *incidence) | 4351 | void CalendarView::schedule_request(Incidence *incidence) |
4337 | { | 4352 | { |
4338 | schedule(Scheduler::Request,incidence); | 4353 | schedule(Scheduler::Request,incidence); |
4339 | } | 4354 | } |
4340 | 4355 | ||
4341 | void CalendarView::schedule_refresh(Incidence *incidence) | 4356 | void CalendarView::schedule_refresh(Incidence *incidence) |
4342 | { | 4357 | { |
4343 | schedule(Scheduler::Refresh,incidence); | 4358 | schedule(Scheduler::Refresh,incidence); |
4344 | } | 4359 | } |
4345 | 4360 | ||
4346 | void CalendarView::schedule_cancel(Incidence *incidence) | 4361 | void CalendarView::schedule_cancel(Incidence *incidence) |
4347 | { | 4362 | { |
4348 | schedule(Scheduler::Cancel,incidence); | 4363 | schedule(Scheduler::Cancel,incidence); |
4349 | } | 4364 | } |
4350 | 4365 | ||
4351 | void CalendarView::schedule_add(Incidence *incidence) | 4366 | void CalendarView::schedule_add(Incidence *incidence) |
4352 | { | 4367 | { |
4353 | schedule(Scheduler::Add,incidence); | 4368 | schedule(Scheduler::Add,incidence); |
4354 | } | 4369 | } |
4355 | 4370 | ||
4356 | void CalendarView::schedule_reply(Incidence *incidence) | 4371 | void CalendarView::schedule_reply(Incidence *incidence) |
4357 | { | 4372 | { |
4358 | schedule(Scheduler::Reply,incidence); | 4373 | schedule(Scheduler::Reply,incidence); |
4359 | } | 4374 | } |
4360 | 4375 | ||
4361 | void CalendarView::schedule_counter(Incidence *incidence) | 4376 | void CalendarView::schedule_counter(Incidence *incidence) |
4362 | { | 4377 | { |
4363 | schedule(Scheduler::Counter,incidence); | 4378 | schedule(Scheduler::Counter,incidence); |
4364 | } | 4379 | } |
4365 | 4380 | ||
4366 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 4381 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
4367 | { | 4382 | { |
4368 | schedule(Scheduler::Declinecounter,incidence); | 4383 | schedule(Scheduler::Declinecounter,incidence); |
4369 | } | 4384 | } |
4370 | 4385 | ||
4371 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 4386 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
4372 | { | 4387 | { |
4373 | QDateTime start = QDateTime::currentDateTime(); | 4388 | QDateTime start = QDateTime::currentDateTime(); |
4374 | QDateTime end = start.addDays(daysToPublish); | 4389 | QDateTime end = start.addDays(daysToPublish); |
4375 | 4390 | ||
4376 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4391 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
4377 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4392 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
4378 | 4393 | ||
4379 | 4394 | ||
4380 | PublishDialog *publishdlg = new PublishDialog(); | 4395 | PublishDialog *publishdlg = new PublishDialog(); |
4381 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4396 | if ( publishdlg->exec() == QDialog::Accepted ) { |
4382 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4397 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4383 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4398 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
4384 | delete(freebusy); | 4399 | delete(freebusy); |
4385 | } | 4400 | } |
4386 | } | 4401 | } |
4387 | delete publishdlg; | 4402 | delete publishdlg; |
4388 | } | 4403 | } |
4389 | 4404 | ||
4390 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4405 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4391 | { | 4406 | { |
4392 | Event *event = 0; | 4407 | Event *event = 0; |
4393 | Todo *todo = 0; | 4408 | Todo *todo = 0; |
4394 | 4409 | ||
4395 | if (incidence == 0) { | 4410 | if (incidence == 0) { |
4396 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4411 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4397 | if (incidence == 0) { | 4412 | if (incidence == 0) { |
4398 | incidence = mTodoList->selectedIncidences().first(); | 4413 | incidence = mTodoList->selectedIncidences().first(); |
4399 | } | 4414 | } |
4400 | } | 4415 | } |
4401 | if ( incidence && incidence->typeID() == eventID ) { | 4416 | if ( incidence && incidence->typeID() == eventID ) { |
4402 | event = static_cast<Event *>(incidence); | 4417 | event = static_cast<Event *>(incidence); |
4403 | } | 4418 | } |
4404 | if ( incidence && incidence->typeID() == todoID ) { | 4419 | if ( incidence && incidence->typeID() == todoID ) { |
4405 | todo = static_cast<Todo *>(incidence); | 4420 | todo = static_cast<Todo *>(incidence); |
4406 | } | 4421 | } |
4407 | 4422 | ||
4408 | if (!event && !todo) { | 4423 | if (!event && !todo) { |
4409 | KMessageBox::sorry(this,i18n("No event selected.")); | 4424 | KMessageBox::sorry(this,i18n("No event selected.")); |
4410 | return; | 4425 | return; |
4411 | } | 4426 | } |
4412 | 4427 | ||
4413 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4428 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4414 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4429 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4415 | return; | 4430 | return; |
4416 | } | 4431 | } |
4417 | 4432 | ||
4418 | Event *ev = 0; | 4433 | Event *ev = 0; |
4419 | if (event) ev = new Event(*event); | 4434 | if (event) ev = new Event(*event); |
4420 | Todo *to = 0; | 4435 | Todo *to = 0; |
4421 | if (todo) to = new Todo(*todo); | 4436 | if (todo) to = new Todo(*todo); |
4422 | 4437 | ||
4423 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4438 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4424 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4439 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4425 | if (!me) { | 4440 | if (!me) { |
4426 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4441 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4427 | return; | 4442 | return; |
4428 | } | 4443 | } |
4429 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4444 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4430 | StatusDialog *statdlg = new StatusDialog(this); | 4445 | StatusDialog *statdlg = new StatusDialog(this); |
4431 | if (!statdlg->exec()==QDialog::Accepted) return; | 4446 | if (!statdlg->exec()==QDialog::Accepted) return; |
4432 | me->setStatus( statdlg->status() ); | 4447 | me->setStatus( statdlg->status() ); |
4433 | delete(statdlg); | 4448 | delete(statdlg); |
4434 | } | 4449 | } |
4435 | Attendee *menew = new Attendee(*me); | 4450 | Attendee *menew = new Attendee(*me); |
4436 | if (ev) { | 4451 | if (ev) { |
4437 | ev->clearAttendees(); | 4452 | ev->clearAttendees(); |
4438 | ev->addAttendee(menew,false); | 4453 | ev->addAttendee(menew,false); |
4439 | } else { | 4454 | } else { |
4440 | if (to) { | 4455 | if (to) { |
4441 | todo->clearAttendees(); | 4456 | todo->clearAttendees(); |
4442 | todo->addAttendee(menew,false); | 4457 | todo->addAttendee(menew,false); |
4443 | } | 4458 | } |
4444 | } | 4459 | } |
4445 | } | 4460 | } |
4446 | 4461 | ||
4447 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4462 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4448 | if (ev) { | 4463 | if (ev) { |
4449 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4464 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4450 | } else { | 4465 | } else { |
4451 | if (to) { | 4466 | if (to) { |
4452 | if ( !dlg->addMessage(to,method) ) delete(to); | 4467 | if ( !dlg->addMessage(to,method) ) delete(to); |
4453 | } | 4468 | } |
4454 | } | 4469 | } |
4455 | } | 4470 | } |
4456 | 4471 | ||
4457 | void CalendarView::openAddressbook() | 4472 | void CalendarView::openAddressbook() |
4458 | { | 4473 | { |
4459 | KRun::runCommand("kaddressbook"); | 4474 | KRun::runCommand("kaddressbook"); |
4460 | } | 4475 | } |
4461 | 4476 | ||
4462 | void CalendarView::setModified(bool modified) | 4477 | void CalendarView::setModified(bool modified) |
4463 | { | 4478 | { |
4464 | //qDebug("CalendarView::setModified %d ", modified); | 4479 | //qDebug("CalendarView::setModified %d ", modified); |
4465 | if ( modified ) | 4480 | if ( modified ) |
4466 | emit signalmodified(); | 4481 | emit signalmodified(); |
4467 | mModified = modified; | 4482 | mModified = modified; |
4468 | if ( mModified ) | 4483 | if ( mModified ) |
4469 | emit modifiedChanged(mModified); | 4484 | emit modifiedChanged(mModified); |
4470 | 4485 | ||
4471 | } | 4486 | } |
4472 | 4487 | ||
4473 | bool CalendarView::isReadOnly() | 4488 | bool CalendarView::isReadOnly() |
4474 | { | 4489 | { |
4475 | return mReadOnly; | 4490 | return mReadOnly; |
4476 | } | 4491 | } |
4477 | 4492 | ||
4478 | void CalendarView::setReadOnly(bool readOnly) | 4493 | void CalendarView::setReadOnly(bool readOnly) |
4479 | { | 4494 | { |
4480 | if (mReadOnly != readOnly) { | 4495 | if (mReadOnly != readOnly) { |
4481 | mReadOnly = readOnly; | 4496 | mReadOnly = readOnly; |
4482 | emit readOnlyChanged(mReadOnly); | 4497 | emit readOnlyChanged(mReadOnly); |
4483 | } | 4498 | } |
4484 | } | 4499 | } |
4485 | 4500 | ||
4486 | bool CalendarView::isModified() | 4501 | bool CalendarView::isModified() |
4487 | { | 4502 | { |
4488 | return mModified; | 4503 | return mModified; |
4489 | } | 4504 | } |
4490 | void CalendarView::slotprintSelInc() | 4505 | void CalendarView::slotprintSelInc() |
4491 | { | 4506 | { |
4492 | if ( currentSelection() == 0 ) { | 4507 | if ( currentSelection() == 0 ) { |
4493 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4508 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4494 | return; | 4509 | return; |
4495 | } | 4510 | } |
4496 | showIncidence(); | 4511 | showIncidence(); |
4497 | getEventViewerDialog()->print(); | 4512 | getEventViewerDialog()->print(); |
4498 | 4513 | ||
4499 | } | 4514 | } |
4500 | void CalendarView::printSetup() | 4515 | void CalendarView::printSetup() |
4501 | { | 4516 | { |
4502 | #ifndef KORG_NOPRINTER | 4517 | #ifndef KORG_NOPRINTER |
4503 | createPrinter(); | 4518 | createPrinter(); |
4504 | 4519 | ||
4505 | mCalPrinter->setupPrinter(); | 4520 | mCalPrinter->setupPrinter(); |
4506 | #endif | 4521 | #endif |
4507 | } | 4522 | } |
4508 | 4523 | ||
4509 | void CalendarView::print() | 4524 | void CalendarView::print() |
4510 | { | 4525 | { |
4511 | #ifndef KORG_NOPRINTER | 4526 | #ifndef KORG_NOPRINTER |
4512 | createPrinter(); | 4527 | createPrinter(); |
4513 | 4528 | ||
4514 | DateList tmpDateList = mNavigator->selectedDates(); | 4529 | DateList tmpDateList = mNavigator->selectedDates(); |
4515 | mCalPrinter->print(CalPrinter::Month, | 4530 | mCalPrinter->print(CalPrinter::Month, |
4516 | tmpDateList.first(), tmpDateList.last()); | 4531 | tmpDateList.first(), tmpDateList.last()); |
4517 | #endif | 4532 | #endif |
4518 | } | 4533 | } |
4519 | 4534 | ||
4520 | void CalendarView::printPreview() | 4535 | void CalendarView::printPreview() |
4521 | { | 4536 | { |
4522 | #ifndef KORG_NOPRINTER | 4537 | #ifndef KORG_NOPRINTER |
4523 | kdDebug() << "CalendarView::printPreview()" << endl; | 4538 | kdDebug() << "CalendarView::printPreview()" << endl; |
4524 | 4539 | ||
4525 | createPrinter(); | 4540 | createPrinter(); |
4526 | 4541 | ||
4527 | DateList tmpDateList = mNavigator->selectedDates(); | 4542 | DateList tmpDateList = mNavigator->selectedDates(); |
4528 | 4543 | ||
4529 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4544 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4530 | tmpDateList.last()); | 4545 | tmpDateList.last()); |
4531 | #endif | 4546 | #endif |
4532 | } | 4547 | } |
4533 | bool CalendarView::exportICalendar( QString filename ) | 4548 | bool CalendarView::exportICalendar( QString filename ) |
4534 | { | 4549 | { |
4535 | // Force correct extension | 4550 | // Force correct extension |
4536 | if (filename.right(4) != ".ics") filename += ".ics"; | 4551 | if (filename.right(4) != ".ics") filename += ".ics"; |
4537 | 4552 | ||
4538 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4553 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4539 | return storage.save(); | 4554 | return storage.save(); |
4540 | } | 4555 | } |
4541 | 4556 | ||
4542 | bool CalendarView::exportICalendar() | 4557 | bool CalendarView::exportICalendar() |
4543 | { | 4558 | { |
4544 | return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); | 4559 | return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); |
4545 | } | 4560 | } |
4546 | 4561 | ||
4547 | bool CalendarView::exportVCalendar( QString filename ) | 4562 | bool CalendarView::exportVCalendar( QString filename ) |
4548 | { | 4563 | { |
4549 | if (mCalendar->journals().count() > 0) { | 4564 | if (mCalendar->journals().count() > 0) { |
4550 | int result = KMessageBox::warningContinueCancel(this, | 4565 | int result = KMessageBox::warningContinueCancel(this, |
4551 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4566 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4552 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4567 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4553 | true); | 4568 | true); |
4554 | if (result != KMessageBox::Continue) return false; | 4569 | if (result != KMessageBox::Continue) return false; |
4555 | } | 4570 | } |
4556 | 4571 | ||
4557 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4572 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4558 | 4573 | ||
4559 | // Force correct extension | 4574 | // Force correct extension |
4560 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4575 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4561 | 4576 | ||
4562 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4577 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4563 | return storage.save(); | 4578 | return storage.save(); |
4564 | 4579 | ||
4565 | } | 4580 | } |
4566 | 4581 | ||
4567 | void CalendarView::eventUpdated(Incidence *) | 4582 | void CalendarView::eventUpdated(Incidence *) |
4568 | { | 4583 | { |
4569 | setModified(); | 4584 | setModified(); |
4570 | // Don't call updateView here. The code, which has caused the update of the | 4585 | // Don't call updateView here. The code, which has caused the update of the |
4571 | // event is responsible for updating the view. | 4586 | // event is responsible for updating the view. |
4572 | // updateView(); | 4587 | // updateView(); |
4573 | } | 4588 | } |
4574 | 4589 | ||
4575 | void CalendarView::adaptNavigationUnits() | 4590 | void CalendarView::adaptNavigationUnits() |
4576 | { | 4591 | { |
4577 | if (mViewManager->currentView()->isEventView()) { | 4592 | if (mViewManager->currentView()->isEventView()) { |
4578 | int days = mViewManager->currentView()->currentDateCount(); | 4593 | int days = mViewManager->currentView()->currentDateCount(); |
4579 | if (days == 1) { | 4594 | if (days == 1) { |
4580 | emit changeNavStringPrev(i18n("&Previous Day")); | 4595 | emit changeNavStringPrev(i18n("&Previous Day")); |
4581 | emit changeNavStringNext(i18n("&Next Day")); | 4596 | emit changeNavStringNext(i18n("&Next Day")); |
4582 | } else { | 4597 | } else { |
4583 | emit changeNavStringPrev(i18n("&Previous Week")); | 4598 | emit changeNavStringPrev(i18n("&Previous Week")); |
4584 | emit changeNavStringNext(i18n("&Next Week")); | 4599 | emit changeNavStringNext(i18n("&Next Week")); |
4585 | } | 4600 | } |
4586 | } | 4601 | } |
4587 | } | 4602 | } |
4588 | 4603 | ||
4589 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4604 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4590 | { | 4605 | { |
4591 | if ( incidence ) mTodoList->clearSelection(); | 4606 | if ( incidence ) mTodoList->clearSelection(); |
4592 | processIncidenceSelection( incidence ); | 4607 | processIncidenceSelection( incidence ); |
4593 | } | 4608 | } |
4594 | 4609 | ||
4595 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4610 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4596 | { | 4611 | { |
4597 | if ( incidence && mViewManager->currentView() ) { | 4612 | if ( incidence && mViewManager->currentView() ) { |
4598 | mViewManager->currentView()->clearSelection(); | 4613 | mViewManager->currentView()->clearSelection(); |
4599 | } | 4614 | } |
4600 | processIncidenceSelection( incidence ); | 4615 | processIncidenceSelection( incidence ); |
4601 | } | 4616 | } |
4602 | 4617 | ||
4603 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4618 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4604 | { | 4619 | { |
4605 | emit incidenceSelected( incidence ); | 4620 | emit incidenceSelected( incidence ); |
4606 | if ( incidence == mSelectedIncidence ) return; | 4621 | if ( incidence == mSelectedIncidence ) return; |
4607 | mSelectedIncidence = incidence; | 4622 | mSelectedIncidence = incidence; |
4608 | 4623 | ||
4609 | if ( incidence && incidence->typeID() == eventID ) { | 4624 | if ( incidence && incidence->typeID() == eventID ) { |
4610 | Event *event = static_cast<Event *>( incidence ); | 4625 | Event *event = static_cast<Event *>( incidence ); |
4611 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4626 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4612 | emit organizerEventsSelected( true ); | 4627 | emit organizerEventsSelected( true ); |
4613 | } else { | 4628 | } else { |
4614 | emit organizerEventsSelected(false); | 4629 | emit organizerEventsSelected(false); |
4615 | } | 4630 | } |
4616 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4631 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4617 | KOPrefs::instance()->email() ) ) { | 4632 | KOPrefs::instance()->email() ) ) { |
4618 | emit groupEventsSelected( true ); | 4633 | emit groupEventsSelected( true ); |
4619 | } else { | 4634 | } else { |
4620 | emit groupEventsSelected(false); | 4635 | emit groupEventsSelected(false); |
4621 | } | 4636 | } |
4622 | return; | 4637 | return; |
4623 | } else { | 4638 | } else { |
4624 | if ( incidence && incidence->typeID() == todoID ) { | 4639 | if ( incidence && incidence->typeID() == todoID ) { |
4625 | emit todoSelected( true ); | 4640 | emit todoSelected( true ); |
4626 | Todo *event = static_cast<Todo *>( incidence ); | 4641 | Todo *event = static_cast<Todo *>( incidence ); |
4627 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4642 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4628 | emit organizerEventsSelected( true ); | 4643 | emit organizerEventsSelected( true ); |
4629 | } else { | 4644 | } else { |
4630 | emit organizerEventsSelected(false); | 4645 | emit organizerEventsSelected(false); |
4631 | } | 4646 | } |
4632 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4647 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4633 | KOPrefs::instance()->email() ) ) { | 4648 | KOPrefs::instance()->email() ) ) { |
4634 | emit groupEventsSelected( true ); | 4649 | emit groupEventsSelected( true ); |
4635 | } else { | 4650 | } else { |
4636 | emit groupEventsSelected(false); | 4651 | emit groupEventsSelected(false); |
4637 | } | 4652 | } |
4638 | return; | 4653 | return; |
4639 | } else { | 4654 | } else { |
4640 | emit todoSelected( false ); | 4655 | emit todoSelected( false ); |
4641 | emit organizerEventsSelected(false); | 4656 | emit organizerEventsSelected(false); |
4642 | emit groupEventsSelected(false); | 4657 | emit groupEventsSelected(false); |
4643 | } | 4658 | } |
4644 | return; | 4659 | return; |
4645 | } | 4660 | } |
4646 | 4661 | ||
4647 | /* if ( incidence && incidence->typeID() == todoID ) { | 4662 | /* if ( incidence && incidence->typeID() == todoID ) { |
4648 | emit todoSelected( true ); | 4663 | emit todoSelected( true ); |
4649 | } else { | 4664 | } else { |
4650 | emit todoSelected( false ); | 4665 | emit todoSelected( false ); |
4651 | }*/ | 4666 | }*/ |
4652 | } | 4667 | } |
4653 | 4668 | ||
4654 | 4669 | ||
4655 | void CalendarView::checkClipboard() | 4670 | void CalendarView::checkClipboard() |
4656 | { | 4671 | { |
4657 | #ifndef KORG_NODND | 4672 | #ifndef KORG_NODND |
4658 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4673 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4659 | emit pasteEnabled(true); | 4674 | emit pasteEnabled(true); |
4660 | } else { | 4675 | } else { |
4661 | emit pasteEnabled(false); | 4676 | emit pasteEnabled(false); |
4662 | } | 4677 | } |
4663 | #endif | 4678 | #endif |
4664 | } | 4679 | } |
4665 | 4680 | ||
4666 | void CalendarView::showDates(const DateList &selectedDates) | 4681 | void CalendarView::showDates(const DateList &selectedDates) |
4667 | { | 4682 | { |
4668 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4683 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4669 | 4684 | ||
4670 | 4685 | ||
4671 | if ( !mBlockShowDates ) { | 4686 | if ( !mBlockShowDates ) { |
4672 | if ( mViewManager->currentView() ) { | 4687 | if ( mViewManager->currentView() ) { |
4673 | updateView( selectedDates.first(), selectedDates.last() ); | 4688 | updateView( selectedDates.first(), selectedDates.last() ); |
4674 | } else { | 4689 | } else { |
4675 | mViewManager->showAgendaView(); | 4690 | mViewManager->showAgendaView(); |
4676 | } | 4691 | } |
4677 | } | 4692 | } |
4678 | 4693 | ||
4679 | QDate date = selectedDates.first(); | 4694 | QDate date = selectedDates.first(); |
4680 | if ( ! date.isValid() ) { | 4695 | if ( ! date.isValid() ) { |
4681 | topLevelWidget()->setCaption(""); | 4696 | topLevelWidget()->setCaption(""); |
4682 | return; | 4697 | return; |
4683 | } | 4698 | } |
4684 | 4699 | ||
4685 | QString selDates; | 4700 | QString selDates; |
4686 | selDates = KGlobal::locale()->formatDate( date, true); | 4701 | selDates = KGlobal::locale()->formatDate( date, true); |
4687 | if (selectedDates.first() < selectedDates.last() ) | 4702 | if (selectedDates.first() < selectedDates.last() ) |
4688 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4703 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4689 | else { | 4704 | else { |
4690 | QString addString; | 4705 | QString addString; |
4691 | if ( date == QDateTime::currentDateTime().date() ) | 4706 | if ( date == QDateTime::currentDateTime().date() ) |
4692 | addString = i18n("Today"); | 4707 | addString = i18n("Today"); |
4693 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4708 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4694 | addString = i18n("Tomorrow"); | 4709 | addString = i18n("Tomorrow"); |
4695 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4710 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4696 | addString = i18n("Yesterday"); | 4711 | addString = i18n("Yesterday"); |
4697 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4712 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4698 | addString = i18n("Day before yesterday"); | 4713 | addString = i18n("Day before yesterday"); |
4699 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4714 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4700 | addString = i18n("Day after tomorrow"); | 4715 | addString = i18n("Day after tomorrow"); |
4701 | if ( !addString.isEmpty() ) { | 4716 | if ( !addString.isEmpty() ) { |
4702 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4717 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4703 | return; | 4718 | return; |
4704 | } | 4719 | } |
4705 | } | 4720 | } |
4706 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4721 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4707 | 4722 | ||
4708 | } | 4723 | } |
4709 | 4724 | ||
4710 | QPtrList<CalFilter> CalendarView::filters() | 4725 | QPtrList<CalFilter> CalendarView::filters() |
4711 | { | 4726 | { |
4712 | return mFilters; | 4727 | return mFilters; |
4713 | 4728 | ||
4714 | } | 4729 | } |
4715 | void CalendarView::editFilters() | 4730 | void CalendarView::editFilters() |
4716 | { | 4731 | { |
4717 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4732 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4718 | 4733 | ||
4719 | CalFilter *filter = mFilters.first(); | 4734 | CalFilter *filter = mFilters.first(); |
4720 | while(filter) { | 4735 | while(filter) { |
4721 | filter = mFilters.next(); | 4736 | filter = mFilters.next(); |
4722 | } | 4737 | } |
4723 | 4738 | ||
4724 | mDialogManager->showFilterEditDialog(&mFilters); | 4739 | mDialogManager->showFilterEditDialog(&mFilters); |
4725 | updateFilter(); | 4740 | updateFilter(); |
4726 | } | 4741 | } |
4727 | void CalendarView::toggleFilter() | 4742 | void CalendarView::toggleFilter() |
4728 | { | 4743 | { |
4729 | if ( mLeftFrame->isHidden() ) { | 4744 | if ( mLeftFrame->isHidden() ) { |
4730 | toggleExpand(); | 4745 | toggleExpand(); |
4731 | showFilter( true ); | 4746 | showFilter( true ); |
4732 | } else | 4747 | } else |
4733 | showFilter(! mCalEditView->isVisible()); | 4748 | showFilter(! mCalEditView->isVisible()); |
4734 | } | 4749 | } |
4735 | 4750 | ||
4736 | KOFilterView *CalendarView::filterView() | 4751 | KOFilterView *CalendarView::filterView() |
4737 | { | 4752 | { |
4738 | return mFilterView; | 4753 | return mFilterView; |
4739 | } | 4754 | } |
4740 | void CalendarView::selectFilter( int fil ) | 4755 | void CalendarView::selectFilter( int fil ) |
4741 | { | 4756 | { |
4742 | mFilterView->setSelectedFilter( fil ); | 4757 | mFilterView->setSelectedFilter( fil ); |
4743 | updateUnmanagedViews(); | 4758 | updateUnmanagedViews(); |
4744 | } | 4759 | } |
4745 | void CalendarView::showFilter(bool visible) | 4760 | void CalendarView::showFilter(bool visible) |
4746 | { | 4761 | { |
4747 | #if 1 | 4762 | #if 1 |
4748 | if (visible) { | 4763 | if (visible) { |
4749 | mCalEditView->readConfig(); | 4764 | mCalEditView->readConfig(); |
4750 | mCalEditView->show(); | 4765 | mCalEditView->show(); |
4751 | QValueList<int> sizes; | 4766 | QValueList<int> sizes; |
4752 | sizes = mLeftFrame->sizes(); | 4767 | sizes = mLeftFrame->sizes(); |
4753 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4768 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4754 | sizes.clear(); | 4769 | sizes.clear(); |
4755 | sizes << 100; | 4770 | sizes << 100; |
4756 | sizes << 0; | 4771 | sizes << 0; |
4757 | sizes << 0; | 4772 | sizes << 0; |
4758 | sizes << 100; | 4773 | sizes << 100; |
4759 | mLeftFrame->setSizes(sizes); | 4774 | mLeftFrame->setSizes(sizes); |
4760 | } | 4775 | } |
4761 | #if 0 | 4776 | #if 0 |
4762 | sizes = mLeftFrame->sizes(); | 4777 | sizes = mLeftFrame->sizes(); |
4763 | int ccc = 0; | 4778 | int ccc = 0; |
4764 | while ( ccc < sizes.count()) { | 4779 | while ( ccc < sizes.count()) { |
4765 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4780 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4766 | ++ccc; | 4781 | ++ccc; |
4767 | } | 4782 | } |
4768 | #endif | 4783 | #endif |
4769 | 4784 | ||
4770 | } | 4785 | } |
4771 | else { | 4786 | else { |
4772 | mCalEditView->hide(); | 4787 | mCalEditView->hide(); |
4773 | } | 4788 | } |
4774 | #else | 4789 | #else |
4775 | if (visible) mFilterView->show(); | 4790 | if (visible) mFilterView->show(); |
4776 | else mFilterView->hide(); | 4791 | else mFilterView->hide(); |
4777 | #endif | 4792 | #endif |
4778 | } | 4793 | } |
4779 | void CalendarView::toggleFilerEnabled( ) | 4794 | void CalendarView::toggleFilerEnabled( ) |
4780 | { | 4795 | { |
4781 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4796 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4782 | if ( !mFilterView->filtersEnabled() ) | 4797 | if ( !mFilterView->filtersEnabled() ) |
4783 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4798 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4784 | updateUnmanagedViews(); | 4799 | updateUnmanagedViews(); |
4785 | 4800 | ||
4786 | } | 4801 | } |
4787 | void CalendarView::updateFilter() | 4802 | void CalendarView::updateFilter() |
4788 | { | 4803 | { |
4789 | CalFilter *filter = mFilterView->selectedFilter(); | 4804 | CalFilter *filter = mFilterView->selectedFilter(); |
4790 | if (filter) { | 4805 | if (filter) { |
4791 | QString mess; | 4806 | QString mess; |
4792 | if (mFilterView->filtersEnabled()) { | 4807 | if (mFilterView->filtersEnabled()) { |
4793 | mess = i18n("Filter selected: ")+filter->name(); | 4808 | mess = i18n("Filter selected: ")+filter->name(); |
4794 | filter->setEnabled(true); | 4809 | filter->setEnabled(true); |
4795 | } | 4810 | } |
4796 | else filter->setEnabled(false); | 4811 | else filter->setEnabled(false); |
4797 | mCalendar->setFilter(filter); | 4812 | mCalendar->setFilter(filter); |
4798 | updateView(); | 4813 | updateView(); |
4799 | if ( !mess.isEmpty() ) | 4814 | if ( !mess.isEmpty() ) |
4800 | topLevelWidget()->setCaption( mess ); | 4815 | topLevelWidget()->setCaption( mess ); |
4801 | 4816 | ||
4802 | } | 4817 | } |
4803 | emit filtersUpdated(); | 4818 | emit filtersUpdated(); |
4804 | } | 4819 | } |
4805 | 4820 | ||
4806 | void CalendarView::filterEdited() | 4821 | void CalendarView::filterEdited() |
4807 | { | 4822 | { |
4808 | mFilterView->updateFilters(); | 4823 | mFilterView->updateFilters(); |
4809 | updateFilter(); | 4824 | updateFilter(); |
4810 | writeSettings(); | 4825 | writeSettings(); |
4811 | } | 4826 | } |
4812 | 4827 | ||
4813 | 4828 | ||
4814 | void CalendarView::takeOverEvent() | 4829 | void CalendarView::takeOverEvent() |
4815 | { | 4830 | { |
4816 | Incidence *incidence = currentSelection(); | 4831 | Incidence *incidence = currentSelection(); |
4817 | 4832 | ||
4818 | if (!incidence) return; | 4833 | if (!incidence) return; |
4819 | 4834 | ||
4820 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4835 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4821 | incidence->recreate(); | 4836 | incidence->recreate(); |
4822 | incidence->setReadOnly(false); | 4837 | incidence->setReadOnly(false); |
4823 | 4838 | ||
4824 | updateView(); | 4839 | updateView(); |
4825 | } | 4840 | } |
4826 | 4841 | ||
4827 | void CalendarView::takeOverCalendar() | 4842 | void CalendarView::takeOverCalendar() |
4828 | { | 4843 | { |
4829 | // TODO: Create Calendar::allIncidences() function and use it here | 4844 | // TODO: Create Calendar::allIncidences() function and use it here |
4830 | 4845 | ||
4831 | clearAllViews(); | 4846 | clearAllViews(); |
4832 | QPtrList<Event> events = mCalendar->events(); | 4847 | QPtrList<Event> events = mCalendar->events(); |
4833 | for(uint i=0; i<events.count(); ++i) { | 4848 | for(uint i=0; i<events.count(); ++i) { |
4834 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4849 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4835 | events.at(i)->recreate(); | 4850 | events.at(i)->recreate(); |
4836 | events.at(i)->setReadOnly(false); | 4851 | events.at(i)->setReadOnly(false); |
4837 | } | 4852 | } |
4838 | 4853 | ||
4839 | QPtrList<Todo> todos = mCalendar->todos(); | 4854 | QPtrList<Todo> todos = mCalendar->todos(); |
4840 | for(uint i=0; i<todos.count(); ++i) { | 4855 | for(uint i=0; i<todos.count(); ++i) { |
4841 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4856 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4842 | todos.at(i)->recreate(); | 4857 | todos.at(i)->recreate(); |
4843 | todos.at(i)->setReadOnly(false); | 4858 | todos.at(i)->setReadOnly(false); |
4844 | } | 4859 | } |
4845 | 4860 | ||
4846 | QPtrList<Journal> journals = mCalendar->journals(); | 4861 | QPtrList<Journal> journals = mCalendar->journals(); |
4847 | for(uint i=0; i<journals.count(); ++i) { | 4862 | for(uint i=0; i<journals.count(); ++i) { |
4848 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4863 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4849 | journals.at(i)->recreate(); | 4864 | journals.at(i)->recreate(); |
4850 | journals.at(i)->setReadOnly(false); | 4865 | journals.at(i)->setReadOnly(false); |
4851 | } | 4866 | } |
4852 | 4867 | ||
4853 | updateView(); | 4868 | updateView(); |
4854 | } | 4869 | } |
4855 | 4870 | ||
4856 | void CalendarView::showIntro() | 4871 | void CalendarView::showIntro() |
4857 | { | 4872 | { |
4858 | kdDebug() << "To be implemented." << endl; | 4873 | kdDebug() << "To be implemented." << endl; |
4859 | } | 4874 | } |
4860 | 4875 | ||
4861 | QWidgetStack *CalendarView::viewStack() | 4876 | QWidgetStack *CalendarView::viewStack() |
4862 | { | 4877 | { |
4863 | return mRightFrame; | 4878 | return mRightFrame; |
4864 | } | 4879 | } |
4865 | 4880 | ||
4866 | QWidget *CalendarView::leftFrame() | 4881 | QWidget *CalendarView::leftFrame() |
4867 | { | 4882 | { |
4868 | return ( QWidget *)mLeftFrame; | 4883 | return ( QWidget *)mLeftFrame; |
4869 | } | 4884 | } |
4870 | 4885 | ||
4871 | DateNavigator *CalendarView::dateNavigator() | 4886 | DateNavigator *CalendarView::dateNavigator() |
4872 | { | 4887 | { |
4873 | return mNavigator; | 4888 | return mNavigator; |
4874 | } | 4889 | } |
4875 | 4890 | ||
4876 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4891 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4877 | { | 4892 | { |
4878 | return mDateNavigator->navigatorView(); | 4893 | return mDateNavigator->navigatorView(); |
4879 | } | 4894 | } |
4880 | void CalendarView::toggleDateNavigatorWidget() | 4895 | void CalendarView::toggleDateNavigatorWidget() |
4881 | { | 4896 | { |
4882 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4897 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4883 | 4898 | ||
4884 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4899 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4885 | mDateNavigator->hide(); | 4900 | mDateNavigator->hide(); |
4886 | else | 4901 | else |
4887 | mDateNavigator->show(); | 4902 | mDateNavigator->show(); |
4888 | } | 4903 | } |
4889 | void CalendarView::addView(KOrg::BaseView *view) | 4904 | void CalendarView::addView(KOrg::BaseView *view) |
4890 | { | 4905 | { |
4891 | mViewManager->addView(view); | 4906 | mViewManager->addView(view); |
4892 | } | 4907 | } |
4893 | 4908 | ||
4894 | void CalendarView::showView(KOrg::BaseView *view) | 4909 | void CalendarView::showView(KOrg::BaseView *view) |
4895 | { | 4910 | { |
4896 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4911 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4897 | } | 4912 | } |
4898 | 4913 | ||
4899 | Incidence *CalendarView::currentSelection() | 4914 | Incidence *CalendarView::currentSelection() |
4900 | { | 4915 | { |
4901 | return mViewManager->currentSelection(); | 4916 | return mViewManager->currentSelection(); |
4902 | } | 4917 | } |
4903 | void CalendarView::toggleAllDaySize() | 4918 | void CalendarView::toggleAllDaySize() |
4904 | { | 4919 | { |
4905 | /* | 4920 | /* |
4906 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4921 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4907 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4922 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4908 | else | 4923 | else |
4909 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4924 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4910 | */ | 4925 | */ |
4911 | viewManager()->agendaView()->toggleAllDay(); | 4926 | viewManager()->agendaView()->toggleAllDay(); |
4912 | } | 4927 | } |
4913 | void CalendarView::toggleExpand() | 4928 | void CalendarView::toggleExpand() |
4914 | { | 4929 | { |
4915 | // if ( mLeftFrame->isHidden() ) { | 4930 | // if ( mLeftFrame->isHidden() ) { |
4916 | // mLeftFrame->show(); | 4931 | // mLeftFrame->show(); |
4917 | // emit calendarViewExpanded( false ); | 4932 | // emit calendarViewExpanded( false ); |
4918 | // } else { | 4933 | // } else { |
4919 | // mLeftFrame->hide(); | 4934 | // mLeftFrame->hide(); |
4920 | // emit calendarViewExpanded( true ); | 4935 | // emit calendarViewExpanded( true ); |
4921 | // } | 4936 | // } |
4922 | //qDebug(" CalendarView::toggleExpand()"); | 4937 | //qDebug(" CalendarView::toggleExpand()"); |
4923 | globalFlagBlockAgenda = 1; | 4938 | globalFlagBlockAgenda = 1; |
4924 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4939 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4925 | globalFlagBlockAgenda = 5; | 4940 | globalFlagBlockAgenda = 5; |
4926 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4941 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4927 | //mViewManager->showView( 0, true ); | 4942 | //mViewManager->showView( 0, true ); |
4928 | } | 4943 | } |
4929 | 4944 | ||
4930 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4945 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4931 | { | 4946 | { |
4932 | setModified( modified ); | 4947 | setModified( modified ); |
4933 | } | 4948 | } |
4934 | 4949 | ||
4935 | Todo *CalendarView::selectedTodo() | 4950 | Todo *CalendarView::selectedTodo() |
4936 | { | 4951 | { |
4937 | Incidence *incidence = currentSelection(); | 4952 | Incidence *incidence = currentSelection(); |
4938 | if ( incidence && incidence->typeID() == todoID ) { | 4953 | if ( incidence && incidence->typeID() == todoID ) { |
4939 | return static_cast<Todo *>( incidence ); | 4954 | return static_cast<Todo *>( incidence ); |
4940 | } | 4955 | } |
4941 | 4956 | ||
4942 | incidence = mTodoList->selectedIncidences().first(); | 4957 | incidence = mTodoList->selectedIncidences().first(); |
4943 | if ( incidence && incidence->typeID() == todoID ) { | 4958 | if ( incidence && incidence->typeID() == todoID ) { |
4944 | return static_cast<Todo *>( incidence ); | 4959 | return static_cast<Todo *>( incidence ); |
4945 | } | 4960 | } |
4946 | 4961 | ||
4947 | return 0; | 4962 | return 0; |
4948 | } | 4963 | } |
4949 | 4964 | ||
4950 | void CalendarView::showIncidence() | 4965 | void CalendarView::showIncidence() |
4951 | { | 4966 | { |
4952 | mViewerCallerIsSearchDialog = false; | 4967 | mViewerCallerIsSearchDialog = false; |
4953 | Incidence *incidence = currentSelection(); | 4968 | Incidence *incidence = currentSelection(); |
4954 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4969 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4955 | if ( incidence ) { | 4970 | if ( incidence ) { |
4956 | ShowIncidenceVisitor v; | 4971 | ShowIncidenceVisitor v; |
4957 | v.act( incidence, this ); | 4972 | v.act( incidence, this ); |
4958 | } | 4973 | } |
4959 | } | 4974 | } |
4960 | void CalendarView::editIncidenceDescription() | 4975 | void CalendarView::editIncidenceDescription() |
4961 | { | 4976 | { |
4962 | mFlagEditDescription = true; | 4977 | mFlagEditDescription = true; |
4963 | editIncidence(); | 4978 | editIncidence(); |
4964 | mFlagEditDescription = false; | 4979 | mFlagEditDescription = false; |
4965 | } | 4980 | } |
4966 | void CalendarView::editIncidence() | 4981 | void CalendarView::editIncidence() |
4967 | { | 4982 | { |
4968 | // qDebug("editIncidence() "); | 4983 | // qDebug("editIncidence() "); |
4969 | Incidence *incidence = currentSelection(); | 4984 | Incidence *incidence = currentSelection(); |
4970 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4985 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4971 | if ( incidence ) { | 4986 | if ( incidence ) { |
4972 | EditIncidenceVisitor v; | 4987 | EditIncidenceVisitor v; |
4973 | v.act( incidence, this ); | 4988 | v.act( incidence, this ); |
4974 | } | 4989 | } |
4975 | } | 4990 | } |
4976 | 4991 | ||
4977 | void CalendarView::deleteIncidence() | 4992 | void CalendarView::deleteIncidence() |
4978 | { | 4993 | { |
4979 | Incidence *incidence = currentSelection(); | 4994 | Incidence *incidence = currentSelection(); |
4980 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4995 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4981 | if ( incidence ) { | 4996 | if ( incidence ) { |
4982 | deleteIncidence(incidence); | 4997 | deleteIncidence(incidence); |
4983 | } | 4998 | } |
4984 | } | 4999 | } |
4985 | void CalendarView::showIncidence(QString uid) | 5000 | void CalendarView::showIncidence(QString uid) |
4986 | { | 5001 | { |
4987 | Incidence *inc = mCalendar->incidence( uid ); | 5002 | Incidence *inc = mCalendar->incidence( uid ); |
4988 | if ( inc ) | 5003 | if ( inc ) |
4989 | showIncidence( inc ); | 5004 | showIncidence( inc ); |
4990 | } | 5005 | } |
4991 | void CalendarView::showIncidence(Incidence *incidence) | 5006 | void CalendarView::showIncidence(Incidence *incidence) |
4992 | { | 5007 | { |
4993 | mViewerCallerIsSearchDialog = false; | 5008 | mViewerCallerIsSearchDialog = false; |
4994 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 5009 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4995 | if ( sender() && mDialogManager->getSearchDialog() ) { | 5010 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4996 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 5011 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4997 | mViewerCallerIsSearchDialog = true; | 5012 | mViewerCallerIsSearchDialog = true; |
4998 | } | 5013 | } |
4999 | } | 5014 | } |
5000 | if ( incidence ) { | 5015 | if ( incidence ) { |
5001 | ShowIncidenceVisitor v; | 5016 | ShowIncidenceVisitor v; |
5002 | v.act( incidence, this ); | 5017 | v.act( incidence, this ); |
5003 | } | 5018 | } |
5004 | } | 5019 | } |
5005 | 5020 | ||
5006 | void CalendarView::editIncidence(Incidence *incidence) | 5021 | void CalendarView::editIncidence(Incidence *incidence) |
5007 | { | 5022 | { |
5008 | if ( incidence ) { | 5023 | if ( incidence ) { |
5009 | 5024 | ||
5010 | EditIncidenceVisitor v; | 5025 | EditIncidenceVisitor v; |
5011 | v.act( incidence, this ); | 5026 | v.act( incidence, this ); |
5012 | 5027 | ||
5013 | } | 5028 | } |
5014 | } | 5029 | } |
5015 | 5030 | ||
5016 | void CalendarView::deleteIncidence(Incidence *incidence) | 5031 | void CalendarView::deleteIncidence(Incidence *incidence) |
5017 | { | 5032 | { |
5018 | //qDebug(" CalendarView::deleteIncidence "); | 5033 | //qDebug(" CalendarView::deleteIncidence "); |
5019 | if ( incidence == 0 ) { | 5034 | if ( incidence == 0 ) { |
5020 | updateView(); | 5035 | updateView(); |
5021 | emit updateSearchDialog(); | 5036 | emit updateSearchDialog(); |
5022 | return; | 5037 | return; |
5023 | } | 5038 | } |
5024 | if ( incidence ) { | 5039 | if ( incidence ) { |
5025 | DeleteIncidenceVisitor v; | 5040 | DeleteIncidenceVisitor v; |
5026 | v.act( incidence, this ); | 5041 | v.act( incidence, this ); |
5027 | } | 5042 | } |
5028 | } | 5043 | } |
5029 | 5044 | ||
5030 | 5045 | ||
5031 | void CalendarView::lookForOutgoingMessages() | 5046 | void CalendarView::lookForOutgoingMessages() |
5032 | { | 5047 | { |
5033 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 5048 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
5034 | ogd->loadMessages(); | 5049 | ogd->loadMessages(); |
5035 | } | 5050 | } |
5036 | 5051 | ||
5037 | void CalendarView::lookForIncomingMessages() | 5052 | void CalendarView::lookForIncomingMessages() |
5038 | { | 5053 | { |
5039 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 5054 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
5040 | icd->retrieve(); | 5055 | icd->retrieve(); |
5041 | } | 5056 | } |
5042 | 5057 | ||
5043 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 5058 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
5044 | { | 5059 | { |
5045 | bool deleteTodo = true; | 5060 | bool deleteTodo = true; |
5046 | QPtrList<Incidence> subTodos; | 5061 | QPtrList<Incidence> subTodos; |
5047 | Incidence *aTodo; | 5062 | Incidence *aTodo; |
5048 | subTodos = t->relations(); | 5063 | subTodos = t->relations(); |
5049 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 5064 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
5050 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 5065 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
5051 | deleteTodo = false; | 5066 | deleteTodo = false; |
5052 | } | 5067 | } |
5053 | if ( deleteTodo ) { | 5068 | if ( deleteTodo ) { |
5054 | if ( t->isCompleted() && !t->doesRecur()) { | 5069 | if ( t->isCompleted() && !t->doesRecur()) { |
5055 | checkExternalId( t ); | 5070 | checkExternalId( t ); |
5056 | mCalendar->deleteTodo( t ); | 5071 | mCalendar->deleteTodo( t ); |
5057 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 5072 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
5058 | } | 5073 | } |
5059 | else | 5074 | else |
5060 | deleteTodo = false; | 5075 | deleteTodo = false; |
5061 | } | 5076 | } |
5062 | return deleteTodo; | 5077 | return deleteTodo; |
5063 | 5078 | ||
5064 | } | 5079 | } |
5065 | void CalendarView::purgeCompleted() | 5080 | void CalendarView::purgeCompleted() |
5066 | { | 5081 | { |
5067 | int result = KMessageBox::warningContinueCancel(this, | 5082 | int result = KMessageBox::warningContinueCancel(this, |
5068 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 5083 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
5069 | 5084 | ||
5070 | if (result == KMessageBox::Continue) { | 5085 | if (result == KMessageBox::Continue) { |
5071 | 5086 | ||
5072 | QPtrList<Todo> todoCal; | 5087 | QPtrList<Todo> todoCal; |
5073 | QPtrList<Todo> rootTodos; | 5088 | QPtrList<Todo> rootTodos; |
5074 | //QPtrList<Incidence> rel; | 5089 | //QPtrList<Incidence> rel; |
5075 | Todo *aTodo; | 5090 | Todo *aTodo; |
5076 | todoCal = calendar()->todos(); | 5091 | todoCal = calendar()->todos(); |
5077 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 5092 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
5078 | if ( !aTodo->relatedTo() ) | 5093 | if ( !aTodo->relatedTo() ) |
5079 | rootTodos.append( aTodo ); | 5094 | rootTodos.append( aTodo ); |
5080 | } | 5095 | } |
5081 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 5096 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
5082 | removeCompletedSubTodos( aTodo ); | 5097 | removeCompletedSubTodos( aTodo ); |
5083 | } | 5098 | } |
5084 | 5099 | ||
5085 | updateView(); | 5100 | updateView(); |
5086 | } | 5101 | } |
5087 | } | 5102 | } |
5088 | 5103 | ||
5089 | void CalendarView::slotCalendarChanged() | 5104 | void CalendarView::slotCalendarChanged() |
5090 | { | 5105 | { |
5091 | ; | 5106 | ; |
5092 | } | 5107 | } |
5093 | 5108 | ||
5094 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 5109 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
5095 | { | 5110 | { |
5096 | //qDebug("CalendarView::keyPressEvent "); | 5111 | //qDebug("CalendarView::keyPressEvent "); |
5097 | e->ignore(); | 5112 | e->ignore(); |
5098 | } | 5113 | } |
5099 | 5114 | ||
5100 | void CalendarView::multiResourceSyncStart( bool start ) | 5115 | void CalendarView::multiResourceSyncStart( bool start ) |
5101 | { | 5116 | { |
5102 | mMultiResourceSync = start; | 5117 | mMultiResourceSync = start; |
5103 | 5118 | ||
5104 | } | 5119 | } |
5105 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) | 5120 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
5106 | { | 5121 | { |
5107 | 5122 | ||
5108 | if ( manager != mSyncManager) | 5123 | if ( manager != mSyncManager) |
5109 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 5124 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
5110 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 5125 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
5111 | qDebug("KO: SyncKDE request detected!"); | 5126 | qDebug("KO: SyncKDE request detected!"); |
5112 | } | 5127 | } |
5113 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5128 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5114 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5129 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5115 | if ( !resource.isEmpty() ) { | 5130 | if ( !resource.isEmpty() ) { |
5116 | int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | 5131 | int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); |
5117 | qDebug( "KO: Sync request for resource: %s", resource.latin1() ); | 5132 | qDebug( "KO: Sync request for resource: %s", resource.latin1() ); |
5118 | 5133 | ||
5119 | if ( !exclusiveSyncResource ) { | 5134 | if ( !exclusiveSyncResource ) { |
5120 | qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); | 5135 | qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); |
5121 | return false; | 5136 | return false; |
5122 | } | 5137 | } |
5123 | mCalendar->setDefaultCalendar( exclusiveSyncResource ); | 5138 | mCalendar->setDefaultCalendar( exclusiveSyncResource ); |
5124 | mCalendar->setDefaultCalendarEnabledOnly(); | 5139 | mCalendar->setDefaultCalendarEnabledOnly(); |
5125 | } | 5140 | } |
5126 | bool result = syncCalendar( filename, mode ); | 5141 | bool result = syncCalendar( filename, mode ); |
5127 | if ( !resource.isEmpty() ) | 5142 | if ( !resource.isEmpty() ) |
5128 | restoreCalendarSettings(); | 5143 | restoreCalendarSettings(); |
5129 | return result; | 5144 | return result; |
5130 | } | 5145 | } |
5131 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 5146 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
5132 | { | 5147 | { |
5133 | //mSyncManager = manager; | 5148 | //mSyncManager = manager; |
5134 | if ( manager != mSyncManager) | 5149 | if ( manager != mSyncManager) |
5135 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 5150 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
5136 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5151 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5137 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5152 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5138 | if ( resource == "sharp" ) | 5153 | if ( resource == "sharp" ) |
5139 | syncExternal( 0 ); | 5154 | syncExternal( 0 ); |
5140 | if ( resource == "phone" ) | 5155 | if ( resource == "phone" ) |
5141 | syncExternal( 1 ); | 5156 | syncExternal( 1 ); |
5142 | // pending setmodified | 5157 | // pending setmodified |
5143 | return true; | 5158 | return true; |
5144 | } | 5159 | } |
5145 | void CalendarView::setSyncManager(KSyncManager* manager) | 5160 | void CalendarView::setSyncManager(KSyncManager* manager) |
5146 | { | 5161 | { |
5147 | mSyncManager = manager; | 5162 | mSyncManager = manager; |
5148 | } | 5163 | } |
5149 | 5164 | ||
5150 | void CalendarView::removeSyncInfo( QString syncProfile) | 5165 | void CalendarView::removeSyncInfo( QString syncProfile) |
5151 | { | 5166 | { |
5152 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 5167 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
5153 | mCalendar->removeSyncInfo( syncProfile ); | 5168 | mCalendar->removeSyncInfo( syncProfile ); |
5154 | 5169 | ||
5155 | } | 5170 | } |
5156 | 5171 | ||
5157 | void CalendarView::undo_delete() | 5172 | void CalendarView::undo_delete() |
5158 | { | 5173 | { |
5159 | //qDebug("undo_delete() "); | 5174 | //qDebug("undo_delete() "); |
5160 | Incidence* undo = mCalendar->undoIncidence(); | 5175 | Incidence* undo = mCalendar->undoIncidence(); |
5161 | if ( !undo ) { | 5176 | if ( !undo ) { |
5162 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 5177 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
5163 | i18n("KO/Pi")); | 5178 | i18n("KO/Pi")); |
5164 | return; | 5179 | return; |
5165 | } | 5180 | } |
5166 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 5181 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
5167 | i18n("\nAre you sure you want\nto restore this?"), | 5182 | i18n("\nAre you sure you want\nto restore this?"), |
5168 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 5183 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
5169 | mCalendar->undoDeleteIncidence(); | 5184 | mCalendar->undoDeleteIncidence(); |
5170 | updateView(); | 5185 | updateView(); |
5171 | } | 5186 | } |
5172 | } | 5187 | } |
5173 | 5188 | ||
5174 | void CalendarView::slotViewerClosed() | 5189 | void CalendarView::slotViewerClosed() |
5175 | { | 5190 | { |
5176 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 5191 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
5177 | } | 5192 | } |
5178 | 5193 | ||
5179 | void CalendarView::resetFocus() | 5194 | void CalendarView::resetFocus() |
5180 | { | 5195 | { |
5181 | if ( mViewerCallerIsSearchDialog ) { | 5196 | if ( mViewerCallerIsSearchDialog ) { |
5182 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 5197 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
5183 | mDialogManager->getSearchDialog()->raise(); | 5198 | mDialogManager->getSearchDialog()->raise(); |
5184 | mDialogManager->getSearchDialog()->setActiveWindow(); | 5199 | mDialogManager->getSearchDialog()->setActiveWindow(); |
5185 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 5200 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
5186 | } else | 5201 | } else |
5187 | mViewerCallerIsSearchDialog = false; | 5202 | mViewerCallerIsSearchDialog = false; |
5188 | } | 5203 | } |
5189 | if ( !mViewerCallerIsSearchDialog ) { | 5204 | if ( !mViewerCallerIsSearchDialog ) { |
5190 | //mViewManager->currentView()->setFocus(); | 5205 | //mViewManager->currentView()->setFocus(); |
5191 | //qDebug("sssssssssssssssset focus "); | 5206 | //qDebug("sssssssssssssssset focus "); |
5192 | topLevelWidget()->raise(); | 5207 | topLevelWidget()->raise(); |
5193 | setActiveWindow(); | 5208 | setActiveWindow(); |
5194 | //setFocus(); | 5209 | //setFocus(); |
5195 | } | 5210 | } |
5196 | mViewerCallerIsSearchDialog = false; | 5211 | mViewerCallerIsSearchDialog = false; |
5197 | } | 5212 | } |
5198 | 5213 | ||
5199 | void CalendarView::showNextAlarms() | 5214 | void CalendarView::showNextAlarms() |
5200 | { | 5215 | { |
5201 | QString message; | 5216 | QString message; |
5202 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 5217 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
5203 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 5218 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
5204 | QString sum = mCalendar->nextSummary(); | 5219 | QString sum = mCalendar->nextSummary(); |
5205 | QDateTime nextA = mNextAlarmDateTime; | 5220 | QDateTime nextA = mNextAlarmDateTime; |
5206 | QDateTime cur = QDateTime::currentDateTime(); | 5221 | QDateTime cur = QDateTime::currentDateTime(); |
5207 | int secs = cur.secsTo( nextA ); | 5222 | int secs = cur.secsTo( nextA ); |
5208 | int min = secs /60; | 5223 | int min = secs /60; |
5209 | int hours = min /60; | 5224 | int hours = min /60; |
5210 | min = min % 60; | 5225 | min = min % 60; |
5211 | int days = hours /24; | 5226 | int days = hours /24; |
5212 | hours = hours % 24; | 5227 | hours = hours % 24; |
5213 | 5228 | ||
5214 | //message = i18n("The next alarm is in:\n"); | 5229 | //message = i18n("The next alarm is in:\n"); |
5215 | if ( days > 1 ) | 5230 | if ( days > 1 ) |
5216 | message += i18n("%1 days\n").arg( days ); | 5231 | message += i18n("%1 days\n").arg( days ); |
5217 | else if ( days == 1 ) | 5232 | else if ( days == 1 ) |
5218 | message += i18n("1 day\n"); | 5233 | message += i18n("1 day\n"); |
5219 | if ( hours > 1 ) | 5234 | if ( hours > 1 ) |
5220 | message += i18n("%1 hours\n").arg( hours ); | 5235 | message += i18n("%1 hours\n").arg( hours ); |
5221 | else if ( hours == 1 ) | 5236 | else if ( hours == 1 ) |
5222 | message += i18n("1 hour\n"); | 5237 | message += i18n("1 hour\n"); |
5223 | if ( min > 1 ) | 5238 | if ( min > 1 ) |
5224 | message += i18n("%1 minutes\n").arg( min ); | 5239 | message += i18n("%1 minutes\n").arg( min ); |
5225 | else if ( min == 1 ) | 5240 | else if ( min == 1 ) |
5226 | message += i18n("1 minute\n"); | 5241 | message += i18n("1 minute\n"); |
5227 | if ( message.isEmpty() ) | 5242 | if ( message.isEmpty() ) |
5228 | message = i18n("The next alarm is in\nless than one minute!"); | 5243 | message = i18n("The next alarm is in\nless than one minute!"); |
5229 | else | 5244 | else |
5230 | message = i18n("The next alarm is in:\n") + message; | 5245 | message = i18n("The next alarm is in:\n") + message; |
5231 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 5246 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
5232 | } else { | 5247 | } else { |
5233 | message = i18n("There is no next alarm."); | 5248 | message = i18n("There is no next alarm."); |
5234 | 5249 | ||
5235 | } | 5250 | } |
5236 | #ifdef DESKTOP_VERSION | 5251 | #ifdef DESKTOP_VERSION |
5237 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 5252 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
5238 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 5253 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
5239 | message += i18n("Enable it in the settings menu, TAB alarm."); | 5254 | message += i18n("Enable it in the settings menu, TAB alarm."); |
5240 | } | 5255 | } |
5241 | 5256 | ||
5242 | #endif | 5257 | #endif |
5243 | KMessageBox::information( this, message); | 5258 | KMessageBox::information( this, message); |
5244 | } | 5259 | } |
5245 | 5260 | ||
5246 | void CalendarView::displayCalendarInfo( int id ) | 5261 | void CalendarView::displayCalendarInfo( int id ) |
5247 | { | 5262 | { |
5248 | int e, t,j; | 5263 | int e, t,j; |
5249 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 5264 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
5250 | QString name = kkf->mName; | 5265 | QString name = kkf->mName; |
5251 | mCalendar->getIncidenceCount( id, e, t, j ); | 5266 | mCalendar->getIncidenceCount( id, e, t, j ); |
5252 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); | 5267 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); |
5253 | QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); | 5268 | QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); |
5254 | mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); | 5269 | mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); |
5255 | KMessageBox::information( this, mess ); | 5270 | KMessageBox::information( this, mess ); |
5256 | 5271 | ||
5257 | 5272 | ||
5258 | } | 5273 | } |
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 8535191..1350f6d 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -1,523 +1,526 @@ | |||
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) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,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 | |||
11 | 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, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 13 | Library General Public License for more details. |
15 | 14 | ||
16 | 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 |
17 | 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 |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
20 | */ | 19 | */ |
21 | 20 | ||
22 | #include <stdlib.h> | 21 | #include <stdlib.h> |
23 | #include <time.h> | 22 | #include <time.h> |
24 | 23 | ||
25 | #include <kdebug.h> | 24 | #include <kdebug.h> |
26 | #include <kglobal.h> | 25 | #include <kglobal.h> |
27 | #include <klocale.h> | 26 | #include <klocale.h> |
28 | 27 | ||
29 | #include "exceptions.h" | 28 | #include "exceptions.h" |
30 | #include "calfilter.h" | 29 | #include "calfilter.h" |
31 | 30 | ||
32 | #include "calendar.h" | 31 | #include "calendar.h" |
33 | #include "syncdefines.h" | 32 | #include "syncdefines.h" |
34 | 33 | ||
35 | using namespace KCal; | 34 | using namespace KCal; |
36 | 35 | ||
37 | Calendar::Calendar() | 36 | Calendar::Calendar() |
38 | { | 37 | { |
39 | 38 | ||
40 | init(); | 39 | init(); |
41 | setTimeZoneId( " 00:00 Europe/London(UTC)" ); | 40 | setTimeZoneId( " 00:00 Europe/London(UTC)" ); |
42 | } | 41 | } |
43 | 42 | ||
44 | Calendar::Calendar( const QString &timeZoneId ) | 43 | Calendar::Calendar( const QString &timeZoneId ) |
45 | { | 44 | { |
46 | 45 | ||
47 | init(); | 46 | init(); |
48 | setTimeZoneId(timeZoneId); | 47 | setTimeZoneId(timeZoneId); |
49 | } | 48 | } |
50 | 49 | ||
51 | void Calendar::init() | 50 | void Calendar::init() |
52 | { | 51 | { |
53 | mObserver = 0; | 52 | mObserver = 0; |
54 | mNewObserver = false; | 53 | mNewObserver = false; |
55 | mUndoIncidence = 0; | 54 | mUndoIncidence = 0; |
56 | mDeleteIncidencesOnClose = true; | 55 | mDeleteIncidencesOnClose = true; |
57 | mModified = false; | 56 | mModified = false; |
58 | mDefaultCalendar = 1; | 57 | mDefaultCalendar = 1; |
59 | // Setup default filter, which does nothing | 58 | // Setup default filter, which does nothing |
60 | mDefaultFilter = new CalFilter; | 59 | mDefaultFilter = new CalFilter; |
61 | mFilter = mDefaultFilter; | 60 | mFilter = mDefaultFilter; |
62 | mFilter->setEnabled(false); | 61 | mFilter->setEnabled(false); |
63 | 62 | ||
64 | // initialize random numbers. This is a hack, and not | 63 | // initialize random numbers. This is a hack, and not |
65 | // even that good of one at that. | 64 | // even that good of one at that. |
66 | // srandom(time(0)); | 65 | // srandom(time(0)); |
67 | 66 | ||
68 | // user information... | 67 | // user information... |
69 | setOwner(i18n("Unknown Name")); | 68 | setOwner(i18n("Unknown Name")); |
70 | setEmail(i18n("unknown@nowhere")); | 69 | setEmail(i18n("unknown@nowhere")); |
71 | 70 | ||
72 | #if 0 | 71 | #if 0 |
73 | tmpStr = KOPrefs::instance()->mTimeZone; | 72 | tmpStr = KOPrefs::instance()->mTimeZone; |
74 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; | 73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; |
75 | int dstSetting = KOPrefs::instance()->mDaylightSavings; | 74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; |
76 | extern long int timezone; | 75 | extern long int timezone; |
77 | struct tm *now; | 76 | struct tm *now; |
78 | time_t curtime; | 77 | time_t curtime; |
79 | curtime = time(0); | 78 | curtime = time(0); |
80 | now = localtime(&curtime); | 79 | now = localtime(&curtime); |
81 | int hourOff = - ((timezone / 60) / 60); | 80 | int hourOff = - ((timezone / 60) / 60); |
82 | if (now->tm_isdst) | 81 | if (now->tm_isdst) |
83 | hourOff += 1; | 82 | hourOff += 1; |
84 | QString tzStr; | 83 | QString tzStr; |
85 | tzStr.sprintf("%.2d%.2d", | 84 | tzStr.sprintf("%.2d%.2d", |
86 | hourOff, | 85 | hourOff, |
87 | abs((timezone / 60) % 60)); | 86 | abs((timezone / 60) % 60)); |
88 | 87 | ||
89 | // if no time zone was in the config file, write what we just discovered. | 88 | // if no time zone was in the config file, write what we just discovered. |
90 | if (tmpStr.isEmpty()) { | 89 | if (tmpStr.isEmpty()) { |
91 | // KOPrefs::instance()->mTimeZone = tzStr; | 90 | // KOPrefs::instance()->mTimeZone = tzStr; |
92 | } else { | 91 | } else { |
93 | tzStr = tmpStr; | 92 | tzStr = tmpStr; |
94 | } | 93 | } |
95 | 94 | ||
96 | // if daylight savings has changed since last load time, we need | 95 | // if daylight savings has changed since last load time, we need |
97 | // to rewrite these settings to the config file. | 96 | // to rewrite these settings to the config file. |
98 | if ((now->tm_isdst && !dstSetting) || | 97 | if ((now->tm_isdst && !dstSetting) || |
99 | (!now->tm_isdst && dstSetting)) { | 98 | (!now->tm_isdst && dstSetting)) { |
100 | KOPrefs::instance()->mTimeZone = tzStr; | 99 | KOPrefs::instance()->mTimeZone = tzStr; |
101 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; | 100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; |
102 | } | 101 | } |
103 | 102 | ||
104 | setTimeZone(tzStr); | 103 | setTimeZone(tzStr); |
105 | #endif | 104 | #endif |
106 | 105 | ||
107 | // KOPrefs::instance()->writeConfig(); | 106 | // KOPrefs::instance()->writeConfig(); |
108 | } | 107 | } |
109 | 108 | ||
110 | Calendar::~Calendar() | 109 | Calendar::~Calendar() |
111 | { | 110 | { |
112 | delete mDefaultFilter; | 111 | delete mDefaultFilter; |
113 | clearUndo( 0 ); | 112 | clearUndo( 0 ); |
114 | } | 113 | } |
115 | void Calendar::clearUndo( Incidence * newUndo ) | 114 | void Calendar::clearUndo( Incidence * newUndo ) |
116 | { | 115 | { |
117 | 116 | ||
118 | if ( mUndoIncidence ) { | 117 | if ( mUndoIncidence ) { |
119 | if ( mUndoIncidence->typeID() == eventID ) | 118 | if ( mUndoIncidence->typeID() == eventID ) |
120 | delete ((Event*) mUndoIncidence) ; | 119 | delete ((Event*) mUndoIncidence) ; |
121 | else if ( mUndoIncidence->typeID() == todoID ) | 120 | else if ( mUndoIncidence->typeID() == todoID ) |
122 | delete ( (Todo*) mUndoIncidence ); | 121 | delete ( (Todo*) mUndoIncidence ); |
123 | else if ( mUndoIncidence->typeID() == journalID ) | 122 | else if ( mUndoIncidence->typeID() == journalID ) |
124 | delete ( (Journal*) mUndoIncidence ); | 123 | delete ( (Journal*) mUndoIncidence ); |
125 | else | 124 | else |
126 | delete mUndoIncidence; | 125 | delete mUndoIncidence; |
127 | } | 126 | } |
128 | mUndoIncidence = newUndo; | 127 | mUndoIncidence = newUndo; |
129 | if ( mUndoIncidence ) { | 128 | if ( mUndoIncidence ) { |
130 | mUndoIncidence->clearRelations(); | 129 | mUndoIncidence->clearRelations(); |
131 | } | 130 | } |
132 | 131 | ||
133 | } | 132 | } |
134 | 133 | ||
135 | void Calendar::setDontDeleteIncidencesOnClose () | 134 | void Calendar::setDontDeleteIncidencesOnClose () |
136 | { | 135 | { |
137 | mDeleteIncidencesOnClose = false; | 136 | mDeleteIncidencesOnClose = false; |
138 | } | 137 | } |
139 | void Calendar::setDefaultCalendar( int d ) | 138 | void Calendar::setDefaultCalendar( int d ) |
140 | { | 139 | { |
141 | mDefaultCalendar = d; | 140 | mDefaultCalendar = d; |
142 | } | 141 | } |
143 | int Calendar::defaultCalendar() | 142 | int Calendar::defaultCalendar() |
144 | { | 143 | { |
145 | return mDefaultCalendar; | 144 | return mDefaultCalendar; |
146 | } | 145 | } |
147 | const QString &Calendar::getOwner() const | 146 | const QString &Calendar::getOwner() const |
148 | { | 147 | { |
149 | return mOwner; | 148 | return mOwner; |
150 | } | 149 | } |
151 | 150 | ||
152 | bool Calendar::undoDeleteIncidence() | 151 | bool Calendar::undoDeleteIncidence() |
153 | { | 152 | { |
154 | if (!mUndoIncidence) | 153 | if (!mUndoIncidence) |
155 | return false; | 154 | return false; |
156 | addIncidence(mUndoIncidence); | 155 | addIncidence(mUndoIncidence); |
157 | mUndoIncidence = 0; | 156 | mUndoIncidence = 0; |
158 | return true; | 157 | return true; |
159 | } | 158 | } |
160 | void Calendar::setOwner(const QString &os) | 159 | void Calendar::setOwner(const QString &os) |
161 | { | 160 | { |
162 | int i; | 161 | int i; |
163 | mOwner = os; | 162 | mOwner = os; |
164 | i = mOwner.find(','); | 163 | i = mOwner.find(','); |
165 | if (i != -1) | 164 | if (i != -1) |
166 | mOwner = mOwner.left(i); | 165 | mOwner = mOwner.left(i); |
167 | 166 | ||
168 | setModified( true ); | 167 | setModified( true ); |
169 | } | 168 | } |
170 | 169 | ||
171 | void Calendar::setTimeZone(const QString & tz) | 170 | void Calendar::setTimeZone(const QString & tz) |
172 | { | 171 | { |
173 | bool neg = FALSE; | 172 | bool neg = FALSE; |
174 | int hours, minutes; | 173 | int hours, minutes; |
175 | QString tmpStr(tz); | 174 | QString tmpStr(tz); |
176 | 175 | ||
177 | if (tmpStr.left(1) == "-") | 176 | if (tmpStr.left(1) == "-") |
178 | neg = TRUE; | 177 | neg = TRUE; |
179 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") | 178 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") |
180 | tmpStr.remove(0, 1); | 179 | tmpStr.remove(0, 1); |
181 | hours = tmpStr.left(2).toInt(); | 180 | hours = tmpStr.left(2).toInt(); |
182 | if (tmpStr.length() > 2) | 181 | if (tmpStr.length() > 2) |
183 | minutes = tmpStr.right(2).toInt(); | 182 | minutes = tmpStr.right(2).toInt(); |
184 | else | 183 | else |
185 | minutes = 0; | 184 | minutes = 0; |
186 | mTimeZone = (60*hours+minutes); | 185 | mTimeZone = (60*hours+minutes); |
187 | if (neg) | 186 | if (neg) |
188 | mTimeZone = -mTimeZone; | 187 | mTimeZone = -mTimeZone; |
189 | mLocalTime = false; | 188 | mLocalTime = false; |
190 | 189 | ||
191 | setModified( true ); | 190 | setModified( true ); |
192 | } | 191 | } |
193 | 192 | ||
194 | QString Calendar::getTimeZoneStr() const | 193 | QString Calendar::getTimeZoneStr() const |
195 | { | 194 | { |
196 | if (mLocalTime) | 195 | if (mLocalTime) |
197 | return ""; | 196 | return ""; |
198 | QString tmpStr; | 197 | QString tmpStr; |
199 | int hours = abs(mTimeZone / 60); | 198 | int hours = abs(mTimeZone / 60); |
200 | int minutes = abs(mTimeZone % 60); | 199 | int minutes = abs(mTimeZone % 60); |
201 | bool neg = mTimeZone < 0; | 200 | bool neg = mTimeZone < 0; |
202 | 201 | ||
203 | tmpStr.sprintf("%c%.2d%.2d", | 202 | tmpStr.sprintf("%c%.2d%.2d", |
204 | (neg ? '-' : '+'), | 203 | (neg ? '-' : '+'), |
205 | hours, minutes); | 204 | hours, minutes); |
206 | return tmpStr; | 205 | return tmpStr; |
207 | } | 206 | } |
208 | 207 | ||
209 | void Calendar::setTimeZone(int tz) | 208 | void Calendar::setTimeZone(int tz) |
210 | { | 209 | { |
211 | mTimeZone = tz; | 210 | mTimeZone = tz; |
212 | mLocalTime = false; | 211 | mLocalTime = false; |
213 | 212 | ||
214 | setModified( true ); | 213 | setModified( true ); |
215 | } | 214 | } |
216 | 215 | ||
217 | int Calendar::getTimeZone() const | 216 | int Calendar::getTimeZone() const |
218 | { | 217 | { |
219 | return mTimeZone; | 218 | return mTimeZone; |
220 | } | 219 | } |
221 | 220 | ||
222 | void Calendar::setTimeZoneId(const QString &id) | 221 | void Calendar::setTimeZoneId(const QString &id) |
223 | { | 222 | { |
224 | mTimeZoneId = id; | 223 | mTimeZoneId = id; |
225 | mLocalTime = false; | 224 | mLocalTime = false; |
226 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); | 225 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); |
227 | if ( mTimeZone > 1000) | 226 | if ( mTimeZone > 1000) |
228 | setLocalTime(); | 227 | setLocalTime(); |
229 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); | 228 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); |
230 | setModified( true ); | 229 | setModified( true ); |
231 | } | 230 | } |
232 | 231 | ||
233 | QString Calendar::timeZoneId() const | 232 | QString Calendar::timeZoneId() const |
234 | { | 233 | { |
235 | return mTimeZoneId; | 234 | return mTimeZoneId; |
236 | } | 235 | } |
237 | 236 | ||
238 | void Calendar::setLocalTime() | 237 | void Calendar::setLocalTime() |
239 | { | 238 | { |
240 | //qDebug("Calendar::setLocalTime() "); | 239 | //qDebug("Calendar::setLocalTime() "); |
241 | mLocalTime = true; | 240 | mLocalTime = true; |
242 | mTimeZone = 0; | 241 | mTimeZone = 0; |
243 | mTimeZoneId = ""; | 242 | mTimeZoneId = ""; |
244 | 243 | ||
245 | setModified( true ); | 244 | setModified( true ); |
246 | } | 245 | } |
247 | 246 | ||
248 | bool Calendar::isLocalTime() const | 247 | bool Calendar::isLocalTime() const |
249 | { | 248 | { |
250 | return mLocalTime; | 249 | return mLocalTime; |
251 | } | 250 | } |
252 | 251 | ||
253 | const QString &Calendar::getEmail() | 252 | const QString &Calendar::getEmail() |
254 | { | 253 | { |
255 | return mOwnerEmail; | 254 | return mOwnerEmail; |
256 | } | 255 | } |
257 | 256 | ||
258 | void Calendar::setEmail(const QString &e) | 257 | void Calendar::setEmail(const QString &e) |
259 | { | 258 | { |
260 | mOwnerEmail = e; | 259 | mOwnerEmail = e; |
261 | 260 | ||
262 | setModified( true ); | 261 | setModified( true ); |
263 | } | 262 | } |
264 | 263 | ||
265 | void Calendar::setFilter(CalFilter *filter) | 264 | void Calendar::setFilter(CalFilter *filter) |
266 | { | 265 | { |
267 | mFilter = filter; | 266 | mFilter = filter; |
268 | } | 267 | } |
269 | 268 | ||
270 | CalFilter *Calendar::filter() | 269 | CalFilter *Calendar::filter() |
271 | { | 270 | { |
272 | return mFilter; | 271 | return mFilter; |
273 | } | 272 | } |
274 | 273 | ||
275 | QPtrList<Incidence> Calendar::incidences() | 274 | QPtrList<Incidence> Calendar::incidences() |
276 | { | 275 | { |
277 | QPtrList<Incidence> incidences; | 276 | QPtrList<Incidence> incidences; |
278 | 277 | ||
279 | Incidence *i; | 278 | Incidence *i; |
280 | 279 | ||
281 | QPtrList<Event> e = events(); | 280 | QPtrList<Event> e = events(); |
282 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 281 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
283 | 282 | ||
284 | QPtrList<Todo> t = todos(); | 283 | QPtrList<Todo> t = todos(); |
285 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 284 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
286 | 285 | ||
287 | QPtrList<Journal> j = journals(); | 286 | QPtrList<Journal> j = journals(); |
288 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 287 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
289 | 288 | ||
290 | return incidences; | 289 | return incidences; |
291 | } | 290 | } |
292 | 291 | ||
293 | void Calendar::resetPilotStat(int id ) | 292 | void Calendar::resetPilotStat(int id ) |
294 | { | 293 | { |
295 | QPtrList<Incidence> incidences; | 294 | QPtrList<Incidence> incidences; |
296 | 295 | ||
297 | Incidence *i; | 296 | Incidence *i; |
298 | 297 | ||
299 | QPtrList<Event> e = rawEvents(); | 298 | QPtrList<Event> e = rawEvents(); |
300 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); | 299 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); |
301 | 300 | ||
302 | QPtrList<Todo> t = rawTodos(); | 301 | QPtrList<Todo> t = rawTodos(); |
303 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); | 302 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); |
304 | 303 | ||
305 | QPtrList<Journal> j = journals(); | 304 | QPtrList<Journal> j = journals(); |
306 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); | 305 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); |
307 | } | 306 | } |
308 | void Calendar::resetTempSyncStat() | 307 | void Calendar::resetTempSyncStat() |
309 | { | 308 | { |
310 | QPtrList<Incidence> incidences; | 309 | QPtrList<Incidence> incidences; |
311 | 310 | ||
312 | Incidence *i; | 311 | Incidence *i; |
313 | 312 | ||
314 | QPtrList<Event> e = rawEvents(); | 313 | QPtrList<Event> e = rawEvents(); |
315 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 314 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
316 | 315 | ||
317 | QPtrList<Todo> t = rawTodos(); | 316 | QPtrList<Todo> t = rawTodos(); |
318 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 317 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
319 | 318 | ||
320 | QPtrList<Journal> j = journals(); | 319 | QPtrList<Journal> j = journals(); |
321 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 320 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
322 | } | 321 | } |
323 | QPtrList<Incidence> Calendar::rawIncidences() | 322 | QPtrList<Incidence> Calendar::rawIncidences() |
324 | { | 323 | { |
325 | QPtrList<Incidence> incidences; | 324 | QPtrList<Incidence> incidences; |
326 | 325 | ||
327 | Incidence *i; | 326 | Incidence *i; |
328 | 327 | ||
329 | QPtrList<Event> e = rawEvents(); | 328 | QPtrList<Event> e = rawEvents(); |
330 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 329 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
331 | 330 | ||
332 | QPtrList<Todo> t = rawTodos(); | 331 | QPtrList<Todo> t = rawTodos(); |
333 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 332 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
334 | 333 | ||
335 | QPtrList<Journal> j = journals(); | 334 | QPtrList<Journal> j = journals(); |
336 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 335 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
337 | 336 | ||
338 | return incidences; | 337 | return incidences; |
339 | } | 338 | } |
340 | 339 | ||
341 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) | 340 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) |
342 | { | 341 | { |
343 | QPtrList<Event> el = rawEventsForDate(date,sorted); | 342 | QPtrList<Event> el = rawEventsForDate(date,sorted); |
344 | mFilter->apply(&el); | 343 | mFilter->apply(&el); |
345 | return el; | 344 | return el; |
346 | } | 345 | } |
347 | 346 | ||
348 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) | 347 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) |
349 | { | 348 | { |
350 | QPtrList<Event> el = rawEventsForDate(qdt); | 349 | QPtrList<Event> el = rawEventsForDate(qdt); |
351 | mFilter->apply(&el); | 350 | mFilter->apply(&el); |
352 | return el; | 351 | return el; |
353 | } | 352 | } |
354 | 353 | ||
355 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | 354 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, |
356 | bool inclusive) | 355 | bool inclusive) |
357 | { | 356 | { |
358 | QPtrList<Event> el = rawEvents(start,end,inclusive); | 357 | QPtrList<Event> el = rawEvents(start,end,inclusive); |
359 | mFilter->apply(&el); | 358 | mFilter->apply(&el); |
360 | return el; | 359 | return el; |
361 | } | 360 | } |
362 | 361 | ||
363 | QPtrList<Event> Calendar::events() | 362 | QPtrList<Event> Calendar::events() |
364 | { | 363 | { |
365 | QPtrList<Event> el = rawEvents(); | 364 | QPtrList<Event> el = rawEvents(); |
366 | mFilter->apply(&el); | 365 | mFilter->apply(&el); |
367 | return el; | 366 | return el; |
368 | } | 367 | } |
369 | void Calendar::addIncidenceBranch(Incidence *i) | 368 | void Calendar::addIncidenceBranch(Incidence *i) |
370 | { | 369 | { |
371 | addIncidence( i ); | 370 | addIncidence( i ); |
372 | Incidence * inc; | 371 | Incidence * inc; |
373 | QPtrList<Incidence> Relations = i->relations(); | 372 | QPtrList<Incidence> Relations = i->relations(); |
374 | for (inc=Relations.first();inc;inc=Relations.next()) { | 373 | for (inc=Relations.first();inc;inc=Relations.next()) { |
375 | addIncidenceBranch( inc ); | 374 | addIncidenceBranch( inc ); |
376 | } | 375 | } |
377 | } | 376 | } |
378 | 377 | ||
379 | bool Calendar::addIncidence(Incidence *i) | 378 | bool Calendar::addIncidence(Incidence *i) |
380 | { | 379 | { |
381 | Incidence::AddVisitor<Calendar> v(this); | 380 | Incidence::AddVisitor<Calendar> v(this); |
382 | if ( i->calID() == 0 ) | 381 | if ( i->calID() == 0 ) |
383 | i->setCalID_block( mDefaultCalendar ); | 382 | i->setCalID_block( mDefaultCalendar ); |
384 | i->setCalEnabled( true ); | 383 | i->setCalEnabled( true ); |
385 | return i->accept(v); | 384 | return i->accept(v); |
386 | } | 385 | } |
387 | void Calendar::deleteIncidence(Incidence *in) | 386 | void Calendar::deleteIncidence(Incidence *in) |
388 | { | 387 | { |
389 | if ( in->typeID() == eventID ) | 388 | if ( in->typeID() == eventID ) |
390 | deleteEvent( (Event*) in ); | 389 | deleteEvent( (Event*) in ); |
391 | else if ( in->typeID() == todoID ) | 390 | else if ( in->typeID() == todoID ) |
392 | deleteTodo( (Todo*) in); | 391 | deleteTodo( (Todo*) in); |
393 | else if ( in->typeID() == journalID ) | 392 | else if ( in->typeID() == journalID ) |
394 | deleteJournal( (Journal*) in ); | 393 | deleteJournal( (Journal*) in ); |
395 | } | 394 | } |
396 | 395 | ||
397 | Incidence* Calendar::incidence( const QString& uid ) | 396 | Incidence* Calendar::incidence( const QString& uid ) |
398 | { | 397 | { |
399 | Incidence* i; | 398 | Incidence* i; |
400 | 399 | ||
401 | if( (i = todo( uid )) != 0 ) | 400 | if( (i = todo( uid )) != 0 ) |
402 | return i; | 401 | return i; |
403 | if( (i = event( uid )) != 0 ) | 402 | if( (i = event( uid )) != 0 ) |
404 | return i; | 403 | return i; |
405 | if( (i = journal( uid )) != 0 ) | 404 | if( (i = journal( uid )) != 0 ) |
406 | return i; | 405 | return i; |
407 | 406 | ||
408 | return 0; | 407 | return 0; |
409 | } | 408 | } |
410 | 409 | ||
411 | QPtrList<Todo> Calendar::todos() | 410 | QPtrList<Todo> Calendar::todos() |
412 | { | 411 | { |
413 | QPtrList<Todo> tl = rawTodos(); | 412 | QPtrList<Todo> tl = rawTodos(); |
414 | mFilter->apply( &tl ); | 413 | mFilter->apply( &tl ); |
415 | return tl; | 414 | return tl; |
416 | } | 415 | } |
417 | 416 | ||
418 | // When this is called, the todo have already been added to the calendar. | 417 | // When this is called, the todo have already been added to the calendar. |
419 | // This method is only about linking related todos | 418 | // This method is only about linking related todos |
420 | void Calendar::setupRelations( Incidence *incidence ) | 419 | void Calendar::setupRelations( Incidence *incidence ) |
421 | { | 420 | { |
422 | QString uid = incidence->uid(); | 421 | QString uid = incidence->uid(); |
423 | //qDebug("Calendar::setupRelations "); | 422 | //qDebug("Calendar::setupRelations %s", incidence->summary().latin1()); |
424 | // First, go over the list of orphans and see if this is their parent | 423 | // First, go over the list of orphans and see if this is their parent |
425 | while( Incidence* i = mOrphans[ uid ] ) { | 424 | while( Incidence* i = mOrphans[ uid ] ) { |
426 | mOrphans.remove( uid ); | 425 | mOrphans.remove( uid ); |
427 | i->setRelatedTo( incidence ); | 426 | i->setRelatedTo( incidence ); |
427 | //qDebug("Add child %s ti inc %s", i->summary().latin1(),incidence->summary().latin1()); | ||
428 | incidence->addRelation( i ); | 428 | incidence->addRelation( i ); |
429 | mOrphanUids.remove( i->uid() ); | 429 | mOrphanUids.remove( i->uid() ); |
430 | } | 430 | } |
431 | 431 | ||
432 | // Now see about this incidences parent | 432 | // Now see about this incidences parent |
433 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { | 433 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { |
434 | // This incidence has a uid it is related to, but is not registered to it yet | 434 | // This incidence has a uid it is related to, but is not registered to it yet |
435 | // Try to find it | 435 | // Try to find it |
436 | Incidence* parent = this->incidence( incidence->relatedToUid() ); | 436 | //qDebug("Test parent for %s", incidence->summary().latin1()); |
437 | Incidence* parent = this->incidenceForUid( incidence->relatedToUid(), true ); | ||
437 | if( parent ) { | 438 | if( parent ) { |
438 | // Found it | 439 | // Found it |
440 | // qDebug("parent found for for %s", incidence->summary().latin1()); | ||
439 | incidence->setRelatedTo( parent ); | 441 | incidence->setRelatedTo( parent ); |
440 | parent->addRelation( incidence ); | 442 | parent->addRelation( incidence ); |
441 | } else { | 443 | } else { |
444 | // qDebug("NO parent found for for %s", incidence->summary().latin1()); | ||
442 | // Not found, put this in the mOrphans list | 445 | // Not found, put this in the mOrphans list |
443 | mOrphans.insert( incidence->relatedToUid(), incidence ); | 446 | mOrphans.insert( incidence->relatedToUid(), incidence ); |
444 | mOrphanUids.insert( incidence->uid(), incidence ); | 447 | mOrphanUids.insert( incidence->uid(), incidence ); |
445 | } | 448 | } |
446 | } | 449 | } |
447 | } | 450 | } |
448 | 451 | ||
449 | // If a task with subtasks is deleted, move it's subtasks to the orphans list | 452 | // If a task with subtasks is deleted, move it's subtasks to the orphans list |
450 | void Calendar::removeRelations( Incidence *incidence ) | 453 | void Calendar::removeRelations( Incidence *incidence ) |
451 | { | 454 | { |
452 | // qDebug("Calendar::removeRelations "); | 455 | // qDebug("Calendar::removeRelations "); |
453 | QString uid = incidence->uid(); | 456 | QString uid = incidence->uid(); |
454 | 457 | ||
455 | QPtrList<Incidence> relations = incidence->relations(); | 458 | QPtrList<Incidence> relations = incidence->relations(); |
456 | for( Incidence* i = relations.first(); i; i = relations.next() ) | 459 | for( Incidence* i = relations.first(); i; i = relations.next() ) |
457 | if( !mOrphanUids.find( i->uid() ) ) { | 460 | if( !mOrphanUids.find( i->uid() ) ) { |
458 | mOrphans.insert( uid, i ); | 461 | mOrphans.insert( uid, i ); |
459 | mOrphanUids.insert( i->uid(), i ); | 462 | mOrphanUids.insert( i->uid(), i ); |
460 | i->setRelatedTo( 0 ); | 463 | i->setRelatedTo( 0 ); |
461 | i->setRelatedToUid( uid ); | 464 | i->setRelatedToUid( uid ); |
462 | } | 465 | } |
463 | 466 | ||
464 | // If this incidence is related to something else, tell that about it | 467 | // If this incidence is related to something else, tell that about it |
465 | if( incidence->relatedTo() ) | 468 | if( incidence->relatedTo() ) |
466 | incidence->relatedTo()->removeRelation( incidence ); | 469 | incidence->relatedTo()->removeRelation( incidence ); |
467 | 470 | ||
468 | // Remove this one from the orphans list | 471 | // Remove this one from the orphans list |
469 | if( mOrphanUids.remove( uid ) ) { | 472 | if( mOrphanUids.remove( uid ) ) { |
470 | QString r2uid = incidence->relatedToUid(); | 473 | QString r2uid = incidence->relatedToUid(); |
471 | QPtrList<Incidence> tempList; | 474 | QPtrList<Incidence> tempList; |
472 | while( Incidence* i = mOrphans[ r2uid ] ) { | 475 | while( Incidence* i = mOrphans[ r2uid ] ) { |
473 | mOrphans.remove( r2uid ); | 476 | mOrphans.remove( r2uid ); |
474 | if ( i != incidence ) tempList.append( i ); | 477 | if ( i != incidence ) tempList.append( i ); |
475 | } | 478 | } |
476 | Incidence* inc = tempList.first(); | 479 | Incidence* inc = tempList.first(); |
477 | while ( inc ) { | 480 | while ( inc ) { |
478 | mOrphans.insert( r2uid, inc ); | 481 | mOrphans.insert( r2uid, inc ); |
479 | inc = tempList.next(); | 482 | inc = tempList.next(); |
480 | } | 483 | } |
481 | } | 484 | } |
482 | // LR: and another big bad bug found | 485 | // LR: and another big bad bug found |
483 | #if 0 | 486 | #if 0 |
484 | // This incidence is located in the orphans list - it should be removed | 487 | // This incidence is located in the orphans list - it should be removed |
485 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { | 488 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { |
486 | // Removing wasn't that easy | 489 | // Removing wasn't that easy |
487 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { | 490 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { |
488 | if( it.current()->uid() == uid ) { | 491 | if( it.current()->uid() == uid ) { |
489 | mOrphans.remove( it.currentKey() ); | 492 | mOrphans.remove( it.currentKey() ); |
490 | break; | 493 | break; |
491 | } | 494 | } |
492 | } | 495 | } |
493 | } | 496 | } |
494 | #endif | 497 | #endif |
495 | } | 498 | } |
496 | 499 | ||
497 | void Calendar::registerObserver( Observer *observer ) | 500 | void Calendar::registerObserver( Observer *observer ) |
498 | { | 501 | { |
499 | mObserver = observer; | 502 | mObserver = observer; |
500 | mNewObserver = true; | 503 | mNewObserver = true; |
501 | } | 504 | } |
502 | 505 | ||
503 | void Calendar::setModified( bool modified ) | 506 | void Calendar::setModified( bool modified ) |
504 | { | 507 | { |
505 | if ( mObserver ) mObserver->calendarModified( modified, this ); | 508 | if ( mObserver ) mObserver->calendarModified( modified, this ); |
506 | if ( modified != mModified || mNewObserver ) { | 509 | if ( modified != mModified || mNewObserver ) { |
507 | mNewObserver = false; | 510 | mNewObserver = false; |
508 | // if ( mObserver ) mObserver->calendarModified( modified, this ); | 511 | // if ( mObserver ) mObserver->calendarModified( modified, this ); |
509 | mModified = modified; | 512 | mModified = modified; |
510 | } | 513 | } |
511 | } | 514 | } |
512 | 515 | ||
513 | void Calendar::setLoadedProductId( const QString &id ) | 516 | void Calendar::setLoadedProductId( const QString &id ) |
514 | { | 517 | { |
515 | mLoadedProductId = id; | 518 | mLoadedProductId = id; |
516 | } | 519 | } |
517 | 520 | ||
518 | QString Calendar::loadedProductId() | 521 | QString Calendar::loadedProductId() |
519 | { | 522 | { |
520 | return mLoadedProductId; | 523 | return mLoadedProductId; |
521 | } | 524 | } |
522 | 525 | ||
523 | //#include "calendar.moc" | 526 | //#include "calendar.moc" |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index f301768..fbc40ad 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,384 +1,385 @@ | |||
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 , bool enabledOnly = false ) = 0; | 80 | virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates , bool enabledOnly = false ,int * isDup = 0 ) = 0; |
81 | virtual Todo* todoForUid( const QString& uid, bool doNotCheckDuplicates = true, bool enabledOnly = false ,int * isDup = 0) = 0; | ||
81 | virtual void setSyncEventsReadOnly() = 0; | 82 | virtual void setSyncEventsReadOnly() = 0; |
82 | virtual void setSyncEventsEnabled() = 0; | 83 | virtual void setSyncEventsEnabled() = 0; |
83 | virtual void stopAllTodos() = 0; | 84 | virtual void stopAllTodos() = 0; |
84 | virtual void clearUndo( Incidence * newUndo ); | 85 | virtual void clearUndo( Incidence * newUndo ); |
85 | 86 | ||
86 | /** | 87 | /** |
87 | Sync changes in memory to persistant storage. | 88 | Sync changes in memory to persistant storage. |
88 | */ | 89 | */ |
89 | virtual void save() = 0; | 90 | virtual void save() = 0; |
90 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 91 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
91 | virtual void removeSyncInfo( QString syncProfile) = 0; | 92 | virtual void removeSyncInfo( QString syncProfile) = 0; |
92 | virtual bool isSaving() { return false; } | 93 | virtual bool isSaving() { return false; } |
93 | 94 | ||
94 | /** | 95 | /** |
95 | Return the owner of the calendar's full name. | 96 | Return the owner of the calendar's full name. |
96 | */ | 97 | */ |
97 | const QString &getOwner() const; | 98 | const QString &getOwner() const; |
98 | /** | 99 | /** |
99 | Set the owner of the calendar. Should be owner's full name. | 100 | Set the owner of the calendar. Should be owner's full name. |
100 | */ | 101 | */ |
101 | void setOwner( const QString &os ); | 102 | void setOwner( const QString &os ); |
102 | /** | 103 | /** |
103 | Return the email address of the calendar owner. | 104 | Return the email address of the calendar owner. |
104 | */ | 105 | */ |
105 | const QString &getEmail(); | 106 | const QString &getEmail(); |
106 | /** | 107 | /** |
107 | Set the email address of the calendar owner. | 108 | Set the email address of the calendar owner. |
108 | */ | 109 | */ |
109 | void setEmail( const QString & ); | 110 | void setEmail( const QString & ); |
110 | 111 | ||
111 | /** | 112 | /** |
112 | Set time zone from a timezone string (e.g. -2:00) | 113 | Set time zone from a timezone string (e.g. -2:00) |
113 | */ | 114 | */ |
114 | void setTimeZone( const QString &tz ); | 115 | void setTimeZone( const QString &tz ); |
115 | /** | 116 | /** |
116 | Set time zone from a minutes value (e.g. -60) | 117 | Set time zone from a minutes value (e.g. -60) |
117 | */ | 118 | */ |
118 | void setTimeZone( int tz ); | 119 | void setTimeZone( int tz ); |
119 | /** | 120 | /** |
120 | Return time zone as offest in minutes. | 121 | Return time zone as offest in minutes. |
121 | */ | 122 | */ |
122 | int getTimeZone() const; | 123 | int getTimeZone() const; |
123 | /** | 124 | /** |
124 | Compute an ISO 8601 format string from the time zone. | 125 | Compute an ISO 8601 format string from the time zone. |
125 | */ | 126 | */ |
126 | QString getTimeZoneStr() const; | 127 | QString getTimeZoneStr() const; |
127 | /** | 128 | /** |
128 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 129 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
129 | values). | 130 | values). |
130 | */ | 131 | */ |
131 | void setTimeZoneId( const QString & ); | 132 | void setTimeZoneId( const QString & ); |
132 | /** | 133 | /** |
133 | Return time zone id. | 134 | Return time zone id. |
134 | */ | 135 | */ |
135 | QString timeZoneId() const; | 136 | QString timeZoneId() const; |
136 | /** | 137 | /** |
137 | Use local time, not UTC or a time zone. | 138 | Use local time, not UTC or a time zone. |
138 | */ | 139 | */ |
139 | void setLocalTime(); | 140 | void setLocalTime(); |
140 | /** | 141 | /** |
141 | Return whether local time is being used. | 142 | Return whether local time is being used. |
142 | */ | 143 | */ |
143 | bool isLocalTime() const; | 144 | bool isLocalTime() const; |
144 | 145 | ||
145 | /** | 146 | /** |
146 | Add an incidence to calendar. | 147 | Add an incidence to calendar. |
147 | 148 | ||
148 | @return true on success, false on error. | 149 | @return true on success, false on error. |
149 | */ | 150 | */ |
150 | virtual bool addIncidence( Incidence * ); | 151 | virtual bool addIncidence( Incidence * ); |
151 | 152 | ||
152 | // Adds an incidence and all relatedto incidences to the cal | 153 | // Adds an incidence and all relatedto incidences to the cal |
153 | void addIncidenceBranch( Incidence * ); | 154 | void addIncidenceBranch( Incidence * ); |
154 | /** | 155 | /** |
155 | Return filtered list of all incidences of this calendar. | 156 | Return filtered list of all incidences of this calendar. |
156 | */ | 157 | */ |
157 | virtual QPtrList<Incidence> incidences(); | 158 | virtual QPtrList<Incidence> incidences(); |
158 | 159 | ||
159 | /** | 160 | /** |
160 | Return unfiltered list of all incidences of this calendar. | 161 | Return unfiltered list of all incidences of this calendar. |
161 | */ | 162 | */ |
162 | virtual QPtrList<Incidence> rawIncidences(); | 163 | virtual QPtrList<Incidence> rawIncidences(); |
163 | 164 | ||
164 | /** | 165 | /** |
165 | Adds a Event to this calendar object. | 166 | Adds a Event to this calendar object. |
166 | @param anEvent a pointer to the event to add | 167 | @param anEvent a pointer to the event to add |
167 | 168 | ||
168 | @return true on success, false on error. | 169 | @return true on success, false on error. |
169 | */ | 170 | */ |
170 | virtual bool addEventNoDup( Event *event ) = 0; | 171 | virtual bool addEventNoDup( Event *event ) = 0; |
171 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 172 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
172 | virtual bool addEvent( Event *anEvent ) = 0; | 173 | virtual bool addEvent( Event *anEvent ) = 0; |
173 | /** | 174 | /** |
174 | Delete event from calendar. | 175 | Delete event from calendar. |
175 | */ | 176 | */ |
176 | virtual void deleteEvent( Event * ) = 0; | 177 | virtual void deleteEvent( Event * ) = 0; |
177 | /** | 178 | /** |
178 | Retrieves an event on the basis of the unique string ID. | 179 | Retrieves an event on the basis of the unique string ID. |
179 | */ | 180 | */ |
180 | virtual Event *event( const QString &UniqueStr ) = 0; | 181 | virtual Event *event( const QString &UniqueStr ) = 0; |
181 | virtual Event *event( QString, QString ) = 0; | 182 | virtual Event *event( QString, QString ) = 0; |
182 | /** | 183 | /** |
183 | Builds and then returns a list of all events that match for the | 184 | Builds and then returns a list of all events that match for the |
184 | date specified. useful for dayView, etc. etc. | 185 | date specified. useful for dayView, etc. etc. |
185 | The calendar filter is applied. | 186 | The calendar filter is applied. |
186 | */ | 187 | */ |
187 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 188 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
188 | /** | 189 | /** |
189 | Get events, which occur on the given date. | 190 | Get events, which occur on the given date. |
190 | The calendar filter is applied. | 191 | The calendar filter is applied. |
191 | */ | 192 | */ |
192 | QPtrList<Event> events( const QDateTime &qdt ); | 193 | QPtrList<Event> events( const QDateTime &qdt ); |
193 | /** | 194 | /** |
194 | Get events in a range of dates. If inclusive is set to true, only events | 195 | Get events in a range of dates. If inclusive is set to true, only events |
195 | are returned, which are completely included in the range. | 196 | are returned, which are completely included in the range. |
196 | The calendar filter is applied. | 197 | The calendar filter is applied. |
197 | */ | 198 | */ |
198 | QPtrList<Event> events( const QDate &start, const QDate &end, | 199 | QPtrList<Event> events( const QDate &start, const QDate &end, |
199 | bool inclusive = false); | 200 | bool inclusive = false); |
200 | /** | 201 | /** |
201 | Return filtered list of all events in calendar. | 202 | Return filtered list of all events in calendar. |
202 | */ | 203 | */ |
203 | virtual QPtrList<Event> events(); | 204 | virtual QPtrList<Event> events(); |
204 | /** | 205 | /** |
205 | Return unfiltered list of all events in calendar. | 206 | Return unfiltered list of all events in calendar. |
206 | */ | 207 | */ |
207 | virtual QPtrList<Event> rawEvents() = 0; | 208 | virtual QPtrList<Event> rawEvents() = 0; |
208 | 209 | ||
209 | /** | 210 | /** |
210 | Add a todo to the todolist. | 211 | Add a todo to the todolist. |
211 | 212 | ||
212 | @return true on success, false on error. | 213 | @return true on success, false on error. |
213 | */ | 214 | */ |
214 | virtual bool addTodo( Todo *todo ) = 0; | 215 | virtual bool addTodo( Todo *todo ) = 0; |
215 | virtual bool addTodoNoDup( Todo *todo ) = 0; | 216 | virtual bool addTodoNoDup( Todo *todo ) = 0; |
216 | /** | 217 | /** |
217 | Remove a todo from the todolist. | 218 | Remove a todo from the todolist. |
218 | */ | 219 | */ |
219 | virtual void deleteTodo( Todo * ) = 0; | 220 | virtual void deleteTodo( Todo * ) = 0; |
220 | virtual void deleteJournal( Journal * ) = 0; | 221 | virtual void deleteJournal( Journal * ) = 0; |
221 | /** | 222 | /** |
222 | Return filterd list of todos. | 223 | Return filterd list of todos. |
223 | */ | 224 | */ |
224 | virtual QPtrList<Todo> todos(); | 225 | virtual QPtrList<Todo> todos(); |
225 | /** | 226 | /** |
226 | Searches todolist for an event with this unique string identifier, | 227 | Searches todolist for an event with this unique string identifier, |
227 | returns a pointer or null. | 228 | returns a pointer or null. |
228 | */ | 229 | */ |
229 | virtual Todo *todo( const QString &uid ) = 0; | 230 | virtual Todo *todo( const QString &uid ) = 0; |
230 | virtual Todo *todo( QString, QString ) = 0; | 231 | virtual Todo *todo( QString, QString ) = 0; |
231 | /** | 232 | /** |
232 | Returns list of todos due on the specified date. | 233 | Returns list of todos due on the specified date. |
233 | */ | 234 | */ |
234 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; | 235 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; |
235 | /** | 236 | /** |
236 | Return unfiltered list of todos. | 237 | Return unfiltered list of todos. |
237 | */ | 238 | */ |
238 | virtual QPtrList<Todo> rawTodos() = 0; | 239 | virtual QPtrList<Todo> rawTodos() = 0; |
239 | 240 | ||
240 | /** | 241 | /** |
241 | Add a Journal entry to calendar. | 242 | Add a Journal entry to calendar. |
242 | 243 | ||
243 | @return true on success, false on error. | 244 | @return true on success, false on error. |
244 | */ | 245 | */ |
245 | virtual bool addJournal( Journal * ) = 0; | 246 | virtual bool addJournal( Journal * ) = 0; |
246 | /** | 247 | /** |
247 | Return Journal for given date. | 248 | Return Journal for given date. |
248 | */ | 249 | */ |
249 | virtual Journal *journal( const QDate & ) = 0; | 250 | virtual Journal *journal( const QDate & ) = 0; |
250 | virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; | 251 | virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; |
251 | /** | 252 | /** |
252 | Return Journal with given UID. | 253 | Return Journal with given UID. |
253 | */ | 254 | */ |
254 | virtual Journal *journal( const QString &UID ) = 0; | 255 | virtual Journal *journal( const QString &UID ) = 0; |
255 | /** | 256 | /** |
256 | Return list of all Journal entries. | 257 | Return list of all Journal entries. |
257 | */ | 258 | */ |
258 | virtual QPtrList<Journal> journals() = 0; | 259 | virtual QPtrList<Journal> journals() = 0; |
259 | 260 | ||
260 | /** | 261 | /** |
261 | Searches all incidence types for an incidence with this unique | 262 | Searches all incidence types for an incidence with this unique |
262 | string identifier, returns a pointer or null. | 263 | string identifier, returns a pointer or null. |
263 | */ | 264 | */ |
264 | Incidence* incidence( const QString&UID ); | 265 | Incidence* incidence( const QString&UID ); |
265 | 266 | ||
266 | /** | 267 | /** |
267 | Setup relations for an incidence. | 268 | Setup relations for an incidence. |
268 | */ | 269 | */ |
269 | virtual void setupRelations( Incidence * ); | 270 | virtual void setupRelations( Incidence * ); |
270 | /** | 271 | /** |
271 | Remove all relations to an incidence | 272 | Remove all relations to an incidence |
272 | */ | 273 | */ |
273 | virtual void removeRelations( Incidence * ); | 274 | virtual void removeRelations( Incidence * ); |
274 | 275 | ||
275 | /** | 276 | /** |
276 | Set calendar filter, which filters events for the events() functions. | 277 | Set calendar filter, which filters events for the events() functions. |
277 | The Filter object is owned by the caller. | 278 | The Filter object is owned by the caller. |
278 | */ | 279 | */ |
279 | void setFilter( CalFilter * ); | 280 | void setFilter( CalFilter * ); |
280 | /** | 281 | /** |
281 | Return calendar filter. | 282 | Return calendar filter. |
282 | */ | 283 | */ |
283 | CalFilter *filter(); | 284 | CalFilter *filter(); |
284 | virtual QDateTime nextAlarm( int daysTo ) = 0; | 285 | virtual QDateTime nextAlarm( int daysTo ) = 0; |
285 | virtual QString nextSummary( ) const = 0; | 286 | virtual QString nextSummary( ) const = 0; |
286 | virtual void reInitAlarmSettings() = 0; | 287 | virtual void reInitAlarmSettings() = 0; |
287 | virtual QDateTime nextAlarmEventDateTime() const = 0; | 288 | virtual QDateTime nextAlarmEventDateTime() const = 0; |
288 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; | 289 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; |
289 | /** | 290 | /** |
290 | Return all alarms, which ocur in the given time interval. | 291 | Return all alarms, which ocur in the given time interval. |
291 | */ | 292 | */ |
292 | virtual Alarm::List alarms( const QDateTime &from, | 293 | virtual Alarm::List alarms( const QDateTime &from, |
293 | const QDateTime &to ) = 0; | 294 | const QDateTime &to ) = 0; |
294 | 295 | ||
295 | class Observer { | 296 | class Observer { |
296 | public: | 297 | public: |
297 | virtual void calendarModified( bool, Calendar * ) = 0; | 298 | virtual void calendarModified( bool, Calendar * ) = 0; |
298 | }; | 299 | }; |
299 | 300 | ||
300 | void registerObserver( Observer * ); | 301 | void registerObserver( Observer * ); |
301 | 302 | ||
302 | void setModified( bool ); | 303 | void setModified( bool ); |
303 | 304 | ||
304 | /** | 305 | /** |
305 | Set product id returned by loadedProductId(). This function is only | 306 | Set product id returned by loadedProductId(). This function is only |
306 | useful for the calendar loading code. | 307 | useful for the calendar loading code. |
307 | */ | 308 | */ |
308 | void setLoadedProductId( const QString & ); | 309 | void setLoadedProductId( const QString & ); |
309 | /** | 310 | /** |
310 | Return product id taken from file that has been loaded. Returns | 311 | Return product id taken from file that has been loaded. Returns |
311 | QString::null, if no calendar has been loaded. | 312 | QString::null, if no calendar has been loaded. |
312 | */ | 313 | */ |
313 | QString loadedProductId(); | 314 | QString loadedProductId(); |
314 | int defaultCalendar(); | 315 | int defaultCalendar(); |
315 | void setDontDeleteIncidencesOnClose (); | 316 | void setDontDeleteIncidencesOnClose (); |
316 | public slots: | 317 | public slots: |
317 | void setDefaultCalendar( int ); | 318 | void setDefaultCalendar( int ); |
318 | virtual void setCalendarEnabled( int id, bool enable ) = 0; | 319 | virtual void setCalendarEnabled( int id, bool enable ) = 0; |
319 | virtual void setAllCalendarEnabled( bool enable ) = 0; | 320 | virtual void setAllCalendarEnabled( bool enable ) = 0; |
320 | virtual void setAlarmEnabled( int id, bool enable ) = 0; | 321 | virtual void setAlarmEnabled( int id, bool enable ) = 0; |
321 | virtual void setReadOnly( int id, bool enable ) = 0; | 322 | virtual void setReadOnly( int id, bool enable ) = 0; |
322 | virtual void setDefaultCalendarEnabledOnly() = 0; | 323 | virtual void setDefaultCalendarEnabledOnly() = 0; |
323 | virtual void setCalendarRemove( int id ) = 0; | 324 | virtual void setCalendarRemove( int id ) = 0; |
324 | virtual void getIncidenceCount( int calId, int& events, int & todos, int & journals) = 0; | 325 | virtual void getIncidenceCount( int calId, int& events, int & todos, int & journals) = 0; |
325 | 326 | ||
326 | signals: | 327 | signals: |
327 | void calendarChanged(); | 328 | void calendarChanged(); |
328 | void calendarSaved(); | 329 | void calendarSaved(); |
329 | void calendarLoaded(); | 330 | void calendarLoaded(); |
330 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 331 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
331 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 332 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
332 | 333 | ||
333 | protected: | 334 | protected: |
334 | /** | 335 | /** |
335 | Get unfiltered events, which occur on the given date. | 336 | Get unfiltered events, which occur on the given date. |
336 | */ | 337 | */ |
337 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; | 338 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; |
338 | /** | 339 | /** |
339 | Get unfiltered events, which occur on the given date. | 340 | Get unfiltered events, which occur on the given date. |
340 | */ | 341 | */ |
341 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, | 342 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, |
342 | bool sorted = false ) = 0; | 343 | bool sorted = false ) = 0; |
343 | /** | 344 | /** |
344 | Get events in a range of dates. If inclusive is set to true, only events | 345 | Get events in a range of dates. If inclusive is set to true, only events |
345 | are returned, which are completely included in the range. | 346 | are returned, which are completely included in the range. |
346 | */ | 347 | */ |
347 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 348 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
348 | bool inclusive = false ) = 0; | 349 | bool inclusive = false ) = 0; |
349 | 350 | ||
350 | Incidence *mNextAlarmIncidence; | 351 | Incidence *mNextAlarmIncidence; |
351 | Incidence *mUndoIncidence; | 352 | Incidence *mUndoIncidence; |
352 | int mDefaultCalendar; | 353 | int mDefaultCalendar; |
353 | bool mDeleteIncidencesOnClose; | 354 | bool mDeleteIncidencesOnClose; |
354 | 355 | ||
355 | private: | 356 | private: |
356 | void init(); | 357 | void init(); |
357 | 358 | ||
358 | QString mOwner; // who the calendar belongs to | 359 | QString mOwner; // who the calendar belongs to |
359 | QString mOwnerEmail; // email address of the owner | 360 | QString mOwnerEmail; // email address of the owner |
360 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) | 361 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) |
361 | bool mLocalTime; // use local time, not UTC or a time zone | 362 | bool mLocalTime; // use local time, not UTC or a time zone |
362 | 363 | ||
363 | 364 | ||
364 | CalFilter *mFilter; | 365 | CalFilter *mFilter; |
365 | CalFilter *mDefaultFilter; | 366 | CalFilter *mDefaultFilter; |
366 | 367 | ||
367 | 368 | ||
368 | QString mTimeZoneId; | 369 | QString mTimeZoneId; |
369 | 370 | ||
370 | Observer *mObserver; | 371 | Observer *mObserver; |
371 | bool mNewObserver; | 372 | bool mNewObserver; |
372 | 373 | ||
373 | bool mModified; | 374 | bool mModified; |
374 | 375 | ||
375 | QString mLoadedProductId; | 376 | QString mLoadedProductId; |
376 | 377 | ||
377 | // This list is used to put together related todos | 378 | // This list is used to put together related todos |
378 | QDict<Incidence> mOrphans; | 379 | QDict<Incidence> mOrphans; |
379 | QDict<Incidence> mOrphanUids; | 380 | QDict<Incidence> mOrphanUids; |
380 | }; | 381 | }; |
381 | 382 | ||
382 | } | 383 | } |
383 | 384 | ||
384 | #endif | 385 | #endif |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index ad8ace3..980663f 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -1,1089 +1,1140 @@ | |||
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 | registerObserver( 0 ); | 68 | registerObserver( 0 ); |
69 | if ( mDeleteIncidencesOnClose ) | 69 | if ( mDeleteIncidencesOnClose ) |
70 | close(); | 70 | close(); |
71 | } | 71 | } |
72 | bool CalendarLocal::mergeCalendarFile( QString name ) | 72 | bool CalendarLocal::mergeCalendarFile( QString name ) |
73 | { | 73 | { |
74 | CalendarLocal calendar( timeZoneId() ); | 74 | CalendarLocal calendar( timeZoneId() ); |
75 | calendar.setDefaultCalendar( 1 ); | 75 | calendar.setDefaultCalendar( 1 ); |
76 | if ( calendar.load( name ) ) { | 76 | if ( calendar.load( name ) ) { |
77 | mergeCalendar( &calendar ); | 77 | mergeCalendar( &calendar ); |
78 | return true; | 78 | return true; |
79 | } | 79 | } |
80 | return false; | 80 | return false; |
81 | } | 81 | } |
82 | 82 | ||
83 | Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates, bool enabledOnly ) | 83 | Todo* CalendarLocal::todoForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly,int * isDup ) |
84 | { | 84 | { |
85 | |||
86 | int calID = 0; | ||
87 | if ( isDup && *isDup > 0 ) | ||
88 | calID = *isDup; | ||
85 | Todo *todo;; | 89 | Todo *todo;; |
86 | Incidence *retVal = 0; | 90 | Todo *retVal = 0; |
87 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 91 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
88 | if ( todo->uid() == uid ) { | 92 | if ( todo->uid() == uid ) { |
89 | if ( enabledOnly ) | 93 | if( calID ) { |
90 | if ( !todo->calEnabled() ) | 94 | if ( todo->calID() != calID ) |
91 | continue; | 95 | continue; |
96 | } | ||
97 | else { | ||
98 | if ( enabledOnly ) { | ||
99 | if ( !todo->calEnabled() ) { | ||
100 | if ( isDup ) | ||
101 | *isDup = todo->calID(); | ||
102 | continue; | ||
103 | } | ||
104 | } | ||
105 | } | ||
92 | if ( doNotCheckDuplicates ) return todo; | 106 | if ( doNotCheckDuplicates ) return todo; |
93 | if ( retVal ) { | 107 | if ( retVal ) { |
94 | if ( retVal->calID() > todo->calID() ) { | 108 | if ( retVal->calID() > todo->calID() ) { |
109 | if ( isDup ) | ||
110 | *isDup = retVal->calID(); | ||
95 | retVal = todo; | 111 | retVal = todo; |
96 | } | 112 | } |
97 | } else { | 113 | } else { |
98 | retVal = todo; | 114 | retVal = todo; |
99 | } | 115 | } |
100 | } | 116 | } |
101 | } | 117 | } |
118 | return retVal; | ||
119 | } | ||
120 | //if ( isDup) and * isDup == 0: store duplicate found cal id in isDup | ||
121 | //if ( isDup) and * isDup > 0: search only in calendar with ID *isDup, ignore enabledOnly | ||
122 | |||
123 | Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates, bool enabledOnly, int * isDup ) | ||
124 | { | ||
125 | int calID = 0; | ||
126 | if ( isDup && *isDup > 0 ) | ||
127 | calID = *isDup; | ||
128 | Incidence *retVal = todoForUid( uid , doNotCheckDuplicates,enabledOnly, isDup ); | ||
102 | if ( retVal ) return retVal; | 129 | if ( retVal ) return retVal; |
103 | Event *event; | 130 | Event *event; |
104 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 131 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
105 | if ( event->uid() == uid ) { | 132 | if ( event->uid() == uid ) { |
106 | if ( enabledOnly ) | 133 | if( calID ) { |
107 | if ( !event->calEnabled() ) | 134 | if ( event->calID() != calID ) |
108 | continue; | 135 | continue; |
136 | } | ||
137 | else { | ||
138 | if ( enabledOnly ) { | ||
139 | if ( !event->calEnabled() ) { | ||
140 | if ( isDup ) | ||
141 | *isDup =event->calID() ; | ||
142 | continue; | ||
143 | } | ||
144 | } | ||
145 | } | ||
109 | if ( doNotCheckDuplicates ) return event; | 146 | if ( doNotCheckDuplicates ) return event; |
110 | if ( retVal ) { | 147 | if ( retVal ) { |
111 | if ( retVal->calID() > event->calID() ) { | 148 | if ( retVal->calID() > event->calID() ) { |
149 | if ( isDup ) | ||
150 | *isDup = retVal->calID(); | ||
112 | retVal = event; | 151 | retVal = event; |
113 | } | 152 | } |
114 | } else { | 153 | } else { |
115 | retVal = event; | 154 | retVal = event; |
116 | } | 155 | } |
117 | } | 156 | } |
118 | } | 157 | } |
119 | if ( retVal ) return retVal; | 158 | if ( retVal ) return retVal; |
120 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 159 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
121 | if ( it->uid() == uid ) { | 160 | if ( it->uid() == uid ) { |
122 | if ( enabledOnly ) | 161 | if( calID ) { |
123 | if ( !it->calEnabled() ) | 162 | if ( event->calID() != calID ) |
124 | continue; | 163 | continue; |
164 | } | ||
165 | else { | ||
166 | if ( enabledOnly ) { | ||
167 | if ( !it->calEnabled() ) { | ||
168 | if ( isDup ) | ||
169 | *isDup = it->calID(); | ||
170 | continue; | ||
171 | } | ||
172 | } | ||
173 | } | ||
125 | if ( doNotCheckDuplicates ) return it; | 174 | if ( doNotCheckDuplicates ) return it; |
126 | if ( retVal ) { | 175 | if ( retVal ) { |
127 | if ( retVal->calID() > it->calID() ) { | 176 | if ( retVal->calID() > it->calID() ) { |
177 | if ( isDup ) | ||
178 | *isDup = retVal->calID(); | ||
128 | retVal = it; | 179 | retVal = it; |
129 | } | 180 | } |
130 | } else { | 181 | } else { |
131 | retVal = it; | 182 | retVal = it; |
132 | } | 183 | } |
133 | } | 184 | } |
134 | return retVal; | 185 | return retVal; |
135 | } | 186 | } |
136 | 187 | ||
137 | bool CalendarLocal::mergeCalendar( Calendar* remote ) | 188 | bool CalendarLocal::mergeCalendar( Calendar* remote ) |
138 | { | 189 | { |
139 | // 1 look for raw inc in local | 190 | // 1 look for raw inc in local |
140 | // if inc not in remote, delete in local | 191 | // if inc not in remote, delete in local |
141 | // 2 look for raw inc in remote | 192 | // 2 look for raw inc in remote |
142 | // if inc in local, replace it | 193 | // if inc in local, replace it |
143 | // if not in local, add it to default calendar | 194 | // if not in local, add it to default calendar |
144 | QPtrList<Incidence> localInc = rawIncidences(); | 195 | QPtrList<Incidence> localInc = rawIncidences(); |
145 | Incidence* inL = localInc.first(); | 196 | Incidence* inL = localInc.first(); |
146 | while ( inL ) { | 197 | while ( inL ) { |
147 | if ( ! inL->isReadOnly () ) | 198 | if ( ! inL->isReadOnly () ) |
148 | if ( !remote->incidenceForUid( inL->uid(), true )) | 199 | if ( !remote->incidenceForUid( inL->uid(), true )) |
149 | deleteIncidence( inL ); | 200 | deleteIncidence( inL ); |
150 | inL = localInc.next(); | 201 | inL = localInc.next(); |
151 | } | 202 | } |
152 | QPtrList<Incidence> er = remote->rawIncidences(); | 203 | QPtrList<Incidence> er = remote->rawIncidences(); |
153 | Incidence* inR = er.first(); | 204 | Incidence* inR = er.first(); |
154 | while ( inR ) { | 205 | while ( inR ) { |
155 | inL = incidenceForUid( inR->uid(),false ); | 206 | inL = incidenceForUid( inR->uid(),false ); |
156 | if ( inL ) { | 207 | if ( inL ) { |
157 | if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { | 208 | if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { |
158 | int calID = inL->calID(); | 209 | int calID = inL->calID(); |
159 | deleteIncidence( inL ); | 210 | deleteIncidence( inL ); |
160 | inL = inR->clone(); | 211 | inL = inR->clone(); |
161 | inL->setCalID_block( calID ); | 212 | inL->setCalID_block( calID ); |
162 | addIncidence( inL ); | 213 | addIncidence( inL ); |
163 | } | 214 | } |
164 | } else { | 215 | } else { |
165 | inL = inR->clone(); | 216 | inL = inR->clone(); |
166 | inL->setCalID_block( 0 );// add to default cal | 217 | inL->setCalID_block( 0 );// add to default cal |
167 | addIncidence( inL ); | 218 | addIncidence( inL ); |
168 | } | 219 | } |
169 | inR = er.next(); | 220 | inR = er.next(); |
170 | } | 221 | } |
171 | return true; | 222 | return true; |
172 | } | 223 | } |
173 | 224 | ||
174 | 225 | ||
175 | bool CalendarLocal::addCalendarFile( QString name, int id ) | 226 | bool CalendarLocal::addCalendarFile( QString name, int id ) |
176 | { | 227 | { |
177 | CalendarLocal calendar( timeZoneId() ); | 228 | CalendarLocal calendar( timeZoneId() ); |
178 | calendar.setDefaultCalendar( id ); | 229 | calendar.setDefaultCalendar( id ); |
179 | if ( calendar.load( name ) ) { | 230 | if ( calendar.load( name ) ) { |
180 | addCalendar( &calendar ); | 231 | addCalendar( &calendar ); |
181 | return true; | 232 | return true; |
182 | } | 233 | } |
183 | return false; | 234 | return false; |
184 | } | 235 | } |
185 | void CalendarLocal::setSyncEventsEnabled() | 236 | void CalendarLocal::setSyncEventsEnabled() |
186 | { | 237 | { |
187 | Event * ev; | 238 | Event * ev; |
188 | ev = mEventList.first(); | 239 | ev = mEventList.first(); |
189 | while ( ev ) { | 240 | while ( ev ) { |
190 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 241 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
191 | ev->setCalEnabled( true ); | 242 | ev->setCalEnabled( true ); |
192 | ev = mEventList.next(); | 243 | ev = mEventList.next(); |
193 | } | 244 | } |
194 | } | 245 | } |
195 | void CalendarLocal::setSyncEventsReadOnly() | 246 | void CalendarLocal::setSyncEventsReadOnly() |
196 | { | 247 | { |
197 | Event * ev; | 248 | Event * ev; |
198 | ev = mEventList.first(); | 249 | ev = mEventList.first(); |
199 | while ( ev ) { | 250 | while ( ev ) { |
200 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) { | 251 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) { |
201 | ev->setReadOnly( true ); | 252 | ev->setReadOnly( true ); |
202 | } | 253 | } |
203 | ev = mEventList.next(); | 254 | ev = mEventList.next(); |
204 | } | 255 | } |
205 | } | 256 | } |
206 | 257 | ||
207 | void CalendarLocal::addCalendar( Calendar* cal ) | 258 | void CalendarLocal::addCalendar( Calendar* cal ) |
208 | { | 259 | { |
209 | cal->setDontDeleteIncidencesOnClose(); | 260 | cal->setDontDeleteIncidencesOnClose(); |
210 | setSyncEventsEnabled(); | 261 | setSyncEventsEnabled(); |
211 | { | 262 | { |
212 | QPtrList<Event> EventList = cal->rawEvents(); | 263 | QPtrList<Event> EventList = cal->rawEvents(); |
213 | QPtrList<Event> el; | 264 | QPtrList<Event> el; |
214 | Event * ev = EventList.first(); | 265 | Event * ev = EventList.first(); |
215 | while ( ev ) { | 266 | while ( ev ) { |
216 | if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { | 267 | if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { |
217 | Event * se = event( ev->uid() ); | 268 | Event * se = event( ev->uid() ); |
218 | if ( se ) | 269 | if ( se ) |
219 | el.append( se ); | 270 | el.append( se ); |
220 | ev->setCalID_block( 1 ); | 271 | ev->setCalID_block( 1 ); |
221 | } | 272 | } |
222 | ev->unRegisterObserver( cal ); | 273 | ev->unRegisterObserver( cal ); |
223 | ev->registerObserver( this ); | 274 | ev->registerObserver( this ); |
224 | mEventList.append( ev ); | 275 | mEventList.append( ev ); |
225 | ev = EventList.next(); | 276 | ev = EventList.next(); |
226 | } | 277 | } |
227 | for ( ev = el.first(); ev; ev = el.next() ) { | 278 | for ( ev = el.first(); ev; ev = el.next() ) { |
228 | deleteIncidence ( ev ); | 279 | deleteIncidence ( ev ); |
229 | } | 280 | } |
230 | } | 281 | } |
231 | { | 282 | { |
232 | 283 | ||
233 | QPtrList<Todo> TodoList = cal->rawTodos(); | 284 | QPtrList<Todo> TodoList = cal->rawTodos(); |
234 | Todo * ev = TodoList.first(); | 285 | Todo * ev = TodoList.first(); |
235 | while ( ev ) { | 286 | while ( ev ) { |
236 | QString rel = ev->relatedToUid(); | 287 | ev->resetRelatedTo(); |
237 | if ( !rel.isEmpty() ){ | ||
238 | ev->setRelatedTo ( 0 ); | ||
239 | ev->setRelatedToUid( rel ); | ||
240 | } | ||
241 | ev = TodoList.next(); | 288 | ev = TodoList.next(); |
242 | } | 289 | } |
243 | //TodoList = cal->rawTodos(); | 290 | //TodoList = cal->rawTodos(); |
244 | ev = TodoList.first(); | 291 | ev = TodoList.first(); |
245 | while ( ev ) { | 292 | while ( ev ) { |
246 | ev->unRegisterObserver( cal ); | 293 | ev->unRegisterObserver( cal ); |
247 | ev->registerObserver( this ); | 294 | ev->registerObserver( this ); |
248 | mTodoList.append( ev ); | 295 | mTodoList.append( ev ); |
249 | setupRelations( ev ); | 296 | setupRelations( ev ); |
250 | ev = TodoList.next(); | 297 | ev = TodoList.next(); |
251 | } | 298 | } |
252 | } | 299 | } |
253 | { | 300 | { |
254 | QPtrList<Journal> JournalList = cal->journals(); | 301 | QPtrList<Journal> JournalList = cal->journals(); |
255 | Journal * ev = JournalList.first(); | 302 | Journal * ev = JournalList.first(); |
256 | while ( ev ) { | 303 | while ( ev ) { |
257 | ev->unRegisterObserver( cal ); | 304 | ev->unRegisterObserver( cal ); |
258 | ev->registerObserver( this ); | 305 | ev->registerObserver( this ); |
259 | mJournalList.append( ev ); | 306 | mJournalList.append( ev ); |
260 | ev = JournalList.next(); | 307 | ev = JournalList.next(); |
261 | } | 308 | } |
262 | } | 309 | } |
263 | setModified( true ); | 310 | setModified( true ); |
264 | } | 311 | } |
265 | bool CalendarLocal::load( const QString &fileName ) | 312 | bool CalendarLocal::load( const QString &fileName ) |
266 | { | 313 | { |
267 | FileStorage storage( this, fileName ); | 314 | FileStorage storage( this, fileName ); |
268 | return storage.load(); | 315 | return storage.load(); |
269 | } | 316 | } |
270 | 317 | ||
271 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) | 318 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) |
272 | { | 319 | { |
273 | FileStorage storage( this, fileName, format ); | 320 | FileStorage storage( this, fileName, format ); |
274 | return storage.save(); | 321 | return storage.save(); |
275 | } | 322 | } |
276 | 323 | ||
277 | void CalendarLocal::stopAllTodos() | 324 | void CalendarLocal::stopAllTodos() |
278 | { | 325 | { |
279 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 326 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
280 | it->setRunning( false ); | 327 | it->setRunning( false ); |
281 | 328 | ||
282 | } | 329 | } |
283 | void CalendarLocal::close() | 330 | void CalendarLocal::close() |
284 | { | 331 | { |
285 | 332 | ||
286 | Todo * i; | 333 | Todo * i; |
287 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); | 334 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); |
288 | 335 | ||
289 | mEventList.setAutoDelete( true ); | 336 | mEventList.setAutoDelete( true ); |
290 | mTodoList.setAutoDelete( true ); | 337 | mTodoList.setAutoDelete( true ); |
291 | mJournalList.setAutoDelete( true ); | 338 | mJournalList.setAutoDelete( true ); |
292 | 339 | ||
293 | mEventList.clear(); | 340 | mEventList.clear(); |
294 | mTodoList.clear(); | 341 | mTodoList.clear(); |
295 | mJournalList.clear(); | 342 | mJournalList.clear(); |
296 | 343 | ||
297 | mEventList.setAutoDelete( false ); | 344 | mEventList.setAutoDelete( false ); |
298 | mTodoList.setAutoDelete( false ); | 345 | mTodoList.setAutoDelete( false ); |
299 | mJournalList.setAutoDelete( false ); | 346 | mJournalList.setAutoDelete( false ); |
300 | 347 | ||
301 | setModified( false ); | 348 | setModified( false ); |
302 | } | 349 | } |
303 | 350 | ||
304 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | 351 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) |
305 | { | 352 | { |
306 | QString cat; | 353 | QString cat; |
307 | bool isBirthday = true; | 354 | bool isBirthday = true; |
308 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { | 355 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { |
309 | isBirthday = false; | 356 | isBirthday = false; |
310 | cat = i18n( "Anniversary" ); | 357 | cat = i18n( "Anniversary" ); |
311 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { | 358 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { |
312 | isBirthday = true; | 359 | isBirthday = true; |
313 | cat = i18n( "Birthday" ); | 360 | cat = i18n( "Birthday" ); |
314 | } else { | 361 | } else { |
315 | qDebug("addAnniversaryNoDup called without fitting category! "); | 362 | qDebug("addAnniversaryNoDup called without fitting category! "); |
316 | return false; | 363 | return false; |
317 | } | 364 | } |
318 | Event * eve; | 365 | Event * eve; |
319 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 366 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
320 | if ( !(eve->categories().contains( cat ) )) | 367 | if ( !(eve->categories().contains( cat ) )) |
321 | continue; | 368 | continue; |
322 | // now we have an event with fitting category | 369 | // now we have an event with fitting category |
323 | if ( eve->dtStart().date() != event->dtStart().date() ) | 370 | if ( eve->dtStart().date() != event->dtStart().date() ) |
324 | continue; | 371 | continue; |
325 | // now we have an event with fitting category+date | 372 | // now we have an event with fitting category+date |
326 | if ( eve->summary() != event->summary() ) | 373 | if ( eve->summary() != event->summary() ) |
327 | continue; | 374 | continue; |
328 | // now we have an event with fitting category+date+summary | 375 | // now we have an event with fitting category+date+summary |
329 | return false; | 376 | return false; |
330 | } | 377 | } |
331 | return addEvent( event ); | 378 | return addEvent( event ); |
332 | 379 | ||
333 | } | 380 | } |
334 | bool CalendarLocal::addEventNoDup( Event *event ) | 381 | bool CalendarLocal::addEventNoDup( Event *event ) |
335 | { | 382 | { |
336 | Event * eve; | 383 | Event * eve; |
337 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 384 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
338 | if ( *eve == *event ) { | 385 | if ( *eve == *event ) { |
339 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 386 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
340 | return false; | 387 | return false; |
341 | } | 388 | } |
342 | } | 389 | } |
343 | return addEvent( event ); | 390 | return addEvent( event ); |
344 | } | 391 | } |
345 | 392 | ||
346 | bool CalendarLocal::addEvent( Event *event ) | 393 | bool CalendarLocal::addEvent( Event *event ) |
347 | { | 394 | { |
348 | insertEvent( event ); | 395 | insertEvent( event ); |
349 | 396 | ||
350 | event->registerObserver( this ); | 397 | event->registerObserver( this ); |
351 | 398 | ||
352 | setModified( true ); | 399 | setModified( true ); |
353 | if ( event->calID() == 0 ) | 400 | if ( event->calID() == 0 ) |
354 | event->setCalID_block( mDefaultCalendar ); | 401 | event->setCalID_block( mDefaultCalendar ); |
355 | event->setCalEnabled( true ); | 402 | event->setCalEnabled( true ); |
356 | 403 | ||
357 | return true; | 404 | return true; |
358 | } | 405 | } |
359 | 406 | ||
360 | void CalendarLocal::deleteEvent( Event *event ) | 407 | void CalendarLocal::deleteEvent( Event *event ) |
361 | { | 408 | { |
362 | clearUndo(event); | 409 | clearUndo(event); |
363 | if ( mEventList.removeRef( event ) ) { | 410 | if ( mEventList.removeRef( event ) ) { |
364 | setModified( true ); | 411 | setModified( true ); |
365 | } | 412 | } |
366 | } | 413 | } |
367 | 414 | ||
368 | 415 | ||
369 | Event *CalendarLocal::event( const QString &uid ) | 416 | Event *CalendarLocal::event( const QString &uid ) |
370 | { | 417 | { |
371 | Event *event; | 418 | Event *event; |
372 | Event *retVal = 0; | 419 | Event *retVal = 0; |
373 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 420 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
374 | if ( event->calEnabled() && event->uid() == uid ) { | 421 | if ( event->calEnabled() && event->uid() == uid ) { |
375 | if ( retVal ) { | 422 | if ( retVal ) { |
376 | if ( retVal->calID() > event->calID() ) { | 423 | if ( retVal->calID() > event->calID() ) { |
377 | retVal = event; | 424 | retVal = event; |
378 | } | 425 | } |
379 | } else { | 426 | } else { |
380 | retVal = event; | 427 | retVal = event; |
381 | } | 428 | } |
382 | } | 429 | } |
383 | } | 430 | } |
384 | return retVal; | 431 | return retVal; |
385 | } | 432 | } |
386 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 433 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
387 | { | 434 | { |
388 | Todo * eve; | 435 | Todo * eve; |
389 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 436 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
390 | if ( *eve == *todo ) { | 437 | if ( *eve == *todo ) { |
391 | //qDebug("duplicate todo found! not inserted! "); | 438 | //qDebug("duplicate todo found! not inserted! "); |
392 | return false; | 439 | return false; |
393 | } | 440 | } |
394 | } | 441 | } |
395 | return addTodo( todo ); | 442 | return addTodo( todo ); |
396 | } | 443 | } |
397 | bool CalendarLocal::addTodo( Todo *todo ) | 444 | bool CalendarLocal::addTodo( Todo *todo ) |
398 | { | 445 | { |
399 | mTodoList.append( todo ); | 446 | mTodoList.append( todo ); |
400 | 447 | ||
401 | todo->registerObserver( this ); | 448 | todo->registerObserver( this ); |
402 | 449 | ||
403 | // Set up subtask relations | 450 | // Set up subtask relations |
404 | setupRelations( todo ); | 451 | setupRelations( todo ); |
405 | 452 | ||
406 | setModified( true ); | 453 | setModified( true ); |
407 | if ( todo->calID() == 0 ) | 454 | if ( todo->calID() == 0 ) |
408 | todo->setCalID_block( mDefaultCalendar ); | 455 | todo->setCalID_block( mDefaultCalendar ); |
409 | todo->setCalEnabled( true ); | 456 | todo->setCalEnabled( true ); |
410 | return true; | 457 | return true; |
411 | } | 458 | } |
412 | 459 | ||
413 | void CalendarLocal::deleteTodo( Todo *todo ) | 460 | void CalendarLocal::deleteTodo( Todo *todo ) |
414 | { | 461 | { |
462 | QString uid = todo->uid(); | ||
415 | // Handle orphaned children | 463 | // Handle orphaned children |
416 | removeRelations( todo ); | 464 | removeRelations( todo ); |
417 | clearUndo(todo); | 465 | clearUndo(todo); |
418 | 466 | ||
419 | if ( mTodoList.removeRef( todo ) ) { | 467 | if ( mTodoList.removeRef( todo ) ) { |
420 | setModified( true ); | 468 | setModified( true ); |
421 | } | 469 | } |
470 | Todo* dup = todoForUid( uid ); | ||
471 | if ( dup ) | ||
472 | setupRelations( dup ); | ||
422 | } | 473 | } |
423 | 474 | ||
424 | QPtrList<Todo> CalendarLocal::rawTodos() | 475 | QPtrList<Todo> CalendarLocal::rawTodos() |
425 | { | 476 | { |
426 | QPtrList<Todo> el; | 477 | QPtrList<Todo> el; |
427 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 478 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
428 | if ( it->calEnabled() ) el.append( it ); | 479 | if ( it->calEnabled() ) el.append( it ); |
429 | return el; | 480 | return el; |
430 | } | 481 | } |
431 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 482 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
432 | { | 483 | { |
433 | Todo *todo; | 484 | Todo *todo; |
434 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 485 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
435 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; | 486 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
436 | } | 487 | } |
437 | 488 | ||
438 | return 0; | 489 | return 0; |
439 | } | 490 | } |
440 | void CalendarLocal::removeSyncInfo( QString syncProfile) | 491 | void CalendarLocal::removeSyncInfo( QString syncProfile) |
441 | { | 492 | { |
442 | QPtrList<Incidence> all = rawIncidences() ; | 493 | QPtrList<Incidence> all = rawIncidences() ; |
443 | Incidence *inc; | 494 | Incidence *inc; |
444 | for ( inc = all.first(); inc; inc = all.next() ) { | 495 | for ( inc = all.first(); inc; inc = all.next() ) { |
445 | inc->removeID( syncProfile ); | 496 | inc->removeID( syncProfile ); |
446 | } | 497 | } |
447 | if ( syncProfile.isEmpty() ) { | 498 | if ( syncProfile.isEmpty() ) { |
448 | QPtrList<Event> el; | 499 | QPtrList<Event> el; |
449 | Event *todo; | 500 | Event *todo; |
450 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 501 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
451 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 502 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
452 | el.append( todo ); | 503 | el.append( todo ); |
453 | } | 504 | } |
454 | for ( todo = el.first(); todo; todo = el.next() ) { | 505 | for ( todo = el.first(); todo; todo = el.next() ) { |
455 | deleteIncidence ( todo ); | 506 | deleteIncidence ( todo ); |
456 | } | 507 | } |
457 | } else { | 508 | } else { |
458 | Event *lse = event( "last-syncEvent-"+ syncProfile); | 509 | Event *lse = event( "last-syncEvent-"+ syncProfile); |
459 | if ( lse ) | 510 | if ( lse ) |
460 | deleteIncidence ( lse ); | 511 | deleteIncidence ( lse ); |
461 | } | 512 | } |
462 | } | 513 | } |
463 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 514 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
464 | { | 515 | { |
465 | QPtrList<Event> el; | 516 | QPtrList<Event> el; |
466 | Event *todo; | 517 | Event *todo; |
467 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 518 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
468 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 519 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
469 | if ( todo->summary().left(3) == "E: " ) | 520 | if ( todo->summary().left(3) == "E: " ) |
470 | el.append( todo ); | 521 | el.append( todo ); |
471 | } | 522 | } |
472 | 523 | ||
473 | return el; | 524 | return el; |
474 | 525 | ||
475 | } | 526 | } |
476 | Event *CalendarLocal::event( QString syncProf, QString id ) | 527 | Event *CalendarLocal::event( QString syncProf, QString id ) |
477 | { | 528 | { |
478 | Event *todo; | 529 | Event *todo; |
479 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 530 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
480 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; | 531 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
481 | } | 532 | } |
482 | 533 | ||
483 | return 0; | 534 | return 0; |
484 | } | 535 | } |
485 | Todo *CalendarLocal::todo( const QString &uid ) | 536 | Todo *CalendarLocal::todo( const QString &uid ) |
486 | { | 537 | { |
487 | Todo *todo; | 538 | Todo *todo; |
488 | Todo *retVal = 0; | 539 | Todo *retVal = 0; |
489 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 540 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
490 | if ( todo->calEnabled() && todo->uid() == uid ) { | 541 | if ( todo->calEnabled() && todo->uid() == uid ) { |
491 | if ( retVal ) { | 542 | if ( retVal ) { |
492 | if ( retVal->calID() > todo->calID() ) { | 543 | if ( retVal->calID() > todo->calID() ) { |
493 | retVal = todo; | 544 | retVal = todo; |
494 | } | 545 | } |
495 | } else { | 546 | } else { |
496 | retVal = todo; | 547 | retVal = todo; |
497 | } | 548 | } |
498 | } | 549 | } |
499 | } | 550 | } |
500 | return retVal; | 551 | return retVal; |
501 | } | 552 | } |
502 | void CalendarLocal::getIncidenceCount( int calId, int& events, int & todos, int & journals) | 553 | void CalendarLocal::getIncidenceCount( int calId, int& events, int & todos, int & journals) |
503 | { | 554 | { |
504 | events = 0; | 555 | events = 0; |
505 | todos = 0; | 556 | todos = 0; |
506 | journals = 0; | 557 | journals = 0; |
507 | { | 558 | { |
508 | Todo *todo; | 559 | Todo *todo; |
509 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 560 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
510 | if ( todo->calID() == calId ) | 561 | if ( todo->calID() == calId ) |
511 | ++todos; | 562 | ++todos; |
512 | } | 563 | } |
513 | } | 564 | } |
514 | { | 565 | { |
515 | Event *todo; | 566 | Event *todo; |
516 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 567 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
517 | if ( todo->calID() == calId ) | 568 | if ( todo->calID() == calId ) |
518 | ++events; | 569 | ++events; |
519 | 570 | ||
520 | } | 571 | } |
521 | } | 572 | } |
522 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 573 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
523 | if ( it->calID() == calId ) ++journals; | 574 | if ( it->calID() == calId ) ++journals; |
524 | 575 | ||
525 | } | 576 | } |
526 | QString CalendarLocal::nextSummary() const | 577 | QString CalendarLocal::nextSummary() const |
527 | { | 578 | { |
528 | return mNextSummary; | 579 | return mNextSummary; |
529 | } | 580 | } |
530 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 581 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
531 | { | 582 | { |
532 | return mNextAlarmEventDateTime; | 583 | return mNextAlarmEventDateTime; |
533 | } | 584 | } |
534 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 585 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
535 | { | 586 | { |
536 | //mNextAlarmIncidence | 587 | //mNextAlarmIncidence |
537 | //mNextAlarmDateTime | 588 | //mNextAlarmDateTime |
538 | //return mNextSummary; | 589 | //return mNextSummary; |
539 | //return mNextAlarmEventDateTime; | 590 | //return mNextAlarmEventDateTime; |
540 | bool newNextAlarm = false; | 591 | bool newNextAlarm = false; |
541 | bool computeNextAlarm = false; | 592 | bool computeNextAlarm = false; |
542 | bool ok; | 593 | bool ok; |
543 | int offset; | 594 | int offset; |
544 | QDateTime nextA; | 595 | QDateTime nextA; |
545 | // QString nextSum; | 596 | // QString nextSum; |
546 | //QDateTime nextEvent; | 597 | //QDateTime nextEvent; |
547 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 598 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
548 | computeNextAlarm = true; | 599 | computeNextAlarm = true; |
549 | } else { | 600 | } else { |
550 | if ( ! deleted ) { | 601 | if ( ! deleted ) { |
551 | nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 602 | nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
552 | if ( ok ) { | 603 | if ( ok ) { |
553 | if ( nextA < mNextAlarmDateTime ) { | 604 | if ( nextA < mNextAlarmDateTime ) { |
554 | deRegisterAlarm(); | 605 | deRegisterAlarm(); |
555 | mNextAlarmDateTime = nextA; | 606 | mNextAlarmDateTime = nextA; |
556 | mNextSummary = incidence->summary(); | 607 | mNextSummary = incidence->summary(); |
557 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; | 608 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; |
558 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 609 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
559 | newNextAlarm = true; | 610 | newNextAlarm = true; |
560 | mNextAlarmIncidence = incidence; | 611 | mNextAlarmIncidence = incidence; |
561 | } else { | 612 | } else { |
562 | if ( incidence == mNextAlarmIncidence ) { | 613 | if ( incidence == mNextAlarmIncidence ) { |
563 | computeNextAlarm = true; | 614 | computeNextAlarm = true; |
564 | } | 615 | } |
565 | } | 616 | } |
566 | } else { | 617 | } else { |
567 | if ( mNextAlarmIncidence == incidence ) { | 618 | if ( mNextAlarmIncidence == incidence ) { |
568 | computeNextAlarm = true; | 619 | computeNextAlarm = true; |
569 | } | 620 | } |
570 | } | 621 | } |
571 | } else { // deleted | 622 | } else { // deleted |
572 | if ( incidence == mNextAlarmIncidence ) { | 623 | if ( incidence == mNextAlarmIncidence ) { |
573 | computeNextAlarm = true; | 624 | computeNextAlarm = true; |
574 | } | 625 | } |
575 | } | 626 | } |
576 | } | 627 | } |
577 | if ( computeNextAlarm ) { | 628 | if ( computeNextAlarm ) { |
578 | deRegisterAlarm(); | 629 | deRegisterAlarm(); |
579 | nextA = nextAlarm( 1000 ); | 630 | nextA = nextAlarm( 1000 ); |
580 | if (! mNextAlarmIncidence ) { | 631 | if (! mNextAlarmIncidence ) { |
581 | return; | 632 | return; |
582 | } | 633 | } |
583 | newNextAlarm = true; | 634 | newNextAlarm = true; |
584 | } | 635 | } |
585 | if ( newNextAlarm ) | 636 | if ( newNextAlarm ) |
586 | registerAlarm(); | 637 | registerAlarm(); |
587 | } | 638 | } |
588 | QString CalendarLocal:: getAlarmNotification() | 639 | QString CalendarLocal:: getAlarmNotification() |
589 | { | 640 | { |
590 | QString ret; | 641 | QString ret; |
591 | // this should not happen | 642 | // this should not happen |
592 | if (! mNextAlarmIncidence ) | 643 | if (! mNextAlarmIncidence ) |
593 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; | 644 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; |
594 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); | 645 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); |
595 | if ( alarm->type() == Alarm::Procedure ) { | 646 | if ( alarm->type() == Alarm::Procedure ) { |
596 | ret = "proc_alarm" + alarm->programFile()+"+++"; | 647 | ret = "proc_alarm" + alarm->programFile()+"+++"; |
597 | } else { | 648 | } else { |
598 | ret = "audio_alarm" +alarm->audioFile() +"+++"; | 649 | ret = "audio_alarm" +alarm->audioFile() +"+++"; |
599 | } | 650 | } |
600 | ret += "cal_alarm"+ mNextSummary.left( 25 ); | 651 | ret += "cal_alarm"+ mNextSummary.left( 25 ); |
601 | if ( mNextSummary.length() > 25 ) | 652 | if ( mNextSummary.length() > 25 ) |
602 | ret += "\n" + mNextSummary.mid(25, 25 ); | 653 | ret += "\n" + mNextSummary.mid(25, 25 ); |
603 | ret+= "\n"+mNextAlarmEventDateTimeString; | 654 | ret+= "\n"+mNextAlarmEventDateTimeString; |
604 | return ret; | 655 | return ret; |
605 | } | 656 | } |
606 | void CalendarLocal::registerAlarm() | 657 | void CalendarLocal::registerAlarm() |
607 | { | 658 | { |
608 | mLastAlarmNotificationString = getAlarmNotification(); | 659 | mLastAlarmNotificationString = getAlarmNotification(); |
609 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); | 660 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); |
610 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 661 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
611 | // #ifndef DESKTOP_VERSION | 662 | // #ifndef DESKTOP_VERSION |
612 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); | 663 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); |
613 | // #endif | 664 | // #endif |
614 | } | 665 | } |
615 | void CalendarLocal::deRegisterAlarm() | 666 | void CalendarLocal::deRegisterAlarm() |
616 | { | 667 | { |
617 | if ( mLastAlarmNotificationString.isNull() ) | 668 | if ( mLastAlarmNotificationString.isNull() ) |
618 | return; | 669 | return; |
619 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); | 670 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); |
620 | 671 | ||
621 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 672 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
622 | mNextAlarmEventDateTime = QDateTime(); | 673 | mNextAlarmEventDateTime = QDateTime(); |
623 | // #ifndef DESKTOP_VERSION | 674 | // #ifndef DESKTOP_VERSION |
624 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); | 675 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); |
625 | // #endif | 676 | // #endif |
626 | } | 677 | } |
627 | 678 | ||
628 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) | 679 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) |
629 | { | 680 | { |
630 | QPtrList<Todo> todos; | 681 | QPtrList<Todo> todos; |
631 | 682 | ||
632 | Todo *todo; | 683 | Todo *todo; |
633 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 684 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
634 | if ( !todo->calEnabled() ) continue; | 685 | if ( !todo->calEnabled() ) continue; |
635 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { | 686 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { |
636 | todos.append( todo ); | 687 | todos.append( todo ); |
637 | } | 688 | } |
638 | } | 689 | } |
639 | 690 | ||
640 | filter()->apply( &todos ); | 691 | filter()->apply( &todos ); |
641 | return todos; | 692 | return todos; |
642 | } | 693 | } |
643 | void CalendarLocal::reInitAlarmSettings() | 694 | void CalendarLocal::reInitAlarmSettings() |
644 | { | 695 | { |
645 | if ( !mNextAlarmIncidence ) { | 696 | if ( !mNextAlarmIncidence ) { |
646 | nextAlarm( 1000 ); | 697 | nextAlarm( 1000 ); |
647 | } | 698 | } |
648 | deRegisterAlarm(); | 699 | deRegisterAlarm(); |
649 | mNextAlarmIncidence = 0; | 700 | mNextAlarmIncidence = 0; |
650 | checkAlarmForIncidence( 0, false ); | 701 | checkAlarmForIncidence( 0, false ); |
651 | 702 | ||
652 | } | 703 | } |
653 | 704 | ||
654 | 705 | ||
655 | 706 | ||
656 | QDateTime CalendarLocal::nextAlarm( int daysTo ) | 707 | QDateTime CalendarLocal::nextAlarm( int daysTo ) |
657 | { | 708 | { |
658 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); | 709 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); |
659 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); | 710 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); |
660 | QDateTime next; | 711 | QDateTime next; |
661 | Event *e; | 712 | Event *e; |
662 | bool ok; | 713 | bool ok; |
663 | bool found = false; | 714 | bool found = false; |
664 | int offset; | 715 | int offset; |
665 | mNextAlarmIncidence = 0; | 716 | mNextAlarmIncidence = 0; |
666 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 717 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
667 | if ( !e->calEnabled() ) continue; | 718 | if ( !e->calEnabled() ) continue; |
668 | next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 719 | next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
669 | if ( ok ) { | 720 | if ( ok ) { |
670 | if ( next < nextA ) { | 721 | if ( next < nextA ) { |
671 | nextA = next; | 722 | nextA = next; |
672 | found = true; | 723 | found = true; |
673 | mNextSummary = e->summary(); | 724 | mNextSummary = e->summary(); |
674 | mNextAlarmEventDateTime = next.addSecs(offset ) ; | 725 | mNextAlarmEventDateTime = next.addSecs(offset ) ; |
675 | mNextAlarmIncidence = (Incidence *) e; | 726 | mNextAlarmIncidence = (Incidence *) e; |
676 | } | 727 | } |
677 | } | 728 | } |
678 | } | 729 | } |
679 | Todo *t; | 730 | Todo *t; |
680 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 731 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
681 | if ( !t->calEnabled() ) continue; | 732 | if ( !t->calEnabled() ) continue; |
682 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | 733 | next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; |
683 | if ( ok ) { | 734 | if ( ok ) { |
684 | if ( next < nextA ) { | 735 | if ( next < nextA ) { |
685 | nextA = next; | 736 | nextA = next; |
686 | found = true; | 737 | found = true; |
687 | mNextSummary = t->summary(); | 738 | mNextSummary = t->summary(); |
688 | mNextAlarmEventDateTime = next.addSecs(offset ); | 739 | mNextAlarmEventDateTime = next.addSecs(offset ); |
689 | mNextAlarmIncidence = (Incidence *) t; | 740 | mNextAlarmIncidence = (Incidence *) t; |
690 | } | 741 | } |
691 | } | 742 | } |
692 | } | 743 | } |
693 | if ( mNextAlarmIncidence ) { | 744 | if ( mNextAlarmIncidence ) { |
694 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 745 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
695 | mNextAlarmDateTime = nextA; | 746 | mNextAlarmDateTime = nextA; |
696 | } | 747 | } |
697 | return nextA; | 748 | return nextA; |
698 | } | 749 | } |
699 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) | 750 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) |
700 | { | 751 | { |
701 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); | 752 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); |
702 | } | 753 | } |
703 | 754 | ||
704 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) | 755 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) |
705 | { | 756 | { |
706 | 757 | ||
707 | Alarm::List alarms; | 758 | Alarm::List alarms; |
708 | 759 | ||
709 | Event *e; | 760 | Event *e; |
710 | 761 | ||
711 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 762 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
712 | if ( !e->calEnabled() ) continue; | 763 | if ( !e->calEnabled() ) continue; |
713 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); | 764 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); |
714 | else appendAlarms( alarms, e, from, to ); | 765 | else appendAlarms( alarms, e, from, to ); |
715 | } | 766 | } |
716 | 767 | ||
717 | Todo *t; | 768 | Todo *t; |
718 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 769 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
719 | if ( !t->calEnabled() ) continue; | 770 | if ( !t->calEnabled() ) continue; |
720 | appendAlarms( alarms, t, from, to ); | 771 | appendAlarms( alarms, t, from, to ); |
721 | } | 772 | } |
722 | 773 | ||
723 | return alarms; | 774 | return alarms; |
724 | } | 775 | } |
725 | 776 | ||
726 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, | 777 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, |
727 | const QDateTime &from, const QDateTime &to ) | 778 | const QDateTime &from, const QDateTime &to ) |
728 | { | 779 | { |
729 | QPtrList<Alarm> alarmList = incidence->alarms(); | 780 | QPtrList<Alarm> alarmList = incidence->alarms(); |
730 | Alarm *alarm; | 781 | Alarm *alarm; |
731 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 782 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
732 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() | 783 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() |
733 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; | 784 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; |
734 | if ( alarm->enabled() ) { | 785 | if ( alarm->enabled() ) { |
735 | if ( alarm->time() >= from && alarm->time() <= to ) { | 786 | if ( alarm->time() >= from && alarm->time() <= to ) { |
736 | alarms.append( alarm ); | 787 | alarms.append( alarm ); |
737 | } | 788 | } |
738 | } | 789 | } |
739 | } | 790 | } |
740 | } | 791 | } |
741 | 792 | ||
742 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | 793 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, |
743 | Incidence *incidence, | 794 | Incidence *incidence, |
744 | const QDateTime &from, | 795 | const QDateTime &from, |
745 | const QDateTime &to ) | 796 | const QDateTime &to ) |
746 | { | 797 | { |
747 | 798 | ||
748 | QPtrList<Alarm> alarmList = incidence->alarms(); | 799 | QPtrList<Alarm> alarmList = incidence->alarms(); |
749 | Alarm *alarm; | 800 | Alarm *alarm; |
750 | QDateTime qdt; | 801 | QDateTime qdt; |
751 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 802 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
752 | if (incidence->recursOn(from.date())) { | 803 | if (incidence->recursOn(from.date())) { |
753 | qdt.setTime(alarm->time().time()); | 804 | qdt.setTime(alarm->time().time()); |
754 | qdt.setDate(from.date()); | 805 | qdt.setDate(from.date()); |
755 | } | 806 | } |
756 | else qdt = alarm->time(); | 807 | else qdt = alarm->time(); |
757 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); | 808 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); |
758 | if ( alarm->enabled() ) { | 809 | if ( alarm->enabled() ) { |
759 | if ( qdt >= from && qdt <= to ) { | 810 | if ( qdt >= from && qdt <= to ) { |
760 | alarms.append( alarm ); | 811 | alarms.append( alarm ); |
761 | } | 812 | } |
762 | } | 813 | } |
763 | } | 814 | } |
764 | } | 815 | } |
765 | 816 | ||
766 | 817 | ||
767 | /****************************** PROTECTED METHODS ****************************/ | 818 | /****************************** PROTECTED METHODS ****************************/ |
768 | 819 | ||
769 | // after changes are made to an event, this should be called. | 820 | // after changes are made to an event, this should be called. |
770 | void CalendarLocal::update( IncidenceBase *incidence ) | 821 | void CalendarLocal::update( IncidenceBase *incidence ) |
771 | { | 822 | { |
772 | incidence->setSyncStatus( Event::SYNCMOD ); | 823 | incidence->setSyncStatus( Event::SYNCMOD ); |
773 | incidence->setLastModified( QDateTime::currentDateTime() ); | 824 | incidence->setLastModified( QDateTime::currentDateTime() ); |
774 | // we should probably update the revision number here, | 825 | // we should probably update the revision number here, |
775 | // or internally in the Event itself when certain things change. | 826 | // or internally in the Event itself when certain things change. |
776 | // need to verify with ical documentation. | 827 | // need to verify with ical documentation. |
777 | 828 | ||
778 | setModified( true ); | 829 | setModified( true ); |
779 | } | 830 | } |
780 | 831 | ||
781 | void CalendarLocal::insertEvent( Event *event ) | 832 | void CalendarLocal::insertEvent( Event *event ) |
782 | { | 833 | { |
783 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); | 834 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); |
784 | } | 835 | } |
785 | 836 | ||
786 | 837 | ||
787 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | 838 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) |
788 | { | 839 | { |
789 | QPtrList<Event> eventList; | 840 | QPtrList<Event> eventList; |
790 | 841 | ||
791 | Event *event; | 842 | Event *event; |
792 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 843 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
793 | if ( !event->calEnabled() ) continue; | 844 | if ( !event->calEnabled() ) continue; |
794 | if ( event->doesRecur() ) { | 845 | if ( event->doesRecur() ) { |
795 | if ( event->isMultiDay() ) { | 846 | if ( event->isMultiDay() ) { |
796 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); | 847 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); |
797 | int i; | 848 | int i; |
798 | for ( i = 0; i <= extraDays; i++ ) { | 849 | for ( i = 0; i <= extraDays; i++ ) { |
799 | if ( event->recursOn( qd.addDays( -i ) ) ) { | 850 | if ( event->recursOn( qd.addDays( -i ) ) ) { |
800 | eventList.append( event ); | 851 | eventList.append( event ); |
801 | break; | 852 | break; |
802 | } | 853 | } |
803 | } | 854 | } |
804 | } else { | 855 | } else { |
805 | if ( event->recursOn( qd ) ) | 856 | if ( event->recursOn( qd ) ) |
806 | eventList.append( event ); | 857 | eventList.append( event ); |
807 | } | 858 | } |
808 | } else { | 859 | } else { |
809 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 860 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
810 | eventList.append( event ); | 861 | eventList.append( event ); |
811 | } | 862 | } |
812 | } | 863 | } |
813 | } | 864 | } |
814 | 865 | ||
815 | if ( !sorted ) { | 866 | if ( !sorted ) { |
816 | return eventList; | 867 | return eventList; |
817 | } | 868 | } |
818 | 869 | ||
819 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 870 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
820 | // now, we have to sort it based on dtStart.time() | 871 | // now, we have to sort it based on dtStart.time() |
821 | QPtrList<Event> eventListSorted; | 872 | QPtrList<Event> eventListSorted; |
822 | Event *sortEvent; | 873 | Event *sortEvent; |
823 | for ( event = eventList.first(); event; event = eventList.next() ) { | 874 | for ( event = eventList.first(); event; event = eventList.next() ) { |
824 | sortEvent = eventListSorted.first(); | 875 | sortEvent = eventListSorted.first(); |
825 | int i = 0; | 876 | int i = 0; |
826 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 877 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
827 | { | 878 | { |
828 | i++; | 879 | i++; |
829 | sortEvent = eventListSorted.next(); | 880 | sortEvent = eventListSorted.next(); |
830 | } | 881 | } |
831 | eventListSorted.insert( i, event ); | 882 | eventListSorted.insert( i, event ); |
832 | } | 883 | } |
833 | return eventListSorted; | 884 | return eventListSorted; |
834 | } | 885 | } |
835 | 886 | ||
836 | 887 | ||
837 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 888 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
838 | bool inclusive ) | 889 | bool inclusive ) |
839 | { | 890 | { |
840 | Event *event = 0; | 891 | Event *event = 0; |
841 | 892 | ||
842 | QPtrList<Event> eventList; | 893 | QPtrList<Event> eventList; |
843 | 894 | ||
844 | // Get non-recurring events | 895 | // Get non-recurring events |
845 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 896 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
846 | if ( !event->calEnabled() ) continue; | 897 | if ( !event->calEnabled() ) continue; |
847 | if ( event->doesRecur() ) { | 898 | if ( event->doesRecur() ) { |
848 | QDate rStart = event->dtStart().date(); | 899 | QDate rStart = event->dtStart().date(); |
849 | bool found = false; | 900 | bool found = false; |
850 | if ( inclusive ) { | 901 | if ( inclusive ) { |
851 | if ( rStart >= start && rStart <= end ) { | 902 | if ( rStart >= start && rStart <= end ) { |
852 | // Start date of event is in range. Now check for end date. | 903 | // Start date of event is in range. Now check for end date. |
853 | // if duration is negative, event recurs forever, so do not include it. | 904 | // if duration is negative, event recurs forever, so do not include it. |
854 | if ( event->recurrence()->duration() == 0 ) { // End date set | 905 | if ( event->recurrence()->duration() == 0 ) { // End date set |
855 | QDate rEnd = event->recurrence()->endDate(); | 906 | QDate rEnd = event->recurrence()->endDate(); |
856 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 907 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
857 | found = true; | 908 | found = true; |
858 | } | 909 | } |
859 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 910 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
860 | // TODO: Calculate end date from duration. Should be done in Event | 911 | // TODO: Calculate end date from duration. Should be done in Event |
861 | // For now exclude all events with a duration. | 912 | // For now exclude all events with a duration. |
862 | } | 913 | } |
863 | } | 914 | } |
864 | } else { | 915 | } else { |
865 | bool founOne; | 916 | bool founOne; |
866 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 917 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
867 | if ( founOne ) { | 918 | if ( founOne ) { |
868 | if ( next <= end ) { | 919 | if ( next <= end ) { |
869 | found = true; | 920 | found = true; |
870 | } | 921 | } |
871 | } | 922 | } |
872 | 923 | ||
873 | /* | 924 | /* |
874 | // crap !!! | 925 | // crap !!! |
875 | if ( rStart <= end ) { // Start date not after range | 926 | if ( rStart <= end ) { // Start date not after range |
876 | if ( rStart >= start ) { // Start date within range | 927 | if ( rStart >= start ) { // Start date within range |
877 | found = true; | 928 | found = true; |
878 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 929 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
879 | found = true; | 930 | found = true; |
880 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 931 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
881 | QDate rEnd = event->recurrence()->endDate(); | 932 | QDate rEnd = event->recurrence()->endDate(); |
882 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 933 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
883 | found = true; | 934 | found = true; |
884 | } | 935 | } |
885 | } else { // Duration set | 936 | } else { // Duration set |
886 | // TODO: Calculate end date from duration. Should be done in Event | 937 | // TODO: Calculate end date from duration. Should be done in Event |
887 | // For now include all events with a duration. | 938 | // For now include all events with a duration. |
888 | found = true; | 939 | found = true; |
889 | } | 940 | } |
890 | } | 941 | } |
891 | */ | 942 | */ |
892 | 943 | ||
893 | } | 944 | } |
894 | 945 | ||
895 | if ( found ) eventList.append( event ); | 946 | if ( found ) eventList.append( event ); |
896 | } else { | 947 | } else { |
897 | QDate s = event->dtStart().date(); | 948 | QDate s = event->dtStart().date(); |
898 | QDate e = event->dtEnd().date(); | 949 | QDate e = event->dtEnd().date(); |
899 | 950 | ||
900 | if ( inclusive ) { | 951 | if ( inclusive ) { |
901 | if ( s >= start && e <= end ) { | 952 | if ( s >= start && e <= end ) { |
902 | eventList.append( event ); | 953 | eventList.append( event ); |
903 | } | 954 | } |
904 | } else { | 955 | } else { |
905 | if ( ( e >= start && s <= end ) ) { | 956 | if ( ( e >= start && s <= end ) ) { |
906 | eventList.append( event ); | 957 | eventList.append( event ); |
907 | } | 958 | } |
908 | } | 959 | } |
909 | } | 960 | } |
910 | } | 961 | } |
911 | 962 | ||
912 | return eventList; | 963 | return eventList; |
913 | } | 964 | } |
914 | 965 | ||
915 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 966 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
916 | { | 967 | { |
917 | return rawEventsForDate( qdt.date() ); | 968 | return rawEventsForDate( qdt.date() ); |
918 | } | 969 | } |
919 | 970 | ||
920 | QPtrList<Event> CalendarLocal::rawEvents() | 971 | QPtrList<Event> CalendarLocal::rawEvents() |
921 | { | 972 | { |
922 | QPtrList<Event> el; | 973 | QPtrList<Event> el; |
923 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 974 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
924 | if ( it->calEnabled() ) el.append( it ); | 975 | if ( it->calEnabled() ) el.append( it ); |
925 | return el; | 976 | return el; |
926 | } | 977 | } |
927 | 978 | ||
928 | bool CalendarLocal::addJournal(Journal *journal) | 979 | bool CalendarLocal::addJournal(Journal *journal) |
929 | { | 980 | { |
930 | mJournalList.append(journal); | 981 | mJournalList.append(journal); |
931 | 982 | ||
932 | journal->registerObserver( this ); | 983 | journal->registerObserver( this ); |
933 | 984 | ||
934 | setModified( true ); | 985 | setModified( true ); |
935 | if ( journal->calID() == 0 ) | 986 | if ( journal->calID() == 0 ) |
936 | journal->setCalID_block( mDefaultCalendar ); | 987 | journal->setCalID_block( mDefaultCalendar ); |
937 | journal->setCalEnabled( true ); | 988 | journal->setCalEnabled( true ); |
938 | return true; | 989 | return true; |
939 | } | 990 | } |
940 | 991 | ||
941 | void CalendarLocal::deleteJournal( Journal *journal ) | 992 | void CalendarLocal::deleteJournal( Journal *journal ) |
942 | { | 993 | { |
943 | clearUndo(journal); | 994 | clearUndo(journal); |
944 | if ( mJournalList.removeRef(journal) ) { | 995 | if ( mJournalList.removeRef(journal) ) { |
945 | setModified( true ); | 996 | setModified( true ); |
946 | } | 997 | } |
947 | } | 998 | } |
948 | 999 | ||
949 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) | 1000 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) |
950 | { | 1001 | { |
951 | QPtrList<Journal> el; | 1002 | QPtrList<Journal> el; |
952 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1003 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
953 | if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); | 1004 | if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); |
954 | return el; | 1005 | return el; |
955 | } | 1006 | } |
956 | Journal *CalendarLocal::journal( const QDate &date ) | 1007 | Journal *CalendarLocal::journal( const QDate &date ) |
957 | { | 1008 | { |
958 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 1009 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
959 | 1010 | ||
960 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1011 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
961 | if ( it->calEnabled() && it->dtStart().date() == date ) | 1012 | if ( it->calEnabled() && it->dtStart().date() == date ) |
962 | return it; | 1013 | return it; |
963 | 1014 | ||
964 | return 0; | 1015 | return 0; |
965 | } | 1016 | } |
966 | 1017 | ||
967 | Journal *CalendarLocal::journal( const QString &uid ) | 1018 | Journal *CalendarLocal::journal( const QString &uid ) |
968 | { | 1019 | { |
969 | Journal * retVal = 0; | 1020 | Journal * retVal = 0; |
970 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1021 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
971 | if ( it->calEnabled() && it->uid() == uid ) { | 1022 | if ( it->calEnabled() && it->uid() == uid ) { |
972 | if ( retVal ) { | 1023 | if ( retVal ) { |
973 | if ( retVal->calID() > it->calID() ) { | 1024 | if ( retVal->calID() > it->calID() ) { |
974 | retVal = it; | 1025 | retVal = it; |
975 | } | 1026 | } |
976 | } else { | 1027 | } else { |
977 | retVal = it; | 1028 | retVal = it; |
978 | } | 1029 | } |
979 | } | 1030 | } |
980 | return retVal; | 1031 | return retVal; |
981 | } | 1032 | } |
982 | 1033 | ||
983 | QPtrList<Journal> CalendarLocal::journals() | 1034 | QPtrList<Journal> CalendarLocal::journals() |
984 | { | 1035 | { |
985 | QPtrList<Journal> el; | 1036 | QPtrList<Journal> el; |
986 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1037 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
987 | if ( it->calEnabled() ) el.append( it ); | 1038 | if ( it->calEnabled() ) el.append( it ); |
988 | return el; | 1039 | return el; |
989 | } | 1040 | } |
990 | void CalendarLocal::setCalendarRemove( int id ) | 1041 | void CalendarLocal::setCalendarRemove( int id ) |
991 | { | 1042 | { |
992 | 1043 | ||
993 | { | 1044 | { |
994 | QPtrList<Event> EventList = mEventList; | 1045 | QPtrList<Event> EventList = mEventList; |
995 | Event * ev = EventList.first(); | 1046 | Event * ev = EventList.first(); |
996 | while ( ev ) { | 1047 | while ( ev ) { |
997 | if ( ev->calID() == id && ev->uid().left( 15 ) != QString("last-syncEvent-") ) | 1048 | if ( ev->calID() == id && ev->uid().left( 15 ) != QString("last-syncEvent-") ) |
998 | deleteEvent( ev ); | 1049 | deleteEvent( ev ); |
999 | ev = EventList.next(); | 1050 | ev = EventList.next(); |
1000 | } | 1051 | } |
1001 | } | 1052 | } |
1002 | { | 1053 | { |
1003 | 1054 | ||
1004 | QPtrList<Todo> TodoList = mTodoList; | 1055 | QPtrList<Todo> TodoList = mTodoList; |
1005 | Todo * ev = TodoList.first(); | 1056 | Todo * ev = TodoList.first(); |
1006 | while ( ev ) { | 1057 | while ( ev ) { |
1007 | if ( ev->calID() == id ) | 1058 | if ( ev->calID() == id ) |
1008 | deleteTodo( ev ); | 1059 | deleteTodo( ev ); |
1009 | ev = TodoList.next(); | 1060 | ev = TodoList.next(); |
1010 | } | 1061 | } |
1011 | } | 1062 | } |
1012 | { | 1063 | { |
1013 | QPtrList<Journal> JournalList = mJournalList; | 1064 | QPtrList<Journal> JournalList = mJournalList; |
1014 | Journal * ev = JournalList.first(); | 1065 | Journal * ev = JournalList.first(); |
1015 | while ( ev ) { | 1066 | while ( ev ) { |
1016 | if ( ev->calID() == id ) | 1067 | if ( ev->calID() == id ) |
1017 | deleteJournal( ev ); | 1068 | deleteJournal( ev ); |
1018 | ev = JournalList.next(); | 1069 | ev = JournalList.next(); |
1019 | } | 1070 | } |
1020 | } | 1071 | } |
1021 | 1072 | ||
1022 | clearUndo(0); | 1073 | clearUndo(0); |
1023 | 1074 | ||
1024 | } | 1075 | } |
1025 | 1076 | ||
1026 | void CalendarLocal::setAllCalendarEnabled( bool enable ) | 1077 | void CalendarLocal::setAllCalendarEnabled( bool enable ) |
1027 | { | 1078 | { |
1028 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1079 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
1029 | it->setCalEnabled( enable ); | 1080 | it->setCalEnabled( enable ); |
1030 | 1081 | ||
1031 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1082 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1032 | it->setCalEnabled( enable ); | 1083 | it->setCalEnabled( enable ); |
1033 | 1084 | ||
1034 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1085 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1035 | it->setCalEnabled( enable ); | 1086 | it->setCalEnabled( enable ); |
1036 | 1087 | ||
1037 | 1088 | ||
1038 | } | 1089 | } |
1039 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) | 1090 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) |
1040 | { | 1091 | { |
1041 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1092 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
1042 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 1093 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
1043 | 1094 | ||
1044 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1095 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1045 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 1096 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
1046 | 1097 | ||
1047 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1098 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1048 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 1099 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
1049 | 1100 | ||
1050 | } | 1101 | } |
1051 | 1102 | ||
1052 | void CalendarLocal::setReadOnly( int id, bool enable ) | 1103 | void CalendarLocal::setReadOnly( int id, bool enable ) |
1053 | { | 1104 | { |
1054 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1105 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
1055 | if ( it->calID() == id ) it->setReadOnly( enable ); | 1106 | if ( it->calID() == id ) it->setReadOnly( enable ); |
1056 | 1107 | ||
1057 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1108 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1058 | if ( it->calID() == id ) it->setReadOnly( enable ); | 1109 | if ( it->calID() == id ) it->setReadOnly( enable ); |
1059 | 1110 | ||
1060 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1111 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1061 | if ( it->calID() == id ) it->setReadOnly( enable ); | 1112 | if ( it->calID() == id ) it->setReadOnly( enable ); |
1062 | 1113 | ||
1063 | } | 1114 | } |
1064 | 1115 | ||
1065 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) | 1116 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) |
1066 | { | 1117 | { |
1067 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1118 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
1068 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 1119 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
1069 | 1120 | ||
1070 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1121 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1071 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 1122 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
1072 | 1123 | ||
1073 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1124 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1074 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 1125 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
1075 | reInitAlarmSettings(); | 1126 | reInitAlarmSettings(); |
1076 | 1127 | ||
1077 | } | 1128 | } |
1078 | void CalendarLocal::setDefaultCalendarEnabledOnly() | 1129 | void CalendarLocal::setDefaultCalendarEnabledOnly() |
1079 | { | 1130 | { |
1080 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1131 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
1081 | it->setCalEnabled( it->calID() == mDefaultCalendar ); | 1132 | it->setCalEnabled( it->calID() == mDefaultCalendar ); |
1082 | 1133 | ||
1083 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1134 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1084 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 1135 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
1085 | 1136 | ||
1086 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1137 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1087 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 1138 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
1088 | 1139 | ||
1089 | } | 1140 | } |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index b611704..1ceabce 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -1,233 +1,234 @@ | |||
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, bool doNotCheckDuplicates, bool enabledOnly = false ); | 50 | Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly = false,int * isDup = 0 ); |
51 | Todo* todoForUid( const QString& uid, bool doNotCheckDuplicates = true, bool enabledOnly = false ,int * isDup = 0 ); | ||
51 | void setSyncEventsReadOnly(); | 52 | void setSyncEventsReadOnly(); |
52 | void setSyncEventsEnabled(); | 53 | void setSyncEventsEnabled(); |
53 | void stopAllTodos(); | 54 | void stopAllTodos(); |
54 | /** | 55 | /** |
55 | Loads a calendar on disk in vCalendar or iCalendar format into the current | 56 | Loads a calendar on disk in vCalendar or iCalendar format into the current |
56 | calendar. Any information already present is lost. | 57 | calendar. Any information already present is lost. |
57 | @return true, if successfull, false on error. | 58 | @return true, if successfull, false on error. |
58 | @param fileName the name of the calendar on disk. | 59 | @param fileName the name of the calendar on disk. |
59 | */ | 60 | */ |
60 | bool load( const QString &fileName ); | 61 | bool load( const QString &fileName ); |
61 | /** | 62 | /** |
62 | Writes out the calendar to disk in the specified \a format. | 63 | Writes out the calendar to disk in the specified \a format. |
63 | CalendarLocal takes ownership of the CalFormat object. | 64 | CalendarLocal takes ownership of the CalFormat object. |
64 | @return true, if successfull, false on error. | 65 | @return true, if successfull, false on error. |
65 | @param fileName the name of the file | 66 | @param fileName the name of the file |
66 | */ | 67 | */ |
67 | bool save( const QString &fileName, CalFormat *format = 0 ); | 68 | bool save( const QString &fileName, CalFormat *format = 0 ); |
68 | 69 | ||
69 | /** | 70 | /** |
70 | Clears out the current calendar, freeing all used memory etc. etc. | 71 | Clears out the current calendar, freeing all used memory etc. etc. |
71 | */ | 72 | */ |
72 | void close(); | 73 | void close(); |
73 | 74 | ||
74 | void save() {} | 75 | void save() {} |
75 | 76 | ||
76 | /** | 77 | /** |
77 | Add Event to calendar. | 78 | Add Event to calendar. |
78 | */ | 79 | */ |
79 | void removeSyncInfo( QString syncProfile); | 80 | void removeSyncInfo( QString syncProfile); |
80 | bool addAnniversaryNoDup( Event *event ); | 81 | bool addAnniversaryNoDup( Event *event ); |
81 | bool addEventNoDup( Event *event ); | 82 | bool addEventNoDup( Event *event ); |
82 | bool addEvent( Event *event ); | 83 | bool addEvent( Event *event ); |
83 | /** | 84 | /** |
84 | Deletes an event from this calendar. | 85 | Deletes an event from this calendar. |
85 | */ | 86 | */ |
86 | void deleteEvent( Event *event ); | 87 | void deleteEvent( Event *event ); |
87 | 88 | ||
88 | /** | 89 | /** |
89 | Retrieves an event on the basis of the unique string ID. | 90 | Retrieves an event on the basis of the unique string ID. |
90 | */ | 91 | */ |
91 | Event *event( const QString &uid ); | 92 | Event *event( const QString &uid ); |
92 | /** | 93 | /** |
93 | Return unfiltered list of all events in calendar. | 94 | Return unfiltered list of all events in calendar. |
94 | */ | 95 | */ |
95 | QPtrList<Event> rawEvents(); | 96 | QPtrList<Event> rawEvents(); |
96 | QPtrList<Event> getExternLastSyncEvents(); | 97 | QPtrList<Event> getExternLastSyncEvents(); |
97 | /** | 98 | /** |
98 | Add a todo to the todolist. | 99 | Add a todo to the todolist. |
99 | */ | 100 | */ |
100 | bool addTodo( Todo *todo ); | 101 | bool addTodo( Todo *todo ); |
101 | bool addTodoNoDup( Todo *todo ); | 102 | bool addTodoNoDup( Todo *todo ); |
102 | /** | 103 | /** |
103 | Remove a todo from the todolist. | 104 | Remove a todo from the todolist. |
104 | */ | 105 | */ |
105 | void deleteTodo( Todo * ); | 106 | void deleteTodo( Todo * ); |
106 | /** | 107 | /** |
107 | Searches todolist for an event with this unique string identifier, | 108 | Searches todolist for an event with this unique string identifier, |
108 | returns a pointer or null. | 109 | returns a pointer or null. |
109 | */ | 110 | */ |
110 | Todo *todo( const QString &uid ); | 111 | Todo *todo( const QString &uid ); |
111 | /** | 112 | /** |
112 | Return list of all todos. | 113 | Return list of all todos. |
113 | */ | 114 | */ |
114 | QPtrList<Todo> rawTodos(); | 115 | QPtrList<Todo> rawTodos(); |
115 | /** | 116 | /** |
116 | Returns list of todos due on the specified date. | 117 | Returns list of todos due on the specified date. |
117 | */ | 118 | */ |
118 | QPtrList<Todo> todos( const QDate &date ); | 119 | QPtrList<Todo> todos( const QDate &date ); |
119 | /** | 120 | /** |
120 | Return list of all todos. | 121 | Return list of all todos. |
121 | 122 | ||
122 | Workaround because compiler does not recognize function of base class. | 123 | Workaround because compiler does not recognize function of base class. |
123 | */ | 124 | */ |
124 | QPtrList<Todo> todos() { return Calendar::todos(); } | 125 | QPtrList<Todo> todos() { return Calendar::todos(); } |
125 | 126 | ||
126 | /** | 127 | /** |
127 | Add a Journal entry to calendar. | 128 | Add a Journal entry to calendar. |
128 | */ | 129 | */ |
129 | bool addJournal( Journal * ); | 130 | bool addJournal( Journal * ); |
130 | /** | 131 | /** |
131 | Remove a Journal from the calendar. | 132 | Remove a Journal from the calendar. |
132 | */ | 133 | */ |
133 | void deleteJournal( Journal * ); | 134 | void deleteJournal( Journal * ); |
134 | /** | 135 | /** |
135 | Return Journal for given date. | 136 | Return Journal for given date. |
136 | */ | 137 | */ |
137 | Journal *journal( const QDate & ); | 138 | Journal *journal( const QDate & ); |
138 | QPtrList<Journal> journals4Date( const QDate & ); | 139 | QPtrList<Journal> journals4Date( const QDate & ); |
139 | /** | 140 | /** |
140 | Return Journal with given UID. | 141 | Return Journal with given UID. |
141 | */ | 142 | */ |
142 | Journal *journal( const QString &uid ); | 143 | Journal *journal( const QString &uid ); |
143 | /** | 144 | /** |
144 | Return list of all Journals stored in calendar. | 145 | Return list of all Journals stored in calendar. |
145 | */ | 146 | */ |
146 | QPtrList<Journal> journals(); | 147 | QPtrList<Journal> journals(); |
147 | 148 | ||
148 | /** | 149 | /** |
149 | Return all alarms, which ocur in the given time interval. | 150 | Return all alarms, which ocur in the given time interval. |
150 | */ | 151 | */ |
151 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); | 152 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); |
152 | 153 | ||
153 | /** | 154 | /** |
154 | Return all alarms, which ocur before given date. | 155 | Return all alarms, which ocur before given date. |
155 | */ | 156 | */ |
156 | Alarm::List alarmsTo( const QDateTime &to ); | 157 | Alarm::List alarmsTo( const QDateTime &to ); |
157 | 158 | ||
158 | QDateTime nextAlarm( int daysTo ) ; | 159 | QDateTime nextAlarm( int daysTo ) ; |
159 | QDateTime nextAlarmEventDateTime() const; | 160 | QDateTime nextAlarmEventDateTime() const; |
160 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; | 161 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; |
161 | void registerAlarm(); | 162 | void registerAlarm(); |
162 | void deRegisterAlarm(); | 163 | void deRegisterAlarm(); |
163 | QString getAlarmNotification(); | 164 | QString getAlarmNotification(); |
164 | QString nextSummary() const ; | 165 | QString nextSummary() const ; |
165 | /** | 166 | /** |
166 | This method should be called whenever a Event is modified directly | 167 | This method should be called whenever a Event is modified directly |
167 | via it's pointer. It makes sure that the calendar is internally | 168 | via it's pointer. It makes sure that the calendar is internally |
168 | consistent. | 169 | consistent. |
169 | */ | 170 | */ |
170 | void update( IncidenceBase *incidence ); | 171 | void update( IncidenceBase *incidence ); |
171 | 172 | ||
172 | /** | 173 | /** |
173 | Builds and then returns a list of all events that match for the | 174 | Builds and then returns a list of all events that match for the |
174 | date specified. useful for dayView, etc. etc. | 175 | date specified. useful for dayView, etc. etc. |
175 | */ | 176 | */ |
176 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); | 177 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); |
177 | /** | 178 | /** |
178 | Get unfiltered events for date \a qdt. | 179 | Get unfiltered events for date \a qdt. |
179 | */ | 180 | */ |
180 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); | 181 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); |
181 | /** | 182 | /** |
182 | Get unfiltered events in a range of dates. If inclusive is set to true, | 183 | Get unfiltered events in a range of dates. If inclusive is set to true, |
183 | only events are returned, which are completely included in the range. | 184 | only events are returned, which are completely included in the range. |
184 | */ | 185 | */ |
185 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 186 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
186 | bool inclusive = false ); | 187 | bool inclusive = false ); |
187 | Todo *todo( QString, QString ); | 188 | Todo *todo( QString, QString ); |
188 | Event *event( QString, QString ); | 189 | Event *event( QString, QString ); |
189 | void getIncidenceCount( int calId, int& events, int & todos, int & journals); | 190 | void getIncidenceCount( int calId, int& events, int & todos, int & journals); |
190 | 191 | ||
191 | public slots: | 192 | public slots: |
192 | void setCalendarEnabled( int id, bool enable ); | 193 | void setCalendarEnabled( int id, bool enable ); |
193 | void setAlarmEnabled( int id, bool enable ); | 194 | void setAlarmEnabled( int id, bool enable ); |
194 | void setReadOnly( int id, bool enable ); | 195 | void setReadOnly( int id, bool enable ); |
195 | void setDefaultCalendarEnabledOnly(); | 196 | void setDefaultCalendarEnabledOnly(); |
196 | void setCalendarRemove( int id ); | 197 | void setCalendarRemove( int id ); |
197 | void setAllCalendarEnabled( bool enable ); | 198 | void setAllCalendarEnabled( bool enable ); |
198 | 199 | ||
199 | protected: | 200 | protected: |
200 | 201 | ||
201 | // Event* mNextAlarmEvent; | 202 | // Event* mNextAlarmEvent; |
202 | QString mNextSummary; | 203 | QString mNextSummary; |
203 | QString mNextAlarmEventDateTimeString; | 204 | QString mNextAlarmEventDateTimeString; |
204 | QString mLastAlarmNotificationString; | 205 | QString mLastAlarmNotificationString; |
205 | QDateTime mNextAlarmEventDateTime; | 206 | QDateTime mNextAlarmEventDateTime; |
206 | QDateTime mNextAlarmDateTime; | 207 | QDateTime mNextAlarmDateTime; |
207 | void reInitAlarmSettings(); | 208 | void reInitAlarmSettings(); |
208 | 209 | ||
209 | /** Notification function of IncidenceBase::Observer. */ | 210 | /** Notification function of IncidenceBase::Observer. */ |
210 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } | 211 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } |
211 | 212 | ||
212 | /** inserts an event into its "proper place" in the calendar. */ | 213 | /** inserts an event into its "proper place" in the calendar. */ |
213 | void insertEvent( Event *event ); | 214 | void insertEvent( Event *event ); |
214 | 215 | ||
215 | /** Append alarms of incidence in interval to list of alarms. */ | 216 | /** Append alarms of incidence in interval to list of alarms. */ |
216 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, | 217 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, |
217 | const QDateTime &from, const QDateTime &to ); | 218 | const QDateTime &from, const QDateTime &to ); |
218 | 219 | ||
219 | /** Append alarms of recurring events in interval to list of alarms. */ | 220 | /** Append alarms of recurring events in interval to list of alarms. */ |
220 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, | 221 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, |
221 | const QDateTime &from, const QDateTime &to ); | 222 | const QDateTime &from, const QDateTime &to ); |
222 | 223 | ||
223 | private: | 224 | private: |
224 | void init(); | 225 | void init(); |
225 | 226 | ||
226 | QPtrList<Event> mEventList; | 227 | QPtrList<Event> mEventList; |
227 | QPtrList<Todo> mTodoList; | 228 | QPtrList<Todo> mTodoList; |
228 | QPtrList<Journal> mJournalList; | 229 | QPtrList<Journal> mJournalList; |
229 | }; | 230 | }; |
230 | 231 | ||
231 | } | 232 | } |
232 | 233 | ||
233 | #endif | 234 | #endif |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index fe9f854..7dd9bd2 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -1,866 +1,872 @@ | |||
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 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | #include "todo.h" | 28 | #include "todo.h" |
29 | 29 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | 31 | ||
32 | Incidence::Incidence() : | 32 | Incidence::Incidence() : |
33 | IncidenceBase(), | 33 | IncidenceBase(), |
34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) | 34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) |
35 | { | 35 | { |
36 | mRecurrence = 0;//new Recurrence(this); | 36 | mRecurrence = 0;//new Recurrence(this); |
37 | mCancelled = false; | 37 | mCancelled = false; |
38 | recreate(); | 38 | recreate(); |
39 | mHasStartDate = true; | 39 | mHasStartDate = true; |
40 | mAlarms.setAutoDelete(true); | 40 | mAlarms.setAutoDelete(true); |
41 | mAttachments.setAutoDelete(true); | 41 | mAttachments.setAutoDelete(true); |
42 | mHasRecurrenceID = false; | 42 | mHasRecurrenceID = false; |
43 | mHoliday = false; | 43 | mHoliday = false; |
44 | mBirthday = false; | 44 | mBirthday = false; |
45 | mAnniversary = false; | 45 | mAnniversary = false; |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | 49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) |
50 | { | 50 | { |
51 | // TODO: reenable attributes currently commented out. | 51 | // TODO: reenable attributes currently commented out. |
52 | mRevision = i.mRevision; | 52 | mRevision = i.mRevision; |
53 | mCreated = i.mCreated; | 53 | mCreated = i.mCreated; |
54 | mDescription = i.mDescription; | 54 | mDescription = i.mDescription; |
55 | mSummary = i.mSummary; | 55 | mSummary = i.mSummary; |
56 | mCategories = i.mCategories; | 56 | mCategories = i.mCategories; |
57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; | 57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; |
58 | mRelatedTo = 0; | 58 | mRelatedTo = 0; |
59 | mRelatedToUid = i.mRelatedToUid; | 59 | mRelatedToUid = i.mRelatedToUid; |
60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
61 | mExDates = i.mExDates; | 61 | mExDates = i.mExDates; |
62 | QPtrListIterator<Attachment> itat( i.mAttachments ); | 62 | QPtrListIterator<Attachment> itat( i.mAttachments ); |
63 | Attachment *at; | 63 | Attachment *at; |
64 | while( (at = itat.current()) ) { | 64 | while( (at = itat.current()) ) { |
65 | Attachment *a = new Attachment( *at ); | 65 | Attachment *a = new Attachment( *at ); |
66 | mAttachments.append( a ); | 66 | mAttachments.append( a ); |
67 | ++itat; | 67 | ++itat; |
68 | } | 68 | } |
69 | mAttachments.setAutoDelete( true ); | 69 | mAttachments.setAutoDelete( true ); |
70 | mResources = i.mResources; | 70 | mResources = i.mResources; |
71 | mSecrecy = i.mSecrecy; | 71 | mSecrecy = i.mSecrecy; |
72 | mPriority = i.mPriority; | 72 | mPriority = i.mPriority; |
73 | mLocation = i.mLocation; | 73 | mLocation = i.mLocation; |
74 | mCancelled = i.mCancelled; | 74 | mCancelled = i.mCancelled; |
75 | mHasStartDate = i.mHasStartDate; | 75 | mHasStartDate = i.mHasStartDate; |
76 | QPtrListIterator<Alarm> it( i.mAlarms ); | 76 | QPtrListIterator<Alarm> it( i.mAlarms ); |
77 | const Alarm *a; | 77 | const Alarm *a; |
78 | while( (a = it.current()) ) { | 78 | while( (a = it.current()) ) { |
79 | Alarm *b = new Alarm( *a ); | 79 | Alarm *b = new Alarm( *a ); |
80 | b->setParent( this ); | 80 | b->setParent( this ); |
81 | mAlarms.append( b ); | 81 | mAlarms.append( b ); |
82 | 82 | ||
83 | ++it; | 83 | ++it; |
84 | } | 84 | } |
85 | mAlarms.setAutoDelete(true); | 85 | mAlarms.setAutoDelete(true); |
86 | mHasRecurrenceID = i.mHasRecurrenceID; | 86 | mHasRecurrenceID = i.mHasRecurrenceID; |
87 | mRecurrenceID = i.mRecurrenceID; | 87 | mRecurrenceID = i.mRecurrenceID; |
88 | if ( i.mRecurrence ) | 88 | if ( i.mRecurrence ) |
89 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 89 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); |
90 | else | 90 | else |
91 | mRecurrence = 0; | 91 | mRecurrence = 0; |
92 | mHoliday = i.mHoliday ; | 92 | mHoliday = i.mHoliday ; |
93 | mBirthday = i.mBirthday; | 93 | mBirthday = i.mBirthday; |
94 | mAnniversary = i.mAnniversary; | 94 | mAnniversary = i.mAnniversary; |
95 | } | 95 | } |
96 | 96 | ||
97 | Incidence::~Incidence() | 97 | Incidence::~Incidence() |
98 | { | 98 | { |
99 | 99 | ||
100 | Incidence *ev; | 100 | Incidence *ev; |
101 | QPtrList<Incidence> Relations = relations(); | 101 | QPtrList<Incidence> Relations = relations(); |
102 | for (ev=Relations.first();ev;ev=Relations.next()) { | 102 | for (ev=Relations.first();ev;ev=Relations.next()) { |
103 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 103 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
104 | } | 104 | } |
105 | if (relatedTo()) relatedTo()->removeRelation(this); | 105 | if (relatedTo()) relatedTo()->removeRelation(this); |
106 | if ( mRecurrence ) | 106 | if ( mRecurrence ) |
107 | delete mRecurrence; | 107 | delete mRecurrence; |
108 | 108 | ||
109 | } | 109 | } |
110 | QString Incidence::durationText() | 110 | QString Incidence::durationText() |
111 | { | 111 | { |
112 | return "---"; | 112 | return "---"; |
113 | } | 113 | } |
114 | QString Incidence::durationText4Time( int offset ) | 114 | QString Incidence::durationText4Time( int offset ) |
115 | { | 115 | { |
116 | int min = offset/60; | 116 | int min = offset/60; |
117 | int hours = min /60; | 117 | int hours = min /60; |
118 | min = min % 60; | 118 | min = min % 60; |
119 | int days = hours /24; | 119 | int days = hours /24; |
120 | hours = hours % 24; | 120 | hours = hours % 24; |
121 | 121 | ||
122 | if ( doesFloat() || ( min == 0 && hours == 0 ) ) { | 122 | if ( doesFloat() || ( min == 0 && hours == 0 ) ) { |
123 | if ( days == 1 ) | 123 | if ( days == 1 ) |
124 | return "1" + i18n(" day"); | 124 | return "1" + i18n(" day"); |
125 | else | 125 | else |
126 | return QString::number( days )+ i18n(" days"); | 126 | return QString::number( days )+ i18n(" days"); |
127 | 127 | ||
128 | } | 128 | } |
129 | QString message = QString::number ( hours ) +":"; | 129 | QString message = QString::number ( hours ) +":"; |
130 | if ( min < 10 ) message += "0"; | 130 | if ( min < 10 ) message += "0"; |
131 | message += QString::number ( min ); | 131 | message += QString::number ( min ); |
132 | if ( days > 0 ) { | 132 | if ( days > 0 ) { |
133 | if ( days == 1 ) | 133 | if ( days == 1 ) |
134 | message = "1" + i18n(" day") + " "+message; | 134 | message = "1" + i18n(" day") + " "+message; |
135 | else | 135 | else |
136 | message = QString::number( days )+ i18n(" days") + " "+message; | 136 | message = QString::number( days )+ i18n(" days") + " "+message; |
137 | } | 137 | } |
138 | return message; | 138 | return message; |
139 | } | 139 | } |
140 | bool Incidence::isHoliday() const | 140 | bool Incidence::isHoliday() const |
141 | { | 141 | { |
142 | return mHoliday; | 142 | return mHoliday; |
143 | } | 143 | } |
144 | bool Incidence::isBirthday() const | 144 | bool Incidence::isBirthday() const |
145 | { | 145 | { |
146 | 146 | ||
147 | return mBirthday ; | 147 | return mBirthday ; |
148 | } | 148 | } |
149 | bool Incidence::isAnniversary() const | 149 | bool Incidence::isAnniversary() const |
150 | { | 150 | { |
151 | return mAnniversary ; | 151 | return mAnniversary ; |
152 | 152 | ||
153 | } | 153 | } |
154 | 154 | ||
155 | bool Incidence::hasRecurrenceID() const | 155 | bool Incidence::hasRecurrenceID() const |
156 | { | 156 | { |
157 | return mHasRecurrenceID; | 157 | return mHasRecurrenceID; |
158 | } | 158 | } |
159 | 159 | ||
160 | void Incidence::setHasRecurrenceID( bool b ) | 160 | void Incidence::setHasRecurrenceID( bool b ) |
161 | { | 161 | { |
162 | mHasRecurrenceID = b; | 162 | mHasRecurrenceID = b; |
163 | } | 163 | } |
164 | 164 | ||
165 | void Incidence::setRecurrenceID(QDateTime d) | 165 | void Incidence::setRecurrenceID(QDateTime d) |
166 | { | 166 | { |
167 | mRecurrenceID = d; | 167 | mRecurrenceID = d; |
168 | mHasRecurrenceID = true; | 168 | mHasRecurrenceID = true; |
169 | updated(); | 169 | updated(); |
170 | } | 170 | } |
171 | QDateTime Incidence::recurrenceID () const | 171 | QDateTime Incidence::recurrenceID () const |
172 | { | 172 | { |
173 | return mRecurrenceID; | 173 | return mRecurrenceID; |
174 | } | 174 | } |
175 | 175 | ||
176 | bool Incidence::cancelled() const | 176 | bool Incidence::cancelled() const |
177 | { | 177 | { |
178 | return mCancelled; | 178 | return mCancelled; |
179 | } | 179 | } |
180 | void Incidence::setCancelled( bool b ) | 180 | void Incidence::setCancelled( bool b ) |
181 | { | 181 | { |
182 | mCancelled = b; | 182 | mCancelled = b; |
183 | updated(); | 183 | updated(); |
184 | } | 184 | } |
185 | bool Incidence::hasStartDate() const | 185 | bool Incidence::hasStartDate() const |
186 | { | 186 | { |
187 | return mHasStartDate; | 187 | return mHasStartDate; |
188 | } | 188 | } |
189 | 189 | ||
190 | void Incidence::setHasStartDate(bool f) | 190 | void Incidence::setHasStartDate(bool f) |
191 | { | 191 | { |
192 | if (mReadOnly) return; | 192 | if (mReadOnly) return; |
193 | mHasStartDate = f; | 193 | mHasStartDate = f; |
194 | updated(); | 194 | updated(); |
195 | } | 195 | } |
196 | 196 | ||
197 | // A string comparison that considers that null and empty are the same | 197 | // A string comparison that considers that null and empty are the same |
198 | static bool stringCompare( const QString& s1, const QString& s2 ) | 198 | static bool stringCompare( const QString& s1, const QString& s2 ) |
199 | { | 199 | { |
200 | if ( s1.isEmpty() && s2.isEmpty() ) | 200 | if ( s1.isEmpty() && s2.isEmpty() ) |
201 | return true; | 201 | return true; |
202 | return s1 == s2; | 202 | return s1 == s2; |
203 | } | 203 | } |
204 | 204 | ||
205 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 205 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
206 | { | 206 | { |
207 | 207 | ||
208 | if( i1.alarms().count() != i2.alarms().count() ) { | 208 | if( i1.alarms().count() != i2.alarms().count() ) { |
209 | return false; // no need to check further | 209 | return false; // no need to check further |
210 | } | 210 | } |
211 | if ( i1.alarms().count() > 0 ) { | 211 | if ( i1.alarms().count() > 0 ) { |
212 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 212 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
213 | { | 213 | { |
214 | qDebug("alarm not equal "); | 214 | qDebug("alarm not equal "); |
215 | return false; | 215 | return false; |
216 | } | 216 | } |
217 | } | 217 | } |
218 | #if 0 | 218 | #if 0 |
219 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 219 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
220 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 220 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
221 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 221 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
222 | if( *a1.current() == *a2.current() ) { | 222 | if( *a1.current() == *a2.current() ) { |
223 | continue; | 223 | continue; |
224 | } | 224 | } |
225 | else { | 225 | else { |
226 | return false; | 226 | return false; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | #endif | 229 | #endif |
230 | 230 | ||
231 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { | 231 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { |
232 | if ( i1.hasRecurrenceID() ) { | 232 | if ( i1.hasRecurrenceID() ) { |
233 | if ( i1.recurrenceID() != i2.recurrenceID() ) | 233 | if ( i1.recurrenceID() != i2.recurrenceID() ) |
234 | return false; | 234 | return false; |
235 | } | 235 | } |
236 | 236 | ||
237 | } else { | 237 | } else { |
238 | return false; | 238 | return false; |
239 | } | 239 | } |
240 | 240 | ||
241 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 241 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
242 | return false; | 242 | return false; |
243 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 243 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
244 | if ( i1.hasStartDate() ) { | 244 | if ( i1.hasStartDate() ) { |
245 | if ( i1.dtStart() != i2.dtStart() ) | 245 | if ( i1.dtStart() != i2.dtStart() ) |
246 | return false; | 246 | return false; |
247 | } | 247 | } |
248 | } else { | 248 | } else { |
249 | return false; | 249 | return false; |
250 | } | 250 | } |
251 | if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) { | 251 | if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) { |
252 | if (!( *i1.mRecurrence == *i2.mRecurrence) ) { | 252 | if (!( *i1.mRecurrence == *i2.mRecurrence) ) { |
253 | //qDebug("recurrence is NOT equal "); | 253 | //qDebug("recurrence is NOT equal "); |
254 | return false; | 254 | return false; |
255 | } | 255 | } |
256 | } else { | 256 | } else { |
257 | // one ( or both ) recurrence is 0 | 257 | // one ( or both ) recurrence is 0 |
258 | if ( i1.mRecurrence == 0 ) { | 258 | if ( i1.mRecurrence == 0 ) { |
259 | if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone ) | 259 | if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone ) |
260 | return false; | 260 | return false; |
261 | } else { | 261 | } else { |
262 | // i1.mRecurrence != 0 | 262 | // i1.mRecurrence != 0 |
263 | // i2.mRecurrence == 0 | 263 | // i2.mRecurrence == 0 |
264 | if ( i1.mRecurrence->doesRecur() != Recurrence::rNone ) | 264 | if ( i1.mRecurrence->doesRecur() != Recurrence::rNone ) |
265 | return false; | 265 | return false; |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | return | 269 | return |
270 | // i1.created() == i2.created() && | 270 | // i1.created() == i2.created() && |
271 | stringCompare( i1.description(), i2.description() ) && | 271 | stringCompare( i1.description(), i2.description() ) && |
272 | stringCompare( i1.summary(), i2.summary() ) && | 272 | stringCompare( i1.summary(), i2.summary() ) && |
273 | i1.categories() == i2.categories() && | 273 | i1.categories() == i2.categories() && |
274 | // no need to compare mRelatedTo | 274 | // no need to compare mRelatedTo |
275 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 275 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
276 | // i1.relations() == i2.relations() && | 276 | // i1.relations() == i2.relations() && |
277 | i1.exDates() == i2.exDates() && | 277 | i1.exDates() == i2.exDates() && |
278 | i1.attachments() == i2.attachments() && | 278 | i1.attachments() == i2.attachments() && |
279 | i1.resources() == i2.resources() && | 279 | i1.resources() == i2.resources() && |
280 | i1.secrecy() == i2.secrecy() && | 280 | i1.secrecy() == i2.secrecy() && |
281 | i1.priority() == i2.priority() && | 281 | i1.priority() == i2.priority() && |
282 | i1.cancelled() == i2.cancelled() && | 282 | i1.cancelled() == i2.cancelled() && |
283 | stringCompare( i1.location(), i2.location() ); | 283 | stringCompare( i1.location(), i2.location() ); |
284 | } | 284 | } |
285 | 285 | ||
286 | Incidence* Incidence::recreateCloneException( QDate d ) | 286 | Incidence* Incidence::recreateCloneException( QDate d ) |
287 | { | 287 | { |
288 | Incidence* newInc = clone(); | 288 | Incidence* newInc = clone(); |
289 | newInc->recreate(); | 289 | newInc->recreate(); |
290 | if ( doesRecur() ) { | 290 | if ( doesRecur() ) { |
291 | addExDate( d ); | 291 | addExDate( d ); |
292 | newInc->recurrence()->unsetRecurs(); | 292 | newInc->recurrence()->unsetRecurs(); |
293 | if ( typeID() == eventID ) { | 293 | if ( typeID() == eventID ) { |
294 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | 294 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); |
295 | QTime tim = dtStart().time(); | 295 | QTime tim = dtStart().time(); |
296 | newInc->setDtStart( QDateTime(d, tim) ); | 296 | newInc->setDtStart( QDateTime(d, tim) ); |
297 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 297 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
298 | } else { | 298 | } else { |
299 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); | 299 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); |
300 | QTime tim = ((Todo*)this)->dtDue().time(); | 300 | QTime tim = ((Todo*)this)->dtDue().time(); |
301 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); | 301 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); |
302 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); | 302 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); |
303 | ((Todo*)this)->setRecurDates(); | 303 | ((Todo*)this)->setRecurDates(); |
304 | } | 304 | } |
305 | newInc->setExDates( DateList () ); | 305 | newInc->setExDates( DateList () ); |
306 | } | 306 | } |
307 | return newInc; | 307 | return newInc; |
308 | } | 308 | } |
309 | 309 | ||
310 | void Incidence::recreate() | 310 | void Incidence::recreate() |
311 | { | 311 | { |
312 | setCreated(QDateTime::currentDateTime()); | 312 | setCreated(QDateTime::currentDateTime()); |
313 | 313 | ||
314 | setUid(CalFormat::createUniqueId()); | 314 | setUid(CalFormat::createUniqueId()); |
315 | 315 | ||
316 | setRevision(0); | 316 | setRevision(0); |
317 | setIDStr( ":" ); | 317 | setIDStr( ":" ); |
318 | setLastModified(QDateTime::currentDateTime()); | 318 | setLastModified(QDateTime::currentDateTime()); |
319 | } | 319 | } |
320 | void Incidence::cloneRelations( Incidence * newInc ) | 320 | void Incidence::cloneRelations( Incidence * newInc ) |
321 | { | 321 | { |
322 | // newInc is already a clone of this incidence | 322 | // newInc is already a clone of this incidence |
323 | Incidence * inc; | 323 | Incidence * inc; |
324 | Incidence * cloneInc; | 324 | Incidence * cloneInc; |
325 | QPtrList<Incidence> Relations = relations(); | 325 | QPtrList<Incidence> Relations = relations(); |
326 | for (inc=Relations.first();inc;inc=Relations.next()) { | 326 | for (inc=Relations.first();inc;inc=Relations.next()) { |
327 | cloneInc = inc->clone(); | 327 | cloneInc = inc->clone(); |
328 | cloneInc->recreate(); | 328 | cloneInc->recreate(); |
329 | cloneInc->setRelatedTo( newInc ); | 329 | cloneInc->setRelatedTo( newInc ); |
330 | inc->cloneRelations( cloneInc ); | 330 | inc->cloneRelations( cloneInc ); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | void Incidence::setReadOnly( bool readOnly ) | 333 | void Incidence::setReadOnly( bool readOnly ) |
334 | { | 334 | { |
335 | IncidenceBase::setReadOnly( readOnly ); | 335 | IncidenceBase::setReadOnly( readOnly ); |
336 | if ( mRecurrence ) | 336 | if ( mRecurrence ) |
337 | mRecurrence->setRecurReadOnly( readOnly); | 337 | mRecurrence->setRecurReadOnly( readOnly); |
338 | } | 338 | } |
339 | void Incidence::setLastModifiedSubInvalid() | 339 | void Incidence::setLastModifiedSubInvalid() |
340 | { | 340 | { |
341 | mLastModifiedSub = QDateTime(); | 341 | mLastModifiedSub = QDateTime(); |
342 | if ( mRelatedTo ) | 342 | if ( mRelatedTo ) |
343 | mRelatedTo->setLastModifiedSubInvalid(); | 343 | mRelatedTo->setLastModifiedSubInvalid(); |
344 | } | 344 | } |
345 | QString Incidence::lastModifiedSubSortKey() const | 345 | QString Incidence::lastModifiedSubSortKey() const |
346 | { | 346 | { |
347 | if ( mLastModifiedSubSortKey.isEmpty() ) | 347 | if ( mLastModifiedSubSortKey.isEmpty() ) |
348 | return lastModifiedSortKey(); | 348 | return lastModifiedSortKey(); |
349 | return mLastModifiedSubSortKey; | 349 | return mLastModifiedSubSortKey; |
350 | } | 350 | } |
351 | QDateTime Incidence::lastModifiedSub() | 351 | QDateTime Incidence::lastModifiedSub() |
352 | { | 352 | { |
353 | if ( !mRelations.count() ) | 353 | if ( !mRelations.count() ) |
354 | return lastModified(); | 354 | return lastModified(); |
355 | if ( mLastModifiedSub.isValid() ) | 355 | if ( mLastModifiedSub.isValid() ) |
356 | return mLastModifiedSub; | 356 | return mLastModifiedSub; |
357 | mLastModifiedSub = lastModified(); | 357 | mLastModifiedSub = lastModified(); |
358 | Incidence * inc; | 358 | Incidence * inc; |
359 | QPtrList<Incidence> Relations = relations(); | 359 | QPtrList<Incidence> Relations = relations(); |
360 | for (inc=Relations.first();inc;inc=Relations.next()) { | 360 | for (inc=Relations.first();inc;inc=Relations.next()) { |
361 | if ( inc->lastModifiedSub() > mLastModifiedSub ) | 361 | if ( inc->lastModifiedSub() > mLastModifiedSub ) |
362 | mLastModifiedSub = inc->lastModifiedSub(); | 362 | mLastModifiedSub = inc->lastModifiedSub(); |
363 | } | 363 | } |
364 | mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d", | 364 | mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d", |
365 | mLastModifiedSub.date().year(), | 365 | mLastModifiedSub.date().year(), |
366 | mLastModifiedSub.date().month(), | 366 | mLastModifiedSub.date().month(), |
367 | mLastModifiedSub.date().day(), | 367 | mLastModifiedSub.date().day(), |
368 | mLastModifiedSub.time().hour(), | 368 | mLastModifiedSub.time().hour(), |
369 | mLastModifiedSub.time().minute(), | 369 | mLastModifiedSub.time().minute(), |
370 | mLastModifiedSub.time().second() ); | 370 | mLastModifiedSub.time().second() ); |
371 | return mLastModifiedSub; | 371 | return mLastModifiedSub; |
372 | } | 372 | } |
373 | void Incidence::setCreated(QDateTime created) | 373 | void Incidence::setCreated(QDateTime created) |
374 | { | 374 | { |
375 | if (mReadOnly) return; | 375 | if (mReadOnly) return; |
376 | mCreated = getEvenTime(created); | 376 | mCreated = getEvenTime(created); |
377 | } | 377 | } |
378 | 378 | ||
379 | QDateTime Incidence::created() const | 379 | QDateTime Incidence::created() const |
380 | { | 380 | { |
381 | return mCreated; | 381 | return mCreated; |
382 | } | 382 | } |
383 | 383 | ||
384 | void Incidence::setRevision(int rev) | 384 | void Incidence::setRevision(int rev) |
385 | { | 385 | { |
386 | if (mReadOnly) return; | 386 | if (mReadOnly) return; |
387 | mRevision = rev; | 387 | mRevision = rev; |
388 | 388 | ||
389 | updated(); | 389 | updated(); |
390 | } | 390 | } |
391 | 391 | ||
392 | int Incidence::revision() const | 392 | int Incidence::revision() const |
393 | { | 393 | { |
394 | return mRevision; | 394 | return mRevision; |
395 | } | 395 | } |
396 | 396 | ||
397 | void Incidence::setDtStart(const QDateTime &dtStart) | 397 | void Incidence::setDtStart(const QDateTime &dtStart) |
398 | { | 398 | { |
399 | 399 | ||
400 | QDateTime dt = getEvenTime(dtStart); | 400 | QDateTime dt = getEvenTime(dtStart); |
401 | 401 | ||
402 | if ( mRecurrence ) | 402 | if ( mRecurrence ) |
403 | mRecurrence->setRecurStart( dt); | 403 | mRecurrence->setRecurStart( dt); |
404 | IncidenceBase::setDtStart( dt ); | 404 | IncidenceBase::setDtStart( dt ); |
405 | } | 405 | } |
406 | 406 | ||
407 | void Incidence::setDescription(const QString &description) | 407 | void Incidence::setDescription(const QString &description) |
408 | { | 408 | { |
409 | if (mReadOnly) return; | 409 | if (mReadOnly) return; |
410 | mDescription = description; | 410 | mDescription = description; |
411 | updated(); | 411 | updated(); |
412 | } | 412 | } |
413 | 413 | ||
414 | QString Incidence::description() const | 414 | QString Incidence::description() const |
415 | { | 415 | { |
416 | return mDescription; | 416 | return mDescription; |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | void Incidence::setSummary(const QString &summary) | 420 | void Incidence::setSummary(const QString &summary) |
421 | { | 421 | { |
422 | if (mReadOnly) return; | 422 | if (mReadOnly) return; |
423 | mSummary = summary; | 423 | mSummary = summary; |
424 | updated(); | 424 | updated(); |
425 | } | 425 | } |
426 | 426 | ||
427 | QString Incidence::summary() const | 427 | QString Incidence::summary() const |
428 | { | 428 | { |
429 | return mSummary; | 429 | return mSummary; |
430 | } | 430 | } |
431 | void Incidence::checkCategories() | 431 | void Incidence::checkCategories() |
432 | { | 432 | { |
433 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); | 433 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); |
434 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); | 434 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); |
435 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); | 435 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); |
436 | } | 436 | } |
437 | 437 | ||
438 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false | 438 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false |
439 | { | 439 | { |
440 | if (mReadOnly) return; | 440 | if (mReadOnly) return; |
441 | int i; | 441 | int i; |
442 | for( i = 0; i < categories.count(); ++i ) { | 442 | for( i = 0; i < categories.count(); ++i ) { |
443 | if ( !mCategories.contains (categories[i])) | 443 | if ( !mCategories.contains (categories[i])) |
444 | mCategories.append( categories[i] ); | 444 | mCategories.append( categories[i] ); |
445 | } | 445 | } |
446 | checkCategories(); | 446 | checkCategories(); |
447 | updated(); | 447 | updated(); |
448 | if ( addToRelations ) { | 448 | if ( addToRelations ) { |
449 | Incidence * inc; | 449 | Incidence * inc; |
450 | QPtrList<Incidence> Relations = relations(); | 450 | QPtrList<Incidence> Relations = relations(); |
451 | for (inc=Relations.first();inc;inc=Relations.next()) { | 451 | for (inc=Relations.first();inc;inc=Relations.next()) { |
452 | inc->addCategories( categories, true ); | 452 | inc->addCategories( categories, true ); |
453 | } | 453 | } |
454 | } | 454 | } |
455 | } | 455 | } |
456 | 456 | ||
457 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false | 457 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false |
458 | { | 458 | { |
459 | if (mReadOnly) return; | 459 | if (mReadOnly) return; |
460 | mCategories = categories; | 460 | mCategories = categories; |
461 | checkCategories(); | 461 | checkCategories(); |
462 | updated(); | 462 | updated(); |
463 | if ( setForRelations ) { | 463 | if ( setForRelations ) { |
464 | Incidence * inc; | 464 | Incidence * inc; |
465 | QPtrList<Incidence> Relations = relations(); | 465 | QPtrList<Incidence> Relations = relations(); |
466 | for (inc=Relations.first();inc;inc=Relations.next()) { | 466 | for (inc=Relations.first();inc;inc=Relations.next()) { |
467 | inc->setCategories( categories, true ); | 467 | inc->setCategories( categories, true ); |
468 | } | 468 | } |
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
472 | // TODO: remove setCategories(QString) function | 472 | // TODO: remove setCategories(QString) function |
473 | void Incidence::setCategories(const QString &catStr) | 473 | void Incidence::setCategories(const QString &catStr) |
474 | { | 474 | { |
475 | if (mReadOnly) return; | 475 | if (mReadOnly) return; |
476 | mCategories.clear(); | 476 | mCategories.clear(); |
477 | 477 | ||
478 | if (catStr.isEmpty()) return; | 478 | if (catStr.isEmpty()) return; |
479 | 479 | ||
480 | mCategories = QStringList::split(",",catStr); | 480 | mCategories = QStringList::split(",",catStr); |
481 | 481 | ||
482 | QStringList::Iterator it; | 482 | QStringList::Iterator it; |
483 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 483 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
484 | *it = (*it).stripWhiteSpace(); | 484 | *it = (*it).stripWhiteSpace(); |
485 | } | 485 | } |
486 | checkCategories(); | 486 | checkCategories(); |
487 | updated(); | 487 | updated(); |
488 | } | 488 | } |
489 | // using this makes filtering 3 times faster | 489 | // using this makes filtering 3 times faster |
490 | QStringList* Incidence::categoriesP() | 490 | QStringList* Incidence::categoriesP() |
491 | { | 491 | { |
492 | return &mCategories; | 492 | return &mCategories; |
493 | } | 493 | } |
494 | 494 | ||
495 | QStringList Incidence::categories() const | 495 | QStringList Incidence::categories() const |
496 | { | 496 | { |
497 | return mCategories; | 497 | return mCategories; |
498 | } | 498 | } |
499 | 499 | ||
500 | QString Incidence::categoriesStr() | 500 | QString Incidence::categoriesStr() |
501 | { | 501 | { |
502 | return mCategories.join(","); | 502 | return mCategories.join(","); |
503 | } | 503 | } |
504 | QString Incidence::categoriesStrWithSpace() | 504 | QString Incidence::categoriesStrWithSpace() |
505 | { | 505 | { |
506 | return mCategories.join(", "); | 506 | return mCategories.join(", "); |
507 | } | 507 | } |
508 | 508 | ||
509 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 509 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
510 | { | 510 | { |
511 | if (mReadOnly) return; | 511 | if (mReadOnly) return; |
512 | mRelatedToUid = relatedToUid; | 512 | mRelatedToUid = relatedToUid; |
513 | } | 513 | } |
514 | void Incidence::clearRelations() | 514 | void Incidence::clearRelations() |
515 | { | 515 | { |
516 | mRelatedTo = 0; | 516 | mRelatedTo = 0; |
517 | mRelations.clear(); | 517 | mRelations.clear(); |
518 | } | 518 | } |
519 | QString Incidence::relatedToUid() const | 519 | QString Incidence::relatedToUid() const |
520 | { | 520 | { |
521 | return mRelatedToUid; | 521 | return mRelatedToUid; |
522 | } | 522 | } |
523 | void Incidence::resetRelatedTo() | ||
524 | { | ||
525 | QString store = mRelatedToUid; | ||
526 | setRelatedTo( 0 ); | ||
527 | mRelatedToUid = store; | ||
528 | } | ||
523 | 529 | ||
524 | void Incidence::setRelatedTo(Incidence *relatedTo) | 530 | void Incidence::setRelatedTo(Incidence *relatedTo) |
525 | { | 531 | { |
526 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 532 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
527 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 533 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
528 | if (mReadOnly || mRelatedTo == relatedTo) return; | 534 | if (mReadOnly || mRelatedTo == relatedTo) return; |
529 | if(mRelatedTo) { | 535 | if(mRelatedTo) { |
530 | // updated(); | 536 | // updated(); |
531 | mRelatedTo->removeRelation(this); | 537 | mRelatedTo->removeRelation(this); |
532 | } | 538 | } |
533 | mRelatedTo = relatedTo; | 539 | mRelatedTo = relatedTo; |
534 | if (mRelatedTo) { | 540 | if (mRelatedTo) { |
535 | mRelatedTo->addRelation(this); | 541 | mRelatedTo->addRelation(this); |
536 | mRelatedToUid = mRelatedTo->uid(); | 542 | mRelatedToUid = mRelatedTo->uid(); |
537 | } else { | 543 | } else { |
538 | mRelatedToUid = ""; | 544 | mRelatedToUid = ""; |
539 | } | 545 | } |
540 | } | 546 | } |
541 | 547 | ||
542 | Incidence *Incidence::relatedTo() const | 548 | Incidence *Incidence::relatedTo() const |
543 | { | 549 | { |
544 | return mRelatedTo; | 550 | return mRelatedTo; |
545 | } | 551 | } |
546 | 552 | ||
547 | QPtrList<Incidence> Incidence::relations() const | 553 | QPtrList<Incidence> Incidence::relations() const |
548 | { | 554 | { |
549 | return mRelations; | 555 | return mRelations; |
550 | } | 556 | } |
551 | 557 | ||
552 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) | 558 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) |
553 | { | 559 | { |
554 | Incidence* inc; | 560 | Incidence* inc; |
555 | QPtrList<Incidence> Relations = relations(); | 561 | QPtrList<Incidence> Relations = relations(); |
556 | for (inc=Relations.first();inc;inc=Relations.next()) { | 562 | for (inc=Relations.first();inc;inc=Relations.next()) { |
557 | inc->addRelationsToList( rel ); | 563 | inc->addRelationsToList( rel ); |
558 | } | 564 | } |
559 | if ( rel->findRef( this ) == -1 ) | 565 | if ( rel->findRef( this ) == -1 ) |
560 | rel->append( this ); | 566 | rel->append( this ); |
561 | } | 567 | } |
562 | 568 | ||
563 | void Incidence::addRelation(Incidence *event) | 569 | void Incidence::addRelation(Incidence *event) |
564 | { | 570 | { |
565 | setLastModifiedSubInvalid(); | 571 | setLastModifiedSubInvalid(); |
566 | if( mRelations.findRef( event ) == -1 ) { | 572 | if( mRelations.findRef( event ) == -1 ) { |
567 | mRelations.append(event); | 573 | mRelations.append(event); |
568 | //updated(); | 574 | //updated(); |
569 | } | 575 | } |
570 | } | 576 | } |
571 | 577 | ||
572 | void Incidence::removeRelation(Incidence *event) | 578 | void Incidence::removeRelation(Incidence *event) |
573 | { | 579 | { |
574 | setLastModifiedSubInvalid(); | 580 | setLastModifiedSubInvalid(); |
575 | mRelations.removeRef(event); | 581 | mRelations.removeRef(event); |
576 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 582 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
577 | } | 583 | } |
578 | 584 | ||
579 | bool Incidence::recursOn(const QDate &qd) const | 585 | bool Incidence::recursOn(const QDate &qd) const |
580 | { | 586 | { |
581 | if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; | 587 | if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; |
582 | else return false; | 588 | else return false; |
583 | } | 589 | } |
584 | 590 | ||
585 | void Incidence::setExDates(const DateList &exDates) | 591 | void Incidence::setExDates(const DateList &exDates) |
586 | { | 592 | { |
587 | if (mReadOnly) return; | 593 | if (mReadOnly) return; |
588 | mExDates = exDates; | 594 | mExDates = exDates; |
589 | recurrence()->setRecurExDatesCount(mExDates.count()); | 595 | recurrence()->setRecurExDatesCount(mExDates.count()); |
590 | 596 | ||
591 | updated(); | 597 | updated(); |
592 | } | 598 | } |
593 | 599 | ||
594 | void Incidence::addExDate(const QDate &date) | 600 | void Incidence::addExDate(const QDate &date) |
595 | { | 601 | { |
596 | if (mReadOnly) return; | 602 | if (mReadOnly) return; |
597 | mExDates.append(date); | 603 | mExDates.append(date); |
598 | 604 | ||
599 | recurrence()->setRecurExDatesCount(mExDates.count()); | 605 | recurrence()->setRecurExDatesCount(mExDates.count()); |
600 | 606 | ||
601 | updated(); | 607 | updated(); |
602 | } | 608 | } |
603 | 609 | ||
604 | DateList Incidence::exDates() const | 610 | DateList Incidence::exDates() const |
605 | { | 611 | { |
606 | return mExDates; | 612 | return mExDates; |
607 | } | 613 | } |
608 | 614 | ||
609 | bool Incidence::isException(const QDate &date) const | 615 | bool Incidence::isException(const QDate &date) const |
610 | { | 616 | { |
611 | DateList::ConstIterator it; | 617 | DateList::ConstIterator it; |
612 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 618 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
613 | if ( (*it) == date ) { | 619 | if ( (*it) == date ) { |
614 | return true; | 620 | return true; |
615 | } | 621 | } |
616 | } | 622 | } |
617 | 623 | ||
618 | return false; | 624 | return false; |
619 | } | 625 | } |
620 | 626 | ||
621 | void Incidence::addAttachment(Attachment *attachment) | 627 | void Incidence::addAttachment(Attachment *attachment) |
622 | { | 628 | { |
623 | if (mReadOnly || !attachment) return; | 629 | if (mReadOnly || !attachment) return; |
624 | mAttachments.append(attachment); | 630 | mAttachments.append(attachment); |
625 | updated(); | 631 | updated(); |
626 | } | 632 | } |
627 | 633 | ||
628 | void Incidence::deleteAttachment(Attachment *attachment) | 634 | void Incidence::deleteAttachment(Attachment *attachment) |
629 | { | 635 | { |
630 | mAttachments.removeRef(attachment); | 636 | mAttachments.removeRef(attachment); |
631 | } | 637 | } |
632 | 638 | ||
633 | void Incidence::deleteAttachments(const QString& mime) | 639 | void Incidence::deleteAttachments(const QString& mime) |
634 | { | 640 | { |
635 | Attachment *at = mAttachments.first(); | 641 | Attachment *at = mAttachments.first(); |
636 | while (at) { | 642 | while (at) { |
637 | if (at->mimeType() == mime) | 643 | if (at->mimeType() == mime) |
638 | mAttachments.remove(); | 644 | mAttachments.remove(); |
639 | else | 645 | else |
640 | at = mAttachments.next(); | 646 | at = mAttachments.next(); |
641 | } | 647 | } |
642 | } | 648 | } |
643 | 649 | ||
644 | QPtrList<Attachment> Incidence::attachments() const | 650 | QPtrList<Attachment> Incidence::attachments() const |
645 | { | 651 | { |
646 | return mAttachments; | 652 | return mAttachments; |
647 | } | 653 | } |
648 | 654 | ||
649 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 655 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
650 | { | 656 | { |
651 | QPtrList<Attachment> attachments; | 657 | QPtrList<Attachment> attachments; |
652 | QPtrListIterator<Attachment> it( mAttachments ); | 658 | QPtrListIterator<Attachment> it( mAttachments ); |
653 | Attachment *at; | 659 | Attachment *at; |
654 | while ( (at = it.current()) ) { | 660 | while ( (at = it.current()) ) { |
655 | if (at->mimeType() == mime) | 661 | if (at->mimeType() == mime) |
656 | attachments.append(at); | 662 | attachments.append(at); |
657 | ++it; | 663 | ++it; |
658 | } | 664 | } |
659 | 665 | ||
660 | return attachments; | 666 | return attachments; |
661 | } | 667 | } |
662 | 668 | ||
663 | void Incidence::setResources(const QStringList &resources) | 669 | void Incidence::setResources(const QStringList &resources) |
664 | { | 670 | { |
665 | if (mReadOnly) return; | 671 | if (mReadOnly) return; |
666 | mResources = resources; | 672 | mResources = resources; |
667 | updated(); | 673 | updated(); |
668 | } | 674 | } |
669 | 675 | ||
670 | QStringList Incidence::resources() const | 676 | QStringList Incidence::resources() const |
671 | { | 677 | { |
672 | return mResources; | 678 | return mResources; |
673 | } | 679 | } |
674 | 680 | ||
675 | 681 | ||
676 | void Incidence::setPriority(int priority) | 682 | void Incidence::setPriority(int priority) |
677 | { | 683 | { |
678 | if (mReadOnly) return; | 684 | if (mReadOnly) return; |
679 | mPriority = priority; | 685 | mPriority = priority; |
680 | updated(); | 686 | updated(); |
681 | } | 687 | } |
682 | 688 | ||
683 | int Incidence::priority() const | 689 | int Incidence::priority() const |
684 | { | 690 | { |
685 | return mPriority; | 691 | return mPriority; |
686 | } | 692 | } |
687 | 693 | ||
688 | void Incidence::setSecrecy(int sec) | 694 | void Incidence::setSecrecy(int sec) |
689 | { | 695 | { |
690 | if (mReadOnly) return; | 696 | if (mReadOnly) return; |
691 | mSecrecy = sec; | 697 | mSecrecy = sec; |
692 | updated(); | 698 | updated(); |
693 | } | 699 | } |
694 | 700 | ||
695 | int Incidence::secrecy() const | 701 | int Incidence::secrecy() const |
696 | { | 702 | { |
697 | return mSecrecy; | 703 | return mSecrecy; |
698 | } | 704 | } |
699 | 705 | ||
700 | QString Incidence::secrecyStr() const | 706 | QString Incidence::secrecyStr() const |
701 | { | 707 | { |
702 | return secrecyName(mSecrecy); | 708 | return secrecyName(mSecrecy); |
703 | } | 709 | } |
704 | 710 | ||
705 | QString Incidence::secrecyName(int secrecy) | 711 | QString Incidence::secrecyName(int secrecy) |
706 | { | 712 | { |
707 | switch (secrecy) { | 713 | switch (secrecy) { |
708 | case SecrecyPublic: | 714 | case SecrecyPublic: |
709 | return i18n("Public"); | 715 | return i18n("Public"); |
710 | break; | 716 | break; |
711 | case SecrecyPrivate: | 717 | case SecrecyPrivate: |
712 | return i18n("Private"); | 718 | return i18n("Private"); |
713 | break; | 719 | break; |
714 | case SecrecyConfidential: | 720 | case SecrecyConfidential: |
715 | return i18n("Confidential"); | 721 | return i18n("Confidential"); |
716 | break; | 722 | break; |
717 | default: | 723 | default: |
718 | return i18n("Undefined"); | 724 | return i18n("Undefined"); |
719 | break; | 725 | break; |
720 | } | 726 | } |
721 | } | 727 | } |
722 | 728 | ||
723 | QStringList Incidence::secrecyList() | 729 | QStringList Incidence::secrecyList() |
724 | { | 730 | { |
725 | QStringList list; | 731 | QStringList list; |
726 | list << secrecyName(SecrecyPublic); | 732 | list << secrecyName(SecrecyPublic); |
727 | list << secrecyName(SecrecyPrivate); | 733 | list << secrecyName(SecrecyPrivate); |
728 | list << secrecyName(SecrecyConfidential); | 734 | list << secrecyName(SecrecyConfidential); |
729 | 735 | ||
730 | return list; | 736 | return list; |
731 | } | 737 | } |
732 | 738 | ||
733 | 739 | ||
734 | QPtrList<Alarm> Incidence::alarms() const | 740 | QPtrList<Alarm> Incidence::alarms() const |
735 | { | 741 | { |
736 | return mAlarms; | 742 | return mAlarms; |
737 | } | 743 | } |
738 | 744 | ||
739 | Alarm* Incidence::newAlarm() | 745 | Alarm* Incidence::newAlarm() |
740 | { | 746 | { |
741 | Alarm* alarm = new Alarm(this); | 747 | Alarm* alarm = new Alarm(this); |
742 | mAlarms.append(alarm); | 748 | mAlarms.append(alarm); |
743 | // updated(); | 749 | // updated(); |
744 | return alarm; | 750 | return alarm; |
745 | } | 751 | } |
746 | 752 | ||
747 | void Incidence::addAlarm(Alarm *alarm) | 753 | void Incidence::addAlarm(Alarm *alarm) |
748 | { | 754 | { |
749 | mAlarms.append(alarm); | 755 | mAlarms.append(alarm); |
750 | updated(); | 756 | updated(); |
751 | } | 757 | } |
752 | 758 | ||
753 | void Incidence::removeAlarm(Alarm *alarm) | 759 | void Incidence::removeAlarm(Alarm *alarm) |
754 | { | 760 | { |
755 | mAlarms.removeRef(alarm); | 761 | mAlarms.removeRef(alarm); |
756 | updated(); | 762 | updated(); |
757 | } | 763 | } |
758 | 764 | ||
759 | void Incidence::clearAlarms() | 765 | void Incidence::clearAlarms() |
760 | { | 766 | { |
761 | mAlarms.clear(); | 767 | mAlarms.clear(); |
762 | updated(); | 768 | updated(); |
763 | } | 769 | } |
764 | 770 | ||
765 | bool Incidence::isAlarmEnabled() const | 771 | bool Incidence::isAlarmEnabled() const |
766 | { | 772 | { |
767 | Alarm* alarm; | 773 | Alarm* alarm; |
768 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 774 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
769 | if (alarm->enabled()) | 775 | if (alarm->enabled()) |
770 | return true; | 776 | return true; |
771 | } | 777 | } |
772 | return false; | 778 | return false; |
773 | } | 779 | } |
774 | #include <stdlib.h> | 780 | #include <stdlib.h> |
775 | Recurrence *Incidence::recurrence() | 781 | Recurrence *Incidence::recurrence() |
776 | { | 782 | { |
777 | if ( ! mRecurrence ) { | 783 | if ( ! mRecurrence ) { |
778 | mRecurrence = new Recurrence(this); | 784 | mRecurrence = new Recurrence(this); |
779 | mRecurrence->setRecurStart( dtStart() ); | 785 | mRecurrence->setRecurStart( dtStart() ); |
780 | mRecurrence->setRecurReadOnly( isReadOnly()); | 786 | mRecurrence->setRecurReadOnly( isReadOnly()); |
781 | //qDebug("creating new recurence "); | 787 | //qDebug("creating new recurence "); |
782 | //abort(); | 788 | //abort(); |
783 | } | 789 | } |
784 | return mRecurrence; | 790 | return mRecurrence; |
785 | } | 791 | } |
786 | void Incidence::setRecurrence( Recurrence * r) | 792 | void Incidence::setRecurrence( Recurrence * r) |
787 | { | 793 | { |
788 | if ( mRecurrence ) | 794 | if ( mRecurrence ) |
789 | delete mRecurrence; | 795 | delete mRecurrence; |
790 | mRecurrence = r; | 796 | mRecurrence = r; |
791 | } | 797 | } |
792 | 798 | ||
793 | void Incidence::setLocation(const QString &location) | 799 | void Incidence::setLocation(const QString &location) |
794 | { | 800 | { |
795 | if (mReadOnly) return; | 801 | if (mReadOnly) return; |
796 | mLocation = location; | 802 | mLocation = location; |
797 | updated(); | 803 | updated(); |
798 | } | 804 | } |
799 | 805 | ||
800 | QString Incidence::location() const | 806 | QString Incidence::location() const |
801 | { | 807 | { |
802 | return mLocation; | 808 | return mLocation; |
803 | } | 809 | } |
804 | QString Incidence::recurrenceText() const | 810 | QString Incidence::recurrenceText() const |
805 | { | 811 | { |
806 | if ( mRecurrence ) return mRecurrence->recurrenceText(); | 812 | if ( mRecurrence ) return mRecurrence->recurrenceText(); |
807 | return i18n("No"); | 813 | return i18n("No"); |
808 | } | 814 | } |
809 | 815 | ||
810 | ushort Incidence::doesRecur() const | 816 | ushort Incidence::doesRecur() const |
811 | { | 817 | { |
812 | if ( mRecurrence ) return mRecurrence->doesRecur(); | 818 | if ( mRecurrence ) return mRecurrence->doesRecur(); |
813 | else return Recurrence::rNone; | 819 | else return Recurrence::rNone; |
814 | } | 820 | } |
815 | 821 | ||
816 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | 822 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const |
817 | { | 823 | { |
818 | QDateTime incidenceStart = dt; | 824 | QDateTime incidenceStart = dt; |
819 | *ok = false; | 825 | *ok = false; |
820 | if ( doesRecur() ) { | 826 | if ( doesRecur() ) { |
821 | bool last; | 827 | bool last; |
822 | mRecurrence->getPreviousDateTime( incidenceStart , &last ); | 828 | mRecurrence->getPreviousDateTime( incidenceStart , &last ); |
823 | int count = 0; | 829 | int count = 0; |
824 | if ( !last ) { | 830 | if ( !last ) { |
825 | while ( !last ) { | 831 | while ( !last ) { |
826 | ++count; | 832 | ++count; |
827 | incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); | 833 | incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); |
828 | if ( recursOn( incidenceStart.date() ) ) { | 834 | if ( recursOn( incidenceStart.date() ) ) { |
829 | last = true; // exit while llop | 835 | last = true; // exit while llop |
830 | } else { | 836 | } else { |
831 | if ( last ) { // no alarm on last recurrence | 837 | if ( last ) { // no alarm on last recurrence |
832 | return QDateTime (); | 838 | return QDateTime (); |
833 | } | 839 | } |
834 | int year = incidenceStart.date().year(); | 840 | int year = incidenceStart.date().year(); |
835 | // workaround for bug in recurrence | 841 | // workaround for bug in recurrence |
836 | if ( count == 100 || year < 1000 || year > 5000 ) { | 842 | if ( count == 100 || year < 1000 || year > 5000 ) { |
837 | return QDateTime (); | 843 | return QDateTime (); |
838 | } | 844 | } |
839 | incidenceStart = incidenceStart.addSecs( 1 ); | 845 | incidenceStart = incidenceStart.addSecs( 1 ); |
840 | } | 846 | } |
841 | } | 847 | } |
842 | } else { | 848 | } else { |
843 | return QDateTime (); | 849 | return QDateTime (); |
844 | } | 850 | } |
845 | } else { | 851 | } else { |
846 | if ( hasStartDate () ) { | 852 | if ( hasStartDate () ) { |
847 | incidenceStart = dtStart(); | 853 | incidenceStart = dtStart(); |
848 | } | 854 | } |
849 | if ( typeID() == todoID ) { | 855 | if ( typeID() == todoID ) { |
850 | if ( ((Todo*)this)->hasDueDate() ) | 856 | if ( ((Todo*)this)->hasDueDate() ) |
851 | incidenceStart = ((Todo*)this)->dtDue(); | 857 | incidenceStart = ((Todo*)this)->dtDue(); |
852 | } | 858 | } |
853 | } | 859 | } |
854 | if ( incidenceStart > dt ) | 860 | if ( incidenceStart > dt ) |
855 | *ok = true; | 861 | *ok = true; |
856 | return incidenceStart; | 862 | return incidenceStart; |
857 | } | 863 | } |
858 | QDateTime Incidence::dtStart() const | 864 | QDateTime Incidence::dtStart() const |
859 | { | 865 | { |
860 | if ( doesRecur() ) { | 866 | if ( doesRecur() ) { |
861 | if ( typeID() == todoID ) { | 867 | if ( typeID() == todoID ) { |
862 | ((Todo*)this)->checkSetCompletedFalse(); | 868 | ((Todo*)this)->checkSetCompletedFalse(); |
863 | } | 869 | } |
864 | } | 870 | } |
865 | return mDtStart; | 871 | return mDtStart; |
866 | } | 872 | } |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index dc49640..f89942f 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -1,326 +1,327 @@ | |||
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 INCIDENCE_H | 20 | #ifndef INCIDENCE_H |
21 | #define INCIDENCE_H | 21 | #define INCIDENCE_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 | 29 | ||
30 | #include "recurrence.h" | 30 | #include "recurrence.h" |
31 | #include "alarm.h" | 31 | #include "alarm.h" |
32 | #include "attachment.h" | 32 | #include "attachment.h" |
33 | #include "listbase.h" | 33 | #include "listbase.h" |
34 | #include "incidencebase.h" | 34 | #include "incidencebase.h" |
35 | 35 | ||
36 | namespace KCal { | 36 | namespace KCal { |
37 | 37 | ||
38 | class Event; | 38 | class Event; |
39 | class Todo; | 39 | class Todo; |
40 | class Journal; | 40 | class Journal; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | This class provides the base class common to all calendar components. | 43 | This class provides the base class common to all calendar components. |
44 | */ | 44 | */ |
45 | class Incidence : public IncidenceBase | 45 | class Incidence : public IncidenceBase |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | /** | 48 | /** |
49 | This class provides the interface for a visitor of calendar components. It | 49 | This class provides the interface for a visitor of calendar components. It |
50 | serves as base class for concrete visitors, which implement certain actions on | 50 | serves as base class for concrete visitors, which implement certain actions on |
51 | calendar components. It allows to add functions, which operate on the concrete | 51 | calendar components. It allows to add functions, which operate on the concrete |
52 | types of calendar components, without changing the calendar component classes. | 52 | types of calendar components, without changing the calendar component classes. |
53 | */ | 53 | */ |
54 | class Visitor | 54 | class Visitor |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | /** Destruct Incidence::Visitor */ | 57 | /** Destruct Incidence::Visitor */ |
58 | virtual ~Visitor() {} | 58 | virtual ~Visitor() {} |
59 | 59 | ||
60 | /** | 60 | /** |
61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
62 | on an Event object. | 62 | on an Event object. |
63 | */ | 63 | */ |
64 | virtual bool visit(Event *) { return false; } | 64 | virtual bool visit(Event *) { return false; } |
65 | /** | 65 | /** |
66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
67 | on an Todo object. | 67 | on an Todo object. |
68 | */ | 68 | */ |
69 | virtual bool visit(Todo *) { return false; } | 69 | virtual bool visit(Todo *) { return false; } |
70 | /** | 70 | /** |
71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
72 | on an Journal object. | 72 | on an Journal object. |
73 | */ | 73 | */ |
74 | virtual bool visit(Journal *) { return false; } | 74 | virtual bool visit(Journal *) { return false; } |
75 | 75 | ||
76 | protected: | 76 | protected: |
77 | /** Constructor is protected to prevent direct creation of visitor base class. */ | 77 | /** Constructor is protected to prevent direct creation of visitor base class. */ |
78 | Visitor() {} | 78 | Visitor() {} |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | This class implements a visitor for adding an Incidence to a resource | 82 | This class implements a visitor for adding an Incidence to a resource |
83 | supporting addEvent(), addTodo() and addJournal() calls. | 83 | supporting addEvent(), addTodo() and addJournal() calls. |
84 | */ | 84 | */ |
85 | template<class T> | 85 | template<class T> |
86 | class AddVisitor : public Visitor | 86 | class AddVisitor : public Visitor |
87 | { | 87 | { |
88 | public: | 88 | public: |
89 | AddVisitor( T *r ) : mResource( r ) {} | 89 | AddVisitor( T *r ) : mResource( r ) {} |
90 | bool visit( Event *e ) { return mResource->addEvent( e ); } | 90 | bool visit( Event *e ) { return mResource->addEvent( e ); } |
91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } | 91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } |
92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } | 92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } |
93 | 93 | ||
94 | private: | 94 | private: |
95 | T *mResource; | 95 | T *mResource; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | /** enumeration for describing an event's secrecy. */ | 98 | /** enumeration for describing an event's secrecy. */ |
99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; | 99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; |
100 | typedef ListBase<Incidence> List; | 100 | typedef ListBase<Incidence> List; |
101 | Incidence(); | 101 | Incidence(); |
102 | Incidence(const Incidence &); | 102 | Incidence(const Incidence &); |
103 | ~Incidence(); | 103 | ~Incidence(); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to | 106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to |
107 | provide this implementation: | 107 | provide this implementation: |
108 | <pre> | 108 | <pre> |
109 | bool accept(Visitor &v) { return v.visit(this); } | 109 | bool accept(Visitor &v) { return v.visit(this); } |
110 | </pre> | 110 | </pre> |
111 | */ | 111 | */ |
112 | virtual bool accept(Visitor &) { return false; } | 112 | virtual bool accept(Visitor &) { return false; } |
113 | 113 | ||
114 | virtual Incidence *clone() = 0; | 114 | virtual Incidence *clone() = 0; |
115 | virtual void cloneRelations( Incidence * ); | 115 | virtual void cloneRelations( Incidence * ); |
116 | void addRelationsToList(QPtrList<Incidence> *rel); | 116 | void addRelationsToList(QPtrList<Incidence> *rel); |
117 | void clearRelations(); | 117 | void clearRelations(); |
118 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; | 118 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; |
119 | void setReadOnly( bool ); | 119 | void setReadOnly( bool ); |
120 | 120 | ||
121 | /** | 121 | /** |
122 | Recreate event. The event is made a new unique event, but already stored | 122 | Recreate event. The event is made a new unique event, but already stored |
123 | event information is preserved. Sets uniquie id, creation date, last | 123 | event information is preserved. Sets uniquie id, creation date, last |
124 | modification date and revision number. | 124 | modification date and revision number. |
125 | */ | 125 | */ |
126 | void recreate(); | 126 | void recreate(); |
127 | Incidence* recreateCloneException(QDate); | 127 | Incidence* recreateCloneException(QDate); |
128 | 128 | ||
129 | /** set creation date */ | 129 | /** set creation date */ |
130 | void setCreated(QDateTime); | 130 | void setCreated(QDateTime); |
131 | /** return time and date of creation. */ | 131 | /** return time and date of creation. */ |
132 | QDateTime created() const; | 132 | QDateTime created() const; |
133 | 133 | ||
134 | /** set the number of revisions this event has seen */ | 134 | /** set the number of revisions this event has seen */ |
135 | void setRevision(int rev); | 135 | void setRevision(int rev); |
136 | /** return the number of revisions this event has seen */ | 136 | /** return the number of revisions this event has seen */ |
137 | int revision() const; | 137 | int revision() const; |
138 | 138 | ||
139 | /** Set starting date/time. */ | 139 | /** Set starting date/time. */ |
140 | virtual void setDtStart(const QDateTime &dtStart); | 140 | virtual void setDtStart(const QDateTime &dtStart); |
141 | /** Return the incidence's ending date/time as a QDateTime. */ | 141 | /** Return the incidence's ending date/time as a QDateTime. */ |
142 | virtual QDateTime dtEnd() const { return QDateTime(); } | 142 | virtual QDateTime dtEnd() const { return QDateTime(); } |
143 | 143 | ||
144 | /** sets the event's lengthy description. */ | 144 | /** sets the event's lengthy description. */ |
145 | void setDescription(const QString &description); | 145 | void setDescription(const QString &description); |
146 | /** returns a reference to the event's description. */ | 146 | /** returns a reference to the event's description. */ |
147 | QString description() const; | 147 | QString description() const; |
148 | 148 | ||
149 | /** sets the event's short summary. */ | 149 | /** sets the event's short summary. */ |
150 | void setSummary(const QString &summary); | 150 | void setSummary(const QString &summary); |
151 | /** returns a reference to the event's summary. */ | 151 | /** returns a reference to the event's summary. */ |
152 | QString summary() const; | 152 | QString summary() const; |
153 | 153 | ||
154 | /** set event's applicable categories */ | 154 | /** set event's applicable categories */ |
155 | void setCategories(const QStringList &categories, bool setForRelations = false); | 155 | void setCategories(const QStringList &categories, bool setForRelations = false); |
156 | void addCategories(const QStringList &categories, bool addToRelations = false); | 156 | void addCategories(const QStringList &categories, bool addToRelations = false); |
157 | /** set event's categories based on a comma delimited string */ | 157 | /** set event's categories based on a comma delimited string */ |
158 | void setCategories(const QString &catStr); | 158 | void setCategories(const QString &catStr); |
159 | /** return categories in a list */ | 159 | /** return categories in a list */ |
160 | QStringList categories() const; | 160 | QStringList categories() const; |
161 | QStringList* categoriesP(); | 161 | QStringList* categoriesP(); |
162 | /** return categories as a comma separated string */ | 162 | /** return categories as a comma separated string */ |
163 | QString categoriesStr(); | 163 | QString categoriesStr(); |
164 | QString categoriesStrWithSpace(); | 164 | QString categoriesStrWithSpace(); |
165 | 165 | ||
166 | /** point at some other event to which the event relates. This function should | 166 | /** point at some other event to which the event relates. This function should |
167 | * only be used when constructing a calendar before the related Event | 167 | * only be used when constructing a calendar before the related Event |
168 | * exists. */ | 168 | * exists. */ |
169 | void setRelatedToUid(const QString &); | 169 | void setRelatedToUid(const QString &); |
170 | /** what event does this one relate to? This function should | 170 | /** what event does this one relate to? This function should |
171 | * only be used when constructing a calendar before the related Event | 171 | * only be used when constructing a calendar before the related Event |
172 | * exists. */ | 172 | * exists. */ |
173 | QString relatedToUid() const; | 173 | QString relatedToUid() const; |
174 | /** point at some other event to which the event relates */ | 174 | /** point at some other event to which the event relates */ |
175 | void setRelatedTo(Incidence *relatedTo); | 175 | void setRelatedTo(Incidence *relatedTo); |
176 | void resetRelatedTo(); | ||
176 | /** what event does this one relate to? */ | 177 | /** what event does this one relate to? */ |
177 | Incidence *relatedTo() const; | 178 | Incidence *relatedTo() const; |
178 | /** All events that are related to this event */ | 179 | /** All events that are related to this event */ |
179 | QPtrList<Incidence> relations() const; | 180 | QPtrList<Incidence> relations() const; |
180 | /** Add an event which is related to this event */ | 181 | /** Add an event which is related to this event */ |
181 | void addRelation(Incidence *); | 182 | void addRelation(Incidence *); |
182 | /** Remove event that is related to this event */ | 183 | /** Remove event that is related to this event */ |
183 | void removeRelation(Incidence *); | 184 | void removeRelation(Incidence *); |
184 | 185 | ||
185 | /** returns the list of dates which are exceptions to the recurrence rule */ | 186 | /** returns the list of dates which are exceptions to the recurrence rule */ |
186 | DateList exDates() const; | 187 | DateList exDates() const; |
187 | /** sets the list of dates which are exceptions to the recurrence rule */ | 188 | /** sets the list of dates which are exceptions to the recurrence rule */ |
188 | void setExDates(const DateList &_exDates); | 189 | void setExDates(const DateList &_exDates); |
189 | void setExDates(const char *dates); | 190 | void setExDates(const char *dates); |
190 | /** Add a date to the list of exceptions of the recurrence rule. */ | 191 | /** Add a date to the list of exceptions of the recurrence rule. */ |
191 | void addExDate(const QDate &date); | 192 | void addExDate(const QDate &date); |
192 | 193 | ||
193 | /** returns true if there is an exception for this date in the recurrence | 194 | /** returns true if there is an exception for this date in the recurrence |
194 | rule set, or false otherwise. */ | 195 | rule set, or false otherwise. */ |
195 | bool isException(const QDate &qd) const; | 196 | bool isException(const QDate &qd) const; |
196 | 197 | ||
197 | /** add attachment to this event */ | 198 | /** add attachment to this event */ |
198 | void addAttachment(Attachment *attachment); | 199 | void addAttachment(Attachment *attachment); |
199 | /** remove and delete a specific attachment */ | 200 | /** remove and delete a specific attachment */ |
200 | void deleteAttachment(Attachment *attachment); | 201 | void deleteAttachment(Attachment *attachment); |
201 | /** remove and delete all attachments with this mime type */ | 202 | /** remove and delete all attachments with this mime type */ |
202 | void deleteAttachments(const QString& mime); | 203 | void deleteAttachments(const QString& mime); |
203 | /** return list of all associated attachments */ | 204 | /** return list of all associated attachments */ |
204 | QPtrList<Attachment> attachments() const; | 205 | QPtrList<Attachment> attachments() const; |
205 | /** find a list of attachments with this mime type */ | 206 | /** find a list of attachments with this mime type */ |
206 | QPtrList<Attachment> attachments(const QString& mime) const; | 207 | QPtrList<Attachment> attachments(const QString& mime) const; |
207 | 208 | ||
208 | /** sets the event's status the value specified. See the enumeration | 209 | /** sets the event's status the value specified. See the enumeration |
209 | * above for possible values. */ | 210 | * above for possible values. */ |
210 | void setSecrecy(int); | 211 | void setSecrecy(int); |
211 | /** return the event's secrecy. */ | 212 | /** return the event's secrecy. */ |
212 | int secrecy() const; | 213 | int secrecy() const; |
213 | /** return the event's secrecy in string format. */ | 214 | /** return the event's secrecy in string format. */ |
214 | QString secrecyStr() const; | 215 | QString secrecyStr() const; |
215 | /** return list of all availbale secrecy classes */ | 216 | /** return list of all availbale secrecy classes */ |
216 | static QStringList secrecyList(); | 217 | static QStringList secrecyList(); |
217 | /** return human-readable name of secrecy class */ | 218 | /** return human-readable name of secrecy class */ |
218 | static QString secrecyName(int); | 219 | static QString secrecyName(int); |
219 | 220 | ||
220 | /** returns TRUE if the date specified is one on which the event will | 221 | /** returns TRUE if the date specified is one on which the event will |
221 | * recur. */ | 222 | * recur. */ |
222 | bool recursOn(const QDate &qd) const; | 223 | bool recursOn(const QDate &qd) const; |
223 | 224 | ||
224 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): | 225 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): |
225 | 226 | ||
226 | /** set resources used, such as Office, Car, etc. */ | 227 | /** set resources used, such as Office, Car, etc. */ |
227 | void setResources(const QStringList &resources); | 228 | void setResources(const QStringList &resources); |
228 | /** return list of current resources */ | 229 | /** return list of current resources */ |
229 | QStringList resources() const; | 230 | QStringList resources() const; |
230 | 231 | ||
231 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ | 232 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ |
232 | void setPriority(int priority); | 233 | void setPriority(int priority); |
233 | /** get the event's priority */ | 234 | /** get the event's priority */ |
234 | int priority() const; | 235 | int priority() const; |
235 | 236 | ||
236 | /** All alarms that are associated with this incidence */ | 237 | /** All alarms that are associated with this incidence */ |
237 | QPtrList<Alarm> alarms() const; | 238 | QPtrList<Alarm> alarms() const; |
238 | /** Create a new alarm which is associated with this incidence */ | 239 | /** Create a new alarm which is associated with this incidence */ |
239 | Alarm* newAlarm(); | 240 | Alarm* newAlarm(); |
240 | /** Add an alarm which is associated with this incidence */ | 241 | /** Add an alarm which is associated with this incidence */ |
241 | void addAlarm(Alarm*); | 242 | void addAlarm(Alarm*); |
242 | /** Remove an alarm that is associated with this incidence */ | 243 | /** Remove an alarm that is associated with this incidence */ |
243 | void removeAlarm(Alarm*); | 244 | void removeAlarm(Alarm*); |
244 | /** Remove all alarms that are associated with this incidence */ | 245 | /** Remove all alarms that are associated with this incidence */ |
245 | void clearAlarms(); | 246 | void clearAlarms(); |
246 | /** return whether any alarm associated with this incidence is enabled */ | 247 | /** return whether any alarm associated with this incidence is enabled */ |
247 | bool isAlarmEnabled() const; | 248 | bool isAlarmEnabled() const; |
248 | 249 | ||
249 | /** | 250 | /** |
250 | Return the recurrence rule associated with this incidence. If there is | 251 | Return the recurrence rule associated with this incidence. If there is |
251 | none, returns an appropriate (non-0) object. | 252 | none, returns an appropriate (non-0) object. |
252 | */ | 253 | */ |
253 | Recurrence *recurrence(); | 254 | Recurrence *recurrence(); |
254 | void setRecurrence(Recurrence * r); | 255 | void setRecurrence(Recurrence * r); |
255 | /** | 256 | /** |
256 | Forward to Recurrence::doesRecur(). | 257 | Forward to Recurrence::doesRecur(). |
257 | */ | 258 | */ |
258 | ushort doesRecur() const; | 259 | ushort doesRecur() const; |
259 | 260 | ||
260 | /** set the event's/todo's location. Do _not_ use it with journal */ | 261 | /** set the event's/todo's location. Do _not_ use it with journal */ |
261 | void setLocation(const QString &location); | 262 | void setLocation(const QString &location); |
262 | /** return the event's/todo's location. Do _not_ use it with journal */ | 263 | /** return the event's/todo's location. Do _not_ use it with journal */ |
263 | QString location() const; | 264 | QString location() const; |
264 | /** returns TRUE or FALSE depending on whether the todo has a start date */ | 265 | /** returns TRUE or FALSE depending on whether the todo has a start date */ |
265 | bool hasStartDate() const; | 266 | bool hasStartDate() const; |
266 | /** sets the event's hasStartDate value. */ | 267 | /** sets the event's hasStartDate value. */ |
267 | void setHasStartDate(bool f); | 268 | void setHasStartDate(bool f); |
268 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; | 269 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; |
269 | bool cancelled() const; | 270 | bool cancelled() const; |
270 | void setCancelled( bool b ); | 271 | void setCancelled( bool b ); |
271 | 272 | ||
272 | bool hasRecurrenceID() const; | 273 | bool hasRecurrenceID() const; |
273 | void setHasRecurrenceID( bool b ); | 274 | void setHasRecurrenceID( bool b ); |
274 | 275 | ||
275 | void setRecurrenceID(QDateTime); | 276 | void setRecurrenceID(QDateTime); |
276 | QDateTime recurrenceID () const; | 277 | QDateTime recurrenceID () const; |
277 | QDateTime dtStart() const; | 278 | QDateTime dtStart() const; |
278 | bool isHoliday() const; | 279 | bool isHoliday() const; |
279 | bool isBirthday() const; | 280 | bool isBirthday() const; |
280 | bool isAnniversary() const; | 281 | bool isAnniversary() const; |
281 | QDateTime lastModifiedSub(); | 282 | QDateTime lastModifiedSub(); |
282 | QString lastModifiedSubSortKey() const; | 283 | QString lastModifiedSubSortKey() const; |
283 | QString recurrenceText() const; | 284 | QString recurrenceText() const; |
284 | void setLastModifiedSubInvalid(); | 285 | void setLastModifiedSubInvalid(); |
285 | 286 | ||
286 | virtual QString durationText(); | 287 | virtual QString durationText(); |
287 | QString durationText4Time( int secs ); | 288 | QString durationText4Time( int secs ); |
288 | Recurrence *mRecurrence; | 289 | Recurrence *mRecurrence; |
289 | protected: | 290 | protected: |
290 | QPtrList<Alarm> mAlarms; | 291 | QPtrList<Alarm> mAlarms; |
291 | QPtrList<Incidence> mRelations; | 292 | QPtrList<Incidence> mRelations; |
292 | QDateTime mRecurrenceID; | 293 | QDateTime mRecurrenceID; |
293 | bool mHasRecurrenceID; | 294 | bool mHasRecurrenceID; |
294 | private: | 295 | private: |
295 | void checkCategories(); | 296 | void checkCategories(); |
296 | QString mLastModifiedSubSortKey; | 297 | QString mLastModifiedSubSortKey; |
297 | bool mHoliday, mBirthday, mAnniversary; | 298 | bool mHoliday, mBirthday, mAnniversary; |
298 | int mRevision; | 299 | int mRevision; |
299 | bool mCancelled; | 300 | bool mCancelled; |
300 | 301 | ||
301 | // base components of jounal, event and todo | 302 | // base components of jounal, event and todo |
302 | QDateTime mCreated; | 303 | QDateTime mCreated; |
303 | QDateTime mLastModifiedSub; | 304 | QDateTime mLastModifiedSub; |
304 | QString mDescription; | 305 | QString mDescription; |
305 | QString mSummary; | 306 | QString mSummary; |
306 | QStringList mCategories; | 307 | QStringList mCategories; |
307 | Incidence *mRelatedTo; | 308 | Incidence *mRelatedTo; |
308 | QString mRelatedToUid; | 309 | QString mRelatedToUid; |
309 | DateList mExDates; | 310 | DateList mExDates; |
310 | QPtrList<Attachment> mAttachments; | 311 | QPtrList<Attachment> mAttachments; |
311 | QStringList mResources; | 312 | QStringList mResources; |
312 | bool mHasStartDate; // if todo has associated start date | 313 | bool mHasStartDate; // if todo has associated start date |
313 | 314 | ||
314 | int mSecrecy; | 315 | int mSecrecy; |
315 | int mPriority; // 1 = highest, 2 = less, etc. | 316 | int mPriority; // 1 = highest, 2 = less, etc. |
316 | 317 | ||
317 | //QPtrList<Alarm> mAlarms; | 318 | //QPtrList<Alarm> mAlarms; |
318 | 319 | ||
319 | QString mLocation; | 320 | QString mLocation; |
320 | }; | 321 | }; |
321 | 322 | ||
322 | bool operator==( const Incidence&, const Incidence& ); | 323 | bool operator==( const Incidence&, const Incidence& ); |
323 | 324 | ||
324 | } | 325 | } |
325 | 326 | ||
326 | #endif | 327 | #endif |