author | zautrix <zautrix> | 2005-07-07 22:42:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-07 22:42:31 (UTC) |
commit | 9635c9a7b8f5c19a1784079d4b67cb3ca600fc33 (patch) (unidiff) | |
tree | 55a23c20f4092409a1dd2c34cecf6bdb7341a04b | |
parent | 876816e6582299d527610e847d259d2be6de403c (diff) | |
download | kdepimpi-9635c9a7b8f5c19a1784079d4b67cb3ca600fc33.zip kdepimpi-9635c9a7b8f5c19a1784079d4b67cb3ca600fc33.tar.gz kdepimpi-9635c9a7b8f5c19a1784079d4b67cb3ca600fc33.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/calendarview.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 2582931..68d1bc6 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4798 +1,4797 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "koagenda.h" | 107 | #include "koagenda.h" |
108 | #include "kodialogmanager.h" | 108 | #include "kodialogmanager.h" |
109 | #include "outgoingdialog.h" | 109 | #include "outgoingdialog.h" |
110 | #include "incomingdialog.h" | 110 | #include "incomingdialog.h" |
111 | #include "datenavigatorcontainer.h" | 111 | #include "datenavigatorcontainer.h" |
112 | #include "statusdialog.h" | 112 | #include "statusdialog.h" |
113 | #include "kdatenavigator.h" | 113 | #include "kdatenavigator.h" |
114 | #include "kotodoview.h" | 114 | #include "kotodoview.h" |
115 | #include "datenavigator.h" | 115 | #include "datenavigator.h" |
116 | #include "resourceview.h" | 116 | #include "resourceview.h" |
117 | #include "navigatorbar.h" | 117 | #include "navigatorbar.h" |
118 | #include "searchdialog.h" | 118 | #include "searchdialog.h" |
119 | #include "mainwindow.h" | 119 | #include "mainwindow.h" |
120 | #include "categoryeditdialog.h" | 120 | #include "categoryeditdialog.h" |
121 | 121 | ||
122 | #include "calendarview.h" | 122 | #include "calendarview.h" |
123 | #ifndef DESKTOP_VERSION | 123 | #ifndef DESKTOP_VERSION |
124 | #include <qtopia/alarmserver.h> | 124 | #include <qtopia/alarmserver.h> |
125 | #endif | 125 | #endif |
126 | #ifndef _WIN32_ | 126 | #ifndef _WIN32_ |
127 | #include <stdlib.h> | 127 | #include <stdlib.h> |
128 | #include <stdio.h> | 128 | #include <stdio.h> |
129 | #include <unistd.h> | 129 | #include <unistd.h> |
130 | #else | 130 | #else |
131 | #include <qprocess.h> | 131 | #include <qprocess.h> |
132 | #endif | 132 | #endif |
133 | 133 | ||
134 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
135 | #include <kabc/stdaddressbook.h> | 135 | #include <kabc/stdaddressbook.h> |
136 | #endif | 136 | #endif |
137 | using namespace KOrg; | 137 | using namespace KOrg; |
138 | using namespace KCal; | 138 | using namespace KCal; |
139 | extern int globalFlagBlockAgenda; | 139 | extern int globalFlagBlockAgenda; |
140 | extern int globalFlagBlockStartup; | 140 | extern int globalFlagBlockStartup; |
141 | 141 | ||
142 | 142 | ||
143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
144 | 144 | ||
145 | { | 145 | { |
146 | mAlarms = alarms; | 146 | mAlarms = alarms; |
147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
148 | QString mText = "<table width=\"100%\">\n"; | 148 | QString mText = "<table width=\"100%\">\n"; |
149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
150 | #ifdef DESKTOP_VERSION | 150 | #ifdef DESKTOP_VERSION |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
152 | #else | 152 | #else |
153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
154 | #endif | 154 | #endif |
155 | // mText += "<img src=\""; | 155 | // mText += "<img src=\""; |
156 | // mText += ipath; | 156 | // mText += ipath; |
157 | // mText += "\">"; | 157 | // mText += "\">"; |
158 | //mEventDate = QDate::currentDate(); | 158 | //mEventDate = QDate::currentDate(); |
159 | #ifdef DESKTOP_VERSION | 159 | #ifdef DESKTOP_VERSION |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
161 | #else | 161 | #else |
162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
163 | #endif | 163 | #endif |
164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
165 | 165 | ||
166 | Incidence * inc = getNextInc( start ); | 166 | Incidence * inc = getNextInc( start ); |
167 | int time = 0; | 167 | int time = 0; |
168 | //mText += "<table>"; | 168 | //mText += "<table>"; |
169 | while ( inc ) { | 169 | while ( inc ) { |
170 | QDateTime dt ; | 170 | QDateTime dt ; |
171 | QString tempText = "<a "; | 171 | QString tempText = "<a "; |
172 | bool ok; | 172 | bool ok; |
173 | dt = inc->getNextOccurence( start, &ok ); | 173 | dt = inc->getNextOccurence( start, &ok ); |
174 | if ( !ok ) continue; | 174 | if ( !ok ) continue; |
175 | if ( inc->typeID() == eventID ) { | 175 | if ( inc->typeID() == eventID ) { |
176 | tempText += "href=\"event:"; | 176 | tempText += "href=\"event:"; |
177 | } else if ( inc->typeID() == todoID ) { | 177 | } else if ( inc->typeID() == todoID ) { |
178 | tempText += "href=\"todo:"; | 178 | tempText += "href=\"todo:"; |
179 | } | 179 | } |
180 | tempText += inc->uid() + "\">"; | 180 | tempText += inc->uid() + "\">"; |
181 | if ( inc->typeID() == todoID ) | 181 | if ( inc->typeID() == todoID ) |
182 | tempText += i18n("Todo: "); | 182 | tempText += i18n("Todo: "); |
183 | if ( inc->summary().length() > 0 ) | 183 | if ( inc->summary().length() > 0 ) |
184 | tempText += inc->summary(); | 184 | tempText += inc->summary(); |
185 | else | 185 | else |
186 | tempText += i18n("-no summary-"); | 186 | tempText += i18n("-no summary-"); |
187 | QString timestr; | 187 | QString timestr; |
188 | if (!inc->doesFloat()) | 188 | if (!inc->doesFloat()) |
189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | else | 190 | else |
191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
194 | mText += "<table>"; | 194 | mText += "<table>"; |
195 | time = 1; | 195 | time = 1; |
196 | } | 196 | } |
197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
198 | if ( time > 0 ) | 198 | if ( time > 0 ) |
199 | mText +="</table>"; | 199 | mText +="</table>"; |
200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
201 | mText += "<table>"; | 201 | mText += "<table>"; |
202 | time = 2; | 202 | time = 2; |
203 | 203 | ||
204 | } | 204 | } |
205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
206 | if ( time > 0 ) | 206 | if ( time > 0 ) |
207 | mText +="</table>"; | 207 | mText +="</table>"; |
208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
209 | mText += "<table>"; | 209 | mText += "<table>"; |
210 | time = 3; | 210 | time = 3; |
211 | } | 211 | } |
212 | mText +="<tr><td><b>"; | 212 | mText +="<tr><td><b>"; |
213 | mText += timestr; | 213 | mText += timestr; |
214 | mText += "</b></td><td>"; | 214 | mText += "</b></td><td>"; |
215 | mText += tempText; | 215 | mText += tempText; |
216 | mText += "</td></tr>\n"; | 216 | mText += "</td></tr>\n"; |
217 | inc = getNextInc( start ); | 217 | inc = getNextInc( start ); |
218 | } | 218 | } |
219 | mText +="</table>"; | 219 | mText +="</table>"; |
220 | setText( mText ); | 220 | setText( mText ); |
221 | } | 221 | } |
222 | 222 | ||
223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
224 | { | 224 | { |
225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
226 | } | 226 | } |
227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
228 | { | 228 | { |
229 | QDateTime dt ; | 229 | QDateTime dt ; |
230 | Incidence * retInc; | 230 | Incidence * retInc; |
231 | Incidence * inc = mAlarms.first(); | 231 | Incidence * inc = mAlarms.first(); |
232 | if ( inc == 0 ) | 232 | if ( inc == 0 ) |
233 | return 0; | 233 | return 0; |
234 | bool ok; | 234 | bool ok; |
235 | dt = inc->getNextOccurence( start, &ok ); | 235 | dt = inc->getNextOccurence( start, &ok ); |
236 | if ( ! ok ) return 0; | 236 | if ( ! ok ) return 0; |
237 | QDateTime dtn ; | 237 | QDateTime dtn ; |
238 | retInc = inc; | 238 | retInc = inc; |
239 | inc = mAlarms.next(); | 239 | inc = mAlarms.next(); |
240 | while ( inc ) { | 240 | while ( inc ) { |
241 | dtn = inc->getNextOccurence( start, &ok ); | 241 | dtn = inc->getNextOccurence( start, &ok ); |
242 | if ( ! ok ) return 0; | 242 | if ( ! ok ) return 0; |
243 | if ( dtn < dt ) { | 243 | if ( dtn < dt ) { |
244 | dt = dtn; | 244 | dt = dtn; |
245 | retInc = inc; | 245 | retInc = inc; |
246 | } | 246 | } |
247 | inc = mAlarms.next(); | 247 | inc = mAlarms.next(); |
248 | } | 248 | } |
249 | mAlarms.remove( retInc ); | 249 | mAlarms.remove( retInc ); |
250 | return retInc; | 250 | return retInc; |
251 | 251 | ||
252 | } | 252 | } |
253 | void MissedAlarmTextBrowser::setSource(const QString & n) | 253 | void MissedAlarmTextBrowser::setSource(const QString & n) |
254 | { | 254 | { |
255 | if (n.startsWith("event:")) { | 255 | if (n.startsWith("event:")) { |
256 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
257 | emit showIncidence(n.mid(8)); | 257 | emit showIncidence(n.mid(8)); |
258 | #else | 258 | #else |
259 | emit showIncidence(n.mid(6)); | 259 | emit showIncidence(n.mid(6)); |
260 | #endif | 260 | #endif |
261 | return; | 261 | return; |
262 | } else if (n.startsWith("todo:")) { | 262 | } else if (n.startsWith("todo:")) { |
263 | #ifdef DESKTOP_VERSION | 263 | #ifdef DESKTOP_VERSION |
264 | emit showIncidence(n.mid(7)); | 264 | emit showIncidence(n.mid(7)); |
265 | #else | 265 | #else |
266 | emit showIncidence(n.mid(5)); | 266 | emit showIncidence(n.mid(5)); |
267 | #endif | 267 | #endif |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | class KOBeamPrefs : public QDialog | 273 | class KOBeamPrefs : public QDialog |
274 | { | 274 | { |
275 | public: | 275 | public: |
276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
277 | QDialog( parent, name, true ) | 277 | QDialog( parent, name, true ) |
278 | { | 278 | { |
279 | setCaption( i18n("Beam Options") ); | 279 | setCaption( i18n("Beam Options") ); |
280 | QVBoxLayout* lay = new QVBoxLayout( this ); | 280 | QVBoxLayout* lay = new QVBoxLayout( this ); |
281 | lay->setSpacing( 3 ); | 281 | lay->setSpacing( 3 ); |
282 | lay->setMargin( 3 ); | 282 | lay->setMargin( 3 ); |
283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
284 | lay->addWidget( format ); | 284 | lay->addWidget( format ); |
285 | format->setExclusive ( true ) ; | 285 | format->setExclusive ( true ) ; |
286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
287 | lay->addWidget( time ); time->setExclusive ( true ) ; | 287 | lay->addWidget( time ); time->setExclusive ( true ) ; |
288 | vcal = new QRadioButton(" vCalendar ", format ); | 288 | vcal = new QRadioButton(" vCalendar ", format ); |
289 | ical = new QRadioButton(" iCalendar ", format ); | 289 | ical = new QRadioButton(" iCalendar ", format ); |
290 | vcal->setChecked( true ); | 290 | vcal->setChecked( true ); |
291 | tz = new QRadioButton(i18n(" With timezone "), time ); | 291 | tz = new QRadioButton(i18n(" With timezone "), time ); |
292 | local = new QRadioButton(i18n(" Local time "), time ); | 292 | local = new QRadioButton(i18n(" Local time "), time ); |
293 | tz->setChecked( true ); | 293 | tz->setChecked( true ); |
294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
295 | lay->addWidget( ok ); | 295 | lay->addWidget( ok ); |
296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
297 | lay->addWidget( cancel ); | 297 | lay->addWidget( cancel ); |
298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
300 | resize( 200, 200 ); | 300 | resize( 200, 200 ); |
301 | } | 301 | } |
302 | 302 | ||
303 | bool beamVcal() { return vcal->isChecked(); } | 303 | bool beamVcal() { return vcal->isChecked(); } |
304 | bool beamLocal() { return local->isChecked(); } | 304 | bool beamLocal() { return local->isChecked(); } |
305 | private: | 305 | private: |
306 | QRadioButton* vcal, *ical, *local, *tz; | 306 | QRadioButton* vcal, *ical, *local, *tz; |
307 | }; | 307 | }; |
308 | class KOCatPrefs : public QDialog | 308 | class KOCatPrefs : public QDialog |
309 | { | 309 | { |
310 | public: | 310 | public: |
311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
312 | QDialog( parent, name, true ) | 312 | QDialog( parent, name, true ) |
313 | { | 313 | { |
314 | setCaption( i18n("Manage new Categories") ); | 314 | setCaption( i18n("Manage new Categories") ); |
315 | QVBoxLayout* lay = new QVBoxLayout( this ); | 315 | QVBoxLayout* lay = new QVBoxLayout( this ); |
316 | lay->setSpacing( 3 ); | 316 | lay->setSpacing( 3 ); |
317 | lay->setMargin( 3 ); | 317 | lay->setMargin( 3 ); |
318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); | 318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); |
319 | lay->addWidget( lab ); | 319 | lay->addWidget( lab ); |
320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
321 | lay->addWidget( format ); | 321 | lay->addWidget( format ); |
322 | format->setExclusive ( true ) ; | 322 | format->setExclusive ( true ) ; |
323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
325 | addCatBut->setChecked( true ); | 325 | addCatBut->setChecked( true ); |
326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
327 | lay->addWidget( ok ); | 327 | lay->addWidget( ok ); |
328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
329 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
332 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
333 | } | 333 | } |
334 | 334 | ||
335 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
336 | private: | 336 | private: |
337 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | 340 | ||
341 | 341 | ||
342 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
343 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
344 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
345 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
346 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
347 | { | 347 | { |
348 | 348 | ||
349 | mEventEditor = 0; | 349 | mEventEditor = 0; |
350 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
351 | 351 | ||
352 | init(); | 352 | init(); |
353 | } | 353 | } |
354 | 354 | ||
355 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
356 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
357 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
358 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
359 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
360 | { | 360 | { |
361 | 361 | ||
362 | mEventEditor = 0; | 362 | mEventEditor = 0; |
363 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
364 | init(); | 364 | init(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void CalendarView::init() | 367 | void CalendarView::init() |
368 | { | 368 | { |
369 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 369 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
370 | setFocusPolicy ( NoFocus ); | 370 | setFocusPolicy ( NoFocus ); |
371 | mViewerCallerIsSearchDialog = false; | 371 | mViewerCallerIsSearchDialog = false; |
372 | mBlockShowDates = false; | 372 | mBlockShowDates = false; |
373 | 373 | ||
374 | mDatePickerMode = 0; | 374 | mDatePickerMode = 0; |
375 | mCurrentSyncDevice = ""; | 375 | mCurrentSyncDevice = ""; |
376 | mViewManager = new KOViewManager( this ); | 376 | mViewManager = new KOViewManager( this ); |
377 | mDialogManager = new KODialogManager( this ); | 377 | mDialogManager = new KODialogManager( this ); |
378 | mEventViewerDialog = 0; | 378 | mEventViewerDialog = 0; |
379 | mModified = false; | 379 | mModified = false; |
380 | mReadOnly = false; | 380 | mReadOnly = false; |
381 | mSelectedIncidence = 0; | 381 | mSelectedIncidence = 0; |
382 | mCalPrinter = 0; | 382 | mCalPrinter = 0; |
383 | mFilters.setAutoDelete(true); | 383 | mFilters.setAutoDelete(true); |
384 | 384 | ||
385 | mCalendar->registerObserver( this ); | 385 | mCalendar->registerObserver( this ); |
386 | // TODO: Make sure that view is updated, when calendar is changed. | 386 | // TODO: Make sure that view is updated, when calendar is changed. |
387 | 387 | ||
388 | mStorage = new FileStorage( mCalendar ); | 388 | mStorage = new FileStorage( mCalendar ); |
389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
390 | 390 | ||
391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
392 | #ifndef KORG_NOSPLITTER | 392 | #ifndef KORG_NOSPLITTER |
393 | // create the main layout frames. | 393 | // create the main layout frames. |
394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
395 | topLayout->addWidget(mPanner); | 395 | topLayout->addWidget(mPanner); |
396 | 396 | ||
397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
398 | "CalendarView::LeftFrame"); | 398 | "CalendarView::LeftFrame"); |
399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
400 | 400 | ||
401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
402 | "CalendarView::DateNavigator" ); | 402 | "CalendarView::DateNavigator" ); |
403 | 403 | ||
404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
406 | mTodoList->setNavigator( mNavigator ); | 406 | mTodoList->setNavigator( mNavigator ); |
407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
408 | 408 | ||
409 | #ifdef KORG_NORESOURCEVIEW | 409 | #ifdef KORG_NORESOURCEVIEW |
410 | mResourceView = 0; | 410 | mResourceView = 0; |
411 | #else | 411 | #else |
412 | if ( mResourceManager ) { | 412 | if ( mResourceManager ) { |
413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
414 | mResourceView->updateView(); | 414 | mResourceView->updateView(); |
415 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 415 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
416 | SLOT( updateView() ) ); | 416 | SLOT( updateView() ) ); |
417 | } else { | 417 | } else { |
418 | mResourceView = 0; | 418 | mResourceView = 0; |
419 | } | 419 | } |
420 | #endif | 420 | #endif |
421 | QWidget *rightBox = new QWidget( mPanner ); | 421 | QWidget *rightBox = new QWidget( mPanner ); |
422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
423 | 423 | ||
424 | mRightFrame = new QWidgetStack( rightBox ); | 424 | mRightFrame = new QWidgetStack( rightBox ); |
425 | rightLayout->addWidget( mRightFrame, 1 ); | 425 | rightLayout->addWidget( mRightFrame, 1 ); |
426 | 426 | ||
427 | mLeftFrame = mLeftSplitter; | 427 | mLeftFrame = mLeftSplitter; |
428 | #else | 428 | #else |
429 | //QWidget *mainBox = new QWidget( this ); | 429 | //QWidget *mainBox = new QWidget( this ); |
430 | //QWidget *leftFrame = new QWidget( mainBox ); | 430 | //QWidget *leftFrame = new QWidget( mainBox ); |
431 | //QBoxLayout * mainBoxLayout; | 431 | //QBoxLayout * mainBoxLayout; |
432 | if ( KOPrefs::instance()->mVerticalScreen ) { | 432 | if ( KOPrefs::instance()->mVerticalScreen ) { |
433 | //mainBoxLayout = new QVBoxLayout(mainBox); | 433 | //mainBoxLayout = new QVBoxLayout(mainBox); |
434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
439 | } else { | 439 | } else { |
440 | //mainBoxLayout = new QHBoxLayout(mainBox); | 440 | //mainBoxLayout = new QHBoxLayout(mainBox); |
441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
446 | } | 446 | } |
447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
448 | //QBoxLayout * leftFrameLayout; | 448 | //QBoxLayout * leftFrameLayout; |
449 | topLayout->addWidget( mMainFrame ); | 449 | topLayout->addWidget( mMainFrame ); |
450 | #ifdef DESKTOP_VERSION | 450 | #ifdef DESKTOP_VERSION |
451 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); |
452 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
454 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
455 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
456 | #endif | 456 | #endif |
457 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
459 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
460 | #if 0 | 460 | #if 0 |
461 | // FIXME | 461 | // FIXME |
462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
463 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
464 | #endif | 464 | #endif |
465 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
466 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
480 | 480 | ||
481 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
482 | #if 0 | 482 | #if 0 |
483 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
484 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
485 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
486 | 486 | ||
487 | } else { | 487 | } else { |
488 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
489 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
490 | } | 490 | } |
491 | #endif | 491 | #endif |
492 | mFilterView->hide(); | 492 | mFilterView->hide(); |
493 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
494 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
495 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
497 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
498 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
499 | 499 | ||
500 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
501 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
506 | } else { | 506 | } else { |
507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
510 | } | 510 | } |
511 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
512 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
513 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
517 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
518 | 518 | ||
519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
521 | 521 | ||
522 | 522 | ||
523 | 523 | ||
524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
529 | 529 | ||
530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
531 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
532 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
533 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
535 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
537 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
538 | 538 | ||
539 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
540 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
541 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
542 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
545 | 545 | ||
546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
548 | #if 0 | 548 | #if 0 |
549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
550 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
551 | #endif | 551 | #endif |
552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
553 | 553 | ||
554 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
555 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
558 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
560 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
562 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
564 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
566 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
569 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
571 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
572 | 572 | ||
573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
576 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
577 | 577 | ||
578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
579 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
581 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
582 | 582 | ||
583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
584 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
585 | 585 | ||
586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
589 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
592 | 592 | ||
593 | 593 | ||
594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | 602 | ||
603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
604 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
606 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
608 | 608 | ||
609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
610 | 610 | ||
611 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
614 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
615 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
616 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
618 | 618 | ||
619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
620 | 620 | ||
621 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
622 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
623 | 623 | ||
624 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
625 | 625 | ||
626 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
627 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
628 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
632 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
634 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
636 | 636 | ||
637 | 637 | ||
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
642 | #endif | 642 | #endif |
643 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
648 | { | 648 | { |
649 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
650 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
651 | delete mDialogManager; | 651 | delete mDialogManager; |
652 | delete mViewManager; | 652 | delete mViewManager; |
653 | delete mStorage; | 653 | delete mStorage; |
654 | delete mDateFrame ; | 654 | delete mDateFrame ; |
655 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
656 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
657 | } | 657 | } |
658 | void CalendarView::nextConflict( bool all, bool allday ) | 658 | void CalendarView::nextConflict( bool all, bool allday ) |
659 | { | 659 | { |
660 | 660 | ||
661 | QPtrList<Event> testlist = mCalendar->events(); | 661 | QPtrList<Event> testlist = mCalendar->events(); |
662 | Event * test = testlist.first(); | 662 | Event * test = testlist.first(); |
663 | while ( test ) { | 663 | while ( test ) { |
664 | test->setTagged( false ); | 664 | test->setTagged( false ); |
665 | test = testlist.next(); | 665 | test = testlist.next(); |
666 | } | 666 | } |
667 | QTime st ( 0,0,0); | 667 | QTime st ( 0,0,0); |
668 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 668 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
669 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 669 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
670 | //qDebug("time %s ", st.toString().latin1()); | 670 | //qDebug("time %s ", st.toString().latin1()); |
671 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 671 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
672 | QDateTime conflict; | 672 | QDateTime conflict; |
673 | QDateTime retVal; | 673 | QDateTime retVal; |
674 | bool found = false; | 674 | bool found = false; |
675 | Event * cE = 0; | 675 | Event * cE = 0; |
676 | Event * cE2 = 0; | 676 | Event * cE2 = 0; |
677 | QPtrList<Event> testlist2 = testlist; | 677 | QPtrList<Event> testlist2 = testlist; |
678 | test = testlist.first(); | 678 | test = testlist.first(); |
679 | bool skip = false; | 679 | bool skip = false; |
680 | while ( test ) { | 680 | while ( test ) { |
681 | skip = false; | 681 | skip = false; |
682 | if ( !all ) skip = ( allday != test->doesFloat() ); | 682 | if ( !all ) skip = ( allday != test->doesFloat() ); |
683 | if ( !skip ) { | 683 | if ( !skip ) { |
684 | Event * test2 = testlist2.first(); | 684 | Event * test2 = testlist2.first(); |
685 | while ( test2 ) { | 685 | while ( test2 ) { |
686 | skip = false; | 686 | skip = false; |
687 | if ( !all ) skip = ( allday != test2->doesFloat() ); | 687 | if ( !all ) skip = ( allday != test2->doesFloat() ); |
688 | if ( !skip ) { | 688 | if ( !skip ) { |
689 | if ( !test2->isTagged() ) { | 689 | if ( !test2->isTagged() ) { |
690 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 690 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
691 | //qDebug("overlap "); | 691 | //qDebug("overlap "); |
692 | if ( ! found ) { | 692 | if ( ! found ) { |
693 | if ( retVal >= startDT ) { | 693 | if ( retVal >= startDT ) { |
694 | conflict = retVal; | 694 | conflict = retVal; |
695 | cE = test; | 695 | cE = test; |
696 | cE2 = test2; | 696 | cE2 = test2; |
697 | found = true; | 697 | found = true; |
698 | } | 698 | } |
699 | } else { | 699 | } else { |
700 | if ( retVal >= startDT && retVal < conflict ) { | 700 | if ( retVal >= startDT && retVal < conflict ) { |
701 | conflict = retVal; | 701 | conflict = retVal; |
702 | cE = test; | 702 | cE = test; |
703 | cE2 = test2; | 703 | cE2 = test2; |
704 | } | 704 | } |
705 | } | 705 | } |
706 | } | 706 | } |
707 | } | 707 | } |
708 | } | 708 | } |
709 | test2 = testlist2.next(); | 709 | test2 = testlist2.next(); |
710 | } | 710 | } |
711 | } | 711 | } |
712 | test->setTagged( true ); | 712 | test->setTagged( true ); |
713 | test = testlist.next(); | 713 | test = testlist.next(); |
714 | } | 714 | } |
715 | if ( found ) { | 715 | if ( found ) { |
716 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 716 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
717 | mViewManager->showDayView(); | 717 | mViewManager->showDayView(); |
718 | mNavigator->slotDaySelect( conflict.date() ); | 718 | mNavigator->slotDaySelect( conflict.date() ); |
719 | int hour = conflict.time().hour(); | 719 | int hour = conflict.time().hour(); |
720 | mViewManager->agendaView()->setStartHour( hour ); | 720 | mViewManager->agendaView()->setStartHour( hour ); |
721 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 721 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
722 | return; | 722 | return; |
723 | } | 723 | } |
724 | 724 | ||
725 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 725 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
726 | qDebug("No conflict found "); | 726 | qDebug("No conflict found "); |
727 | return; | 727 | return; |
728 | } | 728 | } |
729 | 729 | ||
730 | void CalendarView::conflictAll() | 730 | void CalendarView::conflictAll() |
731 | { | 731 | { |
732 | nextConflict ( true, true ); | 732 | nextConflict ( true, true ); |
733 | } | 733 | } |
734 | void CalendarView::conflictAllday() | 734 | void CalendarView::conflictAllday() |
735 | { | 735 | { |
736 | nextConflict ( false, true ); | 736 | nextConflict ( false, true ); |
737 | } | 737 | } |
738 | void CalendarView::conflictNotAll() | 738 | void CalendarView::conflictNotAll() |
739 | { | 739 | { |
740 | nextConflict ( false, false ); | 740 | nextConflict ( false, false ); |
741 | } | 741 | } |
742 | 742 | ||
743 | void CalendarView::setCalReadOnly( int id, bool readO ) | 743 | void CalendarView::setCalReadOnly( int id, bool readO ) |
744 | { | 744 | { |
745 | if ( readO ) { | 745 | if ( readO ) { |
746 | emit save(); | 746 | emit save(); |
747 | } | 747 | } |
748 | mCalendar->setReadOnly( id, readO ); | 748 | mCalendar->setReadOnly( id, readO ); |
749 | } | 749 | } |
750 | void CalendarView::setScrollBarStep(int val ) | 750 | void CalendarView::setScrollBarStep(int val ) |
751 | { | 751 | { |
752 | #ifdef DESKTOP_VERSION | 752 | #ifdef DESKTOP_VERSION |
753 | mDateScrollBar->setLineStep ( val ); | 753 | mDateScrollBar->setLineStep ( val ); |
754 | #endif | 754 | #endif |
755 | } | 755 | } |
756 | void CalendarView::scrollBarValue(int val ) | 756 | void CalendarView::scrollBarValue(int val ) |
757 | { | 757 | { |
758 | #ifdef DESKTOP_VERSION | 758 | #ifdef DESKTOP_VERSION |
759 | if ( QApplication::desktop()->width() < 800 ) return; | 759 | if ( QApplication::desktop()->width() < 800 ) return; |
760 | static bool block = false; | 760 | static bool block = false; |
761 | if ( block ) return; | 761 | if ( block ) return; |
762 | block = true; | 762 | block = true; |
763 | int count = mNavigator->selectedDates().count(); | 763 | int count = mNavigator->selectedDates().count(); |
764 | int day = mNavigator->selectedDates().first().dayOfYear(); | 764 | int day = mNavigator->selectedDates().first().dayOfYear(); |
765 | int stepdays = val; | 765 | int stepdays = val; |
766 | if ( mDateScrollBar->lineStep () <= count ) { | 766 | if ( mDateScrollBar->lineStep () <= count ) { |
767 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 767 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
768 | //qDebug("VAL %d ",val ); | 768 | //qDebug("VAL %d ",val ); |
769 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 769 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
770 | stepdays = day+stepdays; | 770 | stepdays = day+stepdays; |
771 | if ( stepdays < 0 ) stepdays = 0; | 771 | if ( stepdays < 0 ) stepdays = 0; |
772 | } | 772 | } |
773 | if ( stepdays == day ) { | 773 | if ( stepdays == day ) { |
774 | block = false; | 774 | block = false; |
775 | return; | 775 | return; |
776 | } | 776 | } |
777 | int year = mNavigator->selectedDates().first().year(); | 777 | int year = mNavigator->selectedDates().first().year(); |
778 | QDate d ( year,1,1 ); | 778 | QDate d ( year,1,1 ); |
779 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 779 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
780 | block = false; | 780 | block = false; |
781 | #endif | 781 | #endif |
782 | 782 | ||
783 | } | 783 | } |
784 | void CalendarView::updateView(const QDate &start, const QDate &end) | 784 | void CalendarView::updateView(const QDate &start, const QDate &end) |
785 | { | 785 | { |
786 | #ifdef DESKTOP_VERSION | 786 | #ifdef DESKTOP_VERSION |
787 | if ( ! mDateScrollBar->draggingSlider () ) { | 787 | if ( ! mDateScrollBar->draggingSlider () ) { |
788 | int dof = start.dayOfYear(); | 788 | int dof = start.dayOfYear(); |
789 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 789 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
790 | if ( dof != mDateScrollBar->value() ) { | 790 | if ( dof != mDateScrollBar->value() ) { |
791 | mDateScrollBar->blockSignals( true ); | 791 | mDateScrollBar->blockSignals( true ); |
792 | mDateScrollBar->setValue( start.dayOfYear()); | 792 | mDateScrollBar->setValue( start.dayOfYear()); |
793 | mDateScrollBar->blockSignals( false ); | 793 | mDateScrollBar->blockSignals( false ); |
794 | } | 794 | } |
795 | } | 795 | } |
796 | #endif | 796 | #endif |
797 | mTodoList->updateView(); | 797 | mTodoList->updateView(); |
798 | mViewManager->updateView(start, end); | 798 | mViewManager->updateView(start, end); |
799 | //mDateNavigator->updateView(); | 799 | //mDateNavigator->updateView(); |
800 | } | 800 | } |
801 | 801 | ||
802 | 802 | ||
803 | 803 | ||
804 | void CalendarView::checkFiles() | 804 | void CalendarView::checkFiles() |
805 | { | 805 | { |
806 | QString message; | 806 | QString message; |
807 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 807 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
808 | KopiCalendarFile * cal = calendars.first(); | 808 | KopiCalendarFile * cal = calendars.first(); |
809 | while ( cal ) { | 809 | while ( cal ) { |
810 | if ( cal->mErrorOnLoad ) { | 810 | if ( cal->mErrorOnLoad ) { |
811 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 811 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
812 | } | 812 | } |
813 | cal = calendars.next(); | 813 | cal = calendars.next(); |
814 | } | 814 | } |
815 | if ( !message.isEmpty() ) { | 815 | if ( !message.isEmpty() ) { |
816 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); | 816 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
817 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 817 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
818 | } | 818 | } |
819 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 819 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
820 | } | 820 | } |
821 | void CalendarView::checkAlarms() | 821 | void CalendarView::checkAlarms() |
822 | { | 822 | { |
823 | 823 | ||
824 | 824 | ||
825 | KConfig *config = KOGlobals::config(); | 825 | KConfig *config = KOGlobals::config(); |
826 | config->setGroup( "AppRun" ); | 826 | config->setGroup( "AppRun" ); |
827 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 827 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
828 | int daysto = dt.daysTo( QDate::currentDate() ); | 828 | int daysto = dt.daysTo( QDate::currentDate() ); |
829 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 829 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
830 | dt = dt.addDays( days ); | 830 | dt = dt.addDays( days ); |
831 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 831 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
832 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 832 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
833 | //qDebug("KO: Reading program stop %d ", secs); | 833 | //qDebug("KO: Reading program stop %d ", secs); |
834 | //secs -= ( 3600 * 24*3 ); // debug only | 834 | //secs -= ( 3600 * 24*3 ); // debug only |
835 | QDateTime latest = dt.addSecs ( secs ); | 835 | QDateTime latest = dt.addSecs ( secs ); |
836 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 836 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
837 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 837 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
838 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 838 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
839 | QPtrList<Incidence> al; | 839 | QPtrList<Incidence> al; |
840 | Incidence* inL = el.first(); | 840 | Incidence* inL = el.first(); |
841 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 841 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
842 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 842 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
843 | while ( inL ) { | 843 | while ( inL ) { |
844 | bool ok = false; | 844 | bool ok = false; |
845 | int offset = 0; | 845 | int offset = 0; |
846 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 846 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
847 | if ( ok ) { | 847 | if ( ok ) { |
848 | //qDebug("OK %s",next.toString().latin1()); | 848 | //qDebug("OK %s",next.toString().latin1()); |
849 | if ( next < cur ) { | 849 | if ( next < cur ) { |
850 | al.append( inL ); | 850 | al.append( inL ); |
851 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 851 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
852 | } | 852 | } |
853 | } | 853 | } |
854 | inL = el.next(); | 854 | inL = el.next(); |
855 | } | 855 | } |
856 | if ( al.count() ) { | 856 | if ( al.count() ) { |
857 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 857 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
858 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 858 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
859 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 859 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
860 | lay->setSpacing( 0 ); | 860 | lay->setSpacing( 0 ); |
861 | lay->setMargin( 0 ); | 861 | lay->setMargin( 0 ); |
862 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 862 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
863 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 863 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
864 | lay->addWidget( matb ); | 864 | lay->addWidget( matb ); |
865 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 865 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
866 | int wid = 210; | 866 | int wid = 210; |
867 | int x = QApplication::desktop()->width() - wid - 7; | 867 | int x = QApplication::desktop()->width() - wid - 7; |
868 | int y = QApplication::desktop()->height() - wid - 70; | 868 | int y = QApplication::desktop()->height() - wid - 70; |
869 | dia->setGeometry ( x,y,wid,wid); | 869 | dia->setGeometry ( x,y,wid,wid); |
870 | } else { | 870 | } else { |
871 | int si = 220; | 871 | int si = 220; |
872 | if ( QApplication::desktop()->width() > 470 ) | 872 | if ( QApplication::desktop()->width() > 470 ) |
873 | si = 400; | 873 | si = 400; |
874 | dia->resize(si,si/2); | 874 | dia->resize(si,si/2); |
875 | } | 875 | } |
876 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 876 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
877 | dia->show(); | 877 | dia->show(); |
878 | 878 | ||
879 | } | 879 | } |
880 | } | 880 | } |
881 | void CalendarView::showDay( QDate d ) | 881 | void CalendarView::showDay( QDate d ) |
882 | { | 882 | { |
883 | dateNavigator()->blockSignals( true ); | 883 | dateNavigator()->blockSignals( true ); |
884 | dateNavigator()->selectDate( d ); | 884 | dateNavigator()->selectDate( d ); |
885 | dateNavigator()->blockSignals( false ); | 885 | dateNavigator()->blockSignals( false ); |
886 | mViewManager->showDayView(); | 886 | mViewManager->showDayView(); |
887 | //dateNavigator()->selectDate( d ); | 887 | //dateNavigator()->selectDate( d ); |
888 | } | 888 | } |
889 | void CalendarView::timerAlarm() | 889 | void CalendarView::timerAlarm() |
890 | { | 890 | { |
891 | //qDebug("CalendarView::timerAlarm() "); | 891 | //qDebug("CalendarView::timerAlarm() "); |
892 | computeAlarm(mAlarmNotification ); | 892 | computeAlarm(mAlarmNotification ); |
893 | } | 893 | } |
894 | 894 | ||
895 | void CalendarView::suspendAlarm() | 895 | void CalendarView::suspendAlarm() |
896 | { | 896 | { |
897 | //qDebug(" CalendarView::suspendAlarm() "); | 897 | //qDebug(" CalendarView::suspendAlarm() "); |
898 | computeAlarm(mSuspendAlarmNotification ); | 898 | computeAlarm(mSuspendAlarmNotification ); |
899 | 899 | ||
900 | } | 900 | } |
901 | 901 | ||
902 | void CalendarView::startAlarm( QString mess , QString filename) | 902 | void CalendarView::startAlarm( QString mess , QString filename) |
903 | { | 903 | { |
904 | 904 | ||
905 | topLevelWidget()->showNormal(); | 905 | topLevelWidget()->showNormal(); |
906 | topLevelWidget()->setActiveWindow(); | 906 | topLevelWidget()->setActiveWindow(); |
907 | topLevelWidget()->raise(); | 907 | topLevelWidget()->raise(); |
908 | 908 | ||
909 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 909 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
910 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 910 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
911 | 911 | ||
912 | } | 912 | } |
913 | 913 | ||
914 | void CalendarView::checkNextTimerAlarm() | 914 | void CalendarView::checkNextTimerAlarm() |
915 | { | 915 | { |
916 | mCalendar->checkAlarmForIncidence( 0, true ); | 916 | mCalendar->checkAlarmForIncidence( 0, true ); |
917 | } | 917 | } |
918 | 918 | ||
919 | void CalendarView::computeAlarm( QString msg ) | 919 | void CalendarView::computeAlarm( QString msg ) |
920 | { | 920 | { |
921 | 921 | ||
922 | QString mess = msg; | 922 | QString mess = msg; |
923 | QString mAlarmMessage = mess.mid( 9 ); | 923 | QString mAlarmMessage = mess.mid( 9 ); |
924 | QString filename = MainWindow::resourcePath(); | 924 | QString filename = MainWindow::resourcePath(); |
925 | filename += "koalarm.wav"; | 925 | filename += "koalarm.wav"; |
926 | QString tempfilename; | 926 | QString tempfilename; |
927 | if ( mess.left( 13 ) == "suspend_alarm") { | 927 | if ( mess.left( 13 ) == "suspend_alarm") { |
928 | bool error = false; | 928 | bool error = false; |
929 | int len = mess.mid( 13 ).find("+++"); | 929 | int len = mess.mid( 13 ).find("+++"); |
930 | if ( len < 2 ) | 930 | if ( len < 2 ) |
931 | error = true; | 931 | error = true; |
932 | else { | 932 | else { |
933 | tempfilename = mess.mid( 13, len ); | 933 | tempfilename = mess.mid( 13, len ); |
934 | if ( !QFile::exists( tempfilename ) ) | 934 | if ( !QFile::exists( tempfilename ) ) |
935 | error = true; | 935 | error = true; |
936 | } | 936 | } |
937 | if ( ! error ) { | 937 | if ( ! error ) { |
938 | filename = tempfilename; | 938 | filename = tempfilename; |
939 | } | 939 | } |
940 | mAlarmMessage = mess.mid( 13+len+3 ); | 940 | mAlarmMessage = mess.mid( 13+len+3 ); |
941 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 941 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
942 | startAlarm( mAlarmMessage, filename); | 942 | startAlarm( mAlarmMessage, filename); |
943 | return; | 943 | return; |
944 | } | 944 | } |
945 | if ( mess.left( 11 ) == "timer_alarm") { | 945 | if ( mess.left( 11 ) == "timer_alarm") { |
946 | //mTimerTime = 0; | 946 | //mTimerTime = 0; |
947 | startAlarm( mess.mid( 11 ), filename ); | 947 | startAlarm( mess.mid( 11 ), filename ); |
948 | return; | 948 | return; |
949 | } | 949 | } |
950 | if ( mess.left( 10 ) == "proc_alarm") { | 950 | if ( mess.left( 10 ) == "proc_alarm") { |
951 | bool error = false; | 951 | bool error = false; |
952 | int len = mess.mid( 10 ).find("+++"); | 952 | int len = mess.mid( 10 ).find("+++"); |
953 | if ( len < 2 ) | 953 | if ( len < 2 ) |
954 | error = true; | 954 | error = true; |
955 | else { | 955 | else { |
956 | tempfilename = mess.mid( 10, len ); | 956 | tempfilename = mess.mid( 10, len ); |
957 | if ( !QFile::exists( tempfilename ) ) | 957 | if ( !QFile::exists( tempfilename ) ) |
958 | error = true; | 958 | error = true; |
959 | } | 959 | } |
960 | if ( error ) { | 960 | if ( error ) { |
961 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 961 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
962 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 962 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
963 | } else { | 963 | } else { |
964 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 964 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
965 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 965 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
966 | #ifndef _WIN32_ | 966 | #ifndef _WIN32_ |
967 | if ( vfork () == 0 ) { | 967 | if ( vfork () == 0 ) { |
968 | execl ( tempfilename.latin1(), 0 ); | 968 | execl ( tempfilename.latin1(), 0 ); |
969 | return; | 969 | return; |
970 | } | 970 | } |
971 | #else | 971 | #else |
972 | QProcess* p = new QProcess(); | 972 | QProcess* p = new QProcess(); |
973 | p->addArgument( tempfilename.latin1() ); | 973 | p->addArgument( tempfilename.latin1() ); |
974 | p->start(); | 974 | p->start(); |
975 | return; | 975 | return; |
976 | #endif | 976 | #endif |
977 | 977 | ||
978 | return; | 978 | return; |
979 | } | 979 | } |
980 | 980 | ||
981 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 981 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
982 | } | 982 | } |
983 | if ( mess.left( 11 ) == "audio_alarm") { | 983 | if ( mess.left( 11 ) == "audio_alarm") { |
984 | bool error = false; | 984 | bool error = false; |
985 | int len = mess.mid( 11 ).find("+++"); | 985 | int len = mess.mid( 11 ).find("+++"); |
986 | if ( len < 2 ) | 986 | if ( len < 2 ) |
987 | error = true; | 987 | error = true; |
988 | else { | 988 | else { |
989 | tempfilename = mess.mid( 11, len ); | 989 | tempfilename = mess.mid( 11, len ); |
990 | if ( !QFile::exists( tempfilename ) ) | 990 | if ( !QFile::exists( tempfilename ) ) |
991 | error = true; | 991 | error = true; |
992 | } | 992 | } |
993 | if ( ! error ) { | 993 | if ( ! error ) { |
994 | filename = tempfilename; | 994 | filename = tempfilename; |
995 | } | 995 | } |
996 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 996 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
997 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 997 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
998 | } | 998 | } |
999 | if ( mess.left( 9 ) == "cal_alarm") { | 999 | if ( mess.left( 9 ) == "cal_alarm") { |
1000 | mAlarmMessage = mess.mid( 9 ) ; | 1000 | mAlarmMessage = mess.mid( 9 ) ; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | startAlarm( mAlarmMessage, filename ); | 1003 | startAlarm( mAlarmMessage, filename ); |
1004 | 1004 | ||
1005 | 1005 | ||
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1008 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1009 | { | 1009 | { |
1010 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1010 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1011 | 1011 | ||
1012 | mSuspendAlarmNotification = noti; | 1012 | mSuspendAlarmNotification = noti; |
1013 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1013 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1014 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1014 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1015 | mSuspendTimer->start( ms , true ); | 1015 | mSuspendTimer->start( ms , true ); |
1016 | 1016 | ||
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1019 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1020 | { | 1020 | { |
1021 | mNextAlarmDateTime = qdt; | 1021 | mNextAlarmDateTime = qdt; |
1022 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1022 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1023 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1023 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1024 | #ifndef DESKTOP_VERSION | 1024 | #ifndef DESKTOP_VERSION |
1025 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1025 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1026 | #endif | 1026 | #endif |
1027 | return; | 1027 | return; |
1028 | } | 1028 | } |
1029 | int maxSec; | 1029 | int maxSec; |
1030 | //maxSec = 5; //testing only | 1030 | //maxSec = 5; //testing only |
1031 | maxSec = 86400+3600; // one day+1hour | 1031 | maxSec = 86400+3600; // one day+1hour |
1032 | mAlarmNotification = noti; | 1032 | mAlarmNotification = noti; |
1033 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1033 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1034 | if ( sec > maxSec ) { | 1034 | if ( sec > maxSec ) { |
1035 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1035 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1036 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1036 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1037 | return; | 1037 | return; |
1038 | } else { | 1038 | } else { |
1039 | mRecheckAlarmTimer->stop(); | 1039 | mRecheckAlarmTimer->stop(); |
1040 | } | 1040 | } |
1041 | //qDebug("Alarm timer started with secs: %d ", sec); | 1041 | //qDebug("Alarm timer started with secs: %d ", sec); |
1042 | mAlarmTimer->start( sec *1000 , true ); | 1042 | mAlarmTimer->start( sec *1000 , true ); |
1043 | 1043 | ||
1044 | } | 1044 | } |
1045 | // called by mRecheckAlarmTimer to get next alarm | 1045 | // called by mRecheckAlarmTimer to get next alarm |
1046 | // we need this, because a QTimer has only a max range of 25 days | 1046 | // we need this, because a QTimer has only a max range of 25 days |
1047 | void CalendarView::recheckTimerAlarm() | 1047 | void CalendarView::recheckTimerAlarm() |
1048 | { | 1048 | { |
1049 | mAlarmTimer->stop(); | 1049 | mAlarmTimer->stop(); |
1050 | mRecheckAlarmTimer->stop(); | 1050 | mRecheckAlarmTimer->stop(); |
1051 | mCalendar->checkAlarmForIncidence( 0, true ); | 1051 | mCalendar->checkAlarmForIncidence( 0, true ); |
1052 | } | 1052 | } |
1053 | #ifndef DESKTOP_VERSION | 1053 | #ifndef DESKTOP_VERSION |
1054 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1054 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1055 | #else | 1055 | #else |
1056 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1056 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1057 | #endif | 1057 | #endif |
1058 | { | 1058 | { |
1059 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1059 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1060 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1060 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1061 | #ifndef DESKTOP_VERSION | 1061 | #ifndef DESKTOP_VERSION |
1062 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1062 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1063 | #endif | 1063 | #endif |
1064 | return; | 1064 | return; |
1065 | } | 1065 | } |
1066 | mAlarmTimer->stop(); | 1066 | mAlarmTimer->stop(); |
1067 | } | 1067 | } |
1068 | void CalendarView::selectWeekNum ( int num ) | 1068 | void CalendarView::selectWeekNum ( int num ) |
1069 | { | 1069 | { |
1070 | dateNavigator()->blockSignals( true ); | 1070 | dateNavigator()->blockSignals( true ); |
1071 | dateNavigator()->selectWeek( num ); | 1071 | dateNavigator()->selectWeek( num ); |
1072 | dateNavigator()->blockSignals( false ); | 1072 | dateNavigator()->blockSignals( false ); |
1073 | mViewManager->showWeekView(); | 1073 | mViewManager->showWeekView(); |
1074 | } | 1074 | } |
1075 | KOViewManager *CalendarView::viewManager() | 1075 | KOViewManager *CalendarView::viewManager() |
1076 | { | 1076 | { |
1077 | return mViewManager; | 1077 | return mViewManager; |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | KODialogManager *CalendarView::dialogManager() | 1080 | KODialogManager *CalendarView::dialogManager() |
1081 | { | 1081 | { |
1082 | return mDialogManager; | 1082 | return mDialogManager; |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | QDate CalendarView::startDate() | 1085 | QDate CalendarView::startDate() |
1086 | { | 1086 | { |
1087 | DateList dates = mNavigator->selectedDates(); | 1087 | DateList dates = mNavigator->selectedDates(); |
1088 | 1088 | ||
1089 | return dates.first(); | 1089 | return dates.first(); |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | QDate CalendarView::endDate() | 1092 | QDate CalendarView::endDate() |
1093 | { | 1093 | { |
1094 | DateList dates = mNavigator->selectedDates(); | 1094 | DateList dates = mNavigator->selectedDates(); |
1095 | 1095 | ||
1096 | return dates.last(); | 1096 | return dates.last(); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | 1099 | ||
1100 | void CalendarView::createPrinter() | 1100 | void CalendarView::createPrinter() |
1101 | { | 1101 | { |
1102 | #ifndef KORG_NOPRINTER | 1102 | #ifndef KORG_NOPRINTER |
1103 | if (!mCalPrinter) { | 1103 | if (!mCalPrinter) { |
1104 | mCalPrinter = new CalPrinter(this, mCalendar); | 1104 | mCalPrinter = new CalPrinter(this, mCalendar); |
1105 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1105 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1106 | } | 1106 | } |
1107 | #endif | 1107 | #endif |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | 1110 | ||
1111 | //KOPrefs::instance()->mWriteBackFile | 1111 | //KOPrefs::instance()->mWriteBackFile |
1112 | //KOPrefs::instance()->mWriteBackExistingOnly | 1112 | //KOPrefs::instance()->mWriteBackExistingOnly |
1113 | 1113 | ||
1114 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1114 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1115 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1115 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1116 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1116 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1117 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1117 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1118 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1118 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1119 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1119 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1120 | 1120 | ||
1121 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1121 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1122 | { | 1122 | { |
1123 | 1123 | ||
1124 | // 0 equal | 1124 | // 0 equal |
1125 | // 1 take local | 1125 | // 1 take local |
1126 | // 2 take remote | 1126 | // 2 take remote |
1127 | // 3 cancel | 1127 | // 3 cancel |
1128 | QDateTime lastSync = mLastCalendarSync; | 1128 | QDateTime lastSync = mLastCalendarSync; |
1129 | QDateTime localMod = local->lastModified(); | 1129 | QDateTime localMod = local->lastModified(); |
1130 | QDateTime remoteMod = remote->lastModified(); | 1130 | QDateTime remoteMod = remote->lastModified(); |
1131 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1131 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1132 | bool remCh, locCh; | 1132 | bool remCh, locCh; |
1133 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1133 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1134 | //if ( remCh ) | 1134 | //if ( remCh ) |
1135 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1135 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1136 | locCh = ( localMod > mLastCalendarSync ); | 1136 | locCh = ( localMod > mLastCalendarSync ); |
1137 | if ( !remCh && ! locCh ) { | 1137 | if ( !remCh && ! locCh ) { |
1138 | //qDebug("both not changed "); | 1138 | //qDebug("both not changed "); |
1139 | lastSync = localMod.addDays(1); | 1139 | lastSync = localMod.addDays(1); |
1140 | if ( mode <= SYNC_PREF_ASK ) | 1140 | if ( mode <= SYNC_PREF_ASK ) |
1141 | return 0; | 1141 | return 0; |
1142 | } else { | 1142 | } else { |
1143 | if ( locCh ) { | 1143 | if ( locCh ) { |
1144 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1144 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1145 | lastSync = localMod.addDays( -1 ); | 1145 | lastSync = localMod.addDays( -1 ); |
1146 | if ( !remCh ) | 1146 | if ( !remCh ) |
1147 | remoteMod = ( lastSync.addDays( -1 ) ); | 1147 | remoteMod = ( lastSync.addDays( -1 ) ); |
1148 | } else { | 1148 | } else { |
1149 | //qDebug(" not loc changed "); | 1149 | //qDebug(" not loc changed "); |
1150 | lastSync = localMod.addDays( 1 ); | 1150 | lastSync = localMod.addDays( 1 ); |
1151 | if ( remCh ) | 1151 | if ( remCh ) |
1152 | remoteMod =( lastSync.addDays( 1 ) ); | 1152 | remoteMod =( lastSync.addDays( 1 ) ); |
1153 | 1153 | ||
1154 | } | 1154 | } |
1155 | } | 1155 | } |
1156 | full = true; | 1156 | full = true; |
1157 | if ( mode < SYNC_PREF_ASK ) | 1157 | if ( mode < SYNC_PREF_ASK ) |
1158 | mode = SYNC_PREF_ASK; | 1158 | mode = SYNC_PREF_ASK; |
1159 | } else { | 1159 | } else { |
1160 | if ( localMod == remoteMod ) | 1160 | if ( localMod == remoteMod ) |
1161 | // if ( local->revision() == remote->revision() ) | 1161 | // if ( local->revision() == remote->revision() ) |
1162 | return 0; | 1162 | return 0; |
1163 | 1163 | ||
1164 | } | 1164 | } |
1165 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1165 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1166 | 1166 | ||
1167 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1167 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1168 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1168 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1169 | //full = true; //debug only | 1169 | //full = true; //debug only |
1170 | if ( full ) { | 1170 | if ( full ) { |
1171 | bool equ = false; | 1171 | bool equ = false; |
1172 | if ( local->typeID() == eventID ) { | 1172 | if ( local->typeID() == eventID ) { |
1173 | equ = (*((Event*) local) == *((Event*) remote)); | 1173 | equ = (*((Event*) local) == *((Event*) remote)); |
1174 | } | 1174 | } |
1175 | else if ( local->typeID() == todoID ) | 1175 | else if ( local->typeID() == todoID ) |
1176 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1176 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1177 | else if ( local->typeID() == journalID ) | 1177 | else if ( local->typeID() == journalID ) |
1178 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1178 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1179 | if ( equ ) { | 1179 | if ( equ ) { |
1180 | //qDebug("equal "); | 1180 | //qDebug("equal "); |
1181 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1181 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1182 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1182 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1183 | } | 1183 | } |
1184 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1184 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1185 | return 0; | 1185 | return 0; |
1186 | 1186 | ||
1187 | }//else //debug only | 1187 | }//else //debug only |
1188 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1188 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1189 | } | 1189 | } |
1190 | int result; | 1190 | int result; |
1191 | bool localIsNew; | 1191 | bool localIsNew; |
1192 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 1192 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
1193 | 1193 | ||
1194 | 1194 | ||
1195 | // ************************************************ | 1195 | // ************************************************ |
1196 | // ************************************************ | 1196 | // ************************************************ |
1197 | // ************************************************ | 1197 | // ************************************************ |
1198 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1198 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1199 | // BUT remoteMod != localMod | 1199 | // BUT remoteMod != localMod |
1200 | 1200 | ||
1201 | 1201 | ||
1202 | if ( full && mode < SYNC_PREF_NEWEST ) | 1202 | if ( full && mode < SYNC_PREF_NEWEST ) |
1203 | mode = SYNC_PREF_ASK; | 1203 | mode = SYNC_PREF_ASK; |
1204 | 1204 | ||
1205 | switch( mode ) { | 1205 | switch( mode ) { |
1206 | case SYNC_PREF_LOCAL: | 1206 | case SYNC_PREF_LOCAL: |
1207 | if ( lastSync > remoteMod ) | 1207 | if ( lastSync > remoteMod ) |
1208 | return 1; | 1208 | return 1; |
1209 | if ( lastSync > localMod ) | 1209 | if ( lastSync > localMod ) |
1210 | return 2; | 1210 | return 2; |
1211 | return 1; | 1211 | return 1; |
1212 | break; | 1212 | break; |
1213 | case SYNC_PREF_REMOTE: | 1213 | case SYNC_PREF_REMOTE: |
1214 | if ( lastSync > localMod ) | 1214 | if ( lastSync > localMod ) |
1215 | return 2; | 1215 | return 2; |
1216 | if ( lastSync > remoteMod ) | 1216 | if ( lastSync > remoteMod ) |
1217 | return 1; | 1217 | return 1; |
1218 | return 2; | 1218 | return 2; |
1219 | break; | 1219 | break; |
1220 | case SYNC_PREF_NEWEST: | 1220 | case SYNC_PREF_NEWEST: |
1221 | if ( localMod >= remoteMod ) | 1221 | if ( localMod >= remoteMod ) |
1222 | return 1; | 1222 | return 1; |
1223 | else | 1223 | else |
1224 | return 2; | 1224 | return 2; |
1225 | break; | 1225 | break; |
1226 | case SYNC_PREF_ASK: | 1226 | case SYNC_PREF_ASK: |
1227 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1227 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1228 | if ( lastSync > remoteMod && lastSync > localMod) | 1228 | if ( lastSync > remoteMod && lastSync > localMod) |
1229 | return 0; | 1229 | return 0; |
1230 | if ( lastSync > remoteMod ) | 1230 | if ( lastSync > remoteMod ) |
1231 | return 1; | 1231 | return 1; |
1232 | if ( lastSync > localMod ) | 1232 | if ( lastSync > localMod ) |
1233 | return 2; | 1233 | return 2; |
1234 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1234 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1235 | localIsNew = localMod >= remoteMod; | 1235 | localIsNew = localMod >= remoteMod; |
1236 | if ( localIsNew ) | 1236 | if ( localIsNew ) |
1237 | getEventViewerDialog()->setColorMode( 1 ); | 1237 | getEventViewerDialog()->setColorMode( 1 ); |
1238 | else | 1238 | else |
1239 | getEventViewerDialog()->setColorMode( 2 ); | 1239 | getEventViewerDialog()->setColorMode( 2 ); |
1240 | getEventViewerDialog()->setIncidence(local); | 1240 | getEventViewerDialog()->setIncidence(local); |
1241 | if ( localIsNew ) | 1241 | if ( localIsNew ) |
1242 | getEventViewerDialog()->setColorMode( 2 ); | 1242 | getEventViewerDialog()->setColorMode( 2 ); |
1243 | else | 1243 | else |
1244 | getEventViewerDialog()->setColorMode( 1 ); | 1244 | getEventViewerDialog()->setColorMode( 1 ); |
1245 | getEventViewerDialog()->addIncidence(remote); | 1245 | getEventViewerDialog()->addIncidence(remote); |
1246 | getEventViewerDialog()->setColorMode( 0 ); | 1246 | getEventViewerDialog()->setColorMode( 0 ); |
1247 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1247 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1248 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1248 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1249 | getEventViewerDialog()->showMe(); | 1249 | getEventViewerDialog()->showMe(); |
1250 | result = getEventViewerDialog()->executeS( localIsNew ); | 1250 | result = getEventViewerDialog()->executeS( localIsNew ); |
1251 | return result; | 1251 | return result; |
1252 | 1252 | ||
1253 | break; | 1253 | break; |
1254 | case SYNC_PREF_FORCE_LOCAL: | 1254 | case SYNC_PREF_FORCE_LOCAL: |
1255 | return 1; | 1255 | return 1; |
1256 | break; | 1256 | break; |
1257 | case SYNC_PREF_FORCE_REMOTE: | 1257 | case SYNC_PREF_FORCE_REMOTE: |
1258 | return 2; | 1258 | return 2; |
1259 | break; | 1259 | break; |
1260 | 1260 | ||
1261 | default: | 1261 | default: |
1262 | // SYNC_PREF_TAKE_BOTH not implemented | 1262 | // SYNC_PREF_TAKE_BOTH not implemented |
1263 | break; | 1263 | break; |
1264 | } | 1264 | } |
1265 | return 0; | 1265 | return 0; |
1266 | } | 1266 | } |
1267 | Event* CalendarView::getLastSyncEvent() | 1267 | Event* CalendarView::getLastSyncEvent() |
1268 | { | 1268 | { |
1269 | Event* lse; | 1269 | Event* lse; |
1270 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1270 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1271 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1271 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1272 | if (!lse) { | 1272 | if (!lse) { |
1273 | lse = new Event(); | 1273 | lse = new Event(); |
1274 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1274 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1275 | QString sum = ""; | 1275 | QString sum = ""; |
1276 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1276 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1277 | sum = "E: "; | 1277 | sum = "E: "; |
1278 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1278 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1279 | lse->setDtStart( mLastCalendarSync ); | 1279 | lse->setDtStart( mLastCalendarSync ); |
1280 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1280 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1281 | lse->setCategories( i18n("SyncEvent") ); | 1281 | lse->setCategories( i18n("SyncEvent") ); |
1282 | lse->setReadOnly( true ); | 1282 | lse->setReadOnly( true ); |
1283 | mCalendar->addEvent( lse ); | 1283 | mCalendar->addEvent( lse ); |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | return lse; | 1286 | return lse; |
1287 | 1287 | ||
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | // we check, if the to delete event has a id for a profile | 1290 | // we check, if the to delete event has a id for a profile |
1291 | // if yes, we set this id in the profile to delete | 1291 | // if yes, we set this id in the profile to delete |
1292 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1292 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1293 | { | 1293 | { |
1294 | if ( lastSync.count() == 0 ) { | 1294 | if ( lastSync.count() == 0 ) { |
1295 | //qDebug(" lastSync.count() == 0"); | 1295 | //qDebug(" lastSync.count() == 0"); |
1296 | return; | 1296 | return; |
1297 | } | 1297 | } |
1298 | if ( toDelete->typeID() == journalID ) | 1298 | if ( toDelete->typeID() == journalID ) |
1299 | return; | 1299 | return; |
1300 | 1300 | ||
1301 | Event* eve = lastSync.first(); | 1301 | Event* eve = lastSync.first(); |
1302 | 1302 | ||
1303 | while ( eve ) { | 1303 | while ( eve ) { |
1304 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1304 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1305 | if ( !id.isEmpty() ) { | 1305 | if ( !id.isEmpty() ) { |
1306 | QString des = eve->description(); | 1306 | QString des = eve->description(); |
1307 | QString pref = "e"; | 1307 | QString pref = "e"; |
1308 | if ( toDelete->typeID() == todoID ) | 1308 | if ( toDelete->typeID() == todoID ) |
1309 | pref = "t"; | 1309 | pref = "t"; |
1310 | des += pref+ id + ","; | 1310 | des += pref+ id + ","; |
1311 | eve->setReadOnly( false ); | 1311 | eve->setReadOnly( false ); |
1312 | eve->setDescription( des ); | 1312 | eve->setDescription( des ); |
1313 | //qDebug("setdes %s ", des.latin1()); | 1313 | //qDebug("setdes %s ", des.latin1()); |
1314 | eve->setReadOnly( true ); | 1314 | eve->setReadOnly( true ); |
1315 | } | 1315 | } |
1316 | eve = lastSync.next(); | 1316 | eve = lastSync.next(); |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | } | 1319 | } |
1320 | void CalendarView::checkExternalId( Incidence * inc ) | 1320 | void CalendarView::checkExternalId( Incidence * inc ) |
1321 | { | 1321 | { |
1322 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1322 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1323 | checkExternSyncEvent( lastSync, inc ); | 1323 | checkExternSyncEvent( lastSync, inc ); |
1324 | 1324 | ||
1325 | } | 1325 | } |
1326 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1326 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1327 | { | 1327 | { |
1328 | bool syncOK = true; | 1328 | bool syncOK = true; |
1329 | int addedEvent = 0; | 1329 | int addedEvent = 0; |
1330 | int addedEventR = 0; | 1330 | int addedEventR = 0; |
1331 | int deletedEventR = 0; | 1331 | int deletedEventR = 0; |
1332 | int deletedEventL = 0; | 1332 | int deletedEventL = 0; |
1333 | int changedLocal = 0; | 1333 | int changedLocal = 0; |
1334 | int changedRemote = 0; | 1334 | int changedRemote = 0; |
1335 | int filteredIN = 0; | 1335 | int filteredIN = 0; |
1336 | int filteredOUT = 0; | 1336 | int filteredOUT = 0; |
1337 | //QPtrList<Event> el = local->rawEvents(); | 1337 | //QPtrList<Event> el = local->rawEvents(); |
1338 | Event* eventR; | 1338 | Event* eventR; |
1339 | QString uid; | 1339 | QString uid; |
1340 | int take; | 1340 | int take; |
1341 | Event* eventRSync; | 1341 | Event* eventRSync; |
1342 | Event* eventLSync; | 1342 | Event* eventLSync; |
1343 | clearAllViews(); | 1343 | clearAllViews(); |
1344 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1344 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1345 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1345 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1346 | bool fullDateRange = false; | 1346 | bool fullDateRange = false; |
1347 | local->resetTempSyncStat(); | 1347 | local->resetTempSyncStat(); |
1348 | mLastCalendarSync = QDateTime::currentDateTime(); | 1348 | mLastCalendarSync = QDateTime::currentDateTime(); |
1349 | if ( mSyncManager->syncWithDesktop() ) { | 1349 | if ( mSyncManager->syncWithDesktop() ) { |
1350 | remote->resetPilotStat(1); | 1350 | remote->resetPilotStat(1); |
1351 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1351 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1352 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1352 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1353 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1353 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1354 | } else { | 1354 | } else { |
1355 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1355 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1356 | } | 1356 | } |
1357 | } | 1357 | } |
1358 | QDateTime modifiedCalendar = mLastCalendarSync; | 1358 | QDateTime modifiedCalendar = mLastCalendarSync; |
1359 | eventLSync = getLastSyncEvent(); | 1359 | eventLSync = getLastSyncEvent(); |
1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1361 | if ( eventR ) { | 1361 | if ( eventR ) { |
1362 | eventRSync = (Event*) eventR->clone(); | 1362 | eventRSync = (Event*) eventR->clone(); |
1363 | remote->deleteEvent(eventR ); | 1363 | remote->deleteEvent(eventR ); |
1364 | 1364 | ||
1365 | } else { | 1365 | } else { |
1366 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1366 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1367 | eventRSync = (Event*)eventLSync->clone(); | 1367 | eventRSync = (Event*)eventLSync->clone(); |
1368 | } else { | 1368 | } else { |
1369 | fullDateRange = true; | 1369 | fullDateRange = true; |
1370 | eventRSync = new Event(); | 1370 | eventRSync = new Event(); |
1371 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1371 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1372 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1372 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1373 | eventRSync->setDtStart( mLastCalendarSync ); | 1373 | eventRSync->setDtStart( mLastCalendarSync ); |
1374 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1374 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1375 | eventRSync->setCategories( i18n("SyncEvent") ); | 1375 | eventRSync->setCategories( i18n("SyncEvent") ); |
1376 | } | 1376 | } |
1377 | } | 1377 | } |
1378 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1378 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1379 | fullDateRange = true; | 1379 | fullDateRange = true; |
1380 | 1380 | ||
1381 | if ( ! fullDateRange ) { | 1381 | if ( ! fullDateRange ) { |
1382 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1382 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1383 | 1383 | ||
1384 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1384 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1385 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1385 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1386 | fullDateRange = true; | 1386 | fullDateRange = true; |
1387 | } | 1387 | } |
1388 | } | 1388 | } |
1389 | if ( mSyncManager->syncWithDesktop() ) { | 1389 | if ( mSyncManager->syncWithDesktop() ) { |
1390 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1390 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1391 | } | 1391 | } |
1392 | if ( fullDateRange ) | 1392 | if ( fullDateRange ) |
1393 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1393 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1394 | else | 1394 | else |
1395 | mLastCalendarSync = eventLSync->dtStart(); | 1395 | mLastCalendarSync = eventLSync->dtStart(); |
1396 | // for resyncing if own file has changed | 1396 | // for resyncing if own file has changed |
1397 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1397 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1398 | mLastCalendarSync = loadedFileVersion; | 1398 | mLastCalendarSync = loadedFileVersion; |
1399 | //qDebug("setting mLastCalendarSync "); | 1399 | //qDebug("setting mLastCalendarSync "); |
1400 | } | 1400 | } |
1401 | //qDebug("*************************** "); | 1401 | //qDebug("*************************** "); |
1402 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1402 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1403 | QPtrList<Incidence> er = remote->rawIncidences(); | 1403 | QPtrList<Incidence> er = remote->rawIncidences(); |
1404 | Incidence* inR = er.first(); | 1404 | Incidence* inR = er.first(); |
1405 | Incidence* inL; | 1405 | Incidence* inL; |
1406 | QProgressBar bar( er.count(),0 ); | 1406 | QProgressBar bar( er.count(),0 ); |
1407 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1407 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1408 | 1408 | ||
1409 | // ************** setting up filter ************* | 1409 | // ************** setting up filter ************* |
1410 | CalFilter *filterIN = 0; | 1410 | CalFilter *filterIN = 0; |
1411 | CalFilter *filterOUT = 0; | 1411 | CalFilter *filterOUT = 0; |
1412 | CalFilter *filter = mFilters.first(); | 1412 | CalFilter *filter = mFilters.first(); |
1413 | while(filter) { | 1413 | while(filter) { |
1414 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1414 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1415 | filterIN = filter; | 1415 | filterIN = filter; |
1416 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1416 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1417 | filterOUT = filter; | 1417 | filterOUT = filter; |
1418 | filter = mFilters.next(); | 1418 | filter = mFilters.next(); |
1419 | } | 1419 | } |
1420 | int w = 300; | 1420 | int w = 300; |
1421 | if ( QApplication::desktop()->width() < 320 ) | 1421 | if ( QApplication::desktop()->width() < 320 ) |
1422 | w = 220; | 1422 | w = 220; |
1423 | int h = bar.sizeHint().height() ; | 1423 | int h = bar.sizeHint().height() ; |
1424 | int dw = QApplication::desktop()->width(); | 1424 | int dw = QApplication::desktop()->width(); |
1425 | int dh = QApplication::desktop()->height(); | 1425 | int dh = QApplication::desktop()->height(); |
1426 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1426 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1427 | bar.show(); | 1427 | bar.show(); |
1428 | int modulo = (er.count()/10)+1; | 1428 | int modulo = (er.count()/10)+1; |
1429 | int incCounter = 0; | 1429 | int incCounter = 0; |
1430 | while ( inR ) { | 1430 | while ( inR ) { |
1431 | if ( ! bar.isVisible() ) | 1431 | if ( ! bar.isVisible() ) |
1432 | return false; | 1432 | return false; |
1433 | if ( incCounter % modulo == 0 ) | 1433 | if ( incCounter % modulo == 0 ) |
1434 | bar.setProgress( incCounter ); | 1434 | bar.setProgress( incCounter ); |
1435 | ++incCounter; | 1435 | ++incCounter; |
1436 | uid = inR->uid(); | 1436 | uid = inR->uid(); |
1437 | bool skipIncidence = false; | 1437 | bool skipIncidence = false; |
1438 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1438 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1439 | skipIncidence = true; | 1439 | skipIncidence = true; |
1440 | QString idS; | 1440 | QString idS; |
1441 | qApp->processEvents(); | 1441 | qApp->processEvents(); |
1442 | if ( !skipIncidence ) { | 1442 | if ( !skipIncidence ) { |
1443 | inL = local->incidence( uid ); | 1443 | inL = local->incidence( uid ); |
1444 | if ( inL ) { // maybe conflict - same uid in both calendars | 1444 | if ( inL ) { // maybe conflict - same uid in both calendars |
1445 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1445 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1446 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1446 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1447 | if ( take == 3 ) | 1447 | if ( take == 3 ) |
1448 | return false; | 1448 | return false; |
1449 | if ( take == 1 ) {// take local ********************** | 1449 | if ( take == 1 ) {// take local ********************** |
1450 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1450 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1451 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1451 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1452 | else | 1452 | else |
1453 | idS = inR->IDStr(); | 1453 | idS = inR->IDStr(); |
1454 | remote->deleteIncidence( inR ); | 1454 | remote->deleteIncidence( inR ); |
1455 | inR = inL->clone(); | 1455 | inR = inL->clone(); |
1456 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1456 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1457 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1457 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1458 | inR->setIDStr( idS ); | 1458 | inR->setIDStr( idS ); |
1459 | remote->addIncidence( inR ); | 1459 | remote->addIncidence( inR ); |
1460 | if ( mSyncManager->syncWithDesktop() ) | 1460 | if ( mSyncManager->syncWithDesktop() ) |
1461 | inR->setPilotId( 2 ); | 1461 | inR->setPilotId( 2 ); |
1462 | ++changedRemote; | 1462 | ++changedRemote; |
1463 | } else {// take remote ********************** | 1463 | } else {// take remote ********************** |
1464 | idS = inL->IDStr(); | 1464 | idS = inL->IDStr(); |
1465 | int pid = inL->pilotId(); | 1465 | int pid = inL->pilotId(); |
1466 | local->deleteIncidence( inL ); | 1466 | local->deleteIncidence( inL ); |
1467 | inL = inR->clone(); | 1467 | inL = inR->clone(); |
1468 | if ( mSyncManager->syncWithDesktop() ) | 1468 | if ( mSyncManager->syncWithDesktop() ) |
1469 | inL->setPilotId( pid ); | 1469 | inL->setPilotId( pid ); |
1470 | inL->setIDStr( idS ); | 1470 | inL->setIDStr( idS ); |
1471 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1471 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1472 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1472 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1473 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1473 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1474 | } | 1474 | } |
1475 | local->addIncidence( inL ); | 1475 | local->addIncidence( inL ); |
1476 | ++changedLocal; | 1476 | ++changedLocal; |
1477 | } | 1477 | } |
1478 | } | 1478 | } |
1479 | } else { // no conflict ********** add or delete remote | 1479 | } else { // no conflict ********** add or delete remote |
1480 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1480 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1481 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1481 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1482 | QString des = eventLSync->description(); | 1482 | QString des = eventLSync->description(); |
1483 | QString pref = "e"; | 1483 | QString pref = "e"; |
1484 | if ( inR->typeID() == todoID ) | 1484 | if ( inR->typeID() == todoID ) |
1485 | pref = "t"; | 1485 | pref = "t"; |
1486 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1486 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1487 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1487 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1488 | //remote->deleteIncidence( inR ); | 1488 | //remote->deleteIncidence( inR ); |
1489 | ++deletedEventR; | 1489 | ++deletedEventR; |
1490 | } else { | 1490 | } else { |
1491 | inR->setLastModified( modifiedCalendar ); | 1491 | inR->setLastModified( modifiedCalendar ); |
1492 | inL = inR->clone(); | 1492 | inL = inR->clone(); |
1493 | inL->setIDStr( ":" ); | 1493 | inL->setIDStr( ":" ); |
1494 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1494 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1495 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1495 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1496 | local->addIncidence( inL ); | 1496 | local->addIncidence( inL ); |
1497 | ++addedEvent; | 1497 | ++addedEvent; |
1498 | 1498 | ||
1499 | } | 1499 | } |
1500 | } else { | 1500 | } else { |
1501 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1501 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1502 | inR->setLastModified( modifiedCalendar ); | 1502 | inR->setLastModified( modifiedCalendar ); |
1503 | inL = inR->clone(); | 1503 | inL = inR->clone(); |
1504 | inL->setIDStr( ":" ); | 1504 | inL->setIDStr( ":" ); |
1505 | local->addIncidence( inL ); | 1505 | local->addIncidence( inL ); |
1506 | ++addedEvent; | 1506 | ++addedEvent; |
1507 | 1507 | ||
1508 | } else { | 1508 | } else { |
1509 | checkExternSyncEvent(eventRSyncSharp, inR); | 1509 | checkExternSyncEvent(eventRSyncSharp, inR); |
1510 | remote->deleteIncidence( inR ); | 1510 | remote->deleteIncidence( inR ); |
1511 | ++deletedEventR; | 1511 | ++deletedEventR; |
1512 | } | 1512 | } |
1513 | } | 1513 | } |
1514 | } else { | 1514 | } else { |
1515 | ++filteredIN; | 1515 | ++filteredIN; |
1516 | } | 1516 | } |
1517 | } | 1517 | } |
1518 | } | 1518 | } |
1519 | inR = er.next(); | 1519 | inR = er.next(); |
1520 | } | 1520 | } |
1521 | QPtrList<Incidence> el = local->rawIncidences(); | 1521 | QPtrList<Incidence> el = local->rawIncidences(); |
1522 | inL = el.first(); | 1522 | inL = el.first(); |
1523 | modulo = (el.count()/10)+1; | 1523 | modulo = (el.count()/10)+1; |
1524 | bar.setCaption (i18n("Add / remove events") ); | 1524 | bar.setCaption (i18n("Add / remove events") ); |
1525 | bar.setTotalSteps ( el.count() ) ; | 1525 | bar.setTotalSteps ( el.count() ) ; |
1526 | bar.show(); | 1526 | bar.show(); |
1527 | incCounter = 0; | 1527 | incCounter = 0; |
1528 | 1528 | ||
1529 | while ( inL ) { | 1529 | while ( inL ) { |
1530 | 1530 | ||
1531 | qApp->processEvents(); | 1531 | qApp->processEvents(); |
1532 | if ( ! bar.isVisible() ) | 1532 | if ( ! bar.isVisible() ) |
1533 | return false; | 1533 | return false; |
1534 | if ( incCounter % modulo == 0 ) | 1534 | if ( incCounter % modulo == 0 ) |
1535 | bar.setProgress( incCounter ); | 1535 | bar.setProgress( incCounter ); |
1536 | ++incCounter; | 1536 | ++incCounter; |
1537 | uid = inL->uid(); | 1537 | uid = inL->uid(); |
1538 | bool skipIncidence = false; | 1538 | bool skipIncidence = false; |
1539 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1539 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1540 | skipIncidence = true; | 1540 | skipIncidence = true; |
1541 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1541 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1542 | skipIncidence = true; | 1542 | skipIncidence = true; |
1543 | if ( !skipIncidence ) { | 1543 | if ( !skipIncidence ) { |
1544 | inR = remote->incidence( uid ); | 1544 | inR = remote->incidence( uid ); |
1545 | if ( ! inR ) { | 1545 | if ( ! inR ) { |
1546 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1546 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1547 | // no conflict ********** add or delete local | 1547 | // no conflict ********** add or delete local |
1548 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1548 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1549 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1549 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1550 | checkExternSyncEvent(eventLSyncSharp, inL); | 1550 | checkExternSyncEvent(eventLSyncSharp, inL); |
1551 | local->deleteIncidence( inL ); | 1551 | local->deleteIncidence( inL ); |
1552 | ++deletedEventL; | 1552 | ++deletedEventL; |
1553 | } else { | 1553 | } else { |
1554 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1554 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1555 | inL->removeID(mCurrentSyncDevice ); | 1555 | inL->removeID(mCurrentSyncDevice ); |
1556 | ++addedEventR; | 1556 | ++addedEventR; |
1557 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1557 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1558 | inL->setLastModified( modifiedCalendar ); | 1558 | inL->setLastModified( modifiedCalendar ); |
1559 | inR = inL->clone(); | 1559 | inR = inL->clone(); |
1560 | inR->setIDStr( ":" ); | 1560 | inR->setIDStr( ":" ); |
1561 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1561 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1562 | remote->addIncidence( inR ); | 1562 | remote->addIncidence( inR ); |
1563 | } | 1563 | } |
1564 | } | 1564 | } |
1565 | } else { | 1565 | } else { |
1566 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1566 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1567 | checkExternSyncEvent(eventLSyncSharp, inL); | 1567 | checkExternSyncEvent(eventLSyncSharp, inL); |
1568 | local->deleteIncidence( inL ); | 1568 | local->deleteIncidence( inL ); |
1569 | ++deletedEventL; | 1569 | ++deletedEventL; |
1570 | } else { | 1570 | } else { |
1571 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1571 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1572 | ++addedEventR; | 1572 | ++addedEventR; |
1573 | inL->setLastModified( modifiedCalendar ); | 1573 | inL->setLastModified( modifiedCalendar ); |
1574 | inR = inL->clone(); | 1574 | inR = inL->clone(); |
1575 | inR->setIDStr( ":" ); | 1575 | inR->setIDStr( ":" ); |
1576 | remote->addIncidence( inR ); | 1576 | remote->addIncidence( inR ); |
1577 | } | 1577 | } |
1578 | } | 1578 | } |
1579 | } | 1579 | } |
1580 | } else { | 1580 | } else { |
1581 | ++filteredOUT; | 1581 | ++filteredOUT; |
1582 | } | 1582 | } |
1583 | } | 1583 | } |
1584 | } | 1584 | } |
1585 | inL = el.next(); | 1585 | inL = el.next(); |
1586 | } | 1586 | } |
1587 | int delFut = 0; | 1587 | int delFut = 0; |
1588 | int remRem = 0; | 1588 | int remRem = 0; |
1589 | if ( mSyncManager->mWriteBackInFuture ) { | 1589 | if ( mSyncManager->mWriteBackInFuture ) { |
1590 | er = remote->rawIncidences(); | 1590 | er = remote->rawIncidences(); |
1591 | remRem = er.count(); | 1591 | remRem = er.count(); |
1592 | inR = er.first(); | 1592 | inR = er.first(); |
1593 | QDateTime dt; | 1593 | QDateTime dt; |
1594 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1594 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1595 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1595 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1596 | while ( inR ) { | 1596 | while ( inR ) { |
1597 | if ( inR->typeID() == todoID ) { | 1597 | if ( inR->typeID() == todoID ) { |
1598 | Todo * t = (Todo*)inR; | 1598 | Todo * t = (Todo*)inR; |
1599 | if ( t->hasDueDate() ) | 1599 | if ( t->hasDueDate() ) |
1600 | dt = t->dtDue(); | 1600 | dt = t->dtDue(); |
1601 | else | 1601 | else |
1602 | dt = cur.addSecs( 62 ); | 1602 | dt = cur.addSecs( 62 ); |
1603 | } | 1603 | } |
1604 | else if (inR->typeID() == eventID ) { | 1604 | else if (inR->typeID() == eventID ) { |
1605 | bool ok; | 1605 | bool ok; |
1606 | dt = inR->getNextOccurence( cur, &ok ); | 1606 | dt = inR->getNextOccurence( cur, &ok ); |
1607 | if ( !ok ) | 1607 | if ( !ok ) |
1608 | dt = cur.addSecs( -62 ); | 1608 | dt = cur.addSecs( -62 ); |
1609 | } | 1609 | } |
1610 | else | 1610 | else |
1611 | dt = inR->dtStart(); | 1611 | dt = inR->dtStart(); |
1612 | if ( dt < cur || dt > end ) { | 1612 | if ( dt < cur || dt > end ) { |
1613 | remote->deleteIncidence( inR ); | 1613 | remote->deleteIncidence( inR ); |
1614 | ++delFut; | 1614 | ++delFut; |
1615 | } | 1615 | } |
1616 | inR = er.next(); | 1616 | inR = er.next(); |
1617 | } | 1617 | } |
1618 | } | 1618 | } |
1619 | bar.hide(); | 1619 | bar.hide(); |
1620 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1620 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1621 | eventLSync->setReadOnly( false ); | 1621 | eventLSync->setReadOnly( false ); |
1622 | eventLSync->setDtStart( mLastCalendarSync ); | 1622 | eventLSync->setDtStart( mLastCalendarSync ); |
1623 | eventRSync->setDtStart( mLastCalendarSync ); | 1623 | eventRSync->setDtStart( mLastCalendarSync ); |
1624 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1624 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1625 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1625 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1626 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1626 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1627 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1627 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1628 | eventLSync->setReadOnly( true ); | 1628 | eventLSync->setReadOnly( true ); |
1629 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1629 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1630 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1630 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1631 | remote->addEvent( eventRSync ); | 1631 | remote->addEvent( eventRSync ); |
1632 | else | 1632 | else |
1633 | delete eventRSync; | 1633 | delete eventRSync; |
1634 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1634 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1635 | QString mes; | 1635 | QString mes; |
1636 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1636 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1637 | QString delmess; | 1637 | QString delmess; |
1638 | if ( delFut ) { | 1638 | if ( delFut ) { |
1639 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1639 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1640 | mes += delmess; | 1640 | mes += delmess; |
1641 | } | 1641 | } |
1642 | mes = i18n("Local calendar changed!\n") +mes; | 1642 | mes = i18n("Local calendar changed!\n") +mes; |
1643 | mCalendar->checkAlarmForIncidence( 0, true ); | 1643 | mCalendar->checkAlarmForIncidence( 0, true ); |
1644 | qDebug( mes ); | 1644 | qDebug( mes ); |
1645 | if ( mSyncManager->mShowSyncSummary ) { | 1645 | if ( mSyncManager->mShowSyncSummary ) { |
1646 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1646 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1647 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1647 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1648 | qDebug("KO: WB cancelled "); | 1648 | qDebug("KO: WB cancelled "); |
1649 | mSyncManager->mWriteBackFile = false; | 1649 | mSyncManager->mWriteBackFile = false; |
1650 | return syncOK; | 1650 | return syncOK; |
1651 | } | 1651 | } |
1652 | } | 1652 | } |
1653 | return syncOK; | 1653 | return syncOK; |
1654 | } | 1654 | } |
1655 | 1655 | ||
1656 | void CalendarView::setSyncDevice( QString s ) | 1656 | void CalendarView::setSyncDevice( QString s ) |
1657 | { | 1657 | { |
1658 | mCurrentSyncDevice= s; | 1658 | mCurrentSyncDevice= s; |
1659 | } | 1659 | } |
1660 | void CalendarView::setSyncName( QString s ) | 1660 | void CalendarView::setSyncName( QString s ) |
1661 | { | 1661 | { |
1662 | mCurrentSyncName= s; | 1662 | mCurrentSyncName= s; |
1663 | } | 1663 | } |
1664 | bool CalendarView::syncCalendar(QString filename, int mode) | 1664 | bool CalendarView::syncCalendar(QString filename, int mode) |
1665 | { | 1665 | { |
1666 | //qDebug("syncCalendar %s ", filename.latin1()); | 1666 | //qDebug("syncCalendar %s ", filename.latin1()); |
1667 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1667 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1668 | CalendarLocal* calendar = new CalendarLocal(); | 1668 | CalendarLocal* calendar = new CalendarLocal(); |
1669 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1669 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1670 | FileStorage* storage = new FileStorage( calendar ); | 1670 | FileStorage* storage = new FileStorage( calendar ); |
1671 | bool syncOK = false; | 1671 | bool syncOK = false; |
1672 | storage->setFileName( filename ); | 1672 | storage->setFileName( filename ); |
1673 | // qDebug("loading ... "); | 1673 | // qDebug("loading ... "); |
1674 | if ( storage->load() ) { | 1674 | if ( storage->load() ) { |
1675 | getEventViewerDialog()->setSyncMode( true ); | 1675 | getEventViewerDialog()->setSyncMode( true ); |
1676 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1676 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1677 | getEventViewerDialog()->setSyncMode( false ); | 1677 | getEventViewerDialog()->setSyncMode( false ); |
1678 | if ( syncOK ) { | 1678 | if ( syncOK ) { |
1679 | if ( mSyncManager->mWriteBackFile ) | 1679 | if ( mSyncManager->mWriteBackFile ) |
1680 | { | 1680 | { |
1681 | storage->setSaveFormat( new ICalFormat() ); | 1681 | storage->setSaveFormat( new ICalFormat() ); |
1682 | storage->save(); | 1682 | storage->save(); |
1683 | } | 1683 | } |
1684 | } | 1684 | } |
1685 | setModified( true ); | 1685 | setModified( true ); |
1686 | } | 1686 | } |
1687 | delete storage; | 1687 | delete storage; |
1688 | delete calendar; | 1688 | delete calendar; |
1689 | if ( syncOK ) | 1689 | if ( syncOK ) |
1690 | updateView(); | 1690 | updateView(); |
1691 | return syncOK; | 1691 | return syncOK; |
1692 | } | 1692 | } |
1693 | 1693 | ||
1694 | void CalendarView::syncExternal( int mode ) | 1694 | void CalendarView::syncExternal( int mode ) |
1695 | { | 1695 | { |
1696 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1696 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1697 | 1697 | ||
1698 | qApp->processEvents(); | 1698 | qApp->processEvents(); |
1699 | CalendarLocal* calendar = new CalendarLocal(); | 1699 | CalendarLocal* calendar = new CalendarLocal(); |
1700 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1700 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1701 | bool syncOK = false; | 1701 | bool syncOK = false; |
1702 | bool loadSuccess = false; | 1702 | bool loadSuccess = false; |
1703 | PhoneFormat* phoneFormat = 0; | 1703 | PhoneFormat* phoneFormat = 0; |
1704 | emit tempDisableBR(true); | 1704 | emit tempDisableBR(true); |
1705 | #ifndef DESKTOP_VERSION | 1705 | #ifndef DESKTOP_VERSION |
1706 | SharpFormat* sharpFormat = 0; | 1706 | SharpFormat* sharpFormat = 0; |
1707 | if ( mode == 0 ) { // sharp | 1707 | if ( mode == 0 ) { // sharp |
1708 | sharpFormat = new SharpFormat () ; | 1708 | sharpFormat = new SharpFormat () ; |
1709 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1709 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1710 | 1710 | ||
1711 | } else | 1711 | } else |
1712 | #endif | 1712 | #endif |
1713 | if ( mode == 1 ) { // phone | 1713 | if ( mode == 1 ) { // phone |
1714 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1714 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1715 | mSyncManager->mPhoneDevice, | 1715 | mSyncManager->mPhoneDevice, |
1716 | mSyncManager->mPhoneConnection, | 1716 | mSyncManager->mPhoneConnection, |
1717 | mSyncManager->mPhoneModel); | 1717 | mSyncManager->mPhoneModel); |
1718 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1718 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1719 | 1719 | ||
1720 | } else { | 1720 | } else { |
1721 | emit tempDisableBR(false); | 1721 | emit tempDisableBR(false); |
1722 | return; | 1722 | return; |
1723 | } | 1723 | } |
1724 | if ( loadSuccess ) { | 1724 | if ( loadSuccess ) { |
1725 | getEventViewerDialog()->setSyncMode( true ); | 1725 | getEventViewerDialog()->setSyncMode( true ); |
1726 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1726 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1727 | getEventViewerDialog()->setSyncMode( false ); | 1727 | getEventViewerDialog()->setSyncMode( false ); |
1728 | qApp->processEvents(); | 1728 | qApp->processEvents(); |
1729 | if ( syncOK ) { | 1729 | if ( syncOK ) { |
1730 | if ( mSyncManager->mWriteBackFile ) | 1730 | if ( mSyncManager->mWriteBackFile ) |
1731 | { | 1731 | { |
1732 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1732 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1733 | Incidence* inc = iL.first(); | 1733 | Incidence* inc = iL.first(); |
1734 | if ( phoneFormat ) { | 1734 | if ( phoneFormat ) { |
1735 | while ( inc ) { | 1735 | while ( inc ) { |
1736 | inc->removeID(mCurrentSyncDevice); | 1736 | inc->removeID(mCurrentSyncDevice); |
1737 | inc = iL.next(); | 1737 | inc = iL.next(); |
1738 | } | 1738 | } |
1739 | } | 1739 | } |
1740 | #ifndef DESKTOP_VERSION | 1740 | #ifndef DESKTOP_VERSION |
1741 | if ( sharpFormat ) | 1741 | if ( sharpFormat ) |
1742 | sharpFormat->save(calendar); | 1742 | sharpFormat->save(calendar); |
1743 | #endif | 1743 | #endif |
1744 | if ( phoneFormat ) | 1744 | if ( phoneFormat ) |
1745 | phoneFormat->save(calendar); | 1745 | phoneFormat->save(calendar); |
1746 | iL = calendar->rawIncidences(); | 1746 | iL = calendar->rawIncidences(); |
1747 | inc = iL.first(); | 1747 | inc = iL.first(); |
1748 | Incidence* loc; | 1748 | Incidence* loc; |
1749 | while ( inc ) { | 1749 | while ( inc ) { |
1750 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1750 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1751 | loc = mCalendar->incidence(inc->uid() ); | 1751 | loc = mCalendar->incidence(inc->uid() ); |
1752 | if ( loc ) { | 1752 | if ( loc ) { |
1753 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1753 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1754 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1754 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1755 | } | 1755 | } |
1756 | } | 1756 | } |
1757 | inc = iL.next(); | 1757 | inc = iL.next(); |
1758 | } | 1758 | } |
1759 | Incidence* lse = getLastSyncEvent(); | 1759 | Incidence* lse = getLastSyncEvent(); |
1760 | if ( lse ) { | 1760 | if ( lse ) { |
1761 | lse->setReadOnly( false ); | 1761 | lse->setReadOnly( false ); |
1762 | lse->setDescription( "" ); | 1762 | lse->setDescription( "" ); |
1763 | lse->setReadOnly( true ); | 1763 | lse->setReadOnly( true ); |
1764 | } | 1764 | } |
1765 | } | 1765 | } |
1766 | } else { | 1766 | } else { |
1767 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1767 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1768 | } | 1768 | } |
1769 | setModified( true ); | 1769 | setModified( true ); |
1770 | } else { | 1770 | } else { |
1771 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1771 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1772 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1772 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1773 | question, i18n("Ok")) ; | 1773 | question, i18n("Ok")) ; |
1774 | 1774 | ||
1775 | } | 1775 | } |
1776 | delete calendar; | 1776 | delete calendar; |
1777 | updateView(); | 1777 | updateView(); |
1778 | emit tempDisableBR(false); | 1778 | emit tempDisableBR(false); |
1779 | return ;//syncOK; | 1779 | return ;//syncOK; |
1780 | 1780 | ||
1781 | } | 1781 | } |
1782 | 1782 | ||
1783 | bool CalendarView::importBday() | 1783 | bool CalendarView::importBday() |
1784 | { | 1784 | { |
1785 | #ifndef KORG_NOKABC | 1785 | #ifndef KORG_NOKABC |
1786 | 1786 | ||
1787 | #ifdef DESKTOP_VERSION | 1787 | #ifdef DESKTOP_VERSION |
1788 | int curCal = mCalendar->defaultCalendar(); | 1788 | int curCal = mCalendar->defaultCalendar(); |
1789 | int bd = mCalEditView->getBirtdayID(); | 1789 | int bd = mCalEditView->getBirtdayID(); |
1790 | if ( bd == 0 ) | 1790 | if ( bd == 0 ) |
1791 | return false; | 1791 | return false; |
1792 | mCalendar->setDefaultCalendar( bd ); | 1792 | mCalendar->setDefaultCalendar( bd ); |
1793 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1793 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1794 | KABC::AddressBook::Iterator it; | 1794 | KABC::AddressBook::Iterator it; |
1795 | int count = 0; | 1795 | int count = 0; |
1796 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1796 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1797 | ++count; | 1797 | ++count; |
1798 | } | 1798 | } |
1799 | QProgressBar bar(count,0 ); | 1799 | QProgressBar bar(count,0 ); |
1800 | int w = 300; | 1800 | int w = 300; |
1801 | if ( QApplication::desktop()->width() < 320 ) | 1801 | if ( QApplication::desktop()->width() < 320 ) |
1802 | w = 220; | 1802 | w = 220; |
1803 | int h = bar.sizeHint().height() ; | 1803 | int h = bar.sizeHint().height() ; |
1804 | int dw = QApplication::desktop()->width(); | 1804 | int dw = QApplication::desktop()->width(); |
1805 | int dh = QApplication::desktop()->height(); | 1805 | int dh = QApplication::desktop()->height(); |
1806 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1806 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1807 | bar.show(); | 1807 | bar.show(); |
1808 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1808 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1809 | qApp->processEvents(); | 1809 | qApp->processEvents(); |
1810 | count = 0; | 1810 | count = 0; |
1811 | int addCount = 0; | 1811 | int addCount = 0; |
1812 | KCal::Attendee* a = 0; | 1812 | KCal::Attendee* a = 0; |
1813 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1813 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1814 | if ( ! bar.isVisible() ) | 1814 | if ( ! bar.isVisible() ) |
1815 | return false; | 1815 | return false; |
1816 | bar.setProgress( count++ ); | 1816 | bar.setProgress( count++ ); |
1817 | qApp->processEvents(); | 1817 | qApp->processEvents(); |
1818 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1818 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1819 | if ( (*it).birthday().date().isValid() ){ | 1819 | if ( (*it).birthday().date().isValid() ){ |
1820 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1820 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1821 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1821 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1822 | ++addCount; | 1822 | ++addCount; |
1823 | } | 1823 | } |
1824 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1824 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1825 | if ( anni.isValid() ){ | 1825 | if ( anni.isValid() ){ |
1826 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1826 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1827 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1827 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1828 | ++addCount; | 1828 | ++addCount; |
1829 | } | 1829 | } |
1830 | } | 1830 | } |
1831 | mCalendar->setDefaultCalendar( curCal ); | 1831 | mCalendar->setDefaultCalendar( curCal ); |
1832 | updateView(); | 1832 | updateView(); |
1833 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1833 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1834 | #else //DESKTOP_VERSION | 1834 | #else //DESKTOP_VERSION |
1835 | 1835 | ||
1836 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1836 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1837 | // the result should now arrive through method insertBirthdays | 1837 | // the result should now arrive through method insertBirthdays |
1838 | 1838 | ||
1839 | #endif //DESKTOP_VERSION | 1839 | #endif //DESKTOP_VERSION |
1840 | 1840 | ||
1841 | #endif //KORG_NOKABC | 1841 | #endif //KORG_NOKABC |
1842 | 1842 | ||
1843 | 1843 | ||
1844 | return true; | 1844 | return true; |
1845 | } | 1845 | } |
1846 | 1846 | ||
1847 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1847 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1848 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1848 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1849 | const QStringList& anniversaryList, const QStringList& realNameList, | 1849 | const QStringList& anniversaryList, const QStringList& realNameList, |
1850 | const QStringList& emailList, const QStringList& assembledNameList, | 1850 | const QStringList& emailList, const QStringList& assembledNameList, |
1851 | const QStringList& uidList) | 1851 | const QStringList& uidList) |
1852 | { | 1852 | { |
1853 | 1853 | ||
1854 | //qDebug("KO::CalendarView::insertBirthdays"); | 1854 | //qDebug("KO::CalendarView::insertBirthdays"); |
1855 | if (uid == this->name()) | 1855 | if (uid == this->name()) |
1856 | { | 1856 | { |
1857 | int curCal = mCalendar->defaultCalendar(); | 1857 | int curCal = mCalendar->defaultCalendar(); |
1858 | int bd = mCalEditView->getBirtdayID(); | 1858 | int bd = mCalEditView->getBirtdayID(); |
1859 | if ( bd == 0 ) | 1859 | if ( bd == 0 ) |
1860 | return; | 1860 | return; |
1861 | mCalendar->setDefaultCalendar( bd ); | 1861 | mCalendar->setDefaultCalendar( bd ); |
1862 | 1862 | ||
1863 | 1863 | ||
1864 | int count = birthdayList.count(); | 1864 | int count = birthdayList.count(); |
1865 | int addCount = 0; | 1865 | int addCount = 0; |
1866 | KCal::Attendee* a = 0; | 1866 | KCal::Attendee* a = 0; |
1867 | 1867 | ||
1868 | //qDebug("CalView 1 %i", count); | 1868 | //qDebug("CalView 1 %i", count); |
1869 | 1869 | ||
1870 | QProgressBar bar(count,0 ); | 1870 | QProgressBar bar(count,0 ); |
1871 | int w = 300; | 1871 | int w = 300; |
1872 | if ( QApplication::desktop()->width() < 320 ) | 1872 | if ( QApplication::desktop()->width() < 320 ) |
1873 | w = 220; | 1873 | w = 220; |
1874 | int h = bar.sizeHint().height() ; | 1874 | int h = bar.sizeHint().height() ; |
1875 | int dw = QApplication::desktop()->width(); | 1875 | int dw = QApplication::desktop()->width(); |
1876 | int dh = QApplication::desktop()->height(); | 1876 | int dh = QApplication::desktop()->height(); |
1877 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1877 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1878 | bar.show(); | 1878 | bar.show(); |
1879 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1879 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1880 | qApp->processEvents(); | 1880 | qApp->processEvents(); |
1881 | 1881 | ||
1882 | QDate birthday; | 1882 | QDate birthday; |
1883 | QDate anniversary; | 1883 | QDate anniversary; |
1884 | QString realName; | 1884 | QString realName; |
1885 | QString email; | 1885 | QString email; |
1886 | QString assembledName; | 1886 | QString assembledName; |
1887 | QString uid; | 1887 | QString uid; |
1888 | bool ok = true; | 1888 | bool ok = true; |
1889 | for ( int i = 0; i < count; i++) | 1889 | for ( int i = 0; i < count; i++) |
1890 | { | 1890 | { |
1891 | if ( ! bar.isVisible() ) | 1891 | if ( ! bar.isVisible() ) |
1892 | return; | 1892 | return; |
1893 | bar.setProgress( i ); | 1893 | bar.setProgress( i ); |
1894 | qApp->processEvents(); | 1894 | qApp->processEvents(); |
1895 | 1895 | ||
1896 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1896 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1897 | if (!ok) { | 1897 | if (!ok) { |
1898 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1898 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1899 | } | 1899 | } |
1900 | 1900 | ||
1901 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1901 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1902 | if (!ok) { | 1902 | if (!ok) { |
1903 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1903 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1904 | } | 1904 | } |
1905 | realName = realNameList[i]; | 1905 | realName = realNameList[i]; |
1906 | email = emailList[i]; | 1906 | email = emailList[i]; |
1907 | assembledName = assembledNameList[i]; | 1907 | assembledName = assembledNameList[i]; |
1908 | uid = uidList[i]; | 1908 | uid = uidList[i]; |
1909 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1909 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1910 | 1910 | ||
1911 | if ( birthday.isValid() ){ | 1911 | if ( birthday.isValid() ){ |
1912 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1912 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1913 | KCal::Attendee::ReqParticipant,uid) ; | 1913 | KCal::Attendee::ReqParticipant,uid) ; |
1914 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1914 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1915 | ++addCount; | 1915 | ++addCount; |
1916 | } | 1916 | } |
1917 | 1917 | ||
1918 | if ( anniversary.isValid() ){ | 1918 | if ( anniversary.isValid() ){ |
1919 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1919 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1920 | KCal::Attendee::ReqParticipant,uid) ; | 1920 | KCal::Attendee::ReqParticipant,uid) ; |
1921 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1921 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1922 | ++addCount; | 1922 | ++addCount; |
1923 | } | 1923 | } |
1924 | } | 1924 | } |
1925 | 1925 | ||
1926 | mCalendar->setDefaultCalendar( curCal ); | 1926 | mCalendar->setDefaultCalendar( curCal ); |
1927 | updateView(); | 1927 | updateView(); |
1928 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1928 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1929 | 1929 | ||
1930 | } | 1930 | } |
1931 | 1931 | ||
1932 | } | 1932 | } |
1933 | 1933 | ||
1934 | 1934 | ||
1935 | 1935 | ||
1936 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1936 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1937 | { | 1937 | { |
1938 | //qDebug("addAnni "); | 1938 | //qDebug("addAnni "); |
1939 | Event * ev = new Event(); | 1939 | Event * ev = new Event(); |
1940 | ev->setOrganizer(KOPrefs::instance()->email()); | 1940 | ev->setOrganizer(KOPrefs::instance()->email()); |
1941 | if ( a ) { | 1941 | if ( a ) { |
1942 | ev->addAttendee( a ); | 1942 | ev->addAttendee( a ); |
1943 | } | 1943 | } |
1944 | QString kind; | 1944 | QString kind; |
1945 | if ( birthday ) { | 1945 | if ( birthday ) { |
1946 | kind = i18n( "Birthday" ); | 1946 | kind = i18n( "Birthday" ); |
1947 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1947 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1948 | } | 1948 | } |
1949 | else { | 1949 | else { |
1950 | kind = i18n( "Anniversary" ); | 1950 | kind = i18n( "Anniversary" ); |
1951 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1951 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1952 | } | 1952 | } |
1953 | ev->setCategories( kind ); | 1953 | ev->setCategories( kind ); |
1954 | ev->setDtStart( QDateTime(date) ); | 1954 | ev->setDtStart( QDateTime(date) ); |
1955 | ev->setDtEnd( QDateTime(date) ); | 1955 | ev->setDtEnd( QDateTime(date) ); |
1956 | ev->setFloats( true ); | 1956 | ev->setFloats( true ); |
1957 | Recurrence * rec = ev->recurrence(); | 1957 | Recurrence * rec = ev->recurrence(); |
1958 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1958 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1959 | rec->addYearlyNum( date.month() ); | 1959 | rec->addYearlyNum( date.month() ); |
1960 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1960 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1961 | delete ev; | 1961 | delete ev; |
1962 | return false; | 1962 | return false; |
1963 | } | 1963 | } |
1964 | return true; | 1964 | return true; |
1965 | 1965 | ||
1966 | } | 1966 | } |
1967 | bool CalendarView::importQtopia( const QString &categories, | 1967 | bool CalendarView::importQtopia( const QString &categories, |
1968 | const QString &datebook, | 1968 | const QString &datebook, |
1969 | const QString &todolist ) | 1969 | const QString &todolist ) |
1970 | { | 1970 | { |
1971 | 1971 | ||
1972 | QtopiaFormat qtopiaFormat; | 1972 | QtopiaFormat qtopiaFormat; |
1973 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1973 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1974 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1974 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1975 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1975 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1976 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1976 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1977 | 1977 | ||
1978 | updateView(); | 1978 | updateView(); |
1979 | return true; | 1979 | return true; |
1980 | 1980 | ||
1981 | #if 0 | 1981 | #if 0 |
1982 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1982 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1983 | mCurrentSyncDevice = "qtopia-XML"; | 1983 | mCurrentSyncDevice = "qtopia-XML"; |
1984 | if ( mSyncManager->mAskForPreferences ) | 1984 | if ( mSyncManager->mAskForPreferences ) |
1985 | edit_sync_options(); | 1985 | edit_sync_options(); |
1986 | qApp->processEvents(); | 1986 | qApp->processEvents(); |
1987 | CalendarLocal* calendar = new CalendarLocal(); | 1987 | CalendarLocal* calendar = new CalendarLocal(); |
1988 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1988 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1989 | bool syncOK = false; | 1989 | bool syncOK = false; |
1990 | QtopiaFormat qtopiaFormat; | 1990 | QtopiaFormat qtopiaFormat; |
1991 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1991 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1992 | bool loadOk = true; | 1992 | bool loadOk = true; |
1993 | if ( !categories.isEmpty() ) | 1993 | if ( !categories.isEmpty() ) |
1994 | loadOk = qtopiaFormat.load( calendar, categories ); | 1994 | loadOk = qtopiaFormat.load( calendar, categories ); |
1995 | if ( loadOk && !datebook.isEmpty() ) | 1995 | if ( loadOk && !datebook.isEmpty() ) |
1996 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1996 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1997 | if ( loadOk && !todolist.isEmpty() ) | 1997 | if ( loadOk && !todolist.isEmpty() ) |
1998 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1998 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1999 | 1999 | ||
2000 | if ( loadOk ) { | 2000 | if ( loadOk ) { |
2001 | getEventViewerDialog()->setSyncMode( true ); | 2001 | getEventViewerDialog()->setSyncMode( true ); |
2002 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2002 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2003 | getEventViewerDialog()->setSyncMode( false ); | 2003 | getEventViewerDialog()->setSyncMode( false ); |
2004 | qApp->processEvents(); | 2004 | qApp->processEvents(); |
2005 | if ( syncOK ) { | 2005 | if ( syncOK ) { |
2006 | if ( mSyncManager->mWriteBackFile ) | 2006 | if ( mSyncManager->mWriteBackFile ) |
2007 | { | 2007 | { |
2008 | // write back XML file | 2008 | // write back XML file |
2009 | 2009 | ||
2010 | } | 2010 | } |
2011 | setModified( true ); | 2011 | setModified( true ); |
2012 | } | 2012 | } |
2013 | } else { | 2013 | } else { |
2014 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2014 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2015 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2015 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2016 | question, i18n("Ok")) ; | 2016 | question, i18n("Ok")) ; |
2017 | } | 2017 | } |
2018 | delete calendar; | 2018 | delete calendar; |
2019 | updateView(); | 2019 | updateView(); |
2020 | return syncOK; | 2020 | return syncOK; |
2021 | 2021 | ||
2022 | 2022 | ||
2023 | #endif | 2023 | #endif |
2024 | 2024 | ||
2025 | } | 2025 | } |
2026 | 2026 | ||
2027 | void CalendarView::setSyncEventsReadOnly() | 2027 | void CalendarView::setSyncEventsReadOnly() |
2028 | { | 2028 | { |
2029 | mCalendar->setSyncEventsReadOnly(); | 2029 | mCalendar->setSyncEventsReadOnly(); |
2030 | } | 2030 | } |
2031 | 2031 | ||
2032 | bool CalendarView::loadCalendars() | 2032 | bool CalendarView::loadCalendars() |
2033 | { | 2033 | { |
2034 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2034 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2035 | KopiCalendarFile * cal = calendars.first(); | 2035 | KopiCalendarFile * cal = calendars.first(); |
2036 | mCalendar->setDefaultCalendar( 1 ); | 2036 | mCalendar->setDefaultCalendar( 1 ); |
2037 | openCalendar( MainWindow::defaultFileName(), false ); | 2037 | openCalendar( MainWindow::defaultFileName(), false ); |
2038 | cal = calendars.next(); | 2038 | cal = calendars.next(); |
2039 | while ( cal ) { | 2039 | while ( cal ) { |
2040 | addCalendar( cal ); | 2040 | addCalendar( cal ); |
2041 | cal = calendars.next(); | 2041 | cal = calendars.next(); |
2042 | } | 2042 | } |
2043 | restoreCalendarSettings(); | 2043 | restoreCalendarSettings(); |
2044 | return true; | 2044 | return true; |
2045 | } | 2045 | } |
2046 | bool CalendarView::restoreCalendarSettings() | 2046 | bool CalendarView::restoreCalendarSettings() |
2047 | { | 2047 | { |
2048 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2048 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2049 | KopiCalendarFile * cal = calendars.first(); | 2049 | KopiCalendarFile * cal = calendars.first(); |
2050 | while ( cal ) { | 2050 | while ( cal ) { |
2051 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2051 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2052 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2052 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2053 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2053 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2054 | if ( cal->isStandard ) | 2054 | if ( cal->isStandard ) |
2055 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2055 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2056 | cal = calendars.next(); | 2056 | cal = calendars.next(); |
2057 | } | 2057 | } |
2058 | setSyncEventsReadOnly(); | 2058 | setSyncEventsReadOnly(); |
2059 | mCalendar->reInitAlarmSettings(); | 2059 | mCalendar->reInitAlarmSettings(); |
2060 | updateUnmanagedViews(); | 2060 | updateUnmanagedViews(); |
2061 | updateView(); | 2061 | updateView(); |
2062 | return true; | 2062 | return true; |
2063 | } | 2063 | } |
2064 | void CalendarView::addCalendarId( int id ) | 2064 | void CalendarView::addCalendarId( int id ) |
2065 | { | 2065 | { |
2066 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2066 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2067 | if ( cal ) | 2067 | if ( cal ) |
2068 | addCalendar( cal ); | 2068 | addCalendar( cal ); |
2069 | } | 2069 | } |
2070 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2070 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2071 | { | 2071 | { |
2072 | cal->mErrorOnLoad = false; | 2072 | cal->mErrorOnLoad = false; |
2073 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2073 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2074 | cal->mLoadDt = QDateTime::currentDateTime(); | 2074 | cal->mLoadDt = QDateTime::currentDateTime(); |
2075 | return true; | 2075 | return true; |
2076 | } | 2076 | } |
2077 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2077 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2078 | cal->mErrorOnLoad = true; | 2078 | cal->mErrorOnLoad = true; |
2079 | return false; | 2079 | return false; |
2080 | } | 2080 | } |
2081 | bool CalendarView::openCalendar(QString filename, bool merge) | 2081 | bool CalendarView::openCalendar(QString filename, bool merge) |
2082 | { | 2082 | { |
2083 | 2083 | ||
2084 | if (filename.isEmpty()) { | 2084 | if (filename.isEmpty()) { |
2085 | return false; | 2085 | return false; |
2086 | } | 2086 | } |
2087 | 2087 | ||
2088 | if (!QFile::exists(filename)) { | 2088 | if (!QFile::exists(filename)) { |
2089 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2089 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2090 | return false; | 2090 | return false; |
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | globalFlagBlockAgenda = 1; | 2093 | globalFlagBlockAgenda = 1; |
2094 | clearAllViews(); | 2094 | clearAllViews(); |
2095 | if (!merge) { | 2095 | if (!merge) { |
2096 | mViewManager->setDocumentId( filename ); | 2096 | mViewManager->setDocumentId( filename ); |
2097 | mCalendar->close(); | 2097 | mCalendar->close(); |
2098 | } | 2098 | } |
2099 | mStorage->setFileName( filename ); | 2099 | mStorage->setFileName( filename ); |
2100 | 2100 | ||
2101 | if ( mStorage->load() ) { | 2101 | if ( mStorage->load() ) { |
2102 | if ( merge ) ;//setModified( true ); | 2102 | if ( merge ) ;//setModified( true ); |
2103 | else { | 2103 | else { |
2104 | //setModified( true ); | 2104 | //setModified( true ); |
2105 | mViewManager->setDocumentId( filename ); | 2105 | mViewManager->setDocumentId( filename ); |
2106 | mDialogManager->setDocumentId( filename ); | 2106 | mDialogManager->setDocumentId( filename ); |
2107 | mTodoList->setDocumentId( filename ); | 2107 | mTodoList->setDocumentId( filename ); |
2108 | } | 2108 | } |
2109 | globalFlagBlockAgenda = 2; | 2109 | globalFlagBlockAgenda = 2; |
2110 | // if ( getLastSyncEvent() ) | 2110 | // if ( getLastSyncEvent() ) |
2111 | // getLastSyncEvent()->setReadOnly( true ); | 2111 | // getLastSyncEvent()->setReadOnly( true ); |
2112 | mCalendar->reInitAlarmSettings(); | 2112 | mCalendar->reInitAlarmSettings(); |
2113 | setSyncEventsReadOnly(); | 2113 | setSyncEventsReadOnly(); |
2114 | updateUnmanagedViews(); | 2114 | updateUnmanagedViews(); |
2115 | updateView(); | 2115 | updateView(); |
2116 | if ( filename != MainWindow::defaultFileName() ) { | 2116 | if ( filename != MainWindow::defaultFileName() ) { |
2117 | saveCalendar( MainWindow::defaultFileName() ); | 2117 | saveCalendar( MainWindow::defaultFileName() ); |
2118 | } else { | 2118 | } else { |
2119 | QFileInfo finf ( MainWindow::defaultFileName()); | 2119 | QFileInfo finf ( MainWindow::defaultFileName()); |
2120 | if ( finf.exists() ) { | 2120 | if ( finf.exists() ) { |
2121 | setLoadedFileVersion( finf.lastModified () ); | 2121 | setLoadedFileVersion( finf.lastModified () ); |
2122 | } | 2122 | } |
2123 | } | 2123 | } |
2124 | return true; | 2124 | return true; |
2125 | } else { | 2125 | } else { |
2126 | // while failing to load, the calendar object could | 2126 | // while failing to load, the calendar object could |
2127 | // have become partially populated. Clear it out. | 2127 | // have become partially populated. Clear it out. |
2128 | if ( !merge ) { | 2128 | if ( !merge ) { |
2129 | mCalendar->close(); | 2129 | mCalendar->close(); |
2130 | mViewManager->setDocumentId( filename ); | 2130 | mViewManager->setDocumentId( filename ); |
2131 | mDialogManager->setDocumentId( filename ); | 2131 | mDialogManager->setDocumentId( filename ); |
2132 | mTodoList->setDocumentId( filename ); | 2132 | mTodoList->setDocumentId( filename ); |
2133 | } | 2133 | } |
2134 | 2134 | ||
2135 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2135 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2136 | 2136 | ||
2137 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2137 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2138 | globalFlagBlockAgenda = 2; | 2138 | globalFlagBlockAgenda = 2; |
2139 | mCalendar->reInitAlarmSettings(); | 2139 | mCalendar->reInitAlarmSettings(); |
2140 | setSyncEventsReadOnly(); | 2140 | setSyncEventsReadOnly(); |
2141 | updateUnmanagedViews(); | 2141 | updateUnmanagedViews(); |
2142 | updateView(); | 2142 | updateView(); |
2143 | } | 2143 | } |
2144 | return false; | 2144 | return false; |
2145 | } | 2145 | } |
2146 | void CalendarView::showOpenError() | 2146 | void CalendarView::showOpenError() |
2147 | { | 2147 | { |
2148 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2148 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2149 | } | 2149 | } |
2150 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2150 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2151 | { | 2151 | { |
2152 | loadedFileVersion = dt; | 2152 | loadedFileVersion = dt; |
2153 | } | 2153 | } |
2154 | bool CalendarView::checkFileChanged(QString fn) | 2154 | bool CalendarView::checkFileChanged(QString fn) |
2155 | { | 2155 | { |
2156 | QFileInfo finf ( fn ); | 2156 | QFileInfo finf ( fn ); |
2157 | if ( !finf.exists() ) | 2157 | if ( !finf.exists() ) |
2158 | return true; | 2158 | return true; |
2159 | QDateTime dt = finf.lastModified (); | 2159 | QDateTime dt = finf.lastModified (); |
2160 | if ( dt <= loadedFileVersion ) | 2160 | if ( dt <= loadedFileVersion ) |
2161 | return false; | 2161 | return false; |
2162 | return true; | 2162 | return true; |
2163 | 2163 | ||
2164 | } | 2164 | } |
2165 | void CalendarView::watchSavedFile() | 2165 | void CalendarView::watchSavedFile() |
2166 | { | 2166 | { |
2167 | QFileInfo finf ( MainWindow::defaultFileName()); | 2167 | QFileInfo finf ( MainWindow::defaultFileName()); |
2168 | if ( !finf.exists() ) | 2168 | if ( !finf.exists() ) |
2169 | return; | 2169 | return; |
2170 | QDateTime dt = finf.lastModified (); | 2170 | QDateTime dt = finf.lastModified (); |
2171 | if ( dt < loadedFileVersion ) { | 2171 | if ( dt < loadedFileVersion ) { |
2172 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2172 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2173 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2173 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2174 | return; | 2174 | return; |
2175 | } | 2175 | } |
2176 | loadedFileVersion = dt; | 2176 | loadedFileVersion = dt; |
2177 | } | 2177 | } |
2178 | bool CalendarView::checkAllFileVersions() | 2178 | bool CalendarView::checkAllFileVersions() |
2179 | { | 2179 | { |
2180 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2180 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2181 | KopiCalendarFile * cal = calendars.first(); | 2181 | KopiCalendarFile * cal = calendars.first(); |
2182 | mCalendar->setDefaultCalendar( 1 ); | 2182 | mCalendar->setDefaultCalendar( 1 ); |
2183 | mCalendar->setDefaultCalendarEnabledOnly(); | 2183 | mCalendar->setDefaultCalendarEnabledOnly(); |
2184 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2184 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2185 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2185 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2186 | restoreCalendarSettings(); | 2186 | restoreCalendarSettings(); |
2187 | return false; | 2187 | return false; |
2188 | } | 2188 | } |
2189 | } | 2189 | } |
2190 | cal = calendars.next(); | 2190 | cal = calendars.next(); |
2191 | QDateTime storeTemp = loadedFileVersion; | 2191 | QDateTime storeTemp = loadedFileVersion; |
2192 | while ( cal ) { | 2192 | while ( cal ) { |
2193 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2193 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2194 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2194 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2195 | mCalendar->setDefaultCalendarEnabledOnly(); | 2195 | mCalendar->setDefaultCalendarEnabledOnly(); |
2196 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2196 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2197 | if ( !checkFileVersion(cal->mFileName )) { | 2197 | if ( !checkFileVersion(cal->mFileName )) { |
2198 | loadedFileVersion = storeTemp; | 2198 | loadedFileVersion = storeTemp; |
2199 | restoreCalendarSettings(); | 2199 | restoreCalendarSettings(); |
2200 | return false; | 2200 | return false; |
2201 | } | 2201 | } |
2202 | } | 2202 | } |
2203 | cal = calendars.next(); | 2203 | cal = calendars.next(); |
2204 | } | 2204 | } |
2205 | loadedFileVersion = storeTemp; | 2205 | loadedFileVersion = storeTemp; |
2206 | return true; | 2206 | return true; |
2207 | } | 2207 | } |
2208 | bool CalendarView::checkFileVersion(QString fn) | 2208 | bool CalendarView::checkFileVersion(QString fn) |
2209 | { | 2209 | { |
2210 | QFileInfo finf ( fn ); | 2210 | QFileInfo finf ( fn ); |
2211 | if ( !finf.exists() ) | 2211 | if ( !finf.exists() ) |
2212 | return true; | 2212 | return true; |
2213 | QDateTime dt = finf.lastModified (); | 2213 | QDateTime dt = finf.lastModified (); |
2214 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2214 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2215 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2215 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2216 | if ( dt <= loadedFileVersion ) | 2216 | if ( dt <= loadedFileVersion ) |
2217 | return true; | 2217 | return true; |
2218 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2218 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2219 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2219 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2220 | i18n("Sync+save")); | 2220 | i18n("Sync+save")); |
2221 | 2221 | ||
2222 | if ( km == KMessageBox::Cancel ) | 2222 | if ( km == KMessageBox::Cancel ) |
2223 | return false; | 2223 | return false; |
2224 | if ( km == KMessageBox::Yes ) | 2224 | if ( km == KMessageBox::Yes ) |
2225 | return true; | 2225 | return true; |
2226 | 2226 | ||
2227 | setSyncDevice("deleteaftersync" ); | 2227 | setSyncDevice("deleteaftersync" ); |
2228 | mSyncManager->mAskForPreferences = true; | 2228 | mSyncManager->mAskForPreferences = true; |
2229 | mSyncManager->mSyncAlgoPrefs = 3; | 2229 | mSyncManager->mSyncAlgoPrefs = 3; |
2230 | mSyncManager->mWriteBackFile = false; | 2230 | mSyncManager->mWriteBackFile = false; |
2231 | mSyncManager->mWriteBackExistingOnly = false; | 2231 | mSyncManager->mWriteBackExistingOnly = false; |
2232 | mSyncManager->mShowSyncSummary = false; | 2232 | mSyncManager->mShowSyncSummary = false; |
2233 | syncCalendar( fn, 3 ); | 2233 | syncCalendar( fn, 3 ); |
2234 | Event * e = getLastSyncEvent(); | 2234 | Event * e = getLastSyncEvent(); |
2235 | if ( e ) | 2235 | if ( e ) |
2236 | mCalendar->deleteEvent( e ); | 2236 | mCalendar->deleteEvent( e ); |
2237 | return true; | 2237 | return true; |
2238 | } | 2238 | } |
2239 | bool CalendarView::saveCalendars() | 2239 | bool CalendarView::saveCalendars() |
2240 | { | 2240 | { |
2241 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2241 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2242 | KopiCalendarFile * cal = calendars.first(); | 2242 | KopiCalendarFile * cal = calendars.first(); |
2243 | mCalendar->setDefaultCalendar( 1 ); | 2243 | mCalendar->setDefaultCalendar( 1 ); |
2244 | mCalendar->setDefaultCalendarEnabledOnly(); | 2244 | mCalendar->setDefaultCalendarEnabledOnly(); |
2245 | saveCalendar( MainWindow::defaultFileName() ); | 2245 | saveCalendar( MainWindow::defaultFileName() ); |
2246 | cal = calendars.next(); | 2246 | cal = calendars.next(); |
2247 | while ( cal ) { | 2247 | while ( cal ) { |
2248 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2248 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2249 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2249 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2250 | mCalendar->setDefaultCalendarEnabledOnly(); | 2250 | mCalendar->setDefaultCalendarEnabledOnly(); |
2251 | if ( saveCalendar( cal->mFileName ) ) | 2251 | if ( saveCalendar( cal->mFileName ) ) |
2252 | cal->mLoadDt = QDateTime::currentDateTime(); | 2252 | cal->mLoadDt = QDateTime::currentDateTime(); |
2253 | } | 2253 | } |
2254 | cal = calendars.next(); | 2254 | cal = calendars.next(); |
2255 | } | 2255 | } |
2256 | restoreCalendarSettings(); | 2256 | restoreCalendarSettings(); |
2257 | return true; | 2257 | return true; |
2258 | } | 2258 | } |
2259 | bool CalendarView::saveCalendar( QString filename ) | 2259 | bool CalendarView::saveCalendar( QString filename ) |
2260 | { | 2260 | { |
2261 | 2261 | ||
2262 | // Store back all unsaved data into calendar object | 2262 | // Store back all unsaved data into calendar object |
2263 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2263 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2264 | if ( mViewManager->currentView() ) | 2264 | if ( mViewManager->currentView() ) |
2265 | mViewManager->currentView()->flushView(); | 2265 | mViewManager->currentView()->flushView(); |
2266 | 2266 | ||
2267 | 2267 | ||
2268 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2268 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2269 | mStorage->setSaveFormat( new ICalFormat() ); | 2269 | mStorage->setSaveFormat( new ICalFormat() ); |
2270 | mStorage->setFileName( filename ); | 2270 | mStorage->setFileName( filename ); |
2271 | bool success; | 2271 | bool success; |
2272 | success = mStorage->save(); | 2272 | success = mStorage->save(); |
2273 | if ( !success ) { | 2273 | if ( !success ) { |
2274 | return false; | 2274 | return false; |
2275 | } | 2275 | } |
2276 | if ( filename == MainWindow::defaultFileName() ) { | 2276 | if ( filename == MainWindow::defaultFileName() ) { |
2277 | setLoadedFileVersion( lfv ); | 2277 | setLoadedFileVersion( lfv ); |
2278 | watchSavedFile(); | 2278 | watchSavedFile(); |
2279 | } | 2279 | } |
2280 | return true; | 2280 | return true; |
2281 | } | 2281 | } |
2282 | 2282 | ||
2283 | void CalendarView::closeCalendar() | 2283 | void CalendarView::closeCalendar() |
2284 | { | 2284 | { |
2285 | 2285 | ||
2286 | // child windows no longer valid | 2286 | // child windows no longer valid |
2287 | clearAllViews(); | 2287 | clearAllViews(); |
2288 | emit closingDown(); | 2288 | emit closingDown(); |
2289 | 2289 | ||
2290 | mCalendar->close(); | 2290 | mCalendar->close(); |
2291 | setModified(false); | 2291 | setModified(false); |
2292 | updateView(); | 2292 | updateView(); |
2293 | } | 2293 | } |
2294 | 2294 | ||
2295 | void CalendarView::archiveCalendar() | 2295 | void CalendarView::archiveCalendar() |
2296 | { | 2296 | { |
2297 | mDialogManager->showArchiveDialog(); | 2297 | mDialogManager->showArchiveDialog(); |
2298 | } | 2298 | } |
2299 | 2299 | ||
2300 | 2300 | ||
2301 | void CalendarView::readSettings() | 2301 | void CalendarView::readSettings() |
2302 | { | 2302 | { |
2303 | 2303 | ||
2304 | 2304 | ||
2305 | // mViewManager->showAgendaView(); | 2305 | // mViewManager->showAgendaView(); |
2306 | QString str; | 2306 | QString str; |
2307 | //qDebug("CalendarView::readSettings() "); | 2307 | //qDebug("CalendarView::readSettings() "); |
2308 | // read settings from the KConfig, supplying reasonable | 2308 | // read settings from the KConfig, supplying reasonable |
2309 | // defaults where none are to be found | 2309 | // defaults where none are to be found |
2310 | KConfig *config = KOGlobals::config(); | 2310 | KConfig *config = KOGlobals::config(); |
2311 | #ifndef KORG_NOSPLITTER | 2311 | #ifndef KORG_NOSPLITTER |
2312 | config->setGroup("KOrganizer Geometry"); | 2312 | config->setGroup("KOrganizer Geometry"); |
2313 | 2313 | ||
2314 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2314 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2315 | if (sizes.count() != 2) { | 2315 | if (sizes.count() != 2) { |
2316 | sizes << mDateNavigator->minimumSizeHint().width(); | 2316 | sizes << mDateNavigator->minimumSizeHint().width(); |
2317 | sizes << 300; | 2317 | sizes << 300; |
2318 | } | 2318 | } |
2319 | mPanner->setSizes(sizes); | 2319 | mPanner->setSizes(sizes); |
2320 | 2320 | ||
2321 | sizes = config->readIntListEntry("Separator2"); | 2321 | sizes = config->readIntListEntry("Separator2"); |
2322 | if ( ( mResourceView && sizes.count() == 4 ) || | 2322 | if ( ( mResourceView && sizes.count() == 4 ) || |
2323 | ( !mResourceView && sizes.count() == 3 ) ) { | 2323 | ( !mResourceView && sizes.count() == 3 ) ) { |
2324 | mLeftSplitter->setSizes(sizes); | 2324 | mLeftSplitter->setSizes(sizes); |
2325 | } | 2325 | } |
2326 | #endif | 2326 | #endif |
2327 | globalFlagBlockAgenda = 1; | 2327 | globalFlagBlockAgenda = 1; |
2328 | mViewManager->showAgendaView(); | 2328 | mViewManager->showAgendaView(); |
2329 | //mViewManager->readSettings( config ); | 2329 | //mViewManager->readSettings( config ); |
2330 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2330 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2331 | readFilterSettings(config); | 2331 | readFilterSettings(config); |
2332 | 2332 | ||
2333 | #ifdef DESKTOP_VERSION | 2333 | #ifdef DESKTOP_VERSION |
2334 | config->setGroup("WidgetLayout"); | 2334 | config->setGroup("WidgetLayout"); |
2335 | QStringList list; | 2335 | QStringList list; |
2336 | list = config->readListEntry("MainLayout"); | 2336 | list = config->readListEntry("MainLayout"); |
2337 | int x,y,w,h; | 2337 | int x,y,w,h; |
2338 | if ( ! list.isEmpty() ) { | 2338 | if ( ! list.isEmpty() ) { |
2339 | x = list[0].toInt(); | 2339 | x = list[0].toInt(); |
2340 | y = list[1].toInt(); | 2340 | y = list[1].toInt(); |
2341 | w = list[2].toInt(); | 2341 | w = list[2].toInt(); |
2342 | h = list[3].toInt(); | 2342 | h = list[3].toInt(); |
2343 | KApplication::testCoords( &x,&y,&w,&h ); | 2343 | KApplication::testCoords( &x,&y,&w,&h ); |
2344 | topLevelWidget()->setGeometry(x,y,w,h); | 2344 | topLevelWidget()->setGeometry(x,y,w,h); |
2345 | 2345 | ||
2346 | } else { | 2346 | } else { |
2347 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2347 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2348 | } | 2348 | } |
2349 | list = config->readListEntry("EditEventLayout"); | 2349 | list = config->readListEntry("EditEventLayout"); |
2350 | if ( ! list.isEmpty() ) { | 2350 | if ( ! list.isEmpty() ) { |
2351 | x = list[0].toInt(); | 2351 | x = list[0].toInt(); |
2352 | y = list[1].toInt(); | 2352 | y = list[1].toInt(); |
2353 | w = list[2].toInt(); | 2353 | w = list[2].toInt(); |
2354 | h = list[3].toInt(); | 2354 | h = list[3].toInt(); |
2355 | KApplication::testCoords( &x,&y,&w,&h ); | 2355 | KApplication::testCoords( &x,&y,&w,&h ); |
2356 | mEventEditor->setGeometry(x,y,w,h); | 2356 | mEventEditor->setGeometry(x,y,w,h); |
2357 | 2357 | ||
2358 | } | 2358 | } |
2359 | list = config->readListEntry("EditTodoLayout"); | 2359 | list = config->readListEntry("EditTodoLayout"); |
2360 | if ( ! list.isEmpty() ) { | 2360 | if ( ! list.isEmpty() ) { |
2361 | x = list[0].toInt(); | 2361 | x = list[0].toInt(); |
2362 | y = list[1].toInt(); | 2362 | y = list[1].toInt(); |
2363 | w = list[2].toInt(); | 2363 | w = list[2].toInt(); |
2364 | h = list[3].toInt(); | 2364 | h = list[3].toInt(); |
2365 | KApplication::testCoords( &x,&y,&w,&h ); | 2365 | KApplication::testCoords( &x,&y,&w,&h ); |
2366 | mTodoEditor->setGeometry(x,y,w,h); | 2366 | mTodoEditor->setGeometry(x,y,w,h); |
2367 | 2367 | ||
2368 | } | 2368 | } |
2369 | list = config->readListEntry("ViewerLayout"); | 2369 | list = config->readListEntry("ViewerLayout"); |
2370 | if ( ! list.isEmpty() ) { | 2370 | if ( ! list.isEmpty() ) { |
2371 | x = list[0].toInt(); | 2371 | x = list[0].toInt(); |
2372 | y = list[1].toInt(); | 2372 | y = list[1].toInt(); |
2373 | w = list[2].toInt(); | 2373 | w = list[2].toInt(); |
2374 | h = list[3].toInt(); | 2374 | h = list[3].toInt(); |
2375 | KApplication::testCoords( &x,&y,&w,&h ); | 2375 | KApplication::testCoords( &x,&y,&w,&h ); |
2376 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2376 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2377 | } | 2377 | } |
2378 | #endif | 2378 | #endif |
2379 | config->setGroup( "Views" ); | 2379 | config->setGroup( "Views" ); |
2380 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2380 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2381 | 2381 | ||
2382 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2382 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2383 | 2383 | ||
2384 | int resetval = 0; | 2384 | int resetval = 0; |
2385 | int maxVal = 0; | 2385 | int maxVal = 0; |
2386 | if (sizes.count() != 3) { | 2386 | if (sizes.count() != 3) { |
2387 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2387 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2388 | resetval = mDateNavigator->sizeHint().width()+2; | 2388 | resetval = mDateNavigator->sizeHint().width()+2; |
2389 | } else { | 2389 | } else { |
2390 | resetval = mDateNavigator->sizeHint().height()+2; | 2390 | resetval = mDateNavigator->sizeHint().height()+2; |
2391 | } | 2391 | } |
2392 | } | 2392 | } |
2393 | if ( resetval ) { | 2393 | if ( resetval ) { |
2394 | sizes.clear(); | 2394 | sizes.clear(); |
2395 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2395 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2396 | maxVal = QApplication::desktop()->width() -10; | 2396 | maxVal = QApplication::desktop()->width() -10; |
2397 | } else { | 2397 | } else { |
2398 | maxVal = QApplication::desktop()->height()-10; | 2398 | maxVal = QApplication::desktop()->height()-10; |
2399 | } | 2399 | } |
2400 | sizes << resetval; | 2400 | sizes << resetval; |
2401 | if ( maxVal < resetval + resetval) | 2401 | if ( maxVal < resetval + resetval) |
2402 | resetval = maxVal - resetval; | 2402 | resetval = maxVal - resetval; |
2403 | sizes << resetval; | 2403 | sizes << resetval; |
2404 | sizes << 100; | 2404 | sizes << 100; |
2405 | } | 2405 | } |
2406 | mLeftFrame->setSizes(sizes); | 2406 | mLeftFrame->setSizes(sizes); |
2407 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2407 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2408 | resetval = 0; | 2408 | resetval = 0; |
2409 | maxVal = 0; | 2409 | maxVal = 0; |
2410 | if (sizes.count() != 2) { | 2410 | if (sizes.count() != 2) { |
2411 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2411 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2412 | resetval = mDateNavigator->sizeHint().width()+2; | 2412 | resetval = mDateNavigator->sizeHint().width()+2; |
2413 | } else { | 2413 | } else { |
2414 | resetval = mDateNavigator->sizeHint().height()+2; | 2414 | resetval = mDateNavigator->sizeHint().height()+2; |
2415 | } | 2415 | } |
2416 | } | 2416 | } |
2417 | if ( resetval ) { | 2417 | if ( resetval ) { |
2418 | sizes.clear(); | 2418 | sizes.clear(); |
2419 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2419 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2420 | maxVal = QApplication::desktop()->width() -10; | 2420 | maxVal = QApplication::desktop()->width() -10; |
2421 | } else { | 2421 | } else { |
2422 | maxVal = QApplication::desktop()->height()-10; | 2422 | maxVal = QApplication::desktop()->height()-10; |
2423 | } | 2423 | } |
2424 | sizes << resetval; | 2424 | sizes << resetval; |
2425 | if ( maxVal < resetval + resetval) | 2425 | if ( maxVal < resetval + resetval) |
2426 | resetval = maxVal - resetval; | 2426 | resetval = maxVal - resetval; |
2427 | sizes << resetval; | 2427 | sizes << resetval; |
2428 | } | 2428 | } |
2429 | mMainFrame->setSizes(sizes); | 2429 | mMainFrame->setSizes(sizes); |
2430 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2430 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2431 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2431 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2432 | else mNavigator->selectDates( dateCount ); | 2432 | else mNavigator->selectDates( dateCount ); |
2433 | // mViewManager->readSettings( config ); | 2433 | // mViewManager->readSettings( config ); |
2434 | updateConfig(); | 2434 | updateConfig(); |
2435 | globalFlagBlockAgenda = 2; | 2435 | globalFlagBlockAgenda = 2; |
2436 | mViewManager->readSettings( config ); | 2436 | mViewManager->readSettings( config ); |
2437 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2437 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2438 | } | 2438 | } |
2439 | 2439 | ||
2440 | void CalendarView::checkSuspendAlarm() | 2440 | void CalendarView::checkSuspendAlarm() |
2441 | { | 2441 | { |
2442 | if ( mSuspendTimer->isActive() ) { | 2442 | if ( mSuspendTimer->isActive() ) { |
2443 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2443 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2444 | } | 2444 | } |
2445 | } | 2445 | } |
2446 | void CalendarView::writeSettings() | 2446 | void CalendarView::writeSettings() |
2447 | { | 2447 | { |
2448 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2448 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2449 | 2449 | ||
2450 | KConfig *config = KOGlobals::config(); | 2450 | KConfig *config = KOGlobals::config(); |
2451 | 2451 | ||
2452 | mViewManager->writeSettings( config ); | 2452 | mViewManager->writeSettings( config ); |
2453 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2453 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2454 | mDialogManager->writeSettings( config ); | 2454 | mDialogManager->writeSettings( config ); |
2455 | //KOPrefs::instance()->usrWriteConfig(); | 2455 | //KOPrefs::instance()->usrWriteConfig(); |
2456 | KOPrefs::instance()->writeConfig(); | 2456 | KOPrefs::instance()->writeConfig(); |
2457 | 2457 | ||
2458 | writeFilterSettings(config); | 2458 | writeFilterSettings(config); |
2459 | config->setGroup( "AppRun" ); | 2459 | config->setGroup( "AppRun" ); |
2460 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2460 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2461 | int days = dt.daysTo( QDate::currentDate() ); | 2461 | int days = dt.daysTo( QDate::currentDate() ); |
2462 | dt = dt.addDays( days ); | 2462 | dt = dt.addDays( days ); |
2463 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2463 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2464 | config->writeEntry( "LatestProgramStopDays", days ); | 2464 | config->writeEntry( "LatestProgramStopDays", days ); |
2465 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2465 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2466 | //qDebug("KO: Writing stop time: %d ", secs); | 2466 | //qDebug("KO: Writing stop time: %d ", secs); |
2467 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2467 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2468 | //QDateTime latest = dt.addSecs ( secs ); | 2468 | //QDateTime latest = dt.addSecs ( secs ); |
2469 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2469 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2470 | config->setGroup( "Views" ); | 2470 | config->setGroup( "Views" ); |
2471 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2471 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2472 | 2472 | ||
2473 | #if 0 | 2473 | #if 0 |
2474 | qDebug("********************* "); | 2474 | qDebug("********************* "); |
2475 | qDebug("Testcode secsto "); | 2475 | qDebug("Testcode secsto "); |
2476 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2476 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2477 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2477 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2478 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2478 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2479 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2479 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2480 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2480 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2481 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2481 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2482 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2482 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2483 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2483 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2484 | qDebug("********************* testcode end"); | 2484 | qDebug("********************* testcode end"); |
2485 | 2485 | ||
2486 | #endif | 2486 | #endif |
2487 | 2487 | ||
2488 | QValueList<int> listINT = mLeftFrame->sizes(); | 2488 | QValueList<int> listINT = mLeftFrame->sizes(); |
2489 | config->writeEntry("Left Splitter Frame",listINT); | 2489 | config->writeEntry("Left Splitter Frame",listINT); |
2490 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2490 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2491 | config->writeEntry("Main Splitter Frame",listINT2); | 2491 | config->writeEntry("Main Splitter Frame",listINT2); |
2492 | #ifdef DESKTOP_VERSION | 2492 | #ifdef DESKTOP_VERSION |
2493 | config->setGroup("WidgetLayout"); | 2493 | config->setGroup("WidgetLayout"); |
2494 | QStringList list ;//= config->readListEntry("MainLayout"); | 2494 | QStringList list ;//= config->readListEntry("MainLayout"); |
2495 | int x,y,w,h; | 2495 | int x,y,w,h; |
2496 | QWidget* wid; | 2496 | QWidget* wid; |
2497 | wid = topLevelWidget(); | 2497 | wid = topLevelWidget(); |
2498 | x = wid->geometry().x(); | 2498 | x = wid->geometry().x(); |
2499 | y = wid->geometry().y(); | 2499 | y = wid->geometry().y(); |
2500 | w = wid->width(); | 2500 | w = wid->width(); |
2501 | h = wid->height(); | 2501 | h = wid->height(); |
2502 | list.clear(); | 2502 | list.clear(); |
2503 | list << QString::number( x ); | 2503 | list << QString::number( x ); |
2504 | list << QString::number( y ); | 2504 | list << QString::number( y ); |
2505 | list << QString::number( w ); | 2505 | list << QString::number( w ); |
2506 | list << QString::number( h ); | 2506 | list << QString::number( h ); |
2507 | config->writeEntry("MainLayout",list ); | 2507 | config->writeEntry("MainLayout",list ); |
2508 | 2508 | ||
2509 | wid = mEventEditor; | 2509 | wid = mEventEditor; |
2510 | x = wid->geometry().x(); | 2510 | x = wid->geometry().x(); |
2511 | y = wid->geometry().y(); | 2511 | y = wid->geometry().y(); |
2512 | w = wid->width(); | 2512 | w = wid->width(); |
2513 | h = wid->height(); | 2513 | h = wid->height(); |
2514 | list.clear(); | 2514 | list.clear(); |
2515 | list << QString::number( x ); | 2515 | list << QString::number( x ); |
2516 | list << QString::number( y ); | 2516 | list << QString::number( y ); |
2517 | list << QString::number( w ); | 2517 | list << QString::number( w ); |
2518 | list << QString::number( h ); | 2518 | list << QString::number( h ); |
2519 | config->writeEntry("EditEventLayout",list ); | 2519 | config->writeEntry("EditEventLayout",list ); |
2520 | 2520 | ||
2521 | wid = mTodoEditor; | 2521 | wid = mTodoEditor; |
2522 | x = wid->geometry().x(); | 2522 | x = wid->geometry().x(); |
2523 | y = wid->geometry().y(); | 2523 | y = wid->geometry().y(); |
2524 | w = wid->width(); | 2524 | w = wid->width(); |
2525 | h = wid->height(); | 2525 | h = wid->height(); |
2526 | list.clear(); | 2526 | list.clear(); |
2527 | list << QString::number( x ); | 2527 | list << QString::number( x ); |
2528 | list << QString::number( y ); | 2528 | list << QString::number( y ); |
2529 | list << QString::number( w ); | 2529 | list << QString::number( w ); |
2530 | list << QString::number( h ); | 2530 | list << QString::number( h ); |
2531 | config->writeEntry("EditTodoLayout",list ); | 2531 | config->writeEntry("EditTodoLayout",list ); |
2532 | wid = getEventViewerDialog(); | 2532 | wid = getEventViewerDialog(); |
2533 | x = wid->geometry().x(); | 2533 | x = wid->geometry().x(); |
2534 | y = wid->geometry().y(); | 2534 | y = wid->geometry().y(); |
2535 | w = wid->width(); | 2535 | w = wid->width(); |
2536 | h = wid->height(); | 2536 | h = wid->height(); |
2537 | list.clear(); | 2537 | list.clear(); |
2538 | list << QString::number( x ); | 2538 | list << QString::number( x ); |
2539 | list << QString::number( y ); | 2539 | list << QString::number( y ); |
2540 | list << QString::number( w ); | 2540 | list << QString::number( w ); |
2541 | list << QString::number( h ); | 2541 | list << QString::number( h ); |
2542 | config->writeEntry("ViewerLayout",list ); | 2542 | config->writeEntry("ViewerLayout",list ); |
2543 | wid = mDialogManager->getSearchDialog(); | 2543 | wid = mDialogManager->getSearchDialog(); |
2544 | if ( wid ) { | 2544 | if ( wid ) { |
2545 | x = wid->geometry().x(); | 2545 | x = wid->geometry().x(); |
2546 | y = wid->geometry().y(); | 2546 | y = wid->geometry().y(); |
2547 | w = wid->width(); | 2547 | w = wid->width(); |
2548 | h = wid->height(); | 2548 | h = wid->height(); |
2549 | list.clear(); | 2549 | list.clear(); |
2550 | list << QString::number( x ); | 2550 | list << QString::number( x ); |
2551 | list << QString::number( y ); | 2551 | list << QString::number( y ); |
2552 | list << QString::number( w ); | 2552 | list << QString::number( w ); |
2553 | list << QString::number( h ); | 2553 | list << QString::number( h ); |
2554 | config->writeEntry("SearchLayout",list ); | 2554 | config->writeEntry("SearchLayout",list ); |
2555 | } | 2555 | } |
2556 | #endif | 2556 | #endif |
2557 | 2557 | ||
2558 | 2558 | ||
2559 | config->sync(); | 2559 | config->sync(); |
2560 | } | 2560 | } |
2561 | 2561 | ||
2562 | void CalendarView::readFilterSettings(KConfig *config) | 2562 | void CalendarView::readFilterSettings(KConfig *config) |
2563 | { | 2563 | { |
2564 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2564 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2565 | 2565 | ||
2566 | mFilters.clear(); | 2566 | mFilters.clear(); |
2567 | 2567 | ||
2568 | config->setGroup("General"); | 2568 | config->setGroup("General"); |
2569 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2569 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2570 | 2570 | ||
2571 | QStringList::ConstIterator it = filterList.begin(); | 2571 | QStringList::ConstIterator it = filterList.begin(); |
2572 | QStringList::ConstIterator end = filterList.end(); | 2572 | QStringList::ConstIterator end = filterList.end(); |
2573 | while(it != end) { | 2573 | while(it != end) { |
2574 | // kdDebug() << " filter: " << (*it) << endl; | 2574 | // kdDebug() << " filter: " << (*it) << endl; |
2575 | 2575 | ||
2576 | CalFilter *filter; | 2576 | CalFilter *filter; |
2577 | filter = new CalFilter(*it); | 2577 | filter = new CalFilter(*it); |
2578 | config->setGroup("Filter_" + (*it).utf8()); | 2578 | config->setGroup("Filter_" + (*it).utf8()); |
2579 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2579 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2580 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2580 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2581 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2581 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2582 | mFilters.append(filter); | 2582 | mFilters.append(filter); |
2583 | 2583 | ||
2584 | ++it; | 2584 | ++it; |
2585 | } | 2585 | } |
2586 | 2586 | ||
2587 | if (mFilters.count() == 0) { | 2587 | if (mFilters.count() == 0) { |
2588 | CalFilter *filter = new CalFilter(i18n("Default")); | 2588 | CalFilter *filter = new CalFilter(i18n("Default")); |
2589 | mFilters.append(filter); | 2589 | mFilters.append(filter); |
2590 | } | 2590 | } |
2591 | mFilterView->updateFilters(); | 2591 | mFilterView->updateFilters(); |
2592 | config->setGroup("FilterView"); | 2592 | config->setGroup("FilterView"); |
2593 | 2593 | ||
2594 | mFilterView->blockSignals(true); | 2594 | mFilterView->blockSignals(true); |
2595 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2595 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2596 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2596 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2597 | mFilterView->blockSignals(false); | 2597 | mFilterView->blockSignals(false); |
2598 | // We do it manually to avoid it being done twice by the above calls | 2598 | // We do it manually to avoid it being done twice by the above calls |
2599 | updateFilter(); | 2599 | updateFilter(); |
2600 | } | 2600 | } |
2601 | 2601 | ||
2602 | void CalendarView::writeFilterSettings(KConfig *config) | 2602 | void CalendarView::writeFilterSettings(KConfig *config) |
2603 | { | 2603 | { |
2604 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2604 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2605 | 2605 | ||
2606 | QStringList filterList; | 2606 | QStringList filterList; |
2607 | 2607 | ||
2608 | CalFilter *filter = mFilters.first(); | 2608 | CalFilter *filter = mFilters.first(); |
2609 | while(filter) { | 2609 | while(filter) { |
2610 | // kdDebug() << " fn: " << filter->name() << endl; | 2610 | // kdDebug() << " fn: " << filter->name() << endl; |
2611 | filterList << filter->name(); | 2611 | filterList << filter->name(); |
2612 | config->setGroup("Filter_" + filter->name().utf8()); | 2612 | config->setGroup("Filter_" + filter->name().utf8()); |
2613 | config->writeEntry("Criteria",filter->criteria()); | 2613 | config->writeEntry("Criteria",filter->criteria()); |
2614 | config->writeEntry("CategoryList",filter->categoryList()); | 2614 | config->writeEntry("CategoryList",filter->categoryList()); |
2615 | filter = mFilters.next(); | 2615 | filter = mFilters.next(); |
2616 | } | 2616 | } |
2617 | config->setGroup("General"); | 2617 | config->setGroup("General"); |
2618 | config->writeEntry("CalendarFilters",filterList); | 2618 | config->writeEntry("CalendarFilters",filterList); |
2619 | 2619 | ||
2620 | config->setGroup("FilterView"); | 2620 | config->setGroup("FilterView"); |
2621 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2621 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2622 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2622 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2623 | } | 2623 | } |
2624 | 2624 | ||
2625 | 2625 | ||
2626 | void CalendarView::goToday() | 2626 | void CalendarView::goToday() |
2627 | { | 2627 | { |
2628 | if ( mViewManager->currentView()->isMonthView() ) | 2628 | if ( mViewManager->currentView()->isMonthView() ) |
2629 | mNavigator->selectTodayMonth(); | 2629 | mNavigator->selectTodayMonth(); |
2630 | else | 2630 | else |
2631 | mNavigator->selectToday(); | 2631 | mNavigator->selectToday(); |
2632 | } | 2632 | } |
2633 | 2633 | ||
2634 | void CalendarView::goNext() | 2634 | void CalendarView::goNext() |
2635 | { | 2635 | { |
2636 | mNavigator->selectNext(); | 2636 | mNavigator->selectNext(); |
2637 | } | 2637 | } |
2638 | 2638 | ||
2639 | void CalendarView::goPrevious() | 2639 | void CalendarView::goPrevious() |
2640 | { | 2640 | { |
2641 | mNavigator->selectPrevious(); | 2641 | mNavigator->selectPrevious(); |
2642 | } | 2642 | } |
2643 | void CalendarView::goNextMonth() | 2643 | void CalendarView::goNextMonth() |
2644 | { | 2644 | { |
2645 | mNavigator->selectNextMonth(); | 2645 | mNavigator->selectNextMonth(); |
2646 | } | 2646 | } |
2647 | 2647 | ||
2648 | void CalendarView::goPreviousMonth() | 2648 | void CalendarView::goPreviousMonth() |
2649 | { | 2649 | { |
2650 | mNavigator->selectPreviousMonth(); | 2650 | mNavigator->selectPreviousMonth(); |
2651 | } | 2651 | } |
2652 | 2652 | ||
2653 | void CalendarView::updateConfig() | 2653 | void CalendarView::updateConfig() |
2654 | { | 2654 | { |
2655 | if ( KOPrefs::instance()->mUseAppColors ) | 2655 | if ( KOPrefs::instance()->mUseAppColors ) |
2656 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2656 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2657 | emit configChanged(); | 2657 | emit configChanged(); |
2658 | mTodoList->updateConfig(); | 2658 | mTodoList->updateConfig(); |
2659 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2659 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2660 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2660 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2661 | // To make the "fill window" configurations work | 2661 | // To make the "fill window" configurations work |
2662 | //mViewManager->raiseCurrentView(); | 2662 | //mViewManager->raiseCurrentView(); |
2663 | } | 2663 | } |
2664 | 2664 | ||
2665 | 2665 | ||
2666 | void CalendarView::eventChanged(Event *event) | 2666 | void CalendarView::eventChanged(Event *event) |
2667 | { | 2667 | { |
2668 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2668 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2669 | //updateUnmanagedViews(); | 2669 | //updateUnmanagedViews(); |
2670 | } | 2670 | } |
2671 | 2671 | ||
2672 | void CalendarView::eventAdded(Event *event) | 2672 | void CalendarView::eventAdded(Event *event) |
2673 | { | 2673 | { |
2674 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2674 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2675 | } | 2675 | } |
2676 | 2676 | ||
2677 | void CalendarView::eventToBeDeleted(Event *) | 2677 | void CalendarView::eventToBeDeleted(Event *) |
2678 | { | 2678 | { |
2679 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2679 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2680 | } | 2680 | } |
2681 | 2681 | ||
2682 | void CalendarView::eventDeleted() | 2682 | void CalendarView::eventDeleted() |
2683 | { | 2683 | { |
2684 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2684 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2685 | } | 2685 | } |
2686 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2686 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2687 | { | 2687 | { |
2688 | changeIncidenceDisplay((Incidence *)which, action); | 2688 | changeIncidenceDisplay((Incidence *)which, action); |
2689 | mDateNavigator->updateView(); //LR | 2689 | mDateNavigator->updateView(); //LR |
2690 | //mDialogManager->updateSearchDialog(); | 2690 | //mDialogManager->updateSearchDialog(); |
2691 | 2691 | ||
2692 | if (which) { | 2692 | if (which) { |
2693 | mViewManager->updateWNview(); | 2693 | mViewManager->updateWNview(); |
2694 | //mTodoList->updateView(); | 2694 | //mTodoList->updateView(); |
2695 | } | 2695 | } |
2696 | 2696 | ||
2697 | } | 2697 | } |
2698 | 2698 | ||
2699 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2699 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2700 | { | 2700 | { |
2701 | updateUnmanagedViews(); | 2701 | updateUnmanagedViews(); |
2702 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2702 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2703 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2703 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2704 | mCalendar->checkAlarmForIncidence( 0, true ); | 2704 | mCalendar->checkAlarmForIncidence( 0, true ); |
2705 | if ( mEventViewerDialog ) | 2705 | if ( mEventViewerDialog ) |
2706 | mEventViewerDialog->hide(); | 2706 | mEventViewerDialog->hide(); |
2707 | } | 2707 | } |
2708 | else | 2708 | else |
2709 | mCalendar->checkAlarmForIncidence( which , false ); | 2709 | mCalendar->checkAlarmForIncidence( which , false ); |
2710 | } | 2710 | } |
2711 | 2711 | ||
2712 | // most of the changeEventDisplays() right now just call the view's | 2712 | // most of the changeEventDisplays() right now just call the view's |
2713 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2713 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2714 | void CalendarView::changeEventDisplay(Event *which, int action) | 2714 | void CalendarView::changeEventDisplay(Event *which, int action) |
2715 | { | 2715 | { |
2716 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2716 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2717 | changeIncidenceDisplay((Incidence *)which, action); | 2717 | changeIncidenceDisplay((Incidence *)which, action); |
2718 | static bool clearallviews = false; | 2718 | static bool clearallviews = false; |
2719 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2719 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2720 | if ( clearallviews ) { | 2720 | if ( clearallviews ) { |
2721 | clearAllViews(); | 2721 | clearAllViews(); |
2722 | clearallviews = false; | 2722 | clearallviews = false; |
2723 | } | 2723 | } |
2724 | return; | 2724 | return; |
2725 | } | 2725 | } |
2726 | clearallviews = true; | 2726 | clearallviews = true; |
2727 | mDateNavigator->updateView(); | 2727 | mDateNavigator->updateView(); |
2728 | //mDialogManager->updateSearchDialog(); | 2728 | //mDialogManager->updateSearchDialog(); |
2729 | if (which) { | 2729 | if (which) { |
2730 | // If there is an event view visible update the display | 2730 | // If there is an event view visible update the display |
2731 | mViewManager->currentView()->changeEventDisplay(which,action); | 2731 | mViewManager->currentView()->changeEventDisplay(which,action); |
2732 | // TODO: check, if update needed | 2732 | // TODO: check, if update needed |
2733 | // if (which->getTodoStatus()) { | 2733 | // if (which->getTodoStatus()) { |
2734 | mTodoList->updateView(); | 2734 | mTodoList->updateView(); |
2735 | if ( action != KOGlobals::EVENTDELETED ) { | 2735 | if ( action != KOGlobals::EVENTDELETED ) { |
2736 | mConflictingEvent = which ; | 2736 | mConflictingEvent = which ; |
2737 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); | 2737 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); |
2738 | } | 2738 | } |
2739 | // } | 2739 | // } |
2740 | } else { | 2740 | } else { |
2741 | mViewManager->currentView()->updateView(); | 2741 | mViewManager->currentView()->updateView(); |
2742 | } | 2742 | } |
2743 | } | 2743 | } |
2744 | void CalendarView::checkConflictForEvent() | 2744 | void CalendarView::checkConflictForEvent() |
2745 | { | 2745 | { |
2746 | 2746 | ||
2747 | if (!KOPrefs::instance()->mConfirm) | 2747 | if (!KOPrefs::instance()->mConfirm) |
2748 | return; | 2748 | return; |
2749 | if ( ! mConflictingEvent ) return; | 2749 | if ( ! mConflictingEvent ) return; |
2750 | if ( mConflictingEvent->doesFloat() ) { | 2750 | if ( mConflictingEvent->isHoliday() || mConflictingEvent->isBirthday() || mConflictingEvent->isAnniversary() ) { |
2751 | mConflictingEvent = 0; | 2751 | mConflictingEvent = 0; |
2752 | return; | 2752 | return; |
2753 | } | 2753 | } |
2754 | QPtrList<Event> testlist = mCalendar->events(); | 2754 | QPtrList<Event> testlist = mCalendar->events(); |
2755 | Event * test = testlist.first(); | 2755 | Event * test = testlist.first(); |
2756 | QDateTime conflict; | 2756 | QDateTime conflict; |
2757 | QDateTime retVal; | 2757 | QDateTime retVal; |
2758 | bool found = false; | 2758 | bool found = false; |
2759 | Event * cE = 0; | 2759 | Event * cE = 0; |
2760 | QDateTime current = QDateTime::currentDateTime(); | 2760 | QDateTime current = QDateTime::currentDateTime(); |
2761 | while ( test ) { | 2761 | while ( test ) { |
2762 | if ( !test->doesFloat() ) { | 2762 | if ( !test->doesFloat() ) { |
2763 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 2763 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
2764 | if ( ! found ) { | 2764 | if ( ! found ) { |
2765 | conflict = retVal; | 2765 | conflict = retVal; |
2766 | cE = test; | 2766 | cE = test; |
2767 | } else { | 2767 | } else { |
2768 | if ( retVal < conflict ) { | 2768 | if ( retVal < conflict ) { |
2769 | conflict = retVal; | 2769 | conflict = retVal; |
2770 | cE = test; | 2770 | cE = test; |
2771 | } | 2771 | } |
2772 | } | 2772 | } |
2773 | found = true; | 2773 | found = true; |
2774 | } | 2774 | } |
2775 | } | 2775 | } |
2776 | test = testlist.next(); | 2776 | test = testlist.next(); |
2777 | } | 2777 | } |
2778 | if ( found ) { | 2778 | if ( found ) { |
2779 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 2779 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
2780 | qApp->processEvents(); | 2780 | qApp->processEvents(); |
2781 | int km = KMessageBox::warningContinueCancel(this,mess, | 2781 | int km = KMessageBox::warningContinueCancel(this,mess, |
2782 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | 2782 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); |
2783 | if ( km != KMessageBox::Continue ) | 2783 | if ( km != KMessageBox::Continue ) |
2784 | return; | 2784 | return; |
2785 | 2785 | ||
2786 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 2786 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
2787 | mViewManager->showDayView(); | 2787 | mViewManager->showDayView(); |
2788 | mNavigator->slotDaySelect( conflict.date() ); | 2788 | mNavigator->slotDaySelect( conflict.date() ); |
2789 | int hour = conflict.time().hour(); | 2789 | int hour = conflict.time().hour(); |
2790 | mViewManager->agendaView()->setStartHour( hour ); | 2790 | mViewManager->agendaView()->setStartHour( hour ); |
2791 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 2791 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
2792 | return; | ||
2793 | } | 2792 | } |
2794 | 2793 | mConflictingEvent = 0; | |
2795 | return; | 2794 | return; |
2796 | 2795 | ||
2797 | } | 2796 | } |
2798 | 2797 | ||
2799 | void CalendarView::updateTodoViews() | 2798 | void CalendarView::updateTodoViews() |
2800 | { | 2799 | { |
2801 | mTodoList->updateView(); | 2800 | mTodoList->updateView(); |
2802 | mViewManager->currentView()->updateView(); | 2801 | mViewManager->currentView()->updateView(); |
2803 | 2802 | ||
2804 | } | 2803 | } |
2805 | 2804 | ||
2806 | 2805 | ||
2807 | 2806 | ||
2808 | void CalendarView::clearAllViews() | 2807 | void CalendarView::clearAllViews() |
2809 | { | 2808 | { |
2810 | mTodoList->clearList(); | 2809 | mTodoList->clearList(); |
2811 | mViewManager->clearAllViews(); | 2810 | mViewManager->clearAllViews(); |
2812 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2811 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2813 | if ( sd ) { | 2812 | if ( sd ) { |
2814 | KOListView* kol = sd->listview(); | 2813 | KOListView* kol = sd->listview(); |
2815 | if ( kol ) | 2814 | if ( kol ) |
2816 | kol->clearList(); | 2815 | kol->clearList(); |
2817 | } | 2816 | } |
2818 | } | 2817 | } |
2819 | void CalendarView::updateView() | 2818 | void CalendarView::updateView() |
2820 | { | 2819 | { |
2821 | static bool clearallviews = false; | 2820 | static bool clearallviews = false; |
2822 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2821 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2823 | if ( clearallviews ) { | 2822 | if ( clearallviews ) { |
2824 | clearAllViews(); | 2823 | clearAllViews(); |
2825 | clearallviews = false; | 2824 | clearallviews = false; |
2826 | } | 2825 | } |
2827 | return; | 2826 | return; |
2828 | } | 2827 | } |
2829 | clearallviews = true; | 2828 | clearallviews = true; |
2830 | DateList tmpList = mNavigator->selectedDates(); | 2829 | DateList tmpList = mNavigator->selectedDates(); |
2831 | 2830 | ||
2832 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2831 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2833 | mTodoList->updateView(); | 2832 | mTodoList->updateView(); |
2834 | // We assume that the navigator only selects consecutive days. | 2833 | // We assume that the navigator only selects consecutive days. |
2835 | updateView( tmpList.first(), tmpList.last() ); | 2834 | updateView( tmpList.first(), tmpList.last() ); |
2836 | } | 2835 | } |
2837 | 2836 | ||
2838 | void CalendarView::updateUnmanagedViews() | 2837 | void CalendarView::updateUnmanagedViews() |
2839 | { | 2838 | { |
2840 | mDateNavigator->updateDayMatrix(); | 2839 | mDateNavigator->updateDayMatrix(); |
2841 | } | 2840 | } |
2842 | 2841 | ||
2843 | int CalendarView::msgItemDelete(const QString name) | 2842 | int CalendarView::msgItemDelete(const QString name) |
2844 | { | 2843 | { |
2845 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2844 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2846 | i18n("This item will be\npermanently deleted."), | 2845 | i18n("This item will be\npermanently deleted."), |
2847 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2846 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2848 | } | 2847 | } |
2849 | 2848 | ||
2850 | 2849 | ||
2851 | void CalendarView::edit_cut() | 2850 | void CalendarView::edit_cut() |
2852 | { | 2851 | { |
2853 | Event *anEvent=0; | 2852 | Event *anEvent=0; |
2854 | 2853 | ||
2855 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2854 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2856 | 2855 | ||
2857 | if (mViewManager->currentView()->isEventView()) { | 2856 | if (mViewManager->currentView()->isEventView()) { |
2858 | if ( incidence && incidence->typeID() == eventID ) { | 2857 | if ( incidence && incidence->typeID() == eventID ) { |
2859 | anEvent = static_cast<Event *>(incidence); | 2858 | anEvent = static_cast<Event *>(incidence); |
2860 | } | 2859 | } |
2861 | } | 2860 | } |
2862 | 2861 | ||
2863 | if (!anEvent) { | 2862 | if (!anEvent) { |
2864 | KNotifyClient::beep(); | 2863 | KNotifyClient::beep(); |
2865 | return; | 2864 | return; |
2866 | } | 2865 | } |
2867 | DndFactory factory( mCalendar ); | 2866 | DndFactory factory( mCalendar ); |
2868 | factory.cutIncidence(anEvent); | 2867 | factory.cutIncidence(anEvent); |
2869 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2868 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2870 | } | 2869 | } |
2871 | 2870 | ||
2872 | void CalendarView::edit_copy() | 2871 | void CalendarView::edit_copy() |
2873 | { | 2872 | { |
2874 | Event *anEvent=0; | 2873 | Event *anEvent=0; |
2875 | 2874 | ||
2876 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2875 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2877 | 2876 | ||
2878 | if (mViewManager->currentView()->isEventView()) { | 2877 | if (mViewManager->currentView()->isEventView()) { |
2879 | if ( incidence && incidence->typeID() == eventID ) { | 2878 | if ( incidence && incidence->typeID() == eventID ) { |
2880 | anEvent = static_cast<Event *>(incidence); | 2879 | anEvent = static_cast<Event *>(incidence); |
2881 | } | 2880 | } |
2882 | } | 2881 | } |
2883 | 2882 | ||
2884 | if (!anEvent) { | 2883 | if (!anEvent) { |
2885 | KNotifyClient::beep(); | 2884 | KNotifyClient::beep(); |
2886 | return; | 2885 | return; |
2887 | } | 2886 | } |
2888 | DndFactory factory( mCalendar ); | 2887 | DndFactory factory( mCalendar ); |
2889 | factory.copyIncidence(anEvent); | 2888 | factory.copyIncidence(anEvent); |
2890 | } | 2889 | } |
2891 | 2890 | ||
2892 | void CalendarView::edit_paste() | 2891 | void CalendarView::edit_paste() |
2893 | { | 2892 | { |
2894 | QDate date = mNavigator->selectedDates().first(); | 2893 | QDate date = mNavigator->selectedDates().first(); |
2895 | 2894 | ||
2896 | DndFactory factory( mCalendar ); | 2895 | DndFactory factory( mCalendar ); |
2897 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2896 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2898 | 2897 | ||
2899 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2898 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2900 | } | 2899 | } |
2901 | void CalendarView::edit_global_options() | 2900 | void CalendarView::edit_global_options() |
2902 | { | 2901 | { |
2903 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2902 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2904 | emit save(); | 2903 | emit save(); |
2905 | emit saveStopTimer(); | 2904 | emit saveStopTimer(); |
2906 | mDialogManager->showGlobalOptionsDialog(); | 2905 | mDialogManager->showGlobalOptionsDialog(); |
2907 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2906 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2908 | emit saveStopTimer(); | 2907 | emit saveStopTimer(); |
2909 | 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!"), | 2908 | 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!"), |
2910 | i18n("Timezone settings"),i18n("Reload"))) { | 2909 | i18n("Timezone settings"),i18n("Reload"))) { |
2911 | qDebug("KO: TZ reload cancelled "); | 2910 | qDebug("KO: TZ reload cancelled "); |
2912 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2911 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2913 | return; | 2912 | return; |
2914 | } | 2913 | } |
2915 | qDebug("KO: Timezone change "); | 2914 | qDebug("KO: Timezone change "); |
2916 | loadCalendars(); | 2915 | loadCalendars(); |
2917 | setModified(true); | 2916 | setModified(true); |
2918 | } | 2917 | } |
2919 | else | 2918 | else |
2920 | qDebug("KO: No tz change "); | 2919 | qDebug("KO: No tz change "); |
2921 | } | 2920 | } |
2922 | void CalendarView::edit_options() | 2921 | void CalendarView::edit_options() |
2923 | { | 2922 | { |
2924 | mDialogManager->showOptionsDialog(); | 2923 | mDialogManager->showOptionsDialog(); |
2925 | } | 2924 | } |
2926 | 2925 | ||
2927 | 2926 | ||
2928 | void CalendarView::slotSelectPickerDate( QDate d) | 2927 | void CalendarView::slotSelectPickerDate( QDate d) |
2929 | { | 2928 | { |
2930 | mDateFrame->hide(); | 2929 | mDateFrame->hide(); |
2931 | if ( mDatePickerMode == 1 ) { | 2930 | if ( mDatePickerMode == 1 ) { |
2932 | mNavigator->slotDaySelect( d ); | 2931 | mNavigator->slotDaySelect( d ); |
2933 | } else if ( mDatePickerMode == 2 ) { | 2932 | } else if ( mDatePickerMode == 2 ) { |
2934 | if ( mMoveIncidence->typeID() == todoID ) { | 2933 | if ( mMoveIncidence->typeID() == todoID ) { |
2935 | Todo * to = (Todo *) mMoveIncidence; | 2934 | Todo * to = (Todo *) mMoveIncidence; |
2936 | QTime tim; | 2935 | QTime tim; |
2937 | int len = 0; | 2936 | int len = 0; |
2938 | if ( to->hasStartDate() && to->hasDueDate() ) | 2937 | if ( to->hasStartDate() && to->hasDueDate() ) |
2939 | len = to->dtStart().secsTo( to->dtDue()); | 2938 | len = to->dtStart().secsTo( to->dtDue()); |
2940 | if ( to->hasDueDate() ) | 2939 | if ( to->hasDueDate() ) |
2941 | tim = to->dtDue().time(); | 2940 | tim = to->dtDue().time(); |
2942 | else { | 2941 | else { |
2943 | tim = QTime ( 0,0,0 ); | 2942 | tim = QTime ( 0,0,0 ); |
2944 | to->setFloats( true ); | 2943 | to->setFloats( true ); |
2945 | to->setHasDueDate( true ); | 2944 | to->setHasDueDate( true ); |
2946 | } | 2945 | } |
2947 | QDateTime dt ( d,tim ); | 2946 | QDateTime dt ( d,tim ); |
2948 | to->setDtDue( dt ); | 2947 | to->setDtDue( dt ); |
2949 | 2948 | ||
2950 | if ( to->hasStartDate() ) { | 2949 | if ( to->hasStartDate() ) { |
2951 | if ( len>0 ) | 2950 | if ( len>0 ) |
2952 | to->setDtStart(to->dtDue().addSecs( -len )); | 2951 | to->setDtStart(to->dtDue().addSecs( -len )); |
2953 | else | 2952 | else |
2954 | if (to->dtStart() > to->dtDue() ) | 2953 | if (to->dtStart() > to->dtDue() ) |
2955 | to->setDtStart(to->dtDue().addDays( -3 )); | 2954 | to->setDtStart(to->dtDue().addDays( -3 )); |
2956 | } | 2955 | } |
2957 | 2956 | ||
2958 | todoChanged( to ); | 2957 | todoChanged( to ); |
2959 | } else if ( mMoveIncidence->typeID() == eventID ) { | 2958 | } else if ( mMoveIncidence->typeID() == eventID ) { |
2960 | if ( mMoveIncidence->doesRecur() ) { | 2959 | if ( mMoveIncidence->doesRecur() ) { |
2961 | #if 0 | 2960 | #if 0 |
2962 | // PENDING implement this | 2961 | // PENDING implement this |
2963 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2962 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2964 | mCalendar()->addIncidence( newInc ); | 2963 | mCalendar()->addIncidence( newInc ); |
2965 | if ( mMoveIncidence->typeID() == todoID ) | 2964 | if ( mMoveIncidence->typeID() == todoID ) |
2966 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2965 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2967 | else | 2966 | else |
2968 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2967 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2969 | mMoveIncidence = newInc; | 2968 | mMoveIncidence = newInc; |
2970 | 2969 | ||
2971 | #endif | 2970 | #endif |
2972 | } | 2971 | } |
2973 | QTime tim = mMoveIncidence->dtStart().time(); | 2972 | QTime tim = mMoveIncidence->dtStart().time(); |
2974 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2973 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2975 | QDateTime dt ( d,tim ); | 2974 | QDateTime dt ( d,tim ); |
2976 | mMoveIncidence->setDtStart( dt ); | 2975 | mMoveIncidence->setDtStart( dt ); |
2977 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2976 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2978 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2977 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2979 | } else if ( mMoveIncidence->typeID() == journalID ) { | 2978 | } else if ( mMoveIncidence->typeID() == journalID ) { |
2980 | QTime tim = mMoveIncidence->dtStart().time(); | 2979 | QTime tim = mMoveIncidence->dtStart().time(); |
2981 | QDateTime dt ( d,tim ); | 2980 | QDateTime dt ( d,tim ); |
2982 | mMoveIncidence->setDtStart( dt ); | 2981 | mMoveIncidence->setDtStart( dt ); |
2983 | updateView(); | 2982 | updateView(); |
2984 | } | 2983 | } |
2985 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2984 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2986 | } | 2985 | } |
2987 | } | 2986 | } |
2988 | 2987 | ||
2989 | void CalendarView::removeCategories() | 2988 | void CalendarView::removeCategories() |
2990 | { | 2989 | { |
2991 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2990 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2992 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2991 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2993 | QStringList catIncList; | 2992 | QStringList catIncList; |
2994 | QStringList newCatList; | 2993 | QStringList newCatList; |
2995 | Incidence* inc = incList.first(); | 2994 | Incidence* inc = incList.first(); |
2996 | uint i; | 2995 | uint i; |
2997 | while ( inc ) { | 2996 | while ( inc ) { |
2998 | newCatList.clear(); | 2997 | newCatList.clear(); |
2999 | catIncList = inc->categories() ; | 2998 | catIncList = inc->categories() ; |
3000 | for( i = 0; i< catIncList.count(); ++i ) { | 2999 | for( i = 0; i< catIncList.count(); ++i ) { |
3001 | if ( catList.contains (catIncList[i])) | 3000 | if ( catList.contains (catIncList[i])) |
3002 | newCatList.append( catIncList[i] ); | 3001 | newCatList.append( catIncList[i] ); |
3003 | } | 3002 | } |
3004 | newCatList.sort(); | 3003 | newCatList.sort(); |
3005 | inc->setCategories( newCatList.join(",") ); | 3004 | inc->setCategories( newCatList.join(",") ); |
3006 | inc = incList.next(); | 3005 | inc = incList.next(); |
3007 | } | 3006 | } |
3008 | } | 3007 | } |
3009 | 3008 | ||
3010 | int CalendarView::addCategories() | 3009 | int CalendarView::addCategories() |
3011 | { | 3010 | { |
3012 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3011 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3013 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3012 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3014 | QStringList catIncList; | 3013 | QStringList catIncList; |
3015 | Incidence* inc = incList.first(); | 3014 | Incidence* inc = incList.first(); |
3016 | uint i; | 3015 | uint i; |
3017 | int count = 0; | 3016 | int count = 0; |
3018 | while ( inc ) { | 3017 | while ( inc ) { |
3019 | catIncList = inc->categories() ; | 3018 | catIncList = inc->categories() ; |
3020 | for( i = 0; i< catIncList.count(); ++i ) { | 3019 | for( i = 0; i< catIncList.count(); ++i ) { |
3021 | if ( !catList.contains (catIncList[i])) { | 3020 | if ( !catList.contains (catIncList[i])) { |
3022 | catList.append( catIncList[i] ); | 3021 | catList.append( catIncList[i] ); |
3023 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3022 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3024 | ++count; | 3023 | ++count; |
3025 | } | 3024 | } |
3026 | } | 3025 | } |
3027 | inc = incList.next(); | 3026 | inc = incList.next(); |
3028 | } | 3027 | } |
3029 | catList.sort(); | 3028 | catList.sort(); |
3030 | KOPrefs::instance()->mCustomCategories = catList; | 3029 | KOPrefs::instance()->mCustomCategories = catList; |
3031 | return count; | 3030 | return count; |
3032 | } | 3031 | } |
3033 | 3032 | ||
3034 | void CalendarView::editCategories() | 3033 | void CalendarView::editCategories() |
3035 | { | 3034 | { |
3036 | qDebug("CalendarView::editCategories() "); | 3035 | qDebug("CalendarView::editCategories() "); |
3037 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3036 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3038 | ced.exec(); | 3037 | ced.exec(); |
3039 | } | 3038 | } |
3040 | void CalendarView::manageCategories() | 3039 | void CalendarView::manageCategories() |
3041 | { | 3040 | { |
3042 | KOCatPrefs* cp = new KOCatPrefs(); | 3041 | KOCatPrefs* cp = new KOCatPrefs(); |
3043 | cp->show(); | 3042 | cp->show(); |
3044 | int w =cp->sizeHint().width() ; | 3043 | int w =cp->sizeHint().width() ; |
3045 | int h = cp->sizeHint().height() ; | 3044 | int h = cp->sizeHint().height() ; |
3046 | int dw = QApplication::desktop()->width(); | 3045 | int dw = QApplication::desktop()->width(); |
3047 | int dh = QApplication::desktop()->height(); | 3046 | int dh = QApplication::desktop()->height(); |
3048 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3047 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3049 | if ( !cp->exec() ) { | 3048 | if ( !cp->exec() ) { |
3050 | delete cp; | 3049 | delete cp; |
3051 | return; | 3050 | return; |
3052 | } | 3051 | } |
3053 | int count = 0; | 3052 | int count = 0; |
3054 | if ( cp->addCat() ) { | 3053 | if ( cp->addCat() ) { |
3055 | count = addCategories(); | 3054 | count = addCategories(); |
3056 | if ( count ) { | 3055 | if ( count ) { |
3057 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3056 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3058 | writeSettings(); | 3057 | writeSettings(); |
3059 | } else | 3058 | } else |
3060 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3059 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3061 | } else { | 3060 | } else { |
3062 | removeCategories(); | 3061 | removeCategories(); |
3063 | updateView(); | 3062 | updateView(); |
3064 | } | 3063 | } |
3065 | delete cp; | 3064 | delete cp; |
3066 | } | 3065 | } |
3067 | 3066 | ||
3068 | void CalendarView::beamIncidence(Incidence * Inc) | 3067 | void CalendarView::beamIncidence(Incidence * Inc) |
3069 | { | 3068 | { |
3070 | QPtrList<Incidence> delSel ; | 3069 | QPtrList<Incidence> delSel ; |
3071 | delSel.append(Inc); | 3070 | delSel.append(Inc); |
3072 | beamIncidenceList( delSel ); | 3071 | beamIncidenceList( delSel ); |
3073 | } | 3072 | } |
3074 | void CalendarView::beamCalendar() | 3073 | void CalendarView::beamCalendar() |
3075 | { | 3074 | { |
3076 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3075 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3077 | //qDebug("beamCalendar() "); | 3076 | //qDebug("beamCalendar() "); |
3078 | beamIncidenceList( delSel ); | 3077 | beamIncidenceList( delSel ); |
3079 | } | 3078 | } |
3080 | void CalendarView::beamFilteredCalendar() | 3079 | void CalendarView::beamFilteredCalendar() |
3081 | { | 3080 | { |
3082 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3081 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3083 | //qDebug("beamFilteredCalendar() "); | 3082 | //qDebug("beamFilteredCalendar() "); |
3084 | beamIncidenceList( delSel ); | 3083 | beamIncidenceList( delSel ); |
3085 | } | 3084 | } |
3086 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3085 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3087 | { | 3086 | { |
3088 | 3087 | ||
3089 | KOBeamPrefs beamDialog; | 3088 | KOBeamPrefs beamDialog; |
3090 | if ( beamDialog.exec () == QDialog::Rejected ) | 3089 | if ( beamDialog.exec () == QDialog::Rejected ) |
3091 | return; | 3090 | return; |
3092 | #ifdef DESKTOP_VERSION | 3091 | #ifdef DESKTOP_VERSION |
3093 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3092 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3094 | #else | 3093 | #else |
3095 | QString fn = "/tmp/kopibeamfile"; | 3094 | QString fn = "/tmp/kopibeamfile"; |
3096 | #endif | 3095 | #endif |
3097 | QString mes; | 3096 | QString mes; |
3098 | bool createbup = true; | 3097 | bool createbup = true; |
3099 | if ( createbup ) { | 3098 | if ( createbup ) { |
3100 | QString description = "\n"; | 3099 | QString description = "\n"; |
3101 | CalendarLocal* cal = new CalendarLocal(); | 3100 | CalendarLocal* cal = new CalendarLocal(); |
3102 | if ( beamDialog.beamLocal() ) | 3101 | if ( beamDialog.beamLocal() ) |
3103 | cal->setLocalTime(); | 3102 | cal->setLocalTime(); |
3104 | else | 3103 | else |
3105 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3104 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3106 | Incidence *incidence = delSel.first(); | 3105 | Incidence *incidence = delSel.first(); |
3107 | bool addText = false; | 3106 | bool addText = false; |
3108 | if ( delSel.count() < 10 ) | 3107 | if ( delSel.count() < 10 ) |
3109 | addText = true; | 3108 | addText = true; |
3110 | else { | 3109 | else { |
3111 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3110 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3112 | } | 3111 | } |
3113 | while ( incidence ) { | 3112 | while ( incidence ) { |
3114 | Incidence *in = incidence->clone(); | 3113 | Incidence *in = incidence->clone(); |
3115 | if ( ! in->summary().isEmpty() ) { | 3114 | if ( ! in->summary().isEmpty() ) { |
3116 | in->setDescription(""); | 3115 | in->setDescription(""); |
3117 | } else { | 3116 | } else { |
3118 | in->setSummary( in->description().left(20)); | 3117 | in->setSummary( in->description().left(20)); |
3119 | in->setDescription(""); | 3118 | in->setDescription(""); |
3120 | } | 3119 | } |
3121 | if ( addText ) | 3120 | if ( addText ) |
3122 | description += in->summary() + "\n"; | 3121 | description += in->summary() + "\n"; |
3123 | cal->addIncidence( in ); | 3122 | cal->addIncidence( in ); |
3124 | incidence = delSel.next(); | 3123 | incidence = delSel.next(); |
3125 | } | 3124 | } |
3126 | if ( beamDialog.beamVcal() ) { | 3125 | if ( beamDialog.beamVcal() ) { |
3127 | fn += ".vcs"; | 3126 | fn += ".vcs"; |
3128 | FileStorage storage( cal, fn, new VCalFormat ); | 3127 | FileStorage storage( cal, fn, new VCalFormat ); |
3129 | storage.save(); | 3128 | storage.save(); |
3130 | } else { | 3129 | } else { |
3131 | fn += ".ics"; | 3130 | fn += ".ics"; |
3132 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3131 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3133 | storage.save(); | 3132 | storage.save(); |
3134 | } | 3133 | } |
3135 | delete cal; | 3134 | delete cal; |
3136 | mes = i18n("KO/Pi: Ready for beaming"); | 3135 | mes = i18n("KO/Pi: Ready for beaming"); |
3137 | topLevelWidget()->setCaption(mes); | 3136 | topLevelWidget()->setCaption(mes); |
3138 | KApplication::convert2latin1( fn ); | 3137 | KApplication::convert2latin1( fn ); |
3139 | #ifndef DESKTOP_VERSION | 3138 | #ifndef DESKTOP_VERSION |
3140 | Ir *ir = new Ir( this ); | 3139 | Ir *ir = new Ir( this ); |
3141 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3140 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3142 | ir->send( fn, description, "text/x-vCalendar" ); | 3141 | ir->send( fn, description, "text/x-vCalendar" ); |
3143 | #endif | 3142 | #endif |
3144 | } | 3143 | } |
3145 | } | 3144 | } |
3146 | 3145 | ||
3147 | #ifndef DESKTOP_VERSION | 3146 | #ifndef DESKTOP_VERSION |
3148 | void CalendarView::beamDone( Ir *ir ) | 3147 | void CalendarView::beamDone( Ir *ir ) |
3149 | { | 3148 | { |
3150 | delete ir; | 3149 | delete ir; |
3151 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3150 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3152 | topLevelWidget()->raise(); | 3151 | topLevelWidget()->raise(); |
3153 | } | 3152 | } |
3154 | #else | 3153 | #else |
3155 | void CalendarView::beamDone( Ir *){;} | 3154 | void CalendarView::beamDone( Ir *){;} |
3156 | #endif | 3155 | #endif |
3157 | void CalendarView::moveIncidence(Incidence * inc ) | 3156 | void CalendarView::moveIncidence(Incidence * inc ) |
3158 | { | 3157 | { |
3159 | if ( !inc ) return; | 3158 | if ( !inc ) return; |
3160 | showDatePickerPopup(); | 3159 | showDatePickerPopup(); |
3161 | mDatePickerMode = 2; | 3160 | mDatePickerMode = 2; |
3162 | mMoveIncidence = inc ; | 3161 | mMoveIncidence = inc ; |
3163 | QDate da; | 3162 | QDate da; |
3164 | if ( mMoveIncidence->typeID() == todoID ) { | 3163 | if ( mMoveIncidence->typeID() == todoID ) { |
3165 | Todo * to = (Todo *) mMoveIncidence; | 3164 | Todo * to = (Todo *) mMoveIncidence; |
3166 | if ( to->hasDueDate() ) | 3165 | if ( to->hasDueDate() ) |
3167 | da = to->dtDue().date(); | 3166 | da = to->dtDue().date(); |
3168 | else | 3167 | else |
3169 | da = QDate::currentDate(); | 3168 | da = QDate::currentDate(); |
3170 | } else { | 3169 | } else { |
3171 | da = mMoveIncidence->dtStart().date(); | 3170 | da = mMoveIncidence->dtStart().date(); |
3172 | } | 3171 | } |
3173 | //PENDING set date for recurring incidence to date of recurrence | 3172 | //PENDING set date for recurring incidence to date of recurrence |
3174 | //mMoveIncidenceOldDate; | 3173 | //mMoveIncidenceOldDate; |
3175 | mDatePicker->setDate( da ); | 3174 | mDatePicker->setDate( da ); |
3176 | } | 3175 | } |
3177 | void CalendarView::showDatePickerPopup() | 3176 | void CalendarView::showDatePickerPopup() |
3178 | { | 3177 | { |
3179 | if ( mDateFrame->isVisible() ) | 3178 | if ( mDateFrame->isVisible() ) |
3180 | mDateFrame->hide(); | 3179 | mDateFrame->hide(); |
3181 | else { | 3180 | else { |
3182 | int offX = 0, offY = 0; | 3181 | int offX = 0, offY = 0; |
3183 | #ifdef DESKTOP_VERSION | 3182 | #ifdef DESKTOP_VERSION |
3184 | int w =mDatePicker->sizeHint().width() ; | 3183 | int w =mDatePicker->sizeHint().width() ; |
3185 | int h = mDatePicker->sizeHint().height() ; | 3184 | int h = mDatePicker->sizeHint().height() ; |
3186 | int dw = topLevelWidget()->width(); | 3185 | int dw = topLevelWidget()->width(); |
3187 | int dh = topLevelWidget()->height(); | 3186 | int dh = topLevelWidget()->height(); |
3188 | offX = topLevelWidget()->x(); | 3187 | offX = topLevelWidget()->x(); |
3189 | offY = topLevelWidget()->y(); | 3188 | offY = topLevelWidget()->y(); |
3190 | #else | 3189 | #else |
3191 | int w =mDatePicker->sizeHint().width() ; | 3190 | int w =mDatePicker->sizeHint().width() ; |
3192 | int h = mDatePicker->sizeHint().height() ; | 3191 | int h = mDatePicker->sizeHint().height() ; |
3193 | int dw = QApplication::desktop()->width(); | 3192 | int dw = QApplication::desktop()->width(); |
3194 | int dh = QApplication::desktop()->height(); | 3193 | int dh = QApplication::desktop()->height(); |
3195 | #endif | 3194 | #endif |
3196 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3195 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3197 | mDateFrame->show(); | 3196 | mDateFrame->show(); |
3198 | } | 3197 | } |
3199 | } | 3198 | } |
3200 | void CalendarView::showDatePicker( ) | 3199 | void CalendarView::showDatePicker( ) |
3201 | { | 3200 | { |
3202 | showDatePickerPopup(); | 3201 | showDatePickerPopup(); |
3203 | mDatePickerMode = 1; | 3202 | mDatePickerMode = 1; |
3204 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3203 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3205 | } | 3204 | } |
3206 | 3205 | ||
3207 | void CalendarView::showEventEditor() | 3206 | void CalendarView::showEventEditor() |
3208 | { | 3207 | { |
3209 | #ifdef DESKTOP_VERSION | 3208 | #ifdef DESKTOP_VERSION |
3210 | int x,y,w,h; | 3209 | int x,y,w,h; |
3211 | x = mEventEditor->geometry().x(); | 3210 | x = mEventEditor->geometry().x(); |
3212 | y = mEventEditor->geometry().y(); | 3211 | y = mEventEditor->geometry().y(); |
3213 | w = mEventEditor->width(); | 3212 | w = mEventEditor->width(); |
3214 | h = mEventEditor->height(); | 3213 | h = mEventEditor->height(); |
3215 | mEventEditor->show(); | 3214 | mEventEditor->show(); |
3216 | mEventEditor->setGeometry(x,y,w,h); | 3215 | mEventEditor->setGeometry(x,y,w,h); |
3217 | #else | 3216 | #else |
3218 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3217 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3219 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3218 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3220 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3219 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3221 | qApp->processEvents(); | 3220 | qApp->processEvents(); |
3222 | delete mEventEditor; | 3221 | delete mEventEditor; |
3223 | mEventEditor = mDialogManager->getEventEditor(); | 3222 | mEventEditor = mDialogManager->getEventEditor(); |
3224 | topLevelWidget()->setCaption( i18n("") ); | 3223 | topLevelWidget()->setCaption( i18n("") ); |
3225 | } | 3224 | } |
3226 | mEventEditor->showMaximized(); | 3225 | mEventEditor->showMaximized(); |
3227 | #endif | 3226 | #endif |
3228 | } | 3227 | } |
3229 | void CalendarView::showTodoEditor() | 3228 | void CalendarView::showTodoEditor() |
3230 | { | 3229 | { |
3231 | #ifdef DESKTOP_VERSION | 3230 | #ifdef DESKTOP_VERSION |
3232 | int x,y,w,h; | 3231 | int x,y,w,h; |
3233 | x = mTodoEditor->geometry().x(); | 3232 | x = mTodoEditor->geometry().x(); |
3234 | y = mTodoEditor->geometry().y(); | 3233 | y = mTodoEditor->geometry().y(); |
3235 | w = mTodoEditor->width(); | 3234 | w = mTodoEditor->width(); |
3236 | h = mTodoEditor->height(); | 3235 | h = mTodoEditor->height(); |
3237 | mTodoEditor->show(); | 3236 | mTodoEditor->show(); |
3238 | mTodoEditor->setGeometry(x,y,w,h); | 3237 | mTodoEditor->setGeometry(x,y,w,h); |
3239 | #else | 3238 | #else |
3240 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3239 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3241 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3240 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3242 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3241 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3243 | qApp->processEvents(); | 3242 | qApp->processEvents(); |
3244 | delete mTodoEditor; | 3243 | delete mTodoEditor; |
3245 | mTodoEditor = mDialogManager->getTodoEditor(); | 3244 | mTodoEditor = mDialogManager->getTodoEditor(); |
3246 | topLevelWidget()->setCaption( i18n("") ); | 3245 | topLevelWidget()->setCaption( i18n("") ); |
3247 | } | 3246 | } |
3248 | mTodoEditor->showMaximized(); | 3247 | mTodoEditor->showMaximized(); |
3249 | #endif | 3248 | #endif |
3250 | } | 3249 | } |
3251 | 3250 | ||
3252 | void CalendarView::cloneIncidence() | 3251 | void CalendarView::cloneIncidence() |
3253 | { | 3252 | { |
3254 | Incidence *incidence = currentSelection(); | 3253 | Incidence *incidence = currentSelection(); |
3255 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3254 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3256 | if ( incidence ) { | 3255 | if ( incidence ) { |
3257 | cloneIncidence(incidence); | 3256 | cloneIncidence(incidence); |
3258 | } | 3257 | } |
3259 | } | 3258 | } |
3260 | void CalendarView::moveIncidence() | 3259 | void CalendarView::moveIncidence() |
3261 | { | 3260 | { |
3262 | Incidence *incidence = currentSelection(); | 3261 | Incidence *incidence = currentSelection(); |
3263 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3262 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3264 | if ( incidence ) { | 3263 | if ( incidence ) { |
3265 | moveIncidence(incidence); | 3264 | moveIncidence(incidence); |
3266 | } | 3265 | } |
3267 | } | 3266 | } |
3268 | void CalendarView::beamIncidence() | 3267 | void CalendarView::beamIncidence() |
3269 | { | 3268 | { |
3270 | Incidence *incidence = currentSelection(); | 3269 | Incidence *incidence = currentSelection(); |
3271 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3270 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3272 | if ( incidence ) { | 3271 | if ( incidence ) { |
3273 | beamIncidence(incidence); | 3272 | beamIncidence(incidence); |
3274 | } | 3273 | } |
3275 | } | 3274 | } |
3276 | void CalendarView::toggleCancelIncidence() | 3275 | void CalendarView::toggleCancelIncidence() |
3277 | { | 3276 | { |
3278 | Incidence *incidence = currentSelection(); | 3277 | Incidence *incidence = currentSelection(); |
3279 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3278 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3280 | if ( incidence ) { | 3279 | if ( incidence ) { |
3281 | cancelIncidence(incidence); | 3280 | cancelIncidence(incidence); |
3282 | } | 3281 | } |
3283 | } | 3282 | } |
3284 | 3283 | ||
3285 | 3284 | ||
3286 | void CalendarView::cancelIncidence(Incidence * inc ) | 3285 | void CalendarView::cancelIncidence(Incidence * inc ) |
3287 | { | 3286 | { |
3288 | inc->setCancelled( ! inc->cancelled() ); | 3287 | inc->setCancelled( ! inc->cancelled() ); |
3289 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3288 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3290 | updateView(); | 3289 | updateView(); |
3291 | } | 3290 | } |
3292 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3291 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3293 | { | 3292 | { |
3294 | Incidence * newInc = orgInc->clone(); | 3293 | Incidence * newInc = orgInc->clone(); |
3295 | newInc->recreate(); | 3294 | newInc->recreate(); |
3296 | 3295 | ||
3297 | if ( newInc->typeID() == todoID ) { | 3296 | if ( newInc->typeID() == todoID ) { |
3298 | Todo* t = (Todo*) newInc; | 3297 | Todo* t = (Todo*) newInc; |
3299 | bool cloneSub = false; | 3298 | bool cloneSub = false; |
3300 | if ( orgInc->relations().count() ) { | 3299 | if ( orgInc->relations().count() ) { |
3301 | int result = KMessageBox::warningYesNoCancel(this, | 3300 | int result = KMessageBox::warningYesNoCancel(this, |
3302 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), | 3301 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), |
3303 | i18n("Todo has subtodos"), | 3302 | i18n("Todo has subtodos"), |
3304 | i18n("Yes"), | 3303 | i18n("Yes"), |
3305 | i18n("No")); | 3304 | i18n("No")); |
3306 | 3305 | ||
3307 | if ( result == KMessageBox::Cancel ) { | 3306 | if ( result == KMessageBox::Cancel ) { |
3308 | delete t; | 3307 | delete t; |
3309 | return; | 3308 | return; |
3310 | } | 3309 | } |
3311 | if (result == KMessageBox::Yes) cloneSub = true; | 3310 | if (result == KMessageBox::Yes) cloneSub = true; |
3312 | } | 3311 | } |
3313 | showTodoEditor(); | 3312 | showTodoEditor(); |
3314 | mTodoEditor->editTodo( t ); | 3313 | mTodoEditor->editTodo( t ); |
3315 | if ( mTodoEditor->exec() ) { | 3314 | if ( mTodoEditor->exec() ) { |
3316 | if ( cloneSub ) { | 3315 | if ( cloneSub ) { |
3317 | orgInc->cloneRelations( t ); | 3316 | orgInc->cloneRelations( t ); |
3318 | mCalendar->addIncidenceBranch( t ); | 3317 | mCalendar->addIncidenceBranch( t ); |
3319 | updateView(); | 3318 | updateView(); |
3320 | 3319 | ||
3321 | } else { | 3320 | } else { |
3322 | mCalendar->addTodo( t ); | 3321 | mCalendar->addTodo( t ); |
3323 | updateView(); | 3322 | updateView(); |
3324 | } | 3323 | } |
3325 | } else { | 3324 | } else { |
3326 | delete t; | 3325 | delete t; |
3327 | } | 3326 | } |
3328 | } | 3327 | } |
3329 | else if ( newInc->typeID() == eventID ) { | 3328 | else if ( newInc->typeID() == eventID ) { |
3330 | Event* e = (Event*) newInc; | 3329 | Event* e = (Event*) newInc; |
3331 | showEventEditor(); | 3330 | showEventEditor(); |
3332 | mEventEditor->editEvent( e ); | 3331 | mEventEditor->editEvent( e ); |
3333 | if ( mEventEditor->exec() ) { | 3332 | if ( mEventEditor->exec() ) { |
3334 | mCalendar->addEvent( e ); | 3333 | mCalendar->addEvent( e ); |
3335 | updateView(); | 3334 | updateView(); |
3336 | } else { | 3335 | } else { |
3337 | delete e; | 3336 | delete e; |
3338 | } | 3337 | } |
3339 | } if ( newInc->typeID() == journalID ) { | 3338 | } if ( newInc->typeID() == journalID ) { |
3340 | mCalendar->addJournal( (Journal*) newInc ); | 3339 | mCalendar->addJournal( (Journal*) newInc ); |
3341 | editJournal( (Journal*) newInc ); | 3340 | editJournal( (Journal*) newInc ); |
3342 | } | 3341 | } |
3343 | setActiveWindow(); | 3342 | setActiveWindow(); |
3344 | } | 3343 | } |
3345 | 3344 | ||
3346 | void CalendarView::newEvent() | 3345 | void CalendarView::newEvent() |
3347 | { | 3346 | { |
3348 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3347 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3349 | KOAgendaView *aView = mViewManager->agendaView(); | 3348 | KOAgendaView *aView = mViewManager->agendaView(); |
3350 | if (aView) { | 3349 | if (aView) { |
3351 | if (aView->selectionStart().isValid()) { | 3350 | if (aView->selectionStart().isValid()) { |
3352 | if (aView->selectedIsAllDay()) { | 3351 | if (aView->selectedIsAllDay()) { |
3353 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3352 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3354 | } else { | 3353 | } else { |
3355 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3354 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3356 | } | 3355 | } |
3357 | return; | 3356 | return; |
3358 | } | 3357 | } |
3359 | } | 3358 | } |
3360 | 3359 | ||
3361 | QDate date = mNavigator->selectedDates().first(); | 3360 | QDate date = mNavigator->selectedDates().first(); |
3362 | QDateTime current = QDateTime::currentDateTime(); | 3361 | QDateTime current = QDateTime::currentDateTime(); |
3363 | if ( date <= current.date() ) { | 3362 | if ( date <= current.date() ) { |
3364 | int hour = current.time().hour() +1; | 3363 | int hour = current.time().hour() +1; |
3365 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3364 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3366 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3365 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3367 | } else | 3366 | } else |
3368 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3367 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3369 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3368 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3370 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3369 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3371 | } | 3370 | } |
3372 | 3371 | ||
3373 | void CalendarView::newEvent(QDateTime fh) | 3372 | void CalendarView::newEvent(QDateTime fh) |
3374 | { | 3373 | { |
3375 | newEvent(fh, | 3374 | newEvent(fh, |
3376 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3375 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3377 | } | 3376 | } |
3378 | 3377 | ||
3379 | void CalendarView::newEvent(QDate dt) | 3378 | void CalendarView::newEvent(QDate dt) |
3380 | { | 3379 | { |
3381 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3380 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3382 | QDateTime(dt, QTime(0,0,0)), true); | 3381 | QDateTime(dt, QTime(0,0,0)), true); |
3383 | } | 3382 | } |
3384 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3383 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3385 | { | 3384 | { |
3386 | newEvent(fromHint, toHint, false); | 3385 | newEvent(fromHint, toHint, false); |
3387 | } | 3386 | } |
3388 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3387 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3389 | { | 3388 | { |
3390 | 3389 | ||
3391 | showEventEditor(); | 3390 | showEventEditor(); |
3392 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3391 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3393 | if ( mFilterView->filtersEnabled() ) { | 3392 | if ( mFilterView->filtersEnabled() ) { |
3394 | CalFilter *filter = mFilterView->selectedFilter(); | 3393 | CalFilter *filter = mFilterView->selectedFilter(); |
3395 | if (filter && filter->showCategories()) { | 3394 | if (filter && filter->showCategories()) { |
3396 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3395 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3397 | } | 3396 | } |
3398 | if ( filter ) | 3397 | if ( filter ) |
3399 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3398 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3400 | } | 3399 | } |
3401 | mEventEditor->exec(); | 3400 | mEventEditor->exec(); |
3402 | setActiveWindow(); | 3401 | setActiveWindow(); |
3403 | } | 3402 | } |
3404 | void CalendarView::todoAdded(Todo * t) | 3403 | void CalendarView::todoAdded(Todo * t) |
3405 | { | 3404 | { |
3406 | 3405 | ||
3407 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3406 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3408 | updateTodoViews(); | 3407 | updateTodoViews(); |
3409 | } | 3408 | } |
3410 | void CalendarView::todoChanged(Todo * t) | 3409 | void CalendarView::todoChanged(Todo * t) |
3411 | { | 3410 | { |
3412 | emit todoModified( t, 4 ); | 3411 | emit todoModified( t, 4 ); |
3413 | // updateTodoViews(); | 3412 | // updateTodoViews(); |
3414 | } | 3413 | } |
3415 | void CalendarView::todoToBeDeleted(Todo *) | 3414 | void CalendarView::todoToBeDeleted(Todo *) |
3416 | { | 3415 | { |
3417 | //qDebug("todoToBeDeleted(Todo *) "); | 3416 | //qDebug("todoToBeDeleted(Todo *) "); |
3418 | updateTodoViews(); | 3417 | updateTodoViews(); |
3419 | } | 3418 | } |
3420 | void CalendarView::todoDeleted() | 3419 | void CalendarView::todoDeleted() |
3421 | { | 3420 | { |
3422 | //qDebug(" todoDeleted()"); | 3421 | //qDebug(" todoDeleted()"); |
3423 | updateTodoViews(); | 3422 | updateTodoViews(); |
3424 | } | 3423 | } |
3425 | 3424 | ||
3426 | 3425 | ||
3427 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3426 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3428 | { | 3427 | { |
3429 | showTodoEditor(); | 3428 | showTodoEditor(); |
3430 | mTodoEditor->newTodo(dt,0,allday); | 3429 | mTodoEditor->newTodo(dt,0,allday); |
3431 | if ( mFilterView->filtersEnabled() ) { | 3430 | if ( mFilterView->filtersEnabled() ) { |
3432 | CalFilter *filter = mFilterView->selectedFilter(); | 3431 | CalFilter *filter = mFilterView->selectedFilter(); |
3433 | if (filter && filter->showCategories()) { | 3432 | if (filter && filter->showCategories()) { |
3434 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3433 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3435 | } | 3434 | } |
3436 | if ( filter ) | 3435 | if ( filter ) |
3437 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3436 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3438 | } | 3437 | } |
3439 | mTodoEditor->exec(); | 3438 | mTodoEditor->exec(); |
3440 | setActiveWindow(); | 3439 | setActiveWindow(); |
3441 | } | 3440 | } |
3442 | 3441 | ||
3443 | void CalendarView::newTodo() | 3442 | void CalendarView::newTodo() |
3444 | { | 3443 | { |
3445 | newTodoDateTime( QDateTime(),true ); | 3444 | newTodoDateTime( QDateTime(),true ); |
3446 | } | 3445 | } |
3447 | 3446 | ||
3448 | void CalendarView::newSubTodo() | 3447 | void CalendarView::newSubTodo() |
3449 | { | 3448 | { |
3450 | Todo *todo = selectedTodo(); | 3449 | Todo *todo = selectedTodo(); |
3451 | if ( todo ) newSubTodo( todo ); | 3450 | if ( todo ) newSubTodo( todo ); |
3452 | } | 3451 | } |
3453 | 3452 | ||
3454 | void CalendarView::newSubTodo(Todo *parentEvent) | 3453 | void CalendarView::newSubTodo(Todo *parentEvent) |
3455 | { | 3454 | { |
3456 | 3455 | ||
3457 | showTodoEditor(); | 3456 | showTodoEditor(); |
3458 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3457 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3459 | mTodoEditor->exec(); | 3458 | mTodoEditor->exec(); |
3460 | setActiveWindow(); | 3459 | setActiveWindow(); |
3461 | } | 3460 | } |
3462 | 3461 | ||
3463 | void CalendarView::newFloatingEvent() | 3462 | void CalendarView::newFloatingEvent() |
3464 | { | 3463 | { |
3465 | DateList tmpList = mNavigator->selectedDates(); | 3464 | DateList tmpList = mNavigator->selectedDates(); |
3466 | QDate date = tmpList.first(); | 3465 | QDate date = tmpList.first(); |
3467 | 3466 | ||
3468 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3467 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3469 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3468 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3470 | } | 3469 | } |
3471 | 3470 | ||
3472 | 3471 | ||
3473 | void CalendarView::editEvent( Event *event ) | 3472 | void CalendarView::editEvent( Event *event ) |
3474 | { | 3473 | { |
3475 | 3474 | ||
3476 | if ( !event ) return; | 3475 | if ( !event ) return; |
3477 | if ( event->isReadOnly() ) { | 3476 | if ( event->isReadOnly() ) { |
3478 | showEvent( event ); | 3477 | showEvent( event ); |
3479 | return; | 3478 | return; |
3480 | } | 3479 | } |
3481 | showEventEditor(); | 3480 | showEventEditor(); |
3482 | mEventEditor->editEvent( event , mFlagEditDescription); | 3481 | mEventEditor->editEvent( event , mFlagEditDescription); |
3483 | mEventEditor->exec(); | 3482 | mEventEditor->exec(); |
3484 | setActiveWindow(); | 3483 | setActiveWindow(); |
3485 | 3484 | ||
3486 | } | 3485 | } |
3487 | void CalendarView::editJournal( Journal *jour ) | 3486 | void CalendarView::editJournal( Journal *jour ) |
3488 | { | 3487 | { |
3489 | if ( !jour ) return; | 3488 | if ( !jour ) return; |
3490 | mDialogManager->hideSearchDialog(); | 3489 | mDialogManager->hideSearchDialog(); |
3491 | mViewManager->showJournalView(); | 3490 | mViewManager->showJournalView(); |
3492 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3491 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3493 | } | 3492 | } |
3494 | void CalendarView::editTodo( Todo *todo ) | 3493 | void CalendarView::editTodo( Todo *todo ) |
3495 | { | 3494 | { |
3496 | if ( !todo ) return; | 3495 | if ( !todo ) return; |
3497 | 3496 | ||
3498 | if ( todo->isReadOnly() ) { | 3497 | if ( todo->isReadOnly() ) { |
3499 | showTodo( todo ); | 3498 | showTodo( todo ); |
3500 | return; | 3499 | return; |
3501 | } | 3500 | } |
3502 | showTodoEditor(); | 3501 | showTodoEditor(); |
3503 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3502 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3504 | mTodoEditor->exec(); | 3503 | mTodoEditor->exec(); |
3505 | setActiveWindow(); | 3504 | setActiveWindow(); |
3506 | 3505 | ||
3507 | } | 3506 | } |
3508 | 3507 | ||
3509 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3508 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3510 | { | 3509 | { |
3511 | if ( !mEventViewerDialog ) { | 3510 | if ( !mEventViewerDialog ) { |
3512 | mEventViewerDialog = new KOEventViewerDialog(0); | 3511 | mEventViewerDialog = new KOEventViewerDialog(0); |
3513 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3512 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3514 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3513 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3515 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3514 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3516 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3515 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3517 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3516 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3518 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3517 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3519 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3518 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3520 | this, SLOT( slotViewerClosed() ) ); | 3519 | this, SLOT( slotViewerClosed() ) ); |
3521 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3520 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3522 | this, SLOT( todoChanged(Todo *) ) ); | 3521 | this, SLOT( todoChanged(Todo *) ) ); |
3523 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3522 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3524 | mEventViewerDialog->resize( 640, 480 ); | 3523 | mEventViewerDialog->resize( 640, 480 ); |
3525 | 3524 | ||
3526 | } | 3525 | } |
3527 | return mEventViewerDialog; | 3526 | return mEventViewerDialog; |
3528 | } | 3527 | } |
3529 | void CalendarView::showEvent(Event *event) | 3528 | void CalendarView::showEvent(Event *event) |
3530 | { | 3529 | { |
3531 | getEventViewerDialog()->setEvent(event); | 3530 | getEventViewerDialog()->setEvent(event); |
3532 | getEventViewerDialog()->showMe(); | 3531 | getEventViewerDialog()->showMe(); |
3533 | } | 3532 | } |
3534 | 3533 | ||
3535 | void CalendarView::showTodo(Todo *event) | 3534 | void CalendarView::showTodo(Todo *event) |
3536 | { | 3535 | { |
3537 | getEventViewerDialog()->setTodo(event); | 3536 | getEventViewerDialog()->setTodo(event); |
3538 | getEventViewerDialog()->showMe(); | 3537 | getEventViewerDialog()->showMe(); |
3539 | } | 3538 | } |
3540 | void CalendarView::showJournal( Journal *jour ) | 3539 | void CalendarView::showJournal( Journal *jour ) |
3541 | { | 3540 | { |
3542 | getEventViewerDialog()->setJournal(jour); | 3541 | getEventViewerDialog()->setJournal(jour); |
3543 | getEventViewerDialog()->showMe(); | 3542 | getEventViewerDialog()->showMe(); |
3544 | 3543 | ||
3545 | } | 3544 | } |
3546 | // void CalendarView::todoModified (Todo *event, int changed) | 3545 | // void CalendarView::todoModified (Todo *event, int changed) |
3547 | // { | 3546 | // { |
3548 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3547 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3549 | // // kdDebug() << "Todo modified and open" << endl; | 3548 | // // kdDebug() << "Todo modified and open" << endl; |
3550 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3549 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3551 | // // temp->modified (changed); | 3550 | // // temp->modified (changed); |
3552 | 3551 | ||
3553 | // // } | 3552 | // // } |
3554 | 3553 | ||
3555 | // mViewManager->updateView(); | 3554 | // mViewManager->updateView(); |
3556 | // } | 3555 | // } |
3557 | 3556 | ||
3558 | void CalendarView::appointment_show() | 3557 | void CalendarView::appointment_show() |
3559 | { | 3558 | { |
3560 | Event *anEvent = 0; | 3559 | Event *anEvent = 0; |
3561 | 3560 | ||
3562 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3561 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3563 | 3562 | ||
3564 | if (mViewManager->currentView()->isEventView()) { | 3563 | if (mViewManager->currentView()->isEventView()) { |
3565 | if ( incidence && incidence->typeID() == eventID ) { | 3564 | if ( incidence && incidence->typeID() == eventID ) { |
3566 | anEvent = static_cast<Event *>(incidence); | 3565 | anEvent = static_cast<Event *>(incidence); |
3567 | } | 3566 | } |
3568 | } | 3567 | } |
3569 | 3568 | ||
3570 | if (!anEvent) { | 3569 | if (!anEvent) { |
3571 | KNotifyClient::beep(); | 3570 | KNotifyClient::beep(); |
3572 | return; | 3571 | return; |
3573 | } | 3572 | } |
3574 | 3573 | ||
3575 | showEvent(anEvent); | 3574 | showEvent(anEvent); |
3576 | } | 3575 | } |
3577 | 3576 | ||
3578 | void CalendarView::appointment_edit() | 3577 | void CalendarView::appointment_edit() |
3579 | { | 3578 | { |
3580 | Event *anEvent = 0; | 3579 | Event *anEvent = 0; |
3581 | 3580 | ||
3582 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3581 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3583 | 3582 | ||
3584 | if (mViewManager->currentView()->isEventView()) { | 3583 | if (mViewManager->currentView()->isEventView()) { |
3585 | if ( incidence && incidence->typeID() == eventID ) { | 3584 | if ( incidence && incidence->typeID() == eventID ) { |
3586 | anEvent = static_cast<Event *>(incidence); | 3585 | anEvent = static_cast<Event *>(incidence); |
3587 | } | 3586 | } |
3588 | } | 3587 | } |
3589 | 3588 | ||
3590 | if (!anEvent) { | 3589 | if (!anEvent) { |
3591 | KNotifyClient::beep(); | 3590 | KNotifyClient::beep(); |
3592 | return; | 3591 | return; |
3593 | } | 3592 | } |
3594 | 3593 | ||
3595 | editEvent(anEvent); | 3594 | editEvent(anEvent); |
3596 | } | 3595 | } |
3597 | 3596 | ||
3598 | void CalendarView::appointment_delete() | 3597 | void CalendarView::appointment_delete() |
3599 | { | 3598 | { |
3600 | Event *anEvent = 0; | 3599 | Event *anEvent = 0; |
3601 | 3600 | ||
3602 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3601 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3603 | 3602 | ||
3604 | if (mViewManager->currentView()->isEventView()) { | 3603 | if (mViewManager->currentView()->isEventView()) { |
3605 | if ( incidence && incidence->typeID() == eventID ) { | 3604 | if ( incidence && incidence->typeID() == eventID ) { |
3606 | anEvent = static_cast<Event *>(incidence); | 3605 | anEvent = static_cast<Event *>(incidence); |
3607 | } | 3606 | } |
3608 | } | 3607 | } |
3609 | 3608 | ||
3610 | if (!anEvent) { | 3609 | if (!anEvent) { |
3611 | KNotifyClient::beep(); | 3610 | KNotifyClient::beep(); |
3612 | return; | 3611 | return; |
3613 | } | 3612 | } |
3614 | 3613 | ||
3615 | deleteEvent(anEvent); | 3614 | deleteEvent(anEvent); |
3616 | } | 3615 | } |
3617 | 3616 | ||
3618 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3617 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3619 | { | 3618 | { |
3620 | if (!sub) return; | 3619 | if (!sub) return; |
3621 | if ( sub->relatedTo() == parent ) | 3620 | if ( sub->relatedTo() == parent ) |
3622 | return; | 3621 | return; |
3623 | sub->setRelatedTo(parent); | 3622 | sub->setRelatedTo(parent); |
3624 | sub->updated(); | 3623 | sub->updated(); |
3625 | setModified(true); | 3624 | setModified(true); |
3626 | updateView(); | 3625 | updateView(); |
3627 | } | 3626 | } |
3628 | void CalendarView::todo_unsub(Todo *anTodo ) | 3627 | void CalendarView::todo_unsub(Todo *anTodo ) |
3629 | { | 3628 | { |
3630 | todo_resub( 0, anTodo ); | 3629 | todo_resub( 0, anTodo ); |
3631 | } | 3630 | } |
3632 | 3631 | ||
3633 | void CalendarView::deleteTodo(Todo *todo) | 3632 | void CalendarView::deleteTodo(Todo *todo) |
3634 | { | 3633 | { |
3635 | if (!todo) { | 3634 | if (!todo) { |
3636 | KNotifyClient::beep(); | 3635 | KNotifyClient::beep(); |
3637 | return; | 3636 | return; |
3638 | } | 3637 | } |
3639 | if (KOPrefs::instance()->mConfirm) { | 3638 | if (KOPrefs::instance()->mConfirm) { |
3640 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3639 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3641 | if (!todo->relations().isEmpty()) { | 3640 | if (!todo->relations().isEmpty()) { |
3642 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3641 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3643 | 3642 | ||
3644 | } | 3643 | } |
3645 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3644 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3646 | case KMessageBox::Continue: // OK | 3645 | case KMessageBox::Continue: // OK |
3647 | bool deleteT = false; | 3646 | bool deleteT = false; |
3648 | if (!todo->relations().isEmpty()) { | 3647 | if (!todo->relations().isEmpty()) { |
3649 | deleteT = removeCompletedSubTodos( todo ); | 3648 | deleteT = removeCompletedSubTodos( todo ); |
3650 | } | 3649 | } |
3651 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3650 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3652 | if ( !deleteT ) { | 3651 | if ( !deleteT ) { |
3653 | checkExternalId( todo ); | 3652 | checkExternalId( todo ); |
3654 | calendar()->deleteTodo(todo); | 3653 | calendar()->deleteTodo(todo); |
3655 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3654 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3656 | updateView(); | 3655 | updateView(); |
3657 | } | 3656 | } |
3658 | break; | 3657 | break; |
3659 | } // switch | 3658 | } // switch |
3660 | } else { | 3659 | } else { |
3661 | checkExternalId( todo ); | 3660 | checkExternalId( todo ); |
3662 | mCalendar->deleteTodo(todo); | 3661 | mCalendar->deleteTodo(todo); |
3663 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3662 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3664 | updateView(); | 3663 | updateView(); |
3665 | } | 3664 | } |
3666 | 3665 | ||
3667 | emit updateSearchDialog(); | 3666 | emit updateSearchDialog(); |
3668 | } | 3667 | } |
3669 | void CalendarView::deleteJournal(Journal *jour) | 3668 | void CalendarView::deleteJournal(Journal *jour) |
3670 | { | 3669 | { |
3671 | if (!jour) { | 3670 | if (!jour) { |
3672 | KNotifyClient::beep(); | 3671 | KNotifyClient::beep(); |
3673 | return; | 3672 | return; |
3674 | } | 3673 | } |
3675 | if (KOPrefs::instance()->mConfirm) { | 3674 | if (KOPrefs::instance()->mConfirm) { |
3676 | 3675 | ||
3677 | QString des; | 3676 | QString des; |
3678 | if ( !jour->summary().isEmpty() ) { | 3677 | if ( !jour->summary().isEmpty() ) { |
3679 | des = jour->summary(); | 3678 | des = jour->summary(); |
3680 | } else { | 3679 | } else { |
3681 | des = jour->description().left(30); | 3680 | des = jour->description().left(30); |
3682 | des = des.simplifyWhiteSpace (); | 3681 | des = des.simplifyWhiteSpace (); |
3683 | des.replace (QRegExp ("\\n"),"" ); | 3682 | des.replace (QRegExp ("\\n"),"" ); |
3684 | des.replace (QRegExp ("\\r"),"" ); | 3683 | des.replace (QRegExp ("\\r"),"" ); |
3685 | } | 3684 | } |
3686 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 3685 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3687 | case KMessageBox::Continue: // OK | 3686 | case KMessageBox::Continue: // OK |
3688 | calendar()->deleteJournal(jour); | 3687 | calendar()->deleteJournal(jour); |
3689 | updateView(); | 3688 | updateView(); |
3690 | break; | 3689 | break; |
3691 | } // switch | 3690 | } // switch |
3692 | } else { | 3691 | } else { |
3693 | calendar()->deleteJournal(jour);; | 3692 | calendar()->deleteJournal(jour);; |
3694 | updateView(); | 3693 | updateView(); |
3695 | } | 3694 | } |
3696 | emit updateSearchDialog(); | 3695 | emit updateSearchDialog(); |
3697 | } | 3696 | } |
3698 | 3697 | ||
3699 | void CalendarView::deleteEvent(Event *anEvent) | 3698 | void CalendarView::deleteEvent(Event *anEvent) |
3700 | { | 3699 | { |
3701 | if (!anEvent) { | 3700 | if (!anEvent) { |
3702 | KNotifyClient::beep(); | 3701 | KNotifyClient::beep(); |
3703 | return; | 3702 | return; |
3704 | } | 3703 | } |
3705 | 3704 | ||
3706 | if (anEvent->recurrence()->doesRecur()) { | 3705 | if (anEvent->recurrence()->doesRecur()) { |
3707 | QDate itemDate = mViewManager->currentSelectionDate(); | 3706 | QDate itemDate = mViewManager->currentSelectionDate(); |
3708 | int km; | 3707 | int km; |
3709 | if (!itemDate.isValid()) { | 3708 | if (!itemDate.isValid()) { |
3710 | //kdDebug() << "Date Not Valid" << endl; | 3709 | //kdDebug() << "Date Not Valid" << endl; |
3711 | if (KOPrefs::instance()->mConfirm) { | 3710 | if (KOPrefs::instance()->mConfirm) { |
3712 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3711 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3713 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3712 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3714 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3713 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3715 | if ( km == KMessageBox::Continue ) | 3714 | if ( km == KMessageBox::Continue ) |
3716 | km = KMessageBox::No; // No = all below | 3715 | km = KMessageBox::No; // No = all below |
3717 | } else | 3716 | } else |
3718 | km = KMessageBox::No; | 3717 | km = KMessageBox::No; |
3719 | } else { | 3718 | } else { |
3720 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3719 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3721 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3720 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3722 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3721 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3723 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3722 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3724 | i18n("All")); | 3723 | i18n("All")); |
3725 | } | 3724 | } |
3726 | switch(km) { | 3725 | switch(km) { |
3727 | 3726 | ||
3728 | case KMessageBox::No: // Continue // all | 3727 | case KMessageBox::No: // Continue // all |
3729 | //qDebug("KMessageBox::No "); | 3728 | //qDebug("KMessageBox::No "); |
3730 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3729 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3731 | schedule(Scheduler::Cancel,anEvent); | 3730 | schedule(Scheduler::Cancel,anEvent); |
3732 | 3731 | ||
3733 | checkExternalId( anEvent); | 3732 | checkExternalId( anEvent); |
3734 | mCalendar->deleteEvent(anEvent); | 3733 | mCalendar->deleteEvent(anEvent); |
3735 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3734 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3736 | break; | 3735 | break; |
3737 | 3736 | ||
3738 | // Disabled because it does not work | 3737 | // Disabled because it does not work |
3739 | //#if 0 | 3738 | //#if 0 |
3740 | case KMessageBox::Yes: // just this one | 3739 | case KMessageBox::Yes: // just this one |
3741 | //QDate qd = mNavigator->selectedDates().first(); | 3740 | //QDate qd = mNavigator->selectedDates().first(); |
3742 | //if (!qd.isValid()) { | 3741 | //if (!qd.isValid()) { |
3743 | // kdDebug() << "no date selected, or invalid date" << endl; | 3742 | // kdDebug() << "no date selected, or invalid date" << endl; |
3744 | // KNotifyClient::beep(); | 3743 | // KNotifyClient::beep(); |
3745 | // return; | 3744 | // return; |
3746 | //} | 3745 | //} |
3747 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3746 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3748 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3747 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3749 | anEvent->addExDate(itemDate); | 3748 | anEvent->addExDate(itemDate); |
3750 | int duration = anEvent->recurrence()->duration(); | 3749 | int duration = anEvent->recurrence()->duration(); |
3751 | if ( duration > 0 ) { | 3750 | if ( duration > 0 ) { |
3752 | anEvent->recurrence()->setDuration( duration - 1 ); | 3751 | anEvent->recurrence()->setDuration( duration - 1 ); |
3753 | } | 3752 | } |
3754 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3753 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3755 | } | 3754 | } |
3756 | break; | 3755 | break; |
3757 | //#endif | 3756 | //#endif |
3758 | } // switch | 3757 | } // switch |
3759 | } else { | 3758 | } else { |
3760 | if (KOPrefs::instance()->mConfirm) { | 3759 | if (KOPrefs::instance()->mConfirm) { |
3761 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3760 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3762 | i18n("\nAre you sure you want\nto delete this event?"), | 3761 | i18n("\nAre you sure you want\nto delete this event?"), |
3763 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3762 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3764 | case KMessageBox::Continue: // OK | 3763 | case KMessageBox::Continue: // OK |
3765 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3764 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3766 | schedule(Scheduler::Cancel,anEvent); | 3765 | schedule(Scheduler::Cancel,anEvent); |
3767 | checkExternalId( anEvent); | 3766 | checkExternalId( anEvent); |
3768 | mCalendar->deleteEvent(anEvent); | 3767 | mCalendar->deleteEvent(anEvent); |
3769 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3768 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3770 | break; | 3769 | break; |
3771 | } // switch | 3770 | } // switch |
3772 | } else { | 3771 | } else { |
3773 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3772 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3774 | schedule(Scheduler::Cancel,anEvent); | 3773 | schedule(Scheduler::Cancel,anEvent); |
3775 | checkExternalId( anEvent); | 3774 | checkExternalId( anEvent); |
3776 | mCalendar->deleteEvent(anEvent); | 3775 | mCalendar->deleteEvent(anEvent); |
3777 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3776 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3778 | } | 3777 | } |
3779 | } // if-else | 3778 | } // if-else |
3780 | emit updateSearchDialog(); | 3779 | emit updateSearchDialog(); |
3781 | } | 3780 | } |
3782 | 3781 | ||
3783 | bool CalendarView::deleteEvent(const QString &uid) | 3782 | bool CalendarView::deleteEvent(const QString &uid) |
3784 | { | 3783 | { |
3785 | Event *ev = mCalendar->event(uid); | 3784 | Event *ev = mCalendar->event(uid); |
3786 | if (ev) { | 3785 | if (ev) { |
3787 | deleteEvent(ev); | 3786 | deleteEvent(ev); |
3788 | return true; | 3787 | return true; |
3789 | } else { | 3788 | } else { |
3790 | return false; | 3789 | return false; |
3791 | } | 3790 | } |
3792 | } | 3791 | } |
3793 | 3792 | ||
3794 | /*****************************************************************************/ | 3793 | /*****************************************************************************/ |
3795 | 3794 | ||
3796 | void CalendarView::action_mail() | 3795 | void CalendarView::action_mail() |
3797 | { | 3796 | { |
3798 | #ifndef KORG_NOMAIL | 3797 | #ifndef KORG_NOMAIL |
3799 | KOMailClient mailClient; | 3798 | KOMailClient mailClient; |
3800 | 3799 | ||
3801 | Incidence *incidence = currentSelection(); | 3800 | Incidence *incidence = currentSelection(); |
3802 | 3801 | ||
3803 | if (!incidence) { | 3802 | if (!incidence) { |
3804 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3803 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3805 | return; | 3804 | return; |
3806 | } | 3805 | } |
3807 | if(incidence->attendeeCount() == 0 ) { | 3806 | if(incidence->attendeeCount() == 0 ) { |
3808 | KMessageBox::sorry(this, | 3807 | KMessageBox::sorry(this, |
3809 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3808 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3810 | return; | 3809 | return; |
3811 | } | 3810 | } |
3812 | 3811 | ||
3813 | CalendarLocal cal_tmp; | 3812 | CalendarLocal cal_tmp; |
3814 | Event *event = 0; | 3813 | Event *event = 0; |
3815 | Event *ev = 0; | 3814 | Event *ev = 0; |
3816 | if ( incidence && incidence->typeID() == eventID ) { | 3815 | if ( incidence && incidence->typeID() == eventID ) { |
3817 | event = static_cast<Event *>(incidence); | 3816 | event = static_cast<Event *>(incidence); |
3818 | ev = new Event(*event); | 3817 | ev = new Event(*event); |
3819 | cal_tmp.addEvent(ev); | 3818 | cal_tmp.addEvent(ev); |
3820 | } | 3819 | } |
3821 | ICalFormat mForm(); | 3820 | ICalFormat mForm(); |
3822 | QString attachment = mForm.toString( &cal_tmp ); | 3821 | QString attachment = mForm.toString( &cal_tmp ); |
3823 | if (ev) delete(ev); | 3822 | if (ev) delete(ev); |
3824 | 3823 | ||
3825 | mailClient.mailAttendees(currentSelection(), attachment); | 3824 | mailClient.mailAttendees(currentSelection(), attachment); |
3826 | 3825 | ||
3827 | #endif | 3826 | #endif |
3828 | 3827 | ||
3829 | #if 0 | 3828 | #if 0 |
3830 | Event *anEvent = 0; | 3829 | Event *anEvent = 0; |
3831 | if (mViewManager->currentView()->isEventView()) { | 3830 | if (mViewManager->currentView()->isEventView()) { |
3832 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3831 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3833 | } | 3832 | } |
3834 | 3833 | ||
3835 | if (!anEvent) { | 3834 | if (!anEvent) { |
3836 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3835 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3837 | return; | 3836 | return; |
3838 | } | 3837 | } |
3839 | if(anEvent->attendeeCount() == 0 ) { | 3838 | if(anEvent->attendeeCount() == 0 ) { |
3840 | KMessageBox::sorry(this, | 3839 | KMessageBox::sorry(this, |
3841 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3840 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3842 | return; | 3841 | return; |
3843 | } | 3842 | } |
3844 | 3843 | ||
3845 | mailobject.emailEvent(anEvent); | 3844 | mailobject.emailEvent(anEvent); |
3846 | #endif | 3845 | #endif |
3847 | } | 3846 | } |
3848 | 3847 | ||
3849 | 3848 | ||
3850 | void CalendarView::schedule_publish(Incidence *incidence) | 3849 | void CalendarView::schedule_publish(Incidence *incidence) |
3851 | { | 3850 | { |
3852 | Event *event = 0; | 3851 | Event *event = 0; |
3853 | Todo *todo = 0; | 3852 | Todo *todo = 0; |
3854 | 3853 | ||
3855 | if (incidence == 0) { | 3854 | if (incidence == 0) { |
3856 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3855 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3857 | if (incidence == 0) { | 3856 | if (incidence == 0) { |
3858 | incidence = mTodoList->selectedIncidences().first(); | 3857 | incidence = mTodoList->selectedIncidences().first(); |
3859 | } | 3858 | } |
3860 | } | 3859 | } |
3861 | if ( incidence && incidence->typeID() == eventID ) { | 3860 | if ( incidence && incidence->typeID() == eventID ) { |
3862 | event = static_cast<Event *>(incidence); | 3861 | event = static_cast<Event *>(incidence); |
3863 | } else { | 3862 | } else { |
3864 | if ( incidence && incidence->typeID() == todoID ) { | 3863 | if ( incidence && incidence->typeID() == todoID ) { |
3865 | todo = static_cast<Todo *>(incidence); | 3864 | todo = static_cast<Todo *>(incidence); |
3866 | } | 3865 | } |
3867 | } | 3866 | } |
3868 | 3867 | ||
3869 | if (!event && !todo) { | 3868 | if (!event && !todo) { |
3870 | KMessageBox::sorry(this,i18n("No event selected.")); | 3869 | KMessageBox::sorry(this,i18n("No event selected.")); |
3871 | return; | 3870 | return; |
3872 | } | 3871 | } |
3873 | 3872 | ||
3874 | PublishDialog *publishdlg = new PublishDialog(); | 3873 | PublishDialog *publishdlg = new PublishDialog(); |
3875 | if (incidence->attendeeCount()>0) { | 3874 | if (incidence->attendeeCount()>0) { |
3876 | QPtrList<Attendee> attendees = incidence->attendees(); | 3875 | QPtrList<Attendee> attendees = incidence->attendees(); |
3877 | attendees.first(); | 3876 | attendees.first(); |
3878 | while ( attendees.current()!=0 ) { | 3877 | while ( attendees.current()!=0 ) { |
3879 | publishdlg->addAttendee(attendees.current()); | 3878 | publishdlg->addAttendee(attendees.current()); |
3880 | attendees.next(); | 3879 | attendees.next(); |
3881 | } | 3880 | } |
3882 | } | 3881 | } |
3883 | bool send = true; | 3882 | bool send = true; |
3884 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3883 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3885 | if ( publishdlg->exec() != QDialog::Accepted ) | 3884 | if ( publishdlg->exec() != QDialog::Accepted ) |
3886 | send = false; | 3885 | send = false; |
3887 | } | 3886 | } |
3888 | if ( send ) { | 3887 | if ( send ) { |
3889 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3888 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3890 | if ( event ) { | 3889 | if ( event ) { |
3891 | Event *ev = new Event(*event); | 3890 | Event *ev = new Event(*event); |
3892 | ev->registerObserver(0); | 3891 | ev->registerObserver(0); |
3893 | ev->clearAttendees(); | 3892 | ev->clearAttendees(); |
3894 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3893 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3895 | delete(ev); | 3894 | delete(ev); |
3896 | } | 3895 | } |
3897 | } else { | 3896 | } else { |
3898 | if ( todo ) { | 3897 | if ( todo ) { |
3899 | Todo *ev = new Todo(*todo); | 3898 | Todo *ev = new Todo(*todo); |
3900 | ev->registerObserver(0); | 3899 | ev->registerObserver(0); |
3901 | ev->clearAttendees(); | 3900 | ev->clearAttendees(); |
3902 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3901 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3903 | delete(ev); | 3902 | delete(ev); |
3904 | } | 3903 | } |
3905 | } | 3904 | } |
3906 | } | 3905 | } |
3907 | } | 3906 | } |
3908 | delete publishdlg; | 3907 | delete publishdlg; |
3909 | } | 3908 | } |
3910 | 3909 | ||
3911 | void CalendarView::schedule_request(Incidence *incidence) | 3910 | void CalendarView::schedule_request(Incidence *incidence) |
3912 | { | 3911 | { |
3913 | schedule(Scheduler::Request,incidence); | 3912 | schedule(Scheduler::Request,incidence); |
3914 | } | 3913 | } |
3915 | 3914 | ||
3916 | void CalendarView::schedule_refresh(Incidence *incidence) | 3915 | void CalendarView::schedule_refresh(Incidence *incidence) |
3917 | { | 3916 | { |
3918 | schedule(Scheduler::Refresh,incidence); | 3917 | schedule(Scheduler::Refresh,incidence); |
3919 | } | 3918 | } |
3920 | 3919 | ||
3921 | void CalendarView::schedule_cancel(Incidence *incidence) | 3920 | void CalendarView::schedule_cancel(Incidence *incidence) |
3922 | { | 3921 | { |
3923 | schedule(Scheduler::Cancel,incidence); | 3922 | schedule(Scheduler::Cancel,incidence); |
3924 | } | 3923 | } |
3925 | 3924 | ||
3926 | void CalendarView::schedule_add(Incidence *incidence) | 3925 | void CalendarView::schedule_add(Incidence *incidence) |
3927 | { | 3926 | { |
3928 | schedule(Scheduler::Add,incidence); | 3927 | schedule(Scheduler::Add,incidence); |
3929 | } | 3928 | } |
3930 | 3929 | ||
3931 | void CalendarView::schedule_reply(Incidence *incidence) | 3930 | void CalendarView::schedule_reply(Incidence *incidence) |
3932 | { | 3931 | { |
3933 | schedule(Scheduler::Reply,incidence); | 3932 | schedule(Scheduler::Reply,incidence); |
3934 | } | 3933 | } |
3935 | 3934 | ||
3936 | void CalendarView::schedule_counter(Incidence *incidence) | 3935 | void CalendarView::schedule_counter(Incidence *incidence) |
3937 | { | 3936 | { |
3938 | schedule(Scheduler::Counter,incidence); | 3937 | schedule(Scheduler::Counter,incidence); |
3939 | } | 3938 | } |
3940 | 3939 | ||
3941 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3940 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3942 | { | 3941 | { |
3943 | schedule(Scheduler::Declinecounter,incidence); | 3942 | schedule(Scheduler::Declinecounter,incidence); |
3944 | } | 3943 | } |
3945 | 3944 | ||
3946 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3945 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3947 | { | 3946 | { |
3948 | QDateTime start = QDateTime::currentDateTime(); | 3947 | QDateTime start = QDateTime::currentDateTime(); |
3949 | QDateTime end = start.addDays(daysToPublish); | 3948 | QDateTime end = start.addDays(daysToPublish); |
3950 | 3949 | ||
3951 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3950 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3952 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3951 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3953 | 3952 | ||
3954 | 3953 | ||
3955 | PublishDialog *publishdlg = new PublishDialog(); | 3954 | PublishDialog *publishdlg = new PublishDialog(); |
3956 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3955 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3957 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3956 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3958 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3957 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3959 | delete(freebusy); | 3958 | delete(freebusy); |
3960 | } | 3959 | } |
3961 | } | 3960 | } |
3962 | delete publishdlg; | 3961 | delete publishdlg; |
3963 | } | 3962 | } |
3964 | 3963 | ||
3965 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3964 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3966 | { | 3965 | { |
3967 | Event *event = 0; | 3966 | Event *event = 0; |
3968 | Todo *todo = 0; | 3967 | Todo *todo = 0; |
3969 | 3968 | ||
3970 | if (incidence == 0) { | 3969 | if (incidence == 0) { |
3971 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3970 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3972 | if (incidence == 0) { | 3971 | if (incidence == 0) { |
3973 | incidence = mTodoList->selectedIncidences().first(); | 3972 | incidence = mTodoList->selectedIncidences().first(); |
3974 | } | 3973 | } |
3975 | } | 3974 | } |
3976 | if ( incidence && incidence->typeID() == eventID ) { | 3975 | if ( incidence && incidence->typeID() == eventID ) { |
3977 | event = static_cast<Event *>(incidence); | 3976 | event = static_cast<Event *>(incidence); |
3978 | } | 3977 | } |
3979 | if ( incidence && incidence->typeID() == todoID ) { | 3978 | if ( incidence && incidence->typeID() == todoID ) { |
3980 | todo = static_cast<Todo *>(incidence); | 3979 | todo = static_cast<Todo *>(incidence); |
3981 | } | 3980 | } |
3982 | 3981 | ||
3983 | if (!event && !todo) { | 3982 | if (!event && !todo) { |
3984 | KMessageBox::sorry(this,i18n("No event selected.")); | 3983 | KMessageBox::sorry(this,i18n("No event selected.")); |
3985 | return; | 3984 | return; |
3986 | } | 3985 | } |
3987 | 3986 | ||
3988 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3987 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3989 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3988 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3990 | return; | 3989 | return; |
3991 | } | 3990 | } |
3992 | 3991 | ||
3993 | Event *ev = 0; | 3992 | Event *ev = 0; |
3994 | if (event) ev = new Event(*event); | 3993 | if (event) ev = new Event(*event); |
3995 | Todo *to = 0; | 3994 | Todo *to = 0; |
3996 | if (todo) to = new Todo(*todo); | 3995 | if (todo) to = new Todo(*todo); |
3997 | 3996 | ||
3998 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3997 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3999 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3998 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4000 | if (!me) { | 3999 | if (!me) { |
4001 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4000 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4002 | return; | 4001 | return; |
4003 | } | 4002 | } |
4004 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4003 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4005 | StatusDialog *statdlg = new StatusDialog(this); | 4004 | StatusDialog *statdlg = new StatusDialog(this); |
4006 | if (!statdlg->exec()==QDialog::Accepted) return; | 4005 | if (!statdlg->exec()==QDialog::Accepted) return; |
4007 | me->setStatus( statdlg->status() ); | 4006 | me->setStatus( statdlg->status() ); |
4008 | delete(statdlg); | 4007 | delete(statdlg); |
4009 | } | 4008 | } |
4010 | Attendee *menew = new Attendee(*me); | 4009 | Attendee *menew = new Attendee(*me); |
4011 | if (ev) { | 4010 | if (ev) { |
4012 | ev->clearAttendees(); | 4011 | ev->clearAttendees(); |
4013 | ev->addAttendee(menew,false); | 4012 | ev->addAttendee(menew,false); |
4014 | } else { | 4013 | } else { |
4015 | if (to) { | 4014 | if (to) { |
4016 | todo->clearAttendees(); | 4015 | todo->clearAttendees(); |
4017 | todo->addAttendee(menew,false); | 4016 | todo->addAttendee(menew,false); |
4018 | } | 4017 | } |
4019 | } | 4018 | } |
4020 | } | 4019 | } |
4021 | 4020 | ||
4022 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4021 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4023 | if (ev) { | 4022 | if (ev) { |
4024 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4023 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4025 | } else { | 4024 | } else { |
4026 | if (to) { | 4025 | if (to) { |
4027 | if ( !dlg->addMessage(to,method) ) delete(to); | 4026 | if ( !dlg->addMessage(to,method) ) delete(to); |
4028 | } | 4027 | } |
4029 | } | 4028 | } |
4030 | } | 4029 | } |
4031 | 4030 | ||
4032 | void CalendarView::openAddressbook() | 4031 | void CalendarView::openAddressbook() |
4033 | { | 4032 | { |
4034 | KRun::runCommand("kaddressbook"); | 4033 | KRun::runCommand("kaddressbook"); |
4035 | } | 4034 | } |
4036 | 4035 | ||
4037 | void CalendarView::setModified(bool modified) | 4036 | void CalendarView::setModified(bool modified) |
4038 | { | 4037 | { |
4039 | if ( modified ) | 4038 | if ( modified ) |
4040 | emit signalmodified(); | 4039 | emit signalmodified(); |
4041 | if (mModified != modified) { | 4040 | if (mModified != modified) { |
4042 | mModified = modified; | 4041 | mModified = modified; |
4043 | emit modifiedChanged(mModified); | 4042 | emit modifiedChanged(mModified); |
4044 | } | 4043 | } |
4045 | } | 4044 | } |
4046 | 4045 | ||
4047 | bool CalendarView::isReadOnly() | 4046 | bool CalendarView::isReadOnly() |
4048 | { | 4047 | { |
4049 | return mReadOnly; | 4048 | return mReadOnly; |
4050 | } | 4049 | } |
4051 | 4050 | ||
4052 | void CalendarView::setReadOnly(bool readOnly) | 4051 | void CalendarView::setReadOnly(bool readOnly) |
4053 | { | 4052 | { |
4054 | if (mReadOnly != readOnly) { | 4053 | if (mReadOnly != readOnly) { |
4055 | mReadOnly = readOnly; | 4054 | mReadOnly = readOnly; |
4056 | emit readOnlyChanged(mReadOnly); | 4055 | emit readOnlyChanged(mReadOnly); |
4057 | } | 4056 | } |
4058 | } | 4057 | } |
4059 | 4058 | ||
4060 | bool CalendarView::isModified() | 4059 | bool CalendarView::isModified() |
4061 | { | 4060 | { |
4062 | return mModified; | 4061 | return mModified; |
4063 | } | 4062 | } |
4064 | void CalendarView::slotprintSelInc() | 4063 | void CalendarView::slotprintSelInc() |
4065 | { | 4064 | { |
4066 | if ( currentSelection() == 0 ) { | 4065 | if ( currentSelection() == 0 ) { |
4067 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4066 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4068 | return; | 4067 | return; |
4069 | } | 4068 | } |
4070 | showIncidence(); | 4069 | showIncidence(); |
4071 | getEventViewerDialog()->print(); | 4070 | getEventViewerDialog()->print(); |
4072 | 4071 | ||
4073 | } | 4072 | } |
4074 | void CalendarView::printSetup() | 4073 | void CalendarView::printSetup() |
4075 | { | 4074 | { |
4076 | #ifndef KORG_NOPRINTER | 4075 | #ifndef KORG_NOPRINTER |
4077 | createPrinter(); | 4076 | createPrinter(); |
4078 | 4077 | ||
4079 | mCalPrinter->setupPrinter(); | 4078 | mCalPrinter->setupPrinter(); |
4080 | #endif | 4079 | #endif |
4081 | } | 4080 | } |
4082 | 4081 | ||
4083 | void CalendarView::print() | 4082 | void CalendarView::print() |
4084 | { | 4083 | { |
4085 | #ifndef KORG_NOPRINTER | 4084 | #ifndef KORG_NOPRINTER |
4086 | createPrinter(); | 4085 | createPrinter(); |
4087 | 4086 | ||
4088 | DateList tmpDateList = mNavigator->selectedDates(); | 4087 | DateList tmpDateList = mNavigator->selectedDates(); |
4089 | mCalPrinter->print(CalPrinter::Month, | 4088 | mCalPrinter->print(CalPrinter::Month, |
4090 | tmpDateList.first(), tmpDateList.last()); | 4089 | tmpDateList.first(), tmpDateList.last()); |
4091 | #endif | 4090 | #endif |
4092 | } | 4091 | } |
4093 | 4092 | ||
4094 | void CalendarView::printPreview() | 4093 | void CalendarView::printPreview() |
4095 | { | 4094 | { |
4096 | #ifndef KORG_NOPRINTER | 4095 | #ifndef KORG_NOPRINTER |
4097 | kdDebug() << "CalendarView::printPreview()" << endl; | 4096 | kdDebug() << "CalendarView::printPreview()" << endl; |
4098 | 4097 | ||
4099 | createPrinter(); | 4098 | createPrinter(); |
4100 | 4099 | ||
4101 | DateList tmpDateList = mNavigator->selectedDates(); | 4100 | DateList tmpDateList = mNavigator->selectedDates(); |
4102 | 4101 | ||
4103 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4102 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4104 | tmpDateList.last()); | 4103 | tmpDateList.last()); |
4105 | #endif | 4104 | #endif |
4106 | } | 4105 | } |
4107 | 4106 | ||
4108 | void CalendarView::exportICalendar() | 4107 | void CalendarView::exportICalendar() |
4109 | { | 4108 | { |
4110 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 4109 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
4111 | 4110 | ||
4112 | // Force correct extension | 4111 | // Force correct extension |
4113 | if (filename.right(4) != ".ics") filename += ".ics"; | 4112 | if (filename.right(4) != ".ics") filename += ".ics"; |
4114 | 4113 | ||
4115 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4114 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4116 | storage.save(); | 4115 | storage.save(); |
4117 | } | 4116 | } |
4118 | 4117 | ||
4119 | bool CalendarView::exportVCalendar( QString filename ) | 4118 | bool CalendarView::exportVCalendar( QString filename ) |
4120 | { | 4119 | { |
4121 | if (mCalendar->journals().count() > 0) { | 4120 | if (mCalendar->journals().count() > 0) { |
4122 | int result = KMessageBox::warningContinueCancel(this, | 4121 | int result = KMessageBox::warningContinueCancel(this, |
4123 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4122 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4124 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4123 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4125 | true); | 4124 | true); |
4126 | if (result != KMessageBox::Continue) return false; | 4125 | if (result != KMessageBox::Continue) return false; |
4127 | } | 4126 | } |
4128 | 4127 | ||
4129 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4128 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4130 | 4129 | ||
4131 | // Force correct extension | 4130 | // Force correct extension |
4132 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4131 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4133 | 4132 | ||
4134 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4133 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4135 | return storage.save(); | 4134 | return storage.save(); |
4136 | 4135 | ||
4137 | } | 4136 | } |
4138 | 4137 | ||
4139 | void CalendarView::eventUpdated(Incidence *) | 4138 | void CalendarView::eventUpdated(Incidence *) |
4140 | { | 4139 | { |
4141 | setModified(); | 4140 | setModified(); |
4142 | // Don't call updateView here. The code, which has caused the update of the | 4141 | // Don't call updateView here. The code, which has caused the update of the |
4143 | // event is responsible for updating the view. | 4142 | // event is responsible for updating the view. |
4144 | // updateView(); | 4143 | // updateView(); |
4145 | } | 4144 | } |
4146 | 4145 | ||
4147 | void CalendarView::adaptNavigationUnits() | 4146 | void CalendarView::adaptNavigationUnits() |
4148 | { | 4147 | { |
4149 | if (mViewManager->currentView()->isEventView()) { | 4148 | if (mViewManager->currentView()->isEventView()) { |
4150 | int days = mViewManager->currentView()->currentDateCount(); | 4149 | int days = mViewManager->currentView()->currentDateCount(); |
4151 | if (days == 1) { | 4150 | if (days == 1) { |
4152 | emit changeNavStringPrev(i18n("&Previous Day")); | 4151 | emit changeNavStringPrev(i18n("&Previous Day")); |
4153 | emit changeNavStringNext(i18n("&Next Day")); | 4152 | emit changeNavStringNext(i18n("&Next Day")); |
4154 | } else { | 4153 | } else { |
4155 | emit changeNavStringPrev(i18n("&Previous Week")); | 4154 | emit changeNavStringPrev(i18n("&Previous Week")); |
4156 | emit changeNavStringNext(i18n("&Next Week")); | 4155 | emit changeNavStringNext(i18n("&Next Week")); |
4157 | } | 4156 | } |
4158 | } | 4157 | } |
4159 | } | 4158 | } |
4160 | 4159 | ||
4161 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4160 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4162 | { | 4161 | { |
4163 | if ( incidence ) mTodoList->clearSelection(); | 4162 | if ( incidence ) mTodoList->clearSelection(); |
4164 | processIncidenceSelection( incidence ); | 4163 | processIncidenceSelection( incidence ); |
4165 | } | 4164 | } |
4166 | 4165 | ||
4167 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4166 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4168 | { | 4167 | { |
4169 | if ( incidence && mViewManager->currentView() ) { | 4168 | if ( incidence && mViewManager->currentView() ) { |
4170 | mViewManager->currentView()->clearSelection(); | 4169 | mViewManager->currentView()->clearSelection(); |
4171 | } | 4170 | } |
4172 | processIncidenceSelection( incidence ); | 4171 | processIncidenceSelection( incidence ); |
4173 | } | 4172 | } |
4174 | 4173 | ||
4175 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4174 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4176 | { | 4175 | { |
4177 | emit incidenceSelected( incidence ); | 4176 | emit incidenceSelected( incidence ); |
4178 | if ( incidence == mSelectedIncidence ) return; | 4177 | if ( incidence == mSelectedIncidence ) return; |
4179 | mSelectedIncidence = incidence; | 4178 | mSelectedIncidence = incidence; |
4180 | 4179 | ||
4181 | if ( incidence && incidence->typeID() == eventID ) { | 4180 | if ( incidence && incidence->typeID() == eventID ) { |
4182 | Event *event = static_cast<Event *>( incidence ); | 4181 | Event *event = static_cast<Event *>( incidence ); |
4183 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4182 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4184 | emit organizerEventsSelected( true ); | 4183 | emit organizerEventsSelected( true ); |
4185 | } else { | 4184 | } else { |
4186 | emit organizerEventsSelected(false); | 4185 | emit organizerEventsSelected(false); |
4187 | } | 4186 | } |
4188 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4187 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4189 | KOPrefs::instance()->email() ) ) { | 4188 | KOPrefs::instance()->email() ) ) { |
4190 | emit groupEventsSelected( true ); | 4189 | emit groupEventsSelected( true ); |
4191 | } else { | 4190 | } else { |
4192 | emit groupEventsSelected(false); | 4191 | emit groupEventsSelected(false); |
4193 | } | 4192 | } |
4194 | return; | 4193 | return; |
4195 | } else { | 4194 | } else { |
4196 | if ( incidence && incidence->typeID() == todoID ) { | 4195 | if ( incidence && incidence->typeID() == todoID ) { |
4197 | emit todoSelected( true ); | 4196 | emit todoSelected( true ); |
4198 | Todo *event = static_cast<Todo *>( incidence ); | 4197 | Todo *event = static_cast<Todo *>( incidence ); |
4199 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4198 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4200 | emit organizerEventsSelected( true ); | 4199 | emit organizerEventsSelected( true ); |
4201 | } else { | 4200 | } else { |
4202 | emit organizerEventsSelected(false); | 4201 | emit organizerEventsSelected(false); |
4203 | } | 4202 | } |
4204 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4203 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4205 | KOPrefs::instance()->email() ) ) { | 4204 | KOPrefs::instance()->email() ) ) { |
4206 | emit groupEventsSelected( true ); | 4205 | emit groupEventsSelected( true ); |
4207 | } else { | 4206 | } else { |
4208 | emit groupEventsSelected(false); | 4207 | emit groupEventsSelected(false); |
4209 | } | 4208 | } |
4210 | return; | 4209 | return; |
4211 | } else { | 4210 | } else { |
4212 | emit todoSelected( false ); | 4211 | emit todoSelected( false ); |
4213 | emit organizerEventsSelected(false); | 4212 | emit organizerEventsSelected(false); |
4214 | emit groupEventsSelected(false); | 4213 | emit groupEventsSelected(false); |
4215 | } | 4214 | } |
4216 | return; | 4215 | return; |
4217 | } | 4216 | } |
4218 | 4217 | ||
4219 | /* if ( incidence && incidence->typeID() == todoID ) { | 4218 | /* if ( incidence && incidence->typeID() == todoID ) { |
4220 | emit todoSelected( true ); | 4219 | emit todoSelected( true ); |
4221 | } else { | 4220 | } else { |
4222 | emit todoSelected( false ); | 4221 | emit todoSelected( false ); |
4223 | }*/ | 4222 | }*/ |
4224 | } | 4223 | } |
4225 | 4224 | ||
4226 | 4225 | ||
4227 | void CalendarView::checkClipboard() | 4226 | void CalendarView::checkClipboard() |
4228 | { | 4227 | { |
4229 | #ifndef KORG_NODND | 4228 | #ifndef KORG_NODND |
4230 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4229 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4231 | emit pasteEnabled(true); | 4230 | emit pasteEnabled(true); |
4232 | } else { | 4231 | } else { |
4233 | emit pasteEnabled(false); | 4232 | emit pasteEnabled(false); |
4234 | } | 4233 | } |
4235 | #endif | 4234 | #endif |
4236 | } | 4235 | } |
4237 | 4236 | ||
4238 | void CalendarView::showDates(const DateList &selectedDates) | 4237 | void CalendarView::showDates(const DateList &selectedDates) |
4239 | { | 4238 | { |
4240 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4239 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4241 | 4240 | ||
4242 | 4241 | ||
4243 | if ( !mBlockShowDates ) { | 4242 | if ( !mBlockShowDates ) { |
4244 | if ( mViewManager->currentView() ) { | 4243 | if ( mViewManager->currentView() ) { |
4245 | updateView( selectedDates.first(), selectedDates.last() ); | 4244 | updateView( selectedDates.first(), selectedDates.last() ); |
4246 | } else { | 4245 | } else { |
4247 | mViewManager->showAgendaView(); | 4246 | mViewManager->showAgendaView(); |
4248 | } | 4247 | } |
4249 | } | 4248 | } |
4250 | 4249 | ||
4251 | QDate date = selectedDates.first(); | 4250 | QDate date = selectedDates.first(); |
4252 | if ( ! date.isValid() ) { | 4251 | if ( ! date.isValid() ) { |
4253 | topLevelWidget()->setCaption(""); | 4252 | topLevelWidget()->setCaption(""); |
4254 | return; | 4253 | return; |
4255 | } | 4254 | } |
4256 | 4255 | ||
4257 | QString selDates; | 4256 | QString selDates; |
4258 | selDates = KGlobal::locale()->formatDate( date, true); | 4257 | selDates = KGlobal::locale()->formatDate( date, true); |
4259 | if (selectedDates.first() < selectedDates.last() ) | 4258 | if (selectedDates.first() < selectedDates.last() ) |
4260 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4259 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4261 | else { | 4260 | else { |
4262 | QString addString; | 4261 | QString addString; |
4263 | if ( date == QDateTime::currentDateTime().date() ) | 4262 | if ( date == QDateTime::currentDateTime().date() ) |
4264 | addString = i18n("Today"); | 4263 | addString = i18n("Today"); |
4265 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4264 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4266 | addString = i18n("Tomorrow"); | 4265 | addString = i18n("Tomorrow"); |
4267 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4266 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4268 | addString = i18n("Yesterday"); | 4267 | addString = i18n("Yesterday"); |
4269 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4268 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4270 | addString = i18n("Day before yesterday"); | 4269 | addString = i18n("Day before yesterday"); |
4271 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4270 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4272 | addString = i18n("Day after tomorrow"); | 4271 | addString = i18n("Day after tomorrow"); |
4273 | if ( !addString.isEmpty() ) { | 4272 | if ( !addString.isEmpty() ) { |
4274 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4273 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4275 | return; | 4274 | return; |
4276 | } | 4275 | } |
4277 | } | 4276 | } |
4278 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4277 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4279 | 4278 | ||
4280 | } | 4279 | } |
4281 | 4280 | ||
4282 | QPtrList<CalFilter> CalendarView::filters() | 4281 | QPtrList<CalFilter> CalendarView::filters() |
4283 | { | 4282 | { |
4284 | return mFilters; | 4283 | return mFilters; |
4285 | 4284 | ||
4286 | } | 4285 | } |
4287 | void CalendarView::editFilters() | 4286 | void CalendarView::editFilters() |
4288 | { | 4287 | { |
4289 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4288 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4290 | 4289 | ||
4291 | CalFilter *filter = mFilters.first(); | 4290 | CalFilter *filter = mFilters.first(); |
4292 | while(filter) { | 4291 | while(filter) { |
4293 | filter = mFilters.next(); | 4292 | filter = mFilters.next(); |
4294 | } | 4293 | } |
4295 | 4294 | ||
4296 | mDialogManager->showFilterEditDialog(&mFilters); | 4295 | mDialogManager->showFilterEditDialog(&mFilters); |
4297 | updateFilter(); | 4296 | updateFilter(); |
4298 | } | 4297 | } |
4299 | void CalendarView::toggleFilter() | 4298 | void CalendarView::toggleFilter() |
4300 | { | 4299 | { |
4301 | if ( mLeftFrame->isHidden() ) { | 4300 | if ( mLeftFrame->isHidden() ) { |
4302 | toggleExpand(); | 4301 | toggleExpand(); |
4303 | showFilter( true ); | 4302 | showFilter( true ); |
4304 | } else | 4303 | } else |
4305 | showFilter(! mCalEditView->isVisible()); | 4304 | showFilter(! mCalEditView->isVisible()); |
4306 | } | 4305 | } |
4307 | 4306 | ||
4308 | KOFilterView *CalendarView::filterView() | 4307 | KOFilterView *CalendarView::filterView() |
4309 | { | 4308 | { |
4310 | return mFilterView; | 4309 | return mFilterView; |
4311 | } | 4310 | } |
4312 | void CalendarView::selectFilter( int fil ) | 4311 | void CalendarView::selectFilter( int fil ) |
4313 | { | 4312 | { |
4314 | mFilterView->setSelectedFilter( fil ); | 4313 | mFilterView->setSelectedFilter( fil ); |
4315 | updateUnmanagedViews(); | 4314 | updateUnmanagedViews(); |
4316 | } | 4315 | } |
4317 | void CalendarView::showFilter(bool visible) | 4316 | void CalendarView::showFilter(bool visible) |
4318 | { | 4317 | { |
4319 | #if 1 | 4318 | #if 1 |
4320 | if (visible) { | 4319 | if (visible) { |
4321 | mCalEditView->readConfig(); | 4320 | mCalEditView->readConfig(); |
4322 | mCalEditView->show(); | 4321 | mCalEditView->show(); |
4323 | QValueList<int> sizes; | 4322 | QValueList<int> sizes; |
4324 | sizes = mLeftFrame->sizes(); | 4323 | sizes = mLeftFrame->sizes(); |
4325 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4324 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4326 | sizes.clear(); | 4325 | sizes.clear(); |
4327 | sizes << 100; | 4326 | sizes << 100; |
4328 | sizes << 0; | 4327 | sizes << 0; |
4329 | sizes << 0; | 4328 | sizes << 0; |
4330 | sizes << 100; | 4329 | sizes << 100; |
4331 | mLeftFrame->setSizes(sizes); | 4330 | mLeftFrame->setSizes(sizes); |
4332 | } | 4331 | } |
4333 | #if 0 | 4332 | #if 0 |
4334 | sizes = mLeftFrame->sizes(); | 4333 | sizes = mLeftFrame->sizes(); |
4335 | int ccc = 0; | 4334 | int ccc = 0; |
4336 | while ( ccc < sizes.count()) { | 4335 | while ( ccc < sizes.count()) { |
4337 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4336 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4338 | ++ccc; | 4337 | ++ccc; |
4339 | } | 4338 | } |
4340 | #endif | 4339 | #endif |
4341 | 4340 | ||
4342 | } | 4341 | } |
4343 | else { | 4342 | else { |
4344 | mCalEditView->hide(); | 4343 | mCalEditView->hide(); |
4345 | } | 4344 | } |
4346 | #else | 4345 | #else |
4347 | if (visible) mFilterView->show(); | 4346 | if (visible) mFilterView->show(); |
4348 | else mFilterView->hide(); | 4347 | else mFilterView->hide(); |
4349 | #endif | 4348 | #endif |
4350 | } | 4349 | } |
4351 | void CalendarView::toggleFilerEnabled( ) | 4350 | void CalendarView::toggleFilerEnabled( ) |
4352 | { | 4351 | { |
4353 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4352 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4354 | if ( !mFilterView->filtersEnabled() ) | 4353 | if ( !mFilterView->filtersEnabled() ) |
4355 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4354 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4356 | updateUnmanagedViews(); | 4355 | updateUnmanagedViews(); |
4357 | 4356 | ||
4358 | } | 4357 | } |
4359 | void CalendarView::updateFilter() | 4358 | void CalendarView::updateFilter() |
4360 | { | 4359 | { |
4361 | CalFilter *filter = mFilterView->selectedFilter(); | 4360 | CalFilter *filter = mFilterView->selectedFilter(); |
4362 | if (filter) { | 4361 | if (filter) { |
4363 | QString mess; | 4362 | QString mess; |
4364 | if (mFilterView->filtersEnabled()) { | 4363 | if (mFilterView->filtersEnabled()) { |
4365 | mess = i18n("Filter selected: ")+filter->name(); | 4364 | mess = i18n("Filter selected: ")+filter->name(); |
4366 | filter->setEnabled(true); | 4365 | filter->setEnabled(true); |
4367 | } | 4366 | } |
4368 | else filter->setEnabled(false); | 4367 | else filter->setEnabled(false); |
4369 | mCalendar->setFilter(filter); | 4368 | mCalendar->setFilter(filter); |
4370 | updateView(); | 4369 | updateView(); |
4371 | if ( !mess.isEmpty() ) | 4370 | if ( !mess.isEmpty() ) |
4372 | topLevelWidget()->setCaption( mess ); | 4371 | topLevelWidget()->setCaption( mess ); |
4373 | 4372 | ||
4374 | } | 4373 | } |
4375 | emit filtersUpdated(); | 4374 | emit filtersUpdated(); |
4376 | } | 4375 | } |
4377 | 4376 | ||
4378 | void CalendarView::filterEdited() | 4377 | void CalendarView::filterEdited() |
4379 | { | 4378 | { |
4380 | mFilterView->updateFilters(); | 4379 | mFilterView->updateFilters(); |
4381 | updateFilter(); | 4380 | updateFilter(); |
4382 | writeSettings(); | 4381 | writeSettings(); |
4383 | } | 4382 | } |
4384 | 4383 | ||
4385 | 4384 | ||
4386 | void CalendarView::takeOverEvent() | 4385 | void CalendarView::takeOverEvent() |
4387 | { | 4386 | { |
4388 | Incidence *incidence = currentSelection(); | 4387 | Incidence *incidence = currentSelection(); |
4389 | 4388 | ||
4390 | if (!incidence) return; | 4389 | if (!incidence) return; |
4391 | 4390 | ||
4392 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4391 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4393 | incidence->recreate(); | 4392 | incidence->recreate(); |
4394 | incidence->setReadOnly(false); | 4393 | incidence->setReadOnly(false); |
4395 | 4394 | ||
4396 | updateView(); | 4395 | updateView(); |
4397 | } | 4396 | } |
4398 | 4397 | ||
4399 | void CalendarView::takeOverCalendar() | 4398 | void CalendarView::takeOverCalendar() |
4400 | { | 4399 | { |
4401 | // TODO: Create Calendar::allIncidences() function and use it here | 4400 | // TODO: Create Calendar::allIncidences() function and use it here |
4402 | 4401 | ||
4403 | clearAllViews(); | 4402 | clearAllViews(); |
4404 | QPtrList<Event> events = mCalendar->events(); | 4403 | QPtrList<Event> events = mCalendar->events(); |
4405 | for(uint i=0; i<events.count(); ++i) { | 4404 | for(uint i=0; i<events.count(); ++i) { |
4406 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4405 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4407 | events.at(i)->recreate(); | 4406 | events.at(i)->recreate(); |
4408 | events.at(i)->setReadOnly(false); | 4407 | events.at(i)->setReadOnly(false); |
4409 | } | 4408 | } |
4410 | 4409 | ||
4411 | QPtrList<Todo> todos = mCalendar->todos(); | 4410 | QPtrList<Todo> todos = mCalendar->todos(); |
4412 | for(uint i=0; i<todos.count(); ++i) { | 4411 | for(uint i=0; i<todos.count(); ++i) { |
4413 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4412 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4414 | todos.at(i)->recreate(); | 4413 | todos.at(i)->recreate(); |
4415 | todos.at(i)->setReadOnly(false); | 4414 | todos.at(i)->setReadOnly(false); |
4416 | } | 4415 | } |
4417 | 4416 | ||
4418 | QPtrList<Journal> journals = mCalendar->journals(); | 4417 | QPtrList<Journal> journals = mCalendar->journals(); |
4419 | for(uint i=0; i<journals.count(); ++i) { | 4418 | for(uint i=0; i<journals.count(); ++i) { |
4420 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4419 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4421 | journals.at(i)->recreate(); | 4420 | journals.at(i)->recreate(); |
4422 | journals.at(i)->setReadOnly(false); | 4421 | journals.at(i)->setReadOnly(false); |
4423 | } | 4422 | } |
4424 | 4423 | ||
4425 | updateView(); | 4424 | updateView(); |
4426 | } | 4425 | } |
4427 | 4426 | ||
4428 | void CalendarView::showIntro() | 4427 | void CalendarView::showIntro() |
4429 | { | 4428 | { |
4430 | kdDebug() << "To be implemented." << endl; | 4429 | kdDebug() << "To be implemented." << endl; |
4431 | } | 4430 | } |
4432 | 4431 | ||
4433 | QWidgetStack *CalendarView::viewStack() | 4432 | QWidgetStack *CalendarView::viewStack() |
4434 | { | 4433 | { |
4435 | return mRightFrame; | 4434 | return mRightFrame; |
4436 | } | 4435 | } |
4437 | 4436 | ||
4438 | QWidget *CalendarView::leftFrame() | 4437 | QWidget *CalendarView::leftFrame() |
4439 | { | 4438 | { |
4440 | return ( QWidget *)mLeftFrame; | 4439 | return ( QWidget *)mLeftFrame; |
4441 | } | 4440 | } |
4442 | 4441 | ||
4443 | DateNavigator *CalendarView::dateNavigator() | 4442 | DateNavigator *CalendarView::dateNavigator() |
4444 | { | 4443 | { |
4445 | return mNavigator; | 4444 | return mNavigator; |
4446 | } | 4445 | } |
4447 | 4446 | ||
4448 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4447 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4449 | { | 4448 | { |
4450 | return mDateNavigator->navigatorView(); | 4449 | return mDateNavigator->navigatorView(); |
4451 | } | 4450 | } |
4452 | void CalendarView::toggleDateNavigatorWidget() | 4451 | void CalendarView::toggleDateNavigatorWidget() |
4453 | { | 4452 | { |
4454 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4453 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4455 | 4454 | ||
4456 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4455 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4457 | mDateNavigator->hide(); | 4456 | mDateNavigator->hide(); |
4458 | else | 4457 | else |
4459 | mDateNavigator->show(); | 4458 | mDateNavigator->show(); |
4460 | } | 4459 | } |
4461 | void CalendarView::addView(KOrg::BaseView *view) | 4460 | void CalendarView::addView(KOrg::BaseView *view) |
4462 | { | 4461 | { |
4463 | mViewManager->addView(view); | 4462 | mViewManager->addView(view); |
4464 | } | 4463 | } |
4465 | 4464 | ||
4466 | void CalendarView::showView(KOrg::BaseView *view) | 4465 | void CalendarView::showView(KOrg::BaseView *view) |
4467 | { | 4466 | { |
4468 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4467 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4469 | } | 4468 | } |
4470 | 4469 | ||
4471 | Incidence *CalendarView::currentSelection() | 4470 | Incidence *CalendarView::currentSelection() |
4472 | { | 4471 | { |
4473 | return mViewManager->currentSelection(); | 4472 | return mViewManager->currentSelection(); |
4474 | } | 4473 | } |
4475 | void CalendarView::toggleAllDaySize() | 4474 | void CalendarView::toggleAllDaySize() |
4476 | { | 4475 | { |
4477 | /* | 4476 | /* |
4478 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4477 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4479 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4478 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4480 | else | 4479 | else |
4481 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4480 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4482 | */ | 4481 | */ |
4483 | viewManager()->agendaView()->toggleAllDay(); | 4482 | viewManager()->agendaView()->toggleAllDay(); |
4484 | } | 4483 | } |
4485 | void CalendarView::toggleExpand() | 4484 | void CalendarView::toggleExpand() |
4486 | { | 4485 | { |
4487 | // if ( mLeftFrame->isHidden() ) { | 4486 | // if ( mLeftFrame->isHidden() ) { |
4488 | // mLeftFrame->show(); | 4487 | // mLeftFrame->show(); |
4489 | // emit calendarViewExpanded( false ); | 4488 | // emit calendarViewExpanded( false ); |
4490 | // } else { | 4489 | // } else { |
4491 | // mLeftFrame->hide(); | 4490 | // mLeftFrame->hide(); |
4492 | // emit calendarViewExpanded( true ); | 4491 | // emit calendarViewExpanded( true ); |
4493 | // } | 4492 | // } |
4494 | //qDebug(" CalendarView::toggleExpand()"); | 4493 | //qDebug(" CalendarView::toggleExpand()"); |
4495 | globalFlagBlockAgenda = 1; | 4494 | globalFlagBlockAgenda = 1; |
4496 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4495 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4497 | globalFlagBlockAgenda = 5; | 4496 | globalFlagBlockAgenda = 5; |
4498 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4497 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4499 | //mViewManager->showView( 0, true ); | 4498 | //mViewManager->showView( 0, true ); |
4500 | } | 4499 | } |
4501 | 4500 | ||
4502 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4501 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4503 | { | 4502 | { |
4504 | setModified( modified ); | 4503 | setModified( modified ); |
4505 | } | 4504 | } |
4506 | 4505 | ||
4507 | Todo *CalendarView::selectedTodo() | 4506 | Todo *CalendarView::selectedTodo() |
4508 | { | 4507 | { |
4509 | Incidence *incidence = currentSelection(); | 4508 | Incidence *incidence = currentSelection(); |
4510 | if ( incidence && incidence->typeID() == todoID ) { | 4509 | if ( incidence && incidence->typeID() == todoID ) { |
4511 | return static_cast<Todo *>( incidence ); | 4510 | return static_cast<Todo *>( incidence ); |
4512 | } | 4511 | } |
4513 | 4512 | ||
4514 | incidence = mTodoList->selectedIncidences().first(); | 4513 | incidence = mTodoList->selectedIncidences().first(); |
4515 | if ( incidence && incidence->typeID() == todoID ) { | 4514 | if ( incidence && incidence->typeID() == todoID ) { |
4516 | return static_cast<Todo *>( incidence ); | 4515 | return static_cast<Todo *>( incidence ); |
4517 | } | 4516 | } |
4518 | 4517 | ||
4519 | return 0; | 4518 | return 0; |
4520 | } | 4519 | } |
4521 | 4520 | ||
4522 | void CalendarView::showIncidence() | 4521 | void CalendarView::showIncidence() |
4523 | { | 4522 | { |
4524 | mViewerCallerIsSearchDialog = false; | 4523 | mViewerCallerIsSearchDialog = false; |
4525 | Incidence *incidence = currentSelection(); | 4524 | Incidence *incidence = currentSelection(); |
4526 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4525 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4527 | if ( incidence ) { | 4526 | if ( incidence ) { |
4528 | ShowIncidenceVisitor v; | 4527 | ShowIncidenceVisitor v; |
4529 | v.act( incidence, this ); | 4528 | v.act( incidence, this ); |
4530 | } | 4529 | } |
4531 | } | 4530 | } |
4532 | void CalendarView::editIncidenceDescription() | 4531 | void CalendarView::editIncidenceDescription() |
4533 | { | 4532 | { |
4534 | mFlagEditDescription = true; | 4533 | mFlagEditDescription = true; |
4535 | editIncidence(); | 4534 | editIncidence(); |
4536 | mFlagEditDescription = false; | 4535 | mFlagEditDescription = false; |
4537 | } | 4536 | } |
4538 | void CalendarView::editIncidence() | 4537 | void CalendarView::editIncidence() |
4539 | { | 4538 | { |
4540 | // qDebug("editIncidence() "); | 4539 | // qDebug("editIncidence() "); |
4541 | Incidence *incidence = currentSelection(); | 4540 | Incidence *incidence = currentSelection(); |
4542 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4541 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4543 | if ( incidence ) { | 4542 | if ( incidence ) { |
4544 | EditIncidenceVisitor v; | 4543 | EditIncidenceVisitor v; |
4545 | v.act( incidence, this ); | 4544 | v.act( incidence, this ); |
4546 | } | 4545 | } |
4547 | } | 4546 | } |
4548 | 4547 | ||
4549 | void CalendarView::deleteIncidence() | 4548 | void CalendarView::deleteIncidence() |
4550 | { | 4549 | { |
4551 | Incidence *incidence = currentSelection(); | 4550 | Incidence *incidence = currentSelection(); |
4552 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4551 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4553 | if ( incidence ) { | 4552 | if ( incidence ) { |
4554 | deleteIncidence(incidence); | 4553 | deleteIncidence(incidence); |
4555 | } | 4554 | } |
4556 | } | 4555 | } |
4557 | void CalendarView::showIncidence(QString uid) | 4556 | void CalendarView::showIncidence(QString uid) |
4558 | { | 4557 | { |
4559 | Incidence *inc = mCalendar->incidence( uid ); | 4558 | Incidence *inc = mCalendar->incidence( uid ); |
4560 | if ( inc ) | 4559 | if ( inc ) |
4561 | showIncidence( inc ); | 4560 | showIncidence( inc ); |
4562 | } | 4561 | } |
4563 | void CalendarView::showIncidence(Incidence *incidence) | 4562 | void CalendarView::showIncidence(Incidence *incidence) |
4564 | { | 4563 | { |
4565 | mViewerCallerIsSearchDialog = false; | 4564 | mViewerCallerIsSearchDialog = false; |
4566 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4565 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4567 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4566 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4568 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4567 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4569 | mViewerCallerIsSearchDialog = true; | 4568 | mViewerCallerIsSearchDialog = true; |
4570 | } | 4569 | } |
4571 | } | 4570 | } |
4572 | if ( incidence ) { | 4571 | if ( incidence ) { |
4573 | ShowIncidenceVisitor v; | 4572 | ShowIncidenceVisitor v; |
4574 | v.act( incidence, this ); | 4573 | v.act( incidence, this ); |
4575 | } | 4574 | } |
4576 | } | 4575 | } |
4577 | 4576 | ||
4578 | void CalendarView::editIncidence(Incidence *incidence) | 4577 | void CalendarView::editIncidence(Incidence *incidence) |
4579 | { | 4578 | { |
4580 | if ( incidence ) { | 4579 | if ( incidence ) { |
4581 | 4580 | ||
4582 | EditIncidenceVisitor v; | 4581 | EditIncidenceVisitor v; |
4583 | v.act( incidence, this ); | 4582 | v.act( incidence, this ); |
4584 | 4583 | ||
4585 | } | 4584 | } |
4586 | } | 4585 | } |
4587 | 4586 | ||
4588 | void CalendarView::deleteIncidence(Incidence *incidence) | 4587 | void CalendarView::deleteIncidence(Incidence *incidence) |
4589 | { | 4588 | { |
4590 | //qDebug(" CalendarView::deleteIncidence "); | 4589 | //qDebug(" CalendarView::deleteIncidence "); |
4591 | if ( incidence == 0 ) { | 4590 | if ( incidence == 0 ) { |
4592 | updateView(); | 4591 | updateView(); |
4593 | emit updateSearchDialog(); | 4592 | emit updateSearchDialog(); |
4594 | return; | 4593 | return; |
4595 | } | 4594 | } |
4596 | if ( incidence ) { | 4595 | if ( incidence ) { |
4597 | DeleteIncidenceVisitor v; | 4596 | DeleteIncidenceVisitor v; |
4598 | v.act( incidence, this ); | 4597 | v.act( incidence, this ); |
4599 | } | 4598 | } |
4600 | } | 4599 | } |
4601 | 4600 | ||
4602 | 4601 | ||
4603 | void CalendarView::lookForOutgoingMessages() | 4602 | void CalendarView::lookForOutgoingMessages() |
4604 | { | 4603 | { |
4605 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4604 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4606 | ogd->loadMessages(); | 4605 | ogd->loadMessages(); |
4607 | } | 4606 | } |
4608 | 4607 | ||
4609 | void CalendarView::lookForIncomingMessages() | 4608 | void CalendarView::lookForIncomingMessages() |
4610 | { | 4609 | { |
4611 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4610 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4612 | icd->retrieve(); | 4611 | icd->retrieve(); |
4613 | } | 4612 | } |
4614 | 4613 | ||
4615 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4614 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4616 | { | 4615 | { |
4617 | bool deleteTodo = true; | 4616 | bool deleteTodo = true; |
4618 | QPtrList<Incidence> subTodos; | 4617 | QPtrList<Incidence> subTodos; |
4619 | Incidence *aTodo; | 4618 | Incidence *aTodo; |
4620 | subTodos = t->relations(); | 4619 | subTodos = t->relations(); |
4621 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4620 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4622 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4621 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4623 | deleteTodo = false; | 4622 | deleteTodo = false; |
4624 | } | 4623 | } |
4625 | if ( deleteTodo ) { | 4624 | if ( deleteTodo ) { |
4626 | if ( t->isCompleted() && !t->doesRecur()) { | 4625 | if ( t->isCompleted() && !t->doesRecur()) { |
4627 | checkExternalId( t ); | 4626 | checkExternalId( t ); |
4628 | mCalendar->deleteTodo( t ); | 4627 | mCalendar->deleteTodo( t ); |
4629 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4628 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4630 | } | 4629 | } |
4631 | else | 4630 | else |
4632 | deleteTodo = false; | 4631 | deleteTodo = false; |
4633 | } | 4632 | } |
4634 | return deleteTodo; | 4633 | return deleteTodo; |
4635 | 4634 | ||
4636 | } | 4635 | } |
4637 | void CalendarView::purgeCompleted() | 4636 | void CalendarView::purgeCompleted() |
4638 | { | 4637 | { |
4639 | int result = KMessageBox::warningContinueCancel(this, | 4638 | int result = KMessageBox::warningContinueCancel(this, |
4640 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4639 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4641 | 4640 | ||
4642 | if (result == KMessageBox::Continue) { | 4641 | if (result == KMessageBox::Continue) { |
4643 | 4642 | ||
4644 | QPtrList<Todo> todoCal; | 4643 | QPtrList<Todo> todoCal; |
4645 | QPtrList<Todo> rootTodos; | 4644 | QPtrList<Todo> rootTodos; |
4646 | //QPtrList<Incidence> rel; | 4645 | //QPtrList<Incidence> rel; |
4647 | Todo *aTodo; | 4646 | Todo *aTodo; |
4648 | todoCal = calendar()->todos(); | 4647 | todoCal = calendar()->todos(); |
4649 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4648 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4650 | if ( !aTodo->relatedTo() ) | 4649 | if ( !aTodo->relatedTo() ) |
4651 | rootTodos.append( aTodo ); | 4650 | rootTodos.append( aTodo ); |
4652 | } | 4651 | } |
4653 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4652 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4654 | removeCompletedSubTodos( aTodo ); | 4653 | removeCompletedSubTodos( aTodo ); |
4655 | } | 4654 | } |
4656 | 4655 | ||
4657 | updateView(); | 4656 | updateView(); |
4658 | } | 4657 | } |
4659 | } | 4658 | } |
4660 | 4659 | ||
4661 | void CalendarView::slotCalendarChanged() | 4660 | void CalendarView::slotCalendarChanged() |
4662 | { | 4661 | { |
4663 | ; | 4662 | ; |
4664 | } | 4663 | } |
4665 | 4664 | ||
4666 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4665 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4667 | { | 4666 | { |
4668 | //qDebug(" alendarView::keyPressEvent "); | 4667 | //qDebug(" alendarView::keyPressEvent "); |
4669 | e->ignore(); | 4668 | e->ignore(); |
4670 | } | 4669 | } |
4671 | 4670 | ||
4672 | 4671 | ||
4673 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4672 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4674 | { | 4673 | { |
4675 | 4674 | ||
4676 | if ( manager != mSyncManager) | 4675 | if ( manager != mSyncManager) |
4677 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 4676 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
4678 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4677 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4679 | qDebug("KO: SyncKDE request detected!"); | 4678 | qDebug("KO: SyncKDE request detected!"); |
4680 | } | 4679 | } |
4681 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4680 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4682 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4681 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4683 | return syncCalendar( filename, mode ); | 4682 | return syncCalendar( filename, mode ); |
4684 | } | 4683 | } |
4685 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4684 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4686 | { | 4685 | { |
4687 | //mSyncManager = manager; | 4686 | //mSyncManager = manager; |
4688 | if ( manager != mSyncManager) | 4687 | if ( manager != mSyncManager) |
4689 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 4688 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
4690 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4689 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4691 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4690 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4692 | if ( resource == "sharp" ) | 4691 | if ( resource == "sharp" ) |
4693 | syncExternal( 0 ); | 4692 | syncExternal( 0 ); |
4694 | if ( resource == "phone" ) | 4693 | if ( resource == "phone" ) |
4695 | syncExternal( 1 ); | 4694 | syncExternal( 1 ); |
4696 | // pending setmodified | 4695 | // pending setmodified |
4697 | return true; | 4696 | return true; |
4698 | } | 4697 | } |
4699 | void CalendarView::setSyncManager(KSyncManager* manager) | 4698 | void CalendarView::setSyncManager(KSyncManager* manager) |
4700 | { | 4699 | { |
4701 | mSyncManager = manager; | 4700 | mSyncManager = manager; |
4702 | } | 4701 | } |
4703 | 4702 | ||
4704 | void CalendarView::removeSyncInfo( QString syncProfile) | 4703 | void CalendarView::removeSyncInfo( QString syncProfile) |
4705 | { | 4704 | { |
4706 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4705 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4707 | mCalendar->removeSyncInfo( syncProfile ); | 4706 | mCalendar->removeSyncInfo( syncProfile ); |
4708 | 4707 | ||
4709 | } | 4708 | } |
4710 | 4709 | ||
4711 | void CalendarView::undo_delete() | 4710 | void CalendarView::undo_delete() |
4712 | { | 4711 | { |
4713 | //qDebug("undo_delete() "); | 4712 | //qDebug("undo_delete() "); |
4714 | Incidence* undo = mCalendar->undoIncidence(); | 4713 | Incidence* undo = mCalendar->undoIncidence(); |
4715 | if ( !undo ) { | 4714 | if ( !undo ) { |
4716 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4715 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4717 | i18n("KO/Pi")); | 4716 | i18n("KO/Pi")); |
4718 | return; | 4717 | return; |
4719 | } | 4718 | } |
4720 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 4719 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
4721 | i18n("\nAre you sure you want\nto restore this?"), | 4720 | i18n("\nAre you sure you want\nto restore this?"), |
4722 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4721 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4723 | mCalendar->undoDeleteIncidence(); | 4722 | mCalendar->undoDeleteIncidence(); |
4724 | updateView(); | 4723 | updateView(); |
4725 | } | 4724 | } |
4726 | } | 4725 | } |
4727 | 4726 | ||
4728 | void CalendarView::slotViewerClosed() | 4727 | void CalendarView::slotViewerClosed() |
4729 | { | 4728 | { |
4730 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4729 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4731 | } | 4730 | } |
4732 | 4731 | ||
4733 | void CalendarView::resetFocus() | 4732 | void CalendarView::resetFocus() |
4734 | { | 4733 | { |
4735 | if ( mViewerCallerIsSearchDialog ) { | 4734 | if ( mViewerCallerIsSearchDialog ) { |
4736 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4735 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4737 | mDialogManager->getSearchDialog()->raise(); | 4736 | mDialogManager->getSearchDialog()->raise(); |
4738 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4737 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4739 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4738 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4740 | } else | 4739 | } else |
4741 | mViewerCallerIsSearchDialog = false; | 4740 | mViewerCallerIsSearchDialog = false; |
4742 | } | 4741 | } |
4743 | if ( !mViewerCallerIsSearchDialog ) { | 4742 | if ( !mViewerCallerIsSearchDialog ) { |
4744 | //mViewManager->currentView()->setFocus(); | 4743 | //mViewManager->currentView()->setFocus(); |
4745 | //qDebug("sssssssssssssssset focus "); | 4744 | //qDebug("sssssssssssssssset focus "); |
4746 | topLevelWidget()->raise(); | 4745 | topLevelWidget()->raise(); |
4747 | setActiveWindow(); | 4746 | setActiveWindow(); |
4748 | //setFocus(); | 4747 | //setFocus(); |
4749 | } | 4748 | } |
4750 | mViewerCallerIsSearchDialog = false; | 4749 | mViewerCallerIsSearchDialog = false; |
4751 | } | 4750 | } |
4752 | 4751 | ||
4753 | void CalendarView::showNextAlarms() | 4752 | void CalendarView::showNextAlarms() |
4754 | { | 4753 | { |
4755 | QString message; | 4754 | QString message; |
4756 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4755 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4757 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4756 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4758 | QString sum = mCalendar->nextSummary(); | 4757 | QString sum = mCalendar->nextSummary(); |
4759 | QDateTime nextA = mNextAlarmDateTime; | 4758 | QDateTime nextA = mNextAlarmDateTime; |
4760 | QDateTime cur = QDateTime::currentDateTime(); | 4759 | QDateTime cur = QDateTime::currentDateTime(); |
4761 | int secs = cur.secsTo( nextA ); | 4760 | int secs = cur.secsTo( nextA ); |
4762 | int min = secs /60; | 4761 | int min = secs /60; |
4763 | int hours = min /60; | 4762 | int hours = min /60; |
4764 | min = min % 60; | 4763 | min = min % 60; |
4765 | int days = hours /24; | 4764 | int days = hours /24; |
4766 | hours = hours % 24; | 4765 | hours = hours % 24; |
4767 | 4766 | ||
4768 | //message = i18n("The next alarm is in:\n"); | 4767 | //message = i18n("The next alarm is in:\n"); |
4769 | if ( days > 1 ) | 4768 | if ( days > 1 ) |
4770 | message += i18n("%1 days\n").arg( days ); | 4769 | message += i18n("%1 days\n").arg( days ); |
4771 | else if ( days == 1 ) | 4770 | else if ( days == 1 ) |
4772 | message += i18n("1 day\n"); | 4771 | message += i18n("1 day\n"); |
4773 | if ( hours > 1 ) | 4772 | if ( hours > 1 ) |
4774 | message += i18n("%1 hours\n").arg( hours ); | 4773 | message += i18n("%1 hours\n").arg( hours ); |
4775 | else if ( hours == 1 ) | 4774 | else if ( hours == 1 ) |
4776 | message += i18n("1 hour\n"); | 4775 | message += i18n("1 hour\n"); |
4777 | if ( min > 1 ) | 4776 | if ( min > 1 ) |
4778 | message += i18n("%1 minutes\n").arg( min ); | 4777 | message += i18n("%1 minutes\n").arg( min ); |
4779 | else if ( min == 1 ) | 4778 | else if ( min == 1 ) |
4780 | message += i18n("1 minute\n"); | 4779 | message += i18n("1 minute\n"); |
4781 | if ( message.isEmpty() ) | 4780 | if ( message.isEmpty() ) |
4782 | message = i18n("The next alarm is in\nless than one minute!"); | 4781 | message = i18n("The next alarm is in\nless than one minute!"); |
4783 | else | 4782 | else |
4784 | message = i18n("The next alarm is in:\n") + message; | 4783 | message = i18n("The next alarm is in:\n") + message; |
4785 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4784 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4786 | } else { | 4785 | } else { |
4787 | message = i18n("There is no next alarm."); | 4786 | message = i18n("There is no next alarm."); |
4788 | 4787 | ||
4789 | } | 4788 | } |
4790 | #ifdef DESKTOP_VERSION | 4789 | #ifdef DESKTOP_VERSION |
4791 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4790 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4792 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4791 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4793 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4792 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4794 | } | 4793 | } |
4795 | 4794 | ||
4796 | #endif | 4795 | #endif |
4797 | KMessageBox::information( this, message); | 4796 | KMessageBox::information( this, message); |
4798 | } | 4797 | } |