author | zautrix <zautrix> | 2005-07-29 09:42:43 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-29 09:42:43 (UTC) |
commit | 8feb7e617f1aa5cd5bb04d9a69d05409c3c4c60d (patch) (unidiff) | |
tree | 89646a8417d381dbebe158530fd0212d092b9365 | |
parent | ea12a774c5a36a4bd96ac53c36e92560989e3cbc (diff) | |
download | kdepimpi-8feb7e617f1aa5cd5bb04d9a69d05409c3c4c60d.zip kdepimpi-8feb7e617f1aa5cd5bb04d9a69d05409c3c4c60d.tar.gz kdepimpi-8feb7e617f1aa5cd5bb04d9a69d05409c3c4c60d.tar.bz2 |
chechalarm fix
-rw-r--r-- | korganizer/calendarview.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a9d42f0..28649d9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4855 +1,4859 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "koagenda.h" | 107 | #include "koagenda.h" |
108 | #include "kodialogmanager.h" | 108 | #include "kodialogmanager.h" |
109 | #include "outgoingdialog.h" | 109 | #include "outgoingdialog.h" |
110 | #include "incomingdialog.h" | 110 | #include "incomingdialog.h" |
111 | #include "datenavigatorcontainer.h" | 111 | #include "datenavigatorcontainer.h" |
112 | #include "statusdialog.h" | 112 | #include "statusdialog.h" |
113 | #include "kdatenavigator.h" | 113 | #include "kdatenavigator.h" |
114 | #include "kotodoview.h" | 114 | #include "kotodoview.h" |
115 | #include "datenavigator.h" | 115 | #include "datenavigator.h" |
116 | #include "resourceview.h" | 116 | #include "resourceview.h" |
117 | #include "navigatorbar.h" | 117 | #include "navigatorbar.h" |
118 | #include "searchdialog.h" | 118 | #include "searchdialog.h" |
119 | #include "mainwindow.h" | 119 | #include "mainwindow.h" |
120 | #include "categoryeditdialog.h" | 120 | #include "categoryeditdialog.h" |
121 | 121 | ||
122 | #include "calendarview.h" | 122 | #include "calendarview.h" |
123 | #ifndef DESKTOP_VERSION | 123 | #ifndef DESKTOP_VERSION |
124 | #include <qtopia/alarmserver.h> | 124 | #include <qtopia/alarmserver.h> |
125 | #endif | 125 | #endif |
126 | #ifndef _WIN32_ | 126 | #ifndef _WIN32_ |
127 | #include <stdlib.h> | 127 | #include <stdlib.h> |
128 | #include <stdio.h> | 128 | #include <stdio.h> |
129 | #include <unistd.h> | 129 | #include <unistd.h> |
130 | #else | 130 | #else |
131 | #include <qprocess.h> | 131 | #include <qprocess.h> |
132 | #endif | 132 | #endif |
133 | 133 | ||
134 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
135 | #include <kabc/stdaddressbook.h> | 135 | #include <kabc/stdaddressbook.h> |
136 | #endif | 136 | #endif |
137 | using namespace KOrg; | 137 | using namespace KOrg; |
138 | using namespace KCal; | 138 | using namespace KCal; |
139 | extern int globalFlagBlockAgenda; | 139 | extern int globalFlagBlockAgenda; |
140 | extern int globalFlagBlockStartup; | 140 | extern int globalFlagBlockStartup; |
141 | 141 | ||
142 | 142 | ||
143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
144 | 144 | ||
145 | { | 145 | { |
146 | mAlarms = alarms; | 146 | mAlarms = alarms; |
147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
148 | QString mText = "<table width=\"100%\">\n"; | 148 | QString mText = "<table width=\"100%\">\n"; |
149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
150 | #ifdef DESKTOP_VERSION | 150 | #ifdef DESKTOP_VERSION |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
152 | #else | 152 | #else |
153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
154 | #endif | 154 | #endif |
155 | // mText += "<img src=\""; | 155 | // mText += "<img src=\""; |
156 | // mText += ipath; | 156 | // mText += ipath; |
157 | // mText += "\">"; | 157 | // mText += "\">"; |
158 | //mEventDate = QDate::currentDate(); | 158 | //mEventDate = QDate::currentDate(); |
159 | #ifdef DESKTOP_VERSION | 159 | #ifdef DESKTOP_VERSION |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
161 | #else | 161 | #else |
162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
163 | #endif | 163 | #endif |
164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
165 | 165 | ||
166 | Incidence * inc = getNextInc( start ); | 166 | Incidence * inc = getNextInc( start ); |
167 | int time = 0; | 167 | int time = 0; |
168 | //mText += "<table>"; | 168 | //mText += "<table>"; |
169 | while ( inc ) { | 169 | while ( inc ) { |
170 | QDateTime dt ; | 170 | QDateTime dt ; |
171 | QString tempText = "<a "; | 171 | QString tempText = "<a "; |
172 | bool ok; | 172 | bool ok; |
173 | dt = inc->getNextOccurence( start, &ok ); | 173 | dt = inc->getNextOccurence( start, &ok ); |
174 | if ( !ok ) continue; | 174 | if ( !ok ) continue; |
175 | if ( inc->typeID() == eventID ) { | 175 | if ( inc->typeID() == eventID ) { |
176 | tempText += "href=\"event:"; | 176 | tempText += "href=\"event:"; |
177 | } else if ( inc->typeID() == todoID ) { | 177 | } else if ( inc->typeID() == todoID ) { |
178 | tempText += "href=\"todo:"; | 178 | tempText += "href=\"todo:"; |
179 | } | 179 | } |
180 | tempText += inc->uid() + "\">"; | 180 | tempText += inc->uid() + "\">"; |
181 | if ( inc->typeID() == todoID ) | 181 | if ( inc->typeID() == todoID ) |
182 | tempText += i18n("Todo: "); | 182 | tempText += i18n("Todo: "); |
183 | if ( inc->summary().length() > 0 ) | 183 | if ( inc->summary().length() > 0 ) |
184 | tempText += inc->summary(); | 184 | tempText += inc->summary(); |
185 | else | 185 | else |
186 | tempText += i18n("-no summary-"); | 186 | tempText += i18n("-no summary-"); |
187 | QString timestr; | 187 | QString timestr; |
188 | if (!inc->doesFloat()) | 188 | if (!inc->doesFloat()) |
189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | else | 190 | else |
191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
194 | mText += "<table>"; | 194 | mText += "<table>"; |
195 | time = 1; | 195 | time = 1; |
196 | } | 196 | } |
197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
198 | if ( time > 0 ) | 198 | if ( time > 0 ) |
199 | mText +="</table>"; | 199 | mText +="</table>"; |
200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
201 | mText += "<table>"; | 201 | mText += "<table>"; |
202 | time = 2; | 202 | time = 2; |
203 | 203 | ||
204 | } | 204 | } |
205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
206 | if ( time > 0 ) | 206 | if ( time > 0 ) |
207 | mText +="</table>"; | 207 | mText +="</table>"; |
208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
209 | mText += "<table>"; | 209 | mText += "<table>"; |
210 | time = 3; | 210 | time = 3; |
211 | } | 211 | } |
212 | mText +="<tr><td><b>"; | 212 | mText +="<tr><td><b>"; |
213 | mText += timestr; | 213 | mText += timestr; |
214 | mText += "</b></td><td>"; | 214 | mText += "</b></td><td>"; |
215 | mText += tempText; | 215 | mText += tempText; |
216 | mText += "</td></tr>\n"; | 216 | mText += "</td></tr>\n"; |
217 | inc = getNextInc( start ); | 217 | inc = getNextInc( start ); |
218 | } | 218 | } |
219 | mText +="</table>"; | 219 | mText +="</table>"; |
220 | setText( mText ); | 220 | setText( mText ); |
221 | } | 221 | } |
222 | 222 | ||
223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
224 | { | 224 | { |
225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
226 | } | 226 | } |
227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
228 | { | 228 | { |
229 | QDateTime dt ; | 229 | QDateTime dt ; |
230 | Incidence * retInc; | 230 | Incidence * retInc; |
231 | Incidence * inc = mAlarms.first(); | 231 | Incidence * inc = mAlarms.first(); |
232 | if ( inc == 0 ) | 232 | if ( inc == 0 ) |
233 | return 0; | 233 | return 0; |
234 | bool ok; | 234 | bool ok; |
235 | dt = inc->getNextOccurence( start, &ok ); | 235 | dt = inc->getNextOccurence( start, &ok ); |
236 | if ( ! ok ) return 0; | 236 | if ( ! ok ) return 0; |
237 | QDateTime dtn ; | 237 | QDateTime dtn ; |
238 | retInc = inc; | 238 | retInc = inc; |
239 | inc = mAlarms.next(); | 239 | inc = mAlarms.next(); |
240 | while ( inc ) { | 240 | while ( inc ) { |
241 | dtn = inc->getNextOccurence( start, &ok ); | 241 | dtn = inc->getNextOccurence( start, &ok ); |
242 | if ( ! ok ) return 0; | 242 | if ( ! ok ) return 0; |
243 | if ( dtn < dt ) { | 243 | if ( dtn < dt ) { |
244 | dt = dtn; | 244 | dt = dtn; |
245 | retInc = inc; | 245 | retInc = inc; |
246 | } | 246 | } |
247 | inc = mAlarms.next(); | 247 | inc = mAlarms.next(); |
248 | } | 248 | } |
249 | mAlarms.remove( retInc ); | 249 | mAlarms.remove( retInc ); |
250 | return retInc; | 250 | return retInc; |
251 | 251 | ||
252 | } | 252 | } |
253 | void MissedAlarmTextBrowser::setSource(const QString & n) | 253 | void MissedAlarmTextBrowser::setSource(const QString & n) |
254 | { | 254 | { |
255 | if (n.startsWith("event:")) { | 255 | if (n.startsWith("event:")) { |
256 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
257 | emit showIncidence(n.mid(8)); | 257 | emit showIncidence(n.mid(8)); |
258 | #else | 258 | #else |
259 | emit showIncidence(n.mid(6)); | 259 | emit showIncidence(n.mid(6)); |
260 | #endif | 260 | #endif |
261 | return; | 261 | return; |
262 | } else if (n.startsWith("todo:")) { | 262 | } else if (n.startsWith("todo:")) { |
263 | #ifdef DESKTOP_VERSION | 263 | #ifdef DESKTOP_VERSION |
264 | emit showIncidence(n.mid(7)); | 264 | emit showIncidence(n.mid(7)); |
265 | #else | 265 | #else |
266 | emit showIncidence(n.mid(5)); | 266 | emit showIncidence(n.mid(5)); |
267 | #endif | 267 | #endif |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | class KOBeamPrefs : public QDialog | 273 | class KOBeamPrefs : public QDialog |
274 | { | 274 | { |
275 | public: | 275 | public: |
276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
277 | QDialog( parent, name, true ) | 277 | QDialog( parent, name, true ) |
278 | { | 278 | { |
279 | setCaption( i18n("Beam Options") ); | 279 | setCaption( i18n("Beam Options") ); |
280 | QVBoxLayout* lay = new QVBoxLayout( this ); | 280 | QVBoxLayout* lay = new QVBoxLayout( this ); |
281 | lay->setSpacing( 3 ); | 281 | lay->setSpacing( 3 ); |
282 | lay->setMargin( 3 ); | 282 | lay->setMargin( 3 ); |
283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
284 | lay->addWidget( format ); | 284 | lay->addWidget( format ); |
285 | format->setExclusive ( true ) ; | 285 | format->setExclusive ( true ) ; |
286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
287 | lay->addWidget( time ); time->setExclusive ( true ) ; | 287 | lay->addWidget( time ); time->setExclusive ( true ) ; |
288 | vcal = new QRadioButton(" vCalendar ", format ); | 288 | vcal = new QRadioButton(" vCalendar ", format ); |
289 | ical = new QRadioButton(" iCalendar ", format ); | 289 | ical = new QRadioButton(" iCalendar ", format ); |
290 | vcal->setChecked( true ); | 290 | vcal->setChecked( true ); |
291 | tz = new QRadioButton(i18n(" With timezone "), time ); | 291 | tz = new QRadioButton(i18n(" With timezone "), time ); |
292 | local = new QRadioButton(i18n(" Local time "), time ); | 292 | local = new QRadioButton(i18n(" Local time "), time ); |
293 | tz->setChecked( true ); | 293 | tz->setChecked( true ); |
294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
295 | lay->addWidget( ok ); | 295 | lay->addWidget( ok ); |
296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
297 | lay->addWidget( cancel ); | 297 | lay->addWidget( cancel ); |
298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
300 | resize( 200, 200 ); | 300 | resize( 200, 200 ); |
301 | } | 301 | } |
302 | 302 | ||
303 | bool beamVcal() { return vcal->isChecked(); } | 303 | bool beamVcal() { return vcal->isChecked(); } |
304 | bool beamLocal() { return local->isChecked(); } | 304 | bool beamLocal() { return local->isChecked(); } |
305 | private: | 305 | private: |
306 | QRadioButton* vcal, *ical, *local, *tz; | 306 | QRadioButton* vcal, *ical, *local, *tz; |
307 | }; | 307 | }; |
308 | class KOCatPrefs : public QDialog | 308 | class KOCatPrefs : public QDialog |
309 | { | 309 | { |
310 | public: | 310 | public: |
311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
312 | QDialog( parent, name, true ) | 312 | QDialog( parent, name, true ) |
313 | { | 313 | { |
314 | setCaption( i18n("Manage new Categories") ); | 314 | setCaption( i18n("Manage new Categories") ); |
315 | QVBoxLayout* lay = new QVBoxLayout( this ); | 315 | QVBoxLayout* lay = new QVBoxLayout( this ); |
316 | lay->setSpacing( 3 ); | 316 | lay->setSpacing( 3 ); |
317 | lay->setMargin( 3 ); | 317 | lay->setMargin( 3 ); |
318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); | 318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); |
319 | lay->addWidget( lab ); | 319 | lay->addWidget( lab ); |
320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
321 | lay->addWidget( format ); | 321 | lay->addWidget( format ); |
322 | format->setExclusive ( true ) ; | 322 | format->setExclusive ( true ) ; |
323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
325 | addCatBut->setChecked( true ); | 325 | addCatBut->setChecked( true ); |
326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
327 | lay->addWidget( ok ); | 327 | lay->addWidget( ok ); |
328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
329 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
332 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
333 | } | 333 | } |
334 | 334 | ||
335 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
336 | private: | 336 | private: |
337 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | 340 | ||
341 | 341 | ||
342 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
343 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
344 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
345 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
346 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
347 | { | 347 | { |
348 | 348 | ||
349 | mEventEditor = 0; | 349 | mEventEditor = 0; |
350 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
351 | 351 | ||
352 | init(); | 352 | init(); |
353 | } | 353 | } |
354 | 354 | ||
355 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
356 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
357 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
358 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
359 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
360 | { | 360 | { |
361 | 361 | ||
362 | mEventEditor = 0; | 362 | mEventEditor = 0; |
363 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
364 | init(); | 364 | init(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void CalendarView::init() | 367 | void CalendarView::init() |
368 | { | 368 | { |
369 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 369 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
370 | setFocusPolicy (NoFocus ); | 370 | setFocusPolicy (NoFocus ); |
371 | mViewerCallerIsSearchDialog = false; | 371 | mViewerCallerIsSearchDialog = false; |
372 | mBlockShowDates = false; | 372 | mBlockShowDates = false; |
373 | mConflictingEvent = 0; | 373 | mConflictingEvent = 0; |
374 | mDatePickerMode = 0; | 374 | mDatePickerMode = 0; |
375 | mCurrentSyncDevice = ""; | 375 | mCurrentSyncDevice = ""; |
376 | mViewManager = new KOViewManager( this ); | 376 | mViewManager = new KOViewManager( this ); |
377 | mDialogManager = new KODialogManager( this ); | 377 | mDialogManager = new KODialogManager( this ); |
378 | mEventViewerDialog = 0; | 378 | mEventViewerDialog = 0; |
379 | mModified = false; | 379 | mModified = false; |
380 | mReadOnly = false; | 380 | mReadOnly = false; |
381 | mSelectedIncidence = 0; | 381 | mSelectedIncidence = 0; |
382 | mCalPrinter = 0; | 382 | mCalPrinter = 0; |
383 | mFilters.setAutoDelete(true); | 383 | mFilters.setAutoDelete(true); |
384 | 384 | ||
385 | mCalendar->registerObserver( this ); | 385 | mCalendar->registerObserver( this ); |
386 | // TODO: Make sure that view is updated, when calendar is changed. | 386 | // TODO: Make sure that view is updated, when calendar is changed. |
387 | 387 | ||
388 | mStorage = new FileStorage( mCalendar ); | 388 | mStorage = new FileStorage( mCalendar ); |
389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
390 | 390 | ||
391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
392 | #ifndef KORG_NOSPLITTER | 392 | #ifndef KORG_NOSPLITTER |
393 | // create the main layout frames. | 393 | // create the main layout frames. |
394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
395 | topLayout->addWidget(mPanner); | 395 | topLayout->addWidget(mPanner); |
396 | 396 | ||
397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
398 | "CalendarView::LeftFrame"); | 398 | "CalendarView::LeftFrame"); |
399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
400 | 400 | ||
401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
402 | "CalendarView::DateNavigator" ); | 402 | "CalendarView::DateNavigator" ); |
403 | 403 | ||
404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
406 | mTodoList->setNavigator( mNavigator ); | 406 | mTodoList->setNavigator( mNavigator ); |
407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
408 | 408 | ||
409 | #ifdef KORG_NORESOURCEVIEW | 409 | #ifdef KORG_NORESOURCEVIEW |
410 | mResourceView = 0; | 410 | mResourceView = 0; |
411 | #else | 411 | #else |
412 | if ( mResourceManager ) { | 412 | if ( mResourceManager ) { |
413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
414 | mResourceView->updateView(); | 414 | mResourceView->updateView(); |
415 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 415 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
416 | SLOT( updateView() ) ); | 416 | SLOT( updateView() ) ); |
417 | } else { | 417 | } else { |
418 | mResourceView = 0; | 418 | mResourceView = 0; |
419 | } | 419 | } |
420 | #endif | 420 | #endif |
421 | QWidget *rightBox = new QWidget( mPanner ); | 421 | QWidget *rightBox = new QWidget( mPanner ); |
422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
423 | 423 | ||
424 | mRightFrame = new QWidgetStack( rightBox ); | 424 | mRightFrame = new QWidgetStack( rightBox ); |
425 | rightLayout->addWidget( mRightFrame, 1 ); | 425 | rightLayout->addWidget( mRightFrame, 1 ); |
426 | 426 | ||
427 | mLeftFrame = mLeftSplitter; | 427 | mLeftFrame = mLeftSplitter; |
428 | #else | 428 | #else |
429 | //QWidget *mainBox = new QWidget( this ); | 429 | //QWidget *mainBox = new QWidget( this ); |
430 | //QWidget *leftFrame = new QWidget( mainBox ); | 430 | //QWidget *leftFrame = new QWidget( mainBox ); |
431 | //QBoxLayout * mainBoxLayout; | 431 | //QBoxLayout * mainBoxLayout; |
432 | if ( KOPrefs::instance()->mVerticalScreen ) { | 432 | if ( KOPrefs::instance()->mVerticalScreen ) { |
433 | //mainBoxLayout = new QVBoxLayout(mainBox); | 433 | //mainBoxLayout = new QVBoxLayout(mainBox); |
434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
439 | } else { | 439 | } else { |
440 | //mainBoxLayout = new QHBoxLayout(mainBox); | 440 | //mainBoxLayout = new QHBoxLayout(mainBox); |
441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
446 | } | 446 | } |
447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
448 | //QBoxLayout * leftFrameLayout; | 448 | //QBoxLayout * leftFrameLayout; |
449 | topLayout->addWidget( mMainFrame ); | 449 | topLayout->addWidget( mMainFrame ); |
450 | #ifdef DESKTOP_VERSION | 450 | #ifdef DESKTOP_VERSION |
451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
452 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
454 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
455 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
456 | #endif | 456 | #endif |
457 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
459 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
460 | #if 0 | 460 | #if 0 |
461 | // FIXME | 461 | // FIXME |
462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
463 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
464 | #endif | 464 | #endif |
465 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
466 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
480 | 480 | ||
481 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
482 | #if 0 | 482 | #if 0 |
483 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
484 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
485 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
486 | 486 | ||
487 | } else { | 487 | } else { |
488 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
489 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
490 | } | 490 | } |
491 | #endif | 491 | #endif |
492 | mFilterView->hide(); | 492 | mFilterView->hide(); |
493 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
494 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
495 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
497 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
498 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
499 | 499 | ||
500 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
501 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
506 | } else { | 506 | } else { |
507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
510 | } | 510 | } |
511 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
512 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
513 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
517 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
518 | 518 | ||
519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
521 | 521 | ||
522 | 522 | ||
523 | 523 | ||
524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
529 | 529 | ||
530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
531 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
532 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
533 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
535 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
537 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
538 | 538 | ||
539 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
540 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
541 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
542 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
545 | 545 | ||
546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
548 | #if 0 | 548 | #if 0 |
549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
550 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
551 | #endif | 551 | #endif |
552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
553 | 553 | ||
554 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
555 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
558 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
560 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
562 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
564 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
566 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
569 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
571 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
572 | 572 | ||
573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
576 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
577 | 577 | ||
578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
579 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
581 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
582 | 582 | ||
583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
584 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
585 | 585 | ||
586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
589 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
592 | 592 | ||
593 | 593 | ||
594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | 602 | ||
603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
604 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
606 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
608 | 608 | ||
609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
610 | 610 | ||
611 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
614 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
615 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
616 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
618 | 618 | ||
619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
620 | 620 | ||
621 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
622 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
623 | 623 | ||
624 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
625 | 625 | ||
626 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
627 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
628 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
632 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
634 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
636 | 636 | ||
637 | 637 | ||
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
642 | #endif | 642 | #endif |
643 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
648 | { | 648 | { |
649 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
650 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
651 | delete mDialogManager; | 651 | delete mDialogManager; |
652 | delete mViewManager; | 652 | delete mViewManager; |
653 | delete mStorage; | 653 | delete mStorage; |
654 | delete mDateFrame ; | 654 | delete mDateFrame ; |
655 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
656 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
657 | } | 657 | } |
658 | 658 | ||
659 | 659 | ||
660 | void CalendarView::nextConflict( bool all, bool allday ) | 660 | void CalendarView::nextConflict( bool all, bool allday ) |
661 | { | 661 | { |
662 | static bool block = false; | 662 | static bool block = false; |
663 | if ( block ) return; | 663 | if ( block ) return; |
664 | block = true; | 664 | block = true; |
665 | QPtrList<Event> testlist = mCalendar->events(); | 665 | QPtrList<Event> testlist = mCalendar->events(); |
666 | Event * test = testlist.first(); | 666 | Event * test = testlist.first(); |
667 | while ( test ) { | 667 | while ( test ) { |
668 | test->setTagged( false ); | 668 | test->setTagged( false ); |
669 | test = testlist.next(); | 669 | test = testlist.next(); |
670 | } | 670 | } |
671 | QTime st ( 0,0,0); | 671 | QTime st ( 0,0,0); |
672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
673 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 673 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
674 | //qDebug("time %s ", st.toString().latin1()); | 674 | //qDebug("time %s ", st.toString().latin1()); |
675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
676 | QDateTime conflict; | 676 | QDateTime conflict; |
677 | QDateTime retVal; | 677 | QDateTime retVal; |
678 | bool found = false; | 678 | bool found = false; |
679 | Event * cE = 0; | 679 | Event * cE = 0; |
680 | Event * cE2 = 0; | 680 | Event * cE2 = 0; |
681 | QPtrList<Event> testlist2 = testlist; | 681 | QPtrList<Event> testlist2 = testlist; |
682 | test = testlist.first(); | 682 | test = testlist.first(); |
683 | bool skip = false; | 683 | bool skip = false; |
684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
685 | //QTime tm; | 685 | //QTime tm; |
686 | //tm.start(); | 686 | //tm.start(); |
687 | while ( test ) { | 687 | while ( test ) { |
688 | qApp->processEvents(); | 688 | qApp->processEvents(); |
689 | skip = false; | 689 | skip = false; |
690 | if ( !all ) skip = ( allday != test->doesFloat() ); | 690 | if ( !all ) skip = ( allday != test->doesFloat() ); |
691 | if ( !skip ) { | 691 | if ( !skip ) { |
692 | if ( found ) | 692 | if ( found ) |
693 | skip = !test->matchTime( &startDT, &conflict ); | 693 | skip = !test->matchTime( &startDT, &conflict ); |
694 | else | 694 | else |
695 | skip = !test->matchTime( &startDT, 0 ); | 695 | skip = !test->matchTime( &startDT, 0 ); |
696 | } | 696 | } |
697 | if ( !skip ) { | 697 | if ( !skip ) { |
698 | Event * test2 = testlist2.first(); | 698 | Event * test2 = testlist2.first(); |
699 | while ( test2 ) { | 699 | while ( test2 ) { |
700 | skip = test2->isTagged(); | 700 | skip = test2->isTagged(); |
701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); | 701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); |
702 | if ( !skip ) { | 702 | if ( !skip ) { |
703 | if ( found ) | 703 | if ( found ) |
704 | skip = !test2->matchTime( &startDT, &conflict ); | 704 | skip = !test2->matchTime( &startDT, &conflict ); |
705 | else | 705 | else |
706 | skip = !test2->matchTime( &startDT, 0 ); | 706 | skip = !test2->matchTime( &startDT, 0 ); |
707 | } | 707 | } |
708 | if ( !skip ) { | 708 | if ( !skip ) { |
709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
710 | //qDebug("overlap "); | 710 | //qDebug("overlap "); |
711 | if ( ! found ) { | 711 | if ( ! found ) { |
712 | if ( retVal >= startDT ) { | 712 | if ( retVal >= startDT ) { |
713 | conflict = retVal; | 713 | conflict = retVal; |
714 | cE = test; | 714 | cE = test; |
715 | cE2 = test2; | 715 | cE2 = test2; |
716 | found = true; | 716 | found = true; |
717 | } | 717 | } |
718 | } else { | 718 | } else { |
719 | if ( retVal >= startDT && retVal < conflict ) { | 719 | if ( retVal >= startDT && retVal < conflict ) { |
720 | conflict = retVal; | 720 | conflict = retVal; |
721 | cE = test; | 721 | cE = test; |
722 | cE2 = test2; | 722 | cE2 = test2; |
723 | } | 723 | } |
724 | } | 724 | } |
725 | } | 725 | } |
726 | } | 726 | } |
727 | test2 = testlist2.next(); | 727 | test2 = testlist2.next(); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | test->setTagged( true ); | 730 | test->setTagged( true ); |
731 | test = testlist.next(); | 731 | test = testlist.next(); |
732 | } | 732 | } |
733 | //qDebug("Search time : %d", tm.elapsed()); | 733 | //qDebug("Search time : %d", tm.elapsed()); |
734 | if ( found ) { | 734 | if ( found ) { |
735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
736 | mViewManager->showDayView(); | 736 | mViewManager->showDayView(); |
737 | mNavigator->slotDaySelect( conflict.date() ); | 737 | mNavigator->slotDaySelect( conflict.date() ); |
738 | int hour = conflict.time().hour(); | 738 | int hour = conflict.time().hour(); |
739 | mViewManager->agendaView()->setStartHour( hour ); | 739 | mViewManager->agendaView()->setStartHour( hour ); |
740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
741 | block = false; | 741 | block = false; |
742 | return; | 742 | return; |
743 | } | 743 | } |
744 | 744 | ||
745 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 745 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
746 | //qDebug("No conflict found "); | 746 | //qDebug("No conflict found "); |
747 | block = false; | 747 | block = false; |
748 | return; | 748 | return; |
749 | } | 749 | } |
750 | 750 | ||
751 | void CalendarView::conflictAll() | 751 | void CalendarView::conflictAll() |
752 | { | 752 | { |
753 | nextConflict ( true, true ); | 753 | nextConflict ( true, true ); |
754 | } | 754 | } |
755 | void CalendarView::conflictAllday() | 755 | void CalendarView::conflictAllday() |
756 | { | 756 | { |
757 | nextConflict ( false, true ); | 757 | nextConflict ( false, true ); |
758 | } | 758 | } |
759 | void CalendarView::conflictNotAll() | 759 | void CalendarView::conflictNotAll() |
760 | { | 760 | { |
761 | nextConflict ( false, false ); | 761 | nextConflict ( false, false ); |
762 | } | 762 | } |
763 | 763 | ||
764 | void CalendarView::setCalReadOnly( int id, bool readO ) | 764 | void CalendarView::setCalReadOnly( int id, bool readO ) |
765 | { | 765 | { |
766 | if ( readO ) { | 766 | if ( readO ) { |
767 | emit save(); | 767 | emit save(); |
768 | } | 768 | } |
769 | mCalendar->setReadOnly( id, readO ); | 769 | mCalendar->setReadOnly( id, readO ); |
770 | } | 770 | } |
771 | void CalendarView::setScrollBarStep(int val ) | 771 | void CalendarView::setScrollBarStep(int val ) |
772 | { | 772 | { |
773 | #ifdef DESKTOP_VERSION | 773 | #ifdef DESKTOP_VERSION |
774 | mDateScrollBar->setLineStep ( val ); | 774 | mDateScrollBar->setLineStep ( val ); |
775 | #endif | 775 | #endif |
776 | } | 776 | } |
777 | void CalendarView::scrollBarValue(int val ) | 777 | void CalendarView::scrollBarValue(int val ) |
778 | { | 778 | { |
779 | #ifdef DESKTOP_VERSION | 779 | #ifdef DESKTOP_VERSION |
780 | if ( QApplication::desktop()->width() < 800 ) return; | 780 | if ( QApplication::desktop()->width() < 800 ) return; |
781 | static bool block = false; | 781 | static bool block = false; |
782 | if ( block ) return; | 782 | if ( block ) return; |
783 | block = true; | 783 | block = true; |
784 | int count = mNavigator->selectedDates().count(); | 784 | int count = mNavigator->selectedDates().count(); |
785 | int day = mNavigator->selectedDates().first().dayOfYear(); | 785 | int day = mNavigator->selectedDates().first().dayOfYear(); |
786 | int stepdays = val; | 786 | int stepdays = val; |
787 | if ( mDateScrollBar->lineStep () <= count ) { | 787 | if ( mDateScrollBar->lineStep () <= count ) { |
788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
789 | //qDebug("VAL %d ",val ); | 789 | //qDebug("VAL %d ",val ); |
790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
791 | stepdays = day+stepdays; | 791 | stepdays = day+stepdays; |
792 | if ( stepdays < 0 ) stepdays = 0; | 792 | if ( stepdays < 0 ) stepdays = 0; |
793 | } | 793 | } |
794 | if ( stepdays == day ) { | 794 | if ( stepdays == day ) { |
795 | block = false; | 795 | block = false; |
796 | return; | 796 | return; |
797 | } | 797 | } |
798 | int year = mNavigator->selectedDates().first().year(); | 798 | int year = mNavigator->selectedDates().first().year(); |
799 | QDate d ( year,1,1 ); | 799 | QDate d ( year,1,1 ); |
800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
801 | block = false; | 801 | block = false; |
802 | #endif | 802 | #endif |
803 | 803 | ||
804 | } | 804 | } |
805 | void CalendarView::updateView(const QDate &start, const QDate &end) | 805 | void CalendarView::updateView(const QDate &start, const QDate &end) |
806 | { | 806 | { |
807 | #ifdef DESKTOP_VERSION | 807 | #ifdef DESKTOP_VERSION |
808 | if ( ! mDateScrollBar->draggingSlider () ) { | 808 | if ( ! mDateScrollBar->draggingSlider () ) { |
809 | int dof = start.dayOfYear(); | 809 | int dof = start.dayOfYear(); |
810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
811 | if ( dof != mDateScrollBar->value() ) { | 811 | if ( dof != mDateScrollBar->value() ) { |
812 | mDateScrollBar->blockSignals( true ); | 812 | mDateScrollBar->blockSignals( true ); |
813 | mDateScrollBar->setValue( start.dayOfYear()); | 813 | mDateScrollBar->setValue( start.dayOfYear()); |
814 | mDateScrollBar->blockSignals( false ); | 814 | mDateScrollBar->blockSignals( false ); |
815 | } | 815 | } |
816 | } | 816 | } |
817 | #endif | 817 | #endif |
818 | mTodoList->updateView(); | 818 | mTodoList->updateView(); |
819 | mViewManager->updateView(start, end); | 819 | mViewManager->updateView(start, end); |
820 | //mDateNavigator->updateView(); | 820 | //mDateNavigator->updateView(); |
821 | } | 821 | } |
822 | 822 | ||
823 | 823 | ||
824 | 824 | ||
825 | void CalendarView::checkFiles() | 825 | void CalendarView::checkFiles() |
826 | { | 826 | { |
827 | QString message; | 827 | QString message; |
828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
829 | KopiCalendarFile * cal = calendars.first(); | 829 | KopiCalendarFile * cal = calendars.first(); |
830 | while ( cal ) { | 830 | while ( cal ) { |
831 | if ( cal->mErrorOnLoad ) { | 831 | if ( cal->mErrorOnLoad ) { |
832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
833 | } | 833 | } |
834 | cal = calendars.next(); | 834 | cal = calendars.next(); |
835 | } | 835 | } |
836 | if ( !message.isEmpty() ) { | 836 | if ( !message.isEmpty() ) { |
837 | 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); | 837 | 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); |
838 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 838 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
839 | } | 839 | } |
840 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 840 | static bool firstTime = true; |
841 | if ( firstTime ) { | ||
842 | firstTime = false; | ||
843 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | ||
844 | } | ||
841 | } | 845 | } |
842 | void CalendarView::checkAlarms() | 846 | void CalendarView::checkAlarms() |
843 | { | 847 | { |
844 | 848 | ||
845 | 849 | ||
846 | KConfig *config = KOGlobals::config(); | 850 | KConfig *config = KOGlobals::config(); |
847 | config->setGroup( "AppRun" ); | 851 | config->setGroup( "AppRun" ); |
848 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 852 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
849 | int daysto = dt.daysTo( QDate::currentDate() ); | 853 | int daysto = dt.daysTo( QDate::currentDate() ); |
850 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 854 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
851 | dt = dt.addDays( days ); | 855 | dt = dt.addDays( days ); |
852 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 856 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
853 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 857 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
854 | //qDebug("KO: Reading program stop %d ", secs); | 858 | //qDebug("KO: Reading program stop %d ", secs); |
855 | //secs -= ( 3600 * 24*3 ); // debug only | 859 | //secs -= ( 3600 * 24*3 ); // debug only |
856 | QDateTime latest = dt.addSecs ( secs ); | 860 | QDateTime latest = dt.addSecs ( secs ); |
857 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 861 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
858 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 862 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
859 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 863 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
860 | QPtrList<Incidence> al; | 864 | QPtrList<Incidence> al; |
861 | Incidence* inL = el.first(); | 865 | Incidence* inL = el.first(); |
862 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 866 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
863 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 867 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
864 | while ( inL ) { | 868 | while ( inL ) { |
865 | bool ok = false; | 869 | bool ok = false; |
866 | int offset = 0; | 870 | int offset = 0; |
867 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 871 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
868 | if ( ok ) { | 872 | if ( ok ) { |
869 | //qDebug("OK %s",next.toString().latin1()); | 873 | //qDebug("OK %s",next.toString().latin1()); |
870 | if ( next < cur ) { | 874 | if ( next < cur ) { |
871 | al.append( inL ); | 875 | al.append( inL ); |
872 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 876 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
873 | } | 877 | } |
874 | } | 878 | } |
875 | inL = el.next(); | 879 | inL = el.next(); |
876 | } | 880 | } |
877 | if ( al.count() ) { | 881 | if ( al.count() ) { |
878 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 882 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
879 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 883 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
880 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 884 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
881 | lay->setSpacing( 0 ); | 885 | lay->setSpacing( 0 ); |
882 | lay->setMargin( 0 ); | 886 | lay->setMargin( 0 ); |
883 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 887 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
884 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 888 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
885 | lay->addWidget( matb ); | 889 | lay->addWidget( matb ); |
886 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 890 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
887 | int wid = 210; | 891 | int wid = 210; |
888 | int x = QApplication::desktop()->width() - wid - 7; | 892 | int x = QApplication::desktop()->width() - wid - 7; |
889 | int y = QApplication::desktop()->height() - wid - 70; | 893 | int y = QApplication::desktop()->height() - wid - 70; |
890 | dia->setGeometry ( x,y,wid,wid); | 894 | dia->setGeometry ( x,y,wid,wid); |
891 | } else { | 895 | } else { |
892 | int si = 220; | 896 | int si = 220; |
893 | if ( QApplication::desktop()->width() > 470 ) | 897 | if ( QApplication::desktop()->width() > 470 ) |
894 | si = 400; | 898 | si = 400; |
895 | dia->resize(si,si/2); | 899 | dia->resize(si,si/2); |
896 | } | 900 | } |
897 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 901 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
898 | dia->show(); | 902 | dia->show(); |
899 | 903 | ||
900 | } | 904 | } |
901 | } | 905 | } |
902 | void CalendarView::showDay( QDate d ) | 906 | void CalendarView::showDay( QDate d ) |
903 | { | 907 | { |
904 | dateNavigator()->blockSignals( true ); | 908 | dateNavigator()->blockSignals( true ); |
905 | dateNavigator()->selectDate( d ); | 909 | dateNavigator()->selectDate( d ); |
906 | dateNavigator()->blockSignals( false ); | 910 | dateNavigator()->blockSignals( false ); |
907 | mViewManager->showDayView(); | 911 | mViewManager->showDayView(); |
908 | //dateNavigator()->selectDate( d ); | 912 | //dateNavigator()->selectDate( d ); |
909 | } | 913 | } |
910 | void CalendarView::timerAlarm() | 914 | void CalendarView::timerAlarm() |
911 | { | 915 | { |
912 | //qDebug("CalendarView::timerAlarm() "); | 916 | //qDebug("CalendarView::timerAlarm() "); |
913 | computeAlarm(mAlarmNotification ); | 917 | computeAlarm(mAlarmNotification ); |
914 | } | 918 | } |
915 | 919 | ||
916 | void CalendarView::suspendAlarm() | 920 | void CalendarView::suspendAlarm() |
917 | { | 921 | { |
918 | //qDebug(" CalendarView::suspendAlarm() "); | 922 | //qDebug(" CalendarView::suspendAlarm() "); |
919 | computeAlarm(mSuspendAlarmNotification ); | 923 | computeAlarm(mSuspendAlarmNotification ); |
920 | 924 | ||
921 | } | 925 | } |
922 | 926 | ||
923 | void CalendarView::startAlarm( QString mess , QString filename) | 927 | void CalendarView::startAlarm( QString mess , QString filename) |
924 | { | 928 | { |
925 | 929 | ||
926 | topLevelWidget()->showNormal(); | 930 | topLevelWidget()->showNormal(); |
927 | topLevelWidget()->setActiveWindow(); | 931 | topLevelWidget()->setActiveWindow(); |
928 | topLevelWidget()->raise(); | 932 | topLevelWidget()->raise(); |
929 | 933 | ||
930 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 934 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
931 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 935 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
932 | 936 | ||
933 | } | 937 | } |
934 | 938 | ||
935 | void CalendarView::checkNextTimerAlarm() | 939 | void CalendarView::checkNextTimerAlarm() |
936 | { | 940 | { |
937 | mCalendar->checkAlarmForIncidence( 0, true ); | 941 | mCalendar->checkAlarmForIncidence( 0, true ); |
938 | } | 942 | } |
939 | 943 | ||
940 | void CalendarView::computeAlarm( QString msg ) | 944 | void CalendarView::computeAlarm( QString msg ) |
941 | { | 945 | { |
942 | 946 | ||
943 | QString mess = msg; | 947 | QString mess = msg; |
944 | QString mAlarmMessage = mess.mid( 9 ); | 948 | QString mAlarmMessage = mess.mid( 9 ); |
945 | QString filename = MainWindow::resourcePath(); | 949 | QString filename = MainWindow::resourcePath(); |
946 | filename += "koalarm.wav"; | 950 | filename += "koalarm.wav"; |
947 | QString tempfilename; | 951 | QString tempfilename; |
948 | if ( mess.left( 13 ) == "suspend_alarm") { | 952 | if ( mess.left( 13 ) == "suspend_alarm") { |
949 | bool error = false; | 953 | bool error = false; |
950 | int len = mess.mid( 13 ).find("+++"); | 954 | int len = mess.mid( 13 ).find("+++"); |
951 | if ( len < 2 ) | 955 | if ( len < 2 ) |
952 | error = true; | 956 | error = true; |
953 | else { | 957 | else { |
954 | tempfilename = mess.mid( 13, len ); | 958 | tempfilename = mess.mid( 13, len ); |
955 | if ( !QFile::exists( tempfilename ) ) | 959 | if ( !QFile::exists( tempfilename ) ) |
956 | error = true; | 960 | error = true; |
957 | } | 961 | } |
958 | if ( ! error ) { | 962 | if ( ! error ) { |
959 | filename = tempfilename; | 963 | filename = tempfilename; |
960 | } | 964 | } |
961 | mAlarmMessage = mess.mid( 13+len+3 ); | 965 | mAlarmMessage = mess.mid( 13+len+3 ); |
962 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 966 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
963 | startAlarm( mAlarmMessage, filename); | 967 | startAlarm( mAlarmMessage, filename); |
964 | return; | 968 | return; |
965 | } | 969 | } |
966 | if ( mess.left( 11 ) == "timer_alarm") { | 970 | if ( mess.left( 11 ) == "timer_alarm") { |
967 | //mTimerTime = 0; | 971 | //mTimerTime = 0; |
968 | startAlarm( mess.mid( 11 ), filename ); | 972 | startAlarm( mess.mid( 11 ), filename ); |
969 | return; | 973 | return; |
970 | } | 974 | } |
971 | if ( mess.left( 10 ) == "proc_alarm") { | 975 | if ( mess.left( 10 ) == "proc_alarm") { |
972 | bool error = false; | 976 | bool error = false; |
973 | int len = mess.mid( 10 ).find("+++"); | 977 | int len = mess.mid( 10 ).find("+++"); |
974 | if ( len < 2 ) | 978 | if ( len < 2 ) |
975 | error = true; | 979 | error = true; |
976 | else { | 980 | else { |
977 | tempfilename = mess.mid( 10, len ); | 981 | tempfilename = mess.mid( 10, len ); |
978 | if ( !QFile::exists( tempfilename ) ) | 982 | if ( !QFile::exists( tempfilename ) ) |
979 | error = true; | 983 | error = true; |
980 | } | 984 | } |
981 | if ( error ) { | 985 | if ( error ) { |
982 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 986 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
983 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 987 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
984 | } else { | 988 | } else { |
985 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 989 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
986 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 990 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
987 | #ifndef _WIN32_ | 991 | #ifndef _WIN32_ |
988 | if ( vfork () == 0 ) { | 992 | if ( vfork () == 0 ) { |
989 | execl ( tempfilename.latin1(), 0 ); | 993 | execl ( tempfilename.latin1(), 0 ); |
990 | return; | 994 | return; |
991 | } | 995 | } |
992 | #else | 996 | #else |
993 | QProcess* p = new QProcess(); | 997 | QProcess* p = new QProcess(); |
994 | p->addArgument( tempfilename.latin1() ); | 998 | p->addArgument( tempfilename.latin1() ); |
995 | p->start(); | 999 | p->start(); |
996 | return; | 1000 | return; |
997 | #endif | 1001 | #endif |
998 | 1002 | ||
999 | return; | 1003 | return; |
1000 | } | 1004 | } |
1001 | 1005 | ||
1002 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1006 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1003 | } | 1007 | } |
1004 | if ( mess.left( 11 ) == "audio_alarm") { | 1008 | if ( mess.left( 11 ) == "audio_alarm") { |
1005 | bool error = false; | 1009 | bool error = false; |
1006 | int len = mess.mid( 11 ).find("+++"); | 1010 | int len = mess.mid( 11 ).find("+++"); |
1007 | if ( len < 2 ) | 1011 | if ( len < 2 ) |
1008 | error = true; | 1012 | error = true; |
1009 | else { | 1013 | else { |
1010 | tempfilename = mess.mid( 11, len ); | 1014 | tempfilename = mess.mid( 11, len ); |
1011 | if ( !QFile::exists( tempfilename ) ) | 1015 | if ( !QFile::exists( tempfilename ) ) |
1012 | error = true; | 1016 | error = true; |
1013 | } | 1017 | } |
1014 | if ( ! error ) { | 1018 | if ( ! error ) { |
1015 | filename = tempfilename; | 1019 | filename = tempfilename; |
1016 | } | 1020 | } |
1017 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1021 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1018 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1022 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1019 | } | 1023 | } |
1020 | if ( mess.left( 9 ) == "cal_alarm") { | 1024 | if ( mess.left( 9 ) == "cal_alarm") { |
1021 | mAlarmMessage = mess.mid( 9 ) ; | 1025 | mAlarmMessage = mess.mid( 9 ) ; |
1022 | } | 1026 | } |
1023 | 1027 | ||
1024 | startAlarm( mAlarmMessage, filename ); | 1028 | startAlarm( mAlarmMessage, filename ); |
1025 | 1029 | ||
1026 | 1030 | ||
1027 | } | 1031 | } |
1028 | 1032 | ||
1029 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1033 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1030 | { | 1034 | { |
1031 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1035 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1032 | 1036 | ||
1033 | mSuspendAlarmNotification = noti; | 1037 | mSuspendAlarmNotification = noti; |
1034 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1038 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1035 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1039 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1036 | mSuspendTimer->start( ms , true ); | 1040 | mSuspendTimer->start( ms , true ); |
1037 | 1041 | ||
1038 | } | 1042 | } |
1039 | 1043 | ||
1040 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1044 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1041 | { | 1045 | { |
1042 | mNextAlarmDateTime = qdt; | 1046 | mNextAlarmDateTime = qdt; |
1043 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1047 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1044 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1048 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1045 | #ifndef DESKTOP_VERSION | 1049 | #ifndef DESKTOP_VERSION |
1046 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1050 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1047 | #endif | 1051 | #endif |
1048 | return; | 1052 | return; |
1049 | } | 1053 | } |
1050 | int maxSec; | 1054 | int maxSec; |
1051 | //maxSec = 5; //testing only | 1055 | //maxSec = 5; //testing only |
1052 | maxSec = 86400+3600; // one day+1hour | 1056 | maxSec = 86400+3600; // one day+1hour |
1053 | mAlarmNotification = noti; | 1057 | mAlarmNotification = noti; |
1054 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1058 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1055 | if ( sec > maxSec ) { | 1059 | if ( sec > maxSec ) { |
1056 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1060 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1057 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1061 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1058 | return; | 1062 | return; |
1059 | } else { | 1063 | } else { |
1060 | mRecheckAlarmTimer->stop(); | 1064 | mRecheckAlarmTimer->stop(); |
1061 | } | 1065 | } |
1062 | //qDebug("Alarm timer started with secs: %d ", sec); | 1066 | //qDebug("Alarm timer started with secs: %d ", sec); |
1063 | mAlarmTimer->start( sec *1000 , true ); | 1067 | mAlarmTimer->start( sec *1000 , true ); |
1064 | 1068 | ||
1065 | } | 1069 | } |
1066 | // called by mRecheckAlarmTimer to get next alarm | 1070 | // called by mRecheckAlarmTimer to get next alarm |
1067 | // we need this, because a QTimer has only a max range of 25 days | 1071 | // we need this, because a QTimer has only a max range of 25 days |
1068 | void CalendarView::recheckTimerAlarm() | 1072 | void CalendarView::recheckTimerAlarm() |
1069 | { | 1073 | { |
1070 | mAlarmTimer->stop(); | 1074 | mAlarmTimer->stop(); |
1071 | mRecheckAlarmTimer->stop(); | 1075 | mRecheckAlarmTimer->stop(); |
1072 | mCalendar->checkAlarmForIncidence( 0, true ); | 1076 | mCalendar->checkAlarmForIncidence( 0, true ); |
1073 | } | 1077 | } |
1074 | #ifndef DESKTOP_VERSION | 1078 | #ifndef DESKTOP_VERSION |
1075 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1079 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1076 | #else | 1080 | #else |
1077 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1081 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1078 | #endif | 1082 | #endif |
1079 | { | 1083 | { |
1080 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1084 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1081 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1085 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1082 | #ifndef DESKTOP_VERSION | 1086 | #ifndef DESKTOP_VERSION |
1083 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1087 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1084 | #endif | 1088 | #endif |
1085 | return; | 1089 | return; |
1086 | } | 1090 | } |
1087 | mAlarmTimer->stop(); | 1091 | mAlarmTimer->stop(); |
1088 | } | 1092 | } |
1089 | void CalendarView::selectWeekNum ( int num ) | 1093 | void CalendarView::selectWeekNum ( int num ) |
1090 | { | 1094 | { |
1091 | dateNavigator()->blockSignals( true ); | 1095 | dateNavigator()->blockSignals( true ); |
1092 | dateNavigator()->selectWeek( num ); | 1096 | dateNavigator()->selectWeek( num ); |
1093 | dateNavigator()->blockSignals( false ); | 1097 | dateNavigator()->blockSignals( false ); |
1094 | mViewManager->showWeekView(); | 1098 | mViewManager->showWeekView(); |
1095 | } | 1099 | } |
1096 | KOViewManager *CalendarView::viewManager() | 1100 | KOViewManager *CalendarView::viewManager() |
1097 | { | 1101 | { |
1098 | return mViewManager; | 1102 | return mViewManager; |
1099 | } | 1103 | } |
1100 | 1104 | ||
1101 | KODialogManager *CalendarView::dialogManager() | 1105 | KODialogManager *CalendarView::dialogManager() |
1102 | { | 1106 | { |
1103 | return mDialogManager; | 1107 | return mDialogManager; |
1104 | } | 1108 | } |
1105 | 1109 | ||
1106 | QDate CalendarView::startDate() | 1110 | QDate CalendarView::startDate() |
1107 | { | 1111 | { |
1108 | DateList dates = mNavigator->selectedDates(); | 1112 | DateList dates = mNavigator->selectedDates(); |
1109 | 1113 | ||
1110 | return dates.first(); | 1114 | return dates.first(); |
1111 | } | 1115 | } |
1112 | 1116 | ||
1113 | QDate CalendarView::endDate() | 1117 | QDate CalendarView::endDate() |
1114 | { | 1118 | { |
1115 | DateList dates = mNavigator->selectedDates(); | 1119 | DateList dates = mNavigator->selectedDates(); |
1116 | 1120 | ||
1117 | return dates.last(); | 1121 | return dates.last(); |
1118 | } | 1122 | } |
1119 | 1123 | ||
1120 | 1124 | ||
1121 | void CalendarView::createPrinter() | 1125 | void CalendarView::createPrinter() |
1122 | { | 1126 | { |
1123 | #ifndef KORG_NOPRINTER | 1127 | #ifndef KORG_NOPRINTER |
1124 | if (!mCalPrinter) { | 1128 | if (!mCalPrinter) { |
1125 | mCalPrinter = new CalPrinter(this, mCalendar); | 1129 | mCalPrinter = new CalPrinter(this, mCalendar); |
1126 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1130 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1127 | } | 1131 | } |
1128 | #endif | 1132 | #endif |
1129 | } | 1133 | } |
1130 | 1134 | ||
1131 | 1135 | ||
1132 | //KOPrefs::instance()->mWriteBackFile | 1136 | //KOPrefs::instance()->mWriteBackFile |
1133 | //KOPrefs::instance()->mWriteBackExistingOnly | 1137 | //KOPrefs::instance()->mWriteBackExistingOnly |
1134 | 1138 | ||
1135 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1139 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1136 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1140 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1137 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1141 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1138 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1142 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1139 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1143 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1140 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1144 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1141 | 1145 | ||
1142 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1146 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1143 | { | 1147 | { |
1144 | 1148 | ||
1145 | // 0 equal | 1149 | // 0 equal |
1146 | // 1 take local | 1150 | // 1 take local |
1147 | // 2 take remote | 1151 | // 2 take remote |
1148 | // 3 cancel | 1152 | // 3 cancel |
1149 | QDateTime lastSync = mLastCalendarSync; | 1153 | QDateTime lastSync = mLastCalendarSync; |
1150 | QDateTime localMod = local->lastModified(); | 1154 | QDateTime localMod = local->lastModified(); |
1151 | QDateTime remoteMod = remote->lastModified(); | 1155 | QDateTime remoteMod = remote->lastModified(); |
1152 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1156 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1153 | bool remCh, locCh; | 1157 | bool remCh, locCh; |
1154 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1158 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1155 | //if ( remCh ) | 1159 | //if ( remCh ) |
1156 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1160 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1157 | locCh = ( localMod > mLastCalendarSync ); | 1161 | locCh = ( localMod > mLastCalendarSync ); |
1158 | if ( !remCh && ! locCh ) { | 1162 | if ( !remCh && ! locCh ) { |
1159 | //qDebug("both not changed "); | 1163 | //qDebug("both not changed "); |
1160 | lastSync = localMod.addDays(1); | 1164 | lastSync = localMod.addDays(1); |
1161 | if ( mode <= SYNC_PREF_ASK ) | 1165 | if ( mode <= SYNC_PREF_ASK ) |
1162 | return 0; | 1166 | return 0; |
1163 | } else { | 1167 | } else { |
1164 | if ( locCh ) { | 1168 | if ( locCh ) { |
1165 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1169 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1166 | lastSync = localMod.addDays( -1 ); | 1170 | lastSync = localMod.addDays( -1 ); |
1167 | if ( !remCh ) | 1171 | if ( !remCh ) |
1168 | remoteMod = ( lastSync.addDays( -1 ) ); | 1172 | remoteMod = ( lastSync.addDays( -1 ) ); |
1169 | } else { | 1173 | } else { |
1170 | //qDebug(" not loc changed "); | 1174 | //qDebug(" not loc changed "); |
1171 | lastSync = localMod.addDays( 1 ); | 1175 | lastSync = localMod.addDays( 1 ); |
1172 | if ( remCh ) | 1176 | if ( remCh ) |
1173 | remoteMod =( lastSync.addDays( 1 ) ); | 1177 | remoteMod =( lastSync.addDays( 1 ) ); |
1174 | 1178 | ||
1175 | } | 1179 | } |
1176 | } | 1180 | } |
1177 | full = true; | 1181 | full = true; |
1178 | if ( mode < SYNC_PREF_ASK ) | 1182 | if ( mode < SYNC_PREF_ASK ) |
1179 | mode = SYNC_PREF_ASK; | 1183 | mode = SYNC_PREF_ASK; |
1180 | } else { | 1184 | } else { |
1181 | if ( localMod == remoteMod ) | 1185 | if ( localMod == remoteMod ) |
1182 | // if ( local->revision() == remote->revision() ) | 1186 | // if ( local->revision() == remote->revision() ) |
1183 | return 0; | 1187 | return 0; |
1184 | 1188 | ||
1185 | } | 1189 | } |
1186 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1190 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1187 | 1191 | ||
1188 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1192 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1189 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1193 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1190 | //full = true; //debug only | 1194 | //full = true; //debug only |
1191 | if ( full ) { | 1195 | if ( full ) { |
1192 | bool equ = false; | 1196 | bool equ = false; |
1193 | if ( local->typeID() == eventID ) { | 1197 | if ( local->typeID() == eventID ) { |
1194 | equ = (*((Event*) local) == *((Event*) remote)); | 1198 | equ = (*((Event*) local) == *((Event*) remote)); |
1195 | } | 1199 | } |
1196 | else if ( local->typeID() == todoID ) | 1200 | else if ( local->typeID() == todoID ) |
1197 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1201 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1198 | else if ( local->typeID() == journalID ) | 1202 | else if ( local->typeID() == journalID ) |
1199 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1203 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1200 | if ( equ ) { | 1204 | if ( equ ) { |
1201 | //qDebug("equal "); | 1205 | //qDebug("equal "); |
1202 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1206 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1203 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1207 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1204 | } | 1208 | } |
1205 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1209 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1206 | return 0; | 1210 | return 0; |
1207 | 1211 | ||
1208 | }//else //debug only | 1212 | }//else //debug only |
1209 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1213 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1210 | } | 1214 | } |
1211 | int result; | 1215 | int result; |
1212 | bool localIsNew; | 1216 | bool localIsNew; |
1213 | //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() ); | 1217 | //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() ); |
1214 | 1218 | ||
1215 | 1219 | ||
1216 | // ************************************************ | 1220 | // ************************************************ |
1217 | // ************************************************ | 1221 | // ************************************************ |
1218 | // ************************************************ | 1222 | // ************************************************ |
1219 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1223 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1220 | // BUT remoteMod != localMod | 1224 | // BUT remoteMod != localMod |
1221 | 1225 | ||
1222 | 1226 | ||
1223 | if ( full && mode < SYNC_PREF_NEWEST ) | 1227 | if ( full && mode < SYNC_PREF_NEWEST ) |
1224 | mode = SYNC_PREF_ASK; | 1228 | mode = SYNC_PREF_ASK; |
1225 | 1229 | ||
1226 | switch( mode ) { | 1230 | switch( mode ) { |
1227 | case SYNC_PREF_LOCAL: | 1231 | case SYNC_PREF_LOCAL: |
1228 | if ( lastSync > remoteMod ) | 1232 | if ( lastSync > remoteMod ) |
1229 | return 1; | 1233 | return 1; |
1230 | if ( lastSync > localMod ) | 1234 | if ( lastSync > localMod ) |
1231 | return 2; | 1235 | return 2; |
1232 | return 1; | 1236 | return 1; |
1233 | break; | 1237 | break; |
1234 | case SYNC_PREF_REMOTE: | 1238 | case SYNC_PREF_REMOTE: |
1235 | if ( lastSync > localMod ) | 1239 | if ( lastSync > localMod ) |
1236 | return 2; | 1240 | return 2; |
1237 | if ( lastSync > remoteMod ) | 1241 | if ( lastSync > remoteMod ) |
1238 | return 1; | 1242 | return 1; |
1239 | return 2; | 1243 | return 2; |
1240 | break; | 1244 | break; |
1241 | case SYNC_PREF_NEWEST: | 1245 | case SYNC_PREF_NEWEST: |
1242 | if ( localMod >= remoteMod ) | 1246 | if ( localMod >= remoteMod ) |
1243 | return 1; | 1247 | return 1; |
1244 | else | 1248 | else |
1245 | return 2; | 1249 | return 2; |
1246 | break; | 1250 | break; |
1247 | case SYNC_PREF_ASK: | 1251 | case SYNC_PREF_ASK: |
1248 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1252 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1249 | if ( lastSync > remoteMod && lastSync > localMod) | 1253 | if ( lastSync > remoteMod && lastSync > localMod) |
1250 | return 0; | 1254 | return 0; |
1251 | if ( lastSync > remoteMod ) | 1255 | if ( lastSync > remoteMod ) |
1252 | return 1; | 1256 | return 1; |
1253 | if ( lastSync > localMod ) | 1257 | if ( lastSync > localMod ) |
1254 | return 2; | 1258 | return 2; |
1255 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1259 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1256 | localIsNew = localMod >= remoteMod; | 1260 | localIsNew = localMod >= remoteMod; |
1257 | if ( localIsNew ) | 1261 | if ( localIsNew ) |
1258 | getEventViewerDialog()->setColorMode( 1 ); | 1262 | getEventViewerDialog()->setColorMode( 1 ); |
1259 | else | 1263 | else |
1260 | getEventViewerDialog()->setColorMode( 2 ); | 1264 | getEventViewerDialog()->setColorMode( 2 ); |
1261 | getEventViewerDialog()->setIncidence(local); | 1265 | getEventViewerDialog()->setIncidence(local); |
1262 | if ( localIsNew ) | 1266 | if ( localIsNew ) |
1263 | getEventViewerDialog()->setColorMode( 2 ); | 1267 | getEventViewerDialog()->setColorMode( 2 ); |
1264 | else | 1268 | else |
1265 | getEventViewerDialog()->setColorMode( 1 ); | 1269 | getEventViewerDialog()->setColorMode( 1 ); |
1266 | getEventViewerDialog()->addIncidence(remote); | 1270 | getEventViewerDialog()->addIncidence(remote); |
1267 | getEventViewerDialog()->setColorMode( 0 ); | 1271 | getEventViewerDialog()->setColorMode( 0 ); |
1268 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1272 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1269 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1273 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1270 | getEventViewerDialog()->showMe(); | 1274 | getEventViewerDialog()->showMe(); |
1271 | result = getEventViewerDialog()->executeS( localIsNew ); | 1275 | result = getEventViewerDialog()->executeS( localIsNew ); |
1272 | return result; | 1276 | return result; |
1273 | 1277 | ||
1274 | break; | 1278 | break; |
1275 | case SYNC_PREF_FORCE_LOCAL: | 1279 | case SYNC_PREF_FORCE_LOCAL: |
1276 | return 1; | 1280 | return 1; |
1277 | break; | 1281 | break; |
1278 | case SYNC_PREF_FORCE_REMOTE: | 1282 | case SYNC_PREF_FORCE_REMOTE: |
1279 | return 2; | 1283 | return 2; |
1280 | break; | 1284 | break; |
1281 | 1285 | ||
1282 | default: | 1286 | default: |
1283 | // SYNC_PREF_TAKE_BOTH not implemented | 1287 | // SYNC_PREF_TAKE_BOTH not implemented |
1284 | break; | 1288 | break; |
1285 | } | 1289 | } |
1286 | return 0; | 1290 | return 0; |
1287 | } | 1291 | } |
1288 | Event* CalendarView::getLastSyncEvent() | 1292 | Event* CalendarView::getLastSyncEvent() |
1289 | { | 1293 | { |
1290 | Event* lse; | 1294 | Event* lse; |
1291 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1295 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1292 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1296 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1293 | if (!lse) { | 1297 | if (!lse) { |
1294 | lse = new Event(); | 1298 | lse = new Event(); |
1295 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1299 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1296 | QString sum = ""; | 1300 | QString sum = ""; |
1297 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1301 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1298 | sum = "E: "; | 1302 | sum = "E: "; |
1299 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1303 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1300 | lse->setDtStart( mLastCalendarSync ); | 1304 | lse->setDtStart( mLastCalendarSync ); |
1301 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1305 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1302 | lse->setCategories( i18n("SyncEvent") ); | 1306 | lse->setCategories( i18n("SyncEvent") ); |
1303 | lse->setReadOnly( true ); | 1307 | lse->setReadOnly( true ); |
1304 | mCalendar->addEvent( lse ); | 1308 | mCalendar->addEvent( lse ); |
1305 | } | 1309 | } |
1306 | 1310 | ||
1307 | return lse; | 1311 | return lse; |
1308 | 1312 | ||
1309 | } | 1313 | } |
1310 | 1314 | ||
1311 | // we check, if the to delete event has a id for a profile | 1315 | // we check, if the to delete event has a id for a profile |
1312 | // if yes, we set this id in the profile to delete | 1316 | // if yes, we set this id in the profile to delete |
1313 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1317 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1314 | { | 1318 | { |
1315 | if ( lastSync.count() == 0 ) { | 1319 | if ( lastSync.count() == 0 ) { |
1316 | //qDebug(" lastSync.count() == 0"); | 1320 | //qDebug(" lastSync.count() == 0"); |
1317 | return; | 1321 | return; |
1318 | } | 1322 | } |
1319 | if ( toDelete->typeID() == journalID ) | 1323 | if ( toDelete->typeID() == journalID ) |
1320 | return; | 1324 | return; |
1321 | 1325 | ||
1322 | Event* eve = lastSync.first(); | 1326 | Event* eve = lastSync.first(); |
1323 | 1327 | ||
1324 | while ( eve ) { | 1328 | while ( eve ) { |
1325 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1329 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1326 | if ( !id.isEmpty() ) { | 1330 | if ( !id.isEmpty() ) { |
1327 | QString des = eve->description(); | 1331 | QString des = eve->description(); |
1328 | QString pref = "e"; | 1332 | QString pref = "e"; |
1329 | if ( toDelete->typeID() == todoID ) | 1333 | if ( toDelete->typeID() == todoID ) |
1330 | pref = "t"; | 1334 | pref = "t"; |
1331 | des += pref+ id + ","; | 1335 | des += pref+ id + ","; |
1332 | eve->setReadOnly( false ); | 1336 | eve->setReadOnly( false ); |
1333 | eve->setDescription( des ); | 1337 | eve->setDescription( des ); |
1334 | //qDebug("setdes %s ", des.latin1()); | 1338 | //qDebug("setdes %s ", des.latin1()); |
1335 | eve->setReadOnly( true ); | 1339 | eve->setReadOnly( true ); |
1336 | } | 1340 | } |
1337 | eve = lastSync.next(); | 1341 | eve = lastSync.next(); |
1338 | } | 1342 | } |
1339 | 1343 | ||
1340 | } | 1344 | } |
1341 | void CalendarView::checkExternalId( Incidence * inc ) | 1345 | void CalendarView::checkExternalId( Incidence * inc ) |
1342 | { | 1346 | { |
1343 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1347 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1344 | checkExternSyncEvent( lastSync, inc ); | 1348 | checkExternSyncEvent( lastSync, inc ); |
1345 | 1349 | ||
1346 | } | 1350 | } |
1347 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1351 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1348 | { | 1352 | { |
1349 | bool syncOK = true; | 1353 | bool syncOK = true; |
1350 | int addedEvent = 0; | 1354 | int addedEvent = 0; |
1351 | int addedEventR = 0; | 1355 | int addedEventR = 0; |
1352 | int deletedEventR = 0; | 1356 | int deletedEventR = 0; |
1353 | int deletedEventL = 0; | 1357 | int deletedEventL = 0; |
1354 | int changedLocal = 0; | 1358 | int changedLocal = 0; |
1355 | int changedRemote = 0; | 1359 | int changedRemote = 0; |
1356 | int filteredIN = 0; | 1360 | int filteredIN = 0; |
1357 | int filteredOUT = 0; | 1361 | int filteredOUT = 0; |
1358 | //QPtrList<Event> el = local->rawEvents(); | 1362 | //QPtrList<Event> el = local->rawEvents(); |
1359 | Event* eventR; | 1363 | Event* eventR; |
1360 | QString uid; | 1364 | QString uid; |
1361 | int take; | 1365 | int take; |
1362 | Event* eventRSync; | 1366 | Event* eventRSync; |
1363 | Event* eventLSync; | 1367 | Event* eventLSync; |
1364 | clearAllViews(); | 1368 | clearAllViews(); |
1365 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1369 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1366 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1370 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1367 | bool fullDateRange = false; | 1371 | bool fullDateRange = false; |
1368 | local->resetTempSyncStat(); | 1372 | local->resetTempSyncStat(); |
1369 | mLastCalendarSync = QDateTime::currentDateTime(); | 1373 | mLastCalendarSync = QDateTime::currentDateTime(); |
1370 | if ( mSyncManager->syncWithDesktop() ) { | 1374 | if ( mSyncManager->syncWithDesktop() ) { |
1371 | remote->resetPilotStat(1); | 1375 | remote->resetPilotStat(1); |
1372 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1376 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1373 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1377 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1374 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1378 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1375 | } else { | 1379 | } else { |
1376 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1380 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1377 | } | 1381 | } |
1378 | } | 1382 | } |
1379 | QDateTime modifiedCalendar = mLastCalendarSync; | 1383 | QDateTime modifiedCalendar = mLastCalendarSync; |
1380 | eventLSync = getLastSyncEvent(); | 1384 | eventLSync = getLastSyncEvent(); |
1381 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1385 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1382 | if ( eventR ) { | 1386 | if ( eventR ) { |
1383 | qDebug("last-syncEvent on remote found "); | 1387 | qDebug("last-syncEvent on remote found "); |
1384 | eventRSync = (Event*) eventR->clone(); | 1388 | eventRSync = (Event*) eventR->clone(); |
1385 | remote->deleteEvent(eventR ); | 1389 | remote->deleteEvent(eventR ); |
1386 | 1390 | ||
1387 | } else { | 1391 | } else { |
1388 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1392 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1389 | eventRSync = (Event*)eventLSync->clone(); | 1393 | eventRSync = (Event*)eventLSync->clone(); |
1390 | } else { | 1394 | } else { |
1391 | fullDateRange = true; | 1395 | fullDateRange = true; |
1392 | eventRSync = new Event(); | 1396 | eventRSync = new Event(); |
1393 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1397 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1394 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1398 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1395 | eventRSync->setDtStart( mLastCalendarSync ); | 1399 | eventRSync->setDtStart( mLastCalendarSync ); |
1396 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1400 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1397 | eventRSync->setCategories( i18n("SyncEvent") ); | 1401 | eventRSync->setCategories( i18n("SyncEvent") ); |
1398 | } | 1402 | } |
1399 | } | 1403 | } |
1400 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1404 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1401 | fullDateRange = true; | 1405 | fullDateRange = true; |
1402 | 1406 | ||
1403 | if ( ! fullDateRange ) { | 1407 | if ( ! fullDateRange ) { |
1404 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1408 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1405 | 1409 | ||
1406 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1410 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1407 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1411 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1408 | fullDateRange = true; | 1412 | fullDateRange = true; |
1409 | } | 1413 | } |
1410 | } | 1414 | } |
1411 | if ( mSyncManager->syncWithDesktop() ) { | 1415 | if ( mSyncManager->syncWithDesktop() ) { |
1412 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1416 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1413 | } | 1417 | } |
1414 | if ( fullDateRange ) | 1418 | if ( fullDateRange ) |
1415 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1419 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1416 | else | 1420 | else |
1417 | mLastCalendarSync = eventLSync->dtStart(); | 1421 | mLastCalendarSync = eventLSync->dtStart(); |
1418 | // for resyncing if own file has changed | 1422 | // for resyncing if own file has changed |
1419 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1423 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1420 | mLastCalendarSync = loadedFileVersion; | 1424 | mLastCalendarSync = loadedFileVersion; |
1421 | //qDebug("setting mLastCalendarSync "); | 1425 | //qDebug("setting mLastCalendarSync "); |
1422 | } | 1426 | } |
1423 | //qDebug("*************************** "); | 1427 | //qDebug("*************************** "); |
1424 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1428 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1425 | QPtrList<Incidence> er = remote->rawIncidences(); | 1429 | QPtrList<Incidence> er = remote->rawIncidences(); |
1426 | Incidence* inR = er.first(); | 1430 | Incidence* inR = er.first(); |
1427 | Incidence* inL; | 1431 | Incidence* inL; |
1428 | QProgressBar bar( er.count(),0 ); | 1432 | QProgressBar bar( er.count(),0 ); |
1429 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1433 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1430 | 1434 | ||
1431 | // ************** setting up filter ************* | 1435 | // ************** setting up filter ************* |
1432 | CalFilter *filterIN = 0; | 1436 | CalFilter *filterIN = 0; |
1433 | CalFilter *filterOUT = 0; | 1437 | CalFilter *filterOUT = 0; |
1434 | CalFilter *filter = mFilters.first(); | 1438 | CalFilter *filter = mFilters.first(); |
1435 | while(filter) { | 1439 | while(filter) { |
1436 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1440 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1437 | filterIN = filter; | 1441 | filterIN = filter; |
1438 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1442 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1439 | filterOUT = filter; | 1443 | filterOUT = filter; |
1440 | filter = mFilters.next(); | 1444 | filter = mFilters.next(); |
1441 | } | 1445 | } |
1442 | int w = 300; | 1446 | int w = 300; |
1443 | if ( QApplication::desktop()->width() < 320 ) | 1447 | if ( QApplication::desktop()->width() < 320 ) |
1444 | w = 220; | 1448 | w = 220; |
1445 | int h = bar.sizeHint().height() ; | 1449 | int h = bar.sizeHint().height() ; |
1446 | int dw = QApplication::desktop()->width(); | 1450 | int dw = QApplication::desktop()->width(); |
1447 | int dh = QApplication::desktop()->height(); | 1451 | int dh = QApplication::desktop()->height(); |
1448 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1452 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1449 | bar.show(); | 1453 | bar.show(); |
1450 | int modulo = (er.count()/10)+1; | 1454 | int modulo = (er.count()/10)+1; |
1451 | int incCounter = 0; | 1455 | int incCounter = 0; |
1452 | while ( inR ) { | 1456 | while ( inR ) { |
1453 | if ( ! bar.isVisible() ) | 1457 | if ( ! bar.isVisible() ) |
1454 | return false; | 1458 | return false; |
1455 | if ( incCounter % modulo == 0 ) | 1459 | if ( incCounter % modulo == 0 ) |
1456 | bar.setProgress( incCounter ); | 1460 | bar.setProgress( incCounter ); |
1457 | ++incCounter; | 1461 | ++incCounter; |
1458 | uid = inR->uid(); | 1462 | uid = inR->uid(); |
1459 | bool skipIncidence = false; | 1463 | bool skipIncidence = false; |
1460 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1464 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1461 | skipIncidence = true; | 1465 | skipIncidence = true; |
1462 | QString idS; | 1466 | QString idS; |
1463 | qApp->processEvents(); | 1467 | qApp->processEvents(); |
1464 | if ( !skipIncidence ) { | 1468 | if ( !skipIncidence ) { |
1465 | inL = local->incidenceForUid( uid , false ); | 1469 | inL = local->incidenceForUid( uid , false ); |
1466 | if ( inL ) { // maybe conflict - same uid in both calendars | 1470 | if ( inL ) { // maybe conflict - same uid in both calendars |
1467 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1471 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1468 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1472 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1469 | if ( take == 3 ) | 1473 | if ( take == 3 ) |
1470 | return false; | 1474 | return false; |
1471 | if ( take == 1 ) {// take local ********************** | 1475 | if ( take == 1 ) {// take local ********************** |
1472 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1476 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1473 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1477 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1474 | else | 1478 | else |
1475 | idS = inR->IDStr(); | 1479 | idS = inR->IDStr(); |
1476 | int calID = inR->calID(); | 1480 | int calID = inR->calID(); |
1477 | remote->deleteIncidence( inR ); | 1481 | remote->deleteIncidence( inR ); |
1478 | inR = inL->clone(); | 1482 | inR = inL->clone(); |
1479 | inR->setCalID( calID ); | 1483 | inR->setCalID( calID ); |
1480 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1484 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1481 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1485 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1482 | inR->setIDStr( idS ); | 1486 | inR->setIDStr( idS ); |
1483 | remote->addIncidence( inR ); | 1487 | remote->addIncidence( inR ); |
1484 | if ( mSyncManager->syncWithDesktop() ) | 1488 | if ( mSyncManager->syncWithDesktop() ) |
1485 | inR->setPilotId( 2 ); | 1489 | inR->setPilotId( 2 ); |
1486 | ++changedRemote; | 1490 | ++changedRemote; |
1487 | } else {// take remote ********************** | 1491 | } else {// take remote ********************** |
1488 | if ( !inL->isReadOnly() ) { | 1492 | if ( !inL->isReadOnly() ) { |
1489 | idS = inL->IDStr(); | 1493 | idS = inL->IDStr(); |
1490 | int pid = inL->pilotId(); | 1494 | int pid = inL->pilotId(); |
1491 | int calID = inL->calID(); | 1495 | int calID = inL->calID(); |
1492 | local->deleteIncidence( inL ); | 1496 | local->deleteIncidence( inL ); |
1493 | inL = inR->clone(); | 1497 | inL = inR->clone(); |
1494 | inL->setCalID( calID ); | 1498 | inL->setCalID( calID ); |
1495 | if ( mSyncManager->syncWithDesktop() ) | 1499 | if ( mSyncManager->syncWithDesktop() ) |
1496 | inL->setPilotId( pid ); | 1500 | inL->setPilotId( pid ); |
1497 | inL->setIDStr( idS ); | 1501 | inL->setIDStr( idS ); |
1498 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1502 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1499 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1503 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1500 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1504 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1501 | } | 1505 | } |
1502 | local->addIncidence( inL ); | 1506 | local->addIncidence( inL ); |
1503 | ++changedLocal; | 1507 | ++changedLocal; |
1504 | } | 1508 | } |
1505 | } | 1509 | } |
1506 | } | 1510 | } |
1507 | } else { // no conflict ********** add or delete remote | 1511 | } else { // no conflict ********** add or delete remote |
1508 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1512 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1509 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1513 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1510 | QString des = eventLSync->description(); | 1514 | QString des = eventLSync->description(); |
1511 | QString pref = "e"; | 1515 | QString pref = "e"; |
1512 | if ( inR->typeID() == todoID ) | 1516 | if ( inR->typeID() == todoID ) |
1513 | pref = "t"; | 1517 | pref = "t"; |
1514 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1518 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1515 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1519 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1516 | //remote->deleteIncidence( inR ); | 1520 | //remote->deleteIncidence( inR ); |
1517 | ++deletedEventR; | 1521 | ++deletedEventR; |
1518 | } else { | 1522 | } else { |
1519 | inR->setLastModified( modifiedCalendar ); | 1523 | inR->setLastModified( modifiedCalendar ); |
1520 | inL = inR->clone(); | 1524 | inL = inR->clone(); |
1521 | inL->setIDStr( ":" ); | 1525 | inL->setIDStr( ":" ); |
1522 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1526 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1523 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1527 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1524 | 1528 | ||
1525 | inL->setCalID( 0 );// add to default cal | 1529 | inL->setCalID( 0 );// add to default cal |
1526 | local->addIncidence( inL ); | 1530 | local->addIncidence( inL ); |
1527 | ++addedEvent; | 1531 | ++addedEvent; |
1528 | 1532 | ||
1529 | } | 1533 | } |
1530 | } else { | 1534 | } else { |
1531 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1535 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1532 | inR->setLastModified( modifiedCalendar ); | 1536 | inR->setLastModified( modifiedCalendar ); |
1533 | inL = inR->clone(); | 1537 | inL = inR->clone(); |
1534 | inL->setIDStr( ":" ); | 1538 | inL->setIDStr( ":" ); |
1535 | inL->setCalID( 0 );// add to default cal | 1539 | inL->setCalID( 0 );// add to default cal |
1536 | local->addIncidence( inL ); | 1540 | local->addIncidence( inL ); |
1537 | ++addedEvent; | 1541 | ++addedEvent; |
1538 | 1542 | ||
1539 | } else { | 1543 | } else { |
1540 | checkExternSyncEvent(eventRSyncSharp, inR); | 1544 | checkExternSyncEvent(eventRSyncSharp, inR); |
1541 | remote->deleteIncidence( inR ); | 1545 | remote->deleteIncidence( inR ); |
1542 | ++deletedEventR; | 1546 | ++deletedEventR; |
1543 | } | 1547 | } |
1544 | } | 1548 | } |
1545 | } else { | 1549 | } else { |
1546 | ++filteredIN; | 1550 | ++filteredIN; |
1547 | } | 1551 | } |
1548 | } | 1552 | } |
1549 | } | 1553 | } |
1550 | inR = er.next(); | 1554 | inR = er.next(); |
1551 | } | 1555 | } |
1552 | QPtrList<Incidence> el = local->rawIncidences(); | 1556 | QPtrList<Incidence> el = local->rawIncidences(); |
1553 | inL = el.first(); | 1557 | inL = el.first(); |
1554 | modulo = (el.count()/10)+1; | 1558 | modulo = (el.count()/10)+1; |
1555 | bar.setCaption (i18n("Add / remove events") ); | 1559 | bar.setCaption (i18n("Add / remove events") ); |
1556 | bar.setTotalSteps ( el.count() ) ; | 1560 | bar.setTotalSteps ( el.count() ) ; |
1557 | bar.show(); | 1561 | bar.show(); |
1558 | incCounter = 0; | 1562 | incCounter = 0; |
1559 | 1563 | ||
1560 | while ( inL ) { | 1564 | while ( inL ) { |
1561 | 1565 | ||
1562 | qApp->processEvents(); | 1566 | qApp->processEvents(); |
1563 | if ( ! bar.isVisible() ) | 1567 | if ( ! bar.isVisible() ) |
1564 | return false; | 1568 | return false; |
1565 | if ( incCounter % modulo == 0 ) | 1569 | if ( incCounter % modulo == 0 ) |
1566 | bar.setProgress( incCounter ); | 1570 | bar.setProgress( incCounter ); |
1567 | ++incCounter; | 1571 | ++incCounter; |
1568 | uid = inL->uid(); | 1572 | uid = inL->uid(); |
1569 | bool skipIncidence = false; | 1573 | bool skipIncidence = false; |
1570 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1574 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1571 | skipIncidence = true; | 1575 | skipIncidence = true; |
1572 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1576 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1573 | skipIncidence = true; | 1577 | skipIncidence = true; |
1574 | if ( !skipIncidence ) { | 1578 | if ( !skipIncidence ) { |
1575 | inR = remote->incidenceForUid( uid , true ); | 1579 | inR = remote->incidenceForUid( uid , true ); |
1576 | if ( ! inR ) { | 1580 | if ( ! inR ) { |
1577 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1581 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1578 | // no conflict ********** add or delete local | 1582 | // no conflict ********** add or delete local |
1579 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1583 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1580 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1584 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1581 | checkExternSyncEvent(eventLSyncSharp, inL); | 1585 | checkExternSyncEvent(eventLSyncSharp, inL); |
1582 | local->deleteIncidence( inL ); | 1586 | local->deleteIncidence( inL ); |
1583 | ++deletedEventL; | 1587 | ++deletedEventL; |
1584 | } else { | 1588 | } else { |
1585 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1589 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1586 | inL->removeID(mCurrentSyncDevice ); | 1590 | inL->removeID(mCurrentSyncDevice ); |
1587 | ++addedEventR; | 1591 | ++addedEventR; |
1588 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1592 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1589 | inL->setLastModified( modifiedCalendar ); | 1593 | inL->setLastModified( modifiedCalendar ); |
1590 | inR = inL->clone(); | 1594 | inR = inL->clone(); |
1591 | inR->setIDStr( ":" ); | 1595 | inR->setIDStr( ":" ); |
1592 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1596 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1593 | inR->setCalID( 0 );// add to default cal | 1597 | inR->setCalID( 0 );// add to default cal |
1594 | remote->addIncidence( inR ); | 1598 | remote->addIncidence( inR ); |
1595 | } | 1599 | } |
1596 | } | 1600 | } |
1597 | } else { | 1601 | } else { |
1598 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1602 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1599 | checkExternSyncEvent(eventLSyncSharp, inL); | 1603 | checkExternSyncEvent(eventLSyncSharp, inL); |
1600 | local->deleteIncidence( inL ); | 1604 | local->deleteIncidence( inL ); |
1601 | ++deletedEventL; | 1605 | ++deletedEventL; |
1602 | } else { | 1606 | } else { |
1603 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1607 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1604 | ++addedEventR; | 1608 | ++addedEventR; |
1605 | inL->setLastModified( modifiedCalendar ); | 1609 | inL->setLastModified( modifiedCalendar ); |
1606 | inR = inL->clone(); | 1610 | inR = inL->clone(); |
1607 | inR->setIDStr( ":" ); | 1611 | inR->setIDStr( ":" ); |
1608 | inR->setCalID( 0 );// add to default cal | 1612 | inR->setCalID( 0 );// add to default cal |
1609 | remote->addIncidence( inR ); | 1613 | remote->addIncidence( inR ); |
1610 | } | 1614 | } |
1611 | } | 1615 | } |
1612 | } | 1616 | } |
1613 | } else { | 1617 | } else { |
1614 | ++filteredOUT; | 1618 | ++filteredOUT; |
1615 | } | 1619 | } |
1616 | } | 1620 | } |
1617 | } | 1621 | } |
1618 | inL = el.next(); | 1622 | inL = el.next(); |
1619 | } | 1623 | } |
1620 | int delFut = 0; | 1624 | int delFut = 0; |
1621 | int remRem = 0; | 1625 | int remRem = 0; |
1622 | if ( mSyncManager->mWriteBackInFuture ) { | 1626 | if ( mSyncManager->mWriteBackInFuture ) { |
1623 | er = remote->rawIncidences(); | 1627 | er = remote->rawIncidences(); |
1624 | remRem = er.count(); | 1628 | remRem = er.count(); |
1625 | inR = er.first(); | 1629 | inR = er.first(); |
1626 | QDateTime dt; | 1630 | QDateTime dt; |
1627 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1631 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1628 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1632 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1629 | while ( inR ) { | 1633 | while ( inR ) { |
1630 | if ( inR->typeID() == todoID ) { | 1634 | if ( inR->typeID() == todoID ) { |
1631 | Todo * t = (Todo*)inR; | 1635 | Todo * t = (Todo*)inR; |
1632 | if ( t->hasDueDate() ) | 1636 | if ( t->hasDueDate() ) |
1633 | dt = t->dtDue(); | 1637 | dt = t->dtDue(); |
1634 | else | 1638 | else |
1635 | dt = cur.addSecs( 62 ); | 1639 | dt = cur.addSecs( 62 ); |
1636 | } | 1640 | } |
1637 | else if (inR->typeID() == eventID ) { | 1641 | else if (inR->typeID() == eventID ) { |
1638 | bool ok; | 1642 | bool ok; |
1639 | dt = inR->getNextOccurence( cur, &ok ); | 1643 | dt = inR->getNextOccurence( cur, &ok ); |
1640 | if ( !ok ) | 1644 | if ( !ok ) |
1641 | dt = cur.addSecs( -62 ); | 1645 | dt = cur.addSecs( -62 ); |
1642 | } | 1646 | } |
1643 | else | 1647 | else |
1644 | dt = inR->dtStart(); | 1648 | dt = inR->dtStart(); |
1645 | if ( dt < cur || dt > end ) { | 1649 | if ( dt < cur || dt > end ) { |
1646 | remote->deleteIncidence( inR ); | 1650 | remote->deleteIncidence( inR ); |
1647 | ++delFut; | 1651 | ++delFut; |
1648 | } | 1652 | } |
1649 | inR = er.next(); | 1653 | inR = er.next(); |
1650 | } | 1654 | } |
1651 | } | 1655 | } |
1652 | bar.hide(); | 1656 | bar.hide(); |
1653 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1657 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1654 | eventLSync->setReadOnly( false ); | 1658 | eventLSync->setReadOnly( false ); |
1655 | eventLSync->setDtStart( mLastCalendarSync ); | 1659 | eventLSync->setDtStart( mLastCalendarSync ); |
1656 | eventRSync->setDtStart( mLastCalendarSync ); | 1660 | eventRSync->setDtStart( mLastCalendarSync ); |
1657 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1661 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1658 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1662 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1659 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1663 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1660 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1664 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1661 | eventLSync->setReadOnly( true ); | 1665 | eventLSync->setReadOnly( true ); |
1662 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1666 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1663 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1667 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1664 | remote->addEvent( eventRSync ); | 1668 | remote->addEvent( eventRSync ); |
1665 | else | 1669 | else |
1666 | delete eventRSync; | 1670 | delete eventRSync; |
1667 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1671 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1668 | QString mes; | 1672 | QString mes; |
1669 | 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 ); | 1673 | 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 ); |
1670 | QString delmess; | 1674 | QString delmess; |
1671 | if ( delFut ) { | 1675 | if ( delFut ) { |
1672 | 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); | 1676 | 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); |
1673 | mes += delmess; | 1677 | mes += delmess; |
1674 | } | 1678 | } |
1675 | mes = i18n("Local calendar changed!\n") +mes; | 1679 | mes = i18n("Local calendar changed!\n") +mes; |
1676 | mCalendar->checkAlarmForIncidence( 0, true ); | 1680 | mCalendar->checkAlarmForIncidence( 0, true ); |
1677 | qDebug( mes ); | 1681 | qDebug( mes ); |
1678 | if ( mSyncManager->mShowSyncSummary ) { | 1682 | if ( mSyncManager->mShowSyncSummary ) { |
1679 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1683 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1680 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1684 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1681 | qDebug("KO: WB cancelled "); | 1685 | qDebug("KO: WB cancelled "); |
1682 | mSyncManager->mWriteBackFile = false; | 1686 | mSyncManager->mWriteBackFile = false; |
1683 | return syncOK; | 1687 | return syncOK; |
1684 | } | 1688 | } |
1685 | } | 1689 | } |
1686 | return syncOK; | 1690 | return syncOK; |
1687 | } | 1691 | } |
1688 | 1692 | ||
1689 | void CalendarView::setSyncDevice( QString s ) | 1693 | void CalendarView::setSyncDevice( QString s ) |
1690 | { | 1694 | { |
1691 | mCurrentSyncDevice= s; | 1695 | mCurrentSyncDevice= s; |
1692 | } | 1696 | } |
1693 | void CalendarView::setSyncName( QString s ) | 1697 | void CalendarView::setSyncName( QString s ) |
1694 | { | 1698 | { |
1695 | mCurrentSyncName= s; | 1699 | mCurrentSyncName= s; |
1696 | } | 1700 | } |
1697 | bool CalendarView::syncCalendar(QString filename, int mode) | 1701 | bool CalendarView::syncCalendar(QString filename, int mode) |
1698 | { | 1702 | { |
1699 | //qDebug("syncCalendar %s ", filename.latin1()); | 1703 | //qDebug("syncCalendar %s ", filename.latin1()); |
1700 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1704 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1701 | CalendarLocal* calendar = new CalendarLocal(); | 1705 | CalendarLocal* calendar = new CalendarLocal(); |
1702 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1706 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1703 | FileStorage* storage = new FileStorage( calendar ); | 1707 | FileStorage* storage = new FileStorage( calendar ); |
1704 | bool syncOK = false; | 1708 | bool syncOK = false; |
1705 | storage->setFileName( filename ); | 1709 | storage->setFileName( filename ); |
1706 | // qDebug("loading ... "); | 1710 | // qDebug("loading ... "); |
1707 | if ( storage->load() ) { | 1711 | if ( storage->load() ) { |
1708 | getEventViewerDialog()->setSyncMode( true ); | 1712 | getEventViewerDialog()->setSyncMode( true ); |
1709 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1713 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1710 | getEventViewerDialog()->setSyncMode( false ); | 1714 | getEventViewerDialog()->setSyncMode( false ); |
1711 | if ( syncOK ) { | 1715 | if ( syncOK ) { |
1712 | if ( mSyncManager->mWriteBackFile ) | 1716 | if ( mSyncManager->mWriteBackFile ) |
1713 | { | 1717 | { |
1714 | storage->setSaveFormat( new ICalFormat() ); | 1718 | storage->setSaveFormat( new ICalFormat() ); |
1715 | storage->save(); | 1719 | storage->save(); |
1716 | } | 1720 | } |
1717 | } | 1721 | } |
1718 | setModified( true ); | 1722 | setModified( true ); |
1719 | } | 1723 | } |
1720 | delete storage; | 1724 | delete storage; |
1721 | delete calendar; | 1725 | delete calendar; |
1722 | if ( syncOK ) | 1726 | if ( syncOK ) |
1723 | updateView(); | 1727 | updateView(); |
1724 | return syncOK; | 1728 | return syncOK; |
1725 | } | 1729 | } |
1726 | 1730 | ||
1727 | void CalendarView::syncExternal( int mode ) | 1731 | void CalendarView::syncExternal( int mode ) |
1728 | { | 1732 | { |
1729 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1733 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1730 | 1734 | ||
1731 | qApp->processEvents(); | 1735 | qApp->processEvents(); |
1732 | CalendarLocal* calendar = new CalendarLocal(); | 1736 | CalendarLocal* calendar = new CalendarLocal(); |
1733 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1737 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1734 | bool syncOK = false; | 1738 | bool syncOK = false; |
1735 | bool loadSuccess = false; | 1739 | bool loadSuccess = false; |
1736 | PhoneFormat* phoneFormat = 0; | 1740 | PhoneFormat* phoneFormat = 0; |
1737 | emit tempDisableBR(true); | 1741 | emit tempDisableBR(true); |
1738 | #ifndef DESKTOP_VERSION | 1742 | #ifndef DESKTOP_VERSION |
1739 | SharpFormat* sharpFormat = 0; | 1743 | SharpFormat* sharpFormat = 0; |
1740 | if ( mode == 0 ) { // sharp | 1744 | if ( mode == 0 ) { // sharp |
1741 | sharpFormat = new SharpFormat () ; | 1745 | sharpFormat = new SharpFormat () ; |
1742 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1746 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1743 | 1747 | ||
1744 | } else | 1748 | } else |
1745 | #endif | 1749 | #endif |
1746 | if ( mode == 1 ) { // phone | 1750 | if ( mode == 1 ) { // phone |
1747 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1751 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1748 | mSyncManager->mPhoneDevice, | 1752 | mSyncManager->mPhoneDevice, |
1749 | mSyncManager->mPhoneConnection, | 1753 | mSyncManager->mPhoneConnection, |
1750 | mSyncManager->mPhoneModel); | 1754 | mSyncManager->mPhoneModel); |
1751 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1755 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1752 | 1756 | ||
1753 | } else { | 1757 | } else { |
1754 | emit tempDisableBR(false); | 1758 | emit tempDisableBR(false); |
1755 | return; | 1759 | return; |
1756 | } | 1760 | } |
1757 | if ( loadSuccess ) { | 1761 | if ( loadSuccess ) { |
1758 | getEventViewerDialog()->setSyncMode( true ); | 1762 | getEventViewerDialog()->setSyncMode( true ); |
1759 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1763 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1760 | getEventViewerDialog()->setSyncMode( false ); | 1764 | getEventViewerDialog()->setSyncMode( false ); |
1761 | qApp->processEvents(); | 1765 | qApp->processEvents(); |
1762 | if ( syncOK ) { | 1766 | if ( syncOK ) { |
1763 | if ( mSyncManager->mWriteBackFile ) | 1767 | if ( mSyncManager->mWriteBackFile ) |
1764 | { | 1768 | { |
1765 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1769 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1766 | Incidence* inc = iL.first(); | 1770 | Incidence* inc = iL.first(); |
1767 | if ( phoneFormat ) { | 1771 | if ( phoneFormat ) { |
1768 | while ( inc ) { | 1772 | while ( inc ) { |
1769 | inc->removeID(mCurrentSyncDevice); | 1773 | inc->removeID(mCurrentSyncDevice); |
1770 | inc = iL.next(); | 1774 | inc = iL.next(); |
1771 | } | 1775 | } |
1772 | } | 1776 | } |
1773 | #ifndef DESKTOP_VERSION | 1777 | #ifndef DESKTOP_VERSION |
1774 | if ( sharpFormat ) | 1778 | if ( sharpFormat ) |
1775 | sharpFormat->save(calendar); | 1779 | sharpFormat->save(calendar); |
1776 | #endif | 1780 | #endif |
1777 | if ( phoneFormat ) | 1781 | if ( phoneFormat ) |
1778 | phoneFormat->save(calendar); | 1782 | phoneFormat->save(calendar); |
1779 | iL = calendar->rawIncidences(); | 1783 | iL = calendar->rawIncidences(); |
1780 | inc = iL.first(); | 1784 | inc = iL.first(); |
1781 | Incidence* loc; | 1785 | Incidence* loc; |
1782 | while ( inc ) { | 1786 | while ( inc ) { |
1783 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1787 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1784 | loc = mCalendar->incidence(inc->uid() ); | 1788 | loc = mCalendar->incidence(inc->uid() ); |
1785 | if ( loc ) { | 1789 | if ( loc ) { |
1786 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1790 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1787 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1791 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1788 | } | 1792 | } |
1789 | } | 1793 | } |
1790 | inc = iL.next(); | 1794 | inc = iL.next(); |
1791 | } | 1795 | } |
1792 | Incidence* lse = getLastSyncEvent(); | 1796 | Incidence* lse = getLastSyncEvent(); |
1793 | if ( lse ) { | 1797 | if ( lse ) { |
1794 | lse->setReadOnly( false ); | 1798 | lse->setReadOnly( false ); |
1795 | lse->setDescription( "" ); | 1799 | lse->setDescription( "" ); |
1796 | lse->setReadOnly( true ); | 1800 | lse->setReadOnly( true ); |
1797 | } | 1801 | } |
1798 | } | 1802 | } |
1799 | } else { | 1803 | } else { |
1800 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1804 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1801 | } | 1805 | } |
1802 | setModified( true ); | 1806 | setModified( true ); |
1803 | } else { | 1807 | } else { |
1804 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1808 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1805 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1809 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1806 | question, i18n("Ok")) ; | 1810 | question, i18n("Ok")) ; |
1807 | 1811 | ||
1808 | } | 1812 | } |
1809 | delete calendar; | 1813 | delete calendar; |
1810 | updateView(); | 1814 | updateView(); |
1811 | emit tempDisableBR(false); | 1815 | emit tempDisableBR(false); |
1812 | return ;//syncOK; | 1816 | return ;//syncOK; |
1813 | 1817 | ||
1814 | } | 1818 | } |
1815 | 1819 | ||
1816 | bool CalendarView::importBday() | 1820 | bool CalendarView::importBday() |
1817 | { | 1821 | { |
1818 | #ifndef KORG_NOKABC | 1822 | #ifndef KORG_NOKABC |
1819 | 1823 | ||
1820 | #ifdef DESKTOP_VERSION | 1824 | #ifdef DESKTOP_VERSION |
1821 | int curCal = mCalendar->defaultCalendar(); | 1825 | int curCal = mCalendar->defaultCalendar(); |
1822 | int bd = mCalEditView->getBirtdayID(); | 1826 | int bd = mCalEditView->getBirtdayID(); |
1823 | if ( bd == 0 ) | 1827 | if ( bd == 0 ) |
1824 | return false; | 1828 | return false; |
1825 | mCalendar->setDefaultCalendar( bd ); | 1829 | mCalendar->setDefaultCalendar( bd ); |
1826 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1830 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1827 | KABC::AddressBook::Iterator it; | 1831 | KABC::AddressBook::Iterator it; |
1828 | int count = 0; | 1832 | int count = 0; |
1829 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1833 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1830 | ++count; | 1834 | ++count; |
1831 | } | 1835 | } |
1832 | QProgressBar bar(count,0 ); | 1836 | QProgressBar bar(count,0 ); |
1833 | int w = 300; | 1837 | int w = 300; |
1834 | if ( QApplication::desktop()->width() < 320 ) | 1838 | if ( QApplication::desktop()->width() < 320 ) |
1835 | w = 220; | 1839 | w = 220; |
1836 | int h = bar.sizeHint().height() ; | 1840 | int h = bar.sizeHint().height() ; |
1837 | int dw = QApplication::desktop()->width(); | 1841 | int dw = QApplication::desktop()->width(); |
1838 | int dh = QApplication::desktop()->height(); | 1842 | int dh = QApplication::desktop()->height(); |
1839 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1843 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1840 | bar.show(); | 1844 | bar.show(); |
1841 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1845 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1842 | qApp->processEvents(); | 1846 | qApp->processEvents(); |
1843 | count = 0; | 1847 | count = 0; |
1844 | int addCount = 0; | 1848 | int addCount = 0; |
1845 | KCal::Attendee* a = 0; | 1849 | KCal::Attendee* a = 0; |
1846 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1850 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1847 | if ( ! bar.isVisible() ) | 1851 | if ( ! bar.isVisible() ) |
1848 | return false; | 1852 | return false; |
1849 | bar.setProgress( count++ ); | 1853 | bar.setProgress( count++ ); |
1850 | qApp->processEvents(); | 1854 | qApp->processEvents(); |
1851 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1855 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1852 | if ( (*it).birthday().date().isValid() ){ | 1856 | if ( (*it).birthday().date().isValid() ){ |
1853 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1857 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1854 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1858 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1855 | ++addCount; | 1859 | ++addCount; |
1856 | } | 1860 | } |
1857 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1861 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1858 | if ( anni.isValid() ){ | 1862 | if ( anni.isValid() ){ |
1859 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1863 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1860 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1864 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1861 | ++addCount; | 1865 | ++addCount; |
1862 | } | 1866 | } |
1863 | } | 1867 | } |
1864 | mCalendar->setDefaultCalendar( curCal ); | 1868 | mCalendar->setDefaultCalendar( curCal ); |
1865 | updateView(); | 1869 | updateView(); |
1866 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1870 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1867 | #else //DESKTOP_VERSION | 1871 | #else //DESKTOP_VERSION |
1868 | 1872 | ||
1869 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1873 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1870 | // the result should now arrive through method insertBirthdays | 1874 | // the result should now arrive through method insertBirthdays |
1871 | 1875 | ||
1872 | #endif //DESKTOP_VERSION | 1876 | #endif //DESKTOP_VERSION |
1873 | 1877 | ||
1874 | #endif //KORG_NOKABC | 1878 | #endif //KORG_NOKABC |
1875 | 1879 | ||
1876 | 1880 | ||
1877 | return true; | 1881 | return true; |
1878 | } | 1882 | } |
1879 | 1883 | ||
1880 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1884 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1881 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1885 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1882 | const QStringList& anniversaryList, const QStringList& realNameList, | 1886 | const QStringList& anniversaryList, const QStringList& realNameList, |
1883 | const QStringList& emailList, const QStringList& assembledNameList, | 1887 | const QStringList& emailList, const QStringList& assembledNameList, |
1884 | const QStringList& uidList) | 1888 | const QStringList& uidList) |
1885 | { | 1889 | { |
1886 | 1890 | ||
1887 | //qDebug("KO::CalendarView::insertBirthdays"); | 1891 | //qDebug("KO::CalendarView::insertBirthdays"); |
1888 | if (uid == this->name()) | 1892 | if (uid == this->name()) |
1889 | { | 1893 | { |
1890 | int curCal = mCalendar->defaultCalendar(); | 1894 | int curCal = mCalendar->defaultCalendar(); |
1891 | int bd = mCalEditView->getBirtdayID(); | 1895 | int bd = mCalEditView->getBirtdayID(); |
1892 | if ( bd == 0 ) | 1896 | if ( bd == 0 ) |
1893 | return; | 1897 | return; |
1894 | mCalendar->setDefaultCalendar( bd ); | 1898 | mCalendar->setDefaultCalendar( bd ); |
1895 | 1899 | ||
1896 | 1900 | ||
1897 | int count = birthdayList.count(); | 1901 | int count = birthdayList.count(); |
1898 | int addCount = 0; | 1902 | int addCount = 0; |
1899 | KCal::Attendee* a = 0; | 1903 | KCal::Attendee* a = 0; |
1900 | 1904 | ||
1901 | //qDebug("CalView 1 %i", count); | 1905 | //qDebug("CalView 1 %i", count); |
1902 | 1906 | ||
1903 | QProgressBar bar(count,0 ); | 1907 | QProgressBar bar(count,0 ); |
1904 | int w = 300; | 1908 | int w = 300; |
1905 | if ( QApplication::desktop()->width() < 320 ) | 1909 | if ( QApplication::desktop()->width() < 320 ) |
1906 | w = 220; | 1910 | w = 220; |
1907 | int h = bar.sizeHint().height() ; | 1911 | int h = bar.sizeHint().height() ; |
1908 | int dw = QApplication::desktop()->width(); | 1912 | int dw = QApplication::desktop()->width(); |
1909 | int dh = QApplication::desktop()->height(); | 1913 | int dh = QApplication::desktop()->height(); |
1910 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1914 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1911 | bar.show(); | 1915 | bar.show(); |
1912 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1916 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1913 | qApp->processEvents(); | 1917 | qApp->processEvents(); |
1914 | 1918 | ||
1915 | QDate birthday; | 1919 | QDate birthday; |
1916 | QDate anniversary; | 1920 | QDate anniversary; |
1917 | QString realName; | 1921 | QString realName; |
1918 | QString email; | 1922 | QString email; |
1919 | QString assembledName; | 1923 | QString assembledName; |
1920 | QString uid; | 1924 | QString uid; |
1921 | bool ok = true; | 1925 | bool ok = true; |
1922 | for ( int i = 0; i < count; i++) | 1926 | for ( int i = 0; i < count; i++) |
1923 | { | 1927 | { |
1924 | if ( ! bar.isVisible() ) | 1928 | if ( ! bar.isVisible() ) |
1925 | return; | 1929 | return; |
1926 | bar.setProgress( i ); | 1930 | bar.setProgress( i ); |
1927 | qApp->processEvents(); | 1931 | qApp->processEvents(); |
1928 | 1932 | ||
1929 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1933 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1930 | if (!ok) { | 1934 | if (!ok) { |
1931 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1935 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1932 | } | 1936 | } |
1933 | 1937 | ||
1934 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1938 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1935 | if (!ok) { | 1939 | if (!ok) { |
1936 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1940 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1937 | } | 1941 | } |
1938 | realName = realNameList[i]; | 1942 | realName = realNameList[i]; |
1939 | email = emailList[i]; | 1943 | email = emailList[i]; |
1940 | assembledName = assembledNameList[i]; | 1944 | assembledName = assembledNameList[i]; |
1941 | uid = uidList[i]; | 1945 | uid = uidList[i]; |
1942 | //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() ); | 1946 | //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() ); |
1943 | 1947 | ||
1944 | if ( birthday.isValid() ){ | 1948 | if ( birthday.isValid() ){ |
1945 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1949 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1946 | KCal::Attendee::ReqParticipant,uid) ; | 1950 | KCal::Attendee::ReqParticipant,uid) ; |
1947 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1951 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1948 | ++addCount; | 1952 | ++addCount; |
1949 | } | 1953 | } |
1950 | 1954 | ||
1951 | if ( anniversary.isValid() ){ | 1955 | if ( anniversary.isValid() ){ |
1952 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1956 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1953 | KCal::Attendee::ReqParticipant,uid) ; | 1957 | KCal::Attendee::ReqParticipant,uid) ; |
1954 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1958 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1955 | ++addCount; | 1959 | ++addCount; |
1956 | } | 1960 | } |
1957 | } | 1961 | } |
1958 | 1962 | ||
1959 | mCalendar->setDefaultCalendar( curCal ); | 1963 | mCalendar->setDefaultCalendar( curCal ); |
1960 | updateView(); | 1964 | updateView(); |
1961 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1965 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1962 | 1966 | ||
1963 | } | 1967 | } |
1964 | 1968 | ||
1965 | } | 1969 | } |
1966 | 1970 | ||
1967 | 1971 | ||
1968 | 1972 | ||
1969 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1973 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1970 | { | 1974 | { |
1971 | //qDebug("addAnni "); | 1975 | //qDebug("addAnni "); |
1972 | Event * ev = new Event(); | 1976 | Event * ev = new Event(); |
1973 | ev->setOrganizer(KOPrefs::instance()->email()); | 1977 | ev->setOrganizer(KOPrefs::instance()->email()); |
1974 | if ( a ) { | 1978 | if ( a ) { |
1975 | ev->addAttendee( a ); | 1979 | ev->addAttendee( a ); |
1976 | } | 1980 | } |
1977 | QString kind; | 1981 | QString kind; |
1978 | if ( birthday ) { | 1982 | if ( birthday ) { |
1979 | kind = i18n( "Birthday" ); | 1983 | kind = i18n( "Birthday" ); |
1980 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1984 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1981 | } | 1985 | } |
1982 | else { | 1986 | else { |
1983 | kind = i18n( "Anniversary" ); | 1987 | kind = i18n( "Anniversary" ); |
1984 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1988 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1985 | } | 1989 | } |
1986 | ev->setCategories( kind ); | 1990 | ev->setCategories( kind ); |
1987 | ev->setDtStart( QDateTime(date) ); | 1991 | ev->setDtStart( QDateTime(date) ); |
1988 | ev->setDtEnd( QDateTime(date) ); | 1992 | ev->setDtEnd( QDateTime(date) ); |
1989 | ev->setFloats( true ); | 1993 | ev->setFloats( true ); |
1990 | Recurrence * rec = ev->recurrence(); | 1994 | Recurrence * rec = ev->recurrence(); |
1991 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1995 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1992 | rec->addYearlyNum( date.month() ); | 1996 | rec->addYearlyNum( date.month() ); |
1993 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1997 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1994 | delete ev; | 1998 | delete ev; |
1995 | return false; | 1999 | return false; |
1996 | } | 2000 | } |
1997 | return true; | 2001 | return true; |
1998 | 2002 | ||
1999 | } | 2003 | } |
2000 | bool CalendarView::importQtopia( const QString &categories, | 2004 | bool CalendarView::importQtopia( const QString &categories, |
2001 | const QString &datebook, | 2005 | const QString &datebook, |
2002 | const QString &todolist ) | 2006 | const QString &todolist ) |
2003 | { | 2007 | { |
2004 | 2008 | ||
2005 | QtopiaFormat qtopiaFormat; | 2009 | QtopiaFormat qtopiaFormat; |
2006 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2010 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2007 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2011 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2008 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2012 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2009 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2013 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2010 | 2014 | ||
2011 | updateView(); | 2015 | updateView(); |
2012 | return true; | 2016 | return true; |
2013 | 2017 | ||
2014 | #if 0 | 2018 | #if 0 |
2015 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2019 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2016 | mCurrentSyncDevice = "qtopia-XML"; | 2020 | mCurrentSyncDevice = "qtopia-XML"; |
2017 | if ( mSyncManager->mAskForPreferences ) | 2021 | if ( mSyncManager->mAskForPreferences ) |
2018 | edit_sync_options(); | 2022 | edit_sync_options(); |
2019 | qApp->processEvents(); | 2023 | qApp->processEvents(); |
2020 | CalendarLocal* calendar = new CalendarLocal(); | 2024 | CalendarLocal* calendar = new CalendarLocal(); |
2021 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2025 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2022 | bool syncOK = false; | 2026 | bool syncOK = false; |
2023 | QtopiaFormat qtopiaFormat; | 2027 | QtopiaFormat qtopiaFormat; |
2024 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2028 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2025 | bool loadOk = true; | 2029 | bool loadOk = true; |
2026 | if ( !categories.isEmpty() ) | 2030 | if ( !categories.isEmpty() ) |
2027 | loadOk = qtopiaFormat.load( calendar, categories ); | 2031 | loadOk = qtopiaFormat.load( calendar, categories ); |
2028 | if ( loadOk && !datebook.isEmpty() ) | 2032 | if ( loadOk && !datebook.isEmpty() ) |
2029 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2033 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2030 | if ( loadOk && !todolist.isEmpty() ) | 2034 | if ( loadOk && !todolist.isEmpty() ) |
2031 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2035 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2032 | 2036 | ||
2033 | if ( loadOk ) { | 2037 | if ( loadOk ) { |
2034 | getEventViewerDialog()->setSyncMode( true ); | 2038 | getEventViewerDialog()->setSyncMode( true ); |
2035 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2039 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2036 | getEventViewerDialog()->setSyncMode( false ); | 2040 | getEventViewerDialog()->setSyncMode( false ); |
2037 | qApp->processEvents(); | 2041 | qApp->processEvents(); |
2038 | if ( syncOK ) { | 2042 | if ( syncOK ) { |
2039 | if ( mSyncManager->mWriteBackFile ) | 2043 | if ( mSyncManager->mWriteBackFile ) |
2040 | { | 2044 | { |
2041 | // write back XML file | 2045 | // write back XML file |
2042 | 2046 | ||
2043 | } | 2047 | } |
2044 | setModified( true ); | 2048 | setModified( true ); |
2045 | } | 2049 | } |
2046 | } else { | 2050 | } else { |
2047 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2051 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2048 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2052 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2049 | question, i18n("Ok")) ; | 2053 | question, i18n("Ok")) ; |
2050 | } | 2054 | } |
2051 | delete calendar; | 2055 | delete calendar; |
2052 | updateView(); | 2056 | updateView(); |
2053 | return syncOK; | 2057 | return syncOK; |
2054 | 2058 | ||
2055 | 2059 | ||
2056 | #endif | 2060 | #endif |
2057 | 2061 | ||
2058 | } | 2062 | } |
2059 | 2063 | ||
2060 | void CalendarView::setSyncEventsReadOnly() | 2064 | void CalendarView::setSyncEventsReadOnly() |
2061 | { | 2065 | { |
2062 | mCalendar->setSyncEventsReadOnly(); | 2066 | mCalendar->setSyncEventsReadOnly(); |
2063 | } | 2067 | } |
2064 | 2068 | ||
2065 | bool CalendarView::loadCalendars() | 2069 | bool CalendarView::loadCalendars() |
2066 | { | 2070 | { |
2067 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2071 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2068 | KopiCalendarFile * cal = calendars.first(); | 2072 | KopiCalendarFile * cal = calendars.first(); |
2069 | mCalendar->setDefaultCalendar( 1 ); | 2073 | mCalendar->setDefaultCalendar( 1 ); |
2070 | openCalendar( MainWindow::defaultFileName(), false ); | 2074 | openCalendar( MainWindow::defaultFileName(), false ); |
2071 | cal = calendars.next(); | 2075 | cal = calendars.next(); |
2072 | while ( cal ) { | 2076 | while ( cal ) { |
2073 | addCalendar( cal ); | 2077 | addCalendar( cal ); |
2074 | cal = calendars.next(); | 2078 | cal = calendars.next(); |
2075 | } | 2079 | } |
2076 | restoreCalendarSettings(); | 2080 | restoreCalendarSettings(); |
2077 | return true; | 2081 | return true; |
2078 | } | 2082 | } |
2079 | bool CalendarView::restoreCalendarSettings() | 2083 | bool CalendarView::restoreCalendarSettings() |
2080 | { | 2084 | { |
2081 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2085 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2082 | KopiCalendarFile * cal = calendars.first(); | 2086 | KopiCalendarFile * cal = calendars.first(); |
2083 | while ( cal ) { | 2087 | while ( cal ) { |
2084 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2088 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2085 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2089 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2086 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2090 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2087 | if ( cal->isStandard ) | 2091 | if ( cal->isStandard ) |
2088 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2092 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2089 | cal = calendars.next(); | 2093 | cal = calendars.next(); |
2090 | } | 2094 | } |
2091 | setSyncEventsReadOnly(); | 2095 | setSyncEventsReadOnly(); |
2092 | mCalendar->reInitAlarmSettings(); | 2096 | mCalendar->reInitAlarmSettings(); |
2093 | updateUnmanagedViews(); | 2097 | updateUnmanagedViews(); |
2094 | updateView(); | 2098 | updateView(); |
2095 | return true; | 2099 | return true; |
2096 | } | 2100 | } |
2097 | void CalendarView::addCalendarId( int id ) | 2101 | void CalendarView::addCalendarId( int id ) |
2098 | { | 2102 | { |
2099 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2103 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2100 | if ( cal ) | 2104 | if ( cal ) |
2101 | addCalendar( cal ); | 2105 | addCalendar( cal ); |
2102 | } | 2106 | } |
2103 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2107 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2104 | { | 2108 | { |
2105 | cal->mErrorOnLoad = false; | 2109 | cal->mErrorOnLoad = false; |
2106 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2110 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2107 | cal->mLoadDt = QDateTime::currentDateTime(); | 2111 | cal->mLoadDt = QDateTime::currentDateTime(); |
2108 | return true; | 2112 | return true; |
2109 | } | 2113 | } |
2110 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2114 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2111 | cal->mErrorOnLoad = true; | 2115 | cal->mErrorOnLoad = true; |
2112 | return false; | 2116 | return false; |
2113 | } | 2117 | } |
2114 | bool CalendarView::openCalendar(QString filename, bool merge) | 2118 | bool CalendarView::openCalendar(QString filename, bool merge) |
2115 | { | 2119 | { |
2116 | 2120 | ||
2117 | if (filename.isEmpty()) { | 2121 | if (filename.isEmpty()) { |
2118 | return false; | 2122 | return false; |
2119 | } | 2123 | } |
2120 | 2124 | ||
2121 | if (!QFile::exists(filename)) { | 2125 | if (!QFile::exists(filename)) { |
2122 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2126 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2123 | return false; | 2127 | return false; |
2124 | } | 2128 | } |
2125 | 2129 | ||
2126 | globalFlagBlockAgenda = 1; | 2130 | globalFlagBlockAgenda = 1; |
2127 | clearAllViews(); | 2131 | clearAllViews(); |
2128 | if (!merge) { | 2132 | if (!merge) { |
2129 | mViewManager->setDocumentId( filename ); | 2133 | mViewManager->setDocumentId( filename ); |
2130 | mCalendar->close(); | 2134 | mCalendar->close(); |
2131 | } | 2135 | } |
2132 | mStorage->setFileName( filename ); | 2136 | mStorage->setFileName( filename ); |
2133 | 2137 | ||
2134 | if ( mStorage->load() ) { | 2138 | if ( mStorage->load() ) { |
2135 | if ( merge ) ;//setModified( true ); | 2139 | if ( merge ) ;//setModified( true ); |
2136 | else { | 2140 | else { |
2137 | //setModified( true ); | 2141 | //setModified( true ); |
2138 | mViewManager->setDocumentId( filename ); | 2142 | mViewManager->setDocumentId( filename ); |
2139 | mDialogManager->setDocumentId( filename ); | 2143 | mDialogManager->setDocumentId( filename ); |
2140 | mTodoList->setDocumentId( filename ); | 2144 | mTodoList->setDocumentId( filename ); |
2141 | } | 2145 | } |
2142 | globalFlagBlockAgenda = 2; | 2146 | globalFlagBlockAgenda = 2; |
2143 | // if ( getLastSyncEvent() ) | 2147 | // if ( getLastSyncEvent() ) |
2144 | // getLastSyncEvent()->setReadOnly( true ); | 2148 | // getLastSyncEvent()->setReadOnly( true ); |
2145 | mCalendar->reInitAlarmSettings(); | 2149 | mCalendar->reInitAlarmSettings(); |
2146 | setSyncEventsReadOnly(); | 2150 | setSyncEventsReadOnly(); |
2147 | updateUnmanagedViews(); | 2151 | updateUnmanagedViews(); |
2148 | updateView(); | 2152 | updateView(); |
2149 | if ( filename != MainWindow::defaultFileName() ) { | 2153 | if ( filename != MainWindow::defaultFileName() ) { |
2150 | saveCalendar( MainWindow::defaultFileName() ); | 2154 | saveCalendar( MainWindow::defaultFileName() ); |
2151 | } else { | 2155 | } else { |
2152 | QFileInfo finf ( MainWindow::defaultFileName()); | 2156 | QFileInfo finf ( MainWindow::defaultFileName()); |
2153 | if ( finf.exists() ) { | 2157 | if ( finf.exists() ) { |
2154 | setLoadedFileVersion( finf.lastModified () ); | 2158 | setLoadedFileVersion( finf.lastModified () ); |
2155 | } | 2159 | } |
2156 | } | 2160 | } |
2157 | return true; | 2161 | return true; |
2158 | } else { | 2162 | } else { |
2159 | // while failing to load, the calendar object could | 2163 | // while failing to load, the calendar object could |
2160 | // have become partially populated. Clear it out. | 2164 | // have become partially populated. Clear it out. |
2161 | if ( !merge ) { | 2165 | if ( !merge ) { |
2162 | mCalendar->close(); | 2166 | mCalendar->close(); |
2163 | mViewManager->setDocumentId( filename ); | 2167 | mViewManager->setDocumentId( filename ); |
2164 | mDialogManager->setDocumentId( filename ); | 2168 | mDialogManager->setDocumentId( filename ); |
2165 | mTodoList->setDocumentId( filename ); | 2169 | mTodoList->setDocumentId( filename ); |
2166 | } | 2170 | } |
2167 | 2171 | ||
2168 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2172 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2169 | 2173 | ||
2170 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2174 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2171 | globalFlagBlockAgenda = 2; | 2175 | globalFlagBlockAgenda = 2; |
2172 | mCalendar->reInitAlarmSettings(); | 2176 | mCalendar->reInitAlarmSettings(); |
2173 | setSyncEventsReadOnly(); | 2177 | setSyncEventsReadOnly(); |
2174 | updateUnmanagedViews(); | 2178 | updateUnmanagedViews(); |
2175 | updateView(); | 2179 | updateView(); |
2176 | } | 2180 | } |
2177 | return false; | 2181 | return false; |
2178 | } | 2182 | } |
2179 | void CalendarView::mergeFile( QString fn ) | 2183 | void CalendarView::mergeFile( QString fn ) |
2180 | { | 2184 | { |
2181 | clearAllViews(); | 2185 | clearAllViews(); |
2182 | mCalendar->mergeCalendarFile( fn ); | 2186 | mCalendar->mergeCalendarFile( fn ); |
2183 | mCalendar->reInitAlarmSettings(); | 2187 | mCalendar->reInitAlarmSettings(); |
2184 | setSyncEventsReadOnly(); | 2188 | setSyncEventsReadOnly(); |
2185 | updateUnmanagedViews(); | 2189 | updateUnmanagedViews(); |
2186 | updateView(); | 2190 | updateView(); |
2187 | } | 2191 | } |
2188 | void CalendarView::showOpenError() | 2192 | void CalendarView::showOpenError() |
2189 | { | 2193 | { |
2190 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2194 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2191 | } | 2195 | } |
2192 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2196 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2193 | { | 2197 | { |
2194 | loadedFileVersion = dt; | 2198 | loadedFileVersion = dt; |
2195 | } | 2199 | } |
2196 | bool CalendarView::checkFileChanged(QString fn) | 2200 | bool CalendarView::checkFileChanged(QString fn) |
2197 | { | 2201 | { |
2198 | QFileInfo finf ( fn ); | 2202 | QFileInfo finf ( fn ); |
2199 | if ( !finf.exists() ) | 2203 | if ( !finf.exists() ) |
2200 | return true; | 2204 | return true; |
2201 | QDateTime dt = finf.lastModified (); | 2205 | QDateTime dt = finf.lastModified (); |
2202 | if ( dt <= loadedFileVersion ) | 2206 | if ( dt <= loadedFileVersion ) |
2203 | return false; | 2207 | return false; |
2204 | return true; | 2208 | return true; |
2205 | 2209 | ||
2206 | } | 2210 | } |
2207 | void CalendarView::watchSavedFile() | 2211 | void CalendarView::watchSavedFile() |
2208 | { | 2212 | { |
2209 | QFileInfo finf ( MainWindow::defaultFileName()); | 2213 | QFileInfo finf ( MainWindow::defaultFileName()); |
2210 | if ( !finf.exists() ) | 2214 | if ( !finf.exists() ) |
2211 | return; | 2215 | return; |
2212 | QDateTime dt = finf.lastModified (); | 2216 | QDateTime dt = finf.lastModified (); |
2213 | if ( dt < loadedFileVersion ) { | 2217 | if ( dt < loadedFileVersion ) { |
2214 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2218 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2215 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2219 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2216 | return; | 2220 | return; |
2217 | } | 2221 | } |
2218 | loadedFileVersion = dt; | 2222 | loadedFileVersion = dt; |
2219 | } | 2223 | } |
2220 | bool CalendarView::checkAllFileVersions() | 2224 | bool CalendarView::checkAllFileVersions() |
2221 | { | 2225 | { |
2222 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2226 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2223 | KopiCalendarFile * cal = calendars.first(); | 2227 | KopiCalendarFile * cal = calendars.first(); |
2224 | mCalendar->setDefaultCalendar( 1 ); | 2228 | mCalendar->setDefaultCalendar( 1 ); |
2225 | mCalendar->setDefaultCalendarEnabledOnly(); | 2229 | mCalendar->setDefaultCalendarEnabledOnly(); |
2226 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2230 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2227 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2231 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2228 | restoreCalendarSettings(); | 2232 | restoreCalendarSettings(); |
2229 | return false; | 2233 | return false; |
2230 | } | 2234 | } |
2231 | } | 2235 | } |
2232 | cal = calendars.next(); | 2236 | cal = calendars.next(); |
2233 | QDateTime storeTemp = loadedFileVersion; | 2237 | QDateTime storeTemp = loadedFileVersion; |
2234 | while ( cal ) { | 2238 | while ( cal ) { |
2235 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2239 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2236 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2240 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2237 | mCalendar->setDefaultCalendarEnabledOnly(); | 2241 | mCalendar->setDefaultCalendarEnabledOnly(); |
2238 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2242 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2239 | if ( !checkFileVersion(cal->mFileName )) { | 2243 | if ( !checkFileVersion(cal->mFileName )) { |
2240 | loadedFileVersion = storeTemp; | 2244 | loadedFileVersion = storeTemp; |
2241 | restoreCalendarSettings(); | 2245 | restoreCalendarSettings(); |
2242 | return false; | 2246 | return false; |
2243 | } | 2247 | } |
2244 | } | 2248 | } |
2245 | cal = calendars.next(); | 2249 | cal = calendars.next(); |
2246 | } | 2250 | } |
2247 | loadedFileVersion = storeTemp; | 2251 | loadedFileVersion = storeTemp; |
2248 | return true; | 2252 | return true; |
2249 | } | 2253 | } |
2250 | bool CalendarView::checkFileVersion(QString fn) | 2254 | bool CalendarView::checkFileVersion(QString fn) |
2251 | { | 2255 | { |
2252 | QFileInfo finf ( fn ); | 2256 | QFileInfo finf ( fn ); |
2253 | if ( !finf.exists() ) | 2257 | if ( !finf.exists() ) |
2254 | return true; | 2258 | return true; |
2255 | QDateTime dt = finf.lastModified (); | 2259 | QDateTime dt = finf.lastModified (); |
2256 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2260 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2257 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2261 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2258 | if ( dt <= loadedFileVersion ) | 2262 | if ( dt <= loadedFileVersion ) |
2259 | return true; | 2263 | return true; |
2260 | 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)) , | 2264 | 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)) , |
2261 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2265 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2262 | i18n("Sync+save")); | 2266 | i18n("Sync+save")); |
2263 | 2267 | ||
2264 | if ( km == KMessageBox::Cancel ) | 2268 | if ( km == KMessageBox::Cancel ) |
2265 | return false; | 2269 | return false; |
2266 | if ( km == KMessageBox::Yes ) | 2270 | if ( km == KMessageBox::Yes ) |
2267 | return true; | 2271 | return true; |
2268 | 2272 | ||
2269 | setSyncDevice("deleteaftersync" ); | 2273 | setSyncDevice("deleteaftersync" ); |
2270 | mSyncManager->mAskForPreferences = true; | 2274 | mSyncManager->mAskForPreferences = true; |
2271 | mSyncManager->mSyncAlgoPrefs = 3; | 2275 | mSyncManager->mSyncAlgoPrefs = 3; |
2272 | mSyncManager->mWriteBackFile = false; | 2276 | mSyncManager->mWriteBackFile = false; |
2273 | mSyncManager->mWriteBackExistingOnly = false; | 2277 | mSyncManager->mWriteBackExistingOnly = false; |
2274 | mSyncManager->mShowSyncSummary = false; | 2278 | mSyncManager->mShowSyncSummary = false; |
2275 | syncCalendar( fn, 3 ); | 2279 | syncCalendar( fn, 3 ); |
2276 | Event * e = getLastSyncEvent(); | 2280 | Event * e = getLastSyncEvent(); |
2277 | if ( e ) | 2281 | if ( e ) |
2278 | mCalendar->deleteEvent( e ); | 2282 | mCalendar->deleteEvent( e ); |
2279 | return true; | 2283 | return true; |
2280 | } | 2284 | } |
2281 | bool CalendarView::saveCalendars() | 2285 | bool CalendarView::saveCalendars() |
2282 | { | 2286 | { |
2283 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2287 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2284 | KopiCalendarFile * cal = calendars.first(); | 2288 | KopiCalendarFile * cal = calendars.first(); |
2285 | mCalendar->setDefaultCalendar( 1 ); | 2289 | mCalendar->setDefaultCalendar( 1 ); |
2286 | mCalendar->setDefaultCalendarEnabledOnly(); | 2290 | mCalendar->setDefaultCalendarEnabledOnly(); |
2287 | saveCalendar( MainWindow::defaultFileName() ); | 2291 | saveCalendar( MainWindow::defaultFileName() ); |
2288 | cal = calendars.next(); | 2292 | cal = calendars.next(); |
2289 | while ( cal ) { | 2293 | while ( cal ) { |
2290 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2294 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2291 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2295 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2292 | mCalendar->setDefaultCalendarEnabledOnly(); | 2296 | mCalendar->setDefaultCalendarEnabledOnly(); |
2293 | if ( saveCalendar( cal->mFileName ) ) | 2297 | if ( saveCalendar( cal->mFileName ) ) |
2294 | cal->mLoadDt = QDateTime::currentDateTime(); | 2298 | cal->mLoadDt = QDateTime::currentDateTime(); |
2295 | } | 2299 | } |
2296 | cal = calendars.next(); | 2300 | cal = calendars.next(); |
2297 | } | 2301 | } |
2298 | restoreCalendarSettings(); | 2302 | restoreCalendarSettings(); |
2299 | return true; | 2303 | return true; |
2300 | } | 2304 | } |
2301 | bool CalendarView::saveCalendar( QString filename ) | 2305 | bool CalendarView::saveCalendar( QString filename ) |
2302 | { | 2306 | { |
2303 | 2307 | ||
2304 | // Store back all unsaved data into calendar object | 2308 | // Store back all unsaved data into calendar object |
2305 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2309 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2306 | if ( mViewManager->currentView() ) | 2310 | if ( mViewManager->currentView() ) |
2307 | mViewManager->currentView()->flushView(); | 2311 | mViewManager->currentView()->flushView(); |
2308 | 2312 | ||
2309 | 2313 | ||
2310 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2314 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2311 | mStorage->setSaveFormat( new ICalFormat() ); | 2315 | mStorage->setSaveFormat( new ICalFormat() ); |
2312 | mStorage->setFileName( filename ); | 2316 | mStorage->setFileName( filename ); |
2313 | bool success; | 2317 | bool success; |
2314 | success = mStorage->save(); | 2318 | success = mStorage->save(); |
2315 | if ( !success ) { | 2319 | if ( !success ) { |
2316 | return false; | 2320 | return false; |
2317 | } | 2321 | } |
2318 | if ( filename == MainWindow::defaultFileName() ) { | 2322 | if ( filename == MainWindow::defaultFileName() ) { |
2319 | setLoadedFileVersion( lfv ); | 2323 | setLoadedFileVersion( lfv ); |
2320 | watchSavedFile(); | 2324 | watchSavedFile(); |
2321 | } | 2325 | } |
2322 | return true; | 2326 | return true; |
2323 | } | 2327 | } |
2324 | 2328 | ||
2325 | void CalendarView::closeCalendar() | 2329 | void CalendarView::closeCalendar() |
2326 | { | 2330 | { |
2327 | 2331 | ||
2328 | // child windows no longer valid | 2332 | // child windows no longer valid |
2329 | clearAllViews(); | 2333 | clearAllViews(); |
2330 | emit closingDown(); | 2334 | emit closingDown(); |
2331 | 2335 | ||
2332 | mCalendar->close(); | 2336 | mCalendar->close(); |
2333 | setModified(false); | 2337 | setModified(false); |
2334 | updateView(); | 2338 | updateView(); |
2335 | } | 2339 | } |
2336 | 2340 | ||
2337 | void CalendarView::archiveCalendar() | 2341 | void CalendarView::archiveCalendar() |
2338 | { | 2342 | { |
2339 | mDialogManager->showArchiveDialog(); | 2343 | mDialogManager->showArchiveDialog(); |
2340 | } | 2344 | } |
2341 | 2345 | ||
2342 | 2346 | ||
2343 | void CalendarView::readSettings() | 2347 | void CalendarView::readSettings() |
2344 | { | 2348 | { |
2345 | 2349 | ||
2346 | 2350 | ||
2347 | // mViewManager->showAgendaView(); | 2351 | // mViewManager->showAgendaView(); |
2348 | QString str; | 2352 | QString str; |
2349 | //qDebug("CalendarView::readSettings() "); | 2353 | //qDebug("CalendarView::readSettings() "); |
2350 | // read settings from the KConfig, supplying reasonable | 2354 | // read settings from the KConfig, supplying reasonable |
2351 | // defaults where none are to be found | 2355 | // defaults where none are to be found |
2352 | KConfig *config = KOGlobals::config(); | 2356 | KConfig *config = KOGlobals::config(); |
2353 | #ifndef KORG_NOSPLITTER | 2357 | #ifndef KORG_NOSPLITTER |
2354 | config->setGroup("KOrganizer Geometry"); | 2358 | config->setGroup("KOrganizer Geometry"); |
2355 | 2359 | ||
2356 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2360 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2357 | if (sizes.count() != 2) { | 2361 | if (sizes.count() != 2) { |
2358 | sizes << mDateNavigator->minimumSizeHint().width(); | 2362 | sizes << mDateNavigator->minimumSizeHint().width(); |
2359 | sizes << 300; | 2363 | sizes << 300; |
2360 | } | 2364 | } |
2361 | mPanner->setSizes(sizes); | 2365 | mPanner->setSizes(sizes); |
2362 | 2366 | ||
2363 | sizes = config->readIntListEntry("Separator2"); | 2367 | sizes = config->readIntListEntry("Separator2"); |
2364 | if ( ( mResourceView && sizes.count() == 4 ) || | 2368 | if ( ( mResourceView && sizes.count() == 4 ) || |
2365 | ( !mResourceView && sizes.count() == 3 ) ) { | 2369 | ( !mResourceView && sizes.count() == 3 ) ) { |
2366 | mLeftSplitter->setSizes(sizes); | 2370 | mLeftSplitter->setSizes(sizes); |
2367 | } | 2371 | } |
2368 | #endif | 2372 | #endif |
2369 | globalFlagBlockAgenda = 1; | 2373 | globalFlagBlockAgenda = 1; |
2370 | mViewManager->showAgendaView(); | 2374 | mViewManager->showAgendaView(); |
2371 | //mViewManager->readSettings( config ); | 2375 | //mViewManager->readSettings( config ); |
2372 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2376 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2373 | readFilterSettings(config); | 2377 | readFilterSettings(config); |
2374 | 2378 | ||
2375 | #ifdef DESKTOP_VERSION | 2379 | #ifdef DESKTOP_VERSION |
2376 | config->setGroup("WidgetLayout"); | 2380 | config->setGroup("WidgetLayout"); |
2377 | QStringList list; | 2381 | QStringList list; |
2378 | list = config->readListEntry("MainLayout"); | 2382 | list = config->readListEntry("MainLayout"); |
2379 | int x,y,w,h; | 2383 | int x,y,w,h; |
2380 | if ( ! list.isEmpty() ) { | 2384 | if ( ! list.isEmpty() ) { |
2381 | x = list[0].toInt(); | 2385 | x = list[0].toInt(); |
2382 | y = list[1].toInt(); | 2386 | y = list[1].toInt(); |
2383 | w = list[2].toInt(); | 2387 | w = list[2].toInt(); |
2384 | h = list[3].toInt(); | 2388 | h = list[3].toInt(); |
2385 | KApplication::testCoords( &x,&y,&w,&h ); | 2389 | KApplication::testCoords( &x,&y,&w,&h ); |
2386 | topLevelWidget()->setGeometry(x,y,w,h); | 2390 | topLevelWidget()->setGeometry(x,y,w,h); |
2387 | 2391 | ||
2388 | } else { | 2392 | } else { |
2389 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2393 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2390 | } | 2394 | } |
2391 | list = config->readListEntry("EditEventLayout"); | 2395 | list = config->readListEntry("EditEventLayout"); |
2392 | if ( ! list.isEmpty() ) { | 2396 | if ( ! list.isEmpty() ) { |
2393 | x = list[0].toInt(); | 2397 | x = list[0].toInt(); |
2394 | y = list[1].toInt(); | 2398 | y = list[1].toInt(); |
2395 | w = list[2].toInt(); | 2399 | w = list[2].toInt(); |
2396 | h = list[3].toInt(); | 2400 | h = list[3].toInt(); |
2397 | KApplication::testCoords( &x,&y,&w,&h ); | 2401 | KApplication::testCoords( &x,&y,&w,&h ); |
2398 | mEventEditor->setGeometry(x,y,w,h); | 2402 | mEventEditor->setGeometry(x,y,w,h); |
2399 | 2403 | ||
2400 | } | 2404 | } |
2401 | list = config->readListEntry("EditTodoLayout"); | 2405 | list = config->readListEntry("EditTodoLayout"); |
2402 | if ( ! list.isEmpty() ) { | 2406 | if ( ! list.isEmpty() ) { |
2403 | x = list[0].toInt(); | 2407 | x = list[0].toInt(); |
2404 | y = list[1].toInt(); | 2408 | y = list[1].toInt(); |
2405 | w = list[2].toInt(); | 2409 | w = list[2].toInt(); |
2406 | h = list[3].toInt(); | 2410 | h = list[3].toInt(); |
2407 | KApplication::testCoords( &x,&y,&w,&h ); | 2411 | KApplication::testCoords( &x,&y,&w,&h ); |
2408 | mTodoEditor->setGeometry(x,y,w,h); | 2412 | mTodoEditor->setGeometry(x,y,w,h); |
2409 | 2413 | ||
2410 | } | 2414 | } |
2411 | list = config->readListEntry("ViewerLayout"); | 2415 | list = config->readListEntry("ViewerLayout"); |
2412 | if ( ! list.isEmpty() ) { | 2416 | if ( ! list.isEmpty() ) { |
2413 | x = list[0].toInt(); | 2417 | x = list[0].toInt(); |
2414 | y = list[1].toInt(); | 2418 | y = list[1].toInt(); |
2415 | w = list[2].toInt(); | 2419 | w = list[2].toInt(); |
2416 | h = list[3].toInt(); | 2420 | h = list[3].toInt(); |
2417 | KApplication::testCoords( &x,&y,&w,&h ); | 2421 | KApplication::testCoords( &x,&y,&w,&h ); |
2418 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2422 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2419 | } | 2423 | } |
2420 | #endif | 2424 | #endif |
2421 | config->setGroup( "Views" ); | 2425 | config->setGroup( "Views" ); |
2422 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2426 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2423 | 2427 | ||
2424 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2428 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2425 | 2429 | ||
2426 | int resetval = 0; | 2430 | int resetval = 0; |
2427 | int maxVal = 0; | 2431 | int maxVal = 0; |
2428 | if (sizes.count() != 3) { | 2432 | if (sizes.count() != 3) { |
2429 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2433 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2430 | resetval = mDateNavigator->sizeHint().width()+2; | 2434 | resetval = mDateNavigator->sizeHint().width()+2; |
2431 | } else { | 2435 | } else { |
2432 | resetval = mDateNavigator->sizeHint().height()+2; | 2436 | resetval = mDateNavigator->sizeHint().height()+2; |
2433 | } | 2437 | } |
2434 | } | 2438 | } |
2435 | if ( resetval ) { | 2439 | if ( resetval ) { |
2436 | sizes.clear(); | 2440 | sizes.clear(); |
2437 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2441 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2438 | maxVal = QApplication::desktop()->width() -10; | 2442 | maxVal = QApplication::desktop()->width() -10; |
2439 | } else { | 2443 | } else { |
2440 | maxVal = QApplication::desktop()->height()-10; | 2444 | maxVal = QApplication::desktop()->height()-10; |
2441 | } | 2445 | } |
2442 | sizes << resetval; | 2446 | sizes << resetval; |
2443 | if ( maxVal < resetval + resetval) | 2447 | if ( maxVal < resetval + resetval) |
2444 | resetval = maxVal - resetval; | 2448 | resetval = maxVal - resetval; |
2445 | sizes << resetval; | 2449 | sizes << resetval; |
2446 | sizes << 100; | 2450 | sizes << 100; |
2447 | } | 2451 | } |
2448 | mLeftFrame->setSizes(sizes); | 2452 | mLeftFrame->setSizes(sizes); |
2449 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2453 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2450 | resetval = 0; | 2454 | resetval = 0; |
2451 | maxVal = 0; | 2455 | maxVal = 0; |
2452 | if (sizes.count() != 2) { | 2456 | if (sizes.count() != 2) { |
2453 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2457 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2454 | resetval = mDateNavigator->sizeHint().width()+2; | 2458 | resetval = mDateNavigator->sizeHint().width()+2; |
2455 | } else { | 2459 | } else { |
2456 | resetval = mDateNavigator->sizeHint().height()+2; | 2460 | resetval = mDateNavigator->sizeHint().height()+2; |
2457 | } | 2461 | } |
2458 | } | 2462 | } |
2459 | if ( resetval ) { | 2463 | if ( resetval ) { |
2460 | sizes.clear(); | 2464 | sizes.clear(); |
2461 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2465 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2462 | maxVal = QApplication::desktop()->width() -10; | 2466 | maxVal = QApplication::desktop()->width() -10; |
2463 | } else { | 2467 | } else { |
2464 | maxVal = QApplication::desktop()->height()-10; | 2468 | maxVal = QApplication::desktop()->height()-10; |
2465 | } | 2469 | } |
2466 | sizes << resetval; | 2470 | sizes << resetval; |
2467 | if ( maxVal < resetval + resetval) | 2471 | if ( maxVal < resetval + resetval) |
2468 | resetval = maxVal - resetval; | 2472 | resetval = maxVal - resetval; |
2469 | sizes << resetval; | 2473 | sizes << resetval; |
2470 | } | 2474 | } |
2471 | mMainFrame->setSizes(sizes); | 2475 | mMainFrame->setSizes(sizes); |
2472 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2476 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2473 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2477 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2474 | else mNavigator->selectDates( dateCount ); | 2478 | else mNavigator->selectDates( dateCount ); |
2475 | // mViewManager->readSettings( config ); | 2479 | // mViewManager->readSettings( config ); |
2476 | updateConfig(); | 2480 | updateConfig(); |
2477 | globalFlagBlockAgenda = 2; | 2481 | globalFlagBlockAgenda = 2; |
2478 | mViewManager->readSettings( config ); | 2482 | mViewManager->readSettings( config ); |
2479 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2483 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2480 | } | 2484 | } |
2481 | 2485 | ||
2482 | void CalendarView::checkSuspendAlarm() | 2486 | void CalendarView::checkSuspendAlarm() |
2483 | { | 2487 | { |
2484 | if ( mSuspendTimer->isActive() ) { | 2488 | if ( mSuspendTimer->isActive() ) { |
2485 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2489 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2486 | } | 2490 | } |
2487 | } | 2491 | } |
2488 | void CalendarView::writeSettings() | 2492 | void CalendarView::writeSettings() |
2489 | { | 2493 | { |
2490 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2494 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2491 | 2495 | ||
2492 | KConfig *config = KOGlobals::config(); | 2496 | KConfig *config = KOGlobals::config(); |
2493 | 2497 | ||
2494 | mViewManager->writeSettings( config ); | 2498 | mViewManager->writeSettings( config ); |
2495 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2499 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2496 | mDialogManager->writeSettings( config ); | 2500 | mDialogManager->writeSettings( config ); |
2497 | //KOPrefs::instance()->usrWriteConfig(); | 2501 | //KOPrefs::instance()->usrWriteConfig(); |
2498 | KOPrefs::instance()->writeConfig(); | 2502 | KOPrefs::instance()->writeConfig(); |
2499 | 2503 | ||
2500 | writeFilterSettings(config); | 2504 | writeFilterSettings(config); |
2501 | config->setGroup( "AppRun" ); | 2505 | config->setGroup( "AppRun" ); |
2502 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2506 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2503 | int days = dt.daysTo( QDate::currentDate() ); | 2507 | int days = dt.daysTo( QDate::currentDate() ); |
2504 | dt = dt.addDays( days ); | 2508 | dt = dt.addDays( days ); |
2505 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2509 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2506 | config->writeEntry( "LatestProgramStopDays", days ); | 2510 | config->writeEntry( "LatestProgramStopDays", days ); |
2507 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2511 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2508 | //qDebug("KO: Writing stop time: %d ", secs); | 2512 | //qDebug("KO: Writing stop time: %d ", secs); |
2509 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2513 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2510 | //QDateTime latest = dt.addSecs ( secs ); | 2514 | //QDateTime latest = dt.addSecs ( secs ); |
2511 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2515 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2512 | config->setGroup( "Views" ); | 2516 | config->setGroup( "Views" ); |
2513 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2517 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2514 | 2518 | ||
2515 | #if 0 | 2519 | #if 0 |
2516 | qDebug("********************* "); | 2520 | qDebug("********************* "); |
2517 | qDebug("Testcode secsto "); | 2521 | qDebug("Testcode secsto "); |
2518 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2522 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2519 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2523 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2520 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2524 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2521 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2525 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2522 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2526 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2523 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2527 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2524 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2528 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2525 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2529 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2526 | qDebug("********************* testcode end"); | 2530 | qDebug("********************* testcode end"); |
2527 | 2531 | ||
2528 | #endif | 2532 | #endif |
2529 | 2533 | ||
2530 | QValueList<int> listINT = mLeftFrame->sizes(); | 2534 | QValueList<int> listINT = mLeftFrame->sizes(); |
2531 | config->writeEntry("Left Splitter Frame",listINT); | 2535 | config->writeEntry("Left Splitter Frame",listINT); |
2532 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2536 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2533 | config->writeEntry("Main Splitter Frame",listINT2); | 2537 | config->writeEntry("Main Splitter Frame",listINT2); |
2534 | #ifdef DESKTOP_VERSION | 2538 | #ifdef DESKTOP_VERSION |
2535 | config->setGroup("WidgetLayout"); | 2539 | config->setGroup("WidgetLayout"); |
2536 | QStringList list ;//= config->readListEntry("MainLayout"); | 2540 | QStringList list ;//= config->readListEntry("MainLayout"); |
2537 | int x,y,w,h; | 2541 | int x,y,w,h; |
2538 | QWidget* wid; | 2542 | QWidget* wid; |
2539 | wid = topLevelWidget(); | 2543 | wid = topLevelWidget(); |
2540 | x = wid->geometry().x(); | 2544 | x = wid->geometry().x(); |
2541 | y = wid->geometry().y(); | 2545 | y = wid->geometry().y(); |
2542 | w = wid->width(); | 2546 | w = wid->width(); |
2543 | h = wid->height(); | 2547 | h = wid->height(); |
2544 | list.clear(); | 2548 | list.clear(); |
2545 | list << QString::number( x ); | 2549 | list << QString::number( x ); |
2546 | list << QString::number( y ); | 2550 | list << QString::number( y ); |
2547 | list << QString::number( w ); | 2551 | list << QString::number( w ); |
2548 | list << QString::number( h ); | 2552 | list << QString::number( h ); |
2549 | config->writeEntry("MainLayout",list ); | 2553 | config->writeEntry("MainLayout",list ); |
2550 | 2554 | ||
2551 | wid = mEventEditor; | 2555 | wid = mEventEditor; |
2552 | x = wid->geometry().x(); | 2556 | x = wid->geometry().x(); |
2553 | y = wid->geometry().y(); | 2557 | y = wid->geometry().y(); |
2554 | w = wid->width(); | 2558 | w = wid->width(); |
2555 | h = wid->height(); | 2559 | h = wid->height(); |
2556 | list.clear(); | 2560 | list.clear(); |
2557 | list << QString::number( x ); | 2561 | list << QString::number( x ); |
2558 | list << QString::number( y ); | 2562 | list << QString::number( y ); |
2559 | list << QString::number( w ); | 2563 | list << QString::number( w ); |
2560 | list << QString::number( h ); | 2564 | list << QString::number( h ); |
2561 | config->writeEntry("EditEventLayout",list ); | 2565 | config->writeEntry("EditEventLayout",list ); |
2562 | 2566 | ||
2563 | wid = mTodoEditor; | 2567 | wid = mTodoEditor; |
2564 | x = wid->geometry().x(); | 2568 | x = wid->geometry().x(); |
2565 | y = wid->geometry().y(); | 2569 | y = wid->geometry().y(); |
2566 | w = wid->width(); | 2570 | w = wid->width(); |
2567 | h = wid->height(); | 2571 | h = wid->height(); |
2568 | list.clear(); | 2572 | list.clear(); |
2569 | list << QString::number( x ); | 2573 | list << QString::number( x ); |
2570 | list << QString::number( y ); | 2574 | list << QString::number( y ); |
2571 | list << QString::number( w ); | 2575 | list << QString::number( w ); |
2572 | list << QString::number( h ); | 2576 | list << QString::number( h ); |
2573 | config->writeEntry("EditTodoLayout",list ); | 2577 | config->writeEntry("EditTodoLayout",list ); |
2574 | wid = getEventViewerDialog(); | 2578 | wid = getEventViewerDialog(); |
2575 | x = wid->geometry().x(); | 2579 | x = wid->geometry().x(); |
2576 | y = wid->geometry().y(); | 2580 | y = wid->geometry().y(); |
2577 | w = wid->width(); | 2581 | w = wid->width(); |
2578 | h = wid->height(); | 2582 | h = wid->height(); |
2579 | list.clear(); | 2583 | list.clear(); |
2580 | list << QString::number( x ); | 2584 | list << QString::number( x ); |
2581 | list << QString::number( y ); | 2585 | list << QString::number( y ); |
2582 | list << QString::number( w ); | 2586 | list << QString::number( w ); |
2583 | list << QString::number( h ); | 2587 | list << QString::number( h ); |
2584 | config->writeEntry("ViewerLayout",list ); | 2588 | config->writeEntry("ViewerLayout",list ); |
2585 | wid = mDialogManager->getSearchDialog(); | 2589 | wid = mDialogManager->getSearchDialog(); |
2586 | if ( wid ) { | 2590 | if ( wid ) { |
2587 | x = wid->geometry().x(); | 2591 | x = wid->geometry().x(); |
2588 | y = wid->geometry().y(); | 2592 | y = wid->geometry().y(); |
2589 | w = wid->width(); | 2593 | w = wid->width(); |
2590 | h = wid->height(); | 2594 | h = wid->height(); |
2591 | list.clear(); | 2595 | list.clear(); |
2592 | list << QString::number( x ); | 2596 | list << QString::number( x ); |
2593 | list << QString::number( y ); | 2597 | list << QString::number( y ); |
2594 | list << QString::number( w ); | 2598 | list << QString::number( w ); |
2595 | list << QString::number( h ); | 2599 | list << QString::number( h ); |
2596 | config->writeEntry("SearchLayout",list ); | 2600 | config->writeEntry("SearchLayout",list ); |
2597 | } | 2601 | } |
2598 | #endif | 2602 | #endif |
2599 | 2603 | ||
2600 | 2604 | ||
2601 | config->sync(); | 2605 | config->sync(); |
2602 | } | 2606 | } |
2603 | 2607 | ||
2604 | void CalendarView::readFilterSettings(KConfig *config) | 2608 | void CalendarView::readFilterSettings(KConfig *config) |
2605 | { | 2609 | { |
2606 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2610 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2607 | 2611 | ||
2608 | mFilters.clear(); | 2612 | mFilters.clear(); |
2609 | 2613 | ||
2610 | config->setGroup("General"); | 2614 | config->setGroup("General"); |
2611 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2615 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2612 | 2616 | ||
2613 | QStringList::ConstIterator it = filterList.begin(); | 2617 | QStringList::ConstIterator it = filterList.begin(); |
2614 | QStringList::ConstIterator end = filterList.end(); | 2618 | QStringList::ConstIterator end = filterList.end(); |
2615 | while(it != end) { | 2619 | while(it != end) { |
2616 | // kdDebug() << " filter: " << (*it) << endl; | 2620 | // kdDebug() << " filter: " << (*it) << endl; |
2617 | 2621 | ||
2618 | CalFilter *filter; | 2622 | CalFilter *filter; |
2619 | filter = new CalFilter(*it); | 2623 | filter = new CalFilter(*it); |
2620 | config->setGroup("Filter_" + (*it).utf8()); | 2624 | config->setGroup("Filter_" + (*it).utf8()); |
2621 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2625 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2622 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2626 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2623 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2627 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2624 | mFilters.append(filter); | 2628 | mFilters.append(filter); |
2625 | 2629 | ||
2626 | ++it; | 2630 | ++it; |
2627 | } | 2631 | } |
2628 | 2632 | ||
2629 | if (mFilters.count() == 0) { | 2633 | if (mFilters.count() == 0) { |
2630 | CalFilter *filter = new CalFilter(i18n("Default")); | 2634 | CalFilter *filter = new CalFilter(i18n("Default")); |
2631 | mFilters.append(filter); | 2635 | mFilters.append(filter); |
2632 | } | 2636 | } |
2633 | mFilterView->updateFilters(); | 2637 | mFilterView->updateFilters(); |
2634 | config->setGroup("FilterView"); | 2638 | config->setGroup("FilterView"); |
2635 | 2639 | ||
2636 | mFilterView->blockSignals(true); | 2640 | mFilterView->blockSignals(true); |
2637 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2641 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2638 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2642 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2639 | mFilterView->blockSignals(false); | 2643 | mFilterView->blockSignals(false); |
2640 | // We do it manually to avoid it being done twice by the above calls | 2644 | // We do it manually to avoid it being done twice by the above calls |
2641 | updateFilter(); | 2645 | updateFilter(); |
2642 | } | 2646 | } |
2643 | 2647 | ||
2644 | void CalendarView::writeFilterSettings(KConfig *config) | 2648 | void CalendarView::writeFilterSettings(KConfig *config) |
2645 | { | 2649 | { |
2646 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2650 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2647 | 2651 | ||
2648 | QStringList filterList; | 2652 | QStringList filterList; |
2649 | 2653 | ||
2650 | CalFilter *filter = mFilters.first(); | 2654 | CalFilter *filter = mFilters.first(); |
2651 | while(filter) { | 2655 | while(filter) { |
2652 | // kdDebug() << " fn: " << filter->name() << endl; | 2656 | // kdDebug() << " fn: " << filter->name() << endl; |
2653 | filterList << filter->name(); | 2657 | filterList << filter->name(); |
2654 | config->setGroup("Filter_" + filter->name().utf8()); | 2658 | config->setGroup("Filter_" + filter->name().utf8()); |
2655 | config->writeEntry("Criteria",filter->criteria()); | 2659 | config->writeEntry("Criteria",filter->criteria()); |
2656 | config->writeEntry("CategoryList",filter->categoryList()); | 2660 | config->writeEntry("CategoryList",filter->categoryList()); |
2657 | filter = mFilters.next(); | 2661 | filter = mFilters.next(); |
2658 | } | 2662 | } |
2659 | config->setGroup("General"); | 2663 | config->setGroup("General"); |
2660 | config->writeEntry("CalendarFilters",filterList); | 2664 | config->writeEntry("CalendarFilters",filterList); |
2661 | 2665 | ||
2662 | config->setGroup("FilterView"); | 2666 | config->setGroup("FilterView"); |
2663 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2667 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2664 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2668 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2665 | } | 2669 | } |
2666 | 2670 | ||
2667 | 2671 | ||
2668 | void CalendarView::goToday() | 2672 | void CalendarView::goToday() |
2669 | { | 2673 | { |
2670 | if ( mViewManager->currentView()->isMonthView() ) | 2674 | if ( mViewManager->currentView()->isMonthView() ) |
2671 | mNavigator->selectTodayMonth(); | 2675 | mNavigator->selectTodayMonth(); |
2672 | else | 2676 | else |
2673 | mNavigator->selectToday(); | 2677 | mNavigator->selectToday(); |
2674 | } | 2678 | } |
2675 | 2679 | ||
2676 | void CalendarView::goNext() | 2680 | void CalendarView::goNext() |
2677 | { | 2681 | { |
2678 | mNavigator->selectNext(); | 2682 | mNavigator->selectNext(); |
2679 | } | 2683 | } |
2680 | 2684 | ||
2681 | void CalendarView::goPrevious() | 2685 | void CalendarView::goPrevious() |
2682 | { | 2686 | { |
2683 | mNavigator->selectPrevious(); | 2687 | mNavigator->selectPrevious(); |
2684 | } | 2688 | } |
2685 | void CalendarView::goNextMonth() | 2689 | void CalendarView::goNextMonth() |
2686 | { | 2690 | { |
2687 | mNavigator->selectNextMonth(); | 2691 | mNavigator->selectNextMonth(); |
2688 | } | 2692 | } |
2689 | 2693 | ||
2690 | void CalendarView::goPreviousMonth() | 2694 | void CalendarView::goPreviousMonth() |
2691 | { | 2695 | { |
2692 | mNavigator->selectPreviousMonth(); | 2696 | mNavigator->selectPreviousMonth(); |
2693 | } | 2697 | } |
2694 | 2698 | ||
2695 | void CalendarView::updateConfig() | 2699 | void CalendarView::updateConfig() |
2696 | { | 2700 | { |
2697 | if ( KOPrefs::instance()->mUseAppColors ) | 2701 | if ( KOPrefs::instance()->mUseAppColors ) |
2698 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2702 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2699 | emit configChanged(); | 2703 | emit configChanged(); |
2700 | mTodoList->updateConfig(); | 2704 | mTodoList->updateConfig(); |
2701 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2705 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2702 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2706 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2703 | // To make the "fill window" configurations work | 2707 | // To make the "fill window" configurations work |
2704 | //mViewManager->raiseCurrentView(); | 2708 | //mViewManager->raiseCurrentView(); |
2705 | } | 2709 | } |
2706 | 2710 | ||
2707 | 2711 | ||
2708 | void CalendarView::eventChanged(Event *event) | 2712 | void CalendarView::eventChanged(Event *event) |
2709 | { | 2713 | { |
2710 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2714 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2711 | //updateUnmanagedViews(); | 2715 | //updateUnmanagedViews(); |
2712 | } | 2716 | } |
2713 | 2717 | ||
2714 | void CalendarView::eventAdded(Event *event) | 2718 | void CalendarView::eventAdded(Event *event) |
2715 | { | 2719 | { |
2716 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2720 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2717 | } | 2721 | } |
2718 | 2722 | ||
2719 | void CalendarView::eventToBeDeleted(Event *) | 2723 | void CalendarView::eventToBeDeleted(Event *) |
2720 | { | 2724 | { |
2721 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2725 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2722 | } | 2726 | } |
2723 | 2727 | ||
2724 | void CalendarView::eventDeleted() | 2728 | void CalendarView::eventDeleted() |
2725 | { | 2729 | { |
2726 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2730 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2727 | } | 2731 | } |
2728 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2732 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2729 | { | 2733 | { |
2730 | changeIncidenceDisplay((Incidence *)which, action); | 2734 | changeIncidenceDisplay((Incidence *)which, action); |
2731 | mDateNavigator->updateView(); //LR | 2735 | mDateNavigator->updateView(); //LR |
2732 | //mDialogManager->updateSearchDialog(); | 2736 | //mDialogManager->updateSearchDialog(); |
2733 | 2737 | ||
2734 | if (which) { | 2738 | if (which) { |
2735 | mViewManager->updateWNview(); | 2739 | mViewManager->updateWNview(); |
2736 | //mTodoList->updateView(); | 2740 | //mTodoList->updateView(); |
2737 | } | 2741 | } |
2738 | 2742 | ||
2739 | } | 2743 | } |
2740 | 2744 | ||
2741 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2745 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2742 | { | 2746 | { |
2743 | updateUnmanagedViews(); | 2747 | updateUnmanagedViews(); |
2744 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2748 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2745 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2749 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2746 | mCalendar->checkAlarmForIncidence( 0, true ); | 2750 | mCalendar->checkAlarmForIncidence( 0, true ); |
2747 | if ( mEventViewerDialog ) | 2751 | if ( mEventViewerDialog ) |
2748 | mEventViewerDialog->hide(); | 2752 | mEventViewerDialog->hide(); |
2749 | } | 2753 | } |
2750 | else | 2754 | else |
2751 | mCalendar->checkAlarmForIncidence( which , false ); | 2755 | mCalendar->checkAlarmForIncidence( which , false ); |
2752 | } | 2756 | } |
2753 | 2757 | ||
2754 | // most of the changeEventDisplays() right now just call the view's | 2758 | // most of the changeEventDisplays() right now just call the view's |
2755 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2759 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2756 | void CalendarView::changeEventDisplay(Event *which, int action) | 2760 | void CalendarView::changeEventDisplay(Event *which, int action) |
2757 | { | 2761 | { |
2758 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2762 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2759 | changeIncidenceDisplay((Incidence *)which, action); | 2763 | changeIncidenceDisplay((Incidence *)which, action); |
2760 | static bool clearallviews = false; | 2764 | static bool clearallviews = false; |
2761 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2765 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2762 | if ( clearallviews ) { | 2766 | if ( clearallviews ) { |
2763 | clearAllViews(); | 2767 | clearAllViews(); |
2764 | clearallviews = false; | 2768 | clearallviews = false; |
2765 | } | 2769 | } |
2766 | return; | 2770 | return; |
2767 | } | 2771 | } |
2768 | clearallviews = true; | 2772 | clearallviews = true; |
2769 | mDateNavigator->updateView(); | 2773 | mDateNavigator->updateView(); |
2770 | //mDialogManager->updateSearchDialog(); | 2774 | //mDialogManager->updateSearchDialog(); |
2771 | if (which) { | 2775 | if (which) { |
2772 | // If there is an event view visible update the display | 2776 | // If there is an event view visible update the display |
2773 | mViewManager->currentView()->changeEventDisplay(which,action); | 2777 | mViewManager->currentView()->changeEventDisplay(which,action); |
2774 | // TODO: check, if update needed | 2778 | // TODO: check, if update needed |
2775 | // if (which->getTodoStatus()) { | 2779 | // if (which->getTodoStatus()) { |
2776 | mTodoList->updateView(); | 2780 | mTodoList->updateView(); |
2777 | if ( action != KOGlobals::EVENTDELETED ) { | 2781 | if ( action != KOGlobals::EVENTDELETED ) { |
2778 | mConflictingEvent = which ; | 2782 | mConflictingEvent = which ; |
2779 | int time = 1000; | 2783 | int time = 1000; |
2780 | #ifdef DESKTOP_VERSION | 2784 | #ifdef DESKTOP_VERSION |
2781 | time = 500; | 2785 | time = 500; |
2782 | #endif | 2786 | #endif |
2783 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); | 2787 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); |
2784 | } | 2788 | } |
2785 | // } | 2789 | // } |
2786 | } else { | 2790 | } else { |
2787 | mViewManager->currentView()->updateView(); | 2791 | mViewManager->currentView()->updateView(); |
2788 | } | 2792 | } |
2789 | } | 2793 | } |
2790 | void CalendarView::checkConflictForEvent() | 2794 | void CalendarView::checkConflictForEvent() |
2791 | { | 2795 | { |
2792 | 2796 | ||
2793 | if (!KOPrefs::instance()->mConfirm) | 2797 | if (!KOPrefs::instance()->mConfirm) |
2794 | return; | 2798 | return; |
2795 | if ( ! mConflictingEvent ) return; | 2799 | if ( ! mConflictingEvent ) return; |
2796 | Event * conflictingEvent = mConflictingEvent; | 2800 | Event * conflictingEvent = mConflictingEvent; |
2797 | mConflictingEvent = 0; | 2801 | mConflictingEvent = 0; |
2798 | QDateTime current = QDateTime::currentDateTime(); | 2802 | QDateTime current = QDateTime::currentDateTime(); |
2799 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { | 2803 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { |
2800 | return; | 2804 | return; |
2801 | } | 2805 | } |
2802 | QPtrList<Event> testlist = mCalendar->events(); | 2806 | QPtrList<Event> testlist = mCalendar->events(); |
2803 | Event * test = testlist.first(); | 2807 | Event * test = testlist.first(); |
2804 | QDateTime conflict; | 2808 | QDateTime conflict; |
2805 | QDateTime retVal; | 2809 | QDateTime retVal; |
2806 | bool found = false; | 2810 | bool found = false; |
2807 | Event * cE = 0; | 2811 | Event * cE = 0; |
2808 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 2812 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
2809 | while ( test ) { | 2813 | while ( test ) { |
2810 | qApp->processEvents(); | 2814 | qApp->processEvents(); |
2811 | bool skip = false; | 2815 | bool skip = false; |
2812 | if ( found ) | 2816 | if ( found ) |
2813 | skip = !test->matchTime( ¤t, &conflict ); | 2817 | skip = !test->matchTime( ¤t, &conflict ); |
2814 | else | 2818 | else |
2815 | skip = !test->matchTime( ¤t, 0 ); | 2819 | skip = !test->matchTime( ¤t, 0 ); |
2816 | if ( !skip && !test->doesFloat() ) { | 2820 | if ( !skip && !test->doesFloat() ) { |
2817 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 2821 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
2818 | if ( ! found ) { | 2822 | if ( ! found ) { |
2819 | conflict = retVal; | 2823 | conflict = retVal; |
2820 | cE = test; | 2824 | cE = test; |
2821 | } else { | 2825 | } else { |
2822 | if ( retVal < conflict ) { | 2826 | if ( retVal < conflict ) { |
2823 | conflict = retVal; | 2827 | conflict = retVal; |
2824 | cE = test; | 2828 | cE = test; |
2825 | } | 2829 | } |
2826 | } | 2830 | } |
2827 | found = true; | 2831 | found = true; |
2828 | } | 2832 | } |
2829 | } | 2833 | } |
2830 | test = testlist.next(); | 2834 | test = testlist.next(); |
2831 | } | 2835 | } |
2832 | topLevelWidget()->setCaption( i18n("KO/Pi") ); | 2836 | topLevelWidget()->setCaption( i18n("KO/Pi") ); |
2833 | if ( found ) { | 2837 | if ( found ) { |
2834 | 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()) ) ; | 2838 | 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()) ) ; |
2835 | qApp->processEvents(); | 2839 | qApp->processEvents(); |
2836 | int km = KMessageBox::warningContinueCancel(this,mess, | 2840 | int km = KMessageBox::warningContinueCancel(this,mess, |
2837 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | 2841 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); |
2838 | if ( km != KMessageBox::Continue ) { | 2842 | if ( km != KMessageBox::Continue ) { |
2839 | return; | 2843 | return; |
2840 | } | 2844 | } |
2841 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 2845 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
2842 | mViewManager->showDayView(); | 2846 | mViewManager->showDayView(); |
2843 | mNavigator->slotDaySelect( conflict.date() ); | 2847 | mNavigator->slotDaySelect( conflict.date() ); |
2844 | int hour = conflict.time().hour(); | 2848 | int hour = conflict.time().hour(); |
2845 | mViewManager->agendaView()->setStartHour( hour ); | 2849 | mViewManager->agendaView()->setStartHour( hour ); |
2846 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 2850 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
2847 | } else | 2851 | } else |
2848 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 2852 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
2849 | return; | 2853 | return; |
2850 | 2854 | ||
2851 | } | 2855 | } |
2852 | 2856 | ||
2853 | void CalendarView::updateTodoViews() | 2857 | void CalendarView::updateTodoViews() |
2854 | { | 2858 | { |
2855 | mTodoList->updateView(); | 2859 | mTodoList->updateView(); |
2856 | mViewManager->currentView()->updateView(); | 2860 | mViewManager->currentView()->updateView(); |
2857 | 2861 | ||
2858 | } | 2862 | } |
2859 | 2863 | ||
2860 | 2864 | ||
2861 | 2865 | ||
2862 | void CalendarView::clearAllViews() | 2866 | void CalendarView::clearAllViews() |
2863 | { | 2867 | { |
2864 | mTodoList->clearList(); | 2868 | mTodoList->clearList(); |
2865 | mViewManager->clearAllViews(); | 2869 | mViewManager->clearAllViews(); |
2866 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2870 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2867 | if ( sd ) { | 2871 | if ( sd ) { |
2868 | KOListView* kol = sd->listview(); | 2872 | KOListView* kol = sd->listview(); |
2869 | if ( kol ) | 2873 | if ( kol ) |
2870 | kol->clearList(); | 2874 | kol->clearList(); |
2871 | } | 2875 | } |
2872 | } | 2876 | } |
2873 | void CalendarView::updateView() | 2877 | void CalendarView::updateView() |
2874 | { | 2878 | { |
2875 | static bool clearallviews = false; | 2879 | static bool clearallviews = false; |
2876 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2880 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2877 | if ( clearallviews ) { | 2881 | if ( clearallviews ) { |
2878 | clearAllViews(); | 2882 | clearAllViews(); |
2879 | clearallviews = false; | 2883 | clearallviews = false; |
2880 | } | 2884 | } |
2881 | return; | 2885 | return; |
2882 | } | 2886 | } |
2883 | clearallviews = true; | 2887 | clearallviews = true; |
2884 | DateList tmpList = mNavigator->selectedDates(); | 2888 | DateList tmpList = mNavigator->selectedDates(); |
2885 | 2889 | ||
2886 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2890 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2887 | mTodoList->updateView(); | 2891 | mTodoList->updateView(); |
2888 | // We assume that the navigator only selects consecutive days. | 2892 | // We assume that the navigator only selects consecutive days. |
2889 | updateView( tmpList.first(), tmpList.last() ); | 2893 | updateView( tmpList.first(), tmpList.last() ); |
2890 | } | 2894 | } |
2891 | 2895 | ||
2892 | void CalendarView::updateUnmanagedViews() | 2896 | void CalendarView::updateUnmanagedViews() |
2893 | { | 2897 | { |
2894 | mDateNavigator->updateDayMatrix(); | 2898 | mDateNavigator->updateDayMatrix(); |
2895 | } | 2899 | } |
2896 | 2900 | ||
2897 | int CalendarView::msgItemDelete(const QString name) | 2901 | int CalendarView::msgItemDelete(const QString name) |
2898 | { | 2902 | { |
2899 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2903 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2900 | i18n("This item will be\npermanently deleted."), | 2904 | i18n("This item will be\npermanently deleted."), |
2901 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2905 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2902 | } | 2906 | } |
2903 | 2907 | ||
2904 | 2908 | ||
2905 | void CalendarView::edit_cut() | 2909 | void CalendarView::edit_cut() |
2906 | { | 2910 | { |
2907 | Event *anEvent=0; | 2911 | Event *anEvent=0; |
2908 | 2912 | ||
2909 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2913 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2910 | 2914 | ||
2911 | if (mViewManager->currentView()->isEventView()) { | 2915 | if (mViewManager->currentView()->isEventView()) { |
2912 | if ( incidence && incidence->typeID() == eventID ) { | 2916 | if ( incidence && incidence->typeID() == eventID ) { |
2913 | anEvent = static_cast<Event *>(incidence); | 2917 | anEvent = static_cast<Event *>(incidence); |
2914 | } | 2918 | } |
2915 | } | 2919 | } |
2916 | 2920 | ||
2917 | if (!anEvent) { | 2921 | if (!anEvent) { |
2918 | KNotifyClient::beep(); | 2922 | KNotifyClient::beep(); |
2919 | return; | 2923 | return; |
2920 | } | 2924 | } |
2921 | DndFactory factory( mCalendar ); | 2925 | DndFactory factory( mCalendar ); |
2922 | factory.cutIncidence(anEvent); | 2926 | factory.cutIncidence(anEvent); |
2923 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2927 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2924 | } | 2928 | } |
2925 | 2929 | ||
2926 | void CalendarView::edit_copy() | 2930 | void CalendarView::edit_copy() |
2927 | { | 2931 | { |
2928 | Event *anEvent=0; | 2932 | Event *anEvent=0; |
2929 | 2933 | ||
2930 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2934 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2931 | 2935 | ||
2932 | if (mViewManager->currentView()->isEventView()) { | 2936 | if (mViewManager->currentView()->isEventView()) { |
2933 | if ( incidence && incidence->typeID() == eventID ) { | 2937 | if ( incidence && incidence->typeID() == eventID ) { |
2934 | anEvent = static_cast<Event *>(incidence); | 2938 | anEvent = static_cast<Event *>(incidence); |
2935 | } | 2939 | } |
2936 | } | 2940 | } |
2937 | 2941 | ||
2938 | if (!anEvent) { | 2942 | if (!anEvent) { |
2939 | KNotifyClient::beep(); | 2943 | KNotifyClient::beep(); |
2940 | return; | 2944 | return; |
2941 | } | 2945 | } |
2942 | DndFactory factory( mCalendar ); | 2946 | DndFactory factory( mCalendar ); |
2943 | factory.copyIncidence(anEvent); | 2947 | factory.copyIncidence(anEvent); |
2944 | } | 2948 | } |
2945 | 2949 | ||
2946 | void CalendarView::edit_paste() | 2950 | void CalendarView::edit_paste() |
2947 | { | 2951 | { |
2948 | QDate date = mNavigator->selectedDates().first(); | 2952 | QDate date = mNavigator->selectedDates().first(); |
2949 | 2953 | ||
2950 | DndFactory factory( mCalendar ); | 2954 | DndFactory factory( mCalendar ); |
2951 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2955 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2952 | 2956 | ||
2953 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2957 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2954 | } | 2958 | } |
2955 | void CalendarView::edit_global_options() | 2959 | void CalendarView::edit_global_options() |
2956 | { | 2960 | { |
2957 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2961 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2958 | emit save(); | 2962 | emit save(); |
2959 | emit saveStopTimer(); | 2963 | emit saveStopTimer(); |
2960 | mDialogManager->showGlobalOptionsDialog(); | 2964 | mDialogManager->showGlobalOptionsDialog(); |
2961 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2965 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2962 | emit saveStopTimer(); | 2966 | emit saveStopTimer(); |
2963 | 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!"), | 2967 | 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!"), |
2964 | i18n("Timezone settings"),i18n("Reload"))) { | 2968 | i18n("Timezone settings"),i18n("Reload"))) { |
2965 | qDebug("KO: TZ reload cancelled "); | 2969 | qDebug("KO: TZ reload cancelled "); |
2966 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2970 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2967 | return; | 2971 | return; |
2968 | } | 2972 | } |
2969 | qDebug("KO: Timezone change "); | 2973 | qDebug("KO: Timezone change "); |
2970 | loadCalendars(); | 2974 | loadCalendars(); |
2971 | setModified(true); | 2975 | setModified(true); |
2972 | } | 2976 | } |
2973 | else | 2977 | else |
2974 | qDebug("KO: No tz change "); | 2978 | qDebug("KO: No tz change "); |
2975 | } | 2979 | } |
2976 | void CalendarView::edit_options() | 2980 | void CalendarView::edit_options() |
2977 | { | 2981 | { |
2978 | mDialogManager->showOptionsDialog(); | 2982 | mDialogManager->showOptionsDialog(); |
2979 | } | 2983 | } |
2980 | 2984 | ||
2981 | 2985 | ||
2982 | void CalendarView::slotSelectPickerDate( QDate d) | 2986 | void CalendarView::slotSelectPickerDate( QDate d) |
2983 | { | 2987 | { |
2984 | mDateFrame->hide(); | 2988 | mDateFrame->hide(); |
2985 | if ( mDatePickerMode == 1 ) { | 2989 | if ( mDatePickerMode == 1 ) { |
2986 | mNavigator->slotDaySelect( d ); | 2990 | mNavigator->slotDaySelect( d ); |
2987 | } else if ( mDatePickerMode == 2 ) { | 2991 | } else if ( mDatePickerMode == 2 ) { |
2988 | if ( mMoveIncidence->typeID() == todoID ) { | 2992 | if ( mMoveIncidence->typeID() == todoID ) { |
2989 | Todo * to = (Todo *) mMoveIncidence; | 2993 | Todo * to = (Todo *) mMoveIncidence; |
2990 | QTime tim; | 2994 | QTime tim; |
2991 | int len = 0; | 2995 | int len = 0; |
2992 | if ( to->hasStartDate() && to->hasDueDate() ) | 2996 | if ( to->hasStartDate() && to->hasDueDate() ) |
2993 | len = to->dtStart().secsTo( to->dtDue()); | 2997 | len = to->dtStart().secsTo( to->dtDue()); |
2994 | if ( to->hasDueDate() ) | 2998 | if ( to->hasDueDate() ) |
2995 | tim = to->dtDue().time(); | 2999 | tim = to->dtDue().time(); |
2996 | else { | 3000 | else { |
2997 | tim = QTime ( 0,0,0 ); | 3001 | tim = QTime ( 0,0,0 ); |
2998 | to->setFloats( true ); | 3002 | to->setFloats( true ); |
2999 | to->setHasDueDate( true ); | 3003 | to->setHasDueDate( true ); |
3000 | } | 3004 | } |
3001 | QDateTime dt ( d,tim ); | 3005 | QDateTime dt ( d,tim ); |
3002 | to->setDtDue( dt ); | 3006 | to->setDtDue( dt ); |
3003 | 3007 | ||
3004 | if ( to->hasStartDate() ) { | 3008 | if ( to->hasStartDate() ) { |
3005 | if ( len>0 ) | 3009 | if ( len>0 ) |
3006 | to->setDtStart(to->dtDue().addSecs( -len )); | 3010 | to->setDtStart(to->dtDue().addSecs( -len )); |
3007 | else | 3011 | else |
3008 | if (to->dtStart() > to->dtDue() ) | 3012 | if (to->dtStart() > to->dtDue() ) |
3009 | to->setDtStart(to->dtDue().addDays( -3 )); | 3013 | to->setDtStart(to->dtDue().addDays( -3 )); |
3010 | } | 3014 | } |
3011 | 3015 | ||
3012 | todoChanged( to ); | 3016 | todoChanged( to ); |
3013 | } else if ( mMoveIncidence->typeID() == eventID ) { | 3017 | } else if ( mMoveIncidence->typeID() == eventID ) { |
3014 | if ( mMoveIncidence->doesRecur() ) { | 3018 | if ( mMoveIncidence->doesRecur() ) { |
3015 | #if 0 | 3019 | #if 0 |
3016 | // PENDING implement this | 3020 | // PENDING implement this |
3017 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 3021 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3018 | mCalendar()->addIncidence( newInc ); | 3022 | mCalendar()->addIncidence( newInc ); |
3019 | if ( mMoveIncidence->typeID() == todoID ) | 3023 | if ( mMoveIncidence->typeID() == todoID ) |
3020 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 3024 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3021 | else | 3025 | else |
3022 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 3026 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3023 | mMoveIncidence = newInc; | 3027 | mMoveIncidence = newInc; |
3024 | 3028 | ||
3025 | #endif | 3029 | #endif |
3026 | } | 3030 | } |
3027 | QTime tim = mMoveIncidence->dtStart().time(); | 3031 | QTime tim = mMoveIncidence->dtStart().time(); |
3028 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 3032 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3029 | QDateTime dt ( d,tim ); | 3033 | QDateTime dt ( d,tim ); |
3030 | mMoveIncidence->setDtStart( dt ); | 3034 | mMoveIncidence->setDtStart( dt ); |
3031 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 3035 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3032 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 3036 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3033 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3037 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3034 | QTime tim = mMoveIncidence->dtStart().time(); | 3038 | QTime tim = mMoveIncidence->dtStart().time(); |
3035 | QDateTime dt ( d,tim ); | 3039 | QDateTime dt ( d,tim ); |
3036 | mMoveIncidence->setDtStart( dt ); | 3040 | mMoveIncidence->setDtStart( dt ); |
3037 | updateView(); | 3041 | updateView(); |
3038 | } | 3042 | } |
3039 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3043 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3040 | } | 3044 | } |
3041 | } | 3045 | } |
3042 | 3046 | ||
3043 | void CalendarView::removeCategories() | 3047 | void CalendarView::removeCategories() |
3044 | { | 3048 | { |
3045 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3049 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3046 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3050 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3047 | QStringList catIncList; | 3051 | QStringList catIncList; |
3048 | QStringList newCatList; | 3052 | QStringList newCatList; |
3049 | Incidence* inc = incList.first(); | 3053 | Incidence* inc = incList.first(); |
3050 | uint i; | 3054 | uint i; |
3051 | while ( inc ) { | 3055 | while ( inc ) { |
3052 | newCatList.clear(); | 3056 | newCatList.clear(); |
3053 | catIncList = inc->categories() ; | 3057 | catIncList = inc->categories() ; |
3054 | for( i = 0; i< catIncList.count(); ++i ) { | 3058 | for( i = 0; i< catIncList.count(); ++i ) { |
3055 | if ( catList.contains (catIncList[i])) | 3059 | if ( catList.contains (catIncList[i])) |
3056 | newCatList.append( catIncList[i] ); | 3060 | newCatList.append( catIncList[i] ); |
3057 | } | 3061 | } |
3058 | newCatList.sort(); | 3062 | newCatList.sort(); |
3059 | inc->setCategories( newCatList.join(",") ); | 3063 | inc->setCategories( newCatList.join(",") ); |
3060 | inc = incList.next(); | 3064 | inc = incList.next(); |
3061 | } | 3065 | } |
3062 | } | 3066 | } |
3063 | 3067 | ||
3064 | int CalendarView::addCategories() | 3068 | int CalendarView::addCategories() |
3065 | { | 3069 | { |
3066 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3070 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3067 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3071 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3068 | QStringList catIncList; | 3072 | QStringList catIncList; |
3069 | Incidence* inc = incList.first(); | 3073 | Incidence* inc = incList.first(); |
3070 | uint i; | 3074 | uint i; |
3071 | int count = 0; | 3075 | int count = 0; |
3072 | while ( inc ) { | 3076 | while ( inc ) { |
3073 | catIncList = inc->categories() ; | 3077 | catIncList = inc->categories() ; |
3074 | for( i = 0; i< catIncList.count(); ++i ) { | 3078 | for( i = 0; i< catIncList.count(); ++i ) { |
3075 | if ( !catList.contains (catIncList[i])) { | 3079 | if ( !catList.contains (catIncList[i])) { |
3076 | catList.append( catIncList[i] ); | 3080 | catList.append( catIncList[i] ); |
3077 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3081 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3078 | ++count; | 3082 | ++count; |
3079 | } | 3083 | } |
3080 | } | 3084 | } |
3081 | inc = incList.next(); | 3085 | inc = incList.next(); |
3082 | } | 3086 | } |
3083 | catList.sort(); | 3087 | catList.sort(); |
3084 | KOPrefs::instance()->mCustomCategories = catList; | 3088 | KOPrefs::instance()->mCustomCategories = catList; |
3085 | return count; | 3089 | return count; |
3086 | } | 3090 | } |
3087 | 3091 | ||
3088 | void CalendarView::editCategories() | 3092 | void CalendarView::editCategories() |
3089 | { | 3093 | { |
3090 | qDebug("CalendarView::editCategories() "); | 3094 | qDebug("CalendarView::editCategories() "); |
3091 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3095 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3092 | ced.exec(); | 3096 | ced.exec(); |
3093 | } | 3097 | } |
3094 | void CalendarView::manageCategories() | 3098 | void CalendarView::manageCategories() |
3095 | { | 3099 | { |
3096 | KOCatPrefs* cp = new KOCatPrefs(); | 3100 | KOCatPrefs* cp = new KOCatPrefs(); |
3097 | cp->show(); | 3101 | cp->show(); |
3098 | int w =cp->sizeHint().width() ; | 3102 | int w =cp->sizeHint().width() ; |
3099 | int h = cp->sizeHint().height() ; | 3103 | int h = cp->sizeHint().height() ; |
3100 | int dw = QApplication::desktop()->width(); | 3104 | int dw = QApplication::desktop()->width(); |
3101 | int dh = QApplication::desktop()->height(); | 3105 | int dh = QApplication::desktop()->height(); |
3102 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3106 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3103 | if ( !cp->exec() ) { | 3107 | if ( !cp->exec() ) { |
3104 | delete cp; | 3108 | delete cp; |
3105 | return; | 3109 | return; |
3106 | } | 3110 | } |
3107 | int count = 0; | 3111 | int count = 0; |
3108 | if ( cp->addCat() ) { | 3112 | if ( cp->addCat() ) { |
3109 | count = addCategories(); | 3113 | count = addCategories(); |
3110 | if ( count ) { | 3114 | if ( count ) { |
3111 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3115 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3112 | writeSettings(); | 3116 | writeSettings(); |
3113 | } else | 3117 | } else |
3114 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3118 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3115 | } else { | 3119 | } else { |
3116 | removeCategories(); | 3120 | removeCategories(); |
3117 | updateView(); | 3121 | updateView(); |
3118 | } | 3122 | } |
3119 | delete cp; | 3123 | delete cp; |
3120 | } | 3124 | } |
3121 | 3125 | ||
3122 | void CalendarView::beamIncidence(Incidence * Inc) | 3126 | void CalendarView::beamIncidence(Incidence * Inc) |
3123 | { | 3127 | { |
3124 | QPtrList<Incidence> delSel ; | 3128 | QPtrList<Incidence> delSel ; |
3125 | delSel.append(Inc); | 3129 | delSel.append(Inc); |
3126 | beamIncidenceList( delSel ); | 3130 | beamIncidenceList( delSel ); |
3127 | } | 3131 | } |
3128 | void CalendarView::beamCalendar() | 3132 | void CalendarView::beamCalendar() |
3129 | { | 3133 | { |
3130 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3134 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3131 | //qDebug("beamCalendar() "); | 3135 | //qDebug("beamCalendar() "); |
3132 | beamIncidenceList( delSel ); | 3136 | beamIncidenceList( delSel ); |
3133 | } | 3137 | } |
3134 | void CalendarView::beamFilteredCalendar() | 3138 | void CalendarView::beamFilteredCalendar() |
3135 | { | 3139 | { |
3136 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3140 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3137 | //qDebug("beamFilteredCalendar() "); | 3141 | //qDebug("beamFilteredCalendar() "); |
3138 | beamIncidenceList( delSel ); | 3142 | beamIncidenceList( delSel ); |
3139 | } | 3143 | } |
3140 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3144 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3141 | { | 3145 | { |
3142 | 3146 | ||
3143 | KOBeamPrefs beamDialog; | 3147 | KOBeamPrefs beamDialog; |
3144 | if ( beamDialog.exec () == QDialog::Rejected ) | 3148 | if ( beamDialog.exec () == QDialog::Rejected ) |
3145 | return; | 3149 | return; |
3146 | #ifdef DESKTOP_VERSION | 3150 | #ifdef DESKTOP_VERSION |
3147 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3151 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3148 | #else | 3152 | #else |
3149 | QString fn = "/tmp/kopibeamfile"; | 3153 | QString fn = "/tmp/kopibeamfile"; |
3150 | #endif | 3154 | #endif |
3151 | QString mes; | 3155 | QString mes; |
3152 | bool createbup = true; | 3156 | bool createbup = true; |
3153 | if ( createbup ) { | 3157 | if ( createbup ) { |
3154 | QString description = "\n"; | 3158 | QString description = "\n"; |
3155 | CalendarLocal* cal = new CalendarLocal(); | 3159 | CalendarLocal* cal = new CalendarLocal(); |
3156 | if ( beamDialog.beamLocal() ) | 3160 | if ( beamDialog.beamLocal() ) |
3157 | cal->setLocalTime(); | 3161 | cal->setLocalTime(); |
3158 | else | 3162 | else |
3159 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3163 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3160 | Incidence *incidence = delSel.first(); | 3164 | Incidence *incidence = delSel.first(); |
3161 | bool addText = false; | 3165 | bool addText = false; |
3162 | if ( delSel.count() < 10 ) | 3166 | if ( delSel.count() < 10 ) |
3163 | addText = true; | 3167 | addText = true; |
3164 | else { | 3168 | else { |
3165 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3169 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3166 | } | 3170 | } |
3167 | while ( incidence ) { | 3171 | while ( incidence ) { |
3168 | Incidence *in = incidence->clone(); | 3172 | Incidence *in = incidence->clone(); |
3169 | if ( ! in->summary().isEmpty() ) { | 3173 | if ( ! in->summary().isEmpty() ) { |
3170 | in->setDescription(""); | 3174 | in->setDescription(""); |
3171 | } else { | 3175 | } else { |
3172 | in->setSummary( in->description().left(20)); | 3176 | in->setSummary( in->description().left(20)); |
3173 | in->setDescription(""); | 3177 | in->setDescription(""); |
3174 | } | 3178 | } |
3175 | if ( addText ) | 3179 | if ( addText ) |
3176 | description += in->summary() + "\n"; | 3180 | description += in->summary() + "\n"; |
3177 | cal->addIncidence( in ); | 3181 | cal->addIncidence( in ); |
3178 | incidence = delSel.next(); | 3182 | incidence = delSel.next(); |
3179 | } | 3183 | } |
3180 | if ( beamDialog.beamVcal() ) { | 3184 | if ( beamDialog.beamVcal() ) { |
3181 | fn += ".vcs"; | 3185 | fn += ".vcs"; |
3182 | FileStorage storage( cal, fn, new VCalFormat ); | 3186 | FileStorage storage( cal, fn, new VCalFormat ); |
3183 | storage.save(); | 3187 | storage.save(); |
3184 | } else { | 3188 | } else { |
3185 | fn += ".ics"; | 3189 | fn += ".ics"; |
3186 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3190 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3187 | storage.save(); | 3191 | storage.save(); |
3188 | } | 3192 | } |
3189 | delete cal; | 3193 | delete cal; |
3190 | mes = i18n("KO/Pi: Ready for beaming"); | 3194 | mes = i18n("KO/Pi: Ready for beaming"); |
3191 | topLevelWidget()->setCaption(mes); | 3195 | topLevelWidget()->setCaption(mes); |
3192 | KApplication::convert2latin1( fn ); | 3196 | KApplication::convert2latin1( fn ); |
3193 | #ifndef DESKTOP_VERSION | 3197 | #ifndef DESKTOP_VERSION |
3194 | Ir *ir = new Ir( this ); | 3198 | Ir *ir = new Ir( this ); |
3195 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3199 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3196 | ir->send( fn, description, "text/x-vCalendar" ); | 3200 | ir->send( fn, description, "text/x-vCalendar" ); |
3197 | #endif | 3201 | #endif |
3198 | } | 3202 | } |
3199 | } | 3203 | } |
3200 | 3204 | ||
3201 | #ifndef DESKTOP_VERSION | 3205 | #ifndef DESKTOP_VERSION |
3202 | void CalendarView::beamDone( Ir *ir ) | 3206 | void CalendarView::beamDone( Ir *ir ) |
3203 | { | 3207 | { |
3204 | delete ir; | 3208 | delete ir; |
3205 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3209 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3206 | topLevelWidget()->raise(); | 3210 | topLevelWidget()->raise(); |
3207 | } | 3211 | } |
3208 | #else | 3212 | #else |
3209 | void CalendarView::beamDone( Ir *){;} | 3213 | void CalendarView::beamDone( Ir *){;} |
3210 | #endif | 3214 | #endif |
3211 | void CalendarView::moveIncidence(Incidence * inc ) | 3215 | void CalendarView::moveIncidence(Incidence * inc ) |
3212 | { | 3216 | { |
3213 | if ( !inc ) return; | 3217 | if ( !inc ) return; |
3214 | showDatePickerPopup(); | 3218 | showDatePickerPopup(); |
3215 | mDatePickerMode = 2; | 3219 | mDatePickerMode = 2; |
3216 | mMoveIncidence = inc ; | 3220 | mMoveIncidence = inc ; |
3217 | QDate da; | 3221 | QDate da; |
3218 | if ( mMoveIncidence->typeID() == todoID ) { | 3222 | if ( mMoveIncidence->typeID() == todoID ) { |
3219 | Todo * to = (Todo *) mMoveIncidence; | 3223 | Todo * to = (Todo *) mMoveIncidence; |
3220 | if ( to->hasDueDate() ) | 3224 | if ( to->hasDueDate() ) |
3221 | da = to->dtDue().date(); | 3225 | da = to->dtDue().date(); |
3222 | else | 3226 | else |
3223 | da = QDate::currentDate(); | 3227 | da = QDate::currentDate(); |
3224 | } else { | 3228 | } else { |
3225 | da = mMoveIncidence->dtStart().date(); | 3229 | da = mMoveIncidence->dtStart().date(); |
3226 | } | 3230 | } |
3227 | //PENDING set date for recurring incidence to date of recurrence | 3231 | //PENDING set date for recurring incidence to date of recurrence |
3228 | //mMoveIncidenceOldDate; | 3232 | //mMoveIncidenceOldDate; |
3229 | mDatePicker->setDate( da ); | 3233 | mDatePicker->setDate( da ); |
3230 | } | 3234 | } |
3231 | void CalendarView::showDatePickerPopup() | 3235 | void CalendarView::showDatePickerPopup() |
3232 | { | 3236 | { |
3233 | if ( mDateFrame->isVisible() ) | 3237 | if ( mDateFrame->isVisible() ) |
3234 | mDateFrame->hide(); | 3238 | mDateFrame->hide(); |
3235 | else { | 3239 | else { |
3236 | int offX = 0, offY = 0; | 3240 | int offX = 0, offY = 0; |
3237 | #ifdef DESKTOP_VERSION | 3241 | #ifdef DESKTOP_VERSION |
3238 | int w =mDatePicker->sizeHint().width() ; | 3242 | int w =mDatePicker->sizeHint().width() ; |
3239 | int h = mDatePicker->sizeHint().height() ; | 3243 | int h = mDatePicker->sizeHint().height() ; |
3240 | int dw = topLevelWidget()->width(); | 3244 | int dw = topLevelWidget()->width(); |
3241 | int dh = topLevelWidget()->height(); | 3245 | int dh = topLevelWidget()->height(); |
3242 | offX = topLevelWidget()->x(); | 3246 | offX = topLevelWidget()->x(); |
3243 | offY = topLevelWidget()->y(); | 3247 | offY = topLevelWidget()->y(); |
3244 | #else | 3248 | #else |
3245 | int w =mDatePicker->sizeHint().width() ; | 3249 | int w =mDatePicker->sizeHint().width() ; |
3246 | int h = mDatePicker->sizeHint().height() ; | 3250 | int h = mDatePicker->sizeHint().height() ; |
3247 | int dw = QApplication::desktop()->width(); | 3251 | int dw = QApplication::desktop()->width(); |
3248 | int dh = QApplication::desktop()->height(); | 3252 | int dh = QApplication::desktop()->height(); |
3249 | #endif | 3253 | #endif |
3250 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3254 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3251 | mDateFrame->show(); | 3255 | mDateFrame->show(); |
3252 | } | 3256 | } |
3253 | } | 3257 | } |
3254 | void CalendarView::showDatePicker( ) | 3258 | void CalendarView::showDatePicker( ) |
3255 | { | 3259 | { |
3256 | showDatePickerPopup(); | 3260 | showDatePickerPopup(); |
3257 | mDatePickerMode = 1; | 3261 | mDatePickerMode = 1; |
3258 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3262 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3259 | } | 3263 | } |
3260 | 3264 | ||
3261 | void CalendarView::showEventEditor() | 3265 | void CalendarView::showEventEditor() |
3262 | { | 3266 | { |
3263 | #ifdef DESKTOP_VERSION | 3267 | #ifdef DESKTOP_VERSION |
3264 | int x,y,w,h; | 3268 | int x,y,w,h; |
3265 | x = mEventEditor->geometry().x(); | 3269 | x = mEventEditor->geometry().x(); |
3266 | y = mEventEditor->geometry().y(); | 3270 | y = mEventEditor->geometry().y(); |
3267 | w = mEventEditor->width(); | 3271 | w = mEventEditor->width(); |
3268 | h = mEventEditor->height(); | 3272 | h = mEventEditor->height(); |
3269 | mEventEditor->show(); | 3273 | mEventEditor->show(); |
3270 | mEventEditor->setGeometry(x,y,w,h); | 3274 | mEventEditor->setGeometry(x,y,w,h); |
3271 | #else | 3275 | #else |
3272 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3276 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3273 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3277 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3274 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3278 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3275 | qApp->processEvents(); | 3279 | qApp->processEvents(); |
3276 | delete mEventEditor; | 3280 | delete mEventEditor; |
3277 | mEventEditor = mDialogManager->getEventEditor(); | 3281 | mEventEditor = mDialogManager->getEventEditor(); |
3278 | topLevelWidget()->setCaption( i18n("") ); | 3282 | topLevelWidget()->setCaption( i18n("") ); |
3279 | } | 3283 | } |
3280 | mEventEditor->showMaximized(); | 3284 | mEventEditor->showMaximized(); |
3281 | #endif | 3285 | #endif |
3282 | } | 3286 | } |
3283 | void CalendarView::showTodoEditor() | 3287 | void CalendarView::showTodoEditor() |
3284 | { | 3288 | { |
3285 | #ifdef DESKTOP_VERSION | 3289 | #ifdef DESKTOP_VERSION |
3286 | int x,y,w,h; | 3290 | int x,y,w,h; |
3287 | x = mTodoEditor->geometry().x(); | 3291 | x = mTodoEditor->geometry().x(); |
3288 | y = mTodoEditor->geometry().y(); | 3292 | y = mTodoEditor->geometry().y(); |
3289 | w = mTodoEditor->width(); | 3293 | w = mTodoEditor->width(); |
3290 | h = mTodoEditor->height(); | 3294 | h = mTodoEditor->height(); |
3291 | mTodoEditor->show(); | 3295 | mTodoEditor->show(); |
3292 | mTodoEditor->setGeometry(x,y,w,h); | 3296 | mTodoEditor->setGeometry(x,y,w,h); |
3293 | #else | 3297 | #else |
3294 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3298 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3295 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3299 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3296 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3300 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3297 | qApp->processEvents(); | 3301 | qApp->processEvents(); |
3298 | delete mTodoEditor; | 3302 | delete mTodoEditor; |
3299 | mTodoEditor = mDialogManager->getTodoEditor(); | 3303 | mTodoEditor = mDialogManager->getTodoEditor(); |
3300 | topLevelWidget()->setCaption( i18n("") ); | 3304 | topLevelWidget()->setCaption( i18n("") ); |
3301 | } | 3305 | } |
3302 | mTodoEditor->showMaximized(); | 3306 | mTodoEditor->showMaximized(); |
3303 | #endif | 3307 | #endif |
3304 | } | 3308 | } |
3305 | 3309 | ||
3306 | void CalendarView::cloneIncidence() | 3310 | void CalendarView::cloneIncidence() |
3307 | { | 3311 | { |
3308 | Incidence *incidence = currentSelection(); | 3312 | Incidence *incidence = currentSelection(); |
3309 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3313 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3310 | if ( incidence ) { | 3314 | if ( incidence ) { |
3311 | cloneIncidence(incidence); | 3315 | cloneIncidence(incidence); |
3312 | } | 3316 | } |
3313 | } | 3317 | } |
3314 | void CalendarView::moveIncidence() | 3318 | void CalendarView::moveIncidence() |
3315 | { | 3319 | { |
3316 | Incidence *incidence = currentSelection(); | 3320 | Incidence *incidence = currentSelection(); |
3317 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3321 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3318 | if ( incidence ) { | 3322 | if ( incidence ) { |
3319 | moveIncidence(incidence); | 3323 | moveIncidence(incidence); |
3320 | } | 3324 | } |
3321 | } | 3325 | } |
3322 | void CalendarView::beamIncidence() | 3326 | void CalendarView::beamIncidence() |
3323 | { | 3327 | { |
3324 | Incidence *incidence = currentSelection(); | 3328 | Incidence *incidence = currentSelection(); |
3325 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3329 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3326 | if ( incidence ) { | 3330 | if ( incidence ) { |
3327 | beamIncidence(incidence); | 3331 | beamIncidence(incidence); |
3328 | } | 3332 | } |
3329 | } | 3333 | } |
3330 | void CalendarView::toggleCancelIncidence() | 3334 | void CalendarView::toggleCancelIncidence() |
3331 | { | 3335 | { |
3332 | Incidence *incidence = currentSelection(); | 3336 | Incidence *incidence = currentSelection(); |
3333 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3337 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3334 | if ( incidence ) { | 3338 | if ( incidence ) { |
3335 | cancelIncidence(incidence); | 3339 | cancelIncidence(incidence); |
3336 | } | 3340 | } |
3337 | } | 3341 | } |
3338 | 3342 | ||
3339 | 3343 | ||
3340 | void CalendarView::cancelIncidence(Incidence * inc ) | 3344 | void CalendarView::cancelIncidence(Incidence * inc ) |
3341 | { | 3345 | { |
3342 | inc->setCancelled( ! inc->cancelled() ); | 3346 | inc->setCancelled( ! inc->cancelled() ); |
3343 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3347 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3344 | updateView(); | 3348 | updateView(); |
3345 | } | 3349 | } |
3346 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3350 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3347 | { | 3351 | { |
3348 | Incidence * newInc = orgInc->clone(); | 3352 | Incidence * newInc = orgInc->clone(); |
3349 | newInc->recreate(); | 3353 | newInc->recreate(); |
3350 | 3354 | ||
3351 | if ( newInc->typeID() == todoID ) { | 3355 | if ( newInc->typeID() == todoID ) { |
3352 | Todo* t = (Todo*) newInc; | 3356 | Todo* t = (Todo*) newInc; |
3353 | bool cloneSub = false; | 3357 | bool cloneSub = false; |
3354 | if ( orgInc->relations().count() ) { | 3358 | if ( orgInc->relations().count() ) { |
3355 | int result = KMessageBox::warningYesNoCancel(this, | 3359 | int result = KMessageBox::warningYesNoCancel(this, |
3356 | 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 ) ), | 3360 | 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 ) ), |
3357 | i18n("Todo has subtodos"), | 3361 | i18n("Todo has subtodos"), |
3358 | i18n("Yes"), | 3362 | i18n("Yes"), |
3359 | i18n("No")); | 3363 | i18n("No")); |
3360 | 3364 | ||
3361 | if ( result == KMessageBox::Cancel ) { | 3365 | if ( result == KMessageBox::Cancel ) { |
3362 | delete t; | 3366 | delete t; |
3363 | return; | 3367 | return; |
3364 | } | 3368 | } |
3365 | if (result == KMessageBox::Yes) cloneSub = true; | 3369 | if (result == KMessageBox::Yes) cloneSub = true; |
3366 | } | 3370 | } |
3367 | showTodoEditor(); | 3371 | showTodoEditor(); |
3368 | mTodoEditor->editTodo( t ); | 3372 | mTodoEditor->editTodo( t ); |
3369 | if ( mTodoEditor->exec() ) { | 3373 | if ( mTodoEditor->exec() ) { |
3370 | if ( cloneSub ) { | 3374 | if ( cloneSub ) { |
3371 | orgInc->cloneRelations( t ); | 3375 | orgInc->cloneRelations( t ); |
3372 | mCalendar->addIncidenceBranch( t ); | 3376 | mCalendar->addIncidenceBranch( t ); |
3373 | updateView(); | 3377 | updateView(); |
3374 | 3378 | ||
3375 | } else { | 3379 | } else { |
3376 | mCalendar->addTodo( t ); | 3380 | mCalendar->addTodo( t ); |
3377 | updateView(); | 3381 | updateView(); |
3378 | } | 3382 | } |
3379 | } else { | 3383 | } else { |
3380 | delete t; | 3384 | delete t; |
3381 | } | 3385 | } |
3382 | } | 3386 | } |
3383 | else if ( newInc->typeID() == eventID ) { | 3387 | else if ( newInc->typeID() == eventID ) { |
3384 | Event* e = (Event*) newInc; | 3388 | Event* e = (Event*) newInc; |
3385 | showEventEditor(); | 3389 | showEventEditor(); |
3386 | mEventEditor->editEvent( e ); | 3390 | mEventEditor->editEvent( e ); |
3387 | if ( mEventEditor->exec() ) { | 3391 | if ( mEventEditor->exec() ) { |
3388 | mCalendar->addEvent( e ); | 3392 | mCalendar->addEvent( e ); |
3389 | updateView(); | 3393 | updateView(); |
3390 | } else { | 3394 | } else { |
3391 | delete e; | 3395 | delete e; |
3392 | } | 3396 | } |
3393 | } if ( newInc->typeID() == journalID ) { | 3397 | } if ( newInc->typeID() == journalID ) { |
3394 | mCalendar->addJournal( (Journal*) newInc ); | 3398 | mCalendar->addJournal( (Journal*) newInc ); |
3395 | editJournal( (Journal*) newInc ); | 3399 | editJournal( (Journal*) newInc ); |
3396 | } | 3400 | } |
3397 | setActiveWindow(); | 3401 | setActiveWindow(); |
3398 | } | 3402 | } |
3399 | 3403 | ||
3400 | void CalendarView::newEvent() | 3404 | void CalendarView::newEvent() |
3401 | { | 3405 | { |
3402 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3406 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3403 | KOAgendaView *aView = mViewManager->agendaView(); | 3407 | KOAgendaView *aView = mViewManager->agendaView(); |
3404 | if (aView) { | 3408 | if (aView) { |
3405 | if (aView->selectionStart().isValid()) { | 3409 | if (aView->selectionStart().isValid()) { |
3406 | if (aView->selectedIsAllDay()) { | 3410 | if (aView->selectedIsAllDay()) { |
3407 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3411 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3408 | } else { | 3412 | } else { |
3409 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3413 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3410 | } | 3414 | } |
3411 | return; | 3415 | return; |
3412 | } | 3416 | } |
3413 | } | 3417 | } |
3414 | 3418 | ||
3415 | QDate date = mNavigator->selectedDates().first(); | 3419 | QDate date = mNavigator->selectedDates().first(); |
3416 | #if 0 | 3420 | #if 0 |
3417 | QDateTime current = QDateTime::currentDateTime(); | 3421 | QDateTime current = QDateTime::currentDateTime(); |
3418 | if ( date <= current.date() ) { | 3422 | if ( date <= current.date() ) { |
3419 | int hour = current.time().hour() +1; | 3423 | int hour = current.time().hour() +1; |
3420 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3424 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3421 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3425 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3422 | } else | 3426 | } else |
3423 | #endif | 3427 | #endif |
3424 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3428 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3425 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3429 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3426 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3430 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3427 | } | 3431 | } |
3428 | 3432 | ||
3429 | void CalendarView::newEvent(QDateTime fh) | 3433 | void CalendarView::newEvent(QDateTime fh) |
3430 | { | 3434 | { |
3431 | newEvent(fh, | 3435 | newEvent(fh, |
3432 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3436 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3433 | } | 3437 | } |
3434 | 3438 | ||
3435 | void CalendarView::newEvent(QDate dt) | 3439 | void CalendarView::newEvent(QDate dt) |
3436 | { | 3440 | { |
3437 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3441 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3438 | QDateTime(dt, QTime(0,0,0)), true); | 3442 | QDateTime(dt, QTime(0,0,0)), true); |
3439 | } | 3443 | } |
3440 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3444 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3441 | { | 3445 | { |
3442 | newEvent(fromHint, toHint, false); | 3446 | newEvent(fromHint, toHint, false); |
3443 | } | 3447 | } |
3444 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3448 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3445 | { | 3449 | { |
3446 | 3450 | ||
3447 | showEventEditor(); | 3451 | showEventEditor(); |
3448 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3452 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3449 | if ( mFilterView->filtersEnabled() ) { | 3453 | if ( mFilterView->filtersEnabled() ) { |
3450 | CalFilter *filter = mFilterView->selectedFilter(); | 3454 | CalFilter *filter = mFilterView->selectedFilter(); |
3451 | if (filter && filter->showCategories()) { | 3455 | if (filter && filter->showCategories()) { |
3452 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3456 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3453 | } | 3457 | } |
3454 | if ( filter ) | 3458 | if ( filter ) |
3455 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3459 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3456 | } | 3460 | } |
3457 | mEventEditor->exec(); | 3461 | mEventEditor->exec(); |
3458 | setActiveWindow(); | 3462 | setActiveWindow(); |
3459 | } | 3463 | } |
3460 | void CalendarView::todoAdded(Todo * t) | 3464 | void CalendarView::todoAdded(Todo * t) |
3461 | { | 3465 | { |
3462 | 3466 | ||
3463 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3467 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3464 | updateTodoViews(); | 3468 | updateTodoViews(); |
3465 | } | 3469 | } |
3466 | void CalendarView::todoChanged(Todo * t) | 3470 | void CalendarView::todoChanged(Todo * t) |
3467 | { | 3471 | { |
3468 | emit todoModified( t, 4 ); | 3472 | emit todoModified( t, 4 ); |
3469 | // updateTodoViews(); | 3473 | // updateTodoViews(); |
3470 | } | 3474 | } |
3471 | void CalendarView::todoToBeDeleted(Todo *) | 3475 | void CalendarView::todoToBeDeleted(Todo *) |
3472 | { | 3476 | { |
3473 | //qDebug("todoToBeDeleted(Todo *) "); | 3477 | //qDebug("todoToBeDeleted(Todo *) "); |
3474 | updateTodoViews(); | 3478 | updateTodoViews(); |
3475 | } | 3479 | } |
3476 | void CalendarView::todoDeleted() | 3480 | void CalendarView::todoDeleted() |
3477 | { | 3481 | { |
3478 | //qDebug(" todoDeleted()"); | 3482 | //qDebug(" todoDeleted()"); |
3479 | updateTodoViews(); | 3483 | updateTodoViews(); |
3480 | } | 3484 | } |
3481 | 3485 | ||
3482 | 3486 | ||
3483 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3487 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3484 | { | 3488 | { |
3485 | showTodoEditor(); | 3489 | showTodoEditor(); |
3486 | mTodoEditor->newTodo(dt,0,allday); | 3490 | mTodoEditor->newTodo(dt,0,allday); |
3487 | if ( mFilterView->filtersEnabled() ) { | 3491 | if ( mFilterView->filtersEnabled() ) { |
3488 | CalFilter *filter = mFilterView->selectedFilter(); | 3492 | CalFilter *filter = mFilterView->selectedFilter(); |
3489 | if (filter && filter->showCategories()) { | 3493 | if (filter && filter->showCategories()) { |
3490 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3494 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3491 | } | 3495 | } |
3492 | if ( filter ) | 3496 | if ( filter ) |
3493 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3497 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3494 | } | 3498 | } |
3495 | mTodoEditor->exec(); | 3499 | mTodoEditor->exec(); |
3496 | setActiveWindow(); | 3500 | setActiveWindow(); |
3497 | } | 3501 | } |
3498 | 3502 | ||
3499 | void CalendarView::newTodo() | 3503 | void CalendarView::newTodo() |
3500 | { | 3504 | { |
3501 | newTodoDateTime( QDateTime(),true ); | 3505 | newTodoDateTime( QDateTime(),true ); |
3502 | } | 3506 | } |
3503 | 3507 | ||
3504 | void CalendarView::newSubTodo() | 3508 | void CalendarView::newSubTodo() |
3505 | { | 3509 | { |
3506 | Todo *todo = selectedTodo(); | 3510 | Todo *todo = selectedTodo(); |
3507 | if ( todo ) newSubTodo( todo ); | 3511 | if ( todo ) newSubTodo( todo ); |
3508 | } | 3512 | } |
3509 | 3513 | ||
3510 | void CalendarView::newSubTodo(Todo *parentEvent) | 3514 | void CalendarView::newSubTodo(Todo *parentEvent) |
3511 | { | 3515 | { |
3512 | 3516 | ||
3513 | showTodoEditor(); | 3517 | showTodoEditor(); |
3514 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3518 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3515 | mTodoEditor->exec(); | 3519 | mTodoEditor->exec(); |
3516 | setActiveWindow(); | 3520 | setActiveWindow(); |
3517 | } | 3521 | } |
3518 | 3522 | ||
3519 | void CalendarView::newFloatingEvent() | 3523 | void CalendarView::newFloatingEvent() |
3520 | { | 3524 | { |
3521 | DateList tmpList = mNavigator->selectedDates(); | 3525 | DateList tmpList = mNavigator->selectedDates(); |
3522 | QDate date = tmpList.first(); | 3526 | QDate date = tmpList.first(); |
3523 | 3527 | ||
3524 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3528 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3525 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3529 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3526 | } | 3530 | } |
3527 | 3531 | ||
3528 | 3532 | ||
3529 | void CalendarView::editEvent( Event *event ) | 3533 | void CalendarView::editEvent( Event *event ) |
3530 | { | 3534 | { |
3531 | 3535 | ||
3532 | if ( !event ) return; | 3536 | if ( !event ) return; |
3533 | if ( event->isReadOnly() ) { | 3537 | if ( event->isReadOnly() ) { |
3534 | showEvent( event ); | 3538 | showEvent( event ); |
3535 | return; | 3539 | return; |
3536 | } | 3540 | } |
3537 | showEventEditor(); | 3541 | showEventEditor(); |
3538 | mEventEditor->editEvent( event , mFlagEditDescription); | 3542 | mEventEditor->editEvent( event , mFlagEditDescription); |
3539 | mEventEditor->exec(); | 3543 | mEventEditor->exec(); |
3540 | setActiveWindow(); | 3544 | setActiveWindow(); |
3541 | 3545 | ||
3542 | } | 3546 | } |
3543 | void CalendarView::editJournal( Journal *jour ) | 3547 | void CalendarView::editJournal( Journal *jour ) |
3544 | { | 3548 | { |
3545 | if ( !jour ) return; | 3549 | if ( !jour ) return; |
3546 | mDialogManager->hideSearchDialog(); | 3550 | mDialogManager->hideSearchDialog(); |
3547 | mViewManager->showJournalView(); | 3551 | mViewManager->showJournalView(); |
3548 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3552 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3549 | } | 3553 | } |
3550 | void CalendarView::editTodo( Todo *todo ) | 3554 | void CalendarView::editTodo( Todo *todo ) |
3551 | { | 3555 | { |
3552 | if ( !todo ) return; | 3556 | if ( !todo ) return; |
3553 | 3557 | ||
3554 | if ( todo->isReadOnly() ) { | 3558 | if ( todo->isReadOnly() ) { |
3555 | showTodo( todo ); | 3559 | showTodo( todo ); |
3556 | return; | 3560 | return; |
3557 | } | 3561 | } |
3558 | showTodoEditor(); | 3562 | showTodoEditor(); |
3559 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3563 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3560 | mTodoEditor->exec(); | 3564 | mTodoEditor->exec(); |
3561 | setActiveWindow(); | 3565 | setActiveWindow(); |
3562 | 3566 | ||
3563 | } | 3567 | } |
3564 | 3568 | ||
3565 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3569 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3566 | { | 3570 | { |
3567 | if ( !mEventViewerDialog ) { | 3571 | if ( !mEventViewerDialog ) { |
3568 | mEventViewerDialog = new KOEventViewerDialog(0); | 3572 | mEventViewerDialog = new KOEventViewerDialog(0); |
3569 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3573 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3570 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3574 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3571 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3575 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3572 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3576 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3573 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3577 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3574 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3578 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3575 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3579 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3576 | this, SLOT( slotViewerClosed() ) ); | 3580 | this, SLOT( slotViewerClosed() ) ); |
3577 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3581 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3578 | this, SLOT( todoChanged(Todo *) ) ); | 3582 | this, SLOT( todoChanged(Todo *) ) ); |
3579 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3583 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3580 | mEventViewerDialog->resize( 640, 480 ); | 3584 | mEventViewerDialog->resize( 640, 480 ); |
3581 | 3585 | ||
3582 | } | 3586 | } |
3583 | return mEventViewerDialog; | 3587 | return mEventViewerDialog; |
3584 | } | 3588 | } |
3585 | void CalendarView::showEvent(Event *event) | 3589 | void CalendarView::showEvent(Event *event) |
3586 | { | 3590 | { |
3587 | getEventViewerDialog()->setEvent(event); | 3591 | getEventViewerDialog()->setEvent(event); |
3588 | getEventViewerDialog()->showMe(); | 3592 | getEventViewerDialog()->showMe(); |
3589 | } | 3593 | } |
3590 | 3594 | ||
3591 | void CalendarView::showTodo(Todo *event) | 3595 | void CalendarView::showTodo(Todo *event) |
3592 | { | 3596 | { |
3593 | getEventViewerDialog()->setTodo(event); | 3597 | getEventViewerDialog()->setTodo(event); |
3594 | getEventViewerDialog()->showMe(); | 3598 | getEventViewerDialog()->showMe(); |
3595 | } | 3599 | } |
3596 | void CalendarView::showJournal( Journal *jour ) | 3600 | void CalendarView::showJournal( Journal *jour ) |
3597 | { | 3601 | { |
3598 | getEventViewerDialog()->setJournal(jour); | 3602 | getEventViewerDialog()->setJournal(jour); |
3599 | getEventViewerDialog()->showMe(); | 3603 | getEventViewerDialog()->showMe(); |
3600 | 3604 | ||
3601 | } | 3605 | } |
3602 | // void CalendarView::todoModified (Todo *event, int changed) | 3606 | // void CalendarView::todoModified (Todo *event, int changed) |
3603 | // { | 3607 | // { |
3604 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3608 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3605 | // // kdDebug() << "Todo modified and open" << endl; | 3609 | // // kdDebug() << "Todo modified and open" << endl; |
3606 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3610 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3607 | // // temp->modified (changed); | 3611 | // // temp->modified (changed); |
3608 | 3612 | ||
3609 | // // } | 3613 | // // } |
3610 | 3614 | ||
3611 | // mViewManager->updateView(); | 3615 | // mViewManager->updateView(); |
3612 | // } | 3616 | // } |
3613 | 3617 | ||
3614 | void CalendarView::appointment_show() | 3618 | void CalendarView::appointment_show() |
3615 | { | 3619 | { |
3616 | Event *anEvent = 0; | 3620 | Event *anEvent = 0; |
3617 | 3621 | ||
3618 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3622 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3619 | 3623 | ||
3620 | if (mViewManager->currentView()->isEventView()) { | 3624 | if (mViewManager->currentView()->isEventView()) { |
3621 | if ( incidence && incidence->typeID() == eventID ) { | 3625 | if ( incidence && incidence->typeID() == eventID ) { |
3622 | anEvent = static_cast<Event *>(incidence); | 3626 | anEvent = static_cast<Event *>(incidence); |
3623 | } | 3627 | } |
3624 | } | 3628 | } |
3625 | 3629 | ||
3626 | if (!anEvent) { | 3630 | if (!anEvent) { |
3627 | KNotifyClient::beep(); | 3631 | KNotifyClient::beep(); |
3628 | return; | 3632 | return; |
3629 | } | 3633 | } |
3630 | 3634 | ||
3631 | showEvent(anEvent); | 3635 | showEvent(anEvent); |
3632 | } | 3636 | } |
3633 | 3637 | ||
3634 | void CalendarView::appointment_edit() | 3638 | void CalendarView::appointment_edit() |
3635 | { | 3639 | { |
3636 | Event *anEvent = 0; | 3640 | Event *anEvent = 0; |
3637 | 3641 | ||
3638 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3642 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3639 | 3643 | ||
3640 | if (mViewManager->currentView()->isEventView()) { | 3644 | if (mViewManager->currentView()->isEventView()) { |
3641 | if ( incidence && incidence->typeID() == eventID ) { | 3645 | if ( incidence && incidence->typeID() == eventID ) { |
3642 | anEvent = static_cast<Event *>(incidence); | 3646 | anEvent = static_cast<Event *>(incidence); |
3643 | } | 3647 | } |
3644 | } | 3648 | } |
3645 | 3649 | ||
3646 | if (!anEvent) { | 3650 | if (!anEvent) { |
3647 | KNotifyClient::beep(); | 3651 | KNotifyClient::beep(); |
3648 | return; | 3652 | return; |
3649 | } | 3653 | } |
3650 | 3654 | ||
3651 | editEvent(anEvent); | 3655 | editEvent(anEvent); |
3652 | } | 3656 | } |
3653 | 3657 | ||
3654 | void CalendarView::appointment_delete() | 3658 | void CalendarView::appointment_delete() |
3655 | { | 3659 | { |
3656 | Event *anEvent = 0; | 3660 | Event *anEvent = 0; |
3657 | 3661 | ||
3658 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3662 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3659 | 3663 | ||
3660 | if (mViewManager->currentView()->isEventView()) { | 3664 | if (mViewManager->currentView()->isEventView()) { |
3661 | if ( incidence && incidence->typeID() == eventID ) { | 3665 | if ( incidence && incidence->typeID() == eventID ) { |
3662 | anEvent = static_cast<Event *>(incidence); | 3666 | anEvent = static_cast<Event *>(incidence); |
3663 | } | 3667 | } |
3664 | } | 3668 | } |
3665 | 3669 | ||
3666 | if (!anEvent) { | 3670 | if (!anEvent) { |
3667 | KNotifyClient::beep(); | 3671 | KNotifyClient::beep(); |
3668 | return; | 3672 | return; |
3669 | } | 3673 | } |
3670 | 3674 | ||
3671 | deleteEvent(anEvent); | 3675 | deleteEvent(anEvent); |
3672 | } | 3676 | } |
3673 | 3677 | ||
3674 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3678 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3675 | { | 3679 | { |
3676 | if (!sub) return; | 3680 | if (!sub) return; |
3677 | if ( sub->relatedTo() == parent ) | 3681 | if ( sub->relatedTo() == parent ) |
3678 | return; | 3682 | return; |
3679 | sub->setRelatedTo(parent); | 3683 | sub->setRelatedTo(parent); |
3680 | sub->updated(); | 3684 | sub->updated(); |
3681 | setModified(true); | 3685 | setModified(true); |
3682 | updateView(); | 3686 | updateView(); |
3683 | } | 3687 | } |
3684 | void CalendarView::todo_unsub(Todo *anTodo ) | 3688 | void CalendarView::todo_unsub(Todo *anTodo ) |
3685 | { | 3689 | { |
3686 | todo_resub( 0, anTodo ); | 3690 | todo_resub( 0, anTodo ); |
3687 | } | 3691 | } |
3688 | 3692 | ||
3689 | void CalendarView::deleteTodo(Todo *todo) | 3693 | void CalendarView::deleteTodo(Todo *todo) |
3690 | { | 3694 | { |
3691 | if (!todo) { | 3695 | if (!todo) { |
3692 | KNotifyClient::beep(); | 3696 | KNotifyClient::beep(); |
3693 | return; | 3697 | return; |
3694 | } | 3698 | } |
3695 | if (KOPrefs::instance()->mConfirm) { | 3699 | if (KOPrefs::instance()->mConfirm) { |
3696 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3700 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3697 | if (!todo->relations().isEmpty()) { | 3701 | if (!todo->relations().isEmpty()) { |
3698 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3702 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3699 | 3703 | ||
3700 | } | 3704 | } |
3701 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3705 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3702 | case KMessageBox::Continue: // OK | 3706 | case KMessageBox::Continue: // OK |
3703 | bool deleteT = false; | 3707 | bool deleteT = false; |
3704 | if (!todo->relations().isEmpty()) { | 3708 | if (!todo->relations().isEmpty()) { |
3705 | deleteT = removeCompletedSubTodos( todo ); | 3709 | deleteT = removeCompletedSubTodos( todo ); |
3706 | } | 3710 | } |
3707 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3711 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3708 | if ( !deleteT ) { | 3712 | if ( !deleteT ) { |
3709 | checkExternalId( todo ); | 3713 | checkExternalId( todo ); |
3710 | calendar()->deleteTodo(todo); | 3714 | calendar()->deleteTodo(todo); |
3711 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3715 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3712 | updateView(); | 3716 | updateView(); |
3713 | } | 3717 | } |
3714 | break; | 3718 | break; |
3715 | } // switch | 3719 | } // switch |
3716 | } else { | 3720 | } else { |
3717 | checkExternalId( todo ); | 3721 | checkExternalId( todo ); |
3718 | mCalendar->deleteTodo(todo); | 3722 | mCalendar->deleteTodo(todo); |
3719 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3723 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3720 | updateView(); | 3724 | updateView(); |
3721 | } | 3725 | } |
3722 | 3726 | ||
3723 | emit updateSearchDialog(); | 3727 | emit updateSearchDialog(); |
3724 | } | 3728 | } |
3725 | void CalendarView::deleteJournal(Journal *jour) | 3729 | void CalendarView::deleteJournal(Journal *jour) |
3726 | { | 3730 | { |
3727 | if (!jour) { | 3731 | if (!jour) { |
3728 | KNotifyClient::beep(); | 3732 | KNotifyClient::beep(); |
3729 | return; | 3733 | return; |
3730 | } | 3734 | } |
3731 | if (KOPrefs::instance()->mConfirm) { | 3735 | if (KOPrefs::instance()->mConfirm) { |
3732 | 3736 | ||
3733 | QString des; | 3737 | QString des; |
3734 | if ( !jour->summary().isEmpty() ) { | 3738 | if ( !jour->summary().isEmpty() ) { |
3735 | des = jour->summary(); | 3739 | des = jour->summary(); |
3736 | } else { | 3740 | } else { |
3737 | des = jour->description().left(30); | 3741 | des = jour->description().left(30); |
3738 | des = des.simplifyWhiteSpace (); | 3742 | des = des.simplifyWhiteSpace (); |
3739 | des.replace (QRegExp ("\\n"),"" ); | 3743 | des.replace (QRegExp ("\\n"),"" ); |
3740 | des.replace (QRegExp ("\\r"),"" ); | 3744 | des.replace (QRegExp ("\\r"),"" ); |
3741 | } | 3745 | } |
3742 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 3746 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3743 | case KMessageBox::Continue: // OK | 3747 | case KMessageBox::Continue: // OK |
3744 | calendar()->deleteJournal(jour); | 3748 | calendar()->deleteJournal(jour); |
3745 | updateView(); | 3749 | updateView(); |
3746 | break; | 3750 | break; |
3747 | } // switch | 3751 | } // switch |
3748 | } else { | 3752 | } else { |
3749 | calendar()->deleteJournal(jour);; | 3753 | calendar()->deleteJournal(jour);; |
3750 | updateView(); | 3754 | updateView(); |
3751 | } | 3755 | } |
3752 | emit updateSearchDialog(); | 3756 | emit updateSearchDialog(); |
3753 | } | 3757 | } |
3754 | 3758 | ||
3755 | void CalendarView::deleteEvent(Event *anEvent) | 3759 | void CalendarView::deleteEvent(Event *anEvent) |
3756 | { | 3760 | { |
3757 | if (!anEvent) { | 3761 | if (!anEvent) { |
3758 | KNotifyClient::beep(); | 3762 | KNotifyClient::beep(); |
3759 | return; | 3763 | return; |
3760 | } | 3764 | } |
3761 | 3765 | ||
3762 | if (anEvent->doesRecur()) { | 3766 | if (anEvent->doesRecur()) { |
3763 | QDate itemDate = mViewManager->currentSelectionDate(); | 3767 | QDate itemDate = mViewManager->currentSelectionDate(); |
3764 | int km; | 3768 | int km; |
3765 | if (!itemDate.isValid()) { | 3769 | if (!itemDate.isValid()) { |
3766 | //kdDebug() << "Date Not Valid" << endl; | 3770 | //kdDebug() << "Date Not Valid" << endl; |
3767 | if (KOPrefs::instance()->mConfirm) { | 3771 | if (KOPrefs::instance()->mConfirm) { |
3768 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3772 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3769 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3773 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3770 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3774 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3771 | if ( km == KMessageBox::Continue ) | 3775 | if ( km == KMessageBox::Continue ) |
3772 | km = KMessageBox::No; // No = all below | 3776 | km = KMessageBox::No; // No = all below |
3773 | } else | 3777 | } else |
3774 | km = KMessageBox::No; | 3778 | km = KMessageBox::No; |
3775 | } else { | 3779 | } else { |
3776 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3780 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3777 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3781 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3778 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3782 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3779 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3783 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3780 | i18n("All")); | 3784 | i18n("All")); |
3781 | } | 3785 | } |
3782 | switch(km) { | 3786 | switch(km) { |
3783 | 3787 | ||
3784 | case KMessageBox::No: // Continue // all | 3788 | case KMessageBox::No: // Continue // all |
3785 | //qDebug("KMessageBox::No "); | 3789 | //qDebug("KMessageBox::No "); |
3786 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3790 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3787 | schedule(Scheduler::Cancel,anEvent); | 3791 | schedule(Scheduler::Cancel,anEvent); |
3788 | 3792 | ||
3789 | checkExternalId( anEvent); | 3793 | checkExternalId( anEvent); |
3790 | mCalendar->deleteEvent(anEvent); | 3794 | mCalendar->deleteEvent(anEvent); |
3791 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3795 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3792 | break; | 3796 | break; |
3793 | 3797 | ||
3794 | // Disabled because it does not work | 3798 | // Disabled because it does not work |
3795 | //#if 0 | 3799 | //#if 0 |
3796 | case KMessageBox::Yes: // just this one | 3800 | case KMessageBox::Yes: // just this one |
3797 | //QDate qd = mNavigator->selectedDates().first(); | 3801 | //QDate qd = mNavigator->selectedDates().first(); |
3798 | //if (!qd.isValid()) { | 3802 | //if (!qd.isValid()) { |
3799 | // kdDebug() << "no date selected, or invalid date" << endl; | 3803 | // kdDebug() << "no date selected, or invalid date" << endl; |
3800 | // KNotifyClient::beep(); | 3804 | // KNotifyClient::beep(); |
3801 | // return; | 3805 | // return; |
3802 | //} | 3806 | //} |
3803 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3807 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3804 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3808 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3805 | anEvent->addExDate(itemDate); | 3809 | anEvent->addExDate(itemDate); |
3806 | int duration = anEvent->recurrence()->duration(); | 3810 | int duration = anEvent->recurrence()->duration(); |
3807 | if ( duration > 0 ) { | 3811 | if ( duration > 0 ) { |
3808 | anEvent->recurrence()->setDuration( duration - 1 ); | 3812 | anEvent->recurrence()->setDuration( duration - 1 ); |
3809 | } | 3813 | } |
3810 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3814 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3811 | } | 3815 | } |
3812 | break; | 3816 | break; |
3813 | //#endif | 3817 | //#endif |
3814 | } // switch | 3818 | } // switch |
3815 | } else { | 3819 | } else { |
3816 | if (KOPrefs::instance()->mConfirm) { | 3820 | if (KOPrefs::instance()->mConfirm) { |
3817 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3821 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3818 | i18n("\nAre you sure you want\nto delete this event?"), | 3822 | i18n("\nAre you sure you want\nto delete this event?"), |
3819 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3823 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3820 | case KMessageBox::Continue: // OK | 3824 | case KMessageBox::Continue: // OK |
3821 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3825 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3822 | schedule(Scheduler::Cancel,anEvent); | 3826 | schedule(Scheduler::Cancel,anEvent); |
3823 | checkExternalId( anEvent); | 3827 | checkExternalId( anEvent); |
3824 | mCalendar->deleteEvent(anEvent); | 3828 | mCalendar->deleteEvent(anEvent); |
3825 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3829 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3826 | break; | 3830 | break; |
3827 | } // switch | 3831 | } // switch |
3828 | } else { | 3832 | } else { |
3829 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3833 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3830 | schedule(Scheduler::Cancel,anEvent); | 3834 | schedule(Scheduler::Cancel,anEvent); |
3831 | checkExternalId( anEvent); | 3835 | checkExternalId( anEvent); |
3832 | mCalendar->deleteEvent(anEvent); | 3836 | mCalendar->deleteEvent(anEvent); |
3833 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3837 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3834 | } | 3838 | } |
3835 | } // if-else | 3839 | } // if-else |
3836 | emit updateSearchDialog(); | 3840 | emit updateSearchDialog(); |
3837 | } | 3841 | } |
3838 | 3842 | ||
3839 | bool CalendarView::deleteEvent(const QString &uid) | 3843 | bool CalendarView::deleteEvent(const QString &uid) |
3840 | { | 3844 | { |
3841 | Event *ev = mCalendar->event(uid); | 3845 | Event *ev = mCalendar->event(uid); |
3842 | if (ev) { | 3846 | if (ev) { |
3843 | deleteEvent(ev); | 3847 | deleteEvent(ev); |
3844 | return true; | 3848 | return true; |
3845 | } else { | 3849 | } else { |
3846 | return false; | 3850 | return false; |
3847 | } | 3851 | } |
3848 | } | 3852 | } |
3849 | 3853 | ||
3850 | /*****************************************************************************/ | 3854 | /*****************************************************************************/ |
3851 | 3855 | ||
3852 | void CalendarView::action_mail() | 3856 | void CalendarView::action_mail() |
3853 | { | 3857 | { |
3854 | #ifndef KORG_NOMAIL | 3858 | #ifndef KORG_NOMAIL |
3855 | KOMailClient mailClient; | 3859 | KOMailClient mailClient; |
3856 | 3860 | ||
3857 | Incidence *incidence = currentSelection(); | 3861 | Incidence *incidence = currentSelection(); |
3858 | 3862 | ||
3859 | if (!incidence) { | 3863 | if (!incidence) { |
3860 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3864 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3861 | return; | 3865 | return; |
3862 | } | 3866 | } |
3863 | if(incidence->attendeeCount() == 0 ) { | 3867 | if(incidence->attendeeCount() == 0 ) { |
3864 | KMessageBox::sorry(this, | 3868 | KMessageBox::sorry(this, |
3865 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3869 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3866 | return; | 3870 | return; |
3867 | } | 3871 | } |
3868 | 3872 | ||
3869 | CalendarLocal cal_tmp; | 3873 | CalendarLocal cal_tmp; |
3870 | Event *event = 0; | 3874 | Event *event = 0; |
3871 | Event *ev = 0; | 3875 | Event *ev = 0; |
3872 | if ( incidence && incidence->typeID() == eventID ) { | 3876 | if ( incidence && incidence->typeID() == eventID ) { |
3873 | event = static_cast<Event *>(incidence); | 3877 | event = static_cast<Event *>(incidence); |
3874 | ev = new Event(*event); | 3878 | ev = new Event(*event); |
3875 | cal_tmp.addEvent(ev); | 3879 | cal_tmp.addEvent(ev); |
3876 | } | 3880 | } |
3877 | ICalFormat mForm(); | 3881 | ICalFormat mForm(); |
3878 | QString attachment = mForm.toString( &cal_tmp ); | 3882 | QString attachment = mForm.toString( &cal_tmp ); |
3879 | if (ev) delete(ev); | 3883 | if (ev) delete(ev); |
3880 | 3884 | ||
3881 | mailClient.mailAttendees(currentSelection(), attachment); | 3885 | mailClient.mailAttendees(currentSelection(), attachment); |
3882 | 3886 | ||
3883 | #endif | 3887 | #endif |
3884 | 3888 | ||
3885 | #if 0 | 3889 | #if 0 |
3886 | Event *anEvent = 0; | 3890 | Event *anEvent = 0; |
3887 | if (mViewManager->currentView()->isEventView()) { | 3891 | if (mViewManager->currentView()->isEventView()) { |
3888 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3892 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3889 | } | 3893 | } |
3890 | 3894 | ||
3891 | if (!anEvent) { | 3895 | if (!anEvent) { |
3892 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3896 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3893 | return; | 3897 | return; |
3894 | } | 3898 | } |
3895 | if(anEvent->attendeeCount() == 0 ) { | 3899 | if(anEvent->attendeeCount() == 0 ) { |
3896 | KMessageBox::sorry(this, | 3900 | KMessageBox::sorry(this, |
3897 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3901 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3898 | return; | 3902 | return; |
3899 | } | 3903 | } |
3900 | 3904 | ||
3901 | mailobject.emailEvent(anEvent); | 3905 | mailobject.emailEvent(anEvent); |
3902 | #endif | 3906 | #endif |
3903 | } | 3907 | } |
3904 | 3908 | ||
3905 | 3909 | ||
3906 | void CalendarView::schedule_publish(Incidence *incidence) | 3910 | void CalendarView::schedule_publish(Incidence *incidence) |
3907 | { | 3911 | { |
3908 | Event *event = 0; | 3912 | Event *event = 0; |
3909 | Todo *todo = 0; | 3913 | Todo *todo = 0; |
3910 | 3914 | ||
3911 | if (incidence == 0) { | 3915 | if (incidence == 0) { |
3912 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3916 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3913 | if (incidence == 0) { | 3917 | if (incidence == 0) { |
3914 | incidence = mTodoList->selectedIncidences().first(); | 3918 | incidence = mTodoList->selectedIncidences().first(); |
3915 | } | 3919 | } |
3916 | } | 3920 | } |
3917 | if ( incidence && incidence->typeID() == eventID ) { | 3921 | if ( incidence && incidence->typeID() == eventID ) { |
3918 | event = static_cast<Event *>(incidence); | 3922 | event = static_cast<Event *>(incidence); |
3919 | } else { | 3923 | } else { |
3920 | if ( incidence && incidence->typeID() == todoID ) { | 3924 | if ( incidence && incidence->typeID() == todoID ) { |
3921 | todo = static_cast<Todo *>(incidence); | 3925 | todo = static_cast<Todo *>(incidence); |
3922 | } | 3926 | } |
3923 | } | 3927 | } |
3924 | 3928 | ||
3925 | if (!event && !todo) { | 3929 | if (!event && !todo) { |
3926 | KMessageBox::sorry(this,i18n("No event selected.")); | 3930 | KMessageBox::sorry(this,i18n("No event selected.")); |
3927 | return; | 3931 | return; |
3928 | } | 3932 | } |
3929 | 3933 | ||
3930 | PublishDialog *publishdlg = new PublishDialog(); | 3934 | PublishDialog *publishdlg = new PublishDialog(); |
3931 | if (incidence->attendeeCount()>0) { | 3935 | if (incidence->attendeeCount()>0) { |
3932 | QPtrList<Attendee> attendees = incidence->attendees(); | 3936 | QPtrList<Attendee> attendees = incidence->attendees(); |
3933 | attendees.first(); | 3937 | attendees.first(); |
3934 | while ( attendees.current()!=0 ) { | 3938 | while ( attendees.current()!=0 ) { |
3935 | publishdlg->addAttendee(attendees.current()); | 3939 | publishdlg->addAttendee(attendees.current()); |
3936 | attendees.next(); | 3940 | attendees.next(); |
3937 | } | 3941 | } |
3938 | } | 3942 | } |
3939 | bool send = true; | 3943 | bool send = true; |
3940 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3944 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3941 | if ( publishdlg->exec() != QDialog::Accepted ) | 3945 | if ( publishdlg->exec() != QDialog::Accepted ) |
3942 | send = false; | 3946 | send = false; |
3943 | } | 3947 | } |
3944 | if ( send ) { | 3948 | if ( send ) { |
3945 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3949 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3946 | if ( event ) { | 3950 | if ( event ) { |
3947 | Event *ev = new Event(*event); | 3951 | Event *ev = new Event(*event); |
3948 | ev->registerObserver(0); | 3952 | ev->registerObserver(0); |
3949 | ev->clearAttendees(); | 3953 | ev->clearAttendees(); |
3950 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3954 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3951 | delete(ev); | 3955 | delete(ev); |
3952 | } | 3956 | } |
3953 | } else { | 3957 | } else { |
3954 | if ( todo ) { | 3958 | if ( todo ) { |
3955 | Todo *ev = new Todo(*todo); | 3959 | Todo *ev = new Todo(*todo); |
3956 | ev->registerObserver(0); | 3960 | ev->registerObserver(0); |
3957 | ev->clearAttendees(); | 3961 | ev->clearAttendees(); |
3958 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3962 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3959 | delete(ev); | 3963 | delete(ev); |
3960 | } | 3964 | } |
3961 | } | 3965 | } |
3962 | } | 3966 | } |
3963 | } | 3967 | } |
3964 | delete publishdlg; | 3968 | delete publishdlg; |
3965 | } | 3969 | } |
3966 | 3970 | ||
3967 | void CalendarView::schedule_request(Incidence *incidence) | 3971 | void CalendarView::schedule_request(Incidence *incidence) |
3968 | { | 3972 | { |
3969 | schedule(Scheduler::Request,incidence); | 3973 | schedule(Scheduler::Request,incidence); |
3970 | } | 3974 | } |
3971 | 3975 | ||
3972 | void CalendarView::schedule_refresh(Incidence *incidence) | 3976 | void CalendarView::schedule_refresh(Incidence *incidence) |
3973 | { | 3977 | { |
3974 | schedule(Scheduler::Refresh,incidence); | 3978 | schedule(Scheduler::Refresh,incidence); |
3975 | } | 3979 | } |
3976 | 3980 | ||
3977 | void CalendarView::schedule_cancel(Incidence *incidence) | 3981 | void CalendarView::schedule_cancel(Incidence *incidence) |
3978 | { | 3982 | { |
3979 | schedule(Scheduler::Cancel,incidence); | 3983 | schedule(Scheduler::Cancel,incidence); |
3980 | } | 3984 | } |
3981 | 3985 | ||
3982 | void CalendarView::schedule_add(Incidence *incidence) | 3986 | void CalendarView::schedule_add(Incidence *incidence) |
3983 | { | 3987 | { |
3984 | schedule(Scheduler::Add,incidence); | 3988 | schedule(Scheduler::Add,incidence); |
3985 | } | 3989 | } |
3986 | 3990 | ||
3987 | void CalendarView::schedule_reply(Incidence *incidence) | 3991 | void CalendarView::schedule_reply(Incidence *incidence) |
3988 | { | 3992 | { |
3989 | schedule(Scheduler::Reply,incidence); | 3993 | schedule(Scheduler::Reply,incidence); |
3990 | } | 3994 | } |
3991 | 3995 | ||
3992 | void CalendarView::schedule_counter(Incidence *incidence) | 3996 | void CalendarView::schedule_counter(Incidence *incidence) |
3993 | { | 3997 | { |
3994 | schedule(Scheduler::Counter,incidence); | 3998 | schedule(Scheduler::Counter,incidence); |
3995 | } | 3999 | } |
3996 | 4000 | ||
3997 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 4001 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3998 | { | 4002 | { |
3999 | schedule(Scheduler::Declinecounter,incidence); | 4003 | schedule(Scheduler::Declinecounter,incidence); |
4000 | } | 4004 | } |
4001 | 4005 | ||
4002 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 4006 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
4003 | { | 4007 | { |
4004 | QDateTime start = QDateTime::currentDateTime(); | 4008 | QDateTime start = QDateTime::currentDateTime(); |
4005 | QDateTime end = start.addDays(daysToPublish); | 4009 | QDateTime end = start.addDays(daysToPublish); |
4006 | 4010 | ||
4007 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4011 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
4008 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4012 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
4009 | 4013 | ||
4010 | 4014 | ||
4011 | PublishDialog *publishdlg = new PublishDialog(); | 4015 | PublishDialog *publishdlg = new PublishDialog(); |
4012 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4016 | if ( publishdlg->exec() == QDialog::Accepted ) { |
4013 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4017 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4014 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4018 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
4015 | delete(freebusy); | 4019 | delete(freebusy); |
4016 | } | 4020 | } |
4017 | } | 4021 | } |
4018 | delete publishdlg; | 4022 | delete publishdlg; |
4019 | } | 4023 | } |
4020 | 4024 | ||
4021 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4025 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4022 | { | 4026 | { |
4023 | Event *event = 0; | 4027 | Event *event = 0; |
4024 | Todo *todo = 0; | 4028 | Todo *todo = 0; |
4025 | 4029 | ||
4026 | if (incidence == 0) { | 4030 | if (incidence == 0) { |
4027 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4031 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4028 | if (incidence == 0) { | 4032 | if (incidence == 0) { |
4029 | incidence = mTodoList->selectedIncidences().first(); | 4033 | incidence = mTodoList->selectedIncidences().first(); |
4030 | } | 4034 | } |
4031 | } | 4035 | } |
4032 | if ( incidence && incidence->typeID() == eventID ) { | 4036 | if ( incidence && incidence->typeID() == eventID ) { |
4033 | event = static_cast<Event *>(incidence); | 4037 | event = static_cast<Event *>(incidence); |
4034 | } | 4038 | } |
4035 | if ( incidence && incidence->typeID() == todoID ) { | 4039 | if ( incidence && incidence->typeID() == todoID ) { |
4036 | todo = static_cast<Todo *>(incidence); | 4040 | todo = static_cast<Todo *>(incidence); |
4037 | } | 4041 | } |
4038 | 4042 | ||
4039 | if (!event && !todo) { | 4043 | if (!event && !todo) { |
4040 | KMessageBox::sorry(this,i18n("No event selected.")); | 4044 | KMessageBox::sorry(this,i18n("No event selected.")); |
4041 | return; | 4045 | return; |
4042 | } | 4046 | } |
4043 | 4047 | ||
4044 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4048 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4045 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4049 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4046 | return; | 4050 | return; |
4047 | } | 4051 | } |
4048 | 4052 | ||
4049 | Event *ev = 0; | 4053 | Event *ev = 0; |
4050 | if (event) ev = new Event(*event); | 4054 | if (event) ev = new Event(*event); |
4051 | Todo *to = 0; | 4055 | Todo *to = 0; |
4052 | if (todo) to = new Todo(*todo); | 4056 | if (todo) to = new Todo(*todo); |
4053 | 4057 | ||
4054 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4058 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4055 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4059 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4056 | if (!me) { | 4060 | if (!me) { |
4057 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4061 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4058 | return; | 4062 | return; |
4059 | } | 4063 | } |
4060 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4064 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4061 | StatusDialog *statdlg = new StatusDialog(this); | 4065 | StatusDialog *statdlg = new StatusDialog(this); |
4062 | if (!statdlg->exec()==QDialog::Accepted) return; | 4066 | if (!statdlg->exec()==QDialog::Accepted) return; |
4063 | me->setStatus( statdlg->status() ); | 4067 | me->setStatus( statdlg->status() ); |
4064 | delete(statdlg); | 4068 | delete(statdlg); |
4065 | } | 4069 | } |
4066 | Attendee *menew = new Attendee(*me); | 4070 | Attendee *menew = new Attendee(*me); |
4067 | if (ev) { | 4071 | if (ev) { |
4068 | ev->clearAttendees(); | 4072 | ev->clearAttendees(); |
4069 | ev->addAttendee(menew,false); | 4073 | ev->addAttendee(menew,false); |
4070 | } else { | 4074 | } else { |
4071 | if (to) { | 4075 | if (to) { |
4072 | todo->clearAttendees(); | 4076 | todo->clearAttendees(); |
4073 | todo->addAttendee(menew,false); | 4077 | todo->addAttendee(menew,false); |
4074 | } | 4078 | } |
4075 | } | 4079 | } |
4076 | } | 4080 | } |
4077 | 4081 | ||
4078 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4082 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4079 | if (ev) { | 4083 | if (ev) { |
4080 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4084 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4081 | } else { | 4085 | } else { |
4082 | if (to) { | 4086 | if (to) { |
4083 | if ( !dlg->addMessage(to,method) ) delete(to); | 4087 | if ( !dlg->addMessage(to,method) ) delete(to); |
4084 | } | 4088 | } |
4085 | } | 4089 | } |
4086 | } | 4090 | } |
4087 | 4091 | ||
4088 | void CalendarView::openAddressbook() | 4092 | void CalendarView::openAddressbook() |
4089 | { | 4093 | { |
4090 | KRun::runCommand("kaddressbook"); | 4094 | KRun::runCommand("kaddressbook"); |
4091 | } | 4095 | } |
4092 | 4096 | ||
4093 | void CalendarView::setModified(bool modified) | 4097 | void CalendarView::setModified(bool modified) |
4094 | { | 4098 | { |
4095 | //qDebug("CalendarView::setModified %d ", modified); | 4099 | //qDebug("CalendarView::setModified %d ", modified); |
4096 | if ( modified ) | 4100 | if ( modified ) |
4097 | emit signalmodified(); | 4101 | emit signalmodified(); |
4098 | mModified = modified; | 4102 | mModified = modified; |
4099 | if ( mModified ) | 4103 | if ( mModified ) |
4100 | emit modifiedChanged(mModified); | 4104 | emit modifiedChanged(mModified); |
4101 | 4105 | ||
4102 | } | 4106 | } |
4103 | 4107 | ||
4104 | bool CalendarView::isReadOnly() | 4108 | bool CalendarView::isReadOnly() |
4105 | { | 4109 | { |
4106 | return mReadOnly; | 4110 | return mReadOnly; |
4107 | } | 4111 | } |
4108 | 4112 | ||
4109 | void CalendarView::setReadOnly(bool readOnly) | 4113 | void CalendarView::setReadOnly(bool readOnly) |
4110 | { | 4114 | { |
4111 | if (mReadOnly != readOnly) { | 4115 | if (mReadOnly != readOnly) { |
4112 | mReadOnly = readOnly; | 4116 | mReadOnly = readOnly; |
4113 | emit readOnlyChanged(mReadOnly); | 4117 | emit readOnlyChanged(mReadOnly); |
4114 | } | 4118 | } |
4115 | } | 4119 | } |
4116 | 4120 | ||
4117 | bool CalendarView::isModified() | 4121 | bool CalendarView::isModified() |
4118 | { | 4122 | { |
4119 | return mModified; | 4123 | return mModified; |
4120 | } | 4124 | } |
4121 | void CalendarView::slotprintSelInc() | 4125 | void CalendarView::slotprintSelInc() |
4122 | { | 4126 | { |
4123 | if ( currentSelection() == 0 ) { | 4127 | if ( currentSelection() == 0 ) { |
4124 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4128 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4125 | return; | 4129 | return; |
4126 | } | 4130 | } |
4127 | showIncidence(); | 4131 | showIncidence(); |
4128 | getEventViewerDialog()->print(); | 4132 | getEventViewerDialog()->print(); |
4129 | 4133 | ||
4130 | } | 4134 | } |
4131 | void CalendarView::printSetup() | 4135 | void CalendarView::printSetup() |
4132 | { | 4136 | { |
4133 | #ifndef KORG_NOPRINTER | 4137 | #ifndef KORG_NOPRINTER |
4134 | createPrinter(); | 4138 | createPrinter(); |
4135 | 4139 | ||
4136 | mCalPrinter->setupPrinter(); | 4140 | mCalPrinter->setupPrinter(); |
4137 | #endif | 4141 | #endif |
4138 | } | 4142 | } |
4139 | 4143 | ||
4140 | void CalendarView::print() | 4144 | void CalendarView::print() |
4141 | { | 4145 | { |
4142 | #ifndef KORG_NOPRINTER | 4146 | #ifndef KORG_NOPRINTER |
4143 | createPrinter(); | 4147 | createPrinter(); |
4144 | 4148 | ||
4145 | DateList tmpDateList = mNavigator->selectedDates(); | 4149 | DateList tmpDateList = mNavigator->selectedDates(); |
4146 | mCalPrinter->print(CalPrinter::Month, | 4150 | mCalPrinter->print(CalPrinter::Month, |
4147 | tmpDateList.first(), tmpDateList.last()); | 4151 | tmpDateList.first(), tmpDateList.last()); |
4148 | #endif | 4152 | #endif |
4149 | } | 4153 | } |
4150 | 4154 | ||
4151 | void CalendarView::printPreview() | 4155 | void CalendarView::printPreview() |
4152 | { | 4156 | { |
4153 | #ifndef KORG_NOPRINTER | 4157 | #ifndef KORG_NOPRINTER |
4154 | kdDebug() << "CalendarView::printPreview()" << endl; | 4158 | kdDebug() << "CalendarView::printPreview()" << endl; |
4155 | 4159 | ||
4156 | createPrinter(); | 4160 | createPrinter(); |
4157 | 4161 | ||
4158 | DateList tmpDateList = mNavigator->selectedDates(); | 4162 | DateList tmpDateList = mNavigator->selectedDates(); |
4159 | 4163 | ||
4160 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4164 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4161 | tmpDateList.last()); | 4165 | tmpDateList.last()); |
4162 | #endif | 4166 | #endif |
4163 | } | 4167 | } |
4164 | 4168 | ||
4165 | void CalendarView::exportICalendar() | 4169 | void CalendarView::exportICalendar() |
4166 | { | 4170 | { |
4167 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 4171 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
4168 | 4172 | ||
4169 | // Force correct extension | 4173 | // Force correct extension |
4170 | if (filename.right(4) != ".ics") filename += ".ics"; | 4174 | if (filename.right(4) != ".ics") filename += ".ics"; |
4171 | 4175 | ||
4172 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4176 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4173 | storage.save(); | 4177 | storage.save(); |
4174 | } | 4178 | } |
4175 | 4179 | ||
4176 | bool CalendarView::exportVCalendar( QString filename ) | 4180 | bool CalendarView::exportVCalendar( QString filename ) |
4177 | { | 4181 | { |
4178 | if (mCalendar->journals().count() > 0) { | 4182 | if (mCalendar->journals().count() > 0) { |
4179 | int result = KMessageBox::warningContinueCancel(this, | 4183 | int result = KMessageBox::warningContinueCancel(this, |
4180 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4184 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4181 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4185 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4182 | true); | 4186 | true); |
4183 | if (result != KMessageBox::Continue) return false; | 4187 | if (result != KMessageBox::Continue) return false; |
4184 | } | 4188 | } |
4185 | 4189 | ||
4186 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4190 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4187 | 4191 | ||
4188 | // Force correct extension | 4192 | // Force correct extension |
4189 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4193 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4190 | 4194 | ||
4191 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4195 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4192 | return storage.save(); | 4196 | return storage.save(); |
4193 | 4197 | ||
4194 | } | 4198 | } |
4195 | 4199 | ||
4196 | void CalendarView::eventUpdated(Incidence *) | 4200 | void CalendarView::eventUpdated(Incidence *) |
4197 | { | 4201 | { |
4198 | setModified(); | 4202 | setModified(); |
4199 | // Don't call updateView here. The code, which has caused the update of the | 4203 | // Don't call updateView here. The code, which has caused the update of the |
4200 | // event is responsible for updating the view. | 4204 | // event is responsible for updating the view. |
4201 | // updateView(); | 4205 | // updateView(); |
4202 | } | 4206 | } |
4203 | 4207 | ||
4204 | void CalendarView::adaptNavigationUnits() | 4208 | void CalendarView::adaptNavigationUnits() |
4205 | { | 4209 | { |
4206 | if (mViewManager->currentView()->isEventView()) { | 4210 | if (mViewManager->currentView()->isEventView()) { |
4207 | int days = mViewManager->currentView()->currentDateCount(); | 4211 | int days = mViewManager->currentView()->currentDateCount(); |
4208 | if (days == 1) { | 4212 | if (days == 1) { |
4209 | emit changeNavStringPrev(i18n("&Previous Day")); | 4213 | emit changeNavStringPrev(i18n("&Previous Day")); |
4210 | emit changeNavStringNext(i18n("&Next Day")); | 4214 | emit changeNavStringNext(i18n("&Next Day")); |
4211 | } else { | 4215 | } else { |
4212 | emit changeNavStringPrev(i18n("&Previous Week")); | 4216 | emit changeNavStringPrev(i18n("&Previous Week")); |
4213 | emit changeNavStringNext(i18n("&Next Week")); | 4217 | emit changeNavStringNext(i18n("&Next Week")); |
4214 | } | 4218 | } |
4215 | } | 4219 | } |
4216 | } | 4220 | } |
4217 | 4221 | ||
4218 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4222 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4219 | { | 4223 | { |
4220 | if ( incidence ) mTodoList->clearSelection(); | 4224 | if ( incidence ) mTodoList->clearSelection(); |
4221 | processIncidenceSelection( incidence ); | 4225 | processIncidenceSelection( incidence ); |
4222 | } | 4226 | } |
4223 | 4227 | ||
4224 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4228 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4225 | { | 4229 | { |
4226 | if ( incidence && mViewManager->currentView() ) { | 4230 | if ( incidence && mViewManager->currentView() ) { |
4227 | mViewManager->currentView()->clearSelection(); | 4231 | mViewManager->currentView()->clearSelection(); |
4228 | } | 4232 | } |
4229 | processIncidenceSelection( incidence ); | 4233 | processIncidenceSelection( incidence ); |
4230 | } | 4234 | } |
4231 | 4235 | ||
4232 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4236 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4233 | { | 4237 | { |
4234 | emit incidenceSelected( incidence ); | 4238 | emit incidenceSelected( incidence ); |
4235 | if ( incidence == mSelectedIncidence ) return; | 4239 | if ( incidence == mSelectedIncidence ) return; |
4236 | mSelectedIncidence = incidence; | 4240 | mSelectedIncidence = incidence; |
4237 | 4241 | ||
4238 | if ( incidence && incidence->typeID() == eventID ) { | 4242 | if ( incidence && incidence->typeID() == eventID ) { |
4239 | Event *event = static_cast<Event *>( incidence ); | 4243 | Event *event = static_cast<Event *>( incidence ); |
4240 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4244 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4241 | emit organizerEventsSelected( true ); | 4245 | emit organizerEventsSelected( true ); |
4242 | } else { | 4246 | } else { |
4243 | emit organizerEventsSelected(false); | 4247 | emit organizerEventsSelected(false); |
4244 | } | 4248 | } |
4245 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4249 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4246 | KOPrefs::instance()->email() ) ) { | 4250 | KOPrefs::instance()->email() ) ) { |
4247 | emit groupEventsSelected( true ); | 4251 | emit groupEventsSelected( true ); |
4248 | } else { | 4252 | } else { |
4249 | emit groupEventsSelected(false); | 4253 | emit groupEventsSelected(false); |
4250 | } | 4254 | } |
4251 | return; | 4255 | return; |
4252 | } else { | 4256 | } else { |
4253 | if ( incidence && incidence->typeID() == todoID ) { | 4257 | if ( incidence && incidence->typeID() == todoID ) { |
4254 | emit todoSelected( true ); | 4258 | emit todoSelected( true ); |
4255 | Todo *event = static_cast<Todo *>( incidence ); | 4259 | Todo *event = static_cast<Todo *>( incidence ); |
4256 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4260 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4257 | emit organizerEventsSelected( true ); | 4261 | emit organizerEventsSelected( true ); |
4258 | } else { | 4262 | } else { |
4259 | emit organizerEventsSelected(false); | 4263 | emit organizerEventsSelected(false); |
4260 | } | 4264 | } |
4261 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4265 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4262 | KOPrefs::instance()->email() ) ) { | 4266 | KOPrefs::instance()->email() ) ) { |
4263 | emit groupEventsSelected( true ); | 4267 | emit groupEventsSelected( true ); |
4264 | } else { | 4268 | } else { |
4265 | emit groupEventsSelected(false); | 4269 | emit groupEventsSelected(false); |
4266 | } | 4270 | } |
4267 | return; | 4271 | return; |
4268 | } else { | 4272 | } else { |
4269 | emit todoSelected( false ); | 4273 | emit todoSelected( false ); |
4270 | emit organizerEventsSelected(false); | 4274 | emit organizerEventsSelected(false); |
4271 | emit groupEventsSelected(false); | 4275 | emit groupEventsSelected(false); |
4272 | } | 4276 | } |
4273 | return; | 4277 | return; |
4274 | } | 4278 | } |
4275 | 4279 | ||
4276 | /* if ( incidence && incidence->typeID() == todoID ) { | 4280 | /* if ( incidence && incidence->typeID() == todoID ) { |
4277 | emit todoSelected( true ); | 4281 | emit todoSelected( true ); |
4278 | } else { | 4282 | } else { |
4279 | emit todoSelected( false ); | 4283 | emit todoSelected( false ); |
4280 | }*/ | 4284 | }*/ |
4281 | } | 4285 | } |
4282 | 4286 | ||
4283 | 4287 | ||
4284 | void CalendarView::checkClipboard() | 4288 | void CalendarView::checkClipboard() |
4285 | { | 4289 | { |
4286 | #ifndef KORG_NODND | 4290 | #ifndef KORG_NODND |
4287 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4291 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4288 | emit pasteEnabled(true); | 4292 | emit pasteEnabled(true); |
4289 | } else { | 4293 | } else { |
4290 | emit pasteEnabled(false); | 4294 | emit pasteEnabled(false); |
4291 | } | 4295 | } |
4292 | #endif | 4296 | #endif |
4293 | } | 4297 | } |
4294 | 4298 | ||
4295 | void CalendarView::showDates(const DateList &selectedDates) | 4299 | void CalendarView::showDates(const DateList &selectedDates) |
4296 | { | 4300 | { |
4297 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4301 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4298 | 4302 | ||
4299 | 4303 | ||
4300 | if ( !mBlockShowDates ) { | 4304 | if ( !mBlockShowDates ) { |
4301 | if ( mViewManager->currentView() ) { | 4305 | if ( mViewManager->currentView() ) { |
4302 | updateView( selectedDates.first(), selectedDates.last() ); | 4306 | updateView( selectedDates.first(), selectedDates.last() ); |
4303 | } else { | 4307 | } else { |
4304 | mViewManager->showAgendaView(); | 4308 | mViewManager->showAgendaView(); |
4305 | } | 4309 | } |
4306 | } | 4310 | } |
4307 | 4311 | ||
4308 | QDate date = selectedDates.first(); | 4312 | QDate date = selectedDates.first(); |
4309 | if ( ! date.isValid() ) { | 4313 | if ( ! date.isValid() ) { |
4310 | topLevelWidget()->setCaption(""); | 4314 | topLevelWidget()->setCaption(""); |
4311 | return; | 4315 | return; |
4312 | } | 4316 | } |
4313 | 4317 | ||
4314 | QString selDates; | 4318 | QString selDates; |
4315 | selDates = KGlobal::locale()->formatDate( date, true); | 4319 | selDates = KGlobal::locale()->formatDate( date, true); |
4316 | if (selectedDates.first() < selectedDates.last() ) | 4320 | if (selectedDates.first() < selectedDates.last() ) |
4317 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4321 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4318 | else { | 4322 | else { |
4319 | QString addString; | 4323 | QString addString; |
4320 | if ( date == QDateTime::currentDateTime().date() ) | 4324 | if ( date == QDateTime::currentDateTime().date() ) |
4321 | addString = i18n("Today"); | 4325 | addString = i18n("Today"); |
4322 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4326 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4323 | addString = i18n("Tomorrow"); | 4327 | addString = i18n("Tomorrow"); |
4324 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4328 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4325 | addString = i18n("Yesterday"); | 4329 | addString = i18n("Yesterday"); |
4326 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4330 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4327 | addString = i18n("Day before yesterday"); | 4331 | addString = i18n("Day before yesterday"); |
4328 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4332 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4329 | addString = i18n("Day after tomorrow"); | 4333 | addString = i18n("Day after tomorrow"); |
4330 | if ( !addString.isEmpty() ) { | 4334 | if ( !addString.isEmpty() ) { |
4331 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4335 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4332 | return; | 4336 | return; |
4333 | } | 4337 | } |
4334 | } | 4338 | } |
4335 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4339 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4336 | 4340 | ||
4337 | } | 4341 | } |
4338 | 4342 | ||
4339 | QPtrList<CalFilter> CalendarView::filters() | 4343 | QPtrList<CalFilter> CalendarView::filters() |
4340 | { | 4344 | { |
4341 | return mFilters; | 4345 | return mFilters; |
4342 | 4346 | ||
4343 | } | 4347 | } |
4344 | void CalendarView::editFilters() | 4348 | void CalendarView::editFilters() |
4345 | { | 4349 | { |
4346 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4350 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4347 | 4351 | ||
4348 | CalFilter *filter = mFilters.first(); | 4352 | CalFilter *filter = mFilters.first(); |
4349 | while(filter) { | 4353 | while(filter) { |
4350 | filter = mFilters.next(); | 4354 | filter = mFilters.next(); |
4351 | } | 4355 | } |
4352 | 4356 | ||
4353 | mDialogManager->showFilterEditDialog(&mFilters); | 4357 | mDialogManager->showFilterEditDialog(&mFilters); |
4354 | updateFilter(); | 4358 | updateFilter(); |
4355 | } | 4359 | } |
4356 | void CalendarView::toggleFilter() | 4360 | void CalendarView::toggleFilter() |
4357 | { | 4361 | { |
4358 | if ( mLeftFrame->isHidden() ) { | 4362 | if ( mLeftFrame->isHidden() ) { |
4359 | toggleExpand(); | 4363 | toggleExpand(); |
4360 | showFilter( true ); | 4364 | showFilter( true ); |
4361 | } else | 4365 | } else |
4362 | showFilter(! mCalEditView->isVisible()); | 4366 | showFilter(! mCalEditView->isVisible()); |
4363 | } | 4367 | } |
4364 | 4368 | ||
4365 | KOFilterView *CalendarView::filterView() | 4369 | KOFilterView *CalendarView::filterView() |
4366 | { | 4370 | { |
4367 | return mFilterView; | 4371 | return mFilterView; |
4368 | } | 4372 | } |
4369 | void CalendarView::selectFilter( int fil ) | 4373 | void CalendarView::selectFilter( int fil ) |
4370 | { | 4374 | { |
4371 | mFilterView->setSelectedFilter( fil ); | 4375 | mFilterView->setSelectedFilter( fil ); |
4372 | updateUnmanagedViews(); | 4376 | updateUnmanagedViews(); |
4373 | } | 4377 | } |
4374 | void CalendarView::showFilter(bool visible) | 4378 | void CalendarView::showFilter(bool visible) |
4375 | { | 4379 | { |
4376 | #if 1 | 4380 | #if 1 |
4377 | if (visible) { | 4381 | if (visible) { |
4378 | mCalEditView->readConfig(); | 4382 | mCalEditView->readConfig(); |
4379 | mCalEditView->show(); | 4383 | mCalEditView->show(); |
4380 | QValueList<int> sizes; | 4384 | QValueList<int> sizes; |
4381 | sizes = mLeftFrame->sizes(); | 4385 | sizes = mLeftFrame->sizes(); |
4382 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4386 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4383 | sizes.clear(); | 4387 | sizes.clear(); |
4384 | sizes << 100; | 4388 | sizes << 100; |
4385 | sizes << 0; | 4389 | sizes << 0; |
4386 | sizes << 0; | 4390 | sizes << 0; |
4387 | sizes << 100; | 4391 | sizes << 100; |
4388 | mLeftFrame->setSizes(sizes); | 4392 | mLeftFrame->setSizes(sizes); |
4389 | } | 4393 | } |
4390 | #if 0 | 4394 | #if 0 |
4391 | sizes = mLeftFrame->sizes(); | 4395 | sizes = mLeftFrame->sizes(); |
4392 | int ccc = 0; | 4396 | int ccc = 0; |
4393 | while ( ccc < sizes.count()) { | 4397 | while ( ccc < sizes.count()) { |
4394 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4398 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4395 | ++ccc; | 4399 | ++ccc; |
4396 | } | 4400 | } |
4397 | #endif | 4401 | #endif |
4398 | 4402 | ||
4399 | } | 4403 | } |
4400 | else { | 4404 | else { |
4401 | mCalEditView->hide(); | 4405 | mCalEditView->hide(); |
4402 | } | 4406 | } |
4403 | #else | 4407 | #else |
4404 | if (visible) mFilterView->show(); | 4408 | if (visible) mFilterView->show(); |
4405 | else mFilterView->hide(); | 4409 | else mFilterView->hide(); |
4406 | #endif | 4410 | #endif |
4407 | } | 4411 | } |
4408 | void CalendarView::toggleFilerEnabled( ) | 4412 | void CalendarView::toggleFilerEnabled( ) |
4409 | { | 4413 | { |
4410 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4414 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4411 | if ( !mFilterView->filtersEnabled() ) | 4415 | if ( !mFilterView->filtersEnabled() ) |
4412 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4416 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4413 | updateUnmanagedViews(); | 4417 | updateUnmanagedViews(); |
4414 | 4418 | ||
4415 | } | 4419 | } |
4416 | void CalendarView::updateFilter() | 4420 | void CalendarView::updateFilter() |
4417 | { | 4421 | { |
4418 | CalFilter *filter = mFilterView->selectedFilter(); | 4422 | CalFilter *filter = mFilterView->selectedFilter(); |
4419 | if (filter) { | 4423 | if (filter) { |
4420 | QString mess; | 4424 | QString mess; |
4421 | if (mFilterView->filtersEnabled()) { | 4425 | if (mFilterView->filtersEnabled()) { |
4422 | mess = i18n("Filter selected: ")+filter->name(); | 4426 | mess = i18n("Filter selected: ")+filter->name(); |
4423 | filter->setEnabled(true); | 4427 | filter->setEnabled(true); |
4424 | } | 4428 | } |
4425 | else filter->setEnabled(false); | 4429 | else filter->setEnabled(false); |
4426 | mCalendar->setFilter(filter); | 4430 | mCalendar->setFilter(filter); |
4427 | updateView(); | 4431 | updateView(); |
4428 | if ( !mess.isEmpty() ) | 4432 | if ( !mess.isEmpty() ) |
4429 | topLevelWidget()->setCaption( mess ); | 4433 | topLevelWidget()->setCaption( mess ); |
4430 | 4434 | ||
4431 | } | 4435 | } |
4432 | emit filtersUpdated(); | 4436 | emit filtersUpdated(); |
4433 | } | 4437 | } |
4434 | 4438 | ||
4435 | void CalendarView::filterEdited() | 4439 | void CalendarView::filterEdited() |
4436 | { | 4440 | { |
4437 | mFilterView->updateFilters(); | 4441 | mFilterView->updateFilters(); |
4438 | updateFilter(); | 4442 | updateFilter(); |
4439 | writeSettings(); | 4443 | writeSettings(); |
4440 | } | 4444 | } |
4441 | 4445 | ||
4442 | 4446 | ||
4443 | void CalendarView::takeOverEvent() | 4447 | void CalendarView::takeOverEvent() |
4444 | { | 4448 | { |
4445 | Incidence *incidence = currentSelection(); | 4449 | Incidence *incidence = currentSelection(); |
4446 | 4450 | ||
4447 | if (!incidence) return; | 4451 | if (!incidence) return; |
4448 | 4452 | ||
4449 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4453 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4450 | incidence->recreate(); | 4454 | incidence->recreate(); |
4451 | incidence->setReadOnly(false); | 4455 | incidence->setReadOnly(false); |
4452 | 4456 | ||
4453 | updateView(); | 4457 | updateView(); |
4454 | } | 4458 | } |
4455 | 4459 | ||
4456 | void CalendarView::takeOverCalendar() | 4460 | void CalendarView::takeOverCalendar() |
4457 | { | 4461 | { |
4458 | // TODO: Create Calendar::allIncidences() function and use it here | 4462 | // TODO: Create Calendar::allIncidences() function and use it here |
4459 | 4463 | ||
4460 | clearAllViews(); | 4464 | clearAllViews(); |
4461 | QPtrList<Event> events = mCalendar->events(); | 4465 | QPtrList<Event> events = mCalendar->events(); |
4462 | for(uint i=0; i<events.count(); ++i) { | 4466 | for(uint i=0; i<events.count(); ++i) { |
4463 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4467 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4464 | events.at(i)->recreate(); | 4468 | events.at(i)->recreate(); |
4465 | events.at(i)->setReadOnly(false); | 4469 | events.at(i)->setReadOnly(false); |
4466 | } | 4470 | } |
4467 | 4471 | ||
4468 | QPtrList<Todo> todos = mCalendar->todos(); | 4472 | QPtrList<Todo> todos = mCalendar->todos(); |
4469 | for(uint i=0; i<todos.count(); ++i) { | 4473 | for(uint i=0; i<todos.count(); ++i) { |
4470 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4474 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4471 | todos.at(i)->recreate(); | 4475 | todos.at(i)->recreate(); |
4472 | todos.at(i)->setReadOnly(false); | 4476 | todos.at(i)->setReadOnly(false); |
4473 | } | 4477 | } |
4474 | 4478 | ||
4475 | QPtrList<Journal> journals = mCalendar->journals(); | 4479 | QPtrList<Journal> journals = mCalendar->journals(); |
4476 | for(uint i=0; i<journals.count(); ++i) { | 4480 | for(uint i=0; i<journals.count(); ++i) { |
4477 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4481 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4478 | journals.at(i)->recreate(); | 4482 | journals.at(i)->recreate(); |
4479 | journals.at(i)->setReadOnly(false); | 4483 | journals.at(i)->setReadOnly(false); |
4480 | } | 4484 | } |
4481 | 4485 | ||
4482 | updateView(); | 4486 | updateView(); |
4483 | } | 4487 | } |
4484 | 4488 | ||
4485 | void CalendarView::showIntro() | 4489 | void CalendarView::showIntro() |
4486 | { | 4490 | { |
4487 | kdDebug() << "To be implemented." << endl; | 4491 | kdDebug() << "To be implemented." << endl; |
4488 | } | 4492 | } |
4489 | 4493 | ||
4490 | QWidgetStack *CalendarView::viewStack() | 4494 | QWidgetStack *CalendarView::viewStack() |
4491 | { | 4495 | { |
4492 | return mRightFrame; | 4496 | return mRightFrame; |
4493 | } | 4497 | } |
4494 | 4498 | ||
4495 | QWidget *CalendarView::leftFrame() | 4499 | QWidget *CalendarView::leftFrame() |
4496 | { | 4500 | { |
4497 | return ( QWidget *)mLeftFrame; | 4501 | return ( QWidget *)mLeftFrame; |
4498 | } | 4502 | } |
4499 | 4503 | ||
4500 | DateNavigator *CalendarView::dateNavigator() | 4504 | DateNavigator *CalendarView::dateNavigator() |
4501 | { | 4505 | { |
4502 | return mNavigator; | 4506 | return mNavigator; |
4503 | } | 4507 | } |
4504 | 4508 | ||
4505 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4509 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4506 | { | 4510 | { |
4507 | return mDateNavigator->navigatorView(); | 4511 | return mDateNavigator->navigatorView(); |
4508 | } | 4512 | } |
4509 | void CalendarView::toggleDateNavigatorWidget() | 4513 | void CalendarView::toggleDateNavigatorWidget() |
4510 | { | 4514 | { |
4511 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4515 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4512 | 4516 | ||
4513 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4517 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4514 | mDateNavigator->hide(); | 4518 | mDateNavigator->hide(); |
4515 | else | 4519 | else |
4516 | mDateNavigator->show(); | 4520 | mDateNavigator->show(); |
4517 | } | 4521 | } |
4518 | void CalendarView::addView(KOrg::BaseView *view) | 4522 | void CalendarView::addView(KOrg::BaseView *view) |
4519 | { | 4523 | { |
4520 | mViewManager->addView(view); | 4524 | mViewManager->addView(view); |
4521 | } | 4525 | } |
4522 | 4526 | ||
4523 | void CalendarView::showView(KOrg::BaseView *view) | 4527 | void CalendarView::showView(KOrg::BaseView *view) |
4524 | { | 4528 | { |
4525 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4529 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4526 | } | 4530 | } |
4527 | 4531 | ||
4528 | Incidence *CalendarView::currentSelection() | 4532 | Incidence *CalendarView::currentSelection() |
4529 | { | 4533 | { |
4530 | return mViewManager->currentSelection(); | 4534 | return mViewManager->currentSelection(); |
4531 | } | 4535 | } |
4532 | void CalendarView::toggleAllDaySize() | 4536 | void CalendarView::toggleAllDaySize() |
4533 | { | 4537 | { |
4534 | /* | 4538 | /* |
4535 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4539 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4536 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4540 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4537 | else | 4541 | else |
4538 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4542 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4539 | */ | 4543 | */ |
4540 | viewManager()->agendaView()->toggleAllDay(); | 4544 | viewManager()->agendaView()->toggleAllDay(); |
4541 | } | 4545 | } |
4542 | void CalendarView::toggleExpand() | 4546 | void CalendarView::toggleExpand() |
4543 | { | 4547 | { |
4544 | // if ( mLeftFrame->isHidden() ) { | 4548 | // if ( mLeftFrame->isHidden() ) { |
4545 | // mLeftFrame->show(); | 4549 | // mLeftFrame->show(); |
4546 | // emit calendarViewExpanded( false ); | 4550 | // emit calendarViewExpanded( false ); |
4547 | // } else { | 4551 | // } else { |
4548 | // mLeftFrame->hide(); | 4552 | // mLeftFrame->hide(); |
4549 | // emit calendarViewExpanded( true ); | 4553 | // emit calendarViewExpanded( true ); |
4550 | // } | 4554 | // } |
4551 | //qDebug(" CalendarView::toggleExpand()"); | 4555 | //qDebug(" CalendarView::toggleExpand()"); |
4552 | globalFlagBlockAgenda = 1; | 4556 | globalFlagBlockAgenda = 1; |
4553 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4557 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4554 | globalFlagBlockAgenda = 5; | 4558 | globalFlagBlockAgenda = 5; |
4555 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4559 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4556 | //mViewManager->showView( 0, true ); | 4560 | //mViewManager->showView( 0, true ); |
4557 | } | 4561 | } |
4558 | 4562 | ||
4559 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4563 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4560 | { | 4564 | { |
4561 | setModified( modified ); | 4565 | setModified( modified ); |
4562 | } | 4566 | } |
4563 | 4567 | ||
4564 | Todo *CalendarView::selectedTodo() | 4568 | Todo *CalendarView::selectedTodo() |
4565 | { | 4569 | { |
4566 | Incidence *incidence = currentSelection(); | 4570 | Incidence *incidence = currentSelection(); |
4567 | if ( incidence && incidence->typeID() == todoID ) { | 4571 | if ( incidence && incidence->typeID() == todoID ) { |
4568 | return static_cast<Todo *>( incidence ); | 4572 | return static_cast<Todo *>( incidence ); |
4569 | } | 4573 | } |
4570 | 4574 | ||
4571 | incidence = mTodoList->selectedIncidences().first(); | 4575 | incidence = mTodoList->selectedIncidences().first(); |
4572 | if ( incidence && incidence->typeID() == todoID ) { | 4576 | if ( incidence && incidence->typeID() == todoID ) { |
4573 | return static_cast<Todo *>( incidence ); | 4577 | return static_cast<Todo *>( incidence ); |
4574 | } | 4578 | } |
4575 | 4579 | ||
4576 | return 0; | 4580 | return 0; |
4577 | } | 4581 | } |
4578 | 4582 | ||
4579 | void CalendarView::showIncidence() | 4583 | void CalendarView::showIncidence() |
4580 | { | 4584 | { |
4581 | mViewerCallerIsSearchDialog = false; | 4585 | mViewerCallerIsSearchDialog = false; |
4582 | Incidence *incidence = currentSelection(); | 4586 | Incidence *incidence = currentSelection(); |
4583 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4587 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4584 | if ( incidence ) { | 4588 | if ( incidence ) { |
4585 | ShowIncidenceVisitor v; | 4589 | ShowIncidenceVisitor v; |
4586 | v.act( incidence, this ); | 4590 | v.act( incidence, this ); |
4587 | } | 4591 | } |
4588 | } | 4592 | } |
4589 | void CalendarView::editIncidenceDescription() | 4593 | void CalendarView::editIncidenceDescription() |
4590 | { | 4594 | { |
4591 | mFlagEditDescription = true; | 4595 | mFlagEditDescription = true; |
4592 | editIncidence(); | 4596 | editIncidence(); |
4593 | mFlagEditDescription = false; | 4597 | mFlagEditDescription = false; |
4594 | } | 4598 | } |
4595 | void CalendarView::editIncidence() | 4599 | void CalendarView::editIncidence() |
4596 | { | 4600 | { |
4597 | // qDebug("editIncidence() "); | 4601 | // qDebug("editIncidence() "); |
4598 | Incidence *incidence = currentSelection(); | 4602 | Incidence *incidence = currentSelection(); |
4599 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4603 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4600 | if ( incidence ) { | 4604 | if ( incidence ) { |
4601 | EditIncidenceVisitor v; | 4605 | EditIncidenceVisitor v; |
4602 | v.act( incidence, this ); | 4606 | v.act( incidence, this ); |
4603 | } | 4607 | } |
4604 | } | 4608 | } |
4605 | 4609 | ||
4606 | void CalendarView::deleteIncidence() | 4610 | void CalendarView::deleteIncidence() |
4607 | { | 4611 | { |
4608 | Incidence *incidence = currentSelection(); | 4612 | Incidence *incidence = currentSelection(); |
4609 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4613 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4610 | if ( incidence ) { | 4614 | if ( incidence ) { |
4611 | deleteIncidence(incidence); | 4615 | deleteIncidence(incidence); |
4612 | } | 4616 | } |
4613 | } | 4617 | } |
4614 | void CalendarView::showIncidence(QString uid) | 4618 | void CalendarView::showIncidence(QString uid) |
4615 | { | 4619 | { |
4616 | Incidence *inc = mCalendar->incidence( uid ); | 4620 | Incidence *inc = mCalendar->incidence( uid ); |
4617 | if ( inc ) | 4621 | if ( inc ) |
4618 | showIncidence( inc ); | 4622 | showIncidence( inc ); |
4619 | } | 4623 | } |
4620 | void CalendarView::showIncidence(Incidence *incidence) | 4624 | void CalendarView::showIncidence(Incidence *incidence) |
4621 | { | 4625 | { |
4622 | mViewerCallerIsSearchDialog = false; | 4626 | mViewerCallerIsSearchDialog = false; |
4623 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4627 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4624 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4628 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4625 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4629 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4626 | mViewerCallerIsSearchDialog = true; | 4630 | mViewerCallerIsSearchDialog = true; |
4627 | } | 4631 | } |
4628 | } | 4632 | } |
4629 | if ( incidence ) { | 4633 | if ( incidence ) { |
4630 | ShowIncidenceVisitor v; | 4634 | ShowIncidenceVisitor v; |
4631 | v.act( incidence, this ); | 4635 | v.act( incidence, this ); |
4632 | } | 4636 | } |
4633 | } | 4637 | } |
4634 | 4638 | ||
4635 | void CalendarView::editIncidence(Incidence *incidence) | 4639 | void CalendarView::editIncidence(Incidence *incidence) |
4636 | { | 4640 | { |
4637 | if ( incidence ) { | 4641 | if ( incidence ) { |
4638 | 4642 | ||
4639 | EditIncidenceVisitor v; | 4643 | EditIncidenceVisitor v; |
4640 | v.act( incidence, this ); | 4644 | v.act( incidence, this ); |
4641 | 4645 | ||
4642 | } | 4646 | } |
4643 | } | 4647 | } |
4644 | 4648 | ||
4645 | void CalendarView::deleteIncidence(Incidence *incidence) | 4649 | void CalendarView::deleteIncidence(Incidence *incidence) |
4646 | { | 4650 | { |
4647 | //qDebug(" CalendarView::deleteIncidence "); | 4651 | //qDebug(" CalendarView::deleteIncidence "); |
4648 | if ( incidence == 0 ) { | 4652 | if ( incidence == 0 ) { |
4649 | updateView(); | 4653 | updateView(); |
4650 | emit updateSearchDialog(); | 4654 | emit updateSearchDialog(); |
4651 | return; | 4655 | return; |
4652 | } | 4656 | } |
4653 | if ( incidence ) { | 4657 | if ( incidence ) { |
4654 | DeleteIncidenceVisitor v; | 4658 | DeleteIncidenceVisitor v; |
4655 | v.act( incidence, this ); | 4659 | v.act( incidence, this ); |
4656 | } | 4660 | } |
4657 | } | 4661 | } |
4658 | 4662 | ||
4659 | 4663 | ||
4660 | void CalendarView::lookForOutgoingMessages() | 4664 | void CalendarView::lookForOutgoingMessages() |
4661 | { | 4665 | { |
4662 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4666 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4663 | ogd->loadMessages(); | 4667 | ogd->loadMessages(); |
4664 | } | 4668 | } |
4665 | 4669 | ||
4666 | void CalendarView::lookForIncomingMessages() | 4670 | void CalendarView::lookForIncomingMessages() |
4667 | { | 4671 | { |
4668 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4672 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4669 | icd->retrieve(); | 4673 | icd->retrieve(); |
4670 | } | 4674 | } |
4671 | 4675 | ||
4672 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4676 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4673 | { | 4677 | { |
4674 | bool deleteTodo = true; | 4678 | bool deleteTodo = true; |
4675 | QPtrList<Incidence> subTodos; | 4679 | QPtrList<Incidence> subTodos; |
4676 | Incidence *aTodo; | 4680 | Incidence *aTodo; |
4677 | subTodos = t->relations(); | 4681 | subTodos = t->relations(); |
4678 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4682 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4679 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4683 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4680 | deleteTodo = false; | 4684 | deleteTodo = false; |
4681 | } | 4685 | } |
4682 | if ( deleteTodo ) { | 4686 | if ( deleteTodo ) { |
4683 | if ( t->isCompleted() && !t->doesRecur()) { | 4687 | if ( t->isCompleted() && !t->doesRecur()) { |
4684 | checkExternalId( t ); | 4688 | checkExternalId( t ); |
4685 | mCalendar->deleteTodo( t ); | 4689 | mCalendar->deleteTodo( t ); |
4686 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4690 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4687 | } | 4691 | } |
4688 | else | 4692 | else |
4689 | deleteTodo = false; | 4693 | deleteTodo = false; |
4690 | } | 4694 | } |
4691 | return deleteTodo; | 4695 | return deleteTodo; |
4692 | 4696 | ||
4693 | } | 4697 | } |
4694 | void CalendarView::purgeCompleted() | 4698 | void CalendarView::purgeCompleted() |
4695 | { | 4699 | { |
4696 | int result = KMessageBox::warningContinueCancel(this, | 4700 | int result = KMessageBox::warningContinueCancel(this, |
4697 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4701 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4698 | 4702 | ||
4699 | if (result == KMessageBox::Continue) { | 4703 | if (result == KMessageBox::Continue) { |
4700 | 4704 | ||
4701 | QPtrList<Todo> todoCal; | 4705 | QPtrList<Todo> todoCal; |
4702 | QPtrList<Todo> rootTodos; | 4706 | QPtrList<Todo> rootTodos; |
4703 | //QPtrList<Incidence> rel; | 4707 | //QPtrList<Incidence> rel; |
4704 | Todo *aTodo; | 4708 | Todo *aTodo; |
4705 | todoCal = calendar()->todos(); | 4709 | todoCal = calendar()->todos(); |
4706 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4710 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4707 | if ( !aTodo->relatedTo() ) | 4711 | if ( !aTodo->relatedTo() ) |
4708 | rootTodos.append( aTodo ); | 4712 | rootTodos.append( aTodo ); |
4709 | } | 4713 | } |
4710 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4714 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4711 | removeCompletedSubTodos( aTodo ); | 4715 | removeCompletedSubTodos( aTodo ); |
4712 | } | 4716 | } |
4713 | 4717 | ||
4714 | updateView(); | 4718 | updateView(); |
4715 | } | 4719 | } |
4716 | } | 4720 | } |
4717 | 4721 | ||
4718 | void CalendarView::slotCalendarChanged() | 4722 | void CalendarView::slotCalendarChanged() |
4719 | { | 4723 | { |
4720 | ; | 4724 | ; |
4721 | } | 4725 | } |
4722 | 4726 | ||
4723 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4727 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4724 | { | 4728 | { |
4725 | //qDebug("CalendarView::keyPressEvent "); | 4729 | //qDebug("CalendarView::keyPressEvent "); |
4726 | e->ignore(); | 4730 | e->ignore(); |
4727 | } | 4731 | } |
4728 | 4732 | ||
4729 | 4733 | ||
4730 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4734 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4731 | { | 4735 | { |
4732 | 4736 | ||
4733 | if ( manager != mSyncManager) | 4737 | if ( manager != mSyncManager) |
4734 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 4738 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
4735 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4739 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4736 | qDebug("KO: SyncKDE request detected!"); | 4740 | qDebug("KO: SyncKDE request detected!"); |
4737 | } | 4741 | } |
4738 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4742 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4739 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4743 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4740 | return syncCalendar( filename, mode ); | 4744 | return syncCalendar( filename, mode ); |
4741 | } | 4745 | } |
4742 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4746 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4743 | { | 4747 | { |
4744 | //mSyncManager = manager; | 4748 | //mSyncManager = manager; |
4745 | if ( manager != mSyncManager) | 4749 | if ( manager != mSyncManager) |
4746 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 4750 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
4747 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4751 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4748 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4752 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4749 | if ( resource == "sharp" ) | 4753 | if ( resource == "sharp" ) |
4750 | syncExternal( 0 ); | 4754 | syncExternal( 0 ); |
4751 | if ( resource == "phone" ) | 4755 | if ( resource == "phone" ) |
4752 | syncExternal( 1 ); | 4756 | syncExternal( 1 ); |
4753 | // pending setmodified | 4757 | // pending setmodified |
4754 | return true; | 4758 | return true; |
4755 | } | 4759 | } |
4756 | void CalendarView::setSyncManager(KSyncManager* manager) | 4760 | void CalendarView::setSyncManager(KSyncManager* manager) |
4757 | { | 4761 | { |
4758 | mSyncManager = manager; | 4762 | mSyncManager = manager; |
4759 | } | 4763 | } |
4760 | 4764 | ||
4761 | void CalendarView::removeSyncInfo( QString syncProfile) | 4765 | void CalendarView::removeSyncInfo( QString syncProfile) |
4762 | { | 4766 | { |
4763 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4767 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4764 | mCalendar->removeSyncInfo( syncProfile ); | 4768 | mCalendar->removeSyncInfo( syncProfile ); |
4765 | 4769 | ||
4766 | } | 4770 | } |
4767 | 4771 | ||
4768 | void CalendarView::undo_delete() | 4772 | void CalendarView::undo_delete() |
4769 | { | 4773 | { |
4770 | //qDebug("undo_delete() "); | 4774 | //qDebug("undo_delete() "); |
4771 | Incidence* undo = mCalendar->undoIncidence(); | 4775 | Incidence* undo = mCalendar->undoIncidence(); |
4772 | if ( !undo ) { | 4776 | if ( !undo ) { |
4773 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4777 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4774 | i18n("KO/Pi")); | 4778 | i18n("KO/Pi")); |
4775 | return; | 4779 | return; |
4776 | } | 4780 | } |
4777 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 4781 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
4778 | i18n("\nAre you sure you want\nto restore this?"), | 4782 | i18n("\nAre you sure you want\nto restore this?"), |
4779 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4783 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4780 | mCalendar->undoDeleteIncidence(); | 4784 | mCalendar->undoDeleteIncidence(); |
4781 | updateView(); | 4785 | updateView(); |
4782 | } | 4786 | } |
4783 | } | 4787 | } |
4784 | 4788 | ||
4785 | void CalendarView::slotViewerClosed() | 4789 | void CalendarView::slotViewerClosed() |
4786 | { | 4790 | { |
4787 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4791 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4788 | } | 4792 | } |
4789 | 4793 | ||
4790 | void CalendarView::resetFocus() | 4794 | void CalendarView::resetFocus() |
4791 | { | 4795 | { |
4792 | if ( mViewerCallerIsSearchDialog ) { | 4796 | if ( mViewerCallerIsSearchDialog ) { |
4793 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4797 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4794 | mDialogManager->getSearchDialog()->raise(); | 4798 | mDialogManager->getSearchDialog()->raise(); |
4795 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4799 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4796 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4800 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4797 | } else | 4801 | } else |
4798 | mViewerCallerIsSearchDialog = false; | 4802 | mViewerCallerIsSearchDialog = false; |
4799 | } | 4803 | } |
4800 | if ( !mViewerCallerIsSearchDialog ) { | 4804 | if ( !mViewerCallerIsSearchDialog ) { |
4801 | //mViewManager->currentView()->setFocus(); | 4805 | //mViewManager->currentView()->setFocus(); |
4802 | //qDebug("sssssssssssssssset focus "); | 4806 | //qDebug("sssssssssssssssset focus "); |
4803 | topLevelWidget()->raise(); | 4807 | topLevelWidget()->raise(); |
4804 | setActiveWindow(); | 4808 | setActiveWindow(); |
4805 | //setFocus(); | 4809 | //setFocus(); |
4806 | } | 4810 | } |
4807 | mViewerCallerIsSearchDialog = false; | 4811 | mViewerCallerIsSearchDialog = false; |
4808 | } | 4812 | } |
4809 | 4813 | ||
4810 | void CalendarView::showNextAlarms() | 4814 | void CalendarView::showNextAlarms() |
4811 | { | 4815 | { |
4812 | QString message; | 4816 | QString message; |
4813 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4817 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4814 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4818 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4815 | QString sum = mCalendar->nextSummary(); | 4819 | QString sum = mCalendar->nextSummary(); |
4816 | QDateTime nextA = mNextAlarmDateTime; | 4820 | QDateTime nextA = mNextAlarmDateTime; |
4817 | QDateTime cur = QDateTime::currentDateTime(); | 4821 | QDateTime cur = QDateTime::currentDateTime(); |
4818 | int secs = cur.secsTo( nextA ); | 4822 | int secs = cur.secsTo( nextA ); |
4819 | int min = secs /60; | 4823 | int min = secs /60; |
4820 | int hours = min /60; | 4824 | int hours = min /60; |
4821 | min = min % 60; | 4825 | min = min % 60; |
4822 | int days = hours /24; | 4826 | int days = hours /24; |
4823 | hours = hours % 24; | 4827 | hours = hours % 24; |
4824 | 4828 | ||
4825 | //message = i18n("The next alarm is in:\n"); | 4829 | //message = i18n("The next alarm is in:\n"); |
4826 | if ( days > 1 ) | 4830 | if ( days > 1 ) |
4827 | message += i18n("%1 days\n").arg( days ); | 4831 | message += i18n("%1 days\n").arg( days ); |
4828 | else if ( days == 1 ) | 4832 | else if ( days == 1 ) |
4829 | message += i18n("1 day\n"); | 4833 | message += i18n("1 day\n"); |
4830 | if ( hours > 1 ) | 4834 | if ( hours > 1 ) |
4831 | message += i18n("%1 hours\n").arg( hours ); | 4835 | message += i18n("%1 hours\n").arg( hours ); |
4832 | else if ( hours == 1 ) | 4836 | else if ( hours == 1 ) |
4833 | message += i18n("1 hour\n"); | 4837 | message += i18n("1 hour\n"); |
4834 | if ( min > 1 ) | 4838 | if ( min > 1 ) |
4835 | message += i18n("%1 minutes\n").arg( min ); | 4839 | message += i18n("%1 minutes\n").arg( min ); |
4836 | else if ( min == 1 ) | 4840 | else if ( min == 1 ) |
4837 | message += i18n("1 minute\n"); | 4841 | message += i18n("1 minute\n"); |
4838 | if ( message.isEmpty() ) | 4842 | if ( message.isEmpty() ) |
4839 | message = i18n("The next alarm is in\nless than one minute!"); | 4843 | message = i18n("The next alarm is in\nless than one minute!"); |
4840 | else | 4844 | else |
4841 | message = i18n("The next alarm is in:\n") + message; | 4845 | message = i18n("The next alarm is in:\n") + message; |
4842 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4846 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4843 | } else { | 4847 | } else { |
4844 | message = i18n("There is no next alarm."); | 4848 | message = i18n("There is no next alarm."); |
4845 | 4849 | ||
4846 | } | 4850 | } |
4847 | #ifdef DESKTOP_VERSION | 4851 | #ifdef DESKTOP_VERSION |
4848 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4852 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4849 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4853 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4850 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4854 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4851 | } | 4855 | } |
4852 | 4856 | ||
4853 | #endif | 4857 | #endif |
4854 | KMessageBox::information( this, message); | 4858 | KMessageBox::information( this, message); |
4855 | } | 4859 | } |