-rw-r--r-- | korganizer/calendarview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 68d1bc6..940ea91 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,1987 +1,1987 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "koagenda.h" | 107 | #include "koagenda.h" |
108 | #include "kodialogmanager.h" | 108 | #include "kodialogmanager.h" |
109 | #include "outgoingdialog.h" | 109 | #include "outgoingdialog.h" |
110 | #include "incomingdialog.h" | 110 | #include "incomingdialog.h" |
111 | #include "datenavigatorcontainer.h" | 111 | #include "datenavigatorcontainer.h" |
112 | #include "statusdialog.h" | 112 | #include "statusdialog.h" |
113 | #include "kdatenavigator.h" | 113 | #include "kdatenavigator.h" |
114 | #include "kotodoview.h" | 114 | #include "kotodoview.h" |
115 | #include "datenavigator.h" | 115 | #include "datenavigator.h" |
116 | #include "resourceview.h" | 116 | #include "resourceview.h" |
117 | #include "navigatorbar.h" | 117 | #include "navigatorbar.h" |
118 | #include "searchdialog.h" | 118 | #include "searchdialog.h" |
119 | #include "mainwindow.h" | 119 | #include "mainwindow.h" |
120 | #include "categoryeditdialog.h" | 120 | #include "categoryeditdialog.h" |
121 | 121 | ||
122 | #include "calendarview.h" | 122 | #include "calendarview.h" |
123 | #ifndef DESKTOP_VERSION | 123 | #ifndef DESKTOP_VERSION |
124 | #include <qtopia/alarmserver.h> | 124 | #include <qtopia/alarmserver.h> |
125 | #endif | 125 | #endif |
126 | #ifndef _WIN32_ | 126 | #ifndef _WIN32_ |
127 | #include <stdlib.h> | 127 | #include <stdlib.h> |
128 | #include <stdio.h> | 128 | #include <stdio.h> |
129 | #include <unistd.h> | 129 | #include <unistd.h> |
130 | #else | 130 | #else |
131 | #include <qprocess.h> | 131 | #include <qprocess.h> |
132 | #endif | 132 | #endif |
133 | 133 | ||
134 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
135 | #include <kabc/stdaddressbook.h> | 135 | #include <kabc/stdaddressbook.h> |
136 | #endif | 136 | #endif |
137 | using namespace KOrg; | 137 | using namespace KOrg; |
138 | using namespace KCal; | 138 | using namespace KCal; |
139 | extern int globalFlagBlockAgenda; | 139 | extern int globalFlagBlockAgenda; |
140 | extern int globalFlagBlockStartup; | 140 | extern int globalFlagBlockStartup; |
141 | 141 | ||
142 | 142 | ||
143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
144 | 144 | ||
145 | { | 145 | { |
146 | mAlarms = alarms; | 146 | mAlarms = alarms; |
147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
148 | QString mText = "<table width=\"100%\">\n"; | 148 | QString mText = "<table width=\"100%\">\n"; |
149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
150 | #ifdef DESKTOP_VERSION | 150 | #ifdef DESKTOP_VERSION |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
152 | #else | 152 | #else |
153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
154 | #endif | 154 | #endif |
155 | // mText += "<img src=\""; | 155 | // mText += "<img src=\""; |
156 | // mText += ipath; | 156 | // mText += ipath; |
157 | // mText += "\">"; | 157 | // mText += "\">"; |
158 | //mEventDate = QDate::currentDate(); | 158 | //mEventDate = QDate::currentDate(); |
159 | #ifdef DESKTOP_VERSION | 159 | #ifdef DESKTOP_VERSION |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
161 | #else | 161 | #else |
162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
163 | #endif | 163 | #endif |
164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
165 | 165 | ||
166 | Incidence * inc = getNextInc( start ); | 166 | Incidence * inc = getNextInc( start ); |
167 | int time = 0; | 167 | int time = 0; |
168 | //mText += "<table>"; | 168 | //mText += "<table>"; |
169 | while ( inc ) { | 169 | while ( inc ) { |
170 | QDateTime dt ; | 170 | QDateTime dt ; |
171 | QString tempText = "<a "; | 171 | QString tempText = "<a "; |
172 | bool ok; | 172 | bool ok; |
173 | dt = inc->getNextOccurence( start, &ok ); | 173 | dt = inc->getNextOccurence( start, &ok ); |
174 | if ( !ok ) continue; | 174 | if ( !ok ) continue; |
175 | if ( inc->typeID() == eventID ) { | 175 | if ( inc->typeID() == eventID ) { |
176 | tempText += "href=\"event:"; | 176 | tempText += "href=\"event:"; |
177 | } else if ( inc->typeID() == todoID ) { | 177 | } else if ( inc->typeID() == todoID ) { |
178 | tempText += "href=\"todo:"; | 178 | tempText += "href=\"todo:"; |
179 | } | 179 | } |
180 | tempText += inc->uid() + "\">"; | 180 | tempText += inc->uid() + "\">"; |
181 | if ( inc->typeID() == todoID ) | 181 | if ( inc->typeID() == todoID ) |
182 | tempText += i18n("Todo: "); | 182 | tempText += i18n("Todo: "); |
183 | if ( inc->summary().length() > 0 ) | 183 | if ( inc->summary().length() > 0 ) |
184 | tempText += inc->summary(); | 184 | tempText += inc->summary(); |
185 | else | 185 | else |
186 | tempText += i18n("-no summary-"); | 186 | tempText += i18n("-no summary-"); |
187 | QString timestr; | 187 | QString timestr; |
188 | if (!inc->doesFloat()) | 188 | if (!inc->doesFloat()) |
189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | else | 190 | else |
191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
194 | mText += "<table>"; | 194 | mText += "<table>"; |
195 | time = 1; | 195 | time = 1; |
196 | } | 196 | } |
197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
198 | if ( time > 0 ) | 198 | if ( time > 0 ) |
199 | mText +="</table>"; | 199 | mText +="</table>"; |
200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
201 | mText += "<table>"; | 201 | mText += "<table>"; |
202 | time = 2; | 202 | time = 2; |
203 | 203 | ||
204 | } | 204 | } |
205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
206 | if ( time > 0 ) | 206 | if ( time > 0 ) |
207 | mText +="</table>"; | 207 | mText +="</table>"; |
208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
209 | mText += "<table>"; | 209 | mText += "<table>"; |
210 | time = 3; | 210 | time = 3; |
211 | } | 211 | } |
212 | mText +="<tr><td><b>"; | 212 | mText +="<tr><td><b>"; |
213 | mText += timestr; | 213 | mText += timestr; |
214 | mText += "</b></td><td>"; | 214 | mText += "</b></td><td>"; |
215 | mText += tempText; | 215 | mText += tempText; |
216 | mText += "</td></tr>\n"; | 216 | mText += "</td></tr>\n"; |
217 | inc = getNextInc( start ); | 217 | inc = getNextInc( start ); |
218 | } | 218 | } |
219 | mText +="</table>"; | 219 | mText +="</table>"; |
220 | setText( mText ); | 220 | setText( mText ); |
221 | } | 221 | } |
222 | 222 | ||
223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
224 | { | 224 | { |
225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
226 | } | 226 | } |
227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
228 | { | 228 | { |
229 | QDateTime dt ; | 229 | QDateTime dt ; |
230 | Incidence * retInc; | 230 | Incidence * retInc; |
231 | Incidence * inc = mAlarms.first(); | 231 | Incidence * inc = mAlarms.first(); |
232 | if ( inc == 0 ) | 232 | if ( inc == 0 ) |
233 | return 0; | 233 | return 0; |
234 | bool ok; | 234 | bool ok; |
235 | dt = inc->getNextOccurence( start, &ok ); | 235 | dt = inc->getNextOccurence( start, &ok ); |
236 | if ( ! ok ) return 0; | 236 | if ( ! ok ) return 0; |
237 | QDateTime dtn ; | 237 | QDateTime dtn ; |
238 | retInc = inc; | 238 | retInc = inc; |
239 | inc = mAlarms.next(); | 239 | inc = mAlarms.next(); |
240 | while ( inc ) { | 240 | while ( inc ) { |
241 | dtn = inc->getNextOccurence( start, &ok ); | 241 | dtn = inc->getNextOccurence( start, &ok ); |
242 | if ( ! ok ) return 0; | 242 | if ( ! ok ) return 0; |
243 | if ( dtn < dt ) { | 243 | if ( dtn < dt ) { |
244 | dt = dtn; | 244 | dt = dtn; |
245 | retInc = inc; | 245 | retInc = inc; |
246 | } | 246 | } |
247 | inc = mAlarms.next(); | 247 | inc = mAlarms.next(); |
248 | } | 248 | } |
249 | mAlarms.remove( retInc ); | 249 | mAlarms.remove( retInc ); |
250 | return retInc; | 250 | return retInc; |
251 | 251 | ||
252 | } | 252 | } |
253 | void MissedAlarmTextBrowser::setSource(const QString & n) | 253 | void MissedAlarmTextBrowser::setSource(const QString & n) |
254 | { | 254 | { |
255 | if (n.startsWith("event:")) { | 255 | if (n.startsWith("event:")) { |
256 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
257 | emit showIncidence(n.mid(8)); | 257 | emit showIncidence(n.mid(8)); |
258 | #else | 258 | #else |
259 | emit showIncidence(n.mid(6)); | 259 | emit showIncidence(n.mid(6)); |
260 | #endif | 260 | #endif |
261 | return; | 261 | return; |
262 | } else if (n.startsWith("todo:")) { | 262 | } else if (n.startsWith("todo:")) { |
263 | #ifdef DESKTOP_VERSION | 263 | #ifdef DESKTOP_VERSION |
264 | emit showIncidence(n.mid(7)); | 264 | emit showIncidence(n.mid(7)); |
265 | #else | 265 | #else |
266 | emit showIncidence(n.mid(5)); | 266 | emit showIncidence(n.mid(5)); |
267 | #endif | 267 | #endif |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | class KOBeamPrefs : public QDialog | 273 | class KOBeamPrefs : public QDialog |
274 | { | 274 | { |
275 | public: | 275 | public: |
276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
277 | QDialog( parent, name, true ) | 277 | QDialog( parent, name, true ) |
278 | { | 278 | { |
279 | setCaption( i18n("Beam Options") ); | 279 | setCaption( i18n("Beam Options") ); |
280 | QVBoxLayout* lay = new QVBoxLayout( this ); | 280 | QVBoxLayout* lay = new QVBoxLayout( this ); |
281 | lay->setSpacing( 3 ); | 281 | lay->setSpacing( 3 ); |
282 | lay->setMargin( 3 ); | 282 | lay->setMargin( 3 ); |
283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
284 | lay->addWidget( format ); | 284 | lay->addWidget( format ); |
285 | format->setExclusive ( true ) ; | 285 | format->setExclusive ( true ) ; |
286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
287 | lay->addWidget( time ); time->setExclusive ( true ) ; | 287 | lay->addWidget( time ); time->setExclusive ( true ) ; |
288 | vcal = new QRadioButton(" vCalendar ", format ); | 288 | vcal = new QRadioButton(" vCalendar ", format ); |
289 | ical = new QRadioButton(" iCalendar ", format ); | 289 | ical = new QRadioButton(" iCalendar ", format ); |
290 | vcal->setChecked( true ); | 290 | vcal->setChecked( true ); |
291 | tz = new QRadioButton(i18n(" With timezone "), time ); | 291 | tz = new QRadioButton(i18n(" With timezone "), time ); |
292 | local = new QRadioButton(i18n(" Local time "), time ); | 292 | local = new QRadioButton(i18n(" Local time "), time ); |
293 | tz->setChecked( true ); | 293 | tz->setChecked( true ); |
294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
295 | lay->addWidget( ok ); | 295 | lay->addWidget( ok ); |
296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
297 | lay->addWidget( cancel ); | 297 | lay->addWidget( cancel ); |
298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
300 | resize( 200, 200 ); | 300 | resize( 200, 200 ); |
301 | } | 301 | } |
302 | 302 | ||
303 | bool beamVcal() { return vcal->isChecked(); } | 303 | bool beamVcal() { return vcal->isChecked(); } |
304 | bool beamLocal() { return local->isChecked(); } | 304 | bool beamLocal() { return local->isChecked(); } |
305 | private: | 305 | private: |
306 | QRadioButton* vcal, *ical, *local, *tz; | 306 | QRadioButton* vcal, *ical, *local, *tz; |
307 | }; | 307 | }; |
308 | class KOCatPrefs : public QDialog | 308 | class KOCatPrefs : public QDialog |
309 | { | 309 | { |
310 | public: | 310 | public: |
311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
312 | QDialog( parent, name, true ) | 312 | QDialog( parent, name, true ) |
313 | { | 313 | { |
314 | setCaption( i18n("Manage new Categories") ); | 314 | setCaption( i18n("Manage new Categories") ); |
315 | QVBoxLayout* lay = new QVBoxLayout( this ); | 315 | QVBoxLayout* lay = new QVBoxLayout( this ); |
316 | lay->setSpacing( 3 ); | 316 | lay->setSpacing( 3 ); |
317 | lay->setMargin( 3 ); | 317 | lay->setMargin( 3 ); |
318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); | 318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); |
319 | lay->addWidget( lab ); | 319 | lay->addWidget( lab ); |
320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
321 | lay->addWidget( format ); | 321 | lay->addWidget( format ); |
322 | format->setExclusive ( true ) ; | 322 | format->setExclusive ( true ) ; |
323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
325 | addCatBut->setChecked( true ); | 325 | addCatBut->setChecked( true ); |
326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
327 | lay->addWidget( ok ); | 327 | lay->addWidget( ok ); |
328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
329 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
332 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
333 | } | 333 | } |
334 | 334 | ||
335 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
336 | private: | 336 | private: |
337 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | 340 | ||
341 | 341 | ||
342 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
343 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
344 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
345 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
346 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
347 | { | 347 | { |
348 | 348 | ||
349 | mEventEditor = 0; | 349 | mEventEditor = 0; |
350 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
351 | 351 | ||
352 | init(); | 352 | init(); |
353 | } | 353 | } |
354 | 354 | ||
355 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
356 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
357 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
358 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
359 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
360 | { | 360 | { |
361 | 361 | ||
362 | mEventEditor = 0; | 362 | mEventEditor = 0; |
363 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
364 | init(); | 364 | init(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void CalendarView::init() | 367 | void CalendarView::init() |
368 | { | 368 | { |
369 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 369 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
370 | setFocusPolicy ( NoFocus ); | 370 | setFocusPolicy ( NoFocus ); |
371 | mViewerCallerIsSearchDialog = false; | 371 | mViewerCallerIsSearchDialog = false; |
372 | mBlockShowDates = false; | 372 | mBlockShowDates = false; |
373 | 373 | ||
374 | mDatePickerMode = 0; | 374 | mDatePickerMode = 0; |
375 | mCurrentSyncDevice = ""; | 375 | mCurrentSyncDevice = ""; |
376 | mViewManager = new KOViewManager( this ); | 376 | mViewManager = new KOViewManager( this ); |
377 | mDialogManager = new KODialogManager( this ); | 377 | mDialogManager = new KODialogManager( this ); |
378 | mEventViewerDialog = 0; | 378 | mEventViewerDialog = 0; |
379 | mModified = false; | 379 | mModified = false; |
380 | mReadOnly = false; | 380 | mReadOnly = false; |
381 | mSelectedIncidence = 0; | 381 | mSelectedIncidence = 0; |
382 | mCalPrinter = 0; | 382 | mCalPrinter = 0; |
383 | mFilters.setAutoDelete(true); | 383 | mFilters.setAutoDelete(true); |
384 | 384 | ||
385 | mCalendar->registerObserver( this ); | 385 | mCalendar->registerObserver( this ); |
386 | // TODO: Make sure that view is updated, when calendar is changed. | 386 | // TODO: Make sure that view is updated, when calendar is changed. |
387 | 387 | ||
388 | mStorage = new FileStorage( mCalendar ); | 388 | mStorage = new FileStorage( mCalendar ); |
389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
390 | 390 | ||
391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
392 | #ifndef KORG_NOSPLITTER | 392 | #ifndef KORG_NOSPLITTER |
393 | // create the main layout frames. | 393 | // create the main layout frames. |
394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
395 | topLayout->addWidget(mPanner); | 395 | topLayout->addWidget(mPanner); |
396 | 396 | ||
397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
398 | "CalendarView::LeftFrame"); | 398 | "CalendarView::LeftFrame"); |
399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
400 | 400 | ||
401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
402 | "CalendarView::DateNavigator" ); | 402 | "CalendarView::DateNavigator" ); |
403 | 403 | ||
404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
406 | mTodoList->setNavigator( mNavigator ); | 406 | mTodoList->setNavigator( mNavigator ); |
407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
408 | 408 | ||
409 | #ifdef KORG_NORESOURCEVIEW | 409 | #ifdef KORG_NORESOURCEVIEW |
410 | mResourceView = 0; | 410 | mResourceView = 0; |
411 | #else | 411 | #else |
412 | if ( mResourceManager ) { | 412 | if ( mResourceManager ) { |
413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
414 | mResourceView->updateView(); | 414 | mResourceView->updateView(); |
415 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 415 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
416 | SLOT( updateView() ) ); | 416 | SLOT( updateView() ) ); |
417 | } else { | 417 | } else { |
418 | mResourceView = 0; | 418 | mResourceView = 0; |
419 | } | 419 | } |
420 | #endif | 420 | #endif |
421 | QWidget *rightBox = new QWidget( mPanner ); | 421 | QWidget *rightBox = new QWidget( mPanner ); |
422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
423 | 423 | ||
424 | mRightFrame = new QWidgetStack( rightBox ); | 424 | mRightFrame = new QWidgetStack( rightBox ); |
425 | rightLayout->addWidget( mRightFrame, 1 ); | 425 | rightLayout->addWidget( mRightFrame, 1 ); |
426 | 426 | ||
427 | mLeftFrame = mLeftSplitter; | 427 | mLeftFrame = mLeftSplitter; |
428 | #else | 428 | #else |
429 | //QWidget *mainBox = new QWidget( this ); | 429 | //QWidget *mainBox = new QWidget( this ); |
430 | //QWidget *leftFrame = new QWidget( mainBox ); | 430 | //QWidget *leftFrame = new QWidget( mainBox ); |
431 | //QBoxLayout * mainBoxLayout; | 431 | //QBoxLayout * mainBoxLayout; |
432 | if ( KOPrefs::instance()->mVerticalScreen ) { | 432 | if ( KOPrefs::instance()->mVerticalScreen ) { |
433 | //mainBoxLayout = new QVBoxLayout(mainBox); | 433 | //mainBoxLayout = new QVBoxLayout(mainBox); |
434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
439 | } else { | 439 | } else { |
440 | //mainBoxLayout = new QHBoxLayout(mainBox); | 440 | //mainBoxLayout = new QHBoxLayout(mainBox); |
441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
446 | } | 446 | } |
447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
448 | //QBoxLayout * leftFrameLayout; | 448 | //QBoxLayout * leftFrameLayout; |
449 | topLayout->addWidget( mMainFrame ); | 449 | topLayout->addWidget( mMainFrame ); |
450 | #ifdef DESKTOP_VERSION | 450 | #ifdef DESKTOP_VERSION |
451 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
452 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
454 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
455 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
456 | #endif | 456 | #endif |
457 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
459 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
460 | #if 0 | 460 | #if 0 |
461 | // FIXME | 461 | // FIXME |
462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
463 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
464 | #endif | 464 | #endif |
465 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
466 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
480 | 480 | ||
481 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
482 | #if 0 | 482 | #if 0 |
483 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
484 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
485 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
486 | 486 | ||
487 | } else { | 487 | } else { |
488 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
489 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
490 | } | 490 | } |
491 | #endif | 491 | #endif |
492 | mFilterView->hide(); | 492 | mFilterView->hide(); |
493 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
494 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
495 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
497 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
498 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
499 | 499 | ||
500 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
501 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
506 | } else { | 506 | } else { |
507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
510 | } | 510 | } |
511 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
512 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
513 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
517 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
518 | 518 | ||
519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
521 | 521 | ||
522 | 522 | ||
523 | 523 | ||
524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
529 | 529 | ||
530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
531 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
532 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
533 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
535 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
537 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
538 | 538 | ||
539 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
540 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
541 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
542 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
545 | 545 | ||
546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
548 | #if 0 | 548 | #if 0 |
549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
550 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
551 | #endif | 551 | #endif |
552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
553 | 553 | ||
554 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
555 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
558 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
560 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
562 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
564 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
566 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
569 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
571 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
572 | 572 | ||
573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
576 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
577 | 577 | ||
578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
579 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
581 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
582 | 582 | ||
583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
584 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
585 | 585 | ||
586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
589 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
592 | 592 | ||
593 | 593 | ||
594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | 602 | ||
603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
604 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
606 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
608 | 608 | ||
609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
610 | 610 | ||
611 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
614 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
615 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
616 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
618 | 618 | ||
619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
620 | 620 | ||
621 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
622 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
623 | 623 | ||
624 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
625 | 625 | ||
626 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
627 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
628 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
632 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
634 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
636 | 636 | ||
637 | 637 | ||
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
642 | #endif | 642 | #endif |
643 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
648 | { | 648 | { |
649 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
650 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
651 | delete mDialogManager; | 651 | delete mDialogManager; |
652 | delete mViewManager; | 652 | delete mViewManager; |
653 | delete mStorage; | 653 | delete mStorage; |
654 | delete mDateFrame ; | 654 | delete mDateFrame ; |
655 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
656 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
657 | } | 657 | } |
658 | void CalendarView::nextConflict( bool all, bool allday ) | 658 | void CalendarView::nextConflict( bool all, bool allday ) |
659 | { | 659 | { |
660 | 660 | ||
661 | QPtrList<Event> testlist = mCalendar->events(); | 661 | QPtrList<Event> testlist = mCalendar->events(); |
662 | Event * test = testlist.first(); | 662 | Event * test = testlist.first(); |
663 | while ( test ) { | 663 | while ( test ) { |
664 | test->setTagged( false ); | 664 | test->setTagged( false ); |
665 | test = testlist.next(); | 665 | test = testlist.next(); |
666 | } | 666 | } |
667 | QTime st ( 0,0,0); | 667 | QTime st ( 0,0,0); |
668 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 668 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
669 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 669 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
670 | //qDebug("time %s ", st.toString().latin1()); | 670 | //qDebug("time %s ", st.toString().latin1()); |
671 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 671 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
672 | QDateTime conflict; | 672 | QDateTime conflict; |
673 | QDateTime retVal; | 673 | QDateTime retVal; |
674 | bool found = false; | 674 | bool found = false; |
675 | Event * cE = 0; | 675 | Event * cE = 0; |
676 | Event * cE2 = 0; | 676 | Event * cE2 = 0; |
677 | QPtrList<Event> testlist2 = testlist; | 677 | QPtrList<Event> testlist2 = testlist; |
678 | test = testlist.first(); | 678 | test = testlist.first(); |
679 | bool skip = false; | 679 | bool skip = false; |
680 | while ( test ) { | 680 | while ( test ) { |
681 | skip = false; | 681 | skip = false; |
682 | if ( !all ) skip = ( allday != test->doesFloat() ); | 682 | if ( !all ) skip = ( allday != test->doesFloat() ); |
683 | if ( !skip ) { | 683 | if ( !skip ) { |
684 | Event * test2 = testlist2.first(); | 684 | Event * test2 = testlist2.first(); |
685 | while ( test2 ) { | 685 | while ( test2 ) { |
686 | skip = false; | 686 | skip = false; |
687 | if ( !all ) skip = ( allday != test2->doesFloat() ); | 687 | if ( !all ) skip = ( allday != test2->doesFloat() ); |
688 | if ( !skip ) { | 688 | if ( !skip ) { |
689 | if ( !test2->isTagged() ) { | 689 | if ( !test2->isTagged() ) { |
690 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 690 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
691 | //qDebug("overlap "); | 691 | //qDebug("overlap "); |
692 | if ( ! found ) { | 692 | if ( ! found ) { |
693 | if ( retVal >= startDT ) { | 693 | if ( retVal >= startDT ) { |
694 | conflict = retVal; | 694 | conflict = retVal; |
695 | cE = test; | 695 | cE = test; |
696 | cE2 = test2; | 696 | cE2 = test2; |
697 | found = true; | 697 | found = true; |
698 | } | 698 | } |
699 | } else { | 699 | } else { |
700 | if ( retVal >= startDT && retVal < conflict ) { | 700 | if ( retVal >= startDT && retVal < conflict ) { |
701 | conflict = retVal; | 701 | conflict = retVal; |
702 | cE = test; | 702 | cE = test; |
703 | cE2 = test2; | 703 | cE2 = test2; |
704 | } | 704 | } |
705 | } | 705 | } |
706 | } | 706 | } |
707 | } | 707 | } |
708 | } | 708 | } |
709 | test2 = testlist2.next(); | 709 | test2 = testlist2.next(); |
710 | } | 710 | } |
711 | } | 711 | } |
712 | test->setTagged( true ); | 712 | test->setTagged( true ); |
713 | test = testlist.next(); | 713 | test = testlist.next(); |
714 | } | 714 | } |
715 | if ( found ) { | 715 | if ( found ) { |
716 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 716 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
717 | mViewManager->showDayView(); | 717 | mViewManager->showDayView(); |
718 | mNavigator->slotDaySelect( conflict.date() ); | 718 | mNavigator->slotDaySelect( conflict.date() ); |
719 | int hour = conflict.time().hour(); | 719 | int hour = conflict.time().hour(); |
720 | mViewManager->agendaView()->setStartHour( hour ); | 720 | mViewManager->agendaView()->setStartHour( hour ); |
721 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 721 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
722 | return; | 722 | return; |
723 | } | 723 | } |
724 | 724 | ||
725 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 725 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
726 | qDebug("No conflict found "); | 726 | qDebug("No conflict found "); |
727 | return; | 727 | return; |
728 | } | 728 | } |
729 | 729 | ||
730 | void CalendarView::conflictAll() | 730 | void CalendarView::conflictAll() |
731 | { | 731 | { |
732 | nextConflict ( true, true ); | 732 | nextConflict ( true, true ); |
733 | } | 733 | } |
734 | void CalendarView::conflictAllday() | 734 | void CalendarView::conflictAllday() |
735 | { | 735 | { |
736 | nextConflict ( false, true ); | 736 | nextConflict ( false, true ); |
737 | } | 737 | } |
738 | void CalendarView::conflictNotAll() | 738 | void CalendarView::conflictNotAll() |
739 | { | 739 | { |
740 | nextConflict ( false, false ); | 740 | nextConflict ( false, false ); |
741 | } | 741 | } |
742 | 742 | ||
743 | void CalendarView::setCalReadOnly( int id, bool readO ) | 743 | void CalendarView::setCalReadOnly( int id, bool readO ) |
744 | { | 744 | { |
745 | if ( readO ) { | 745 | if ( readO ) { |
746 | emit save(); | 746 | emit save(); |
747 | } | 747 | } |
748 | mCalendar->setReadOnly( id, readO ); | 748 | mCalendar->setReadOnly( id, readO ); |
749 | } | 749 | } |
750 | void CalendarView::setScrollBarStep(int val ) | 750 | void CalendarView::setScrollBarStep(int val ) |
751 | { | 751 | { |
752 | #ifdef DESKTOP_VERSION | 752 | #ifdef DESKTOP_VERSION |
753 | mDateScrollBar->setLineStep ( val ); | 753 | mDateScrollBar->setLineStep ( val ); |
754 | #endif | 754 | #endif |
755 | } | 755 | } |
756 | void CalendarView::scrollBarValue(int val ) | 756 | void CalendarView::scrollBarValue(int val ) |
757 | { | 757 | { |
758 | #ifdef DESKTOP_VERSION | 758 | #ifdef DESKTOP_VERSION |
759 | if ( QApplication::desktop()->width() < 800 ) return; | 759 | if ( QApplication::desktop()->width() < 800 ) return; |
760 | static bool block = false; | 760 | static bool block = false; |
761 | if ( block ) return; | 761 | if ( block ) return; |
762 | block = true; | 762 | block = true; |
763 | int count = mNavigator->selectedDates().count(); | 763 | int count = mNavigator->selectedDates().count(); |
764 | int day = mNavigator->selectedDates().first().dayOfYear(); | 764 | int day = mNavigator->selectedDates().first().dayOfYear(); |
765 | int stepdays = val; | 765 | int stepdays = val; |
766 | if ( mDateScrollBar->lineStep () <= count ) { | 766 | if ( mDateScrollBar->lineStep () <= count ) { |
767 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 767 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
768 | //qDebug("VAL %d ",val ); | 768 | //qDebug("VAL %d ",val ); |
769 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 769 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
770 | stepdays = day+stepdays; | 770 | stepdays = day+stepdays; |
771 | if ( stepdays < 0 ) stepdays = 0; | 771 | if ( stepdays < 0 ) stepdays = 0; |
772 | } | 772 | } |
773 | if ( stepdays == day ) { | 773 | if ( stepdays == day ) { |
774 | block = false; | 774 | block = false; |
775 | return; | 775 | return; |
776 | } | 776 | } |
777 | int year = mNavigator->selectedDates().first().year(); | 777 | int year = mNavigator->selectedDates().first().year(); |
778 | QDate d ( year,1,1 ); | 778 | QDate d ( year,1,1 ); |
779 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 779 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
780 | block = false; | 780 | block = false; |
781 | #endif | 781 | #endif |
782 | 782 | ||
783 | } | 783 | } |
784 | void CalendarView::updateView(const QDate &start, const QDate &end) | 784 | void CalendarView::updateView(const QDate &start, const QDate &end) |
785 | { | 785 | { |
786 | #ifdef DESKTOP_VERSION | 786 | #ifdef DESKTOP_VERSION |
787 | if ( ! mDateScrollBar->draggingSlider () ) { | 787 | if ( ! mDateScrollBar->draggingSlider () ) { |
788 | int dof = start.dayOfYear(); | 788 | int dof = start.dayOfYear(); |
789 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 789 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
790 | if ( dof != mDateScrollBar->value() ) { | 790 | if ( dof != mDateScrollBar->value() ) { |
791 | mDateScrollBar->blockSignals( true ); | 791 | mDateScrollBar->blockSignals( true ); |
792 | mDateScrollBar->setValue( start.dayOfYear()); | 792 | mDateScrollBar->setValue( start.dayOfYear()); |
793 | mDateScrollBar->blockSignals( false ); | 793 | mDateScrollBar->blockSignals( false ); |
794 | } | 794 | } |
795 | } | 795 | } |
796 | #endif | 796 | #endif |
797 | mTodoList->updateView(); | 797 | mTodoList->updateView(); |
798 | mViewManager->updateView(start, end); | 798 | mViewManager->updateView(start, end); |
799 | //mDateNavigator->updateView(); | 799 | //mDateNavigator->updateView(); |
800 | } | 800 | } |
801 | 801 | ||
802 | 802 | ||
803 | 803 | ||
804 | void CalendarView::checkFiles() | 804 | void CalendarView::checkFiles() |
805 | { | 805 | { |
806 | QString message; | 806 | QString message; |
807 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 807 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
808 | KopiCalendarFile * cal = calendars.first(); | 808 | KopiCalendarFile * cal = calendars.first(); |
809 | while ( cal ) { | 809 | while ( cal ) { |
810 | if ( cal->mErrorOnLoad ) { | 810 | if ( cal->mErrorOnLoad ) { |
811 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 811 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
812 | } | 812 | } |
813 | cal = calendars.next(); | 813 | cal = calendars.next(); |
814 | } | 814 | } |
815 | if ( !message.isEmpty() ) { | 815 | if ( !message.isEmpty() ) { |
816 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); | 816 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
817 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 817 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
818 | } | 818 | } |
819 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 819 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
820 | } | 820 | } |
821 | void CalendarView::checkAlarms() | 821 | void CalendarView::checkAlarms() |
822 | { | 822 | { |
823 | 823 | ||
824 | 824 | ||
825 | KConfig *config = KOGlobals::config(); | 825 | KConfig *config = KOGlobals::config(); |
826 | config->setGroup( "AppRun" ); | 826 | config->setGroup( "AppRun" ); |
827 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 827 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
828 | int daysto = dt.daysTo( QDate::currentDate() ); | 828 | int daysto = dt.daysTo( QDate::currentDate() ); |
829 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 829 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
830 | dt = dt.addDays( days ); | 830 | dt = dt.addDays( days ); |
831 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 831 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
832 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 832 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
833 | //qDebug("KO: Reading program stop %d ", secs); | 833 | //qDebug("KO: Reading program stop %d ", secs); |
834 | //secs -= ( 3600 * 24*3 ); // debug only | 834 | //secs -= ( 3600 * 24*3 ); // debug only |
835 | QDateTime latest = dt.addSecs ( secs ); | 835 | QDateTime latest = dt.addSecs ( secs ); |
836 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 836 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
837 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 837 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
838 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 838 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
839 | QPtrList<Incidence> al; | 839 | QPtrList<Incidence> al; |
840 | Incidence* inL = el.first(); | 840 | Incidence* inL = el.first(); |
841 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 841 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
842 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 842 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
843 | while ( inL ) { | 843 | while ( inL ) { |
844 | bool ok = false; | 844 | bool ok = false; |
845 | int offset = 0; | 845 | int offset = 0; |
846 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 846 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
847 | if ( ok ) { | 847 | if ( ok ) { |
848 | //qDebug("OK %s",next.toString().latin1()); | 848 | //qDebug("OK %s",next.toString().latin1()); |
849 | if ( next < cur ) { | 849 | if ( next < cur ) { |
850 | al.append( inL ); | 850 | al.append( inL ); |
851 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 851 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
852 | } | 852 | } |
853 | } | 853 | } |
854 | inL = el.next(); | 854 | inL = el.next(); |
855 | } | 855 | } |
856 | if ( al.count() ) { | 856 | if ( al.count() ) { |
857 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 857 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
858 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 858 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
859 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 859 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
860 | lay->setSpacing( 0 ); | 860 | lay->setSpacing( 0 ); |
861 | lay->setMargin( 0 ); | 861 | lay->setMargin( 0 ); |
862 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 862 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
863 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 863 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
864 | lay->addWidget( matb ); | 864 | lay->addWidget( matb ); |
865 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 865 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
866 | int wid = 210; | 866 | int wid = 210; |
867 | int x = QApplication::desktop()->width() - wid - 7; | 867 | int x = QApplication::desktop()->width() - wid - 7; |
868 | int y = QApplication::desktop()->height() - wid - 70; | 868 | int y = QApplication::desktop()->height() - wid - 70; |
869 | dia->setGeometry ( x,y,wid,wid); | 869 | dia->setGeometry ( x,y,wid,wid); |
870 | } else { | 870 | } else { |
871 | int si = 220; | 871 | int si = 220; |
872 | if ( QApplication::desktop()->width() > 470 ) | 872 | if ( QApplication::desktop()->width() > 470 ) |
873 | si = 400; | 873 | si = 400; |
874 | dia->resize(si,si/2); | 874 | dia->resize(si,si/2); |
875 | } | 875 | } |
876 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 876 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
877 | dia->show(); | 877 | dia->show(); |
878 | 878 | ||
879 | } | 879 | } |
880 | } | 880 | } |
881 | void CalendarView::showDay( QDate d ) | 881 | void CalendarView::showDay( QDate d ) |
882 | { | 882 | { |
883 | dateNavigator()->blockSignals( true ); | 883 | dateNavigator()->blockSignals( true ); |
884 | dateNavigator()->selectDate( d ); | 884 | dateNavigator()->selectDate( d ); |
885 | dateNavigator()->blockSignals( false ); | 885 | dateNavigator()->blockSignals( false ); |
886 | mViewManager->showDayView(); | 886 | mViewManager->showDayView(); |
887 | //dateNavigator()->selectDate( d ); | 887 | //dateNavigator()->selectDate( d ); |
888 | } | 888 | } |
889 | void CalendarView::timerAlarm() | 889 | void CalendarView::timerAlarm() |
890 | { | 890 | { |
891 | //qDebug("CalendarView::timerAlarm() "); | 891 | //qDebug("CalendarView::timerAlarm() "); |
892 | computeAlarm(mAlarmNotification ); | 892 | computeAlarm(mAlarmNotification ); |
893 | } | 893 | } |
894 | 894 | ||
895 | void CalendarView::suspendAlarm() | 895 | void CalendarView::suspendAlarm() |
896 | { | 896 | { |
897 | //qDebug(" CalendarView::suspendAlarm() "); | 897 | //qDebug(" CalendarView::suspendAlarm() "); |
898 | computeAlarm(mSuspendAlarmNotification ); | 898 | computeAlarm(mSuspendAlarmNotification ); |
899 | 899 | ||
900 | } | 900 | } |
901 | 901 | ||
902 | void CalendarView::startAlarm( QString mess , QString filename) | 902 | void CalendarView::startAlarm( QString mess , QString filename) |
903 | { | 903 | { |
904 | 904 | ||
905 | topLevelWidget()->showNormal(); | 905 | topLevelWidget()->showNormal(); |
906 | topLevelWidget()->setActiveWindow(); | 906 | topLevelWidget()->setActiveWindow(); |
907 | topLevelWidget()->raise(); | 907 | topLevelWidget()->raise(); |
908 | 908 | ||
909 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 909 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
910 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 910 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
911 | 911 | ||
912 | } | 912 | } |
913 | 913 | ||
914 | void CalendarView::checkNextTimerAlarm() | 914 | void CalendarView::checkNextTimerAlarm() |
915 | { | 915 | { |
916 | mCalendar->checkAlarmForIncidence( 0, true ); | 916 | mCalendar->checkAlarmForIncidence( 0, true ); |
917 | } | 917 | } |
918 | 918 | ||
919 | void CalendarView::computeAlarm( QString msg ) | 919 | void CalendarView::computeAlarm( QString msg ) |
920 | { | 920 | { |
921 | 921 | ||
922 | QString mess = msg; | 922 | QString mess = msg; |
923 | QString mAlarmMessage = mess.mid( 9 ); | 923 | QString mAlarmMessage = mess.mid( 9 ); |
924 | QString filename = MainWindow::resourcePath(); | 924 | QString filename = MainWindow::resourcePath(); |
925 | filename += "koalarm.wav"; | 925 | filename += "koalarm.wav"; |
926 | QString tempfilename; | 926 | QString tempfilename; |
927 | if ( mess.left( 13 ) == "suspend_alarm") { | 927 | if ( mess.left( 13 ) == "suspend_alarm") { |
928 | bool error = false; | 928 | bool error = false; |
929 | int len = mess.mid( 13 ).find("+++"); | 929 | int len = mess.mid( 13 ).find("+++"); |
930 | if ( len < 2 ) | 930 | if ( len < 2 ) |
931 | error = true; | 931 | error = true; |
932 | else { | 932 | else { |
933 | tempfilename = mess.mid( 13, len ); | 933 | tempfilename = mess.mid( 13, len ); |
934 | if ( !QFile::exists( tempfilename ) ) | 934 | if ( !QFile::exists( tempfilename ) ) |
935 | error = true; | 935 | error = true; |
936 | } | 936 | } |
937 | if ( ! error ) { | 937 | if ( ! error ) { |
938 | filename = tempfilename; | 938 | filename = tempfilename; |
939 | } | 939 | } |
940 | mAlarmMessage = mess.mid( 13+len+3 ); | 940 | mAlarmMessage = mess.mid( 13+len+3 ); |
941 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 941 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
942 | startAlarm( mAlarmMessage, filename); | 942 | startAlarm( mAlarmMessage, filename); |
943 | return; | 943 | return; |
944 | } | 944 | } |
945 | if ( mess.left( 11 ) == "timer_alarm") { | 945 | if ( mess.left( 11 ) == "timer_alarm") { |
946 | //mTimerTime = 0; | 946 | //mTimerTime = 0; |
947 | startAlarm( mess.mid( 11 ), filename ); | 947 | startAlarm( mess.mid( 11 ), filename ); |
948 | return; | 948 | return; |
949 | } | 949 | } |
950 | if ( mess.left( 10 ) == "proc_alarm") { | 950 | if ( mess.left( 10 ) == "proc_alarm") { |
951 | bool error = false; | 951 | bool error = false; |
952 | int len = mess.mid( 10 ).find("+++"); | 952 | int len = mess.mid( 10 ).find("+++"); |
953 | if ( len < 2 ) | 953 | if ( len < 2 ) |
954 | error = true; | 954 | error = true; |
955 | else { | 955 | else { |
956 | tempfilename = mess.mid( 10, len ); | 956 | tempfilename = mess.mid( 10, len ); |
957 | if ( !QFile::exists( tempfilename ) ) | 957 | if ( !QFile::exists( tempfilename ) ) |
958 | error = true; | 958 | error = true; |
959 | } | 959 | } |
960 | if ( error ) { | 960 | if ( error ) { |
961 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 961 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
962 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 962 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
963 | } else { | 963 | } else { |
964 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 964 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
965 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 965 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
966 | #ifndef _WIN32_ | 966 | #ifndef _WIN32_ |
967 | if ( vfork () == 0 ) { | 967 | if ( vfork () == 0 ) { |
968 | execl ( tempfilename.latin1(), 0 ); | 968 | execl ( tempfilename.latin1(), 0 ); |
969 | return; | 969 | return; |
970 | } | 970 | } |
971 | #else | 971 | #else |
972 | QProcess* p = new QProcess(); | 972 | QProcess* p = new QProcess(); |
973 | p->addArgument( tempfilename.latin1() ); | 973 | p->addArgument( tempfilename.latin1() ); |
974 | p->start(); | 974 | p->start(); |
975 | return; | 975 | return; |
976 | #endif | 976 | #endif |
977 | 977 | ||
978 | return; | 978 | return; |
979 | } | 979 | } |
980 | 980 | ||
981 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 981 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
982 | } | 982 | } |
983 | if ( mess.left( 11 ) == "audio_alarm") { | 983 | if ( mess.left( 11 ) == "audio_alarm") { |
984 | bool error = false; | 984 | bool error = false; |
985 | int len = mess.mid( 11 ).find("+++"); | 985 | int len = mess.mid( 11 ).find("+++"); |
986 | if ( len < 2 ) | 986 | if ( len < 2 ) |
987 | error = true; | 987 | error = true; |
988 | else { | 988 | else { |
989 | tempfilename = mess.mid( 11, len ); | 989 | tempfilename = mess.mid( 11, len ); |
990 | if ( !QFile::exists( tempfilename ) ) | 990 | if ( !QFile::exists( tempfilename ) ) |
991 | error = true; | 991 | error = true; |
992 | } | 992 | } |
993 | if ( ! error ) { | 993 | if ( ! error ) { |
994 | filename = tempfilename; | 994 | filename = tempfilename; |
995 | } | 995 | } |
996 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 996 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
997 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 997 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
998 | } | 998 | } |
999 | if ( mess.left( 9 ) == "cal_alarm") { | 999 | if ( mess.left( 9 ) == "cal_alarm") { |
1000 | mAlarmMessage = mess.mid( 9 ) ; | 1000 | mAlarmMessage = mess.mid( 9 ) ; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | startAlarm( mAlarmMessage, filename ); | 1003 | startAlarm( mAlarmMessage, filename ); |
1004 | 1004 | ||
1005 | 1005 | ||
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1008 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1009 | { | 1009 | { |
1010 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1010 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1011 | 1011 | ||
1012 | mSuspendAlarmNotification = noti; | 1012 | mSuspendAlarmNotification = noti; |
1013 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1013 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1014 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1014 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1015 | mSuspendTimer->start( ms , true ); | 1015 | mSuspendTimer->start( ms , true ); |
1016 | 1016 | ||
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1019 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1020 | { | 1020 | { |
1021 | mNextAlarmDateTime = qdt; | 1021 | mNextAlarmDateTime = qdt; |
1022 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1022 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1023 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1023 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1024 | #ifndef DESKTOP_VERSION | 1024 | #ifndef DESKTOP_VERSION |
1025 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1025 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1026 | #endif | 1026 | #endif |
1027 | return; | 1027 | return; |
1028 | } | 1028 | } |
1029 | int maxSec; | 1029 | int maxSec; |
1030 | //maxSec = 5; //testing only | 1030 | //maxSec = 5; //testing only |
1031 | maxSec = 86400+3600; // one day+1hour | 1031 | maxSec = 86400+3600; // one day+1hour |
1032 | mAlarmNotification = noti; | 1032 | mAlarmNotification = noti; |
1033 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1033 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1034 | if ( sec > maxSec ) { | 1034 | if ( sec > maxSec ) { |
1035 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1035 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1036 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1036 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1037 | return; | 1037 | return; |
1038 | } else { | 1038 | } else { |
1039 | mRecheckAlarmTimer->stop(); | 1039 | mRecheckAlarmTimer->stop(); |
1040 | } | 1040 | } |
1041 | //qDebug("Alarm timer started with secs: %d ", sec); | 1041 | //qDebug("Alarm timer started with secs: %d ", sec); |
1042 | mAlarmTimer->start( sec *1000 , true ); | 1042 | mAlarmTimer->start( sec *1000 , true ); |
1043 | 1043 | ||
1044 | } | 1044 | } |
1045 | // called by mRecheckAlarmTimer to get next alarm | 1045 | // called by mRecheckAlarmTimer to get next alarm |
1046 | // we need this, because a QTimer has only a max range of 25 days | 1046 | // we need this, because a QTimer has only a max range of 25 days |
1047 | void CalendarView::recheckTimerAlarm() | 1047 | void CalendarView::recheckTimerAlarm() |
1048 | { | 1048 | { |
1049 | mAlarmTimer->stop(); | 1049 | mAlarmTimer->stop(); |
1050 | mRecheckAlarmTimer->stop(); | 1050 | mRecheckAlarmTimer->stop(); |
1051 | mCalendar->checkAlarmForIncidence( 0, true ); | 1051 | mCalendar->checkAlarmForIncidence( 0, true ); |
1052 | } | 1052 | } |
1053 | #ifndef DESKTOP_VERSION | 1053 | #ifndef DESKTOP_VERSION |
1054 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1054 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1055 | #else | 1055 | #else |
1056 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1056 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1057 | #endif | 1057 | #endif |
1058 | { | 1058 | { |
1059 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1059 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1060 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1060 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1061 | #ifndef DESKTOP_VERSION | 1061 | #ifndef DESKTOP_VERSION |
1062 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1062 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1063 | #endif | 1063 | #endif |
1064 | return; | 1064 | return; |
1065 | } | 1065 | } |
1066 | mAlarmTimer->stop(); | 1066 | mAlarmTimer->stop(); |
1067 | } | 1067 | } |
1068 | void CalendarView::selectWeekNum ( int num ) | 1068 | void CalendarView::selectWeekNum ( int num ) |
1069 | { | 1069 | { |
1070 | dateNavigator()->blockSignals( true ); | 1070 | dateNavigator()->blockSignals( true ); |
1071 | dateNavigator()->selectWeek( num ); | 1071 | dateNavigator()->selectWeek( num ); |
1072 | dateNavigator()->blockSignals( false ); | 1072 | dateNavigator()->blockSignals( false ); |
1073 | mViewManager->showWeekView(); | 1073 | mViewManager->showWeekView(); |
1074 | } | 1074 | } |
1075 | KOViewManager *CalendarView::viewManager() | 1075 | KOViewManager *CalendarView::viewManager() |
1076 | { | 1076 | { |
1077 | return mViewManager; | 1077 | return mViewManager; |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | KODialogManager *CalendarView::dialogManager() | 1080 | KODialogManager *CalendarView::dialogManager() |
1081 | { | 1081 | { |
1082 | return mDialogManager; | 1082 | return mDialogManager; |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | QDate CalendarView::startDate() | 1085 | QDate CalendarView::startDate() |
1086 | { | 1086 | { |
1087 | DateList dates = mNavigator->selectedDates(); | 1087 | DateList dates = mNavigator->selectedDates(); |
1088 | 1088 | ||
1089 | return dates.first(); | 1089 | return dates.first(); |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | QDate CalendarView::endDate() | 1092 | QDate CalendarView::endDate() |
1093 | { | 1093 | { |
1094 | DateList dates = mNavigator->selectedDates(); | 1094 | DateList dates = mNavigator->selectedDates(); |
1095 | 1095 | ||
1096 | return dates.last(); | 1096 | return dates.last(); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | 1099 | ||
1100 | void CalendarView::createPrinter() | 1100 | void CalendarView::createPrinter() |
1101 | { | 1101 | { |
1102 | #ifndef KORG_NOPRINTER | 1102 | #ifndef KORG_NOPRINTER |
1103 | if (!mCalPrinter) { | 1103 | if (!mCalPrinter) { |
1104 | mCalPrinter = new CalPrinter(this, mCalendar); | 1104 | mCalPrinter = new CalPrinter(this, mCalendar); |
1105 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1105 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1106 | } | 1106 | } |
1107 | #endif | 1107 | #endif |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | 1110 | ||
1111 | //KOPrefs::instance()->mWriteBackFile | 1111 | //KOPrefs::instance()->mWriteBackFile |
1112 | //KOPrefs::instance()->mWriteBackExistingOnly | 1112 | //KOPrefs::instance()->mWriteBackExistingOnly |
1113 | 1113 | ||
1114 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1114 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1115 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1115 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1116 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1116 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1117 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1117 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1118 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1118 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1119 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1119 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1120 | 1120 | ||
1121 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1121 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1122 | { | 1122 | { |
1123 | 1123 | ||
1124 | // 0 equal | 1124 | // 0 equal |
1125 | // 1 take local | 1125 | // 1 take local |
1126 | // 2 take remote | 1126 | // 2 take remote |
1127 | // 3 cancel | 1127 | // 3 cancel |
1128 | QDateTime lastSync = mLastCalendarSync; | 1128 | QDateTime lastSync = mLastCalendarSync; |
1129 | QDateTime localMod = local->lastModified(); | 1129 | QDateTime localMod = local->lastModified(); |
1130 | QDateTime remoteMod = remote->lastModified(); | 1130 | QDateTime remoteMod = remote->lastModified(); |
1131 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1131 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1132 | bool remCh, locCh; | 1132 | bool remCh, locCh; |
1133 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1133 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1134 | //if ( remCh ) | 1134 | //if ( remCh ) |
1135 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1135 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1136 | locCh = ( localMod > mLastCalendarSync ); | 1136 | locCh = ( localMod > mLastCalendarSync ); |
1137 | if ( !remCh && ! locCh ) { | 1137 | if ( !remCh && ! locCh ) { |
1138 | //qDebug("both not changed "); | 1138 | //qDebug("both not changed "); |
1139 | lastSync = localMod.addDays(1); | 1139 | lastSync = localMod.addDays(1); |
1140 | if ( mode <= SYNC_PREF_ASK ) | 1140 | if ( mode <= SYNC_PREF_ASK ) |
1141 | return 0; | 1141 | return 0; |
1142 | } else { | 1142 | } else { |
1143 | if ( locCh ) { | 1143 | if ( locCh ) { |
1144 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1144 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1145 | lastSync = localMod.addDays( -1 ); | 1145 | lastSync = localMod.addDays( -1 ); |
1146 | if ( !remCh ) | 1146 | if ( !remCh ) |
1147 | remoteMod = ( lastSync.addDays( -1 ) ); | 1147 | remoteMod = ( lastSync.addDays( -1 ) ); |
1148 | } else { | 1148 | } else { |
1149 | //qDebug(" not loc changed "); | 1149 | //qDebug(" not loc changed "); |
1150 | lastSync = localMod.addDays( 1 ); | 1150 | lastSync = localMod.addDays( 1 ); |
1151 | if ( remCh ) | 1151 | if ( remCh ) |
1152 | remoteMod =( lastSync.addDays( 1 ) ); | 1152 | remoteMod =( lastSync.addDays( 1 ) ); |
1153 | 1153 | ||
1154 | } | 1154 | } |
1155 | } | 1155 | } |
1156 | full = true; | 1156 | full = true; |
1157 | if ( mode < SYNC_PREF_ASK ) | 1157 | if ( mode < SYNC_PREF_ASK ) |
1158 | mode = SYNC_PREF_ASK; | 1158 | mode = SYNC_PREF_ASK; |
1159 | } else { | 1159 | } else { |
1160 | if ( localMod == remoteMod ) | 1160 | if ( localMod == remoteMod ) |
1161 | // if ( local->revision() == remote->revision() ) | 1161 | // if ( local->revision() == remote->revision() ) |
1162 | return 0; | 1162 | return 0; |
1163 | 1163 | ||
1164 | } | 1164 | } |
1165 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1165 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1166 | 1166 | ||
1167 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1167 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1168 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1168 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1169 | //full = true; //debug only | 1169 | //full = true; //debug only |
1170 | if ( full ) { | 1170 | if ( full ) { |
1171 | bool equ = false; | 1171 | bool equ = false; |
1172 | if ( local->typeID() == eventID ) { | 1172 | if ( local->typeID() == eventID ) { |
1173 | equ = (*((Event*) local) == *((Event*) remote)); | 1173 | equ = (*((Event*) local) == *((Event*) remote)); |
1174 | } | 1174 | } |
1175 | else if ( local->typeID() == todoID ) | 1175 | else if ( local->typeID() == todoID ) |
1176 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1176 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1177 | else if ( local->typeID() == journalID ) | 1177 | else if ( local->typeID() == journalID ) |
1178 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1178 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1179 | if ( equ ) { | 1179 | if ( equ ) { |
1180 | //qDebug("equal "); | 1180 | //qDebug("equal "); |
1181 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1181 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1182 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1182 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1183 | } | 1183 | } |
1184 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1184 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1185 | return 0; | 1185 | return 0; |
1186 | 1186 | ||
1187 | }//else //debug only | 1187 | }//else //debug only |
1188 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1188 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1189 | } | 1189 | } |
1190 | int result; | 1190 | int result; |
1191 | bool localIsNew; | 1191 | bool localIsNew; |
1192 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 1192 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
1193 | 1193 | ||
1194 | 1194 | ||
1195 | // ************************************************ | 1195 | // ************************************************ |
1196 | // ************************************************ | 1196 | // ************************************************ |
1197 | // ************************************************ | 1197 | // ************************************************ |
1198 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1198 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1199 | // BUT remoteMod != localMod | 1199 | // BUT remoteMod != localMod |
1200 | 1200 | ||
1201 | 1201 | ||
1202 | if ( full && mode < SYNC_PREF_NEWEST ) | 1202 | if ( full && mode < SYNC_PREF_NEWEST ) |
1203 | mode = SYNC_PREF_ASK; | 1203 | mode = SYNC_PREF_ASK; |
1204 | 1204 | ||
1205 | switch( mode ) { | 1205 | switch( mode ) { |
1206 | case SYNC_PREF_LOCAL: | 1206 | case SYNC_PREF_LOCAL: |
1207 | if ( lastSync > remoteMod ) | 1207 | if ( lastSync > remoteMod ) |
1208 | return 1; | 1208 | return 1; |
1209 | if ( lastSync > localMod ) | 1209 | if ( lastSync > localMod ) |
1210 | return 2; | 1210 | return 2; |
1211 | return 1; | 1211 | return 1; |
1212 | break; | 1212 | break; |
1213 | case SYNC_PREF_REMOTE: | 1213 | case SYNC_PREF_REMOTE: |
1214 | if ( lastSync > localMod ) | 1214 | if ( lastSync > localMod ) |
1215 | return 2; | 1215 | return 2; |
1216 | if ( lastSync > remoteMod ) | 1216 | if ( lastSync > remoteMod ) |
1217 | return 1; | 1217 | return 1; |
1218 | return 2; | 1218 | return 2; |
1219 | break; | 1219 | break; |
1220 | case SYNC_PREF_NEWEST: | 1220 | case SYNC_PREF_NEWEST: |
1221 | if ( localMod >= remoteMod ) | 1221 | if ( localMod >= remoteMod ) |
1222 | return 1; | 1222 | return 1; |
1223 | else | 1223 | else |
1224 | return 2; | 1224 | return 2; |
1225 | break; | 1225 | break; |
1226 | case SYNC_PREF_ASK: | 1226 | case SYNC_PREF_ASK: |
1227 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1227 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1228 | if ( lastSync > remoteMod && lastSync > localMod) | 1228 | if ( lastSync > remoteMod && lastSync > localMod) |
1229 | return 0; | 1229 | return 0; |
1230 | if ( lastSync > remoteMod ) | 1230 | if ( lastSync > remoteMod ) |
1231 | return 1; | 1231 | return 1; |
1232 | if ( lastSync > localMod ) | 1232 | if ( lastSync > localMod ) |
1233 | return 2; | 1233 | return 2; |
1234 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1234 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1235 | localIsNew = localMod >= remoteMod; | 1235 | localIsNew = localMod >= remoteMod; |
1236 | if ( localIsNew ) | 1236 | if ( localIsNew ) |
1237 | getEventViewerDialog()->setColorMode( 1 ); | 1237 | getEventViewerDialog()->setColorMode( 1 ); |
1238 | else | 1238 | else |
1239 | getEventViewerDialog()->setColorMode( 2 ); | 1239 | getEventViewerDialog()->setColorMode( 2 ); |
1240 | getEventViewerDialog()->setIncidence(local); | 1240 | getEventViewerDialog()->setIncidence(local); |
1241 | if ( localIsNew ) | 1241 | if ( localIsNew ) |
1242 | getEventViewerDialog()->setColorMode( 2 ); | 1242 | getEventViewerDialog()->setColorMode( 2 ); |
1243 | else | 1243 | else |
1244 | getEventViewerDialog()->setColorMode( 1 ); | 1244 | getEventViewerDialog()->setColorMode( 1 ); |
1245 | getEventViewerDialog()->addIncidence(remote); | 1245 | getEventViewerDialog()->addIncidence(remote); |
1246 | getEventViewerDialog()->setColorMode( 0 ); | 1246 | getEventViewerDialog()->setColorMode( 0 ); |
1247 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1247 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1248 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1248 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1249 | getEventViewerDialog()->showMe(); | 1249 | getEventViewerDialog()->showMe(); |
1250 | result = getEventViewerDialog()->executeS( localIsNew ); | 1250 | result = getEventViewerDialog()->executeS( localIsNew ); |
1251 | return result; | 1251 | return result; |
1252 | 1252 | ||
1253 | break; | 1253 | break; |
1254 | case SYNC_PREF_FORCE_LOCAL: | 1254 | case SYNC_PREF_FORCE_LOCAL: |
1255 | return 1; | 1255 | return 1; |
1256 | break; | 1256 | break; |
1257 | case SYNC_PREF_FORCE_REMOTE: | 1257 | case SYNC_PREF_FORCE_REMOTE: |
1258 | return 2; | 1258 | return 2; |
1259 | break; | 1259 | break; |
1260 | 1260 | ||
1261 | default: | 1261 | default: |
1262 | // SYNC_PREF_TAKE_BOTH not implemented | 1262 | // SYNC_PREF_TAKE_BOTH not implemented |
1263 | break; | 1263 | break; |
1264 | } | 1264 | } |
1265 | return 0; | 1265 | return 0; |
1266 | } | 1266 | } |
1267 | Event* CalendarView::getLastSyncEvent() | 1267 | Event* CalendarView::getLastSyncEvent() |
1268 | { | 1268 | { |
1269 | Event* lse; | 1269 | Event* lse; |
1270 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1270 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1271 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1271 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1272 | if (!lse) { | 1272 | if (!lse) { |
1273 | lse = new Event(); | 1273 | lse = new Event(); |
1274 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1274 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1275 | QString sum = ""; | 1275 | QString sum = ""; |
1276 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1276 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1277 | sum = "E: "; | 1277 | sum = "E: "; |
1278 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1278 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1279 | lse->setDtStart( mLastCalendarSync ); | 1279 | lse->setDtStart( mLastCalendarSync ); |
1280 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1280 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1281 | lse->setCategories( i18n("SyncEvent") ); | 1281 | lse->setCategories( i18n("SyncEvent") ); |
1282 | lse->setReadOnly( true ); | 1282 | lse->setReadOnly( true ); |
1283 | mCalendar->addEvent( lse ); | 1283 | mCalendar->addEvent( lse ); |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | return lse; | 1286 | return lse; |
1287 | 1287 | ||
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | // we check, if the to delete event has a id for a profile | 1290 | // we check, if the to delete event has a id for a profile |
1291 | // if yes, we set this id in the profile to delete | 1291 | // if yes, we set this id in the profile to delete |
1292 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1292 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1293 | { | 1293 | { |
1294 | if ( lastSync.count() == 0 ) { | 1294 | if ( lastSync.count() == 0 ) { |
1295 | //qDebug(" lastSync.count() == 0"); | 1295 | //qDebug(" lastSync.count() == 0"); |
1296 | return; | 1296 | return; |
1297 | } | 1297 | } |
1298 | if ( toDelete->typeID() == journalID ) | 1298 | if ( toDelete->typeID() == journalID ) |
1299 | return; | 1299 | return; |
1300 | 1300 | ||
1301 | Event* eve = lastSync.first(); | 1301 | Event* eve = lastSync.first(); |
1302 | 1302 | ||
1303 | while ( eve ) { | 1303 | while ( eve ) { |
1304 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1304 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1305 | if ( !id.isEmpty() ) { | 1305 | if ( !id.isEmpty() ) { |
1306 | QString des = eve->description(); | 1306 | QString des = eve->description(); |
1307 | QString pref = "e"; | 1307 | QString pref = "e"; |
1308 | if ( toDelete->typeID() == todoID ) | 1308 | if ( toDelete->typeID() == todoID ) |
1309 | pref = "t"; | 1309 | pref = "t"; |
1310 | des += pref+ id + ","; | 1310 | des += pref+ id + ","; |
1311 | eve->setReadOnly( false ); | 1311 | eve->setReadOnly( false ); |
1312 | eve->setDescription( des ); | 1312 | eve->setDescription( des ); |
1313 | //qDebug("setdes %s ", des.latin1()); | 1313 | //qDebug("setdes %s ", des.latin1()); |
1314 | eve->setReadOnly( true ); | 1314 | eve->setReadOnly( true ); |
1315 | } | 1315 | } |
1316 | eve = lastSync.next(); | 1316 | eve = lastSync.next(); |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | } | 1319 | } |
1320 | void CalendarView::checkExternalId( Incidence * inc ) | 1320 | void CalendarView::checkExternalId( Incidence * inc ) |
1321 | { | 1321 | { |
1322 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1322 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1323 | checkExternSyncEvent( lastSync, inc ); | 1323 | checkExternSyncEvent( lastSync, inc ); |
1324 | 1324 | ||
1325 | } | 1325 | } |
1326 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1326 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1327 | { | 1327 | { |
1328 | bool syncOK = true; | 1328 | bool syncOK = true; |
1329 | int addedEvent = 0; | 1329 | int addedEvent = 0; |
1330 | int addedEventR = 0; | 1330 | int addedEventR = 0; |
1331 | int deletedEventR = 0; | 1331 | int deletedEventR = 0; |
1332 | int deletedEventL = 0; | 1332 | int deletedEventL = 0; |
1333 | int changedLocal = 0; | 1333 | int changedLocal = 0; |
1334 | int changedRemote = 0; | 1334 | int changedRemote = 0; |
1335 | int filteredIN = 0; | 1335 | int filteredIN = 0; |
1336 | int filteredOUT = 0; | 1336 | int filteredOUT = 0; |
1337 | //QPtrList<Event> el = local->rawEvents(); | 1337 | //QPtrList<Event> el = local->rawEvents(); |
1338 | Event* eventR; | 1338 | Event* eventR; |
1339 | QString uid; | 1339 | QString uid; |
1340 | int take; | 1340 | int take; |
1341 | Event* eventRSync; | 1341 | Event* eventRSync; |
1342 | Event* eventLSync; | 1342 | Event* eventLSync; |
1343 | clearAllViews(); | 1343 | clearAllViews(); |
1344 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1344 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1345 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1345 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1346 | bool fullDateRange = false; | 1346 | bool fullDateRange = false; |
1347 | local->resetTempSyncStat(); | 1347 | local->resetTempSyncStat(); |
1348 | mLastCalendarSync = QDateTime::currentDateTime(); | 1348 | mLastCalendarSync = QDateTime::currentDateTime(); |
1349 | if ( mSyncManager->syncWithDesktop() ) { | 1349 | if ( mSyncManager->syncWithDesktop() ) { |
1350 | remote->resetPilotStat(1); | 1350 | remote->resetPilotStat(1); |
1351 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1351 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1352 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1352 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1353 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1353 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1354 | } else { | 1354 | } else { |
1355 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1355 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1356 | } | 1356 | } |
1357 | } | 1357 | } |
1358 | QDateTime modifiedCalendar = mLastCalendarSync; | 1358 | QDateTime modifiedCalendar = mLastCalendarSync; |
1359 | eventLSync = getLastSyncEvent(); | 1359 | eventLSync = getLastSyncEvent(); |
1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1361 | if ( eventR ) { | 1361 | if ( eventR ) { |
1362 | eventRSync = (Event*) eventR->clone(); | 1362 | eventRSync = (Event*) eventR->clone(); |
1363 | remote->deleteEvent(eventR ); | 1363 | remote->deleteEvent(eventR ); |
1364 | 1364 | ||
1365 | } else { | 1365 | } else { |
1366 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1366 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1367 | eventRSync = (Event*)eventLSync->clone(); | 1367 | eventRSync = (Event*)eventLSync->clone(); |
1368 | } else { | 1368 | } else { |
1369 | fullDateRange = true; | 1369 | fullDateRange = true; |
1370 | eventRSync = new Event(); | 1370 | eventRSync = new Event(); |
1371 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1371 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1372 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1372 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1373 | eventRSync->setDtStart( mLastCalendarSync ); | 1373 | eventRSync->setDtStart( mLastCalendarSync ); |
1374 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1374 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1375 | eventRSync->setCategories( i18n("SyncEvent") ); | 1375 | eventRSync->setCategories( i18n("SyncEvent") ); |
1376 | } | 1376 | } |
1377 | } | 1377 | } |
1378 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1378 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1379 | fullDateRange = true; | 1379 | fullDateRange = true; |
1380 | 1380 | ||
1381 | if ( ! fullDateRange ) { | 1381 | if ( ! fullDateRange ) { |
1382 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1382 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1383 | 1383 | ||
1384 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1384 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1385 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1385 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1386 | fullDateRange = true; | 1386 | fullDateRange = true; |
1387 | } | 1387 | } |
1388 | } | 1388 | } |
1389 | if ( mSyncManager->syncWithDesktop() ) { | 1389 | if ( mSyncManager->syncWithDesktop() ) { |
1390 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1390 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1391 | } | 1391 | } |
1392 | if ( fullDateRange ) | 1392 | if ( fullDateRange ) |
1393 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1393 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1394 | else | 1394 | else |
1395 | mLastCalendarSync = eventLSync->dtStart(); | 1395 | mLastCalendarSync = eventLSync->dtStart(); |
1396 | // for resyncing if own file has changed | 1396 | // for resyncing if own file has changed |
1397 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1397 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1398 | mLastCalendarSync = loadedFileVersion; | 1398 | mLastCalendarSync = loadedFileVersion; |
1399 | //qDebug("setting mLastCalendarSync "); | 1399 | //qDebug("setting mLastCalendarSync "); |
1400 | } | 1400 | } |
1401 | //qDebug("*************************** "); | 1401 | //qDebug("*************************** "); |
1402 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1402 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1403 | QPtrList<Incidence> er = remote->rawIncidences(); | 1403 | QPtrList<Incidence> er = remote->rawIncidences(); |
1404 | Incidence* inR = er.first(); | 1404 | Incidence* inR = er.first(); |
1405 | Incidence* inL; | 1405 | Incidence* inL; |
1406 | QProgressBar bar( er.count(),0 ); | 1406 | QProgressBar bar( er.count(),0 ); |
1407 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1407 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1408 | 1408 | ||
1409 | // ************** setting up filter ************* | 1409 | // ************** setting up filter ************* |
1410 | CalFilter *filterIN = 0; | 1410 | CalFilter *filterIN = 0; |
1411 | CalFilter *filterOUT = 0; | 1411 | CalFilter *filterOUT = 0; |
1412 | CalFilter *filter = mFilters.first(); | 1412 | CalFilter *filter = mFilters.first(); |
1413 | while(filter) { | 1413 | while(filter) { |
1414 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1414 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1415 | filterIN = filter; | 1415 | filterIN = filter; |
1416 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1416 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1417 | filterOUT = filter; | 1417 | filterOUT = filter; |
1418 | filter = mFilters.next(); | 1418 | filter = mFilters.next(); |
1419 | } | 1419 | } |
1420 | int w = 300; | 1420 | int w = 300; |
1421 | if ( QApplication::desktop()->width() < 320 ) | 1421 | if ( QApplication::desktop()->width() < 320 ) |
1422 | w = 220; | 1422 | w = 220; |
1423 | int h = bar.sizeHint().height() ; | 1423 | int h = bar.sizeHint().height() ; |
1424 | int dw = QApplication::desktop()->width(); | 1424 | int dw = QApplication::desktop()->width(); |
1425 | int dh = QApplication::desktop()->height(); | 1425 | int dh = QApplication::desktop()->height(); |
1426 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1426 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1427 | bar.show(); | 1427 | bar.show(); |
1428 | int modulo = (er.count()/10)+1; | 1428 | int modulo = (er.count()/10)+1; |
1429 | int incCounter = 0; | 1429 | int incCounter = 0; |
1430 | while ( inR ) { | 1430 | while ( inR ) { |
1431 | if ( ! bar.isVisible() ) | 1431 | if ( ! bar.isVisible() ) |
1432 | return false; | 1432 | return false; |
1433 | if ( incCounter % modulo == 0 ) | 1433 | if ( incCounter % modulo == 0 ) |
1434 | bar.setProgress( incCounter ); | 1434 | bar.setProgress( incCounter ); |
1435 | ++incCounter; | 1435 | ++incCounter; |
1436 | uid = inR->uid(); | 1436 | uid = inR->uid(); |
1437 | bool skipIncidence = false; | 1437 | bool skipIncidence = false; |
1438 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1438 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1439 | skipIncidence = true; | 1439 | skipIncidence = true; |
1440 | QString idS; | 1440 | QString idS; |
1441 | qApp->processEvents(); | 1441 | qApp->processEvents(); |
1442 | if ( !skipIncidence ) { | 1442 | if ( !skipIncidence ) { |
1443 | inL = local->incidence( uid ); | 1443 | inL = local->incidence( uid ); |
1444 | if ( inL ) { // maybe conflict - same uid in both calendars | 1444 | if ( inL ) { // maybe conflict - same uid in both calendars |
1445 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1445 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1446 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1446 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1447 | if ( take == 3 ) | 1447 | if ( take == 3 ) |
1448 | return false; | 1448 | return false; |
1449 | if ( take == 1 ) {// take local ********************** | 1449 | if ( take == 1 ) {// take local ********************** |
1450 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1450 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1451 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1451 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1452 | else | 1452 | else |
1453 | idS = inR->IDStr(); | 1453 | idS = inR->IDStr(); |
1454 | remote->deleteIncidence( inR ); | 1454 | remote->deleteIncidence( inR ); |
1455 | inR = inL->clone(); | 1455 | inR = inL->clone(); |
1456 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1456 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1457 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1457 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1458 | inR->setIDStr( idS ); | 1458 | inR->setIDStr( idS ); |
1459 | remote->addIncidence( inR ); | 1459 | remote->addIncidence( inR ); |
1460 | if ( mSyncManager->syncWithDesktop() ) | 1460 | if ( mSyncManager->syncWithDesktop() ) |
1461 | inR->setPilotId( 2 ); | 1461 | inR->setPilotId( 2 ); |
1462 | ++changedRemote; | 1462 | ++changedRemote; |
1463 | } else {// take remote ********************** | 1463 | } else {// take remote ********************** |
1464 | idS = inL->IDStr(); | 1464 | idS = inL->IDStr(); |
1465 | int pid = inL->pilotId(); | 1465 | int pid = inL->pilotId(); |
1466 | local->deleteIncidence( inL ); | 1466 | local->deleteIncidence( inL ); |
1467 | inL = inR->clone(); | 1467 | inL = inR->clone(); |
1468 | if ( mSyncManager->syncWithDesktop() ) | 1468 | if ( mSyncManager->syncWithDesktop() ) |
1469 | inL->setPilotId( pid ); | 1469 | inL->setPilotId( pid ); |
1470 | inL->setIDStr( idS ); | 1470 | inL->setIDStr( idS ); |
1471 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1471 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1472 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1472 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1473 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1473 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1474 | } | 1474 | } |
1475 | local->addIncidence( inL ); | 1475 | local->addIncidence( inL ); |
1476 | ++changedLocal; | 1476 | ++changedLocal; |
1477 | } | 1477 | } |
1478 | } | 1478 | } |
1479 | } else { // no conflict ********** add or delete remote | 1479 | } else { // no conflict ********** add or delete remote |
1480 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1480 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1481 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1481 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1482 | QString des = eventLSync->description(); | 1482 | QString des = eventLSync->description(); |
1483 | QString pref = "e"; | 1483 | QString pref = "e"; |
1484 | if ( inR->typeID() == todoID ) | 1484 | if ( inR->typeID() == todoID ) |
1485 | pref = "t"; | 1485 | pref = "t"; |
1486 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1486 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1487 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1487 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1488 | //remote->deleteIncidence( inR ); | 1488 | //remote->deleteIncidence( inR ); |
1489 | ++deletedEventR; | 1489 | ++deletedEventR; |
1490 | } else { | 1490 | } else { |
1491 | inR->setLastModified( modifiedCalendar ); | 1491 | inR->setLastModified( modifiedCalendar ); |
1492 | inL = inR->clone(); | 1492 | inL = inR->clone(); |
1493 | inL->setIDStr( ":" ); | 1493 | inL->setIDStr( ":" ); |
1494 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1494 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1495 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1495 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1496 | local->addIncidence( inL ); | 1496 | local->addIncidence( inL ); |
1497 | ++addedEvent; | 1497 | ++addedEvent; |
1498 | 1498 | ||
1499 | } | 1499 | } |
1500 | } else { | 1500 | } else { |
1501 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1501 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1502 | inR->setLastModified( modifiedCalendar ); | 1502 | inR->setLastModified( modifiedCalendar ); |
1503 | inL = inR->clone(); | 1503 | inL = inR->clone(); |
1504 | inL->setIDStr( ":" ); | 1504 | inL->setIDStr( ":" ); |
1505 | local->addIncidence( inL ); | 1505 | local->addIncidence( inL ); |
1506 | ++addedEvent; | 1506 | ++addedEvent; |
1507 | 1507 | ||
1508 | } else { | 1508 | } else { |
1509 | checkExternSyncEvent(eventRSyncSharp, inR); | 1509 | checkExternSyncEvent(eventRSyncSharp, inR); |
1510 | remote->deleteIncidence( inR ); | 1510 | remote->deleteIncidence( inR ); |
1511 | ++deletedEventR; | 1511 | ++deletedEventR; |
1512 | } | 1512 | } |
1513 | } | 1513 | } |
1514 | } else { | 1514 | } else { |
1515 | ++filteredIN; | 1515 | ++filteredIN; |
1516 | } | 1516 | } |
1517 | } | 1517 | } |
1518 | } | 1518 | } |
1519 | inR = er.next(); | 1519 | inR = er.next(); |
1520 | } | 1520 | } |
1521 | QPtrList<Incidence> el = local->rawIncidences(); | 1521 | QPtrList<Incidence> el = local->rawIncidences(); |
1522 | inL = el.first(); | 1522 | inL = el.first(); |
1523 | modulo = (el.count()/10)+1; | 1523 | modulo = (el.count()/10)+1; |
1524 | bar.setCaption (i18n("Add / remove events") ); | 1524 | bar.setCaption (i18n("Add / remove events") ); |
1525 | bar.setTotalSteps ( el.count() ) ; | 1525 | bar.setTotalSteps ( el.count() ) ; |
1526 | bar.show(); | 1526 | bar.show(); |
1527 | incCounter = 0; | 1527 | incCounter = 0; |
1528 | 1528 | ||
1529 | while ( inL ) { | 1529 | while ( inL ) { |
1530 | 1530 | ||
1531 | qApp->processEvents(); | 1531 | qApp->processEvents(); |
1532 | if ( ! bar.isVisible() ) | 1532 | if ( ! bar.isVisible() ) |
1533 | return false; | 1533 | return false; |
1534 | if ( incCounter % modulo == 0 ) | 1534 | if ( incCounter % modulo == 0 ) |
1535 | bar.setProgress( incCounter ); | 1535 | bar.setProgress( incCounter ); |
1536 | ++incCounter; | 1536 | ++incCounter; |
1537 | uid = inL->uid(); | 1537 | uid = inL->uid(); |
1538 | bool skipIncidence = false; | 1538 | bool skipIncidence = false; |
1539 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1539 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1540 | skipIncidence = true; | 1540 | skipIncidence = true; |
1541 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1541 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1542 | skipIncidence = true; | 1542 | skipIncidence = true; |
1543 | if ( !skipIncidence ) { | 1543 | if ( !skipIncidence ) { |
1544 | inR = remote->incidence( uid ); | 1544 | inR = remote->incidence( uid ); |
1545 | if ( ! inR ) { | 1545 | if ( ! inR ) { |
1546 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1546 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1547 | // no conflict ********** add or delete local | 1547 | // no conflict ********** add or delete local |
1548 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1548 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1549 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1549 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1550 | checkExternSyncEvent(eventLSyncSharp, inL); | 1550 | checkExternSyncEvent(eventLSyncSharp, inL); |
1551 | local->deleteIncidence( inL ); | 1551 | local->deleteIncidence( inL ); |
1552 | ++deletedEventL; | 1552 | ++deletedEventL; |
1553 | } else { | 1553 | } else { |
1554 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1554 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1555 | inL->removeID(mCurrentSyncDevice ); | 1555 | inL->removeID(mCurrentSyncDevice ); |
1556 | ++addedEventR; | 1556 | ++addedEventR; |
1557 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1557 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1558 | inL->setLastModified( modifiedCalendar ); | 1558 | inL->setLastModified( modifiedCalendar ); |
1559 | inR = inL->clone(); | 1559 | inR = inL->clone(); |
1560 | inR->setIDStr( ":" ); | 1560 | inR->setIDStr( ":" ); |
1561 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1561 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1562 | remote->addIncidence( inR ); | 1562 | remote->addIncidence( inR ); |
1563 | } | 1563 | } |
1564 | } | 1564 | } |
1565 | } else { | 1565 | } else { |
1566 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1566 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1567 | checkExternSyncEvent(eventLSyncSharp, inL); | 1567 | checkExternSyncEvent(eventLSyncSharp, inL); |
1568 | local->deleteIncidence( inL ); | 1568 | local->deleteIncidence( inL ); |
1569 | ++deletedEventL; | 1569 | ++deletedEventL; |
1570 | } else { | 1570 | } else { |
1571 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1571 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1572 | ++addedEventR; | 1572 | ++addedEventR; |
1573 | inL->setLastModified( modifiedCalendar ); | 1573 | inL->setLastModified( modifiedCalendar ); |
1574 | inR = inL->clone(); | 1574 | inR = inL->clone(); |
1575 | inR->setIDStr( ":" ); | 1575 | inR->setIDStr( ":" ); |
1576 | remote->addIncidence( inR ); | 1576 | remote->addIncidence( inR ); |
1577 | } | 1577 | } |
1578 | } | 1578 | } |
1579 | } | 1579 | } |
1580 | } else { | 1580 | } else { |
1581 | ++filteredOUT; | 1581 | ++filteredOUT; |
1582 | } | 1582 | } |
1583 | } | 1583 | } |
1584 | } | 1584 | } |
1585 | inL = el.next(); | 1585 | inL = el.next(); |
1586 | } | 1586 | } |
1587 | int delFut = 0; | 1587 | int delFut = 0; |
1588 | int remRem = 0; | 1588 | int remRem = 0; |
1589 | if ( mSyncManager->mWriteBackInFuture ) { | 1589 | if ( mSyncManager->mWriteBackInFuture ) { |
1590 | er = remote->rawIncidences(); | 1590 | er = remote->rawIncidences(); |
1591 | remRem = er.count(); | 1591 | remRem = er.count(); |
1592 | inR = er.first(); | 1592 | inR = er.first(); |
1593 | QDateTime dt; | 1593 | QDateTime dt; |
1594 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1594 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1595 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1595 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1596 | while ( inR ) { | 1596 | while ( inR ) { |
1597 | if ( inR->typeID() == todoID ) { | 1597 | if ( inR->typeID() == todoID ) { |
1598 | Todo * t = (Todo*)inR; | 1598 | Todo * t = (Todo*)inR; |
1599 | if ( t->hasDueDate() ) | 1599 | if ( t->hasDueDate() ) |
1600 | dt = t->dtDue(); | 1600 | dt = t->dtDue(); |
1601 | else | 1601 | else |
1602 | dt = cur.addSecs( 62 ); | 1602 | dt = cur.addSecs( 62 ); |
1603 | } | 1603 | } |
1604 | else if (inR->typeID() == eventID ) { | 1604 | else if (inR->typeID() == eventID ) { |
1605 | bool ok; | 1605 | bool ok; |
1606 | dt = inR->getNextOccurence( cur, &ok ); | 1606 | dt = inR->getNextOccurence( cur, &ok ); |
1607 | if ( !ok ) | 1607 | if ( !ok ) |
1608 | dt = cur.addSecs( -62 ); | 1608 | dt = cur.addSecs( -62 ); |
1609 | } | 1609 | } |
1610 | else | 1610 | else |
1611 | dt = inR->dtStart(); | 1611 | dt = inR->dtStart(); |
1612 | if ( dt < cur || dt > end ) { | 1612 | if ( dt < cur || dt > end ) { |
1613 | remote->deleteIncidence( inR ); | 1613 | remote->deleteIncidence( inR ); |
1614 | ++delFut; | 1614 | ++delFut; |
1615 | } | 1615 | } |
1616 | inR = er.next(); | 1616 | inR = er.next(); |
1617 | } | 1617 | } |
1618 | } | 1618 | } |
1619 | bar.hide(); | 1619 | bar.hide(); |
1620 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1620 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1621 | eventLSync->setReadOnly( false ); | 1621 | eventLSync->setReadOnly( false ); |
1622 | eventLSync->setDtStart( mLastCalendarSync ); | 1622 | eventLSync->setDtStart( mLastCalendarSync ); |
1623 | eventRSync->setDtStart( mLastCalendarSync ); | 1623 | eventRSync->setDtStart( mLastCalendarSync ); |
1624 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1624 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1625 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1625 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1626 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1626 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1627 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1627 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1628 | eventLSync->setReadOnly( true ); | 1628 | eventLSync->setReadOnly( true ); |
1629 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1629 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1630 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1630 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1631 | remote->addEvent( eventRSync ); | 1631 | remote->addEvent( eventRSync ); |
1632 | else | 1632 | else |
1633 | delete eventRSync; | 1633 | delete eventRSync; |
1634 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1634 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1635 | QString mes; | 1635 | QString mes; |
1636 | 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 ); | 1636 | 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 ); |
1637 | QString delmess; | 1637 | QString delmess; |
1638 | if ( delFut ) { | 1638 | if ( delFut ) { |
1639 | 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); | 1639 | 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); |
1640 | mes += delmess; | 1640 | mes += delmess; |
1641 | } | 1641 | } |
1642 | mes = i18n("Local calendar changed!\n") +mes; | 1642 | mes = i18n("Local calendar changed!\n") +mes; |
1643 | mCalendar->checkAlarmForIncidence( 0, true ); | 1643 | mCalendar->checkAlarmForIncidence( 0, true ); |
1644 | qDebug( mes ); | 1644 | qDebug( mes ); |
1645 | if ( mSyncManager->mShowSyncSummary ) { | 1645 | if ( mSyncManager->mShowSyncSummary ) { |
1646 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1646 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1647 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1647 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1648 | qDebug("KO: WB cancelled "); | 1648 | qDebug("KO: WB cancelled "); |
1649 | mSyncManager->mWriteBackFile = false; | 1649 | mSyncManager->mWriteBackFile = false; |
1650 | return syncOK; | 1650 | return syncOK; |
1651 | } | 1651 | } |
1652 | } | 1652 | } |
1653 | return syncOK; | 1653 | return syncOK; |
1654 | } | 1654 | } |
1655 | 1655 | ||
1656 | void CalendarView::setSyncDevice( QString s ) | 1656 | void CalendarView::setSyncDevice( QString s ) |
1657 | { | 1657 | { |
1658 | mCurrentSyncDevice= s; | 1658 | mCurrentSyncDevice= s; |
1659 | } | 1659 | } |
1660 | void CalendarView::setSyncName( QString s ) | 1660 | void CalendarView::setSyncName( QString s ) |
1661 | { | 1661 | { |
1662 | mCurrentSyncName= s; | 1662 | mCurrentSyncName= s; |
1663 | } | 1663 | } |
1664 | bool CalendarView::syncCalendar(QString filename, int mode) | 1664 | bool CalendarView::syncCalendar(QString filename, int mode) |
1665 | { | 1665 | { |
1666 | //qDebug("syncCalendar %s ", filename.latin1()); | 1666 | //qDebug("syncCalendar %s ", filename.latin1()); |
1667 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1667 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1668 | CalendarLocal* calendar = new CalendarLocal(); | 1668 | CalendarLocal* calendar = new CalendarLocal(); |
1669 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1669 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1670 | FileStorage* storage = new FileStorage( calendar ); | 1670 | FileStorage* storage = new FileStorage( calendar ); |
1671 | bool syncOK = false; | 1671 | bool syncOK = false; |
1672 | storage->setFileName( filename ); | 1672 | storage->setFileName( filename ); |
1673 | // qDebug("loading ... "); | 1673 | // qDebug("loading ... "); |
1674 | if ( storage->load() ) { | 1674 | if ( storage->load() ) { |
1675 | getEventViewerDialog()->setSyncMode( true ); | 1675 | getEventViewerDialog()->setSyncMode( true ); |
1676 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1676 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1677 | getEventViewerDialog()->setSyncMode( false ); | 1677 | getEventViewerDialog()->setSyncMode( false ); |
1678 | if ( syncOK ) { | 1678 | if ( syncOK ) { |
1679 | if ( mSyncManager->mWriteBackFile ) | 1679 | if ( mSyncManager->mWriteBackFile ) |
1680 | { | 1680 | { |
1681 | storage->setSaveFormat( new ICalFormat() ); | 1681 | storage->setSaveFormat( new ICalFormat() ); |
1682 | storage->save(); | 1682 | storage->save(); |
1683 | } | 1683 | } |
1684 | } | 1684 | } |
1685 | setModified( true ); | 1685 | setModified( true ); |
1686 | } | 1686 | } |
1687 | delete storage; | 1687 | delete storage; |
1688 | delete calendar; | 1688 | delete calendar; |
1689 | if ( syncOK ) | 1689 | if ( syncOK ) |
1690 | updateView(); | 1690 | updateView(); |
1691 | return syncOK; | 1691 | return syncOK; |
1692 | } | 1692 | } |
1693 | 1693 | ||
1694 | void CalendarView::syncExternal( int mode ) | 1694 | void CalendarView::syncExternal( int mode ) |
1695 | { | 1695 | { |
1696 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1696 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1697 | 1697 | ||
1698 | qApp->processEvents(); | 1698 | qApp->processEvents(); |
1699 | CalendarLocal* calendar = new CalendarLocal(); | 1699 | CalendarLocal* calendar = new CalendarLocal(); |
1700 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1700 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1701 | bool syncOK = false; | 1701 | bool syncOK = false; |
1702 | bool loadSuccess = false; | 1702 | bool loadSuccess = false; |
1703 | PhoneFormat* phoneFormat = 0; | 1703 | PhoneFormat* phoneFormat = 0; |
1704 | emit tempDisableBR(true); | 1704 | emit tempDisableBR(true); |
1705 | #ifndef DESKTOP_VERSION | 1705 | #ifndef DESKTOP_VERSION |
1706 | SharpFormat* sharpFormat = 0; | 1706 | SharpFormat* sharpFormat = 0; |
1707 | if ( mode == 0 ) { // sharp | 1707 | if ( mode == 0 ) { // sharp |
1708 | sharpFormat = new SharpFormat () ; | 1708 | sharpFormat = new SharpFormat () ; |
1709 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1709 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1710 | 1710 | ||
1711 | } else | 1711 | } else |
1712 | #endif | 1712 | #endif |
1713 | if ( mode == 1 ) { // phone | 1713 | if ( mode == 1 ) { // phone |
1714 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1714 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1715 | mSyncManager->mPhoneDevice, | 1715 | mSyncManager->mPhoneDevice, |
1716 | mSyncManager->mPhoneConnection, | 1716 | mSyncManager->mPhoneConnection, |
1717 | mSyncManager->mPhoneModel); | 1717 | mSyncManager->mPhoneModel); |
1718 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1718 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1719 | 1719 | ||
1720 | } else { | 1720 | } else { |
1721 | emit tempDisableBR(false); | 1721 | emit tempDisableBR(false); |
1722 | return; | 1722 | return; |
1723 | } | 1723 | } |
1724 | if ( loadSuccess ) { | 1724 | if ( loadSuccess ) { |
1725 | getEventViewerDialog()->setSyncMode( true ); | 1725 | getEventViewerDialog()->setSyncMode( true ); |
1726 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1726 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1727 | getEventViewerDialog()->setSyncMode( false ); | 1727 | getEventViewerDialog()->setSyncMode( false ); |
1728 | qApp->processEvents(); | 1728 | qApp->processEvents(); |
1729 | if ( syncOK ) { | 1729 | if ( syncOK ) { |
1730 | if ( mSyncManager->mWriteBackFile ) | 1730 | if ( mSyncManager->mWriteBackFile ) |
1731 | { | 1731 | { |
1732 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1732 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1733 | Incidence* inc = iL.first(); | 1733 | Incidence* inc = iL.first(); |
1734 | if ( phoneFormat ) { | 1734 | if ( phoneFormat ) { |
1735 | while ( inc ) { | 1735 | while ( inc ) { |
1736 | inc->removeID(mCurrentSyncDevice); | 1736 | inc->removeID(mCurrentSyncDevice); |
1737 | inc = iL.next(); | 1737 | inc = iL.next(); |
1738 | } | 1738 | } |
1739 | } | 1739 | } |
1740 | #ifndef DESKTOP_VERSION | 1740 | #ifndef DESKTOP_VERSION |
1741 | if ( sharpFormat ) | 1741 | if ( sharpFormat ) |
1742 | sharpFormat->save(calendar); | 1742 | sharpFormat->save(calendar); |
1743 | #endif | 1743 | #endif |
1744 | if ( phoneFormat ) | 1744 | if ( phoneFormat ) |
1745 | phoneFormat->save(calendar); | 1745 | phoneFormat->save(calendar); |
1746 | iL = calendar->rawIncidences(); | 1746 | iL = calendar->rawIncidences(); |
1747 | inc = iL.first(); | 1747 | inc = iL.first(); |
1748 | Incidence* loc; | 1748 | Incidence* loc; |
1749 | while ( inc ) { | 1749 | while ( inc ) { |
1750 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1750 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1751 | loc = mCalendar->incidence(inc->uid() ); | 1751 | loc = mCalendar->incidence(inc->uid() ); |
1752 | if ( loc ) { | 1752 | if ( loc ) { |
1753 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1753 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1754 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1754 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1755 | } | 1755 | } |
1756 | } | 1756 | } |
1757 | inc = iL.next(); | 1757 | inc = iL.next(); |
1758 | } | 1758 | } |
1759 | Incidence* lse = getLastSyncEvent(); | 1759 | Incidence* lse = getLastSyncEvent(); |
1760 | if ( lse ) { | 1760 | if ( lse ) { |
1761 | lse->setReadOnly( false ); | 1761 | lse->setReadOnly( false ); |
1762 | lse->setDescription( "" ); | 1762 | lse->setDescription( "" ); |
1763 | lse->setReadOnly( true ); | 1763 | lse->setReadOnly( true ); |
1764 | } | 1764 | } |
1765 | } | 1765 | } |
1766 | } else { | 1766 | } else { |
1767 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1767 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1768 | } | 1768 | } |
1769 | setModified( true ); | 1769 | setModified( true ); |
1770 | } else { | 1770 | } else { |
1771 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1771 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1772 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1772 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1773 | question, i18n("Ok")) ; | 1773 | question, i18n("Ok")) ; |
1774 | 1774 | ||
1775 | } | 1775 | } |
1776 | delete calendar; | 1776 | delete calendar; |
1777 | updateView(); | 1777 | updateView(); |
1778 | emit tempDisableBR(false); | 1778 | emit tempDisableBR(false); |
1779 | return ;//syncOK; | 1779 | return ;//syncOK; |
1780 | 1780 | ||
1781 | } | 1781 | } |
1782 | 1782 | ||
1783 | bool CalendarView::importBday() | 1783 | bool CalendarView::importBday() |
1784 | { | 1784 | { |
1785 | #ifndef KORG_NOKABC | 1785 | #ifndef KORG_NOKABC |
1786 | 1786 | ||
1787 | #ifdef DESKTOP_VERSION | 1787 | #ifdef DESKTOP_VERSION |
1788 | int curCal = mCalendar->defaultCalendar(); | 1788 | int curCal = mCalendar->defaultCalendar(); |
1789 | int bd = mCalEditView->getBirtdayID(); | 1789 | int bd = mCalEditView->getBirtdayID(); |
1790 | if ( bd == 0 ) | 1790 | if ( bd == 0 ) |
1791 | return false; | 1791 | return false; |
1792 | mCalendar->setDefaultCalendar( bd ); | 1792 | mCalendar->setDefaultCalendar( bd ); |
1793 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1793 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1794 | KABC::AddressBook::Iterator it; | 1794 | KABC::AddressBook::Iterator it; |
1795 | int count = 0; | 1795 | int count = 0; |
1796 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1796 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1797 | ++count; | 1797 | ++count; |
1798 | } | 1798 | } |
1799 | QProgressBar bar(count,0 ); | 1799 | QProgressBar bar(count,0 ); |
1800 | int w = 300; | 1800 | int w = 300; |
1801 | if ( QApplication::desktop()->width() < 320 ) | 1801 | if ( QApplication::desktop()->width() < 320 ) |
1802 | w = 220; | 1802 | w = 220; |
1803 | int h = bar.sizeHint().height() ; | 1803 | int h = bar.sizeHint().height() ; |
1804 | int dw = QApplication::desktop()->width(); | 1804 | int dw = QApplication::desktop()->width(); |
1805 | int dh = QApplication::desktop()->height(); | 1805 | int dh = QApplication::desktop()->height(); |
1806 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1806 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1807 | bar.show(); | 1807 | bar.show(); |
1808 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1808 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1809 | qApp->processEvents(); | 1809 | qApp->processEvents(); |
1810 | count = 0; | 1810 | count = 0; |
1811 | int addCount = 0; | 1811 | int addCount = 0; |
1812 | KCal::Attendee* a = 0; | 1812 | KCal::Attendee* a = 0; |
1813 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1813 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1814 | if ( ! bar.isVisible() ) | 1814 | if ( ! bar.isVisible() ) |
1815 | return false; | 1815 | return false; |
1816 | bar.setProgress( count++ ); | 1816 | bar.setProgress( count++ ); |
1817 | qApp->processEvents(); | 1817 | qApp->processEvents(); |
1818 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1818 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1819 | if ( (*it).birthday().date().isValid() ){ | 1819 | if ( (*it).birthday().date().isValid() ){ |
1820 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1820 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1821 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1821 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1822 | ++addCount; | 1822 | ++addCount; |
1823 | } | 1823 | } |
1824 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1824 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1825 | if ( anni.isValid() ){ | 1825 | if ( anni.isValid() ){ |
1826 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1826 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1827 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1827 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1828 | ++addCount; | 1828 | ++addCount; |
1829 | } | 1829 | } |
1830 | } | 1830 | } |
1831 | mCalendar->setDefaultCalendar( curCal ); | 1831 | mCalendar->setDefaultCalendar( curCal ); |
1832 | updateView(); | 1832 | updateView(); |
1833 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1833 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1834 | #else //DESKTOP_VERSION | 1834 | #else //DESKTOP_VERSION |
1835 | 1835 | ||
1836 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1836 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1837 | // the result should now arrive through method insertBirthdays | 1837 | // the result should now arrive through method insertBirthdays |
1838 | 1838 | ||
1839 | #endif //DESKTOP_VERSION | 1839 | #endif //DESKTOP_VERSION |
1840 | 1840 | ||
1841 | #endif //KORG_NOKABC | 1841 | #endif //KORG_NOKABC |
1842 | 1842 | ||
1843 | 1843 | ||
1844 | return true; | 1844 | return true; |
1845 | } | 1845 | } |
1846 | 1846 | ||
1847 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1847 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1848 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1848 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1849 | const QStringList& anniversaryList, const QStringList& realNameList, | 1849 | const QStringList& anniversaryList, const QStringList& realNameList, |
1850 | const QStringList& emailList, const QStringList& assembledNameList, | 1850 | const QStringList& emailList, const QStringList& assembledNameList, |
1851 | const QStringList& uidList) | 1851 | const QStringList& uidList) |
1852 | { | 1852 | { |
1853 | 1853 | ||
1854 | //qDebug("KO::CalendarView::insertBirthdays"); | 1854 | //qDebug("KO::CalendarView::insertBirthdays"); |
1855 | if (uid == this->name()) | 1855 | if (uid == this->name()) |
1856 | { | 1856 | { |
1857 | int curCal = mCalendar->defaultCalendar(); | 1857 | int curCal = mCalendar->defaultCalendar(); |
1858 | int bd = mCalEditView->getBirtdayID(); | 1858 | int bd = mCalEditView->getBirtdayID(); |
1859 | if ( bd == 0 ) | 1859 | if ( bd == 0 ) |
1860 | return; | 1860 | return; |
1861 | mCalendar->setDefaultCalendar( bd ); | 1861 | mCalendar->setDefaultCalendar( bd ); |
1862 | 1862 | ||
1863 | 1863 | ||
1864 | int count = birthdayList.count(); | 1864 | int count = birthdayList.count(); |
1865 | int addCount = 0; | 1865 | int addCount = 0; |
1866 | KCal::Attendee* a = 0; | 1866 | KCal::Attendee* a = 0; |
1867 | 1867 | ||
1868 | //qDebug("CalView 1 %i", count); | 1868 | //qDebug("CalView 1 %i", count); |
1869 | 1869 | ||
1870 | QProgressBar bar(count,0 ); | 1870 | QProgressBar bar(count,0 ); |
1871 | int w = 300; | 1871 | int w = 300; |
1872 | if ( QApplication::desktop()->width() < 320 ) | 1872 | if ( QApplication::desktop()->width() < 320 ) |
1873 | w = 220; | 1873 | w = 220; |
1874 | int h = bar.sizeHint().height() ; | 1874 | int h = bar.sizeHint().height() ; |
1875 | int dw = QApplication::desktop()->width(); | 1875 | int dw = QApplication::desktop()->width(); |
1876 | int dh = QApplication::desktop()->height(); | 1876 | int dh = QApplication::desktop()->height(); |
1877 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1877 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1878 | bar.show(); | 1878 | bar.show(); |
1879 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1879 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1880 | qApp->processEvents(); | 1880 | qApp->processEvents(); |
1881 | 1881 | ||
1882 | QDate birthday; | 1882 | QDate birthday; |
1883 | QDate anniversary; | 1883 | QDate anniversary; |
1884 | QString realName; | 1884 | QString realName; |
1885 | QString email; | 1885 | QString email; |
1886 | QString assembledName; | 1886 | QString assembledName; |
1887 | QString uid; | 1887 | QString uid; |
1888 | bool ok = true; | 1888 | bool ok = true; |
1889 | for ( int i = 0; i < count; i++) | 1889 | for ( int i = 0; i < count; i++) |
1890 | { | 1890 | { |
1891 | if ( ! bar.isVisible() ) | 1891 | if ( ! bar.isVisible() ) |
1892 | return; | 1892 | return; |
1893 | bar.setProgress( i ); | 1893 | bar.setProgress( i ); |
1894 | qApp->processEvents(); | 1894 | qApp->processEvents(); |
1895 | 1895 | ||
1896 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1896 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1897 | if (!ok) { | 1897 | if (!ok) { |
1898 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1898 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1899 | } | 1899 | } |
1900 | 1900 | ||
1901 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1901 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1902 | if (!ok) { | 1902 | if (!ok) { |
1903 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1903 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1904 | } | 1904 | } |
1905 | realName = realNameList[i]; | 1905 | realName = realNameList[i]; |
1906 | email = emailList[i]; | 1906 | email = emailList[i]; |
1907 | assembledName = assembledNameList[i]; | 1907 | assembledName = assembledNameList[i]; |
1908 | uid = uidList[i]; | 1908 | uid = uidList[i]; |
1909 | //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() ); | 1909 | //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() ); |
1910 | 1910 | ||
1911 | if ( birthday.isValid() ){ | 1911 | if ( birthday.isValid() ){ |
1912 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1912 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1913 | KCal::Attendee::ReqParticipant,uid) ; | 1913 | KCal::Attendee::ReqParticipant,uid) ; |
1914 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1914 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1915 | ++addCount; | 1915 | ++addCount; |
1916 | } | 1916 | } |
1917 | 1917 | ||
1918 | if ( anniversary.isValid() ){ | 1918 | if ( anniversary.isValid() ){ |
1919 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1919 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1920 | KCal::Attendee::ReqParticipant,uid) ; | 1920 | KCal::Attendee::ReqParticipant,uid) ; |
1921 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1921 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1922 | ++addCount; | 1922 | ++addCount; |
1923 | } | 1923 | } |
1924 | } | 1924 | } |
1925 | 1925 | ||
1926 | mCalendar->setDefaultCalendar( curCal ); | 1926 | mCalendar->setDefaultCalendar( curCal ); |
1927 | updateView(); | 1927 | updateView(); |
1928 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1928 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1929 | 1929 | ||
1930 | } | 1930 | } |
1931 | 1931 | ||
1932 | } | 1932 | } |
1933 | 1933 | ||
1934 | 1934 | ||
1935 | 1935 | ||
1936 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1936 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1937 | { | 1937 | { |
1938 | //qDebug("addAnni "); | 1938 | //qDebug("addAnni "); |
1939 | Event * ev = new Event(); | 1939 | Event * ev = new Event(); |
1940 | ev->setOrganizer(KOPrefs::instance()->email()); | 1940 | ev->setOrganizer(KOPrefs::instance()->email()); |
1941 | if ( a ) { | 1941 | if ( a ) { |
1942 | ev->addAttendee( a ); | 1942 | ev->addAttendee( a ); |
1943 | } | 1943 | } |
1944 | QString kind; | 1944 | QString kind; |
1945 | if ( birthday ) { | 1945 | if ( birthday ) { |
1946 | kind = i18n( "Birthday" ); | 1946 | kind = i18n( "Birthday" ); |
1947 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1947 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1948 | } | 1948 | } |
1949 | else { | 1949 | else { |
1950 | kind = i18n( "Anniversary" ); | 1950 | kind = i18n( "Anniversary" ); |
1951 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1951 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1952 | } | 1952 | } |
1953 | ev->setCategories( kind ); | 1953 | ev->setCategories( kind ); |
1954 | ev->setDtStart( QDateTime(date) ); | 1954 | ev->setDtStart( QDateTime(date) ); |
1955 | ev->setDtEnd( QDateTime(date) ); | 1955 | ev->setDtEnd( QDateTime(date) ); |
1956 | ev->setFloats( true ); | 1956 | ev->setFloats( true ); |
1957 | Recurrence * rec = ev->recurrence(); | 1957 | Recurrence * rec = ev->recurrence(); |
1958 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1958 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1959 | rec->addYearlyNum( date.month() ); | 1959 | rec->addYearlyNum( date.month() ); |
1960 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1960 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1961 | delete ev; | 1961 | delete ev; |
1962 | return false; | 1962 | return false; |
1963 | } | 1963 | } |
1964 | return true; | 1964 | return true; |
1965 | 1965 | ||
1966 | } | 1966 | } |
1967 | bool CalendarView::importQtopia( const QString &categories, | 1967 | bool CalendarView::importQtopia( const QString &categories, |
1968 | const QString &datebook, | 1968 | const QString &datebook, |
1969 | const QString &todolist ) | 1969 | const QString &todolist ) |
1970 | { | 1970 | { |
1971 | 1971 | ||
1972 | QtopiaFormat qtopiaFormat; | 1972 | QtopiaFormat qtopiaFormat; |
1973 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1973 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1974 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1974 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1975 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1975 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1976 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1976 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1977 | 1977 | ||
1978 | updateView(); | 1978 | updateView(); |
1979 | return true; | 1979 | return true; |
1980 | 1980 | ||
1981 | #if 0 | 1981 | #if 0 |
1982 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1982 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1983 | mCurrentSyncDevice = "qtopia-XML"; | 1983 | mCurrentSyncDevice = "qtopia-XML"; |
1984 | if ( mSyncManager->mAskForPreferences ) | 1984 | if ( mSyncManager->mAskForPreferences ) |
1985 | edit_sync_options(); | 1985 | edit_sync_options(); |
1986 | qApp->processEvents(); | 1986 | qApp->processEvents(); |
1987 | CalendarLocal* calendar = new CalendarLocal(); | 1987 | CalendarLocal* calendar = new CalendarLocal(); |