author | zautrix <zautrix> | 2005-07-07 21:34:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-07 21:34:31 (UTC) |
commit | 3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc (patch) (unidiff) | |
tree | 6fceb199e62afe671ed34acb308749ea09cac578 /korganizer | |
parent | de5621f2fd3924f27c05459ae555b3bd06c5e584 (diff) | |
download | kdepimpi-3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc.zip kdepimpi-3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc.tar.gz kdepimpi-3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/calendarview.cpp | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 65750af..426e8f9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4834 +1,4850 @@ | |||
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 "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | #include "categoryeditdialog.h" | 119 | #include "categoryeditdialog.h" |
120 | 120 | ||
121 | #include "calendarview.h" | 121 | #include "calendarview.h" |
122 | #ifndef DESKTOP_VERSION | 122 | #ifndef DESKTOP_VERSION |
123 | #include <qtopia/alarmserver.h> | 123 | #include <qtopia/alarmserver.h> |
124 | #endif | 124 | #endif |
125 | #ifndef _WIN32_ | 125 | #ifndef _WIN32_ |
126 | #include <stdlib.h> | 126 | #include <stdlib.h> |
127 | #include <stdio.h> | 127 | #include <stdio.h> |
128 | #include <unistd.h> | 128 | #include <unistd.h> |
129 | #else | 129 | #else |
130 | #include <qprocess.h> | 130 | #include <qprocess.h> |
131 | #endif | 131 | #endif |
132 | 132 | ||
133 | #ifdef DESKTOP_VERSION | 133 | #ifdef DESKTOP_VERSION |
134 | #include <kabc/stdaddressbook.h> | 134 | #include <kabc/stdaddressbook.h> |
135 | #endif | 135 | #endif |
136 | using namespace KOrg; | 136 | using namespace KOrg; |
137 | using namespace KCal; | 137 | using namespace KCal; |
138 | extern int globalFlagBlockAgenda; | 138 | extern int globalFlagBlockAgenda; |
139 | extern int globalFlagBlockStartup; | 139 | extern int globalFlagBlockStartup; |
140 | 140 | ||
141 | 141 | ||
142 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 142 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
143 | 143 | ||
144 | { | 144 | { |
145 | mAlarms = alarms; | 145 | mAlarms = alarms; |
146 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 146 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
147 | QString mText = "<table width=\"100%\">\n"; | 147 | QString mText = "<table width=\"100%\">\n"; |
148 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 148 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
149 | #ifdef DESKTOP_VERSION | 149 | #ifdef DESKTOP_VERSION |
150 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 150 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
151 | #else | 151 | #else |
152 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 152 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
153 | #endif | 153 | #endif |
154 | // mText += "<img src=\""; | 154 | // mText += "<img src=\""; |
155 | // mText += ipath; | 155 | // mText += ipath; |
156 | // mText += "\">"; | 156 | // mText += "\">"; |
157 | //mEventDate = QDate::currentDate(); | 157 | //mEventDate = QDate::currentDate(); |
158 | #ifdef DESKTOP_VERSION | 158 | #ifdef DESKTOP_VERSION |
159 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 159 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
160 | #else | 160 | #else |
161 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 161 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
162 | #endif | 162 | #endif |
163 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 163 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
164 | 164 | ||
165 | Incidence * inc = getNextInc( start ); | 165 | Incidence * inc = getNextInc( start ); |
166 | int time = 0; | 166 | int time = 0; |
167 | //mText += "<table>"; | 167 | //mText += "<table>"; |
168 | while ( inc ) { | 168 | while ( inc ) { |
169 | QDateTime dt ; | 169 | QDateTime dt ; |
170 | QString tempText = "<a "; | 170 | QString tempText = "<a "; |
171 | bool ok; | 171 | bool ok; |
172 | dt = inc->getNextOccurence( start, &ok ); | 172 | dt = inc->getNextOccurence( start, &ok ); |
173 | if ( !ok ) continue; | 173 | if ( !ok ) continue; |
174 | if ( inc->typeID() == eventID ) { | 174 | if ( inc->typeID() == eventID ) { |
175 | tempText += "href=\"event:"; | 175 | tempText += "href=\"event:"; |
176 | } else if ( inc->typeID() == todoID ) { | 176 | } else if ( inc->typeID() == todoID ) { |
177 | tempText += "href=\"todo:"; | 177 | tempText += "href=\"todo:"; |
178 | } | 178 | } |
179 | tempText += inc->uid() + "\">"; | 179 | tempText += inc->uid() + "\">"; |
180 | if ( inc->typeID() == todoID ) | 180 | if ( inc->typeID() == todoID ) |
181 | tempText += i18n("Todo: "); | 181 | tempText += i18n("Todo: "); |
182 | if ( inc->summary().length() > 0 ) | 182 | if ( inc->summary().length() > 0 ) |
183 | tempText += inc->summary(); | 183 | tempText += inc->summary(); |
184 | else | 184 | else |
185 | tempText += i18n("-no summary-"); | 185 | tempText += i18n("-no summary-"); |
186 | QString timestr; | 186 | QString timestr; |
187 | if (!inc->doesFloat()) | 187 | if (!inc->doesFloat()) |
188 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 188 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
189 | else | 189 | else |
190 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 190 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
191 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 191 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
192 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 192 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
193 | mText += "<table>"; | 193 | mText += "<table>"; |
194 | time = 1; | 194 | time = 1; |
195 | } | 195 | } |
196 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 196 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
197 | if ( time > 0 ) | 197 | if ( time > 0 ) |
198 | mText +="</table>"; | 198 | mText +="</table>"; |
199 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 199 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
200 | mText += "<table>"; | 200 | mText += "<table>"; |
201 | time = 2; | 201 | time = 2; |
202 | 202 | ||
203 | } | 203 | } |
204 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 204 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
205 | if ( time > 0 ) | 205 | if ( time > 0 ) |
206 | mText +="</table>"; | 206 | mText +="</table>"; |
207 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 207 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
208 | mText += "<table>"; | 208 | mText += "<table>"; |
209 | time = 3; | 209 | time = 3; |
210 | } | 210 | } |
211 | mText +="<tr><td><b>"; | 211 | mText +="<tr><td><b>"; |
212 | mText += timestr; | 212 | mText += timestr; |
213 | mText += "</b></td><td>"; | 213 | mText += "</b></td><td>"; |
214 | mText += tempText; | 214 | mText += tempText; |
215 | mText += "</td></tr>\n"; | 215 | mText += "</td></tr>\n"; |
216 | inc = getNextInc( start ); | 216 | inc = getNextInc( start ); |
217 | } | 217 | } |
218 | mText +="</table>"; | 218 | mText +="</table>"; |
219 | setText( mText ); | 219 | setText( mText ); |
220 | } | 220 | } |
221 | 221 | ||
222 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 222 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
223 | { | 223 | { |
224 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 224 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
225 | } | 225 | } |
226 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 226 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
227 | { | 227 | { |
228 | QDateTime dt ; | 228 | QDateTime dt ; |
229 | Incidence * retInc; | 229 | Incidence * retInc; |
230 | Incidence * inc = mAlarms.first(); | 230 | Incidence * inc = mAlarms.first(); |
231 | if ( inc == 0 ) | 231 | if ( inc == 0 ) |
232 | return 0; | 232 | return 0; |
233 | bool ok; | 233 | bool ok; |
234 | dt = inc->getNextOccurence( start, &ok ); | 234 | dt = inc->getNextOccurence( start, &ok ); |
235 | if ( ! ok ) return 0; | 235 | if ( ! ok ) return 0; |
236 | QDateTime dtn ; | 236 | QDateTime dtn ; |
237 | retInc = inc; | 237 | retInc = inc; |
238 | inc = mAlarms.next(); | 238 | inc = mAlarms.next(); |
239 | while ( inc ) { | 239 | while ( inc ) { |
240 | dtn = inc->getNextOccurence( start, &ok ); | 240 | dtn = inc->getNextOccurence( start, &ok ); |
241 | if ( ! ok ) return 0; | 241 | if ( ! ok ) return 0; |
242 | if ( dtn < dt ) { | 242 | if ( dtn < dt ) { |
243 | dt = dtn; | 243 | dt = dtn; |
244 | retInc = inc; | 244 | retInc = inc; |
245 | } | 245 | } |
246 | inc = mAlarms.next(); | 246 | inc = mAlarms.next(); |
247 | } | 247 | } |
248 | mAlarms.remove( retInc ); | 248 | mAlarms.remove( retInc ); |
249 | return retInc; | 249 | return retInc; |
250 | 250 | ||
251 | } | 251 | } |
252 | void MissedAlarmTextBrowser::setSource(const QString & n) | 252 | void MissedAlarmTextBrowser::setSource(const QString & n) |
253 | { | 253 | { |
254 | if (n.startsWith("event:")) { | 254 | if (n.startsWith("event:")) { |
255 | #ifdef DESKTOP_VERSION | 255 | #ifdef DESKTOP_VERSION |
256 | emit showIncidence(n.mid(8)); | 256 | emit showIncidence(n.mid(8)); |
257 | #else | 257 | #else |
258 | emit showIncidence(n.mid(6)); | 258 | emit showIncidence(n.mid(6)); |
259 | #endif | 259 | #endif |
260 | return; | 260 | return; |
261 | } else if (n.startsWith("todo:")) { | 261 | } else if (n.startsWith("todo:")) { |
262 | #ifdef DESKTOP_VERSION | 262 | #ifdef DESKTOP_VERSION |
263 | emit showIncidence(n.mid(7)); | 263 | emit showIncidence(n.mid(7)); |
264 | #else | 264 | #else |
265 | emit showIncidence(n.mid(5)); | 265 | emit showIncidence(n.mid(5)); |
266 | #endif | 266 | #endif |
267 | return; | 267 | return; |
268 | } | 268 | } |
269 | } | 269 | } |
270 | 270 | ||
271 | 271 | ||
272 | class KOBeamPrefs : public QDialog | 272 | class KOBeamPrefs : public QDialog |
273 | { | 273 | { |
274 | public: | 274 | public: |
275 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 275 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
276 | QDialog( parent, name, true ) | 276 | QDialog( parent, name, true ) |
277 | { | 277 | { |
278 | setCaption( i18n("Beam Options") ); | 278 | setCaption( i18n("Beam Options") ); |
279 | QVBoxLayout* lay = new QVBoxLayout( this ); | 279 | QVBoxLayout* lay = new QVBoxLayout( this ); |
280 | lay->setSpacing( 3 ); | 280 | lay->setSpacing( 3 ); |
281 | lay->setMargin( 3 ); | 281 | lay->setMargin( 3 ); |
282 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 282 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
283 | lay->addWidget( format ); | 283 | lay->addWidget( format ); |
284 | format->setExclusive ( true ) ; | 284 | format->setExclusive ( true ) ; |
285 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 285 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
286 | lay->addWidget( time ); time->setExclusive ( true ) ; | 286 | lay->addWidget( time ); time->setExclusive ( true ) ; |
287 | vcal = new QRadioButton(" vCalendar ", format ); | 287 | vcal = new QRadioButton(" vCalendar ", format ); |
288 | ical = new QRadioButton(" iCalendar ", format ); | 288 | ical = new QRadioButton(" iCalendar ", format ); |
289 | vcal->setChecked( true ); | 289 | vcal->setChecked( true ); |
290 | tz = new QRadioButton(i18n(" With timezone "), time ); | 290 | tz = new QRadioButton(i18n(" With timezone "), time ); |
291 | local = new QRadioButton(i18n(" Local time "), time ); | 291 | local = new QRadioButton(i18n(" Local time "), time ); |
292 | tz->setChecked( true ); | 292 | tz->setChecked( true ); |
293 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 293 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
294 | lay->addWidget( ok ); | 294 | lay->addWidget( ok ); |
295 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 295 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
296 | lay->addWidget( cancel ); | 296 | lay->addWidget( cancel ); |
297 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 297 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
298 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 298 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
299 | resize( 200, 200 ); | 299 | resize( 200, 200 ); |
300 | } | 300 | } |
301 | 301 | ||
302 | bool beamVcal() { return vcal->isChecked(); } | 302 | bool beamVcal() { return vcal->isChecked(); } |
303 | bool beamLocal() { return local->isChecked(); } | 303 | bool beamLocal() { return local->isChecked(); } |
304 | private: | 304 | private: |
305 | QRadioButton* vcal, *ical, *local, *tz; | 305 | QRadioButton* vcal, *ical, *local, *tz; |
306 | }; | 306 | }; |
307 | class KOCatPrefs : public QDialog | 307 | class KOCatPrefs : public QDialog |
308 | { | 308 | { |
309 | public: | 309 | public: |
310 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 310 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
311 | QDialog( parent, name, true ) | 311 | QDialog( parent, name, true ) |
312 | { | 312 | { |
313 | setCaption( i18n("Manage new Categories") ); | 313 | setCaption( i18n("Manage new Categories") ); |
314 | QVBoxLayout* lay = new QVBoxLayout( this ); | 314 | QVBoxLayout* lay = new QVBoxLayout( this ); |
315 | lay->setSpacing( 3 ); | 315 | lay->setSpacing( 3 ); |
316 | lay->setMargin( 3 ); | 316 | lay->setMargin( 3 ); |
317 | 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 ); | 317 | 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 | lay->addWidget( lab ); | 318 | lay->addWidget( lab ); |
319 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 319 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
320 | lay->addWidget( format ); | 320 | lay->addWidget( format ); |
321 | format->setExclusive ( true ) ; | 321 | format->setExclusive ( true ) ; |
322 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 322 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
323 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 323 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
324 | addCatBut->setChecked( true ); | 324 | addCatBut->setChecked( true ); |
325 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 325 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
326 | lay->addWidget( ok ); | 326 | lay->addWidget( ok ); |
327 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 327 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
328 | lay->addWidget( cancel ); | 328 | lay->addWidget( cancel ); |
329 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 329 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
330 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 330 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
331 | resize( 200, 200 ); | 331 | resize( 200, 200 ); |
332 | } | 332 | } |
333 | 333 | ||
334 | bool addCat() { return addCatBut->isChecked(); } | 334 | bool addCat() { return addCatBut->isChecked(); } |
335 | private: | 335 | private: |
336 | QRadioButton* addCatBut; | 336 | QRadioButton* addCatBut; |
337 | }; | 337 | }; |
338 | 338 | ||
339 | 339 | ||
340 | 340 | ||
341 | CalendarView::CalendarView( CalendarResources *calendar, | 341 | CalendarView::CalendarView( CalendarResources *calendar, |
342 | QWidget *parent, const char *name ) | 342 | QWidget *parent, const char *name ) |
343 | : CalendarViewBase( parent, name ), | 343 | : CalendarViewBase( parent, name ), |
344 | mCalendar( calendar ), | 344 | mCalendar( calendar ), |
345 | mResourceManager( calendar->resourceManager() ) | 345 | mResourceManager( calendar->resourceManager() ) |
346 | { | 346 | { |
347 | 347 | ||
348 | mEventEditor = 0; | 348 | mEventEditor = 0; |
349 | mTodoEditor = 0; | 349 | mTodoEditor = 0; |
350 | 350 | ||
351 | init(); | 351 | init(); |
352 | } | 352 | } |
353 | 353 | ||
354 | CalendarView::CalendarView( Calendar *calendar, | 354 | CalendarView::CalendarView( Calendar *calendar, |
355 | QWidget *parent, const char *name ) | 355 | QWidget *parent, const char *name ) |
356 | : CalendarViewBase( parent, name ), | 356 | : CalendarViewBase( parent, name ), |
357 | mCalendar( calendar ), | 357 | mCalendar( calendar ), |
358 | mResourceManager( 0 ) | 358 | mResourceManager( 0 ) |
359 | { | 359 | { |
360 | 360 | ||
361 | mEventEditor = 0; | 361 | mEventEditor = 0; |
362 | mTodoEditor = 0; | 362 | mTodoEditor = 0; |
363 | init(); | 363 | init(); |
364 | } | 364 | } |
365 | 365 | ||
366 | void CalendarView::init() | 366 | void CalendarView::init() |
367 | { | 367 | { |
368 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 368 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
369 | setFocusPolicy ( NoFocus ); | 369 | setFocusPolicy ( NoFocus ); |
370 | mViewerCallerIsSearchDialog = false; | 370 | mViewerCallerIsSearchDialog = false; |
371 | mBlockShowDates = false; | 371 | mBlockShowDates = false; |
372 | 372 | ||
373 | mDatePickerMode = 0; | 373 | mDatePickerMode = 0; |
374 | mCurrentSyncDevice = ""; | 374 | mCurrentSyncDevice = ""; |
375 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
378 | mModified = false; | 378 | mModified = false; |
379 | mReadOnly = false; | 379 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
383 | 383 | ||
384 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 386 | ||
387 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 389 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 392 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
395 | 395 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 399 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
402 | 402 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 407 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 409 | mResourceView = 0; |
410 | #else | 410 | #else |
411 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
416 | } else { | 416 | } else { |
417 | mResourceView = 0; | 417 | mResourceView = 0; |
418 | } | 418 | } |
419 | #endif | 419 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 422 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 425 | ||
426 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
427 | #else | 427 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 438 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 445 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
449 | #ifdef DESKTOP_VERSION | 449 | #ifdef DESKTOP_VERSION |
450 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); | 450 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); |
451 | topLayout->addWidget( mDateScrollBar ); | 451 | topLayout->addWidget( mDateScrollBar ); |
452 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 452 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
453 | if ( QApplication::desktop()->width() < 800 ) | 453 | if ( QApplication::desktop()->width() < 800 ) |
454 | mDateScrollBar->hide(); | 454 | mDateScrollBar->hide(); |
455 | #endif | 455 | #endif |
456 | //mainBoxLayout->addWidget (mLeftFrame); | 456 | //mainBoxLayout->addWidget (mLeftFrame); |
457 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 457 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
458 | "CalendarView::DateNavigator" ); | 458 | "CalendarView::DateNavigator" ); |
459 | #if 0 | 459 | #if 0 |
460 | // FIXME | 460 | // FIXME |
461 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 461 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
462 | "CalendarView::DateNavigator", QDate::currentDate()); | 462 | "CalendarView::DateNavigator", QDate::currentDate()); |
463 | #endif | 463 | #endif |
464 | // mDateNavigator->blockSignals( true ); | 464 | // mDateNavigator->blockSignals( true ); |
465 | //leftFrameLayout->addWidget( mDateNavigator ); | 465 | //leftFrameLayout->addWidget( mDateNavigator ); |
466 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 466 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
467 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 467 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
468 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 468 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
469 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 469 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
470 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 472 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 474 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
475 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 475 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
476 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 476 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
477 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 477 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
478 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 478 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
479 | 479 | ||
480 | mTodoList->setNavigator( mNavigator ); | 480 | mTodoList->setNavigator( mNavigator ); |
481 | #if 0 | 481 | #if 0 |
482 | if ( QApplication::desktop()->width() < 480 ) { | 482 | if ( QApplication::desktop()->width() < 480 ) { |
483 | leftFrameLayout->addWidget(mFilterView); | 483 | leftFrameLayout->addWidget(mFilterView); |
484 | leftFrameLayout->addWidget(mTodoList, 2 ); | 484 | leftFrameLayout->addWidget(mTodoList, 2 ); |
485 | 485 | ||
486 | } else { | 486 | } else { |
487 | leftFrameLayout->addWidget(mTodoList,2 ); | 487 | leftFrameLayout->addWidget(mTodoList,2 ); |
488 | leftFrameLayout->addWidget(mFilterView ); | 488 | leftFrameLayout->addWidget(mFilterView ); |
489 | } | 489 | } |
490 | #endif | 490 | #endif |
491 | mFilterView->hide(); | 491 | mFilterView->hide(); |
492 | mCalEditView->hide(); | 492 | mCalEditView->hide(); |
493 | QWidget *rightBox = new QWidget( mMainFrame ); | 493 | QWidget *rightBox = new QWidget( mMainFrame ); |
494 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 494 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
495 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 495 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
496 | mRightFrame = new QWidgetStack( rightBox ); | 496 | mRightFrame = new QWidgetStack( rightBox ); |
497 | rightLayout->addWidget( mRightFrame, 10 ); | 497 | rightLayout->addWidget( mRightFrame, 10 ); |
498 | 498 | ||
499 | //mLeftFrame = (QWidget *)leftFrame; | 499 | //mLeftFrame = (QWidget *)leftFrame; |
500 | if ( KOPrefs::instance()->mVerticalScreen ) { | 500 | if ( KOPrefs::instance()->mVerticalScreen ) { |
501 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 501 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
502 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 502 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
503 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 503 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
504 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | } else { | 505 | } else { |
506 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 506 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
507 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | } | 509 | } |
510 | if ( !KOPrefs::instance()->mShowDateNavigator) | 510 | if ( !KOPrefs::instance()->mShowDateNavigator) |
511 | mDateNavigator->hide(); | 511 | mDateNavigator->hide(); |
512 | //qDebug("Calendarview Size %d %d ", width(), height()); | 512 | //qDebug("Calendarview Size %d %d ", width(), height()); |
513 | #endif | 513 | #endif |
514 | 514 | ||
515 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 515 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
516 | SLOT( showDates( const KCal::DateList & ) ) ); | 516 | SLOT( showDates( const KCal::DateList & ) ) ); |
517 | 517 | ||
518 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 518 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
519 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 519 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
520 | 520 | ||
521 | 521 | ||
522 | 522 | ||
523 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 523 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
524 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 524 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
525 | 525 | ||
526 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 526 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
527 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 527 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
528 | 528 | ||
529 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 529 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
530 | mNavigator, SLOT( selectPreviousYear() ) ); | 530 | mNavigator, SLOT( selectPreviousYear() ) ); |
531 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 531 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
532 | mNavigator, SLOT( selectNextYear() ) ); | 532 | mNavigator, SLOT( selectNextYear() ) ); |
533 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 533 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
534 | mNavigator, SLOT( selectPreviousMonth() ) ); | 534 | mNavigator, SLOT( selectPreviousMonth() ) ); |
535 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 535 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
536 | mNavigator, SLOT( selectNextMonth() ) ); | 536 | mNavigator, SLOT( selectNextMonth() ) ); |
537 | 537 | ||
538 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 538 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
539 | mNavigator, SLOT( selectPrevious() ) ); | 539 | mNavigator, SLOT( selectPrevious() ) ); |
540 | connect( mDateNavigator, SIGNAL( goNext() ), | 540 | connect( mDateNavigator, SIGNAL( goNext() ), |
541 | mNavigator, SLOT( selectNext() ) ); | 541 | mNavigator, SLOT( selectNext() ) ); |
542 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 542 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
543 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 543 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
544 | 544 | ||
545 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 545 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
546 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 546 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
547 | #if 0 | 547 | #if 0 |
548 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 548 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
549 | SLOT( incidenceAdded( Incidence *) ) ); | 549 | SLOT( incidenceAdded( Incidence *) ) ); |
550 | #endif | 550 | #endif |
551 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 551 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
552 | 552 | ||
553 | connect( this, SIGNAL( configChanged() ), | 553 | connect( this, SIGNAL( configChanged() ), |
554 | mDateNavigator, SLOT( updateConfig() ) ); | 554 | mDateNavigator, SLOT( updateConfig() ) ); |
555 | 555 | ||
556 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 556 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
557 | SLOT( newTodo() ) ); | 557 | SLOT( newTodo() ) ); |
558 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 558 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
559 | SLOT( newSubTodo( Todo * ) ) ); | 559 | SLOT( newSubTodo( Todo * ) ) ); |
560 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 560 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
561 | SLOT( editTodo( Todo * ) ) ); | 561 | SLOT( editTodo( Todo * ) ) ); |
562 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 562 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
563 | SLOT( showTodo( Todo *) ) ); | 563 | SLOT( showTodo( Todo *) ) ); |
564 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 564 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
565 | SLOT( deleteTodo( Todo *) ) ); | 565 | SLOT( deleteTodo( Todo *) ) ); |
566 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 566 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
567 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 567 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
568 | SLOT( purgeCompleted() ) ); | 568 | SLOT( purgeCompleted() ) ); |
569 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 569 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
570 | SIGNAL( todoModified( Todo *, int ) ) ); | 570 | SIGNAL( todoModified( Todo *, int ) ) ); |
571 | 571 | ||
572 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 572 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
573 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 573 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
574 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 574 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
575 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 575 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
576 | 576 | ||
577 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 577 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
578 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 578 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
579 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 579 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
580 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 580 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
581 | 581 | ||
582 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 582 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
583 | this, SLOT ( todo_unsub( Todo * ) ) ); | 583 | this, SLOT ( todo_unsub( Todo * ) ) ); |
584 | 584 | ||
585 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 585 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
586 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 586 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
587 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 587 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
588 | SLOT( updateTodo( Todo *, int ) ) ); | 588 | SLOT( updateTodo( Todo *, int ) ) ); |
589 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 589 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
590 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 590 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
591 | 591 | ||
592 | 592 | ||
593 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 593 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
594 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 594 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
595 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 595 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
596 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
597 | 597 | ||
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 602 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
603 | SLOT(checkClipboard())); | 603 | SLOT(checkClipboard())); |
604 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 604 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
605 | SLOT( processTodoListSelection( Incidence * ) ) ); | 605 | SLOT( processTodoListSelection( Incidence * ) ) ); |
606 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 606 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
607 | 607 | ||
608 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 608 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
609 | 609 | ||
610 | mDateFrame = new QVBox(0,0,WType_Popup); | 610 | mDateFrame = new QVBox(0,0,WType_Popup); |
611 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 611 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
612 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 612 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
613 | mDateFrame->setLineWidth(3); | 613 | mDateFrame->setLineWidth(3); |
614 | mDateFrame->hide(); | 614 | mDateFrame->hide(); |
615 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 615 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
616 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 616 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
617 | 617 | ||
618 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 618 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
619 | 619 | ||
620 | mEventEditor = mDialogManager->getEventEditor(); | 620 | mEventEditor = mDialogManager->getEventEditor(); |
621 | mTodoEditor = mDialogManager->getTodoEditor(); | 621 | mTodoEditor = mDialogManager->getTodoEditor(); |
622 | 622 | ||
623 | mFlagEditDescription = false; | 623 | mFlagEditDescription = false; |
624 | 624 | ||
625 | mSuspendTimer = new QTimer( this ); | 625 | mSuspendTimer = new QTimer( this ); |
626 | mAlarmTimer = new QTimer( this ); | 626 | mAlarmTimer = new QTimer( this ); |
627 | mRecheckAlarmTimer = new QTimer( this ); | 627 | mRecheckAlarmTimer = new QTimer( this ); |
628 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 628 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
629 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 629 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
630 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 630 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
631 | mAlarmDialog = new AlarmDialog( this ); | 631 | mAlarmDialog = new AlarmDialog( this ); |
632 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 632 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
633 | mAlarmDialog->setServerNotification( false ); | 633 | mAlarmDialog->setServerNotification( false ); |
634 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 634 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
635 | 635 | ||
636 | 636 | ||
637 | #ifndef DESKTOP_VERSION | 637 | #ifndef DESKTOP_VERSION |
638 | //US listen for arriving address resultsets | 638 | //US listen for arriving address resultsets |
639 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 639 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
640 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 640 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
641 | #endif | 641 | #endif |
642 | mDateNavigator->setCalendar( mCalendar ); | 642 | mDateNavigator->setCalendar( mCalendar ); |
643 | } | 643 | } |
644 | 644 | ||
645 | 645 | ||
646 | CalendarView::~CalendarView() | 646 | CalendarView::~CalendarView() |
647 | { | 647 | { |
648 | // kdDebug() << "~CalendarView()" << endl; | 648 | // kdDebug() << "~CalendarView()" << endl; |
649 | //qDebug("CalendarView::~CalendarView() "); | 649 | //qDebug("CalendarView::~CalendarView() "); |
650 | delete mDialogManager; | 650 | delete mDialogManager; |
651 | delete mViewManager; | 651 | delete mViewManager; |
652 | delete mStorage; | 652 | delete mStorage; |
653 | delete mDateFrame ; | 653 | delete mDateFrame ; |
654 | delete mEventViewerDialog; | 654 | delete mEventViewerDialog; |
655 | //kdDebug() << "~CalendarView() done" << endl; | 655 | //kdDebug() << "~CalendarView() done" << endl; |
656 | } | 656 | } |
657 | void CalendarView::nextConflict( bool all, bool allday ) | 657 | void CalendarView::nextConflict( bool all, bool allday ) |
658 | { | 658 | { |
659 | 659 | ||
660 | QPtrList<Event> testlist = mCalendar->events(); | 660 | QPtrList<Event> testlist = mCalendar->events(); |
661 | Event * test = testlist.first(); | 661 | Event * test = testlist.first(); |
662 | while ( test ) { | 662 | while ( test ) { |
663 | test->setTagged( false ); | 663 | test->setTagged( false ); |
664 | test = testlist.next(); | ||
664 | } | 665 | } |
665 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first().addDays(1), QTime ( 0,0,0)); | 666 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first().addDays(1), QTime ( 0,0,0)); |
666 | QDateTime conflict; | 667 | QDateTime conflict; |
667 | QDateTime retVal; | 668 | QDateTime retVal; |
668 | bool found = false; | 669 | bool found = false; |
669 | Event * cE = 0; | 670 | Event * cE = 0; |
671 | Event * cE2 = 0; | ||
670 | QPtrList<Event> testlist2 = testlist; | 672 | QPtrList<Event> testlist2 = testlist; |
673 | test = testlist.first(); | ||
674 | bool skip = false; | ||
671 | while ( test ) { | 675 | while ( test ) { |
672 | Event * test2 = testlist2.first(); | 676 | skip = false; |
673 | while ( test2 ) { | 677 | if ( !all ) skip = ( allday != test->doesFloat() ); |
674 | if ( !test2->isTagged() ) { | 678 | if ( !skip ) { |
675 | if ( test->isOverlapping ( test2, &retVal, true ) ) { | 679 | Event * test2 = testlist2.first(); |
676 | if ( ! found ) { | 680 | while ( test2 ) { |
677 | if ( retVal >= startDT ) { | 681 | skip = false; |
678 | conflict = retVal; | 682 | if ( !all ) skip = ( allday != test2->doesFloat() ); |
679 | cE = test; | 683 | if ( !skip ) { |
680 | found = true; | 684 | if ( !test2->isTagged() ) { |
681 | } | 685 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
682 | } else { | 686 | //qDebug("overlap "); |
683 | if ( retVal >= startDT && retVal < conflict ) { | 687 | if ( ! found ) { |
684 | conflict = retVal; | 688 | if ( retVal >= startDT ) { |
685 | cE = test; | 689 | conflict = retVal; |
690 | cE = test; | ||
691 | cE2 = test2; | ||
692 | found = true; | ||
693 | } | ||
694 | } else { | ||
695 | if ( retVal >= startDT && retVal < conflict ) { | ||
696 | conflict = retVal; | ||
697 | cE = test; | ||
698 | cE2 = test2; | ||
699 | } | ||
700 | } | ||
686 | } | 701 | } |
687 | } | 702 | } |
688 | } | 703 | } |
704 | test2 = testlist2.next(); | ||
689 | } | 705 | } |
690 | test2 = testlist2.next(); | ||
691 | } | 706 | } |
692 | test->setTagged( true ); | 707 | test->setTagged( true ); |
693 | test = testlist.next(); | 708 | test = testlist.next(); |
694 | } | 709 | } |
695 | if ( found ) { | 710 | if ( found ) { |
696 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 711 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
697 | mViewManager->showDayView(); | 712 | mViewManager->showDayView(); |
698 | mNavigator->slotDaySelect( conflict.date() ); | 713 | mNavigator->slotDaySelect( conflict.date() ); |
699 | int hour = conflict.time().hour(); | 714 | int hour = conflict.time().hour(); |
700 | mViewManager->agendaView()->setStartHour( hour ); | 715 | mViewManager->agendaView()->setStartHour( hour ); |
701 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 716 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
702 | return; | 717 | return; |
703 | } | 718 | } |
704 | 719 | ||
705 | topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); | 720 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
706 | qDebug("No conflict found "); | 721 | qDebug("No conflict found "); |
707 | return; | 722 | return; |
708 | 723 | ||
709 | 724 | ||
710 | 725 | ||
711 | 726 | ||
712 | 727 | ||
713 | #if 0 | 728 | #if 0 |
714 | 729 | ||
715 | 730 | ||
716 | QDate end = start.addDays( 365*2); | 731 | QDate end = start.addDays( 365*2); |
717 | while ( start < end ) { | 732 | while ( start < end ) { |
718 | QPtrList<Event> eventList = calendar()->events( start ); | 733 | QPtrList<Event> eventList = calendar()->events( start ); |
719 | Event * ev = eventList.first(); | 734 | Event * ev = eventList.first(); |
720 | QPtrList<Event> test = eventList; | 735 | QPtrList<Event> test = eventList; |
721 | while ( ev ) { | 736 | while ( ev ) { |
722 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); | 737 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); |
723 | Event * t_ev = test.first(); | 738 | Event * t_ev = test.first(); |
724 | QDateTime es = ev->dtStart(); | 739 | QDateTime es = ev->dtStart(); |
725 | QDateTime ee = ev->dtEnd(); | 740 | QDateTime ee = ev->dtEnd(); |
726 | if ( ev->doesFloat() ) | 741 | if ( ev->doesFloat() ) |
727 | ee = ee.addDays( 1 ); | 742 | ee = ee.addDays( 1 ); |
728 | if ( ! all ) { | 743 | if ( ! all ) { |
729 | if ( ev->doesFloat() != allday ) | 744 | if ( ev->doesFloat() != allday ) |
730 | t_ev = 0; | 745 | t_ev = 0; |
731 | } | 746 | } |
732 | while ( t_ev ) { | 747 | while ( t_ev ) { |
733 | bool skip = false; | 748 | bool skip = false; |
734 | if ( ! all ) { | 749 | if ( ! all ) { |
735 | if ( t_ev->doesFloat() != allday ) | 750 | if ( t_ev->doesFloat() != allday ) |
736 | skip = true; | 751 | skip = true; |
737 | } | 752 | } |
738 | if ( !skip && ev != t_ev ) { | 753 | if ( !skip && ev != t_ev ) { |
739 | QDateTime ets = t_ev->dtStart(); | 754 | QDateTime ets = t_ev->dtStart(); |
740 | QDateTime ete = t_ev->dtEnd(); | 755 | QDateTime ete = t_ev->dtEnd(); |
741 | if ( t_ev->doesFloat() ) | 756 | if ( t_ev->doesFloat() ) |
742 | ete = ete.addDays( 1 ); | 757 | ete = ete.addDays( 1 ); |
743 | //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); | 758 | //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); |
744 | if ( es < ete && ets < ee ) { | 759 | if ( es < ete && ets < ee ) { |
745 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 760 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
746 | mViewManager->showDayView(); | 761 | mViewManager->showDayView(); |
747 | mNavigator->slotDaySelect( start ); | 762 | mNavigator->slotDaySelect( start ); |
748 | int hour = es.time().hour(); | 763 | int hour = es.time().hour(); |
749 | if ( ets > es ) | 764 | if ( ets > es ) |
750 | hour = ets.time().hour(); | 765 | hour = ets.time().hour(); |
751 | mViewManager->agendaView()->setStartHour( hour ); | 766 | mViewManager->agendaView()->setStartHour( hour ); |
752 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); | 767 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); |
753 | return; | 768 | return; |
754 | } | 769 | } |
755 | } | 770 | } |
756 | t_ev = test.next(); | 771 | t_ev = test.next(); |
757 | } | 772 | } |
758 | ev = eventList.next(); | 773 | ev = eventList.next(); |
759 | } | 774 | } |
760 | start = start.addDays( 1 ); | 775 | start = start.addDays( 1 ); |
761 | } | 776 | } |
762 | topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); | 777 | topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); |
763 | qDebug("No conflict found "); | 778 | qDebug("No conflict found "); |
764 | #endif | 779 | #endif |
765 | } | 780 | } |
766 | 781 | ||
767 | void CalendarView::conflictAll() | 782 | void CalendarView::conflictAll() |
768 | { | 783 | { |
769 | nextConflict ( true, true ); | 784 | nextConflict ( true, true ); |
770 | } | 785 | } |
771 | void CalendarView::conflictAllday() | 786 | void CalendarView::conflictAllday() |
772 | { | 787 | { |
773 | nextConflict ( false, true ); | 788 | nextConflict ( false, true ); |
774 | } | 789 | } |
775 | void CalendarView::conflictNotAll() | 790 | void CalendarView::conflictNotAll() |
776 | { | 791 | { |
777 | nextConflict ( false, false ); | 792 | nextConflict ( false, false ); |
778 | } | 793 | } |
779 | 794 | ||
780 | void CalendarView::setCalReadOnly( int id, bool readO ) | 795 | void CalendarView::setCalReadOnly( int id, bool readO ) |
781 | { | 796 | { |
782 | if ( readO ) { | 797 | if ( readO ) { |
783 | emit save(); | 798 | emit save(); |
784 | } | 799 | } |
785 | mCalendar->setReadOnly( id, readO ); | 800 | mCalendar->setReadOnly( id, readO ); |
786 | } | 801 | } |
787 | void CalendarView::setScrollBarStep(int val ) | 802 | void CalendarView::setScrollBarStep(int val ) |
788 | { | 803 | { |
789 | #ifdef DESKTOP_VERSION | 804 | #ifdef DESKTOP_VERSION |
790 | mDateScrollBar->setLineStep ( val ); | 805 | mDateScrollBar->setLineStep ( val ); |
791 | #endif | 806 | #endif |
792 | } | 807 | } |
793 | void CalendarView::scrollBarValue(int val ) | 808 | void CalendarView::scrollBarValue(int val ) |
794 | { | 809 | { |
795 | #ifdef DESKTOP_VERSION | 810 | #ifdef DESKTOP_VERSION |
796 | if ( QApplication::desktop()->width() < 800 ) return; | 811 | if ( QApplication::desktop()->width() < 800 ) return; |
797 | static bool block = false; | 812 | static bool block = false; |
798 | if ( block ) return; | 813 | if ( block ) return; |
799 | block = true; | 814 | block = true; |
800 | int count = mNavigator->selectedDates().count(); | 815 | int count = mNavigator->selectedDates().count(); |
801 | int day = mNavigator->selectedDates().first().dayOfYear(); | 816 | int day = mNavigator->selectedDates().first().dayOfYear(); |
802 | int stepdays = val; | 817 | int stepdays = val; |
803 | if ( mDateScrollBar->lineStep () <= count ) { | 818 | if ( mDateScrollBar->lineStep () <= count ) { |
804 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 819 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
805 | //qDebug("VAL %d ",val ); | 820 | //qDebug("VAL %d ",val ); |
806 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 821 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
807 | stepdays = day+stepdays; | 822 | stepdays = day+stepdays; |
808 | if ( stepdays < 0 ) stepdays = 0; | 823 | if ( stepdays < 0 ) stepdays = 0; |
809 | } | 824 | } |
810 | if ( stepdays == day ) { | 825 | if ( stepdays == day ) { |
811 | block = false; | 826 | block = false; |
812 | return; | 827 | return; |
813 | } | 828 | } |
814 | int year = mNavigator->selectedDates().first().year(); | 829 | int year = mNavigator->selectedDates().first().year(); |
815 | QDate d ( year,1,1 ); | 830 | QDate d ( year,1,1 ); |
816 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 831 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
817 | block = false; | 832 | block = false; |
818 | #endif | 833 | #endif |
819 | 834 | ||
820 | } | 835 | } |
821 | void CalendarView::updateView(const QDate &start, const QDate &end) | 836 | void CalendarView::updateView(const QDate &start, const QDate &end) |
822 | { | 837 | { |
823 | #ifdef DESKTOP_VERSION | 838 | #ifdef DESKTOP_VERSION |
824 | if ( ! mDateScrollBar->draggingSlider () ) { | 839 | if ( ! mDateScrollBar->draggingSlider () ) { |
825 | int dof = start.dayOfYear(); | 840 | int dof = start.dayOfYear(); |
826 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 841 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
827 | if ( dof != mDateScrollBar->value() ) { | 842 | if ( dof != mDateScrollBar->value() ) { |
828 | mDateScrollBar->blockSignals( true ); | 843 | mDateScrollBar->blockSignals( true ); |
829 | mDateScrollBar->setValue( start.dayOfYear()); | 844 | mDateScrollBar->setValue( start.dayOfYear()); |
830 | mDateScrollBar->blockSignals( false ); | 845 | mDateScrollBar->blockSignals( false ); |
831 | } | 846 | } |
832 | } | 847 | } |
833 | #endif | 848 | #endif |
834 | mTodoList->updateView(); | 849 | mTodoList->updateView(); |
835 | mViewManager->updateView(start, end); | 850 | mViewManager->updateView(start, end); |
836 | //mDateNavigator->updateView(); | 851 | //mDateNavigator->updateView(); |
837 | } | 852 | } |
838 | 853 | ||
839 | 854 | ||
840 | 855 | ||
841 | void CalendarView::checkFiles() | 856 | void CalendarView::checkFiles() |
842 | { | 857 | { |
843 | QString message; | 858 | QString message; |
844 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 859 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
845 | KopiCalendarFile * cal = calendars.first(); | 860 | KopiCalendarFile * cal = calendars.first(); |
846 | while ( cal ) { | 861 | while ( cal ) { |
847 | if ( cal->mErrorOnLoad ) { | 862 | if ( cal->mErrorOnLoad ) { |
848 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 863 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
849 | } | 864 | } |
850 | cal = calendars.next(); | 865 | cal = calendars.next(); |
851 | } | 866 | } |
852 | if ( !message.isEmpty() ) { | 867 | if ( !message.isEmpty() ) { |
853 | 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); | 868 | 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); |
854 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 869 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
855 | } | 870 | } |
856 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 871 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
857 | } | 872 | } |
858 | void CalendarView::checkAlarms() | 873 | void CalendarView::checkAlarms() |
859 | { | 874 | { |
860 | 875 | ||
861 | 876 | ||
862 | KConfig *config = KOGlobals::config(); | 877 | KConfig *config = KOGlobals::config(); |
863 | config->setGroup( "AppRun" ); | 878 | config->setGroup( "AppRun" ); |
864 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 879 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
865 | int daysto = dt.daysTo( QDate::currentDate() ); | 880 | int daysto = dt.daysTo( QDate::currentDate() ); |
866 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 881 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
867 | dt = dt.addDays( days ); | 882 | dt = dt.addDays( days ); |
868 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 883 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
869 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 884 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
870 | //qDebug("KO: Reading program stop %d ", secs); | 885 | //qDebug("KO: Reading program stop %d ", secs); |
871 | //secs -= ( 3600 * 24*3 ); // debug only | 886 | //secs -= ( 3600 * 24*3 ); // debug only |
872 | QDateTime latest = dt.addSecs ( secs ); | 887 | QDateTime latest = dt.addSecs ( secs ); |
873 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 888 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
874 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 889 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
875 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 890 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
876 | QPtrList<Incidence> al; | 891 | QPtrList<Incidence> al; |
877 | Incidence* inL = el.first(); | 892 | Incidence* inL = el.first(); |
878 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 893 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
879 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 894 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
880 | while ( inL ) { | 895 | while ( inL ) { |
881 | bool ok = false; | 896 | bool ok = false; |
882 | int offset = 0; | 897 | int offset = 0; |
883 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 898 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
884 | if ( ok ) { | 899 | if ( ok ) { |
885 | //qDebug("OK %s",next.toString().latin1()); | 900 | //qDebug("OK %s",next.toString().latin1()); |
886 | if ( next < cur ) { | 901 | if ( next < cur ) { |
887 | al.append( inL ); | 902 | al.append( inL ); |
888 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 903 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
889 | } | 904 | } |
890 | } | 905 | } |
891 | inL = el.next(); | 906 | inL = el.next(); |
892 | } | 907 | } |
893 | if ( al.count() ) { | 908 | if ( al.count() ) { |
894 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 909 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
895 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 910 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
896 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 911 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
897 | lay->setSpacing( 0 ); | 912 | lay->setSpacing( 0 ); |
898 | lay->setMargin( 0 ); | 913 | lay->setMargin( 0 ); |
899 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 914 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
900 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 915 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
901 | lay->addWidget( matb ); | 916 | lay->addWidget( matb ); |
902 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 917 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
903 | int wid = 210; | 918 | int wid = 210; |
904 | int x = QApplication::desktop()->width() - wid - 7; | 919 | int x = QApplication::desktop()->width() - wid - 7; |
905 | int y = QApplication::desktop()->height() - wid - 70; | 920 | int y = QApplication::desktop()->height() - wid - 70; |
906 | dia->setGeometry ( x,y,wid,wid); | 921 | dia->setGeometry ( x,y,wid,wid); |
907 | } else { | 922 | } else { |
908 | int si = 220; | 923 | int si = 220; |
909 | if ( QApplication::desktop()->width() > 470 ) | 924 | if ( QApplication::desktop()->width() > 470 ) |
910 | si = 400; | 925 | si = 400; |
911 | dia->resize(si,si/2); | 926 | dia->resize(si,si/2); |
912 | } | 927 | } |
913 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 928 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
914 | dia->show(); | 929 | dia->show(); |
915 | 930 | ||
916 | } | 931 | } |
917 | } | 932 | } |
918 | void CalendarView::showDay( QDate d ) | 933 | void CalendarView::showDay( QDate d ) |
919 | { | 934 | { |
920 | dateNavigator()->blockSignals( true ); | 935 | dateNavigator()->blockSignals( true ); |
921 | dateNavigator()->selectDate( d ); | 936 | dateNavigator()->selectDate( d ); |
922 | dateNavigator()->blockSignals( false ); | 937 | dateNavigator()->blockSignals( false ); |
923 | mViewManager->showDayView(); | 938 | mViewManager->showDayView(); |
924 | //dateNavigator()->selectDate( d ); | 939 | //dateNavigator()->selectDate( d ); |
925 | } | 940 | } |
926 | void CalendarView::timerAlarm() | 941 | void CalendarView::timerAlarm() |
927 | { | 942 | { |
928 | //qDebug("CalendarView::timerAlarm() "); | 943 | //qDebug("CalendarView::timerAlarm() "); |
929 | computeAlarm(mAlarmNotification ); | 944 | computeAlarm(mAlarmNotification ); |
930 | } | 945 | } |
931 | 946 | ||
932 | void CalendarView::suspendAlarm() | 947 | void CalendarView::suspendAlarm() |
933 | { | 948 | { |
934 | //qDebug(" CalendarView::suspendAlarm() "); | 949 | //qDebug(" CalendarView::suspendAlarm() "); |
935 | computeAlarm(mSuspendAlarmNotification ); | 950 | computeAlarm(mSuspendAlarmNotification ); |
936 | 951 | ||
937 | } | 952 | } |
938 | 953 | ||
939 | void CalendarView::startAlarm( QString mess , QString filename) | 954 | void CalendarView::startAlarm( QString mess , QString filename) |
940 | { | 955 | { |
941 | 956 | ||
942 | topLevelWidget()->showNormal(); | 957 | topLevelWidget()->showNormal(); |
943 | topLevelWidget()->setActiveWindow(); | 958 | topLevelWidget()->setActiveWindow(); |
944 | topLevelWidget()->raise(); | 959 | topLevelWidget()->raise(); |
945 | 960 | ||
946 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 961 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
947 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 962 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
948 | 963 | ||
949 | } | 964 | } |
950 | 965 | ||
951 | void CalendarView::checkNextTimerAlarm() | 966 | void CalendarView::checkNextTimerAlarm() |
952 | { | 967 | { |
953 | mCalendar->checkAlarmForIncidence( 0, true ); | 968 | mCalendar->checkAlarmForIncidence( 0, true ); |
954 | } | 969 | } |
955 | 970 | ||
956 | void CalendarView::computeAlarm( QString msg ) | 971 | void CalendarView::computeAlarm( QString msg ) |
957 | { | 972 | { |
958 | 973 | ||
959 | QString mess = msg; | 974 | QString mess = msg; |
960 | QString mAlarmMessage = mess.mid( 9 ); | 975 | QString mAlarmMessage = mess.mid( 9 ); |
961 | QString filename = MainWindow::resourcePath(); | 976 | QString filename = MainWindow::resourcePath(); |
962 | filename += "koalarm.wav"; | 977 | filename += "koalarm.wav"; |
963 | QString tempfilename; | 978 | QString tempfilename; |
964 | if ( mess.left( 13 ) == "suspend_alarm") { | 979 | if ( mess.left( 13 ) == "suspend_alarm") { |
965 | bool error = false; | 980 | bool error = false; |
966 | int len = mess.mid( 13 ).find("+++"); | 981 | int len = mess.mid( 13 ).find("+++"); |
967 | if ( len < 2 ) | 982 | if ( len < 2 ) |
968 | error = true; | 983 | error = true; |
969 | else { | 984 | else { |
970 | tempfilename = mess.mid( 13, len ); | 985 | tempfilename = mess.mid( 13, len ); |
971 | if ( !QFile::exists( tempfilename ) ) | 986 | if ( !QFile::exists( tempfilename ) ) |
972 | error = true; | 987 | error = true; |
973 | } | 988 | } |
974 | if ( ! error ) { | 989 | if ( ! error ) { |
975 | filename = tempfilename; | 990 | filename = tempfilename; |
976 | } | 991 | } |
977 | mAlarmMessage = mess.mid( 13+len+3 ); | 992 | mAlarmMessage = mess.mid( 13+len+3 ); |
978 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 993 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
979 | startAlarm( mAlarmMessage, filename); | 994 | startAlarm( mAlarmMessage, filename); |
980 | return; | 995 | return; |
981 | } | 996 | } |
982 | if ( mess.left( 11 ) == "timer_alarm") { | 997 | if ( mess.left( 11 ) == "timer_alarm") { |
983 | //mTimerTime = 0; | 998 | //mTimerTime = 0; |
984 | startAlarm( mess.mid( 11 ), filename ); | 999 | startAlarm( mess.mid( 11 ), filename ); |
985 | return; | 1000 | return; |
986 | } | 1001 | } |
987 | if ( mess.left( 10 ) == "proc_alarm") { | 1002 | if ( mess.left( 10 ) == "proc_alarm") { |
988 | bool error = false; | 1003 | bool error = false; |
989 | int len = mess.mid( 10 ).find("+++"); | 1004 | int len = mess.mid( 10 ).find("+++"); |
990 | if ( len < 2 ) | 1005 | if ( len < 2 ) |
991 | error = true; | 1006 | error = true; |
992 | else { | 1007 | else { |
993 | tempfilename = mess.mid( 10, len ); | 1008 | tempfilename = mess.mid( 10, len ); |
994 | if ( !QFile::exists( tempfilename ) ) | 1009 | if ( !QFile::exists( tempfilename ) ) |
995 | error = true; | 1010 | error = true; |
996 | } | 1011 | } |
997 | if ( error ) { | 1012 | if ( error ) { |
998 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 1013 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
999 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 1014 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1000 | } else { | 1015 | } else { |
1001 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 1016 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1002 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 1017 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1003 | #ifndef _WIN32_ | 1018 | #ifndef _WIN32_ |
1004 | if ( vfork () == 0 ) { | 1019 | if ( vfork () == 0 ) { |
1005 | execl ( tempfilename.latin1(), 0 ); | 1020 | execl ( tempfilename.latin1(), 0 ); |
1006 | return; | 1021 | return; |
1007 | } | 1022 | } |
1008 | #else | 1023 | #else |
1009 | QProcess* p = new QProcess(); | 1024 | QProcess* p = new QProcess(); |
1010 | p->addArgument( tempfilename.latin1() ); | 1025 | p->addArgument( tempfilename.latin1() ); |
1011 | p->start(); | 1026 | p->start(); |
1012 | return; | 1027 | return; |
1013 | #endif | 1028 | #endif |
1014 | 1029 | ||
1015 | return; | 1030 | return; |
1016 | } | 1031 | } |
1017 | 1032 | ||
1018 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1033 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1019 | } | 1034 | } |
1020 | if ( mess.left( 11 ) == "audio_alarm") { | 1035 | if ( mess.left( 11 ) == "audio_alarm") { |
1021 | bool error = false; | 1036 | bool error = false; |
1022 | int len = mess.mid( 11 ).find("+++"); | 1037 | int len = mess.mid( 11 ).find("+++"); |
1023 | if ( len < 2 ) | 1038 | if ( len < 2 ) |
1024 | error = true; | 1039 | error = true; |
1025 | else { | 1040 | else { |
1026 | tempfilename = mess.mid( 11, len ); | 1041 | tempfilename = mess.mid( 11, len ); |
1027 | if ( !QFile::exists( tempfilename ) ) | 1042 | if ( !QFile::exists( tempfilename ) ) |
1028 | error = true; | 1043 | error = true; |
1029 | } | 1044 | } |
1030 | if ( ! error ) { | 1045 | if ( ! error ) { |
1031 | filename = tempfilename; | 1046 | filename = tempfilename; |
1032 | } | 1047 | } |
1033 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1048 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1034 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1049 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1035 | } | 1050 | } |
1036 | if ( mess.left( 9 ) == "cal_alarm") { | 1051 | if ( mess.left( 9 ) == "cal_alarm") { |
1037 | mAlarmMessage = mess.mid( 9 ) ; | 1052 | mAlarmMessage = mess.mid( 9 ) ; |
1038 | } | 1053 | } |
1039 | 1054 | ||
1040 | startAlarm( mAlarmMessage, filename ); | 1055 | startAlarm( mAlarmMessage, filename ); |
1041 | 1056 | ||
1042 | 1057 | ||
1043 | } | 1058 | } |
1044 | 1059 | ||
1045 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1060 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1046 | { | 1061 | { |
1047 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1062 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1048 | 1063 | ||
1049 | mSuspendAlarmNotification = noti; | 1064 | mSuspendAlarmNotification = noti; |
1050 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1065 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1051 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1066 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1052 | mSuspendTimer->start( ms , true ); | 1067 | mSuspendTimer->start( ms , true ); |
1053 | 1068 | ||
1054 | } | 1069 | } |
1055 | 1070 | ||
1056 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1071 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1057 | { | 1072 | { |
1058 | mNextAlarmDateTime = qdt; | 1073 | mNextAlarmDateTime = qdt; |
1059 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1074 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1060 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1075 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1061 | #ifndef DESKTOP_VERSION | 1076 | #ifndef DESKTOP_VERSION |
1062 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1077 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1063 | #endif | 1078 | #endif |
1064 | return; | 1079 | return; |
1065 | } | 1080 | } |
1066 | int maxSec; | 1081 | int maxSec; |
1067 | //maxSec = 5; //testing only | 1082 | //maxSec = 5; //testing only |
1068 | maxSec = 86400+3600; // one day+1hour | 1083 | maxSec = 86400+3600; // one day+1hour |
1069 | mAlarmNotification = noti; | 1084 | mAlarmNotification = noti; |
1070 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1085 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1071 | if ( sec > maxSec ) { | 1086 | if ( sec > maxSec ) { |
1072 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1087 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1073 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1088 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1074 | return; | 1089 | return; |
1075 | } else { | 1090 | } else { |
1076 | mRecheckAlarmTimer->stop(); | 1091 | mRecheckAlarmTimer->stop(); |
1077 | } | 1092 | } |
1078 | //qDebug("Alarm timer started with secs: %d ", sec); | 1093 | //qDebug("Alarm timer started with secs: %d ", sec); |
1079 | mAlarmTimer->start( sec *1000 , true ); | 1094 | mAlarmTimer->start( sec *1000 , true ); |
1080 | 1095 | ||
1081 | } | 1096 | } |
1082 | // called by mRecheckAlarmTimer to get next alarm | 1097 | // called by mRecheckAlarmTimer to get next alarm |
1083 | // we need this, because a QTimer has only a max range of 25 days | 1098 | // we need this, because a QTimer has only a max range of 25 days |
1084 | void CalendarView::recheckTimerAlarm() | 1099 | void CalendarView::recheckTimerAlarm() |
1085 | { | 1100 | { |
1086 | mAlarmTimer->stop(); | 1101 | mAlarmTimer->stop(); |
1087 | mRecheckAlarmTimer->stop(); | 1102 | mRecheckAlarmTimer->stop(); |
1088 | mCalendar->checkAlarmForIncidence( 0, true ); | 1103 | mCalendar->checkAlarmForIncidence( 0, true ); |
1089 | } | 1104 | } |
1090 | #ifndef DESKTOP_VERSION | 1105 | #ifndef DESKTOP_VERSION |
1091 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1106 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1092 | #else | 1107 | #else |
1093 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1108 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1094 | #endif | 1109 | #endif |
1095 | { | 1110 | { |
1096 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1111 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1097 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1112 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1098 | #ifndef DESKTOP_VERSION | 1113 | #ifndef DESKTOP_VERSION |
1099 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1114 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1100 | #endif | 1115 | #endif |
1101 | return; | 1116 | return; |
1102 | } | 1117 | } |
1103 | mAlarmTimer->stop(); | 1118 | mAlarmTimer->stop(); |
1104 | } | 1119 | } |
1105 | void CalendarView::selectWeekNum ( int num ) | 1120 | void CalendarView::selectWeekNum ( int num ) |
1106 | { | 1121 | { |
1107 | dateNavigator()->blockSignals( true ); | 1122 | dateNavigator()->blockSignals( true ); |
1108 | dateNavigator()->selectWeek( num ); | 1123 | dateNavigator()->selectWeek( num ); |
1109 | dateNavigator()->blockSignals( false ); | 1124 | dateNavigator()->blockSignals( false ); |
1110 | mViewManager->showWeekView(); | 1125 | mViewManager->showWeekView(); |
1111 | } | 1126 | } |
1112 | KOViewManager *CalendarView::viewManager() | 1127 | KOViewManager *CalendarView::viewManager() |
1113 | { | 1128 | { |
1114 | return mViewManager; | 1129 | return mViewManager; |
1115 | } | 1130 | } |
1116 | 1131 | ||
1117 | KODialogManager *CalendarView::dialogManager() | 1132 | KODialogManager *CalendarView::dialogManager() |
1118 | { | 1133 | { |
1119 | return mDialogManager; | 1134 | return mDialogManager; |
1120 | } | 1135 | } |
1121 | 1136 | ||
1122 | QDate CalendarView::startDate() | 1137 | QDate CalendarView::startDate() |
1123 | { | 1138 | { |
1124 | DateList dates = mNavigator->selectedDates(); | 1139 | DateList dates = mNavigator->selectedDates(); |
1125 | 1140 | ||
1126 | return dates.first(); | 1141 | return dates.first(); |
1127 | } | 1142 | } |
1128 | 1143 | ||
1129 | QDate CalendarView::endDate() | 1144 | QDate CalendarView::endDate() |
1130 | { | 1145 | { |
1131 | DateList dates = mNavigator->selectedDates(); | 1146 | DateList dates = mNavigator->selectedDates(); |
1132 | 1147 | ||
1133 | return dates.last(); | 1148 | return dates.last(); |
1134 | } | 1149 | } |
1135 | 1150 | ||
1136 | 1151 | ||
1137 | void CalendarView::createPrinter() | 1152 | void CalendarView::createPrinter() |
1138 | { | 1153 | { |
1139 | #ifndef KORG_NOPRINTER | 1154 | #ifndef KORG_NOPRINTER |
1140 | if (!mCalPrinter) { | 1155 | if (!mCalPrinter) { |
1141 | mCalPrinter = new CalPrinter(this, mCalendar); | 1156 | mCalPrinter = new CalPrinter(this, mCalendar); |
1142 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1157 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1143 | } | 1158 | } |
1144 | #endif | 1159 | #endif |
1145 | } | 1160 | } |
1146 | 1161 | ||
1147 | 1162 | ||
1148 | //KOPrefs::instance()->mWriteBackFile | 1163 | //KOPrefs::instance()->mWriteBackFile |
1149 | //KOPrefs::instance()->mWriteBackExistingOnly | 1164 | //KOPrefs::instance()->mWriteBackExistingOnly |
1150 | 1165 | ||
1151 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1166 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1152 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1167 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1153 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1168 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1154 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1169 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1155 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1170 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1156 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1171 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1157 | 1172 | ||
1158 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1173 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1159 | { | 1174 | { |
1160 | 1175 | ||
1161 | // 0 equal | 1176 | // 0 equal |
1162 | // 1 take local | 1177 | // 1 take local |
1163 | // 2 take remote | 1178 | // 2 take remote |
1164 | // 3 cancel | 1179 | // 3 cancel |
1165 | QDateTime lastSync = mLastCalendarSync; | 1180 | QDateTime lastSync = mLastCalendarSync; |
1166 | QDateTime localMod = local->lastModified(); | 1181 | QDateTime localMod = local->lastModified(); |
1167 | QDateTime remoteMod = remote->lastModified(); | 1182 | QDateTime remoteMod = remote->lastModified(); |
1168 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1183 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1169 | bool remCh, locCh; | 1184 | bool remCh, locCh; |
1170 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1185 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1171 | //if ( remCh ) | 1186 | //if ( remCh ) |
1172 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1187 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1173 | locCh = ( localMod > mLastCalendarSync ); | 1188 | locCh = ( localMod > mLastCalendarSync ); |
1174 | if ( !remCh && ! locCh ) { | 1189 | if ( !remCh && ! locCh ) { |
1175 | //qDebug("both not changed "); | 1190 | //qDebug("both not changed "); |
1176 | lastSync = localMod.addDays(1); | 1191 | lastSync = localMod.addDays(1); |
1177 | if ( mode <= SYNC_PREF_ASK ) | 1192 | if ( mode <= SYNC_PREF_ASK ) |
1178 | return 0; | 1193 | return 0; |
1179 | } else { | 1194 | } else { |
1180 | if ( locCh ) { | 1195 | if ( locCh ) { |
1181 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1196 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1182 | lastSync = localMod.addDays( -1 ); | 1197 | lastSync = localMod.addDays( -1 ); |
1183 | if ( !remCh ) | 1198 | if ( !remCh ) |
1184 | remoteMod = ( lastSync.addDays( -1 ) ); | 1199 | remoteMod = ( lastSync.addDays( -1 ) ); |
1185 | } else { | 1200 | } else { |
1186 | //qDebug(" not loc changed "); | 1201 | //qDebug(" not loc changed "); |
1187 | lastSync = localMod.addDays( 1 ); | 1202 | lastSync = localMod.addDays( 1 ); |
1188 | if ( remCh ) | 1203 | if ( remCh ) |
1189 | remoteMod =( lastSync.addDays( 1 ) ); | 1204 | remoteMod =( lastSync.addDays( 1 ) ); |
1190 | 1205 | ||
1191 | } | 1206 | } |
1192 | } | 1207 | } |
1193 | full = true; | 1208 | full = true; |
1194 | if ( mode < SYNC_PREF_ASK ) | 1209 | if ( mode < SYNC_PREF_ASK ) |
1195 | mode = SYNC_PREF_ASK; | 1210 | mode = SYNC_PREF_ASK; |
1196 | } else { | 1211 | } else { |
1197 | if ( localMod == remoteMod ) | 1212 | if ( localMod == remoteMod ) |
1198 | // if ( local->revision() == remote->revision() ) | 1213 | // if ( local->revision() == remote->revision() ) |
1199 | return 0; | 1214 | return 0; |
1200 | 1215 | ||
1201 | } | 1216 | } |
1202 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1217 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1203 | 1218 | ||
1204 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1219 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1205 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1220 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1206 | //full = true; //debug only | 1221 | //full = true; //debug only |
1207 | if ( full ) { | 1222 | if ( full ) { |
1208 | bool equ = false; | 1223 | bool equ = false; |
1209 | if ( local->typeID() == eventID ) { | 1224 | if ( local->typeID() == eventID ) { |
1210 | equ = (*((Event*) local) == *((Event*) remote)); | 1225 | equ = (*((Event*) local) == *((Event*) remote)); |
1211 | } | 1226 | } |
1212 | else if ( local->typeID() == todoID ) | 1227 | else if ( local->typeID() == todoID ) |
1213 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1228 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1214 | else if ( local->typeID() == journalID ) | 1229 | else if ( local->typeID() == journalID ) |
1215 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1230 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1216 | if ( equ ) { | 1231 | if ( equ ) { |
1217 | //qDebug("equal "); | 1232 | //qDebug("equal "); |
1218 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1233 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1219 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1234 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1220 | } | 1235 | } |
1221 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1236 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1222 | return 0; | 1237 | return 0; |
1223 | 1238 | ||
1224 | }//else //debug only | 1239 | }//else //debug only |
1225 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1240 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1226 | } | 1241 | } |
1227 | int result; | 1242 | int result; |
1228 | bool localIsNew; | 1243 | bool localIsNew; |
1229 | //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() ); | 1244 | //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() ); |
1230 | 1245 | ||
1231 | 1246 | ||
1232 | // ************************************************ | 1247 | // ************************************************ |
1233 | // ************************************************ | 1248 | // ************************************************ |
1234 | // ************************************************ | 1249 | // ************************************************ |
1235 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1250 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1236 | // BUT remoteMod != localMod | 1251 | // BUT remoteMod != localMod |
1237 | 1252 | ||
1238 | 1253 | ||
1239 | if ( full && mode < SYNC_PREF_NEWEST ) | 1254 | if ( full && mode < SYNC_PREF_NEWEST ) |
1240 | mode = SYNC_PREF_ASK; | 1255 | mode = SYNC_PREF_ASK; |
1241 | 1256 | ||
1242 | switch( mode ) { | 1257 | switch( mode ) { |
1243 | case SYNC_PREF_LOCAL: | 1258 | case SYNC_PREF_LOCAL: |
1244 | if ( lastSync > remoteMod ) | 1259 | if ( lastSync > remoteMod ) |
1245 | return 1; | 1260 | return 1; |
1246 | if ( lastSync > localMod ) | 1261 | if ( lastSync > localMod ) |
1247 | return 2; | 1262 | return 2; |
1248 | return 1; | 1263 | return 1; |
1249 | break; | 1264 | break; |
1250 | case SYNC_PREF_REMOTE: | 1265 | case SYNC_PREF_REMOTE: |
1251 | if ( lastSync > localMod ) | 1266 | if ( lastSync > localMod ) |
1252 | return 2; | 1267 | return 2; |
1253 | if ( lastSync > remoteMod ) | 1268 | if ( lastSync > remoteMod ) |
1254 | return 1; | 1269 | return 1; |
1255 | return 2; | 1270 | return 2; |
1256 | break; | 1271 | break; |
1257 | case SYNC_PREF_NEWEST: | 1272 | case SYNC_PREF_NEWEST: |
1258 | if ( localMod >= remoteMod ) | 1273 | if ( localMod >= remoteMod ) |
1259 | return 1; | 1274 | return 1; |
1260 | else | 1275 | else |
1261 | return 2; | 1276 | return 2; |
1262 | break; | 1277 | break; |
1263 | case SYNC_PREF_ASK: | 1278 | case SYNC_PREF_ASK: |
1264 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1279 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1265 | if ( lastSync > remoteMod && lastSync > localMod) | 1280 | if ( lastSync > remoteMod && lastSync > localMod) |
1266 | return 0; | 1281 | return 0; |
1267 | if ( lastSync > remoteMod ) | 1282 | if ( lastSync > remoteMod ) |
1268 | return 1; | 1283 | return 1; |
1269 | if ( lastSync > localMod ) | 1284 | if ( lastSync > localMod ) |
1270 | return 2; | 1285 | return 2; |
1271 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1286 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1272 | localIsNew = localMod >= remoteMod; | 1287 | localIsNew = localMod >= remoteMod; |
1273 | if ( localIsNew ) | 1288 | if ( localIsNew ) |
1274 | getEventViewerDialog()->setColorMode( 1 ); | 1289 | getEventViewerDialog()->setColorMode( 1 ); |
1275 | else | 1290 | else |
1276 | getEventViewerDialog()->setColorMode( 2 ); | 1291 | getEventViewerDialog()->setColorMode( 2 ); |
1277 | getEventViewerDialog()->setIncidence(local); | 1292 | getEventViewerDialog()->setIncidence(local); |
1278 | if ( localIsNew ) | 1293 | if ( localIsNew ) |
1279 | getEventViewerDialog()->setColorMode( 2 ); | 1294 | getEventViewerDialog()->setColorMode( 2 ); |
1280 | else | 1295 | else |
1281 | getEventViewerDialog()->setColorMode( 1 ); | 1296 | getEventViewerDialog()->setColorMode( 1 ); |
1282 | getEventViewerDialog()->addIncidence(remote); | 1297 | getEventViewerDialog()->addIncidence(remote); |
1283 | getEventViewerDialog()->setColorMode( 0 ); | 1298 | getEventViewerDialog()->setColorMode( 0 ); |
1284 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1299 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1285 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1300 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1286 | getEventViewerDialog()->showMe(); | 1301 | getEventViewerDialog()->showMe(); |
1287 | result = getEventViewerDialog()->executeS( localIsNew ); | 1302 | result = getEventViewerDialog()->executeS( localIsNew ); |
1288 | return result; | 1303 | return result; |
1289 | 1304 | ||
1290 | break; | 1305 | break; |
1291 | case SYNC_PREF_FORCE_LOCAL: | 1306 | case SYNC_PREF_FORCE_LOCAL: |
1292 | return 1; | 1307 | return 1; |
1293 | break; | 1308 | break; |
1294 | case SYNC_PREF_FORCE_REMOTE: | 1309 | case SYNC_PREF_FORCE_REMOTE: |
1295 | return 2; | 1310 | return 2; |
1296 | break; | 1311 | break; |
1297 | 1312 | ||
1298 | default: | 1313 | default: |
1299 | // SYNC_PREF_TAKE_BOTH not implemented | 1314 | // SYNC_PREF_TAKE_BOTH not implemented |
1300 | break; | 1315 | break; |
1301 | } | 1316 | } |
1302 | return 0; | 1317 | return 0; |
1303 | } | 1318 | } |
1304 | Event* CalendarView::getLastSyncEvent() | 1319 | Event* CalendarView::getLastSyncEvent() |
1305 | { | 1320 | { |
1306 | Event* lse; | 1321 | Event* lse; |
1307 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1322 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1308 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1323 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1309 | if (!lse) { | 1324 | if (!lse) { |
1310 | lse = new Event(); | 1325 | lse = new Event(); |
1311 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1326 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1312 | QString sum = ""; | 1327 | QString sum = ""; |
1313 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1328 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1314 | sum = "E: "; | 1329 | sum = "E: "; |
1315 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1330 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1316 | lse->setDtStart( mLastCalendarSync ); | 1331 | lse->setDtStart( mLastCalendarSync ); |
1317 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1332 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1318 | lse->setCategories( i18n("SyncEvent") ); | 1333 | lse->setCategories( i18n("SyncEvent") ); |
1319 | lse->setReadOnly( true ); | 1334 | lse->setReadOnly( true ); |
1320 | mCalendar->addEvent( lse ); | 1335 | mCalendar->addEvent( lse ); |
1321 | } | 1336 | } |
1322 | 1337 | ||
1323 | return lse; | 1338 | return lse; |
1324 | 1339 | ||
1325 | } | 1340 | } |
1326 | 1341 | ||
1327 | // we check, if the to delete event has a id for a profile | 1342 | // we check, if the to delete event has a id for a profile |
1328 | // if yes, we set this id in the profile to delete | 1343 | // if yes, we set this id in the profile to delete |
1329 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1344 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1330 | { | 1345 | { |
1331 | if ( lastSync.count() == 0 ) { | 1346 | if ( lastSync.count() == 0 ) { |
1332 | //qDebug(" lastSync.count() == 0"); | 1347 | //qDebug(" lastSync.count() == 0"); |
1333 | return; | 1348 | return; |
1334 | } | 1349 | } |
1335 | if ( toDelete->typeID() == journalID ) | 1350 | if ( toDelete->typeID() == journalID ) |
1336 | return; | 1351 | return; |
1337 | 1352 | ||
1338 | Event* eve = lastSync.first(); | 1353 | Event* eve = lastSync.first(); |
1339 | 1354 | ||
1340 | while ( eve ) { | 1355 | while ( eve ) { |
1341 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1356 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1342 | if ( !id.isEmpty() ) { | 1357 | if ( !id.isEmpty() ) { |
1343 | QString des = eve->description(); | 1358 | QString des = eve->description(); |
1344 | QString pref = "e"; | 1359 | QString pref = "e"; |
1345 | if ( toDelete->typeID() == todoID ) | 1360 | if ( toDelete->typeID() == todoID ) |
1346 | pref = "t"; | 1361 | pref = "t"; |
1347 | des += pref+ id + ","; | 1362 | des += pref+ id + ","; |
1348 | eve->setReadOnly( false ); | 1363 | eve->setReadOnly( false ); |
1349 | eve->setDescription( des ); | 1364 | eve->setDescription( des ); |
1350 | //qDebug("setdes %s ", des.latin1()); | 1365 | //qDebug("setdes %s ", des.latin1()); |
1351 | eve->setReadOnly( true ); | 1366 | eve->setReadOnly( true ); |
1352 | } | 1367 | } |
1353 | eve = lastSync.next(); | 1368 | eve = lastSync.next(); |
1354 | } | 1369 | } |
1355 | 1370 | ||
1356 | } | 1371 | } |
1357 | void CalendarView::checkExternalId( Incidence * inc ) | 1372 | void CalendarView::checkExternalId( Incidence * inc ) |
1358 | { | 1373 | { |
1359 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1374 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1360 | checkExternSyncEvent( lastSync, inc ); | 1375 | checkExternSyncEvent( lastSync, inc ); |
1361 | 1376 | ||
1362 | } | 1377 | } |
1363 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1378 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1364 | { | 1379 | { |
1365 | bool syncOK = true; | 1380 | bool syncOK = true; |
1366 | int addedEvent = 0; | 1381 | int addedEvent = 0; |
1367 | int addedEventR = 0; | 1382 | int addedEventR = 0; |
1368 | int deletedEventR = 0; | 1383 | int deletedEventR = 0; |
1369 | int deletedEventL = 0; | 1384 | int deletedEventL = 0; |
1370 | int changedLocal = 0; | 1385 | int changedLocal = 0; |
1371 | int changedRemote = 0; | 1386 | int changedRemote = 0; |
1372 | int filteredIN = 0; | 1387 | int filteredIN = 0; |
1373 | int filteredOUT = 0; | 1388 | int filteredOUT = 0; |
1374 | //QPtrList<Event> el = local->rawEvents(); | 1389 | //QPtrList<Event> el = local->rawEvents(); |
1375 | Event* eventR; | 1390 | Event* eventR; |
1376 | QString uid; | 1391 | QString uid; |
1377 | int take; | 1392 | int take; |
1378 | Event* eventRSync; | 1393 | Event* eventRSync; |
1379 | Event* eventLSync; | 1394 | Event* eventLSync; |
1380 | clearAllViews(); | 1395 | clearAllViews(); |
1381 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1396 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1382 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1397 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1383 | bool fullDateRange = false; | 1398 | bool fullDateRange = false; |
1384 | local->resetTempSyncStat(); | 1399 | local->resetTempSyncStat(); |
1385 | mLastCalendarSync = QDateTime::currentDateTime(); | 1400 | mLastCalendarSync = QDateTime::currentDateTime(); |
1386 | if ( mSyncManager->syncWithDesktop() ) { | 1401 | if ( mSyncManager->syncWithDesktop() ) { |
1387 | remote->resetPilotStat(1); | 1402 | remote->resetPilotStat(1); |
1388 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1403 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1389 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1404 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1390 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1405 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1391 | } else { | 1406 | } else { |
1392 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1407 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1393 | } | 1408 | } |
1394 | } | 1409 | } |
1395 | QDateTime modifiedCalendar = mLastCalendarSync; | 1410 | QDateTime modifiedCalendar = mLastCalendarSync; |
1396 | eventLSync = getLastSyncEvent(); | 1411 | eventLSync = getLastSyncEvent(); |
1397 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1412 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1398 | if ( eventR ) { | 1413 | if ( eventR ) { |
1399 | eventRSync = (Event*) eventR->clone(); | 1414 | eventRSync = (Event*) eventR->clone(); |
1400 | remote->deleteEvent(eventR ); | 1415 | remote->deleteEvent(eventR ); |
1401 | 1416 | ||
1402 | } else { | 1417 | } else { |
1403 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1418 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1404 | eventRSync = (Event*)eventLSync->clone(); | 1419 | eventRSync = (Event*)eventLSync->clone(); |
1405 | } else { | 1420 | } else { |
1406 | fullDateRange = true; | 1421 | fullDateRange = true; |
1407 | eventRSync = new Event(); | 1422 | eventRSync = new Event(); |
1408 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1423 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1409 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1424 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1410 | eventRSync->setDtStart( mLastCalendarSync ); | 1425 | eventRSync->setDtStart( mLastCalendarSync ); |
1411 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1426 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1412 | eventRSync->setCategories( i18n("SyncEvent") ); | 1427 | eventRSync->setCategories( i18n("SyncEvent") ); |
1413 | } | 1428 | } |
1414 | } | 1429 | } |
1415 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1430 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1416 | fullDateRange = true; | 1431 | fullDateRange = true; |
1417 | 1432 | ||
1418 | if ( ! fullDateRange ) { | 1433 | if ( ! fullDateRange ) { |
1419 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1434 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1420 | 1435 | ||
1421 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1436 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1422 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1437 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1423 | fullDateRange = true; | 1438 | fullDateRange = true; |
1424 | } | 1439 | } |
1425 | } | 1440 | } |
1426 | if ( mSyncManager->syncWithDesktop() ) { | 1441 | if ( mSyncManager->syncWithDesktop() ) { |
1427 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1442 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1428 | } | 1443 | } |
1429 | if ( fullDateRange ) | 1444 | if ( fullDateRange ) |
1430 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1445 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1431 | else | 1446 | else |
1432 | mLastCalendarSync = eventLSync->dtStart(); | 1447 | mLastCalendarSync = eventLSync->dtStart(); |
1433 | // for resyncing if own file has changed | 1448 | // for resyncing if own file has changed |
1434 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1449 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1435 | mLastCalendarSync = loadedFileVersion; | 1450 | mLastCalendarSync = loadedFileVersion; |
1436 | //qDebug("setting mLastCalendarSync "); | 1451 | //qDebug("setting mLastCalendarSync "); |
1437 | } | 1452 | } |
1438 | //qDebug("*************************** "); | 1453 | //qDebug("*************************** "); |
1439 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1454 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1440 | QPtrList<Incidence> er = remote->rawIncidences(); | 1455 | QPtrList<Incidence> er = remote->rawIncidences(); |
1441 | Incidence* inR = er.first(); | 1456 | Incidence* inR = er.first(); |
1442 | Incidence* inL; | 1457 | Incidence* inL; |
1443 | QProgressBar bar( er.count(),0 ); | 1458 | QProgressBar bar( er.count(),0 ); |
1444 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1459 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1445 | 1460 | ||
1446 | // ************** setting up filter ************* | 1461 | // ************** setting up filter ************* |
1447 | CalFilter *filterIN = 0; | 1462 | CalFilter *filterIN = 0; |
1448 | CalFilter *filterOUT = 0; | 1463 | CalFilter *filterOUT = 0; |
1449 | CalFilter *filter = mFilters.first(); | 1464 | CalFilter *filter = mFilters.first(); |
1450 | while(filter) { | 1465 | while(filter) { |
1451 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1466 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1452 | filterIN = filter; | 1467 | filterIN = filter; |
1453 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1468 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1454 | filterOUT = filter; | 1469 | filterOUT = filter; |
1455 | filter = mFilters.next(); | 1470 | filter = mFilters.next(); |
1456 | } | 1471 | } |
1457 | int w = 300; | 1472 | int w = 300; |
1458 | if ( QApplication::desktop()->width() < 320 ) | 1473 | if ( QApplication::desktop()->width() < 320 ) |
1459 | w = 220; | 1474 | w = 220; |
1460 | int h = bar.sizeHint().height() ; | 1475 | int h = bar.sizeHint().height() ; |
1461 | int dw = QApplication::desktop()->width(); | 1476 | int dw = QApplication::desktop()->width(); |
1462 | int dh = QApplication::desktop()->height(); | 1477 | int dh = QApplication::desktop()->height(); |
1463 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1478 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1464 | bar.show(); | 1479 | bar.show(); |
1465 | int modulo = (er.count()/10)+1; | 1480 | int modulo = (er.count()/10)+1; |
1466 | int incCounter = 0; | 1481 | int incCounter = 0; |
1467 | while ( inR ) { | 1482 | while ( inR ) { |
1468 | if ( ! bar.isVisible() ) | 1483 | if ( ! bar.isVisible() ) |
1469 | return false; | 1484 | return false; |
1470 | if ( incCounter % modulo == 0 ) | 1485 | if ( incCounter % modulo == 0 ) |
1471 | bar.setProgress( incCounter ); | 1486 | bar.setProgress( incCounter ); |
1472 | ++incCounter; | 1487 | ++incCounter; |
1473 | uid = inR->uid(); | 1488 | uid = inR->uid(); |
1474 | bool skipIncidence = false; | 1489 | bool skipIncidence = false; |
1475 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1490 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1476 | skipIncidence = true; | 1491 | skipIncidence = true; |
1477 | QString idS; | 1492 | QString idS; |
1478 | qApp->processEvents(); | 1493 | qApp->processEvents(); |
1479 | if ( !skipIncidence ) { | 1494 | if ( !skipIncidence ) { |
1480 | inL = local->incidence( uid ); | 1495 | inL = local->incidence( uid ); |
1481 | if ( inL ) { // maybe conflict - same uid in both calendars | 1496 | if ( inL ) { // maybe conflict - same uid in both calendars |
1482 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1497 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1483 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1498 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1484 | if ( take == 3 ) | 1499 | if ( take == 3 ) |
1485 | return false; | 1500 | return false; |
1486 | if ( take == 1 ) {// take local ********************** | 1501 | if ( take == 1 ) {// take local ********************** |
1487 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1502 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1488 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1503 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1489 | else | 1504 | else |
1490 | idS = inR->IDStr(); | 1505 | idS = inR->IDStr(); |
1491 | remote->deleteIncidence( inR ); | 1506 | remote->deleteIncidence( inR ); |
1492 | inR = inL->clone(); | 1507 | inR = inL->clone(); |
1493 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1508 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1494 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1509 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1495 | inR->setIDStr( idS ); | 1510 | inR->setIDStr( idS ); |
1496 | remote->addIncidence( inR ); | 1511 | remote->addIncidence( inR ); |
1497 | if ( mSyncManager->syncWithDesktop() ) | 1512 | if ( mSyncManager->syncWithDesktop() ) |
1498 | inR->setPilotId( 2 ); | 1513 | inR->setPilotId( 2 ); |
1499 | ++changedRemote; | 1514 | ++changedRemote; |
1500 | } else {// take remote ********************** | 1515 | } else {// take remote ********************** |
1501 | idS = inL->IDStr(); | 1516 | idS = inL->IDStr(); |
1502 | int pid = inL->pilotId(); | 1517 | int pid = inL->pilotId(); |
1503 | local->deleteIncidence( inL ); | 1518 | local->deleteIncidence( inL ); |
1504 | inL = inR->clone(); | 1519 | inL = inR->clone(); |
1505 | if ( mSyncManager->syncWithDesktop() ) | 1520 | if ( mSyncManager->syncWithDesktop() ) |
1506 | inL->setPilotId( pid ); | 1521 | inL->setPilotId( pid ); |
1507 | inL->setIDStr( idS ); | 1522 | inL->setIDStr( idS ); |
1508 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1523 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1509 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1524 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1510 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1525 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1511 | } | 1526 | } |
1512 | local->addIncidence( inL ); | 1527 | local->addIncidence( inL ); |
1513 | ++changedLocal; | 1528 | ++changedLocal; |
1514 | } | 1529 | } |
1515 | } | 1530 | } |
1516 | } else { // no conflict ********** add or delete remote | 1531 | } else { // no conflict ********** add or delete remote |
1517 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1532 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1518 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1533 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1519 | QString des = eventLSync->description(); | 1534 | QString des = eventLSync->description(); |
1520 | QString pref = "e"; | 1535 | QString pref = "e"; |
1521 | if ( inR->typeID() == todoID ) | 1536 | if ( inR->typeID() == todoID ) |
1522 | pref = "t"; | 1537 | pref = "t"; |
1523 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1538 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1524 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1539 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1525 | //remote->deleteIncidence( inR ); | 1540 | //remote->deleteIncidence( inR ); |
1526 | ++deletedEventR; | 1541 | ++deletedEventR; |
1527 | } else { | 1542 | } else { |
1528 | inR->setLastModified( modifiedCalendar ); | 1543 | inR->setLastModified( modifiedCalendar ); |
1529 | inL = inR->clone(); | 1544 | inL = inR->clone(); |
1530 | inL->setIDStr( ":" ); | 1545 | inL->setIDStr( ":" ); |
1531 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1546 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1532 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1547 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1533 | local->addIncidence( inL ); | 1548 | local->addIncidence( inL ); |
1534 | ++addedEvent; | 1549 | ++addedEvent; |
1535 | 1550 | ||
1536 | } | 1551 | } |
1537 | } else { | 1552 | } else { |
1538 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1553 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1539 | inR->setLastModified( modifiedCalendar ); | 1554 | inR->setLastModified( modifiedCalendar ); |
1540 | inL = inR->clone(); | 1555 | inL = inR->clone(); |
1541 | inL->setIDStr( ":" ); | 1556 | inL->setIDStr( ":" ); |
1542 | local->addIncidence( inL ); | 1557 | local->addIncidence( inL ); |
1543 | ++addedEvent; | 1558 | ++addedEvent; |
1544 | 1559 | ||
1545 | } else { | 1560 | } else { |
1546 | checkExternSyncEvent(eventRSyncSharp, inR); | 1561 | checkExternSyncEvent(eventRSyncSharp, inR); |
1547 | remote->deleteIncidence( inR ); | 1562 | remote->deleteIncidence( inR ); |
1548 | ++deletedEventR; | 1563 | ++deletedEventR; |
1549 | } | 1564 | } |
1550 | } | 1565 | } |
1551 | } else { | 1566 | } else { |
1552 | ++filteredIN; | 1567 | ++filteredIN; |
1553 | } | 1568 | } |
1554 | } | 1569 | } |
1555 | } | 1570 | } |
1556 | inR = er.next(); | 1571 | inR = er.next(); |
1557 | } | 1572 | } |
1558 | QPtrList<Incidence> el = local->rawIncidences(); | 1573 | QPtrList<Incidence> el = local->rawIncidences(); |
1559 | inL = el.first(); | 1574 | inL = el.first(); |
1560 | modulo = (el.count()/10)+1; | 1575 | modulo = (el.count()/10)+1; |
1561 | bar.setCaption (i18n("Add / remove events") ); | 1576 | bar.setCaption (i18n("Add / remove events") ); |
1562 | bar.setTotalSteps ( el.count() ) ; | 1577 | bar.setTotalSteps ( el.count() ) ; |
1563 | bar.show(); | 1578 | bar.show(); |
1564 | incCounter = 0; | 1579 | incCounter = 0; |
1565 | 1580 | ||
1566 | while ( inL ) { | 1581 | while ( inL ) { |
1567 | 1582 | ||
1568 | qApp->processEvents(); | 1583 | qApp->processEvents(); |
1569 | if ( ! bar.isVisible() ) | 1584 | if ( ! bar.isVisible() ) |
1570 | return false; | 1585 | return false; |
1571 | if ( incCounter % modulo == 0 ) | 1586 | if ( incCounter % modulo == 0 ) |
1572 | bar.setProgress( incCounter ); | 1587 | bar.setProgress( incCounter ); |
1573 | ++incCounter; | 1588 | ++incCounter; |
1574 | uid = inL->uid(); | 1589 | uid = inL->uid(); |
1575 | bool skipIncidence = false; | 1590 | bool skipIncidence = false; |
1576 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1591 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1577 | skipIncidence = true; | 1592 | skipIncidence = true; |
1578 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1593 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1579 | skipIncidence = true; | 1594 | skipIncidence = true; |
1580 | if ( !skipIncidence ) { | 1595 | if ( !skipIncidence ) { |
1581 | inR = remote->incidence( uid ); | 1596 | inR = remote->incidence( uid ); |
1582 | if ( ! inR ) { | 1597 | if ( ! inR ) { |
1583 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1598 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1584 | // no conflict ********** add or delete local | 1599 | // no conflict ********** add or delete local |
1585 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1600 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1586 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1601 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1587 | checkExternSyncEvent(eventLSyncSharp, inL); | 1602 | checkExternSyncEvent(eventLSyncSharp, inL); |
1588 | local->deleteIncidence( inL ); | 1603 | local->deleteIncidence( inL ); |
1589 | ++deletedEventL; | 1604 | ++deletedEventL; |
1590 | } else { | 1605 | } else { |
1591 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1606 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1592 | inL->removeID(mCurrentSyncDevice ); | 1607 | inL->removeID(mCurrentSyncDevice ); |
1593 | ++addedEventR; | 1608 | ++addedEventR; |
1594 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1609 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1595 | inL->setLastModified( modifiedCalendar ); | 1610 | inL->setLastModified( modifiedCalendar ); |
1596 | inR = inL->clone(); | 1611 | inR = inL->clone(); |
1597 | inR->setIDStr( ":" ); | 1612 | inR->setIDStr( ":" ); |
1598 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1613 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1599 | remote->addIncidence( inR ); | 1614 | remote->addIncidence( inR ); |
1600 | } | 1615 | } |
1601 | } | 1616 | } |
1602 | } else { | 1617 | } else { |
1603 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1618 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1604 | checkExternSyncEvent(eventLSyncSharp, inL); | 1619 | checkExternSyncEvent(eventLSyncSharp, inL); |
1605 | local->deleteIncidence( inL ); | 1620 | local->deleteIncidence( inL ); |
1606 | ++deletedEventL; | 1621 | ++deletedEventL; |
1607 | } else { | 1622 | } else { |
1608 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1623 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1609 | ++addedEventR; | 1624 | ++addedEventR; |
1610 | inL->setLastModified( modifiedCalendar ); | 1625 | inL->setLastModified( modifiedCalendar ); |
1611 | inR = inL->clone(); | 1626 | inR = inL->clone(); |
1612 | inR->setIDStr( ":" ); | 1627 | inR->setIDStr( ":" ); |
1613 | remote->addIncidence( inR ); | 1628 | remote->addIncidence( inR ); |
1614 | } | 1629 | } |
1615 | } | 1630 | } |
1616 | } | 1631 | } |
1617 | } else { | 1632 | } else { |
1618 | ++filteredOUT; | 1633 | ++filteredOUT; |
1619 | } | 1634 | } |
1620 | } | 1635 | } |
1621 | } | 1636 | } |
1622 | inL = el.next(); | 1637 | inL = el.next(); |
1623 | } | 1638 | } |
1624 | int delFut = 0; | 1639 | int delFut = 0; |
1625 | int remRem = 0; | 1640 | int remRem = 0; |
1626 | if ( mSyncManager->mWriteBackInFuture ) { | 1641 | if ( mSyncManager->mWriteBackInFuture ) { |
1627 | er = remote->rawIncidences(); | 1642 | er = remote->rawIncidences(); |
1628 | remRem = er.count(); | 1643 | remRem = er.count(); |
1629 | inR = er.first(); | 1644 | inR = er.first(); |
1630 | QDateTime dt; | 1645 | QDateTime dt; |
1631 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1646 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1632 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1647 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1633 | while ( inR ) { | 1648 | while ( inR ) { |
1634 | if ( inR->typeID() == todoID ) { | 1649 | if ( inR->typeID() == todoID ) { |
1635 | Todo * t = (Todo*)inR; | 1650 | Todo * t = (Todo*)inR; |
1636 | if ( t->hasDueDate() ) | 1651 | if ( t->hasDueDate() ) |
1637 | dt = t->dtDue(); | 1652 | dt = t->dtDue(); |
1638 | else | 1653 | else |
1639 | dt = cur.addSecs( 62 ); | 1654 | dt = cur.addSecs( 62 ); |
1640 | } | 1655 | } |
1641 | else if (inR->typeID() == eventID ) { | 1656 | else if (inR->typeID() == eventID ) { |
1642 | bool ok; | 1657 | bool ok; |
1643 | dt = inR->getNextOccurence( cur, &ok ); | 1658 | dt = inR->getNextOccurence( cur, &ok ); |
1644 | if ( !ok ) | 1659 | if ( !ok ) |
1645 | dt = cur.addSecs( -62 ); | 1660 | dt = cur.addSecs( -62 ); |
1646 | } | 1661 | } |
1647 | else | 1662 | else |
1648 | dt = inR->dtStart(); | 1663 | dt = inR->dtStart(); |
1649 | if ( dt < cur || dt > end ) { | 1664 | if ( dt < cur || dt > end ) { |
1650 | remote->deleteIncidence( inR ); | 1665 | remote->deleteIncidence( inR ); |
1651 | ++delFut; | 1666 | ++delFut; |
1652 | } | 1667 | } |
1653 | inR = er.next(); | 1668 | inR = er.next(); |
1654 | } | 1669 | } |
1655 | } | 1670 | } |
1656 | bar.hide(); | 1671 | bar.hide(); |
1657 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1672 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1658 | eventLSync->setReadOnly( false ); | 1673 | eventLSync->setReadOnly( false ); |
1659 | eventLSync->setDtStart( mLastCalendarSync ); | 1674 | eventLSync->setDtStart( mLastCalendarSync ); |
1660 | eventRSync->setDtStart( mLastCalendarSync ); | 1675 | eventRSync->setDtStart( mLastCalendarSync ); |
1661 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1676 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1662 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1677 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1663 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1678 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1664 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1679 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1665 | eventLSync->setReadOnly( true ); | 1680 | eventLSync->setReadOnly( true ); |
1666 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1681 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1667 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1682 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1668 | remote->addEvent( eventRSync ); | 1683 | remote->addEvent( eventRSync ); |
1669 | else | 1684 | else |
1670 | delete eventRSync; | 1685 | delete eventRSync; |
1671 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1686 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1672 | QString mes; | 1687 | 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 ); | 1688 | 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; | 1689 | QString delmess; |
1675 | if ( delFut ) { | 1690 | 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); | 1691 | 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; | 1692 | mes += delmess; |
1678 | } | 1693 | } |
1679 | mes = i18n("Local calendar changed!\n") +mes; | 1694 | mes = i18n("Local calendar changed!\n") +mes; |
1680 | mCalendar->checkAlarmForIncidence( 0, true ); | 1695 | mCalendar->checkAlarmForIncidence( 0, true ); |
1681 | qDebug( mes ); | 1696 | qDebug( mes ); |
1682 | if ( mSyncManager->mShowSyncSummary ) { | 1697 | if ( mSyncManager->mShowSyncSummary ) { |
1683 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1698 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1684 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1699 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1685 | qDebug("KO: WB cancelled "); | 1700 | qDebug("KO: WB cancelled "); |
1686 | mSyncManager->mWriteBackFile = false; | 1701 | mSyncManager->mWriteBackFile = false; |
1687 | return syncOK; | 1702 | return syncOK; |
1688 | } | 1703 | } |
1689 | } | 1704 | } |
1690 | return syncOK; | 1705 | return syncOK; |
1691 | } | 1706 | } |
1692 | 1707 | ||
1693 | void CalendarView::setSyncDevice( QString s ) | 1708 | void CalendarView::setSyncDevice( QString s ) |
1694 | { | 1709 | { |
1695 | mCurrentSyncDevice= s; | 1710 | mCurrentSyncDevice= s; |
1696 | } | 1711 | } |
1697 | void CalendarView::setSyncName( QString s ) | 1712 | void CalendarView::setSyncName( QString s ) |
1698 | { | 1713 | { |
1699 | mCurrentSyncName= s; | 1714 | mCurrentSyncName= s; |
1700 | } | 1715 | } |
1701 | bool CalendarView::syncCalendar(QString filename, int mode) | 1716 | bool CalendarView::syncCalendar(QString filename, int mode) |
1702 | { | 1717 | { |
1703 | //qDebug("syncCalendar %s ", filename.latin1()); | 1718 | //qDebug("syncCalendar %s ", filename.latin1()); |
1704 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1719 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1705 | CalendarLocal* calendar = new CalendarLocal(); | 1720 | CalendarLocal* calendar = new CalendarLocal(); |
1706 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1721 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1707 | FileStorage* storage = new FileStorage( calendar ); | 1722 | FileStorage* storage = new FileStorage( calendar ); |
1708 | bool syncOK = false; | 1723 | bool syncOK = false; |
1709 | storage->setFileName( filename ); | 1724 | storage->setFileName( filename ); |
1710 | // qDebug("loading ... "); | 1725 | // qDebug("loading ... "); |
1711 | if ( storage->load() ) { | 1726 | if ( storage->load() ) { |
1712 | getEventViewerDialog()->setSyncMode( true ); | 1727 | getEventViewerDialog()->setSyncMode( true ); |
1713 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1728 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1714 | getEventViewerDialog()->setSyncMode( false ); | 1729 | getEventViewerDialog()->setSyncMode( false ); |
1715 | if ( syncOK ) { | 1730 | if ( syncOK ) { |
1716 | if ( mSyncManager->mWriteBackFile ) | 1731 | if ( mSyncManager->mWriteBackFile ) |
1717 | { | 1732 | { |
1718 | storage->setSaveFormat( new ICalFormat() ); | 1733 | storage->setSaveFormat( new ICalFormat() ); |
1719 | storage->save(); | 1734 | storage->save(); |
1720 | } | 1735 | } |
1721 | } | 1736 | } |
1722 | setModified( true ); | 1737 | setModified( true ); |
1723 | } | 1738 | } |
1724 | delete storage; | 1739 | delete storage; |
1725 | delete calendar; | 1740 | delete calendar; |
1726 | if ( syncOK ) | 1741 | if ( syncOK ) |
1727 | updateView(); | 1742 | updateView(); |
1728 | return syncOK; | 1743 | return syncOK; |
1729 | } | 1744 | } |
1730 | 1745 | ||
1731 | void CalendarView::syncExternal( int mode ) | 1746 | void CalendarView::syncExternal( int mode ) |
1732 | { | 1747 | { |
1733 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1748 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1734 | 1749 | ||
1735 | qApp->processEvents(); | 1750 | qApp->processEvents(); |
1736 | CalendarLocal* calendar = new CalendarLocal(); | 1751 | CalendarLocal* calendar = new CalendarLocal(); |
1737 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1752 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1738 | bool syncOK = false; | 1753 | bool syncOK = false; |
1739 | bool loadSuccess = false; | 1754 | bool loadSuccess = false; |
1740 | PhoneFormat* phoneFormat = 0; | 1755 | PhoneFormat* phoneFormat = 0; |
1741 | emit tempDisableBR(true); | 1756 | emit tempDisableBR(true); |
1742 | #ifndef DESKTOP_VERSION | 1757 | #ifndef DESKTOP_VERSION |
1743 | SharpFormat* sharpFormat = 0; | 1758 | SharpFormat* sharpFormat = 0; |
1744 | if ( mode == 0 ) { // sharp | 1759 | if ( mode == 0 ) { // sharp |
1745 | sharpFormat = new SharpFormat () ; | 1760 | sharpFormat = new SharpFormat () ; |
1746 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1761 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1747 | 1762 | ||
1748 | } else | 1763 | } else |
1749 | #endif | 1764 | #endif |
1750 | if ( mode == 1 ) { // phone | 1765 | if ( mode == 1 ) { // phone |
1751 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1766 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1752 | mSyncManager->mPhoneDevice, | 1767 | mSyncManager->mPhoneDevice, |
1753 | mSyncManager->mPhoneConnection, | 1768 | mSyncManager->mPhoneConnection, |
1754 | mSyncManager->mPhoneModel); | 1769 | mSyncManager->mPhoneModel); |
1755 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1770 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1756 | 1771 | ||
1757 | } else { | 1772 | } else { |
1758 | emit tempDisableBR(false); | 1773 | emit tempDisableBR(false); |
1759 | return; | 1774 | return; |
1760 | } | 1775 | } |
1761 | if ( loadSuccess ) { | 1776 | if ( loadSuccess ) { |
1762 | getEventViewerDialog()->setSyncMode( true ); | 1777 | getEventViewerDialog()->setSyncMode( true ); |
1763 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1778 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1764 | getEventViewerDialog()->setSyncMode( false ); | 1779 | getEventViewerDialog()->setSyncMode( false ); |
1765 | qApp->processEvents(); | 1780 | qApp->processEvents(); |
1766 | if ( syncOK ) { | 1781 | if ( syncOK ) { |
1767 | if ( mSyncManager->mWriteBackFile ) | 1782 | if ( mSyncManager->mWriteBackFile ) |
1768 | { | 1783 | { |
1769 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1784 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1770 | Incidence* inc = iL.first(); | 1785 | Incidence* inc = iL.first(); |
1771 | if ( phoneFormat ) { | 1786 | if ( phoneFormat ) { |
1772 | while ( inc ) { | 1787 | while ( inc ) { |
1773 | inc->removeID(mCurrentSyncDevice); | 1788 | inc->removeID(mCurrentSyncDevice); |
1774 | inc = iL.next(); | 1789 | inc = iL.next(); |
1775 | } | 1790 | } |
1776 | } | 1791 | } |
1777 | #ifndef DESKTOP_VERSION | 1792 | #ifndef DESKTOP_VERSION |
1778 | if ( sharpFormat ) | 1793 | if ( sharpFormat ) |
1779 | sharpFormat->save(calendar); | 1794 | sharpFormat->save(calendar); |
1780 | #endif | 1795 | #endif |
1781 | if ( phoneFormat ) | 1796 | if ( phoneFormat ) |
1782 | phoneFormat->save(calendar); | 1797 | phoneFormat->save(calendar); |
1783 | iL = calendar->rawIncidences(); | 1798 | iL = calendar->rawIncidences(); |
1784 | inc = iL.first(); | 1799 | inc = iL.first(); |
1785 | Incidence* loc; | 1800 | Incidence* loc; |
1786 | while ( inc ) { | 1801 | while ( inc ) { |
1787 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1802 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1788 | loc = mCalendar->incidence(inc->uid() ); | 1803 | loc = mCalendar->incidence(inc->uid() ); |
1789 | if ( loc ) { | 1804 | if ( loc ) { |
1790 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1805 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1791 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1806 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1792 | } | 1807 | } |
1793 | } | 1808 | } |
1794 | inc = iL.next(); | 1809 | inc = iL.next(); |
1795 | } | 1810 | } |
1796 | Incidence* lse = getLastSyncEvent(); | 1811 | Incidence* lse = getLastSyncEvent(); |
1797 | if ( lse ) { | 1812 | if ( lse ) { |
1798 | lse->setReadOnly( false ); | 1813 | lse->setReadOnly( false ); |
1799 | lse->setDescription( "" ); | 1814 | lse->setDescription( "" ); |
1800 | lse->setReadOnly( true ); | 1815 | lse->setReadOnly( true ); |
1801 | } | 1816 | } |
1802 | } | 1817 | } |
1803 | } else { | 1818 | } else { |
1804 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1819 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1805 | } | 1820 | } |
1806 | setModified( true ); | 1821 | setModified( true ); |
1807 | } else { | 1822 | } else { |
1808 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1823 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1809 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1824 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1810 | question, i18n("Ok")) ; | 1825 | question, i18n("Ok")) ; |
1811 | 1826 | ||
1812 | } | 1827 | } |
1813 | delete calendar; | 1828 | delete calendar; |
1814 | updateView(); | 1829 | updateView(); |
1815 | emit tempDisableBR(false); | 1830 | emit tempDisableBR(false); |
1816 | return ;//syncOK; | 1831 | return ;//syncOK; |
1817 | 1832 | ||
1818 | } | 1833 | } |
1819 | 1834 | ||
1820 | bool CalendarView::importBday() | 1835 | bool CalendarView::importBday() |
1821 | { | 1836 | { |
1822 | #ifndef KORG_NOKABC | 1837 | #ifndef KORG_NOKABC |
1823 | 1838 | ||
1824 | #ifdef DESKTOP_VERSION | 1839 | #ifdef DESKTOP_VERSION |
1825 | int curCal = mCalendar->defaultCalendar(); | 1840 | int curCal = mCalendar->defaultCalendar(); |
1826 | int bd = mCalEditView->getBirtdayID(); | 1841 | int bd = mCalEditView->getBirtdayID(); |
1827 | if ( bd == 0 ) | 1842 | if ( bd == 0 ) |
1828 | return false; | 1843 | return false; |
1829 | mCalendar->setDefaultCalendar( bd ); | 1844 | mCalendar->setDefaultCalendar( bd ); |
1830 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1845 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1831 | KABC::AddressBook::Iterator it; | 1846 | KABC::AddressBook::Iterator it; |
1832 | int count = 0; | 1847 | int count = 0; |
1833 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1848 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1834 | ++count; | 1849 | ++count; |
1835 | } | 1850 | } |
1836 | QProgressBar bar(count,0 ); | 1851 | QProgressBar bar(count,0 ); |
1837 | int w = 300; | 1852 | int w = 300; |
1838 | if ( QApplication::desktop()->width() < 320 ) | 1853 | if ( QApplication::desktop()->width() < 320 ) |
1839 | w = 220; | 1854 | w = 220; |
1840 | int h = bar.sizeHint().height() ; | 1855 | int h = bar.sizeHint().height() ; |
1841 | int dw = QApplication::desktop()->width(); | 1856 | int dw = QApplication::desktop()->width(); |
1842 | int dh = QApplication::desktop()->height(); | 1857 | int dh = QApplication::desktop()->height(); |
1843 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1858 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1844 | bar.show(); | 1859 | bar.show(); |
1845 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1860 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1846 | qApp->processEvents(); | 1861 | qApp->processEvents(); |
1847 | count = 0; | 1862 | count = 0; |
1848 | int addCount = 0; | 1863 | int addCount = 0; |
1849 | KCal::Attendee* a = 0; | 1864 | KCal::Attendee* a = 0; |
1850 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1865 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1851 | if ( ! bar.isVisible() ) | 1866 | if ( ! bar.isVisible() ) |
1852 | return false; | 1867 | return false; |
1853 | bar.setProgress( count++ ); | 1868 | bar.setProgress( count++ ); |
1854 | qApp->processEvents(); | 1869 | qApp->processEvents(); |
1855 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1870 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1856 | if ( (*it).birthday().date().isValid() ){ | 1871 | if ( (*it).birthday().date().isValid() ){ |
1857 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1872 | 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 ) ) | 1873 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1859 | ++addCount; | 1874 | ++addCount; |
1860 | } | 1875 | } |
1861 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1876 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1862 | if ( anni.isValid() ){ | 1877 | if ( anni.isValid() ){ |
1863 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1878 | 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 ) ) | 1879 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1865 | ++addCount; | 1880 | ++addCount; |
1866 | } | 1881 | } |
1867 | } | 1882 | } |
1868 | mCalendar->setDefaultCalendar( curCal ); | 1883 | mCalendar->setDefaultCalendar( curCal ); |
1869 | updateView(); | 1884 | updateView(); |
1870 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1885 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1871 | #else //DESKTOP_VERSION | 1886 | #else //DESKTOP_VERSION |
1872 | 1887 | ||
1873 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1888 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1874 | // the result should now arrive through method insertBirthdays | 1889 | // the result should now arrive through method insertBirthdays |
1875 | 1890 | ||
1876 | #endif //DESKTOP_VERSION | 1891 | #endif //DESKTOP_VERSION |
1877 | 1892 | ||
1878 | #endif //KORG_NOKABC | 1893 | #endif //KORG_NOKABC |
1879 | 1894 | ||
1880 | 1895 | ||
1881 | return true; | 1896 | return true; |
1882 | } | 1897 | } |
1883 | 1898 | ||
1884 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1899 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1885 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1900 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1886 | const QStringList& anniversaryList, const QStringList& realNameList, | 1901 | const QStringList& anniversaryList, const QStringList& realNameList, |
1887 | const QStringList& emailList, const QStringList& assembledNameList, | 1902 | const QStringList& emailList, const QStringList& assembledNameList, |
1888 | const QStringList& uidList) | 1903 | const QStringList& uidList) |
1889 | { | 1904 | { |
1890 | 1905 | ||
1891 | //qDebug("KO::CalendarView::insertBirthdays"); | 1906 | //qDebug("KO::CalendarView::insertBirthdays"); |
1892 | if (uid == this->name()) | 1907 | if (uid == this->name()) |
1893 | { | 1908 | { |
1894 | int curCal = mCalendar->defaultCalendar(); | 1909 | int curCal = mCalendar->defaultCalendar(); |
1895 | int bd = mCalEditView->getBirtdayID(); | 1910 | int bd = mCalEditView->getBirtdayID(); |
1896 | if ( bd == 0 ) | 1911 | if ( bd == 0 ) |
1897 | return; | 1912 | return; |
1898 | mCalendar->setDefaultCalendar( bd ); | 1913 | mCalendar->setDefaultCalendar( bd ); |
1899 | 1914 | ||
1900 | 1915 | ||
1901 | int count = birthdayList.count(); | 1916 | int count = birthdayList.count(); |
1902 | int addCount = 0; | 1917 | int addCount = 0; |
1903 | KCal::Attendee* a = 0; | 1918 | KCal::Attendee* a = 0; |
1904 | 1919 | ||
1905 | //qDebug("CalView 1 %i", count); | 1920 | //qDebug("CalView 1 %i", count); |
1906 | 1921 | ||
1907 | QProgressBar bar(count,0 ); | 1922 | QProgressBar bar(count,0 ); |
1908 | int w = 300; | 1923 | int w = 300; |
1909 | if ( QApplication::desktop()->width() < 320 ) | 1924 | if ( QApplication::desktop()->width() < 320 ) |
1910 | w = 220; | 1925 | w = 220; |
1911 | int h = bar.sizeHint().height() ; | 1926 | int h = bar.sizeHint().height() ; |
1912 | int dw = QApplication::desktop()->width(); | 1927 | int dw = QApplication::desktop()->width(); |
1913 | int dh = QApplication::desktop()->height(); | 1928 | int dh = QApplication::desktop()->height(); |
1914 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1929 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1915 | bar.show(); | 1930 | bar.show(); |
1916 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1931 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1917 | qApp->processEvents(); | 1932 | qApp->processEvents(); |
1918 | 1933 | ||
1919 | QDate birthday; | 1934 | QDate birthday; |
1920 | QDate anniversary; | 1935 | QDate anniversary; |
1921 | QString realName; | 1936 | QString realName; |
1922 | QString email; | 1937 | QString email; |
1923 | QString assembledName; | 1938 | QString assembledName; |
1924 | QString uid; | 1939 | QString uid; |
1925 | bool ok = true; | 1940 | bool ok = true; |
1926 | for ( int i = 0; i < count; i++) | 1941 | for ( int i = 0; i < count; i++) |
1927 | { | 1942 | { |
1928 | if ( ! bar.isVisible() ) | 1943 | if ( ! bar.isVisible() ) |
1929 | return; | 1944 | return; |
1930 | bar.setProgress( i ); | 1945 | bar.setProgress( i ); |
1931 | qApp->processEvents(); | 1946 | qApp->processEvents(); |
1932 | 1947 | ||
1933 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1948 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1934 | if (!ok) { | 1949 | if (!ok) { |
1935 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1950 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1936 | } | 1951 | } |
1937 | 1952 | ||
1938 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1953 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1939 | if (!ok) { | 1954 | if (!ok) { |
1940 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1955 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1941 | } | 1956 | } |
1942 | realName = realNameList[i]; | 1957 | realName = realNameList[i]; |
1943 | email = emailList[i]; | 1958 | email = emailList[i]; |
1944 | assembledName = assembledNameList[i]; | 1959 | assembledName = assembledNameList[i]; |
1945 | uid = uidList[i]; | 1960 | 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() ); | 1961 | //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 | 1962 | ||
1948 | if ( birthday.isValid() ){ | 1963 | if ( birthday.isValid() ){ |
1949 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1964 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1950 | KCal::Attendee::ReqParticipant,uid) ; | 1965 | KCal::Attendee::ReqParticipant,uid) ; |
1951 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1966 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1952 | ++addCount; | 1967 | ++addCount; |
1953 | } | 1968 | } |
1954 | 1969 | ||
1955 | if ( anniversary.isValid() ){ | 1970 | if ( anniversary.isValid() ){ |
1956 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1971 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1957 | KCal::Attendee::ReqParticipant,uid) ; | 1972 | KCal::Attendee::ReqParticipant,uid) ; |
1958 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1973 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1959 | ++addCount; | 1974 | ++addCount; |
1960 | } | 1975 | } |
1961 | } | 1976 | } |
1962 | 1977 | ||
1963 | mCalendar->setDefaultCalendar( curCal ); | 1978 | mCalendar->setDefaultCalendar( curCal ); |
1964 | updateView(); | 1979 | updateView(); |
1965 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1980 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1966 | 1981 | ||
1967 | } | 1982 | } |
1968 | 1983 | ||
1969 | } | 1984 | } |
1970 | 1985 | ||
1971 | 1986 | ||
1972 | 1987 | ||
1973 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1988 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1974 | { | 1989 | { |
1975 | //qDebug("addAnni "); | 1990 | //qDebug("addAnni "); |
1976 | Event * ev = new Event(); | 1991 | Event * ev = new Event(); |
1977 | ev->setOrganizer(KOPrefs::instance()->email()); | 1992 | ev->setOrganizer(KOPrefs::instance()->email()); |
1978 | if ( a ) { | 1993 | if ( a ) { |
1979 | ev->addAttendee( a ); | 1994 | ev->addAttendee( a ); |
1980 | } | 1995 | } |
1981 | QString kind; | 1996 | QString kind; |
1982 | if ( birthday ) { | 1997 | if ( birthday ) { |
1983 | kind = i18n( "Birthday" ); | 1998 | kind = i18n( "Birthday" ); |
1984 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1999 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1985 | } | 2000 | } |
1986 | else { | 2001 | else { |
1987 | kind = i18n( "Anniversary" ); | 2002 | kind = i18n( "Anniversary" ); |
1988 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 2003 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1989 | } | 2004 | } |
1990 | ev->setCategories( kind ); | 2005 | ev->setCategories( kind ); |
1991 | ev->setDtStart( QDateTime(date) ); | 2006 | ev->setDtStart( QDateTime(date) ); |
1992 | ev->setDtEnd( QDateTime(date) ); | 2007 | ev->setDtEnd( QDateTime(date) ); |
1993 | ev->setFloats( true ); | 2008 | ev->setFloats( true ); |
1994 | Recurrence * rec = ev->recurrence(); | 2009 | Recurrence * rec = ev->recurrence(); |
1995 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 2010 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1996 | rec->addYearlyNum( date.month() ); | 2011 | rec->addYearlyNum( date.month() ); |
1997 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 2012 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1998 | delete ev; | 2013 | delete ev; |
1999 | return false; | 2014 | return false; |
2000 | } | 2015 | } |
2001 | return true; | 2016 | return true; |
2002 | 2017 | ||
2003 | } | 2018 | } |
2004 | bool CalendarView::importQtopia( const QString &categories, | 2019 | bool CalendarView::importQtopia( const QString &categories, |
2005 | const QString &datebook, | 2020 | const QString &datebook, |
2006 | const QString &todolist ) | 2021 | const QString &todolist ) |
2007 | { | 2022 | { |
2008 | 2023 | ||
2009 | QtopiaFormat qtopiaFormat; | 2024 | QtopiaFormat qtopiaFormat; |
2010 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2025 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2011 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2026 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2012 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2027 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2013 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2028 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2014 | 2029 | ||
2015 | updateView(); | 2030 | updateView(); |
2016 | return true; | 2031 | return true; |
2017 | 2032 | ||
2018 | #if 0 | 2033 | #if 0 |
2019 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2034 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2020 | mCurrentSyncDevice = "qtopia-XML"; | 2035 | mCurrentSyncDevice = "qtopia-XML"; |
2021 | if ( mSyncManager->mAskForPreferences ) | 2036 | if ( mSyncManager->mAskForPreferences ) |
2022 | edit_sync_options(); | 2037 | edit_sync_options(); |
2023 | qApp->processEvents(); | 2038 | qApp->processEvents(); |
2024 | CalendarLocal* calendar = new CalendarLocal(); | 2039 | CalendarLocal* calendar = new CalendarLocal(); |
2025 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2040 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2026 | bool syncOK = false; | 2041 | bool syncOK = false; |
2027 | QtopiaFormat qtopiaFormat; | 2042 | QtopiaFormat qtopiaFormat; |
2028 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2043 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2029 | bool loadOk = true; | 2044 | bool loadOk = true; |
2030 | if ( !categories.isEmpty() ) | 2045 | if ( !categories.isEmpty() ) |
2031 | loadOk = qtopiaFormat.load( calendar, categories ); | 2046 | loadOk = qtopiaFormat.load( calendar, categories ); |
2032 | if ( loadOk && !datebook.isEmpty() ) | 2047 | if ( loadOk && !datebook.isEmpty() ) |
2033 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2048 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2034 | if ( loadOk && !todolist.isEmpty() ) | 2049 | if ( loadOk && !todolist.isEmpty() ) |
2035 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2050 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2036 | 2051 | ||
2037 | if ( loadOk ) { | 2052 | if ( loadOk ) { |
2038 | getEventViewerDialog()->setSyncMode( true ); | 2053 | getEventViewerDialog()->setSyncMode( true ); |
2039 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2054 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2040 | getEventViewerDialog()->setSyncMode( false ); | 2055 | getEventViewerDialog()->setSyncMode( false ); |
2041 | qApp->processEvents(); | 2056 | qApp->processEvents(); |
2042 | if ( syncOK ) { | 2057 | if ( syncOK ) { |
2043 | if ( mSyncManager->mWriteBackFile ) | 2058 | if ( mSyncManager->mWriteBackFile ) |
2044 | { | 2059 | { |
2045 | // write back XML file | 2060 | // write back XML file |
2046 | 2061 | ||
2047 | } | 2062 | } |
2048 | setModified( true ); | 2063 | setModified( true ); |
2049 | } | 2064 | } |
2050 | } else { | 2065 | } else { |
2051 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2066 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2052 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2067 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2053 | question, i18n("Ok")) ; | 2068 | question, i18n("Ok")) ; |
2054 | } | 2069 | } |
2055 | delete calendar; | 2070 | delete calendar; |
2056 | updateView(); | 2071 | updateView(); |
2057 | return syncOK; | 2072 | return syncOK; |
2058 | 2073 | ||
2059 | 2074 | ||
2060 | #endif | 2075 | #endif |
2061 | 2076 | ||
2062 | } | 2077 | } |
2063 | 2078 | ||
2064 | void CalendarView::setSyncEventsReadOnly() | 2079 | void CalendarView::setSyncEventsReadOnly() |
2065 | { | 2080 | { |
2066 | mCalendar->setSyncEventsReadOnly(); | 2081 | mCalendar->setSyncEventsReadOnly(); |
2067 | } | 2082 | } |
2068 | 2083 | ||
2069 | bool CalendarView::loadCalendars() | 2084 | bool CalendarView::loadCalendars() |
2070 | { | 2085 | { |
2071 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2086 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2072 | KopiCalendarFile * cal = calendars.first(); | 2087 | KopiCalendarFile * cal = calendars.first(); |
2073 | mCalendar->setDefaultCalendar( 1 ); | 2088 | mCalendar->setDefaultCalendar( 1 ); |
2074 | openCalendar( MainWindow::defaultFileName(), false ); | 2089 | openCalendar( MainWindow::defaultFileName(), false ); |
2075 | cal = calendars.next(); | 2090 | cal = calendars.next(); |
2076 | while ( cal ) { | 2091 | while ( cal ) { |
2077 | addCalendar( cal ); | 2092 | addCalendar( cal ); |
2078 | cal = calendars.next(); | 2093 | cal = calendars.next(); |
2079 | } | 2094 | } |
2080 | restoreCalendarSettings(); | 2095 | restoreCalendarSettings(); |
2081 | return true; | 2096 | return true; |
2082 | } | 2097 | } |
2083 | bool CalendarView::restoreCalendarSettings() | 2098 | bool CalendarView::restoreCalendarSettings() |
2084 | { | 2099 | { |
2085 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2100 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2086 | KopiCalendarFile * cal = calendars.first(); | 2101 | KopiCalendarFile * cal = calendars.first(); |
2087 | while ( cal ) { | 2102 | while ( cal ) { |
2088 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2103 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2089 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2104 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2090 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2105 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2091 | if ( cal->isStandard ) | 2106 | if ( cal->isStandard ) |
2092 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2107 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2093 | cal = calendars.next(); | 2108 | cal = calendars.next(); |
2094 | } | 2109 | } |
2095 | setSyncEventsReadOnly(); | 2110 | setSyncEventsReadOnly(); |
2096 | mCalendar->reInitAlarmSettings(); | 2111 | mCalendar->reInitAlarmSettings(); |
2097 | updateUnmanagedViews(); | 2112 | updateUnmanagedViews(); |
2098 | updateView(); | 2113 | updateView(); |
2099 | return true; | 2114 | return true; |
2100 | } | 2115 | } |
2101 | void CalendarView::addCalendarId( int id ) | 2116 | void CalendarView::addCalendarId( int id ) |
2102 | { | 2117 | { |
2103 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2118 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2104 | if ( cal ) | 2119 | if ( cal ) |
2105 | addCalendar( cal ); | 2120 | addCalendar( cal ); |
2106 | } | 2121 | } |
2107 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2122 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2108 | { | 2123 | { |
2109 | cal->mErrorOnLoad = false; | 2124 | cal->mErrorOnLoad = false; |
2110 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2125 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2111 | cal->mLoadDt = QDateTime::currentDateTime(); | 2126 | cal->mLoadDt = QDateTime::currentDateTime(); |
2112 | return true; | 2127 | return true; |
2113 | } | 2128 | } |
2114 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2129 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2115 | cal->mErrorOnLoad = true; | 2130 | cal->mErrorOnLoad = true; |
2116 | return false; | 2131 | return false; |
2117 | } | 2132 | } |
2118 | bool CalendarView::openCalendar(QString filename, bool merge) | 2133 | bool CalendarView::openCalendar(QString filename, bool merge) |
2119 | { | 2134 | { |
2120 | 2135 | ||
2121 | if (filename.isEmpty()) { | 2136 | if (filename.isEmpty()) { |
2122 | return false; | 2137 | return false; |
2123 | } | 2138 | } |
2124 | 2139 | ||
2125 | if (!QFile::exists(filename)) { | 2140 | if (!QFile::exists(filename)) { |
2126 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2141 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2127 | return false; | 2142 | return false; |
2128 | } | 2143 | } |
2129 | 2144 | ||
2130 | globalFlagBlockAgenda = 1; | 2145 | globalFlagBlockAgenda = 1; |
2131 | clearAllViews(); | 2146 | clearAllViews(); |
2132 | if (!merge) { | 2147 | if (!merge) { |
2133 | mViewManager->setDocumentId( filename ); | 2148 | mViewManager->setDocumentId( filename ); |
2134 | mCalendar->close(); | 2149 | mCalendar->close(); |
2135 | } | 2150 | } |
2136 | mStorage->setFileName( filename ); | 2151 | mStorage->setFileName( filename ); |
2137 | 2152 | ||
2138 | if ( mStorage->load() ) { | 2153 | if ( mStorage->load() ) { |
2139 | if ( merge ) ;//setModified( true ); | 2154 | if ( merge ) ;//setModified( true ); |
2140 | else { | 2155 | else { |
2141 | //setModified( true ); | 2156 | //setModified( true ); |
2142 | mViewManager->setDocumentId( filename ); | 2157 | mViewManager->setDocumentId( filename ); |
2143 | mDialogManager->setDocumentId( filename ); | 2158 | mDialogManager->setDocumentId( filename ); |
2144 | mTodoList->setDocumentId( filename ); | 2159 | mTodoList->setDocumentId( filename ); |
2145 | } | 2160 | } |
2146 | globalFlagBlockAgenda = 2; | 2161 | globalFlagBlockAgenda = 2; |
2147 | // if ( getLastSyncEvent() ) | 2162 | // if ( getLastSyncEvent() ) |
2148 | // getLastSyncEvent()->setReadOnly( true ); | 2163 | // getLastSyncEvent()->setReadOnly( true ); |
2149 | mCalendar->reInitAlarmSettings(); | 2164 | mCalendar->reInitAlarmSettings(); |
2150 | setSyncEventsReadOnly(); | 2165 | setSyncEventsReadOnly(); |
2151 | updateUnmanagedViews(); | 2166 | updateUnmanagedViews(); |
2152 | updateView(); | 2167 | updateView(); |
2153 | if ( filename != MainWindow::defaultFileName() ) { | 2168 | if ( filename != MainWindow::defaultFileName() ) { |
2154 | saveCalendar( MainWindow::defaultFileName() ); | 2169 | saveCalendar( MainWindow::defaultFileName() ); |
2155 | } else { | 2170 | } else { |
2156 | QFileInfo finf ( MainWindow::defaultFileName()); | 2171 | QFileInfo finf ( MainWindow::defaultFileName()); |
2157 | if ( finf.exists() ) { | 2172 | if ( finf.exists() ) { |
2158 | setLoadedFileVersion( finf.lastModified () ); | 2173 | setLoadedFileVersion( finf.lastModified () ); |
2159 | } | 2174 | } |
2160 | } | 2175 | } |
2161 | return true; | 2176 | return true; |
2162 | } else { | 2177 | } else { |
2163 | // while failing to load, the calendar object could | 2178 | // while failing to load, the calendar object could |
2164 | // have become partially populated. Clear it out. | 2179 | // have become partially populated. Clear it out. |
2165 | if ( !merge ) { | 2180 | if ( !merge ) { |
2166 | mCalendar->close(); | 2181 | mCalendar->close(); |
2167 | mViewManager->setDocumentId( filename ); | 2182 | mViewManager->setDocumentId( filename ); |
2168 | mDialogManager->setDocumentId( filename ); | 2183 | mDialogManager->setDocumentId( filename ); |
2169 | mTodoList->setDocumentId( filename ); | 2184 | mTodoList->setDocumentId( filename ); |
2170 | } | 2185 | } |
2171 | 2186 | ||
2172 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2187 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2173 | 2188 | ||
2174 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2189 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2175 | globalFlagBlockAgenda = 2; | 2190 | globalFlagBlockAgenda = 2; |
2176 | mCalendar->reInitAlarmSettings(); | 2191 | mCalendar->reInitAlarmSettings(); |
2177 | setSyncEventsReadOnly(); | 2192 | setSyncEventsReadOnly(); |
2178 | updateUnmanagedViews(); | 2193 | updateUnmanagedViews(); |
2179 | updateView(); | 2194 | updateView(); |
2180 | } | 2195 | } |
2181 | return false; | 2196 | return false; |
2182 | } | 2197 | } |
2183 | void CalendarView::showOpenError() | 2198 | void CalendarView::showOpenError() |
2184 | { | 2199 | { |
2185 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2200 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2186 | } | 2201 | } |
2187 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2202 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2188 | { | 2203 | { |
2189 | loadedFileVersion = dt; | 2204 | loadedFileVersion = dt; |
2190 | } | 2205 | } |
2191 | bool CalendarView::checkFileChanged(QString fn) | 2206 | bool CalendarView::checkFileChanged(QString fn) |
2192 | { | 2207 | { |
2193 | QFileInfo finf ( fn ); | 2208 | QFileInfo finf ( fn ); |
2194 | if ( !finf.exists() ) | 2209 | if ( !finf.exists() ) |
2195 | return true; | 2210 | return true; |
2196 | QDateTime dt = finf.lastModified (); | 2211 | QDateTime dt = finf.lastModified (); |
2197 | if ( dt <= loadedFileVersion ) | 2212 | if ( dt <= loadedFileVersion ) |
2198 | return false; | 2213 | return false; |
2199 | return true; | 2214 | return true; |
2200 | 2215 | ||
2201 | } | 2216 | } |
2202 | void CalendarView::watchSavedFile() | 2217 | void CalendarView::watchSavedFile() |
2203 | { | 2218 | { |
2204 | QFileInfo finf ( MainWindow::defaultFileName()); | 2219 | QFileInfo finf ( MainWindow::defaultFileName()); |
2205 | if ( !finf.exists() ) | 2220 | if ( !finf.exists() ) |
2206 | return; | 2221 | return; |
2207 | QDateTime dt = finf.lastModified (); | 2222 | QDateTime dt = finf.lastModified (); |
2208 | if ( dt < loadedFileVersion ) { | 2223 | if ( dt < loadedFileVersion ) { |
2209 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2224 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2210 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2225 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2211 | return; | 2226 | return; |
2212 | } | 2227 | } |
2213 | loadedFileVersion = dt; | 2228 | loadedFileVersion = dt; |
2214 | } | 2229 | } |
2215 | bool CalendarView::checkAllFileVersions() | 2230 | bool CalendarView::checkAllFileVersions() |
2216 | { | 2231 | { |
2217 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2232 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2218 | KopiCalendarFile * cal = calendars.first(); | 2233 | KopiCalendarFile * cal = calendars.first(); |
2219 | mCalendar->setDefaultCalendar( 1 ); | 2234 | mCalendar->setDefaultCalendar( 1 ); |
2220 | mCalendar->setDefaultCalendarEnabledOnly(); | 2235 | mCalendar->setDefaultCalendarEnabledOnly(); |
2221 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2236 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2222 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2237 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2223 | restoreCalendarSettings(); | 2238 | restoreCalendarSettings(); |
2224 | return false; | 2239 | return false; |
2225 | } | 2240 | } |
2226 | } | 2241 | } |
2227 | cal = calendars.next(); | 2242 | cal = calendars.next(); |
2228 | QDateTime storeTemp = loadedFileVersion; | 2243 | QDateTime storeTemp = loadedFileVersion; |
2229 | while ( cal ) { | 2244 | while ( cal ) { |
2230 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2245 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2231 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2246 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2232 | mCalendar->setDefaultCalendarEnabledOnly(); | 2247 | mCalendar->setDefaultCalendarEnabledOnly(); |
2233 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2248 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2234 | if ( !checkFileVersion(cal->mFileName )) { | 2249 | if ( !checkFileVersion(cal->mFileName )) { |
2235 | loadedFileVersion = storeTemp; | 2250 | loadedFileVersion = storeTemp; |
2236 | restoreCalendarSettings(); | 2251 | restoreCalendarSettings(); |
2237 | return false; | 2252 | return false; |
2238 | } | 2253 | } |
2239 | } | 2254 | } |
2240 | cal = calendars.next(); | 2255 | cal = calendars.next(); |
2241 | } | 2256 | } |
2242 | loadedFileVersion = storeTemp; | 2257 | loadedFileVersion = storeTemp; |
2243 | return true; | 2258 | return true; |
2244 | } | 2259 | } |
2245 | bool CalendarView::checkFileVersion(QString fn) | 2260 | bool CalendarView::checkFileVersion(QString fn) |
2246 | { | 2261 | { |
2247 | QFileInfo finf ( fn ); | 2262 | QFileInfo finf ( fn ); |
2248 | if ( !finf.exists() ) | 2263 | if ( !finf.exists() ) |
2249 | return true; | 2264 | return true; |
2250 | QDateTime dt = finf.lastModified (); | 2265 | QDateTime dt = finf.lastModified (); |
2251 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2266 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2252 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2267 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2253 | if ( dt <= loadedFileVersion ) | 2268 | if ( dt <= loadedFileVersion ) |
2254 | return true; | 2269 | return true; |
2255 | 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)) , | 2270 | 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)) , |
2256 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2271 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2257 | i18n("Sync+save")); | 2272 | i18n("Sync+save")); |
2258 | 2273 | ||
2259 | if ( km == KMessageBox::Cancel ) | 2274 | if ( km == KMessageBox::Cancel ) |
2260 | return false; | 2275 | return false; |
2261 | if ( km == KMessageBox::Yes ) | 2276 | if ( km == KMessageBox::Yes ) |
2262 | return true; | 2277 | return true; |
2263 | 2278 | ||
2264 | setSyncDevice("deleteaftersync" ); | 2279 | setSyncDevice("deleteaftersync" ); |
2265 | mSyncManager->mAskForPreferences = true; | 2280 | mSyncManager->mAskForPreferences = true; |
2266 | mSyncManager->mSyncAlgoPrefs = 3; | 2281 | mSyncManager->mSyncAlgoPrefs = 3; |
2267 | mSyncManager->mWriteBackFile = false; | 2282 | mSyncManager->mWriteBackFile = false; |
2268 | mSyncManager->mWriteBackExistingOnly = false; | 2283 | mSyncManager->mWriteBackExistingOnly = false; |
2269 | mSyncManager->mShowSyncSummary = false; | 2284 | mSyncManager->mShowSyncSummary = false; |
2270 | syncCalendar( fn, 3 ); | 2285 | syncCalendar( fn, 3 ); |
2271 | Event * e = getLastSyncEvent(); | 2286 | Event * e = getLastSyncEvent(); |
2272 | if ( e ) | 2287 | if ( e ) |
2273 | mCalendar->deleteEvent( e ); | 2288 | mCalendar->deleteEvent( e ); |
2274 | return true; | 2289 | return true; |
2275 | } | 2290 | } |
2276 | bool CalendarView::saveCalendars() | 2291 | bool CalendarView::saveCalendars() |
2277 | { | 2292 | { |
2278 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2293 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2279 | KopiCalendarFile * cal = calendars.first(); | 2294 | KopiCalendarFile * cal = calendars.first(); |
2280 | mCalendar->setDefaultCalendar( 1 ); | 2295 | mCalendar->setDefaultCalendar( 1 ); |
2281 | mCalendar->setDefaultCalendarEnabledOnly(); | 2296 | mCalendar->setDefaultCalendarEnabledOnly(); |
2282 | saveCalendar( MainWindow::defaultFileName() ); | 2297 | saveCalendar( MainWindow::defaultFileName() ); |
2283 | cal = calendars.next(); | 2298 | cal = calendars.next(); |
2284 | while ( cal ) { | 2299 | while ( cal ) { |
2285 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2300 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2286 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2301 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2287 | mCalendar->setDefaultCalendarEnabledOnly(); | 2302 | mCalendar->setDefaultCalendarEnabledOnly(); |
2288 | if ( saveCalendar( cal->mFileName ) ) | 2303 | if ( saveCalendar( cal->mFileName ) ) |
2289 | cal->mLoadDt = QDateTime::currentDateTime(); | 2304 | cal->mLoadDt = QDateTime::currentDateTime(); |
2290 | } | 2305 | } |
2291 | cal = calendars.next(); | 2306 | cal = calendars.next(); |
2292 | } | 2307 | } |
2293 | restoreCalendarSettings(); | 2308 | restoreCalendarSettings(); |
2294 | return true; | 2309 | return true; |
2295 | } | 2310 | } |
2296 | bool CalendarView::saveCalendar( QString filename ) | 2311 | bool CalendarView::saveCalendar( QString filename ) |
2297 | { | 2312 | { |
2298 | 2313 | ||
2299 | // Store back all unsaved data into calendar object | 2314 | // Store back all unsaved data into calendar object |
2300 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2315 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2301 | if ( mViewManager->currentView() ) | 2316 | if ( mViewManager->currentView() ) |
2302 | mViewManager->currentView()->flushView(); | 2317 | mViewManager->currentView()->flushView(); |
2303 | 2318 | ||
2304 | 2319 | ||
2305 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2320 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2306 | mStorage->setSaveFormat( new ICalFormat() ); | 2321 | mStorage->setSaveFormat( new ICalFormat() ); |
2307 | mStorage->setFileName( filename ); | 2322 | mStorage->setFileName( filename ); |
2308 | bool success; | 2323 | bool success; |
2309 | success = mStorage->save(); | 2324 | success = mStorage->save(); |
2310 | if ( !success ) { | 2325 | if ( !success ) { |
2311 | return false; | 2326 | return false; |
2312 | } | 2327 | } |
2313 | if ( filename == MainWindow::defaultFileName() ) { | 2328 | if ( filename == MainWindow::defaultFileName() ) { |
2314 | setLoadedFileVersion( lfv ); | 2329 | setLoadedFileVersion( lfv ); |
2315 | watchSavedFile(); | 2330 | watchSavedFile(); |
2316 | } | 2331 | } |
2317 | return true; | 2332 | return true; |
2318 | } | 2333 | } |
2319 | 2334 | ||
2320 | void CalendarView::closeCalendar() | 2335 | void CalendarView::closeCalendar() |
2321 | { | 2336 | { |
2322 | 2337 | ||
2323 | // child windows no longer valid | 2338 | // child windows no longer valid |
2324 | clearAllViews(); | 2339 | clearAllViews(); |
2325 | emit closingDown(); | 2340 | emit closingDown(); |
2326 | 2341 | ||
2327 | mCalendar->close(); | 2342 | mCalendar->close(); |
2328 | setModified(false); | 2343 | setModified(false); |
2329 | updateView(); | 2344 | updateView(); |
2330 | } | 2345 | } |
2331 | 2346 | ||
2332 | void CalendarView::archiveCalendar() | 2347 | void CalendarView::archiveCalendar() |
2333 | { | 2348 | { |
2334 | mDialogManager->showArchiveDialog(); | 2349 | mDialogManager->showArchiveDialog(); |
2335 | } | 2350 | } |
2336 | 2351 | ||
2337 | 2352 | ||
2338 | void CalendarView::readSettings() | 2353 | void CalendarView::readSettings() |
2339 | { | 2354 | { |
2340 | 2355 | ||
2341 | 2356 | ||
2342 | // mViewManager->showAgendaView(); | 2357 | // mViewManager->showAgendaView(); |
2343 | QString str; | 2358 | QString str; |
2344 | //qDebug("CalendarView::readSettings() "); | 2359 | //qDebug("CalendarView::readSettings() "); |
2345 | // read settings from the KConfig, supplying reasonable | 2360 | // read settings from the KConfig, supplying reasonable |
2346 | // defaults where none are to be found | 2361 | // defaults where none are to be found |
2347 | KConfig *config = KOGlobals::config(); | 2362 | KConfig *config = KOGlobals::config(); |
2348 | #ifndef KORG_NOSPLITTER | 2363 | #ifndef KORG_NOSPLITTER |
2349 | config->setGroup("KOrganizer Geometry"); | 2364 | config->setGroup("KOrganizer Geometry"); |
2350 | 2365 | ||
2351 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2366 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2352 | if (sizes.count() != 2) { | 2367 | if (sizes.count() != 2) { |
2353 | sizes << mDateNavigator->minimumSizeHint().width(); | 2368 | sizes << mDateNavigator->minimumSizeHint().width(); |
2354 | sizes << 300; | 2369 | sizes << 300; |
2355 | } | 2370 | } |
2356 | mPanner->setSizes(sizes); | 2371 | mPanner->setSizes(sizes); |
2357 | 2372 | ||
2358 | sizes = config->readIntListEntry("Separator2"); | 2373 | sizes = config->readIntListEntry("Separator2"); |
2359 | if ( ( mResourceView && sizes.count() == 4 ) || | 2374 | if ( ( mResourceView && sizes.count() == 4 ) || |
2360 | ( !mResourceView && sizes.count() == 3 ) ) { | 2375 | ( !mResourceView && sizes.count() == 3 ) ) { |
2361 | mLeftSplitter->setSizes(sizes); | 2376 | mLeftSplitter->setSizes(sizes); |
2362 | } | 2377 | } |
2363 | #endif | 2378 | #endif |
2364 | globalFlagBlockAgenda = 1; | 2379 | globalFlagBlockAgenda = 1; |
2365 | mViewManager->showAgendaView(); | 2380 | mViewManager->showAgendaView(); |
2366 | //mViewManager->readSettings( config ); | 2381 | //mViewManager->readSettings( config ); |
2367 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2382 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2368 | readFilterSettings(config); | 2383 | readFilterSettings(config); |
2369 | 2384 | ||
2370 | #ifdef DESKTOP_VERSION | 2385 | #ifdef DESKTOP_VERSION |
2371 | config->setGroup("WidgetLayout"); | 2386 | config->setGroup("WidgetLayout"); |
2372 | QStringList list; | 2387 | QStringList list; |
2373 | list = config->readListEntry("MainLayout"); | 2388 | list = config->readListEntry("MainLayout"); |
2374 | int x,y,w,h; | 2389 | int x,y,w,h; |
2375 | if ( ! list.isEmpty() ) { | 2390 | if ( ! list.isEmpty() ) { |
2376 | x = list[0].toInt(); | 2391 | x = list[0].toInt(); |
2377 | y = list[1].toInt(); | 2392 | y = list[1].toInt(); |
2378 | w = list[2].toInt(); | 2393 | w = list[2].toInt(); |
2379 | h = list[3].toInt(); | 2394 | h = list[3].toInt(); |
2380 | KApplication::testCoords( &x,&y,&w,&h ); | 2395 | KApplication::testCoords( &x,&y,&w,&h ); |
2381 | topLevelWidget()->setGeometry(x,y,w,h); | 2396 | topLevelWidget()->setGeometry(x,y,w,h); |
2382 | 2397 | ||
2383 | } else { | 2398 | } else { |
2384 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2399 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2385 | } | 2400 | } |
2386 | list = config->readListEntry("EditEventLayout"); | 2401 | list = config->readListEntry("EditEventLayout"); |
2387 | if ( ! list.isEmpty() ) { | 2402 | if ( ! list.isEmpty() ) { |
2388 | x = list[0].toInt(); | 2403 | x = list[0].toInt(); |
2389 | y = list[1].toInt(); | 2404 | y = list[1].toInt(); |
2390 | w = list[2].toInt(); | 2405 | w = list[2].toInt(); |
2391 | h = list[3].toInt(); | 2406 | h = list[3].toInt(); |
2392 | KApplication::testCoords( &x,&y,&w,&h ); | 2407 | KApplication::testCoords( &x,&y,&w,&h ); |
2393 | mEventEditor->setGeometry(x,y,w,h); | 2408 | mEventEditor->setGeometry(x,y,w,h); |
2394 | 2409 | ||
2395 | } | 2410 | } |
2396 | list = config->readListEntry("EditTodoLayout"); | 2411 | list = config->readListEntry("EditTodoLayout"); |
2397 | if ( ! list.isEmpty() ) { | 2412 | if ( ! list.isEmpty() ) { |
2398 | x = list[0].toInt(); | 2413 | x = list[0].toInt(); |
2399 | y = list[1].toInt(); | 2414 | y = list[1].toInt(); |
2400 | w = list[2].toInt(); | 2415 | w = list[2].toInt(); |
2401 | h = list[3].toInt(); | 2416 | h = list[3].toInt(); |
2402 | KApplication::testCoords( &x,&y,&w,&h ); | 2417 | KApplication::testCoords( &x,&y,&w,&h ); |
2403 | mTodoEditor->setGeometry(x,y,w,h); | 2418 | mTodoEditor->setGeometry(x,y,w,h); |
2404 | 2419 | ||
2405 | } | 2420 | } |
2406 | list = config->readListEntry("ViewerLayout"); | 2421 | list = config->readListEntry("ViewerLayout"); |
2407 | if ( ! list.isEmpty() ) { | 2422 | if ( ! list.isEmpty() ) { |
2408 | x = list[0].toInt(); | 2423 | x = list[0].toInt(); |
2409 | y = list[1].toInt(); | 2424 | y = list[1].toInt(); |
2410 | w = list[2].toInt(); | 2425 | w = list[2].toInt(); |
2411 | h = list[3].toInt(); | 2426 | h = list[3].toInt(); |
2412 | KApplication::testCoords( &x,&y,&w,&h ); | 2427 | KApplication::testCoords( &x,&y,&w,&h ); |
2413 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2428 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2414 | } | 2429 | } |
2415 | #endif | 2430 | #endif |
2416 | config->setGroup( "Views" ); | 2431 | config->setGroup( "Views" ); |
2417 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2432 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2418 | 2433 | ||
2419 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2434 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2420 | 2435 | ||
2421 | int resetval = 0; | 2436 | int resetval = 0; |
2422 | int maxVal = 0; | 2437 | int maxVal = 0; |
2423 | if (sizes.count() != 3) { | 2438 | if (sizes.count() != 3) { |
2424 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2439 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2425 | resetval = mDateNavigator->sizeHint().width()+2; | 2440 | resetval = mDateNavigator->sizeHint().width()+2; |
2426 | } else { | 2441 | } else { |
2427 | resetval = mDateNavigator->sizeHint().height()+2; | 2442 | resetval = mDateNavigator->sizeHint().height()+2; |
2428 | } | 2443 | } |
2429 | } | 2444 | } |
2430 | if ( resetval ) { | 2445 | if ( resetval ) { |
2431 | sizes.clear(); | 2446 | sizes.clear(); |
2432 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2447 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2433 | maxVal = QApplication::desktop()->width() -10; | 2448 | maxVal = QApplication::desktop()->width() -10; |
2434 | } else { | 2449 | } else { |
2435 | maxVal = QApplication::desktop()->height()-10; | 2450 | maxVal = QApplication::desktop()->height()-10; |
2436 | } | 2451 | } |
2437 | sizes << resetval; | 2452 | sizes << resetval; |
2438 | if ( maxVal < resetval + resetval) | 2453 | if ( maxVal < resetval + resetval) |
2439 | resetval = maxVal - resetval; | 2454 | resetval = maxVal - resetval; |
2440 | sizes << resetval; | 2455 | sizes << resetval; |
2441 | sizes << 100; | 2456 | sizes << 100; |
2442 | } | 2457 | } |
2443 | mLeftFrame->setSizes(sizes); | 2458 | mLeftFrame->setSizes(sizes); |
2444 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2459 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2445 | resetval = 0; | 2460 | resetval = 0; |
2446 | maxVal = 0; | 2461 | maxVal = 0; |
2447 | if (sizes.count() != 2) { | 2462 | if (sizes.count() != 2) { |
2448 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2463 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2449 | resetval = mDateNavigator->sizeHint().width()+2; | 2464 | resetval = mDateNavigator->sizeHint().width()+2; |
2450 | } else { | 2465 | } else { |
2451 | resetval = mDateNavigator->sizeHint().height()+2; | 2466 | resetval = mDateNavigator->sizeHint().height()+2; |
2452 | } | 2467 | } |
2453 | } | 2468 | } |
2454 | if ( resetval ) { | 2469 | if ( resetval ) { |
2455 | sizes.clear(); | 2470 | sizes.clear(); |
2456 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2471 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2457 | maxVal = QApplication::desktop()->width() -10; | 2472 | maxVal = QApplication::desktop()->width() -10; |
2458 | } else { | 2473 | } else { |
2459 | maxVal = QApplication::desktop()->height()-10; | 2474 | maxVal = QApplication::desktop()->height()-10; |
2460 | } | 2475 | } |
2461 | sizes << resetval; | 2476 | sizes << resetval; |
2462 | if ( maxVal < resetval + resetval) | 2477 | if ( maxVal < resetval + resetval) |
2463 | resetval = maxVal - resetval; | 2478 | resetval = maxVal - resetval; |
2464 | sizes << resetval; | 2479 | sizes << resetval; |
2465 | } | 2480 | } |
2466 | mMainFrame->setSizes(sizes); | 2481 | mMainFrame->setSizes(sizes); |
2467 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2482 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2468 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2483 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2469 | else mNavigator->selectDates( dateCount ); | 2484 | else mNavigator->selectDates( dateCount ); |
2470 | // mViewManager->readSettings( config ); | 2485 | // mViewManager->readSettings( config ); |
2471 | updateConfig(); | 2486 | updateConfig(); |
2472 | globalFlagBlockAgenda = 2; | 2487 | globalFlagBlockAgenda = 2; |
2473 | mViewManager->readSettings( config ); | 2488 | mViewManager->readSettings( config ); |
2474 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2489 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2475 | } | 2490 | } |
2476 | 2491 | ||
2477 | void CalendarView::checkSuspendAlarm() | 2492 | void CalendarView::checkSuspendAlarm() |
2478 | { | 2493 | { |
2479 | if ( mSuspendTimer->isActive() ) { | 2494 | if ( mSuspendTimer->isActive() ) { |
2480 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2495 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2481 | } | 2496 | } |
2482 | } | 2497 | } |
2483 | void CalendarView::writeSettings() | 2498 | void CalendarView::writeSettings() |
2484 | { | 2499 | { |
2485 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2500 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2486 | 2501 | ||
2487 | KConfig *config = KOGlobals::config(); | 2502 | KConfig *config = KOGlobals::config(); |
2488 | 2503 | ||
2489 | mViewManager->writeSettings( config ); | 2504 | mViewManager->writeSettings( config ); |
2490 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2505 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2491 | mDialogManager->writeSettings( config ); | 2506 | mDialogManager->writeSettings( config ); |
2492 | //KOPrefs::instance()->usrWriteConfig(); | 2507 | //KOPrefs::instance()->usrWriteConfig(); |
2493 | KOPrefs::instance()->writeConfig(); | 2508 | KOPrefs::instance()->writeConfig(); |
2494 | 2509 | ||
2495 | writeFilterSettings(config); | 2510 | writeFilterSettings(config); |
2496 | config->setGroup( "AppRun" ); | 2511 | config->setGroup( "AppRun" ); |
2497 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2512 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2498 | int days = dt.daysTo( QDate::currentDate() ); | 2513 | int days = dt.daysTo( QDate::currentDate() ); |
2499 | dt = dt.addDays( days ); | 2514 | dt = dt.addDays( days ); |
2500 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2515 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2501 | config->writeEntry( "LatestProgramStopDays", days ); | 2516 | config->writeEntry( "LatestProgramStopDays", days ); |
2502 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2517 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2503 | //qDebug("KO: Writing stop time: %d ", secs); | 2518 | //qDebug("KO: Writing stop time: %d ", secs); |
2504 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2519 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2505 | //QDateTime latest = dt.addSecs ( secs ); | 2520 | //QDateTime latest = dt.addSecs ( secs ); |
2506 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2521 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2507 | config->setGroup( "Views" ); | 2522 | config->setGroup( "Views" ); |
2508 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2523 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2509 | 2524 | ||
2510 | #if 0 | 2525 | #if 0 |
2511 | qDebug("********************* "); | 2526 | qDebug("********************* "); |
2512 | qDebug("Testcode secsto "); | 2527 | qDebug("Testcode secsto "); |
2513 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2528 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2514 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2529 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2515 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2530 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2516 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2531 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2517 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2532 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2518 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2533 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2519 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2534 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2520 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2535 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2521 | qDebug("********************* testcode end"); | 2536 | qDebug("********************* testcode end"); |
2522 | 2537 | ||
2523 | #endif | 2538 | #endif |
2524 | 2539 | ||
2525 | QValueList<int> listINT = mLeftFrame->sizes(); | 2540 | QValueList<int> listINT = mLeftFrame->sizes(); |
2526 | config->writeEntry("Left Splitter Frame",listINT); | 2541 | config->writeEntry("Left Splitter Frame",listINT); |
2527 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2542 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2528 | config->writeEntry("Main Splitter Frame",listINT2); | 2543 | config->writeEntry("Main Splitter Frame",listINT2); |
2529 | #ifdef DESKTOP_VERSION | 2544 | #ifdef DESKTOP_VERSION |
2530 | config->setGroup("WidgetLayout"); | 2545 | config->setGroup("WidgetLayout"); |
2531 | QStringList list ;//= config->readListEntry("MainLayout"); | 2546 | QStringList list ;//= config->readListEntry("MainLayout"); |
2532 | int x,y,w,h; | 2547 | int x,y,w,h; |
2533 | QWidget* wid; | 2548 | QWidget* wid; |
2534 | wid = topLevelWidget(); | 2549 | wid = topLevelWidget(); |
2535 | x = wid->geometry().x(); | 2550 | x = wid->geometry().x(); |
2536 | y = wid->geometry().y(); | 2551 | y = wid->geometry().y(); |
2537 | w = wid->width(); | 2552 | w = wid->width(); |
2538 | h = wid->height(); | 2553 | h = wid->height(); |
2539 | list.clear(); | 2554 | list.clear(); |
2540 | list << QString::number( x ); | 2555 | list << QString::number( x ); |
2541 | list << QString::number( y ); | 2556 | list << QString::number( y ); |
2542 | list << QString::number( w ); | 2557 | list << QString::number( w ); |
2543 | list << QString::number( h ); | 2558 | list << QString::number( h ); |
2544 | config->writeEntry("MainLayout",list ); | 2559 | config->writeEntry("MainLayout",list ); |
2545 | 2560 | ||
2546 | wid = mEventEditor; | 2561 | wid = mEventEditor; |
2547 | x = wid->geometry().x(); | 2562 | x = wid->geometry().x(); |
2548 | y = wid->geometry().y(); | 2563 | y = wid->geometry().y(); |
2549 | w = wid->width(); | 2564 | w = wid->width(); |
2550 | h = wid->height(); | 2565 | h = wid->height(); |
2551 | list.clear(); | 2566 | list.clear(); |
2552 | list << QString::number( x ); | 2567 | list << QString::number( x ); |
2553 | list << QString::number( y ); | 2568 | list << QString::number( y ); |
2554 | list << QString::number( w ); | 2569 | list << QString::number( w ); |
2555 | list << QString::number( h ); | 2570 | list << QString::number( h ); |
2556 | config->writeEntry("EditEventLayout",list ); | 2571 | config->writeEntry("EditEventLayout",list ); |
2557 | 2572 | ||
2558 | wid = mTodoEditor; | 2573 | wid = mTodoEditor; |
2559 | x = wid->geometry().x(); | 2574 | x = wid->geometry().x(); |
2560 | y = wid->geometry().y(); | 2575 | y = wid->geometry().y(); |
2561 | w = wid->width(); | 2576 | w = wid->width(); |
2562 | h = wid->height(); | 2577 | h = wid->height(); |
2563 | list.clear(); | 2578 | list.clear(); |
2564 | list << QString::number( x ); | 2579 | list << QString::number( x ); |
2565 | list << QString::number( y ); | 2580 | list << QString::number( y ); |
2566 | list << QString::number( w ); | 2581 | list << QString::number( w ); |
2567 | list << QString::number( h ); | 2582 | list << QString::number( h ); |
2568 | config->writeEntry("EditTodoLayout",list ); | 2583 | config->writeEntry("EditTodoLayout",list ); |
2569 | wid = getEventViewerDialog(); | 2584 | wid = getEventViewerDialog(); |
2570 | x = wid->geometry().x(); | 2585 | x = wid->geometry().x(); |
2571 | y = wid->geometry().y(); | 2586 | y = wid->geometry().y(); |
2572 | w = wid->width(); | 2587 | w = wid->width(); |
2573 | h = wid->height(); | 2588 | h = wid->height(); |
2574 | list.clear(); | 2589 | list.clear(); |
2575 | list << QString::number( x ); | 2590 | list << QString::number( x ); |
2576 | list << QString::number( y ); | 2591 | list << QString::number( y ); |
2577 | list << QString::number( w ); | 2592 | list << QString::number( w ); |
2578 | list << QString::number( h ); | 2593 | list << QString::number( h ); |
2579 | config->writeEntry("ViewerLayout",list ); | 2594 | config->writeEntry("ViewerLayout",list ); |
2580 | wid = mDialogManager->getSearchDialog(); | 2595 | wid = mDialogManager->getSearchDialog(); |
2581 | if ( wid ) { | 2596 | if ( wid ) { |
2582 | x = wid->geometry().x(); | 2597 | x = wid->geometry().x(); |
2583 | y = wid->geometry().y(); | 2598 | y = wid->geometry().y(); |
2584 | w = wid->width(); | 2599 | w = wid->width(); |
2585 | h = wid->height(); | 2600 | h = wid->height(); |
2586 | list.clear(); | 2601 | list.clear(); |
2587 | list << QString::number( x ); | 2602 | list << QString::number( x ); |
2588 | list << QString::number( y ); | 2603 | list << QString::number( y ); |
2589 | list << QString::number( w ); | 2604 | list << QString::number( w ); |
2590 | list << QString::number( h ); | 2605 | list << QString::number( h ); |
2591 | config->writeEntry("SearchLayout",list ); | 2606 | config->writeEntry("SearchLayout",list ); |
2592 | } | 2607 | } |
2593 | #endif | 2608 | #endif |
2594 | 2609 | ||
2595 | 2610 | ||
2596 | config->sync(); | 2611 | config->sync(); |
2597 | } | 2612 | } |
2598 | 2613 | ||
2599 | void CalendarView::readFilterSettings(KConfig *config) | 2614 | void CalendarView::readFilterSettings(KConfig *config) |
2600 | { | 2615 | { |
2601 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2616 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2602 | 2617 | ||
2603 | mFilters.clear(); | 2618 | mFilters.clear(); |
2604 | 2619 | ||
2605 | config->setGroup("General"); | 2620 | config->setGroup("General"); |
2606 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2621 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2607 | 2622 | ||
2608 | QStringList::ConstIterator it = filterList.begin(); | 2623 | QStringList::ConstIterator it = filterList.begin(); |
2609 | QStringList::ConstIterator end = filterList.end(); | 2624 | QStringList::ConstIterator end = filterList.end(); |
2610 | while(it != end) { | 2625 | while(it != end) { |
2611 | // kdDebug() << " filter: " << (*it) << endl; | 2626 | // kdDebug() << " filter: " << (*it) << endl; |
2612 | 2627 | ||
2613 | CalFilter *filter; | 2628 | CalFilter *filter; |
2614 | filter = new CalFilter(*it); | 2629 | filter = new CalFilter(*it); |
2615 | config->setGroup("Filter_" + (*it).utf8()); | 2630 | config->setGroup("Filter_" + (*it).utf8()); |
2616 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2631 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2617 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2632 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2618 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2633 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2619 | mFilters.append(filter); | 2634 | mFilters.append(filter); |
2620 | 2635 | ||
2621 | ++it; | 2636 | ++it; |
2622 | } | 2637 | } |
2623 | 2638 | ||
2624 | if (mFilters.count() == 0) { | 2639 | if (mFilters.count() == 0) { |
2625 | CalFilter *filter = new CalFilter(i18n("Default")); | 2640 | CalFilter *filter = new CalFilter(i18n("Default")); |
2626 | mFilters.append(filter); | 2641 | mFilters.append(filter); |
2627 | } | 2642 | } |
2628 | mFilterView->updateFilters(); | 2643 | mFilterView->updateFilters(); |
2629 | config->setGroup("FilterView"); | 2644 | config->setGroup("FilterView"); |
2630 | 2645 | ||
2631 | mFilterView->blockSignals(true); | 2646 | mFilterView->blockSignals(true); |
2632 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2647 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2633 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2648 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2634 | mFilterView->blockSignals(false); | 2649 | mFilterView->blockSignals(false); |
2635 | // We do it manually to avoid it being done twice by the above calls | 2650 | // We do it manually to avoid it being done twice by the above calls |
2636 | updateFilter(); | 2651 | updateFilter(); |
2637 | } | 2652 | } |
2638 | 2653 | ||
2639 | void CalendarView::writeFilterSettings(KConfig *config) | 2654 | void CalendarView::writeFilterSettings(KConfig *config) |
2640 | { | 2655 | { |
2641 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2656 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2642 | 2657 | ||
2643 | QStringList filterList; | 2658 | QStringList filterList; |
2644 | 2659 | ||
2645 | CalFilter *filter = mFilters.first(); | 2660 | CalFilter *filter = mFilters.first(); |
2646 | while(filter) { | 2661 | while(filter) { |
2647 | // kdDebug() << " fn: " << filter->name() << endl; | 2662 | // kdDebug() << " fn: " << filter->name() << endl; |
2648 | filterList << filter->name(); | 2663 | filterList << filter->name(); |
2649 | config->setGroup("Filter_" + filter->name().utf8()); | 2664 | config->setGroup("Filter_" + filter->name().utf8()); |
2650 | config->writeEntry("Criteria",filter->criteria()); | 2665 | config->writeEntry("Criteria",filter->criteria()); |
2651 | config->writeEntry("CategoryList",filter->categoryList()); | 2666 | config->writeEntry("CategoryList",filter->categoryList()); |
2652 | filter = mFilters.next(); | 2667 | filter = mFilters.next(); |
2653 | } | 2668 | } |
2654 | config->setGroup("General"); | 2669 | config->setGroup("General"); |
2655 | config->writeEntry("CalendarFilters",filterList); | 2670 | config->writeEntry("CalendarFilters",filterList); |
2656 | 2671 | ||
2657 | config->setGroup("FilterView"); | 2672 | config->setGroup("FilterView"); |
2658 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2673 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2659 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2674 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2660 | } | 2675 | } |
2661 | 2676 | ||
2662 | 2677 | ||
2663 | void CalendarView::goToday() | 2678 | void CalendarView::goToday() |
2664 | { | 2679 | { |
2665 | if ( mViewManager->currentView()->isMonthView() ) | 2680 | if ( mViewManager->currentView()->isMonthView() ) |
2666 | mNavigator->selectTodayMonth(); | 2681 | mNavigator->selectTodayMonth(); |
2667 | else | 2682 | else |
2668 | mNavigator->selectToday(); | 2683 | mNavigator->selectToday(); |
2669 | } | 2684 | } |
2670 | 2685 | ||
2671 | void CalendarView::goNext() | 2686 | void CalendarView::goNext() |
2672 | { | 2687 | { |
2673 | mNavigator->selectNext(); | 2688 | mNavigator->selectNext(); |
2674 | } | 2689 | } |
2675 | 2690 | ||
2676 | void CalendarView::goPrevious() | 2691 | void CalendarView::goPrevious() |
2677 | { | 2692 | { |
2678 | mNavigator->selectPrevious(); | 2693 | mNavigator->selectPrevious(); |
2679 | } | 2694 | } |
2680 | void CalendarView::goNextMonth() | 2695 | void CalendarView::goNextMonth() |
2681 | { | 2696 | { |
2682 | mNavigator->selectNextMonth(); | 2697 | mNavigator->selectNextMonth(); |
2683 | } | 2698 | } |
2684 | 2699 | ||
2685 | void CalendarView::goPreviousMonth() | 2700 | void CalendarView::goPreviousMonth() |
2686 | { | 2701 | { |
2687 | mNavigator->selectPreviousMonth(); | 2702 | mNavigator->selectPreviousMonth(); |
2688 | } | 2703 | } |
2689 | 2704 | ||
2690 | void CalendarView::updateConfig() | 2705 | void CalendarView::updateConfig() |
2691 | { | 2706 | { |
2692 | if ( KOPrefs::instance()->mUseAppColors ) | 2707 | if ( KOPrefs::instance()->mUseAppColors ) |
2693 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2708 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2694 | emit configChanged(); | 2709 | emit configChanged(); |
2695 | mTodoList->updateConfig(); | 2710 | mTodoList->updateConfig(); |
2696 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2711 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2697 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2712 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2698 | // To make the "fill window" configurations work | 2713 | // To make the "fill window" configurations work |
2699 | //mViewManager->raiseCurrentView(); | 2714 | //mViewManager->raiseCurrentView(); |
2700 | } | 2715 | } |
2701 | 2716 | ||
2702 | 2717 | ||
2703 | void CalendarView::eventChanged(Event *event) | 2718 | void CalendarView::eventChanged(Event *event) |
2704 | { | 2719 | { |
2705 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2720 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2706 | //updateUnmanagedViews(); | 2721 | //updateUnmanagedViews(); |
2707 | } | 2722 | } |
2708 | 2723 | ||
2709 | void CalendarView::eventAdded(Event *event) | 2724 | void CalendarView::eventAdded(Event *event) |
2710 | { | 2725 | { |
2711 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2726 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2712 | } | 2727 | } |
2713 | 2728 | ||
2714 | void CalendarView::eventToBeDeleted(Event *) | 2729 | void CalendarView::eventToBeDeleted(Event *) |
2715 | { | 2730 | { |
2716 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2731 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2717 | } | 2732 | } |
2718 | 2733 | ||
2719 | void CalendarView::eventDeleted() | 2734 | void CalendarView::eventDeleted() |
2720 | { | 2735 | { |
2721 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2736 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2722 | } | 2737 | } |
2723 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2738 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2724 | { | 2739 | { |
2725 | changeIncidenceDisplay((Incidence *)which, action); | 2740 | changeIncidenceDisplay((Incidence *)which, action); |
2726 | mDateNavigator->updateView(); //LR | 2741 | mDateNavigator->updateView(); //LR |
2727 | //mDialogManager->updateSearchDialog(); | 2742 | //mDialogManager->updateSearchDialog(); |
2728 | 2743 | ||
2729 | if (which) { | 2744 | if (which) { |
2730 | mViewManager->updateWNview(); | 2745 | mViewManager->updateWNview(); |
2731 | //mTodoList->updateView(); | 2746 | //mTodoList->updateView(); |
2732 | } | 2747 | } |
2733 | 2748 | ||
2734 | } | 2749 | } |
2735 | 2750 | ||
2736 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2751 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2737 | { | 2752 | { |
2738 | updateUnmanagedViews(); | 2753 | updateUnmanagedViews(); |
2739 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2754 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2740 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2755 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2741 | mCalendar->checkAlarmForIncidence( 0, true ); | 2756 | mCalendar->checkAlarmForIncidence( 0, true ); |
2742 | if ( mEventViewerDialog ) | 2757 | if ( mEventViewerDialog ) |
2743 | mEventViewerDialog->hide(); | 2758 | mEventViewerDialog->hide(); |
2744 | } | 2759 | } |
2745 | else | 2760 | else |
2746 | mCalendar->checkAlarmForIncidence( which , false ); | 2761 | mCalendar->checkAlarmForIncidence( which , false ); |
2747 | } | 2762 | } |
2748 | 2763 | ||
2749 | // most of the changeEventDisplays() right now just call the view's | 2764 | // most of the changeEventDisplays() right now just call the view's |
2750 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2765 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2751 | void CalendarView::changeEventDisplay(Event *which, int action) | 2766 | void CalendarView::changeEventDisplay(Event *which, int action) |
2752 | { | 2767 | { |
2753 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2768 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2754 | changeIncidenceDisplay((Incidence *)which, action); | 2769 | changeIncidenceDisplay((Incidence *)which, action); |
2755 | static bool clearallviews = false; | 2770 | static bool clearallviews = false; |
2756 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2771 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2757 | if ( clearallviews ) { | 2772 | if ( clearallviews ) { |
2758 | clearAllViews(); | 2773 | clearAllViews(); |
2759 | clearallviews = false; | 2774 | clearallviews = false; |
2760 | } | 2775 | } |
2761 | return; | 2776 | return; |
2762 | } | 2777 | } |
2763 | clearallviews = true; | 2778 | clearallviews = true; |
2764 | mDateNavigator->updateView(); | 2779 | mDateNavigator->updateView(); |
2765 | //mDialogManager->updateSearchDialog(); | 2780 | //mDialogManager->updateSearchDialog(); |
2766 | if (which) { | 2781 | if (which) { |
2767 | // If there is an event view visible update the display | 2782 | // If there is an event view visible update the display |
2768 | mViewManager->currentView()->changeEventDisplay(which,action); | 2783 | mViewManager->currentView()->changeEventDisplay(which,action); |
2769 | // TODO: check, if update needed | 2784 | // TODO: check, if update needed |
2770 | // if (which->getTodoStatus()) { | 2785 | // if (which->getTodoStatus()) { |
2771 | mTodoList->updateView(); | 2786 | mTodoList->updateView(); |
2772 | if ( action != KOGlobals::EVENTDELETED ) { | 2787 | if ( action != KOGlobals::EVENTDELETED ) { |
2773 | mConflictingEvent = which ; | 2788 | mConflictingEvent = which ; |
2774 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); | 2789 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); |
2775 | } | 2790 | } |
2776 | // } | 2791 | // } |
2777 | } else { | 2792 | } else { |
2778 | mViewManager->currentView()->updateView(); | 2793 | mViewManager->currentView()->updateView(); |
2779 | } | 2794 | } |
2780 | } | 2795 | } |
2781 | void CalendarView::checkConflictForEvent() | 2796 | void CalendarView::checkConflictForEvent() |
2782 | { | 2797 | { |
2783 | 2798 | ||
2784 | if (!KOPrefs::instance()->mConfirm) | 2799 | if (!KOPrefs::instance()->mConfirm) |
2785 | return; | 2800 | return; |
2786 | if ( ! mConflictingEvent ) return; | 2801 | if ( ! mConflictingEvent ) return; |
2787 | if ( mConflictingEvent->doesFloat() ) { | 2802 | if ( mConflictingEvent->doesFloat() ) { |
2788 | mConflictingEvent = 0; | 2803 | mConflictingEvent = 0; |
2789 | return; | 2804 | return; |
2790 | } | 2805 | } |
2791 | QPtrList<Event> testlist = mCalendar->events(); | 2806 | QPtrList<Event> testlist = mCalendar->events(); |
2792 | Event * test = testlist.first(); | 2807 | Event * test = testlist.first(); |
2793 | QDateTime conflict; | 2808 | QDateTime conflict; |
2794 | QDateTime retVal; | 2809 | QDateTime retVal; |
2795 | bool found = false; | 2810 | bool found = false; |
2796 | Event * cE = 0; | 2811 | Event * cE = 0; |
2812 | QDateTime current = QDateTime::currentDateTime(); | ||
2797 | while ( test ) { | 2813 | while ( test ) { |
2798 | if ( !test->doesFloat() ) { | 2814 | if ( !test->doesFloat() ) { |
2799 | if ( mConflictingEvent->isOverlapping ( test, &retVal, true ) ) { | 2815 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
2800 | if ( ! found ) { | 2816 | if ( ! found ) { |
2801 | conflict = retVal; | 2817 | conflict = retVal; |
2802 | cE = test; | 2818 | cE = test; |
2803 | } else { | 2819 | } else { |
2804 | if ( retVal < conflict ) { | 2820 | if ( retVal < conflict ) { |
2805 | conflict = retVal; | 2821 | conflict = retVal; |
2806 | cE = test; | 2822 | cE = test; |
2807 | } | 2823 | } |
2808 | } | 2824 | } |
2809 | found = true; | 2825 | found = true; |
2810 | } | 2826 | } |
2811 | } | 2827 | } |
2812 | test = testlist.next(); | 2828 | test = testlist.next(); |
2813 | } | 2829 | } |
2814 | if ( found ) { | 2830 | if ( found ) { |
2815 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 2831 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
2816 | qApp->processEvents(); | 2832 | qApp->processEvents(); |
2817 | int km = KMessageBox::warningContinueCancel(this,mess, | 2833 | int km = KMessageBox::warningContinueCancel(this,mess, |
2818 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | 2834 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); |
2819 | if ( km != KMessageBox::Continue ) | 2835 | if ( km != KMessageBox::Continue ) |
2820 | return; | 2836 | return; |
2821 | 2837 | ||
2822 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 2838 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
2823 | mViewManager->showDayView(); | 2839 | mViewManager->showDayView(); |
2824 | mNavigator->slotDaySelect( conflict.date() ); | 2840 | mNavigator->slotDaySelect( conflict.date() ); |
2825 | int hour = conflict.time().hour(); | 2841 | int hour = conflict.time().hour(); |
2826 | mViewManager->agendaView()->setStartHour( hour ); | 2842 | mViewManager->agendaView()->setStartHour( hour ); |
2827 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 2843 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
2828 | return; | 2844 | return; |
2829 | } | 2845 | } |
2830 | 2846 | ||
2831 | return; | 2847 | return; |
2832 | 2848 | ||
2833 | } | 2849 | } |
2834 | 2850 | ||
2835 | void CalendarView::updateTodoViews() | 2851 | void CalendarView::updateTodoViews() |
2836 | { | 2852 | { |
2837 | mTodoList->updateView(); | 2853 | mTodoList->updateView(); |
2838 | mViewManager->currentView()->updateView(); | 2854 | mViewManager->currentView()->updateView(); |
2839 | 2855 | ||
2840 | } | 2856 | } |
2841 | 2857 | ||
2842 | 2858 | ||
2843 | 2859 | ||
2844 | void CalendarView::clearAllViews() | 2860 | void CalendarView::clearAllViews() |
2845 | { | 2861 | { |
2846 | mTodoList->clearList(); | 2862 | mTodoList->clearList(); |
2847 | mViewManager->clearAllViews(); | 2863 | mViewManager->clearAllViews(); |
2848 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2864 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2849 | if ( sd ) { | 2865 | if ( sd ) { |
2850 | KOListView* kol = sd->listview(); | 2866 | KOListView* kol = sd->listview(); |
2851 | if ( kol ) | 2867 | if ( kol ) |
2852 | kol->clearList(); | 2868 | kol->clearList(); |
2853 | } | 2869 | } |
2854 | } | 2870 | } |
2855 | void CalendarView::updateView() | 2871 | void CalendarView::updateView() |
2856 | { | 2872 | { |
2857 | static bool clearallviews = false; | 2873 | static bool clearallviews = false; |
2858 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2874 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2859 | if ( clearallviews ) { | 2875 | if ( clearallviews ) { |
2860 | clearAllViews(); | 2876 | clearAllViews(); |
2861 | clearallviews = false; | 2877 | clearallviews = false; |
2862 | } | 2878 | } |
2863 | return; | 2879 | return; |
2864 | } | 2880 | } |
2865 | clearallviews = true; | 2881 | clearallviews = true; |
2866 | DateList tmpList = mNavigator->selectedDates(); | 2882 | DateList tmpList = mNavigator->selectedDates(); |
2867 | 2883 | ||
2868 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2884 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2869 | mTodoList->updateView(); | 2885 | mTodoList->updateView(); |
2870 | // We assume that the navigator only selects consecutive days. | 2886 | // We assume that the navigator only selects consecutive days. |
2871 | updateView( tmpList.first(), tmpList.last() ); | 2887 | updateView( tmpList.first(), tmpList.last() ); |
2872 | } | 2888 | } |
2873 | 2889 | ||
2874 | void CalendarView::updateUnmanagedViews() | 2890 | void CalendarView::updateUnmanagedViews() |
2875 | { | 2891 | { |
2876 | mDateNavigator->updateDayMatrix(); | 2892 | mDateNavigator->updateDayMatrix(); |
2877 | } | 2893 | } |
2878 | 2894 | ||
2879 | int CalendarView::msgItemDelete(const QString name) | 2895 | int CalendarView::msgItemDelete(const QString name) |
2880 | { | 2896 | { |
2881 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2897 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2882 | i18n("This item will be\npermanently deleted."), | 2898 | i18n("This item will be\npermanently deleted."), |
2883 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2899 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2884 | } | 2900 | } |
2885 | 2901 | ||
2886 | 2902 | ||
2887 | void CalendarView::edit_cut() | 2903 | void CalendarView::edit_cut() |
2888 | { | 2904 | { |
2889 | Event *anEvent=0; | 2905 | Event *anEvent=0; |
2890 | 2906 | ||
2891 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2907 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2892 | 2908 | ||
2893 | if (mViewManager->currentView()->isEventView()) { | 2909 | if (mViewManager->currentView()->isEventView()) { |
2894 | if ( incidence && incidence->typeID() == eventID ) { | 2910 | if ( incidence && incidence->typeID() == eventID ) { |
2895 | anEvent = static_cast<Event *>(incidence); | 2911 | anEvent = static_cast<Event *>(incidence); |
2896 | } | 2912 | } |
2897 | } | 2913 | } |
2898 | 2914 | ||
2899 | if (!anEvent) { | 2915 | if (!anEvent) { |
2900 | KNotifyClient::beep(); | 2916 | KNotifyClient::beep(); |
2901 | return; | 2917 | return; |
2902 | } | 2918 | } |
2903 | DndFactory factory( mCalendar ); | 2919 | DndFactory factory( mCalendar ); |
2904 | factory.cutIncidence(anEvent); | 2920 | factory.cutIncidence(anEvent); |
2905 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2921 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2906 | } | 2922 | } |
2907 | 2923 | ||
2908 | void CalendarView::edit_copy() | 2924 | void CalendarView::edit_copy() |
2909 | { | 2925 | { |
2910 | Event *anEvent=0; | 2926 | Event *anEvent=0; |
2911 | 2927 | ||
2912 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2928 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2913 | 2929 | ||
2914 | if (mViewManager->currentView()->isEventView()) { | 2930 | if (mViewManager->currentView()->isEventView()) { |
2915 | if ( incidence && incidence->typeID() == eventID ) { | 2931 | if ( incidence && incidence->typeID() == eventID ) { |
2916 | anEvent = static_cast<Event *>(incidence); | 2932 | anEvent = static_cast<Event *>(incidence); |
2917 | } | 2933 | } |
2918 | } | 2934 | } |
2919 | 2935 | ||
2920 | if (!anEvent) { | 2936 | if (!anEvent) { |
2921 | KNotifyClient::beep(); | 2937 | KNotifyClient::beep(); |
2922 | return; | 2938 | return; |
2923 | } | 2939 | } |
2924 | DndFactory factory( mCalendar ); | 2940 | DndFactory factory( mCalendar ); |
2925 | factory.copyIncidence(anEvent); | 2941 | factory.copyIncidence(anEvent); |
2926 | } | 2942 | } |
2927 | 2943 | ||
2928 | void CalendarView::edit_paste() | 2944 | void CalendarView::edit_paste() |
2929 | { | 2945 | { |
2930 | QDate date = mNavigator->selectedDates().first(); | 2946 | QDate date = mNavigator->selectedDates().first(); |
2931 | 2947 | ||
2932 | DndFactory factory( mCalendar ); | 2948 | DndFactory factory( mCalendar ); |
2933 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2949 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2934 | 2950 | ||
2935 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2951 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2936 | } | 2952 | } |
2937 | void CalendarView::edit_global_options() | 2953 | void CalendarView::edit_global_options() |
2938 | { | 2954 | { |
2939 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2955 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2940 | emit save(); | 2956 | emit save(); |
2941 | emit saveStopTimer(); | 2957 | emit saveStopTimer(); |
2942 | mDialogManager->showGlobalOptionsDialog(); | 2958 | mDialogManager->showGlobalOptionsDialog(); |
2943 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2959 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2944 | emit saveStopTimer(); | 2960 | emit saveStopTimer(); |
2945 | 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!"), | 2961 | 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!"), |
2946 | i18n("Timezone settings"),i18n("Reload"))) { | 2962 | i18n("Timezone settings"),i18n("Reload"))) { |
2947 | qDebug("KO: TZ reload cancelled "); | 2963 | qDebug("KO: TZ reload cancelled "); |
2948 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2964 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2949 | return; | 2965 | return; |
2950 | } | 2966 | } |
2951 | qDebug("KO: Timezone change "); | 2967 | qDebug("KO: Timezone change "); |
2952 | loadCalendars(); | 2968 | loadCalendars(); |
2953 | setModified(true); | 2969 | setModified(true); |
2954 | } | 2970 | } |
2955 | else | 2971 | else |
2956 | qDebug("KO: No tz change "); | 2972 | qDebug("KO: No tz change "); |
2957 | } | 2973 | } |
2958 | void CalendarView::edit_options() | 2974 | void CalendarView::edit_options() |
2959 | { | 2975 | { |
2960 | mDialogManager->showOptionsDialog(); | 2976 | mDialogManager->showOptionsDialog(); |
2961 | } | 2977 | } |
2962 | 2978 | ||
2963 | 2979 | ||
2964 | void CalendarView::slotSelectPickerDate( QDate d) | 2980 | void CalendarView::slotSelectPickerDate( QDate d) |
2965 | { | 2981 | { |
2966 | mDateFrame->hide(); | 2982 | mDateFrame->hide(); |
2967 | if ( mDatePickerMode == 1 ) { | 2983 | if ( mDatePickerMode == 1 ) { |
2968 | mNavigator->slotDaySelect( d ); | 2984 | mNavigator->slotDaySelect( d ); |
2969 | } else if ( mDatePickerMode == 2 ) { | 2985 | } else if ( mDatePickerMode == 2 ) { |
2970 | if ( mMoveIncidence->typeID() == todoID ) { | 2986 | if ( mMoveIncidence->typeID() == todoID ) { |
2971 | Todo * to = (Todo *) mMoveIncidence; | 2987 | Todo * to = (Todo *) mMoveIncidence; |
2972 | QTime tim; | 2988 | QTime tim; |
2973 | int len = 0; | 2989 | int len = 0; |
2974 | if ( to->hasStartDate() && to->hasDueDate() ) | 2990 | if ( to->hasStartDate() && to->hasDueDate() ) |
2975 | len = to->dtStart().secsTo( to->dtDue()); | 2991 | len = to->dtStart().secsTo( to->dtDue()); |
2976 | if ( to->hasDueDate() ) | 2992 | if ( to->hasDueDate() ) |
2977 | tim = to->dtDue().time(); | 2993 | tim = to->dtDue().time(); |
2978 | else { | 2994 | else { |
2979 | tim = QTime ( 0,0,0 ); | 2995 | tim = QTime ( 0,0,0 ); |
2980 | to->setFloats( true ); | 2996 | to->setFloats( true ); |
2981 | to->setHasDueDate( true ); | 2997 | to->setHasDueDate( true ); |
2982 | } | 2998 | } |
2983 | QDateTime dt ( d,tim ); | 2999 | QDateTime dt ( d,tim ); |
2984 | to->setDtDue( dt ); | 3000 | to->setDtDue( dt ); |
2985 | 3001 | ||
2986 | if ( to->hasStartDate() ) { | 3002 | if ( to->hasStartDate() ) { |
2987 | if ( len>0 ) | 3003 | if ( len>0 ) |
2988 | to->setDtStart(to->dtDue().addSecs( -len )); | 3004 | to->setDtStart(to->dtDue().addSecs( -len )); |
2989 | else | 3005 | else |
2990 | if (to->dtStart() > to->dtDue() ) | 3006 | if (to->dtStart() > to->dtDue() ) |
2991 | to->setDtStart(to->dtDue().addDays( -3 )); | 3007 | to->setDtStart(to->dtDue().addDays( -3 )); |
2992 | } | 3008 | } |
2993 | 3009 | ||
2994 | todoChanged( to ); | 3010 | todoChanged( to ); |
2995 | } else if ( mMoveIncidence->typeID() == eventID ) { | 3011 | } else if ( mMoveIncidence->typeID() == eventID ) { |
2996 | if ( mMoveIncidence->doesRecur() ) { | 3012 | if ( mMoveIncidence->doesRecur() ) { |
2997 | #if 0 | 3013 | #if 0 |
2998 | // PENDING implement this | 3014 | // PENDING implement this |
2999 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 3015 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3000 | mCalendar()->addIncidence( newInc ); | 3016 | mCalendar()->addIncidence( newInc ); |
3001 | if ( mMoveIncidence->typeID() == todoID ) | 3017 | if ( mMoveIncidence->typeID() == todoID ) |
3002 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 3018 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3003 | else | 3019 | else |
3004 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 3020 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3005 | mMoveIncidence = newInc; | 3021 | mMoveIncidence = newInc; |
3006 | 3022 | ||
3007 | #endif | 3023 | #endif |
3008 | } | 3024 | } |
3009 | QTime tim = mMoveIncidence->dtStart().time(); | 3025 | QTime tim = mMoveIncidence->dtStart().time(); |
3010 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 3026 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3011 | QDateTime dt ( d,tim ); | 3027 | QDateTime dt ( d,tim ); |
3012 | mMoveIncidence->setDtStart( dt ); | 3028 | mMoveIncidence->setDtStart( dt ); |
3013 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 3029 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3014 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 3030 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3015 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3031 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3016 | QTime tim = mMoveIncidence->dtStart().time(); | 3032 | QTime tim = mMoveIncidence->dtStart().time(); |
3017 | QDateTime dt ( d,tim ); | 3033 | QDateTime dt ( d,tim ); |
3018 | mMoveIncidence->setDtStart( dt ); | 3034 | mMoveIncidence->setDtStart( dt ); |
3019 | updateView(); | 3035 | updateView(); |
3020 | } | 3036 | } |
3021 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3037 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3022 | } | 3038 | } |
3023 | } | 3039 | } |
3024 | 3040 | ||
3025 | void CalendarView::removeCategories() | 3041 | void CalendarView::removeCategories() |
3026 | { | 3042 | { |
3027 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3043 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3028 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3044 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3029 | QStringList catIncList; | 3045 | QStringList catIncList; |
3030 | QStringList newCatList; | 3046 | QStringList newCatList; |
3031 | Incidence* inc = incList.first(); | 3047 | Incidence* inc = incList.first(); |
3032 | uint i; | 3048 | uint i; |
3033 | while ( inc ) { | 3049 | while ( inc ) { |
3034 | newCatList.clear(); | 3050 | newCatList.clear(); |
3035 | catIncList = inc->categories() ; | 3051 | catIncList = inc->categories() ; |
3036 | for( i = 0; i< catIncList.count(); ++i ) { | 3052 | for( i = 0; i< catIncList.count(); ++i ) { |
3037 | if ( catList.contains (catIncList[i])) | 3053 | if ( catList.contains (catIncList[i])) |
3038 | newCatList.append( catIncList[i] ); | 3054 | newCatList.append( catIncList[i] ); |
3039 | } | 3055 | } |
3040 | newCatList.sort(); | 3056 | newCatList.sort(); |
3041 | inc->setCategories( newCatList.join(",") ); | 3057 | inc->setCategories( newCatList.join(",") ); |
3042 | inc = incList.next(); | 3058 | inc = incList.next(); |
3043 | } | 3059 | } |
3044 | } | 3060 | } |
3045 | 3061 | ||
3046 | int CalendarView::addCategories() | 3062 | int CalendarView::addCategories() |
3047 | { | 3063 | { |
3048 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3064 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3049 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3065 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3050 | QStringList catIncList; | 3066 | QStringList catIncList; |
3051 | Incidence* inc = incList.first(); | 3067 | Incidence* inc = incList.first(); |
3052 | uint i; | 3068 | uint i; |
3053 | int count = 0; | 3069 | int count = 0; |
3054 | while ( inc ) { | 3070 | while ( inc ) { |
3055 | catIncList = inc->categories() ; | 3071 | catIncList = inc->categories() ; |
3056 | for( i = 0; i< catIncList.count(); ++i ) { | 3072 | for( i = 0; i< catIncList.count(); ++i ) { |
3057 | if ( !catList.contains (catIncList[i])) { | 3073 | if ( !catList.contains (catIncList[i])) { |
3058 | catList.append( catIncList[i] ); | 3074 | catList.append( catIncList[i] ); |
3059 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3075 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3060 | ++count; | 3076 | ++count; |
3061 | } | 3077 | } |
3062 | } | 3078 | } |
3063 | inc = incList.next(); | 3079 | inc = incList.next(); |
3064 | } | 3080 | } |
3065 | catList.sort(); | 3081 | catList.sort(); |
3066 | KOPrefs::instance()->mCustomCategories = catList; | 3082 | KOPrefs::instance()->mCustomCategories = catList; |
3067 | return count; | 3083 | return count; |
3068 | } | 3084 | } |
3069 | 3085 | ||
3070 | void CalendarView::editCategories() | 3086 | void CalendarView::editCategories() |
3071 | { | 3087 | { |
3072 | qDebug("CalendarView::editCategories() "); | 3088 | qDebug("CalendarView::editCategories() "); |
3073 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3089 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3074 | ced.exec(); | 3090 | ced.exec(); |
3075 | } | 3091 | } |
3076 | void CalendarView::manageCategories() | 3092 | void CalendarView::manageCategories() |
3077 | { | 3093 | { |
3078 | KOCatPrefs* cp = new KOCatPrefs(); | 3094 | KOCatPrefs* cp = new KOCatPrefs(); |
3079 | cp->show(); | 3095 | cp->show(); |
3080 | int w =cp->sizeHint().width() ; | 3096 | int w =cp->sizeHint().width() ; |
3081 | int h = cp->sizeHint().height() ; | 3097 | int h = cp->sizeHint().height() ; |
3082 | int dw = QApplication::desktop()->width(); | 3098 | int dw = QApplication::desktop()->width(); |
3083 | int dh = QApplication::desktop()->height(); | 3099 | int dh = QApplication::desktop()->height(); |
3084 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3100 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3085 | if ( !cp->exec() ) { | 3101 | if ( !cp->exec() ) { |
3086 | delete cp; | 3102 | delete cp; |
3087 | return; | 3103 | return; |
3088 | } | 3104 | } |
3089 | int count = 0; | 3105 | int count = 0; |
3090 | if ( cp->addCat() ) { | 3106 | if ( cp->addCat() ) { |
3091 | count = addCategories(); | 3107 | count = addCategories(); |
3092 | if ( count ) { | 3108 | if ( count ) { |
3093 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3109 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3094 | writeSettings(); | 3110 | writeSettings(); |
3095 | } else | 3111 | } else |
3096 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3112 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3097 | } else { | 3113 | } else { |
3098 | removeCategories(); | 3114 | removeCategories(); |
3099 | updateView(); | 3115 | updateView(); |
3100 | } | 3116 | } |
3101 | delete cp; | 3117 | delete cp; |
3102 | } | 3118 | } |
3103 | 3119 | ||
3104 | void CalendarView::beamIncidence(Incidence * Inc) | 3120 | void CalendarView::beamIncidence(Incidence * Inc) |
3105 | { | 3121 | { |
3106 | QPtrList<Incidence> delSel ; | 3122 | QPtrList<Incidence> delSel ; |
3107 | delSel.append(Inc); | 3123 | delSel.append(Inc); |
3108 | beamIncidenceList( delSel ); | 3124 | beamIncidenceList( delSel ); |
3109 | } | 3125 | } |
3110 | void CalendarView::beamCalendar() | 3126 | void CalendarView::beamCalendar() |
3111 | { | 3127 | { |
3112 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3128 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3113 | //qDebug("beamCalendar() "); | 3129 | //qDebug("beamCalendar() "); |
3114 | beamIncidenceList( delSel ); | 3130 | beamIncidenceList( delSel ); |
3115 | } | 3131 | } |
3116 | void CalendarView::beamFilteredCalendar() | 3132 | void CalendarView::beamFilteredCalendar() |
3117 | { | 3133 | { |
3118 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3134 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3119 | //qDebug("beamFilteredCalendar() "); | 3135 | //qDebug("beamFilteredCalendar() "); |
3120 | beamIncidenceList( delSel ); | 3136 | beamIncidenceList( delSel ); |
3121 | } | 3137 | } |
3122 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3138 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3123 | { | 3139 | { |
3124 | 3140 | ||
3125 | KOBeamPrefs beamDialog; | 3141 | KOBeamPrefs beamDialog; |
3126 | if ( beamDialog.exec () == QDialog::Rejected ) | 3142 | if ( beamDialog.exec () == QDialog::Rejected ) |
3127 | return; | 3143 | return; |
3128 | #ifdef DESKTOP_VERSION | 3144 | #ifdef DESKTOP_VERSION |
3129 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3145 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3130 | #else | 3146 | #else |
3131 | QString fn = "/tmp/kopibeamfile"; | 3147 | QString fn = "/tmp/kopibeamfile"; |
3132 | #endif | 3148 | #endif |
3133 | QString mes; | 3149 | QString mes; |
3134 | bool createbup = true; | 3150 | bool createbup = true; |
3135 | if ( createbup ) { | 3151 | if ( createbup ) { |
3136 | QString description = "\n"; | 3152 | QString description = "\n"; |
3137 | CalendarLocal* cal = new CalendarLocal(); | 3153 | CalendarLocal* cal = new CalendarLocal(); |
3138 | if ( beamDialog.beamLocal() ) | 3154 | if ( beamDialog.beamLocal() ) |
3139 | cal->setLocalTime(); | 3155 | cal->setLocalTime(); |
3140 | else | 3156 | else |
3141 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3157 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3142 | Incidence *incidence = delSel.first(); | 3158 | Incidence *incidence = delSel.first(); |
3143 | bool addText = false; | 3159 | bool addText = false; |
3144 | if ( delSel.count() < 10 ) | 3160 | if ( delSel.count() < 10 ) |
3145 | addText = true; | 3161 | addText = true; |
3146 | else { | 3162 | else { |
3147 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3163 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3148 | } | 3164 | } |
3149 | while ( incidence ) { | 3165 | while ( incidence ) { |
3150 | Incidence *in = incidence->clone(); | 3166 | Incidence *in = incidence->clone(); |
3151 | if ( ! in->summary().isEmpty() ) { | 3167 | if ( ! in->summary().isEmpty() ) { |
3152 | in->setDescription(""); | 3168 | in->setDescription(""); |
3153 | } else { | 3169 | } else { |
3154 | in->setSummary( in->description().left(20)); | 3170 | in->setSummary( in->description().left(20)); |
3155 | in->setDescription(""); | 3171 | in->setDescription(""); |
3156 | } | 3172 | } |
3157 | if ( addText ) | 3173 | if ( addText ) |
3158 | description += in->summary() + "\n"; | 3174 | description += in->summary() + "\n"; |
3159 | cal->addIncidence( in ); | 3175 | cal->addIncidence( in ); |
3160 | incidence = delSel.next(); | 3176 | incidence = delSel.next(); |
3161 | } | 3177 | } |
3162 | if ( beamDialog.beamVcal() ) { | 3178 | if ( beamDialog.beamVcal() ) { |
3163 | fn += ".vcs"; | 3179 | fn += ".vcs"; |
3164 | FileStorage storage( cal, fn, new VCalFormat ); | 3180 | FileStorage storage( cal, fn, new VCalFormat ); |
3165 | storage.save(); | 3181 | storage.save(); |
3166 | } else { | 3182 | } else { |
3167 | fn += ".ics"; | 3183 | fn += ".ics"; |
3168 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3184 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3169 | storage.save(); | 3185 | storage.save(); |
3170 | } | 3186 | } |
3171 | delete cal; | 3187 | delete cal; |
3172 | mes = i18n("KO/Pi: Ready for beaming"); | 3188 | mes = i18n("KO/Pi: Ready for beaming"); |
3173 | topLevelWidget()->setCaption(mes); | 3189 | topLevelWidget()->setCaption(mes); |
3174 | KApplication::convert2latin1( fn ); | 3190 | KApplication::convert2latin1( fn ); |
3175 | #ifndef DESKTOP_VERSION | 3191 | #ifndef DESKTOP_VERSION |
3176 | Ir *ir = new Ir( this ); | 3192 | Ir *ir = new Ir( this ); |
3177 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3193 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3178 | ir->send( fn, description, "text/x-vCalendar" ); | 3194 | ir->send( fn, description, "text/x-vCalendar" ); |
3179 | #endif | 3195 | #endif |
3180 | } | 3196 | } |
3181 | } | 3197 | } |
3182 | 3198 | ||
3183 | #ifndef DESKTOP_VERSION | 3199 | #ifndef DESKTOP_VERSION |
3184 | void CalendarView::beamDone( Ir *ir ) | 3200 | void CalendarView::beamDone( Ir *ir ) |
3185 | { | 3201 | { |
3186 | delete ir; | 3202 | delete ir; |
3187 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3203 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3188 | topLevelWidget()->raise(); | 3204 | topLevelWidget()->raise(); |
3189 | } | 3205 | } |
3190 | #else | 3206 | #else |
3191 | void CalendarView::beamDone( Ir *){;} | 3207 | void CalendarView::beamDone( Ir *){;} |
3192 | #endif | 3208 | #endif |
3193 | void CalendarView::moveIncidence(Incidence * inc ) | 3209 | void CalendarView::moveIncidence(Incidence * inc ) |
3194 | { | 3210 | { |
3195 | if ( !inc ) return; | 3211 | if ( !inc ) return; |
3196 | showDatePickerPopup(); | 3212 | showDatePickerPopup(); |
3197 | mDatePickerMode = 2; | 3213 | mDatePickerMode = 2; |
3198 | mMoveIncidence = inc ; | 3214 | mMoveIncidence = inc ; |
3199 | QDate da; | 3215 | QDate da; |
3200 | if ( mMoveIncidence->typeID() == todoID ) { | 3216 | if ( mMoveIncidence->typeID() == todoID ) { |
3201 | Todo * to = (Todo *) mMoveIncidence; | 3217 | Todo * to = (Todo *) mMoveIncidence; |
3202 | if ( to->hasDueDate() ) | 3218 | if ( to->hasDueDate() ) |
3203 | da = to->dtDue().date(); | 3219 | da = to->dtDue().date(); |
3204 | else | 3220 | else |
3205 | da = QDate::currentDate(); | 3221 | da = QDate::currentDate(); |
3206 | } else { | 3222 | } else { |
3207 | da = mMoveIncidence->dtStart().date(); | 3223 | da = mMoveIncidence->dtStart().date(); |
3208 | } | 3224 | } |
3209 | //PENDING set date for recurring incidence to date of recurrence | 3225 | //PENDING set date for recurring incidence to date of recurrence |
3210 | //mMoveIncidenceOldDate; | 3226 | //mMoveIncidenceOldDate; |
3211 | mDatePicker->setDate( da ); | 3227 | mDatePicker->setDate( da ); |
3212 | } | 3228 | } |
3213 | void CalendarView::showDatePickerPopup() | 3229 | void CalendarView::showDatePickerPopup() |
3214 | { | 3230 | { |
3215 | if ( mDateFrame->isVisible() ) | 3231 | if ( mDateFrame->isVisible() ) |
3216 | mDateFrame->hide(); | 3232 | mDateFrame->hide(); |
3217 | else { | 3233 | else { |
3218 | int offX = 0, offY = 0; | 3234 | int offX = 0, offY = 0; |
3219 | #ifdef DESKTOP_VERSION | 3235 | #ifdef DESKTOP_VERSION |
3220 | int w =mDatePicker->sizeHint().width() ; | 3236 | int w =mDatePicker->sizeHint().width() ; |
3221 | int h = mDatePicker->sizeHint().height() ; | 3237 | int h = mDatePicker->sizeHint().height() ; |
3222 | int dw = topLevelWidget()->width(); | 3238 | int dw = topLevelWidget()->width(); |
3223 | int dh = topLevelWidget()->height(); | 3239 | int dh = topLevelWidget()->height(); |
3224 | offX = topLevelWidget()->x(); | 3240 | offX = topLevelWidget()->x(); |
3225 | offY = topLevelWidget()->y(); | 3241 | offY = topLevelWidget()->y(); |
3226 | #else | 3242 | #else |
3227 | int w =mDatePicker->sizeHint().width() ; | 3243 | int w =mDatePicker->sizeHint().width() ; |
3228 | int h = mDatePicker->sizeHint().height() ; | 3244 | int h = mDatePicker->sizeHint().height() ; |
3229 | int dw = QApplication::desktop()->width(); | 3245 | int dw = QApplication::desktop()->width(); |
3230 | int dh = QApplication::desktop()->height(); | 3246 | int dh = QApplication::desktop()->height(); |
3231 | #endif | 3247 | #endif |
3232 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3248 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3233 | mDateFrame->show(); | 3249 | mDateFrame->show(); |
3234 | } | 3250 | } |
3235 | } | 3251 | } |
3236 | void CalendarView::showDatePicker( ) | 3252 | void CalendarView::showDatePicker( ) |
3237 | { | 3253 | { |
3238 | showDatePickerPopup(); | 3254 | showDatePickerPopup(); |
3239 | mDatePickerMode = 1; | 3255 | mDatePickerMode = 1; |
3240 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3256 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3241 | } | 3257 | } |
3242 | 3258 | ||
3243 | void CalendarView::showEventEditor() | 3259 | void CalendarView::showEventEditor() |
3244 | { | 3260 | { |
3245 | #ifdef DESKTOP_VERSION | 3261 | #ifdef DESKTOP_VERSION |
3246 | int x,y,w,h; | 3262 | int x,y,w,h; |
3247 | x = mEventEditor->geometry().x(); | 3263 | x = mEventEditor->geometry().x(); |
3248 | y = mEventEditor->geometry().y(); | 3264 | y = mEventEditor->geometry().y(); |
3249 | w = mEventEditor->width(); | 3265 | w = mEventEditor->width(); |
3250 | h = mEventEditor->height(); | 3266 | h = mEventEditor->height(); |
3251 | mEventEditor->show(); | 3267 | mEventEditor->show(); |
3252 | mEventEditor->setGeometry(x,y,w,h); | 3268 | mEventEditor->setGeometry(x,y,w,h); |
3253 | #else | 3269 | #else |
3254 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3270 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3255 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3271 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3256 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3272 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3257 | qApp->processEvents(); | 3273 | qApp->processEvents(); |
3258 | delete mEventEditor; | 3274 | delete mEventEditor; |
3259 | mEventEditor = mDialogManager->getEventEditor(); | 3275 | mEventEditor = mDialogManager->getEventEditor(); |
3260 | topLevelWidget()->setCaption( i18n("") ); | 3276 | topLevelWidget()->setCaption( i18n("") ); |
3261 | } | 3277 | } |
3262 | mEventEditor->showMaximized(); | 3278 | mEventEditor->showMaximized(); |
3263 | #endif | 3279 | #endif |
3264 | } | 3280 | } |
3265 | void CalendarView::showTodoEditor() | 3281 | void CalendarView::showTodoEditor() |
3266 | { | 3282 | { |
3267 | #ifdef DESKTOP_VERSION | 3283 | #ifdef DESKTOP_VERSION |
3268 | int x,y,w,h; | 3284 | int x,y,w,h; |
3269 | x = mTodoEditor->geometry().x(); | 3285 | x = mTodoEditor->geometry().x(); |
3270 | y = mTodoEditor->geometry().y(); | 3286 | y = mTodoEditor->geometry().y(); |
3271 | w = mTodoEditor->width(); | 3287 | w = mTodoEditor->width(); |
3272 | h = mTodoEditor->height(); | 3288 | h = mTodoEditor->height(); |
3273 | mTodoEditor->show(); | 3289 | mTodoEditor->show(); |
3274 | mTodoEditor->setGeometry(x,y,w,h); | 3290 | mTodoEditor->setGeometry(x,y,w,h); |
3275 | #else | 3291 | #else |
3276 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3292 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3277 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3293 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3278 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3294 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3279 | qApp->processEvents(); | 3295 | qApp->processEvents(); |
3280 | delete mTodoEditor; | 3296 | delete mTodoEditor; |
3281 | mTodoEditor = mDialogManager->getTodoEditor(); | 3297 | mTodoEditor = mDialogManager->getTodoEditor(); |
3282 | topLevelWidget()->setCaption( i18n("") ); | 3298 | topLevelWidget()->setCaption( i18n("") ); |
3283 | } | 3299 | } |
3284 | mTodoEditor->showMaximized(); | 3300 | mTodoEditor->showMaximized(); |
3285 | #endif | 3301 | #endif |
3286 | } | 3302 | } |
3287 | 3303 | ||
3288 | void CalendarView::cloneIncidence() | 3304 | void CalendarView::cloneIncidence() |
3289 | { | 3305 | { |
3290 | Incidence *incidence = currentSelection(); | 3306 | Incidence *incidence = currentSelection(); |
3291 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3307 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3292 | if ( incidence ) { | 3308 | if ( incidence ) { |
3293 | cloneIncidence(incidence); | 3309 | cloneIncidence(incidence); |
3294 | } | 3310 | } |
3295 | } | 3311 | } |
3296 | void CalendarView::moveIncidence() | 3312 | void CalendarView::moveIncidence() |
3297 | { | 3313 | { |
3298 | Incidence *incidence = currentSelection(); | 3314 | Incidence *incidence = currentSelection(); |
3299 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3315 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3300 | if ( incidence ) { | 3316 | if ( incidence ) { |
3301 | moveIncidence(incidence); | 3317 | moveIncidence(incidence); |
3302 | } | 3318 | } |
3303 | } | 3319 | } |
3304 | void CalendarView::beamIncidence() | 3320 | void CalendarView::beamIncidence() |
3305 | { | 3321 | { |
3306 | Incidence *incidence = currentSelection(); | 3322 | Incidence *incidence = currentSelection(); |
3307 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3323 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3308 | if ( incidence ) { | 3324 | if ( incidence ) { |
3309 | beamIncidence(incidence); | 3325 | beamIncidence(incidence); |
3310 | } | 3326 | } |
3311 | } | 3327 | } |
3312 | void CalendarView::toggleCancelIncidence() | 3328 | void CalendarView::toggleCancelIncidence() |
3313 | { | 3329 | { |
3314 | Incidence *incidence = currentSelection(); | 3330 | Incidence *incidence = currentSelection(); |
3315 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3331 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3316 | if ( incidence ) { | 3332 | if ( incidence ) { |
3317 | cancelIncidence(incidence); | 3333 | cancelIncidence(incidence); |
3318 | } | 3334 | } |
3319 | } | 3335 | } |
3320 | 3336 | ||
3321 | 3337 | ||
3322 | void CalendarView::cancelIncidence(Incidence * inc ) | 3338 | void CalendarView::cancelIncidence(Incidence * inc ) |
3323 | { | 3339 | { |
3324 | inc->setCancelled( ! inc->cancelled() ); | 3340 | inc->setCancelled( ! inc->cancelled() ); |
3325 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3341 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3326 | updateView(); | 3342 | updateView(); |
3327 | } | 3343 | } |
3328 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3344 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3329 | { | 3345 | { |
3330 | Incidence * newInc = orgInc->clone(); | 3346 | Incidence * newInc = orgInc->clone(); |
3331 | newInc->recreate(); | 3347 | newInc->recreate(); |
3332 | 3348 | ||
3333 | if ( newInc->typeID() == todoID ) { | 3349 | if ( newInc->typeID() == todoID ) { |
3334 | Todo* t = (Todo*) newInc; | 3350 | Todo* t = (Todo*) newInc; |
3335 | bool cloneSub = false; | 3351 | bool cloneSub = false; |
3336 | if ( orgInc->relations().count() ) { | 3352 | if ( orgInc->relations().count() ) { |
3337 | int result = KMessageBox::warningYesNoCancel(this, | 3353 | int result = KMessageBox::warningYesNoCancel(this, |
3338 | 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 ) ), | 3354 | 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 ) ), |
3339 | i18n("Todo has subtodos"), | 3355 | i18n("Todo has subtodos"), |
3340 | i18n("Yes"), | 3356 | i18n("Yes"), |
3341 | i18n("No")); | 3357 | i18n("No")); |
3342 | 3358 | ||
3343 | if ( result == KMessageBox::Cancel ) { | 3359 | if ( result == KMessageBox::Cancel ) { |
3344 | delete t; | 3360 | delete t; |
3345 | return; | 3361 | return; |
3346 | } | 3362 | } |
3347 | if (result == KMessageBox::Yes) cloneSub = true; | 3363 | if (result == KMessageBox::Yes) cloneSub = true; |
3348 | } | 3364 | } |
3349 | showTodoEditor(); | 3365 | showTodoEditor(); |
3350 | mTodoEditor->editTodo( t ); | 3366 | mTodoEditor->editTodo( t ); |
3351 | if ( mTodoEditor->exec() ) { | 3367 | if ( mTodoEditor->exec() ) { |
3352 | if ( cloneSub ) { | 3368 | if ( cloneSub ) { |
3353 | orgInc->cloneRelations( t ); | 3369 | orgInc->cloneRelations( t ); |
3354 | mCalendar->addIncidenceBranch( t ); | 3370 | mCalendar->addIncidenceBranch( t ); |
3355 | updateView(); | 3371 | updateView(); |
3356 | 3372 | ||
3357 | } else { | 3373 | } else { |
3358 | mCalendar->addTodo( t ); | 3374 | mCalendar->addTodo( t ); |
3359 | updateView(); | 3375 | updateView(); |
3360 | } | 3376 | } |
3361 | } else { | 3377 | } else { |
3362 | delete t; | 3378 | delete t; |
3363 | } | 3379 | } |
3364 | } | 3380 | } |
3365 | else if ( newInc->typeID() == eventID ) { | 3381 | else if ( newInc->typeID() == eventID ) { |
3366 | Event* e = (Event*) newInc; | 3382 | Event* e = (Event*) newInc; |
3367 | showEventEditor(); | 3383 | showEventEditor(); |
3368 | mEventEditor->editEvent( e ); | 3384 | mEventEditor->editEvent( e ); |
3369 | if ( mEventEditor->exec() ) { | 3385 | if ( mEventEditor->exec() ) { |
3370 | mCalendar->addEvent( e ); | 3386 | mCalendar->addEvent( e ); |
3371 | updateView(); | 3387 | updateView(); |
3372 | } else { | 3388 | } else { |
3373 | delete e; | 3389 | delete e; |
3374 | } | 3390 | } |
3375 | } if ( newInc->typeID() == journalID ) { | 3391 | } if ( newInc->typeID() == journalID ) { |
3376 | mCalendar->addJournal( (Journal*) newInc ); | 3392 | mCalendar->addJournal( (Journal*) newInc ); |
3377 | editJournal( (Journal*) newInc ); | 3393 | editJournal( (Journal*) newInc ); |
3378 | } | 3394 | } |
3379 | setActiveWindow(); | 3395 | setActiveWindow(); |
3380 | } | 3396 | } |
3381 | 3397 | ||
3382 | void CalendarView::newEvent() | 3398 | void CalendarView::newEvent() |
3383 | { | 3399 | { |
3384 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3400 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3385 | KOAgendaView *aView = mViewManager->agendaView(); | 3401 | KOAgendaView *aView = mViewManager->agendaView(); |
3386 | if (aView) { | 3402 | if (aView) { |
3387 | if (aView->selectionStart().isValid()) { | 3403 | if (aView->selectionStart().isValid()) { |
3388 | if (aView->selectedIsAllDay()) { | 3404 | if (aView->selectedIsAllDay()) { |
3389 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3405 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3390 | } else { | 3406 | } else { |
3391 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3407 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3392 | } | 3408 | } |
3393 | return; | 3409 | return; |
3394 | } | 3410 | } |
3395 | } | 3411 | } |
3396 | 3412 | ||
3397 | QDate date = mNavigator->selectedDates().first(); | 3413 | QDate date = mNavigator->selectedDates().first(); |
3398 | QDateTime current = QDateTime::currentDateTime(); | 3414 | QDateTime current = QDateTime::currentDateTime(); |
3399 | if ( date <= current.date() ) { | 3415 | if ( date <= current.date() ) { |
3400 | int hour = current.time().hour() +1; | 3416 | int hour = current.time().hour() +1; |
3401 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3417 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3402 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3418 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3403 | } else | 3419 | } else |
3404 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3420 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3405 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3421 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3406 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3422 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3407 | } | 3423 | } |
3408 | 3424 | ||
3409 | void CalendarView::newEvent(QDateTime fh) | 3425 | void CalendarView::newEvent(QDateTime fh) |
3410 | { | 3426 | { |
3411 | newEvent(fh, | 3427 | newEvent(fh, |
3412 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3428 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3413 | } | 3429 | } |
3414 | 3430 | ||
3415 | void CalendarView::newEvent(QDate dt) | 3431 | void CalendarView::newEvent(QDate dt) |
3416 | { | 3432 | { |
3417 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3433 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3418 | QDateTime(dt, QTime(0,0,0)), true); | 3434 | QDateTime(dt, QTime(0,0,0)), true); |
3419 | } | 3435 | } |
3420 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3436 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3421 | { | 3437 | { |
3422 | newEvent(fromHint, toHint, false); | 3438 | newEvent(fromHint, toHint, false); |
3423 | } | 3439 | } |
3424 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3440 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3425 | { | 3441 | { |
3426 | 3442 | ||
3427 | showEventEditor(); | 3443 | showEventEditor(); |
3428 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3444 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3429 | if ( mFilterView->filtersEnabled() ) { | 3445 | if ( mFilterView->filtersEnabled() ) { |
3430 | CalFilter *filter = mFilterView->selectedFilter(); | 3446 | CalFilter *filter = mFilterView->selectedFilter(); |
3431 | if (filter && filter->showCategories()) { | 3447 | if (filter && filter->showCategories()) { |
3432 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3448 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3433 | } | 3449 | } |
3434 | if ( filter ) | 3450 | if ( filter ) |
3435 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3451 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3436 | } | 3452 | } |
3437 | mEventEditor->exec(); | 3453 | mEventEditor->exec(); |
3438 | setActiveWindow(); | 3454 | setActiveWindow(); |
3439 | } | 3455 | } |
3440 | void CalendarView::todoAdded(Todo * t) | 3456 | void CalendarView::todoAdded(Todo * t) |
3441 | { | 3457 | { |
3442 | 3458 | ||
3443 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3459 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3444 | updateTodoViews(); | 3460 | updateTodoViews(); |
3445 | } | 3461 | } |
3446 | void CalendarView::todoChanged(Todo * t) | 3462 | void CalendarView::todoChanged(Todo * t) |
3447 | { | 3463 | { |
3448 | emit todoModified( t, 4 ); | 3464 | emit todoModified( t, 4 ); |
3449 | // updateTodoViews(); | 3465 | // updateTodoViews(); |
3450 | } | 3466 | } |
3451 | void CalendarView::todoToBeDeleted(Todo *) | 3467 | void CalendarView::todoToBeDeleted(Todo *) |
3452 | { | 3468 | { |
3453 | //qDebug("todoToBeDeleted(Todo *) "); | 3469 | //qDebug("todoToBeDeleted(Todo *) "); |
3454 | updateTodoViews(); | 3470 | updateTodoViews(); |
3455 | } | 3471 | } |
3456 | void CalendarView::todoDeleted() | 3472 | void CalendarView::todoDeleted() |
3457 | { | 3473 | { |
3458 | //qDebug(" todoDeleted()"); | 3474 | //qDebug(" todoDeleted()"); |
3459 | updateTodoViews(); | 3475 | updateTodoViews(); |
3460 | } | 3476 | } |
3461 | 3477 | ||
3462 | 3478 | ||
3463 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3479 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3464 | { | 3480 | { |
3465 | showTodoEditor(); | 3481 | showTodoEditor(); |
3466 | mTodoEditor->newTodo(dt,0,allday); | 3482 | mTodoEditor->newTodo(dt,0,allday); |
3467 | if ( mFilterView->filtersEnabled() ) { | 3483 | if ( mFilterView->filtersEnabled() ) { |
3468 | CalFilter *filter = mFilterView->selectedFilter(); | 3484 | CalFilter *filter = mFilterView->selectedFilter(); |
3469 | if (filter && filter->showCategories()) { | 3485 | if (filter && filter->showCategories()) { |
3470 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3486 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3471 | } | 3487 | } |
3472 | if ( filter ) | 3488 | if ( filter ) |
3473 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3489 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3474 | } | 3490 | } |
3475 | mTodoEditor->exec(); | 3491 | mTodoEditor->exec(); |
3476 | setActiveWindow(); | 3492 | setActiveWindow(); |
3477 | } | 3493 | } |
3478 | 3494 | ||
3479 | void CalendarView::newTodo() | 3495 | void CalendarView::newTodo() |
3480 | { | 3496 | { |
3481 | newTodoDateTime( QDateTime(),true ); | 3497 | newTodoDateTime( QDateTime(),true ); |
3482 | } | 3498 | } |
3483 | 3499 | ||
3484 | void CalendarView::newSubTodo() | 3500 | void CalendarView::newSubTodo() |
3485 | { | 3501 | { |
3486 | Todo *todo = selectedTodo(); | 3502 | Todo *todo = selectedTodo(); |
3487 | if ( todo ) newSubTodo( todo ); | 3503 | if ( todo ) newSubTodo( todo ); |
3488 | } | 3504 | } |
3489 | 3505 | ||
3490 | void CalendarView::newSubTodo(Todo *parentEvent) | 3506 | void CalendarView::newSubTodo(Todo *parentEvent) |
3491 | { | 3507 | { |
3492 | 3508 | ||
3493 | showTodoEditor(); | 3509 | showTodoEditor(); |
3494 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3510 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3495 | mTodoEditor->exec(); | 3511 | mTodoEditor->exec(); |
3496 | setActiveWindow(); | 3512 | setActiveWindow(); |
3497 | } | 3513 | } |
3498 | 3514 | ||
3499 | void CalendarView::newFloatingEvent() | 3515 | void CalendarView::newFloatingEvent() |
3500 | { | 3516 | { |
3501 | DateList tmpList = mNavigator->selectedDates(); | 3517 | DateList tmpList = mNavigator->selectedDates(); |
3502 | QDate date = tmpList.first(); | 3518 | QDate date = tmpList.first(); |
3503 | 3519 | ||
3504 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3520 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3505 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3521 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3506 | } | 3522 | } |
3507 | 3523 | ||
3508 | 3524 | ||
3509 | void CalendarView::editEvent( Event *event ) | 3525 | void CalendarView::editEvent( Event *event ) |
3510 | { | 3526 | { |
3511 | 3527 | ||
3512 | if ( !event ) return; | 3528 | if ( !event ) return; |
3513 | if ( event->isReadOnly() ) { | 3529 | if ( event->isReadOnly() ) { |
3514 | showEvent( event ); | 3530 | showEvent( event ); |
3515 | return; | 3531 | return; |
3516 | } | 3532 | } |
3517 | showEventEditor(); | 3533 | showEventEditor(); |
3518 | mEventEditor->editEvent( event , mFlagEditDescription); | 3534 | mEventEditor->editEvent( event , mFlagEditDescription); |
3519 | mEventEditor->exec(); | 3535 | mEventEditor->exec(); |
3520 | setActiveWindow(); | 3536 | setActiveWindow(); |
3521 | 3537 | ||
3522 | } | 3538 | } |
3523 | void CalendarView::editJournal( Journal *jour ) | 3539 | void CalendarView::editJournal( Journal *jour ) |
3524 | { | 3540 | { |
3525 | if ( !jour ) return; | 3541 | if ( !jour ) return; |
3526 | mDialogManager->hideSearchDialog(); | 3542 | mDialogManager->hideSearchDialog(); |
3527 | mViewManager->showJournalView(); | 3543 | mViewManager->showJournalView(); |
3528 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3544 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3529 | } | 3545 | } |
3530 | void CalendarView::editTodo( Todo *todo ) | 3546 | void CalendarView::editTodo( Todo *todo ) |
3531 | { | 3547 | { |
3532 | if ( !todo ) return; | 3548 | if ( !todo ) return; |
3533 | 3549 | ||
3534 | if ( todo->isReadOnly() ) { | 3550 | if ( todo->isReadOnly() ) { |
3535 | showTodo( todo ); | 3551 | showTodo( todo ); |
3536 | return; | 3552 | return; |
3537 | } | 3553 | } |
3538 | showTodoEditor(); | 3554 | showTodoEditor(); |
3539 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3555 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3540 | mTodoEditor->exec(); | 3556 | mTodoEditor->exec(); |
3541 | setActiveWindow(); | 3557 | setActiveWindow(); |
3542 | 3558 | ||
3543 | } | 3559 | } |
3544 | 3560 | ||
3545 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3561 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3546 | { | 3562 | { |
3547 | if ( !mEventViewerDialog ) { | 3563 | if ( !mEventViewerDialog ) { |
3548 | mEventViewerDialog = new KOEventViewerDialog(0); | 3564 | mEventViewerDialog = new KOEventViewerDialog(0); |
3549 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3565 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3550 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3566 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3551 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3567 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3552 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3568 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3553 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3569 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3554 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3570 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3555 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3571 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3556 | this, SLOT( slotViewerClosed() ) ); | 3572 | this, SLOT( slotViewerClosed() ) ); |
3557 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3573 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3558 | this, SLOT( todoChanged(Todo *) ) ); | 3574 | this, SLOT( todoChanged(Todo *) ) ); |
3559 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3575 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3560 | mEventViewerDialog->resize( 640, 480 ); | 3576 | mEventViewerDialog->resize( 640, 480 ); |
3561 | 3577 | ||
3562 | } | 3578 | } |
3563 | return mEventViewerDialog; | 3579 | return mEventViewerDialog; |
3564 | } | 3580 | } |
3565 | void CalendarView::showEvent(Event *event) | 3581 | void CalendarView::showEvent(Event *event) |
3566 | { | 3582 | { |
3567 | getEventViewerDialog()->setEvent(event); | 3583 | getEventViewerDialog()->setEvent(event); |
3568 | getEventViewerDialog()->showMe(); | 3584 | getEventViewerDialog()->showMe(); |
3569 | } | 3585 | } |
3570 | 3586 | ||
3571 | void CalendarView::showTodo(Todo *event) | 3587 | void CalendarView::showTodo(Todo *event) |
3572 | { | 3588 | { |
3573 | getEventViewerDialog()->setTodo(event); | 3589 | getEventViewerDialog()->setTodo(event); |
3574 | getEventViewerDialog()->showMe(); | 3590 | getEventViewerDialog()->showMe(); |
3575 | } | 3591 | } |
3576 | void CalendarView::showJournal( Journal *jour ) | 3592 | void CalendarView::showJournal( Journal *jour ) |
3577 | { | 3593 | { |
3578 | getEventViewerDialog()->setJournal(jour); | 3594 | getEventViewerDialog()->setJournal(jour); |
3579 | getEventViewerDialog()->showMe(); | 3595 | getEventViewerDialog()->showMe(); |
3580 | 3596 | ||
3581 | } | 3597 | } |
3582 | // void CalendarView::todoModified (Todo *event, int changed) | 3598 | // void CalendarView::todoModified (Todo *event, int changed) |
3583 | // { | 3599 | // { |
3584 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3600 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3585 | // // kdDebug() << "Todo modified and open" << endl; | 3601 | // // kdDebug() << "Todo modified and open" << endl; |
3586 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3602 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3587 | // // temp->modified (changed); | 3603 | // // temp->modified (changed); |
3588 | 3604 | ||
3589 | // // } | 3605 | // // } |
3590 | 3606 | ||
3591 | // mViewManager->updateView(); | 3607 | // mViewManager->updateView(); |
3592 | // } | 3608 | // } |
3593 | 3609 | ||
3594 | void CalendarView::appointment_show() | 3610 | void CalendarView::appointment_show() |
3595 | { | 3611 | { |
3596 | Event *anEvent = 0; | 3612 | Event *anEvent = 0; |
3597 | 3613 | ||
3598 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3614 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3599 | 3615 | ||
3600 | if (mViewManager->currentView()->isEventView()) { | 3616 | if (mViewManager->currentView()->isEventView()) { |
3601 | if ( incidence && incidence->typeID() == eventID ) { | 3617 | if ( incidence && incidence->typeID() == eventID ) { |
3602 | anEvent = static_cast<Event *>(incidence); | 3618 | anEvent = static_cast<Event *>(incidence); |
3603 | } | 3619 | } |
3604 | } | 3620 | } |
3605 | 3621 | ||
3606 | if (!anEvent) { | 3622 | if (!anEvent) { |
3607 | KNotifyClient::beep(); | 3623 | KNotifyClient::beep(); |
3608 | return; | 3624 | return; |
3609 | } | 3625 | } |
3610 | 3626 | ||
3611 | showEvent(anEvent); | 3627 | showEvent(anEvent); |
3612 | } | 3628 | } |
3613 | 3629 | ||
3614 | void CalendarView::appointment_edit() | 3630 | void CalendarView::appointment_edit() |
3615 | { | 3631 | { |
3616 | Event *anEvent = 0; | 3632 | Event *anEvent = 0; |
3617 | 3633 | ||
3618 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3634 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3619 | 3635 | ||
3620 | if (mViewManager->currentView()->isEventView()) { | 3636 | if (mViewManager->currentView()->isEventView()) { |
3621 | if ( incidence && incidence->typeID() == eventID ) { | 3637 | if ( incidence && incidence->typeID() == eventID ) { |
3622 | anEvent = static_cast<Event *>(incidence); | 3638 | anEvent = static_cast<Event *>(incidence); |
3623 | } | 3639 | } |
3624 | } | 3640 | } |
3625 | 3641 | ||
3626 | if (!anEvent) { | 3642 | if (!anEvent) { |
3627 | KNotifyClient::beep(); | 3643 | KNotifyClient::beep(); |
3628 | return; | 3644 | return; |
3629 | } | 3645 | } |
3630 | 3646 | ||
3631 | editEvent(anEvent); | 3647 | editEvent(anEvent); |
3632 | } | 3648 | } |
3633 | 3649 | ||
3634 | void CalendarView::appointment_delete() | 3650 | void CalendarView::appointment_delete() |
3635 | { | 3651 | { |
3636 | Event *anEvent = 0; | 3652 | Event *anEvent = 0; |
3637 | 3653 | ||
3638 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3654 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3639 | 3655 | ||
3640 | if (mViewManager->currentView()->isEventView()) { | 3656 | if (mViewManager->currentView()->isEventView()) { |
3641 | if ( incidence && incidence->typeID() == eventID ) { | 3657 | if ( incidence && incidence->typeID() == eventID ) { |
3642 | anEvent = static_cast<Event *>(incidence); | 3658 | anEvent = static_cast<Event *>(incidence); |
3643 | } | 3659 | } |
3644 | } | 3660 | } |
3645 | 3661 | ||
3646 | if (!anEvent) { | 3662 | if (!anEvent) { |
3647 | KNotifyClient::beep(); | 3663 | KNotifyClient::beep(); |
3648 | return; | 3664 | return; |
3649 | } | 3665 | } |
3650 | 3666 | ||
3651 | deleteEvent(anEvent); | 3667 | deleteEvent(anEvent); |
3652 | } | 3668 | } |
3653 | 3669 | ||
3654 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3670 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3655 | { | 3671 | { |
3656 | if (!sub) return; | 3672 | if (!sub) return; |
3657 | if ( sub->relatedTo() == parent ) | 3673 | if ( sub->relatedTo() == parent ) |
3658 | return; | 3674 | return; |
3659 | sub->setRelatedTo(parent); | 3675 | sub->setRelatedTo(parent); |
3660 | sub->updated(); | 3676 | sub->updated(); |
3661 | setModified(true); | 3677 | setModified(true); |
3662 | updateView(); | 3678 | updateView(); |
3663 | } | 3679 | } |
3664 | void CalendarView::todo_unsub(Todo *anTodo ) | 3680 | void CalendarView::todo_unsub(Todo *anTodo ) |
3665 | { | 3681 | { |
3666 | todo_resub( 0, anTodo ); | 3682 | todo_resub( 0, anTodo ); |
3667 | } | 3683 | } |
3668 | 3684 | ||
3669 | void CalendarView::deleteTodo(Todo *todo) | 3685 | void CalendarView::deleteTodo(Todo *todo) |
3670 | { | 3686 | { |
3671 | if (!todo) { | 3687 | if (!todo) { |
3672 | KNotifyClient::beep(); | 3688 | KNotifyClient::beep(); |
3673 | return; | 3689 | return; |
3674 | } | 3690 | } |
3675 | if (KOPrefs::instance()->mConfirm) { | 3691 | if (KOPrefs::instance()->mConfirm) { |
3676 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3692 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3677 | if (!todo->relations().isEmpty()) { | 3693 | if (!todo->relations().isEmpty()) { |
3678 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3694 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3679 | 3695 | ||
3680 | } | 3696 | } |
3681 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3697 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3682 | case KMessageBox::Continue: // OK | 3698 | case KMessageBox::Continue: // OK |
3683 | bool deleteT = false; | 3699 | bool deleteT = false; |
3684 | if (!todo->relations().isEmpty()) { | 3700 | if (!todo->relations().isEmpty()) { |
3685 | deleteT = removeCompletedSubTodos( todo ); | 3701 | deleteT = removeCompletedSubTodos( todo ); |
3686 | } | 3702 | } |
3687 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3703 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3688 | if ( !deleteT ) { | 3704 | if ( !deleteT ) { |
3689 | checkExternalId( todo ); | 3705 | checkExternalId( todo ); |
3690 | calendar()->deleteTodo(todo); | 3706 | calendar()->deleteTodo(todo); |
3691 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3707 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3692 | updateView(); | 3708 | updateView(); |
3693 | } | 3709 | } |
3694 | break; | 3710 | break; |
3695 | } // switch | 3711 | } // switch |
3696 | } else { | 3712 | } else { |
3697 | checkExternalId( todo ); | 3713 | checkExternalId( todo ); |
3698 | mCalendar->deleteTodo(todo); | 3714 | mCalendar->deleteTodo(todo); |
3699 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3715 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3700 | updateView(); | 3716 | updateView(); |
3701 | } | 3717 | } |
3702 | 3718 | ||
3703 | emit updateSearchDialog(); | 3719 | emit updateSearchDialog(); |
3704 | } | 3720 | } |
3705 | void CalendarView::deleteJournal(Journal *jour) | 3721 | void CalendarView::deleteJournal(Journal *jour) |
3706 | { | 3722 | { |
3707 | if (!jour) { | 3723 | if (!jour) { |
3708 | KNotifyClient::beep(); | 3724 | KNotifyClient::beep(); |
3709 | return; | 3725 | return; |
3710 | } | 3726 | } |
3711 | if (KOPrefs::instance()->mConfirm) { | 3727 | if (KOPrefs::instance()->mConfirm) { |
3712 | 3728 | ||
3713 | QString des; | 3729 | QString des; |
3714 | if ( !jour->summary().isEmpty() ) { | 3730 | if ( !jour->summary().isEmpty() ) { |
3715 | des = jour->summary(); | 3731 | des = jour->summary(); |
3716 | } else { | 3732 | } else { |
3717 | des = jour->description().left(30); | 3733 | des = jour->description().left(30); |
3718 | des = des.simplifyWhiteSpace (); | 3734 | des = des.simplifyWhiteSpace (); |
3719 | des.replace (QRegExp ("\\n"),"" ); | 3735 | des.replace (QRegExp ("\\n"),"" ); |
3720 | des.replace (QRegExp ("\\r"),"" ); | 3736 | des.replace (QRegExp ("\\r"),"" ); |
3721 | } | 3737 | } |
3722 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 3738 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3723 | case KMessageBox::Continue: // OK | 3739 | case KMessageBox::Continue: // OK |
3724 | calendar()->deleteJournal(jour); | 3740 | calendar()->deleteJournal(jour); |
3725 | updateView(); | 3741 | updateView(); |
3726 | break; | 3742 | break; |
3727 | } // switch | 3743 | } // switch |
3728 | } else { | 3744 | } else { |
3729 | calendar()->deleteJournal(jour);; | 3745 | calendar()->deleteJournal(jour);; |
3730 | updateView(); | 3746 | updateView(); |
3731 | } | 3747 | } |
3732 | emit updateSearchDialog(); | 3748 | emit updateSearchDialog(); |
3733 | } | 3749 | } |
3734 | 3750 | ||
3735 | void CalendarView::deleteEvent(Event *anEvent) | 3751 | void CalendarView::deleteEvent(Event *anEvent) |
3736 | { | 3752 | { |
3737 | if (!anEvent) { | 3753 | if (!anEvent) { |
3738 | KNotifyClient::beep(); | 3754 | KNotifyClient::beep(); |
3739 | return; | 3755 | return; |
3740 | } | 3756 | } |
3741 | 3757 | ||
3742 | if (anEvent->recurrence()->doesRecur()) { | 3758 | if (anEvent->recurrence()->doesRecur()) { |
3743 | QDate itemDate = mViewManager->currentSelectionDate(); | 3759 | QDate itemDate = mViewManager->currentSelectionDate(); |
3744 | int km; | 3760 | int km; |
3745 | if (!itemDate.isValid()) { | 3761 | if (!itemDate.isValid()) { |
3746 | //kdDebug() << "Date Not Valid" << endl; | 3762 | //kdDebug() << "Date Not Valid" << endl; |
3747 | if (KOPrefs::instance()->mConfirm) { | 3763 | if (KOPrefs::instance()->mConfirm) { |
3748 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3764 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3749 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3765 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3750 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3766 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3751 | if ( km == KMessageBox::Continue ) | 3767 | if ( km == KMessageBox::Continue ) |
3752 | km = KMessageBox::No; // No = all below | 3768 | km = KMessageBox::No; // No = all below |
3753 | } else | 3769 | } else |
3754 | km = KMessageBox::No; | 3770 | km = KMessageBox::No; |
3755 | } else { | 3771 | } else { |
3756 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3772 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3757 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3773 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3758 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3774 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3759 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3775 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3760 | i18n("All")); | 3776 | i18n("All")); |
3761 | } | 3777 | } |
3762 | switch(km) { | 3778 | switch(km) { |
3763 | 3779 | ||
3764 | case KMessageBox::No: // Continue // all | 3780 | case KMessageBox::No: // Continue // all |
3765 | //qDebug("KMessageBox::No "); | 3781 | //qDebug("KMessageBox::No "); |
3766 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3782 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3767 | schedule(Scheduler::Cancel,anEvent); | 3783 | schedule(Scheduler::Cancel,anEvent); |
3768 | 3784 | ||
3769 | checkExternalId( anEvent); | 3785 | checkExternalId( anEvent); |
3770 | mCalendar->deleteEvent(anEvent); | 3786 | mCalendar->deleteEvent(anEvent); |
3771 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3787 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3772 | break; | 3788 | break; |
3773 | 3789 | ||
3774 | // Disabled because it does not work | 3790 | // Disabled because it does not work |
3775 | //#if 0 | 3791 | //#if 0 |
3776 | case KMessageBox::Yes: // just this one | 3792 | case KMessageBox::Yes: // just this one |
3777 | //QDate qd = mNavigator->selectedDates().first(); | 3793 | //QDate qd = mNavigator->selectedDates().first(); |
3778 | //if (!qd.isValid()) { | 3794 | //if (!qd.isValid()) { |
3779 | // kdDebug() << "no date selected, or invalid date" << endl; | 3795 | // kdDebug() << "no date selected, or invalid date" << endl; |
3780 | // KNotifyClient::beep(); | 3796 | // KNotifyClient::beep(); |
3781 | // return; | 3797 | // return; |
3782 | //} | 3798 | //} |
3783 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3799 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3784 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3800 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3785 | anEvent->addExDate(itemDate); | 3801 | anEvent->addExDate(itemDate); |
3786 | int duration = anEvent->recurrence()->duration(); | 3802 | int duration = anEvent->recurrence()->duration(); |
3787 | if ( duration > 0 ) { | 3803 | if ( duration > 0 ) { |
3788 | anEvent->recurrence()->setDuration( duration - 1 ); | 3804 | anEvent->recurrence()->setDuration( duration - 1 ); |
3789 | } | 3805 | } |
3790 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3806 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3791 | } | 3807 | } |
3792 | break; | 3808 | break; |
3793 | //#endif | 3809 | //#endif |
3794 | } // switch | 3810 | } // switch |
3795 | } else { | 3811 | } else { |
3796 | if (KOPrefs::instance()->mConfirm) { | 3812 | if (KOPrefs::instance()->mConfirm) { |
3797 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3813 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3798 | i18n("\nAre you sure you want\nto delete this event?"), | 3814 | i18n("\nAre you sure you want\nto delete this event?"), |
3799 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3815 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3800 | case KMessageBox::Continue: // OK | 3816 | case KMessageBox::Continue: // OK |
3801 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3817 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3802 | schedule(Scheduler::Cancel,anEvent); | 3818 | schedule(Scheduler::Cancel,anEvent); |
3803 | checkExternalId( anEvent); | 3819 | checkExternalId( anEvent); |
3804 | mCalendar->deleteEvent(anEvent); | 3820 | mCalendar->deleteEvent(anEvent); |
3805 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3821 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3806 | break; | 3822 | break; |
3807 | } // switch | 3823 | } // switch |
3808 | } else { | 3824 | } else { |
3809 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3825 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3810 | schedule(Scheduler::Cancel,anEvent); | 3826 | schedule(Scheduler::Cancel,anEvent); |
3811 | checkExternalId( anEvent); | 3827 | checkExternalId( anEvent); |
3812 | mCalendar->deleteEvent(anEvent); | 3828 | mCalendar->deleteEvent(anEvent); |
3813 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3829 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3814 | } | 3830 | } |
3815 | } // if-else | 3831 | } // if-else |
3816 | emit updateSearchDialog(); | 3832 | emit updateSearchDialog(); |
3817 | } | 3833 | } |
3818 | 3834 | ||
3819 | bool CalendarView::deleteEvent(const QString &uid) | 3835 | bool CalendarView::deleteEvent(const QString &uid) |
3820 | { | 3836 | { |
3821 | Event *ev = mCalendar->event(uid); | 3837 | Event *ev = mCalendar->event(uid); |
3822 | if (ev) { | 3838 | if (ev) { |
3823 | deleteEvent(ev); | 3839 | deleteEvent(ev); |
3824 | return true; | 3840 | return true; |
3825 | } else { | 3841 | } else { |
3826 | return false; | 3842 | return false; |
3827 | } | 3843 | } |
3828 | } | 3844 | } |
3829 | 3845 | ||
3830 | /*****************************************************************************/ | 3846 | /*****************************************************************************/ |
3831 | 3847 | ||
3832 | void CalendarView::action_mail() | 3848 | void CalendarView::action_mail() |
3833 | { | 3849 | { |
3834 | #ifndef KORG_NOMAIL | 3850 | #ifndef KORG_NOMAIL |
3835 | KOMailClient mailClient; | 3851 | KOMailClient mailClient; |
3836 | 3852 | ||
3837 | Incidence *incidence = currentSelection(); | 3853 | Incidence *incidence = currentSelection(); |
3838 | 3854 | ||
3839 | if (!incidence) { | 3855 | if (!incidence) { |
3840 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3856 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3841 | return; | 3857 | return; |
3842 | } | 3858 | } |
3843 | if(incidence->attendeeCount() == 0 ) { | 3859 | if(incidence->attendeeCount() == 0 ) { |
3844 | KMessageBox::sorry(this, | 3860 | KMessageBox::sorry(this, |
3845 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3861 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3846 | return; | 3862 | return; |
3847 | } | 3863 | } |
3848 | 3864 | ||
3849 | CalendarLocal cal_tmp; | 3865 | CalendarLocal cal_tmp; |
3850 | Event *event = 0; | 3866 | Event *event = 0; |
3851 | Event *ev = 0; | 3867 | Event *ev = 0; |
3852 | if ( incidence && incidence->typeID() == eventID ) { | 3868 | if ( incidence && incidence->typeID() == eventID ) { |
3853 | event = static_cast<Event *>(incidence); | 3869 | event = static_cast<Event *>(incidence); |
3854 | ev = new Event(*event); | 3870 | ev = new Event(*event); |
3855 | cal_tmp.addEvent(ev); | 3871 | cal_tmp.addEvent(ev); |
3856 | } | 3872 | } |
3857 | ICalFormat mForm(); | 3873 | ICalFormat mForm(); |
3858 | QString attachment = mForm.toString( &cal_tmp ); | 3874 | QString attachment = mForm.toString( &cal_tmp ); |
3859 | if (ev) delete(ev); | 3875 | if (ev) delete(ev); |
3860 | 3876 | ||
3861 | mailClient.mailAttendees(currentSelection(), attachment); | 3877 | mailClient.mailAttendees(currentSelection(), attachment); |
3862 | 3878 | ||
3863 | #endif | 3879 | #endif |
3864 | 3880 | ||
3865 | #if 0 | 3881 | #if 0 |
3866 | Event *anEvent = 0; | 3882 | Event *anEvent = 0; |
3867 | if (mViewManager->currentView()->isEventView()) { | 3883 | if (mViewManager->currentView()->isEventView()) { |
3868 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3884 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3869 | } | 3885 | } |
3870 | 3886 | ||
3871 | if (!anEvent) { | 3887 | if (!anEvent) { |
3872 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3888 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3873 | return; | 3889 | return; |
3874 | } | 3890 | } |
3875 | if(anEvent->attendeeCount() == 0 ) { | 3891 | if(anEvent->attendeeCount() == 0 ) { |
3876 | KMessageBox::sorry(this, | 3892 | KMessageBox::sorry(this, |
3877 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3893 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3878 | return; | 3894 | return; |
3879 | } | 3895 | } |
3880 | 3896 | ||
3881 | mailobject.emailEvent(anEvent); | 3897 | mailobject.emailEvent(anEvent); |
3882 | #endif | 3898 | #endif |
3883 | } | 3899 | } |
3884 | 3900 | ||
3885 | 3901 | ||
3886 | void CalendarView::schedule_publish(Incidence *incidence) | 3902 | void CalendarView::schedule_publish(Incidence *incidence) |
3887 | { | 3903 | { |
3888 | Event *event = 0; | 3904 | Event *event = 0; |
3889 | Todo *todo = 0; | 3905 | Todo *todo = 0; |
3890 | 3906 | ||
3891 | if (incidence == 0) { | 3907 | if (incidence == 0) { |
3892 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3908 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3893 | if (incidence == 0) { | 3909 | if (incidence == 0) { |
3894 | incidence = mTodoList->selectedIncidences().first(); | 3910 | incidence = mTodoList->selectedIncidences().first(); |
3895 | } | 3911 | } |
3896 | } | 3912 | } |
3897 | if ( incidence && incidence->typeID() == eventID ) { | 3913 | if ( incidence && incidence->typeID() == eventID ) { |
3898 | event = static_cast<Event *>(incidence); | 3914 | event = static_cast<Event *>(incidence); |
3899 | } else { | 3915 | } else { |
3900 | if ( incidence && incidence->typeID() == todoID ) { | 3916 | if ( incidence && incidence->typeID() == todoID ) { |
3901 | todo = static_cast<Todo *>(incidence); | 3917 | todo = static_cast<Todo *>(incidence); |
3902 | } | 3918 | } |
3903 | } | 3919 | } |
3904 | 3920 | ||
3905 | if (!event && !todo) { | 3921 | if (!event && !todo) { |
3906 | KMessageBox::sorry(this,i18n("No event selected.")); | 3922 | KMessageBox::sorry(this,i18n("No event selected.")); |
3907 | return; | 3923 | return; |
3908 | } | 3924 | } |
3909 | 3925 | ||
3910 | PublishDialog *publishdlg = new PublishDialog(); | 3926 | PublishDialog *publishdlg = new PublishDialog(); |
3911 | if (incidence->attendeeCount()>0) { | 3927 | if (incidence->attendeeCount()>0) { |
3912 | QPtrList<Attendee> attendees = incidence->attendees(); | 3928 | QPtrList<Attendee> attendees = incidence->attendees(); |
3913 | attendees.first(); | 3929 | attendees.first(); |
3914 | while ( attendees.current()!=0 ) { | 3930 | while ( attendees.current()!=0 ) { |
3915 | publishdlg->addAttendee(attendees.current()); | 3931 | publishdlg->addAttendee(attendees.current()); |
3916 | attendees.next(); | 3932 | attendees.next(); |
3917 | } | 3933 | } |
3918 | } | 3934 | } |
3919 | bool send = true; | 3935 | bool send = true; |
3920 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3936 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3921 | if ( publishdlg->exec() != QDialog::Accepted ) | 3937 | if ( publishdlg->exec() != QDialog::Accepted ) |
3922 | send = false; | 3938 | send = false; |
3923 | } | 3939 | } |
3924 | if ( send ) { | 3940 | if ( send ) { |
3925 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3941 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3926 | if ( event ) { | 3942 | if ( event ) { |
3927 | Event *ev = new Event(*event); | 3943 | Event *ev = new Event(*event); |
3928 | ev->registerObserver(0); | 3944 | ev->registerObserver(0); |
3929 | ev->clearAttendees(); | 3945 | ev->clearAttendees(); |
3930 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3946 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3931 | delete(ev); | 3947 | delete(ev); |
3932 | } | 3948 | } |
3933 | } else { | 3949 | } else { |
3934 | if ( todo ) { | 3950 | if ( todo ) { |
3935 | Todo *ev = new Todo(*todo); | 3951 | Todo *ev = new Todo(*todo); |
3936 | ev->registerObserver(0); | 3952 | ev->registerObserver(0); |
3937 | ev->clearAttendees(); | 3953 | ev->clearAttendees(); |
3938 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3954 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3939 | delete(ev); | 3955 | delete(ev); |
3940 | } | 3956 | } |
3941 | } | 3957 | } |
3942 | } | 3958 | } |
3943 | } | 3959 | } |
3944 | delete publishdlg; | 3960 | delete publishdlg; |
3945 | } | 3961 | } |
3946 | 3962 | ||
3947 | void CalendarView::schedule_request(Incidence *incidence) | 3963 | void CalendarView::schedule_request(Incidence *incidence) |
3948 | { | 3964 | { |
3949 | schedule(Scheduler::Request,incidence); | 3965 | schedule(Scheduler::Request,incidence); |
3950 | } | 3966 | } |
3951 | 3967 | ||
3952 | void CalendarView::schedule_refresh(Incidence *incidence) | 3968 | void CalendarView::schedule_refresh(Incidence *incidence) |
3953 | { | 3969 | { |
3954 | schedule(Scheduler::Refresh,incidence); | 3970 | schedule(Scheduler::Refresh,incidence); |
3955 | } | 3971 | } |
3956 | 3972 | ||
3957 | void CalendarView::schedule_cancel(Incidence *incidence) | 3973 | void CalendarView::schedule_cancel(Incidence *incidence) |
3958 | { | 3974 | { |
3959 | schedule(Scheduler::Cancel,incidence); | 3975 | schedule(Scheduler::Cancel,incidence); |
3960 | } | 3976 | } |
3961 | 3977 | ||
3962 | void CalendarView::schedule_add(Incidence *incidence) | 3978 | void CalendarView::schedule_add(Incidence *incidence) |
3963 | { | 3979 | { |
3964 | schedule(Scheduler::Add,incidence); | 3980 | schedule(Scheduler::Add,incidence); |
3965 | } | 3981 | } |
3966 | 3982 | ||
3967 | void CalendarView::schedule_reply(Incidence *incidence) | 3983 | void CalendarView::schedule_reply(Incidence *incidence) |
3968 | { | 3984 | { |
3969 | schedule(Scheduler::Reply,incidence); | 3985 | schedule(Scheduler::Reply,incidence); |
3970 | } | 3986 | } |
3971 | 3987 | ||
3972 | void CalendarView::schedule_counter(Incidence *incidence) | 3988 | void CalendarView::schedule_counter(Incidence *incidence) |
3973 | { | 3989 | { |
3974 | schedule(Scheduler::Counter,incidence); | 3990 | schedule(Scheduler::Counter,incidence); |
3975 | } | 3991 | } |
3976 | 3992 | ||
3977 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3993 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3978 | { | 3994 | { |
3979 | schedule(Scheduler::Declinecounter,incidence); | 3995 | schedule(Scheduler::Declinecounter,incidence); |
3980 | } | 3996 | } |
3981 | 3997 | ||
3982 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3998 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3983 | { | 3999 | { |
3984 | QDateTime start = QDateTime::currentDateTime(); | 4000 | QDateTime start = QDateTime::currentDateTime(); |
3985 | QDateTime end = start.addDays(daysToPublish); | 4001 | QDateTime end = start.addDays(daysToPublish); |
3986 | 4002 | ||
3987 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4003 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3988 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4004 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3989 | 4005 | ||
3990 | 4006 | ||
3991 | PublishDialog *publishdlg = new PublishDialog(); | 4007 | PublishDialog *publishdlg = new PublishDialog(); |
3992 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4008 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3993 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4009 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3994 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4010 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3995 | delete(freebusy); | 4011 | delete(freebusy); |
3996 | } | 4012 | } |
3997 | } | 4013 | } |
3998 | delete publishdlg; | 4014 | delete publishdlg; |
3999 | } | 4015 | } |
4000 | 4016 | ||
4001 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4017 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4002 | { | 4018 | { |
4003 | Event *event = 0; | 4019 | Event *event = 0; |
4004 | Todo *todo = 0; | 4020 | Todo *todo = 0; |
4005 | 4021 | ||
4006 | if (incidence == 0) { | 4022 | if (incidence == 0) { |
4007 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4023 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4008 | if (incidence == 0) { | 4024 | if (incidence == 0) { |
4009 | incidence = mTodoList->selectedIncidences().first(); | 4025 | incidence = mTodoList->selectedIncidences().first(); |
4010 | } | 4026 | } |
4011 | } | 4027 | } |
4012 | if ( incidence && incidence->typeID() == eventID ) { | 4028 | if ( incidence && incidence->typeID() == eventID ) { |
4013 | event = static_cast<Event *>(incidence); | 4029 | event = static_cast<Event *>(incidence); |
4014 | } | 4030 | } |
4015 | if ( incidence && incidence->typeID() == todoID ) { | 4031 | if ( incidence && incidence->typeID() == todoID ) { |
4016 | todo = static_cast<Todo *>(incidence); | 4032 | todo = static_cast<Todo *>(incidence); |
4017 | } | 4033 | } |
4018 | 4034 | ||
4019 | if (!event && !todo) { | 4035 | if (!event && !todo) { |
4020 | KMessageBox::sorry(this,i18n("No event selected.")); | 4036 | KMessageBox::sorry(this,i18n("No event selected.")); |
4021 | return; | 4037 | return; |
4022 | } | 4038 | } |
4023 | 4039 | ||
4024 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4040 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4025 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4041 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4026 | return; | 4042 | return; |
4027 | } | 4043 | } |
4028 | 4044 | ||
4029 | Event *ev = 0; | 4045 | Event *ev = 0; |
4030 | if (event) ev = new Event(*event); | 4046 | if (event) ev = new Event(*event); |
4031 | Todo *to = 0; | 4047 | Todo *to = 0; |
4032 | if (todo) to = new Todo(*todo); | 4048 | if (todo) to = new Todo(*todo); |
4033 | 4049 | ||
4034 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4050 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4035 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4051 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4036 | if (!me) { | 4052 | if (!me) { |
4037 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4053 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4038 | return; | 4054 | return; |
4039 | } | 4055 | } |
4040 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4056 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4041 | StatusDialog *statdlg = new StatusDialog(this); | 4057 | StatusDialog *statdlg = new StatusDialog(this); |
4042 | if (!statdlg->exec()==QDialog::Accepted) return; | 4058 | if (!statdlg->exec()==QDialog::Accepted) return; |
4043 | me->setStatus( statdlg->status() ); | 4059 | me->setStatus( statdlg->status() ); |
4044 | delete(statdlg); | 4060 | delete(statdlg); |
4045 | } | 4061 | } |
4046 | Attendee *menew = new Attendee(*me); | 4062 | Attendee *menew = new Attendee(*me); |
4047 | if (ev) { | 4063 | if (ev) { |
4048 | ev->clearAttendees(); | 4064 | ev->clearAttendees(); |
4049 | ev->addAttendee(menew,false); | 4065 | ev->addAttendee(menew,false); |
4050 | } else { | 4066 | } else { |
4051 | if (to) { | 4067 | if (to) { |
4052 | todo->clearAttendees(); | 4068 | todo->clearAttendees(); |
4053 | todo->addAttendee(menew,false); | 4069 | todo->addAttendee(menew,false); |
4054 | } | 4070 | } |
4055 | } | 4071 | } |
4056 | } | 4072 | } |
4057 | 4073 | ||
4058 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4074 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4059 | if (ev) { | 4075 | if (ev) { |
4060 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4076 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4061 | } else { | 4077 | } else { |
4062 | if (to) { | 4078 | if (to) { |
4063 | if ( !dlg->addMessage(to,method) ) delete(to); | 4079 | if ( !dlg->addMessage(to,method) ) delete(to); |
4064 | } | 4080 | } |
4065 | } | 4081 | } |
4066 | } | 4082 | } |
4067 | 4083 | ||
4068 | void CalendarView::openAddressbook() | 4084 | void CalendarView::openAddressbook() |
4069 | { | 4085 | { |
4070 | KRun::runCommand("kaddressbook"); | 4086 | KRun::runCommand("kaddressbook"); |
4071 | } | 4087 | } |
4072 | 4088 | ||
4073 | void CalendarView::setModified(bool modified) | 4089 | void CalendarView::setModified(bool modified) |
4074 | { | 4090 | { |
4075 | if ( modified ) | 4091 | if ( modified ) |
4076 | emit signalmodified(); | 4092 | emit signalmodified(); |
4077 | if (mModified != modified) { | 4093 | if (mModified != modified) { |
4078 | mModified = modified; | 4094 | mModified = modified; |
4079 | emit modifiedChanged(mModified); | 4095 | emit modifiedChanged(mModified); |
4080 | } | 4096 | } |
4081 | } | 4097 | } |
4082 | 4098 | ||
4083 | bool CalendarView::isReadOnly() | 4099 | bool CalendarView::isReadOnly() |
4084 | { | 4100 | { |
4085 | return mReadOnly; | 4101 | return mReadOnly; |
4086 | } | 4102 | } |
4087 | 4103 | ||
4088 | void CalendarView::setReadOnly(bool readOnly) | 4104 | void CalendarView::setReadOnly(bool readOnly) |
4089 | { | 4105 | { |
4090 | if (mReadOnly != readOnly) { | 4106 | if (mReadOnly != readOnly) { |
4091 | mReadOnly = readOnly; | 4107 | mReadOnly = readOnly; |
4092 | emit readOnlyChanged(mReadOnly); | 4108 | emit readOnlyChanged(mReadOnly); |
4093 | } | 4109 | } |
4094 | } | 4110 | } |
4095 | 4111 | ||
4096 | bool CalendarView::isModified() | 4112 | bool CalendarView::isModified() |
4097 | { | 4113 | { |
4098 | return mModified; | 4114 | return mModified; |
4099 | } | 4115 | } |
4100 | void CalendarView::slotprintSelInc() | 4116 | void CalendarView::slotprintSelInc() |
4101 | { | 4117 | { |
4102 | if ( currentSelection() == 0 ) { | 4118 | if ( currentSelection() == 0 ) { |
4103 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4119 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4104 | return; | 4120 | return; |
4105 | } | 4121 | } |
4106 | showIncidence(); | 4122 | showIncidence(); |
4107 | getEventViewerDialog()->print(); | 4123 | getEventViewerDialog()->print(); |
4108 | 4124 | ||
4109 | } | 4125 | } |
4110 | void CalendarView::printSetup() | 4126 | void CalendarView::printSetup() |
4111 | { | 4127 | { |
4112 | #ifndef KORG_NOPRINTER | 4128 | #ifndef KORG_NOPRINTER |
4113 | createPrinter(); | 4129 | createPrinter(); |
4114 | 4130 | ||
4115 | mCalPrinter->setupPrinter(); | 4131 | mCalPrinter->setupPrinter(); |
4116 | #endif | 4132 | #endif |
4117 | } | 4133 | } |
4118 | 4134 | ||
4119 | void CalendarView::print() | 4135 | void CalendarView::print() |
4120 | { | 4136 | { |
4121 | #ifndef KORG_NOPRINTER | 4137 | #ifndef KORG_NOPRINTER |
4122 | createPrinter(); | 4138 | createPrinter(); |
4123 | 4139 | ||
4124 | DateList tmpDateList = mNavigator->selectedDates(); | 4140 | DateList tmpDateList = mNavigator->selectedDates(); |
4125 | mCalPrinter->print(CalPrinter::Month, | 4141 | mCalPrinter->print(CalPrinter::Month, |
4126 | tmpDateList.first(), tmpDateList.last()); | 4142 | tmpDateList.first(), tmpDateList.last()); |
4127 | #endif | 4143 | #endif |
4128 | } | 4144 | } |
4129 | 4145 | ||
4130 | void CalendarView::printPreview() | 4146 | void CalendarView::printPreview() |
4131 | { | 4147 | { |
4132 | #ifndef KORG_NOPRINTER | 4148 | #ifndef KORG_NOPRINTER |
4133 | kdDebug() << "CalendarView::printPreview()" << endl; | 4149 | kdDebug() << "CalendarView::printPreview()" << endl; |
4134 | 4150 | ||
4135 | createPrinter(); | 4151 | createPrinter(); |
4136 | 4152 | ||
4137 | DateList tmpDateList = mNavigator->selectedDates(); | 4153 | DateList tmpDateList = mNavigator->selectedDates(); |
4138 | 4154 | ||
4139 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4155 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4140 | tmpDateList.last()); | 4156 | tmpDateList.last()); |
4141 | #endif | 4157 | #endif |
4142 | } | 4158 | } |
4143 | 4159 | ||
4144 | void CalendarView::exportICalendar() | 4160 | void CalendarView::exportICalendar() |
4145 | { | 4161 | { |
4146 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 4162 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
4147 | 4163 | ||
4148 | // Force correct extension | 4164 | // Force correct extension |
4149 | if (filename.right(4) != ".ics") filename += ".ics"; | 4165 | if (filename.right(4) != ".ics") filename += ".ics"; |
4150 | 4166 | ||
4151 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4167 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4152 | storage.save(); | 4168 | storage.save(); |
4153 | } | 4169 | } |
4154 | 4170 | ||
4155 | bool CalendarView::exportVCalendar( QString filename ) | 4171 | bool CalendarView::exportVCalendar( QString filename ) |
4156 | { | 4172 | { |
4157 | if (mCalendar->journals().count() > 0) { | 4173 | if (mCalendar->journals().count() > 0) { |
4158 | int result = KMessageBox::warningContinueCancel(this, | 4174 | int result = KMessageBox::warningContinueCancel(this, |
4159 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4175 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4160 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4176 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4161 | true); | 4177 | true); |
4162 | if (result != KMessageBox::Continue) return false; | 4178 | if (result != KMessageBox::Continue) return false; |
4163 | } | 4179 | } |
4164 | 4180 | ||
4165 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4181 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4166 | 4182 | ||
4167 | // Force correct extension | 4183 | // Force correct extension |
4168 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4184 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4169 | 4185 | ||
4170 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4186 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4171 | return storage.save(); | 4187 | return storage.save(); |
4172 | 4188 | ||
4173 | } | 4189 | } |
4174 | 4190 | ||
4175 | void CalendarView::eventUpdated(Incidence *) | 4191 | void CalendarView::eventUpdated(Incidence *) |
4176 | { | 4192 | { |
4177 | setModified(); | 4193 | setModified(); |
4178 | // Don't call updateView here. The code, which has caused the update of the | 4194 | // Don't call updateView here. The code, which has caused the update of the |
4179 | // event is responsible for updating the view. | 4195 | // event is responsible for updating the view. |
4180 | // updateView(); | 4196 | // updateView(); |
4181 | } | 4197 | } |
4182 | 4198 | ||
4183 | void CalendarView::adaptNavigationUnits() | 4199 | void CalendarView::adaptNavigationUnits() |
4184 | { | 4200 | { |
4185 | if (mViewManager->currentView()->isEventView()) { | 4201 | if (mViewManager->currentView()->isEventView()) { |
4186 | int days = mViewManager->currentView()->currentDateCount(); | 4202 | int days = mViewManager->currentView()->currentDateCount(); |
4187 | if (days == 1) { | 4203 | if (days == 1) { |
4188 | emit changeNavStringPrev(i18n("&Previous Day")); | 4204 | emit changeNavStringPrev(i18n("&Previous Day")); |
4189 | emit changeNavStringNext(i18n("&Next Day")); | 4205 | emit changeNavStringNext(i18n("&Next Day")); |
4190 | } else { | 4206 | } else { |
4191 | emit changeNavStringPrev(i18n("&Previous Week")); | 4207 | emit changeNavStringPrev(i18n("&Previous Week")); |
4192 | emit changeNavStringNext(i18n("&Next Week")); | 4208 | emit changeNavStringNext(i18n("&Next Week")); |
4193 | } | 4209 | } |
4194 | } | 4210 | } |
4195 | } | 4211 | } |
4196 | 4212 | ||
4197 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4213 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4198 | { | 4214 | { |
4199 | if ( incidence ) mTodoList->clearSelection(); | 4215 | if ( incidence ) mTodoList->clearSelection(); |
4200 | processIncidenceSelection( incidence ); | 4216 | processIncidenceSelection( incidence ); |
4201 | } | 4217 | } |
4202 | 4218 | ||
4203 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4219 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4204 | { | 4220 | { |
4205 | if ( incidence && mViewManager->currentView() ) { | 4221 | if ( incidence && mViewManager->currentView() ) { |
4206 | mViewManager->currentView()->clearSelection(); | 4222 | mViewManager->currentView()->clearSelection(); |
4207 | } | 4223 | } |
4208 | processIncidenceSelection( incidence ); | 4224 | processIncidenceSelection( incidence ); |
4209 | } | 4225 | } |
4210 | 4226 | ||
4211 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4227 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4212 | { | 4228 | { |
4213 | emit incidenceSelected( incidence ); | 4229 | emit incidenceSelected( incidence ); |
4214 | if ( incidence == mSelectedIncidence ) return; | 4230 | if ( incidence == mSelectedIncidence ) return; |
4215 | mSelectedIncidence = incidence; | 4231 | mSelectedIncidence = incidence; |
4216 | 4232 | ||
4217 | if ( incidence && incidence->typeID() == eventID ) { | 4233 | if ( incidence && incidence->typeID() == eventID ) { |
4218 | Event *event = static_cast<Event *>( incidence ); | 4234 | Event *event = static_cast<Event *>( incidence ); |
4219 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4235 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4220 | emit organizerEventsSelected( true ); | 4236 | emit organizerEventsSelected( true ); |
4221 | } else { | 4237 | } else { |
4222 | emit organizerEventsSelected(false); | 4238 | emit organizerEventsSelected(false); |
4223 | } | 4239 | } |
4224 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4240 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4225 | KOPrefs::instance()->email() ) ) { | 4241 | KOPrefs::instance()->email() ) ) { |
4226 | emit groupEventsSelected( true ); | 4242 | emit groupEventsSelected( true ); |
4227 | } else { | 4243 | } else { |
4228 | emit groupEventsSelected(false); | 4244 | emit groupEventsSelected(false); |
4229 | } | 4245 | } |
4230 | return; | 4246 | return; |
4231 | } else { | 4247 | } else { |
4232 | if ( incidence && incidence->typeID() == todoID ) { | 4248 | if ( incidence && incidence->typeID() == todoID ) { |
4233 | emit todoSelected( true ); | 4249 | emit todoSelected( true ); |
4234 | Todo *event = static_cast<Todo *>( incidence ); | 4250 | Todo *event = static_cast<Todo *>( incidence ); |
4235 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4251 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4236 | emit organizerEventsSelected( true ); | 4252 | emit organizerEventsSelected( true ); |
4237 | } else { | 4253 | } else { |
4238 | emit organizerEventsSelected(false); | 4254 | emit organizerEventsSelected(false); |
4239 | } | 4255 | } |
4240 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4256 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4241 | KOPrefs::instance()->email() ) ) { | 4257 | KOPrefs::instance()->email() ) ) { |
4242 | emit groupEventsSelected( true ); | 4258 | emit groupEventsSelected( true ); |
4243 | } else { | 4259 | } else { |
4244 | emit groupEventsSelected(false); | 4260 | emit groupEventsSelected(false); |
4245 | } | 4261 | } |
4246 | return; | 4262 | return; |
4247 | } else { | 4263 | } else { |
4248 | emit todoSelected( false ); | 4264 | emit todoSelected( false ); |
4249 | emit organizerEventsSelected(false); | 4265 | emit organizerEventsSelected(false); |
4250 | emit groupEventsSelected(false); | 4266 | emit groupEventsSelected(false); |
4251 | } | 4267 | } |
4252 | return; | 4268 | return; |
4253 | } | 4269 | } |
4254 | 4270 | ||
4255 | /* if ( incidence && incidence->typeID() == todoID ) { | 4271 | /* if ( incidence && incidence->typeID() == todoID ) { |
4256 | emit todoSelected( true ); | 4272 | emit todoSelected( true ); |
4257 | } else { | 4273 | } else { |
4258 | emit todoSelected( false ); | 4274 | emit todoSelected( false ); |
4259 | }*/ | 4275 | }*/ |
4260 | } | 4276 | } |
4261 | 4277 | ||
4262 | 4278 | ||
4263 | void CalendarView::checkClipboard() | 4279 | void CalendarView::checkClipboard() |
4264 | { | 4280 | { |
4265 | #ifndef KORG_NODND | 4281 | #ifndef KORG_NODND |
4266 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4282 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4267 | emit pasteEnabled(true); | 4283 | emit pasteEnabled(true); |
4268 | } else { | 4284 | } else { |
4269 | emit pasteEnabled(false); | 4285 | emit pasteEnabled(false); |
4270 | } | 4286 | } |
4271 | #endif | 4287 | #endif |
4272 | } | 4288 | } |
4273 | 4289 | ||
4274 | void CalendarView::showDates(const DateList &selectedDates) | 4290 | void CalendarView::showDates(const DateList &selectedDates) |
4275 | { | 4291 | { |
4276 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4292 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4277 | 4293 | ||
4278 | 4294 | ||
4279 | if ( !mBlockShowDates ) { | 4295 | if ( !mBlockShowDates ) { |
4280 | if ( mViewManager->currentView() ) { | 4296 | if ( mViewManager->currentView() ) { |
4281 | updateView( selectedDates.first(), selectedDates.last() ); | 4297 | updateView( selectedDates.first(), selectedDates.last() ); |
4282 | } else { | 4298 | } else { |
4283 | mViewManager->showAgendaView(); | 4299 | mViewManager->showAgendaView(); |
4284 | } | 4300 | } |
4285 | } | 4301 | } |
4286 | 4302 | ||
4287 | QDate date = selectedDates.first(); | 4303 | QDate date = selectedDates.first(); |
4288 | if ( ! date.isValid() ) { | 4304 | if ( ! date.isValid() ) { |
4289 | topLevelWidget()->setCaption(""); | 4305 | topLevelWidget()->setCaption(""); |
4290 | return; | 4306 | return; |
4291 | } | 4307 | } |
4292 | 4308 | ||
4293 | QString selDates; | 4309 | QString selDates; |
4294 | selDates = KGlobal::locale()->formatDate( date, true); | 4310 | selDates = KGlobal::locale()->formatDate( date, true); |
4295 | if (selectedDates.first() < selectedDates.last() ) | 4311 | if (selectedDates.first() < selectedDates.last() ) |
4296 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4312 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4297 | else { | 4313 | else { |
4298 | QString addString; | 4314 | QString addString; |
4299 | if ( date == QDateTime::currentDateTime().date() ) | 4315 | if ( date == QDateTime::currentDateTime().date() ) |
4300 | addString = i18n("Today"); | 4316 | addString = i18n("Today"); |
4301 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4317 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4302 | addString = i18n("Tomorrow"); | 4318 | addString = i18n("Tomorrow"); |
4303 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4319 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4304 | addString = i18n("Yesterday"); | 4320 | addString = i18n("Yesterday"); |
4305 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4321 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4306 | addString = i18n("Day before yesterday"); | 4322 | addString = i18n("Day before yesterday"); |
4307 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4323 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4308 | addString = i18n("Day after tomorrow"); | 4324 | addString = i18n("Day after tomorrow"); |
4309 | if ( !addString.isEmpty() ) { | 4325 | if ( !addString.isEmpty() ) { |
4310 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4326 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4311 | return; | 4327 | return; |
4312 | } | 4328 | } |
4313 | } | 4329 | } |
4314 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4330 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4315 | 4331 | ||
4316 | } | 4332 | } |
4317 | 4333 | ||
4318 | QPtrList<CalFilter> CalendarView::filters() | 4334 | QPtrList<CalFilter> CalendarView::filters() |
4319 | { | 4335 | { |
4320 | return mFilters; | 4336 | return mFilters; |
4321 | 4337 | ||
4322 | } | 4338 | } |
4323 | void CalendarView::editFilters() | 4339 | void CalendarView::editFilters() |
4324 | { | 4340 | { |
4325 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4341 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4326 | 4342 | ||
4327 | CalFilter *filter = mFilters.first(); | 4343 | CalFilter *filter = mFilters.first(); |
4328 | while(filter) { | 4344 | while(filter) { |
4329 | filter = mFilters.next(); | 4345 | filter = mFilters.next(); |
4330 | } | 4346 | } |
4331 | 4347 | ||
4332 | mDialogManager->showFilterEditDialog(&mFilters); | 4348 | mDialogManager->showFilterEditDialog(&mFilters); |
4333 | updateFilter(); | 4349 | updateFilter(); |
4334 | } | 4350 | } |
4335 | void CalendarView::toggleFilter() | 4351 | void CalendarView::toggleFilter() |
4336 | { | 4352 | { |
4337 | if ( mLeftFrame->isHidden() ) { | 4353 | if ( mLeftFrame->isHidden() ) { |
4338 | toggleExpand(); | 4354 | toggleExpand(); |
4339 | showFilter( true ); | 4355 | showFilter( true ); |
4340 | } else | 4356 | } else |
4341 | showFilter(! mCalEditView->isVisible()); | 4357 | showFilter(! mCalEditView->isVisible()); |
4342 | } | 4358 | } |
4343 | 4359 | ||
4344 | KOFilterView *CalendarView::filterView() | 4360 | KOFilterView *CalendarView::filterView() |
4345 | { | 4361 | { |
4346 | return mFilterView; | 4362 | return mFilterView; |
4347 | } | 4363 | } |
4348 | void CalendarView::selectFilter( int fil ) | 4364 | void CalendarView::selectFilter( int fil ) |
4349 | { | 4365 | { |
4350 | mFilterView->setSelectedFilter( fil ); | 4366 | mFilterView->setSelectedFilter( fil ); |
4351 | updateUnmanagedViews(); | 4367 | updateUnmanagedViews(); |
4352 | } | 4368 | } |
4353 | void CalendarView::showFilter(bool visible) | 4369 | void CalendarView::showFilter(bool visible) |
4354 | { | 4370 | { |
4355 | #if 1 | 4371 | #if 1 |
4356 | if (visible) { | 4372 | if (visible) { |
4357 | mCalEditView->readConfig(); | 4373 | mCalEditView->readConfig(); |
4358 | mCalEditView->show(); | 4374 | mCalEditView->show(); |
4359 | QValueList<int> sizes; | 4375 | QValueList<int> sizes; |
4360 | sizes = mLeftFrame->sizes(); | 4376 | sizes = mLeftFrame->sizes(); |
4361 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4377 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4362 | sizes.clear(); | 4378 | sizes.clear(); |
4363 | sizes << 100; | 4379 | sizes << 100; |
4364 | sizes << 0; | 4380 | sizes << 0; |
4365 | sizes << 0; | 4381 | sizes << 0; |
4366 | sizes << 100; | 4382 | sizes << 100; |
4367 | mLeftFrame->setSizes(sizes); | 4383 | mLeftFrame->setSizes(sizes); |
4368 | } | 4384 | } |
4369 | #if 0 | 4385 | #if 0 |
4370 | sizes = mLeftFrame->sizes(); | 4386 | sizes = mLeftFrame->sizes(); |
4371 | int ccc = 0; | 4387 | int ccc = 0; |
4372 | while ( ccc < sizes.count()) { | 4388 | while ( ccc < sizes.count()) { |
4373 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4389 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4374 | ++ccc; | 4390 | ++ccc; |
4375 | } | 4391 | } |
4376 | #endif | 4392 | #endif |
4377 | 4393 | ||
4378 | } | 4394 | } |
4379 | else { | 4395 | else { |
4380 | mCalEditView->hide(); | 4396 | mCalEditView->hide(); |
4381 | } | 4397 | } |
4382 | #else | 4398 | #else |
4383 | if (visible) mFilterView->show(); | 4399 | if (visible) mFilterView->show(); |
4384 | else mFilterView->hide(); | 4400 | else mFilterView->hide(); |
4385 | #endif | 4401 | #endif |
4386 | } | 4402 | } |
4387 | void CalendarView::toggleFilerEnabled( ) | 4403 | void CalendarView::toggleFilerEnabled( ) |
4388 | { | 4404 | { |
4389 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4405 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4390 | if ( !mFilterView->filtersEnabled() ) | 4406 | if ( !mFilterView->filtersEnabled() ) |
4391 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4407 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4392 | updateUnmanagedViews(); | 4408 | updateUnmanagedViews(); |
4393 | 4409 | ||
4394 | } | 4410 | } |
4395 | void CalendarView::updateFilter() | 4411 | void CalendarView::updateFilter() |
4396 | { | 4412 | { |
4397 | CalFilter *filter = mFilterView->selectedFilter(); | 4413 | CalFilter *filter = mFilterView->selectedFilter(); |
4398 | if (filter) { | 4414 | if (filter) { |
4399 | QString mess; | 4415 | QString mess; |
4400 | if (mFilterView->filtersEnabled()) { | 4416 | if (mFilterView->filtersEnabled()) { |
4401 | mess = i18n("Filter selected: ")+filter->name(); | 4417 | mess = i18n("Filter selected: ")+filter->name(); |
4402 | filter->setEnabled(true); | 4418 | filter->setEnabled(true); |
4403 | } | 4419 | } |
4404 | else filter->setEnabled(false); | 4420 | else filter->setEnabled(false); |
4405 | mCalendar->setFilter(filter); | 4421 | mCalendar->setFilter(filter); |
4406 | updateView(); | 4422 | updateView(); |
4407 | if ( !mess.isEmpty() ) | 4423 | if ( !mess.isEmpty() ) |
4408 | topLevelWidget()->setCaption( mess ); | 4424 | topLevelWidget()->setCaption( mess ); |
4409 | 4425 | ||
4410 | } | 4426 | } |
4411 | emit filtersUpdated(); | 4427 | emit filtersUpdated(); |
4412 | } | 4428 | } |
4413 | 4429 | ||
4414 | void CalendarView::filterEdited() | 4430 | void CalendarView::filterEdited() |
4415 | { | 4431 | { |
4416 | mFilterView->updateFilters(); | 4432 | mFilterView->updateFilters(); |
4417 | updateFilter(); | 4433 | updateFilter(); |
4418 | writeSettings(); | 4434 | writeSettings(); |
4419 | } | 4435 | } |
4420 | 4436 | ||
4421 | 4437 | ||
4422 | void CalendarView::takeOverEvent() | 4438 | void CalendarView::takeOverEvent() |
4423 | { | 4439 | { |
4424 | Incidence *incidence = currentSelection(); | 4440 | Incidence *incidence = currentSelection(); |
4425 | 4441 | ||
4426 | if (!incidence) return; | 4442 | if (!incidence) return; |
4427 | 4443 | ||
4428 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4444 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4429 | incidence->recreate(); | 4445 | incidence->recreate(); |
4430 | incidence->setReadOnly(false); | 4446 | incidence->setReadOnly(false); |
4431 | 4447 | ||
4432 | updateView(); | 4448 | updateView(); |
4433 | } | 4449 | } |
4434 | 4450 | ||
4435 | void CalendarView::takeOverCalendar() | 4451 | void CalendarView::takeOverCalendar() |
4436 | { | 4452 | { |
4437 | // TODO: Create Calendar::allIncidences() function and use it here | 4453 | // TODO: Create Calendar::allIncidences() function and use it here |
4438 | 4454 | ||
4439 | clearAllViews(); | 4455 | clearAllViews(); |
4440 | QPtrList<Event> events = mCalendar->events(); | 4456 | QPtrList<Event> events = mCalendar->events(); |
4441 | for(uint i=0; i<events.count(); ++i) { | 4457 | for(uint i=0; i<events.count(); ++i) { |
4442 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4458 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4443 | events.at(i)->recreate(); | 4459 | events.at(i)->recreate(); |
4444 | events.at(i)->setReadOnly(false); | 4460 | events.at(i)->setReadOnly(false); |
4445 | } | 4461 | } |
4446 | 4462 | ||
4447 | QPtrList<Todo> todos = mCalendar->todos(); | 4463 | QPtrList<Todo> todos = mCalendar->todos(); |
4448 | for(uint i=0; i<todos.count(); ++i) { | 4464 | for(uint i=0; i<todos.count(); ++i) { |
4449 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4465 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4450 | todos.at(i)->recreate(); | 4466 | todos.at(i)->recreate(); |
4451 | todos.at(i)->setReadOnly(false); | 4467 | todos.at(i)->setReadOnly(false); |
4452 | } | 4468 | } |
4453 | 4469 | ||
4454 | QPtrList<Journal> journals = mCalendar->journals(); | 4470 | QPtrList<Journal> journals = mCalendar->journals(); |
4455 | for(uint i=0; i<journals.count(); ++i) { | 4471 | for(uint i=0; i<journals.count(); ++i) { |
4456 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4472 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4457 | journals.at(i)->recreate(); | 4473 | journals.at(i)->recreate(); |
4458 | journals.at(i)->setReadOnly(false); | 4474 | journals.at(i)->setReadOnly(false); |
4459 | } | 4475 | } |
4460 | 4476 | ||
4461 | updateView(); | 4477 | updateView(); |
4462 | } | 4478 | } |
4463 | 4479 | ||
4464 | void CalendarView::showIntro() | 4480 | void CalendarView::showIntro() |
4465 | { | 4481 | { |
4466 | kdDebug() << "To be implemented." << endl; | 4482 | kdDebug() << "To be implemented." << endl; |
4467 | } | 4483 | } |
4468 | 4484 | ||
4469 | QWidgetStack *CalendarView::viewStack() | 4485 | QWidgetStack *CalendarView::viewStack() |
4470 | { | 4486 | { |
4471 | return mRightFrame; | 4487 | return mRightFrame; |
4472 | } | 4488 | } |
4473 | 4489 | ||
4474 | QWidget *CalendarView::leftFrame() | 4490 | QWidget *CalendarView::leftFrame() |
4475 | { | 4491 | { |
4476 | return ( QWidget *)mLeftFrame; | 4492 | return ( QWidget *)mLeftFrame; |
4477 | } | 4493 | } |
4478 | 4494 | ||
4479 | DateNavigator *CalendarView::dateNavigator() | 4495 | DateNavigator *CalendarView::dateNavigator() |
4480 | { | 4496 | { |
4481 | return mNavigator; | 4497 | return mNavigator; |
4482 | } | 4498 | } |
4483 | 4499 | ||
4484 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4500 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4485 | { | 4501 | { |
4486 | return mDateNavigator->navigatorView(); | 4502 | return mDateNavigator->navigatorView(); |
4487 | } | 4503 | } |
4488 | void CalendarView::toggleDateNavigatorWidget() | 4504 | void CalendarView::toggleDateNavigatorWidget() |
4489 | { | 4505 | { |
4490 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4506 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4491 | 4507 | ||
4492 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4508 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4493 | mDateNavigator->hide(); | 4509 | mDateNavigator->hide(); |
4494 | else | 4510 | else |
4495 | mDateNavigator->show(); | 4511 | mDateNavigator->show(); |
4496 | } | 4512 | } |
4497 | void CalendarView::addView(KOrg::BaseView *view) | 4513 | void CalendarView::addView(KOrg::BaseView *view) |
4498 | { | 4514 | { |
4499 | mViewManager->addView(view); | 4515 | mViewManager->addView(view); |
4500 | } | 4516 | } |
4501 | 4517 | ||
4502 | void CalendarView::showView(KOrg::BaseView *view) | 4518 | void CalendarView::showView(KOrg::BaseView *view) |
4503 | { | 4519 | { |
4504 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4520 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4505 | } | 4521 | } |
4506 | 4522 | ||
4507 | Incidence *CalendarView::currentSelection() | 4523 | Incidence *CalendarView::currentSelection() |
4508 | { | 4524 | { |
4509 | return mViewManager->currentSelection(); | 4525 | return mViewManager->currentSelection(); |
4510 | } | 4526 | } |
4511 | void CalendarView::toggleAllDaySize() | 4527 | void CalendarView::toggleAllDaySize() |
4512 | { | 4528 | { |
4513 | /* | 4529 | /* |
4514 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4530 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4515 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4531 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4516 | else | 4532 | else |
4517 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4533 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4518 | */ | 4534 | */ |
4519 | viewManager()->agendaView()->toggleAllDay(); | 4535 | viewManager()->agendaView()->toggleAllDay(); |
4520 | } | 4536 | } |
4521 | void CalendarView::toggleExpand() | 4537 | void CalendarView::toggleExpand() |
4522 | { | 4538 | { |
4523 | // if ( mLeftFrame->isHidden() ) { | 4539 | // if ( mLeftFrame->isHidden() ) { |
4524 | // mLeftFrame->show(); | 4540 | // mLeftFrame->show(); |
4525 | // emit calendarViewExpanded( false ); | 4541 | // emit calendarViewExpanded( false ); |
4526 | // } else { | 4542 | // } else { |
4527 | // mLeftFrame->hide(); | 4543 | // mLeftFrame->hide(); |
4528 | // emit calendarViewExpanded( true ); | 4544 | // emit calendarViewExpanded( true ); |
4529 | // } | 4545 | // } |
4530 | //qDebug(" CalendarView::toggleExpand()"); | 4546 | //qDebug(" CalendarView::toggleExpand()"); |
4531 | globalFlagBlockAgenda = 1; | 4547 | globalFlagBlockAgenda = 1; |
4532 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4548 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4533 | globalFlagBlockAgenda = 5; | 4549 | globalFlagBlockAgenda = 5; |
4534 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4550 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4535 | //mViewManager->showView( 0, true ); | 4551 | //mViewManager->showView( 0, true ); |
4536 | } | 4552 | } |
4537 | 4553 | ||
4538 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4554 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4539 | { | 4555 | { |
4540 | setModified( modified ); | 4556 | setModified( modified ); |
4541 | } | 4557 | } |
4542 | 4558 | ||
4543 | Todo *CalendarView::selectedTodo() | 4559 | Todo *CalendarView::selectedTodo() |
4544 | { | 4560 | { |
4545 | Incidence *incidence = currentSelection(); | 4561 | Incidence *incidence = currentSelection(); |
4546 | if ( incidence && incidence->typeID() == todoID ) { | 4562 | if ( incidence && incidence->typeID() == todoID ) { |
4547 | return static_cast<Todo *>( incidence ); | 4563 | return static_cast<Todo *>( incidence ); |
4548 | } | 4564 | } |
4549 | 4565 | ||
4550 | incidence = mTodoList->selectedIncidences().first(); | 4566 | incidence = mTodoList->selectedIncidences().first(); |
4551 | if ( incidence && incidence->typeID() == todoID ) { | 4567 | if ( incidence && incidence->typeID() == todoID ) { |
4552 | return static_cast<Todo *>( incidence ); | 4568 | return static_cast<Todo *>( incidence ); |
4553 | } | 4569 | } |
4554 | 4570 | ||
4555 | return 0; | 4571 | return 0; |
4556 | } | 4572 | } |
4557 | 4573 | ||
4558 | void CalendarView::showIncidence() | 4574 | void CalendarView::showIncidence() |
4559 | { | 4575 | { |
4560 | mViewerCallerIsSearchDialog = false; | 4576 | mViewerCallerIsSearchDialog = false; |
4561 | Incidence *incidence = currentSelection(); | 4577 | Incidence *incidence = currentSelection(); |
4562 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4578 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4563 | if ( incidence ) { | 4579 | if ( incidence ) { |
4564 | ShowIncidenceVisitor v; | 4580 | ShowIncidenceVisitor v; |
4565 | v.act( incidence, this ); | 4581 | v.act( incidence, this ); |
4566 | } | 4582 | } |
4567 | } | 4583 | } |
4568 | void CalendarView::editIncidenceDescription() | 4584 | void CalendarView::editIncidenceDescription() |
4569 | { | 4585 | { |
4570 | mFlagEditDescription = true; | 4586 | mFlagEditDescription = true; |
4571 | editIncidence(); | 4587 | editIncidence(); |
4572 | mFlagEditDescription = false; | 4588 | mFlagEditDescription = false; |
4573 | } | 4589 | } |
4574 | void CalendarView::editIncidence() | 4590 | void CalendarView::editIncidence() |
4575 | { | 4591 | { |
4576 | // qDebug("editIncidence() "); | 4592 | // qDebug("editIncidence() "); |
4577 | Incidence *incidence = currentSelection(); | 4593 | Incidence *incidence = currentSelection(); |
4578 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4594 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4579 | if ( incidence ) { | 4595 | if ( incidence ) { |
4580 | EditIncidenceVisitor v; | 4596 | EditIncidenceVisitor v; |
4581 | v.act( incidence, this ); | 4597 | v.act( incidence, this ); |
4582 | } | 4598 | } |
4583 | } | 4599 | } |
4584 | 4600 | ||
4585 | void CalendarView::deleteIncidence() | 4601 | void CalendarView::deleteIncidence() |
4586 | { | 4602 | { |
4587 | Incidence *incidence = currentSelection(); | 4603 | Incidence *incidence = currentSelection(); |
4588 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4604 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4589 | if ( incidence ) { | 4605 | if ( incidence ) { |
4590 | deleteIncidence(incidence); | 4606 | deleteIncidence(incidence); |
4591 | } | 4607 | } |
4592 | } | 4608 | } |
4593 | void CalendarView::showIncidence(QString uid) | 4609 | void CalendarView::showIncidence(QString uid) |
4594 | { | 4610 | { |
4595 | Incidence *inc = mCalendar->incidence( uid ); | 4611 | Incidence *inc = mCalendar->incidence( uid ); |
4596 | if ( inc ) | 4612 | if ( inc ) |
4597 | showIncidence( inc ); | 4613 | showIncidence( inc ); |
4598 | } | 4614 | } |
4599 | void CalendarView::showIncidence(Incidence *incidence) | 4615 | void CalendarView::showIncidence(Incidence *incidence) |
4600 | { | 4616 | { |
4601 | mViewerCallerIsSearchDialog = false; | 4617 | mViewerCallerIsSearchDialog = false; |
4602 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4618 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4603 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4619 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4604 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4620 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4605 | mViewerCallerIsSearchDialog = true; | 4621 | mViewerCallerIsSearchDialog = true; |
4606 | } | 4622 | } |
4607 | } | 4623 | } |
4608 | if ( incidence ) { | 4624 | if ( incidence ) { |
4609 | ShowIncidenceVisitor v; | 4625 | ShowIncidenceVisitor v; |
4610 | v.act( incidence, this ); | 4626 | v.act( incidence, this ); |
4611 | } | 4627 | } |
4612 | } | 4628 | } |
4613 | 4629 | ||
4614 | void CalendarView::editIncidence(Incidence *incidence) | 4630 | void CalendarView::editIncidence(Incidence *incidence) |
4615 | { | 4631 | { |
4616 | if ( incidence ) { | 4632 | if ( incidence ) { |
4617 | 4633 | ||
4618 | EditIncidenceVisitor v; | 4634 | EditIncidenceVisitor v; |
4619 | v.act( incidence, this ); | 4635 | v.act( incidence, this ); |
4620 | 4636 | ||
4621 | } | 4637 | } |
4622 | } | 4638 | } |
4623 | 4639 | ||
4624 | void CalendarView::deleteIncidence(Incidence *incidence) | 4640 | void CalendarView::deleteIncidence(Incidence *incidence) |
4625 | { | 4641 | { |
4626 | //qDebug(" CalendarView::deleteIncidence "); | 4642 | //qDebug(" CalendarView::deleteIncidence "); |
4627 | if ( incidence == 0 ) { | 4643 | if ( incidence == 0 ) { |
4628 | updateView(); | 4644 | updateView(); |
4629 | emit updateSearchDialog(); | 4645 | emit updateSearchDialog(); |
4630 | return; | 4646 | return; |
4631 | } | 4647 | } |
4632 | if ( incidence ) { | 4648 | if ( incidence ) { |
4633 | DeleteIncidenceVisitor v; | 4649 | DeleteIncidenceVisitor v; |
4634 | v.act( incidence, this ); | 4650 | v.act( incidence, this ); |
4635 | } | 4651 | } |
4636 | } | 4652 | } |
4637 | 4653 | ||
4638 | 4654 | ||
4639 | void CalendarView::lookForOutgoingMessages() | 4655 | void CalendarView::lookForOutgoingMessages() |
4640 | { | 4656 | { |
4641 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4657 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4642 | ogd->loadMessages(); | 4658 | ogd->loadMessages(); |
4643 | } | 4659 | } |
4644 | 4660 | ||
4645 | void CalendarView::lookForIncomingMessages() | 4661 | void CalendarView::lookForIncomingMessages() |
4646 | { | 4662 | { |
4647 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4663 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4648 | icd->retrieve(); | 4664 | icd->retrieve(); |
4649 | } | 4665 | } |
4650 | 4666 | ||
4651 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4667 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4652 | { | 4668 | { |
4653 | bool deleteTodo = true; | 4669 | bool deleteTodo = true; |
4654 | QPtrList<Incidence> subTodos; | 4670 | QPtrList<Incidence> subTodos; |
4655 | Incidence *aTodo; | 4671 | Incidence *aTodo; |
4656 | subTodos = t->relations(); | 4672 | subTodos = t->relations(); |
4657 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4673 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4658 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4674 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4659 | deleteTodo = false; | 4675 | deleteTodo = false; |
4660 | } | 4676 | } |
4661 | if ( deleteTodo ) { | 4677 | if ( deleteTodo ) { |
4662 | if ( t->isCompleted() && !t->doesRecur()) { | 4678 | if ( t->isCompleted() && !t->doesRecur()) { |
4663 | checkExternalId( t ); | 4679 | checkExternalId( t ); |
4664 | mCalendar->deleteTodo( t ); | 4680 | mCalendar->deleteTodo( t ); |
4665 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4681 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4666 | } | 4682 | } |
4667 | else | 4683 | else |
4668 | deleteTodo = false; | 4684 | deleteTodo = false; |
4669 | } | 4685 | } |
4670 | return deleteTodo; | 4686 | return deleteTodo; |
4671 | 4687 | ||
4672 | } | 4688 | } |
4673 | void CalendarView::purgeCompleted() | 4689 | void CalendarView::purgeCompleted() |
4674 | { | 4690 | { |
4675 | int result = KMessageBox::warningContinueCancel(this, | 4691 | int result = KMessageBox::warningContinueCancel(this, |
4676 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4692 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4677 | 4693 | ||
4678 | if (result == KMessageBox::Continue) { | 4694 | if (result == KMessageBox::Continue) { |
4679 | 4695 | ||
4680 | QPtrList<Todo> todoCal; | 4696 | QPtrList<Todo> todoCal; |
4681 | QPtrList<Todo> rootTodos; | 4697 | QPtrList<Todo> rootTodos; |
4682 | //QPtrList<Incidence> rel; | 4698 | //QPtrList<Incidence> rel; |
4683 | Todo *aTodo; | 4699 | Todo *aTodo; |
4684 | todoCal = calendar()->todos(); | 4700 | todoCal = calendar()->todos(); |
4685 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4701 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4686 | if ( !aTodo->relatedTo() ) | 4702 | if ( !aTodo->relatedTo() ) |
4687 | rootTodos.append( aTodo ); | 4703 | rootTodos.append( aTodo ); |
4688 | } | 4704 | } |
4689 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4705 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4690 | removeCompletedSubTodos( aTodo ); | 4706 | removeCompletedSubTodos( aTodo ); |
4691 | } | 4707 | } |
4692 | 4708 | ||
4693 | updateView(); | 4709 | updateView(); |
4694 | } | 4710 | } |
4695 | } | 4711 | } |
4696 | 4712 | ||
4697 | void CalendarView::slotCalendarChanged() | 4713 | void CalendarView::slotCalendarChanged() |
4698 | { | 4714 | { |
4699 | ; | 4715 | ; |
4700 | } | 4716 | } |
4701 | 4717 | ||
4702 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4718 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4703 | { | 4719 | { |
4704 | //qDebug(" alendarView::keyPressEvent "); | 4720 | //qDebug(" alendarView::keyPressEvent "); |
4705 | e->ignore(); | 4721 | e->ignore(); |
4706 | } | 4722 | } |
4707 | 4723 | ||
4708 | 4724 | ||
4709 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4725 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4710 | { | 4726 | { |
4711 | 4727 | ||
4712 | if ( manager != mSyncManager) | 4728 | if ( manager != mSyncManager) |
4713 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 4729 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
4714 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4730 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4715 | qDebug("KO: SyncKDE request detected!"); | 4731 | qDebug("KO: SyncKDE request detected!"); |
4716 | } | 4732 | } |
4717 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4733 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4718 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4734 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4719 | return syncCalendar( filename, mode ); | 4735 | return syncCalendar( filename, mode ); |
4720 | } | 4736 | } |
4721 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4737 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4722 | { | 4738 | { |
4723 | //mSyncManager = manager; | 4739 | //mSyncManager = manager; |
4724 | if ( manager != mSyncManager) | 4740 | if ( manager != mSyncManager) |
4725 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 4741 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
4726 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4742 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4727 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4743 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4728 | if ( resource == "sharp" ) | 4744 | if ( resource == "sharp" ) |
4729 | syncExternal( 0 ); | 4745 | syncExternal( 0 ); |
4730 | if ( resource == "phone" ) | 4746 | if ( resource == "phone" ) |
4731 | syncExternal( 1 ); | 4747 | syncExternal( 1 ); |
4732 | // pending setmodified | 4748 | // pending setmodified |
4733 | return true; | 4749 | return true; |
4734 | } | 4750 | } |
4735 | void CalendarView::setSyncManager(KSyncManager* manager) | 4751 | void CalendarView::setSyncManager(KSyncManager* manager) |
4736 | { | 4752 | { |
4737 | mSyncManager = manager; | 4753 | mSyncManager = manager; |
4738 | } | 4754 | } |
4739 | 4755 | ||
4740 | void CalendarView::removeSyncInfo( QString syncProfile) | 4756 | void CalendarView::removeSyncInfo( QString syncProfile) |
4741 | { | 4757 | { |
4742 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4758 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4743 | mCalendar->removeSyncInfo( syncProfile ); | 4759 | mCalendar->removeSyncInfo( syncProfile ); |
4744 | 4760 | ||
4745 | } | 4761 | } |
4746 | 4762 | ||
4747 | void CalendarView::undo_delete() | 4763 | void CalendarView::undo_delete() |
4748 | { | 4764 | { |
4749 | //qDebug("undo_delete() "); | 4765 | //qDebug("undo_delete() "); |
4750 | Incidence* undo = mCalendar->undoIncidence(); | 4766 | Incidence* undo = mCalendar->undoIncidence(); |
4751 | if ( !undo ) { | 4767 | if ( !undo ) { |
4752 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4768 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4753 | i18n("KO/Pi")); | 4769 | i18n("KO/Pi")); |
4754 | return; | 4770 | return; |
4755 | } | 4771 | } |
4756 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 4772 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
4757 | i18n("\nAre you sure you want\nto restore this?"), | 4773 | i18n("\nAre you sure you want\nto restore this?"), |
4758 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4774 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4759 | mCalendar->undoDeleteIncidence(); | 4775 | mCalendar->undoDeleteIncidence(); |
4760 | updateView(); | 4776 | updateView(); |
4761 | } | 4777 | } |
4762 | } | 4778 | } |
4763 | 4779 | ||
4764 | void CalendarView::slotViewerClosed() | 4780 | void CalendarView::slotViewerClosed() |
4765 | { | 4781 | { |
4766 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4782 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4767 | } | 4783 | } |
4768 | 4784 | ||
4769 | void CalendarView::resetFocus() | 4785 | void CalendarView::resetFocus() |
4770 | { | 4786 | { |
4771 | if ( mViewerCallerIsSearchDialog ) { | 4787 | if ( mViewerCallerIsSearchDialog ) { |
4772 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4788 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4773 | mDialogManager->getSearchDialog()->raise(); | 4789 | mDialogManager->getSearchDialog()->raise(); |
4774 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4790 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4775 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4791 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4776 | } else | 4792 | } else |
4777 | mViewerCallerIsSearchDialog = false; | 4793 | mViewerCallerIsSearchDialog = false; |
4778 | } | 4794 | } |
4779 | if ( !mViewerCallerIsSearchDialog ) { | 4795 | if ( !mViewerCallerIsSearchDialog ) { |
4780 | //mViewManager->currentView()->setFocus(); | 4796 | //mViewManager->currentView()->setFocus(); |
4781 | //qDebug("sssssssssssssssset focus "); | 4797 | //qDebug("sssssssssssssssset focus "); |
4782 | topLevelWidget()->raise(); | 4798 | topLevelWidget()->raise(); |
4783 | setActiveWindow(); | 4799 | setActiveWindow(); |
4784 | //setFocus(); | 4800 | //setFocus(); |
4785 | } | 4801 | } |
4786 | mViewerCallerIsSearchDialog = false; | 4802 | mViewerCallerIsSearchDialog = false; |
4787 | } | 4803 | } |
4788 | 4804 | ||
4789 | void CalendarView::showNextAlarms() | 4805 | void CalendarView::showNextAlarms() |
4790 | { | 4806 | { |
4791 | QString message; | 4807 | QString message; |
4792 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4808 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4793 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4809 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4794 | QString sum = mCalendar->nextSummary(); | 4810 | QString sum = mCalendar->nextSummary(); |
4795 | QDateTime nextA = mNextAlarmDateTime; | 4811 | QDateTime nextA = mNextAlarmDateTime; |
4796 | QDateTime cur = QDateTime::currentDateTime(); | 4812 | QDateTime cur = QDateTime::currentDateTime(); |
4797 | int secs = cur.secsTo( nextA ); | 4813 | int secs = cur.secsTo( nextA ); |
4798 | int min = secs /60; | 4814 | int min = secs /60; |
4799 | int hours = min /60; | 4815 | int hours = min /60; |
4800 | min = min % 60; | 4816 | min = min % 60; |
4801 | int days = hours /24; | 4817 | int days = hours /24; |
4802 | hours = hours % 24; | 4818 | hours = hours % 24; |
4803 | 4819 | ||
4804 | //message = i18n("The next alarm is in:\n"); | 4820 | //message = i18n("The next alarm is in:\n"); |
4805 | if ( days > 1 ) | 4821 | if ( days > 1 ) |
4806 | message += i18n("%1 days\n").arg( days ); | 4822 | message += i18n("%1 days\n").arg( days ); |
4807 | else if ( days == 1 ) | 4823 | else if ( days == 1 ) |
4808 | message += i18n("1 day\n"); | 4824 | message += i18n("1 day\n"); |
4809 | if ( hours > 1 ) | 4825 | if ( hours > 1 ) |
4810 | message += i18n("%1 hours\n").arg( hours ); | 4826 | message += i18n("%1 hours\n").arg( hours ); |
4811 | else if ( hours == 1 ) | 4827 | else if ( hours == 1 ) |
4812 | message += i18n("1 hour\n"); | 4828 | message += i18n("1 hour\n"); |
4813 | if ( min > 1 ) | 4829 | if ( min > 1 ) |
4814 | message += i18n("%1 minutes\n").arg( min ); | 4830 | message += i18n("%1 minutes\n").arg( min ); |
4815 | else if ( min == 1 ) | 4831 | else if ( min == 1 ) |
4816 | message += i18n("1 minute\n"); | 4832 | message += i18n("1 minute\n"); |
4817 | if ( message.isEmpty() ) | 4833 | if ( message.isEmpty() ) |
4818 | message = i18n("The next alarm is in\nless than one minute!"); | 4834 | message = i18n("The next alarm is in\nless than one minute!"); |
4819 | else | 4835 | else |
4820 | message = i18n("The next alarm is in:\n") + message; | 4836 | message = i18n("The next alarm is in:\n") + message; |
4821 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4837 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4822 | } else { | 4838 | } else { |
4823 | message = i18n("There is no next alarm."); | 4839 | message = i18n("There is no next alarm."); |
4824 | 4840 | ||
4825 | } | 4841 | } |
4826 | #ifdef DESKTOP_VERSION | 4842 | #ifdef DESKTOP_VERSION |
4827 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4843 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4828 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4844 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4829 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4845 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4830 | } | 4846 | } |
4831 | 4847 | ||
4832 | #endif | 4848 | #endif |
4833 | KMessageBox::information( this, message); | 4849 | KMessageBox::information( this, message); |
4834 | } | 4850 | } |