-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 28649d9..a1b1d71 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4859 +1,4859 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "koagenda.h" | 107 | #include "koagenda.h" |
108 | #include "kodialogmanager.h" | 108 | #include "kodialogmanager.h" |
109 | #include "outgoingdialog.h" | 109 | #include "outgoingdialog.h" |
110 | #include "incomingdialog.h" | 110 | #include "incomingdialog.h" |
111 | #include "datenavigatorcontainer.h" | 111 | #include "datenavigatorcontainer.h" |
112 | #include "statusdialog.h" | 112 | #include "statusdialog.h" |
113 | #include "kdatenavigator.h" | 113 | #include "kdatenavigator.h" |
114 | #include "kotodoview.h" | 114 | #include "kotodoview.h" |
115 | #include "datenavigator.h" | 115 | #include "datenavigator.h" |
116 | #include "resourceview.h" | 116 | #include "resourceview.h" |
117 | #include "navigatorbar.h" | 117 | #include "navigatorbar.h" |
118 | #include "searchdialog.h" | 118 | #include "searchdialog.h" |
119 | #include "mainwindow.h" | 119 | #include "mainwindow.h" |
120 | #include "categoryeditdialog.h" | 120 | #include "categoryeditdialog.h" |
121 | 121 | ||
122 | #include "calendarview.h" | 122 | #include "calendarview.h" |
123 | #ifndef DESKTOP_VERSION | 123 | #ifndef DESKTOP_VERSION |
124 | #include <qtopia/alarmserver.h> | 124 | #include <qtopia/alarmserver.h> |
125 | #endif | 125 | #endif |
126 | #ifndef _WIN32_ | 126 | #ifndef _WIN32_ |
127 | #include <stdlib.h> | 127 | #include <stdlib.h> |
128 | #include <stdio.h> | 128 | #include <stdio.h> |
129 | #include <unistd.h> | 129 | #include <unistd.h> |
130 | #else | 130 | #else |
131 | #include <qprocess.h> | 131 | #include <qprocess.h> |
132 | #endif | 132 | #endif |
133 | 133 | ||
134 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
135 | #include <kabc/stdaddressbook.h> | 135 | #include <kabc/stdaddressbook.h> |
136 | #endif | 136 | #endif |
137 | using namespace KOrg; | 137 | using namespace KOrg; |
138 | using namespace KCal; | 138 | using namespace KCal; |
139 | extern int globalFlagBlockAgenda; | 139 | extern int globalFlagBlockAgenda; |
140 | extern int globalFlagBlockStartup; | 140 | extern int globalFlagBlockStartup; |
141 | 141 | ||
142 | 142 | ||
143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
144 | 144 | ||
145 | { | 145 | { |
146 | mAlarms = alarms; | 146 | mAlarms = alarms; |
147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
148 | QString mText = "<table width=\"100%\">\n"; | 148 | QString mText = "<table width=\"100%\">\n"; |
149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
150 | #ifdef DESKTOP_VERSION | 150 | #ifdef DESKTOP_VERSION |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
152 | #else | 152 | #else |
153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
154 | #endif | 154 | #endif |
155 | // mText += "<img src=\""; | 155 | // mText += "<img src=\""; |
156 | // mText += ipath; | 156 | // mText += ipath; |
157 | // mText += "\">"; | 157 | // mText += "\">"; |
158 | //mEventDate = QDate::currentDate(); | 158 | //mEventDate = QDate::currentDate(); |
159 | #ifdef DESKTOP_VERSION | 159 | #ifdef DESKTOP_VERSION |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
161 | #else | 161 | #else |
162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
163 | #endif | 163 | #endif |
164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
165 | 165 | ||
166 | Incidence * inc = getNextInc( start ); | 166 | Incidence * inc = getNextInc( start ); |
167 | int time = 0; | 167 | int time = 0; |
168 | //mText += "<table>"; | 168 | //mText += "<table>"; |
169 | while ( inc ) { | 169 | while ( inc ) { |
170 | QDateTime dt ; | 170 | QDateTime dt ; |
171 | QString tempText = "<a "; | 171 | QString tempText = "<a "; |
172 | bool ok; | 172 | bool ok; |
173 | dt = inc->getNextOccurence( start, &ok ); | 173 | dt = inc->getNextOccurence( start, &ok ); |
174 | if ( !ok ) continue; | 174 | if ( !ok ) continue; |
175 | if ( inc->typeID() == eventID ) { | 175 | if ( inc->typeID() == eventID ) { |
176 | tempText += "href=\"event:"; | 176 | tempText += "href=\"event:"; |
177 | } else if ( inc->typeID() == todoID ) { | 177 | } else if ( inc->typeID() == todoID ) { |
178 | tempText += "href=\"todo:"; | 178 | tempText += "href=\"todo:"; |
179 | } | 179 | } |
180 | tempText += inc->uid() + "\">"; | 180 | tempText += inc->uid() + "\">"; |
181 | if ( inc->typeID() == todoID ) | 181 | if ( inc->typeID() == todoID ) |
182 | tempText += i18n("Todo: "); | 182 | tempText += i18n("Todo: "); |
183 | if ( inc->summary().length() > 0 ) | 183 | if ( inc->summary().length() > 0 ) |
184 | tempText += inc->summary(); | 184 | tempText += inc->summary(); |
185 | else | 185 | else |
186 | tempText += i18n("-no summary-"); | 186 | tempText += i18n("-no summary-"); |
187 | QString timestr; | 187 | QString timestr; |
188 | if (!inc->doesFloat()) | 188 | if (!inc->doesFloat()) |
189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | else | 190 | else |
191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
194 | mText += "<table>"; | 194 | mText += "<table>"; |
195 | time = 1; | 195 | time = 1; |
196 | } | 196 | } |
197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
198 | if ( time > 0 ) | 198 | if ( time > 0 ) |
199 | mText +="</table>"; | 199 | mText +="</table>"; |
200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
201 | mText += "<table>"; | 201 | mText += "<table>"; |
202 | time = 2; | 202 | time = 2; |
203 | 203 | ||
204 | } | 204 | } |
205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
206 | if ( time > 0 ) | 206 | if ( time > 0 ) |
207 | mText +="</table>"; | 207 | mText +="</table>"; |
208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
209 | mText += "<table>"; | 209 | mText += "<table>"; |
210 | time = 3; | 210 | time = 3; |
211 | } | 211 | } |
212 | mText +="<tr><td><b>"; | 212 | mText +="<tr><td><b>"; |
213 | mText += timestr; | 213 | mText += timestr; |
214 | mText += "</b></td><td>"; | 214 | mText += "</b></td><td>"; |
215 | mText += tempText; | 215 | mText += tempText; |
216 | mText += "</td></tr>\n"; | 216 | mText += "</td></tr>\n"; |
217 | inc = getNextInc( start ); | 217 | inc = getNextInc( start ); |
218 | } | 218 | } |
219 | mText +="</table>"; | 219 | mText +="</table>"; |
220 | setText( mText ); | 220 | setText( mText ); |
221 | } | 221 | } |
222 | 222 | ||
223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
224 | { | 224 | { |
225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
226 | } | 226 | } |
227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
228 | { | 228 | { |
229 | QDateTime dt ; | 229 | QDateTime dt ; |
230 | Incidence * retInc; | 230 | Incidence * retInc; |
231 | Incidence * inc = mAlarms.first(); | 231 | Incidence * inc = mAlarms.first(); |
232 | if ( inc == 0 ) | 232 | if ( inc == 0 ) |
233 | return 0; | 233 | return 0; |
234 | bool ok; | 234 | bool ok; |
235 | dt = inc->getNextOccurence( start, &ok ); | 235 | dt = inc->getNextOccurence( start, &ok ); |
236 | if ( ! ok ) return 0; | 236 | if ( ! ok ) return 0; |
237 | QDateTime dtn ; | 237 | QDateTime dtn ; |
238 | retInc = inc; | 238 | retInc = inc; |
239 | inc = mAlarms.next(); | 239 | inc = mAlarms.next(); |
240 | while ( inc ) { | 240 | while ( inc ) { |
241 | dtn = inc->getNextOccurence( start, &ok ); | 241 | dtn = inc->getNextOccurence( start, &ok ); |
242 | if ( ! ok ) return 0; | 242 | if ( ! ok ) return 0; |
243 | if ( dtn < dt ) { | 243 | if ( dtn < dt ) { |
244 | dt = dtn; | 244 | dt = dtn; |
245 | retInc = inc; | 245 | retInc = inc; |
246 | } | 246 | } |
247 | inc = mAlarms.next(); | 247 | inc = mAlarms.next(); |
248 | } | 248 | } |
249 | mAlarms.remove( retInc ); | 249 | mAlarms.remove( retInc ); |
250 | return retInc; | 250 | return retInc; |
251 | 251 | ||
252 | } | 252 | } |
253 | void MissedAlarmTextBrowser::setSource(const QString & n) | 253 | void MissedAlarmTextBrowser::setSource(const QString & n) |
254 | { | 254 | { |
255 | if (n.startsWith("event:")) { | 255 | if (n.startsWith("event:")) { |
256 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
257 | emit showIncidence(n.mid(8)); | 257 | emit showIncidence(n.mid(8)); |
258 | #else | 258 | #else |
259 | emit showIncidence(n.mid(6)); | 259 | emit showIncidence(n.mid(6)); |
260 | #endif | 260 | #endif |
261 | return; | 261 | return; |
262 | } else if (n.startsWith("todo:")) { | 262 | } else if (n.startsWith("todo:")) { |
263 | #ifdef DESKTOP_VERSION | 263 | #ifdef DESKTOP_VERSION |
264 | emit showIncidence(n.mid(7)); | 264 | emit showIncidence(n.mid(7)); |
265 | #else | 265 | #else |
266 | emit showIncidence(n.mid(5)); | 266 | emit showIncidence(n.mid(5)); |
267 | #endif | 267 | #endif |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | class KOBeamPrefs : public QDialog | 273 | class KOBeamPrefs : public QDialog |
274 | { | 274 | { |
275 | public: | 275 | public: |
276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
277 | QDialog( parent, name, true ) | 277 | QDialog( parent, name, true ) |
278 | { | 278 | { |
279 | setCaption( i18n("Beam Options") ); | 279 | setCaption( i18n("Beam Options") ); |
280 | QVBoxLayout* lay = new QVBoxLayout( this ); | 280 | QVBoxLayout* lay = new QVBoxLayout( this ); |
281 | lay->setSpacing( 3 ); | 281 | lay->setSpacing( 3 ); |
282 | lay->setMargin( 3 ); | 282 | lay->setMargin( 3 ); |
283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
284 | lay->addWidget( format ); | 284 | lay->addWidget( format ); |
285 | format->setExclusive ( true ) ; | 285 | format->setExclusive ( true ) ; |
286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
287 | lay->addWidget( time ); time->setExclusive ( true ) ; | 287 | lay->addWidget( time ); time->setExclusive ( true ) ; |
288 | vcal = new QRadioButton(" vCalendar ", format ); | 288 | vcal = new QRadioButton(" vCalendar ", format ); |
289 | ical = new QRadioButton(" iCalendar ", format ); | 289 | ical = new QRadioButton(" iCalendar ", format ); |
290 | vcal->setChecked( true ); | 290 | vcal->setChecked( true ); |
291 | tz = new QRadioButton(i18n(" With timezone "), time ); | 291 | tz = new QRadioButton(i18n(" With timezone "), time ); |
292 | local = new QRadioButton(i18n(" Local time "), time ); | 292 | local = new QRadioButton(i18n(" Local time "), time ); |
293 | tz->setChecked( true ); | 293 | tz->setChecked( true ); |
294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
295 | lay->addWidget( ok ); | 295 | lay->addWidget( ok ); |
296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
297 | lay->addWidget( cancel ); | 297 | lay->addWidget( cancel ); |
298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
300 | resize( 200, 200 ); | 300 | resize( 200, 200 ); |
301 | } | 301 | } |
302 | 302 | ||
303 | bool beamVcal() { return vcal->isChecked(); } | 303 | bool beamVcal() { return vcal->isChecked(); } |
304 | bool beamLocal() { return local->isChecked(); } | 304 | bool beamLocal() { return local->isChecked(); } |
305 | private: | 305 | private: |
306 | QRadioButton* vcal, *ical, *local, *tz; | 306 | QRadioButton* vcal, *ical, *local, *tz; |
307 | }; | 307 | }; |
308 | class KOCatPrefs : public QDialog | 308 | class KOCatPrefs : public QDialog |
309 | { | 309 | { |
310 | public: | 310 | public: |
311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
312 | QDialog( parent, name, true ) | 312 | QDialog( parent, name, true ) |
313 | { | 313 | { |
314 | setCaption( i18n("Manage new Categories") ); | 314 | setCaption( i18n("Manage new Categories") ); |
315 | QVBoxLayout* lay = new QVBoxLayout( this ); | 315 | QVBoxLayout* lay = new QVBoxLayout( this ); |
316 | lay->setSpacing( 3 ); | 316 | lay->setSpacing( 3 ); |
317 | lay->setMargin( 3 ); | 317 | lay->setMargin( 3 ); |
318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); | 318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); |
319 | lay->addWidget( lab ); | 319 | lay->addWidget( lab ); |
320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
321 | lay->addWidget( format ); | 321 | lay->addWidget( format ); |
322 | format->setExclusive ( true ) ; | 322 | format->setExclusive ( true ) ; |
323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
325 | addCatBut->setChecked( true ); | 325 | addCatBut->setChecked( true ); |
326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
327 | lay->addWidget( ok ); | 327 | lay->addWidget( ok ); |
328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
329 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
332 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
333 | } | 333 | } |
334 | 334 | ||
335 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
336 | private: | 336 | private: |
337 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | 340 | ||
341 | 341 | ||
342 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
343 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
344 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
345 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
346 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
347 | { | 347 | { |
348 | 348 | ||
349 | mEventEditor = 0; | 349 | mEventEditor = 0; |
350 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
351 | 351 | ||
352 | init(); | 352 | init(); |
353 | } | 353 | } |
354 | 354 | ||
355 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
356 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
357 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
358 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
359 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
360 | { | 360 | { |
361 | 361 | ||
362 | mEventEditor = 0; | 362 | mEventEditor = 0; |
363 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
364 | init(); | 364 | init(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void CalendarView::init() | 367 | void CalendarView::init() |
368 | { | 368 | { |
369 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 369 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
370 | setFocusPolicy (NoFocus ); | 370 | setFocusPolicy (NoFocus ); |
371 | mViewerCallerIsSearchDialog = false; | 371 | mViewerCallerIsSearchDialog = false; |
372 | mBlockShowDates = false; | 372 | mBlockShowDates = false; |
373 | mConflictingEvent = 0; | 373 | mConflictingEvent = 0; |
374 | mDatePickerMode = 0; | 374 | mDatePickerMode = 0; |
375 | mCurrentSyncDevice = ""; | 375 | mCurrentSyncDevice = ""; |
376 | mViewManager = new KOViewManager( this ); | 376 | mViewManager = new KOViewManager( this ); |
377 | mDialogManager = new KODialogManager( this ); | 377 | mDialogManager = new KODialogManager( this ); |
378 | mEventViewerDialog = 0; | 378 | mEventViewerDialog = 0; |
379 | mModified = false; | 379 | mModified = false; |
380 | mReadOnly = false; | 380 | mReadOnly = false; |
381 | mSelectedIncidence = 0; | 381 | mSelectedIncidence = 0; |
382 | mCalPrinter = 0; | 382 | mCalPrinter = 0; |
383 | mFilters.setAutoDelete(true); | 383 | mFilters.setAutoDelete(true); |
384 | 384 | ||
385 | mCalendar->registerObserver( this ); | 385 | mCalendar->registerObserver( this ); |
386 | // TODO: Make sure that view is updated, when calendar is changed. | 386 | // TODO: Make sure that view is updated, when calendar is changed. |
387 | 387 | ||
388 | mStorage = new FileStorage( mCalendar ); | 388 | mStorage = new FileStorage( mCalendar ); |
389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
390 | 390 | ||
391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
392 | #ifndef KORG_NOSPLITTER | 392 | #ifndef KORG_NOSPLITTER |
393 | // create the main layout frames. | 393 | // create the main layout frames. |
394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
395 | topLayout->addWidget(mPanner); | 395 | topLayout->addWidget(mPanner); |
396 | 396 | ||
397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
398 | "CalendarView::LeftFrame"); | 398 | "CalendarView::LeftFrame"); |
399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
400 | 400 | ||
401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
402 | "CalendarView::DateNavigator" ); | 402 | "CalendarView::DateNavigator" ); |
403 | 403 | ||
404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
406 | mTodoList->setNavigator( mNavigator ); | 406 | mTodoList->setNavigator( mNavigator ); |
407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
408 | 408 | ||
409 | #ifdef KORG_NORESOURCEVIEW | 409 | #ifdef KORG_NORESOURCEVIEW |
410 | mResourceView = 0; | 410 | mResourceView = 0; |
411 | #else | 411 | #else |
412 | if ( mResourceManager ) { | 412 | if ( mResourceManager ) { |
413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
414 | mResourceView->updateView(); | 414 | mResourceView->updateView(); |
415 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 415 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
416 | SLOT( updateView() ) ); | 416 | SLOT( updateView() ) ); |
417 | } else { | 417 | } else { |
418 | mResourceView = 0; | 418 | mResourceView = 0; |
419 | } | 419 | } |
420 | #endif | 420 | #endif |
421 | QWidget *rightBox = new QWidget( mPanner ); | 421 | QWidget *rightBox = new QWidget( mPanner ); |
422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
423 | 423 | ||
424 | mRightFrame = new QWidgetStack( rightBox ); | 424 | mRightFrame = new QWidgetStack( rightBox ); |
425 | rightLayout->addWidget( mRightFrame, 1 ); | 425 | rightLayout->addWidget( mRightFrame, 1 ); |
426 | 426 | ||
427 | mLeftFrame = mLeftSplitter; | 427 | mLeftFrame = mLeftSplitter; |
428 | #else | 428 | #else |
429 | //QWidget *mainBox = new QWidget( this ); | 429 | //QWidget *mainBox = new QWidget( this ); |
430 | //QWidget *leftFrame = new QWidget( mainBox ); | 430 | //QWidget *leftFrame = new QWidget( mainBox ); |
431 | //QBoxLayout * mainBoxLayout; | 431 | //QBoxLayout * mainBoxLayout; |
432 | if ( KOPrefs::instance()->mVerticalScreen ) { | 432 | if ( KOPrefs::instance()->mVerticalScreen ) { |
433 | //mainBoxLayout = new QVBoxLayout(mainBox); | 433 | //mainBoxLayout = new QVBoxLayout(mainBox); |
434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
439 | } else { | 439 | } else { |
440 | //mainBoxLayout = new QHBoxLayout(mainBox); | 440 | //mainBoxLayout = new QHBoxLayout(mainBox); |
441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
446 | } | 446 | } |
447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
448 | //QBoxLayout * leftFrameLayout; | 448 | //QBoxLayout * leftFrameLayout; |
449 | topLayout->addWidget( mMainFrame ); | 449 | topLayout->addWidget( mMainFrame ); |
450 | #ifdef DESKTOP_VERSION | 450 | #ifdef DESKTOP_VERSION |
451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
452 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
454 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
455 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
456 | #endif | 456 | #endif |
457 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
459 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
460 | #if 0 | 460 | #if 0 |
461 | // FIXME | 461 | // FIXME |
462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
463 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
464 | #endif | 464 | #endif |
465 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
466 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
480 | 480 | ||
481 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
482 | #if 0 | 482 | #if 0 |
483 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
484 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
485 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
486 | 486 | ||
487 | } else { | 487 | } else { |
488 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
489 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
490 | } | 490 | } |
491 | #endif | 491 | #endif |
492 | mFilterView->hide(); | 492 | mFilterView->hide(); |
493 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
494 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
495 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
497 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
498 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
499 | 499 | ||
500 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
501 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
506 | } else { | 506 | } else { |
507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
510 | } | 510 | } |
511 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
512 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
513 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
517 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
518 | 518 | ||
519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
521 | 521 | ||
522 | 522 | ||
523 | 523 | ||
524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
529 | 529 | ||
530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
531 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
532 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
533 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
535 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
537 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
538 | 538 | ||
539 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
540 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
541 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
542 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
545 | 545 | ||
546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
548 | #if 0 | 548 | #if 0 |
549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
550 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
551 | #endif | 551 | #endif |
552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
553 | 553 | ||
554 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
555 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
558 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
560 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
562 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
564 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
566 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
569 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
571 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
572 | 572 | ||
573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
576 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
577 | 577 | ||
578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
579 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
581 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
582 | 582 | ||
583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
584 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
585 | 585 | ||
586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
589 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
592 | 592 | ||
593 | 593 | ||
594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | 602 | ||
603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
604 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
606 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
608 | 608 | ||
609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
610 | 610 | ||
611 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
614 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
615 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
616 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
618 | 618 | ||
619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
620 | 620 | ||
621 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
622 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
623 | 623 | ||
624 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
625 | 625 | ||
626 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
627 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
628 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
632 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
634 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
636 | 636 | ||
637 | 637 | ||
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
642 | #endif | 642 | #endif |
643 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
648 | { | 648 | { |
649 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
650 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
651 | delete mDialogManager; | 651 | delete mDialogManager; |
652 | delete mViewManager; | 652 | delete mViewManager; |
653 | delete mStorage; | 653 | delete mStorage; |
654 | delete mDateFrame ; | 654 | delete mDateFrame ; |
655 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
656 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
657 | } | 657 | } |
658 | 658 | ||
659 | 659 | ||
660 | void CalendarView::nextConflict( bool all, bool allday ) | 660 | void CalendarView::nextConflict( bool all, bool allday ) |
661 | { | 661 | { |
662 | static bool block = false; | 662 | static bool block = false; |
663 | if ( block ) return; | 663 | if ( block ) return; |
664 | block = true; | 664 | block = true; |
665 | QPtrList<Event> testlist = mCalendar->events(); | 665 | QPtrList<Event> testlist = mCalendar->events(); |
666 | Event * test = testlist.first(); | 666 | Event * test = testlist.first(); |
667 | while ( test ) { | 667 | while ( test ) { |
668 | test->setTagged( false ); | 668 | test->setTagged( false ); |
669 | test = testlist.next(); | 669 | test = testlist.next(); |
670 | } | 670 | } |
671 | QTime st ( 0,0,0); | 671 | QTime st ( 0,0,0); |
672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
673 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 673 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
674 | //qDebug("time %s ", st.toString().latin1()); | 674 | //qDebug("time %s ", st.toString().latin1()); |
675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
676 | QDateTime conflict; | 676 | QDateTime conflict; |
677 | QDateTime retVal; | 677 | QDateTime retVal; |
678 | bool found = false; | 678 | bool found = false; |
679 | Event * cE = 0; | 679 | Event * cE = 0; |
680 | Event * cE2 = 0; | 680 | Event * cE2 = 0; |
681 | QPtrList<Event> testlist2 = testlist; | 681 | QPtrList<Event> testlist2 = testlist; |
682 | test = testlist.first(); | 682 | test = testlist.first(); |
683 | bool skip = false; | 683 | bool skip = false; |
684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
685 | //QTime tm; | 685 | //QTime tm; |
686 | //tm.start(); | 686 | //tm.start(); |
687 | while ( test ) { | 687 | while ( test ) { |
688 | qApp->processEvents(); | 688 | qApp->processEvents(); |
689 | skip = false; | 689 | skip = false; |
690 | if ( !all ) skip = ( allday != test->doesFloat() ); | 690 | if ( !all ) skip = ( allday != test->doesFloat() ); |
691 | if ( !skip ) { | 691 | if ( !skip ) { |
692 | if ( found ) | 692 | if ( found ) |
693 | skip = !test->matchTime( &startDT, &conflict ); | 693 | skip = !test->matchTime( &startDT, &conflict ); |
694 | else | 694 | else |
695 | skip = !test->matchTime( &startDT, 0 ); | 695 | skip = !test->matchTime( &startDT, 0 ); |
696 | } | 696 | } |
697 | if ( !skip ) { | 697 | if ( !skip ) { |
698 | Event * test2 = testlist2.first(); | 698 | Event * test2 = testlist2.first(); |
699 | while ( test2 ) { | 699 | while ( test2 ) { |
700 | skip = test2->isTagged(); | 700 | skip = test2->isTagged(); |
701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); | 701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); |
702 | if ( !skip ) { | 702 | if ( !skip ) { |
703 | if ( found ) | 703 | if ( found ) |
704 | skip = !test2->matchTime( &startDT, &conflict ); | 704 | skip = !test2->matchTime( &startDT, &conflict ); |
705 | else | 705 | else |
706 | skip = !test2->matchTime( &startDT, 0 ); | 706 | skip = !test2->matchTime( &startDT, 0 ); |
707 | } | 707 | } |
708 | if ( !skip ) { | 708 | if ( !skip ) { |
709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
710 | //qDebug("overlap "); | 710 | //qDebug("overlap "); |
711 | if ( ! found ) { | 711 | if ( ! found ) { |
712 | if ( retVal >= startDT ) { | 712 | if ( retVal >= startDT ) { |
713 | conflict = retVal; | 713 | conflict = retVal; |
714 | cE = test; | 714 | cE = test; |
715 | cE2 = test2; | 715 | cE2 = test2; |
716 | found = true; | 716 | found = true; |
717 | } | 717 | } |
718 | } else { | 718 | } else { |
719 | if ( retVal >= startDT && retVal < conflict ) { | 719 | if ( retVal >= startDT && retVal < conflict ) { |
720 | conflict = retVal; | 720 | conflict = retVal; |
721 | cE = test; | 721 | cE = test; |
722 | cE2 = test2; | 722 | cE2 = test2; |
723 | } | 723 | } |
724 | } | 724 | } |
725 | } | 725 | } |
726 | } | 726 | } |
727 | test2 = testlist2.next(); | 727 | test2 = testlist2.next(); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | test->setTagged( true ); | 730 | test->setTagged( true ); |
731 | test = testlist.next(); | 731 | test = testlist.next(); |
732 | } | 732 | } |
733 | //qDebug("Search time : %d", tm.elapsed()); | 733 | //qDebug("Search time : %d", tm.elapsed()); |
734 | if ( found ) { | 734 | if ( found ) { |
735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
736 | mViewManager->showDayView(); | 736 | mViewManager->showDayView(); |
737 | mNavigator->slotDaySelect( conflict.date() ); | 737 | mNavigator->slotDaySelect( conflict.date() ); |
738 | int hour = conflict.time().hour(); | 738 | int hour = conflict.time().hour(); |
739 | mViewManager->agendaView()->setStartHour( hour ); | 739 | mViewManager->agendaView()->setStartHour( hour ); |
740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
741 | block = false; | 741 | block = false; |
742 | return; | 742 | return; |
743 | } | 743 | } |
744 | 744 | ||
745 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 745 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
746 | //qDebug("No conflict found "); | 746 | //qDebug("No conflict found "); |
747 | block = false; | 747 | block = false; |
748 | return; | 748 | return; |
749 | } | 749 | } |
750 | 750 | ||
751 | void CalendarView::conflictAll() | 751 | void CalendarView::conflictAll() |
752 | { | 752 | { |
753 | nextConflict ( true, true ); | 753 | nextConflict ( true, true ); |
754 | } | 754 | } |
755 | void CalendarView::conflictAllday() | 755 | void CalendarView::conflictAllday() |
756 | { | 756 | { |
757 | nextConflict ( false, true ); | 757 | nextConflict ( false, true ); |
758 | } | 758 | } |
759 | void CalendarView::conflictNotAll() | 759 | void CalendarView::conflictNotAll() |
760 | { | 760 | { |
761 | nextConflict ( false, false ); | 761 | nextConflict ( false, false ); |
762 | } | 762 | } |
763 | 763 | ||
764 | void CalendarView::setCalReadOnly( int id, bool readO ) | 764 | void CalendarView::setCalReadOnly( int id, bool readO ) |
765 | { | 765 | { |
766 | if ( readO ) { | 766 | if ( readO ) { |
767 | emit save(); | 767 | emit save(); |
768 | } | 768 | } |
769 | mCalendar->setReadOnly( id, readO ); | 769 | mCalendar->setReadOnly( id, readO ); |
770 | } | 770 | } |
771 | void CalendarView::setScrollBarStep(int val ) | 771 | void CalendarView::setScrollBarStep(int val ) |
772 | { | 772 | { |
773 | #ifdef DESKTOP_VERSION | 773 | #ifdef DESKTOP_VERSION |
774 | mDateScrollBar->setLineStep ( val ); | 774 | mDateScrollBar->setLineStep ( val ); |
775 | #endif | 775 | #endif |
776 | } | 776 | } |
777 | void CalendarView::scrollBarValue(int val ) | 777 | void CalendarView::scrollBarValue(int val ) |
778 | { | 778 | { |
779 | #ifdef DESKTOP_VERSION | 779 | #ifdef DESKTOP_VERSION |
780 | if ( QApplication::desktop()->width() < 800 ) return; | 780 | if ( QApplication::desktop()->width() < 800 ) return; |
781 | static bool block = false; | 781 | static bool block = false; |
782 | if ( block ) return; | 782 | if ( block ) return; |
783 | block = true; | 783 | block = true; |
784 | int count = mNavigator->selectedDates().count(); | 784 | int count = mNavigator->selectedDates().count(); |
785 | int day = mNavigator->selectedDates().first().dayOfYear(); | 785 | int day = mNavigator->selectedDates().first().dayOfYear(); |
786 | int stepdays = val; | 786 | int stepdays = val; |
787 | if ( mDateScrollBar->lineStep () <= count ) { | 787 | if ( mDateScrollBar->lineStep () <= count ) { |
788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
789 | //qDebug("VAL %d ",val ); | 789 | //qDebug("VAL %d ",val ); |
790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
791 | stepdays = day+stepdays; | 791 | stepdays = day+stepdays; |
792 | if ( stepdays < 0 ) stepdays = 0; | 792 | if ( stepdays < 0 ) stepdays = 0; |
793 | } | 793 | } |
794 | if ( stepdays == day ) { | 794 | if ( stepdays == day ) { |
795 | block = false; | 795 | block = false; |
796 | return; | 796 | return; |
797 | } | 797 | } |
798 | int year = mNavigator->selectedDates().first().year(); | 798 | int year = mNavigator->selectedDates().first().year(); |
799 | QDate d ( year,1,1 ); | 799 | QDate d ( year,1,1 ); |
800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
801 | block = false; | 801 | block = false; |
802 | #endif | 802 | #endif |
803 | 803 | ||
804 | } | 804 | } |
805 | void CalendarView::updateView(const QDate &start, const QDate &end) | 805 | void CalendarView::updateView(const QDate &start, const QDate &end) |
806 | { | 806 | { |
807 | #ifdef DESKTOP_VERSION | 807 | #ifdef DESKTOP_VERSION |
808 | if ( ! mDateScrollBar->draggingSlider () ) { | 808 | if ( ! mDateScrollBar->draggingSlider () ) { |
809 | int dof = start.dayOfYear(); | 809 | int dof = start.dayOfYear(); |
810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
811 | if ( dof != mDateScrollBar->value() ) { | 811 | if ( dof != mDateScrollBar->value() ) { |
812 | mDateScrollBar->blockSignals( true ); | 812 | mDateScrollBar->blockSignals( true ); |
813 | mDateScrollBar->setValue( start.dayOfYear()); | 813 | mDateScrollBar->setValue( start.dayOfYear()); |
814 | mDateScrollBar->blockSignals( false ); | 814 | mDateScrollBar->blockSignals( false ); |
815 | } | 815 | } |
816 | } | 816 | } |
817 | #endif | 817 | #endif |
818 | mTodoList->updateView(); | 818 | mTodoList->updateView(); |
819 | mViewManager->updateView(start, end); | 819 | mViewManager->updateView(start, end); |
820 | //mDateNavigator->updateView(); | 820 | //mDateNavigator->updateView(); |
821 | } | 821 | } |
822 | 822 | ||
823 | 823 | ||
824 | 824 | ||
825 | void CalendarView::checkFiles() | 825 | void CalendarView::checkFiles() |
826 | { | 826 | { |
827 | QString message; | 827 | QString message; |
828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
829 | KopiCalendarFile * cal = calendars.first(); | 829 | KopiCalendarFile * cal = calendars.first(); |
830 | while ( cal ) { | 830 | while ( cal ) { |
831 | if ( cal->mErrorOnLoad ) { | 831 | if ( cal->mErrorOnLoad ) { |
832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
833 | } | 833 | } |
834 | cal = calendars.next(); | 834 | cal = calendars.next(); |
835 | } | 835 | } |
836 | if ( !message.isEmpty() ) { | 836 | if ( !message.isEmpty() ) { |
837 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); | 837 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
838 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 838 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
839 | } | 839 | } |
840 | static bool firstTime = true; | 840 | static bool firstTime = true; |
841 | if ( firstTime ) { | 841 | if ( firstTime ) { |
842 | firstTime = false; | 842 | firstTime = false; |
843 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 843 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
844 | } | 844 | } |
845 | } | 845 | } |
846 | void CalendarView::checkAlarms() | 846 | void CalendarView::checkAlarms() |
847 | { | 847 | { |
848 | 848 | ||
849 | 849 | ||
850 | KConfig *config = KOGlobals::config(); | 850 | KConfig *config = KOGlobals::config(); |
851 | config->setGroup( "AppRun" ); | 851 | config->setGroup( "AppRun" ); |
852 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 852 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
853 | int daysto = dt.daysTo( QDate::currentDate() ); | 853 | int daysto = dt.daysTo( QDate::currentDate() ); |
854 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 854 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
855 | dt = dt.addDays( days ); | 855 | dt = dt.addDays( days ); |
856 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 856 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
857 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 857 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
858 | //qDebug("KO: Reading program stop %d ", secs); | 858 | //qDebug("KO: Reading program stop %d ", secs); |
859 | //secs -= ( 3600 * 24*3 ); // debug only | 859 | //secs -= ( 3600 * 24*3 ); // debug only |
860 | QDateTime latest = dt.addSecs ( secs ); | 860 | QDateTime latest = dt.addSecs ( secs ); |
861 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 861 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
862 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 862 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
863 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 863 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
864 | QPtrList<Incidence> al; | 864 | QPtrList<Incidence> al; |
865 | Incidence* inL = el.first(); | 865 | Incidence* inL = el.first(); |
866 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 866 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
867 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 867 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
868 | while ( inL ) { | 868 | while ( inL ) { |
869 | bool ok = false; | 869 | bool ok = false; |
870 | int offset = 0; | 870 | int offset = 0; |
871 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 871 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
872 | if ( ok ) { | 872 | if ( ok ) { |
873 | //qDebug("OK %s",next.toString().latin1()); | 873 | //qDebug("OK %s",next.toString().latin1()); |
874 | if ( next < cur ) { | 874 | if ( next < cur ) { |
875 | al.append( inL ); | 875 | al.append( inL ); |
876 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 876 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
877 | } | 877 | } |
878 | } | 878 | } |
879 | inL = el.next(); | 879 | inL = el.next(); |
880 | } | 880 | } |
881 | if ( al.count() ) { | 881 | if ( al.count() ) { |
882 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 882 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
883 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 883 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
884 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 884 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
885 | lay->setSpacing( 0 ); | 885 | lay->setSpacing( 0 ); |
886 | lay->setMargin( 0 ); | 886 | lay->setMargin( 0 ); |
887 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 887 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
888 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 888 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
889 | lay->addWidget( matb ); | 889 | lay->addWidget( matb ); |
890 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 890 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
891 | int wid = 210; | 891 | int wid = 210; |
892 | int x = QApplication::desktop()->width() - wid - 7; | 892 | int x = QApplication::desktop()->width() - wid - 7; |
893 | int y = QApplication::desktop()->height() - wid - 70; | 893 | int y = QApplication::desktop()->height() - wid - 70; |
894 | dia->setGeometry ( x,y,wid,wid); | 894 | dia->setGeometry ( x,y,wid,wid); |
895 | } else { | 895 | } else { |
896 | int si = 220; | 896 | int si = 220; |
897 | if ( QApplication::desktop()->width() > 470 ) | 897 | if ( QApplication::desktop()->width() > 470 ) |
898 | si = 400; | 898 | si = 400; |
899 | dia->resize(si,si/2); | 899 | dia->resize(si,si/2); |
900 | } | 900 | } |
901 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 901 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
902 | dia->show(); | 902 | dia->show(); |
903 | 903 | ||
904 | } | 904 | } |
905 | } | 905 | } |
906 | void CalendarView::showDay( QDate d ) | 906 | void CalendarView::showDay( QDate d ) |
907 | { | 907 | { |
908 | dateNavigator()->blockSignals( true ); | 908 | dateNavigator()->blockSignals( true ); |
909 | dateNavigator()->selectDate( d ); | 909 | dateNavigator()->selectDate( d ); |
910 | dateNavigator()->blockSignals( false ); | 910 | dateNavigator()->blockSignals( false ); |
911 | mViewManager->showDayView(); | 911 | mViewManager->showDayView(); |
912 | //dateNavigator()->selectDate( d ); | 912 | //dateNavigator()->selectDate( d ); |
913 | } | 913 | } |
914 | void CalendarView::timerAlarm() | 914 | void CalendarView::timerAlarm() |
915 | { | 915 | { |
916 | //qDebug("CalendarView::timerAlarm() "); | 916 | //qDebug("CalendarView::timerAlarm() "); |
917 | computeAlarm(mAlarmNotification ); | 917 | computeAlarm(mAlarmNotification ); |
918 | } | 918 | } |
919 | 919 | ||
920 | void CalendarView::suspendAlarm() | 920 | void CalendarView::suspendAlarm() |
921 | { | 921 | { |
922 | //qDebug(" CalendarView::suspendAlarm() "); | 922 | //qDebug(" CalendarView::suspendAlarm() "); |
923 | computeAlarm(mSuspendAlarmNotification ); | 923 | computeAlarm(mSuspendAlarmNotification ); |
924 | 924 | ||
925 | } | 925 | } |
926 | 926 | ||
927 | void CalendarView::startAlarm( QString mess , QString filename) | 927 | void CalendarView::startAlarm( QString mess , QString filename) |
928 | { | 928 | { |
929 | 929 | ||
930 | topLevelWidget()->showNormal(); | 930 | topLevelWidget()->showNormal(); |
931 | topLevelWidget()->setActiveWindow(); | 931 | topLevelWidget()->setActiveWindow(); |
932 | topLevelWidget()->raise(); | 932 | topLevelWidget()->raise(); |
933 | 933 | ||
934 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 934 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
935 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 935 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
936 | 936 | ||
937 | } | 937 | } |
938 | 938 | ||
939 | void CalendarView::checkNextTimerAlarm() | 939 | void CalendarView::checkNextTimerAlarm() |
940 | { | 940 | { |
941 | mCalendar->checkAlarmForIncidence( 0, true ); | 941 | mCalendar->checkAlarmForIncidence( 0, true ); |
942 | } | 942 | } |
943 | 943 | ||
944 | void CalendarView::computeAlarm( QString msg ) | 944 | void CalendarView::computeAlarm( QString msg ) |
945 | { | 945 | { |
946 | 946 | ||
947 | QString mess = msg; | 947 | QString mess = msg; |
948 | QString mAlarmMessage = mess.mid( 9 ); | 948 | QString mAlarmMessage = mess.mid( 9 ); |
949 | QString filename = MainWindow::resourcePath(); | 949 | QString filename = MainWindow::resourcePath(); |
950 | filename += "koalarm.wav"; | 950 | filename += "koalarm.wav"; |
951 | QString tempfilename; | 951 | QString tempfilename; |
952 | if ( mess.left( 13 ) == "suspend_alarm") { | 952 | if ( mess.left( 13 ) == "suspend_alarm") { |
953 | bool error = false; | 953 | bool error = false; |
954 | int len = mess.mid( 13 ).find("+++"); | 954 | int len = mess.mid( 13 ).find("+++"); |
955 | if ( len < 2 ) | 955 | if ( len < 2 ) |
956 | error = true; | 956 | error = true; |
957 | else { | 957 | else { |
958 | tempfilename = mess.mid( 13, len ); | 958 | tempfilename = mess.mid( 13, len ); |
959 | if ( !QFile::exists( tempfilename ) ) | 959 | if ( !QFile::exists( tempfilename ) ) |
960 | error = true; | 960 | error = true; |
961 | } | 961 | } |
962 | if ( ! error ) { | 962 | if ( ! error ) { |
963 | filename = tempfilename; | 963 | filename = tempfilename; |
964 | } | 964 | } |
965 | mAlarmMessage = mess.mid( 13+len+3 ); | 965 | mAlarmMessage = mess.mid( 13+len+3 ); |
966 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 966 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
967 | startAlarm( mAlarmMessage, filename); | 967 | startAlarm( mAlarmMessage, filename); |
968 | return; | 968 | return; |
969 | } | 969 | } |
970 | if ( mess.left( 11 ) == "timer_alarm") { | 970 | if ( mess.left( 11 ) == "timer_alarm") { |
971 | //mTimerTime = 0; | 971 | //mTimerTime = 0; |
972 | startAlarm( mess.mid( 11 ), filename ); | 972 | startAlarm( mess.mid( 11 ), filename ); |
973 | return; | 973 | return; |
974 | } | 974 | } |
975 | if ( mess.left( 10 ) == "proc_alarm") { | 975 | if ( mess.left( 10 ) == "proc_alarm") { |
976 | bool error = false; | 976 | bool error = false; |
977 | int len = mess.mid( 10 ).find("+++"); | 977 | int len = mess.mid( 10 ).find("+++"); |
978 | if ( len < 2 ) | 978 | if ( len < 2 ) |
979 | error = true; | 979 | error = true; |
980 | else { | 980 | else { |
981 | tempfilename = mess.mid( 10, len ); | 981 | tempfilename = mess.mid( 10, len ); |
982 | if ( !QFile::exists( tempfilename ) ) | 982 | if ( !QFile::exists( tempfilename ) ) |
983 | error = true; | 983 | error = true; |
984 | } | 984 | } |
985 | if ( error ) { | 985 | if ( error ) { |
986 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 986 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
987 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 987 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
988 | } else { | 988 | } else { |
989 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 989 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
990 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 990 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
991 | #ifndef _WIN32_ | 991 | #ifndef _WIN32_ |
992 | if ( vfork () == 0 ) { | 992 | if ( vfork () == 0 ) { |
993 | execl ( tempfilename.latin1(), 0 ); | 993 | execl ( tempfilename.latin1(), 0 ); |
994 | return; | 994 | return; |
995 | } | 995 | } |
996 | #else | 996 | #else |
997 | QProcess* p = new QProcess(); | 997 | QProcess* p = new QProcess(); |
998 | p->addArgument( tempfilename.latin1() ); | 998 | p->addArgument( tempfilename.latin1() ); |
999 | p->start(); | 999 | p->start(); |
1000 | return; | 1000 | return; |
1001 | #endif | 1001 | #endif |
1002 | 1002 | ||
1003 | return; | 1003 | return; |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1006 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1007 | } | 1007 | } |
1008 | if ( mess.left( 11 ) == "audio_alarm") { | 1008 | if ( mess.left( 11 ) == "audio_alarm") { |
1009 | bool error = false; | 1009 | bool error = false; |
1010 | int len = mess.mid( 11 ).find("+++"); | 1010 | int len = mess.mid( 11 ).find("+++"); |
1011 | if ( len < 2 ) | 1011 | if ( len < 2 ) |
1012 | error = true; | 1012 | error = true; |
1013 | else { | 1013 | else { |
1014 | tempfilename = mess.mid( 11, len ); | 1014 | tempfilename = mess.mid( 11, len ); |
1015 | if ( !QFile::exists( tempfilename ) ) | 1015 | if ( !QFile::exists( tempfilename ) ) |
1016 | error = true; | 1016 | error = true; |
1017 | } | 1017 | } |
1018 | if ( ! error ) { | 1018 | if ( ! error ) { |
1019 | filename = tempfilename; | 1019 | filename = tempfilename; |
1020 | } | 1020 | } |
1021 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1021 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1022 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1022 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1023 | } | 1023 | } |
1024 | if ( mess.left( 9 ) == "cal_alarm") { | 1024 | if ( mess.left( 9 ) == "cal_alarm") { |
1025 | mAlarmMessage = mess.mid( 9 ) ; | 1025 | mAlarmMessage = mess.mid( 9 ) ; |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | startAlarm( mAlarmMessage, filename ); | 1028 | startAlarm( mAlarmMessage, filename ); |
1029 | 1029 | ||
1030 | 1030 | ||
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1033 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1034 | { | 1034 | { |
1035 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1035 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1036 | 1036 | ||
1037 | mSuspendAlarmNotification = noti; | 1037 | mSuspendAlarmNotification = noti; |
1038 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1038 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1039 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1039 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1040 | mSuspendTimer->start( ms , true ); | 1040 | mSuspendTimer->start( ms , true ); |
1041 | 1041 | ||
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1044 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1045 | { | 1045 | { |
1046 | mNextAlarmDateTime = qdt; | 1046 | mNextAlarmDateTime = qdt; |
1047 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1047 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1048 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1048 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1049 | #ifndef DESKTOP_VERSION | 1049 | #ifndef DESKTOP_VERSION |
1050 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1050 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1051 | #endif | 1051 | #endif |
1052 | return; | 1052 | return; |
1053 | } | 1053 | } |
1054 | int maxSec; | 1054 | int maxSec; |
1055 | //maxSec = 5; //testing only | 1055 | //maxSec = 5; //testing only |
1056 | maxSec = 86400+3600; // one day+1hour | 1056 | maxSec = 86400+3600; // one day+1hour |
1057 | mAlarmNotification = noti; | 1057 | mAlarmNotification = noti; |
1058 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1058 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1059 | if ( sec > maxSec ) { | 1059 | if ( sec > maxSec ) { |
1060 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1060 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1061 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1061 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1062 | return; | 1062 | return; |
1063 | } else { | 1063 | } else { |
1064 | mRecheckAlarmTimer->stop(); | 1064 | mRecheckAlarmTimer->stop(); |
1065 | } | 1065 | } |
1066 | //qDebug("Alarm timer started with secs: %d ", sec); | 1066 | //qDebug("Alarm timer started with secs: %d ", sec); |
1067 | mAlarmTimer->start( sec *1000 , true ); | 1067 | mAlarmTimer->start( sec *1000 , true ); |
1068 | 1068 | ||
1069 | } | 1069 | } |
1070 | // called by mRecheckAlarmTimer to get next alarm | 1070 | // called by mRecheckAlarmTimer to get next alarm |
1071 | // we need this, because a QTimer has only a max range of 25 days | 1071 | // we need this, because a QTimer has only a max range of 25 days |
1072 | void CalendarView::recheckTimerAlarm() | 1072 | void CalendarView::recheckTimerAlarm() |
1073 | { | 1073 | { |
1074 | mAlarmTimer->stop(); | 1074 | mAlarmTimer->stop(); |
1075 | mRecheckAlarmTimer->stop(); | 1075 | mRecheckAlarmTimer->stop(); |
1076 | mCalendar->checkAlarmForIncidence( 0, true ); | 1076 | mCalendar->checkAlarmForIncidence( 0, true ); |
1077 | } | 1077 | } |
1078 | #ifndef DESKTOP_VERSION | 1078 | #ifndef DESKTOP_VERSION |
1079 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1079 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1080 | #else | 1080 | #else |
1081 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1081 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1082 | #endif | 1082 | #endif |
1083 | { | 1083 | { |
1084 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1084 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1085 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1085 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1086 | #ifndef DESKTOP_VERSION | 1086 | #ifndef DESKTOP_VERSION |
1087 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1087 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1088 | #endif | 1088 | #endif |
1089 | return; | 1089 | return; |
1090 | } | 1090 | } |
1091 | mAlarmTimer->stop(); | 1091 | mAlarmTimer->stop(); |
1092 | } | 1092 | } |
1093 | void CalendarView::selectWeekNum ( int num ) | 1093 | void CalendarView::selectWeekNum ( int num ) |
1094 | { | 1094 | { |
1095 | dateNavigator()->blockSignals( true ); | 1095 | dateNavigator()->blockSignals( true ); |
1096 | dateNavigator()->selectWeek( num ); | 1096 | dateNavigator()->selectWeek( num ); |
1097 | dateNavigator()->blockSignals( false ); | 1097 | dateNavigator()->blockSignals( false ); |
1098 | mViewManager->showWeekView(); | 1098 | mViewManager->showWeekView(); |
1099 | } | 1099 | } |
1100 | KOViewManager *CalendarView::viewManager() | 1100 | KOViewManager *CalendarView::viewManager() |
1101 | { | 1101 | { |
1102 | return mViewManager; | 1102 | return mViewManager; |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | KODialogManager *CalendarView::dialogManager() | 1105 | KODialogManager *CalendarView::dialogManager() |
1106 | { | 1106 | { |
1107 | return mDialogManager; | 1107 | return mDialogManager; |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | QDate CalendarView::startDate() | 1110 | QDate CalendarView::startDate() |
1111 | { | 1111 | { |
1112 | DateList dates = mNavigator->selectedDates(); | 1112 | DateList dates = mNavigator->selectedDates(); |
1113 | 1113 | ||
1114 | return dates.first(); | 1114 | return dates.first(); |
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | QDate CalendarView::endDate() | 1117 | QDate CalendarView::endDate() |
1118 | { | 1118 | { |
1119 | DateList dates = mNavigator->selectedDates(); | 1119 | DateList dates = mNavigator->selectedDates(); |
1120 | 1120 | ||
1121 | return dates.last(); | 1121 | return dates.last(); |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | 1124 | ||
1125 | void CalendarView::createPrinter() | 1125 | void CalendarView::createPrinter() |
1126 | { | 1126 | { |
1127 | #ifndef KORG_NOPRINTER | 1127 | #ifndef KORG_NOPRINTER |
1128 | if (!mCalPrinter) { | 1128 | if (!mCalPrinter) { |
1129 | mCalPrinter = new CalPrinter(this, mCalendar); | 1129 | mCalPrinter = new CalPrinter(this, mCalendar); |
1130 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1130 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1131 | } | 1131 | } |
1132 | #endif | 1132 | #endif |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | 1135 | ||
1136 | //KOPrefs::instance()->mWriteBackFile | 1136 | //KOPrefs::instance()->mWriteBackFile |
1137 | //KOPrefs::instance()->mWriteBackExistingOnly | 1137 | //KOPrefs::instance()->mWriteBackExistingOnly |
1138 | 1138 | ||
1139 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1139 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1140 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1140 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1141 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1141 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1142 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1142 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1143 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1143 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1144 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1144 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1145 | 1145 | ||
1146 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1146 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1147 | { | 1147 | { |
1148 | 1148 | ||
1149 | // 0 equal | 1149 | // 0 equal |
1150 | // 1 take local | 1150 | // 1 take local |
1151 | // 2 take remote | 1151 | // 2 take remote |
1152 | // 3 cancel | 1152 | // 3 cancel |
1153 | QDateTime lastSync = mLastCalendarSync; | 1153 | QDateTime lastSync = mLastCalendarSync; |
1154 | QDateTime localMod = local->lastModified(); | 1154 | QDateTime localMod = local->lastModified(); |
1155 | QDateTime remoteMod = remote->lastModified(); | 1155 | QDateTime remoteMod = remote->lastModified(); |
1156 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1156 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1157 | bool remCh, locCh; | 1157 | bool remCh, locCh; |
1158 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1158 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1159 | //if ( remCh ) | 1159 | //if ( remCh ) |
1160 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1160 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1161 | locCh = ( localMod > mLastCalendarSync ); | 1161 | locCh = ( localMod > mLastCalendarSync ); |
1162 | if ( !remCh && ! locCh ) { | 1162 | if ( !remCh && ! locCh ) { |
1163 | //qDebug("both not changed "); | 1163 | //qDebug("both not changed "); |
1164 | lastSync = localMod.addDays(1); | 1164 | lastSync = localMod.addDays(1); |
1165 | if ( mode <= SYNC_PREF_ASK ) | 1165 | if ( mode <= SYNC_PREF_ASK ) |
1166 | return 0; | 1166 | return 0; |
1167 | } else { | 1167 | } else { |
1168 | if ( locCh ) { | 1168 | if ( locCh ) { |
1169 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1169 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1170 | lastSync = localMod.addDays( -1 ); | 1170 | lastSync = localMod.addDays( -1 ); |
1171 | if ( !remCh ) | 1171 | if ( !remCh ) |
1172 | remoteMod = ( lastSync.addDays( -1 ) ); | 1172 | remoteMod = ( lastSync.addDays( -1 ) ); |
1173 | } else { | 1173 | } else { |
1174 | //qDebug(" not loc changed "); | 1174 | //qDebug(" not loc changed "); |
1175 | lastSync = localMod.addDays( 1 ); | 1175 | lastSync = localMod.addDays( 1 ); |
1176 | if ( remCh ) | 1176 | if ( remCh ) |
1177 | remoteMod =( lastSync.addDays( 1 ) ); | 1177 | remoteMod =( lastSync.addDays( 1 ) ); |
1178 | 1178 | ||
1179 | } | 1179 | } |
1180 | } | 1180 | } |
1181 | full = true; | 1181 | full = true; |
1182 | if ( mode < SYNC_PREF_ASK ) | 1182 | if ( mode < SYNC_PREF_ASK ) |
1183 | mode = SYNC_PREF_ASK; | 1183 | mode = SYNC_PREF_ASK; |
1184 | } else { | 1184 | } else { |
1185 | if ( localMod == remoteMod ) | 1185 | if ( localMod == remoteMod ) |
1186 | // if ( local->revision() == remote->revision() ) | 1186 | // if ( local->revision() == remote->revision() ) |
1187 | return 0; | 1187 | return 0; |
1188 | 1188 | ||
1189 | } | 1189 | } |
1190 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1190 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1191 | 1191 | ||
1192 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1192 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1193 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1193 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1194 | //full = true; //debug only | 1194 | //full = true; //debug only |
1195 | if ( full ) { | 1195 | if ( full ) { |
1196 | bool equ = false; | 1196 | bool equ = false; |
1197 | if ( local->typeID() == eventID ) { | 1197 | if ( local->typeID() == eventID ) { |
1198 | equ = (*((Event*) local) == *((Event*) remote)); | 1198 | equ = (*((Event*) local) == *((Event*) remote)); |
1199 | } | 1199 | } |
1200 | else if ( local->typeID() == todoID ) | 1200 | else if ( local->typeID() == todoID ) |
1201 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1201 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1202 | else if ( local->typeID() == journalID ) | 1202 | else if ( local->typeID() == journalID ) |
1203 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1203 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1204 | if ( equ ) { | 1204 | if ( equ ) { |
1205 | //qDebug("equal "); | 1205 | //qDebug("equal "); |
1206 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1206 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1207 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1207 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1208 | } | 1208 | } |
1209 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1209 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1210 | return 0; | 1210 | return 0; |
1211 | 1211 | ||
1212 | }//else //debug only | 1212 | }//else //debug only |
1213 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1213 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1214 | } | 1214 | } |
1215 | int result; | 1215 | int result; |
1216 | bool localIsNew; | 1216 | bool localIsNew; |
1217 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 1217 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
1218 | 1218 | ||
1219 | 1219 | ||
1220 | // ************************************************ | 1220 | // ************************************************ |
1221 | // ************************************************ | 1221 | // ************************************************ |
1222 | // ************************************************ | 1222 | // ************************************************ |
1223 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1223 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1224 | // BUT remoteMod != localMod | 1224 | // BUT remoteMod != localMod |
1225 | 1225 | ||
1226 | 1226 | ||
1227 | if ( full && mode < SYNC_PREF_NEWEST ) | 1227 | if ( full && mode < SYNC_PREF_NEWEST ) |
1228 | mode = SYNC_PREF_ASK; | 1228 | mode = SYNC_PREF_ASK; |
1229 | 1229 | ||
1230 | switch( mode ) { | 1230 | switch( mode ) { |
1231 | case SYNC_PREF_LOCAL: | 1231 | case SYNC_PREF_LOCAL: |
1232 | if ( lastSync > remoteMod ) | 1232 | if ( lastSync > remoteMod ) |
1233 | return 1; | 1233 | return 1; |
1234 | if ( lastSync > localMod ) | 1234 | if ( lastSync > localMod ) |
1235 | return 2; | 1235 | return 2; |
1236 | return 1; | 1236 | return 1; |
1237 | break; | 1237 | break; |
1238 | case SYNC_PREF_REMOTE: | 1238 | case SYNC_PREF_REMOTE: |
1239 | if ( lastSync > localMod ) | 1239 | if ( lastSync > localMod ) |
1240 | return 2; | 1240 | return 2; |
1241 | if ( lastSync > remoteMod ) | 1241 | if ( lastSync > remoteMod ) |
1242 | return 1; | 1242 | return 1; |
1243 | return 2; | 1243 | return 2; |
1244 | break; | 1244 | break; |
1245 | case SYNC_PREF_NEWEST: | 1245 | case SYNC_PREF_NEWEST: |
1246 | if ( localMod >= remoteMod ) | 1246 | if ( localMod >= remoteMod ) |
1247 | return 1; | 1247 | return 1; |
1248 | else | 1248 | else |
1249 | return 2; | 1249 | return 2; |
1250 | break; | 1250 | break; |
1251 | case SYNC_PREF_ASK: | 1251 | case SYNC_PREF_ASK: |
1252 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1252 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1253 | if ( lastSync > remoteMod && lastSync > localMod) | 1253 | if ( lastSync > remoteMod && lastSync > localMod) |
1254 | return 0; | 1254 | return 0; |
1255 | if ( lastSync > remoteMod ) | 1255 | if ( lastSync > remoteMod ) |
1256 | return 1; | 1256 | return 1; |
1257 | if ( lastSync > localMod ) | 1257 | if ( lastSync > localMod ) |
1258 | return 2; | 1258 | return 2; |
1259 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1259 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1260 | localIsNew = localMod >= remoteMod; | 1260 | localIsNew = localMod >= remoteMod; |
1261 | if ( localIsNew ) | 1261 | if ( localIsNew ) |
1262 | getEventViewerDialog()->setColorMode( 1 ); | 1262 | getEventViewerDialog()->setColorMode( 1 ); |
1263 | else | 1263 | else |
1264 | getEventViewerDialog()->setColorMode( 2 ); | 1264 | getEventViewerDialog()->setColorMode( 2 ); |
1265 | getEventViewerDialog()->setIncidence(local); | 1265 | getEventViewerDialog()->setIncidence(local); |
1266 | if ( localIsNew ) | 1266 | if ( localIsNew ) |
1267 | getEventViewerDialog()->setColorMode( 2 ); | 1267 | getEventViewerDialog()->setColorMode( 2 ); |
1268 | else | 1268 | else |
1269 | getEventViewerDialog()->setColorMode( 1 ); | 1269 | getEventViewerDialog()->setColorMode( 1 ); |
1270 | getEventViewerDialog()->addIncidence(remote); | 1270 | getEventViewerDialog()->addIncidence(remote); |
1271 | getEventViewerDialog()->setColorMode( 0 ); | 1271 | getEventViewerDialog()->setColorMode( 0 ); |
1272 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1272 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1273 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1273 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1274 | getEventViewerDialog()->showMe(); | 1274 | getEventViewerDialog()->showMe(); |
1275 | result = getEventViewerDialog()->executeS( localIsNew ); | 1275 | result = getEventViewerDialog()->executeS( localIsNew ); |
1276 | return result; | 1276 | return result; |
1277 | 1277 | ||
1278 | break; | 1278 | break; |
1279 | case SYNC_PREF_FORCE_LOCAL: | 1279 | case SYNC_PREF_FORCE_LOCAL: |
1280 | return 1; | 1280 | return 1; |
1281 | break; | 1281 | break; |
1282 | case SYNC_PREF_FORCE_REMOTE: | 1282 | case SYNC_PREF_FORCE_REMOTE: |
1283 | return 2; | 1283 | return 2; |
1284 | break; | 1284 | break; |
1285 | 1285 | ||
1286 | default: | 1286 | default: |
1287 | // SYNC_PREF_TAKE_BOTH not implemented | 1287 | // SYNC_PREF_TAKE_BOTH not implemented |
1288 | break; | 1288 | break; |
1289 | } | 1289 | } |
1290 | return 0; | 1290 | return 0; |
1291 | } | 1291 | } |
1292 | Event* CalendarView::getLastSyncEvent() | 1292 | Event* CalendarView::getLastSyncEvent() |
1293 | { | 1293 | { |
1294 | Event* lse; | 1294 | Event* lse; |
1295 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1295 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1296 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1296 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1297 | if (!lse) { | 1297 | if (!lse) { |
1298 | lse = new Event(); | 1298 | lse = new Event(); |
1299 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1299 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1300 | QString sum = ""; | 1300 | QString sum = ""; |
1301 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1301 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1302 | sum = "E: "; | 1302 | sum = "E: "; |
1303 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1303 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1304 | lse->setDtStart( mLastCalendarSync ); | 1304 | lse->setDtStart( mLastCalendarSync ); |
1305 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1305 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1306 | lse->setCategories( i18n("SyncEvent") ); | 1306 | lse->setCategories( i18n("SyncEvent") ); |
1307 | lse->setReadOnly( true ); | 1307 | lse->setReadOnly( true ); |
1308 | mCalendar->addEvent( lse ); | 1308 | mCalendar->addEvent( lse ); |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | return lse; | 1311 | return lse; |
1312 | 1312 | ||
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | // we check, if the to delete event has a id for a profile | 1315 | // we check, if the to delete event has a id for a profile |
1316 | // if yes, we set this id in the profile to delete | 1316 | // if yes, we set this id in the profile to delete |
1317 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1317 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1318 | { | 1318 | { |
1319 | if ( lastSync.count() == 0 ) { | 1319 | if ( lastSync.count() == 0 ) { |
1320 | //qDebug(" lastSync.count() == 0"); | 1320 | //qDebug(" lastSync.count() == 0"); |
1321 | return; | 1321 | return; |
1322 | } | 1322 | } |
1323 | if ( toDelete->typeID() == journalID ) | 1323 | if ( toDelete->typeID() == journalID ) |
1324 | return; | 1324 | return; |
1325 | 1325 | ||
1326 | Event* eve = lastSync.first(); | 1326 | Event* eve = lastSync.first(); |
1327 | 1327 | ||
1328 | while ( eve ) { | 1328 | while ( eve ) { |
1329 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1329 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1330 | if ( !id.isEmpty() ) { | 1330 | if ( !id.isEmpty() ) { |
1331 | QString des = eve->description(); | 1331 | QString des = eve->description(); |
1332 | QString pref = "e"; | 1332 | QString pref = "e"; |
1333 | if ( toDelete->typeID() == todoID ) | 1333 | if ( toDelete->typeID() == todoID ) |
1334 | pref = "t"; | 1334 | pref = "t"; |
1335 | des += pref+ id + ","; | 1335 | des += pref+ id + ","; |
1336 | eve->setReadOnly( false ); | 1336 | eve->setReadOnly( false ); |
1337 | eve->setDescription( des ); | 1337 | eve->setDescription( des ); |
1338 | //qDebug("setdes %s ", des.latin1()); | 1338 | //qDebug("setdes %s ", des.latin1()); |
1339 | eve->setReadOnly( true ); | 1339 | eve->setReadOnly( true ); |
1340 | } | 1340 | } |
1341 | eve = lastSync.next(); | 1341 | eve = lastSync.next(); |
1342 | } | 1342 | } |
1343 | 1343 | ||
1344 | } | 1344 | } |
1345 | void CalendarView::checkExternalId( Incidence * inc ) | 1345 | void CalendarView::checkExternalId( Incidence * inc ) |
1346 | { | 1346 | { |
1347 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1347 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1348 | checkExternSyncEvent( lastSync, inc ); | 1348 | checkExternSyncEvent( lastSync, inc ); |
1349 | 1349 | ||
1350 | } | 1350 | } |
1351 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1351 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1352 | { | 1352 | { |
1353 | bool syncOK = true; | 1353 | bool syncOK = true; |
1354 | int addedEvent = 0; | 1354 | int addedEvent = 0; |
1355 | int addedEventR = 0; | 1355 | int addedEventR = 0; |
1356 | int deletedEventR = 0; | 1356 | int deletedEventR = 0; |
1357 | int deletedEventL = 0; | 1357 | int deletedEventL = 0; |
1358 | int changedLocal = 0; | 1358 | int changedLocal = 0; |
1359 | int changedRemote = 0; | 1359 | int changedRemote = 0; |
1360 | int filteredIN = 0; | 1360 | int filteredIN = 0; |
1361 | int filteredOUT = 0; | 1361 | int filteredOUT = 0; |
1362 | //QPtrList<Event> el = local->rawEvents(); | 1362 | //QPtrList<Event> el = local->rawEvents(); |
1363 | Event* eventR; | 1363 | Event* eventR; |
1364 | QString uid; | 1364 | QString uid; |
1365 | int take; | 1365 | int take; |
1366 | Event* eventRSync; | 1366 | Event* eventRSync; |
1367 | Event* eventLSync; | 1367 | Event* eventLSync; |
1368 | clearAllViews(); | 1368 | clearAllViews(); |
1369 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1369 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1370 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1370 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1371 | bool fullDateRange = false; | 1371 | bool fullDateRange = false; |
1372 | local->resetTempSyncStat(); | 1372 | local->resetTempSyncStat(); |
1373 | mLastCalendarSync = QDateTime::currentDateTime(); | 1373 | mLastCalendarSync = QDateTime::currentDateTime(); |
1374 | if ( mSyncManager->syncWithDesktop() ) { | 1374 | if ( mSyncManager->syncWithDesktop() ) { |
1375 | remote->resetPilotStat(1); | 1375 | remote->resetPilotStat(1); |
1376 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1376 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1377 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1377 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1378 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1378 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1379 | } else { | 1379 | } else { |
1380 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1380 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1381 | } | 1381 | } |
1382 | } | 1382 | } |
1383 | QDateTime modifiedCalendar = mLastCalendarSync; | 1383 | QDateTime modifiedCalendar = mLastCalendarSync; |
1384 | eventLSync = getLastSyncEvent(); | 1384 | eventLSync = getLastSyncEvent(); |
1385 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1385 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1386 | if ( eventR ) { | 1386 | if ( eventR ) { |
1387 | qDebug("last-syncEvent on remote found "); | 1387 | qDebug("last-syncEvent on remote found "); |
1388 | eventRSync = (Event*) eventR->clone(); | 1388 | eventRSync = (Event*) eventR->clone(); |
1389 | remote->deleteEvent(eventR ); | 1389 | remote->deleteEvent(eventR ); |
1390 | 1390 | ||
1391 | } else { | 1391 | } else { |
1392 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1392 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1393 | eventRSync = (Event*)eventLSync->clone(); | 1393 | eventRSync = (Event*)eventLSync->clone(); |
1394 | } else { | 1394 | } else { |
1395 | fullDateRange = true; | 1395 | fullDateRange = true; |
1396 | eventRSync = new Event(); | 1396 | eventRSync = new Event(); |
1397 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1397 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1398 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1398 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1399 | eventRSync->setDtStart( mLastCalendarSync ); | 1399 | eventRSync->setDtStart( mLastCalendarSync ); |
1400 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1400 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1401 | eventRSync->setCategories( i18n("SyncEvent") ); | 1401 | eventRSync->setCategories( i18n("SyncEvent") ); |
1402 | } | 1402 | } |
1403 | } | 1403 | } |
1404 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1404 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1405 | fullDateRange = true; | 1405 | fullDateRange = true; |
1406 | 1406 | ||
1407 | if ( ! fullDateRange ) { | 1407 | if ( ! fullDateRange ) { |
1408 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1408 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1409 | 1409 | ||
1410 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1410 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1411 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1411 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1412 | fullDateRange = true; | 1412 | fullDateRange = true; |
1413 | } | 1413 | } |
1414 | } | 1414 | } |
1415 | if ( mSyncManager->syncWithDesktop() ) { | 1415 | if ( mSyncManager->syncWithDesktop() ) { |
1416 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1416 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1417 | } | 1417 | } |
1418 | if ( fullDateRange ) | 1418 | if ( fullDateRange ) |
1419 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1419 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1420 | else | 1420 | else |
1421 | mLastCalendarSync = eventLSync->dtStart(); | 1421 | mLastCalendarSync = eventLSync->dtStart(); |
1422 | // for resyncing if own file has changed | 1422 | // for resyncing if own file has changed |
1423 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1423 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1424 | mLastCalendarSync = loadedFileVersion; | 1424 | mLastCalendarSync = loadedFileVersion; |
1425 | //qDebug("setting mLastCalendarSync "); | 1425 | //qDebug("setting mLastCalendarSync "); |
1426 | } | 1426 | } |
1427 | //qDebug("*************************** "); | 1427 | //qDebug("*************************** "); |
1428 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1428 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1429 | QPtrList<Incidence> er = remote->rawIncidences(); | 1429 | QPtrList<Incidence> er = remote->rawIncidences(); |
1430 | Incidence* inR = er.first(); | 1430 | Incidence* inR = er.first(); |
1431 | Incidence* inL; | 1431 | Incidence* inL; |
1432 | QProgressBar bar( er.count(),0 ); | 1432 | QProgressBar bar( er.count(),0 ); |
1433 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1433 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1434 | 1434 | ||
1435 | // ************** setting up filter ************* | 1435 | // ************** setting up filter ************* |
1436 | CalFilter *filterIN = 0; | 1436 | CalFilter *filterIN = 0; |
1437 | CalFilter *filterOUT = 0; | 1437 | CalFilter *filterOUT = 0; |
1438 | CalFilter *filter = mFilters.first(); | 1438 | CalFilter *filter = mFilters.first(); |
1439 | while(filter) { | 1439 | while(filter) { |
1440 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1440 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1441 | filterIN = filter; | 1441 | filterIN = filter; |
1442 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1442 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1443 | filterOUT = filter; | 1443 | filterOUT = filter; |
1444 | filter = mFilters.next(); | 1444 | filter = mFilters.next(); |
1445 | } | 1445 | } |
1446 | int w = 300; | 1446 | int w = 300; |
1447 | if ( QApplication::desktop()->width() < 320 ) | 1447 | if ( QApplication::desktop()->width() < 320 ) |
1448 | w = 220; | 1448 | w = 220; |
1449 | int h = bar.sizeHint().height() ; | 1449 | int h = bar.sizeHint().height() ; |
1450 | int dw = QApplication::desktop()->width(); | 1450 | int dw = QApplication::desktop()->width(); |
1451 | int dh = QApplication::desktop()->height(); | 1451 | int dh = QApplication::desktop()->height(); |
1452 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1452 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1453 | bar.show(); | 1453 | bar.show(); |
1454 | int modulo = (er.count()/10)+1; | 1454 | int modulo = (er.count()/10)+1; |
1455 | int incCounter = 0; | 1455 | int incCounter = 0; |
1456 | while ( inR ) { | 1456 | while ( inR ) { |
1457 | if ( ! bar.isVisible() ) | 1457 | if ( ! bar.isVisible() ) |
1458 | return false; | 1458 | return false; |
1459 | if ( incCounter % modulo == 0 ) | 1459 | if ( incCounter % modulo == 0 ) |
1460 | bar.setProgress( incCounter ); | 1460 | bar.setProgress( incCounter ); |
1461 | ++incCounter; | 1461 | ++incCounter; |
1462 | uid = inR->uid(); | 1462 | uid = inR->uid(); |
1463 | bool skipIncidence = false; | 1463 | bool skipIncidence = false; |
1464 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1464 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1465 | skipIncidence = true; | 1465 | skipIncidence = true; |
1466 | QString idS; | 1466 | QString idS; |
1467 | qApp->processEvents(); | 1467 | qApp->processEvents(); |
1468 | if ( !skipIncidence ) { | 1468 | if ( !skipIncidence ) { |
1469 | inL = local->incidenceForUid( uid , false ); | 1469 | inL = local->incidenceForUid( uid , false ); |
1470 | if ( inL ) { // maybe conflict - same uid in both calendars | 1470 | if ( inL ) { // maybe conflict - same uid in both calendars |
1471 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1471 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1472 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1472 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1473 | if ( take == 3 ) | 1473 | if ( take == 3 ) |
1474 | return false; | 1474 | return false; |
1475 | if ( take == 1 ) {// take local ********************** | 1475 | if ( take == 1 ) {// take local ********************** |
1476 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1476 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1477 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1477 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1478 | else | 1478 | else |
1479 | idS = inR->IDStr(); | 1479 | idS = inR->IDStr(); |
1480 | int calID = inR->calID(); | 1480 | int calID = inR->calID(); |
1481 | remote->deleteIncidence( inR ); | 1481 | remote->deleteIncidence( inR ); |
1482 | inR = inL->clone(); | 1482 | inR = inL->clone(); |
1483 | inR->setCalID( calID ); | 1483 | inR->setCalID( calID ); |
1484 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1484 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1485 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1485 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1486 | inR->setIDStr( idS ); | 1486 | inR->setIDStr( idS ); |
1487 | remote->addIncidence( inR ); | 1487 | remote->addIncidence( inR ); |
1488 | if ( mSyncManager->syncWithDesktop() ) | 1488 | if ( mSyncManager->syncWithDesktop() ) |
1489 | inR->setPilotId( 2 ); | 1489 | inR->setPilotId( 2 ); |
1490 | ++changedRemote; | 1490 | ++changedRemote; |
1491 | } else {// take remote ********************** | 1491 | } else {// take remote ********************** |
1492 | if ( !inL->isReadOnly() ) { | 1492 | if ( !inL->isReadOnly() ) { |
1493 | idS = inL->IDStr(); | 1493 | idS = inL->IDStr(); |
1494 | int pid = inL->pilotId(); | 1494 | int pid = inL->pilotId(); |
1495 | int calID = inL->calID(); | 1495 | int calID = inL->calID(); |
1496 | local->deleteIncidence( inL ); | 1496 | local->deleteIncidence( inL ); |
1497 | inL = inR->clone(); | 1497 | inL = inR->clone(); |
1498 | inL->setCalID( calID ); | 1498 | inL->setCalID( calID ); |
1499 | if ( mSyncManager->syncWithDesktop() ) | 1499 | if ( mSyncManager->syncWithDesktop() ) |
1500 | inL->setPilotId( pid ); | 1500 | inL->setPilotId( pid ); |
1501 | inL->setIDStr( idS ); | 1501 | inL->setIDStr( idS ); |
1502 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1502 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1503 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1503 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1504 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1504 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1505 | } | 1505 | } |
1506 | local->addIncidence( inL ); | 1506 | local->addIncidence( inL ); |
1507 | ++changedLocal; | 1507 | ++changedLocal; |
1508 | } | 1508 | } |
1509 | } | 1509 | } |
1510 | } | 1510 | } |
1511 | } else { // no conflict ********** add or delete remote | 1511 | } else { // no conflict ********** add or delete remote |
1512 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1512 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1513 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1513 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1514 | QString des = eventLSync->description(); | 1514 | QString des = eventLSync->description(); |
1515 | QString pref = "e"; | 1515 | QString pref = "e"; |
1516 | if ( inR->typeID() == todoID ) | 1516 | if ( inR->typeID() == todoID ) |
1517 | pref = "t"; | 1517 | pref = "t"; |
1518 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1518 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1519 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1519 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1520 | //remote->deleteIncidence( inR ); | 1520 | //remote->deleteIncidence( inR ); |
1521 | ++deletedEventR; | 1521 | ++deletedEventR; |
1522 | } else { | 1522 | } else { |
1523 | inR->setLastModified( modifiedCalendar ); | 1523 | inR->setLastModified( modifiedCalendar ); |
1524 | inL = inR->clone(); | 1524 | inL = inR->clone(); |
1525 | inL->setIDStr( ":" ); | 1525 | inL->setIDStr( ":" ); |
1526 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1526 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1527 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1527 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1528 | 1528 | ||
1529 | inL->setCalID( 0 );// add to default cal | 1529 | inL->setCalID( 0 );// add to default cal |
1530 | local->addIncidence( inL ); | 1530 | local->addIncidence( inL ); |
1531 | ++addedEvent; | 1531 | ++addedEvent; |
1532 | 1532 | ||
1533 | } | 1533 | } |
1534 | } else { | 1534 | } else { |
1535 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1535 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1536 | inR->setLastModified( modifiedCalendar ); | 1536 | inR->setLastModified( modifiedCalendar ); |
1537 | inL = inR->clone(); | 1537 | inL = inR->clone(); |
1538 | inL->setIDStr( ":" ); | 1538 | inL->setIDStr( ":" ); |
1539 | inL->setCalID( 0 );// add to default cal | 1539 | inL->setCalID( 0 );// add to default cal |
1540 | local->addIncidence( inL ); | 1540 | local->addIncidence( inL ); |
1541 | ++addedEvent; | 1541 | ++addedEvent; |
1542 | 1542 | ||
1543 | } else { | 1543 | } else { |
1544 | checkExternSyncEvent(eventRSyncSharp, inR); | 1544 | checkExternSyncEvent(eventRSyncSharp, inR); |
1545 | remote->deleteIncidence( inR ); | 1545 | remote->deleteIncidence( inR ); |
1546 | ++deletedEventR; | 1546 | ++deletedEventR; |
1547 | } | 1547 | } |
1548 | } | 1548 | } |
1549 | } else { | 1549 | } else { |
1550 | ++filteredIN; | 1550 | ++filteredIN; |
1551 | } | 1551 | } |
1552 | } | 1552 | } |
1553 | } | 1553 | } |
1554 | inR = er.next(); | 1554 | inR = er.next(); |
1555 | } | 1555 | } |
1556 | QPtrList<Incidence> el = local->rawIncidences(); | 1556 | QPtrList<Incidence> el = local->rawIncidences(); |
1557 | inL = el.first(); | 1557 | inL = el.first(); |
1558 | modulo = (el.count()/10)+1; | 1558 | modulo = (el.count()/10)+1; |
1559 | bar.setCaption (i18n("Add / remove events") ); | 1559 | bar.setCaption (i18n("Add / remove events") ); |
1560 | bar.setTotalSteps ( el.count() ) ; | 1560 | bar.setTotalSteps ( el.count() ) ; |
1561 | bar.show(); | 1561 | bar.show(); |
1562 | incCounter = 0; | 1562 | incCounter = 0; |
1563 | 1563 | ||
1564 | while ( inL ) { | 1564 | while ( inL ) { |
1565 | 1565 | ||
1566 | qApp->processEvents(); | 1566 | qApp->processEvents(); |
1567 | if ( ! bar.isVisible() ) | 1567 | if ( ! bar.isVisible() ) |
1568 | return false; | 1568 | return false; |
1569 | if ( incCounter % modulo == 0 ) | 1569 | if ( incCounter % modulo == 0 ) |
1570 | bar.setProgress( incCounter ); | 1570 | bar.setProgress( incCounter ); |
1571 | ++incCounter; | 1571 | ++incCounter; |
1572 | uid = inL->uid(); | 1572 | uid = inL->uid(); |
1573 | bool skipIncidence = false; | 1573 | bool skipIncidence = false; |
1574 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1574 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1575 | skipIncidence = true; | 1575 | skipIncidence = true; |
1576 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1576 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1577 | skipIncidence = true; | 1577 | skipIncidence = true; |
1578 | if ( !skipIncidence ) { | 1578 | if ( !skipIncidence ) { |
1579 | inR = remote->incidenceForUid( uid , true ); | 1579 | inR = remote->incidenceForUid( uid , true ); |
1580 | if ( ! inR ) { | 1580 | if ( ! inR ) { |
1581 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1581 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1582 | // no conflict ********** add or delete local | 1582 | // no conflict ********** add or delete local |
1583 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1583 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1584 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1584 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1585 | checkExternSyncEvent(eventLSyncSharp, inL); | 1585 | checkExternSyncEvent(eventLSyncSharp, inL); |
1586 | local->deleteIncidence( inL ); | 1586 | local->deleteIncidence( inL ); |
1587 | ++deletedEventL; | 1587 | ++deletedEventL; |
1588 | } else { | 1588 | } else { |
1589 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1589 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1590 | inL->removeID(mCurrentSyncDevice ); | 1590 | inL->removeID(mCurrentSyncDevice ); |
1591 | ++addedEventR; | 1591 | ++addedEventR; |
1592 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1592 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1593 | inL->setLastModified( modifiedCalendar ); | 1593 | inL->setLastModified( modifiedCalendar ); |
1594 | inR = inL->clone(); | 1594 | inR = inL->clone(); |
1595 | inR->setIDStr( ":" ); | 1595 | inR->setIDStr( ":" ); |
1596 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1596 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1597 | inR->setCalID( 0 );// add to default cal | 1597 | inR->setCalID( 0 );// add to default cal |
1598 | remote->addIncidence( inR ); | 1598 | remote->addIncidence( inR ); |
1599 | } | 1599 | } |
1600 | } | 1600 | } |
1601 | } else { | 1601 | } else { |
1602 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1602 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1603 | checkExternSyncEvent(eventLSyncSharp, inL); | 1603 | checkExternSyncEvent(eventLSyncSharp, inL); |
1604 | local->deleteIncidence( inL ); | 1604 | local->deleteIncidence( inL ); |
1605 | ++deletedEventL; | 1605 | ++deletedEventL; |
1606 | } else { | 1606 | } else { |
1607 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1607 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1608 | ++addedEventR; | 1608 | ++addedEventR; |
1609 | inL->setLastModified( modifiedCalendar ); | 1609 | inL->setLastModified( modifiedCalendar ); |
1610 | inR = inL->clone(); | 1610 | inR = inL->clone(); |
1611 | inR->setIDStr( ":" ); | 1611 | inR->setIDStr( ":" ); |
1612 | inR->setCalID( 0 );// add to default cal | 1612 | inR->setCalID( 0 );// add to default cal |
1613 | remote->addIncidence( inR ); | 1613 | remote->addIncidence( inR ); |
1614 | } | 1614 | } |
1615 | } | 1615 | } |
1616 | } | 1616 | } |
1617 | } else { | 1617 | } else { |
1618 | ++filteredOUT; | 1618 | ++filteredOUT; |
1619 | } | 1619 | } |
1620 | } | 1620 | } |
1621 | } | 1621 | } |
1622 | inL = el.next(); | 1622 | inL = el.next(); |
1623 | } | 1623 | } |
1624 | int delFut = 0; | 1624 | int delFut = 0; |
1625 | int remRem = 0; | 1625 | int remRem = 0; |
1626 | if ( mSyncManager->mWriteBackInFuture ) { | 1626 | if ( mSyncManager->mWriteBackInFuture ) { |
1627 | er = remote->rawIncidences(); | 1627 | er = remote->rawIncidences(); |
1628 | remRem = er.count(); | 1628 | remRem = er.count(); |
1629 | inR = er.first(); | 1629 | inR = er.first(); |
1630 | QDateTime dt; | 1630 | QDateTime dt; |
1631 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1631 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1632 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1632 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1633 | while ( inR ) { | 1633 | while ( inR ) { |
1634 | if ( inR->typeID() == todoID ) { | 1634 | if ( inR->typeID() == todoID ) { |
1635 | Todo * t = (Todo*)inR; | 1635 | Todo * t = (Todo*)inR; |
1636 | if ( t->hasDueDate() ) | 1636 | if ( t->hasDueDate() ) |
1637 | dt = t->dtDue(); | 1637 | dt = t->dtDue(); |
1638 | else | 1638 | else |
1639 | dt = cur.addSecs( 62 ); | 1639 | dt = cur.addSecs( 62 ); |
1640 | } | 1640 | } |
1641 | else if (inR->typeID() == eventID ) { | 1641 | else if (inR->typeID() == eventID ) { |
1642 | bool ok; | 1642 | bool ok; |
1643 | dt = inR->getNextOccurence( cur, &ok ); | 1643 | dt = inR->getNextOccurence( cur, &ok ); |
1644 | if ( !ok ) | 1644 | if ( !ok ) |
1645 | dt = cur.addSecs( -62 ); | 1645 | dt = cur.addSecs( -62 ); |
1646 | } | 1646 | } |
1647 | else | 1647 | else |
1648 | dt = inR->dtStart(); | 1648 | dt = inR->dtStart(); |
1649 | if ( dt < cur || dt > end ) { | 1649 | if ( dt < cur || dt > end ) { |
1650 | remote->deleteIncidence( inR ); | 1650 | remote->deleteIncidence( inR ); |
1651 | ++delFut; | 1651 | ++delFut; |
1652 | } | 1652 | } |
1653 | inR = er.next(); | 1653 | inR = er.next(); |
1654 | } | 1654 | } |
1655 | } | 1655 | } |
1656 | bar.hide(); | 1656 | bar.hide(); |
1657 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1657 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1658 | eventLSync->setReadOnly( false ); | 1658 | eventLSync->setReadOnly( false ); |
1659 | eventLSync->setDtStart( mLastCalendarSync ); | 1659 | eventLSync->setDtStart( mLastCalendarSync ); |
1660 | eventRSync->setDtStart( mLastCalendarSync ); | 1660 | eventRSync->setDtStart( mLastCalendarSync ); |
1661 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1661 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1662 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1662 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1663 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1663 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1664 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1664 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1665 | eventLSync->setReadOnly( true ); | 1665 | eventLSync->setReadOnly( true ); |
1666 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1666 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1667 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1667 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1668 | remote->addEvent( eventRSync ); | 1668 | remote->addEvent( eventRSync ); |
1669 | else | 1669 | else |
1670 | delete eventRSync; | 1670 | delete eventRSync; |
1671 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1671 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1672 | QString mes; | 1672 | QString mes; |
1673 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1673 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1674 | QString delmess; | 1674 | QString delmess; |
1675 | if ( delFut ) { | 1675 | if ( delFut ) { |
1676 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1676 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1677 | mes += delmess; | 1677 | mes += delmess; |
1678 | } | 1678 | } |
1679 | mes = i18n("Local calendar changed!\n") +mes; | 1679 | mes = i18n("Local calendar changed!\n") +mes; |
1680 | mCalendar->checkAlarmForIncidence( 0, true ); | 1680 | mCalendar->checkAlarmForIncidence( 0, true ); |
1681 | qDebug( mes ); | 1681 | qDebug( mes ); |
1682 | if ( mSyncManager->mShowSyncSummary ) { | 1682 | if ( mSyncManager->mShowSyncSummary ) { |
1683 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1683 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1684 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1684 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1685 | qDebug("KO: WB cancelled "); | 1685 | qDebug("KO: WB cancelled "); |
1686 | mSyncManager->mWriteBackFile = false; | 1686 | mSyncManager->mWriteBackFile = false; |
1687 | return syncOK; | 1687 | return syncOK; |
1688 | } | 1688 | } |
1689 | } | 1689 | } |
1690 | return syncOK; | 1690 | return syncOK; |
1691 | } | 1691 | } |
1692 | 1692 | ||
1693 | void CalendarView::setSyncDevice( QString s ) | 1693 | void CalendarView::setSyncDevice( QString s ) |
1694 | { | 1694 | { |
1695 | mCurrentSyncDevice= s; | 1695 | mCurrentSyncDevice= s; |
1696 | } | 1696 | } |
1697 | void CalendarView::setSyncName( QString s ) | 1697 | void CalendarView::setSyncName( QString s ) |
1698 | { | 1698 | { |
1699 | mCurrentSyncName= s; | 1699 | mCurrentSyncName= s; |
1700 | } | 1700 | } |
1701 | bool CalendarView::syncCalendar(QString filename, int mode) | 1701 | bool CalendarView::syncCalendar(QString filename, int mode) |
1702 | { | 1702 | { |
1703 | //qDebug("syncCalendar %s ", filename.latin1()); | 1703 | //qDebug("syncCalendar %s ", filename.latin1()); |
1704 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1704 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1705 | CalendarLocal* calendar = new CalendarLocal(); | 1705 | CalendarLocal* calendar = new CalendarLocal(); |
1706 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1706 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1707 | FileStorage* storage = new FileStorage( calendar ); | 1707 | FileStorage* storage = new FileStorage( calendar ); |
1708 | bool syncOK = false; | 1708 | bool syncOK = false; |
1709 | storage->setFileName( filename ); | 1709 | storage->setFileName( filename ); |
1710 | // qDebug("loading ... "); | 1710 | // qDebug("loading ... "); |
1711 | if ( storage->load() ) { | 1711 | if ( storage->load() ) { |
1712 | getEventViewerDialog()->setSyncMode( true ); | 1712 | getEventViewerDialog()->setSyncMode( true ); |
1713 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1713 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1714 | getEventViewerDialog()->setSyncMode( false ); | 1714 | getEventViewerDialog()->setSyncMode( false ); |
1715 | if ( syncOK ) { | 1715 | if ( syncOK ) { |
1716 | if ( mSyncManager->mWriteBackFile ) | 1716 | if ( mSyncManager->mWriteBackFile ) |
1717 | { | 1717 | { |
1718 | storage->setSaveFormat( new ICalFormat() ); | 1718 | storage->setSaveFormat( new ICalFormat() ); |
1719 | storage->save(); | 1719 | storage->save(); |
1720 | } | 1720 | } |
1721 | } | 1721 | } |
1722 | setModified( true ); | 1722 | setModified( true ); |
1723 | } | 1723 | } |
1724 | delete storage; | 1724 | delete storage; |
1725 | delete calendar; | 1725 | delete calendar; |
1726 | if ( syncOK ) | 1726 | if ( syncOK ) |
1727 | updateView(); | 1727 | updateView(); |
1728 | return syncOK; | 1728 | return syncOK; |
1729 | } | 1729 | } |
1730 | 1730 | ||
1731 | void CalendarView::syncExternal( int mode ) | 1731 | void CalendarView::syncExternal( int mode ) |
1732 | { | 1732 | { |
1733 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1733 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1734 | 1734 | ||
1735 | qApp->processEvents(); | 1735 | qApp->processEvents(); |
1736 | CalendarLocal* calendar = new CalendarLocal(); | 1736 | CalendarLocal* calendar = new CalendarLocal(); |
1737 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1737 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1738 | bool syncOK = false; | 1738 | bool syncOK = false; |
1739 | bool loadSuccess = false; | 1739 | bool loadSuccess = false; |
1740 | PhoneFormat* phoneFormat = 0; | 1740 | PhoneFormat* phoneFormat = 0; |
1741 | emit tempDisableBR(true); | 1741 | emit tempDisableBR(true); |
1742 | #ifndef DESKTOP_VERSION | 1742 | #ifndef DESKTOP_VERSION |
1743 | SharpFormat* sharpFormat = 0; | 1743 | SharpFormat* sharpFormat = 0; |
1744 | if ( mode == 0 ) { // sharp | 1744 | if ( mode == 0 ) { // sharp |
1745 | sharpFormat = new SharpFormat () ; | 1745 | sharpFormat = new SharpFormat () ; |
1746 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1746 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1747 | 1747 | ||
1748 | } else | 1748 | } else |
1749 | #endif | 1749 | #endif |
1750 | if ( mode == 1 ) { // phone | 1750 | if ( mode == 1 ) { // phone |
1751 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1751 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1752 | mSyncManager->mPhoneDevice, | 1752 | mSyncManager->mPhoneDevice, |
1753 | mSyncManager->mPhoneConnection, | 1753 | mSyncManager->mPhoneConnection, |
1754 | mSyncManager->mPhoneModel); | 1754 | mSyncManager->mPhoneModel); |
1755 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1755 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1756 | 1756 | ||
1757 | } else { | 1757 | } else { |
1758 | emit tempDisableBR(false); | 1758 | emit tempDisableBR(false); |
1759 | return; | 1759 | return; |
1760 | } | 1760 | } |
1761 | if ( loadSuccess ) { | 1761 | if ( loadSuccess ) { |
1762 | getEventViewerDialog()->setSyncMode( true ); | 1762 | getEventViewerDialog()->setSyncMode( true ); |
1763 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1763 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1764 | getEventViewerDialog()->setSyncMode( false ); | 1764 | getEventViewerDialog()->setSyncMode( false ); |
1765 | qApp->processEvents(); | 1765 | qApp->processEvents(); |
1766 | if ( syncOK ) { | 1766 | if ( syncOK ) { |
1767 | if ( mSyncManager->mWriteBackFile ) | 1767 | if ( mSyncManager->mWriteBackFile ) |
1768 | { | 1768 | { |
1769 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1769 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1770 | Incidence* inc = iL.first(); | 1770 | Incidence* inc = iL.first(); |
1771 | if ( phoneFormat ) { | 1771 | if ( phoneFormat ) { |
1772 | while ( inc ) { | 1772 | while ( inc ) { |
1773 | inc->removeID(mCurrentSyncDevice); | 1773 | inc->removeID(mCurrentSyncDevice); |
1774 | inc = iL.next(); | 1774 | inc = iL.next(); |
1775 | } | 1775 | } |
1776 | } | 1776 | } |
1777 | #ifndef DESKTOP_VERSION | 1777 | #ifndef DESKTOP_VERSION |
1778 | if ( sharpFormat ) | 1778 | if ( sharpFormat ) |
1779 | sharpFormat->save(calendar); | 1779 | sharpFormat->save(calendar); |
1780 | #endif | 1780 | #endif |
1781 | if ( phoneFormat ) | 1781 | if ( phoneFormat ) |
1782 | phoneFormat->save(calendar); | 1782 | phoneFormat->save(calendar); |
1783 | iL = calendar->rawIncidences(); | 1783 | iL = calendar->rawIncidences(); |
1784 | inc = iL.first(); | 1784 | inc = iL.first(); |
1785 | Incidence* loc; | 1785 | Incidence* loc; |
1786 | while ( inc ) { | 1786 | while ( inc ) { |
1787 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1787 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1788 | loc = mCalendar->incidence(inc->uid() ); | 1788 | loc = mCalendar->incidence(inc->uid() ); |
1789 | if ( loc ) { | 1789 | if ( loc ) { |
1790 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1790 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1791 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1791 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1792 | } | 1792 | } |
1793 | } | 1793 | } |
1794 | inc = iL.next(); | 1794 | inc = iL.next(); |
1795 | } | 1795 | } |
1796 | Incidence* lse = getLastSyncEvent(); | 1796 | Incidence* lse = getLastSyncEvent(); |
1797 | if ( lse ) { | 1797 | if ( lse ) { |
1798 | lse->setReadOnly( false ); | 1798 | lse->setReadOnly( false ); |
1799 | lse->setDescription( "" ); | 1799 | lse->setDescription( "" ); |
1800 | lse->setReadOnly( true ); | 1800 | lse->setReadOnly( true ); |
1801 | } | 1801 | } |
1802 | } | 1802 | } |
1803 | } else { | 1803 | } else { |
1804 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1804 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1805 | } | 1805 | } |
1806 | setModified( true ); | 1806 | setModified( true ); |
1807 | } else { | 1807 | } else { |
1808 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1808 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1809 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1809 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1810 | question, i18n("Ok")) ; | 1810 | question, i18n("Ok")) ; |
1811 | 1811 | ||
1812 | } | 1812 | } |
1813 | delete calendar; | 1813 | delete calendar; |
1814 | updateView(); | 1814 | updateView(); |
1815 | emit tempDisableBR(false); | 1815 | emit tempDisableBR(false); |
1816 | return ;//syncOK; | 1816 | return ;//syncOK; |
1817 | 1817 | ||
1818 | } | 1818 | } |
1819 | 1819 | ||
1820 | bool CalendarView::importBday() | 1820 | bool CalendarView::importBday() |
1821 | { | 1821 | { |
1822 | #ifndef KORG_NOKABC | 1822 | #ifndef KORG_NOKABC |
1823 | 1823 | ||
1824 | #ifdef DESKTOP_VERSION | 1824 | #ifdef DESKTOP_VERSION |
1825 | int curCal = mCalendar->defaultCalendar(); | 1825 | int curCal = mCalendar->defaultCalendar(); |
1826 | int bd = mCalEditView->getBirtdayID(); | 1826 | int bd = mCalEditView->getBirtdayID(); |
1827 | if ( bd == 0 ) | 1827 | if ( bd == 0 ) |
1828 | return false; | 1828 | return false; |
1829 | mCalendar->setDefaultCalendar( bd ); | 1829 | mCalendar->setDefaultCalendar( bd ); |
1830 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1830 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1831 | KABC::AddressBook::Iterator it; | 1831 | KABC::AddressBook::Iterator it; |
1832 | int count = 0; | 1832 | int count = 0; |
1833 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1833 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1834 | ++count; | 1834 | ++count; |
1835 | } | 1835 | } |
1836 | QProgressBar bar(count,0 ); | 1836 | QProgressBar bar(count,0 ); |
1837 | int w = 300; | 1837 | int w = 300; |
1838 | if ( QApplication::desktop()->width() < 320 ) | 1838 | if ( QApplication::desktop()->width() < 320 ) |
1839 | w = 220; | 1839 | w = 220; |
1840 | int h = bar.sizeHint().height() ; | 1840 | int h = bar.sizeHint().height() ; |
1841 | int dw = QApplication::desktop()->width(); | 1841 | int dw = QApplication::desktop()->width(); |
1842 | int dh = QApplication::desktop()->height(); | 1842 | int dh = QApplication::desktop()->height(); |
1843 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1843 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1844 | bar.show(); | 1844 | bar.show(); |
1845 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1845 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1846 | qApp->processEvents(); | 1846 | qApp->processEvents(); |
1847 | count = 0; | 1847 | count = 0; |
1848 | int addCount = 0; | 1848 | int addCount = 0; |
1849 | KCal::Attendee* a = 0; | 1849 | KCal::Attendee* a = 0; |
1850 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1850 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1851 | if ( ! bar.isVisible() ) | 1851 | if ( ! bar.isVisible() ) |
1852 | return false; | 1852 | return false; |
1853 | bar.setProgress( count++ ); | 1853 | bar.setProgress( count++ ); |
1854 | qApp->processEvents(); | 1854 | qApp->processEvents(); |
1855 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1855 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1856 | if ( (*it).birthday().date().isValid() ){ | 1856 | if ( (*it).birthday().date().isValid() ){ |
1857 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1857 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1858 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1858 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1859 | ++addCount; | 1859 | ++addCount; |
1860 | } | 1860 | } |
1861 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1861 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1862 | if ( anni.isValid() ){ | 1862 | if ( anni.isValid() ){ |
1863 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1863 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1864 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1864 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1865 | ++addCount; | 1865 | ++addCount; |
1866 | } | 1866 | } |
1867 | } | 1867 | } |
1868 | mCalendar->setDefaultCalendar( curCal ); | 1868 | mCalendar->setDefaultCalendar( curCal ); |
1869 | updateView(); | 1869 | updateView(); |
1870 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1870 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1871 | #else //DESKTOP_VERSION | 1871 | #else //DESKTOP_VERSION |
1872 | 1872 | ||
1873 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1873 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1874 | // the result should now arrive through method insertBirthdays | 1874 | // the result should now arrive through method insertBirthdays |
1875 | 1875 | ||
1876 | #endif //DESKTOP_VERSION | 1876 | #endif //DESKTOP_VERSION |
1877 | 1877 | ||
1878 | #endif //KORG_NOKABC | 1878 | #endif //KORG_NOKABC |
1879 | 1879 | ||
1880 | 1880 | ||
1881 | return true; | 1881 | return true; |
1882 | } | 1882 | } |
1883 | 1883 | ||
1884 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1884 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1885 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1885 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1886 | const QStringList& anniversaryList, const QStringList& realNameList, | 1886 | const QStringList& anniversaryList, const QStringList& realNameList, |
1887 | const QStringList& emailList, const QStringList& assembledNameList, | 1887 | const QStringList& emailList, const QStringList& assembledNameList, |
1888 | const QStringList& uidList) | 1888 | const QStringList& uidList) |
1889 | { | 1889 | { |
1890 | 1890 | ||
1891 | //qDebug("KO::CalendarView::insertBirthdays"); | 1891 | //qDebug("KO::CalendarView::insertBirthdays"); |
1892 | if (uid == this->name()) | 1892 | if (uid == this->name()) |
1893 | { | 1893 | { |
1894 | int curCal = mCalendar->defaultCalendar(); | 1894 | int curCal = mCalendar->defaultCalendar(); |
1895 | int bd = mCalEditView->getBirtdayID(); | 1895 | int bd = mCalEditView->getBirtdayID(); |
1896 | if ( bd == 0 ) | 1896 | if ( bd == 0 ) |
1897 | return; | 1897 | return; |
1898 | mCalendar->setDefaultCalendar( bd ); | 1898 | mCalendar->setDefaultCalendar( bd ); |
1899 | 1899 | ||
1900 | 1900 | ||
1901 | int count = birthdayList.count(); | 1901 | int count = birthdayList.count(); |
1902 | int addCount = 0; | 1902 | int addCount = 0; |
1903 | KCal::Attendee* a = 0; | 1903 | KCal::Attendee* a = 0; |
1904 | 1904 | ||
1905 | //qDebug("CalView 1 %i", count); | 1905 | //qDebug("CalView 1 %i", count); |
1906 | 1906 | ||
1907 | QProgressBar bar(count,0 ); | 1907 | QProgressBar bar(count,0 ); |
1908 | int w = 300; | 1908 | int w = 300; |
1909 | if ( QApplication::desktop()->width() < 320 ) | 1909 | if ( QApplication::desktop()->width() < 320 ) |
1910 | w = 220; | 1910 | w = 220; |
1911 | int h = bar.sizeHint().height() ; | 1911 | int h = bar.sizeHint().height() ; |
1912 | int dw = QApplication::desktop()->width(); | 1912 | int dw = QApplication::desktop()->width(); |
1913 | int dh = QApplication::desktop()->height(); | 1913 | int dh = QApplication::desktop()->height(); |
1914 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1914 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1915 | bar.show(); | 1915 | bar.show(); |
1916 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1916 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1917 | qApp->processEvents(); | 1917 | qApp->processEvents(); |
1918 | 1918 | ||
1919 | QDate birthday; | 1919 | QDate birthday; |
1920 | QDate anniversary; | 1920 | QDate anniversary; |
1921 | QString realName; | 1921 | QString realName; |
1922 | QString email; | 1922 | QString email; |
1923 | QString assembledName; | 1923 | QString assembledName; |
1924 | QString uid; | 1924 | QString uid; |
1925 | bool ok = true; | 1925 | bool ok = true; |
1926 | for ( int i = 0; i < count; i++) | 1926 | for ( int i = 0; i < count; i++) |
1927 | { | 1927 | { |
1928 | if ( ! bar.isVisible() ) | 1928 | if ( ! bar.isVisible() ) |
1929 | return; | 1929 | return; |
1930 | bar.setProgress( i ); | 1930 | bar.setProgress( i ); |
1931 | qApp->processEvents(); | 1931 | qApp->processEvents(); |
1932 | 1932 | ||
1933 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1933 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1934 | if (!ok) { | 1934 | if (!ok) { |
1935 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1935 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1938 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1939 | if (!ok) { | 1939 | if (!ok) { |
1940 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1940 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1941 | } | 1941 | } |
1942 | realName = realNameList[i]; | 1942 | realName = realNameList[i]; |
1943 | email = emailList[i]; | 1943 | email = emailList[i]; |
1944 | assembledName = assembledNameList[i]; | 1944 | assembledName = assembledNameList[i]; |
1945 | uid = uidList[i]; | 1945 | uid = uidList[i]; |
1946 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1946 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1947 | 1947 | ||
1948 | if ( birthday.isValid() ){ | 1948 | if ( birthday.isValid() ){ |
1949 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1949 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1950 | KCal::Attendee::ReqParticipant,uid) ; | 1950 | KCal::Attendee::ReqParticipant,uid) ; |
1951 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1951 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1952 | ++addCount; | 1952 | ++addCount; |
1953 | } | 1953 | } |
1954 | 1954 | ||
1955 | if ( anniversary.isValid() ){ | 1955 | if ( anniversary.isValid() ){ |
1956 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1956 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1957 | KCal::Attendee::ReqParticipant,uid) ; | 1957 | KCal::Attendee::ReqParticipant,uid) ; |
1958 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1958 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1959 | ++addCount; | 1959 | ++addCount; |
1960 | } | 1960 | } |
1961 | } | 1961 | } |
1962 | 1962 | ||
1963 | mCalendar->setDefaultCalendar( curCal ); | 1963 | mCalendar->setDefaultCalendar( curCal ); |
1964 | updateView(); | 1964 | updateView(); |
1965 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1965 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1966 | 1966 | ||
1967 | } | 1967 | } |
1968 | 1968 | ||
1969 | } | 1969 | } |
1970 | 1970 | ||
1971 | 1971 | ||
1972 | 1972 | ||
1973 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1973 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1974 | { | 1974 | { |
1975 | //qDebug("addAnni "); | 1975 | //qDebug("addAnni "); |
1976 | Event * ev = new Event(); | 1976 | Event * ev = new Event(); |
1977 | ev->setOrganizer(KOPrefs::instance()->email()); | 1977 | ev->setOrganizer(KOPrefs::instance()->email()); |
1978 | if ( a ) { | 1978 | if ( a ) { |
1979 | ev->addAttendee( a ); | 1979 | ev->addAttendee( a ); |
1980 | } | 1980 | } |
1981 | QString kind; | 1981 | QString kind; |
1982 | if ( birthday ) { | 1982 | if ( birthday ) { |
1983 | kind = i18n( "Birthday" ); | 1983 | kind = i18n( "Birthday" ); |
1984 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1984 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1985 | } | 1985 | } |
1986 | else { | 1986 | else { |
1987 | kind = i18n( "Anniversary" ); | 1987 | kind = i18n( "Anniversary" ); |
1988 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1988 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1989 | } | 1989 | } |
1990 | ev->setCategories( kind ); | 1990 | ev->setCategories( kind ); |
1991 | ev->setDtStart( QDateTime(date) ); | 1991 | ev->setDtStart( QDateTime(date) ); |
1992 | ev->setDtEnd( QDateTime(date) ); | 1992 | ev->setDtEnd( QDateTime(date) ); |
1993 | ev->setFloats( true ); | 1993 | ev->setFloats( true ); |
1994 | Recurrence * rec = ev->recurrence(); | 1994 | Recurrence * rec = ev->recurrence(); |
1995 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1995 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1996 | rec->addYearlyNum( date.month() ); | 1996 | rec->addYearlyNum( date.month() ); |
1997 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1997 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1998 | delete ev; | 1998 | delete ev; |
1999 | return false; | 1999 | return false; |
2000 | } | 2000 | } |
2001 | return true; | 2001 | return true; |
2002 | 2002 | ||
2003 | } | 2003 | } |
2004 | bool CalendarView::importQtopia( const QString &categories, | 2004 | bool CalendarView::importQtopia( const QString &categories, |
2005 | const QString &datebook, | 2005 | const QString &datebook, |
2006 | const QString &todolist ) | 2006 | const QString &todolist ) |
2007 | { | 2007 | { |
2008 | 2008 | ||
2009 | QtopiaFormat qtopiaFormat; | 2009 | QtopiaFormat qtopiaFormat; |
2010 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2010 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2011 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2011 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2012 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2012 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2013 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2013 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2014 | 2014 | ||
2015 | updateView(); | 2015 | updateView(); |
2016 | return true; | 2016 | return true; |
2017 | 2017 | ||
2018 | #if 0 | 2018 | #if 0 |
2019 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2019 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2020 | mCurrentSyncDevice = "qtopia-XML"; | 2020 | mCurrentSyncDevice = "qtopia-XML"; |
2021 | if ( mSyncManager->mAskForPreferences ) | 2021 | if ( mSyncManager->mAskForPreferences ) |
2022 | edit_sync_options(); | 2022 | edit_sync_options(); |
2023 | qApp->processEvents(); | 2023 | qApp->processEvents(); |
2024 | CalendarLocal* calendar = new CalendarLocal(); | 2024 | CalendarLocal* calendar = new CalendarLocal(); |
2025 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2025 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2026 | bool syncOK = false; | 2026 | bool syncOK = false; |
2027 | QtopiaFormat qtopiaFormat; | 2027 | QtopiaFormat qtopiaFormat; |
2028 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2028 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2029 | bool loadOk = true; | 2029 | bool loadOk = true; |
2030 | if ( !categories.isEmpty() ) | 2030 | if ( !categories.isEmpty() ) |
2031 | loadOk = qtopiaFormat.load( calendar, categories ); | 2031 | loadOk = qtopiaFormat.load( calendar, categories ); |
2032 | if ( loadOk && !datebook.isEmpty() ) | 2032 | if ( loadOk && !datebook.isEmpty() ) |
2033 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2033 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2034 | if ( loadOk && !todolist.isEmpty() ) | 2034 | if ( loadOk && !todolist.isEmpty() ) |
2035 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2035 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2036 | 2036 | ||
2037 | if ( loadOk ) { | 2037 | if ( loadOk ) { |
2038 | getEventViewerDialog()->setSyncMode( true ); | 2038 | getEventViewerDialog()->setSyncMode( true ); |
2039 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2039 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2040 | getEventViewerDialog()->setSyncMode( false ); | 2040 | getEventViewerDialog()->setSyncMode( false ); |
2041 | qApp->processEvents(); | 2041 | qApp->processEvents(); |
2042 | if ( syncOK ) { | 2042 | if ( syncOK ) { |
2043 | if ( mSyncManager->mWriteBackFile ) | 2043 | if ( mSyncManager->mWriteBackFile ) |
2044 | { | 2044 | { |
2045 | // write back XML file | 2045 | // write back XML file |
2046 | 2046 | ||
2047 | } | 2047 | } |
2048 | setModified( true ); | 2048 | setModified( true ); |
2049 | } | 2049 | } |
2050 | } else { | 2050 | } else { |
2051 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2051 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2052 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2052 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2053 | question, i18n("Ok")) ; | 2053 | question, i18n("Ok")) ; |
2054 | } | 2054 | } |
2055 | delete calendar; | 2055 | delete calendar; |
2056 | updateView(); | 2056 | updateView(); |
2057 | return syncOK; | 2057 | return syncOK; |
2058 | 2058 | ||
2059 | 2059 | ||
2060 | #endif | 2060 | #endif |
2061 | 2061 | ||
2062 | } | 2062 | } |
2063 | 2063 | ||
2064 | void CalendarView::setSyncEventsReadOnly() | 2064 | void CalendarView::setSyncEventsReadOnly() |
2065 | { | 2065 | { |
2066 | mCalendar->setSyncEventsReadOnly(); | 2066 | mCalendar->setSyncEventsReadOnly(); |
2067 | } | 2067 | } |
2068 | 2068 | ||
2069 | bool CalendarView::loadCalendars() | 2069 | bool CalendarView::loadCalendars() |
2070 | { | 2070 | { |
2071 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2071 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2072 | KopiCalendarFile * cal = calendars.first(); | 2072 | KopiCalendarFile * cal = calendars.first(); |
2073 | mCalendar->setDefaultCalendar( 1 ); | 2073 | mCalendar->setDefaultCalendar( 1 ); |
2074 | openCalendar( MainWindow::defaultFileName(), false ); | 2074 | openCalendar( MainWindow::defaultFileName(), false ); |
2075 | cal = calendars.next(); | 2075 | cal = calendars.next(); |
2076 | while ( cal ) { | 2076 | while ( cal ) { |
2077 | addCalendar( cal ); | 2077 | addCalendar( cal ); |
2078 | cal = calendars.next(); | 2078 | cal = calendars.next(); |
2079 | } | 2079 | } |
2080 | restoreCalendarSettings(); | 2080 | restoreCalendarSettings(); |
2081 | return true; | 2081 | return true; |
2082 | } | 2082 | } |
2083 | bool CalendarView::restoreCalendarSettings() | 2083 | bool CalendarView::restoreCalendarSettings() |
2084 | { | 2084 | { |
2085 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2085 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2086 | KopiCalendarFile * cal = calendars.first(); | 2086 | KopiCalendarFile * cal = calendars.first(); |
2087 | while ( cal ) { | 2087 | while ( cal ) { |
2088 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2088 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2089 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2089 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2090 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2090 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2091 | if ( cal->isStandard ) | 2091 | if ( cal->isStandard ) |
2092 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2092 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2093 | cal = calendars.next(); | 2093 | cal = calendars.next(); |
2094 | } | 2094 | } |
2095 | setSyncEventsReadOnly(); | 2095 | setSyncEventsReadOnly(); |
2096 | mCalendar->reInitAlarmSettings(); | 2096 | mCalendar->reInitAlarmSettings(); |
2097 | updateUnmanagedViews(); | 2097 | updateUnmanagedViews(); |
2098 | updateView(); | 2098 | updateView(); |
2099 | return true; | 2099 | return true; |
2100 | } | 2100 | } |
2101 | void CalendarView::addCalendarId( int id ) | 2101 | void CalendarView::addCalendarId( int id ) |
2102 | { | 2102 | { |
2103 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2103 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2104 | if ( cal ) | 2104 | if ( cal ) |
2105 | addCalendar( cal ); | 2105 | addCalendar( cal ); |
2106 | } | 2106 | } |
2107 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2107 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2108 | { | 2108 | { |
2109 | cal->mErrorOnLoad = false; | 2109 | cal->mErrorOnLoad = false; |
2110 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2110 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2111 | cal->mLoadDt = QDateTime::currentDateTime(); | 2111 | cal->mLoadDt = QDateTime::currentDateTime(); |
2112 | return true; | 2112 | return true; |
2113 | } | 2113 | } |
2114 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2114 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2115 | cal->mErrorOnLoad = true; | 2115 | cal->mErrorOnLoad = true; |
2116 | return false; | 2116 | return false; |
2117 | } | 2117 | } |
2118 | bool CalendarView::openCalendar(QString filename, bool merge) | 2118 | bool CalendarView::openCalendar(QString filename, bool merge) |
2119 | { | 2119 | { |
2120 | 2120 | ||
2121 | if (filename.isEmpty()) { | 2121 | if (filename.isEmpty()) { |
2122 | return false; | 2122 | return false; |
2123 | } | 2123 | } |
2124 | 2124 | ||
2125 | if (!QFile::exists(filename)) { | 2125 | if (!QFile::exists(filename)) { |
2126 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2126 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2127 | return false; | 2127 | return false; |
2128 | } | 2128 | } |
2129 | 2129 | ||
2130 | globalFlagBlockAgenda = 1; | 2130 | globalFlagBlockAgenda = 1; |
2131 | clearAllViews(); | 2131 | clearAllViews(); |
2132 | if (!merge) { | 2132 | if (!merge) { |
2133 | mViewManager->setDocumentId( filename ); | 2133 | mViewManager->setDocumentId( filename ); |
2134 | mCalendar->close(); | 2134 | mCalendar->close(); |
2135 | } | 2135 | } |
2136 | mStorage->setFileName( filename ); | 2136 | mStorage->setFileName( filename ); |
2137 | 2137 | ||
2138 | if ( mStorage->load() ) { | 2138 | if ( mStorage->load() ) { |
2139 | if ( merge ) ;//setModified( true ); | 2139 | if ( merge ) ;//setModified( true ); |
2140 | else { | 2140 | else { |
2141 | //setModified( true ); | 2141 | //setModified( true ); |
2142 | mViewManager->setDocumentId( filename ); | 2142 | mViewManager->setDocumentId( filename ); |
2143 | mDialogManager->setDocumentId( filename ); | 2143 | mDialogManager->setDocumentId( filename ); |
2144 | mTodoList->setDocumentId( filename ); | 2144 | mTodoList->setDocumentId( filename ); |
2145 | } | 2145 | } |
2146 | globalFlagBlockAgenda = 2; | 2146 | globalFlagBlockAgenda = 2; |
2147 | // if ( getLastSyncEvent() ) | 2147 | // if ( getLastSyncEvent() ) |
2148 | // getLastSyncEvent()->setReadOnly( true ); | 2148 | // getLastSyncEvent()->setReadOnly( true ); |
2149 | mCalendar->reInitAlarmSettings(); | 2149 | mCalendar->reInitAlarmSettings(); |
2150 | setSyncEventsReadOnly(); | 2150 | setSyncEventsReadOnly(); |
2151 | updateUnmanagedViews(); | 2151 | updateUnmanagedViews(); |
2152 | updateView(); | 2152 | updateView(); |
2153 | if ( filename != MainWindow::defaultFileName() ) { | 2153 | if ( filename != MainWindow::defaultFileName() ) { |
2154 | saveCalendar( MainWindow::defaultFileName() ); | 2154 | saveCalendar( MainWindow::defaultFileName() ); |
2155 | } else { | 2155 | } else { |
2156 | QFileInfo finf ( MainWindow::defaultFileName()); | 2156 | QFileInfo finf ( MainWindow::defaultFileName()); |
2157 | if ( finf.exists() ) { | 2157 | if ( finf.exists() ) { |
2158 | setLoadedFileVersion( finf.lastModified () ); | 2158 | setLoadedFileVersion( finf.lastModified () ); |
2159 | } | 2159 | } |
2160 | } | 2160 | } |
2161 | return true; | 2161 | return true; |
2162 | } else { | 2162 | } else { |
2163 | // while failing to load, the calendar object could | 2163 | // while failing to load, the calendar object could |
2164 | // have become partially populated. Clear it out. | 2164 | // have become partially populated. Clear it out. |
2165 | if ( !merge ) { | 2165 | if ( !merge ) { |
2166 | mCalendar->close(); | 2166 | mCalendar->close(); |
2167 | mViewManager->setDocumentId( filename ); | 2167 | mViewManager->setDocumentId( filename ); |
2168 | mDialogManager->setDocumentId( filename ); | 2168 | mDialogManager->setDocumentId( filename ); |
2169 | mTodoList->setDocumentId( filename ); | 2169 | mTodoList->setDocumentId( filename ); |
2170 | } | 2170 | } |
2171 | 2171 | ||
2172 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2172 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2173 | 2173 | ||
2174 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2174 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2175 | globalFlagBlockAgenda = 2; | 2175 | globalFlagBlockAgenda = 2; |
2176 | mCalendar->reInitAlarmSettings(); | 2176 | mCalendar->reInitAlarmSettings(); |
2177 | setSyncEventsReadOnly(); | 2177 | setSyncEventsReadOnly(); |
2178 | updateUnmanagedViews(); | 2178 | updateUnmanagedViews(); |
2179 | updateView(); | 2179 | updateView(); |
2180 | } | 2180 | } |
2181 | return false; | 2181 | return false; |
2182 | } | 2182 | } |
2183 | void CalendarView::mergeFile( QString fn ) | 2183 | void CalendarView::mergeFile( QString fn ) |
2184 | { | 2184 | { |
2185 | clearAllViews(); | 2185 | clearAllViews(); |
2186 | mCalendar->mergeCalendarFile( fn ); | 2186 | mCalendar->mergeCalendarFile( fn ); |
2187 | mCalendar->reInitAlarmSettings(); | 2187 | mCalendar->reInitAlarmSettings(); |
2188 | setSyncEventsReadOnly(); | 2188 | setSyncEventsReadOnly(); |
2189 | updateUnmanagedViews(); | 2189 | updateUnmanagedViews(); |
2190 | updateView(); | 2190 | updateView(); |
2191 | } | 2191 | } |
2192 | void CalendarView::showOpenError() | 2192 | void CalendarView::showOpenError() |
2193 | { | 2193 | { |
2194 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2194 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2195 | } | 2195 | } |
2196 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2196 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2197 | { | 2197 | { |
2198 | loadedFileVersion = dt; | 2198 | loadedFileVersion = dt; |
2199 | } | 2199 | } |
2200 | bool CalendarView::checkFileChanged(QString fn) | 2200 | bool CalendarView::checkFileChanged(QString fn) |
2201 | { | 2201 | { |
2202 | QFileInfo finf ( fn ); | 2202 | QFileInfo finf ( fn ); |
2203 | if ( !finf.exists() ) | 2203 | if ( !finf.exists() ) |
2204 | return true; | 2204 | return true; |
2205 | QDateTime dt = finf.lastModified (); | 2205 | QDateTime dt = finf.lastModified (); |
2206 | if ( dt <= loadedFileVersion ) | 2206 | if ( dt <= loadedFileVersion ) |
2207 | return false; | 2207 | return false; |
2208 | return true; | 2208 | return true; |
2209 | 2209 | ||
2210 | } | 2210 | } |
2211 | void CalendarView::watchSavedFile() | 2211 | void CalendarView::watchSavedFile() |
2212 | { | 2212 | { |
2213 | QFileInfo finf ( MainWindow::defaultFileName()); | 2213 | QFileInfo finf ( MainWindow::defaultFileName()); |
2214 | if ( !finf.exists() ) | 2214 | if ( !finf.exists() ) |
2215 | return; | 2215 | return; |
2216 | QDateTime dt = finf.lastModified (); | 2216 | QDateTime dt = finf.lastModified (); |
2217 | if ( dt < loadedFileVersion ) { | 2217 | if ( dt < loadedFileVersion ) { |
2218 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2218 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2219 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2219 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2220 | return; | 2220 | return; |
2221 | } | 2221 | } |
2222 | loadedFileVersion = dt; | 2222 | loadedFileVersion = dt; |
2223 | } | 2223 | } |
2224 | bool CalendarView::checkAllFileVersions() | 2224 | bool CalendarView::checkAllFileVersions() |
2225 | { | 2225 | { |
2226 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2226 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2227 | KopiCalendarFile * cal = calendars.first(); | 2227 | KopiCalendarFile * cal = calendars.first(); |
2228 | mCalendar->setDefaultCalendar( 1 ); | 2228 | mCalendar->setDefaultCalendar( 1 ); |
2229 | mCalendar->setDefaultCalendarEnabledOnly(); | 2229 | mCalendar->setDefaultCalendarEnabledOnly(); |
2230 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2230 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2231 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2231 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2232 | restoreCalendarSettings(); | 2232 | restoreCalendarSettings(); |
2233 | return false; | 2233 | return false; |
2234 | } | 2234 | } |
2235 | } | 2235 | } |
2236 | cal = calendars.next(); | 2236 | cal = calendars.next(); |
2237 | QDateTime storeTemp = loadedFileVersion; | 2237 | QDateTime storeTemp = loadedFileVersion; |
2238 | while ( cal ) { | 2238 | while ( cal ) { |
2239 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2239 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2240 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2240 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2241 | mCalendar->setDefaultCalendarEnabledOnly(); | 2241 | mCalendar->setDefaultCalendarEnabledOnly(); |
2242 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2242 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2243 | if ( !checkFileVersion(cal->mFileName )) { | 2243 | if ( !checkFileVersion(cal->mFileName )) { |
2244 | loadedFileVersion = storeTemp; | 2244 | loadedFileVersion = storeTemp; |
2245 | restoreCalendarSettings(); | 2245 | restoreCalendarSettings(); |
2246 | return false; | 2246 | return false; |
2247 | } | 2247 | } |
2248 | } | 2248 | } |
2249 | cal = calendars.next(); | 2249 | cal = calendars.next(); |
2250 | } | 2250 | } |
2251 | loadedFileVersion = storeTemp; | 2251 | loadedFileVersion = storeTemp; |
2252 | return true; | 2252 | return true; |
2253 | } | 2253 | } |
2254 | bool CalendarView::checkFileVersion(QString fn) | 2254 | bool CalendarView::checkFileVersion(QString fn) |
2255 | { | 2255 | { |
2256 | QFileInfo finf ( fn ); | 2256 | QFileInfo finf ( fn ); |
2257 | if ( !finf.exists() ) | 2257 | if ( !finf.exists() ) |
2258 | return true; | 2258 | return true; |
2259 | QDateTime dt = finf.lastModified (); | 2259 | QDateTime dt = finf.lastModified (); |
2260 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2260 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2261 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2261 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2262 | if ( dt <= loadedFileVersion ) | 2262 | if ( dt <= loadedFileVersion ) |
2263 | return true; | 2263 | return true; |
2264 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2264 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2265 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2265 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2266 | i18n("Sync+save")); | 2266 | i18n("Sync+save")); |
2267 | 2267 | ||
2268 | if ( km == KMessageBox::Cancel ) | 2268 | if ( km == KMessageBox::Cancel ) |
2269 | return false; | 2269 | return false; |
2270 | if ( km == KMessageBox::Yes ) | 2270 | if ( km == KMessageBox::Yes ) |
2271 | return true; | 2271 | return true; |
2272 | 2272 | ||
2273 | setSyncDevice("deleteaftersync" ); | 2273 | setSyncDevice("deleteaftersync" ); |
2274 | mSyncManager->mAskForPreferences = true; | 2274 | mSyncManager->mAskForPreferences = true; |
2275 | mSyncManager->mSyncAlgoPrefs = 3; | 2275 | mSyncManager->mSyncAlgoPrefs = 3; |
2276 | mSyncManager->mWriteBackFile = false; | 2276 | mSyncManager->mWriteBackFile = false; |
2277 | mSyncManager->mWriteBackExistingOnly = false; | 2277 | mSyncManager->mWriteBackExistingOnly = false; |
2278 | mSyncManager->mShowSyncSummary = false; | 2278 | mSyncManager->mShowSyncSummary = false; |
2279 | syncCalendar( fn, 3 ); | 2279 | syncCalendar( fn, 3 ); |
2280 | Event * e = getLastSyncEvent(); | 2280 | Event * e = getLastSyncEvent(); |
2281 | if ( e ) | 2281 | if ( e ) |
2282 | mCalendar->deleteEvent( e ); | 2282 | mCalendar->deleteEvent( e ); |
2283 | return true; | 2283 | return true; |
2284 | } | 2284 | } |
2285 | bool CalendarView::saveCalendars() | 2285 | bool CalendarView::saveCalendars() |
2286 | { | 2286 | { |
2287 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2287 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2288 | KopiCalendarFile * cal = calendars.first(); | 2288 | KopiCalendarFile * cal = calendars.first(); |
2289 | mCalendar->setDefaultCalendar( 1 ); | 2289 | mCalendar->setDefaultCalendar( 1 ); |
2290 | mCalendar->setDefaultCalendarEnabledOnly(); | 2290 | mCalendar->setDefaultCalendarEnabledOnly(); |
2291 | saveCalendar( MainWindow::defaultFileName() ); | 2291 | saveCalendar( MainWindow::defaultFileName() ); |
2292 | cal = calendars.next(); | 2292 | cal = calendars.next(); |
2293 | while ( cal ) { | 2293 | while ( cal ) { |
2294 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2294 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2295 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2295 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2296 | mCalendar->setDefaultCalendarEnabledOnly(); | 2296 | mCalendar->setDefaultCalendarEnabledOnly(); |
2297 | if ( saveCalendar( cal->mFileName ) ) | 2297 | if ( saveCalendar( cal->mFileName ) ) |
2298 | cal->mLoadDt = QDateTime::currentDateTime(); | 2298 | cal->mLoadDt = QDateTime::currentDateTime(); |
2299 | } | 2299 | } |
2300 | cal = calendars.next(); | 2300 | cal = calendars.next(); |
2301 | } | 2301 | } |
2302 | restoreCalendarSettings(); | 2302 | restoreCalendarSettings(); |
2303 | return true; | 2303 | return true; |
2304 | } | 2304 | } |
2305 | bool CalendarView::saveCalendar( QString filename ) | 2305 | bool CalendarView::saveCalendar( QString filename ) |
2306 | { | 2306 | { |
2307 | 2307 | ||
2308 | // Store back all unsaved data into calendar object | 2308 | // Store back all unsaved data into calendar object |
2309 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2309 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2310 | if ( mViewManager->currentView() ) | 2310 | if ( mViewManager->currentView() ) |
2311 | mViewManager->currentView()->flushView(); | 2311 | mViewManager->currentView()->flushView(); |
2312 | 2312 | ||
2313 | 2313 | ||
2314 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2314 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2315 | mStorage->setSaveFormat( new ICalFormat() ); | 2315 | mStorage->setSaveFormat( new ICalFormat() ); |
2316 | mStorage->setFileName( filename ); | 2316 | mStorage->setFileName( filename ); |
2317 | bool success; | 2317 | bool success; |
2318 | success = mStorage->save(); | 2318 | success = mStorage->save(); |
2319 | if ( !success ) { | 2319 | if ( !success ) { |
2320 | return false; | 2320 | return false; |
2321 | } | 2321 | } |
2322 | if ( filename == MainWindow::defaultFileName() ) { | 2322 | if ( filename == MainWindow::defaultFileName() ) { |
2323 | setLoadedFileVersion( lfv ); | 2323 | setLoadedFileVersion( lfv ); |
2324 | watchSavedFile(); | 2324 | watchSavedFile(); |
2325 | } | 2325 | } |
2326 | return true; | 2326 | return true; |
2327 | } | 2327 | } |
2328 | 2328 | ||
2329 | void CalendarView::closeCalendar() | 2329 | void CalendarView::closeCalendar() |
2330 | { | 2330 | { |
2331 | 2331 | ||
2332 | // child windows no longer valid | 2332 | // child windows no longer valid |
2333 | clearAllViews(); | 2333 | clearAllViews(); |
2334 | emit closingDown(); | 2334 | emit closingDown(); |
2335 | 2335 | ||
2336 | mCalendar->close(); | 2336 | mCalendar->close(); |
2337 | setModified(false); | 2337 | setModified(false); |
2338 | updateView(); | 2338 | updateView(); |
2339 | } | 2339 | } |
2340 | 2340 | ||
2341 | void CalendarView::archiveCalendar() | 2341 | void CalendarView::archiveCalendar() |
2342 | { | 2342 | { |
2343 | mDialogManager->showArchiveDialog(); | 2343 | mDialogManager->showArchiveDialog(); |
2344 | } | 2344 | } |
2345 | 2345 | ||
2346 | 2346 | ||
2347 | void CalendarView::readSettings() | 2347 | void CalendarView::readSettings() |
2348 | { | 2348 | { |
2349 | 2349 | ||
2350 | 2350 | ||
2351 | // mViewManager->showAgendaView(); | 2351 | // mViewManager->showAgendaView(); |
2352 | QString str; | 2352 | QString str; |
2353 | //qDebug("CalendarView::readSettings() "); | 2353 | //qDebug("CalendarView::readSettings() "); |
2354 | // read settings from the KConfig, supplying reasonable | 2354 | // read settings from the KConfig, supplying reasonable |
2355 | // defaults where none are to be found | 2355 | // defaults where none are to be found |
2356 | KConfig *config = KOGlobals::config(); | 2356 | KConfig *config = KOGlobals::config(); |
2357 | #ifndef KORG_NOSPLITTER | 2357 | #ifndef KORG_NOSPLITTER |
2358 | config->setGroup("KOrganizer Geometry"); | 2358 | config->setGroup("KOrganizer Geometry"); |
2359 | 2359 | ||
2360 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2360 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2361 | if (sizes.count() != 2) { | 2361 | if (sizes.count() != 2) { |
2362 | sizes << mDateNavigator->minimumSizeHint().width(); | 2362 | sizes << mDateNavigator->minimumSizeHint().width(); |
2363 | sizes << 300; | 2363 | sizes << 300; |
2364 | } | 2364 | } |
2365 | mPanner->setSizes(sizes); | 2365 | mPanner->setSizes(sizes); |
2366 | 2366 | ||
2367 | sizes = config->readIntListEntry("Separator2"); | 2367 | sizes = config->readIntListEntry("Separator2"); |
2368 | if ( ( mResourceView && sizes.count() == 4 ) || | 2368 | if ( ( mResourceView && sizes.count() == 4 ) || |
2369 | ( !mResourceView && sizes.count() == 3 ) ) { | 2369 | ( !mResourceView && sizes.count() == 3 ) ) { |
2370 | mLeftSplitter->setSizes(sizes); | 2370 | mLeftSplitter->setSizes(sizes); |
2371 | } | 2371 | } |
2372 | #endif | 2372 | #endif |
2373 | globalFlagBlockAgenda = 1; | 2373 | globalFlagBlockAgenda = 1; |
2374 | mViewManager->showAgendaView(); | 2374 | mViewManager->showAgendaView(); |
2375 | //mViewManager->readSettings( config ); | 2375 | //mViewManager->readSettings( config ); |
2376 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2376 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2377 | readFilterSettings(config); | 2377 | readFilterSettings(config); |
2378 | 2378 | ||
2379 | #ifdef DESKTOP_VERSION | 2379 | #ifdef DESKTOP_VERSION |
2380 | config->setGroup("WidgetLayout"); | 2380 | config->setGroup("WidgetLayout"); |
2381 | QStringList list; | 2381 | QStringList list; |
2382 | list = config->readListEntry("MainLayout"); | 2382 | list = config->readListEntry("MainLayout"); |
2383 | int x,y,w,h; | 2383 | int x,y,w,h; |
2384 | if ( ! list.isEmpty() ) { | 2384 | if ( ! list.isEmpty() ) { |
2385 | x = list[0].toInt(); | 2385 | x = list[0].toInt(); |
2386 | y = list[1].toInt(); | 2386 | y = list[1].toInt(); |
2387 | w = list[2].toInt(); | 2387 | w = list[2].toInt(); |
2388 | h = list[3].toInt(); | 2388 | h = list[3].toInt(); |
2389 | KApplication::testCoords( &x,&y,&w,&h ); | 2389 | KApplication::testCoords( &x,&y,&w,&h ); |
2390 | topLevelWidget()->setGeometry(x,y,w,h); | 2390 | topLevelWidget()->setGeometry(x,y,w,h); |
2391 | 2391 | ||
2392 | } else { | 2392 | } else { |
2393 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2393 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2394 | } | 2394 | } |
2395 | list = config->readListEntry("EditEventLayout"); | 2395 | list = config->readListEntry("EditEventLayout"); |
2396 | if ( ! list.isEmpty() ) { | 2396 | if ( ! list.isEmpty() ) { |
2397 | x = list[0].toInt(); | 2397 | x = list[0].toInt(); |
2398 | y = list[1].toInt(); | 2398 | y = list[1].toInt(); |
2399 | w = list[2].toInt(); | 2399 | w = list[2].toInt(); |
2400 | h = list[3].toInt(); | 2400 | h = list[3].toInt(); |
2401 | KApplication::testCoords( &x,&y,&w,&h ); | 2401 | KApplication::testCoords( &x,&y,&w,&h ); |
2402 | mEventEditor->setGeometry(x,y,w,h); | 2402 | mEventEditor->setGeometry(x,y,w,h); |
2403 | 2403 | ||
2404 | } | 2404 | } |
2405 | list = config->readListEntry("EditTodoLayout"); | 2405 | list = config->readListEntry("EditTodoLayout"); |
2406 | if ( ! list.isEmpty() ) { | 2406 | if ( ! list.isEmpty() ) { |
2407 | x = list[0].toInt(); | 2407 | x = list[0].toInt(); |
2408 | y = list[1].toInt(); | 2408 | y = list[1].toInt(); |
2409 | w = list[2].toInt(); | 2409 | w = list[2].toInt(); |
2410 | h = list[3].toInt(); | 2410 | h = list[3].toInt(); |
2411 | KApplication::testCoords( &x,&y,&w,&h ); | 2411 | KApplication::testCoords( &x,&y,&w,&h ); |
2412 | mTodoEditor->setGeometry(x,y,w,h); | 2412 | mTodoEditor->setGeometry(x,y,w,h); |
2413 | 2413 | ||
2414 | } | 2414 | } |
2415 | list = config->readListEntry("ViewerLayout"); | 2415 | list = config->readListEntry("ViewerLayout"); |
2416 | if ( ! list.isEmpty() ) { | 2416 | if ( ! list.isEmpty() ) { |
2417 | x = list[0].toInt(); | 2417 | x = list[0].toInt(); |
2418 | y = list[1].toInt(); | 2418 | y = list[1].toInt(); |
2419 | w = list[2].toInt(); | 2419 | w = list[2].toInt(); |
2420 | h = list[3].toInt(); | 2420 | h = list[3].toInt(); |
2421 | KApplication::testCoords( &x,&y,&w,&h ); | 2421 | KApplication::testCoords( &x,&y,&w,&h ); |
2422 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2422 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2423 | } | 2423 | } |
2424 | #endif | 2424 | #endif |
2425 | config->setGroup( "Views" ); | 2425 | config->setGroup( "Views" ); |
2426 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2426 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2427 | 2427 | ||
2428 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2428 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2429 | 2429 | ||
2430 | int resetval = 0; | 2430 | int resetval = 0; |
2431 | int maxVal = 0; | 2431 | int maxVal = 0; |
2432 | if (sizes.count() != 3) { | 2432 | if (sizes.count() != 3) { |
2433 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2433 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2434 | resetval = mDateNavigator->sizeHint().width()+2; | 2434 | resetval = mDateNavigator->sizeHint().width()+2; |
2435 | } else { | 2435 | } else { |
2436 | resetval = mDateNavigator->sizeHint().height()+2; | 2436 | resetval = mDateNavigator->sizeHint().height()+2; |
2437 | } | 2437 | } |
2438 | } | 2438 | } |
2439 | if ( resetval ) { | 2439 | if ( resetval ) { |
2440 | sizes.clear(); | 2440 | sizes.clear(); |
2441 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2441 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2442 | maxVal = QApplication::desktop()->width() -10; | 2442 | maxVal = QApplication::desktop()->width() -10; |
2443 | } else { | 2443 | } else { |
2444 | maxVal = QApplication::desktop()->height()-10; | 2444 | maxVal = QApplication::desktop()->height()-10; |
2445 | } | 2445 | } |
2446 | sizes << resetval; | 2446 | sizes << resetval; |
2447 | if ( maxVal < resetval + resetval) | 2447 | if ( maxVal < resetval + resetval) |
2448 | resetval = maxVal - resetval; | 2448 | resetval = maxVal - resetval; |
2449 | sizes << resetval; | 2449 | sizes << resetval; |
2450 | sizes << 100; | 2450 | sizes << 100; |
2451 | } | 2451 | } |
2452 | mLeftFrame->setSizes(sizes); | 2452 | mLeftFrame->setSizes(sizes); |
2453 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2453 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2454 | resetval = 0; | 2454 | resetval = 0; |
2455 | maxVal = 0; | 2455 | maxVal = 0; |
2456 | if (sizes.count() != 2) { | 2456 | if (sizes.count() != 2) { |
2457 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2457 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2458 | resetval = mDateNavigator->sizeHint().width()+2; | 2458 | resetval = mDateNavigator->sizeHint().width()+2; |
2459 | } else { | 2459 | } else { |
2460 | resetval = mDateNavigator->sizeHint().height()+2; | 2460 | resetval = mDateNavigator->sizeHint().height()+2; |
2461 | } | 2461 | } |
2462 | } | 2462 | } |
2463 | if ( resetval ) { | 2463 | if ( resetval ) { |
2464 | sizes.clear(); | 2464 | sizes.clear(); |
2465 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2465 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2466 | maxVal = QApplication::desktop()->width() -10; | 2466 | maxVal = QApplication::desktop()->width() -10; |
2467 | } else { | 2467 | } else { |
2468 | maxVal = QApplication::desktop()->height()-10; | 2468 | maxVal = QApplication::desktop()->height()-10; |
2469 | } | 2469 | } |
2470 | sizes << resetval; | 2470 | sizes << resetval; |
2471 | if ( maxVal < resetval + resetval) | 2471 | if ( maxVal < resetval + resetval) |
2472 | resetval = maxVal - resetval; | 2472 | resetval = maxVal - resetval; |
2473 | sizes << resetval; | 2473 | sizes << resetval; |
2474 | } | 2474 | } |
2475 | mMainFrame->setSizes(sizes); | 2475 | mMainFrame->setSizes(sizes); |
2476 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2476 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2477 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2477 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2478 | else mNavigator->selectDates( dateCount ); | 2478 | else mNavigator->selectDates( dateCount ); |
2479 | // mViewManager->readSettings( config ); | 2479 | // mViewManager->readSettings( config ); |
2480 | updateConfig(); | 2480 | updateConfig(); |
2481 | globalFlagBlockAgenda = 2; | 2481 | globalFlagBlockAgenda = 2; |
2482 | mViewManager->readSettings( config ); | 2482 | mViewManager->readSettings( config ); |
2483 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2483 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2484 | } | 2484 | } |
2485 | 2485 | ||
2486 | void CalendarView::checkSuspendAlarm() | 2486 | void CalendarView::checkSuspendAlarm() |
2487 | { | 2487 | { |
2488 | if ( mSuspendTimer->isActive() ) { | 2488 | if ( mSuspendTimer->isActive() ) { |
2489 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2489 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2490 | } | 2490 | } |
2491 | } | 2491 | } |
2492 | void CalendarView::writeSettings() | 2492 | void CalendarView::writeSettings() |
2493 | { | 2493 | { |
2494 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2494 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2495 | 2495 | ||
2496 | KConfig *config = KOGlobals::config(); | 2496 | KConfig *config = KOGlobals::config(); |
2497 | 2497 | ||
2498 | mViewManager->writeSettings( config ); | 2498 | mViewManager->writeSettings( config ); |
2499 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2499 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2500 | mDialogManager->writeSettings( config ); | 2500 | mDialogManager->writeSettings( config ); |
2501 | //KOPrefs::instance()->usrWriteConfig(); | 2501 | //KOPrefs::instance()->usrWriteConfig(); |
2502 | KOPrefs::instance()->writeConfig(); | 2502 | KOPrefs::instance()->writeConfig(); |
2503 | 2503 | ||
2504 | writeFilterSettings(config); | 2504 | writeFilterSettings(config); |
2505 | config->setGroup( "AppRun" ); | 2505 | config->setGroup( "AppRun" ); |
2506 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2506 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2507 | int days = dt.daysTo( QDate::currentDate() ); | 2507 | int days = dt.daysTo( QDate::currentDate() ); |
2508 | dt = dt.addDays( days ); | 2508 | dt = dt.addDays( days ); |
2509 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2509 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2510 | config->writeEntry( "LatestProgramStopDays", days ); | 2510 | config->writeEntry( "LatestProgramStopDays", days ); |
2511 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2511 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2512 | //qDebug("KO: Writing stop time: %d ", secs); | 2512 | //qDebug("KO: Writing stop time: %d ", secs); |
2513 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2513 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2514 | //QDateTime latest = dt.addSecs ( secs ); | 2514 | //QDateTime latest = dt.addSecs ( secs ); |
2515 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2515 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2516 | config->setGroup( "Views" ); | 2516 | config->setGroup( "Views" ); |
2517 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2517 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2518 | 2518 | ||
2519 | #if 0 | 2519 | #if 0 |
2520 | qDebug("********************* "); | 2520 | qDebug("********************* "); |
2521 | qDebug("Testcode secsto "); | 2521 | qDebug("Testcode secsto "); |
2522 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2522 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2523 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2523 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2524 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2524 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2525 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2525 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2526 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2526 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2527 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2527 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2528 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2528 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2529 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2529 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2530 | qDebug("********************* testcode end"); | 2530 | qDebug("********************* testcode end"); |
2531 | 2531 | ||
2532 | #endif | 2532 | #endif |
2533 | 2533 | ||
2534 | QValueList<int> listINT = mLeftFrame->sizes(); | 2534 | QValueList<int> listINT = mLeftFrame->sizes(); |
2535 | config->writeEntry("Left Splitter Frame",listINT); | 2535 | config->writeEntry("Left Splitter Frame",listINT); |
2536 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2536 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2537 | config->writeEntry("Main Splitter Frame",listINT2); | 2537 | config->writeEntry("Main Splitter Frame",listINT2); |
2538 | #ifdef DESKTOP_VERSION | 2538 | #ifdef DESKTOP_VERSION |
2539 | config->setGroup("WidgetLayout"); | 2539 | config->setGroup("WidgetLayout"); |
2540 | QStringList list ;//= config->readListEntry("MainLayout"); | 2540 | QStringList list ;//= config->readListEntry("MainLayout"); |
2541 | int x,y,w,h; | 2541 | int x,y,w,h; |
2542 | QWidget* wid; | 2542 | QWidget* wid; |
2543 | wid = topLevelWidget(); | 2543 | wid = topLevelWidget(); |
2544 | x = wid->geometry().x(); | 2544 | x = wid->geometry().x(); |
2545 | y = wid->geometry().y(); | 2545 | y = wid->geometry().y(); |
2546 | w = wid->width(); | 2546 | w = wid->width(); |
2547 | h = wid->height(); | 2547 | h = wid->height(); |
2548 | list.clear(); | 2548 | list.clear(); |
2549 | list << QString::number( x ); | 2549 | list << QString::number( x ); |
2550 | list << QString::number( y ); | 2550 | list << QString::number( y ); |
2551 | list << QString::number( w ); | 2551 | list << QString::number( w ); |
2552 | list << QString::number( h ); | 2552 | list << QString::number( h ); |
2553 | config->writeEntry("MainLayout",list ); | 2553 | config->writeEntry("MainLayout",list ); |
2554 | 2554 | ||
2555 | wid = mEventEditor; | 2555 | wid = mEventEditor; |
2556 | x = wid->geometry().x(); | 2556 | x = wid->geometry().x(); |
2557 | y = wid->geometry().y(); | 2557 | y = wid->geometry().y(); |
2558 | w = wid->width(); | 2558 | w = wid->width(); |
2559 | h = wid->height(); | 2559 | h = wid->height(); |
2560 | list.clear(); | 2560 | list.clear(); |
2561 | list << QString::number( x ); | 2561 | list << QString::number( x ); |
2562 | list << QString::number( y ); | 2562 | list << QString::number( y ); |
2563 | list << QString::number( w ); | 2563 | list << QString::number( w ); |
2564 | list << QString::number( h ); | 2564 | list << QString::number( h ); |
2565 | config->writeEntry("EditEventLayout",list ); | 2565 | config->writeEntry("EditEventLayout",list ); |
2566 | 2566 | ||
2567 | wid = mTodoEditor; | 2567 | wid = mTodoEditor; |
2568 | x = wid->geometry().x(); | 2568 | x = wid->geometry().x(); |
2569 | y = wid->geometry().y(); | 2569 | y = wid->geometry().y(); |
2570 | w = wid->width(); | 2570 | w = wid->width(); |
2571 | h = wid->height(); | 2571 | h = wid->height(); |
2572 | list.clear(); | 2572 | list.clear(); |
2573 | list << QString::number( x ); | 2573 | list << QString::number( x ); |
2574 | list << QString::number( y ); | 2574 | list << QString::number( y ); |
2575 | list << QString::number( w ); | 2575 | list << QString::number( w ); |
2576 | list << QString::number( h ); | 2576 | list << QString::number( h ); |
2577 | config->writeEntry("EditTodoLayout",list ); | 2577 | config->writeEntry("EditTodoLayout",list ); |
2578 | wid = getEventViewerDialog(); | 2578 | wid = getEventViewerDialog(); |
2579 | x = wid->geometry().x(); | 2579 | x = wid->geometry().x(); |
2580 | y = wid->geometry().y(); | 2580 | y = wid->geometry().y(); |
2581 | w = wid->width(); | 2581 | w = wid->width(); |
2582 | h = wid->height(); | 2582 | h = wid->height(); |
2583 | list.clear(); | 2583 | list.clear(); |
2584 | list << QString::number( x ); | 2584 | list << QString::number( x ); |
2585 | list << QString::number( y ); | 2585 | list << QString::number( y ); |
2586 | list << QString::number( w ); | 2586 | list << QString::number( w ); |
2587 | list << QString::number( h ); | 2587 | list << QString::number( h ); |
2588 | config->writeEntry("ViewerLayout",list ); | 2588 | config->writeEntry("ViewerLayout",list ); |
2589 | wid = mDialogManager->getSearchDialog(); | 2589 | wid = mDialogManager->getSearchDialog(); |
2590 | if ( wid ) { | 2590 | if ( wid ) { |
2591 | x = wid->geometry().x(); | 2591 | x = wid->geometry().x(); |
2592 | y = wid->geometry().y(); | 2592 | y = wid->geometry().y(); |
2593 | w = wid->width(); | 2593 | w = wid->width(); |
2594 | h = wid->height(); | 2594 | h = wid->height(); |
2595 | list.clear(); | 2595 | list.clear(); |
2596 | list << QString::number( x ); | 2596 | list << QString::number( x ); |
2597 | list << QString::number( y ); | 2597 | list << QString::number( y ); |
2598 | list << QString::number( w ); | 2598 | list << QString::number( w ); |
2599 | list << QString::number( h ); | 2599 | list << QString::number( h ); |
2600 | config->writeEntry("SearchLayout",list ); | 2600 | config->writeEntry("SearchLayout",list ); |
2601 | } | 2601 | } |
2602 | #endif | 2602 | #endif |
2603 | 2603 | ||
2604 | 2604 | ||
2605 | config->sync(); | 2605 | config->sync(); |
2606 | } | 2606 | } |
2607 | 2607 | ||
2608 | void CalendarView::readFilterSettings(KConfig *config) | 2608 | void CalendarView::readFilterSettings(KConfig *config) |
2609 | { | 2609 | { |
2610 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2610 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2611 | 2611 | ||
2612 | mFilters.clear(); | 2612 | mFilters.clear(); |
2613 | 2613 | ||
2614 | config->setGroup("General"); | 2614 | config->setGroup("General"); |
2615 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2615 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2616 | 2616 | ||
2617 | QStringList::ConstIterator it = filterList.begin(); | 2617 | QStringList::ConstIterator it = filterList.begin(); |
2618 | QStringList::ConstIterator end = filterList.end(); | 2618 | QStringList::ConstIterator end = filterList.end(); |
2619 | while(it != end) { | 2619 | while(it != end) { |
2620 | // kdDebug() << " filter: " << (*it) << endl; | 2620 | // kdDebug() << " filter: " << (*it) << endl; |
2621 | 2621 | ||
2622 | CalFilter *filter; | 2622 | CalFilter *filter; |
2623 | filter = new CalFilter(*it); | 2623 | filter = new CalFilter(*it); |
2624 | config->setGroup("Filter_" + (*it).utf8()); | 2624 | config->setGroup("Filter_" + (*it).utf8()); |
2625 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2625 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2626 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2626 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2627 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2627 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2628 | mFilters.append(filter); | 2628 | mFilters.append(filter); |
2629 | 2629 | ||
2630 | ++it; | 2630 | ++it; |
2631 | } | 2631 | } |
2632 | 2632 | ||
2633 | if (mFilters.count() == 0) { | 2633 | if (mFilters.count() == 0) { |
2634 | CalFilter *filter = new CalFilter(i18n("Default")); | 2634 | CalFilter *filter = new CalFilter(i18n("Default")); |
2635 | mFilters.append(filter); | 2635 | mFilters.append(filter); |
2636 | } | 2636 | } |
2637 | mFilterView->updateFilters(); | 2637 | mFilterView->updateFilters(); |
2638 | config->setGroup("FilterView"); | 2638 | config->setGroup("FilterView"); |
2639 | 2639 | ||
2640 | mFilterView->blockSignals(true); | 2640 | mFilterView->blockSignals(true); |
2641 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2641 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2642 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2642 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2643 | mFilterView->blockSignals(false); | 2643 | mFilterView->blockSignals(false); |
2644 | // We do it manually to avoid it being done twice by the above calls | 2644 | // We do it manually to avoid it being done twice by the above calls |
2645 | updateFilter(); | 2645 | updateFilter(); |
2646 | } | 2646 | } |
2647 | 2647 | ||
2648 | void CalendarView::writeFilterSettings(KConfig *config) | 2648 | void CalendarView::writeFilterSettings(KConfig *config) |
2649 | { | 2649 | { |
2650 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2650 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2651 | 2651 | ||
2652 | QStringList filterList; | 2652 | QStringList filterList; |
2653 | 2653 | ||
2654 | CalFilter *filter = mFilters.first(); | 2654 | CalFilter *filter = mFilters.first(); |
2655 | while(filter) { | 2655 | while(filter) { |
2656 | // kdDebug() << " fn: " << filter->name() << endl; | 2656 | // kdDebug() << " fn: " << filter->name() << endl; |
2657 | filterList << filter->name(); | 2657 | filterList << filter->name(); |
2658 | config->setGroup("Filter_" + filter->name().utf8()); | 2658 | config->setGroup("Filter_" + filter->name().utf8()); |
2659 | config->writeEntry("Criteria",filter->criteria()); | 2659 | config->writeEntry("Criteria",filter->criteria()); |
2660 | config->writeEntry("CategoryList",filter->categoryList()); | 2660 | config->writeEntry("CategoryList",filter->categoryList()); |
2661 | filter = mFilters.next(); | 2661 | filter = mFilters.next(); |
2662 | } | 2662 | } |
2663 | config->setGroup("General"); | 2663 | config->setGroup("General"); |
2664 | config->writeEntry("CalendarFilters",filterList); | 2664 | config->writeEntry("CalendarFilters",filterList); |
2665 | 2665 | ||
2666 | config->setGroup("FilterView"); | 2666 | config->setGroup("FilterView"); |
2667 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2667 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2668 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2668 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2669 | } | 2669 | } |
2670 | 2670 | ||
2671 | 2671 | ||
2672 | void CalendarView::goToday() | 2672 | void CalendarView::goToday() |
2673 | { | 2673 | { |
2674 | if ( mViewManager->currentView()->isMonthView() ) | 2674 | if ( mViewManager->currentView()->isMonthView() ) |
2675 | mNavigator->selectTodayMonth(); | 2675 | mNavigator->selectTodayMonth(); |
2676 | else | 2676 | else |
2677 | mNavigator->selectToday(); | 2677 | mNavigator->selectToday(); |
2678 | } | 2678 | } |
2679 | 2679 | ||
2680 | void CalendarView::goNext() | 2680 | void CalendarView::goNext() |
2681 | { | 2681 | { |
2682 | mNavigator->selectNext(); | 2682 | mNavigator->selectNext(); |
2683 | } | 2683 | } |
2684 | 2684 | ||
2685 | void CalendarView::goPrevious() | 2685 | void CalendarView::goPrevious() |
2686 | { | 2686 | { |
2687 | mNavigator->selectPrevious(); | 2687 | mNavigator->selectPrevious(); |
2688 | } | 2688 | } |
2689 | void CalendarView::goNextMonth() | 2689 | void CalendarView::goNextMonth() |
2690 | { | 2690 | { |
2691 | mNavigator->selectNextMonth(); | 2691 | mNavigator->selectNextMonth(); |
2692 | } | 2692 | } |
2693 | 2693 | ||
2694 | void CalendarView::goPreviousMonth() | 2694 | void CalendarView::goPreviousMonth() |
2695 | { | 2695 | { |
2696 | mNavigator->selectPreviousMonth(); | 2696 | mNavigator->selectPreviousMonth(); |
2697 | } | 2697 | } |
2698 | 2698 | ||
2699 | void CalendarView::updateConfig() | 2699 | void CalendarView::updateConfig() |
2700 | { | 2700 | { |
2701 | if ( KOPrefs::instance()->mUseAppColors ) | 2701 | if ( KOPrefs::instance()->mUseAppColors ) |
2702 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2702 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2703 | emit configChanged(); | 2703 | emit configChanged(); |
2704 | mTodoList->updateConfig(); | 2704 | mTodoList->updateConfig(); |
2705 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2705 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2706 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2706 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2707 | // To make the "fill window" configurations work | 2707 | // To make the "fill window" configurations work |
2708 | //mViewManager->raiseCurrentView(); | 2708 | //mViewManager->raiseCurrentView(); |
2709 | } | 2709 | } |
2710 | 2710 | ||
2711 | 2711 | ||
2712 | void CalendarView::eventChanged(Event *event) | 2712 | void CalendarView::eventChanged(Event *event) |
2713 | { | 2713 | { |
2714 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2714 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2715 | //updateUnmanagedViews(); | 2715 | //updateUnmanagedViews(); |
2716 | } | 2716 | } |
2717 | 2717 | ||
2718 | void CalendarView::eventAdded(Event *event) | 2718 | void CalendarView::eventAdded(Event *event) |
2719 | { | 2719 | { |
2720 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2720 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2721 | } | 2721 | } |
2722 | 2722 | ||
2723 | void CalendarView::eventToBeDeleted(Event *) | 2723 | void CalendarView::eventToBeDeleted(Event *) |
2724 | { | 2724 | { |
2725 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2725 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2726 | } | 2726 | } |
2727 | 2727 | ||
2728 | void CalendarView::eventDeleted() | 2728 | void CalendarView::eventDeleted() |
2729 | { | 2729 | { |
2730 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2730 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2731 | } | 2731 | } |
2732 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2732 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2733 | { | 2733 | { |
2734 | changeIncidenceDisplay((Incidence *)which, action); | 2734 | changeIncidenceDisplay((Incidence *)which, action); |
2735 | mDateNavigator->updateView(); //LR | 2735 | mDateNavigator->updateView(); //LR |
2736 | //mDialogManager->updateSearchDialog(); | 2736 | //mDialogManager->updateSearchDialog(); |
2737 | 2737 | ||
2738 | if (which) { | 2738 | if (which) { |
2739 | mViewManager->updateWNview(); | 2739 | mViewManager->updateWNview(); |
2740 | //mTodoList->updateView(); | 2740 | //mTodoList->updateView(); |
2741 | } | 2741 | } |
2742 | 2742 | ||
2743 | } | 2743 | } |
2744 | 2744 | ||
2745 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2745 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2746 | { | 2746 | { |
2747 | updateUnmanagedViews(); | 2747 | updateUnmanagedViews(); |
2748 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2748 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2749 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2749 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2750 | mCalendar->checkAlarmForIncidence( 0, true ); | 2750 | mCalendar->checkAlarmForIncidence( 0, true ); |
2751 | if ( mEventViewerDialog ) | 2751 | if ( mEventViewerDialog ) |
2752 | mEventViewerDialog->hide(); | 2752 | mEventViewerDialog->hide(); |
2753 | } | 2753 | } |
2754 | else | 2754 | else |
2755 | mCalendar->checkAlarmForIncidence( which , false ); | 2755 | mCalendar->checkAlarmForIncidence( which , false ); |
2756 | } | 2756 | } |
2757 | 2757 | ||
2758 | // most of the changeEventDisplays() right now just call the view's | 2758 | // most of the changeEventDisplays() right now just call the view's |
2759 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2759 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2760 | void CalendarView::changeEventDisplay(Event *which, int action) | 2760 | void CalendarView::changeEventDisplay(Event *which, int action) |
2761 | { | 2761 | { |
2762 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2762 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2763 | changeIncidenceDisplay((Incidence *)which, action); | 2763 | changeIncidenceDisplay((Incidence *)which, action); |
2764 | static bool clearallviews = false; | 2764 | static bool clearallviews = false; |
2765 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2765 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2766 | if ( clearallviews ) { | 2766 | if ( clearallviews ) { |
2767 | clearAllViews(); | 2767 | clearAllViews(); |
2768 | clearallviews = false; | 2768 | clearallviews = false; |
2769 | } | 2769 | } |
2770 | return; | 2770 | return; |
2771 | } | 2771 | } |
2772 | clearallviews = true; | 2772 | clearallviews = true; |
2773 | mDateNavigator->updateView(); | 2773 | mDateNavigator->updateView(); |
2774 | //mDialogManager->updateSearchDialog(); | 2774 | //mDialogManager->updateSearchDialog(); |
2775 | if (which) { | 2775 | if (which) { |
2776 | // If there is an event view visible update the display | 2776 | // If there is an event view visible update the display |
2777 | mViewManager->currentView()->changeEventDisplay(which,action); | 2777 | mViewManager->currentView()->changeEventDisplay(which,action); |
2778 | // TODO: check, if update needed | 2778 | // TODO: check, if update needed |
2779 | // if (which->getTodoStatus()) { | 2779 | // if (which->getTodoStatus()) { |
2780 | mTodoList->updateView(); | 2780 | mTodoList->updateView(); |
2781 | if ( action != KOGlobals::EVENTDELETED ) { | 2781 | if ( action != KOGlobals::EVENTDELETED ) { |
2782 | mConflictingEvent = which ; | 2782 | mConflictingEvent = which ; |
2783 | int time = 1000; | 2783 | int time = 1000; |
2784 | #ifdef DESKTOP_VERSION | 2784 | #ifdef DESKTOP_VERSION |
2785 | time = 500; | 2785 | time = 500; |
2786 | #endif | 2786 | #endif |
2787 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); | 2787 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); |
2788 | } | 2788 | } |
2789 | // } | 2789 | // } |
2790 | } else { | 2790 | } else { |
2791 | mViewManager->currentView()->updateView(); | 2791 | mViewManager->currentView()->updateView(); |
2792 | } | 2792 | } |
2793 | } | 2793 | } |
2794 | void CalendarView::checkConflictForEvent() | 2794 | void CalendarView::checkConflictForEvent() |
2795 | { | 2795 | { |
2796 | 2796 | ||
2797 | if (!KOPrefs::instance()->mConfirm) | 2797 | if (!KOPrefs::instance()->mConfirm) |
2798 | return; | 2798 | return; |
2799 | if ( ! mConflictingEvent ) return; | 2799 | if ( ! mConflictingEvent ) return; |
2800 | Event * conflictingEvent = mConflictingEvent; | 2800 | Event * conflictingEvent = mConflictingEvent; |
2801 | mConflictingEvent = 0; | 2801 | mConflictingEvent = 0; |
2802 | QDateTime current = QDateTime::currentDateTime(); | 2802 | QDateTime current = QDateTime::currentDateTime(); |
2803 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { | 2803 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { |
2804 | return; | 2804 | return; |
2805 | } | 2805 | } |
2806 | QPtrList<Event> testlist = mCalendar->events(); | 2806 | QPtrList<Event> testlist = mCalendar->events(); |
2807 | Event * test = testlist.first(); | 2807 | Event * test = testlist.first(); |
2808 | QDateTime conflict; | 2808 | QDateTime conflict; |
2809 | QDateTime retVal; | 2809 | QDateTime retVal; |
2810 | bool found = false; | 2810 | bool found = false; |
2811 | Event * cE = 0; | 2811 | Event * cE = 0; |
2812 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 2812 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
2813 | while ( test ) { | 2813 | while ( test ) { |
2814 | qApp->processEvents(); | 2814 | qApp->processEvents(); |
2815 | bool skip = false; | 2815 | bool skip = false; |
2816 | if ( found ) | 2816 | if ( found ) |
2817 | skip = !test->matchTime( ¤t, &conflict ); | 2817 | skip = !test->matchTime( ¤t, &conflict ); |
2818 | else | 2818 | else |
2819 | skip = !test->matchTime( ¤t, 0 ); | 2819 | skip = !test->matchTime( ¤t, 0 ); |
2820 | if ( !skip && !test->doesFloat() ) { | 2820 | if ( !skip && !test->doesFloat() ) { |
2821 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 2821 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
2822 | if ( ! found ) { | 2822 | if ( ! found ) { |
2823 | conflict = retVal; | 2823 | conflict = retVal; |
2824 | cE = test; | 2824 | cE = test; |
2825 | } else { | 2825 | } else { |
2826 | if ( retVal < conflict ) { | 2826 | if ( retVal < conflict ) { |
2827 | conflict = retVal; | 2827 | conflict = retVal; |
2828 | cE = test; | 2828 | cE = test; |
2829 | } | 2829 | } |
2830 | } | 2830 | } |
2831 | found = true; | 2831 | found = true; |
2832 | } | 2832 | } |
2833 | } | 2833 | } |
2834 | test = testlist.next(); | 2834 | test = testlist.next(); |
2835 | } | 2835 | } |
2836 | topLevelWidget()->setCaption( i18n("KO/Pi") ); | 2836 | topLevelWidget()->setCaption( i18n("KO/Pi") ); |
2837 | if ( found ) { | 2837 | if ( found ) { |
2838 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 2838 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
2839 | qApp->processEvents(); | 2839 | qApp->processEvents(); |
2840 | int km = KMessageBox::warningContinueCancel(this,mess, | 2840 | int km = KMessageBox::warningContinueCancel(this,mess, |
2841 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | 2841 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); |
2842 | if ( km != KMessageBox::Continue ) { | 2842 | if ( km != KMessageBox::Continue ) { |
2843 | return; | 2843 | return; |
2844 | } | 2844 | } |
2845 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 2845 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
2846 | mViewManager->showDayView(); | 2846 | mViewManager->showDayView(); |
2847 | mNavigator->slotDaySelect( conflict.date() ); | 2847 | mNavigator->slotDaySelect( conflict.date() ); |
2848 | int hour = conflict.time().hour(); | 2848 | int hour = conflict.time().hour(); |
2849 | mViewManager->agendaView()->setStartHour( hour ); | 2849 | mViewManager->agendaView()->setStartHour( hour ); |
2850 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 2850 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
2851 | } else | 2851 | } else |
2852 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 2852 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
2853 | return; | 2853 | return; |
2854 | 2854 | ||
2855 | } | 2855 | } |
2856 | 2856 | ||
2857 | void CalendarView::updateTodoViews() | 2857 | void CalendarView::updateTodoViews() |
2858 | { | 2858 | { |
2859 | mTodoList->updateView(); | 2859 | mTodoList->updateView(); |
2860 | mViewManager->currentView()->updateView(); | 2860 | mViewManager->currentView()->updateView(); |
2861 | 2861 | ||
2862 | } | 2862 | } |
2863 | 2863 | ||
2864 | 2864 | ||
2865 | 2865 | ||
2866 | void CalendarView::clearAllViews() | 2866 | void CalendarView::clearAllViews() |
2867 | { | 2867 | { |
2868 | mTodoList->clearList(); | 2868 | mTodoList->clearList(); |
2869 | mViewManager->clearAllViews(); | 2869 | mViewManager->clearAllViews(); |
2870 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2870 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2871 | if ( sd ) { | 2871 | if ( sd ) { |
2872 | KOListView* kol = sd->listview(); | 2872 | KOListView* kol = sd->listview(); |
2873 | if ( kol ) | 2873 | if ( kol ) |
2874 | kol->clearList(); | 2874 | kol->clearList(); |
2875 | } | 2875 | } |
2876 | } | 2876 | } |
2877 | void CalendarView::updateView() | 2877 | void CalendarView::updateView() |
2878 | { | 2878 | { |
2879 | static bool clearallviews = false; | 2879 | static bool clearallviews = false; |
2880 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2880 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2881 | if ( clearallviews ) { | 2881 | if ( clearallviews ) { |
2882 | clearAllViews(); | 2882 | clearAllViews(); |
2883 | clearallviews = false; | 2883 | clearallviews = false; |
2884 | } | 2884 | } |
2885 | return; | 2885 | return; |
2886 | } | 2886 | } |
2887 | clearallviews = true; | 2887 | clearallviews = true; |
2888 | DateList tmpList = mNavigator->selectedDates(); | 2888 | DateList tmpList = mNavigator->selectedDates(); |
2889 | 2889 | ||
2890 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2890 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2891 | mTodoList->updateView(); | 2891 | mTodoList->updateView(); |
2892 | // We assume that the navigator only selects consecutive days. | 2892 | // We assume that the navigator only selects consecutive days. |
2893 | updateView( tmpList.first(), tmpList.last() ); | 2893 | updateView( tmpList.first(), tmpList.last() ); |
2894 | } | 2894 | } |
2895 | 2895 | ||
2896 | void CalendarView::updateUnmanagedViews() | 2896 | void CalendarView::updateUnmanagedViews() |
2897 | { | 2897 | { |
2898 | mDateNavigator->updateDayMatrix(); | 2898 | mDateNavigator->updateDayMatrix(); |
2899 | } | 2899 | } |
2900 | 2900 | ||
2901 | int CalendarView::msgItemDelete(const QString name) | 2901 | int CalendarView::msgItemDelete(const QString name) |
2902 | { | 2902 | { |
2903 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2903 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2904 | i18n("This item will be\npermanently deleted."), | 2904 | i18n("This item will be\npermanently deleted."), |
2905 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2905 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2906 | } | 2906 | } |
2907 | 2907 | ||
2908 | 2908 | ||
2909 | void CalendarView::edit_cut() | 2909 | void CalendarView::edit_cut() |
2910 | { | 2910 | { |
2911 | Event *anEvent=0; | 2911 | Event *anEvent=0; |
2912 | 2912 | ||
2913 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2913 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2914 | 2914 | ||
2915 | if (mViewManager->currentView()->isEventView()) { | 2915 | if (mViewManager->currentView()->isEventView()) { |
2916 | if ( incidence && incidence->typeID() == eventID ) { | 2916 | if ( incidence && incidence->typeID() == eventID ) { |
2917 | anEvent = static_cast<Event *>(incidence); | 2917 | anEvent = static_cast<Event *>(incidence); |
2918 | } | 2918 | } |
2919 | } | 2919 | } |
2920 | 2920 | ||
2921 | if (!anEvent) { | 2921 | if (!anEvent) { |
2922 | KNotifyClient::beep(); | 2922 | KNotifyClient::beep(); |
2923 | return; | 2923 | return; |
2924 | } | 2924 | } |
2925 | DndFactory factory( mCalendar ); | 2925 | DndFactory factory( mCalendar ); |
2926 | factory.cutIncidence(anEvent); | 2926 | factory.cutIncidence(anEvent); |
2927 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2927 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2928 | } | 2928 | } |
2929 | 2929 | ||
2930 | void CalendarView::edit_copy() | 2930 | void CalendarView::edit_copy() |
2931 | { | 2931 | { |
2932 | Event *anEvent=0; | 2932 | Event *anEvent=0; |
2933 | 2933 | ||
2934 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2934 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2935 | 2935 | ||
2936 | if (mViewManager->currentView()->isEventView()) { | 2936 | if (mViewManager->currentView()->isEventView()) { |
2937 | if ( incidence && incidence->typeID() == eventID ) { | 2937 | if ( incidence && incidence->typeID() == eventID ) { |
2938 | anEvent = static_cast<Event *>(incidence); | 2938 | anEvent = static_cast<Event *>(incidence); |
2939 | } | 2939 | } |
2940 | } | 2940 | } |
2941 | 2941 | ||
2942 | if (!anEvent) { | 2942 | if (!anEvent) { |
2943 | KNotifyClient::beep(); | 2943 | KNotifyClient::beep(); |
2944 | return; | 2944 | return; |
2945 | } | 2945 | } |
2946 | DndFactory factory( mCalendar ); | 2946 | DndFactory factory( mCalendar ); |
2947 | factory.copyIncidence(anEvent); | 2947 | factory.copyIncidence(anEvent); |
2948 | } | 2948 | } |
2949 | 2949 | ||
2950 | void CalendarView::edit_paste() | 2950 | void CalendarView::edit_paste() |
2951 | { | 2951 | { |
2952 | QDate date = mNavigator->selectedDates().first(); | 2952 | QDate date = mNavigator->selectedDates().first(); |
2953 | 2953 | ||
2954 | DndFactory factory( mCalendar ); | 2954 | DndFactory factory( mCalendar ); |
2955 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2955 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2956 | 2956 | ||
2957 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2957 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2958 | } | 2958 | } |
2959 | void CalendarView::edit_global_options() | 2959 | void CalendarView::edit_global_options() |
2960 | { | 2960 | { |
2961 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2961 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2962 | emit save(); | 2962 | emit save(); |
2963 | emit saveStopTimer(); | 2963 | emit saveStopTimer(); |
2964 | mDialogManager->showGlobalOptionsDialog(); | 2964 | mDialogManager->showGlobalOptionsDialog(); |
2965 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2965 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2966 | emit saveStopTimer(); | 2966 | emit saveStopTimer(); |
2967 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2967 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2968 | i18n("Timezone settings"),i18n("Reload"))) { | 2968 | i18n("Timezone settings"),i18n("Reload"))) { |
2969 | qDebug("KO: TZ reload cancelled "); | 2969 | qDebug("KO: TZ reload cancelled "); |
2970 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2970 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2971 | return; | 2971 | return; |
2972 | } | 2972 | } |
2973 | qDebug("KO: Timezone change "); | 2973 | qDebug("KO: Timezone change "); |
2974 | loadCalendars(); | 2974 | loadCalendars(); |
2975 | setModified(true); | 2975 | setModified(true); |
2976 | } | 2976 | } |
2977 | else | 2977 | else |
2978 | qDebug("KO: No tz change "); | 2978 | qDebug("KO: No tz change "); |
2979 | } | 2979 | } |
2980 | void CalendarView::edit_options() | 2980 | void CalendarView::edit_options() |
2981 | { | 2981 | { |
2982 | mDialogManager->showOptionsDialog(); | 2982 | mDialogManager->showOptionsDialog(); |
2983 | } | 2983 | } |
2984 | 2984 | ||
2985 | 2985 | ||
2986 | void CalendarView::slotSelectPickerDate( QDate d) | 2986 | void CalendarView::slotSelectPickerDate( QDate d) |
2987 | { | 2987 | { |
2988 | mDateFrame->hide(); | 2988 | mDateFrame->hide(); |
2989 | if ( mDatePickerMode == 1 ) { | 2989 | if ( mDatePickerMode == 1 ) { |
2990 | mNavigator->slotDaySelect( d ); | 2990 | mNavigator->slotDaySelect( d ); |
2991 | } else if ( mDatePickerMode == 2 ) { | 2991 | } else if ( mDatePickerMode == 2 ) { |
2992 | if ( mMoveIncidence->typeID() == todoID ) { | 2992 | if ( mMoveIncidence->typeID() == todoID ) { |
2993 | Todo * to = (Todo *) mMoveIncidence; | 2993 | Todo * to = (Todo *) mMoveIncidence; |
2994 | QTime tim; | 2994 | QTime tim; |
2995 | int len = 0; | 2995 | int len = 0; |
2996 | if ( to->hasStartDate() && to->hasDueDate() ) | 2996 | if ( to->hasStartDate() && to->hasDueDate() ) |
2997 | len = to->dtStart().secsTo( to->dtDue()); | 2997 | len = to->dtStart().secsTo( to->dtDue()); |
2998 | if ( to->hasDueDate() ) | 2998 | if ( to->hasDueDate() ) |
2999 | tim = to->dtDue().time(); | 2999 | tim = to->dtDue().time(); |
3000 | else { | 3000 | else { |
3001 | tim = QTime ( 0,0,0 ); | 3001 | tim = QTime ( 0,0,0 ); |
3002 | to->setFloats( true ); | 3002 | to->setFloats( true ); |
3003 | to->setHasDueDate( true ); | 3003 | to->setHasDueDate( true ); |
3004 | } | 3004 | } |
3005 | QDateTime dt ( d,tim ); | 3005 | QDateTime dt ( d,tim ); |
3006 | to->setDtDue( dt ); | 3006 | to->setDtDue( dt ); |
3007 | 3007 | ||
3008 | if ( to->hasStartDate() ) { | 3008 | if ( to->hasStartDate() ) { |
3009 | if ( len>0 ) | 3009 | if ( len>0 ) |
3010 | to->setDtStart(to->dtDue().addSecs( -len )); | 3010 | to->setDtStart(to->dtDue().addSecs( -len )); |
3011 | else | 3011 | else |
3012 | if (to->dtStart() > to->dtDue() ) | 3012 | if (to->dtStart() > to->dtDue() ) |
3013 | to->setDtStart(to->dtDue().addDays( -3 )); | 3013 | to->setDtStart(to->dtDue().addDays( -3 )); |
3014 | } | 3014 | } |
3015 | 3015 | ||
3016 | todoChanged( to ); | 3016 | todoChanged( to ); |
3017 | } else if ( mMoveIncidence->typeID() == eventID ) { | 3017 | } else if ( mMoveIncidence->typeID() == eventID ) { |
3018 | if ( mMoveIncidence->doesRecur() ) { | 3018 | if ( mMoveIncidence->doesRecur() ) { |
3019 | #if 0 | 3019 | #if 0 |
3020 | // PENDING implement this | 3020 | // PENDING implement this |
3021 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 3021 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3022 | mCalendar()->addIncidence( newInc ); | 3022 | mCalendar()->addIncidence( newInc ); |
3023 | if ( mMoveIncidence->typeID() == todoID ) | 3023 | if ( mMoveIncidence->typeID() == todoID ) |
3024 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 3024 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3025 | else | 3025 | else |
3026 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 3026 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3027 | mMoveIncidence = newInc; | 3027 | mMoveIncidence = newInc; |
3028 | 3028 | ||
3029 | #endif | 3029 | #endif |
3030 | } | 3030 | } |
3031 | QTime tim = mMoveIncidence->dtStart().time(); | 3031 | QTime tim = mMoveIncidence->dtStart().time(); |
3032 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 3032 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3033 | QDateTime dt ( d,tim ); | 3033 | QDateTime dt ( d,tim ); |
3034 | mMoveIncidence->setDtStart( dt ); | 3034 | mMoveIncidence->setDtStart( dt ); |
3035 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 3035 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3036 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 3036 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3037 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3037 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3038 | QTime tim = mMoveIncidence->dtStart().time(); | 3038 | QTime tim = mMoveIncidence->dtStart().time(); |
3039 | QDateTime dt ( d,tim ); | 3039 | QDateTime dt ( d,tim ); |
3040 | mMoveIncidence->setDtStart( dt ); | 3040 | mMoveIncidence->setDtStart( dt ); |
3041 | updateView(); | 3041 | updateView(); |
3042 | } | 3042 | } |
3043 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3043 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3044 | } | 3044 | } |
3045 | } | 3045 | } |
3046 | 3046 | ||
3047 | void CalendarView::removeCategories() | 3047 | void CalendarView::removeCategories() |
3048 | { | 3048 | { |
3049 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3049 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3050 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3050 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3051 | QStringList catIncList; | 3051 | QStringList catIncList; |
3052 | QStringList newCatList; | 3052 | QStringList newCatList; |
3053 | Incidence* inc = incList.first(); | 3053 | Incidence* inc = incList.first(); |
3054 | uint i; | 3054 | uint i; |
3055 | while ( inc ) { | 3055 | while ( inc ) { |
3056 | newCatList.clear(); | 3056 | newCatList.clear(); |
3057 | catIncList = inc->categories() ; | 3057 | catIncList = inc->categories() ; |
3058 | for( i = 0; i< catIncList.count(); ++i ) { | 3058 | for( i = 0; i< catIncList.count(); ++i ) { |
3059 | if ( catList.contains (catIncList[i])) | 3059 | if ( catList.contains (catIncList[i])) |
3060 | newCatList.append( catIncList[i] ); | 3060 | newCatList.append( catIncList[i] ); |
3061 | } | 3061 | } |
3062 | newCatList.sort(); | 3062 | newCatList.sort(); |
3063 | inc->setCategories( newCatList.join(",") ); | 3063 | inc->setCategories( newCatList.join(",") ); |
3064 | inc = incList.next(); | 3064 | inc = incList.next(); |
3065 | } | 3065 | } |
3066 | } | 3066 | } |
3067 | 3067 | ||
3068 | int CalendarView::addCategories() | 3068 | int CalendarView::addCategories() |
3069 | { | 3069 | { |
3070 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3070 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3071 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3071 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3072 | QStringList catIncList; | 3072 | QStringList catIncList; |
3073 | Incidence* inc = incList.first(); | 3073 | Incidence* inc = incList.first(); |
3074 | uint i; | 3074 | uint i; |
3075 | int count = 0; | 3075 | int count = 0; |
3076 | while ( inc ) { | 3076 | while ( inc ) { |
3077 | catIncList = inc->categories() ; | 3077 | catIncList = inc->categories() ; |
3078 | for( i = 0; i< catIncList.count(); ++i ) { | 3078 | for( i = 0; i< catIncList.count(); ++i ) { |
3079 | if ( !catList.contains (catIncList[i])) { | 3079 | if ( !catList.contains (catIncList[i])) { |
3080 | catList.append( catIncList[i] ); | 3080 | catList.append( catIncList[i] ); |
3081 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3081 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3082 | ++count; | 3082 | ++count; |
3083 | } | 3083 | } |
3084 | } | 3084 | } |
3085 | inc = incList.next(); | 3085 | inc = incList.next(); |
3086 | } | 3086 | } |
3087 | catList.sort(); | 3087 | catList.sort(); |
3088 | KOPrefs::instance()->mCustomCategories = catList; | 3088 | KOPrefs::instance()->mCustomCategories = catList; |
3089 | return count; | 3089 | return count; |
3090 | } | 3090 | } |
3091 | 3091 | ||
3092 | void CalendarView::editCategories() | 3092 | void CalendarView::editCategories() |
3093 | { | 3093 | { |
3094 | qDebug("CalendarView::editCategories() "); | 3094 | qDebug("CalendarView::editCategories() "); |
3095 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3095 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3096 | ced.exec(); | 3096 | ced.exec(); |
3097 | } | 3097 | } |
3098 | void CalendarView::manageCategories() | 3098 | void CalendarView::manageCategories() |
3099 | { | 3099 | { |
3100 | KOCatPrefs* cp = new KOCatPrefs(); | 3100 | KOCatPrefs* cp = new KOCatPrefs(); |
3101 | cp->show(); | 3101 | cp->show(); |
3102 | int w =cp->sizeHint().width() ; | 3102 | int w =cp->sizeHint().width() ; |
3103 | int h = cp->sizeHint().height() ; | 3103 | int h = cp->sizeHint().height() ; |
3104 | int dw = QApplication::desktop()->width(); | 3104 | int dw = QApplication::desktop()->width(); |
3105 | int dh = QApplication::desktop()->height(); | 3105 | int dh = QApplication::desktop()->height(); |
3106 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3106 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3107 | if ( !cp->exec() ) { | 3107 | if ( !cp->exec() ) { |
3108 | delete cp; | 3108 | delete cp; |
3109 | return; | 3109 | return; |
3110 | } | 3110 | } |
3111 | int count = 0; | 3111 | int count = 0; |
3112 | if ( cp->addCat() ) { | 3112 | if ( cp->addCat() ) { |
3113 | count = addCategories(); | 3113 | count = addCategories(); |
3114 | if ( count ) { | 3114 | if ( count ) { |
3115 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3115 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3116 | writeSettings(); | 3116 | writeSettings(); |
3117 | } else | 3117 | } else |
3118 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3118 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3119 | } else { | 3119 | } else { |
3120 | removeCategories(); | 3120 | removeCategories(); |
3121 | updateView(); | 3121 | updateView(); |
3122 | } | 3122 | } |
3123 | delete cp; | 3123 | delete cp; |
3124 | } | 3124 | } |
3125 | 3125 | ||
3126 | void CalendarView::beamIncidence(Incidence * Inc) | 3126 | void CalendarView::beamIncidence(Incidence * Inc) |
3127 | { | 3127 | { |
3128 | QPtrList<Incidence> delSel ; | 3128 | QPtrList<Incidence> delSel ; |
3129 | delSel.append(Inc); | 3129 | delSel.append(Inc); |
3130 | beamIncidenceList( delSel ); | 3130 | beamIncidenceList( delSel ); |
3131 | } | 3131 | } |
3132 | void CalendarView::beamCalendar() | 3132 | void CalendarView::beamCalendar() |
3133 | { | 3133 | { |
3134 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3134 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3135 | //qDebug("beamCalendar() "); | 3135 | //qDebug("beamCalendar() "); |
3136 | beamIncidenceList( delSel ); | 3136 | beamIncidenceList( delSel ); |
3137 | } | 3137 | } |
3138 | void CalendarView::beamFilteredCalendar() | 3138 | void CalendarView::beamFilteredCalendar() |
3139 | { | 3139 | { |
3140 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3140 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3141 | //qDebug("beamFilteredCalendar() "); | 3141 | //qDebug("beamFilteredCalendar() "); |
3142 | beamIncidenceList( delSel ); | 3142 | beamIncidenceList( delSel ); |
3143 | } | 3143 | } |
3144 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3144 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3145 | { | 3145 | { |
3146 | 3146 | ||
3147 | KOBeamPrefs beamDialog; | 3147 | KOBeamPrefs beamDialog; |
3148 | if ( beamDialog.exec () == QDialog::Rejected ) | 3148 | if ( beamDialog.exec () == QDialog::Rejected ) |
3149 | return; | 3149 | return; |
3150 | #ifdef DESKTOP_VERSION | 3150 | #ifdef DESKTOP_VERSION |
3151 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3151 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3152 | #else | 3152 | #else |
3153 | QString fn = "/tmp/kopibeamfile"; | 3153 | QString fn = "/tmp/kopibeamfile"; |
3154 | #endif | 3154 | #endif |
3155 | QString mes; | 3155 | QString mes; |
3156 | bool createbup = true; | 3156 | bool createbup = true; |
3157 | if ( createbup ) { | 3157 | if ( createbup ) { |
3158 | QString description = "\n"; | 3158 | QString description = "\n"; |
3159 | CalendarLocal* cal = new CalendarLocal(); | 3159 | CalendarLocal* cal = new CalendarLocal(); |
3160 | if ( beamDialog.beamLocal() ) | 3160 | if ( beamDialog.beamLocal() ) |
3161 | cal->setLocalTime(); | 3161 | cal->setLocalTime(); |
3162 | else | 3162 | else |
3163 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3163 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3164 | Incidence *incidence = delSel.first(); | 3164 | Incidence *incidence = delSel.first(); |
3165 | bool addText = false; | 3165 | bool addText = false; |
3166 | if ( delSel.count() < 10 ) | 3166 | if ( delSel.count() < 10 ) |
3167 | addText = true; | 3167 | addText = true; |
3168 | else { | 3168 | else { |
3169 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3169 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3170 | } | 3170 | } |
3171 | while ( incidence ) { | 3171 | while ( incidence ) { |
3172 | Incidence *in = incidence->clone(); | 3172 | Incidence *in = incidence->clone(); |
3173 | if ( ! in->summary().isEmpty() ) { | 3173 | if ( ! in->summary().isEmpty() ) { |
3174 | in->setDescription(""); | 3174 | in->setDescription(""); |
3175 | } else { | 3175 | } else { |
3176 | in->setSummary( in->description().left(20)); | 3176 | in->setSummary( in->description().left(20)); |
3177 | in->setDescription(""); | 3177 | in->setDescription(""); |
3178 | } | 3178 | } |
3179 | if ( addText ) | 3179 | if ( addText ) |
3180 | description += in->summary() + "\n"; | 3180 | description += in->summary() + "\n"; |
3181 | cal->addIncidence( in ); | 3181 | cal->addIncidence( in ); |
3182 | incidence = delSel.next(); | 3182 | incidence = delSel.next(); |
3183 | } | 3183 | } |
3184 | if ( beamDialog.beamVcal() ) { | 3184 | if ( beamDialog.beamVcal() ) { |
3185 | fn += ".vcs"; | 3185 | fn += ".vcs"; |
3186 | FileStorage storage( cal, fn, new VCalFormat ); | 3186 | FileStorage storage( cal, fn, new VCalFormat ); |
3187 | storage.save(); | 3187 | storage.save(); |
3188 | } else { | 3188 | } else { |
3189 | fn += ".ics"; | 3189 | fn += ".ics"; |
3190 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3190 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3191 | storage.save(); | 3191 | storage.save(); |
3192 | } | 3192 | } |
3193 | delete cal; | 3193 | delete cal; |
3194 | mes = i18n("KO/Pi: Ready for beaming"); | 3194 | mes = i18n("KO/Pi: Ready for beaming"); |
3195 | topLevelWidget()->setCaption(mes); | 3195 | topLevelWidget()->setCaption(mes); |
3196 | KApplication::convert2latin1( fn ); | 3196 | KApplication::convert2latin1( fn ); |
3197 | #ifndef DESKTOP_VERSION | 3197 | #ifndef DESKTOP_VERSION |
3198 | Ir *ir = new Ir( this ); | 3198 | Ir *ir = new Ir( this ); |
3199 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3199 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3200 | ir->send( fn, description, "text/x-vCalendar" ); | 3200 | ir->send( fn, description, "text/x-vCalendar" ); |
3201 | #endif | 3201 | #endif |
3202 | } | 3202 | } |
3203 | } | 3203 | } |
3204 | 3204 | ||
3205 | #ifndef DESKTOP_VERSION | 3205 | #ifndef DESKTOP_VERSION |
3206 | void CalendarView::beamDone( Ir *ir ) | 3206 | void CalendarView::beamDone( Ir *ir ) |
3207 | { | 3207 | { |
3208 | delete ir; | 3208 | delete ir; |
3209 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3209 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3210 | topLevelWidget()->raise(); | 3210 | topLevelWidget()->raise(); |
3211 | } | 3211 | } |
3212 | #else | 3212 | #else |
3213 | void CalendarView::beamDone( Ir *){;} | 3213 | void CalendarView::beamDone( Ir *){;} |
3214 | #endif | 3214 | #endif |
3215 | void CalendarView::moveIncidence(Incidence * inc ) | 3215 | void CalendarView::moveIncidence(Incidence * inc ) |
3216 | { | 3216 | { |
3217 | if ( !inc ) return; | 3217 | if ( !inc ) return; |
3218 | showDatePickerPopup(); | 3218 | showDatePickerPopup(); |
3219 | mDatePickerMode = 2; | 3219 | mDatePickerMode = 2; |
3220 | mMoveIncidence = inc ; | 3220 | mMoveIncidence = inc ; |
3221 | QDate da; | 3221 | QDate da; |
3222 | if ( mMoveIncidence->typeID() == todoID ) { | 3222 | if ( mMoveIncidence->typeID() == todoID ) { |
3223 | Todo * to = (Todo *) mMoveIncidence; | 3223 | Todo * to = (Todo *) mMoveIncidence; |
3224 | if ( to->hasDueDate() ) | 3224 | if ( to->hasDueDate() ) |
3225 | da = to->dtDue().date(); | 3225 | da = to->dtDue().date(); |
3226 | else | 3226 | else |
3227 | da = QDate::currentDate(); | 3227 | da = QDate::currentDate(); |
3228 | } else { | 3228 | } else { |
3229 | da = mMoveIncidence->dtStart().date(); | 3229 | da = mMoveIncidence->dtStart().date(); |
3230 | } | 3230 | } |
3231 | //PENDING set date for recurring incidence to date of recurrence | 3231 | //PENDING set date for recurring incidence to date of recurrence |
3232 | //mMoveIncidenceOldDate; | 3232 | //mMoveIncidenceOldDate; |
3233 | mDatePicker->setDate( da ); | 3233 | mDatePicker->setDate( da ); |
3234 | } | 3234 | } |
3235 | void CalendarView::showDatePickerPopup() | 3235 | void CalendarView::showDatePickerPopup() |
3236 | { | 3236 | { |
3237 | if ( mDateFrame->isVisible() ) | 3237 | if ( mDateFrame->isVisible() ) |
3238 | mDateFrame->hide(); | 3238 | mDateFrame->hide(); |
3239 | else { | 3239 | else { |
3240 | int offX = 0, offY = 0; | 3240 | int offX = 0, offY = 0; |
3241 | #ifdef DESKTOP_VERSION | 3241 | #ifdef DESKTOP_VERSION |
3242 | int w =mDatePicker->sizeHint().width() ; | 3242 | int w =mDatePicker->sizeHint().width() ; |
3243 | int h = mDatePicker->sizeHint().height() ; | 3243 | int h = mDatePicker->sizeHint().height() ; |
3244 | int dw = topLevelWidget()->width(); | 3244 | int dw = topLevelWidget()->width(); |
3245 | int dh = topLevelWidget()->height(); | 3245 | int dh = topLevelWidget()->height(); |
3246 | offX = topLevelWidget()->x(); | 3246 | offX = topLevelWidget()->x(); |
3247 | offY = topLevelWidget()->y(); | 3247 | offY = topLevelWidget()->y(); |
3248 | #else | 3248 | #else |
3249 | int w =mDatePicker->sizeHint().width() ; | 3249 | int w =mDatePicker->sizeHint().width() ; |
3250 | int h = mDatePicker->sizeHint().height() ; | 3250 | int h = mDatePicker->sizeHint().height() ; |
3251 | int dw = QApplication::desktop()->width(); | 3251 | int dw = QApplication::desktop()->width(); |
3252 | int dh = QApplication::desktop()->height(); | 3252 | int dh = QApplication::desktop()->height(); |
3253 | #endif | 3253 | #endif |
3254 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3254 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3255 | mDateFrame->show(); | 3255 | mDateFrame->show(); |
3256 | } | 3256 | } |
3257 | } | 3257 | } |
3258 | void CalendarView::showDatePicker( ) | 3258 | void CalendarView::showDatePicker( ) |
3259 | { | 3259 | { |
3260 | showDatePickerPopup(); | 3260 | showDatePickerPopup(); |
3261 | mDatePickerMode = 1; | 3261 | mDatePickerMode = 1; |
3262 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3262 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3263 | } | 3263 | } |
3264 | 3264 | ||
3265 | void CalendarView::showEventEditor() | 3265 | void CalendarView::showEventEditor() |
3266 | { | 3266 | { |
3267 | #ifdef DESKTOP_VERSION | 3267 | #ifdef DESKTOP_VERSION |
3268 | int x,y,w,h; | 3268 | int x,y,w,h; |
3269 | x = mEventEditor->geometry().x(); | 3269 | x = mEventEditor->geometry().x(); |
3270 | y = mEventEditor->geometry().y(); | 3270 | y = mEventEditor->geometry().y(); |
3271 | w = mEventEditor->width(); | 3271 | w = mEventEditor->width(); |
3272 | h = mEventEditor->height(); | 3272 | h = mEventEditor->height(); |
3273 | mEventEditor->show(); | 3273 | mEventEditor->show(); |
3274 | mEventEditor->setGeometry(x,y,w,h); | 3274 | mEventEditor->setGeometry(x,y,w,h); |
3275 | #else | 3275 | #else |
3276 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3276 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3277 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3277 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3278 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3278 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3279 | qApp->processEvents(); | 3279 | qApp->processEvents(); |
3280 | delete mEventEditor; | 3280 | delete mEventEditor; |
3281 | mEventEditor = mDialogManager->getEventEditor(); | 3281 | mEventEditor = mDialogManager->getEventEditor(); |
3282 | topLevelWidget()->setCaption( i18n("") ); | 3282 | topLevelWidget()->setCaption( i18n("") ); |
3283 | } | 3283 | } |
3284 | mEventEditor->showMaximized(); | 3284 | mEventEditor->showMaximized(); |
3285 | #endif | 3285 | #endif |
3286 | } | 3286 | } |
3287 | void CalendarView::showTodoEditor() | 3287 | void CalendarView::showTodoEditor() |
3288 | { | 3288 | { |
3289 | #ifdef DESKTOP_VERSION | 3289 | #ifdef DESKTOP_VERSION |
3290 | int x,y,w,h; | 3290 | int x,y,w,h; |
3291 | x = mTodoEditor->geometry().x(); | 3291 | x = mTodoEditor->geometry().x(); |
3292 | y = mTodoEditor->geometry().y(); | 3292 | y = mTodoEditor->geometry().y(); |
3293 | w = mTodoEditor->width(); | 3293 | w = mTodoEditor->width(); |
3294 | h = mTodoEditor->height(); | 3294 | h = mTodoEditor->height(); |
3295 | mTodoEditor->show(); | 3295 | mTodoEditor->show(); |
3296 | mTodoEditor->setGeometry(x,y,w,h); | 3296 | mTodoEditor->setGeometry(x,y,w,h); |
3297 | #else | 3297 | #else |
3298 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3298 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3299 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3299 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3300 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3300 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3301 | qApp->processEvents(); | 3301 | qApp->processEvents(); |
3302 | delete mTodoEditor; | 3302 | delete mTodoEditor; |
3303 | mTodoEditor = mDialogManager->getTodoEditor(); | 3303 | mTodoEditor = mDialogManager->getTodoEditor(); |
3304 | topLevelWidget()->setCaption( i18n("") ); | 3304 | topLevelWidget()->setCaption( i18n("") ); |
3305 | } | 3305 | } |
3306 | mTodoEditor->showMaximized(); | 3306 | mTodoEditor->showMaximized(); |
3307 | #endif | 3307 | #endif |
3308 | } | 3308 | } |
3309 | 3309 | ||
3310 | void CalendarView::cloneIncidence() | 3310 | void CalendarView::cloneIncidence() |
3311 | { | 3311 | { |
3312 | Incidence *incidence = currentSelection(); | 3312 | Incidence *incidence = currentSelection(); |
3313 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3313 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3314 | if ( incidence ) { | 3314 | if ( incidence ) { |
3315 | cloneIncidence(incidence); | 3315 | cloneIncidence(incidence); |
3316 | } | 3316 | } |
3317 | } | 3317 | } |
3318 | void CalendarView::moveIncidence() | 3318 | void CalendarView::moveIncidence() |
3319 | { | 3319 | { |
3320 | Incidence *incidence = currentSelection(); | 3320 | Incidence *incidence = currentSelection(); |
3321 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3321 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3322 | if ( incidence ) { | 3322 | if ( incidence ) { |
3323 | moveIncidence(incidence); | 3323 | moveIncidence(incidence); |
3324 | } | 3324 | } |
3325 | } | 3325 | } |
3326 | void CalendarView::beamIncidence() | 3326 | void CalendarView::beamIncidence() |
3327 | { | 3327 | { |
3328 | Incidence *incidence = currentSelection(); | 3328 | Incidence *incidence = currentSelection(); |
3329 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3329 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3330 | if ( incidence ) { | 3330 | if ( incidence ) { |
3331 | beamIncidence(incidence); | 3331 | beamIncidence(incidence); |
3332 | } | 3332 | } |
3333 | } | 3333 | } |
3334 | void CalendarView::toggleCancelIncidence() | 3334 | void CalendarView::toggleCancelIncidence() |
3335 | { | 3335 | { |
3336 | Incidence *incidence = currentSelection(); | 3336 | Incidence *incidence = currentSelection(); |
3337 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3337 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3338 | if ( incidence ) { | 3338 | if ( incidence ) { |
3339 | cancelIncidence(incidence); | 3339 | cancelIncidence(incidence); |
3340 | } | 3340 | } |
3341 | } | 3341 | } |
3342 | 3342 | ||
3343 | 3343 | ||
3344 | void CalendarView::cancelIncidence(Incidence * inc ) | 3344 | void CalendarView::cancelIncidence(Incidence * inc ) |
3345 | { | 3345 | { |
3346 | inc->setCancelled( ! inc->cancelled() ); | 3346 | inc->setCancelled( ! inc->cancelled() ); |
3347 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3347 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3348 | updateView(); | 3348 | updateView(); |
3349 | } | 3349 | } |
3350 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3350 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3351 | { | 3351 | { |
3352 | Incidence * newInc = orgInc->clone(); | 3352 | Incidence * newInc = orgInc->clone(); |
3353 | newInc->recreate(); | 3353 | newInc->recreate(); |
3354 | 3354 | ||
3355 | if ( newInc->typeID() == todoID ) { | 3355 | if ( newInc->typeID() == todoID ) { |
3356 | Todo* t = (Todo*) newInc; | 3356 | Todo* t = (Todo*) newInc; |
3357 | bool cloneSub = false; | 3357 | bool cloneSub = false; |
3358 | if ( orgInc->relations().count() ) { | 3358 | if ( orgInc->relations().count() ) { |
3359 | int result = KMessageBox::warningYesNoCancel(this, | 3359 | int result = KMessageBox::warningYesNoCancel(this, |
3360 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), | 3360 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), |
3361 | i18n("Todo has subtodos"), | 3361 | i18n("Todo has subtodos"), |
3362 | i18n("Yes"), | 3362 | i18n("Yes"), |
3363 | i18n("No")); | 3363 | i18n("No")); |
3364 | 3364 | ||
3365 | if ( result == KMessageBox::Cancel ) { | 3365 | if ( result == KMessageBox::Cancel ) { |
3366 | delete t; | 3366 | delete t; |
3367 | return; | 3367 | return; |
3368 | } | 3368 | } |
3369 | if (result == KMessageBox::Yes) cloneSub = true; | 3369 | if (result == KMessageBox::Yes) cloneSub = true; |
3370 | } | 3370 | } |
3371 | showTodoEditor(); | 3371 | showTodoEditor(); |
3372 | mTodoEditor->editTodo( t ); | 3372 | mTodoEditor->editTodo( t ); |
3373 | if ( mTodoEditor->exec() ) { | 3373 | if ( mTodoEditor->exec() ) { |
3374 | if ( cloneSub ) { | 3374 | if ( cloneSub ) { |
3375 | orgInc->cloneRelations( t ); | 3375 | orgInc->cloneRelations( t ); |
3376 | mCalendar->addIncidenceBranch( t ); | 3376 | mCalendar->addIncidenceBranch( t ); |
3377 | updateView(); | 3377 | updateView(); |
3378 | 3378 | ||
3379 | } else { | 3379 | } else { |
3380 | mCalendar->addTodo( t ); | 3380 | mCalendar->addTodo( t ); |
3381 | updateView(); | 3381 | updateView(); |
3382 | } | 3382 | } |
3383 | } else { | 3383 | } else { |
3384 | delete t; | 3384 | delete t; |
3385 | } | 3385 | } |
3386 | } | 3386 | } |
3387 | else if ( newInc->typeID() == eventID ) { | 3387 | else if ( newInc->typeID() == eventID ) { |
3388 | Event* e = (Event*) newInc; | 3388 | Event* e = (Event*) newInc; |
3389 | showEventEditor(); | 3389 | showEventEditor(); |
3390 | mEventEditor->editEvent( e ); | 3390 | mEventEditor->editEvent( e ); |
3391 | if ( mEventEditor->exec() ) { | 3391 | if ( mEventEditor->exec() ) { |
3392 | mCalendar->addEvent( e ); | 3392 | mCalendar->addEvent( e ); |
3393 | updateView(); | 3393 | updateView(); |
3394 | } else { | 3394 | } else { |
3395 | delete e; | 3395 | delete e; |
3396 | } | 3396 | } |
3397 | } if ( newInc->typeID() == journalID ) { | 3397 | } else if ( newInc->typeID() == journalID ) { |
3398 | mCalendar->addJournal( (Journal*) newInc ); | 3398 | mCalendar->addJournal( (Journal*) newInc ); |
3399 | editJournal( (Journal*) newInc ); | 3399 | editJournal( (Journal*) newInc ); |
3400 | } | 3400 | } |
3401 | setActiveWindow(); | 3401 | setActiveWindow(); |
3402 | } | 3402 | } |
3403 | 3403 | ||
3404 | void CalendarView::newEvent() | 3404 | void CalendarView::newEvent() |
3405 | { | 3405 | { |
3406 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3406 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3407 | KOAgendaView *aView = mViewManager->agendaView(); | 3407 | KOAgendaView *aView = mViewManager->agendaView(); |
3408 | if (aView) { | 3408 | if (aView) { |
3409 | if (aView->selectionStart().isValid()) { | 3409 | if (aView->selectionStart().isValid()) { |
3410 | if (aView->selectedIsAllDay()) { | 3410 | if (aView->selectedIsAllDay()) { |
3411 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3411 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3412 | } else { | 3412 | } else { |
3413 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3413 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3414 | } | 3414 | } |
3415 | return; | 3415 | return; |
3416 | } | 3416 | } |
3417 | } | 3417 | } |
3418 | 3418 | ||
3419 | QDate date = mNavigator->selectedDates().first(); | 3419 | QDate date = mNavigator->selectedDates().first(); |
3420 | #if 0 | 3420 | #if 0 |
3421 | QDateTime current = QDateTime::currentDateTime(); | 3421 | QDateTime current = QDateTime::currentDateTime(); |
3422 | if ( date <= current.date() ) { | 3422 | if ( date <= current.date() ) { |
3423 | int hour = current.time().hour() +1; | 3423 | int hour = current.time().hour() +1; |
3424 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3424 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3425 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3425 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3426 | } else | 3426 | } else |
3427 | #endif | 3427 | #endif |
3428 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3428 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3429 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3429 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3430 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3430 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3431 | } | 3431 | } |
3432 | 3432 | ||
3433 | void CalendarView::newEvent(QDateTime fh) | 3433 | void CalendarView::newEvent(QDateTime fh) |
3434 | { | 3434 | { |
3435 | newEvent(fh, | 3435 | newEvent(fh, |
3436 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3436 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3437 | } | 3437 | } |
3438 | 3438 | ||
3439 | void CalendarView::newEvent(QDate dt) | 3439 | void CalendarView::newEvent(QDate dt) |
3440 | { | 3440 | { |
3441 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3441 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3442 | QDateTime(dt, QTime(0,0,0)), true); | 3442 | QDateTime(dt, QTime(0,0,0)), true); |
3443 | } | 3443 | } |
3444 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3444 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3445 | { | 3445 | { |
3446 | newEvent(fromHint, toHint, false); | 3446 | newEvent(fromHint, toHint, false); |
3447 | } | 3447 | } |
3448 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3448 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3449 | { | 3449 | { |
3450 | 3450 | ||
3451 | showEventEditor(); | 3451 | showEventEditor(); |
3452 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3452 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3453 | if ( mFilterView->filtersEnabled() ) { | 3453 | if ( mFilterView->filtersEnabled() ) { |
3454 | CalFilter *filter = mFilterView->selectedFilter(); | 3454 | CalFilter *filter = mFilterView->selectedFilter(); |
3455 | if (filter && filter->showCategories()) { | 3455 | if (filter && filter->showCategories()) { |
3456 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3456 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3457 | } | 3457 | } |
3458 | if ( filter ) | 3458 | if ( filter ) |
3459 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3459 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3460 | } | 3460 | } |
3461 | mEventEditor->exec(); | 3461 | mEventEditor->exec(); |
3462 | setActiveWindow(); | 3462 | setActiveWindow(); |
3463 | } | 3463 | } |
3464 | void CalendarView::todoAdded(Todo * t) | 3464 | void CalendarView::todoAdded(Todo * t) |
3465 | { | 3465 | { |
3466 | 3466 | ||
3467 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3467 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3468 | updateTodoViews(); | 3468 | updateTodoViews(); |
3469 | } | 3469 | } |
3470 | void CalendarView::todoChanged(Todo * t) | 3470 | void CalendarView::todoChanged(Todo * t) |
3471 | { | 3471 | { |
3472 | emit todoModified( t, 4 ); | 3472 | emit todoModified( t, 4 ); |
3473 | // updateTodoViews(); | 3473 | // updateTodoViews(); |
3474 | } | 3474 | } |
3475 | void CalendarView::todoToBeDeleted(Todo *) | 3475 | void CalendarView::todoToBeDeleted(Todo *) |
3476 | { | 3476 | { |
3477 | //qDebug("todoToBeDeleted(Todo *) "); | 3477 | //qDebug("todoToBeDeleted(Todo *) "); |
3478 | updateTodoViews(); | 3478 | updateTodoViews(); |
3479 | } | 3479 | } |
3480 | void CalendarView::todoDeleted() | 3480 | void CalendarView::todoDeleted() |
3481 | { | 3481 | { |
3482 | //qDebug(" todoDeleted()"); | 3482 | //qDebug(" todoDeleted()"); |
3483 | updateTodoViews(); | 3483 | updateTodoViews(); |
3484 | } | 3484 | } |
3485 | 3485 | ||
3486 | 3486 | ||
3487 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3487 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3488 | { | 3488 | { |
3489 | showTodoEditor(); | 3489 | showTodoEditor(); |
3490 | mTodoEditor->newTodo(dt,0,allday); | 3490 | mTodoEditor->newTodo(dt,0,allday); |
3491 | if ( mFilterView->filtersEnabled() ) { | 3491 | if ( mFilterView->filtersEnabled() ) { |
3492 | CalFilter *filter = mFilterView->selectedFilter(); | 3492 | CalFilter *filter = mFilterView->selectedFilter(); |
3493 | if (filter && filter->showCategories()) { | 3493 | if (filter && filter->showCategories()) { |
3494 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3494 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3495 | } | 3495 | } |
3496 | if ( filter ) | 3496 | if ( filter ) |
3497 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3497 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3498 | } | 3498 | } |
3499 | mTodoEditor->exec(); | 3499 | mTodoEditor->exec(); |
3500 | setActiveWindow(); | 3500 | setActiveWindow(); |
3501 | } | 3501 | } |
3502 | 3502 | ||
3503 | void CalendarView::newTodo() | 3503 | void CalendarView::newTodo() |
3504 | { | 3504 | { |
3505 | newTodoDateTime( QDateTime(),true ); | 3505 | newTodoDateTime( QDateTime(),true ); |
3506 | } | 3506 | } |
3507 | 3507 | ||
3508 | void CalendarView::newSubTodo() | 3508 | void CalendarView::newSubTodo() |
3509 | { | 3509 | { |
3510 | Todo *todo = selectedTodo(); | 3510 | Todo *todo = selectedTodo(); |
3511 | if ( todo ) newSubTodo( todo ); | 3511 | if ( todo ) newSubTodo( todo ); |
3512 | } | 3512 | } |
3513 | 3513 | ||
3514 | void CalendarView::newSubTodo(Todo *parentEvent) | 3514 | void CalendarView::newSubTodo(Todo *parentEvent) |
3515 | { | 3515 | { |
3516 | 3516 | ||
3517 | showTodoEditor(); | 3517 | showTodoEditor(); |
3518 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3518 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3519 | mTodoEditor->exec(); | 3519 | mTodoEditor->exec(); |
3520 | setActiveWindow(); | 3520 | setActiveWindow(); |
3521 | } | 3521 | } |
3522 | 3522 | ||
3523 | void CalendarView::newFloatingEvent() | 3523 | void CalendarView::newFloatingEvent() |
3524 | { | 3524 | { |
3525 | DateList tmpList = mNavigator->selectedDates(); | 3525 | DateList tmpList = mNavigator->selectedDates(); |
3526 | QDate date = tmpList.first(); | 3526 | QDate date = tmpList.first(); |
3527 | 3527 | ||
3528 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3528 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3529 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3529 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3530 | } | 3530 | } |
3531 | 3531 | ||
3532 | 3532 | ||
3533 | void CalendarView::editEvent( Event *event ) | 3533 | void CalendarView::editEvent( Event *event ) |
3534 | { | 3534 | { |
3535 | 3535 | ||
3536 | if ( !event ) return; | 3536 | if ( !event ) return; |
3537 | if ( event->isReadOnly() ) { | 3537 | if ( event->isReadOnly() ) { |
3538 | showEvent( event ); | 3538 | showEvent( event ); |
3539 | return; | 3539 | return; |
3540 | } | 3540 | } |
3541 | showEventEditor(); | 3541 | showEventEditor(); |
3542 | mEventEditor->editEvent( event , mFlagEditDescription); | 3542 | mEventEditor->editEvent( event , mFlagEditDescription); |
3543 | mEventEditor->exec(); | 3543 | mEventEditor->exec(); |
3544 | setActiveWindow(); | 3544 | setActiveWindow(); |
3545 | 3545 | ||
3546 | } | 3546 | } |
3547 | void CalendarView::editJournal( Journal *jour ) | 3547 | void CalendarView::editJournal( Journal *jour ) |
3548 | { | 3548 | { |
3549 | if ( !jour ) return; | 3549 | if ( !jour ) return; |
3550 | mDialogManager->hideSearchDialog(); | 3550 | mDialogManager->hideSearchDialog(); |
3551 | mViewManager->showJournalView(); | 3551 | mViewManager->showJournalView(); |
3552 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3552 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3553 | } | 3553 | } |
3554 | void CalendarView::editTodo( Todo *todo ) | 3554 | void CalendarView::editTodo( Todo *todo ) |
3555 | { | 3555 | { |
3556 | if ( !todo ) return; | 3556 | if ( !todo ) return; |
3557 | 3557 | ||
3558 | if ( todo->isReadOnly() ) { | 3558 | if ( todo->isReadOnly() ) { |
3559 | showTodo( todo ); | 3559 | showTodo( todo ); |
3560 | return; | 3560 | return; |
3561 | } | 3561 | } |
3562 | showTodoEditor(); | 3562 | showTodoEditor(); |
3563 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3563 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3564 | mTodoEditor->exec(); | 3564 | mTodoEditor->exec(); |
3565 | setActiveWindow(); | 3565 | setActiveWindow(); |
3566 | 3566 | ||
3567 | } | 3567 | } |
3568 | 3568 | ||
3569 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3569 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3570 | { | 3570 | { |
3571 | if ( !mEventViewerDialog ) { | 3571 | if ( !mEventViewerDialog ) { |
3572 | mEventViewerDialog = new KOEventViewerDialog(0); | 3572 | mEventViewerDialog = new KOEventViewerDialog(0); |
3573 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3573 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3574 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3574 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3575 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3575 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3576 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3576 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3577 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3577 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3578 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3578 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3579 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3579 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3580 | this, SLOT( slotViewerClosed() ) ); | 3580 | this, SLOT( slotViewerClosed() ) ); |
3581 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3581 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3582 | this, SLOT( todoChanged(Todo *) ) ); | 3582 | this, SLOT( todoChanged(Todo *) ) ); |
3583 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3583 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3584 | mEventViewerDialog->resize( 640, 480 ); | 3584 | mEventViewerDialog->resize( 640, 480 ); |
3585 | 3585 | ||
3586 | } | 3586 | } |
3587 | return mEventViewerDialog; | 3587 | return mEventViewerDialog; |
3588 | } | 3588 | } |
3589 | void CalendarView::showEvent(Event *event) | 3589 | void CalendarView::showEvent(Event *event) |
3590 | { | 3590 | { |
3591 | getEventViewerDialog()->setEvent(event); | 3591 | getEventViewerDialog()->setEvent(event); |
3592 | getEventViewerDialog()->showMe(); | 3592 | getEventViewerDialog()->showMe(); |
3593 | } | 3593 | } |
3594 | 3594 | ||
3595 | void CalendarView::showTodo(Todo *event) | 3595 | void CalendarView::showTodo(Todo *event) |
3596 | { | 3596 | { |
3597 | getEventViewerDialog()->setTodo(event); | 3597 | getEventViewerDialog()->setTodo(event); |
3598 | getEventViewerDialog()->showMe(); | 3598 | getEventViewerDialog()->showMe(); |
3599 | } | 3599 | } |
3600 | void CalendarView::showJournal( Journal *jour ) | 3600 | void CalendarView::showJournal( Journal *jour ) |
3601 | { | 3601 | { |
3602 | getEventViewerDialog()->setJournal(jour); | 3602 | getEventViewerDialog()->setJournal(jour); |
3603 | getEventViewerDialog()->showMe(); | 3603 | getEventViewerDialog()->showMe(); |
3604 | 3604 | ||
3605 | } | 3605 | } |
3606 | // void CalendarView::todoModified (Todo *event, int changed) | 3606 | // void CalendarView::todoModified (Todo *event, int changed) |
3607 | // { | 3607 | // { |
3608 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3608 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3609 | // // kdDebug() << "Todo modified and open" << endl; | 3609 | // // kdDebug() << "Todo modified and open" << endl; |
3610 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3610 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3611 | // // temp->modified (changed); | 3611 | // // temp->modified (changed); |
3612 | 3612 | ||
3613 | // // } | 3613 | // // } |
3614 | 3614 | ||
3615 | // mViewManager->updateView(); | 3615 | // mViewManager->updateView(); |
3616 | // } | 3616 | // } |
3617 | 3617 | ||
3618 | void CalendarView::appointment_show() | 3618 | void CalendarView::appointment_show() |
3619 | { | 3619 | { |
3620 | Event *anEvent = 0; | 3620 | Event *anEvent = 0; |
3621 | 3621 | ||
3622 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3622 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3623 | 3623 | ||
3624 | if (mViewManager->currentView()->isEventView()) { | 3624 | if (mViewManager->currentView()->isEventView()) { |
3625 | if ( incidence && incidence->typeID() == eventID ) { | 3625 | if ( incidence && incidence->typeID() == eventID ) { |
3626 | anEvent = static_cast<Event *>(incidence); | 3626 | anEvent = static_cast<Event *>(incidence); |
3627 | } | 3627 | } |
3628 | } | 3628 | } |
3629 | 3629 | ||
3630 | if (!anEvent) { | 3630 | if (!anEvent) { |
3631 | KNotifyClient::beep(); | 3631 | KNotifyClient::beep(); |
3632 | return; | 3632 | return; |
3633 | } | 3633 | } |
3634 | 3634 | ||
3635 | showEvent(anEvent); | 3635 | showEvent(anEvent); |
3636 | } | 3636 | } |
3637 | 3637 | ||
3638 | void CalendarView::appointment_edit() | 3638 | void CalendarView::appointment_edit() |
3639 | { | 3639 | { |
3640 | Event *anEvent = 0; | 3640 | Event *anEvent = 0; |
3641 | 3641 | ||
3642 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3642 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3643 | 3643 | ||
3644 | if (mViewManager->currentView()->isEventView()) { | 3644 | if (mViewManager->currentView()->isEventView()) { |
3645 | if ( incidence && incidence->typeID() == eventID ) { | 3645 | if ( incidence && incidence->typeID() == eventID ) { |
3646 | anEvent = static_cast<Event *>(incidence); | 3646 | anEvent = static_cast<Event *>(incidence); |
3647 | } | 3647 | } |
3648 | } | 3648 | } |
3649 | 3649 | ||
3650 | if (!anEvent) { | 3650 | if (!anEvent) { |
3651 | KNotifyClient::beep(); | 3651 | KNotifyClient::beep(); |
3652 | return; | 3652 | return; |
3653 | } | 3653 | } |
3654 | 3654 | ||
3655 | editEvent(anEvent); | 3655 | editEvent(anEvent); |
3656 | } | 3656 | } |
3657 | 3657 | ||
3658 | void CalendarView::appointment_delete() | 3658 | void CalendarView::appointment_delete() |
3659 | { | 3659 | { |
3660 | Event *anEvent = 0; | 3660 | Event *anEvent = 0; |
3661 | 3661 | ||
3662 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3662 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3663 | 3663 | ||
3664 | if (mViewManager->currentView()->isEventView()) { | 3664 | if (mViewManager->currentView()->isEventView()) { |
3665 | if ( incidence && incidence->typeID() == eventID ) { | 3665 | if ( incidence && incidence->typeID() == eventID ) { |
3666 | anEvent = static_cast<Event *>(incidence); | 3666 | anEvent = static_cast<Event *>(incidence); |
3667 | } | 3667 | } |
3668 | } | 3668 | } |
3669 | 3669 | ||
3670 | if (!anEvent) { | 3670 | if (!anEvent) { |
3671 | KNotifyClient::beep(); | 3671 | KNotifyClient::beep(); |
3672 | return; | 3672 | return; |
3673 | } | 3673 | } |
3674 | 3674 | ||
3675 | deleteEvent(anEvent); | 3675 | deleteEvent(anEvent); |
3676 | } | 3676 | } |
3677 | 3677 | ||
3678 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3678 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3679 | { | 3679 | { |
3680 | if (!sub) return; | 3680 | if (!sub) return; |
3681 | if ( sub->relatedTo() == parent ) | 3681 | if ( sub->relatedTo() == parent ) |
3682 | return; | 3682 | return; |
3683 | sub->setRelatedTo(parent); | 3683 | sub->setRelatedTo(parent); |
3684 | sub->updated(); | 3684 | sub->updated(); |
3685 | setModified(true); | 3685 | setModified(true); |
3686 | updateView(); | 3686 | updateView(); |
3687 | } | 3687 | } |
3688 | void CalendarView::todo_unsub(Todo *anTodo ) | 3688 | void CalendarView::todo_unsub(Todo *anTodo ) |
3689 | { | 3689 | { |
3690 | todo_resub( 0, anTodo ); | 3690 | todo_resub( 0, anTodo ); |
3691 | } | 3691 | } |
3692 | 3692 | ||
3693 | void CalendarView::deleteTodo(Todo *todo) | 3693 | void CalendarView::deleteTodo(Todo *todo) |
3694 | { | 3694 | { |
3695 | if (!todo) { | 3695 | if (!todo) { |
3696 | KNotifyClient::beep(); | 3696 | KNotifyClient::beep(); |
3697 | return; | 3697 | return; |
3698 | } | 3698 | } |
3699 | if (KOPrefs::instance()->mConfirm) { | 3699 | if (KOPrefs::instance()->mConfirm) { |
3700 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3700 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3701 | if (!todo->relations().isEmpty()) { | 3701 | if (!todo->relations().isEmpty()) { |
3702 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3702 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3703 | 3703 | ||
3704 | } | 3704 | } |
3705 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3705 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3706 | case KMessageBox::Continue: // OK | 3706 | case KMessageBox::Continue: // OK |
3707 | bool deleteT = false; | 3707 | bool deleteT = false; |
3708 | if (!todo->relations().isEmpty()) { | 3708 | if (!todo->relations().isEmpty()) { |
3709 | deleteT = removeCompletedSubTodos( todo ); | 3709 | deleteT = removeCompletedSubTodos( todo ); |
3710 | } | 3710 | } |
3711 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3711 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3712 | if ( !deleteT ) { | 3712 | if ( !deleteT ) { |
3713 | checkExternalId( todo ); | 3713 | checkExternalId( todo ); |
3714 | calendar()->deleteTodo(todo); | 3714 | calendar()->deleteTodo(todo); |
3715 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3715 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3716 | updateView(); | 3716 | updateView(); |
3717 | } | 3717 | } |
3718 | break; | 3718 | break; |
3719 | } // switch | 3719 | } // switch |
3720 | } else { | 3720 | } else { |
3721 | checkExternalId( todo ); | 3721 | checkExternalId( todo ); |
3722 | mCalendar->deleteTodo(todo); | 3722 | mCalendar->deleteTodo(todo); |
3723 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3723 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3724 | updateView(); | 3724 | updateView(); |
3725 | } | 3725 | } |
3726 | 3726 | ||
3727 | emit updateSearchDialog(); | 3727 | emit updateSearchDialog(); |
3728 | } | 3728 | } |
3729 | void CalendarView::deleteJournal(Journal *jour) | 3729 | void CalendarView::deleteJournal(Journal *jour) |
3730 | { | 3730 | { |
3731 | if (!jour) { | 3731 | if (!jour) { |
3732 | KNotifyClient::beep(); | 3732 | KNotifyClient::beep(); |
3733 | return; | 3733 | return; |
3734 | } | 3734 | } |
3735 | if (KOPrefs::instance()->mConfirm) { | 3735 | if (KOPrefs::instance()->mConfirm) { |
3736 | 3736 | ||
3737 | QString des; | 3737 | QString des; |
3738 | if ( !jour->summary().isEmpty() ) { | 3738 | if ( !jour->summary().isEmpty() ) { |
3739 | des = jour->summary(); | 3739 | des = jour->summary(); |
3740 | } else { | 3740 | } else { |
3741 | des = jour->description().left(30); | 3741 | des = jour->description().left(30); |
3742 | des = des.simplifyWhiteSpace (); | 3742 | des = des.simplifyWhiteSpace (); |
3743 | des.replace (QRegExp ("\\n"),"" ); | 3743 | des.replace (QRegExp ("\\n"),"" ); |
3744 | des.replace (QRegExp ("\\r"),"" ); | 3744 | des.replace (QRegExp ("\\r"),"" ); |
3745 | } | 3745 | } |
3746 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 3746 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3747 | case KMessageBox::Continue: // OK | 3747 | case KMessageBox::Continue: // OK |
3748 | calendar()->deleteJournal(jour); | 3748 | calendar()->deleteJournal(jour); |
3749 | updateView(); | 3749 | updateView(); |
3750 | break; | 3750 | break; |
3751 | } // switch | 3751 | } // switch |
3752 | } else { | 3752 | } else { |
3753 | calendar()->deleteJournal(jour);; | 3753 | calendar()->deleteJournal(jour);; |
3754 | updateView(); | 3754 | updateView(); |
3755 | } | 3755 | } |
3756 | emit updateSearchDialog(); | 3756 | emit updateSearchDialog(); |
3757 | } | 3757 | } |
3758 | 3758 | ||
3759 | void CalendarView::deleteEvent(Event *anEvent) | 3759 | void CalendarView::deleteEvent(Event *anEvent) |
3760 | { | 3760 | { |
3761 | if (!anEvent) { | 3761 | if (!anEvent) { |
3762 | KNotifyClient::beep(); | 3762 | KNotifyClient::beep(); |
3763 | return; | 3763 | return; |
3764 | } | 3764 | } |
3765 | 3765 | ||
3766 | if (anEvent->doesRecur()) { | 3766 | if (anEvent->doesRecur()) { |
3767 | QDate itemDate = mViewManager->currentSelectionDate(); | 3767 | QDate itemDate = mViewManager->currentSelectionDate(); |
3768 | int km; | 3768 | int km; |
3769 | if (!itemDate.isValid()) { | 3769 | if (!itemDate.isValid()) { |
3770 | //kdDebug() << "Date Not Valid" << endl; | 3770 | //kdDebug() << "Date Not Valid" << endl; |
3771 | if (KOPrefs::instance()->mConfirm) { | 3771 | if (KOPrefs::instance()->mConfirm) { |
3772 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3772 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3773 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3773 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3774 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3774 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3775 | if ( km == KMessageBox::Continue ) | 3775 | if ( km == KMessageBox::Continue ) |
3776 | km = KMessageBox::No; // No = all below | 3776 | km = KMessageBox::No; // No = all below |
3777 | } else | 3777 | } else |
3778 | km = KMessageBox::No; | 3778 | km = KMessageBox::No; |
3779 | } else { | 3779 | } else { |
3780 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3780 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3781 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3781 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3782 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3782 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3783 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3783 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3784 | i18n("All")); | 3784 | i18n("All")); |
3785 | } | 3785 | } |
3786 | switch(km) { | 3786 | switch(km) { |
3787 | 3787 | ||
3788 | case KMessageBox::No: // Continue // all | 3788 | case KMessageBox::No: // Continue // all |
3789 | //qDebug("KMessageBox::No "); | 3789 | //qDebug("KMessageBox::No "); |
3790 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3790 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3791 | schedule(Scheduler::Cancel,anEvent); | 3791 | schedule(Scheduler::Cancel,anEvent); |
3792 | 3792 | ||
3793 | checkExternalId( anEvent); | 3793 | checkExternalId( anEvent); |
3794 | mCalendar->deleteEvent(anEvent); | 3794 | mCalendar->deleteEvent(anEvent); |
3795 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3795 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3796 | break; | 3796 | break; |
3797 | 3797 | ||
3798 | // Disabled because it does not work | 3798 | // Disabled because it does not work |
3799 | //#if 0 | 3799 | //#if 0 |
3800 | case KMessageBox::Yes: // just this one | 3800 | case KMessageBox::Yes: // just this one |
3801 | //QDate qd = mNavigator->selectedDates().first(); | 3801 | //QDate qd = mNavigator->selectedDates().first(); |
3802 | //if (!qd.isValid()) { | 3802 | //if (!qd.isValid()) { |
3803 | // kdDebug() << "no date selected, or invalid date" << endl; | 3803 | // kdDebug() << "no date selected, or invalid date" << endl; |
3804 | // KNotifyClient::beep(); | 3804 | // KNotifyClient::beep(); |
3805 | // return; | 3805 | // return; |
3806 | //} | 3806 | //} |
3807 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3807 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3808 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3808 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3809 | anEvent->addExDate(itemDate); | 3809 | anEvent->addExDate(itemDate); |
3810 | int duration = anEvent->recurrence()->duration(); | 3810 | int duration = anEvent->recurrence()->duration(); |
3811 | if ( duration > 0 ) { | 3811 | if ( duration > 0 ) { |
3812 | anEvent->recurrence()->setDuration( duration - 1 ); | 3812 | anEvent->recurrence()->setDuration( duration - 1 ); |
3813 | } | 3813 | } |
3814 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3814 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3815 | } | 3815 | } |
3816 | break; | 3816 | break; |
3817 | //#endif | 3817 | //#endif |
3818 | } // switch | 3818 | } // switch |
3819 | } else { | 3819 | } else { |
3820 | if (KOPrefs::instance()->mConfirm) { | 3820 | if (KOPrefs::instance()->mConfirm) { |
3821 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3821 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3822 | i18n("\nAre you sure you want\nto delete this event?"), | 3822 | i18n("\nAre you sure you want\nto delete this event?"), |
3823 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3823 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3824 | case KMessageBox::Continue: // OK | 3824 | case KMessageBox::Continue: // OK |
3825 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3825 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3826 | schedule(Scheduler::Cancel,anEvent); | 3826 | schedule(Scheduler::Cancel,anEvent); |
3827 | checkExternalId( anEvent); | 3827 | checkExternalId( anEvent); |
3828 | mCalendar->deleteEvent(anEvent); | 3828 | mCalendar->deleteEvent(anEvent); |
3829 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3829 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3830 | break; | 3830 | break; |
3831 | } // switch | 3831 | } // switch |
3832 | } else { | 3832 | } else { |
3833 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3833 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3834 | schedule(Scheduler::Cancel,anEvent); | 3834 | schedule(Scheduler::Cancel,anEvent); |
3835 | checkExternalId( anEvent); | 3835 | checkExternalId( anEvent); |
3836 | mCalendar->deleteEvent(anEvent); | 3836 | mCalendar->deleteEvent(anEvent); |
3837 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3837 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3838 | } | 3838 | } |
3839 | } // if-else | 3839 | } // if-else |
3840 | emit updateSearchDialog(); | 3840 | emit updateSearchDialog(); |
3841 | } | 3841 | } |
3842 | 3842 | ||
3843 | bool CalendarView::deleteEvent(const QString &uid) | 3843 | bool CalendarView::deleteEvent(const QString &uid) |
3844 | { | 3844 | { |
3845 | Event *ev = mCalendar->event(uid); | 3845 | Event *ev = mCalendar->event(uid); |
3846 | if (ev) { | 3846 | if (ev) { |
3847 | deleteEvent(ev); | 3847 | deleteEvent(ev); |
3848 | return true; | 3848 | return true; |
3849 | } else { | 3849 | } else { |
3850 | return false; | 3850 | return false; |
3851 | } | 3851 | } |
3852 | } | 3852 | } |
3853 | 3853 | ||
3854 | /*****************************************************************************/ | 3854 | /*****************************************************************************/ |
3855 | 3855 | ||
3856 | void CalendarView::action_mail() | 3856 | void CalendarView::action_mail() |
3857 | { | 3857 | { |
3858 | #ifndef KORG_NOMAIL | 3858 | #ifndef KORG_NOMAIL |
3859 | KOMailClient mailClient; | 3859 | KOMailClient mailClient; |
3860 | 3860 | ||
3861 | Incidence *incidence = currentSelection(); | 3861 | Incidence *incidence = currentSelection(); |
3862 | 3862 | ||
3863 | if (!incidence) { | 3863 | if (!incidence) { |
3864 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3864 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3865 | return; | 3865 | return; |
3866 | } | 3866 | } |
3867 | if(incidence->attendeeCount() == 0 ) { | 3867 | if(incidence->attendeeCount() == 0 ) { |
3868 | KMessageBox::sorry(this, | 3868 | KMessageBox::sorry(this, |
3869 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3869 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3870 | return; | 3870 | return; |
3871 | } | 3871 | } |
3872 | 3872 | ||
3873 | CalendarLocal cal_tmp; | 3873 | CalendarLocal cal_tmp; |
3874 | Event *event = 0; | 3874 | Event *event = 0; |
3875 | Event *ev = 0; | 3875 | Event *ev = 0; |
3876 | if ( incidence && incidence->typeID() == eventID ) { | 3876 | if ( incidence && incidence->typeID() == eventID ) { |
3877 | event = static_cast<Event *>(incidence); | 3877 | event = static_cast<Event *>(incidence); |
3878 | ev = new Event(*event); | 3878 | ev = new Event(*event); |
3879 | cal_tmp.addEvent(ev); | 3879 | cal_tmp.addEvent(ev); |
3880 | } | 3880 | } |
3881 | ICalFormat mForm(); | 3881 | ICalFormat mForm(); |
3882 | QString attachment = mForm.toString( &cal_tmp ); | 3882 | QString attachment = mForm.toString( &cal_tmp ); |
3883 | if (ev) delete(ev); | 3883 | if (ev) delete(ev); |
3884 | 3884 | ||
3885 | mailClient.mailAttendees(currentSelection(), attachment); | 3885 | mailClient.mailAttendees(currentSelection(), attachment); |
3886 | 3886 | ||
3887 | #endif | 3887 | #endif |
3888 | 3888 | ||
3889 | #if 0 | 3889 | #if 0 |
3890 | Event *anEvent = 0; | 3890 | Event *anEvent = 0; |
3891 | if (mViewManager->currentView()->isEventView()) { | 3891 | if (mViewManager->currentView()->isEventView()) { |
3892 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3892 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3893 | } | 3893 | } |
3894 | 3894 | ||
3895 | if (!anEvent) { | 3895 | if (!anEvent) { |
3896 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3896 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3897 | return; | 3897 | return; |
3898 | } | 3898 | } |
3899 | if(anEvent->attendeeCount() == 0 ) { | 3899 | if(anEvent->attendeeCount() == 0 ) { |
3900 | KMessageBox::sorry(this, | 3900 | KMessageBox::sorry(this, |
3901 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3901 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3902 | return; | 3902 | return; |
3903 | } | 3903 | } |
3904 | 3904 | ||
3905 | mailobject.emailEvent(anEvent); | 3905 | mailobject.emailEvent(anEvent); |
3906 | #endif | 3906 | #endif |
3907 | } | 3907 | } |
3908 | 3908 | ||
3909 | 3909 | ||
3910 | void CalendarView::schedule_publish(Incidence *incidence) | 3910 | void CalendarView::schedule_publish(Incidence *incidence) |
3911 | { | 3911 | { |
3912 | Event *event = 0; | 3912 | Event *event = 0; |
3913 | Todo *todo = 0; | 3913 | Todo *todo = 0; |
3914 | 3914 | ||
3915 | if (incidence == 0) { | 3915 | if (incidence == 0) { |
3916 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3916 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3917 | if (incidence == 0) { | 3917 | if (incidence == 0) { |
3918 | incidence = mTodoList->selectedIncidences().first(); | 3918 | incidence = mTodoList->selectedIncidences().first(); |
3919 | } | 3919 | } |
3920 | } | 3920 | } |
3921 | if ( incidence && incidence->typeID() == eventID ) { | 3921 | if ( incidence && incidence->typeID() == eventID ) { |
3922 | event = static_cast<Event *>(incidence); | 3922 | event = static_cast<Event *>(incidence); |
3923 | } else { | 3923 | } else { |
3924 | if ( incidence && incidence->typeID() == todoID ) { | 3924 | if ( incidence && incidence->typeID() == todoID ) { |
3925 | todo = static_cast<Todo *>(incidence); | 3925 | todo = static_cast<Todo *>(incidence); |
3926 | } | 3926 | } |
3927 | } | 3927 | } |
3928 | 3928 | ||
3929 | if (!event && !todo) { | 3929 | if (!event && !todo) { |
3930 | KMessageBox::sorry(this,i18n("No event selected.")); | 3930 | KMessageBox::sorry(this,i18n("No event selected.")); |
3931 | return; | 3931 | return; |
3932 | } | 3932 | } |
3933 | 3933 | ||
3934 | PublishDialog *publishdlg = new PublishDialog(); | 3934 | PublishDialog *publishdlg = new PublishDialog(); |
3935 | if (incidence->attendeeCount()>0) { | 3935 | if (incidence->attendeeCount()>0) { |
3936 | QPtrList<Attendee> attendees = incidence->attendees(); | 3936 | QPtrList<Attendee> attendees = incidence->attendees(); |
3937 | attendees.first(); | 3937 | attendees.first(); |
3938 | while ( attendees.current()!=0 ) { | 3938 | while ( attendees.current()!=0 ) { |
3939 | publishdlg->addAttendee(attendees.current()); | 3939 | publishdlg->addAttendee(attendees.current()); |
3940 | attendees.next(); | 3940 | attendees.next(); |
3941 | } | 3941 | } |
3942 | } | 3942 | } |
3943 | bool send = true; | 3943 | bool send = true; |
3944 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3944 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3945 | if ( publishdlg->exec() != QDialog::Accepted ) | 3945 | if ( publishdlg->exec() != QDialog::Accepted ) |
3946 | send = false; | 3946 | send = false; |
3947 | } | 3947 | } |
3948 | if ( send ) { | 3948 | if ( send ) { |
3949 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3949 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3950 | if ( event ) { | 3950 | if ( event ) { |
3951 | Event *ev = new Event(*event); | 3951 | Event *ev = new Event(*event); |
3952 | ev->registerObserver(0); | 3952 | ev->registerObserver(0); |
3953 | ev->clearAttendees(); | 3953 | ev->clearAttendees(); |
3954 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3954 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3955 | delete(ev); | 3955 | delete(ev); |
3956 | } | 3956 | } |
3957 | } else { | 3957 | } else { |
3958 | if ( todo ) { | 3958 | if ( todo ) { |
3959 | Todo *ev = new Todo(*todo); | 3959 | Todo *ev = new Todo(*todo); |
3960 | ev->registerObserver(0); | 3960 | ev->registerObserver(0); |
3961 | ev->clearAttendees(); | 3961 | ev->clearAttendees(); |
3962 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3962 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3963 | delete(ev); | 3963 | delete(ev); |
3964 | } | 3964 | } |
3965 | } | 3965 | } |
3966 | } | 3966 | } |
3967 | } | 3967 | } |
3968 | delete publishdlg; | 3968 | delete publishdlg; |
3969 | } | 3969 | } |
3970 | 3970 | ||
3971 | void CalendarView::schedule_request(Incidence *incidence) | 3971 | void CalendarView::schedule_request(Incidence *incidence) |
3972 | { | 3972 | { |
3973 | schedule(Scheduler::Request,incidence); | 3973 | schedule(Scheduler::Request,incidence); |
3974 | } | 3974 | } |
3975 | 3975 | ||
3976 | void CalendarView::schedule_refresh(Incidence *incidence) | 3976 | void CalendarView::schedule_refresh(Incidence *incidence) |
3977 | { | 3977 | { |
3978 | schedule(Scheduler::Refresh,incidence); | 3978 | schedule(Scheduler::Refresh,incidence); |
3979 | } | 3979 | } |
3980 | 3980 | ||
3981 | void CalendarView::schedule_cancel(Incidence *incidence) | 3981 | void CalendarView::schedule_cancel(Incidence *incidence) |
3982 | { | 3982 | { |
3983 | schedule(Scheduler::Cancel,incidence); | 3983 | schedule(Scheduler::Cancel,incidence); |
3984 | } | 3984 | } |
3985 | 3985 | ||
3986 | void CalendarView::schedule_add(Incidence *incidence) | 3986 | void CalendarView::schedule_add(Incidence *incidence) |
3987 | { | 3987 | { |
3988 | schedule(Scheduler::Add,incidence); | 3988 | schedule(Scheduler::Add,incidence); |
3989 | } | 3989 | } |
3990 | 3990 | ||
3991 | void CalendarView::schedule_reply(Incidence *incidence) | 3991 | void CalendarView::schedule_reply(Incidence *incidence) |
3992 | { | 3992 | { |
3993 | schedule(Scheduler::Reply,incidence); | 3993 | schedule(Scheduler::Reply,incidence); |
3994 | } | 3994 | } |
3995 | 3995 | ||
3996 | void CalendarView::schedule_counter(Incidence *incidence) | 3996 | void CalendarView::schedule_counter(Incidence *incidence) |
3997 | { | 3997 | { |
3998 | schedule(Scheduler::Counter,incidence); | 3998 | schedule(Scheduler::Counter,incidence); |
3999 | } | 3999 | } |
4000 | 4000 | ||
4001 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 4001 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
4002 | { | 4002 | { |
4003 | schedule(Scheduler::Declinecounter,incidence); | 4003 | schedule(Scheduler::Declinecounter,incidence); |
4004 | } | 4004 | } |
4005 | 4005 | ||
4006 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 4006 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
4007 | { | 4007 | { |
4008 | QDateTime start = QDateTime::currentDateTime(); | 4008 | QDateTime start = QDateTime::currentDateTime(); |
4009 | QDateTime end = start.addDays(daysToPublish); | 4009 | QDateTime end = start.addDays(daysToPublish); |
4010 | 4010 | ||
4011 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4011 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
4012 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4012 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
4013 | 4013 | ||
4014 | 4014 | ||
4015 | PublishDialog *publishdlg = new PublishDialog(); | 4015 | PublishDialog *publishdlg = new PublishDialog(); |
4016 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4016 | if ( publishdlg->exec() == QDialog::Accepted ) { |
4017 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4017 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4018 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4018 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
4019 | delete(freebusy); | 4019 | delete(freebusy); |
4020 | } | 4020 | } |
4021 | } | 4021 | } |
4022 | delete publishdlg; | 4022 | delete publishdlg; |
4023 | } | 4023 | } |
4024 | 4024 | ||
4025 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4025 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4026 | { | 4026 | { |
4027 | Event *event = 0; | 4027 | Event *event = 0; |
4028 | Todo *todo = 0; | 4028 | Todo *todo = 0; |
4029 | 4029 | ||
4030 | if (incidence == 0) { | 4030 | if (incidence == 0) { |
4031 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4031 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4032 | if (incidence == 0) { | 4032 | if (incidence == 0) { |
4033 | incidence = mTodoList->selectedIncidences().first(); | 4033 | incidence = mTodoList->selectedIncidences().first(); |
4034 | } | 4034 | } |
4035 | } | 4035 | } |
4036 | if ( incidence && incidence->typeID() == eventID ) { | 4036 | if ( incidence && incidence->typeID() == eventID ) { |
4037 | event = static_cast<Event *>(incidence); | 4037 | event = static_cast<Event *>(incidence); |
4038 | } | 4038 | } |
4039 | if ( incidence && incidence->typeID() == todoID ) { | 4039 | if ( incidence && incidence->typeID() == todoID ) { |
4040 | todo = static_cast<Todo *>(incidence); | 4040 | todo = static_cast<Todo *>(incidence); |
4041 | } | 4041 | } |
4042 | 4042 | ||
4043 | if (!event && !todo) { | 4043 | if (!event && !todo) { |
4044 | KMessageBox::sorry(this,i18n("No event selected.")); | 4044 | KMessageBox::sorry(this,i18n("No event selected.")); |
4045 | return; | 4045 | return; |
4046 | } | 4046 | } |
4047 | 4047 | ||
4048 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4048 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4049 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4049 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4050 | return; | 4050 | return; |
4051 | } | 4051 | } |
4052 | 4052 | ||
4053 | Event *ev = 0; | 4053 | Event *ev = 0; |
4054 | if (event) ev = new Event(*event); | 4054 | if (event) ev = new Event(*event); |
4055 | Todo *to = 0; | 4055 | Todo *to = 0; |
4056 | if (todo) to = new Todo(*todo); | 4056 | if (todo) to = new Todo(*todo); |
4057 | 4057 | ||
4058 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4058 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4059 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4059 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4060 | if (!me) { | 4060 | if (!me) { |
4061 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4061 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4062 | return; | 4062 | return; |
4063 | } | 4063 | } |
4064 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4064 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4065 | StatusDialog *statdlg = new StatusDialog(this); | 4065 | StatusDialog *statdlg = new StatusDialog(this); |
4066 | if (!statdlg->exec()==QDialog::Accepted) return; | 4066 | if (!statdlg->exec()==QDialog::Accepted) return; |
4067 | me->setStatus( statdlg->status() ); | 4067 | me->setStatus( statdlg->status() ); |
4068 | delete(statdlg); | 4068 | delete(statdlg); |
4069 | } | 4069 | } |
4070 | Attendee *menew = new Attendee(*me); | 4070 | Attendee *menew = new Attendee(*me); |
4071 | if (ev) { | 4071 | if (ev) { |
4072 | ev->clearAttendees(); | 4072 | ev->clearAttendees(); |
4073 | ev->addAttendee(menew,false); | 4073 | ev->addAttendee(menew,false); |
4074 | } else { | 4074 | } else { |
4075 | if (to) { | 4075 | if (to) { |
4076 | todo->clearAttendees(); | 4076 | todo->clearAttendees(); |
4077 | todo->addAttendee(menew,false); | 4077 | todo->addAttendee(menew,false); |
4078 | } | 4078 | } |
4079 | } | 4079 | } |
4080 | } | 4080 | } |
4081 | 4081 | ||
4082 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4082 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4083 | if (ev) { | 4083 | if (ev) { |
4084 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4084 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4085 | } else { | 4085 | } else { |
4086 | if (to) { | 4086 | if (to) { |
4087 | if ( !dlg->addMessage(to,method) ) delete(to); | 4087 | if ( !dlg->addMessage(to,method) ) delete(to); |
4088 | } | 4088 | } |
4089 | } | 4089 | } |
4090 | } | 4090 | } |
4091 | 4091 | ||
4092 | void CalendarView::openAddressbook() | 4092 | void CalendarView::openAddressbook() |
4093 | { | 4093 | { |
4094 | KRun::runCommand("kaddressbook"); | 4094 | KRun::runCommand("kaddressbook"); |
4095 | } | 4095 | } |
4096 | 4096 | ||
4097 | void CalendarView::setModified(bool modified) | 4097 | void CalendarView::setModified(bool modified) |
4098 | { | 4098 | { |
4099 | //qDebug("CalendarView::setModified %d ", modified); | 4099 | //qDebug("CalendarView::setModified %d ", modified); |
4100 | if ( modified ) | 4100 | if ( modified ) |
4101 | emit signalmodified(); | 4101 | emit signalmodified(); |
4102 | mModified = modified; | 4102 | mModified = modified; |
4103 | if ( mModified ) | 4103 | if ( mModified ) |
4104 | emit modifiedChanged(mModified); | 4104 | emit modifiedChanged(mModified); |
4105 | 4105 | ||
4106 | } | 4106 | } |
4107 | 4107 | ||
4108 | bool CalendarView::isReadOnly() | 4108 | bool CalendarView::isReadOnly() |
4109 | { | 4109 | { |
4110 | return mReadOnly; | 4110 | return mReadOnly; |
4111 | } | 4111 | } |
4112 | 4112 | ||
4113 | void CalendarView::setReadOnly(bool readOnly) | 4113 | void CalendarView::setReadOnly(bool readOnly) |
4114 | { | 4114 | { |
4115 | if (mReadOnly != readOnly) { | 4115 | if (mReadOnly != readOnly) { |
4116 | mReadOnly = readOnly; | 4116 | mReadOnly = readOnly; |
4117 | emit readOnlyChanged(mReadOnly); | 4117 | emit readOnlyChanged(mReadOnly); |
4118 | } | 4118 | } |
4119 | } | 4119 | } |
4120 | 4120 | ||
4121 | bool CalendarView::isModified() | 4121 | bool CalendarView::isModified() |
4122 | { | 4122 | { |
4123 | return mModified; | 4123 | return mModified; |
4124 | } | 4124 | } |
4125 | void CalendarView::slotprintSelInc() | 4125 | void CalendarView::slotprintSelInc() |
4126 | { | 4126 | { |
4127 | if ( currentSelection() == 0 ) { | 4127 | if ( currentSelection() == 0 ) { |
4128 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4128 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4129 | return; | 4129 | return; |
4130 | } | 4130 | } |
4131 | showIncidence(); | 4131 | showIncidence(); |
4132 | getEventViewerDialog()->print(); | 4132 | getEventViewerDialog()->print(); |
4133 | 4133 | ||
4134 | } | 4134 | } |
4135 | void CalendarView::printSetup() | 4135 | void CalendarView::printSetup() |
4136 | { | 4136 | { |
4137 | #ifndef KORG_NOPRINTER | 4137 | #ifndef KORG_NOPRINTER |
4138 | createPrinter(); | 4138 | createPrinter(); |
4139 | 4139 | ||
4140 | mCalPrinter->setupPrinter(); | 4140 | mCalPrinter->setupPrinter(); |
4141 | #endif | 4141 | #endif |
4142 | } | 4142 | } |
4143 | 4143 | ||
4144 | void CalendarView::print() | 4144 | void CalendarView::print() |
4145 | { | 4145 | { |
4146 | #ifndef KORG_NOPRINTER | 4146 | #ifndef KORG_NOPRINTER |
4147 | createPrinter(); | 4147 | createPrinter(); |
4148 | 4148 | ||
4149 | DateList tmpDateList = mNavigator->selectedDates(); | 4149 | DateList tmpDateList = mNavigator->selectedDates(); |
4150 | mCalPrinter->print(CalPrinter::Month, | 4150 | mCalPrinter->print(CalPrinter::Month, |
4151 | tmpDateList.first(), tmpDateList.last()); | 4151 | tmpDateList.first(), tmpDateList.last()); |
4152 | #endif | 4152 | #endif |
4153 | } | 4153 | } |
4154 | 4154 | ||
4155 | void CalendarView::printPreview() | 4155 | void CalendarView::printPreview() |
4156 | { | 4156 | { |
4157 | #ifndef KORG_NOPRINTER | 4157 | #ifndef KORG_NOPRINTER |
4158 | kdDebug() << "CalendarView::printPreview()" << endl; | 4158 | kdDebug() << "CalendarView::printPreview()" << endl; |
4159 | 4159 | ||
4160 | createPrinter(); | 4160 | createPrinter(); |
4161 | 4161 | ||
4162 | DateList tmpDateList = mNavigator->selectedDates(); | 4162 | DateList tmpDateList = mNavigator->selectedDates(); |
4163 | 4163 | ||
4164 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4164 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4165 | tmpDateList.last()); | 4165 | tmpDateList.last()); |
4166 | #endif | 4166 | #endif |
4167 | } | 4167 | } |
4168 | 4168 | ||
4169 | void CalendarView::exportICalendar() | 4169 | void CalendarView::exportICalendar() |
4170 | { | 4170 | { |
4171 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 4171 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
4172 | 4172 | ||
4173 | // Force correct extension | 4173 | // Force correct extension |
4174 | if (filename.right(4) != ".ics") filename += ".ics"; | 4174 | if (filename.right(4) != ".ics") filename += ".ics"; |
4175 | 4175 | ||
4176 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4176 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4177 | storage.save(); | 4177 | storage.save(); |
4178 | } | 4178 | } |
4179 | 4179 | ||
4180 | bool CalendarView::exportVCalendar( QString filename ) | 4180 | bool CalendarView::exportVCalendar( QString filename ) |
4181 | { | 4181 | { |
4182 | if (mCalendar->journals().count() > 0) { | 4182 | if (mCalendar->journals().count() > 0) { |
4183 | int result = KMessageBox::warningContinueCancel(this, | 4183 | int result = KMessageBox::warningContinueCancel(this, |
4184 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4184 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4185 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4185 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4186 | true); | 4186 | true); |
4187 | if (result != KMessageBox::Continue) return false; | 4187 | if (result != KMessageBox::Continue) return false; |
4188 | } | 4188 | } |
4189 | 4189 | ||
4190 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4190 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4191 | 4191 | ||
4192 | // Force correct extension | 4192 | // Force correct extension |
4193 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4193 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4194 | 4194 | ||
4195 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4195 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4196 | return storage.save(); | 4196 | return storage.save(); |
4197 | 4197 | ||
4198 | } | 4198 | } |
4199 | 4199 | ||
4200 | void CalendarView::eventUpdated(Incidence *) | 4200 | void CalendarView::eventUpdated(Incidence *) |
4201 | { | 4201 | { |
4202 | setModified(); | 4202 | setModified(); |
4203 | // Don't call updateView here. The code, which has caused the update of the | 4203 | // Don't call updateView here. The code, which has caused the update of the |
4204 | // event is responsible for updating the view. | 4204 | // event is responsible for updating the view. |
4205 | // updateView(); | 4205 | // updateView(); |
4206 | } | 4206 | } |
4207 | 4207 | ||
4208 | void CalendarView::adaptNavigationUnits() | 4208 | void CalendarView::adaptNavigationUnits() |
4209 | { | 4209 | { |
4210 | if (mViewManager->currentView()->isEventView()) { | 4210 | if (mViewManager->currentView()->isEventView()) { |
4211 | int days = mViewManager->currentView()->currentDateCount(); | 4211 | int days = mViewManager->currentView()->currentDateCount(); |
4212 | if (days == 1) { | 4212 | if (days == 1) { |
4213 | emit changeNavStringPrev(i18n("&Previous Day")); | 4213 | emit changeNavStringPrev(i18n("&Previous Day")); |
4214 | emit changeNavStringNext(i18n("&Next Day")); | 4214 | emit changeNavStringNext(i18n("&Next Day")); |
4215 | } else { | 4215 | } else { |
4216 | emit changeNavStringPrev(i18n("&Previous Week")); | 4216 | emit changeNavStringPrev(i18n("&Previous Week")); |
4217 | emit changeNavStringNext(i18n("&Next Week")); | 4217 | emit changeNavStringNext(i18n("&Next Week")); |
4218 | } | 4218 | } |
4219 | } | 4219 | } |
4220 | } | 4220 | } |
4221 | 4221 | ||
4222 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4222 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4223 | { | 4223 | { |
4224 | if ( incidence ) mTodoList->clearSelection(); | 4224 | if ( incidence ) mTodoList->clearSelection(); |
4225 | processIncidenceSelection( incidence ); | 4225 | processIncidenceSelection( incidence ); |
4226 | } | 4226 | } |
4227 | 4227 | ||
4228 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4228 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4229 | { | 4229 | { |
4230 | if ( incidence && mViewManager->currentView() ) { | 4230 | if ( incidence && mViewManager->currentView() ) { |
4231 | mViewManager->currentView()->clearSelection(); | 4231 | mViewManager->currentView()->clearSelection(); |
4232 | } | 4232 | } |
4233 | processIncidenceSelection( incidence ); | 4233 | processIncidenceSelection( incidence ); |
4234 | } | 4234 | } |
4235 | 4235 | ||
4236 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4236 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4237 | { | 4237 | { |
4238 | emit incidenceSelected( incidence ); | 4238 | emit incidenceSelected( incidence ); |
4239 | if ( incidence == mSelectedIncidence ) return; | 4239 | if ( incidence == mSelectedIncidence ) return; |
4240 | mSelectedIncidence = incidence; | 4240 | mSelectedIncidence = incidence; |
4241 | 4241 | ||
4242 | if ( incidence && incidence->typeID() == eventID ) { | 4242 | if ( incidence && incidence->typeID() == eventID ) { |
4243 | Event *event = static_cast<Event *>( incidence ); | 4243 | Event *event = static_cast<Event *>( incidence ); |
4244 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4244 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4245 | emit organizerEventsSelected( true ); | 4245 | emit organizerEventsSelected( true ); |
4246 | } else { | 4246 | } else { |
4247 | emit organizerEventsSelected(false); | 4247 | emit organizerEventsSelected(false); |
4248 | } | 4248 | } |
4249 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4249 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4250 | KOPrefs::instance()->email() ) ) { | 4250 | KOPrefs::instance()->email() ) ) { |
4251 | emit groupEventsSelected( true ); | 4251 | emit groupEventsSelected( true ); |
4252 | } else { | 4252 | } else { |
4253 | emit groupEventsSelected(false); | 4253 | emit groupEventsSelected(false); |
4254 | } | 4254 | } |
4255 | return; | 4255 | return; |
4256 | } else { | 4256 | } else { |
4257 | if ( incidence && incidence->typeID() == todoID ) { | 4257 | if ( incidence && incidence->typeID() == todoID ) { |
4258 | emit todoSelected( true ); | 4258 | emit todoSelected( true ); |
4259 | Todo *event = static_cast<Todo *>( incidence ); | 4259 | Todo *event = static_cast<Todo *>( incidence ); |
4260 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4260 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4261 | emit organizerEventsSelected( true ); | 4261 | emit organizerEventsSelected( true ); |
4262 | } else { | 4262 | } else { |
4263 | emit organizerEventsSelected(false); | 4263 | emit organizerEventsSelected(false); |
4264 | } | 4264 | } |
4265 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4265 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4266 | KOPrefs::instance()->email() ) ) { | 4266 | KOPrefs::instance()->email() ) ) { |
4267 | emit groupEventsSelected( true ); | 4267 | emit groupEventsSelected( true ); |
4268 | } else { | 4268 | } else { |
4269 | emit groupEventsSelected(false); | 4269 | emit groupEventsSelected(false); |
4270 | } | 4270 | } |
4271 | return; | 4271 | return; |
4272 | } else { | 4272 | } else { |
4273 | emit todoSelected( false ); | 4273 | emit todoSelected( false ); |
4274 | emit organizerEventsSelected(false); | 4274 | emit organizerEventsSelected(false); |
4275 | emit groupEventsSelected(false); | 4275 | emit groupEventsSelected(false); |
4276 | } | 4276 | } |
4277 | return; | 4277 | return; |
4278 | } | 4278 | } |
4279 | 4279 | ||
4280 | /* if ( incidence && incidence->typeID() == todoID ) { | 4280 | /* if ( incidence && incidence->typeID() == todoID ) { |
4281 | emit todoSelected( true ); | 4281 | emit todoSelected( true ); |
4282 | } else { | 4282 | } else { |
4283 | emit todoSelected( false ); | 4283 | emit todoSelected( false ); |
4284 | }*/ | 4284 | }*/ |
4285 | } | 4285 | } |
4286 | 4286 | ||
4287 | 4287 | ||
4288 | void CalendarView::checkClipboard() | 4288 | void CalendarView::checkClipboard() |
4289 | { | 4289 | { |
4290 | #ifndef KORG_NODND | 4290 | #ifndef KORG_NODND |
4291 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4291 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4292 | emit pasteEnabled(true); | 4292 | emit pasteEnabled(true); |
4293 | } else { | 4293 | } else { |
4294 | emit pasteEnabled(false); | 4294 | emit pasteEnabled(false); |
4295 | } | 4295 | } |
4296 | #endif | 4296 | #endif |
4297 | } | 4297 | } |
4298 | 4298 | ||
4299 | void CalendarView::showDates(const DateList &selectedDates) | 4299 | void CalendarView::showDates(const DateList &selectedDates) |
4300 | { | 4300 | { |
4301 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4301 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4302 | 4302 | ||
4303 | 4303 | ||
4304 | if ( !mBlockShowDates ) { | 4304 | if ( !mBlockShowDates ) { |
4305 | if ( mViewManager->currentView() ) { | 4305 | if ( mViewManager->currentView() ) { |
4306 | updateView( selectedDates.first(), selectedDates.last() ); | 4306 | updateView( selectedDates.first(), selectedDates.last() ); |
4307 | } else { | 4307 | } else { |
4308 | mViewManager->showAgendaView(); | 4308 | mViewManager->showAgendaView(); |
4309 | } | 4309 | } |
4310 | } | 4310 | } |
4311 | 4311 | ||
4312 | QDate date = selectedDates.first(); | 4312 | QDate date = selectedDates.first(); |
4313 | if ( ! date.isValid() ) { | 4313 | if ( ! date.isValid() ) { |
4314 | topLevelWidget()->setCaption(""); | 4314 | topLevelWidget()->setCaption(""); |
4315 | return; | 4315 | return; |
4316 | } | 4316 | } |
4317 | 4317 | ||
4318 | QString selDates; | 4318 | QString selDates; |
4319 | selDates = KGlobal::locale()->formatDate( date, true); | 4319 | selDates = KGlobal::locale()->formatDate( date, true); |
4320 | if (selectedDates.first() < selectedDates.last() ) | 4320 | if (selectedDates.first() < selectedDates.last() ) |
4321 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4321 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4322 | else { | 4322 | else { |
4323 | QString addString; | 4323 | QString addString; |
4324 | if ( date == QDateTime::currentDateTime().date() ) | 4324 | if ( date == QDateTime::currentDateTime().date() ) |
4325 | addString = i18n("Today"); | 4325 | addString = i18n("Today"); |
4326 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4326 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4327 | addString = i18n("Tomorrow"); | 4327 | addString = i18n("Tomorrow"); |
4328 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4328 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4329 | addString = i18n("Yesterday"); | 4329 | addString = i18n("Yesterday"); |
4330 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4330 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4331 | addString = i18n("Day before yesterday"); | 4331 | addString = i18n("Day before yesterday"); |
4332 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4332 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4333 | addString = i18n("Day after tomorrow"); | 4333 | addString = i18n("Day after tomorrow"); |
4334 | if ( !addString.isEmpty() ) { | 4334 | if ( !addString.isEmpty() ) { |
4335 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4335 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4336 | return; | 4336 | return; |
4337 | } | 4337 | } |
4338 | } | 4338 | } |
4339 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4339 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4340 | 4340 | ||
4341 | } | 4341 | } |
4342 | 4342 | ||
4343 | QPtrList<CalFilter> CalendarView::filters() | 4343 | QPtrList<CalFilter> CalendarView::filters() |
4344 | { | 4344 | { |
4345 | return mFilters; | 4345 | return mFilters; |
4346 | 4346 | ||
4347 | } | 4347 | } |
4348 | void CalendarView::editFilters() | 4348 | void CalendarView::editFilters() |
4349 | { | 4349 | { |
4350 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4350 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4351 | 4351 | ||
4352 | CalFilter *filter = mFilters.first(); | 4352 | CalFilter *filter = mFilters.first(); |
4353 | while(filter) { | 4353 | while(filter) { |
4354 | filter = mFilters.next(); | 4354 | filter = mFilters.next(); |
4355 | } | 4355 | } |
4356 | 4356 | ||
4357 | mDialogManager->showFilterEditDialog(&mFilters); | 4357 | mDialogManager->showFilterEditDialog(&mFilters); |
4358 | updateFilter(); | 4358 | updateFilter(); |
4359 | } | 4359 | } |
4360 | void CalendarView::toggleFilter() | 4360 | void CalendarView::toggleFilter() |
4361 | { | 4361 | { |
4362 | if ( mLeftFrame->isHidden() ) { | 4362 | if ( mLeftFrame->isHidden() ) { |
4363 | toggleExpand(); | 4363 | toggleExpand(); |
4364 | showFilter( true ); | 4364 | showFilter( true ); |
4365 | } else | 4365 | } else |
4366 | showFilter(! mCalEditView->isVisible()); | 4366 | showFilter(! mCalEditView->isVisible()); |
4367 | } | 4367 | } |
4368 | 4368 | ||
4369 | KOFilterView *CalendarView::filterView() | 4369 | KOFilterView *CalendarView::filterView() |
4370 | { | 4370 | { |
4371 | return mFilterView; | 4371 | return mFilterView; |
4372 | } | 4372 | } |
4373 | void CalendarView::selectFilter( int fil ) | 4373 | void CalendarView::selectFilter( int fil ) |
4374 | { | 4374 | { |
4375 | mFilterView->setSelectedFilter( fil ); | 4375 | mFilterView->setSelectedFilter( fil ); |
4376 | updateUnmanagedViews(); | 4376 | updateUnmanagedViews(); |
4377 | } | 4377 | } |
4378 | void CalendarView::showFilter(bool visible) | 4378 | void CalendarView::showFilter(bool visible) |
4379 | { | 4379 | { |
4380 | #if 1 | 4380 | #if 1 |
4381 | if (visible) { | 4381 | if (visible) { |
4382 | mCalEditView->readConfig(); | 4382 | mCalEditView->readConfig(); |
4383 | mCalEditView->show(); | 4383 | mCalEditView->show(); |
4384 | QValueList<int> sizes; | 4384 | QValueList<int> sizes; |
4385 | sizes = mLeftFrame->sizes(); | 4385 | sizes = mLeftFrame->sizes(); |
4386 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4386 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4387 | sizes.clear(); | 4387 | sizes.clear(); |
4388 | sizes << 100; | 4388 | sizes << 100; |
4389 | sizes << 0; | 4389 | sizes << 0; |
4390 | sizes << 0; | 4390 | sizes << 0; |
4391 | sizes << 100; | 4391 | sizes << 100; |
4392 | mLeftFrame->setSizes(sizes); | 4392 | mLeftFrame->setSizes(sizes); |
4393 | } | 4393 | } |
4394 | #if 0 | 4394 | #if 0 |
4395 | sizes = mLeftFrame->sizes(); | 4395 | sizes = mLeftFrame->sizes(); |
4396 | int ccc = 0; | 4396 | int ccc = 0; |
4397 | while ( ccc < sizes.count()) { | 4397 | while ( ccc < sizes.count()) { |
4398 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4398 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4399 | ++ccc; | 4399 | ++ccc; |
4400 | } | 4400 | } |
4401 | #endif | 4401 | #endif |
4402 | 4402 | ||
4403 | } | 4403 | } |
4404 | else { | 4404 | else { |
4405 | mCalEditView->hide(); | 4405 | mCalEditView->hide(); |
4406 | } | 4406 | } |
4407 | #else | 4407 | #else |
4408 | if (visible) mFilterView->show(); | 4408 | if (visible) mFilterView->show(); |
4409 | else mFilterView->hide(); | 4409 | else mFilterView->hide(); |
4410 | #endif | 4410 | #endif |
4411 | } | 4411 | } |
4412 | void CalendarView::toggleFilerEnabled( ) | 4412 | void CalendarView::toggleFilerEnabled( ) |
4413 | { | 4413 | { |
4414 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4414 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4415 | if ( !mFilterView->filtersEnabled() ) | 4415 | if ( !mFilterView->filtersEnabled() ) |
4416 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4416 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4417 | updateUnmanagedViews(); | 4417 | updateUnmanagedViews(); |
4418 | 4418 | ||
4419 | } | 4419 | } |
4420 | void CalendarView::updateFilter() | 4420 | void CalendarView::updateFilter() |
4421 | { | 4421 | { |
4422 | CalFilter *filter = mFilterView->selectedFilter(); | 4422 | CalFilter *filter = mFilterView->selectedFilter(); |
4423 | if (filter) { | 4423 | if (filter) { |
4424 | QString mess; | 4424 | QString mess; |
4425 | if (mFilterView->filtersEnabled()) { | 4425 | if (mFilterView->filtersEnabled()) { |
4426 | mess = i18n("Filter selected: ")+filter->name(); | 4426 | mess = i18n("Filter selected: ")+filter->name(); |
4427 | filter->setEnabled(true); | 4427 | filter->setEnabled(true); |
4428 | } | 4428 | } |
4429 | else filter->setEnabled(false); | 4429 | else filter->setEnabled(false); |
4430 | mCalendar->setFilter(filter); | 4430 | mCalendar->setFilter(filter); |
4431 | updateView(); | 4431 | updateView(); |
4432 | if ( !mess.isEmpty() ) | 4432 | if ( !mess.isEmpty() ) |
4433 | topLevelWidget()->setCaption( mess ); | 4433 | topLevelWidget()->setCaption( mess ); |
4434 | 4434 | ||
4435 | } | 4435 | } |
4436 | emit filtersUpdated(); | 4436 | emit filtersUpdated(); |
4437 | } | 4437 | } |
4438 | 4438 | ||
4439 | void CalendarView::filterEdited() | 4439 | void CalendarView::filterEdited() |
4440 | { | 4440 | { |
4441 | mFilterView->updateFilters(); | 4441 | mFilterView->updateFilters(); |
4442 | updateFilter(); | 4442 | updateFilter(); |
4443 | writeSettings(); | 4443 | writeSettings(); |
4444 | } | 4444 | } |
4445 | 4445 | ||
4446 | 4446 | ||
4447 | void CalendarView::takeOverEvent() | 4447 | void CalendarView::takeOverEvent() |
4448 | { | 4448 | { |
4449 | Incidence *incidence = currentSelection(); | 4449 | Incidence *incidence = currentSelection(); |
4450 | 4450 | ||
4451 | if (!incidence) return; | 4451 | if (!incidence) return; |
4452 | 4452 | ||
4453 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4453 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4454 | incidence->recreate(); | 4454 | incidence->recreate(); |
4455 | incidence->setReadOnly(false); | 4455 | incidence->setReadOnly(false); |
4456 | 4456 | ||
4457 | updateView(); | 4457 | updateView(); |
4458 | } | 4458 | } |
4459 | 4459 | ||
4460 | void CalendarView::takeOverCalendar() | 4460 | void CalendarView::takeOverCalendar() |
4461 | { | 4461 | { |
4462 | // TODO: Create Calendar::allIncidences() function and use it here | 4462 | // TODO: Create Calendar::allIncidences() function and use it here |
4463 | 4463 | ||
4464 | clearAllViews(); | 4464 | clearAllViews(); |
4465 | QPtrList<Event> events = mCalendar->events(); | 4465 | QPtrList<Event> events = mCalendar->events(); |
4466 | for(uint i=0; i<events.count(); ++i) { | 4466 | for(uint i=0; i<events.count(); ++i) { |
4467 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4467 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4468 | events.at(i)->recreate(); | 4468 | events.at(i)->recreate(); |
4469 | events.at(i)->setReadOnly(false); | 4469 | events.at(i)->setReadOnly(false); |
4470 | } | 4470 | } |
4471 | 4471 | ||
4472 | QPtrList<Todo> todos = mCalendar->todos(); | 4472 | QPtrList<Todo> todos = mCalendar->todos(); |
4473 | for(uint i=0; i<todos.count(); ++i) { | 4473 | for(uint i=0; i<todos.count(); ++i) { |
4474 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4474 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4475 | todos.at(i)->recreate(); | 4475 | todos.at(i)->recreate(); |
4476 | todos.at(i)->setReadOnly(false); | 4476 | todos.at(i)->setReadOnly(false); |
4477 | } | 4477 | } |
4478 | 4478 | ||
4479 | QPtrList<Journal> journals = mCalendar->journals(); | 4479 | QPtrList<Journal> journals = mCalendar->journals(); |
4480 | for(uint i=0; i<journals.count(); ++i) { | 4480 | for(uint i=0; i<journals.count(); ++i) { |
4481 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4481 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4482 | journals.at(i)->recreate(); | 4482 | journals.at(i)->recreate(); |
4483 | journals.at(i)->setReadOnly(false); | 4483 | journals.at(i)->setReadOnly(false); |
4484 | } | 4484 | } |
4485 | 4485 | ||
4486 | updateView(); | 4486 | updateView(); |
4487 | } | 4487 | } |
4488 | 4488 | ||
4489 | void CalendarView::showIntro() | 4489 | void CalendarView::showIntro() |
4490 | { | 4490 | { |
4491 | kdDebug() << "To be implemented." << endl; | 4491 | kdDebug() << "To be implemented." << endl; |
4492 | } | 4492 | } |
4493 | 4493 | ||
4494 | QWidgetStack *CalendarView::viewStack() | 4494 | QWidgetStack *CalendarView::viewStack() |
4495 | { | 4495 | { |
4496 | return mRightFrame; | 4496 | return mRightFrame; |
4497 | } | 4497 | } |
4498 | 4498 | ||
4499 | QWidget *CalendarView::leftFrame() | 4499 | QWidget *CalendarView::leftFrame() |
4500 | { | 4500 | { |
4501 | return ( QWidget *)mLeftFrame; | 4501 | return ( QWidget *)mLeftFrame; |
4502 | } | 4502 | } |
4503 | 4503 | ||
4504 | DateNavigator *CalendarView::dateNavigator() | 4504 | DateNavigator *CalendarView::dateNavigator() |
4505 | { | 4505 | { |
4506 | return mNavigator; | 4506 | return mNavigator; |
4507 | } | 4507 | } |
4508 | 4508 | ||
4509 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4509 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4510 | { | 4510 | { |
4511 | return mDateNavigator->navigatorView(); | 4511 | return mDateNavigator->navigatorView(); |
4512 | } | 4512 | } |
4513 | void CalendarView::toggleDateNavigatorWidget() | 4513 | void CalendarView::toggleDateNavigatorWidget() |
4514 | { | 4514 | { |
4515 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4515 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4516 | 4516 | ||
4517 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4517 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4518 | mDateNavigator->hide(); | 4518 | mDateNavigator->hide(); |
4519 | else | 4519 | else |
4520 | mDateNavigator->show(); | 4520 | mDateNavigator->show(); |
4521 | } | 4521 | } |
4522 | void CalendarView::addView(KOrg::BaseView *view) | 4522 | void CalendarView::addView(KOrg::BaseView *view) |
4523 | { | 4523 | { |
4524 | mViewManager->addView(view); | 4524 | mViewManager->addView(view); |
4525 | } | 4525 | } |
4526 | 4526 | ||
4527 | void CalendarView::showView(KOrg::BaseView *view) | 4527 | void CalendarView::showView(KOrg::BaseView *view) |
4528 | { | 4528 | { |
4529 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4529 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4530 | } | 4530 | } |
4531 | 4531 | ||
4532 | Incidence *CalendarView::currentSelection() | 4532 | Incidence *CalendarView::currentSelection() |
4533 | { | 4533 | { |
4534 | return mViewManager->currentSelection(); | 4534 | return mViewManager->currentSelection(); |
4535 | } | 4535 | } |
4536 | void CalendarView::toggleAllDaySize() | 4536 | void CalendarView::toggleAllDaySize() |
4537 | { | 4537 | { |
4538 | /* | 4538 | /* |
4539 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4539 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4540 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4540 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4541 | else | 4541 | else |
4542 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4542 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4543 | */ | 4543 | */ |
4544 | viewManager()->agendaView()->toggleAllDay(); | 4544 | viewManager()->agendaView()->toggleAllDay(); |
4545 | } | 4545 | } |
4546 | void CalendarView::toggleExpand() | 4546 | void CalendarView::toggleExpand() |
4547 | { | 4547 | { |
4548 | // if ( mLeftFrame->isHidden() ) { | 4548 | // if ( mLeftFrame->isHidden() ) { |
4549 | // mLeftFrame->show(); | 4549 | // mLeftFrame->show(); |
4550 | // emit calendarViewExpanded( false ); | 4550 | // emit calendarViewExpanded( false ); |
4551 | // } else { | 4551 | // } else { |
4552 | // mLeftFrame->hide(); | 4552 | // mLeftFrame->hide(); |
4553 | // emit calendarViewExpanded( true ); | 4553 | // emit calendarViewExpanded( true ); |
4554 | // } | 4554 | // } |
4555 | //qDebug(" CalendarView::toggleExpand()"); | 4555 | //qDebug(" CalendarView::toggleExpand()"); |
4556 | globalFlagBlockAgenda = 1; | 4556 | globalFlagBlockAgenda = 1; |
4557 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4557 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4558 | globalFlagBlockAgenda = 5; | 4558 | globalFlagBlockAgenda = 5; |
4559 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4559 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4560 | //mViewManager->showView( 0, true ); | 4560 | //mViewManager->showView( 0, true ); |
4561 | } | 4561 | } |
4562 | 4562 | ||
4563 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4563 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4564 | { | 4564 | { |
4565 | setModified( modified ); | 4565 | setModified( modified ); |
4566 | } | 4566 | } |
4567 | 4567 | ||
4568 | Todo *CalendarView::selectedTodo() | 4568 | Todo *CalendarView::selectedTodo() |
4569 | { | 4569 | { |
4570 | Incidence *incidence = currentSelection(); | 4570 | Incidence *incidence = currentSelection(); |
4571 | if ( incidence && incidence->typeID() == todoID ) { | 4571 | if ( incidence && incidence->typeID() == todoID ) { |
4572 | return static_cast<Todo *>( incidence ); | 4572 | return static_cast<Todo *>( incidence ); |
4573 | } | 4573 | } |
4574 | 4574 | ||
4575 | incidence = mTodoList->selectedIncidences().first(); | 4575 | incidence = mTodoList->selectedIncidences().first(); |
4576 | if ( incidence && incidence->typeID() == todoID ) { | 4576 | if ( incidence && incidence->typeID() == todoID ) { |
4577 | return static_cast<Todo *>( incidence ); | 4577 | return static_cast<Todo *>( incidence ); |
4578 | } | 4578 | } |
4579 | 4579 | ||
4580 | return 0; | 4580 | return 0; |
4581 | } | 4581 | } |
4582 | 4582 | ||
4583 | void CalendarView::showIncidence() | 4583 | void CalendarView::showIncidence() |
4584 | { | 4584 | { |
4585 | mViewerCallerIsSearchDialog = false; | 4585 | mViewerCallerIsSearchDialog = false; |
4586 | Incidence *incidence = currentSelection(); | 4586 | Incidence *incidence = currentSelection(); |
4587 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4587 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4588 | if ( incidence ) { | 4588 | if ( incidence ) { |
4589 | ShowIncidenceVisitor v; | 4589 | ShowIncidenceVisitor v; |
4590 | v.act( incidence, this ); | 4590 | v.act( incidence, this ); |
4591 | } | 4591 | } |
4592 | } | 4592 | } |
4593 | void CalendarView::editIncidenceDescription() | 4593 | void CalendarView::editIncidenceDescription() |
4594 | { | 4594 | { |
4595 | mFlagEditDescription = true; | 4595 | mFlagEditDescription = true; |
4596 | editIncidence(); | 4596 | editIncidence(); |
4597 | mFlagEditDescription = false; | 4597 | mFlagEditDescription = false; |
4598 | } | 4598 | } |
4599 | void CalendarView::editIncidence() | 4599 | void CalendarView::editIncidence() |
4600 | { | 4600 | { |
4601 | // qDebug("editIncidence() "); | 4601 | // qDebug("editIncidence() "); |
4602 | Incidence *incidence = currentSelection(); | 4602 | Incidence *incidence = currentSelection(); |
4603 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4603 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4604 | if ( incidence ) { | 4604 | if ( incidence ) { |
4605 | EditIncidenceVisitor v; | 4605 | EditIncidenceVisitor v; |
4606 | v.act( incidence, this ); | 4606 | v.act( incidence, this ); |
4607 | } | 4607 | } |
4608 | } | 4608 | } |
4609 | 4609 | ||
4610 | void CalendarView::deleteIncidence() | 4610 | void CalendarView::deleteIncidence() |
4611 | { | 4611 | { |
4612 | Incidence *incidence = currentSelection(); | 4612 | Incidence *incidence = currentSelection(); |
4613 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4613 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4614 | if ( incidence ) { | 4614 | if ( incidence ) { |
4615 | deleteIncidence(incidence); | 4615 | deleteIncidence(incidence); |
4616 | } | 4616 | } |
4617 | } | 4617 | } |
4618 | void CalendarView::showIncidence(QString uid) | 4618 | void CalendarView::showIncidence(QString uid) |
4619 | { | 4619 | { |
4620 | Incidence *inc = mCalendar->incidence( uid ); | 4620 | Incidence *inc = mCalendar->incidence( uid ); |
4621 | if ( inc ) | 4621 | if ( inc ) |
4622 | showIncidence( inc ); | 4622 | showIncidence( inc ); |
4623 | } | 4623 | } |
4624 | void CalendarView::showIncidence(Incidence *incidence) | 4624 | void CalendarView::showIncidence(Incidence *incidence) |
4625 | { | 4625 | { |
4626 | mViewerCallerIsSearchDialog = false; | 4626 | mViewerCallerIsSearchDialog = false; |
4627 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4627 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4628 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4628 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4629 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4629 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4630 | mViewerCallerIsSearchDialog = true; | 4630 | mViewerCallerIsSearchDialog = true; |
4631 | } | 4631 | } |
4632 | } | 4632 | } |
4633 | if ( incidence ) { | 4633 | if ( incidence ) { |
4634 | ShowIncidenceVisitor v; | 4634 | ShowIncidenceVisitor v; |
4635 | v.act( incidence, this ); | 4635 | v.act( incidence, this ); |
4636 | } | 4636 | } |
4637 | } | 4637 | } |
4638 | 4638 | ||
4639 | void CalendarView::editIncidence(Incidence *incidence) | 4639 | void CalendarView::editIncidence(Incidence *incidence) |
4640 | { | 4640 | { |
4641 | if ( incidence ) { | 4641 | if ( incidence ) { |
4642 | 4642 | ||
4643 | EditIncidenceVisitor v; | 4643 | EditIncidenceVisitor v; |
4644 | v.act( incidence, this ); | 4644 | v.act( incidence, this ); |
4645 | 4645 | ||
4646 | } | 4646 | } |
4647 | } | 4647 | } |
4648 | 4648 | ||
4649 | void CalendarView::deleteIncidence(Incidence *incidence) | 4649 | void CalendarView::deleteIncidence(Incidence *incidence) |
4650 | { | 4650 | { |
4651 | //qDebug(" CalendarView::deleteIncidence "); | 4651 | //qDebug(" CalendarView::deleteIncidence "); |
4652 | if ( incidence == 0 ) { | 4652 | if ( incidence == 0 ) { |
4653 | updateView(); | 4653 | updateView(); |
4654 | emit updateSearchDialog(); | 4654 | emit updateSearchDialog(); |
4655 | return; | 4655 | return; |
4656 | } | 4656 | } |
4657 | if ( incidence ) { | 4657 | if ( incidence ) { |
4658 | DeleteIncidenceVisitor v; | 4658 | DeleteIncidenceVisitor v; |
4659 | v.act( incidence, this ); | 4659 | v.act( incidence, this ); |
4660 | } | 4660 | } |
4661 | } | 4661 | } |
4662 | 4662 | ||
4663 | 4663 | ||
4664 | void CalendarView::lookForOutgoingMessages() | 4664 | void CalendarView::lookForOutgoingMessages() |
4665 | { | 4665 | { |
4666 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4666 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4667 | ogd->loadMessages(); | 4667 | ogd->loadMessages(); |
4668 | } | 4668 | } |
4669 | 4669 | ||
4670 | void CalendarView::lookForIncomingMessages() | 4670 | void CalendarView::lookForIncomingMessages() |
4671 | { | 4671 | { |
4672 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4672 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4673 | icd->retrieve(); | 4673 | icd->retrieve(); |
4674 | } | 4674 | } |
4675 | 4675 | ||
4676 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4676 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4677 | { | 4677 | { |
4678 | bool deleteTodo = true; | 4678 | bool deleteTodo = true; |
4679 | QPtrList<Incidence> subTodos; | 4679 | QPtrList<Incidence> subTodos; |
4680 | Incidence *aTodo; | 4680 | Incidence *aTodo; |
4681 | subTodos = t->relations(); | 4681 | subTodos = t->relations(); |
4682 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4682 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4683 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4683 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4684 | deleteTodo = false; | 4684 | deleteTodo = false; |
4685 | } | 4685 | } |
4686 | if ( deleteTodo ) { | 4686 | if ( deleteTodo ) { |
4687 | if ( t->isCompleted() && !t->doesRecur()) { | 4687 | if ( t->isCompleted() && !t->doesRecur()) { |
4688 | checkExternalId( t ); | 4688 | checkExternalId( t ); |
4689 | mCalendar->deleteTodo( t ); | 4689 | mCalendar->deleteTodo( t ); |
4690 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4690 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4691 | } | 4691 | } |
4692 | else | 4692 | else |
4693 | deleteTodo = false; | 4693 | deleteTodo = false; |
4694 | } | 4694 | } |
4695 | return deleteTodo; | 4695 | return deleteTodo; |
4696 | 4696 | ||
4697 | } | 4697 | } |
4698 | void CalendarView::purgeCompleted() | 4698 | void CalendarView::purgeCompleted() |
4699 | { | 4699 | { |
4700 | int result = KMessageBox::warningContinueCancel(this, | 4700 | int result = KMessageBox::warningContinueCancel(this, |
4701 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4701 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4702 | 4702 | ||
4703 | if (result == KMessageBox::Continue) { | 4703 | if (result == KMessageBox::Continue) { |
4704 | 4704 | ||
4705 | QPtrList<Todo> todoCal; | 4705 | QPtrList<Todo> todoCal; |
4706 | QPtrList<Todo> rootTodos; | 4706 | QPtrList<Todo> rootTodos; |
4707 | //QPtrList<Incidence> rel; | 4707 | //QPtrList<Incidence> rel; |
4708 | Todo *aTodo; | 4708 | Todo *aTodo; |
4709 | todoCal = calendar()->todos(); | 4709 | todoCal = calendar()->todos(); |
4710 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4710 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4711 | if ( !aTodo->relatedTo() ) | 4711 | if ( !aTodo->relatedTo() ) |
4712 | rootTodos.append( aTodo ); | 4712 | rootTodos.append( aTodo ); |
4713 | } | 4713 | } |
4714 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4714 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4715 | removeCompletedSubTodos( aTodo ); | 4715 | removeCompletedSubTodos( aTodo ); |
4716 | } | 4716 | } |
4717 | 4717 | ||
4718 | updateView(); | 4718 | updateView(); |
4719 | } | 4719 | } |
4720 | } | 4720 | } |
4721 | 4721 | ||
4722 | void CalendarView::slotCalendarChanged() | 4722 | void CalendarView::slotCalendarChanged() |
4723 | { | 4723 | { |
4724 | ; | 4724 | ; |
4725 | } | 4725 | } |
4726 | 4726 | ||
4727 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4727 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4728 | { | 4728 | { |
4729 | //qDebug("CalendarView::keyPressEvent "); | 4729 | //qDebug("CalendarView::keyPressEvent "); |
4730 | e->ignore(); | 4730 | e->ignore(); |
4731 | } | 4731 | } |
4732 | 4732 | ||
4733 | 4733 | ||
4734 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4734 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4735 | { | 4735 | { |
4736 | 4736 | ||
4737 | if ( manager != mSyncManager) | 4737 | if ( manager != mSyncManager) |
4738 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 4738 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
4739 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4739 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4740 | qDebug("KO: SyncKDE request detected!"); | 4740 | qDebug("KO: SyncKDE request detected!"); |
4741 | } | 4741 | } |
4742 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4742 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4743 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4743 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4744 | return syncCalendar( filename, mode ); | 4744 | return syncCalendar( filename, mode ); |
4745 | } | 4745 | } |
4746 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4746 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4747 | { | 4747 | { |
4748 | //mSyncManager = manager; | 4748 | //mSyncManager = manager; |
4749 | if ( manager != mSyncManager) | 4749 | if ( manager != mSyncManager) |
4750 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 4750 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
4751 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4751 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4752 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4752 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4753 | if ( resource == "sharp" ) | 4753 | if ( resource == "sharp" ) |
4754 | syncExternal( 0 ); | 4754 | syncExternal( 0 ); |
4755 | if ( resource == "phone" ) | 4755 | if ( resource == "phone" ) |
4756 | syncExternal( 1 ); | 4756 | syncExternal( 1 ); |
4757 | // pending setmodified | 4757 | // pending setmodified |
4758 | return true; | 4758 | return true; |
4759 | } | 4759 | } |
4760 | void CalendarView::setSyncManager(KSyncManager* manager) | 4760 | void CalendarView::setSyncManager(KSyncManager* manager) |
4761 | { | 4761 | { |
4762 | mSyncManager = manager; | 4762 | mSyncManager = manager; |
4763 | } | 4763 | } |
4764 | 4764 | ||
4765 | void CalendarView::removeSyncInfo( QString syncProfile) | 4765 | void CalendarView::removeSyncInfo( QString syncProfile) |
4766 | { | 4766 | { |
4767 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4767 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4768 | mCalendar->removeSyncInfo( syncProfile ); | 4768 | mCalendar->removeSyncInfo( syncProfile ); |
4769 | 4769 | ||
4770 | } | 4770 | } |
4771 | 4771 | ||
4772 | void CalendarView::undo_delete() | 4772 | void CalendarView::undo_delete() |
4773 | { | 4773 | { |
4774 | //qDebug("undo_delete() "); | 4774 | //qDebug("undo_delete() "); |
4775 | Incidence* undo = mCalendar->undoIncidence(); | 4775 | Incidence* undo = mCalendar->undoIncidence(); |
4776 | if ( !undo ) { | 4776 | if ( !undo ) { |
4777 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4777 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4778 | i18n("KO/Pi")); | 4778 | i18n("KO/Pi")); |
4779 | return; | 4779 | return; |
4780 | } | 4780 | } |
4781 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 4781 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
4782 | i18n("\nAre you sure you want\nto restore this?"), | 4782 | i18n("\nAre you sure you want\nto restore this?"), |
4783 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4783 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4784 | mCalendar->undoDeleteIncidence(); | 4784 | mCalendar->undoDeleteIncidence(); |
4785 | updateView(); | 4785 | updateView(); |
4786 | } | 4786 | } |
4787 | } | 4787 | } |
4788 | 4788 | ||
4789 | void CalendarView::slotViewerClosed() | 4789 | void CalendarView::slotViewerClosed() |
4790 | { | 4790 | { |
4791 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4791 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4792 | } | 4792 | } |
4793 | 4793 | ||
4794 | void CalendarView::resetFocus() | 4794 | void CalendarView::resetFocus() |
4795 | { | 4795 | { |
4796 | if ( mViewerCallerIsSearchDialog ) { | 4796 | if ( mViewerCallerIsSearchDialog ) { |
4797 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4797 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4798 | mDialogManager->getSearchDialog()->raise(); | 4798 | mDialogManager->getSearchDialog()->raise(); |
4799 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4799 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4800 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4800 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4801 | } else | 4801 | } else |
4802 | mViewerCallerIsSearchDialog = false; | 4802 | mViewerCallerIsSearchDialog = false; |
4803 | } | 4803 | } |
4804 | if ( !mViewerCallerIsSearchDialog ) { | 4804 | if ( !mViewerCallerIsSearchDialog ) { |
4805 | //mViewManager->currentView()->setFocus(); | 4805 | //mViewManager->currentView()->setFocus(); |
4806 | //qDebug("sssssssssssssssset focus "); | 4806 | //qDebug("sssssssssssssssset focus "); |
4807 | topLevelWidget()->raise(); | 4807 | topLevelWidget()->raise(); |
4808 | setActiveWindow(); | 4808 | setActiveWindow(); |
4809 | //setFocus(); | 4809 | //setFocus(); |
4810 | } | 4810 | } |
4811 | mViewerCallerIsSearchDialog = false; | 4811 | mViewerCallerIsSearchDialog = false; |
4812 | } | 4812 | } |
4813 | 4813 | ||
4814 | void CalendarView::showNextAlarms() | 4814 | void CalendarView::showNextAlarms() |
4815 | { | 4815 | { |
4816 | QString message; | 4816 | QString message; |
4817 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4817 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4818 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4818 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4819 | QString sum = mCalendar->nextSummary(); | 4819 | QString sum = mCalendar->nextSummary(); |
4820 | QDateTime nextA = mNextAlarmDateTime; | 4820 | QDateTime nextA = mNextAlarmDateTime; |
4821 | QDateTime cur = QDateTime::currentDateTime(); | 4821 | QDateTime cur = QDateTime::currentDateTime(); |
4822 | int secs = cur.secsTo( nextA ); | 4822 | int secs = cur.secsTo( nextA ); |
4823 | int min = secs /60; | 4823 | int min = secs /60; |
4824 | int hours = min /60; | 4824 | int hours = min /60; |
4825 | min = min % 60; | 4825 | min = min % 60; |
4826 | int days = hours /24; | 4826 | int days = hours /24; |
4827 | hours = hours % 24; | 4827 | hours = hours % 24; |
4828 | 4828 | ||
4829 | //message = i18n("The next alarm is in:\n"); | 4829 | //message = i18n("The next alarm is in:\n"); |
4830 | if ( days > 1 ) | 4830 | if ( days > 1 ) |
4831 | message += i18n("%1 days\n").arg( days ); | 4831 | message += i18n("%1 days\n").arg( days ); |
4832 | else if ( days == 1 ) | 4832 | else if ( days == 1 ) |
4833 | message += i18n("1 day\n"); | 4833 | message += i18n("1 day\n"); |
4834 | if ( hours > 1 ) | 4834 | if ( hours > 1 ) |
4835 | message += i18n("%1 hours\n").arg( hours ); | 4835 | message += i18n("%1 hours\n").arg( hours ); |
4836 | else if ( hours == 1 ) | 4836 | else if ( hours == 1 ) |
4837 | message += i18n("1 hour\n"); | 4837 | message += i18n("1 hour\n"); |
4838 | if ( min > 1 ) | 4838 | if ( min > 1 ) |
4839 | message += i18n("%1 minutes\n").arg( min ); | 4839 | message += i18n("%1 minutes\n").arg( min ); |
4840 | else if ( min == 1 ) | 4840 | else if ( min == 1 ) |
4841 | message += i18n("1 minute\n"); | 4841 | message += i18n("1 minute\n"); |
4842 | if ( message.isEmpty() ) | 4842 | if ( message.isEmpty() ) |
4843 | message = i18n("The next alarm is in\nless than one minute!"); | 4843 | message = i18n("The next alarm is in\nless than one minute!"); |
4844 | else | 4844 | else |
4845 | message = i18n("The next alarm is in:\n") + message; | 4845 | message = i18n("The next alarm is in:\n") + message; |
4846 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4846 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4847 | } else { | 4847 | } else { |
4848 | message = i18n("There is no next alarm."); | 4848 | message = i18n("There is no next alarm."); |
4849 | 4849 | ||
4850 | } | 4850 | } |
4851 | #ifdef DESKTOP_VERSION | 4851 | #ifdef DESKTOP_VERSION |
4852 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4852 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4853 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4853 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4854 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4854 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4855 | } | 4855 | } |
4856 | 4856 | ||
4857 | #endif | 4857 | #endif |
4858 | KMessageBox::information( this, message); | 4858 | KMessageBox::information( this, message); |
4859 | } | 4859 | } |