author | zautrix <zautrix> | 2005-06-29 20:50:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-29 20:50:39 (UTC) |
commit | d1ca2fd41cb1390843c974c985cae5912d458d51 (patch) (unidiff) | |
tree | 7df650cfed3562a9e98c9f1eac9da0ee6beec6c1 | |
parent | f55b992a98cc081207b23283aadcf2ecffc90a87 (diff) | |
download | kdepimpi-d1ca2fd41cb1390843c974c985cae5912d458d51.zip kdepimpi-d1ca2fd41cb1390843c974c985cae5912d458d51.tar.gz kdepimpi-d1ca2fd41cb1390843c974c985cae5912d458d51.tar.bz2 |
fhhh
-rw-r--r-- | korganizer/calendarview.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 623cf9d..214b829 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4560 +1,4562 @@ | |||
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 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
142 | 142 | ||
143 | { | 143 | { |
144 | mAlarms = alarms; | 144 | mAlarms = alarms; |
145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
146 | QString mText = "<table width=\"100%\">\n"; | 146 | QString mText = "<table width=\"100%\">\n"; |
147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
148 | #ifdef DESKTOP_VERSION | 148 | #ifdef DESKTOP_VERSION |
149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
150 | #else | 150 | #else |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
152 | #endif | 152 | #endif |
153 | // mText += "<img src=\""; | 153 | // mText += "<img src=\""; |
154 | // mText += ipath; | 154 | // mText += ipath; |
155 | // mText += "\">"; | 155 | // mText += "\">"; |
156 | //mEventDate = QDate::currentDate(); | 156 | //mEventDate = QDate::currentDate(); |
157 | #ifdef DESKTOP_VERSION | 157 | #ifdef DESKTOP_VERSION |
158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
159 | #else | 159 | #else |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
161 | #endif | 161 | #endif |
162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
163 | 163 | ||
164 | Incidence * inc = getNextInc( start ); | 164 | Incidence * inc = getNextInc( start ); |
165 | int time = 0; | 165 | int time = 0; |
166 | //mText += "<table>"; | 166 | //mText += "<table>"; |
167 | while ( inc ) { | 167 | while ( inc ) { |
168 | QDateTime dt ; | 168 | QDateTime dt ; |
169 | QString tempText = "<a "; | 169 | QString tempText = "<a "; |
170 | bool ok; | 170 | bool ok; |
171 | dt = inc->getNextOccurence( start, &ok ); | 171 | dt = inc->getNextOccurence( start, &ok ); |
172 | if ( !ok ) continue; | 172 | if ( !ok ) continue; |
173 | if ( inc->typeID() == eventID ) { | 173 | if ( inc->typeID() == eventID ) { |
174 | tempText += "href=\"event:"; | 174 | tempText += "href=\"event:"; |
175 | } else if ( inc->typeID() == todoID ) { | 175 | } else if ( inc->typeID() == todoID ) { |
176 | tempText += "href=\"todo:"; | 176 | tempText += "href=\"todo:"; |
177 | } | 177 | } |
178 | tempText += inc->uid() + "\">"; | 178 | tempText += inc->uid() + "\">"; |
179 | if ( inc->typeID() == todoID ) | 179 | if ( inc->typeID() == todoID ) |
180 | tempText += i18n("Todo: "); | 180 | tempText += i18n("Todo: "); |
181 | if ( inc->summary().length() > 0 ) | 181 | if ( inc->summary().length() > 0 ) |
182 | tempText += inc->summary(); | 182 | tempText += inc->summary(); |
183 | else | 183 | else |
184 | tempText += i18n("-no summary-"); | 184 | tempText += i18n("-no summary-"); |
185 | QString timestr; | 185 | QString timestr; |
186 | if (!inc->doesFloat()) | 186 | if (!inc->doesFloat()) |
187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
188 | else | 188 | else |
189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
192 | mText += "<table>"; | 192 | mText += "<table>"; |
193 | time = 1; | 193 | time = 1; |
194 | } | 194 | } |
195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
196 | if ( time > 0 ) | 196 | if ( time > 0 ) |
197 | mText +="</table>"; | 197 | mText +="</table>"; |
198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
199 | mText += "<table>"; | 199 | mText += "<table>"; |
200 | time = 2; | 200 | time = 2; |
201 | 201 | ||
202 | } | 202 | } |
203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
204 | if ( time > 0 ) | 204 | if ( time > 0 ) |
205 | mText +="</table>"; | 205 | mText +="</table>"; |
206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
207 | mText += "<table>"; | 207 | mText += "<table>"; |
208 | time = 3; | 208 | time = 3; |
209 | } | 209 | } |
210 | mText +="<tr><td><b>"; | 210 | mText +="<tr><td><b>"; |
211 | mText += timestr; | 211 | mText += timestr; |
212 | mText += "</b></td><td>"; | 212 | mText += "</b></td><td>"; |
213 | mText += tempText; | 213 | mText += tempText; |
214 | mText += "</td></tr>\n"; | 214 | mText += "</td></tr>\n"; |
215 | inc = getNextInc( start ); | 215 | inc = getNextInc( start ); |
216 | } | 216 | } |
217 | mText +="</table>"; | 217 | mText +="</table>"; |
218 | setText( mText ); | 218 | setText( mText ); |
219 | } | 219 | } |
220 | 220 | ||
221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
222 | { | 222 | { |
223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
224 | } | 224 | } |
225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
226 | { | 226 | { |
227 | QDateTime dt ; | 227 | QDateTime dt ; |
228 | Incidence * retInc; | 228 | Incidence * retInc; |
229 | Incidence * inc = mAlarms.first(); | 229 | Incidence * inc = mAlarms.first(); |
230 | if ( inc == 0 ) | 230 | if ( inc == 0 ) |
231 | return 0; | 231 | return 0; |
232 | bool ok; | 232 | bool ok; |
233 | dt = inc->getNextOccurence( start, &ok ); | 233 | dt = inc->getNextOccurence( start, &ok ); |
234 | if ( ! ok ) return 0; | 234 | if ( ! ok ) return 0; |
235 | QDateTime dtn ; | 235 | QDateTime dtn ; |
236 | retInc = inc; | 236 | retInc = inc; |
237 | inc = mAlarms.next(); | 237 | inc = mAlarms.next(); |
238 | while ( inc ) { | 238 | while ( inc ) { |
239 | dtn = inc->getNextOccurence( start, &ok ); | 239 | dtn = inc->getNextOccurence( start, &ok ); |
240 | if ( ! ok ) return 0; | 240 | if ( ! ok ) return 0; |
241 | if ( dtn < dt ) { | 241 | if ( dtn < dt ) { |
242 | dt = dtn; | 242 | dt = dtn; |
243 | retInc = inc; | 243 | retInc = inc; |
244 | } | 244 | } |
245 | inc = mAlarms.next(); | 245 | inc = mAlarms.next(); |
246 | } | 246 | } |
247 | mAlarms.remove( retInc ); | 247 | mAlarms.remove( retInc ); |
248 | return retInc; | 248 | return retInc; |
249 | 249 | ||
250 | } | 250 | } |
251 | void MissedAlarmTextBrowser::setSource(const QString & n) | 251 | void MissedAlarmTextBrowser::setSource(const QString & n) |
252 | { | 252 | { |
253 | if (n.startsWith("event:")) { | 253 | if (n.startsWith("event:")) { |
254 | #ifdef DESKTOP_VERSION | 254 | #ifdef DESKTOP_VERSION |
255 | emit showIncidence(n.mid(8)); | 255 | emit showIncidence(n.mid(8)); |
256 | #else | 256 | #else |
257 | emit showIncidence(n.mid(6)); | 257 | emit showIncidence(n.mid(6)); |
258 | #endif | 258 | #endif |
259 | return; | 259 | return; |
260 | } else if (n.startsWith("todo:")) { | 260 | } else if (n.startsWith("todo:")) { |
261 | #ifdef DESKTOP_VERSION | 261 | #ifdef DESKTOP_VERSION |
262 | emit showIncidence(n.mid(7)); | 262 | emit showIncidence(n.mid(7)); |
263 | #else | 263 | #else |
264 | emit showIncidence(n.mid(5)); | 264 | emit showIncidence(n.mid(5)); |
265 | #endif | 265 | #endif |
266 | return; | 266 | return; |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | class KOBeamPrefs : public QDialog | 271 | class KOBeamPrefs : public QDialog |
272 | { | 272 | { |
273 | public: | 273 | public: |
274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
275 | QDialog( parent, name, true ) | 275 | QDialog( parent, name, true ) |
276 | { | 276 | { |
277 | setCaption( i18n("Beam Options") ); | 277 | setCaption( i18n("Beam Options") ); |
278 | QVBoxLayout* lay = new QVBoxLayout( this ); | 278 | QVBoxLayout* lay = new QVBoxLayout( this ); |
279 | lay->setSpacing( 3 ); | 279 | lay->setSpacing( 3 ); |
280 | lay->setMargin( 3 ); | 280 | lay->setMargin( 3 ); |
281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
282 | lay->addWidget( format ); | 282 | lay->addWidget( format ); |
283 | format->setExclusive ( true ) ; | 283 | format->setExclusive ( true ) ; |
284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
285 | lay->addWidget( time ); time->setExclusive ( true ) ; | 285 | lay->addWidget( time ); time->setExclusive ( true ) ; |
286 | vcal = new QRadioButton(" vCalendar ", format ); | 286 | vcal = new QRadioButton(" vCalendar ", format ); |
287 | ical = new QRadioButton(" iCalendar ", format ); | 287 | ical = new QRadioButton(" iCalendar ", format ); |
288 | vcal->setChecked( true ); | 288 | vcal->setChecked( true ); |
289 | tz = new QRadioButton(i18n(" With timezone "), time ); | 289 | tz = new QRadioButton(i18n(" With timezone "), time ); |
290 | local = new QRadioButton(i18n(" Local time "), time ); | 290 | local = new QRadioButton(i18n(" Local time "), time ); |
291 | tz->setChecked( true ); | 291 | tz->setChecked( true ); |
292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
293 | lay->addWidget( ok ); | 293 | lay->addWidget( ok ); |
294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
295 | lay->addWidget( cancel ); | 295 | lay->addWidget( cancel ); |
296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
298 | resize( 200, 200 ); | 298 | resize( 200, 200 ); |
299 | } | 299 | } |
300 | 300 | ||
301 | bool beamVcal() { return vcal->isChecked(); } | 301 | bool beamVcal() { return vcal->isChecked(); } |
302 | bool beamLocal() { return local->isChecked(); } | 302 | bool beamLocal() { return local->isChecked(); } |
303 | private: | 303 | private: |
304 | QRadioButton* vcal, *ical, *local, *tz; | 304 | QRadioButton* vcal, *ical, *local, *tz; |
305 | }; | 305 | }; |
306 | class KOCatPrefs : public QDialog | 306 | class KOCatPrefs : public QDialog |
307 | { | 307 | { |
308 | public: | 308 | public: |
309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
310 | QDialog( parent, name, true ) | 310 | QDialog( parent, name, true ) |
311 | { | 311 | { |
312 | setCaption( i18n("Manage new Categories") ); | 312 | setCaption( i18n("Manage new Categories") ); |
313 | QVBoxLayout* lay = new QVBoxLayout( this ); | 313 | QVBoxLayout* lay = new QVBoxLayout( this ); |
314 | lay->setSpacing( 3 ); | 314 | lay->setSpacing( 3 ); |
315 | lay->setMargin( 3 ); | 315 | lay->setMargin( 3 ); |
316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
317 | lay->addWidget( lab ); | 317 | lay->addWidget( lab ); |
318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
319 | lay->addWidget( format ); | 319 | lay->addWidget( format ); |
320 | format->setExclusive ( true ) ; | 320 | format->setExclusive ( true ) ; |
321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
323 | addCatBut->setChecked( true ); | 323 | addCatBut->setChecked( true ); |
324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
325 | lay->addWidget( ok ); | 325 | lay->addWidget( ok ); |
326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
327 | lay->addWidget( cancel ); | 327 | lay->addWidget( cancel ); |
328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
330 | resize( 200, 200 ); | 330 | resize( 200, 200 ); |
331 | } | 331 | } |
332 | 332 | ||
333 | bool addCat() { return addCatBut->isChecked(); } | 333 | bool addCat() { return addCatBut->isChecked(); } |
334 | private: | 334 | private: |
335 | QRadioButton* addCatBut; | 335 | QRadioButton* addCatBut; |
336 | }; | 336 | }; |
337 | 337 | ||
338 | 338 | ||
339 | 339 | ||
340 | CalendarView::CalendarView( CalendarResources *calendar, | 340 | CalendarView::CalendarView( CalendarResources *calendar, |
341 | QWidget *parent, const char *name ) | 341 | QWidget *parent, const char *name ) |
342 | : CalendarViewBase( parent, name ), | 342 | : CalendarViewBase( parent, name ), |
343 | mCalendar( calendar ), | 343 | mCalendar( calendar ), |
344 | mResourceManager( calendar->resourceManager() ) | 344 | mResourceManager( calendar->resourceManager() ) |
345 | { | 345 | { |
346 | 346 | ||
347 | mEventEditor = 0; | 347 | mEventEditor = 0; |
348 | mTodoEditor = 0; | 348 | mTodoEditor = 0; |
349 | 349 | ||
350 | init(); | 350 | init(); |
351 | } | 351 | } |
352 | 352 | ||
353 | CalendarView::CalendarView( Calendar *calendar, | 353 | CalendarView::CalendarView( Calendar *calendar, |
354 | QWidget *parent, const char *name ) | 354 | QWidget *parent, const char *name ) |
355 | : CalendarViewBase( parent, name ), | 355 | : CalendarViewBase( parent, name ), |
356 | mCalendar( calendar ), | 356 | mCalendar( calendar ), |
357 | mResourceManager( 0 ) | 357 | mResourceManager( 0 ) |
358 | { | 358 | { |
359 | 359 | ||
360 | mEventEditor = 0; | 360 | mEventEditor = 0; |
361 | mTodoEditor = 0; | 361 | mTodoEditor = 0; |
362 | init(); | 362 | init(); |
363 | } | 363 | } |
364 | 364 | ||
365 | void CalendarView::init() | 365 | void CalendarView::init() |
366 | { | 366 | { |
367 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 367 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
368 | setFocusPolicy ( NoFocus ); | 368 | setFocusPolicy ( NoFocus ); |
369 | mViewerCallerIsSearchDialog = false; | 369 | mViewerCallerIsSearchDialog = false; |
370 | mBlockShowDates = false; | 370 | mBlockShowDates = false; |
371 | 371 | ||
372 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
373 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
374 | mViewManager = new KOViewManager( this ); | 374 | mViewManager = new KOViewManager( this ); |
375 | mDialogManager = new KODialogManager( this ); | 375 | mDialogManager = new KODialogManager( this ); |
376 | mEventViewerDialog = 0; | 376 | mEventViewerDialog = 0; |
377 | mModified = false; | 377 | mModified = false; |
378 | mReadOnly = false; | 378 | mReadOnly = false; |
379 | mSelectedIncidence = 0; | 379 | mSelectedIncidence = 0; |
380 | mCalPrinter = 0; | 380 | mCalPrinter = 0; |
381 | mFilters.setAutoDelete(true); | 381 | mFilters.setAutoDelete(true); |
382 | 382 | ||
383 | mCalendar->registerObserver( this ); | 383 | mCalendar->registerObserver( this ); |
384 | // TODO: Make sure that view is updated, when calendar is changed. | 384 | // TODO: Make sure that view is updated, when calendar is changed. |
385 | 385 | ||
386 | mStorage = new FileStorage( mCalendar ); | 386 | mStorage = new FileStorage( mCalendar ); |
387 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 387 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
388 | 388 | ||
389 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 389 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
390 | #ifndef KORG_NOSPLITTER | 390 | #ifndef KORG_NOSPLITTER |
391 | // create the main layout frames. | 391 | // create the main layout frames. |
392 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 392 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
393 | topLayout->addWidget(mPanner); | 393 | topLayout->addWidget(mPanner); |
394 | 394 | ||
395 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 395 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
396 | "CalendarView::LeftFrame"); | 396 | "CalendarView::LeftFrame"); |
397 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 397 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
398 | 398 | ||
399 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 399 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
400 | "CalendarView::DateNavigator" ); | 400 | "CalendarView::DateNavigator" ); |
401 | 401 | ||
402 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 402 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
403 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 403 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
404 | mTodoList->setNavigator( mNavigator ); | 404 | mTodoList->setNavigator( mNavigator ); |
405 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 405 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
406 | 406 | ||
407 | #ifdef KORG_NORESOURCEVIEW | 407 | #ifdef KORG_NORESOURCEVIEW |
408 | mResourceView = 0; | 408 | mResourceView = 0; |
409 | #else | 409 | #else |
410 | if ( mResourceManager ) { | 410 | if ( mResourceManager ) { |
411 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 411 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
412 | mResourceView->updateView(); | 412 | mResourceView->updateView(); |
413 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 413 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
414 | SLOT( updateView() ) ); | 414 | SLOT( updateView() ) ); |
415 | } else { | 415 | } else { |
416 | mResourceView = 0; | 416 | mResourceView = 0; |
417 | } | 417 | } |
418 | #endif | 418 | #endif |
419 | QWidget *rightBox = new QWidget( mPanner ); | 419 | QWidget *rightBox = new QWidget( mPanner ); |
420 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 420 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
421 | 421 | ||
422 | mRightFrame = new QWidgetStack( rightBox ); | 422 | mRightFrame = new QWidgetStack( rightBox ); |
423 | rightLayout->addWidget( mRightFrame, 1 ); | 423 | rightLayout->addWidget( mRightFrame, 1 ); |
424 | 424 | ||
425 | mLeftFrame = mLeftSplitter; | 425 | mLeftFrame = mLeftSplitter; |
426 | #else | 426 | #else |
427 | //QWidget *mainBox = new QWidget( this ); | 427 | //QWidget *mainBox = new QWidget( this ); |
428 | //QWidget *leftFrame = new QWidget( mainBox ); | 428 | //QWidget *leftFrame = new QWidget( mainBox ); |
429 | //QBoxLayout * mainBoxLayout; | 429 | //QBoxLayout * mainBoxLayout; |
430 | if ( KOPrefs::instance()->mVerticalScreen ) { | 430 | if ( KOPrefs::instance()->mVerticalScreen ) { |
431 | //mainBoxLayout = new QVBoxLayout(mainBox); | 431 | //mainBoxLayout = new QVBoxLayout(mainBox); |
432 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 432 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
433 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 433 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
434 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 434 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
435 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 435 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
436 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 436 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
437 | } else { | 437 | } else { |
438 | //mainBoxLayout = new QHBoxLayout(mainBox); | 438 | //mainBoxLayout = new QHBoxLayout(mainBox); |
439 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 439 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
440 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 440 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
441 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 441 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
442 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 442 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
443 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 443 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
444 | } | 444 | } |
445 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 445 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
446 | //QBoxLayout * leftFrameLayout; | 446 | //QBoxLayout * leftFrameLayout; |
447 | topLayout->addWidget( mMainFrame ); | 447 | topLayout->addWidget( mMainFrame ); |
448 | #ifdef DESKTOP_VERSION | 448 | #ifdef DESKTOP_VERSION |
449 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); | 449 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); |
450 | topLayout->addWidget( mDateScrollBar ); | 450 | topLayout->addWidget( mDateScrollBar ); |
451 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 451 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
452 | if ( QApplication::desktop()->width() < 800 ) | ||
453 | mDateScrollBar->hide(); | ||
452 | #endif | 454 | #endif |
453 | //mainBoxLayout->addWidget (mLeftFrame); | 455 | //mainBoxLayout->addWidget (mLeftFrame); |
454 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 456 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
455 | "CalendarView::DateNavigator" ); | 457 | "CalendarView::DateNavigator" ); |
456 | #if 0 | 458 | #if 0 |
457 | // FIXME | 459 | // FIXME |
458 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 460 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
459 | "CalendarView::DateNavigator", QDate::currentDate()); | 461 | "CalendarView::DateNavigator", QDate::currentDate()); |
460 | #endif | 462 | #endif |
461 | // mDateNavigator->blockSignals( true ); | 463 | // mDateNavigator->blockSignals( true ); |
462 | //leftFrameLayout->addWidget( mDateNavigator ); | 464 | //leftFrameLayout->addWidget( mDateNavigator ); |
463 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 465 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
464 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 466 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
465 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 467 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
466 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 468 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
467 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 469 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
468 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); |
469 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 471 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
470 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 472 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
471 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 473 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
472 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 474 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
473 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 475 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
474 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 476 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
475 | 477 | ||
476 | mTodoList->setNavigator( mNavigator ); | 478 | mTodoList->setNavigator( mNavigator ); |
477 | #if 0 | 479 | #if 0 |
478 | if ( QApplication::desktop()->width() < 480 ) { | 480 | if ( QApplication::desktop()->width() < 480 ) { |
479 | leftFrameLayout->addWidget(mFilterView); | 481 | leftFrameLayout->addWidget(mFilterView); |
480 | leftFrameLayout->addWidget(mTodoList, 2 ); | 482 | leftFrameLayout->addWidget(mTodoList, 2 ); |
481 | 483 | ||
482 | } else { | 484 | } else { |
483 | leftFrameLayout->addWidget(mTodoList,2 ); | 485 | leftFrameLayout->addWidget(mTodoList,2 ); |
484 | leftFrameLayout->addWidget(mFilterView ); | 486 | leftFrameLayout->addWidget(mFilterView ); |
485 | } | 487 | } |
486 | #endif | 488 | #endif |
487 | mFilterView->hide(); | 489 | mFilterView->hide(); |
488 | mCalEditView->hide(); | 490 | mCalEditView->hide(); |
489 | QWidget *rightBox = new QWidget( mMainFrame ); | 491 | QWidget *rightBox = new QWidget( mMainFrame ); |
490 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 492 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
491 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 493 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
492 | mRightFrame = new QWidgetStack( rightBox ); | 494 | mRightFrame = new QWidgetStack( rightBox ); |
493 | rightLayout->addWidget( mRightFrame, 10 ); | 495 | rightLayout->addWidget( mRightFrame, 10 ); |
494 | 496 | ||
495 | //mLeftFrame = (QWidget *)leftFrame; | 497 | //mLeftFrame = (QWidget *)leftFrame; |
496 | if ( KOPrefs::instance()->mVerticalScreen ) { | 498 | if ( KOPrefs::instance()->mVerticalScreen ) { |
497 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 499 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
498 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 500 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
499 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 501 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
500 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
501 | } else { | 503 | } else { |
502 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 504 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
503 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 505 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
504 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 506 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
505 | } | 507 | } |
506 | if ( !KOPrefs::instance()->mShowDateNavigator) | 508 | if ( !KOPrefs::instance()->mShowDateNavigator) |
507 | mDateNavigator->hide(); | 509 | mDateNavigator->hide(); |
508 | //qDebug("Calendarview Size %d %d ", width(), height()); | 510 | //qDebug("Calendarview Size %d %d ", width(), height()); |
509 | #endif | 511 | #endif |
510 | 512 | ||
511 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 513 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
512 | SLOT( showDates( const KCal::DateList & ) ) ); | 514 | SLOT( showDates( const KCal::DateList & ) ) ); |
513 | 515 | ||
514 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
515 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 517 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
516 | 518 | ||
517 | 519 | ||
518 | 520 | ||
519 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 521 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
520 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 522 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
521 | 523 | ||
522 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
523 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 525 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
524 | 526 | ||
525 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 527 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
526 | mNavigator, SLOT( selectPreviousYear() ) ); | 528 | mNavigator, SLOT( selectPreviousYear() ) ); |
527 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 529 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
528 | mNavigator, SLOT( selectNextYear() ) ); | 530 | mNavigator, SLOT( selectNextYear() ) ); |
529 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 531 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
530 | mNavigator, SLOT( selectPreviousMonth() ) ); | 532 | mNavigator, SLOT( selectPreviousMonth() ) ); |
531 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 533 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
532 | mNavigator, SLOT( selectNextMonth() ) ); | 534 | mNavigator, SLOT( selectNextMonth() ) ); |
533 | 535 | ||
534 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 536 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
535 | mNavigator, SLOT( selectPrevious() ) ); | 537 | mNavigator, SLOT( selectPrevious() ) ); |
536 | connect( mDateNavigator, SIGNAL( goNext() ), | 538 | connect( mDateNavigator, SIGNAL( goNext() ), |
537 | mNavigator, SLOT( selectNext() ) ); | 539 | mNavigator, SLOT( selectNext() ) ); |
538 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 540 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
539 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 541 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
540 | 542 | ||
541 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 543 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
542 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 544 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
543 | #if 0 | 545 | #if 0 |
544 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 546 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
545 | SLOT( incidenceAdded( Incidence *) ) ); | 547 | SLOT( incidenceAdded( Incidence *) ) ); |
546 | #endif | 548 | #endif |
547 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 549 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
548 | 550 | ||
549 | connect( this, SIGNAL( configChanged() ), | 551 | connect( this, SIGNAL( configChanged() ), |
550 | mDateNavigator, SLOT( updateConfig() ) ); | 552 | mDateNavigator, SLOT( updateConfig() ) ); |
551 | 553 | ||
552 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 554 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
553 | SLOT( newTodo() ) ); | 555 | SLOT( newTodo() ) ); |
554 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 556 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
555 | SLOT( newSubTodo( Todo * ) ) ); | 557 | SLOT( newSubTodo( Todo * ) ) ); |
556 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 558 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
557 | SLOT( editTodo( Todo * ) ) ); | 559 | SLOT( editTodo( Todo * ) ) ); |
558 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 560 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
559 | SLOT( showTodo( Todo *) ) ); | 561 | SLOT( showTodo( Todo *) ) ); |
560 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 562 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
561 | SLOT( deleteTodo( Todo *) ) ); | 563 | SLOT( deleteTodo( Todo *) ) ); |
562 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 564 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
563 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 565 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
564 | SLOT( purgeCompleted() ) ); | 566 | SLOT( purgeCompleted() ) ); |
565 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 567 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
566 | SIGNAL( todoModified( Todo *, int ) ) ); | 568 | SIGNAL( todoModified( Todo *, int ) ) ); |
567 | 569 | ||
568 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 570 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
569 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 571 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
570 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 572 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
571 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 573 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
572 | 574 | ||
573 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
574 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 576 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
575 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 577 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
576 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 578 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
577 | 579 | ||
578 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 580 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
579 | this, SLOT ( todo_unsub( Todo * ) ) ); | 581 | this, SLOT ( todo_unsub( Todo * ) ) ); |
580 | 582 | ||
581 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 583 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
582 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 584 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
583 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 585 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
584 | SLOT( updateTodo( Todo *, int ) ) ); | 586 | SLOT( updateTodo( Todo *, int ) ) ); |
585 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 587 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
586 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 588 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
587 | 589 | ||
588 | 590 | ||
589 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 591 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
590 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 592 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
591 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 593 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
592 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 594 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
593 | 595 | ||
594 | 596 | ||
595 | 597 | ||
596 | 598 | ||
597 | 599 | ||
598 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 600 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
599 | SLOT(checkClipboard())); | 601 | SLOT(checkClipboard())); |
600 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 602 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
601 | SLOT( processTodoListSelection( Incidence * ) ) ); | 603 | SLOT( processTodoListSelection( Incidence * ) ) ); |
602 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 604 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
603 | 605 | ||
604 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 606 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
605 | 607 | ||
606 | mDateFrame = new QVBox(0,0,WType_Popup); | 608 | mDateFrame = new QVBox(0,0,WType_Popup); |
607 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 609 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
608 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 610 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
609 | mDateFrame->setLineWidth(3); | 611 | mDateFrame->setLineWidth(3); |
610 | mDateFrame->hide(); | 612 | mDateFrame->hide(); |
611 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 613 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
612 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 614 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
613 | 615 | ||
614 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 616 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
615 | 617 | ||
616 | mEventEditor = mDialogManager->getEventEditor(); | 618 | mEventEditor = mDialogManager->getEventEditor(); |
617 | mTodoEditor = mDialogManager->getTodoEditor(); | 619 | mTodoEditor = mDialogManager->getTodoEditor(); |
618 | 620 | ||
619 | mFlagEditDescription = false; | 621 | mFlagEditDescription = false; |
620 | 622 | ||
621 | mSuspendTimer = new QTimer( this ); | 623 | mSuspendTimer = new QTimer( this ); |
622 | mAlarmTimer = new QTimer( this ); | 624 | mAlarmTimer = new QTimer( this ); |
623 | mRecheckAlarmTimer = new QTimer( this ); | 625 | mRecheckAlarmTimer = new QTimer( this ); |
624 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 626 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
625 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 627 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
626 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 628 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
627 | mAlarmDialog = new AlarmDialog( this ); | 629 | mAlarmDialog = new AlarmDialog( this ); |
628 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 630 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
629 | mAlarmDialog->setServerNotification( false ); | 631 | mAlarmDialog->setServerNotification( false ); |
630 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 632 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
631 | 633 | ||
632 | 634 | ||
633 | #ifndef DESKTOP_VERSION | 635 | #ifndef DESKTOP_VERSION |
634 | //US listen for arriving address resultsets | 636 | //US listen for arriving address resultsets |
635 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 637 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
636 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 638 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
637 | #endif | 639 | #endif |
638 | mDateNavigator->setCalendar( mCalendar ); | 640 | mDateNavigator->setCalendar( mCalendar ); |
639 | } | 641 | } |
640 | 642 | ||
641 | 643 | ||
642 | CalendarView::~CalendarView() | 644 | CalendarView::~CalendarView() |
643 | { | 645 | { |
644 | // kdDebug() << "~CalendarView()" << endl; | 646 | // kdDebug() << "~CalendarView()" << endl; |
645 | //qDebug("CalendarView::~CalendarView() "); | 647 | //qDebug("CalendarView::~CalendarView() "); |
646 | delete mDialogManager; | 648 | delete mDialogManager; |
647 | delete mViewManager; | 649 | delete mViewManager; |
648 | delete mStorage; | 650 | delete mStorage; |
649 | delete mDateFrame ; | 651 | delete mDateFrame ; |
650 | delete mEventViewerDialog; | 652 | delete mEventViewerDialog; |
651 | //kdDebug() << "~CalendarView() done" << endl; | 653 | //kdDebug() << "~CalendarView() done" << endl; |
652 | } | 654 | } |
653 | void CalendarView::setScrollBarStep(int val ) | 655 | void CalendarView::setScrollBarStep(int val ) |
654 | { | 656 | { |
655 | #ifdef DESKTOP_VERSION | 657 | #ifdef DESKTOP_VERSION |
656 | mDateScrollBar->setLineStep ( val ); | 658 | mDateScrollBar->setLineStep ( val ); |
657 | #endif | 659 | #endif |
658 | } | 660 | } |
659 | void CalendarView::scrollBarValue(int val ) | 661 | void CalendarView::scrollBarValue(int val ) |
660 | { | 662 | { |
661 | #ifdef DESKTOP_VERSION | 663 | #ifdef DESKTOP_VERSION |
662 | if ( QApplication::desktop()->width() < 800 ) return; | 664 | if ( QApplication::desktop()->width() < 800 ) return; |
663 | static bool block = false; | 665 | static bool block = false; |
664 | if ( block ) return; | 666 | if ( block ) return; |
665 | block = true; | 667 | block = true; |
666 | val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 668 | val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
667 | //qDebug("VAL %d ",val ); | 669 | //qDebug("VAL %d ",val ); |
668 | int count = mNavigator->selectedDates().count(); | 670 | int count = mNavigator->selectedDates().count(); |
669 | int year = mNavigator->selectedDates().first().year(); | 671 | int year = mNavigator->selectedDates().first().year(); |
670 | int day = mNavigator->selectedDates().first().dayOfYear(); | 672 | int day = mNavigator->selectedDates().first().dayOfYear(); |
671 | if ( val == day -1 ) { | 673 | if ( val == day -1 ) { |
672 | block = false; | 674 | block = false; |
673 | return; | 675 | return; |
674 | } | 676 | } |
675 | QDate d ( year,1,1 ); | 677 | QDate d ( year,1,1 ); |
676 | mNavigator->selectDates( d.addDays( val ), count ); | 678 | mNavigator->selectDates( d.addDays( val ), count ); |
677 | block = false; | 679 | block = false; |
678 | #endif | 680 | #endif |
679 | 681 | ||
680 | } | 682 | } |
681 | 683 | ||
682 | void CalendarView::checkAlarms() | 684 | void CalendarView::checkAlarms() |
683 | { | 685 | { |
684 | KConfig *config = KOGlobals::config(); | 686 | KConfig *config = KOGlobals::config(); |
685 | config->setGroup( "AppRun" ); | 687 | config->setGroup( "AppRun" ); |
686 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 688 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
687 | int daysto = dt.daysTo( QDate::currentDate() ); | 689 | int daysto = dt.daysTo( QDate::currentDate() ); |
688 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 690 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
689 | dt = dt.addDays( days ); | 691 | dt = dt.addDays( days ); |
690 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 692 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
691 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 693 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
692 | //qDebug("KO: Reading program stop %d ", secs); | 694 | //qDebug("KO: Reading program stop %d ", secs); |
693 | //secs -= ( 3600 * 24*3 ); // debug only | 695 | //secs -= ( 3600 * 24*3 ); // debug only |
694 | QDateTime latest = dt.addSecs ( secs ); | 696 | QDateTime latest = dt.addSecs ( secs ); |
695 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 697 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
696 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 698 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
697 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 699 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
698 | QPtrList<Incidence> al; | 700 | QPtrList<Incidence> al; |
699 | Incidence* inL = el.first(); | 701 | Incidence* inL = el.first(); |
700 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 702 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
701 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 703 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
702 | while ( inL ) { | 704 | while ( inL ) { |
703 | bool ok = false; | 705 | bool ok = false; |
704 | int offset = 0; | 706 | int offset = 0; |
705 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 707 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
706 | if ( ok ) { | 708 | if ( ok ) { |
707 | //qDebug("OK %s",next.toString().latin1()); | 709 | //qDebug("OK %s",next.toString().latin1()); |
708 | if ( next < cur ) { | 710 | if ( next < cur ) { |
709 | al.append( inL ); | 711 | al.append( inL ); |
710 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 712 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
711 | } | 713 | } |
712 | } | 714 | } |
713 | inL = el.next(); | 715 | inL = el.next(); |
714 | } | 716 | } |
715 | if ( al.count() ) { | 717 | if ( al.count() ) { |
716 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 718 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
717 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 719 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
718 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 720 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
719 | lay->setSpacing( 0 ); | 721 | lay->setSpacing( 0 ); |
720 | lay->setMargin( 0 ); | 722 | lay->setMargin( 0 ); |
721 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 723 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
722 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 724 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
723 | lay->addWidget( matb ); | 725 | lay->addWidget( matb ); |
724 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 726 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
725 | int wid = 210; | 727 | int wid = 210; |
726 | int x = QApplication::desktop()->width() - wid - 7; | 728 | int x = QApplication::desktop()->width() - wid - 7; |
727 | int y = QApplication::desktop()->height() - wid - 70; | 729 | int y = QApplication::desktop()->height() - wid - 70; |
728 | dia->setGeometry ( x,y,wid,wid); | 730 | dia->setGeometry ( x,y,wid,wid); |
729 | } else { | 731 | } else { |
730 | int si = 220; | 732 | int si = 220; |
731 | if ( QApplication::desktop()->width() > 470 ) | 733 | if ( QApplication::desktop()->width() > 470 ) |
732 | si = 400; | 734 | si = 400; |
733 | dia->resize(si,si/2); | 735 | dia->resize(si,si/2); |
734 | } | 736 | } |
735 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 737 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
736 | dia->show(); | 738 | dia->show(); |
737 | 739 | ||
738 | } | 740 | } |
739 | } | 741 | } |
740 | void CalendarView::showDay( QDate d ) | 742 | void CalendarView::showDay( QDate d ) |
741 | { | 743 | { |
742 | dateNavigator()->blockSignals( true ); | 744 | dateNavigator()->blockSignals( true ); |
743 | dateNavigator()->selectDate( d ); | 745 | dateNavigator()->selectDate( d ); |
744 | dateNavigator()->blockSignals( false ); | 746 | dateNavigator()->blockSignals( false ); |
745 | mViewManager->showDayView(); | 747 | mViewManager->showDayView(); |
746 | //dateNavigator()->selectDate( d ); | 748 | //dateNavigator()->selectDate( d ); |
747 | } | 749 | } |
748 | void CalendarView::timerAlarm() | 750 | void CalendarView::timerAlarm() |
749 | { | 751 | { |
750 | //qDebug("CalendarView::timerAlarm() "); | 752 | //qDebug("CalendarView::timerAlarm() "); |
751 | computeAlarm(mAlarmNotification ); | 753 | computeAlarm(mAlarmNotification ); |
752 | } | 754 | } |
753 | 755 | ||
754 | void CalendarView::suspendAlarm() | 756 | void CalendarView::suspendAlarm() |
755 | { | 757 | { |
756 | //qDebug(" CalendarView::suspendAlarm() "); | 758 | //qDebug(" CalendarView::suspendAlarm() "); |
757 | computeAlarm(mSuspendAlarmNotification ); | 759 | computeAlarm(mSuspendAlarmNotification ); |
758 | 760 | ||
759 | } | 761 | } |
760 | 762 | ||
761 | void CalendarView::startAlarm( QString mess , QString filename) | 763 | void CalendarView::startAlarm( QString mess , QString filename) |
762 | { | 764 | { |
763 | 765 | ||
764 | topLevelWidget()->showNormal(); | 766 | topLevelWidget()->showNormal(); |
765 | topLevelWidget()->setActiveWindow(); | 767 | topLevelWidget()->setActiveWindow(); |
766 | topLevelWidget()->raise(); | 768 | topLevelWidget()->raise(); |
767 | 769 | ||
768 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 770 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
769 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 771 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
770 | 772 | ||
771 | } | 773 | } |
772 | 774 | ||
773 | void CalendarView::checkNextTimerAlarm() | 775 | void CalendarView::checkNextTimerAlarm() |
774 | { | 776 | { |
775 | mCalendar->checkAlarmForIncidence( 0, true ); | 777 | mCalendar->checkAlarmForIncidence( 0, true ); |
776 | } | 778 | } |
777 | 779 | ||
778 | void CalendarView::computeAlarm( QString msg ) | 780 | void CalendarView::computeAlarm( QString msg ) |
779 | { | 781 | { |
780 | 782 | ||
781 | QString mess = msg; | 783 | QString mess = msg; |
782 | QString mAlarmMessage = mess.mid( 9 ); | 784 | QString mAlarmMessage = mess.mid( 9 ); |
783 | QString filename = MainWindow::resourcePath(); | 785 | QString filename = MainWindow::resourcePath(); |
784 | filename += "koalarm.wav"; | 786 | filename += "koalarm.wav"; |
785 | QString tempfilename; | 787 | QString tempfilename; |
786 | if ( mess.left( 13 ) == "suspend_alarm") { | 788 | if ( mess.left( 13 ) == "suspend_alarm") { |
787 | bool error = false; | 789 | bool error = false; |
788 | int len = mess.mid( 13 ).find("+++"); | 790 | int len = mess.mid( 13 ).find("+++"); |
789 | if ( len < 2 ) | 791 | if ( len < 2 ) |
790 | error = true; | 792 | error = true; |
791 | else { | 793 | else { |
792 | tempfilename = mess.mid( 13, len ); | 794 | tempfilename = mess.mid( 13, len ); |
793 | if ( !QFile::exists( tempfilename ) ) | 795 | if ( !QFile::exists( tempfilename ) ) |
794 | error = true; | 796 | error = true; |
795 | } | 797 | } |
796 | if ( ! error ) { | 798 | if ( ! error ) { |
797 | filename = tempfilename; | 799 | filename = tempfilename; |
798 | } | 800 | } |
799 | mAlarmMessage = mess.mid( 13+len+3 ); | 801 | mAlarmMessage = mess.mid( 13+len+3 ); |
800 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 802 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
801 | startAlarm( mAlarmMessage, filename); | 803 | startAlarm( mAlarmMessage, filename); |
802 | return; | 804 | return; |
803 | } | 805 | } |
804 | if ( mess.left( 11 ) == "timer_alarm") { | 806 | if ( mess.left( 11 ) == "timer_alarm") { |
805 | //mTimerTime = 0; | 807 | //mTimerTime = 0; |
806 | startAlarm( mess.mid( 11 ), filename ); | 808 | startAlarm( mess.mid( 11 ), filename ); |
807 | return; | 809 | return; |
808 | } | 810 | } |
809 | if ( mess.left( 10 ) == "proc_alarm") { | 811 | if ( mess.left( 10 ) == "proc_alarm") { |
810 | bool error = false; | 812 | bool error = false; |
811 | int len = mess.mid( 10 ).find("+++"); | 813 | int len = mess.mid( 10 ).find("+++"); |
812 | if ( len < 2 ) | 814 | if ( len < 2 ) |
813 | error = true; | 815 | error = true; |
814 | else { | 816 | else { |
815 | tempfilename = mess.mid( 10, len ); | 817 | tempfilename = mess.mid( 10, len ); |
816 | if ( !QFile::exists( tempfilename ) ) | 818 | if ( !QFile::exists( tempfilename ) ) |
817 | error = true; | 819 | error = true; |
818 | } | 820 | } |
819 | if ( error ) { | 821 | if ( error ) { |
820 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 822 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
821 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 823 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
822 | } else { | 824 | } else { |
823 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 825 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
824 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 826 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
825 | #ifndef _WIN32_ | 827 | #ifndef _WIN32_ |
826 | if ( vfork () == 0 ) { | 828 | if ( vfork () == 0 ) { |
827 | execl ( tempfilename.latin1(), 0 ); | 829 | execl ( tempfilename.latin1(), 0 ); |
828 | return; | 830 | return; |
829 | } | 831 | } |
830 | #else | 832 | #else |
831 | QProcess* p = new QProcess(); | 833 | QProcess* p = new QProcess(); |
832 | p->addArgument( tempfilename.latin1() ); | 834 | p->addArgument( tempfilename.latin1() ); |
833 | p->start(); | 835 | p->start(); |
834 | return; | 836 | return; |
835 | #endif | 837 | #endif |
836 | 838 | ||
837 | return; | 839 | return; |
838 | } | 840 | } |
839 | 841 | ||
840 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 842 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
841 | } | 843 | } |
842 | if ( mess.left( 11 ) == "audio_alarm") { | 844 | if ( mess.left( 11 ) == "audio_alarm") { |
843 | bool error = false; | 845 | bool error = false; |
844 | int len = mess.mid( 11 ).find("+++"); | 846 | int len = mess.mid( 11 ).find("+++"); |
845 | if ( len < 2 ) | 847 | if ( len < 2 ) |
846 | error = true; | 848 | error = true; |
847 | else { | 849 | else { |
848 | tempfilename = mess.mid( 11, len ); | 850 | tempfilename = mess.mid( 11, len ); |
849 | if ( !QFile::exists( tempfilename ) ) | 851 | if ( !QFile::exists( tempfilename ) ) |
850 | error = true; | 852 | error = true; |
851 | } | 853 | } |
852 | if ( ! error ) { | 854 | if ( ! error ) { |
853 | filename = tempfilename; | 855 | filename = tempfilename; |
854 | } | 856 | } |
855 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 857 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
856 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 858 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
857 | } | 859 | } |
858 | if ( mess.left( 9 ) == "cal_alarm") { | 860 | if ( mess.left( 9 ) == "cal_alarm") { |
859 | mAlarmMessage = mess.mid( 9 ) ; | 861 | mAlarmMessage = mess.mid( 9 ) ; |
860 | } | 862 | } |
861 | 863 | ||
862 | startAlarm( mAlarmMessage, filename ); | 864 | startAlarm( mAlarmMessage, filename ); |
863 | 865 | ||
864 | 866 | ||
865 | } | 867 | } |
866 | 868 | ||
867 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 869 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
868 | { | 870 | { |
869 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 871 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
870 | 872 | ||
871 | mSuspendAlarmNotification = noti; | 873 | mSuspendAlarmNotification = noti; |
872 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 874 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
873 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 875 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
874 | mSuspendTimer->start( ms , true ); | 876 | mSuspendTimer->start( ms , true ); |
875 | 877 | ||
876 | } | 878 | } |
877 | 879 | ||
878 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 880 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
879 | { | 881 | { |
880 | mNextAlarmDateTime = qdt; | 882 | mNextAlarmDateTime = qdt; |
881 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 883 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
882 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 884 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
883 | #ifndef DESKTOP_VERSION | 885 | #ifndef DESKTOP_VERSION |
884 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 886 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
885 | #endif | 887 | #endif |
886 | return; | 888 | return; |
887 | } | 889 | } |
888 | int maxSec; | 890 | int maxSec; |
889 | //maxSec = 5; //testing only | 891 | //maxSec = 5; //testing only |
890 | maxSec = 86400+3600; // one day+1hour | 892 | maxSec = 86400+3600; // one day+1hour |
891 | mAlarmNotification = noti; | 893 | mAlarmNotification = noti; |
892 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 894 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
893 | if ( sec > maxSec ) { | 895 | if ( sec > maxSec ) { |
894 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 896 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
895 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 897 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
896 | return; | 898 | return; |
897 | } else { | 899 | } else { |
898 | mRecheckAlarmTimer->stop(); | 900 | mRecheckAlarmTimer->stop(); |
899 | } | 901 | } |
900 | //qDebug("Alarm timer started with secs: %d ", sec); | 902 | //qDebug("Alarm timer started with secs: %d ", sec); |
901 | mAlarmTimer->start( sec *1000 , true ); | 903 | mAlarmTimer->start( sec *1000 , true ); |
902 | 904 | ||
903 | } | 905 | } |
904 | // called by mRecheckAlarmTimer to get next alarm | 906 | // called by mRecheckAlarmTimer to get next alarm |
905 | // we need this, because a QTimer has only a max range of 25 days | 907 | // we need this, because a QTimer has only a max range of 25 days |
906 | void CalendarView::recheckTimerAlarm() | 908 | void CalendarView::recheckTimerAlarm() |
907 | { | 909 | { |
908 | mAlarmTimer->stop(); | 910 | mAlarmTimer->stop(); |
909 | mRecheckAlarmTimer->stop(); | 911 | mRecheckAlarmTimer->stop(); |
910 | mCalendar->checkAlarmForIncidence( 0, true ); | 912 | mCalendar->checkAlarmForIncidence( 0, true ); |
911 | } | 913 | } |
912 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 914 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
913 | { | 915 | { |
914 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 916 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
915 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 917 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
916 | #ifndef DESKTOP_VERSION | 918 | #ifndef DESKTOP_VERSION |
917 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 919 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
918 | #endif | 920 | #endif |
919 | return; | 921 | return; |
920 | } | 922 | } |
921 | mAlarmTimer->stop(); | 923 | mAlarmTimer->stop(); |
922 | } | 924 | } |
923 | void CalendarView::selectWeekNum ( int num ) | 925 | void CalendarView::selectWeekNum ( int num ) |
924 | { | 926 | { |
925 | dateNavigator()->blockSignals( true ); | 927 | dateNavigator()->blockSignals( true ); |
926 | dateNavigator()->selectWeek( num ); | 928 | dateNavigator()->selectWeek( num ); |
927 | dateNavigator()->blockSignals( false ); | 929 | dateNavigator()->blockSignals( false ); |
928 | mViewManager->showWeekView(); | 930 | mViewManager->showWeekView(); |
929 | } | 931 | } |
930 | KOViewManager *CalendarView::viewManager() | 932 | KOViewManager *CalendarView::viewManager() |
931 | { | 933 | { |
932 | return mViewManager; | 934 | return mViewManager; |
933 | } | 935 | } |
934 | 936 | ||
935 | KODialogManager *CalendarView::dialogManager() | 937 | KODialogManager *CalendarView::dialogManager() |
936 | { | 938 | { |
937 | return mDialogManager; | 939 | return mDialogManager; |
938 | } | 940 | } |
939 | 941 | ||
940 | QDate CalendarView::startDate() | 942 | QDate CalendarView::startDate() |
941 | { | 943 | { |
942 | DateList dates = mNavigator->selectedDates(); | 944 | DateList dates = mNavigator->selectedDates(); |
943 | 945 | ||
944 | return dates.first(); | 946 | return dates.first(); |
945 | } | 947 | } |
946 | 948 | ||
947 | QDate CalendarView::endDate() | 949 | QDate CalendarView::endDate() |
948 | { | 950 | { |
949 | DateList dates = mNavigator->selectedDates(); | 951 | DateList dates = mNavigator->selectedDates(); |
950 | 952 | ||
951 | return dates.last(); | 953 | return dates.last(); |
952 | } | 954 | } |
953 | 955 | ||
954 | 956 | ||
955 | void CalendarView::createPrinter() | 957 | void CalendarView::createPrinter() |
956 | { | 958 | { |
957 | #ifndef KORG_NOPRINTER | 959 | #ifndef KORG_NOPRINTER |
958 | if (!mCalPrinter) { | 960 | if (!mCalPrinter) { |
959 | mCalPrinter = new CalPrinter(this, mCalendar); | 961 | mCalPrinter = new CalPrinter(this, mCalendar); |
960 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 962 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
961 | } | 963 | } |
962 | #endif | 964 | #endif |
963 | } | 965 | } |
964 | 966 | ||
965 | 967 | ||
966 | //KOPrefs::instance()->mWriteBackFile | 968 | //KOPrefs::instance()->mWriteBackFile |
967 | //KOPrefs::instance()->mWriteBackExistingOnly | 969 | //KOPrefs::instance()->mWriteBackExistingOnly |
968 | 970 | ||
969 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 971 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
970 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 972 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
971 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 973 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
972 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 974 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
973 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 975 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
974 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 976 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
975 | 977 | ||
976 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 978 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
977 | { | 979 | { |
978 | 980 | ||
979 | // 0 equal | 981 | // 0 equal |
980 | // 1 take local | 982 | // 1 take local |
981 | // 2 take remote | 983 | // 2 take remote |
982 | // 3 cancel | 984 | // 3 cancel |
983 | QDateTime lastSync = mLastCalendarSync; | 985 | QDateTime lastSync = mLastCalendarSync; |
984 | QDateTime localMod = local->lastModified(); | 986 | QDateTime localMod = local->lastModified(); |
985 | QDateTime remoteMod = remote->lastModified(); | 987 | QDateTime remoteMod = remote->lastModified(); |
986 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 988 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
987 | bool remCh, locCh; | 989 | bool remCh, locCh; |
988 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 990 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
989 | //if ( remCh ) | 991 | //if ( remCh ) |
990 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 992 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
991 | locCh = ( localMod > mLastCalendarSync ); | 993 | locCh = ( localMod > mLastCalendarSync ); |
992 | if ( !remCh && ! locCh ) { | 994 | if ( !remCh && ! locCh ) { |
993 | //qDebug("both not changed "); | 995 | //qDebug("both not changed "); |
994 | lastSync = localMod.addDays(1); | 996 | lastSync = localMod.addDays(1); |
995 | if ( mode <= SYNC_PREF_ASK ) | 997 | if ( mode <= SYNC_PREF_ASK ) |
996 | return 0; | 998 | return 0; |
997 | } else { | 999 | } else { |
998 | if ( locCh ) { | 1000 | if ( locCh ) { |
999 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1001 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1000 | lastSync = localMod.addDays( -1 ); | 1002 | lastSync = localMod.addDays( -1 ); |
1001 | if ( !remCh ) | 1003 | if ( !remCh ) |
1002 | remoteMod = ( lastSync.addDays( -1 ) ); | 1004 | remoteMod = ( lastSync.addDays( -1 ) ); |
1003 | } else { | 1005 | } else { |
1004 | //qDebug(" not loc changed "); | 1006 | //qDebug(" not loc changed "); |
1005 | lastSync = localMod.addDays( 1 ); | 1007 | lastSync = localMod.addDays( 1 ); |
1006 | if ( remCh ) | 1008 | if ( remCh ) |
1007 | remoteMod =( lastSync.addDays( 1 ) ); | 1009 | remoteMod =( lastSync.addDays( 1 ) ); |
1008 | 1010 | ||
1009 | } | 1011 | } |
1010 | } | 1012 | } |
1011 | full = true; | 1013 | full = true; |
1012 | if ( mode < SYNC_PREF_ASK ) | 1014 | if ( mode < SYNC_PREF_ASK ) |
1013 | mode = SYNC_PREF_ASK; | 1015 | mode = SYNC_PREF_ASK; |
1014 | } else { | 1016 | } else { |
1015 | if ( localMod == remoteMod ) | 1017 | if ( localMod == remoteMod ) |
1016 | // if ( local->revision() == remote->revision() ) | 1018 | // if ( local->revision() == remote->revision() ) |
1017 | return 0; | 1019 | return 0; |
1018 | 1020 | ||
1019 | } | 1021 | } |
1020 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1022 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1021 | 1023 | ||
1022 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1024 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1023 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1025 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1024 | //full = true; //debug only | 1026 | //full = true; //debug only |
1025 | if ( full ) { | 1027 | if ( full ) { |
1026 | bool equ = false; | 1028 | bool equ = false; |
1027 | if ( local->typeID() == eventID ) { | 1029 | if ( local->typeID() == eventID ) { |
1028 | equ = (*((Event*) local) == *((Event*) remote)); | 1030 | equ = (*((Event*) local) == *((Event*) remote)); |
1029 | } | 1031 | } |
1030 | else if ( local->typeID() == todoID ) | 1032 | else if ( local->typeID() == todoID ) |
1031 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1033 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1032 | else if ( local->typeID() == journalID ) | 1034 | else if ( local->typeID() == journalID ) |
1033 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1035 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1034 | if ( equ ) { | 1036 | if ( equ ) { |
1035 | //qDebug("equal "); | 1037 | //qDebug("equal "); |
1036 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1038 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1037 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1039 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1038 | } | 1040 | } |
1039 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1041 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1040 | return 0; | 1042 | return 0; |
1041 | 1043 | ||
1042 | }//else //debug only | 1044 | }//else //debug only |
1043 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1045 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1044 | } | 1046 | } |
1045 | int result; | 1047 | int result; |
1046 | bool localIsNew; | 1048 | bool localIsNew; |
1047 | //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() ); | 1049 | //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() ); |
1048 | 1050 | ||
1049 | 1051 | ||
1050 | // ************************************************ | 1052 | // ************************************************ |
1051 | // ************************************************ | 1053 | // ************************************************ |
1052 | // ************************************************ | 1054 | // ************************************************ |
1053 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1055 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1054 | // BUT remoteMod != localMod | 1056 | // BUT remoteMod != localMod |
1055 | 1057 | ||
1056 | 1058 | ||
1057 | if ( full && mode < SYNC_PREF_NEWEST ) | 1059 | if ( full && mode < SYNC_PREF_NEWEST ) |
1058 | mode = SYNC_PREF_ASK; | 1060 | mode = SYNC_PREF_ASK; |
1059 | 1061 | ||
1060 | switch( mode ) { | 1062 | switch( mode ) { |
1061 | case SYNC_PREF_LOCAL: | 1063 | case SYNC_PREF_LOCAL: |
1062 | if ( lastSync > remoteMod ) | 1064 | if ( lastSync > remoteMod ) |
1063 | return 1; | 1065 | return 1; |
1064 | if ( lastSync > localMod ) | 1066 | if ( lastSync > localMod ) |
1065 | return 2; | 1067 | return 2; |
1066 | return 1; | 1068 | return 1; |
1067 | break; | 1069 | break; |
1068 | case SYNC_PREF_REMOTE: | 1070 | case SYNC_PREF_REMOTE: |
1069 | if ( lastSync > localMod ) | 1071 | if ( lastSync > localMod ) |
1070 | return 2; | 1072 | return 2; |
1071 | if ( lastSync > remoteMod ) | 1073 | if ( lastSync > remoteMod ) |
1072 | return 1; | 1074 | return 1; |
1073 | return 2; | 1075 | return 2; |
1074 | break; | 1076 | break; |
1075 | case SYNC_PREF_NEWEST: | 1077 | case SYNC_PREF_NEWEST: |
1076 | if ( localMod >= remoteMod ) | 1078 | if ( localMod >= remoteMod ) |
1077 | return 1; | 1079 | return 1; |
1078 | else | 1080 | else |
1079 | return 2; | 1081 | return 2; |
1080 | break; | 1082 | break; |
1081 | case SYNC_PREF_ASK: | 1083 | case SYNC_PREF_ASK: |
1082 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1084 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1083 | if ( lastSync > remoteMod && lastSync > localMod) | 1085 | if ( lastSync > remoteMod && lastSync > localMod) |
1084 | return 0; | 1086 | return 0; |
1085 | if ( lastSync > remoteMod ) | 1087 | if ( lastSync > remoteMod ) |
1086 | return 1; | 1088 | return 1; |
1087 | if ( lastSync > localMod ) | 1089 | if ( lastSync > localMod ) |
1088 | return 2; | 1090 | return 2; |
1089 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1091 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1090 | localIsNew = localMod >= remoteMod; | 1092 | localIsNew = localMod >= remoteMod; |
1091 | if ( localIsNew ) | 1093 | if ( localIsNew ) |
1092 | getEventViewerDialog()->setColorMode( 1 ); | 1094 | getEventViewerDialog()->setColorMode( 1 ); |
1093 | else | 1095 | else |
1094 | getEventViewerDialog()->setColorMode( 2 ); | 1096 | getEventViewerDialog()->setColorMode( 2 ); |
1095 | getEventViewerDialog()->setIncidence(local); | 1097 | getEventViewerDialog()->setIncidence(local); |
1096 | if ( localIsNew ) | 1098 | if ( localIsNew ) |
1097 | getEventViewerDialog()->setColorMode( 2 ); | 1099 | getEventViewerDialog()->setColorMode( 2 ); |
1098 | else | 1100 | else |
1099 | getEventViewerDialog()->setColorMode( 1 ); | 1101 | getEventViewerDialog()->setColorMode( 1 ); |
1100 | getEventViewerDialog()->addIncidence(remote); | 1102 | getEventViewerDialog()->addIncidence(remote); |
1101 | getEventViewerDialog()->setColorMode( 0 ); | 1103 | getEventViewerDialog()->setColorMode( 0 ); |
1102 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1104 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1103 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1105 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1104 | getEventViewerDialog()->showMe(); | 1106 | getEventViewerDialog()->showMe(); |
1105 | result = getEventViewerDialog()->executeS( localIsNew ); | 1107 | result = getEventViewerDialog()->executeS( localIsNew ); |
1106 | return result; | 1108 | return result; |
1107 | 1109 | ||
1108 | break; | 1110 | break; |
1109 | case SYNC_PREF_FORCE_LOCAL: | 1111 | case SYNC_PREF_FORCE_LOCAL: |
1110 | return 1; | 1112 | return 1; |
1111 | break; | 1113 | break; |
1112 | case SYNC_PREF_FORCE_REMOTE: | 1114 | case SYNC_PREF_FORCE_REMOTE: |
1113 | return 2; | 1115 | return 2; |
1114 | break; | 1116 | break; |
1115 | 1117 | ||
1116 | default: | 1118 | default: |
1117 | // SYNC_PREF_TAKE_BOTH not implemented | 1119 | // SYNC_PREF_TAKE_BOTH not implemented |
1118 | break; | 1120 | break; |
1119 | } | 1121 | } |
1120 | return 0; | 1122 | return 0; |
1121 | } | 1123 | } |
1122 | Event* CalendarView::getLastSyncEvent() | 1124 | Event* CalendarView::getLastSyncEvent() |
1123 | { | 1125 | { |
1124 | Event* lse; | 1126 | Event* lse; |
1125 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1127 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1126 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1128 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1127 | if (!lse) { | 1129 | if (!lse) { |
1128 | lse = new Event(); | 1130 | lse = new Event(); |
1129 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1131 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1130 | QString sum = ""; | 1132 | QString sum = ""; |
1131 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1133 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1132 | sum = "E: "; | 1134 | sum = "E: "; |
1133 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1135 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1134 | lse->setDtStart( mLastCalendarSync ); | 1136 | lse->setDtStart( mLastCalendarSync ); |
1135 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1137 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1136 | lse->setCategories( i18n("SyncEvent") ); | 1138 | lse->setCategories( i18n("SyncEvent") ); |
1137 | lse->setReadOnly( true ); | 1139 | lse->setReadOnly( true ); |
1138 | mCalendar->addEvent( lse ); | 1140 | mCalendar->addEvent( lse ); |
1139 | } | 1141 | } |
1140 | 1142 | ||
1141 | return lse; | 1143 | return lse; |
1142 | 1144 | ||
1143 | } | 1145 | } |
1144 | 1146 | ||
1145 | // we check, if the to delete event has a id for a profile | 1147 | // we check, if the to delete event has a id for a profile |
1146 | // if yes, we set this id in the profile to delete | 1148 | // if yes, we set this id in the profile to delete |
1147 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1149 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1148 | { | 1150 | { |
1149 | if ( lastSync.count() == 0 ) { | 1151 | if ( lastSync.count() == 0 ) { |
1150 | //qDebug(" lastSync.count() == 0"); | 1152 | //qDebug(" lastSync.count() == 0"); |
1151 | return; | 1153 | return; |
1152 | } | 1154 | } |
1153 | if ( toDelete->typeID() == journalID ) | 1155 | if ( toDelete->typeID() == journalID ) |
1154 | return; | 1156 | return; |
1155 | 1157 | ||
1156 | Event* eve = lastSync.first(); | 1158 | Event* eve = lastSync.first(); |
1157 | 1159 | ||
1158 | while ( eve ) { | 1160 | while ( eve ) { |
1159 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1161 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1160 | if ( !id.isEmpty() ) { | 1162 | if ( !id.isEmpty() ) { |
1161 | QString des = eve->description(); | 1163 | QString des = eve->description(); |
1162 | QString pref = "e"; | 1164 | QString pref = "e"; |
1163 | if ( toDelete->typeID() == todoID ) | 1165 | if ( toDelete->typeID() == todoID ) |
1164 | pref = "t"; | 1166 | pref = "t"; |
1165 | des += pref+ id + ","; | 1167 | des += pref+ id + ","; |
1166 | eve->setReadOnly( false ); | 1168 | eve->setReadOnly( false ); |
1167 | eve->setDescription( des ); | 1169 | eve->setDescription( des ); |
1168 | //qDebug("setdes %s ", des.latin1()); | 1170 | //qDebug("setdes %s ", des.latin1()); |
1169 | eve->setReadOnly( true ); | 1171 | eve->setReadOnly( true ); |
1170 | } | 1172 | } |
1171 | eve = lastSync.next(); | 1173 | eve = lastSync.next(); |
1172 | } | 1174 | } |
1173 | 1175 | ||
1174 | } | 1176 | } |
1175 | void CalendarView::checkExternalId( Incidence * inc ) | 1177 | void CalendarView::checkExternalId( Incidence * inc ) |
1176 | { | 1178 | { |
1177 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1179 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1178 | checkExternSyncEvent( lastSync, inc ); | 1180 | checkExternSyncEvent( lastSync, inc ); |
1179 | 1181 | ||
1180 | } | 1182 | } |
1181 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1183 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1182 | { | 1184 | { |
1183 | bool syncOK = true; | 1185 | bool syncOK = true; |
1184 | int addedEvent = 0; | 1186 | int addedEvent = 0; |
1185 | int addedEventR = 0; | 1187 | int addedEventR = 0; |
1186 | int deletedEventR = 0; | 1188 | int deletedEventR = 0; |
1187 | int deletedEventL = 0; | 1189 | int deletedEventL = 0; |
1188 | int changedLocal = 0; | 1190 | int changedLocal = 0; |
1189 | int changedRemote = 0; | 1191 | int changedRemote = 0; |
1190 | int filteredIN = 0; | 1192 | int filteredIN = 0; |
1191 | int filteredOUT = 0; | 1193 | int filteredOUT = 0; |
1192 | //QPtrList<Event> el = local->rawEvents(); | 1194 | //QPtrList<Event> el = local->rawEvents(); |
1193 | Event* eventR; | 1195 | Event* eventR; |
1194 | QString uid; | 1196 | QString uid; |
1195 | int take; | 1197 | int take; |
1196 | Event* eventL; | 1198 | Event* eventL; |
1197 | Event* eventRSync; | 1199 | Event* eventRSync; |
1198 | Event* eventLSync; | 1200 | Event* eventLSync; |
1199 | clearAllViews(); | 1201 | clearAllViews(); |
1200 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1202 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1201 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1203 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1202 | bool fullDateRange = false; | 1204 | bool fullDateRange = false; |
1203 | local->resetTempSyncStat(); | 1205 | local->resetTempSyncStat(); |
1204 | mLastCalendarSync = QDateTime::currentDateTime(); | 1206 | mLastCalendarSync = QDateTime::currentDateTime(); |
1205 | if ( mSyncManager->syncWithDesktop() ) { | 1207 | if ( mSyncManager->syncWithDesktop() ) { |
1206 | remote->resetPilotStat(1); | 1208 | remote->resetPilotStat(1); |
1207 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1209 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1208 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1210 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1209 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1211 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1210 | } else { | 1212 | } else { |
1211 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1213 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1212 | } | 1214 | } |
1213 | } | 1215 | } |
1214 | QDateTime modifiedCalendar = mLastCalendarSync; | 1216 | QDateTime modifiedCalendar = mLastCalendarSync; |
1215 | eventLSync = getLastSyncEvent(); | 1217 | eventLSync = getLastSyncEvent(); |
1216 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1218 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1217 | if ( eventR ) { | 1219 | if ( eventR ) { |
1218 | eventRSync = (Event*) eventR->clone(); | 1220 | eventRSync = (Event*) eventR->clone(); |
1219 | remote->deleteEvent(eventR ); | 1221 | remote->deleteEvent(eventR ); |
1220 | 1222 | ||
1221 | } else { | 1223 | } else { |
1222 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1224 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1223 | eventRSync = (Event*)eventLSync->clone(); | 1225 | eventRSync = (Event*)eventLSync->clone(); |
1224 | } else { | 1226 | } else { |
1225 | fullDateRange = true; | 1227 | fullDateRange = true; |
1226 | eventRSync = new Event(); | 1228 | eventRSync = new Event(); |
1227 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1229 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1228 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1230 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1229 | eventRSync->setDtStart( mLastCalendarSync ); | 1231 | eventRSync->setDtStart( mLastCalendarSync ); |
1230 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1232 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1231 | eventRSync->setCategories( i18n("SyncEvent") ); | 1233 | eventRSync->setCategories( i18n("SyncEvent") ); |
1232 | } | 1234 | } |
1233 | } | 1235 | } |
1234 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1236 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1235 | fullDateRange = true; | 1237 | fullDateRange = true; |
1236 | 1238 | ||
1237 | if ( ! fullDateRange ) { | 1239 | if ( ! fullDateRange ) { |
1238 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1240 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1239 | 1241 | ||
1240 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1242 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1241 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1243 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1242 | fullDateRange = true; | 1244 | fullDateRange = true; |
1243 | } | 1245 | } |
1244 | } | 1246 | } |
1245 | if ( mSyncManager->syncWithDesktop() ) { | 1247 | if ( mSyncManager->syncWithDesktop() ) { |
1246 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1248 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1247 | } | 1249 | } |
1248 | if ( fullDateRange ) | 1250 | if ( fullDateRange ) |
1249 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1251 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1250 | else | 1252 | else |
1251 | mLastCalendarSync = eventLSync->dtStart(); | 1253 | mLastCalendarSync = eventLSync->dtStart(); |
1252 | // for resyncing if own file has changed | 1254 | // for resyncing if own file has changed |
1253 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1255 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1254 | mLastCalendarSync = loadedFileVersion; | 1256 | mLastCalendarSync = loadedFileVersion; |
1255 | //qDebug("setting mLastCalendarSync "); | 1257 | //qDebug("setting mLastCalendarSync "); |
1256 | } | 1258 | } |
1257 | //qDebug("*************************** "); | 1259 | //qDebug("*************************** "); |
1258 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1260 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1259 | QPtrList<Incidence> er = remote->rawIncidences(); | 1261 | QPtrList<Incidence> er = remote->rawIncidences(); |
1260 | Incidence* inR = er.first(); | 1262 | Incidence* inR = er.first(); |
1261 | Incidence* inL; | 1263 | Incidence* inL; |
1262 | QProgressBar bar( er.count(),0 ); | 1264 | QProgressBar bar( er.count(),0 ); |
1263 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1265 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1264 | 1266 | ||
1265 | // ************** setting up filter ************* | 1267 | // ************** setting up filter ************* |
1266 | CalFilter *filterIN = 0; | 1268 | CalFilter *filterIN = 0; |
1267 | CalFilter *filterOUT = 0; | 1269 | CalFilter *filterOUT = 0; |
1268 | CalFilter *filter = mFilters.first(); | 1270 | CalFilter *filter = mFilters.first(); |
1269 | while(filter) { | 1271 | while(filter) { |
1270 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1272 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1271 | filterIN = filter; | 1273 | filterIN = filter; |
1272 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1274 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1273 | filterOUT = filter; | 1275 | filterOUT = filter; |
1274 | filter = mFilters.next(); | 1276 | filter = mFilters.next(); |
1275 | } | 1277 | } |
1276 | int w = 300; | 1278 | int w = 300; |
1277 | if ( QApplication::desktop()->width() < 320 ) | 1279 | if ( QApplication::desktop()->width() < 320 ) |
1278 | w = 220; | 1280 | w = 220; |
1279 | int h = bar.sizeHint().height() ; | 1281 | int h = bar.sizeHint().height() ; |
1280 | int dw = QApplication::desktop()->width(); | 1282 | int dw = QApplication::desktop()->width(); |
1281 | int dh = QApplication::desktop()->height(); | 1283 | int dh = QApplication::desktop()->height(); |
1282 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1284 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1283 | bar.show(); | 1285 | bar.show(); |
1284 | int modulo = (er.count()/10)+1; | 1286 | int modulo = (er.count()/10)+1; |
1285 | int incCounter = 0; | 1287 | int incCounter = 0; |
1286 | while ( inR ) { | 1288 | while ( inR ) { |
1287 | if ( ! bar.isVisible() ) | 1289 | if ( ! bar.isVisible() ) |
1288 | return false; | 1290 | return false; |
1289 | if ( incCounter % modulo == 0 ) | 1291 | if ( incCounter % modulo == 0 ) |
1290 | bar.setProgress( incCounter ); | 1292 | bar.setProgress( incCounter ); |
1291 | ++incCounter; | 1293 | ++incCounter; |
1292 | uid = inR->uid(); | 1294 | uid = inR->uid(); |
1293 | bool skipIncidence = false; | 1295 | bool skipIncidence = false; |
1294 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1296 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1295 | skipIncidence = true; | 1297 | skipIncidence = true; |
1296 | QString idS; | 1298 | QString idS; |
1297 | qApp->processEvents(); | 1299 | qApp->processEvents(); |
1298 | if ( !skipIncidence ) { | 1300 | if ( !skipIncidence ) { |
1299 | inL = local->incidence( uid ); | 1301 | inL = local->incidence( uid ); |
1300 | if ( inL ) { // maybe conflict - same uid in both calendars | 1302 | if ( inL ) { // maybe conflict - same uid in both calendars |
1301 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1303 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1302 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1304 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1303 | if ( take == 3 ) | 1305 | if ( take == 3 ) |
1304 | return false; | 1306 | return false; |
1305 | if ( take == 1 ) {// take local ********************** | 1307 | if ( take == 1 ) {// take local ********************** |
1306 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1308 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1307 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1309 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1308 | else | 1310 | else |
1309 | idS = inR->IDStr(); | 1311 | idS = inR->IDStr(); |
1310 | remote->deleteIncidence( inR ); | 1312 | remote->deleteIncidence( inR ); |
1311 | inR = inL->clone(); | 1313 | inR = inL->clone(); |
1312 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1314 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1313 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1315 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1314 | inR->setIDStr( idS ); | 1316 | inR->setIDStr( idS ); |
1315 | remote->addIncidence( inR ); | 1317 | remote->addIncidence( inR ); |
1316 | if ( mSyncManager->syncWithDesktop() ) | 1318 | if ( mSyncManager->syncWithDesktop() ) |
1317 | inR->setPilotId( 2 ); | 1319 | inR->setPilotId( 2 ); |
1318 | ++changedRemote; | 1320 | ++changedRemote; |
1319 | } else {// take remote ********************** | 1321 | } else {// take remote ********************** |
1320 | idS = inL->IDStr(); | 1322 | idS = inL->IDStr(); |
1321 | int pid = inL->pilotId(); | 1323 | int pid = inL->pilotId(); |
1322 | local->deleteIncidence( inL ); | 1324 | local->deleteIncidence( inL ); |
1323 | inL = inR->clone(); | 1325 | inL = inR->clone(); |
1324 | if ( mSyncManager->syncWithDesktop() ) | 1326 | if ( mSyncManager->syncWithDesktop() ) |
1325 | inL->setPilotId( pid ); | 1327 | inL->setPilotId( pid ); |
1326 | inL->setIDStr( idS ); | 1328 | inL->setIDStr( idS ); |
1327 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1329 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1328 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1330 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1329 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1331 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1330 | } | 1332 | } |
1331 | local->addIncidence( inL ); | 1333 | local->addIncidence( inL ); |
1332 | ++changedLocal; | 1334 | ++changedLocal; |
1333 | } | 1335 | } |
1334 | } | 1336 | } |
1335 | } else { // no conflict ********** add or delete remote | 1337 | } else { // no conflict ********** add or delete remote |
1336 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1338 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1337 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1339 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1338 | QString des = eventLSync->description(); | 1340 | QString des = eventLSync->description(); |
1339 | QString pref = "e"; | 1341 | QString pref = "e"; |
1340 | if ( inR->typeID() == todoID ) | 1342 | if ( inR->typeID() == todoID ) |
1341 | pref = "t"; | 1343 | pref = "t"; |
1342 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1344 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1343 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1345 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1344 | //remote->deleteIncidence( inR ); | 1346 | //remote->deleteIncidence( inR ); |
1345 | ++deletedEventR; | 1347 | ++deletedEventR; |
1346 | } else { | 1348 | } else { |
1347 | inR->setLastModified( modifiedCalendar ); | 1349 | inR->setLastModified( modifiedCalendar ); |
1348 | inL = inR->clone(); | 1350 | inL = inR->clone(); |
1349 | inL->setIDStr( ":" ); | 1351 | inL->setIDStr( ":" ); |
1350 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1352 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1351 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1353 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1352 | local->addIncidence( inL ); | 1354 | local->addIncidence( inL ); |
1353 | ++addedEvent; | 1355 | ++addedEvent; |
1354 | 1356 | ||
1355 | } | 1357 | } |
1356 | } else { | 1358 | } else { |
1357 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1359 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1358 | inR->setLastModified( modifiedCalendar ); | 1360 | inR->setLastModified( modifiedCalendar ); |
1359 | inL = inR->clone(); | 1361 | inL = inR->clone(); |
1360 | inL->setIDStr( ":" ); | 1362 | inL->setIDStr( ":" ); |
1361 | local->addIncidence( inL ); | 1363 | local->addIncidence( inL ); |
1362 | ++addedEvent; | 1364 | ++addedEvent; |
1363 | 1365 | ||
1364 | } else { | 1366 | } else { |
1365 | checkExternSyncEvent(eventRSyncSharp, inR); | 1367 | checkExternSyncEvent(eventRSyncSharp, inR); |
1366 | remote->deleteIncidence( inR ); | 1368 | remote->deleteIncidence( inR ); |
1367 | ++deletedEventR; | 1369 | ++deletedEventR; |
1368 | } | 1370 | } |
1369 | } | 1371 | } |
1370 | } else { | 1372 | } else { |
1371 | ++filteredIN; | 1373 | ++filteredIN; |
1372 | } | 1374 | } |
1373 | } | 1375 | } |
1374 | } | 1376 | } |
1375 | inR = er.next(); | 1377 | inR = er.next(); |
1376 | } | 1378 | } |
1377 | QPtrList<Incidence> el = local->rawIncidences(); | 1379 | QPtrList<Incidence> el = local->rawIncidences(); |
1378 | inL = el.first(); | 1380 | inL = el.first(); |
1379 | modulo = (el.count()/10)+1; | 1381 | modulo = (el.count()/10)+1; |
1380 | bar.setCaption (i18n("Add / remove events") ); | 1382 | bar.setCaption (i18n("Add / remove events") ); |
1381 | bar.setTotalSteps ( el.count() ) ; | 1383 | bar.setTotalSteps ( el.count() ) ; |
1382 | bar.show(); | 1384 | bar.show(); |
1383 | incCounter = 0; | 1385 | incCounter = 0; |
1384 | 1386 | ||
1385 | while ( inL ) { | 1387 | while ( inL ) { |
1386 | 1388 | ||
1387 | qApp->processEvents(); | 1389 | qApp->processEvents(); |
1388 | if ( ! bar.isVisible() ) | 1390 | if ( ! bar.isVisible() ) |
1389 | return false; | 1391 | return false; |
1390 | if ( incCounter % modulo == 0 ) | 1392 | if ( incCounter % modulo == 0 ) |
1391 | bar.setProgress( incCounter ); | 1393 | bar.setProgress( incCounter ); |
1392 | ++incCounter; | 1394 | ++incCounter; |
1393 | uid = inL->uid(); | 1395 | uid = inL->uid(); |
1394 | bool skipIncidence = false; | 1396 | bool skipIncidence = false; |
1395 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1397 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1396 | skipIncidence = true; | 1398 | skipIncidence = true; |
1397 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1399 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1398 | skipIncidence = true; | 1400 | skipIncidence = true; |
1399 | if ( !skipIncidence ) { | 1401 | if ( !skipIncidence ) { |
1400 | inR = remote->incidence( uid ); | 1402 | inR = remote->incidence( uid ); |
1401 | if ( ! inR ) { | 1403 | if ( ! inR ) { |
1402 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1404 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1403 | // no conflict ********** add or delete local | 1405 | // no conflict ********** add or delete local |
1404 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1406 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1405 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1407 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1406 | checkExternSyncEvent(eventLSyncSharp, inL); | 1408 | checkExternSyncEvent(eventLSyncSharp, inL); |
1407 | local->deleteIncidence( inL ); | 1409 | local->deleteIncidence( inL ); |
1408 | ++deletedEventL; | 1410 | ++deletedEventL; |
1409 | } else { | 1411 | } else { |
1410 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1412 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1411 | inL->removeID(mCurrentSyncDevice ); | 1413 | inL->removeID(mCurrentSyncDevice ); |
1412 | ++addedEventR; | 1414 | ++addedEventR; |
1413 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1415 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1414 | inL->setLastModified( modifiedCalendar ); | 1416 | inL->setLastModified( modifiedCalendar ); |
1415 | inR = inL->clone(); | 1417 | inR = inL->clone(); |
1416 | inR->setIDStr( ":" ); | 1418 | inR->setIDStr( ":" ); |
1417 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1419 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1418 | remote->addIncidence( inR ); | 1420 | remote->addIncidence( inR ); |
1419 | } | 1421 | } |
1420 | } | 1422 | } |
1421 | } else { | 1423 | } else { |
1422 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1424 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1423 | checkExternSyncEvent(eventLSyncSharp, inL); | 1425 | checkExternSyncEvent(eventLSyncSharp, inL); |
1424 | local->deleteIncidence( inL ); | 1426 | local->deleteIncidence( inL ); |
1425 | ++deletedEventL; | 1427 | ++deletedEventL; |
1426 | } else { | 1428 | } else { |
1427 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1429 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1428 | ++addedEventR; | 1430 | ++addedEventR; |
1429 | inL->setLastModified( modifiedCalendar ); | 1431 | inL->setLastModified( modifiedCalendar ); |
1430 | inR = inL->clone(); | 1432 | inR = inL->clone(); |
1431 | inR->setIDStr( ":" ); | 1433 | inR->setIDStr( ":" ); |
1432 | remote->addIncidence( inR ); | 1434 | remote->addIncidence( inR ); |
1433 | } | 1435 | } |
1434 | } | 1436 | } |
1435 | } | 1437 | } |
1436 | } else { | 1438 | } else { |
1437 | ++filteredOUT; | 1439 | ++filteredOUT; |
1438 | } | 1440 | } |
1439 | } | 1441 | } |
1440 | } | 1442 | } |
1441 | inL = el.next(); | 1443 | inL = el.next(); |
1442 | } | 1444 | } |
1443 | int delFut = 0; | 1445 | int delFut = 0; |
1444 | int remRem = 0; | 1446 | int remRem = 0; |
1445 | if ( mSyncManager->mWriteBackInFuture ) { | 1447 | if ( mSyncManager->mWriteBackInFuture ) { |
1446 | er = remote->rawIncidences(); | 1448 | er = remote->rawIncidences(); |
1447 | remRem = er.count(); | 1449 | remRem = er.count(); |
1448 | inR = er.first(); | 1450 | inR = er.first(); |
1449 | QDateTime dt; | 1451 | QDateTime dt; |
1450 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1452 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1451 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1453 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1452 | while ( inR ) { | 1454 | while ( inR ) { |
1453 | if ( inR->typeID() == todoID ) { | 1455 | if ( inR->typeID() == todoID ) { |
1454 | Todo * t = (Todo*)inR; | 1456 | Todo * t = (Todo*)inR; |
1455 | if ( t->hasDueDate() ) | 1457 | if ( t->hasDueDate() ) |
1456 | dt = t->dtDue(); | 1458 | dt = t->dtDue(); |
1457 | else | 1459 | else |
1458 | dt = cur.addSecs( 62 ); | 1460 | dt = cur.addSecs( 62 ); |
1459 | } | 1461 | } |
1460 | else if (inR->typeID() == eventID ) { | 1462 | else if (inR->typeID() == eventID ) { |
1461 | bool ok; | 1463 | bool ok; |
1462 | dt = inR->getNextOccurence( cur, &ok ); | 1464 | dt = inR->getNextOccurence( cur, &ok ); |
1463 | if ( !ok ) | 1465 | if ( !ok ) |
1464 | dt = cur.addSecs( -62 ); | 1466 | dt = cur.addSecs( -62 ); |
1465 | } | 1467 | } |
1466 | else | 1468 | else |
1467 | dt = inR->dtStart(); | 1469 | dt = inR->dtStart(); |
1468 | if ( dt < cur || dt > end ) { | 1470 | if ( dt < cur || dt > end ) { |
1469 | remote->deleteIncidence( inR ); | 1471 | remote->deleteIncidence( inR ); |
1470 | ++delFut; | 1472 | ++delFut; |
1471 | } | 1473 | } |
1472 | inR = er.next(); | 1474 | inR = er.next(); |
1473 | } | 1475 | } |
1474 | } | 1476 | } |
1475 | bar.hide(); | 1477 | bar.hide(); |
1476 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1478 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1477 | eventLSync->setReadOnly( false ); | 1479 | eventLSync->setReadOnly( false ); |
1478 | eventLSync->setDtStart( mLastCalendarSync ); | 1480 | eventLSync->setDtStart( mLastCalendarSync ); |
1479 | eventRSync->setDtStart( mLastCalendarSync ); | 1481 | eventRSync->setDtStart( mLastCalendarSync ); |
1480 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1482 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1481 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1483 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1482 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1484 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1483 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1485 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1484 | eventLSync->setReadOnly( true ); | 1486 | eventLSync->setReadOnly( true ); |
1485 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1487 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1486 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1488 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1487 | remote->addEvent( eventRSync ); | 1489 | remote->addEvent( eventRSync ); |
1488 | else | 1490 | else |
1489 | delete eventRSync; | 1491 | delete eventRSync; |
1490 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1492 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1491 | QString mes; | 1493 | QString mes; |
1492 | 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 ); | 1494 | 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 ); |
1493 | QString delmess; | 1495 | QString delmess; |
1494 | if ( delFut ) { | 1496 | if ( delFut ) { |
1495 | 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); | 1497 | 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); |
1496 | mes += delmess; | 1498 | mes += delmess; |
1497 | } | 1499 | } |
1498 | mes = i18n("Local calendar changed!\n") +mes; | 1500 | mes = i18n("Local calendar changed!\n") +mes; |
1499 | mCalendar->checkAlarmForIncidence( 0, true ); | 1501 | mCalendar->checkAlarmForIncidence( 0, true ); |
1500 | qDebug( mes ); | 1502 | qDebug( mes ); |
1501 | if ( mSyncManager->mShowSyncSummary ) { | 1503 | if ( mSyncManager->mShowSyncSummary ) { |
1502 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1504 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1503 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1505 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1504 | qDebug("KO: WB cancelled "); | 1506 | qDebug("KO: WB cancelled "); |
1505 | mSyncManager->mWriteBackFile = false; | 1507 | mSyncManager->mWriteBackFile = false; |
1506 | return syncOK; | 1508 | return syncOK; |
1507 | } | 1509 | } |
1508 | } | 1510 | } |
1509 | return syncOK; | 1511 | return syncOK; |
1510 | } | 1512 | } |
1511 | 1513 | ||
1512 | void CalendarView::setSyncDevice( QString s ) | 1514 | void CalendarView::setSyncDevice( QString s ) |
1513 | { | 1515 | { |
1514 | mCurrentSyncDevice= s; | 1516 | mCurrentSyncDevice= s; |
1515 | } | 1517 | } |
1516 | void CalendarView::setSyncName( QString s ) | 1518 | void CalendarView::setSyncName( QString s ) |
1517 | { | 1519 | { |
1518 | mCurrentSyncName= s; | 1520 | mCurrentSyncName= s; |
1519 | } | 1521 | } |
1520 | bool CalendarView::syncCalendar(QString filename, int mode) | 1522 | bool CalendarView::syncCalendar(QString filename, int mode) |
1521 | { | 1523 | { |
1522 | //qDebug("syncCalendar %s ", filename.latin1()); | 1524 | //qDebug("syncCalendar %s ", filename.latin1()); |
1523 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1525 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1524 | CalendarLocal* calendar = new CalendarLocal(); | 1526 | CalendarLocal* calendar = new CalendarLocal(); |
1525 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1527 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1526 | FileStorage* storage = new FileStorage( calendar ); | 1528 | FileStorage* storage = new FileStorage( calendar ); |
1527 | bool syncOK = false; | 1529 | bool syncOK = false; |
1528 | storage->setFileName( filename ); | 1530 | storage->setFileName( filename ); |
1529 | // qDebug("loading ... "); | 1531 | // qDebug("loading ... "); |
1530 | if ( storage->load() ) { | 1532 | if ( storage->load() ) { |
1531 | getEventViewerDialog()->setSyncMode( true ); | 1533 | getEventViewerDialog()->setSyncMode( true ); |
1532 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1534 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1533 | getEventViewerDialog()->setSyncMode( false ); | 1535 | getEventViewerDialog()->setSyncMode( false ); |
1534 | if ( syncOK ) { | 1536 | if ( syncOK ) { |
1535 | if ( mSyncManager->mWriteBackFile ) | 1537 | if ( mSyncManager->mWriteBackFile ) |
1536 | { | 1538 | { |
1537 | storage->setSaveFormat( new ICalFormat() ); | 1539 | storage->setSaveFormat( new ICalFormat() ); |
1538 | storage->save(); | 1540 | storage->save(); |
1539 | } | 1541 | } |
1540 | } | 1542 | } |
1541 | setModified( true ); | 1543 | setModified( true ); |
1542 | } | 1544 | } |
1543 | delete storage; | 1545 | delete storage; |
1544 | delete calendar; | 1546 | delete calendar; |
1545 | if ( syncOK ) | 1547 | if ( syncOK ) |
1546 | updateView(); | 1548 | updateView(); |
1547 | return syncOK; | 1549 | return syncOK; |
1548 | } | 1550 | } |
1549 | 1551 | ||
1550 | void CalendarView::syncExternal( int mode ) | 1552 | void CalendarView::syncExternal( int mode ) |
1551 | { | 1553 | { |
1552 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1554 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1553 | 1555 | ||
1554 | qApp->processEvents(); | 1556 | qApp->processEvents(); |
1555 | CalendarLocal* calendar = new CalendarLocal(); | 1557 | CalendarLocal* calendar = new CalendarLocal(); |
1556 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1558 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1557 | bool syncOK = false; | 1559 | bool syncOK = false; |
1558 | bool loadSuccess = false; | 1560 | bool loadSuccess = false; |
1559 | PhoneFormat* phoneFormat = 0; | 1561 | PhoneFormat* phoneFormat = 0; |
1560 | emit tempDisableBR(true); | 1562 | emit tempDisableBR(true); |
1561 | #ifndef DESKTOP_VERSION | 1563 | #ifndef DESKTOP_VERSION |
1562 | SharpFormat* sharpFormat = 0; | 1564 | SharpFormat* sharpFormat = 0; |
1563 | if ( mode == 0 ) { // sharp | 1565 | if ( mode == 0 ) { // sharp |
1564 | sharpFormat = new SharpFormat () ; | 1566 | sharpFormat = new SharpFormat () ; |
1565 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1567 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1566 | 1568 | ||
1567 | } else | 1569 | } else |
1568 | #endif | 1570 | #endif |
1569 | if ( mode == 1 ) { // phone | 1571 | if ( mode == 1 ) { // phone |
1570 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1572 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1571 | mSyncManager->mPhoneDevice, | 1573 | mSyncManager->mPhoneDevice, |
1572 | mSyncManager->mPhoneConnection, | 1574 | mSyncManager->mPhoneConnection, |
1573 | mSyncManager->mPhoneModel); | 1575 | mSyncManager->mPhoneModel); |
1574 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1576 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1575 | 1577 | ||
1576 | } else { | 1578 | } else { |
1577 | emit tempDisableBR(false); | 1579 | emit tempDisableBR(false); |
1578 | return; | 1580 | return; |
1579 | } | 1581 | } |
1580 | if ( loadSuccess ) { | 1582 | if ( loadSuccess ) { |
1581 | getEventViewerDialog()->setSyncMode( true ); | 1583 | getEventViewerDialog()->setSyncMode( true ); |
1582 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1584 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1583 | getEventViewerDialog()->setSyncMode( false ); | 1585 | getEventViewerDialog()->setSyncMode( false ); |
1584 | qApp->processEvents(); | 1586 | qApp->processEvents(); |
1585 | if ( syncOK ) { | 1587 | if ( syncOK ) { |
1586 | if ( mSyncManager->mWriteBackFile ) | 1588 | if ( mSyncManager->mWriteBackFile ) |
1587 | { | 1589 | { |
1588 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1590 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1589 | Incidence* inc = iL.first(); | 1591 | Incidence* inc = iL.first(); |
1590 | if ( phoneFormat ) { | 1592 | if ( phoneFormat ) { |
1591 | while ( inc ) { | 1593 | while ( inc ) { |
1592 | inc->removeID(mCurrentSyncDevice); | 1594 | inc->removeID(mCurrentSyncDevice); |
1593 | inc = iL.next(); | 1595 | inc = iL.next(); |
1594 | } | 1596 | } |
1595 | } | 1597 | } |
1596 | #ifndef DESKTOP_VERSION | 1598 | #ifndef DESKTOP_VERSION |
1597 | if ( sharpFormat ) | 1599 | if ( sharpFormat ) |
1598 | sharpFormat->save(calendar); | 1600 | sharpFormat->save(calendar); |
1599 | #endif | 1601 | #endif |
1600 | if ( phoneFormat ) | 1602 | if ( phoneFormat ) |
1601 | phoneFormat->save(calendar); | 1603 | phoneFormat->save(calendar); |
1602 | iL = calendar->rawIncidences(); | 1604 | iL = calendar->rawIncidences(); |
1603 | inc = iL.first(); | 1605 | inc = iL.first(); |
1604 | Incidence* loc; | 1606 | Incidence* loc; |
1605 | while ( inc ) { | 1607 | while ( inc ) { |
1606 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1608 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1607 | loc = mCalendar->incidence(inc->uid() ); | 1609 | loc = mCalendar->incidence(inc->uid() ); |
1608 | if ( loc ) { | 1610 | if ( loc ) { |
1609 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1611 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1610 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1612 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1611 | } | 1613 | } |
1612 | } | 1614 | } |
1613 | inc = iL.next(); | 1615 | inc = iL.next(); |
1614 | } | 1616 | } |
1615 | Incidence* lse = getLastSyncEvent(); | 1617 | Incidence* lse = getLastSyncEvent(); |
1616 | if ( lse ) { | 1618 | if ( lse ) { |
1617 | lse->setReadOnly( false ); | 1619 | lse->setReadOnly( false ); |
1618 | lse->setDescription( "" ); | 1620 | lse->setDescription( "" ); |
1619 | lse->setReadOnly( true ); | 1621 | lse->setReadOnly( true ); |
1620 | } | 1622 | } |
1621 | } | 1623 | } |
1622 | } else { | 1624 | } else { |
1623 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1625 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1624 | } | 1626 | } |
1625 | setModified( true ); | 1627 | setModified( true ); |
1626 | } else { | 1628 | } else { |
1627 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1629 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1628 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1630 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1629 | question, i18n("Ok")) ; | 1631 | question, i18n("Ok")) ; |
1630 | 1632 | ||
1631 | } | 1633 | } |
1632 | delete calendar; | 1634 | delete calendar; |
1633 | updateView(); | 1635 | updateView(); |
1634 | emit tempDisableBR(false); | 1636 | emit tempDisableBR(false); |
1635 | return ;//syncOK; | 1637 | return ;//syncOK; |
1636 | 1638 | ||
1637 | } | 1639 | } |
1638 | 1640 | ||
1639 | bool CalendarView::importBday() | 1641 | bool CalendarView::importBday() |
1640 | { | 1642 | { |
1641 | #ifndef KORG_NOKABC | 1643 | #ifndef KORG_NOKABC |
1642 | 1644 | ||
1643 | #ifdef DESKTOP_VERSION | 1645 | #ifdef DESKTOP_VERSION |
1644 | int curCal = mCalendar->defaultCalendar(); | 1646 | int curCal = mCalendar->defaultCalendar(); |
1645 | int bd = mCalEditView->getBirtdayID(); | 1647 | int bd = mCalEditView->getBirtdayID(); |
1646 | if ( bd == 0 ) | 1648 | if ( bd == 0 ) |
1647 | return false; | 1649 | return false; |
1648 | mCalendar->setDefaultCalendar( bd ); | 1650 | mCalendar->setDefaultCalendar( bd ); |
1649 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1651 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1650 | KABC::AddressBook::Iterator it; | 1652 | KABC::AddressBook::Iterator it; |
1651 | int count = 0; | 1653 | int count = 0; |
1652 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1654 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1653 | ++count; | 1655 | ++count; |
1654 | } | 1656 | } |
1655 | QProgressBar bar(count,0 ); | 1657 | QProgressBar bar(count,0 ); |
1656 | int w = 300; | 1658 | int w = 300; |
1657 | if ( QApplication::desktop()->width() < 320 ) | 1659 | if ( QApplication::desktop()->width() < 320 ) |
1658 | w = 220; | 1660 | w = 220; |
1659 | int h = bar.sizeHint().height() ; | 1661 | int h = bar.sizeHint().height() ; |
1660 | int dw = QApplication::desktop()->width(); | 1662 | int dw = QApplication::desktop()->width(); |
1661 | int dh = QApplication::desktop()->height(); | 1663 | int dh = QApplication::desktop()->height(); |
1662 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1664 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1663 | bar.show(); | 1665 | bar.show(); |
1664 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1666 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1665 | qApp->processEvents(); | 1667 | qApp->processEvents(); |
1666 | count = 0; | 1668 | count = 0; |
1667 | int addCount = 0; | 1669 | int addCount = 0; |
1668 | KCal::Attendee* a = 0; | 1670 | KCal::Attendee* a = 0; |
1669 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1671 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1670 | if ( ! bar.isVisible() ) | 1672 | if ( ! bar.isVisible() ) |
1671 | return false; | 1673 | return false; |
1672 | bar.setProgress( count++ ); | 1674 | bar.setProgress( count++ ); |
1673 | qApp->processEvents(); | 1675 | qApp->processEvents(); |
1674 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1676 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1675 | if ( (*it).birthday().date().isValid() ){ | 1677 | if ( (*it).birthday().date().isValid() ){ |
1676 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1678 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1677 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1679 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1678 | ++addCount; | 1680 | ++addCount; |
1679 | } | 1681 | } |
1680 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1682 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1681 | if ( anni.isValid() ){ | 1683 | if ( anni.isValid() ){ |
1682 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1684 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1683 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1685 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1684 | ++addCount; | 1686 | ++addCount; |
1685 | } | 1687 | } |
1686 | } | 1688 | } |
1687 | mCalendar->setDefaultCalendar( curCal ); | 1689 | mCalendar->setDefaultCalendar( curCal ); |
1688 | updateView(); | 1690 | updateView(); |
1689 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1691 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1690 | #else //DESKTOP_VERSION | 1692 | #else //DESKTOP_VERSION |
1691 | 1693 | ||
1692 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1694 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1693 | // the result should now arrive through method insertBirthdays | 1695 | // the result should now arrive through method insertBirthdays |
1694 | 1696 | ||
1695 | #endif //DESKTOP_VERSION | 1697 | #endif //DESKTOP_VERSION |
1696 | 1698 | ||
1697 | #endif //KORG_NOKABC | 1699 | #endif //KORG_NOKABC |
1698 | 1700 | ||
1699 | 1701 | ||
1700 | return true; | 1702 | return true; |
1701 | } | 1703 | } |
1702 | 1704 | ||
1703 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1705 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1704 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1706 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1705 | const QStringList& anniversaryList, const QStringList& realNameList, | 1707 | const QStringList& anniversaryList, const QStringList& realNameList, |
1706 | const QStringList& emailList, const QStringList& assembledNameList, | 1708 | const QStringList& emailList, const QStringList& assembledNameList, |
1707 | const QStringList& uidList) | 1709 | const QStringList& uidList) |
1708 | { | 1710 | { |
1709 | 1711 | ||
1710 | //qDebug("KO::CalendarView::insertBirthdays"); | 1712 | //qDebug("KO::CalendarView::insertBirthdays"); |
1711 | if (uid == this->name()) | 1713 | if (uid == this->name()) |
1712 | { | 1714 | { |
1713 | int curCal = mCalendar->defaultCalendar(); | 1715 | int curCal = mCalendar->defaultCalendar(); |
1714 | int bd = mCalEditView->getBirtdayID(); | 1716 | int bd = mCalEditView->getBirtdayID(); |
1715 | if ( bd == 0 ) | 1717 | if ( bd == 0 ) |
1716 | return; | 1718 | return; |
1717 | mCalendar->setDefaultCalendar( bd ); | 1719 | mCalendar->setDefaultCalendar( bd ); |
1718 | 1720 | ||
1719 | 1721 | ||
1720 | int count = birthdayList.count(); | 1722 | int count = birthdayList.count(); |
1721 | int addCount = 0; | 1723 | int addCount = 0; |
1722 | KCal::Attendee* a = 0; | 1724 | KCal::Attendee* a = 0; |
1723 | 1725 | ||
1724 | //qDebug("CalView 1 %i", count); | 1726 | //qDebug("CalView 1 %i", count); |
1725 | 1727 | ||
1726 | QProgressBar bar(count,0 ); | 1728 | QProgressBar bar(count,0 ); |
1727 | int w = 300; | 1729 | int w = 300; |
1728 | if ( QApplication::desktop()->width() < 320 ) | 1730 | if ( QApplication::desktop()->width() < 320 ) |
1729 | w = 220; | 1731 | w = 220; |
1730 | int h = bar.sizeHint().height() ; | 1732 | int h = bar.sizeHint().height() ; |
1731 | int dw = QApplication::desktop()->width(); | 1733 | int dw = QApplication::desktop()->width(); |
1732 | int dh = QApplication::desktop()->height(); | 1734 | int dh = QApplication::desktop()->height(); |
1733 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1735 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1734 | bar.show(); | 1736 | bar.show(); |
1735 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1737 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1736 | qApp->processEvents(); | 1738 | qApp->processEvents(); |
1737 | 1739 | ||
1738 | QDate birthday; | 1740 | QDate birthday; |
1739 | QDate anniversary; | 1741 | QDate anniversary; |
1740 | QString realName; | 1742 | QString realName; |
1741 | QString email; | 1743 | QString email; |
1742 | QString assembledName; | 1744 | QString assembledName; |
1743 | QString uid; | 1745 | QString uid; |
1744 | bool ok = true; | 1746 | bool ok = true; |
1745 | for ( int i = 0; i < count; i++) | 1747 | for ( int i = 0; i < count; i++) |
1746 | { | 1748 | { |
1747 | if ( ! bar.isVisible() ) | 1749 | if ( ! bar.isVisible() ) |
1748 | return; | 1750 | return; |
1749 | bar.setProgress( i ); | 1751 | bar.setProgress( i ); |
1750 | qApp->processEvents(); | 1752 | qApp->processEvents(); |
1751 | 1753 | ||
1752 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1754 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1753 | if (!ok) { | 1755 | if (!ok) { |
1754 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1756 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1755 | } | 1757 | } |
1756 | 1758 | ||
1757 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1759 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1758 | if (!ok) { | 1760 | if (!ok) { |
1759 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1761 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1760 | } | 1762 | } |
1761 | realName = realNameList[i]; | 1763 | realName = realNameList[i]; |
1762 | email = emailList[i]; | 1764 | email = emailList[i]; |
1763 | assembledName = assembledNameList[i]; | 1765 | assembledName = assembledNameList[i]; |
1764 | uid = uidList[i]; | 1766 | uid = uidList[i]; |
1765 | //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() ); | 1767 | //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() ); |
1766 | 1768 | ||
1767 | if ( birthday.isValid() ){ | 1769 | if ( birthday.isValid() ){ |
1768 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1770 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1769 | KCal::Attendee::ReqParticipant,uid) ; | 1771 | KCal::Attendee::ReqParticipant,uid) ; |
1770 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1772 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1771 | ++addCount; | 1773 | ++addCount; |
1772 | } | 1774 | } |
1773 | 1775 | ||
1774 | if ( anniversary.isValid() ){ | 1776 | if ( anniversary.isValid() ){ |
1775 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1777 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1776 | KCal::Attendee::ReqParticipant,uid) ; | 1778 | KCal::Attendee::ReqParticipant,uid) ; |
1777 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1779 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1778 | ++addCount; | 1780 | ++addCount; |
1779 | } | 1781 | } |
1780 | } | 1782 | } |
1781 | 1783 | ||
1782 | mCalendar->setDefaultCalendar( curCal ); | 1784 | mCalendar->setDefaultCalendar( curCal ); |
1783 | updateView(); | 1785 | updateView(); |
1784 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1786 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1785 | 1787 | ||
1786 | } | 1788 | } |
1787 | 1789 | ||
1788 | } | 1790 | } |
1789 | 1791 | ||
1790 | 1792 | ||
1791 | 1793 | ||
1792 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1794 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1793 | { | 1795 | { |
1794 | //qDebug("addAnni "); | 1796 | //qDebug("addAnni "); |
1795 | Event * ev = new Event(); | 1797 | Event * ev = new Event(); |
1796 | ev->setOrganizer(KOPrefs::instance()->email()); | 1798 | ev->setOrganizer(KOPrefs::instance()->email()); |
1797 | if ( a ) { | 1799 | if ( a ) { |
1798 | ev->addAttendee( a ); | 1800 | ev->addAttendee( a ); |
1799 | } | 1801 | } |
1800 | QString kind; | 1802 | QString kind; |
1801 | if ( birthday ) { | 1803 | if ( birthday ) { |
1802 | kind = i18n( "Birthday" ); | 1804 | kind = i18n( "Birthday" ); |
1803 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1805 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1804 | } | 1806 | } |
1805 | else { | 1807 | else { |
1806 | kind = i18n( "Anniversary" ); | 1808 | kind = i18n( "Anniversary" ); |
1807 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1809 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1808 | } | 1810 | } |
1809 | ev->setCategories( kind ); | 1811 | ev->setCategories( kind ); |
1810 | ev->setDtStart( QDateTime(date) ); | 1812 | ev->setDtStart( QDateTime(date) ); |
1811 | ev->setDtEnd( QDateTime(date) ); | 1813 | ev->setDtEnd( QDateTime(date) ); |
1812 | ev->setFloats( true ); | 1814 | ev->setFloats( true ); |
1813 | Recurrence * rec = ev->recurrence(); | 1815 | Recurrence * rec = ev->recurrence(); |
1814 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1816 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1815 | rec->addYearlyNum( date.month() ); | 1817 | rec->addYearlyNum( date.month() ); |
1816 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1818 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1817 | delete ev; | 1819 | delete ev; |
1818 | return false; | 1820 | return false; |
1819 | } | 1821 | } |
1820 | return true; | 1822 | return true; |
1821 | 1823 | ||
1822 | } | 1824 | } |
1823 | bool CalendarView::importQtopia( const QString &categories, | 1825 | bool CalendarView::importQtopia( const QString &categories, |
1824 | const QString &datebook, | 1826 | const QString &datebook, |
1825 | const QString &todolist ) | 1827 | const QString &todolist ) |
1826 | { | 1828 | { |
1827 | 1829 | ||
1828 | QtopiaFormat qtopiaFormat; | 1830 | QtopiaFormat qtopiaFormat; |
1829 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1831 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1830 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1832 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1831 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1833 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1832 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1834 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1833 | 1835 | ||
1834 | updateView(); | 1836 | updateView(); |
1835 | return true; | 1837 | return true; |
1836 | 1838 | ||
1837 | #if 0 | 1839 | #if 0 |
1838 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1840 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1839 | mCurrentSyncDevice = "qtopia-XML"; | 1841 | mCurrentSyncDevice = "qtopia-XML"; |
1840 | if ( mSyncManager->mAskForPreferences ) | 1842 | if ( mSyncManager->mAskForPreferences ) |
1841 | edit_sync_options(); | 1843 | edit_sync_options(); |
1842 | qApp->processEvents(); | 1844 | qApp->processEvents(); |
1843 | CalendarLocal* calendar = new CalendarLocal(); | 1845 | CalendarLocal* calendar = new CalendarLocal(); |
1844 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1846 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1845 | bool syncOK = false; | 1847 | bool syncOK = false; |
1846 | QtopiaFormat qtopiaFormat; | 1848 | QtopiaFormat qtopiaFormat; |
1847 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1849 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1848 | bool loadOk = true; | 1850 | bool loadOk = true; |
1849 | if ( !categories.isEmpty() ) | 1851 | if ( !categories.isEmpty() ) |
1850 | loadOk = qtopiaFormat.load( calendar, categories ); | 1852 | loadOk = qtopiaFormat.load( calendar, categories ); |
1851 | if ( loadOk && !datebook.isEmpty() ) | 1853 | if ( loadOk && !datebook.isEmpty() ) |
1852 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1854 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1853 | if ( loadOk && !todolist.isEmpty() ) | 1855 | if ( loadOk && !todolist.isEmpty() ) |
1854 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1856 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1855 | 1857 | ||
1856 | if ( loadOk ) { | 1858 | if ( loadOk ) { |
1857 | getEventViewerDialog()->setSyncMode( true ); | 1859 | getEventViewerDialog()->setSyncMode( true ); |
1858 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1860 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1859 | getEventViewerDialog()->setSyncMode( false ); | 1861 | getEventViewerDialog()->setSyncMode( false ); |
1860 | qApp->processEvents(); | 1862 | qApp->processEvents(); |
1861 | if ( syncOK ) { | 1863 | if ( syncOK ) { |
1862 | if ( mSyncManager->mWriteBackFile ) | 1864 | if ( mSyncManager->mWriteBackFile ) |
1863 | { | 1865 | { |
1864 | // write back XML file | 1866 | // write back XML file |
1865 | 1867 | ||
1866 | } | 1868 | } |
1867 | setModified( true ); | 1869 | setModified( true ); |
1868 | } | 1870 | } |
1869 | } else { | 1871 | } else { |
1870 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1872 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1871 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1873 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1872 | question, i18n("Ok")) ; | 1874 | question, i18n("Ok")) ; |
1873 | } | 1875 | } |
1874 | delete calendar; | 1876 | delete calendar; |
1875 | updateView(); | 1877 | updateView(); |
1876 | return syncOK; | 1878 | return syncOK; |
1877 | 1879 | ||
1878 | 1880 | ||
1879 | #endif | 1881 | #endif |
1880 | 1882 | ||
1881 | } | 1883 | } |
1882 | 1884 | ||
1883 | void CalendarView::setSyncEventsReadOnly() | 1885 | void CalendarView::setSyncEventsReadOnly() |
1884 | { | 1886 | { |
1885 | mCalendar->setSyncEventsReadOnly(); | 1887 | mCalendar->setSyncEventsReadOnly(); |
1886 | } | 1888 | } |
1887 | 1889 | ||
1888 | bool CalendarView::loadCalendars() | 1890 | bool CalendarView::loadCalendars() |
1889 | { | 1891 | { |
1890 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1892 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1891 | KopiCalendarFile * cal = calendars.first(); | 1893 | KopiCalendarFile * cal = calendars.first(); |
1892 | mCalendar->setDefaultCalendar( 1 ); | 1894 | mCalendar->setDefaultCalendar( 1 ); |
1893 | openCalendar( MainWindow::defaultFileName(), false ); | 1895 | openCalendar( MainWindow::defaultFileName(), false ); |
1894 | cal = calendars.next(); | 1896 | cal = calendars.next(); |
1895 | while ( cal ) { | 1897 | while ( cal ) { |
1896 | addCalendar( cal ); | 1898 | addCalendar( cal ); |
1897 | cal = calendars.next(); | 1899 | cal = calendars.next(); |
1898 | } | 1900 | } |
1899 | restoreCalendarSettings(); | 1901 | restoreCalendarSettings(); |
1900 | return true; | 1902 | return true; |
1901 | } | 1903 | } |
1902 | bool CalendarView::restoreCalendarSettings() | 1904 | bool CalendarView::restoreCalendarSettings() |
1903 | { | 1905 | { |
1904 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 1906 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
1905 | KopiCalendarFile * cal = calendars.first(); | 1907 | KopiCalendarFile * cal = calendars.first(); |
1906 | while ( cal ) { | 1908 | while ( cal ) { |
1907 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 1909 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
1908 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 1910 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
1909 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 1911 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
1910 | if ( cal->isStandard ) | 1912 | if ( cal->isStandard ) |
1911 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 1913 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
1912 | cal = calendars.next(); | 1914 | cal = calendars.next(); |
1913 | } | 1915 | } |
1914 | setSyncEventsReadOnly(); | 1916 | setSyncEventsReadOnly(); |
1915 | mCalendar->reInitAlarmSettings(); | 1917 | mCalendar->reInitAlarmSettings(); |
1916 | updateUnmanagedViews(); | 1918 | updateUnmanagedViews(); |
1917 | updateView(); | 1919 | updateView(); |
1918 | return true; | 1920 | return true; |
1919 | } | 1921 | } |
1920 | void CalendarView::addCalendarId( int id ) | 1922 | void CalendarView::addCalendarId( int id ) |
1921 | { | 1923 | { |
1922 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 1924 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
1923 | addCalendar( cal ); | 1925 | addCalendar( cal ); |
1924 | } | 1926 | } |
1925 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 1927 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
1926 | { | 1928 | { |
1927 | cal->mErrorOnLoad = false; | 1929 | cal->mErrorOnLoad = false; |
1928 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 1930 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
1929 | cal->mLoadDt = QDateTime::currentDateTime(); | 1931 | cal->mLoadDt = QDateTime::currentDateTime(); |
1930 | return true; | 1932 | return true; |
1931 | } | 1933 | } |
1932 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); | 1934 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); |
1933 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); | 1935 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); |
1934 | cal->mErrorOnLoad = true; | 1936 | cal->mErrorOnLoad = true; |
1935 | return false; | 1937 | return false; |
1936 | } | 1938 | } |
1937 | bool CalendarView::openCalendar(QString filename, bool merge) | 1939 | bool CalendarView::openCalendar(QString filename, bool merge) |
1938 | { | 1940 | { |
1939 | 1941 | ||
1940 | if (filename.isEmpty()) { | 1942 | if (filename.isEmpty()) { |
1941 | return false; | 1943 | return false; |
1942 | } | 1944 | } |
1943 | 1945 | ||
1944 | if (!QFile::exists(filename)) { | 1946 | if (!QFile::exists(filename)) { |
1945 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1947 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1946 | return false; | 1948 | return false; |
1947 | } | 1949 | } |
1948 | 1950 | ||
1949 | globalFlagBlockAgenda = 1; | 1951 | globalFlagBlockAgenda = 1; |
1950 | clearAllViews(); | 1952 | clearAllViews(); |
1951 | if (!merge) { | 1953 | if (!merge) { |
1952 | mViewManager->setDocumentId( filename ); | 1954 | mViewManager->setDocumentId( filename ); |
1953 | mCalendar->close(); | 1955 | mCalendar->close(); |
1954 | } | 1956 | } |
1955 | mStorage->setFileName( filename ); | 1957 | mStorage->setFileName( filename ); |
1956 | 1958 | ||
1957 | if ( mStorage->load() ) { | 1959 | if ( mStorage->load() ) { |
1958 | if ( merge ) ;//setModified( true ); | 1960 | if ( merge ) ;//setModified( true ); |
1959 | else { | 1961 | else { |
1960 | //setModified( true ); | 1962 | //setModified( true ); |
1961 | mViewManager->setDocumentId( filename ); | 1963 | mViewManager->setDocumentId( filename ); |
1962 | mDialogManager->setDocumentId( filename ); | 1964 | mDialogManager->setDocumentId( filename ); |
1963 | mTodoList->setDocumentId( filename ); | 1965 | mTodoList->setDocumentId( filename ); |
1964 | } | 1966 | } |
1965 | globalFlagBlockAgenda = 2; | 1967 | globalFlagBlockAgenda = 2; |
1966 | // if ( getLastSyncEvent() ) | 1968 | // if ( getLastSyncEvent() ) |
1967 | // getLastSyncEvent()->setReadOnly( true ); | 1969 | // getLastSyncEvent()->setReadOnly( true ); |
1968 | mCalendar->reInitAlarmSettings(); | 1970 | mCalendar->reInitAlarmSettings(); |
1969 | setSyncEventsReadOnly(); | 1971 | setSyncEventsReadOnly(); |
1970 | updateUnmanagedViews(); | 1972 | updateUnmanagedViews(); |
1971 | updateView(); | 1973 | updateView(); |
1972 | if ( filename != MainWindow::defaultFileName() ) { | 1974 | if ( filename != MainWindow::defaultFileName() ) { |
1973 | saveCalendar( MainWindow::defaultFileName() ); | 1975 | saveCalendar( MainWindow::defaultFileName() ); |
1974 | } else { | 1976 | } else { |
1975 | QFileInfo finf ( MainWindow::defaultFileName()); | 1977 | QFileInfo finf ( MainWindow::defaultFileName()); |
1976 | if ( finf.exists() ) { | 1978 | if ( finf.exists() ) { |
1977 | setLoadedFileVersion( finf.lastModified () ); | 1979 | setLoadedFileVersion( finf.lastModified () ); |
1978 | } | 1980 | } |
1979 | } | 1981 | } |
1980 | return true; | 1982 | return true; |
1981 | } else { | 1983 | } else { |
1982 | // while failing to load, the calendar object could | 1984 | // while failing to load, the calendar object could |
1983 | // have become partially populated. Clear it out. | 1985 | // have become partially populated. Clear it out. |
1984 | if ( !merge ) { | 1986 | if ( !merge ) { |
1985 | mCalendar->close(); | 1987 | mCalendar->close(); |
1986 | mViewManager->setDocumentId( filename ); | 1988 | mViewManager->setDocumentId( filename ); |
1987 | mDialogManager->setDocumentId( filename ); | 1989 | mDialogManager->setDocumentId( filename ); |
1988 | mTodoList->setDocumentId( filename ); | 1990 | mTodoList->setDocumentId( filename ); |
1989 | } | 1991 | } |
1990 | 1992 | ||
1991 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1993 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1992 | 1994 | ||
1993 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1995 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1994 | globalFlagBlockAgenda = 2; | 1996 | globalFlagBlockAgenda = 2; |
1995 | mCalendar->reInitAlarmSettings(); | 1997 | mCalendar->reInitAlarmSettings(); |
1996 | setSyncEventsReadOnly(); | 1998 | setSyncEventsReadOnly(); |
1997 | updateUnmanagedViews(); | 1999 | updateUnmanagedViews(); |
1998 | updateView(); | 2000 | updateView(); |
1999 | } | 2001 | } |
2000 | return false; | 2002 | return false; |
2001 | } | 2003 | } |
2002 | void CalendarView::showOpenError() | 2004 | void CalendarView::showOpenError() |
2003 | { | 2005 | { |
2004 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2006 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2005 | } | 2007 | } |
2006 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2008 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2007 | { | 2009 | { |
2008 | loadedFileVersion = dt; | 2010 | loadedFileVersion = dt; |
2009 | } | 2011 | } |
2010 | bool CalendarView::checkFileChanged(QString fn) | 2012 | bool CalendarView::checkFileChanged(QString fn) |
2011 | { | 2013 | { |
2012 | QFileInfo finf ( fn ); | 2014 | QFileInfo finf ( fn ); |
2013 | if ( !finf.exists() ) | 2015 | if ( !finf.exists() ) |
2014 | return true; | 2016 | return true; |
2015 | QDateTime dt = finf.lastModified (); | 2017 | QDateTime dt = finf.lastModified (); |
2016 | if ( dt <= loadedFileVersion ) | 2018 | if ( dt <= loadedFileVersion ) |
2017 | return false; | 2019 | return false; |
2018 | return true; | 2020 | return true; |
2019 | 2021 | ||
2020 | } | 2022 | } |
2021 | void CalendarView::watchSavedFile() | 2023 | void CalendarView::watchSavedFile() |
2022 | { | 2024 | { |
2023 | QFileInfo finf ( MainWindow::defaultFileName()); | 2025 | QFileInfo finf ( MainWindow::defaultFileName()); |
2024 | if ( !finf.exists() ) | 2026 | if ( !finf.exists() ) |
2025 | return; | 2027 | return; |
2026 | QDateTime dt = finf.lastModified (); | 2028 | QDateTime dt = finf.lastModified (); |
2027 | if ( dt < loadedFileVersion ) { | 2029 | if ( dt < loadedFileVersion ) { |
2028 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2030 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2029 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2031 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2030 | return; | 2032 | return; |
2031 | } | 2033 | } |
2032 | loadedFileVersion = dt; | 2034 | loadedFileVersion = dt; |
2033 | } | 2035 | } |
2034 | bool CalendarView::checkAllFileVersions() | 2036 | bool CalendarView::checkAllFileVersions() |
2035 | { | 2037 | { |
2036 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2038 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2037 | KopiCalendarFile * cal = calendars.first(); | 2039 | KopiCalendarFile * cal = calendars.first(); |
2038 | mCalendar->setDefaultCalendar( 1 ); | 2040 | mCalendar->setDefaultCalendar( 1 ); |
2039 | mCalendar->setDefaultCalendarEnabledOnly(); | 2041 | mCalendar->setDefaultCalendarEnabledOnly(); |
2040 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2042 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2041 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2043 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2042 | restoreCalendarSettings(); | 2044 | restoreCalendarSettings(); |
2043 | return false; | 2045 | return false; |
2044 | } | 2046 | } |
2045 | } | 2047 | } |
2046 | cal = calendars.next(); | 2048 | cal = calendars.next(); |
2047 | QDateTime storeTemp = loadedFileVersion; | 2049 | QDateTime storeTemp = loadedFileVersion; |
2048 | while ( cal ) { | 2050 | while ( cal ) { |
2049 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2051 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2050 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2052 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2051 | mCalendar->setDefaultCalendarEnabledOnly(); | 2053 | mCalendar->setDefaultCalendarEnabledOnly(); |
2052 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2054 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2053 | if ( !checkFileVersion(cal->mFileName )) { | 2055 | if ( !checkFileVersion(cal->mFileName )) { |
2054 | loadedFileVersion = storeTemp; | 2056 | loadedFileVersion = storeTemp; |
2055 | restoreCalendarSettings(); | 2057 | restoreCalendarSettings(); |
2056 | return false; | 2058 | return false; |
2057 | } | 2059 | } |
2058 | } | 2060 | } |
2059 | cal = calendars.next(); | 2061 | cal = calendars.next(); |
2060 | } | 2062 | } |
2061 | loadedFileVersion = storeTemp; | 2063 | loadedFileVersion = storeTemp; |
2062 | return true; | 2064 | return true; |
2063 | } | 2065 | } |
2064 | bool CalendarView::checkFileVersion(QString fn) | 2066 | bool CalendarView::checkFileVersion(QString fn) |
2065 | { | 2067 | { |
2066 | QFileInfo finf ( fn ); | 2068 | QFileInfo finf ( fn ); |
2067 | if ( !finf.exists() ) | 2069 | if ( !finf.exists() ) |
2068 | return true; | 2070 | return true; |
2069 | QDateTime dt = finf.lastModified (); | 2071 | QDateTime dt = finf.lastModified (); |
2070 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2072 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2071 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2073 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2072 | if ( dt <= loadedFileVersion ) | 2074 | if ( dt <= loadedFileVersion ) |
2073 | return true; | 2075 | return true; |
2074 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on 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(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2076 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on 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(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2075 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2077 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2076 | i18n("Sync+save")); | 2078 | i18n("Sync+save")); |
2077 | 2079 | ||
2078 | if ( km == KMessageBox::Cancel ) | 2080 | if ( km == KMessageBox::Cancel ) |
2079 | return false; | 2081 | return false; |
2080 | if ( km == KMessageBox::Yes ) | 2082 | if ( km == KMessageBox::Yes ) |
2081 | return true; | 2083 | return true; |
2082 | 2084 | ||
2083 | setSyncDevice("deleteaftersync" ); | 2085 | setSyncDevice("deleteaftersync" ); |
2084 | mSyncManager->mAskForPreferences = true; | 2086 | mSyncManager->mAskForPreferences = true; |
2085 | mSyncManager->mSyncAlgoPrefs = 3; | 2087 | mSyncManager->mSyncAlgoPrefs = 3; |
2086 | mSyncManager->mWriteBackFile = false; | 2088 | mSyncManager->mWriteBackFile = false; |
2087 | mSyncManager->mWriteBackExistingOnly = false; | 2089 | mSyncManager->mWriteBackExistingOnly = false; |
2088 | mSyncManager->mShowSyncSummary = false; | 2090 | mSyncManager->mShowSyncSummary = false; |
2089 | syncCalendar( fn, 3 ); | 2091 | syncCalendar( fn, 3 ); |
2090 | Event * e = getLastSyncEvent(); | 2092 | Event * e = getLastSyncEvent(); |
2091 | if ( e ) | 2093 | if ( e ) |
2092 | mCalendar->deleteEvent( e ); | 2094 | mCalendar->deleteEvent( e ); |
2093 | return true; | 2095 | return true; |
2094 | } | 2096 | } |
2095 | bool CalendarView::saveCalendars() | 2097 | bool CalendarView::saveCalendars() |
2096 | { | 2098 | { |
2097 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2099 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2098 | KopiCalendarFile * cal = calendars.first(); | 2100 | KopiCalendarFile * cal = calendars.first(); |
2099 | mCalendar->setDefaultCalendar( 1 ); | 2101 | mCalendar->setDefaultCalendar( 1 ); |
2100 | mCalendar->setDefaultCalendarEnabledOnly(); | 2102 | mCalendar->setDefaultCalendarEnabledOnly(); |
2101 | saveCalendar( MainWindow::defaultFileName() ); | 2103 | saveCalendar( MainWindow::defaultFileName() ); |
2102 | cal = calendars.next(); | 2104 | cal = calendars.next(); |
2103 | while ( cal ) { | 2105 | while ( cal ) { |
2104 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2106 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2105 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2107 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2106 | mCalendar->setDefaultCalendarEnabledOnly(); | 2108 | mCalendar->setDefaultCalendarEnabledOnly(); |
2107 | if ( saveCalendar( cal->mFileName ) ) | 2109 | if ( saveCalendar( cal->mFileName ) ) |
2108 | cal->mLoadDt = QDateTime::currentDateTime(); | 2110 | cal->mLoadDt = QDateTime::currentDateTime(); |
2109 | } | 2111 | } |
2110 | cal = calendars.next(); | 2112 | cal = calendars.next(); |
2111 | } | 2113 | } |
2112 | restoreCalendarSettings(); | 2114 | restoreCalendarSettings(); |
2113 | return true; | 2115 | return true; |
2114 | } | 2116 | } |
2115 | bool CalendarView::saveCalendar( QString filename ) | 2117 | bool CalendarView::saveCalendar( QString filename ) |
2116 | { | 2118 | { |
2117 | 2119 | ||
2118 | // Store back all unsaved data into calendar object | 2120 | // Store back all unsaved data into calendar object |
2119 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2121 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2120 | if ( mViewManager->currentView() ) | 2122 | if ( mViewManager->currentView() ) |
2121 | mViewManager->currentView()->flushView(); | 2123 | mViewManager->currentView()->flushView(); |
2122 | 2124 | ||
2123 | 2125 | ||
2124 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2126 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2125 | mStorage->setSaveFormat( new ICalFormat() ); | 2127 | mStorage->setSaveFormat( new ICalFormat() ); |
2126 | mStorage->setFileName( filename ); | 2128 | mStorage->setFileName( filename ); |
2127 | bool success; | 2129 | bool success; |
2128 | success = mStorage->save(); | 2130 | success = mStorage->save(); |
2129 | if ( !success ) { | 2131 | if ( !success ) { |
2130 | return false; | 2132 | return false; |
2131 | } | 2133 | } |
2132 | if ( filename == MainWindow::defaultFileName() ) { | 2134 | if ( filename == MainWindow::defaultFileName() ) { |
2133 | setLoadedFileVersion( lfv ); | 2135 | setLoadedFileVersion( lfv ); |
2134 | watchSavedFile(); | 2136 | watchSavedFile(); |
2135 | } | 2137 | } |
2136 | return true; | 2138 | return true; |
2137 | } | 2139 | } |
2138 | 2140 | ||
2139 | void CalendarView::closeCalendar() | 2141 | void CalendarView::closeCalendar() |
2140 | { | 2142 | { |
2141 | 2143 | ||
2142 | // child windows no longer valid | 2144 | // child windows no longer valid |
2143 | clearAllViews(); | 2145 | clearAllViews(); |
2144 | emit closingDown(); | 2146 | emit closingDown(); |
2145 | 2147 | ||
2146 | mCalendar->close(); | 2148 | mCalendar->close(); |
2147 | setModified(false); | 2149 | setModified(false); |
2148 | updateView(); | 2150 | updateView(); |
2149 | } | 2151 | } |
2150 | 2152 | ||
2151 | void CalendarView::archiveCalendar() | 2153 | void CalendarView::archiveCalendar() |
2152 | { | 2154 | { |
2153 | mDialogManager->showArchiveDialog(); | 2155 | mDialogManager->showArchiveDialog(); |
2154 | } | 2156 | } |
2155 | 2157 | ||
2156 | 2158 | ||
2157 | void CalendarView::readSettings() | 2159 | void CalendarView::readSettings() |
2158 | { | 2160 | { |
2159 | 2161 | ||
2160 | 2162 | ||
2161 | // mViewManager->showAgendaView(); | 2163 | // mViewManager->showAgendaView(); |
2162 | QString str; | 2164 | QString str; |
2163 | //qDebug("CalendarView::readSettings() "); | 2165 | //qDebug("CalendarView::readSettings() "); |
2164 | // read settings from the KConfig, supplying reasonable | 2166 | // read settings from the KConfig, supplying reasonable |
2165 | // defaults where none are to be found | 2167 | // defaults where none are to be found |
2166 | KConfig *config = KOGlobals::config(); | 2168 | KConfig *config = KOGlobals::config(); |
2167 | #ifndef KORG_NOSPLITTER | 2169 | #ifndef KORG_NOSPLITTER |
2168 | config->setGroup("KOrganizer Geometry"); | 2170 | config->setGroup("KOrganizer Geometry"); |
2169 | 2171 | ||
2170 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2172 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2171 | if (sizes.count() != 2) { | 2173 | if (sizes.count() != 2) { |
2172 | sizes << mDateNavigator->minimumSizeHint().width(); | 2174 | sizes << mDateNavigator->minimumSizeHint().width(); |
2173 | sizes << 300; | 2175 | sizes << 300; |
2174 | } | 2176 | } |
2175 | mPanner->setSizes(sizes); | 2177 | mPanner->setSizes(sizes); |
2176 | 2178 | ||
2177 | sizes = config->readIntListEntry("Separator2"); | 2179 | sizes = config->readIntListEntry("Separator2"); |
2178 | if ( ( mResourceView && sizes.count() == 4 ) || | 2180 | if ( ( mResourceView && sizes.count() == 4 ) || |
2179 | ( !mResourceView && sizes.count() == 3 ) ) { | 2181 | ( !mResourceView && sizes.count() == 3 ) ) { |
2180 | mLeftSplitter->setSizes(sizes); | 2182 | mLeftSplitter->setSizes(sizes); |
2181 | } | 2183 | } |
2182 | #endif | 2184 | #endif |
2183 | globalFlagBlockAgenda = 1; | 2185 | globalFlagBlockAgenda = 1; |
2184 | mViewManager->showAgendaView(); | 2186 | mViewManager->showAgendaView(); |
2185 | //mViewManager->readSettings( config ); | 2187 | //mViewManager->readSettings( config ); |
2186 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2188 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2187 | readFilterSettings(config); | 2189 | readFilterSettings(config); |
2188 | 2190 | ||
2189 | #ifdef DESKTOP_VERSION | 2191 | #ifdef DESKTOP_VERSION |
2190 | config->setGroup("WidgetLayout"); | 2192 | config->setGroup("WidgetLayout"); |
2191 | QStringList list; | 2193 | QStringList list; |
2192 | list = config->readListEntry("MainLayout"); | 2194 | list = config->readListEntry("MainLayout"); |
2193 | int x,y,w,h; | 2195 | int x,y,w,h; |
2194 | if ( ! list.isEmpty() ) { | 2196 | if ( ! list.isEmpty() ) { |
2195 | x = list[0].toInt(); | 2197 | x = list[0].toInt(); |
2196 | y = list[1].toInt(); | 2198 | y = list[1].toInt(); |
2197 | w = list[2].toInt(); | 2199 | w = list[2].toInt(); |
2198 | h = list[3].toInt(); | 2200 | h = list[3].toInt(); |
2199 | KApplication::testCoords( &x,&y,&w,&h ); | 2201 | KApplication::testCoords( &x,&y,&w,&h ); |
2200 | topLevelWidget()->setGeometry(x,y,w,h); | 2202 | topLevelWidget()->setGeometry(x,y,w,h); |
2201 | 2203 | ||
2202 | } else { | 2204 | } else { |
2203 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2205 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2204 | } | 2206 | } |
2205 | list = config->readListEntry("EditEventLayout"); | 2207 | list = config->readListEntry("EditEventLayout"); |
2206 | if ( ! list.isEmpty() ) { | 2208 | if ( ! list.isEmpty() ) { |
2207 | x = list[0].toInt(); | 2209 | x = list[0].toInt(); |
2208 | y = list[1].toInt(); | 2210 | y = list[1].toInt(); |
2209 | w = list[2].toInt(); | 2211 | w = list[2].toInt(); |
2210 | h = list[3].toInt(); | 2212 | h = list[3].toInt(); |
2211 | KApplication::testCoords( &x,&y,&w,&h ); | 2213 | KApplication::testCoords( &x,&y,&w,&h ); |
2212 | mEventEditor->setGeometry(x,y,w,h); | 2214 | mEventEditor->setGeometry(x,y,w,h); |
2213 | 2215 | ||
2214 | } | 2216 | } |
2215 | list = config->readListEntry("EditTodoLayout"); | 2217 | list = config->readListEntry("EditTodoLayout"); |
2216 | if ( ! list.isEmpty() ) { | 2218 | if ( ! list.isEmpty() ) { |
2217 | x = list[0].toInt(); | 2219 | x = list[0].toInt(); |
2218 | y = list[1].toInt(); | 2220 | y = list[1].toInt(); |
2219 | w = list[2].toInt(); | 2221 | w = list[2].toInt(); |
2220 | h = list[3].toInt(); | 2222 | h = list[3].toInt(); |
2221 | KApplication::testCoords( &x,&y,&w,&h ); | 2223 | KApplication::testCoords( &x,&y,&w,&h ); |
2222 | mTodoEditor->setGeometry(x,y,w,h); | 2224 | mTodoEditor->setGeometry(x,y,w,h); |
2223 | 2225 | ||
2224 | } | 2226 | } |
2225 | list = config->readListEntry("ViewerLayout"); | 2227 | list = config->readListEntry("ViewerLayout"); |
2226 | if ( ! list.isEmpty() ) { | 2228 | if ( ! list.isEmpty() ) { |
2227 | x = list[0].toInt(); | 2229 | x = list[0].toInt(); |
2228 | y = list[1].toInt(); | 2230 | y = list[1].toInt(); |
2229 | w = list[2].toInt(); | 2231 | w = list[2].toInt(); |
2230 | h = list[3].toInt(); | 2232 | h = list[3].toInt(); |
2231 | KApplication::testCoords( &x,&y,&w,&h ); | 2233 | KApplication::testCoords( &x,&y,&w,&h ); |
2232 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2234 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2233 | } | 2235 | } |
2234 | #endif | 2236 | #endif |
2235 | config->setGroup( "Views" ); | 2237 | config->setGroup( "Views" ); |
2236 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2238 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2237 | 2239 | ||
2238 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2240 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2239 | 2241 | ||
2240 | int resetval = 0; | 2242 | int resetval = 0; |
2241 | int maxVal = 0; | 2243 | int maxVal = 0; |
2242 | if (sizes.count() != 3) { | 2244 | if (sizes.count() != 3) { |
2243 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2245 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2244 | resetval = mDateNavigator->sizeHint().width()+2; | 2246 | resetval = mDateNavigator->sizeHint().width()+2; |
2245 | } else { | 2247 | } else { |
2246 | resetval = mDateNavigator->sizeHint().height()+2; | 2248 | resetval = mDateNavigator->sizeHint().height()+2; |
2247 | } | 2249 | } |
2248 | } | 2250 | } |
2249 | if ( resetval ) { | 2251 | if ( resetval ) { |
2250 | sizes.clear(); | 2252 | sizes.clear(); |
2251 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2253 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2252 | maxVal = QApplication::desktop()->width() -10; | 2254 | maxVal = QApplication::desktop()->width() -10; |
2253 | } else { | 2255 | } else { |
2254 | maxVal = QApplication::desktop()->height()-10; | 2256 | maxVal = QApplication::desktop()->height()-10; |
2255 | } | 2257 | } |
2256 | sizes << resetval; | 2258 | sizes << resetval; |
2257 | if ( maxVal < resetval + resetval) | 2259 | if ( maxVal < resetval + resetval) |
2258 | resetval = maxVal - resetval; | 2260 | resetval = maxVal - resetval; |
2259 | sizes << resetval; | 2261 | sizes << resetval; |
2260 | sizes << 100; | 2262 | sizes << 100; |
2261 | } | 2263 | } |
2262 | mLeftFrame->setSizes(sizes); | 2264 | mLeftFrame->setSizes(sizes); |
2263 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2265 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2264 | resetval = 0; | 2266 | resetval = 0; |
2265 | maxVal = 0; | 2267 | maxVal = 0; |
2266 | if (sizes.count() != 2) { | 2268 | if (sizes.count() != 2) { |
2267 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2269 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2268 | resetval = mDateNavigator->sizeHint().width()+2; | 2270 | resetval = mDateNavigator->sizeHint().width()+2; |
2269 | } else { | 2271 | } else { |
2270 | resetval = mDateNavigator->sizeHint().height()+2; | 2272 | resetval = mDateNavigator->sizeHint().height()+2; |
2271 | } | 2273 | } |
2272 | } | 2274 | } |
2273 | if ( resetval ) { | 2275 | if ( resetval ) { |
2274 | sizes.clear(); | 2276 | sizes.clear(); |
2275 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2277 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2276 | maxVal = QApplication::desktop()->width() -10; | 2278 | maxVal = QApplication::desktop()->width() -10; |
2277 | } else { | 2279 | } else { |
2278 | maxVal = QApplication::desktop()->height()-10; | 2280 | maxVal = QApplication::desktop()->height()-10; |
2279 | } | 2281 | } |
2280 | sizes << resetval; | 2282 | sizes << resetval; |
2281 | if ( maxVal < resetval + resetval) | 2283 | if ( maxVal < resetval + resetval) |
2282 | resetval = maxVal - resetval; | 2284 | resetval = maxVal - resetval; |
2283 | sizes << resetval; | 2285 | sizes << resetval; |
2284 | } | 2286 | } |
2285 | mMainFrame->setSizes(sizes); | 2287 | mMainFrame->setSizes(sizes); |
2286 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2288 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2287 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2289 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2288 | else mNavigator->selectDates( dateCount ); | 2290 | else mNavigator->selectDates( dateCount ); |
2289 | // mViewManager->readSettings( config ); | 2291 | // mViewManager->readSettings( config ); |
2290 | updateConfig(); | 2292 | updateConfig(); |
2291 | globalFlagBlockAgenda = 2; | 2293 | globalFlagBlockAgenda = 2; |
2292 | mViewManager->readSettings( config ); | 2294 | mViewManager->readSettings( config ); |
2293 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2295 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2294 | } | 2296 | } |
2295 | 2297 | ||
2296 | 2298 | ||
2297 | void CalendarView::writeSettings() | 2299 | void CalendarView::writeSettings() |
2298 | { | 2300 | { |
2299 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2301 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2300 | 2302 | ||
2301 | KConfig *config = KOGlobals::config(); | 2303 | KConfig *config = KOGlobals::config(); |
2302 | 2304 | ||
2303 | mViewManager->writeSettings( config ); | 2305 | mViewManager->writeSettings( config ); |
2304 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2306 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2305 | mDialogManager->writeSettings( config ); | 2307 | mDialogManager->writeSettings( config ); |
2306 | //KOPrefs::instance()->usrWriteConfig(); | 2308 | //KOPrefs::instance()->usrWriteConfig(); |
2307 | KOPrefs::instance()->writeConfig(); | 2309 | KOPrefs::instance()->writeConfig(); |
2308 | 2310 | ||
2309 | writeFilterSettings(config); | 2311 | writeFilterSettings(config); |
2310 | config->setGroup( "AppRun" ); | 2312 | config->setGroup( "AppRun" ); |
2311 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2313 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2312 | int days = dt.daysTo( QDate::currentDate() ); | 2314 | int days = dt.daysTo( QDate::currentDate() ); |
2313 | dt = dt.addDays( days ); | 2315 | dt = dt.addDays( days ); |
2314 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2316 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2315 | config->writeEntry( "LatestProgramStopDays", days ); | 2317 | config->writeEntry( "LatestProgramStopDays", days ); |
2316 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2318 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2317 | //qDebug("KO: Writing stop time: %d ", secs); | 2319 | //qDebug("KO: Writing stop time: %d ", secs); |
2318 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2320 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2319 | //QDateTime latest = dt.addSecs ( secs ); | 2321 | //QDateTime latest = dt.addSecs ( secs ); |
2320 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2322 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2321 | config->setGroup( "Views" ); | 2323 | config->setGroup( "Views" ); |
2322 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2324 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2323 | 2325 | ||
2324 | #if 0 | 2326 | #if 0 |
2325 | qDebug("********************* "); | 2327 | qDebug("********************* "); |
2326 | qDebug("Testcode secsto "); | 2328 | qDebug("Testcode secsto "); |
2327 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2329 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2328 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2330 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2329 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2331 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2330 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2332 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2331 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2333 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2332 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2334 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2333 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2335 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2334 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2336 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2335 | qDebug("********************* testcode end"); | 2337 | qDebug("********************* testcode end"); |
2336 | 2338 | ||
2337 | #endif | 2339 | #endif |
2338 | 2340 | ||
2339 | QValueList<int> listINT = mLeftFrame->sizes(); | 2341 | QValueList<int> listINT = mLeftFrame->sizes(); |
2340 | config->writeEntry("Left Splitter Frame",listINT); | 2342 | config->writeEntry("Left Splitter Frame",listINT); |
2341 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2343 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2342 | config->writeEntry("Main Splitter Frame",listINT2); | 2344 | config->writeEntry("Main Splitter Frame",listINT2); |
2343 | #ifdef DESKTOP_VERSION | 2345 | #ifdef DESKTOP_VERSION |
2344 | config->setGroup("WidgetLayout"); | 2346 | config->setGroup("WidgetLayout"); |
2345 | QStringList list ;//= config->readListEntry("MainLayout"); | 2347 | QStringList list ;//= config->readListEntry("MainLayout"); |
2346 | int x,y,w,h; | 2348 | int x,y,w,h; |
2347 | QWidget* wid; | 2349 | QWidget* wid; |
2348 | wid = topLevelWidget(); | 2350 | wid = topLevelWidget(); |
2349 | x = wid->geometry().x(); | 2351 | x = wid->geometry().x(); |
2350 | y = wid->geometry().y(); | 2352 | y = wid->geometry().y(); |
2351 | w = wid->width(); | 2353 | w = wid->width(); |
2352 | h = wid->height(); | 2354 | h = wid->height(); |
2353 | list.clear(); | 2355 | list.clear(); |
2354 | list << QString::number( x ); | 2356 | list << QString::number( x ); |
2355 | list << QString::number( y ); | 2357 | list << QString::number( y ); |
2356 | list << QString::number( w ); | 2358 | list << QString::number( w ); |
2357 | list << QString::number( h ); | 2359 | list << QString::number( h ); |
2358 | config->writeEntry("MainLayout",list ); | 2360 | config->writeEntry("MainLayout",list ); |
2359 | 2361 | ||
2360 | wid = mEventEditor; | 2362 | wid = mEventEditor; |
2361 | x = wid->geometry().x(); | 2363 | x = wid->geometry().x(); |
2362 | y = wid->geometry().y(); | 2364 | y = wid->geometry().y(); |
2363 | w = wid->width(); | 2365 | w = wid->width(); |
2364 | h = wid->height(); | 2366 | h = wid->height(); |
2365 | list.clear(); | 2367 | list.clear(); |
2366 | list << QString::number( x ); | 2368 | list << QString::number( x ); |
2367 | list << QString::number( y ); | 2369 | list << QString::number( y ); |
2368 | list << QString::number( w ); | 2370 | list << QString::number( w ); |
2369 | list << QString::number( h ); | 2371 | list << QString::number( h ); |
2370 | config->writeEntry("EditEventLayout",list ); | 2372 | config->writeEntry("EditEventLayout",list ); |
2371 | 2373 | ||
2372 | wid = mTodoEditor; | 2374 | wid = mTodoEditor; |
2373 | x = wid->geometry().x(); | 2375 | x = wid->geometry().x(); |
2374 | y = wid->geometry().y(); | 2376 | y = wid->geometry().y(); |
2375 | w = wid->width(); | 2377 | w = wid->width(); |
2376 | h = wid->height(); | 2378 | h = wid->height(); |
2377 | list.clear(); | 2379 | list.clear(); |
2378 | list << QString::number( x ); | 2380 | list << QString::number( x ); |
2379 | list << QString::number( y ); | 2381 | list << QString::number( y ); |
2380 | list << QString::number( w ); | 2382 | list << QString::number( w ); |
2381 | list << QString::number( h ); | 2383 | list << QString::number( h ); |
2382 | config->writeEntry("EditTodoLayout",list ); | 2384 | config->writeEntry("EditTodoLayout",list ); |
2383 | wid = getEventViewerDialog(); | 2385 | wid = getEventViewerDialog(); |
2384 | x = wid->geometry().x(); | 2386 | x = wid->geometry().x(); |
2385 | y = wid->geometry().y(); | 2387 | y = wid->geometry().y(); |
2386 | w = wid->width(); | 2388 | w = wid->width(); |
2387 | h = wid->height(); | 2389 | h = wid->height(); |
2388 | list.clear(); | 2390 | list.clear(); |
2389 | list << QString::number( x ); | 2391 | list << QString::number( x ); |
2390 | list << QString::number( y ); | 2392 | list << QString::number( y ); |
2391 | list << QString::number( w ); | 2393 | list << QString::number( w ); |
2392 | list << QString::number( h ); | 2394 | list << QString::number( h ); |
2393 | config->writeEntry("ViewerLayout",list ); | 2395 | config->writeEntry("ViewerLayout",list ); |
2394 | wid = mDialogManager->getSearchDialog(); | 2396 | wid = mDialogManager->getSearchDialog(); |
2395 | if ( wid ) { | 2397 | if ( wid ) { |
2396 | x = wid->geometry().x(); | 2398 | x = wid->geometry().x(); |
2397 | y = wid->geometry().y(); | 2399 | y = wid->geometry().y(); |
2398 | w = wid->width(); | 2400 | w = wid->width(); |
2399 | h = wid->height(); | 2401 | h = wid->height(); |
2400 | list.clear(); | 2402 | list.clear(); |
2401 | list << QString::number( x ); | 2403 | list << QString::number( x ); |
2402 | list << QString::number( y ); | 2404 | list << QString::number( y ); |
2403 | list << QString::number( w ); | 2405 | list << QString::number( w ); |
2404 | list << QString::number( h ); | 2406 | list << QString::number( h ); |
2405 | config->writeEntry("SearchLayout",list ); | 2407 | config->writeEntry("SearchLayout",list ); |
2406 | } | 2408 | } |
2407 | #endif | 2409 | #endif |
2408 | 2410 | ||
2409 | 2411 | ||
2410 | config->sync(); | 2412 | config->sync(); |
2411 | } | 2413 | } |
2412 | 2414 | ||
2413 | void CalendarView::readFilterSettings(KConfig *config) | 2415 | void CalendarView::readFilterSettings(KConfig *config) |
2414 | { | 2416 | { |
2415 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2417 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2416 | 2418 | ||
2417 | mFilters.clear(); | 2419 | mFilters.clear(); |
2418 | 2420 | ||
2419 | config->setGroup("General"); | 2421 | config->setGroup("General"); |
2420 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2422 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2421 | 2423 | ||
2422 | QStringList::ConstIterator it = filterList.begin(); | 2424 | QStringList::ConstIterator it = filterList.begin(); |
2423 | QStringList::ConstIterator end = filterList.end(); | 2425 | QStringList::ConstIterator end = filterList.end(); |
2424 | while(it != end) { | 2426 | while(it != end) { |
2425 | // kdDebug() << " filter: " << (*it) << endl; | 2427 | // kdDebug() << " filter: " << (*it) << endl; |
2426 | 2428 | ||
2427 | CalFilter *filter; | 2429 | CalFilter *filter; |
2428 | filter = new CalFilter(*it); | 2430 | filter = new CalFilter(*it); |
2429 | config->setGroup("Filter_" + (*it).utf8()); | 2431 | config->setGroup("Filter_" + (*it).utf8()); |
2430 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2432 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2431 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2433 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2432 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2434 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2433 | mFilters.append(filter); | 2435 | mFilters.append(filter); |
2434 | 2436 | ||
2435 | ++it; | 2437 | ++it; |
2436 | } | 2438 | } |
2437 | 2439 | ||
2438 | if (mFilters.count() == 0) { | 2440 | if (mFilters.count() == 0) { |
2439 | CalFilter *filter = new CalFilter(i18n("Default")); | 2441 | CalFilter *filter = new CalFilter(i18n("Default")); |
2440 | mFilters.append(filter); | 2442 | mFilters.append(filter); |
2441 | } | 2443 | } |
2442 | mFilterView->updateFilters(); | 2444 | mFilterView->updateFilters(); |
2443 | config->setGroup("FilterView"); | 2445 | config->setGroup("FilterView"); |
2444 | 2446 | ||
2445 | mFilterView->blockSignals(true); | 2447 | mFilterView->blockSignals(true); |
2446 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2448 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2447 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2449 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2448 | mFilterView->blockSignals(false); | 2450 | mFilterView->blockSignals(false); |
2449 | // We do it manually to avoid it being done twice by the above calls | 2451 | // We do it manually to avoid it being done twice by the above calls |
2450 | updateFilter(); | 2452 | updateFilter(); |
2451 | } | 2453 | } |
2452 | 2454 | ||
2453 | void CalendarView::writeFilterSettings(KConfig *config) | 2455 | void CalendarView::writeFilterSettings(KConfig *config) |
2454 | { | 2456 | { |
2455 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2457 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2456 | 2458 | ||
2457 | QStringList filterList; | 2459 | QStringList filterList; |
2458 | 2460 | ||
2459 | CalFilter *filter = mFilters.first(); | 2461 | CalFilter *filter = mFilters.first(); |
2460 | while(filter) { | 2462 | while(filter) { |
2461 | // kdDebug() << " fn: " << filter->name() << endl; | 2463 | // kdDebug() << " fn: " << filter->name() << endl; |
2462 | filterList << filter->name(); | 2464 | filterList << filter->name(); |
2463 | config->setGroup("Filter_" + filter->name().utf8()); | 2465 | config->setGroup("Filter_" + filter->name().utf8()); |
2464 | config->writeEntry("Criteria",filter->criteria()); | 2466 | config->writeEntry("Criteria",filter->criteria()); |
2465 | config->writeEntry("CategoryList",filter->categoryList()); | 2467 | config->writeEntry("CategoryList",filter->categoryList()); |
2466 | filter = mFilters.next(); | 2468 | filter = mFilters.next(); |
2467 | } | 2469 | } |
2468 | config->setGroup("General"); | 2470 | config->setGroup("General"); |
2469 | config->writeEntry("CalendarFilters",filterList); | 2471 | config->writeEntry("CalendarFilters",filterList); |
2470 | 2472 | ||
2471 | config->setGroup("FilterView"); | 2473 | config->setGroup("FilterView"); |
2472 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2474 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2473 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2475 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2474 | } | 2476 | } |
2475 | 2477 | ||
2476 | 2478 | ||
2477 | void CalendarView::goToday() | 2479 | void CalendarView::goToday() |
2478 | { | 2480 | { |
2479 | if ( mViewManager->currentView()->isMonthView() ) | 2481 | if ( mViewManager->currentView()->isMonthView() ) |
2480 | mNavigator->selectTodayMonth(); | 2482 | mNavigator->selectTodayMonth(); |
2481 | else | 2483 | else |
2482 | mNavigator->selectToday(); | 2484 | mNavigator->selectToday(); |
2483 | } | 2485 | } |
2484 | 2486 | ||
2485 | void CalendarView::goNext() | 2487 | void CalendarView::goNext() |
2486 | { | 2488 | { |
2487 | mNavigator->selectNext(); | 2489 | mNavigator->selectNext(); |
2488 | } | 2490 | } |
2489 | 2491 | ||
2490 | void CalendarView::goPrevious() | 2492 | void CalendarView::goPrevious() |
2491 | { | 2493 | { |
2492 | mNavigator->selectPrevious(); | 2494 | mNavigator->selectPrevious(); |
2493 | } | 2495 | } |
2494 | void CalendarView::goNextMonth() | 2496 | void CalendarView::goNextMonth() |
2495 | { | 2497 | { |
2496 | mNavigator->selectNextMonth(); | 2498 | mNavigator->selectNextMonth(); |
2497 | } | 2499 | } |
2498 | 2500 | ||
2499 | void CalendarView::goPreviousMonth() | 2501 | void CalendarView::goPreviousMonth() |
2500 | { | 2502 | { |
2501 | mNavigator->selectPreviousMonth(); | 2503 | mNavigator->selectPreviousMonth(); |
2502 | } | 2504 | } |
2503 | 2505 | ||
2504 | void CalendarView::updateConfig() | 2506 | void CalendarView::updateConfig() |
2505 | { | 2507 | { |
2506 | if ( KOPrefs::instance()->mUseAppColors ) | 2508 | if ( KOPrefs::instance()->mUseAppColors ) |
2507 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2509 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2508 | emit configChanged(); | 2510 | emit configChanged(); |
2509 | mTodoList->updateConfig(); | 2511 | mTodoList->updateConfig(); |
2510 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2512 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2511 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2513 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2512 | // To make the "fill window" configurations work | 2514 | // To make the "fill window" configurations work |
2513 | //mViewManager->raiseCurrentView(); | 2515 | //mViewManager->raiseCurrentView(); |
2514 | } | 2516 | } |
2515 | 2517 | ||
2516 | 2518 | ||
2517 | void CalendarView::eventChanged(Event *event) | 2519 | void CalendarView::eventChanged(Event *event) |
2518 | { | 2520 | { |
2519 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2521 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2520 | //updateUnmanagedViews(); | 2522 | //updateUnmanagedViews(); |
2521 | } | 2523 | } |
2522 | 2524 | ||
2523 | void CalendarView::eventAdded(Event *event) | 2525 | void CalendarView::eventAdded(Event *event) |
2524 | { | 2526 | { |
2525 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2527 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2526 | } | 2528 | } |
2527 | 2529 | ||
2528 | void CalendarView::eventToBeDeleted(Event *) | 2530 | void CalendarView::eventToBeDeleted(Event *) |
2529 | { | 2531 | { |
2530 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2532 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2531 | } | 2533 | } |
2532 | 2534 | ||
2533 | void CalendarView::eventDeleted() | 2535 | void CalendarView::eventDeleted() |
2534 | { | 2536 | { |
2535 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2537 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2536 | } | 2538 | } |
2537 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2539 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2538 | { | 2540 | { |
2539 | changeIncidenceDisplay((Incidence *)which, action); | 2541 | changeIncidenceDisplay((Incidence *)which, action); |
2540 | mDateNavigator->updateView(); //LR | 2542 | mDateNavigator->updateView(); //LR |
2541 | //mDialogManager->updateSearchDialog(); | 2543 | //mDialogManager->updateSearchDialog(); |
2542 | 2544 | ||
2543 | if (which) { | 2545 | if (which) { |
2544 | mViewManager->updateWNview(); | 2546 | mViewManager->updateWNview(); |
2545 | //mTodoList->updateView(); | 2547 | //mTodoList->updateView(); |
2546 | } | 2548 | } |
2547 | 2549 | ||
2548 | } | 2550 | } |
2549 | 2551 | ||
2550 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2552 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2551 | { | 2553 | { |
2552 | updateUnmanagedViews(); | 2554 | updateUnmanagedViews(); |
2553 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2555 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2554 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2556 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2555 | mCalendar->checkAlarmForIncidence( 0, true ); | 2557 | mCalendar->checkAlarmForIncidence( 0, true ); |
2556 | if ( mEventViewerDialog ) | 2558 | if ( mEventViewerDialog ) |
2557 | mEventViewerDialog->hide(); | 2559 | mEventViewerDialog->hide(); |
2558 | } | 2560 | } |
2559 | else | 2561 | else |
2560 | mCalendar->checkAlarmForIncidence( which , false ); | 2562 | mCalendar->checkAlarmForIncidence( which , false ); |
2561 | } | 2563 | } |
2562 | 2564 | ||
2563 | // most of the changeEventDisplays() right now just call the view's | 2565 | // most of the changeEventDisplays() right now just call the view's |
2564 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2566 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2565 | void CalendarView::changeEventDisplay(Event *which, int action) | 2567 | void CalendarView::changeEventDisplay(Event *which, int action) |
2566 | { | 2568 | { |
2567 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2569 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2568 | changeIncidenceDisplay((Incidence *)which, action); | 2570 | changeIncidenceDisplay((Incidence *)which, action); |
2569 | mDateNavigator->updateView(); | 2571 | mDateNavigator->updateView(); |
2570 | //mDialogManager->updateSearchDialog(); | 2572 | //mDialogManager->updateSearchDialog(); |
2571 | 2573 | ||
2572 | if (which) { | 2574 | if (which) { |
2573 | // If there is an event view visible update the display | 2575 | // If there is an event view visible update the display |
2574 | mViewManager->currentView()->changeEventDisplay(which,action); | 2576 | mViewManager->currentView()->changeEventDisplay(which,action); |
2575 | // TODO: check, if update needed | 2577 | // TODO: check, if update needed |
2576 | // if (which->getTodoStatus()) { | 2578 | // if (which->getTodoStatus()) { |
2577 | mTodoList->updateView(); | 2579 | mTodoList->updateView(); |
2578 | // } | 2580 | // } |
2579 | } else { | 2581 | } else { |
2580 | mViewManager->currentView()->updateView(); | 2582 | mViewManager->currentView()->updateView(); |
2581 | } | 2583 | } |
2582 | } | 2584 | } |
2583 | 2585 | ||
2584 | 2586 | ||
2585 | void CalendarView::updateTodoViews() | 2587 | void CalendarView::updateTodoViews() |
2586 | { | 2588 | { |
2587 | mTodoList->updateView(); | 2589 | mTodoList->updateView(); |
2588 | mViewManager->currentView()->updateView(); | 2590 | mViewManager->currentView()->updateView(); |
2589 | 2591 | ||
2590 | } | 2592 | } |
2591 | 2593 | ||
2592 | 2594 | ||
2593 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2595 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2594 | { | 2596 | { |
2595 | #ifdef DESKTOP_VERSION | 2597 | #ifdef DESKTOP_VERSION |
2596 | mDateScrollBar->setValue( start.dayOfYear()-1); | 2598 | mDateScrollBar->setValue( start.dayOfYear()-1); |
2597 | #endif | 2599 | #endif |
2598 | mTodoList->updateView(); | 2600 | mTodoList->updateView(); |
2599 | mViewManager->updateView(start, end); | 2601 | mViewManager->updateView(start, end); |
2600 | //mDateNavigator->updateView(); | 2602 | //mDateNavigator->updateView(); |
2601 | } | 2603 | } |
2602 | 2604 | ||
2603 | void CalendarView::clearAllViews() | 2605 | void CalendarView::clearAllViews() |
2604 | { | 2606 | { |
2605 | mTodoList->clearList(); | 2607 | mTodoList->clearList(); |
2606 | mViewManager->clearAllViews(); | 2608 | mViewManager->clearAllViews(); |
2607 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2609 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2608 | if ( sd ) { | 2610 | if ( sd ) { |
2609 | KOListView* kol = sd->listview(); | 2611 | KOListView* kol = sd->listview(); |
2610 | if ( kol ) | 2612 | if ( kol ) |
2611 | kol->clearList(); | 2613 | kol->clearList(); |
2612 | } | 2614 | } |
2613 | } | 2615 | } |
2614 | void CalendarView::updateView() | 2616 | void CalendarView::updateView() |
2615 | { | 2617 | { |
2616 | DateList tmpList = mNavigator->selectedDates(); | 2618 | DateList tmpList = mNavigator->selectedDates(); |
2617 | 2619 | ||
2618 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2620 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2619 | mTodoList->updateView(); | 2621 | mTodoList->updateView(); |
2620 | // We assume that the navigator only selects consecutive days. | 2622 | // We assume that the navigator only selects consecutive days. |
2621 | updateView( tmpList.first(), tmpList.last() ); | 2623 | updateView( tmpList.first(), tmpList.last() ); |
2622 | } | 2624 | } |
2623 | 2625 | ||
2624 | void CalendarView::updateUnmanagedViews() | 2626 | void CalendarView::updateUnmanagedViews() |
2625 | { | 2627 | { |
2626 | mDateNavigator->updateDayMatrix(); | 2628 | mDateNavigator->updateDayMatrix(); |
2627 | } | 2629 | } |
2628 | 2630 | ||
2629 | int CalendarView::msgItemDelete(const QString name) | 2631 | int CalendarView::msgItemDelete(const QString name) |
2630 | { | 2632 | { |
2631 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2633 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2632 | i18n("This item will be\npermanently deleted."), | 2634 | i18n("This item will be\npermanently deleted."), |
2633 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2635 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2634 | } | 2636 | } |
2635 | 2637 | ||
2636 | 2638 | ||
2637 | void CalendarView::edit_cut() | 2639 | void CalendarView::edit_cut() |
2638 | { | 2640 | { |
2639 | Event *anEvent=0; | 2641 | Event *anEvent=0; |
2640 | 2642 | ||
2641 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2643 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2642 | 2644 | ||
2643 | if (mViewManager->currentView()->isEventView()) { | 2645 | if (mViewManager->currentView()->isEventView()) { |
2644 | if ( incidence && incidence->typeID() == eventID ) { | 2646 | if ( incidence && incidence->typeID() == eventID ) { |
2645 | anEvent = static_cast<Event *>(incidence); | 2647 | anEvent = static_cast<Event *>(incidence); |
2646 | } | 2648 | } |
2647 | } | 2649 | } |
2648 | 2650 | ||
2649 | if (!anEvent) { | 2651 | if (!anEvent) { |
2650 | KNotifyClient::beep(); | 2652 | KNotifyClient::beep(); |
2651 | return; | 2653 | return; |
2652 | } | 2654 | } |
2653 | DndFactory factory( mCalendar ); | 2655 | DndFactory factory( mCalendar ); |
2654 | factory.cutIncidence(anEvent); | 2656 | factory.cutIncidence(anEvent); |
2655 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2657 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2656 | } | 2658 | } |
2657 | 2659 | ||
2658 | void CalendarView::edit_copy() | 2660 | void CalendarView::edit_copy() |
2659 | { | 2661 | { |
2660 | Event *anEvent=0; | 2662 | Event *anEvent=0; |
2661 | 2663 | ||
2662 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2664 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2663 | 2665 | ||
2664 | if (mViewManager->currentView()->isEventView()) { | 2666 | if (mViewManager->currentView()->isEventView()) { |
2665 | if ( incidence && incidence->typeID() == eventID ) { | 2667 | if ( incidence && incidence->typeID() == eventID ) { |
2666 | anEvent = static_cast<Event *>(incidence); | 2668 | anEvent = static_cast<Event *>(incidence); |
2667 | } | 2669 | } |
2668 | } | 2670 | } |
2669 | 2671 | ||
2670 | if (!anEvent) { | 2672 | if (!anEvent) { |
2671 | KNotifyClient::beep(); | 2673 | KNotifyClient::beep(); |
2672 | return; | 2674 | return; |
2673 | } | 2675 | } |
2674 | DndFactory factory( mCalendar ); | 2676 | DndFactory factory( mCalendar ); |
2675 | factory.copyIncidence(anEvent); | 2677 | factory.copyIncidence(anEvent); |
2676 | } | 2678 | } |
2677 | 2679 | ||
2678 | void CalendarView::edit_paste() | 2680 | void CalendarView::edit_paste() |
2679 | { | 2681 | { |
2680 | QDate date = mNavigator->selectedDates().first(); | 2682 | QDate date = mNavigator->selectedDates().first(); |
2681 | 2683 | ||
2682 | DndFactory factory( mCalendar ); | 2684 | DndFactory factory( mCalendar ); |
2683 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2685 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2684 | 2686 | ||
2685 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2687 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2686 | } | 2688 | } |
2687 | void CalendarView::edit_global_options() | 2689 | void CalendarView::edit_global_options() |
2688 | { | 2690 | { |
2689 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2691 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2690 | emit save(); | 2692 | emit save(); |
2691 | emit saveStopTimer(); | 2693 | emit saveStopTimer(); |
2692 | mDialogManager->showGlobalOptionsDialog(); | 2694 | mDialogManager->showGlobalOptionsDialog(); |
2693 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2695 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2694 | emit saveStopTimer(); | 2696 | emit saveStopTimer(); |
2695 | 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!"), | 2697 | 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!"), |
2696 | i18n("Timezone settings"),i18n("Reload"))) { | 2698 | i18n("Timezone settings"),i18n("Reload"))) { |
2697 | qDebug("KO: TZ reload cancelled "); | 2699 | qDebug("KO: TZ reload cancelled "); |
2698 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2700 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2699 | return; | 2701 | return; |
2700 | } | 2702 | } |
2701 | qDebug("KO: Timezone change "); | 2703 | qDebug("KO: Timezone change "); |
2702 | loadCalendars(); | 2704 | loadCalendars(); |
2703 | setModified(true); | 2705 | setModified(true); |
2704 | } | 2706 | } |
2705 | else | 2707 | else |
2706 | qDebug("KO: No tz change "); | 2708 | qDebug("KO: No tz change "); |
2707 | } | 2709 | } |
2708 | void CalendarView::edit_options() | 2710 | void CalendarView::edit_options() |
2709 | { | 2711 | { |
2710 | mDialogManager->showOptionsDialog(); | 2712 | mDialogManager->showOptionsDialog(); |
2711 | } | 2713 | } |
2712 | 2714 | ||
2713 | 2715 | ||
2714 | void CalendarView::slotSelectPickerDate( QDate d) | 2716 | void CalendarView::slotSelectPickerDate( QDate d) |
2715 | { | 2717 | { |
2716 | mDateFrame->hide(); | 2718 | mDateFrame->hide(); |
2717 | if ( mDatePickerMode == 1 ) { | 2719 | if ( mDatePickerMode == 1 ) { |
2718 | mNavigator->slotDaySelect( d ); | 2720 | mNavigator->slotDaySelect( d ); |
2719 | } else if ( mDatePickerMode == 2 ) { | 2721 | } else if ( mDatePickerMode == 2 ) { |
2720 | if ( mMoveIncidence->typeID() == todoID ) { | 2722 | if ( mMoveIncidence->typeID() == todoID ) { |
2721 | Todo * to = (Todo *) mMoveIncidence; | 2723 | Todo * to = (Todo *) mMoveIncidence; |
2722 | QTime tim; | 2724 | QTime tim; |
2723 | int len = 0; | 2725 | int len = 0; |
2724 | if ( to->hasStartDate() && to->hasDueDate() ) | 2726 | if ( to->hasStartDate() && to->hasDueDate() ) |
2725 | len = to->dtStart().secsTo( to->dtDue()); | 2727 | len = to->dtStart().secsTo( to->dtDue()); |
2726 | if ( to->hasDueDate() ) | 2728 | if ( to->hasDueDate() ) |
2727 | tim = to->dtDue().time(); | 2729 | tim = to->dtDue().time(); |
2728 | else { | 2730 | else { |
2729 | tim = QTime ( 0,0,0 ); | 2731 | tim = QTime ( 0,0,0 ); |
2730 | to->setFloats( true ); | 2732 | to->setFloats( true ); |
2731 | to->setHasDueDate( true ); | 2733 | to->setHasDueDate( true ); |
2732 | } | 2734 | } |
2733 | QDateTime dt ( d,tim ); | 2735 | QDateTime dt ( d,tim ); |
2734 | to->setDtDue( dt ); | 2736 | to->setDtDue( dt ); |
2735 | 2737 | ||
2736 | if ( to->hasStartDate() ) { | 2738 | if ( to->hasStartDate() ) { |
2737 | if ( len>0 ) | 2739 | if ( len>0 ) |
2738 | to->setDtStart(to->dtDue().addSecs( -len )); | 2740 | to->setDtStart(to->dtDue().addSecs( -len )); |
2739 | else | 2741 | else |
2740 | if (to->dtStart() > to->dtDue() ) | 2742 | if (to->dtStart() > to->dtDue() ) |
2741 | to->setDtStart(to->dtDue().addDays( -3 )); | 2743 | to->setDtStart(to->dtDue().addDays( -3 )); |
2742 | } | 2744 | } |
2743 | 2745 | ||
2744 | todoChanged( to ); | 2746 | todoChanged( to ); |
2745 | } else { | 2747 | } else { |
2746 | if ( mMoveIncidence->doesRecur() ) { | 2748 | if ( mMoveIncidence->doesRecur() ) { |
2747 | #if 0 | 2749 | #if 0 |
2748 | // PENDING implement this | 2750 | // PENDING implement this |
2749 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2751 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2750 | mCalendar()->addIncidence( newInc ); | 2752 | mCalendar()->addIncidence( newInc ); |
2751 | if ( mMoveIncidence->typeID() == todoID ) | 2753 | if ( mMoveIncidence->typeID() == todoID ) |
2752 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2754 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2753 | else | 2755 | else |
2754 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2756 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2755 | mMoveIncidence = newInc; | 2757 | mMoveIncidence = newInc; |
2756 | 2758 | ||
2757 | #endif | 2759 | #endif |
2758 | } | 2760 | } |
2759 | QTime tim = mMoveIncidence->dtStart().time(); | 2761 | QTime tim = mMoveIncidence->dtStart().time(); |
2760 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2762 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2761 | QDateTime dt ( d,tim ); | 2763 | QDateTime dt ( d,tim ); |
2762 | mMoveIncidence->setDtStart( dt ); | 2764 | mMoveIncidence->setDtStart( dt ); |
2763 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2765 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2764 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2766 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2765 | } | 2767 | } |
2766 | 2768 | ||
2767 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2769 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2768 | } | 2770 | } |
2769 | } | 2771 | } |
2770 | 2772 | ||
2771 | void CalendarView::removeCategories() | 2773 | void CalendarView::removeCategories() |
2772 | { | 2774 | { |
2773 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2775 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2774 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2776 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2775 | QStringList catIncList; | 2777 | QStringList catIncList; |
2776 | QStringList newCatList; | 2778 | QStringList newCatList; |
2777 | Incidence* inc = incList.first(); | 2779 | Incidence* inc = incList.first(); |
2778 | int i; | 2780 | int i; |
2779 | int count = 0; | 2781 | int count = 0; |
2780 | while ( inc ) { | 2782 | while ( inc ) { |
2781 | newCatList.clear(); | 2783 | newCatList.clear(); |
2782 | catIncList = inc->categories() ; | 2784 | catIncList = inc->categories() ; |
2783 | for( i = 0; i< catIncList.count(); ++i ) { | 2785 | for( i = 0; i< catIncList.count(); ++i ) { |
2784 | if ( catList.contains (catIncList[i])) | 2786 | if ( catList.contains (catIncList[i])) |
2785 | newCatList.append( catIncList[i] ); | 2787 | newCatList.append( catIncList[i] ); |
2786 | } | 2788 | } |
2787 | newCatList.sort(); | 2789 | newCatList.sort(); |
2788 | inc->setCategories( newCatList.join(",") ); | 2790 | inc->setCategories( newCatList.join(",") ); |
2789 | inc = incList.next(); | 2791 | inc = incList.next(); |
2790 | } | 2792 | } |
2791 | } | 2793 | } |
2792 | 2794 | ||
2793 | int CalendarView::addCategories() | 2795 | int CalendarView::addCategories() |
2794 | { | 2796 | { |
2795 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2797 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2796 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2798 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2797 | QStringList catIncList; | 2799 | QStringList catIncList; |
2798 | Incidence* inc = incList.first(); | 2800 | Incidence* inc = incList.first(); |
2799 | int i; | 2801 | int i; |
2800 | int count = 0; | 2802 | int count = 0; |
2801 | while ( inc ) { | 2803 | while ( inc ) { |
2802 | catIncList = inc->categories() ; | 2804 | catIncList = inc->categories() ; |
2803 | for( i = 0; i< catIncList.count(); ++i ) { | 2805 | for( i = 0; i< catIncList.count(); ++i ) { |
2804 | if ( !catList.contains (catIncList[i])) { | 2806 | if ( !catList.contains (catIncList[i])) { |
2805 | catList.append( catIncList[i] ); | 2807 | catList.append( catIncList[i] ); |
2806 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2808 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2807 | ++count; | 2809 | ++count; |
2808 | } | 2810 | } |
2809 | } | 2811 | } |
2810 | inc = incList.next(); | 2812 | inc = incList.next(); |
2811 | } | 2813 | } |
2812 | catList.sort(); | 2814 | catList.sort(); |
2813 | KOPrefs::instance()->mCustomCategories = catList; | 2815 | KOPrefs::instance()->mCustomCategories = catList; |
2814 | return count; | 2816 | return count; |
2815 | } | 2817 | } |
2816 | 2818 | ||
2817 | void CalendarView::manageCategories() | 2819 | void CalendarView::manageCategories() |
2818 | { | 2820 | { |
2819 | KOCatPrefs* cp = new KOCatPrefs(); | 2821 | KOCatPrefs* cp = new KOCatPrefs(); |
2820 | cp->show(); | 2822 | cp->show(); |
2821 | int w =cp->sizeHint().width() ; | 2823 | int w =cp->sizeHint().width() ; |
2822 | int h = cp->sizeHint().height() ; | 2824 | int h = cp->sizeHint().height() ; |
2823 | int dw = QApplication::desktop()->width(); | 2825 | int dw = QApplication::desktop()->width(); |
2824 | int dh = QApplication::desktop()->height(); | 2826 | int dh = QApplication::desktop()->height(); |
2825 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2827 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2826 | if ( !cp->exec() ) { | 2828 | if ( !cp->exec() ) { |
2827 | delete cp; | 2829 | delete cp; |
2828 | return; | 2830 | return; |
2829 | } | 2831 | } |
2830 | int count = 0; | 2832 | int count = 0; |
2831 | if ( cp->addCat() ) { | 2833 | if ( cp->addCat() ) { |
2832 | count = addCategories(); | 2834 | count = addCategories(); |
2833 | if ( count ) { | 2835 | if ( count ) { |
2834 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2836 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2835 | writeSettings(); | 2837 | writeSettings(); |
2836 | } else | 2838 | } else |
2837 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2839 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2838 | } else { | 2840 | } else { |
2839 | removeCategories(); | 2841 | removeCategories(); |
2840 | updateView(); | 2842 | updateView(); |
2841 | } | 2843 | } |
2842 | delete cp; | 2844 | delete cp; |
2843 | } | 2845 | } |
2844 | 2846 | ||
2845 | void CalendarView::beamIncidence(Incidence * Inc) | 2847 | void CalendarView::beamIncidence(Incidence * Inc) |
2846 | { | 2848 | { |
2847 | QPtrList<Incidence> delSel ; | 2849 | QPtrList<Incidence> delSel ; |
2848 | delSel.append(Inc); | 2850 | delSel.append(Inc); |
2849 | beamIncidenceList( delSel ); | 2851 | beamIncidenceList( delSel ); |
2850 | } | 2852 | } |
2851 | void CalendarView::beamCalendar() | 2853 | void CalendarView::beamCalendar() |
2852 | { | 2854 | { |
2853 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2855 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2854 | //qDebug("beamCalendar() "); | 2856 | //qDebug("beamCalendar() "); |
2855 | beamIncidenceList( delSel ); | 2857 | beamIncidenceList( delSel ); |
2856 | } | 2858 | } |
2857 | void CalendarView::beamFilteredCalendar() | 2859 | void CalendarView::beamFilteredCalendar() |
2858 | { | 2860 | { |
2859 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2861 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2860 | //qDebug("beamFilteredCalendar() "); | 2862 | //qDebug("beamFilteredCalendar() "); |
2861 | beamIncidenceList( delSel ); | 2863 | beamIncidenceList( delSel ); |
2862 | } | 2864 | } |
2863 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2865 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2864 | { | 2866 | { |
2865 | 2867 | ||
2866 | KOBeamPrefs beamDialog; | 2868 | KOBeamPrefs beamDialog; |
2867 | if ( beamDialog.exec () == QDialog::Rejected ) | 2869 | if ( beamDialog.exec () == QDialog::Rejected ) |
2868 | return; | 2870 | return; |
2869 | #ifdef DESKTOP_VERSION | 2871 | #ifdef DESKTOP_VERSION |
2870 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2872 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2871 | #else | 2873 | #else |
2872 | QString fn = "/tmp/kopibeamfile"; | 2874 | QString fn = "/tmp/kopibeamfile"; |
2873 | #endif | 2875 | #endif |
2874 | QString mes; | 2876 | QString mes; |
2875 | bool createbup = true; | 2877 | bool createbup = true; |
2876 | if ( createbup ) { | 2878 | if ( createbup ) { |
2877 | QString description = "\n"; | 2879 | QString description = "\n"; |
2878 | CalendarLocal* cal = new CalendarLocal(); | 2880 | CalendarLocal* cal = new CalendarLocal(); |
2879 | if ( beamDialog.beamLocal() ) | 2881 | if ( beamDialog.beamLocal() ) |
2880 | cal->setLocalTime(); | 2882 | cal->setLocalTime(); |
2881 | else | 2883 | else |
2882 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2884 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2883 | Incidence *incidence = delSel.first(); | 2885 | Incidence *incidence = delSel.first(); |
2884 | bool addText = false; | 2886 | bool addText = false; |
2885 | if ( delSel.count() < 10 ) | 2887 | if ( delSel.count() < 10 ) |
2886 | addText = true; | 2888 | addText = true; |
2887 | else { | 2889 | else { |
2888 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2890 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2889 | } | 2891 | } |
2890 | while ( incidence ) { | 2892 | while ( incidence ) { |
2891 | Incidence *in = incidence->clone(); | 2893 | Incidence *in = incidence->clone(); |
2892 | if ( ! in->summary().isEmpty() ) { | 2894 | if ( ! in->summary().isEmpty() ) { |
2893 | in->setDescription(""); | 2895 | in->setDescription(""); |
2894 | } else { | 2896 | } else { |
2895 | in->setSummary( in->description().left(20)); | 2897 | in->setSummary( in->description().left(20)); |
2896 | in->setDescription(""); | 2898 | in->setDescription(""); |
2897 | } | 2899 | } |
2898 | if ( addText ) | 2900 | if ( addText ) |
2899 | description += in->summary() + "\n"; | 2901 | description += in->summary() + "\n"; |
2900 | cal->addIncidence( in ); | 2902 | cal->addIncidence( in ); |
2901 | incidence = delSel.next(); | 2903 | incidence = delSel.next(); |
2902 | } | 2904 | } |
2903 | if ( beamDialog.beamVcal() ) { | 2905 | if ( beamDialog.beamVcal() ) { |
2904 | fn += ".vcs"; | 2906 | fn += ".vcs"; |
2905 | FileStorage storage( cal, fn, new VCalFormat ); | 2907 | FileStorage storage( cal, fn, new VCalFormat ); |
2906 | storage.save(); | 2908 | storage.save(); |
2907 | } else { | 2909 | } else { |
2908 | fn += ".ics"; | 2910 | fn += ".ics"; |
2909 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2911 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2910 | storage.save(); | 2912 | storage.save(); |
2911 | } | 2913 | } |
2912 | delete cal; | 2914 | delete cal; |
2913 | mes = i18n("KO/Pi: Ready for beaming"); | 2915 | mes = i18n("KO/Pi: Ready for beaming"); |
2914 | topLevelWidget()->setCaption(mes); | 2916 | topLevelWidget()->setCaption(mes); |
2915 | KApplication::convert2latin1( fn ); | 2917 | KApplication::convert2latin1( fn ); |
2916 | #ifndef DESKTOP_VERSION | 2918 | #ifndef DESKTOP_VERSION |
2917 | Ir *ir = new Ir( this ); | 2919 | Ir *ir = new Ir( this ); |
2918 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2920 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2919 | ir->send( fn, description, "text/x-vCalendar" ); | 2921 | ir->send( fn, description, "text/x-vCalendar" ); |
2920 | #endif | 2922 | #endif |
2921 | } | 2923 | } |
2922 | } | 2924 | } |
2923 | void CalendarView::beamDone( Ir *ir ) | 2925 | void CalendarView::beamDone( Ir *ir ) |
2924 | { | 2926 | { |
2925 | #ifndef DESKTOP_VERSION | 2927 | #ifndef DESKTOP_VERSION |
2926 | delete ir; | 2928 | delete ir; |
2927 | #endif | 2929 | #endif |
2928 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2930 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2929 | topLevelWidget()->raise(); | 2931 | topLevelWidget()->raise(); |
2930 | } | 2932 | } |
2931 | 2933 | ||
2932 | void CalendarView::moveIncidence(Incidence * inc ) | 2934 | void CalendarView::moveIncidence(Incidence * inc ) |
2933 | { | 2935 | { |
2934 | if ( !inc ) return; | 2936 | if ( !inc ) return; |
2935 | showDatePickerPopup(); | 2937 | showDatePickerPopup(); |
2936 | mDatePickerMode = 2; | 2938 | mDatePickerMode = 2; |
2937 | mMoveIncidence = inc ; | 2939 | mMoveIncidence = inc ; |
2938 | QDate da; | 2940 | QDate da; |
2939 | if ( mMoveIncidence->typeID() == todoID ) { | 2941 | if ( mMoveIncidence->typeID() == todoID ) { |
2940 | Todo * to = (Todo *) mMoveIncidence; | 2942 | Todo * to = (Todo *) mMoveIncidence; |
2941 | if ( to->hasDueDate() ) | 2943 | if ( to->hasDueDate() ) |
2942 | da = to->dtDue().date(); | 2944 | da = to->dtDue().date(); |
2943 | else | 2945 | else |
2944 | da = QDate::currentDate(); | 2946 | da = QDate::currentDate(); |
2945 | } else { | 2947 | } else { |
2946 | da = mMoveIncidence->dtStart().date(); | 2948 | da = mMoveIncidence->dtStart().date(); |
2947 | } | 2949 | } |
2948 | //PENDING set date for recurring incidence to date of recurrence | 2950 | //PENDING set date for recurring incidence to date of recurrence |
2949 | //mMoveIncidenceOldDate; | 2951 | //mMoveIncidenceOldDate; |
2950 | mDatePicker->setDate( da ); | 2952 | mDatePicker->setDate( da ); |
2951 | } | 2953 | } |
2952 | void CalendarView::showDatePickerPopup() | 2954 | void CalendarView::showDatePickerPopup() |
2953 | { | 2955 | { |
2954 | if ( mDateFrame->isVisible() ) | 2956 | if ( mDateFrame->isVisible() ) |
2955 | mDateFrame->hide(); | 2957 | mDateFrame->hide(); |
2956 | else { | 2958 | else { |
2957 | int offX = 0, offY = 0; | 2959 | int offX = 0, offY = 0; |
2958 | #ifdef DESKTOP_VERSION | 2960 | #ifdef DESKTOP_VERSION |
2959 | int w =mDatePicker->sizeHint().width() ; | 2961 | int w =mDatePicker->sizeHint().width() ; |
2960 | int h = mDatePicker->sizeHint().height() ; | 2962 | int h = mDatePicker->sizeHint().height() ; |
2961 | int dw = topLevelWidget()->width(); | 2963 | int dw = topLevelWidget()->width(); |
2962 | int dh = topLevelWidget()->height(); | 2964 | int dh = topLevelWidget()->height(); |
2963 | offX = topLevelWidget()->x(); | 2965 | offX = topLevelWidget()->x(); |
2964 | offY = topLevelWidget()->y(); | 2966 | offY = topLevelWidget()->y(); |
2965 | #else | 2967 | #else |
2966 | int w =mDatePicker->sizeHint().width() ; | 2968 | int w =mDatePicker->sizeHint().width() ; |
2967 | int h = mDatePicker->sizeHint().height() ; | 2969 | int h = mDatePicker->sizeHint().height() ; |
2968 | int dw = QApplication::desktop()->width(); | 2970 | int dw = QApplication::desktop()->width(); |
2969 | int dh = QApplication::desktop()->height(); | 2971 | int dh = QApplication::desktop()->height(); |
2970 | #endif | 2972 | #endif |
2971 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2973 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2972 | mDateFrame->show(); | 2974 | mDateFrame->show(); |
2973 | } | 2975 | } |
2974 | } | 2976 | } |
2975 | void CalendarView::showDatePicker( ) | 2977 | void CalendarView::showDatePicker( ) |
2976 | { | 2978 | { |
2977 | showDatePickerPopup(); | 2979 | showDatePickerPopup(); |
2978 | mDatePickerMode = 1; | 2980 | mDatePickerMode = 1; |
2979 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2981 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2980 | } | 2982 | } |
2981 | 2983 | ||
2982 | void CalendarView::showEventEditor() | 2984 | void CalendarView::showEventEditor() |
2983 | { | 2985 | { |
2984 | #ifdef DESKTOP_VERSION | 2986 | #ifdef DESKTOP_VERSION |
2985 | int x,y,w,h; | 2987 | int x,y,w,h; |
2986 | x = mEventEditor->geometry().x(); | 2988 | x = mEventEditor->geometry().x(); |
2987 | y = mEventEditor->geometry().y(); | 2989 | y = mEventEditor->geometry().y(); |
2988 | w = mEventEditor->width(); | 2990 | w = mEventEditor->width(); |
2989 | h = mEventEditor->height(); | 2991 | h = mEventEditor->height(); |
2990 | mEventEditor->show(); | 2992 | mEventEditor->show(); |
2991 | mEventEditor->setGeometry(x,y,w,h); | 2993 | mEventEditor->setGeometry(x,y,w,h); |
2992 | #else | 2994 | #else |
2993 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2995 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2994 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2996 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2995 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2997 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2996 | qApp->processEvents(); | 2998 | qApp->processEvents(); |
2997 | delete mEventEditor; | 2999 | delete mEventEditor; |
2998 | mEventEditor = mDialogManager->getEventEditor(); | 3000 | mEventEditor = mDialogManager->getEventEditor(); |
2999 | topLevelWidget()->setCaption( i18n("") ); | 3001 | topLevelWidget()->setCaption( i18n("") ); |
3000 | } | 3002 | } |
3001 | mEventEditor->showMaximized(); | 3003 | mEventEditor->showMaximized(); |
3002 | #endif | 3004 | #endif |
3003 | } | 3005 | } |
3004 | void CalendarView::showTodoEditor() | 3006 | void CalendarView::showTodoEditor() |
3005 | { | 3007 | { |
3006 | #ifdef DESKTOP_VERSION | 3008 | #ifdef DESKTOP_VERSION |
3007 | int x,y,w,h; | 3009 | int x,y,w,h; |
3008 | x = mTodoEditor->geometry().x(); | 3010 | x = mTodoEditor->geometry().x(); |
3009 | y = mTodoEditor->geometry().y(); | 3011 | y = mTodoEditor->geometry().y(); |
3010 | w = mTodoEditor->width(); | 3012 | w = mTodoEditor->width(); |
3011 | h = mTodoEditor->height(); | 3013 | h = mTodoEditor->height(); |
3012 | mTodoEditor->show(); | 3014 | mTodoEditor->show(); |
3013 | mTodoEditor->setGeometry(x,y,w,h); | 3015 | mTodoEditor->setGeometry(x,y,w,h); |
3014 | #else | 3016 | #else |
3015 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3017 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3016 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3018 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3017 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3019 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3018 | qApp->processEvents(); | 3020 | qApp->processEvents(); |
3019 | delete mTodoEditor; | 3021 | delete mTodoEditor; |
3020 | mTodoEditor = mDialogManager->getTodoEditor(); | 3022 | mTodoEditor = mDialogManager->getTodoEditor(); |
3021 | topLevelWidget()->setCaption( i18n("") ); | 3023 | topLevelWidget()->setCaption( i18n("") ); |
3022 | } | 3024 | } |
3023 | mTodoEditor->showMaximized(); | 3025 | mTodoEditor->showMaximized(); |
3024 | #endif | 3026 | #endif |
3025 | } | 3027 | } |
3026 | 3028 | ||
3027 | void CalendarView::cloneIncidence() | 3029 | void CalendarView::cloneIncidence() |
3028 | { | 3030 | { |
3029 | Incidence *incidence = currentSelection(); | 3031 | Incidence *incidence = currentSelection(); |
3030 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3032 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3031 | if ( incidence ) { | 3033 | if ( incidence ) { |
3032 | cloneIncidence(incidence); | 3034 | cloneIncidence(incidence); |
3033 | } | 3035 | } |
3034 | } | 3036 | } |
3035 | void CalendarView::moveIncidence() | 3037 | void CalendarView::moveIncidence() |
3036 | { | 3038 | { |
3037 | Incidence *incidence = currentSelection(); | 3039 | Incidence *incidence = currentSelection(); |
3038 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3040 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3039 | if ( incidence ) { | 3041 | if ( incidence ) { |
3040 | moveIncidence(incidence); | 3042 | moveIncidence(incidence); |
3041 | } | 3043 | } |
3042 | } | 3044 | } |
3043 | void CalendarView::beamIncidence() | 3045 | void CalendarView::beamIncidence() |
3044 | { | 3046 | { |
3045 | Incidence *incidence = currentSelection(); | 3047 | Incidence *incidence = currentSelection(); |
3046 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3048 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3047 | if ( incidence ) { | 3049 | if ( incidence ) { |
3048 | beamIncidence(incidence); | 3050 | beamIncidence(incidence); |
3049 | } | 3051 | } |
3050 | } | 3052 | } |
3051 | void CalendarView::toggleCancelIncidence() | 3053 | void CalendarView::toggleCancelIncidence() |
3052 | { | 3054 | { |
3053 | Incidence *incidence = currentSelection(); | 3055 | Incidence *incidence = currentSelection(); |
3054 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3056 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3055 | if ( incidence ) { | 3057 | if ( incidence ) { |
3056 | cancelIncidence(incidence); | 3058 | cancelIncidence(incidence); |
3057 | } | 3059 | } |
3058 | } | 3060 | } |
3059 | 3061 | ||
3060 | 3062 | ||
3061 | void CalendarView::cancelIncidence(Incidence * inc ) | 3063 | void CalendarView::cancelIncidence(Incidence * inc ) |
3062 | { | 3064 | { |
3063 | inc->setCancelled( ! inc->cancelled() ); | 3065 | inc->setCancelled( ! inc->cancelled() ); |
3064 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3066 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3065 | updateView(); | 3067 | updateView(); |
3066 | } | 3068 | } |
3067 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3069 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3068 | { | 3070 | { |
3069 | Incidence * newInc = orgInc->clone(); | 3071 | Incidence * newInc = orgInc->clone(); |
3070 | newInc->recreate(); | 3072 | newInc->recreate(); |
3071 | 3073 | ||
3072 | if ( newInc->typeID() == todoID ) { | 3074 | if ( newInc->typeID() == todoID ) { |
3073 | Todo* t = (Todo*) newInc; | 3075 | Todo* t = (Todo*) newInc; |
3074 | bool cloneSub = false; | 3076 | bool cloneSub = false; |
3075 | if ( orgInc->relations().count() ) { | 3077 | if ( orgInc->relations().count() ) { |
3076 | int result = KMessageBox::warningYesNoCancel(this, | 3078 | int result = KMessageBox::warningYesNoCancel(this, |
3077 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), | 3079 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), |
3078 | i18n("Todo has subtodos"), | 3080 | i18n("Todo has subtodos"), |
3079 | i18n("Yes"), | 3081 | i18n("Yes"), |
3080 | i18n("No")); | 3082 | i18n("No")); |
3081 | 3083 | ||
3082 | if ( result == KMessageBox::Cancel ) { | 3084 | if ( result == KMessageBox::Cancel ) { |
3083 | delete t; | 3085 | delete t; |
3084 | return; | 3086 | return; |
3085 | } | 3087 | } |
3086 | if (result == KMessageBox::Yes) cloneSub = true; | 3088 | if (result == KMessageBox::Yes) cloneSub = true; |
3087 | } | 3089 | } |
3088 | showTodoEditor(); | 3090 | showTodoEditor(); |
3089 | mTodoEditor->editTodo( t ); | 3091 | mTodoEditor->editTodo( t ); |
3090 | if ( mTodoEditor->exec() ) { | 3092 | if ( mTodoEditor->exec() ) { |
3091 | if ( cloneSub ) { | 3093 | if ( cloneSub ) { |
3092 | orgInc->cloneRelations( t ); | 3094 | orgInc->cloneRelations( t ); |
3093 | mCalendar->addIncidenceBranch( t ); | 3095 | mCalendar->addIncidenceBranch( t ); |
3094 | updateView(); | 3096 | updateView(); |
3095 | 3097 | ||
3096 | } else { | 3098 | } else { |
3097 | mCalendar->addTodo( t ); | 3099 | mCalendar->addTodo( t ); |
3098 | updateView(); | 3100 | updateView(); |
3099 | } | 3101 | } |
3100 | } else { | 3102 | } else { |
3101 | delete t; | 3103 | delete t; |
3102 | } | 3104 | } |
3103 | } | 3105 | } |
3104 | else { | 3106 | else { |
3105 | Event* e = (Event*) newInc; | 3107 | Event* e = (Event*) newInc; |
3106 | showEventEditor(); | 3108 | showEventEditor(); |
3107 | mEventEditor->editEvent( e ); | 3109 | mEventEditor->editEvent( e ); |
3108 | if ( mEventEditor->exec() ) { | 3110 | if ( mEventEditor->exec() ) { |
3109 | mCalendar->addEvent( e ); | 3111 | mCalendar->addEvent( e ); |
3110 | updateView(); | 3112 | updateView(); |
3111 | } else { | 3113 | } else { |
3112 | delete e; | 3114 | delete e; |
3113 | } | 3115 | } |
3114 | } | 3116 | } |
3115 | setActiveWindow(); | 3117 | setActiveWindow(); |
3116 | } | 3118 | } |
3117 | 3119 | ||
3118 | void CalendarView::newEvent() | 3120 | void CalendarView::newEvent() |
3119 | { | 3121 | { |
3120 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3122 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3121 | KOAgendaView *aView = mViewManager->agendaView(); | 3123 | KOAgendaView *aView = mViewManager->agendaView(); |
3122 | if (aView) { | 3124 | if (aView) { |
3123 | if (aView->selectionStart().isValid()) { | 3125 | if (aView->selectionStart().isValid()) { |
3124 | if (aView->selectedIsAllDay()) { | 3126 | if (aView->selectedIsAllDay()) { |
3125 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3127 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3126 | } else { | 3128 | } else { |
3127 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3129 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3128 | } | 3130 | } |
3129 | return; | 3131 | return; |
3130 | } | 3132 | } |
3131 | } | 3133 | } |
3132 | 3134 | ||
3133 | QDate date = mNavigator->selectedDates().first(); | 3135 | QDate date = mNavigator->selectedDates().first(); |
3134 | QDateTime current = QDateTime::currentDateTime(); | 3136 | QDateTime current = QDateTime::currentDateTime(); |
3135 | if ( date <= current.date() ) { | 3137 | if ( date <= current.date() ) { |
3136 | int hour = current.time().hour() +1; | 3138 | int hour = current.time().hour() +1; |
3137 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3139 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3138 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3140 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3139 | } else | 3141 | } else |
3140 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3142 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3141 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3143 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3142 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3144 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3143 | } | 3145 | } |
3144 | 3146 | ||
3145 | void CalendarView::newEvent(QDateTime fh) | 3147 | void CalendarView::newEvent(QDateTime fh) |
3146 | { | 3148 | { |
3147 | newEvent(fh, | 3149 | newEvent(fh, |
3148 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3150 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3149 | } | 3151 | } |
3150 | 3152 | ||
3151 | void CalendarView::newEvent(QDate dt) | 3153 | void CalendarView::newEvent(QDate dt) |
3152 | { | 3154 | { |
3153 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3155 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3154 | QDateTime(dt, QTime(0,0,0)), true); | 3156 | QDateTime(dt, QTime(0,0,0)), true); |
3155 | } | 3157 | } |
3156 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3158 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3157 | { | 3159 | { |
3158 | newEvent(fromHint, toHint, false); | 3160 | newEvent(fromHint, toHint, false); |
3159 | } | 3161 | } |
3160 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3162 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3161 | { | 3163 | { |
3162 | 3164 | ||
3163 | showEventEditor(); | 3165 | showEventEditor(); |
3164 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3166 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3165 | if ( mFilterView->filtersEnabled() ) { | 3167 | if ( mFilterView->filtersEnabled() ) { |
3166 | CalFilter *filter = mFilterView->selectedFilter(); | 3168 | CalFilter *filter = mFilterView->selectedFilter(); |
3167 | if (filter && filter->showCategories()) { | 3169 | if (filter && filter->showCategories()) { |
3168 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3170 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3169 | } | 3171 | } |
3170 | if ( filter ) | 3172 | if ( filter ) |
3171 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3173 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3172 | } | 3174 | } |
3173 | mEventEditor->exec(); | 3175 | mEventEditor->exec(); |
3174 | setActiveWindow(); | 3176 | setActiveWindow(); |
3175 | } | 3177 | } |
3176 | void CalendarView::todoAdded(Todo * t) | 3178 | void CalendarView::todoAdded(Todo * t) |
3177 | { | 3179 | { |
3178 | 3180 | ||
3179 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3181 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3180 | updateTodoViews(); | 3182 | updateTodoViews(); |
3181 | } | 3183 | } |
3182 | void CalendarView::todoChanged(Todo * t) | 3184 | void CalendarView::todoChanged(Todo * t) |
3183 | { | 3185 | { |
3184 | emit todoModified( t, 4 ); | 3186 | emit todoModified( t, 4 ); |
3185 | // updateTodoViews(); | 3187 | // updateTodoViews(); |
3186 | } | 3188 | } |
3187 | void CalendarView::todoToBeDeleted(Todo *) | 3189 | void CalendarView::todoToBeDeleted(Todo *) |
3188 | { | 3190 | { |
3189 | //qDebug("todoToBeDeleted(Todo *) "); | 3191 | //qDebug("todoToBeDeleted(Todo *) "); |
3190 | updateTodoViews(); | 3192 | updateTodoViews(); |
3191 | } | 3193 | } |
3192 | void CalendarView::todoDeleted() | 3194 | void CalendarView::todoDeleted() |
3193 | { | 3195 | { |
3194 | //qDebug(" todoDeleted()"); | 3196 | //qDebug(" todoDeleted()"); |
3195 | updateTodoViews(); | 3197 | updateTodoViews(); |
3196 | } | 3198 | } |
3197 | 3199 | ||
3198 | 3200 | ||
3199 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3201 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3200 | { | 3202 | { |
3201 | showTodoEditor(); | 3203 | showTodoEditor(); |
3202 | mTodoEditor->newTodo(dt,0,allday); | 3204 | mTodoEditor->newTodo(dt,0,allday); |
3203 | if ( mFilterView->filtersEnabled() ) { | 3205 | if ( mFilterView->filtersEnabled() ) { |
3204 | CalFilter *filter = mFilterView->selectedFilter(); | 3206 | CalFilter *filter = mFilterView->selectedFilter(); |
3205 | if (filter && filter->showCategories()) { | 3207 | if (filter && filter->showCategories()) { |
3206 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3208 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3207 | } | 3209 | } |
3208 | if ( filter ) | 3210 | if ( filter ) |
3209 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3211 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3210 | } | 3212 | } |
3211 | mTodoEditor->exec(); | 3213 | mTodoEditor->exec(); |
3212 | setActiveWindow(); | 3214 | setActiveWindow(); |
3213 | } | 3215 | } |
3214 | 3216 | ||
3215 | void CalendarView::newTodo() | 3217 | void CalendarView::newTodo() |
3216 | { | 3218 | { |
3217 | newTodoDateTime( QDateTime(),true ); | 3219 | newTodoDateTime( QDateTime(),true ); |
3218 | } | 3220 | } |
3219 | 3221 | ||
3220 | void CalendarView::newSubTodo() | 3222 | void CalendarView::newSubTodo() |
3221 | { | 3223 | { |
3222 | Todo *todo = selectedTodo(); | 3224 | Todo *todo = selectedTodo(); |
3223 | if ( todo ) newSubTodo( todo ); | 3225 | if ( todo ) newSubTodo( todo ); |
3224 | } | 3226 | } |
3225 | 3227 | ||
3226 | void CalendarView::newSubTodo(Todo *parentEvent) | 3228 | void CalendarView::newSubTodo(Todo *parentEvent) |
3227 | { | 3229 | { |
3228 | 3230 | ||
3229 | showTodoEditor(); | 3231 | showTodoEditor(); |
3230 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3232 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3231 | mTodoEditor->exec(); | 3233 | mTodoEditor->exec(); |
3232 | setActiveWindow(); | 3234 | setActiveWindow(); |
3233 | } | 3235 | } |
3234 | 3236 | ||
3235 | void CalendarView::newFloatingEvent() | 3237 | void CalendarView::newFloatingEvent() |
3236 | { | 3238 | { |
3237 | DateList tmpList = mNavigator->selectedDates(); | 3239 | DateList tmpList = mNavigator->selectedDates(); |
3238 | QDate date = tmpList.first(); | 3240 | QDate date = tmpList.first(); |
3239 | 3241 | ||
3240 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3242 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3241 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3243 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3242 | } | 3244 | } |
3243 | 3245 | ||
3244 | 3246 | ||
3245 | void CalendarView::editEvent( Event *event ) | 3247 | void CalendarView::editEvent( Event *event ) |
3246 | { | 3248 | { |
3247 | 3249 | ||
3248 | if ( !event ) return; | 3250 | if ( !event ) return; |
3249 | if ( event->isReadOnly() ) { | 3251 | if ( event->isReadOnly() ) { |
3250 | showEvent( event ); | 3252 | showEvent( event ); |
3251 | return; | 3253 | return; |
3252 | } | 3254 | } |
3253 | showEventEditor(); | 3255 | showEventEditor(); |
3254 | mEventEditor->editEvent( event , mFlagEditDescription); | 3256 | mEventEditor->editEvent( event , mFlagEditDescription); |
3255 | mEventEditor->exec(); | 3257 | mEventEditor->exec(); |
3256 | setActiveWindow(); | 3258 | setActiveWindow(); |
3257 | 3259 | ||
3258 | } | 3260 | } |
3259 | void CalendarView::editJournal( Journal *jour ) | 3261 | void CalendarView::editJournal( Journal *jour ) |
3260 | { | 3262 | { |
3261 | if ( !jour ) return; | 3263 | if ( !jour ) return; |
3262 | mDialogManager->hideSearchDialog(); | 3264 | mDialogManager->hideSearchDialog(); |
3263 | mViewManager->showJournalView(); | 3265 | mViewManager->showJournalView(); |
3264 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3266 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3265 | } | 3267 | } |
3266 | void CalendarView::editTodo( Todo *todo ) | 3268 | void CalendarView::editTodo( Todo *todo ) |
3267 | { | 3269 | { |
3268 | if ( !todo ) return; | 3270 | if ( !todo ) return; |
3269 | 3271 | ||
3270 | if ( todo->isReadOnly() ) { | 3272 | if ( todo->isReadOnly() ) { |
3271 | showTodo( todo ); | 3273 | showTodo( todo ); |
3272 | return; | 3274 | return; |
3273 | } | 3275 | } |
3274 | showTodoEditor(); | 3276 | showTodoEditor(); |
3275 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3277 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3276 | mTodoEditor->exec(); | 3278 | mTodoEditor->exec(); |
3277 | setActiveWindow(); | 3279 | setActiveWindow(); |
3278 | 3280 | ||
3279 | } | 3281 | } |
3280 | 3282 | ||
3281 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3283 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3282 | { | 3284 | { |
3283 | if ( !mEventViewerDialog ) { | 3285 | if ( !mEventViewerDialog ) { |
3284 | mEventViewerDialog = new KOEventViewerDialog(0); | 3286 | mEventViewerDialog = new KOEventViewerDialog(0); |
3285 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3287 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3286 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3288 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3287 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3289 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3288 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3290 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3289 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3291 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3290 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3292 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3291 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3293 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3292 | this, SLOT( slotViewerClosed() ) ); | 3294 | this, SLOT( slotViewerClosed() ) ); |
3293 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3295 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3294 | this, SLOT( todoChanged(Todo *) ) ); | 3296 | this, SLOT( todoChanged(Todo *) ) ); |
3295 | mEventViewerDialog->resize( 640, 480 ); | 3297 | mEventViewerDialog->resize( 640, 480 ); |
3296 | 3298 | ||
3297 | } | 3299 | } |
3298 | return mEventViewerDialog; | 3300 | return mEventViewerDialog; |
3299 | } | 3301 | } |
3300 | void CalendarView::showEvent(Event *event) | 3302 | void CalendarView::showEvent(Event *event) |
3301 | { | 3303 | { |
3302 | getEventViewerDialog()->setEvent(event); | 3304 | getEventViewerDialog()->setEvent(event); |
3303 | getEventViewerDialog()->showMe(); | 3305 | getEventViewerDialog()->showMe(); |
3304 | } | 3306 | } |
3305 | 3307 | ||
3306 | void CalendarView::showTodo(Todo *event) | 3308 | void CalendarView::showTodo(Todo *event) |
3307 | { | 3309 | { |
3308 | getEventViewerDialog()->setTodo(event); | 3310 | getEventViewerDialog()->setTodo(event); |
3309 | getEventViewerDialog()->showMe(); | 3311 | getEventViewerDialog()->showMe(); |
3310 | } | 3312 | } |
3311 | void CalendarView::showJournal( Journal *jour ) | 3313 | void CalendarView::showJournal( Journal *jour ) |
3312 | { | 3314 | { |
3313 | getEventViewerDialog()->setJournal(jour); | 3315 | getEventViewerDialog()->setJournal(jour); |
3314 | getEventViewerDialog()->showMe(); | 3316 | getEventViewerDialog()->showMe(); |
3315 | 3317 | ||
3316 | } | 3318 | } |
3317 | // void CalendarView::todoModified (Todo *event, int changed) | 3319 | // void CalendarView::todoModified (Todo *event, int changed) |
3318 | // { | 3320 | // { |
3319 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3321 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3320 | // // kdDebug() << "Todo modified and open" << endl; | 3322 | // // kdDebug() << "Todo modified and open" << endl; |
3321 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3323 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3322 | // // temp->modified (changed); | 3324 | // // temp->modified (changed); |
3323 | 3325 | ||
3324 | // // } | 3326 | // // } |
3325 | 3327 | ||
3326 | // mViewManager->updateView(); | 3328 | // mViewManager->updateView(); |
3327 | // } | 3329 | // } |
3328 | 3330 | ||
3329 | void CalendarView::appointment_show() | 3331 | void CalendarView::appointment_show() |
3330 | { | 3332 | { |
3331 | Event *anEvent = 0; | 3333 | Event *anEvent = 0; |
3332 | 3334 | ||
3333 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3335 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3334 | 3336 | ||
3335 | if (mViewManager->currentView()->isEventView()) { | 3337 | if (mViewManager->currentView()->isEventView()) { |
3336 | if ( incidence && incidence->typeID() == eventID ) { | 3338 | if ( incidence && incidence->typeID() == eventID ) { |
3337 | anEvent = static_cast<Event *>(incidence); | 3339 | anEvent = static_cast<Event *>(incidence); |
3338 | } | 3340 | } |
3339 | } | 3341 | } |
3340 | 3342 | ||
3341 | if (!anEvent) { | 3343 | if (!anEvent) { |
3342 | KNotifyClient::beep(); | 3344 | KNotifyClient::beep(); |
3343 | return; | 3345 | return; |
3344 | } | 3346 | } |
3345 | 3347 | ||
3346 | showEvent(anEvent); | 3348 | showEvent(anEvent); |
3347 | } | 3349 | } |
3348 | 3350 | ||
3349 | void CalendarView::appointment_edit() | 3351 | void CalendarView::appointment_edit() |
3350 | { | 3352 | { |
3351 | Event *anEvent = 0; | 3353 | Event *anEvent = 0; |
3352 | 3354 | ||
3353 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3355 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3354 | 3356 | ||
3355 | if (mViewManager->currentView()->isEventView()) { | 3357 | if (mViewManager->currentView()->isEventView()) { |
3356 | if ( incidence && incidence->typeID() == eventID ) { | 3358 | if ( incidence && incidence->typeID() == eventID ) { |
3357 | anEvent = static_cast<Event *>(incidence); | 3359 | anEvent = static_cast<Event *>(incidence); |
3358 | } | 3360 | } |
3359 | } | 3361 | } |
3360 | 3362 | ||
3361 | if (!anEvent) { | 3363 | if (!anEvent) { |
3362 | KNotifyClient::beep(); | 3364 | KNotifyClient::beep(); |
3363 | return; | 3365 | return; |
3364 | } | 3366 | } |
3365 | 3367 | ||
3366 | editEvent(anEvent); | 3368 | editEvent(anEvent); |
3367 | } | 3369 | } |
3368 | 3370 | ||
3369 | void CalendarView::appointment_delete() | 3371 | void CalendarView::appointment_delete() |
3370 | { | 3372 | { |
3371 | Event *anEvent = 0; | 3373 | Event *anEvent = 0; |
3372 | 3374 | ||
3373 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3375 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3374 | 3376 | ||
3375 | if (mViewManager->currentView()->isEventView()) { | 3377 | if (mViewManager->currentView()->isEventView()) { |
3376 | if ( incidence && incidence->typeID() == eventID ) { | 3378 | if ( incidence && incidence->typeID() == eventID ) { |
3377 | anEvent = static_cast<Event *>(incidence); | 3379 | anEvent = static_cast<Event *>(incidence); |
3378 | } | 3380 | } |
3379 | } | 3381 | } |
3380 | 3382 | ||
3381 | if (!anEvent) { | 3383 | if (!anEvent) { |
3382 | KNotifyClient::beep(); | 3384 | KNotifyClient::beep(); |
3383 | return; | 3385 | return; |
3384 | } | 3386 | } |
3385 | 3387 | ||
3386 | deleteEvent(anEvent); | 3388 | deleteEvent(anEvent); |
3387 | } | 3389 | } |
3388 | 3390 | ||
3389 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3391 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3390 | { | 3392 | { |
3391 | if (!sub) return; | 3393 | if (!sub) return; |
3392 | if ( sub->relatedTo() == parent ) | 3394 | if ( sub->relatedTo() == parent ) |
3393 | return; | 3395 | return; |
3394 | sub->setRelatedTo(parent); | 3396 | sub->setRelatedTo(parent); |
3395 | sub->updated(); | 3397 | sub->updated(); |
3396 | setModified(true); | 3398 | setModified(true); |
3397 | updateView(); | 3399 | updateView(); |
3398 | } | 3400 | } |
3399 | void CalendarView::todo_unsub(Todo *anTodo ) | 3401 | void CalendarView::todo_unsub(Todo *anTodo ) |
3400 | { | 3402 | { |
3401 | todo_resub( 0, anTodo ); | 3403 | todo_resub( 0, anTodo ); |
3402 | } | 3404 | } |
3403 | 3405 | ||
3404 | void CalendarView::deleteTodo(Todo *todo) | 3406 | void CalendarView::deleteTodo(Todo *todo) |
3405 | { | 3407 | { |
3406 | if (!todo) { | 3408 | if (!todo) { |
3407 | KNotifyClient::beep(); | 3409 | KNotifyClient::beep(); |
3408 | return; | 3410 | return; |
3409 | } | 3411 | } |
3410 | if (KOPrefs::instance()->mConfirm) { | 3412 | if (KOPrefs::instance()->mConfirm) { |
3411 | QString text = todo->summary().left(20); | 3413 | QString text = todo->summary().left(20); |
3412 | if (!todo->relations().isEmpty()) { | 3414 | if (!todo->relations().isEmpty()) { |
3413 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3415 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3414 | 3416 | ||
3415 | } | 3417 | } |
3416 | switch (msgItemDelete(text)) { | 3418 | switch (msgItemDelete(text)) { |
3417 | case KMessageBox::Continue: // OK | 3419 | case KMessageBox::Continue: // OK |
3418 | bool deleteT = false; | 3420 | bool deleteT = false; |
3419 | if (!todo->relations().isEmpty()) { | 3421 | if (!todo->relations().isEmpty()) { |
3420 | deleteT = removeCompletedSubTodos( todo ); | 3422 | deleteT = removeCompletedSubTodos( todo ); |
3421 | } | 3423 | } |
3422 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3424 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3423 | if ( !deleteT ) { | 3425 | if ( !deleteT ) { |
3424 | checkExternalId( todo ); | 3426 | checkExternalId( todo ); |
3425 | calendar()->deleteTodo(todo); | 3427 | calendar()->deleteTodo(todo); |
3426 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3428 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3427 | updateView(); | 3429 | updateView(); |
3428 | } | 3430 | } |
3429 | break; | 3431 | break; |
3430 | } // switch | 3432 | } // switch |
3431 | } else { | 3433 | } else { |
3432 | checkExternalId( todo ); | 3434 | checkExternalId( todo ); |
3433 | mCalendar->deleteTodo(todo); | 3435 | mCalendar->deleteTodo(todo); |
3434 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3436 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3435 | updateView(); | 3437 | updateView(); |
3436 | } | 3438 | } |
3437 | 3439 | ||
3438 | emit updateSearchDialog(); | 3440 | emit updateSearchDialog(); |
3439 | } | 3441 | } |
3440 | void CalendarView::deleteJournal(Journal *jour) | 3442 | void CalendarView::deleteJournal(Journal *jour) |
3441 | { | 3443 | { |
3442 | if (!jour) { | 3444 | if (!jour) { |
3443 | KNotifyClient::beep(); | 3445 | KNotifyClient::beep(); |
3444 | return; | 3446 | return; |
3445 | } | 3447 | } |
3446 | if (KOPrefs::instance()->mConfirm) { | 3448 | if (KOPrefs::instance()->mConfirm) { |
3447 | switch (msgItemDelete( jour->description().left(20))) { | 3449 | switch (msgItemDelete( jour->description().left(20))) { |
3448 | case KMessageBox::Continue: // OK | 3450 | case KMessageBox::Continue: // OK |
3449 | calendar()->deleteJournal(jour); | 3451 | calendar()->deleteJournal(jour); |
3450 | updateView(); | 3452 | updateView(); |
3451 | break; | 3453 | break; |
3452 | } // switch | 3454 | } // switch |
3453 | } else { | 3455 | } else { |
3454 | calendar()->deleteJournal(jour);; | 3456 | calendar()->deleteJournal(jour);; |
3455 | updateView(); | 3457 | updateView(); |
3456 | } | 3458 | } |
3457 | emit updateSearchDialog(); | 3459 | emit updateSearchDialog(); |
3458 | } | 3460 | } |
3459 | 3461 | ||
3460 | void CalendarView::deleteEvent(Event *anEvent) | 3462 | void CalendarView::deleteEvent(Event *anEvent) |
3461 | { | 3463 | { |
3462 | if (!anEvent) { | 3464 | if (!anEvent) { |
3463 | KNotifyClient::beep(); | 3465 | KNotifyClient::beep(); |
3464 | return; | 3466 | return; |
3465 | } | 3467 | } |
3466 | 3468 | ||
3467 | if (anEvent->recurrence()->doesRecur()) { | 3469 | if (anEvent->recurrence()->doesRecur()) { |
3468 | QDate itemDate = mViewManager->currentSelectionDate(); | 3470 | QDate itemDate = mViewManager->currentSelectionDate(); |
3469 | int km; | 3471 | int km; |
3470 | if (!itemDate.isValid()) { | 3472 | if (!itemDate.isValid()) { |
3471 | //kdDebug() << "Date Not Valid" << endl; | 3473 | //kdDebug() << "Date Not Valid" << endl; |
3472 | if (KOPrefs::instance()->mConfirm) { | 3474 | if (KOPrefs::instance()->mConfirm) { |
3473 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3475 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3474 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3476 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3475 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3477 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3476 | if ( km == KMessageBox::Continue ) | 3478 | if ( km == KMessageBox::Continue ) |
3477 | km = KMessageBox::No; // No = all below | 3479 | km = KMessageBox::No; // No = all below |
3478 | } else | 3480 | } else |
3479 | km = KMessageBox::No; | 3481 | km = KMessageBox::No; |
3480 | } else { | 3482 | } else { |
3481 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3483 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3482 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3484 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3483 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3485 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3484 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3486 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3485 | i18n("All")); | 3487 | i18n("All")); |
3486 | } | 3488 | } |
3487 | switch(km) { | 3489 | switch(km) { |
3488 | 3490 | ||
3489 | case KMessageBox::No: // Continue // all | 3491 | case KMessageBox::No: // Continue // all |
3490 | //qDebug("KMessageBox::No "); | 3492 | //qDebug("KMessageBox::No "); |
3491 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3493 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3492 | schedule(Scheduler::Cancel,anEvent); | 3494 | schedule(Scheduler::Cancel,anEvent); |
3493 | 3495 | ||
3494 | checkExternalId( anEvent); | 3496 | checkExternalId( anEvent); |
3495 | mCalendar->deleteEvent(anEvent); | 3497 | mCalendar->deleteEvent(anEvent); |
3496 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3498 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3497 | break; | 3499 | break; |
3498 | 3500 | ||
3499 | // Disabled because it does not work | 3501 | // Disabled because it does not work |
3500 | //#if 0 | 3502 | //#if 0 |
3501 | case KMessageBox::Yes: // just this one | 3503 | case KMessageBox::Yes: // just this one |
3502 | //QDate qd = mNavigator->selectedDates().first(); | 3504 | //QDate qd = mNavigator->selectedDates().first(); |
3503 | //if (!qd.isValid()) { | 3505 | //if (!qd.isValid()) { |
3504 | // kdDebug() << "no date selected, or invalid date" << endl; | 3506 | // kdDebug() << "no date selected, or invalid date" << endl; |
3505 | // KNotifyClient::beep(); | 3507 | // KNotifyClient::beep(); |
3506 | // return; | 3508 | // return; |
3507 | //} | 3509 | //} |
3508 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3510 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3509 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3511 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3510 | anEvent->addExDate(itemDate); | 3512 | anEvent->addExDate(itemDate); |
3511 | int duration = anEvent->recurrence()->duration(); | 3513 | int duration = anEvent->recurrence()->duration(); |
3512 | if ( duration > 0 ) { | 3514 | if ( duration > 0 ) { |
3513 | anEvent->recurrence()->setDuration( duration - 1 ); | 3515 | anEvent->recurrence()->setDuration( duration - 1 ); |
3514 | } | 3516 | } |
3515 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3517 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3516 | } | 3518 | } |
3517 | break; | 3519 | break; |
3518 | //#endif | 3520 | //#endif |
3519 | } // switch | 3521 | } // switch |
3520 | } else { | 3522 | } else { |
3521 | if (KOPrefs::instance()->mConfirm) { | 3523 | if (KOPrefs::instance()->mConfirm) { |
3522 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3524 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3523 | i18n("\nAre you sure you want\nto delete this event?"), | 3525 | i18n("\nAre you sure you want\nto delete this event?"), |
3524 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3526 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3525 | case KMessageBox::Continue: // OK | 3527 | case KMessageBox::Continue: // OK |
3526 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3528 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3527 | schedule(Scheduler::Cancel,anEvent); | 3529 | schedule(Scheduler::Cancel,anEvent); |
3528 | checkExternalId( anEvent); | 3530 | checkExternalId( anEvent); |
3529 | mCalendar->deleteEvent(anEvent); | 3531 | mCalendar->deleteEvent(anEvent); |
3530 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3532 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3531 | break; | 3533 | break; |
3532 | } // switch | 3534 | } // switch |
3533 | } else { | 3535 | } else { |
3534 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3536 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3535 | schedule(Scheduler::Cancel,anEvent); | 3537 | schedule(Scheduler::Cancel,anEvent); |
3536 | checkExternalId( anEvent); | 3538 | checkExternalId( anEvent); |
3537 | mCalendar->deleteEvent(anEvent); | 3539 | mCalendar->deleteEvent(anEvent); |
3538 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3540 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3539 | } | 3541 | } |
3540 | } // if-else | 3542 | } // if-else |
3541 | emit updateSearchDialog(); | 3543 | emit updateSearchDialog(); |
3542 | } | 3544 | } |
3543 | 3545 | ||
3544 | bool CalendarView::deleteEvent(const QString &uid) | 3546 | bool CalendarView::deleteEvent(const QString &uid) |
3545 | { | 3547 | { |
3546 | Event *ev = mCalendar->event(uid); | 3548 | Event *ev = mCalendar->event(uid); |
3547 | if (ev) { | 3549 | if (ev) { |
3548 | deleteEvent(ev); | 3550 | deleteEvent(ev); |
3549 | return true; | 3551 | return true; |
3550 | } else { | 3552 | } else { |
3551 | return false; | 3553 | return false; |
3552 | } | 3554 | } |
3553 | } | 3555 | } |
3554 | 3556 | ||
3555 | /*****************************************************************************/ | 3557 | /*****************************************************************************/ |
3556 | 3558 | ||
3557 | void CalendarView::action_mail() | 3559 | void CalendarView::action_mail() |
3558 | { | 3560 | { |
3559 | #ifndef KORG_NOMAIL | 3561 | #ifndef KORG_NOMAIL |
3560 | KOMailClient mailClient; | 3562 | KOMailClient mailClient; |
3561 | 3563 | ||
3562 | Incidence *incidence = currentSelection(); | 3564 | Incidence *incidence = currentSelection(); |
3563 | 3565 | ||
3564 | if (!incidence) { | 3566 | if (!incidence) { |
3565 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3567 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3566 | return; | 3568 | return; |
3567 | } | 3569 | } |
3568 | if(incidence->attendeeCount() == 0 ) { | 3570 | if(incidence->attendeeCount() == 0 ) { |
3569 | KMessageBox::sorry(this, | 3571 | KMessageBox::sorry(this, |
3570 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3572 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3571 | return; | 3573 | return; |
3572 | } | 3574 | } |
3573 | 3575 | ||
3574 | CalendarLocal cal_tmp; | 3576 | CalendarLocal cal_tmp; |
3575 | Event *event = 0; | 3577 | Event *event = 0; |
3576 | Event *ev = 0; | 3578 | Event *ev = 0; |
3577 | if ( incidence && incidence->typeID() == eventID ) { | 3579 | if ( incidence && incidence->typeID() == eventID ) { |
3578 | event = static_cast<Event *>(incidence); | 3580 | event = static_cast<Event *>(incidence); |
3579 | ev = new Event(*event); | 3581 | ev = new Event(*event); |
3580 | cal_tmp.addEvent(ev); | 3582 | cal_tmp.addEvent(ev); |
3581 | } | 3583 | } |
3582 | ICalFormat mForm(); | 3584 | ICalFormat mForm(); |
3583 | QString attachment = mForm.toString( &cal_tmp ); | 3585 | QString attachment = mForm.toString( &cal_tmp ); |
3584 | if (ev) delete(ev); | 3586 | if (ev) delete(ev); |
3585 | 3587 | ||
3586 | mailClient.mailAttendees(currentSelection(), attachment); | 3588 | mailClient.mailAttendees(currentSelection(), attachment); |
3587 | 3589 | ||
3588 | #endif | 3590 | #endif |
3589 | 3591 | ||
3590 | #if 0 | 3592 | #if 0 |
3591 | Event *anEvent = 0; | 3593 | Event *anEvent = 0; |
3592 | if (mViewManager->currentView()->isEventView()) { | 3594 | if (mViewManager->currentView()->isEventView()) { |
3593 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3595 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3594 | } | 3596 | } |
3595 | 3597 | ||
3596 | if (!anEvent) { | 3598 | if (!anEvent) { |
3597 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3599 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3598 | return; | 3600 | return; |
3599 | } | 3601 | } |
3600 | if(anEvent->attendeeCount() == 0 ) { | 3602 | if(anEvent->attendeeCount() == 0 ) { |
3601 | KMessageBox::sorry(this, | 3603 | KMessageBox::sorry(this, |
3602 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3604 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3603 | return; | 3605 | return; |
3604 | } | 3606 | } |
3605 | 3607 | ||
3606 | mailobject.emailEvent(anEvent); | 3608 | mailobject.emailEvent(anEvent); |
3607 | #endif | 3609 | #endif |
3608 | } | 3610 | } |
3609 | 3611 | ||
3610 | 3612 | ||
3611 | void CalendarView::schedule_publish(Incidence *incidence) | 3613 | void CalendarView::schedule_publish(Incidence *incidence) |
3612 | { | 3614 | { |
3613 | Event *event = 0; | 3615 | Event *event = 0; |
3614 | Todo *todo = 0; | 3616 | Todo *todo = 0; |
3615 | 3617 | ||
3616 | if (incidence == 0) { | 3618 | if (incidence == 0) { |
3617 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3619 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3618 | if (incidence == 0) { | 3620 | if (incidence == 0) { |
3619 | incidence = mTodoList->selectedIncidences().first(); | 3621 | incidence = mTodoList->selectedIncidences().first(); |
3620 | } | 3622 | } |
3621 | } | 3623 | } |
3622 | if ( incidence && incidence->typeID() == eventID ) { | 3624 | if ( incidence && incidence->typeID() == eventID ) { |
3623 | event = static_cast<Event *>(incidence); | 3625 | event = static_cast<Event *>(incidence); |
3624 | } else { | 3626 | } else { |
3625 | if ( incidence && incidence->typeID() == todoID ) { | 3627 | if ( incidence && incidence->typeID() == todoID ) { |
3626 | todo = static_cast<Todo *>(incidence); | 3628 | todo = static_cast<Todo *>(incidence); |
3627 | } | 3629 | } |
3628 | } | 3630 | } |
3629 | 3631 | ||
3630 | if (!event && !todo) { | 3632 | if (!event && !todo) { |
3631 | KMessageBox::sorry(this,i18n("No event selected.")); | 3633 | KMessageBox::sorry(this,i18n("No event selected.")); |
3632 | return; | 3634 | return; |
3633 | } | 3635 | } |
3634 | 3636 | ||
3635 | PublishDialog *publishdlg = new PublishDialog(); | 3637 | PublishDialog *publishdlg = new PublishDialog(); |
3636 | if (incidence->attendeeCount()>0) { | 3638 | if (incidence->attendeeCount()>0) { |
3637 | QPtrList<Attendee> attendees = incidence->attendees(); | 3639 | QPtrList<Attendee> attendees = incidence->attendees(); |
3638 | attendees.first(); | 3640 | attendees.first(); |
3639 | while ( attendees.current()!=0 ) { | 3641 | while ( attendees.current()!=0 ) { |
3640 | publishdlg->addAttendee(attendees.current()); | 3642 | publishdlg->addAttendee(attendees.current()); |
3641 | attendees.next(); | 3643 | attendees.next(); |
3642 | } | 3644 | } |
3643 | } | 3645 | } |
3644 | bool send = true; | 3646 | bool send = true; |
3645 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3647 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3646 | if ( publishdlg->exec() != QDialog::Accepted ) | 3648 | if ( publishdlg->exec() != QDialog::Accepted ) |
3647 | send = false; | 3649 | send = false; |
3648 | } | 3650 | } |
3649 | if ( send ) { | 3651 | if ( send ) { |
3650 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3652 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3651 | if ( event ) { | 3653 | if ( event ) { |
3652 | Event *ev = new Event(*event); | 3654 | Event *ev = new Event(*event); |
3653 | ev->registerObserver(0); | 3655 | ev->registerObserver(0); |
3654 | ev->clearAttendees(); | 3656 | ev->clearAttendees(); |
3655 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3657 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3656 | delete(ev); | 3658 | delete(ev); |
3657 | } | 3659 | } |
3658 | } else { | 3660 | } else { |
3659 | if ( todo ) { | 3661 | if ( todo ) { |
3660 | Todo *ev = new Todo(*todo); | 3662 | Todo *ev = new Todo(*todo); |
3661 | ev->registerObserver(0); | 3663 | ev->registerObserver(0); |
3662 | ev->clearAttendees(); | 3664 | ev->clearAttendees(); |
3663 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3665 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3664 | delete(ev); | 3666 | delete(ev); |
3665 | } | 3667 | } |
3666 | } | 3668 | } |
3667 | } | 3669 | } |
3668 | } | 3670 | } |
3669 | delete publishdlg; | 3671 | delete publishdlg; |
3670 | } | 3672 | } |
3671 | 3673 | ||
3672 | void CalendarView::schedule_request(Incidence *incidence) | 3674 | void CalendarView::schedule_request(Incidence *incidence) |
3673 | { | 3675 | { |
3674 | schedule(Scheduler::Request,incidence); | 3676 | schedule(Scheduler::Request,incidence); |
3675 | } | 3677 | } |
3676 | 3678 | ||
3677 | void CalendarView::schedule_refresh(Incidence *incidence) | 3679 | void CalendarView::schedule_refresh(Incidence *incidence) |
3678 | { | 3680 | { |
3679 | schedule(Scheduler::Refresh,incidence); | 3681 | schedule(Scheduler::Refresh,incidence); |
3680 | } | 3682 | } |
3681 | 3683 | ||
3682 | void CalendarView::schedule_cancel(Incidence *incidence) | 3684 | void CalendarView::schedule_cancel(Incidence *incidence) |
3683 | { | 3685 | { |
3684 | schedule(Scheduler::Cancel,incidence); | 3686 | schedule(Scheduler::Cancel,incidence); |
3685 | } | 3687 | } |
3686 | 3688 | ||
3687 | void CalendarView::schedule_add(Incidence *incidence) | 3689 | void CalendarView::schedule_add(Incidence *incidence) |
3688 | { | 3690 | { |
3689 | schedule(Scheduler::Add,incidence); | 3691 | schedule(Scheduler::Add,incidence); |
3690 | } | 3692 | } |
3691 | 3693 | ||
3692 | void CalendarView::schedule_reply(Incidence *incidence) | 3694 | void CalendarView::schedule_reply(Incidence *incidence) |
3693 | { | 3695 | { |
3694 | schedule(Scheduler::Reply,incidence); | 3696 | schedule(Scheduler::Reply,incidence); |
3695 | } | 3697 | } |
3696 | 3698 | ||
3697 | void CalendarView::schedule_counter(Incidence *incidence) | 3699 | void CalendarView::schedule_counter(Incidence *incidence) |
3698 | { | 3700 | { |
3699 | schedule(Scheduler::Counter,incidence); | 3701 | schedule(Scheduler::Counter,incidence); |
3700 | } | 3702 | } |
3701 | 3703 | ||
3702 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3704 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3703 | { | 3705 | { |
3704 | schedule(Scheduler::Declinecounter,incidence); | 3706 | schedule(Scheduler::Declinecounter,incidence); |
3705 | } | 3707 | } |
3706 | 3708 | ||
3707 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3709 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3708 | { | 3710 | { |
3709 | QDateTime start = QDateTime::currentDateTime(); | 3711 | QDateTime start = QDateTime::currentDateTime(); |
3710 | QDateTime end = start.addDays(daysToPublish); | 3712 | QDateTime end = start.addDays(daysToPublish); |
3711 | 3713 | ||
3712 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3714 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3713 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3715 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3714 | 3716 | ||
3715 | 3717 | ||
3716 | PublishDialog *publishdlg = new PublishDialog(); | 3718 | PublishDialog *publishdlg = new PublishDialog(); |
3717 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3719 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3718 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3720 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3719 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3721 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3720 | delete(freebusy); | 3722 | delete(freebusy); |
3721 | } | 3723 | } |
3722 | } | 3724 | } |
3723 | delete publishdlg; | 3725 | delete publishdlg; |
3724 | } | 3726 | } |
3725 | 3727 | ||
3726 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3728 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3727 | { | 3729 | { |
3728 | Event *event = 0; | 3730 | Event *event = 0; |
3729 | Todo *todo = 0; | 3731 | Todo *todo = 0; |
3730 | 3732 | ||
3731 | if (incidence == 0) { | 3733 | if (incidence == 0) { |
3732 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3734 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3733 | if (incidence == 0) { | 3735 | if (incidence == 0) { |
3734 | incidence = mTodoList->selectedIncidences().first(); | 3736 | incidence = mTodoList->selectedIncidences().first(); |
3735 | } | 3737 | } |
3736 | } | 3738 | } |
3737 | if ( incidence && incidence->typeID() == eventID ) { | 3739 | if ( incidence && incidence->typeID() == eventID ) { |
3738 | event = static_cast<Event *>(incidence); | 3740 | event = static_cast<Event *>(incidence); |
3739 | } | 3741 | } |
3740 | if ( incidence && incidence->typeID() == todoID ) { | 3742 | if ( incidence && incidence->typeID() == todoID ) { |
3741 | todo = static_cast<Todo *>(incidence); | 3743 | todo = static_cast<Todo *>(incidence); |
3742 | } | 3744 | } |
3743 | 3745 | ||
3744 | if (!event && !todo) { | 3746 | if (!event && !todo) { |
3745 | KMessageBox::sorry(this,i18n("No event selected.")); | 3747 | KMessageBox::sorry(this,i18n("No event selected.")); |
3746 | return; | 3748 | return; |
3747 | } | 3749 | } |
3748 | 3750 | ||
3749 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3751 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3750 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3752 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3751 | return; | 3753 | return; |
3752 | } | 3754 | } |
3753 | 3755 | ||
3754 | Event *ev = 0; | 3756 | Event *ev = 0; |
3755 | if (event) ev = new Event(*event); | 3757 | if (event) ev = new Event(*event); |
3756 | Todo *to = 0; | 3758 | Todo *to = 0; |
3757 | if (todo) to = new Todo(*todo); | 3759 | if (todo) to = new Todo(*todo); |
3758 | 3760 | ||
3759 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3761 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3760 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3762 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3761 | if (!me) { | 3763 | if (!me) { |
3762 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3764 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3763 | return; | 3765 | return; |
3764 | } | 3766 | } |
3765 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3767 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3766 | StatusDialog *statdlg = new StatusDialog(this); | 3768 | StatusDialog *statdlg = new StatusDialog(this); |
3767 | if (!statdlg->exec()==QDialog::Accepted) return; | 3769 | if (!statdlg->exec()==QDialog::Accepted) return; |
3768 | me->setStatus( statdlg->status() ); | 3770 | me->setStatus( statdlg->status() ); |
3769 | delete(statdlg); | 3771 | delete(statdlg); |
3770 | } | 3772 | } |
3771 | Attendee *menew = new Attendee(*me); | 3773 | Attendee *menew = new Attendee(*me); |
3772 | if (ev) { | 3774 | if (ev) { |
3773 | ev->clearAttendees(); | 3775 | ev->clearAttendees(); |
3774 | ev->addAttendee(menew,false); | 3776 | ev->addAttendee(menew,false); |
3775 | } else { | 3777 | } else { |
3776 | if (to) { | 3778 | if (to) { |
3777 | todo->clearAttendees(); | 3779 | todo->clearAttendees(); |
3778 | todo->addAttendee(menew,false); | 3780 | todo->addAttendee(menew,false); |
3779 | } | 3781 | } |
3780 | } | 3782 | } |
3781 | } | 3783 | } |
3782 | 3784 | ||
3783 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3785 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3784 | if (ev) { | 3786 | if (ev) { |
3785 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3787 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3786 | } else { | 3788 | } else { |
3787 | if (to) { | 3789 | if (to) { |
3788 | if ( !dlg->addMessage(to,method) ) delete(to); | 3790 | if ( !dlg->addMessage(to,method) ) delete(to); |
3789 | } | 3791 | } |
3790 | } | 3792 | } |
3791 | } | 3793 | } |
3792 | 3794 | ||
3793 | void CalendarView::openAddressbook() | 3795 | void CalendarView::openAddressbook() |
3794 | { | 3796 | { |
3795 | KRun::runCommand("kaddressbook"); | 3797 | KRun::runCommand("kaddressbook"); |
3796 | } | 3798 | } |
3797 | 3799 | ||
3798 | void CalendarView::setModified(bool modified) | 3800 | void CalendarView::setModified(bool modified) |
3799 | { | 3801 | { |
3800 | if ( modified ) | 3802 | if ( modified ) |
3801 | emit signalmodified(); | 3803 | emit signalmodified(); |
3802 | if (mModified != modified) { | 3804 | if (mModified != modified) { |
3803 | mModified = modified; | 3805 | mModified = modified; |
3804 | emit modifiedChanged(mModified); | 3806 | emit modifiedChanged(mModified); |
3805 | } | 3807 | } |
3806 | } | 3808 | } |
3807 | 3809 | ||
3808 | bool CalendarView::isReadOnly() | 3810 | bool CalendarView::isReadOnly() |
3809 | { | 3811 | { |
3810 | return mReadOnly; | 3812 | return mReadOnly; |
3811 | } | 3813 | } |
3812 | 3814 | ||
3813 | void CalendarView::setReadOnly(bool readOnly) | 3815 | void CalendarView::setReadOnly(bool readOnly) |
3814 | { | 3816 | { |
3815 | if (mReadOnly != readOnly) { | 3817 | if (mReadOnly != readOnly) { |
3816 | mReadOnly = readOnly; | 3818 | mReadOnly = readOnly; |
3817 | emit readOnlyChanged(mReadOnly); | 3819 | emit readOnlyChanged(mReadOnly); |
3818 | } | 3820 | } |
3819 | } | 3821 | } |
3820 | 3822 | ||
3821 | bool CalendarView::isModified() | 3823 | bool CalendarView::isModified() |
3822 | { | 3824 | { |
3823 | return mModified; | 3825 | return mModified; |
3824 | } | 3826 | } |
3825 | void CalendarView::slotprintSelInc() | 3827 | void CalendarView::slotprintSelInc() |
3826 | { | 3828 | { |
3827 | if ( currentSelection() == 0 ) { | 3829 | if ( currentSelection() == 0 ) { |
3828 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 3830 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
3829 | return; | 3831 | return; |
3830 | } | 3832 | } |
3831 | showIncidence(); | 3833 | showIncidence(); |
3832 | getEventViewerDialog()->print(); | 3834 | getEventViewerDialog()->print(); |
3833 | 3835 | ||
3834 | } | 3836 | } |
3835 | void CalendarView::printSetup() | 3837 | void CalendarView::printSetup() |
3836 | { | 3838 | { |
3837 | #ifndef KORG_NOPRINTER | 3839 | #ifndef KORG_NOPRINTER |
3838 | createPrinter(); | 3840 | createPrinter(); |
3839 | 3841 | ||
3840 | mCalPrinter->setupPrinter(); | 3842 | mCalPrinter->setupPrinter(); |
3841 | #endif | 3843 | #endif |
3842 | } | 3844 | } |
3843 | 3845 | ||
3844 | void CalendarView::print() | 3846 | void CalendarView::print() |
3845 | { | 3847 | { |
3846 | #ifndef KORG_NOPRINTER | 3848 | #ifndef KORG_NOPRINTER |
3847 | createPrinter(); | 3849 | createPrinter(); |
3848 | 3850 | ||
3849 | DateList tmpDateList = mNavigator->selectedDates(); | 3851 | DateList tmpDateList = mNavigator->selectedDates(); |
3850 | mCalPrinter->print(CalPrinter::Month, | 3852 | mCalPrinter->print(CalPrinter::Month, |
3851 | tmpDateList.first(), tmpDateList.last()); | 3853 | tmpDateList.first(), tmpDateList.last()); |
3852 | #endif | 3854 | #endif |
3853 | } | 3855 | } |
3854 | 3856 | ||
3855 | void CalendarView::printPreview() | 3857 | void CalendarView::printPreview() |
3856 | { | 3858 | { |
3857 | #ifndef KORG_NOPRINTER | 3859 | #ifndef KORG_NOPRINTER |
3858 | kdDebug() << "CalendarView::printPreview()" << endl; | 3860 | kdDebug() << "CalendarView::printPreview()" << endl; |
3859 | 3861 | ||
3860 | createPrinter(); | 3862 | createPrinter(); |
3861 | 3863 | ||
3862 | DateList tmpDateList = mNavigator->selectedDates(); | 3864 | DateList tmpDateList = mNavigator->selectedDates(); |
3863 | 3865 | ||
3864 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3866 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3865 | tmpDateList.last()); | 3867 | tmpDateList.last()); |
3866 | #endif | 3868 | #endif |
3867 | } | 3869 | } |
3868 | 3870 | ||
3869 | void CalendarView::exportICalendar() | 3871 | void CalendarView::exportICalendar() |
3870 | { | 3872 | { |
3871 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3873 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3872 | 3874 | ||
3873 | // Force correct extension | 3875 | // Force correct extension |
3874 | if (filename.right(4) != ".ics") filename += ".ics"; | 3876 | if (filename.right(4) != ".ics") filename += ".ics"; |
3875 | 3877 | ||
3876 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3878 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3877 | storage.save(); | 3879 | storage.save(); |
3878 | } | 3880 | } |
3879 | 3881 | ||
3880 | bool CalendarView::exportVCalendar( QString filename ) | 3882 | bool CalendarView::exportVCalendar( QString filename ) |
3881 | { | 3883 | { |
3882 | if (mCalendar->journals().count() > 0) { | 3884 | if (mCalendar->journals().count() > 0) { |
3883 | int result = KMessageBox::warningContinueCancel(this, | 3885 | int result = KMessageBox::warningContinueCancel(this, |
3884 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3886 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3885 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3887 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3886 | true); | 3888 | true); |
3887 | if (result != KMessageBox::Continue) return false; | 3889 | if (result != KMessageBox::Continue) return false; |
3888 | } | 3890 | } |
3889 | 3891 | ||
3890 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3892 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3891 | 3893 | ||
3892 | // Force correct extension | 3894 | // Force correct extension |
3893 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3895 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3894 | 3896 | ||
3895 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3897 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3896 | return storage.save(); | 3898 | return storage.save(); |
3897 | 3899 | ||
3898 | } | 3900 | } |
3899 | 3901 | ||
3900 | void CalendarView::eventUpdated(Incidence *) | 3902 | void CalendarView::eventUpdated(Incidence *) |
3901 | { | 3903 | { |
3902 | setModified(); | 3904 | setModified(); |
3903 | // Don't call updateView here. The code, which has caused the update of the | 3905 | // Don't call updateView here. The code, which has caused the update of the |
3904 | // event is responsible for updating the view. | 3906 | // event is responsible for updating the view. |
3905 | // updateView(); | 3907 | // updateView(); |
3906 | } | 3908 | } |
3907 | 3909 | ||
3908 | void CalendarView::adaptNavigationUnits() | 3910 | void CalendarView::adaptNavigationUnits() |
3909 | { | 3911 | { |
3910 | if (mViewManager->currentView()->isEventView()) { | 3912 | if (mViewManager->currentView()->isEventView()) { |
3911 | int days = mViewManager->currentView()->currentDateCount(); | 3913 | int days = mViewManager->currentView()->currentDateCount(); |
3912 | if (days == 1) { | 3914 | if (days == 1) { |
3913 | emit changeNavStringPrev(i18n("&Previous Day")); | 3915 | emit changeNavStringPrev(i18n("&Previous Day")); |
3914 | emit changeNavStringNext(i18n("&Next Day")); | 3916 | emit changeNavStringNext(i18n("&Next Day")); |
3915 | } else { | 3917 | } else { |
3916 | emit changeNavStringPrev(i18n("&Previous Week")); | 3918 | emit changeNavStringPrev(i18n("&Previous Week")); |
3917 | emit changeNavStringNext(i18n("&Next Week")); | 3919 | emit changeNavStringNext(i18n("&Next Week")); |
3918 | } | 3920 | } |
3919 | } | 3921 | } |
3920 | } | 3922 | } |
3921 | 3923 | ||
3922 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3924 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3923 | { | 3925 | { |
3924 | if ( incidence ) mTodoList->clearSelection(); | 3926 | if ( incidence ) mTodoList->clearSelection(); |
3925 | processIncidenceSelection( incidence ); | 3927 | processIncidenceSelection( incidence ); |
3926 | } | 3928 | } |
3927 | 3929 | ||
3928 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3930 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3929 | { | 3931 | { |
3930 | if ( incidence && mViewManager->currentView() ) { | 3932 | if ( incidence && mViewManager->currentView() ) { |
3931 | mViewManager->currentView()->clearSelection(); | 3933 | mViewManager->currentView()->clearSelection(); |
3932 | } | 3934 | } |
3933 | processIncidenceSelection( incidence ); | 3935 | processIncidenceSelection( incidence ); |
3934 | } | 3936 | } |
3935 | 3937 | ||
3936 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3938 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3937 | { | 3939 | { |
3938 | if ( incidence == mSelectedIncidence ) return; | 3940 | if ( incidence == mSelectedIncidence ) return; |
3939 | 3941 | ||
3940 | mSelectedIncidence = incidence; | 3942 | mSelectedIncidence = incidence; |
3941 | 3943 | ||
3942 | emit incidenceSelected( mSelectedIncidence ); | 3944 | emit incidenceSelected( mSelectedIncidence ); |
3943 | 3945 | ||
3944 | if ( incidence && incidence->typeID() == eventID ) { | 3946 | if ( incidence && incidence->typeID() == eventID ) { |
3945 | Event *event = static_cast<Event *>( incidence ); | 3947 | Event *event = static_cast<Event *>( incidence ); |
3946 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3948 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3947 | emit organizerEventsSelected( true ); | 3949 | emit organizerEventsSelected( true ); |
3948 | } else { | 3950 | } else { |
3949 | emit organizerEventsSelected(false); | 3951 | emit organizerEventsSelected(false); |
3950 | } | 3952 | } |
3951 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3953 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3952 | KOPrefs::instance()->email() ) ) { | 3954 | KOPrefs::instance()->email() ) ) { |
3953 | emit groupEventsSelected( true ); | 3955 | emit groupEventsSelected( true ); |
3954 | } else { | 3956 | } else { |
3955 | emit groupEventsSelected(false); | 3957 | emit groupEventsSelected(false); |
3956 | } | 3958 | } |
3957 | return; | 3959 | return; |
3958 | } else { | 3960 | } else { |
3959 | if ( incidence && incidence->typeID() == todoID ) { | 3961 | if ( incidence && incidence->typeID() == todoID ) { |
3960 | emit todoSelected( true ); | 3962 | emit todoSelected( true ); |
3961 | Todo *event = static_cast<Todo *>( incidence ); | 3963 | Todo *event = static_cast<Todo *>( incidence ); |
3962 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3964 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3963 | emit organizerEventsSelected( true ); | 3965 | emit organizerEventsSelected( true ); |
3964 | } else { | 3966 | } else { |
3965 | emit organizerEventsSelected(false); | 3967 | emit organizerEventsSelected(false); |
3966 | } | 3968 | } |
3967 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3969 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3968 | KOPrefs::instance()->email() ) ) { | 3970 | KOPrefs::instance()->email() ) ) { |
3969 | emit groupEventsSelected( true ); | 3971 | emit groupEventsSelected( true ); |
3970 | } else { | 3972 | } else { |
3971 | emit groupEventsSelected(false); | 3973 | emit groupEventsSelected(false); |
3972 | } | 3974 | } |
3973 | return; | 3975 | return; |
3974 | } else { | 3976 | } else { |
3975 | emit todoSelected( false ); | 3977 | emit todoSelected( false ); |
3976 | emit organizerEventsSelected(false); | 3978 | emit organizerEventsSelected(false); |
3977 | emit groupEventsSelected(false); | 3979 | emit groupEventsSelected(false); |
3978 | } | 3980 | } |
3979 | return; | 3981 | return; |
3980 | } | 3982 | } |
3981 | 3983 | ||
3982 | /* if ( incidence && incidence->typeID() == todoID ) { | 3984 | /* if ( incidence && incidence->typeID() == todoID ) { |
3983 | emit todoSelected( true ); | 3985 | emit todoSelected( true ); |
3984 | } else { | 3986 | } else { |
3985 | emit todoSelected( false ); | 3987 | emit todoSelected( false ); |
3986 | }*/ | 3988 | }*/ |
3987 | } | 3989 | } |
3988 | 3990 | ||
3989 | 3991 | ||
3990 | void CalendarView::checkClipboard() | 3992 | void CalendarView::checkClipboard() |
3991 | { | 3993 | { |
3992 | #ifndef KORG_NODND | 3994 | #ifndef KORG_NODND |
3993 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3995 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3994 | emit pasteEnabled(true); | 3996 | emit pasteEnabled(true); |
3995 | } else { | 3997 | } else { |
3996 | emit pasteEnabled(false); | 3998 | emit pasteEnabled(false); |
3997 | } | 3999 | } |
3998 | #endif | 4000 | #endif |
3999 | } | 4001 | } |
4000 | 4002 | ||
4001 | void CalendarView::showDates(const DateList &selectedDates) | 4003 | void CalendarView::showDates(const DateList &selectedDates) |
4002 | { | 4004 | { |
4003 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4005 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4004 | 4006 | ||
4005 | 4007 | ||
4006 | if ( !mBlockShowDates ) { | 4008 | if ( !mBlockShowDates ) { |
4007 | if ( mViewManager->currentView() ) { | 4009 | if ( mViewManager->currentView() ) { |
4008 | updateView( selectedDates.first(), selectedDates.last() ); | 4010 | updateView( selectedDates.first(), selectedDates.last() ); |
4009 | } else { | 4011 | } else { |
4010 | mViewManager->showAgendaView(); | 4012 | mViewManager->showAgendaView(); |
4011 | } | 4013 | } |
4012 | } | 4014 | } |
4013 | 4015 | ||
4014 | QDate date = selectedDates.first(); | 4016 | QDate date = selectedDates.first(); |
4015 | if ( ! date.isValid() ) { | 4017 | if ( ! date.isValid() ) { |
4016 | topLevelWidget()->setCaption(""); | 4018 | topLevelWidget()->setCaption(""); |
4017 | return; | 4019 | return; |
4018 | } | 4020 | } |
4019 | 4021 | ||
4020 | QString selDates; | 4022 | QString selDates; |
4021 | selDates = KGlobal::locale()->formatDate( date, true); | 4023 | selDates = KGlobal::locale()->formatDate( date, true); |
4022 | if (selectedDates.first() < selectedDates.last() ) | 4024 | if (selectedDates.first() < selectedDates.last() ) |
4023 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4025 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4024 | else { | 4026 | else { |
4025 | QString addString; | 4027 | QString addString; |
4026 | if ( date == QDateTime::currentDateTime().date() ) | 4028 | if ( date == QDateTime::currentDateTime().date() ) |
4027 | addString = i18n("Today"); | 4029 | addString = i18n("Today"); |
4028 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4030 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4029 | addString = i18n("Tomorrow"); | 4031 | addString = i18n("Tomorrow"); |
4030 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4032 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4031 | addString = i18n("Yesterday"); | 4033 | addString = i18n("Yesterday"); |
4032 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4034 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4033 | addString = i18n("Day before yesterday"); | 4035 | addString = i18n("Day before yesterday"); |
4034 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4036 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4035 | addString = i18n("Day after tomorrow"); | 4037 | addString = i18n("Day after tomorrow"); |
4036 | if ( !addString.isEmpty() ) { | 4038 | if ( !addString.isEmpty() ) { |
4037 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4039 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4038 | return; | 4040 | return; |
4039 | } | 4041 | } |
4040 | } | 4042 | } |
4041 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4043 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4042 | 4044 | ||
4043 | } | 4045 | } |
4044 | 4046 | ||
4045 | QPtrList<CalFilter> CalendarView::filters() | 4047 | QPtrList<CalFilter> CalendarView::filters() |
4046 | { | 4048 | { |
4047 | return mFilters; | 4049 | return mFilters; |
4048 | 4050 | ||
4049 | } | 4051 | } |
4050 | void CalendarView::editFilters() | 4052 | void CalendarView::editFilters() |
4051 | { | 4053 | { |
4052 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4054 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4053 | 4055 | ||
4054 | CalFilter *filter = mFilters.first(); | 4056 | CalFilter *filter = mFilters.first(); |
4055 | while(filter) { | 4057 | while(filter) { |
4056 | filter = mFilters.next(); | 4058 | filter = mFilters.next(); |
4057 | } | 4059 | } |
4058 | 4060 | ||
4059 | mDialogManager->showFilterEditDialog(&mFilters); | 4061 | mDialogManager->showFilterEditDialog(&mFilters); |
4060 | updateFilter(); | 4062 | updateFilter(); |
4061 | } | 4063 | } |
4062 | void CalendarView::toggleFilter() | 4064 | void CalendarView::toggleFilter() |
4063 | { | 4065 | { |
4064 | if ( mLeftFrame->isHidden() ) { | 4066 | if ( mLeftFrame->isHidden() ) { |
4065 | toggleExpand(); | 4067 | toggleExpand(); |
4066 | showFilter( true ); | 4068 | showFilter( true ); |
4067 | } else | 4069 | } else |
4068 | showFilter(! mCalEditView->isVisible()); | 4070 | showFilter(! mCalEditView->isVisible()); |
4069 | } | 4071 | } |
4070 | 4072 | ||
4071 | KOFilterView *CalendarView::filterView() | 4073 | KOFilterView *CalendarView::filterView() |
4072 | { | 4074 | { |
4073 | return mFilterView; | 4075 | return mFilterView; |
4074 | } | 4076 | } |
4075 | void CalendarView::selectFilter( int fil ) | 4077 | void CalendarView::selectFilter( int fil ) |
4076 | { | 4078 | { |
4077 | mFilterView->setSelectedFilter( fil ); | 4079 | mFilterView->setSelectedFilter( fil ); |
4078 | updateUnmanagedViews(); | 4080 | updateUnmanagedViews(); |
4079 | } | 4081 | } |
4080 | void CalendarView::showFilter(bool visible) | 4082 | void CalendarView::showFilter(bool visible) |
4081 | { | 4083 | { |
4082 | #if 1 | 4084 | #if 1 |
4083 | if (visible) { | 4085 | if (visible) { |
4084 | mCalEditView->readConfig(); | 4086 | mCalEditView->readConfig(); |
4085 | mCalEditView->show(); | 4087 | mCalEditView->show(); |
4086 | QValueList<int> sizes; | 4088 | QValueList<int> sizes; |
4087 | sizes = mLeftFrame->sizes(); | 4089 | sizes = mLeftFrame->sizes(); |
4088 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4090 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4089 | sizes.clear(); | 4091 | sizes.clear(); |
4090 | sizes << 100; | 4092 | sizes << 100; |
4091 | sizes << 0; | 4093 | sizes << 0; |
4092 | sizes << 0; | 4094 | sizes << 0; |
4093 | sizes << 100; | 4095 | sizes << 100; |
4094 | mLeftFrame->setSizes(sizes); | 4096 | mLeftFrame->setSizes(sizes); |
4095 | } | 4097 | } |
4096 | #if 0 | 4098 | #if 0 |
4097 | sizes = mLeftFrame->sizes(); | 4099 | sizes = mLeftFrame->sizes(); |
4098 | int ccc = 0; | 4100 | int ccc = 0; |
4099 | while ( ccc < sizes.count()) { | 4101 | while ( ccc < sizes.count()) { |
4100 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4102 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4101 | ++ccc; | 4103 | ++ccc; |
4102 | } | 4104 | } |
4103 | #endif | 4105 | #endif |
4104 | 4106 | ||
4105 | } | 4107 | } |
4106 | else { | 4108 | else { |
4107 | mCalEditView->hide(); | 4109 | mCalEditView->hide(); |
4108 | } | 4110 | } |
4109 | #else | 4111 | #else |
4110 | if (visible) mFilterView->show(); | 4112 | if (visible) mFilterView->show(); |
4111 | else mFilterView->hide(); | 4113 | else mFilterView->hide(); |
4112 | #endif | 4114 | #endif |
4113 | } | 4115 | } |
4114 | void CalendarView::toggleFilerEnabled( ) | 4116 | void CalendarView::toggleFilerEnabled( ) |
4115 | { | 4117 | { |
4116 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4118 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4117 | if ( !mFilterView->filtersEnabled() ) | 4119 | if ( !mFilterView->filtersEnabled() ) |
4118 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4120 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4119 | updateUnmanagedViews(); | 4121 | updateUnmanagedViews(); |
4120 | 4122 | ||
4121 | } | 4123 | } |
4122 | void CalendarView::updateFilter() | 4124 | void CalendarView::updateFilter() |
4123 | { | 4125 | { |
4124 | CalFilter *filter = mFilterView->selectedFilter(); | 4126 | CalFilter *filter = mFilterView->selectedFilter(); |
4125 | if (filter) { | 4127 | if (filter) { |
4126 | QString mess; | 4128 | QString mess; |
4127 | if (mFilterView->filtersEnabled()) { | 4129 | if (mFilterView->filtersEnabled()) { |
4128 | mess = i18n("Filter selected: ")+filter->name(); | 4130 | mess = i18n("Filter selected: ")+filter->name(); |
4129 | filter->setEnabled(true); | 4131 | filter->setEnabled(true); |
4130 | } | 4132 | } |
4131 | else filter->setEnabled(false); | 4133 | else filter->setEnabled(false); |
4132 | mCalendar->setFilter(filter); | 4134 | mCalendar->setFilter(filter); |
4133 | updateView(); | 4135 | updateView(); |
4134 | if ( !mess.isEmpty() ) | 4136 | if ( !mess.isEmpty() ) |
4135 | topLevelWidget()->setCaption( mess ); | 4137 | topLevelWidget()->setCaption( mess ); |
4136 | 4138 | ||
4137 | } | 4139 | } |
4138 | emit filtersUpdated(); | 4140 | emit filtersUpdated(); |
4139 | } | 4141 | } |
4140 | 4142 | ||
4141 | void CalendarView::filterEdited() | 4143 | void CalendarView::filterEdited() |
4142 | { | 4144 | { |
4143 | mFilterView->updateFilters(); | 4145 | mFilterView->updateFilters(); |
4144 | updateFilter(); | 4146 | updateFilter(); |
4145 | writeSettings(); | 4147 | writeSettings(); |
4146 | } | 4148 | } |
4147 | 4149 | ||
4148 | 4150 | ||
4149 | void CalendarView::takeOverEvent() | 4151 | void CalendarView::takeOverEvent() |
4150 | { | 4152 | { |
4151 | Incidence *incidence = currentSelection(); | 4153 | Incidence *incidence = currentSelection(); |
4152 | 4154 | ||
4153 | if (!incidence) return; | 4155 | if (!incidence) return; |
4154 | 4156 | ||
4155 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4157 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4156 | incidence->recreate(); | 4158 | incidence->recreate(); |
4157 | incidence->setReadOnly(false); | 4159 | incidence->setReadOnly(false); |
4158 | 4160 | ||
4159 | updateView(); | 4161 | updateView(); |
4160 | } | 4162 | } |
4161 | 4163 | ||
4162 | void CalendarView::takeOverCalendar() | 4164 | void CalendarView::takeOverCalendar() |
4163 | { | 4165 | { |
4164 | // TODO: Create Calendar::allIncidences() function and use it here | 4166 | // TODO: Create Calendar::allIncidences() function and use it here |
4165 | 4167 | ||
4166 | clearAllViews(); | 4168 | clearAllViews(); |
4167 | QPtrList<Event> events = mCalendar->events(); | 4169 | QPtrList<Event> events = mCalendar->events(); |
4168 | for(uint i=0; i<events.count(); ++i) { | 4170 | for(uint i=0; i<events.count(); ++i) { |
4169 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4171 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4170 | events.at(i)->recreate(); | 4172 | events.at(i)->recreate(); |
4171 | events.at(i)->setReadOnly(false); | 4173 | events.at(i)->setReadOnly(false); |
4172 | } | 4174 | } |
4173 | 4175 | ||
4174 | QPtrList<Todo> todos = mCalendar->todos(); | 4176 | QPtrList<Todo> todos = mCalendar->todos(); |
4175 | for(uint i=0; i<todos.count(); ++i) { | 4177 | for(uint i=0; i<todos.count(); ++i) { |
4176 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4178 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4177 | todos.at(i)->recreate(); | 4179 | todos.at(i)->recreate(); |
4178 | todos.at(i)->setReadOnly(false); | 4180 | todos.at(i)->setReadOnly(false); |
4179 | } | 4181 | } |
4180 | 4182 | ||
4181 | QPtrList<Journal> journals = mCalendar->journals(); | 4183 | QPtrList<Journal> journals = mCalendar->journals(); |
4182 | for(uint i=0; i<journals.count(); ++i) { | 4184 | for(uint i=0; i<journals.count(); ++i) { |
4183 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4185 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4184 | journals.at(i)->recreate(); | 4186 | journals.at(i)->recreate(); |
4185 | journals.at(i)->setReadOnly(false); | 4187 | journals.at(i)->setReadOnly(false); |
4186 | } | 4188 | } |
4187 | 4189 | ||
4188 | updateView(); | 4190 | updateView(); |
4189 | } | 4191 | } |
4190 | 4192 | ||
4191 | void CalendarView::showIntro() | 4193 | void CalendarView::showIntro() |
4192 | { | 4194 | { |
4193 | kdDebug() << "To be implemented." << endl; | 4195 | kdDebug() << "To be implemented." << endl; |
4194 | } | 4196 | } |
4195 | 4197 | ||
4196 | QWidgetStack *CalendarView::viewStack() | 4198 | QWidgetStack *CalendarView::viewStack() |
4197 | { | 4199 | { |
4198 | return mRightFrame; | 4200 | return mRightFrame; |
4199 | } | 4201 | } |
4200 | 4202 | ||
4201 | QWidget *CalendarView::leftFrame() | 4203 | QWidget *CalendarView::leftFrame() |
4202 | { | 4204 | { |
4203 | return ( QWidget *)mLeftFrame; | 4205 | return ( QWidget *)mLeftFrame; |
4204 | } | 4206 | } |
4205 | 4207 | ||
4206 | DateNavigator *CalendarView::dateNavigator() | 4208 | DateNavigator *CalendarView::dateNavigator() |
4207 | { | 4209 | { |
4208 | return mNavigator; | 4210 | return mNavigator; |
4209 | } | 4211 | } |
4210 | 4212 | ||
4211 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4213 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4212 | { | 4214 | { |
4213 | return mDateNavigator->navigatorView(); | 4215 | return mDateNavigator->navigatorView(); |
4214 | } | 4216 | } |
4215 | void CalendarView::toggleDateNavigatorWidget() | 4217 | void CalendarView::toggleDateNavigatorWidget() |
4216 | { | 4218 | { |
4217 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4219 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4218 | 4220 | ||
4219 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4221 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4220 | mDateNavigator->hide(); | 4222 | mDateNavigator->hide(); |
4221 | else | 4223 | else |
4222 | mDateNavigator->show(); | 4224 | mDateNavigator->show(); |
4223 | } | 4225 | } |
4224 | void CalendarView::addView(KOrg::BaseView *view) | 4226 | void CalendarView::addView(KOrg::BaseView *view) |
4225 | { | 4227 | { |
4226 | mViewManager->addView(view); | 4228 | mViewManager->addView(view); |
4227 | } | 4229 | } |
4228 | 4230 | ||
4229 | void CalendarView::showView(KOrg::BaseView *view) | 4231 | void CalendarView::showView(KOrg::BaseView *view) |
4230 | { | 4232 | { |
4231 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4233 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4232 | } | 4234 | } |
4233 | 4235 | ||
4234 | Incidence *CalendarView::currentSelection() | 4236 | Incidence *CalendarView::currentSelection() |
4235 | { | 4237 | { |
4236 | return mViewManager->currentSelection(); | 4238 | return mViewManager->currentSelection(); |
4237 | } | 4239 | } |
4238 | void CalendarView::toggleAllDaySize() | 4240 | void CalendarView::toggleAllDaySize() |
4239 | { | 4241 | { |
4240 | /* | 4242 | /* |
4241 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4243 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4242 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4244 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4243 | else | 4245 | else |
4244 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4246 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4245 | */ | 4247 | */ |
4246 | viewManager()->agendaView()->toggleAllDay(); | 4248 | viewManager()->agendaView()->toggleAllDay(); |
4247 | } | 4249 | } |
4248 | void CalendarView::toggleExpand() | 4250 | void CalendarView::toggleExpand() |
4249 | { | 4251 | { |
4250 | // if ( mLeftFrame->isHidden() ) { | 4252 | // if ( mLeftFrame->isHidden() ) { |
4251 | // mLeftFrame->show(); | 4253 | // mLeftFrame->show(); |
4252 | // emit calendarViewExpanded( false ); | 4254 | // emit calendarViewExpanded( false ); |
4253 | // } else { | 4255 | // } else { |
4254 | // mLeftFrame->hide(); | 4256 | // mLeftFrame->hide(); |
4255 | // emit calendarViewExpanded( true ); | 4257 | // emit calendarViewExpanded( true ); |
4256 | // } | 4258 | // } |
4257 | //qDebug(" CalendarView::toggleExpand()"); | 4259 | //qDebug(" CalendarView::toggleExpand()"); |
4258 | globalFlagBlockAgenda = 1; | 4260 | globalFlagBlockAgenda = 1; |
4259 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4261 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4260 | globalFlagBlockAgenda = 5; | 4262 | globalFlagBlockAgenda = 5; |
4261 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4263 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4262 | //mViewManager->showView( 0, true ); | 4264 | //mViewManager->showView( 0, true ); |
4263 | } | 4265 | } |
4264 | 4266 | ||
4265 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4267 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4266 | { | 4268 | { |
4267 | setModified( modified ); | 4269 | setModified( modified ); |
4268 | } | 4270 | } |
4269 | 4271 | ||
4270 | Todo *CalendarView::selectedTodo() | 4272 | Todo *CalendarView::selectedTodo() |
4271 | { | 4273 | { |
4272 | Incidence *incidence = currentSelection(); | 4274 | Incidence *incidence = currentSelection(); |
4273 | if ( incidence && incidence->typeID() == todoID ) { | 4275 | if ( incidence && incidence->typeID() == todoID ) { |
4274 | return static_cast<Todo *>( incidence ); | 4276 | return static_cast<Todo *>( incidence ); |
4275 | } | 4277 | } |
4276 | 4278 | ||
4277 | incidence = mTodoList->selectedIncidences().first(); | 4279 | incidence = mTodoList->selectedIncidences().first(); |
4278 | if ( incidence && incidence->typeID() == todoID ) { | 4280 | if ( incidence && incidence->typeID() == todoID ) { |
4279 | return static_cast<Todo *>( incidence ); | 4281 | return static_cast<Todo *>( incidence ); |
4280 | } | 4282 | } |
4281 | 4283 | ||
4282 | return 0; | 4284 | return 0; |
4283 | } | 4285 | } |
4284 | 4286 | ||
4285 | void CalendarView::dialogClosing(Incidence *in) | 4287 | void CalendarView::dialogClosing(Incidence *in) |
4286 | { | 4288 | { |
4287 | // mDialogList.remove(in); | 4289 | // mDialogList.remove(in); |
4288 | } | 4290 | } |
4289 | 4291 | ||
4290 | void CalendarView::showIncidence() | 4292 | void CalendarView::showIncidence() |
4291 | { | 4293 | { |
4292 | mViewerCallerIsSearchDialog = false; | 4294 | mViewerCallerIsSearchDialog = false; |
4293 | Incidence *incidence = currentSelection(); | 4295 | Incidence *incidence = currentSelection(); |
4294 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4296 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4295 | if ( incidence ) { | 4297 | if ( incidence ) { |
4296 | ShowIncidenceVisitor v; | 4298 | ShowIncidenceVisitor v; |
4297 | v.act( incidence, this ); | 4299 | v.act( incidence, this ); |
4298 | } | 4300 | } |
4299 | } | 4301 | } |
4300 | void CalendarView::editIncidenceDescription() | 4302 | void CalendarView::editIncidenceDescription() |
4301 | { | 4303 | { |
4302 | mFlagEditDescription = true; | 4304 | mFlagEditDescription = true; |
4303 | editIncidence(); | 4305 | editIncidence(); |
4304 | mFlagEditDescription = false; | 4306 | mFlagEditDescription = false; |
4305 | } | 4307 | } |
4306 | void CalendarView::editIncidence() | 4308 | void CalendarView::editIncidence() |
4307 | { | 4309 | { |
4308 | // qDebug("editIncidence() "); | 4310 | // qDebug("editIncidence() "); |
4309 | Incidence *incidence = currentSelection(); | 4311 | Incidence *incidence = currentSelection(); |
4310 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4312 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4311 | if ( incidence ) { | 4313 | if ( incidence ) { |
4312 | EditIncidenceVisitor v; | 4314 | EditIncidenceVisitor v; |
4313 | v.act( incidence, this ); | 4315 | v.act( incidence, this ); |
4314 | } | 4316 | } |
4315 | } | 4317 | } |
4316 | 4318 | ||
4317 | void CalendarView::deleteIncidence() | 4319 | void CalendarView::deleteIncidence() |
4318 | { | 4320 | { |
4319 | Incidence *incidence = currentSelection(); | 4321 | Incidence *incidence = currentSelection(); |
4320 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4322 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4321 | if ( incidence ) { | 4323 | if ( incidence ) { |
4322 | deleteIncidence(incidence); | 4324 | deleteIncidence(incidence); |
4323 | } | 4325 | } |
4324 | } | 4326 | } |
4325 | void CalendarView::showIncidence(QString uid) | 4327 | void CalendarView::showIncidence(QString uid) |
4326 | { | 4328 | { |
4327 | Incidence *inc = mCalendar->incidence( uid ); | 4329 | Incidence *inc = mCalendar->incidence( uid ); |
4328 | if ( inc ) | 4330 | if ( inc ) |
4329 | showIncidence( inc ); | 4331 | showIncidence( inc ); |
4330 | } | 4332 | } |
4331 | void CalendarView::showIncidence(Incidence *incidence) | 4333 | void CalendarView::showIncidence(Incidence *incidence) |
4332 | { | 4334 | { |
4333 | mViewerCallerIsSearchDialog = false; | 4335 | mViewerCallerIsSearchDialog = false; |
4334 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4336 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4335 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4337 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4336 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4338 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4337 | mViewerCallerIsSearchDialog = true; | 4339 | mViewerCallerIsSearchDialog = true; |
4338 | } | 4340 | } |
4339 | } | 4341 | } |
4340 | if ( incidence ) { | 4342 | if ( incidence ) { |
4341 | ShowIncidenceVisitor v; | 4343 | ShowIncidenceVisitor v; |
4342 | v.act( incidence, this ); | 4344 | v.act( incidence, this ); |
4343 | } | 4345 | } |
4344 | } | 4346 | } |
4345 | 4347 | ||
4346 | void CalendarView::editIncidence(Incidence *incidence) | 4348 | void CalendarView::editIncidence(Incidence *incidence) |
4347 | { | 4349 | { |
4348 | if ( incidence ) { | 4350 | if ( incidence ) { |
4349 | 4351 | ||
4350 | EditIncidenceVisitor v; | 4352 | EditIncidenceVisitor v; |
4351 | v.act( incidence, this ); | 4353 | v.act( incidence, this ); |
4352 | 4354 | ||
4353 | } | 4355 | } |
4354 | } | 4356 | } |
4355 | 4357 | ||
4356 | void CalendarView::deleteIncidence(Incidence *incidence) | 4358 | void CalendarView::deleteIncidence(Incidence *incidence) |
4357 | { | 4359 | { |
4358 | //qDebug(" CalendarView::deleteIncidence "); | 4360 | //qDebug(" CalendarView::deleteIncidence "); |
4359 | if ( incidence ) { | 4361 | if ( incidence ) { |
4360 | DeleteIncidenceVisitor v; | 4362 | DeleteIncidenceVisitor v; |
4361 | v.act( incidence, this ); | 4363 | v.act( incidence, this ); |
4362 | } | 4364 | } |
4363 | } | 4365 | } |
4364 | 4366 | ||
4365 | 4367 | ||
4366 | void CalendarView::lookForOutgoingMessages() | 4368 | void CalendarView::lookForOutgoingMessages() |
4367 | { | 4369 | { |
4368 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4370 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4369 | ogd->loadMessages(); | 4371 | ogd->loadMessages(); |
4370 | } | 4372 | } |
4371 | 4373 | ||
4372 | void CalendarView::lookForIncomingMessages() | 4374 | void CalendarView::lookForIncomingMessages() |
4373 | { | 4375 | { |
4374 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4376 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4375 | icd->retrieve(); | 4377 | icd->retrieve(); |
4376 | } | 4378 | } |
4377 | 4379 | ||
4378 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4380 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4379 | { | 4381 | { |
4380 | bool deleteTodo = true; | 4382 | bool deleteTodo = true; |
4381 | QPtrList<Incidence> subTodos; | 4383 | QPtrList<Incidence> subTodos; |
4382 | Incidence *aTodo; | 4384 | Incidence *aTodo; |
4383 | subTodos = t->relations(); | 4385 | subTodos = t->relations(); |
4384 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4386 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4385 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4387 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4386 | deleteTodo = false; | 4388 | deleteTodo = false; |
4387 | } | 4389 | } |
4388 | if ( deleteTodo ) { | 4390 | if ( deleteTodo ) { |
4389 | if ( t->isCompleted() && !t->doesRecur()) { | 4391 | if ( t->isCompleted() && !t->doesRecur()) { |
4390 | checkExternalId( t ); | 4392 | checkExternalId( t ); |
4391 | mCalendar->deleteTodo( t ); | 4393 | mCalendar->deleteTodo( t ); |
4392 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4394 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4393 | } | 4395 | } |
4394 | else | 4396 | else |
4395 | deleteTodo = false; | 4397 | deleteTodo = false; |
4396 | } | 4398 | } |
4397 | return deleteTodo; | 4399 | return deleteTodo; |
4398 | 4400 | ||
4399 | } | 4401 | } |
4400 | void CalendarView::purgeCompleted() | 4402 | void CalendarView::purgeCompleted() |
4401 | { | 4403 | { |
4402 | int result = KMessageBox::warningContinueCancel(this, | 4404 | int result = KMessageBox::warningContinueCancel(this, |
4403 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4405 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4404 | 4406 | ||
4405 | if (result == KMessageBox::Continue) { | 4407 | if (result == KMessageBox::Continue) { |
4406 | 4408 | ||
4407 | QPtrList<Todo> todoCal; | 4409 | QPtrList<Todo> todoCal; |
4408 | QPtrList<Todo> rootTodos; | 4410 | QPtrList<Todo> rootTodos; |
4409 | //QPtrList<Incidence> rel; | 4411 | //QPtrList<Incidence> rel; |
4410 | Todo *aTodo;//, *rTodo; | 4412 | Todo *aTodo;//, *rTodo; |
4411 | Incidence *rIncidence; | 4413 | Incidence *rIncidence; |
4412 | bool childDelete = false; | 4414 | bool childDelete = false; |
4413 | bool deletedOne = true; | 4415 | bool deletedOne = true; |
4414 | todoCal = calendar()->todos(); | 4416 | todoCal = calendar()->todos(); |
4415 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4417 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4416 | if ( !aTodo->relatedTo() ) | 4418 | if ( !aTodo->relatedTo() ) |
4417 | rootTodos.append( aTodo ); | 4419 | rootTodos.append( aTodo ); |
4418 | } | 4420 | } |
4419 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4421 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4420 | removeCompletedSubTodos( aTodo ); | 4422 | removeCompletedSubTodos( aTodo ); |
4421 | } | 4423 | } |
4422 | 4424 | ||
4423 | updateView(); | 4425 | updateView(); |
4424 | } | 4426 | } |
4425 | } | 4427 | } |
4426 | 4428 | ||
4427 | void CalendarView::slotCalendarChanged() | 4429 | void CalendarView::slotCalendarChanged() |
4428 | { | 4430 | { |
4429 | ; | 4431 | ; |
4430 | } | 4432 | } |
4431 | 4433 | ||
4432 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4434 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4433 | { | 4435 | { |
4434 | //qDebug(" alendarView::keyPressEvent "); | 4436 | //qDebug(" alendarView::keyPressEvent "); |
4435 | e->ignore(); | 4437 | e->ignore(); |
4436 | } | 4438 | } |
4437 | 4439 | ||
4438 | 4440 | ||
4439 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4441 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4440 | { | 4442 | { |
4441 | // mSyncManager = manager; | 4443 | // mSyncManager = manager; |
4442 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4444 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4443 | qDebug("KO: SyncKDE request detected!"); | 4445 | qDebug("KO: SyncKDE request detected!"); |
4444 | } | 4446 | } |
4445 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4447 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4446 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4448 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4447 | return syncCalendar( filename, mode ); | 4449 | return syncCalendar( filename, mode ); |
4448 | } | 4450 | } |
4449 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4451 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4450 | { | 4452 | { |
4451 | //mSyncManager = manager; | 4453 | //mSyncManager = manager; |
4452 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4454 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4453 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4455 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4454 | if ( resource == "sharp" ) | 4456 | if ( resource == "sharp" ) |
4455 | syncExternal( 0 ); | 4457 | syncExternal( 0 ); |
4456 | if ( resource == "phone" ) | 4458 | if ( resource == "phone" ) |
4457 | syncExternal( 1 ); | 4459 | syncExternal( 1 ); |
4458 | // pending setmodified | 4460 | // pending setmodified |
4459 | return true; | 4461 | return true; |
4460 | } | 4462 | } |
4461 | void CalendarView::setSyncManager(KSyncManager* manager) | 4463 | void CalendarView::setSyncManager(KSyncManager* manager) |
4462 | { | 4464 | { |
4463 | mSyncManager = manager; | 4465 | mSyncManager = manager; |
4464 | } | 4466 | } |
4465 | 4467 | ||
4466 | void CalendarView::removeSyncInfo( QString syncProfile) | 4468 | void CalendarView::removeSyncInfo( QString syncProfile) |
4467 | { | 4469 | { |
4468 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4470 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4469 | mCalendar->removeSyncInfo( syncProfile ); | 4471 | mCalendar->removeSyncInfo( syncProfile ); |
4470 | 4472 | ||
4471 | } | 4473 | } |
4472 | 4474 | ||
4473 | void CalendarView::undo_delete() | 4475 | void CalendarView::undo_delete() |
4474 | { | 4476 | { |
4475 | //qDebug("undo_delete() "); | 4477 | //qDebug("undo_delete() "); |
4476 | Incidence* undo = mCalendar->undoIncidence(); | 4478 | Incidence* undo = mCalendar->undoIncidence(); |
4477 | if ( !undo ) { | 4479 | if ( !undo ) { |
4478 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4480 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4479 | i18n("KO/Pi")); | 4481 | i18n("KO/Pi")); |
4480 | return; | 4482 | return; |
4481 | } | 4483 | } |
4482 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 4484 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
4483 | i18n("\nAre you sure you want\nto restore this?"), | 4485 | i18n("\nAre you sure you want\nto restore this?"), |
4484 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4486 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4485 | mCalendar->undoDeleteIncidence(); | 4487 | mCalendar->undoDeleteIncidence(); |
4486 | updateView(); | 4488 | updateView(); |
4487 | } | 4489 | } |
4488 | } | 4490 | } |
4489 | 4491 | ||
4490 | void CalendarView::slotViewerClosed() | 4492 | void CalendarView::slotViewerClosed() |
4491 | { | 4493 | { |
4492 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4494 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4493 | } | 4495 | } |
4494 | 4496 | ||
4495 | void CalendarView::resetFocus() | 4497 | void CalendarView::resetFocus() |
4496 | { | 4498 | { |
4497 | if ( mViewerCallerIsSearchDialog ) { | 4499 | if ( mViewerCallerIsSearchDialog ) { |
4498 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4500 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4499 | mDialogManager->getSearchDialog()->raise(); | 4501 | mDialogManager->getSearchDialog()->raise(); |
4500 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4502 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4501 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4503 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4502 | } else | 4504 | } else |
4503 | mViewerCallerIsSearchDialog = false; | 4505 | mViewerCallerIsSearchDialog = false; |
4504 | } | 4506 | } |
4505 | if ( !mViewerCallerIsSearchDialog ) { | 4507 | if ( !mViewerCallerIsSearchDialog ) { |
4506 | //mViewManager->currentView()->setFocus(); | 4508 | //mViewManager->currentView()->setFocus(); |
4507 | //qDebug("sssssssssssssssset focus "); | 4509 | //qDebug("sssssssssssssssset focus "); |
4508 | topLevelWidget()->raise(); | 4510 | topLevelWidget()->raise(); |
4509 | setActiveWindow(); | 4511 | setActiveWindow(); |
4510 | //setFocus(); | 4512 | //setFocus(); |
4511 | } | 4513 | } |
4512 | mViewerCallerIsSearchDialog = false; | 4514 | mViewerCallerIsSearchDialog = false; |
4513 | } | 4515 | } |
4514 | 4516 | ||
4515 | void CalendarView::showNextAlarms() | 4517 | void CalendarView::showNextAlarms() |
4516 | { | 4518 | { |
4517 | QString message; | 4519 | QString message; |
4518 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4520 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4519 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4521 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4520 | QString sum = mCalendar->nextSummary(); | 4522 | QString sum = mCalendar->nextSummary(); |
4521 | QDateTime nextA = mNextAlarmDateTime; | 4523 | QDateTime nextA = mNextAlarmDateTime; |
4522 | QDateTime cur = QDateTime::currentDateTime(); | 4524 | QDateTime cur = QDateTime::currentDateTime(); |
4523 | int secs = cur.secsTo( nextA ); | 4525 | int secs = cur.secsTo( nextA ); |
4524 | int min = secs /60; | 4526 | int min = secs /60; |
4525 | int hours = min /60; | 4527 | int hours = min /60; |
4526 | min = min % 60; | 4528 | min = min % 60; |
4527 | int days = hours /24; | 4529 | int days = hours /24; |
4528 | hours = hours % 24; | 4530 | hours = hours % 24; |
4529 | 4531 | ||
4530 | //message = i18n("The next alarm is in:\n"); | 4532 | //message = i18n("The next alarm is in:\n"); |
4531 | if ( days > 1 ) | 4533 | if ( days > 1 ) |
4532 | message += i18n("%1 days\n").arg( days ); | 4534 | message += i18n("%1 days\n").arg( days ); |
4533 | else if ( days == 1 ) | 4535 | else if ( days == 1 ) |
4534 | message += i18n("1 day\n"); | 4536 | message += i18n("1 day\n"); |
4535 | if ( hours > 1 ) | 4537 | if ( hours > 1 ) |
4536 | message += i18n("%1 hours\n").arg( hours ); | 4538 | message += i18n("%1 hours\n").arg( hours ); |
4537 | else if ( hours == 1 ) | 4539 | else if ( hours == 1 ) |
4538 | message += i18n("1 hour\n"); | 4540 | message += i18n("1 hour\n"); |
4539 | if ( min > 1 ) | 4541 | if ( min > 1 ) |
4540 | message += i18n("%1 minutes\n").arg( min ); | 4542 | message += i18n("%1 minutes\n").arg( min ); |
4541 | else if ( min == 1 ) | 4543 | else if ( min == 1 ) |
4542 | message += i18n("1 minute\n"); | 4544 | message += i18n("1 minute\n"); |
4543 | if ( message.isEmpty() ) | 4545 | if ( message.isEmpty() ) |
4544 | message = i18n("The next alarm is in\nless than one minute!"); | 4546 | message = i18n("The next alarm is in\nless than one minute!"); |
4545 | else | 4547 | else |
4546 | message = i18n("The next alarm is in:\n") + message; | 4548 | message = i18n("The next alarm is in:\n") + message; |
4547 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4549 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4548 | } else { | 4550 | } else { |
4549 | message = i18n("There is no next alarm."); | 4551 | message = i18n("There is no next alarm."); |
4550 | 4552 | ||
4551 | } | 4553 | } |
4552 | #ifdef DESKTOP_VERSION | 4554 | #ifdef DESKTOP_VERSION |
4553 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4555 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4554 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4556 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4555 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4557 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4556 | } | 4558 | } |
4557 | 4559 | ||
4558 | #endif | 4560 | #endif |
4559 | KMessageBox::information( this, message); | 4561 | KMessageBox::information( this, message); |
4560 | } | 4562 | } |