-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,2888 +1,2892 @@ | |||
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. |