author | zautrix <zautrix> | 2005-07-26 14:26:36 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-26 14:26:36 (UTC) |
commit | e1d72bb77c51ff7313b390f263bc1f10d20123b0 (patch) (unidiff) | |
tree | 35f6cb7936a6e05914bdb9329ece3143c8c9a2f7 /korganizer | |
parent | 08f8edb64a919e51ad6e1a62031569a629cffa0f (diff) | |
download | kdepimpi-e1d72bb77c51ff7313b390f263bc1f10d20123b0.zip kdepimpi-e1d72bb77c51ff7313b390f263bc1f10d20123b0.tar.gz kdepimpi-e1d72bb77c51ff7313b390f263bc1f10d20123b0.tar.bz2 |
fixx
-rw-r--r-- | korganizer/calendarview.cpp | 7 | ||||
-rw-r--r-- | korganizer/kofilterview.cpp | 10 |
2 files changed, 11 insertions, 6 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 9674921..3ab4bb4 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4853 +1,4854 @@ | |||
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 ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
452 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
454 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
455 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
456 | #endif | 456 | #endif |
457 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
459 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
460 | #if 0 | 460 | #if 0 |
461 | // FIXME | 461 | // FIXME |
462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
463 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
464 | #endif | 464 | #endif |
465 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
466 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
480 | 480 | ||
481 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
482 | #if 0 | 482 | #if 0 |
483 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
484 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
485 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
486 | 486 | ||
487 | } else { | 487 | } else { |
488 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
489 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
490 | } | 490 | } |
491 | #endif | 491 | #endif |
492 | mFilterView->hide(); | 492 | mFilterView->hide(); |
493 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
494 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
495 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
497 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
498 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
499 | 499 | ||
500 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
501 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
506 | } else { | 506 | } else { |
507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
510 | } | 510 | } |
511 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
512 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
513 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
517 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
518 | 518 | ||
519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
521 | 521 | ||
522 | 522 | ||
523 | 523 | ||
524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
529 | 529 | ||
530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
531 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
532 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
533 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
535 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
537 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
538 | 538 | ||
539 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
540 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
541 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
542 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
545 | 545 | ||
546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
548 | #if 0 | 548 | #if 0 |
549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
550 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
551 | #endif | 551 | #endif |
552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
553 | 553 | ||
554 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
555 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
558 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
560 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
562 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
564 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
566 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
569 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
571 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
572 | 572 | ||
573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
576 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
577 | 577 | ||
578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
579 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
581 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
582 | 582 | ||
583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
584 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
585 | 585 | ||
586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
589 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
592 | 592 | ||
593 | 593 | ||
594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | 602 | ||
603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
604 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
606 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
608 | 608 | ||
609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
610 | 610 | ||
611 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
614 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
615 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
616 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
618 | 618 | ||
619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
620 | 620 | ||
621 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
622 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
623 | 623 | ||
624 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
625 | 625 | ||
626 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
627 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
628 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
632 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
634 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
636 | 636 | ||
637 | 637 | ||
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
642 | #endif | 642 | #endif |
643 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
648 | { | 648 | { |
649 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
650 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
651 | delete mDialogManager; | 651 | delete mDialogManager; |
652 | delete mViewManager; | 652 | delete mViewManager; |
653 | delete mStorage; | 653 | delete mStorage; |
654 | delete mDateFrame ; | 654 | delete mDateFrame ; |
655 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
656 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
657 | } | 657 | } |
658 | 658 | ||
659 | 659 | ||
660 | void CalendarView::nextConflict( bool all, bool allday ) | 660 | void CalendarView::nextConflict( bool all, bool allday ) |
661 | { | 661 | { |
662 | static bool block = false; | 662 | static bool block = false; |
663 | if ( block ) return; | 663 | if ( block ) return; |
664 | block = true; | 664 | block = true; |
665 | QPtrList<Event> testlist = mCalendar->events(); | 665 | QPtrList<Event> testlist = mCalendar->events(); |
666 | Event * test = testlist.first(); | 666 | Event * test = testlist.first(); |
667 | while ( test ) { | 667 | while ( test ) { |
668 | test->setTagged( false ); | 668 | test->setTagged( false ); |
669 | test = testlist.next(); | 669 | test = testlist.next(); |
670 | } | 670 | } |
671 | QTime st ( 0,0,0); | 671 | QTime st ( 0,0,0); |
672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
673 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 673 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
674 | //qDebug("time %s ", st.toString().latin1()); | 674 | //qDebug("time %s ", st.toString().latin1()); |
675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
676 | QDateTime conflict; | 676 | QDateTime conflict; |
677 | QDateTime retVal; | 677 | QDateTime retVal; |
678 | bool found = false; | 678 | bool found = false; |
679 | Event * cE = 0; | 679 | Event * cE = 0; |
680 | Event * cE2 = 0; | 680 | Event * cE2 = 0; |
681 | QPtrList<Event> testlist2 = testlist; | 681 | QPtrList<Event> testlist2 = testlist; |
682 | test = testlist.first(); | 682 | test = testlist.first(); |
683 | bool skip = false; | 683 | bool skip = false; |
684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
685 | //QTime tm; | 685 | //QTime tm; |
686 | //tm.start(); | 686 | //tm.start(); |
687 | while ( test ) { | 687 | while ( test ) { |
688 | qApp->processEvents(); | 688 | qApp->processEvents(); |
689 | skip = false; | 689 | skip = false; |
690 | if ( !all ) skip = ( allday != test->doesFloat() ); | 690 | if ( !all ) skip = ( allday != test->doesFloat() ); |
691 | if ( !skip ) { | 691 | if ( !skip ) { |
692 | if ( found ) | 692 | if ( found ) |
693 | skip = !test->matchTime( &startDT, &conflict ); | 693 | skip = !test->matchTime( &startDT, &conflict ); |
694 | else | 694 | else |
695 | skip = !test->matchTime( &startDT, 0 ); | 695 | skip = !test->matchTime( &startDT, 0 ); |
696 | } | 696 | } |
697 | if ( !skip ) { | 697 | if ( !skip ) { |
698 | Event * test2 = testlist2.first(); | 698 | Event * test2 = testlist2.first(); |
699 | while ( test2 ) { | 699 | while ( test2 ) { |
700 | skip = test2->isTagged(); | 700 | skip = test2->isTagged(); |
701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); | 701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); |
702 | if ( !skip ) { | 702 | if ( !skip ) { |
703 | if ( found ) | 703 | if ( found ) |
704 | skip = !test2->matchTime( &startDT, &conflict ); | 704 | skip = !test2->matchTime( &startDT, &conflict ); |
705 | else | 705 | else |
706 | skip = !test2->matchTime( &startDT, 0 ); | 706 | skip = !test2->matchTime( &startDT, 0 ); |
707 | } | 707 | } |
708 | if ( !skip ) { | 708 | if ( !skip ) { |
709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
710 | //qDebug("overlap "); | 710 | //qDebug("overlap "); |
711 | if ( ! found ) { | 711 | if ( ! found ) { |
712 | if ( retVal >= startDT ) { | 712 | if ( retVal >= startDT ) { |
713 | conflict = retVal; | 713 | conflict = retVal; |
714 | cE = test; | 714 | cE = test; |
715 | cE2 = test2; | 715 | cE2 = test2; |
716 | found = true; | 716 | found = true; |
717 | } | 717 | } |
718 | } else { | 718 | } else { |
719 | if ( retVal >= startDT && retVal < conflict ) { | 719 | if ( retVal >= startDT && retVal < conflict ) { |
720 | conflict = retVal; | 720 | conflict = retVal; |
721 | cE = test; | 721 | cE = test; |
722 | cE2 = test2; | 722 | cE2 = test2; |
723 | } | 723 | } |
724 | } | 724 | } |
725 | } | 725 | } |
726 | } | 726 | } |
727 | test2 = testlist2.next(); | 727 | test2 = testlist2.next(); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | test->setTagged( true ); | 730 | test->setTagged( true ); |
731 | test = testlist.next(); | 731 | test = testlist.next(); |
732 | } | 732 | } |
733 | //qDebug("Search time : %d", tm.elapsed()); | 733 | //qDebug("Search time : %d", tm.elapsed()); |
734 | if ( found ) { | 734 | if ( found ) { |
735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
736 | mViewManager->showDayView(); | 736 | mViewManager->showDayView(); |
737 | mNavigator->slotDaySelect( conflict.date() ); | 737 | mNavigator->slotDaySelect( conflict.date() ); |
738 | int hour = conflict.time().hour(); | 738 | int hour = conflict.time().hour(); |
739 | mViewManager->agendaView()->setStartHour( hour ); | 739 | mViewManager->agendaView()->setStartHour( hour ); |
740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
741 | block = false; | 741 | block = false; |
742 | return; | 742 | return; |
743 | } | 743 | } |
744 | 744 | ||
745 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 745 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
746 | qDebug("No conflict found "); | 746 | //qDebug("No conflict found "); |
747 | block = false; | 747 | block = false; |
748 | return; | 748 | return; |
749 | } | 749 | } |
750 | 750 | ||
751 | void CalendarView::conflictAll() | 751 | void CalendarView::conflictAll() |
752 | { | 752 | { |
753 | nextConflict ( true, true ); | 753 | nextConflict ( true, true ); |
754 | } | 754 | } |
755 | void CalendarView::conflictAllday() | 755 | void CalendarView::conflictAllday() |
756 | { | 756 | { |
757 | nextConflict ( false, true ); | 757 | nextConflict ( false, true ); |
758 | } | 758 | } |
759 | void CalendarView::conflictNotAll() | 759 | void CalendarView::conflictNotAll() |
760 | { | 760 | { |
761 | nextConflict ( false, false ); | 761 | nextConflict ( false, false ); |
762 | } | 762 | } |
763 | 763 | ||
764 | void CalendarView::setCalReadOnly( int id, bool readO ) | 764 | void CalendarView::setCalReadOnly( int id, bool readO ) |
765 | { | 765 | { |
766 | if ( readO ) { | 766 | if ( readO ) { |
767 | emit save(); | 767 | emit save(); |
768 | } | 768 | } |
769 | mCalendar->setReadOnly( id, readO ); | 769 | mCalendar->setReadOnly( id, readO ); |
770 | } | 770 | } |
771 | void CalendarView::setScrollBarStep(int val ) | 771 | void CalendarView::setScrollBarStep(int val ) |
772 | { | 772 | { |
773 | #ifdef DESKTOP_VERSION | 773 | #ifdef DESKTOP_VERSION |
774 | mDateScrollBar->setLineStep ( val ); | 774 | mDateScrollBar->setLineStep ( val ); |
775 | #endif | 775 | #endif |
776 | } | 776 | } |
777 | void CalendarView::scrollBarValue(int val ) | 777 | void CalendarView::scrollBarValue(int val ) |
778 | { | 778 | { |
779 | #ifdef DESKTOP_VERSION | 779 | #ifdef DESKTOP_VERSION |
780 | if ( QApplication::desktop()->width() < 800 ) return; | 780 | if ( QApplication::desktop()->width() < 800 ) return; |
781 | static bool block = false; | 781 | static bool block = false; |
782 | if ( block ) return; | 782 | if ( block ) return; |
783 | block = true; | 783 | block = true; |
784 | int count = mNavigator->selectedDates().count(); | 784 | int count = mNavigator->selectedDates().count(); |
785 | int day = mNavigator->selectedDates().first().dayOfYear(); | 785 | int day = mNavigator->selectedDates().first().dayOfYear(); |
786 | int stepdays = val; | 786 | int stepdays = val; |
787 | if ( mDateScrollBar->lineStep () <= count ) { | 787 | if ( mDateScrollBar->lineStep () <= count ) { |
788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
789 | //qDebug("VAL %d ",val ); | 789 | //qDebug("VAL %d ",val ); |
790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
791 | stepdays = day+stepdays; | 791 | stepdays = day+stepdays; |
792 | if ( stepdays < 0 ) stepdays = 0; | 792 | if ( stepdays < 0 ) stepdays = 0; |
793 | } | 793 | } |
794 | if ( stepdays == day ) { | 794 | if ( stepdays == day ) { |
795 | block = false; | 795 | block = false; |
796 | return; | 796 | return; |
797 | } | 797 | } |
798 | int year = mNavigator->selectedDates().first().year(); | 798 | int year = mNavigator->selectedDates().first().year(); |
799 | QDate d ( year,1,1 ); | 799 | QDate d ( year,1,1 ); |
800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
801 | block = false; | 801 | block = false; |
802 | #endif | 802 | #endif |
803 | 803 | ||
804 | } | 804 | } |
805 | void CalendarView::updateView(const QDate &start, const QDate &end) | 805 | void CalendarView::updateView(const QDate &start, const QDate &end) |
806 | { | 806 | { |
807 | #ifdef DESKTOP_VERSION | 807 | #ifdef DESKTOP_VERSION |
808 | if ( ! mDateScrollBar->draggingSlider () ) { | 808 | if ( ! mDateScrollBar->draggingSlider () ) { |
809 | int dof = start.dayOfYear(); | 809 | int dof = start.dayOfYear(); |
810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
811 | if ( dof != mDateScrollBar->value() ) { | 811 | if ( dof != mDateScrollBar->value() ) { |
812 | mDateScrollBar->blockSignals( true ); | 812 | mDateScrollBar->blockSignals( true ); |
813 | mDateScrollBar->setValue( start.dayOfYear()); | 813 | mDateScrollBar->setValue( start.dayOfYear()); |
814 | mDateScrollBar->blockSignals( false ); | 814 | mDateScrollBar->blockSignals( false ); |
815 | } | 815 | } |
816 | } | 816 | } |
817 | #endif | 817 | #endif |
818 | mTodoList->updateView(); | 818 | mTodoList->updateView(); |
819 | mViewManager->updateView(start, end); | 819 | mViewManager->updateView(start, end); |
820 | //mDateNavigator->updateView(); | 820 | //mDateNavigator->updateView(); |
821 | } | 821 | } |
822 | 822 | ||
823 | 823 | ||
824 | 824 | ||
825 | void CalendarView::checkFiles() | 825 | void CalendarView::checkFiles() |
826 | { | 826 | { |
827 | QString message; | 827 | QString message; |
828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
829 | KopiCalendarFile * cal = calendars.first(); | 829 | KopiCalendarFile * cal = calendars.first(); |
830 | while ( cal ) { | 830 | while ( cal ) { |
831 | if ( cal->mErrorOnLoad ) { | 831 | if ( cal->mErrorOnLoad ) { |
832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
833 | } | 833 | } |
834 | cal = calendars.next(); | 834 | cal = calendars.next(); |
835 | } | 835 | } |
836 | if ( !message.isEmpty() ) { | 836 | if ( !message.isEmpty() ) { |
837 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); | 837 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
838 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 838 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
839 | } | 839 | } |
840 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 840 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
841 | } | 841 | } |
842 | void CalendarView::checkAlarms() | 842 | void CalendarView::checkAlarms() |
843 | { | 843 | { |
844 | 844 | ||
845 | 845 | ||
846 | KConfig *config = KOGlobals::config(); | 846 | KConfig *config = KOGlobals::config(); |
847 | config->setGroup( "AppRun" ); | 847 | config->setGroup( "AppRun" ); |
848 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 848 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
849 | int daysto = dt.daysTo( QDate::currentDate() ); | 849 | int daysto = dt.daysTo( QDate::currentDate() ); |
850 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 850 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
851 | dt = dt.addDays( days ); | 851 | dt = dt.addDays( days ); |
852 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 852 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
853 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 853 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
854 | //qDebug("KO: Reading program stop %d ", secs); | 854 | //qDebug("KO: Reading program stop %d ", secs); |
855 | //secs -= ( 3600 * 24*3 ); // debug only | 855 | //secs -= ( 3600 * 24*3 ); // debug only |
856 | QDateTime latest = dt.addSecs ( secs ); | 856 | QDateTime latest = dt.addSecs ( secs ); |
857 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 857 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
858 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 858 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
859 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 859 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
860 | QPtrList<Incidence> al; | 860 | QPtrList<Incidence> al; |
861 | Incidence* inL = el.first(); | 861 | Incidence* inL = el.first(); |
862 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 862 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
863 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 863 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
864 | while ( inL ) { | 864 | while ( inL ) { |
865 | bool ok = false; | 865 | bool ok = false; |
866 | int offset = 0; | 866 | int offset = 0; |
867 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 867 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
868 | if ( ok ) { | 868 | if ( ok ) { |
869 | //qDebug("OK %s",next.toString().latin1()); | 869 | //qDebug("OK %s",next.toString().latin1()); |
870 | if ( next < cur ) { | 870 | if ( next < cur ) { |
871 | al.append( inL ); | 871 | al.append( inL ); |
872 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 872 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | inL = el.next(); | 875 | inL = el.next(); |
876 | } | 876 | } |
877 | if ( al.count() ) { | 877 | if ( al.count() ) { |
878 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 878 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
879 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 879 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
880 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 880 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
881 | lay->setSpacing( 0 ); | 881 | lay->setSpacing( 0 ); |
882 | lay->setMargin( 0 ); | 882 | lay->setMargin( 0 ); |
883 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 883 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
884 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 884 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
885 | lay->addWidget( matb ); | 885 | lay->addWidget( matb ); |
886 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 886 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
887 | int wid = 210; | 887 | int wid = 210; |
888 | int x = QApplication::desktop()->width() - wid - 7; | 888 | int x = QApplication::desktop()->width() - wid - 7; |
889 | int y = QApplication::desktop()->height() - wid - 70; | 889 | int y = QApplication::desktop()->height() - wid - 70; |
890 | dia->setGeometry ( x,y,wid,wid); | 890 | dia->setGeometry ( x,y,wid,wid); |
891 | } else { | 891 | } else { |
892 | int si = 220; | 892 | int si = 220; |
893 | if ( QApplication::desktop()->width() > 470 ) | 893 | if ( QApplication::desktop()->width() > 470 ) |
894 | si = 400; | 894 | si = 400; |
895 | dia->resize(si,si/2); | 895 | dia->resize(si,si/2); |
896 | } | 896 | } |
897 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 897 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
898 | dia->show(); | 898 | dia->show(); |
899 | 899 | ||
900 | } | 900 | } |
901 | } | 901 | } |
902 | void CalendarView::showDay( QDate d ) | 902 | void CalendarView::showDay( QDate d ) |
903 | { | 903 | { |
904 | dateNavigator()->blockSignals( true ); | 904 | dateNavigator()->blockSignals( true ); |
905 | dateNavigator()->selectDate( d ); | 905 | dateNavigator()->selectDate( d ); |
906 | dateNavigator()->blockSignals( false ); | 906 | dateNavigator()->blockSignals( false ); |
907 | mViewManager->showDayView(); | 907 | mViewManager->showDayView(); |
908 | //dateNavigator()->selectDate( d ); | 908 | //dateNavigator()->selectDate( d ); |
909 | } | 909 | } |
910 | void CalendarView::timerAlarm() | 910 | void CalendarView::timerAlarm() |
911 | { | 911 | { |
912 | //qDebug("CalendarView::timerAlarm() "); | 912 | //qDebug("CalendarView::timerAlarm() "); |
913 | computeAlarm(mAlarmNotification ); | 913 | computeAlarm(mAlarmNotification ); |
914 | } | 914 | } |
915 | 915 | ||
916 | void CalendarView::suspendAlarm() | 916 | void CalendarView::suspendAlarm() |
917 | { | 917 | { |
918 | //qDebug(" CalendarView::suspendAlarm() "); | 918 | //qDebug(" CalendarView::suspendAlarm() "); |
919 | computeAlarm(mSuspendAlarmNotification ); | 919 | computeAlarm(mSuspendAlarmNotification ); |
920 | 920 | ||
921 | } | 921 | } |
922 | 922 | ||
923 | void CalendarView::startAlarm( QString mess , QString filename) | 923 | void CalendarView::startAlarm( QString mess , QString filename) |
924 | { | 924 | { |
925 | 925 | ||
926 | topLevelWidget()->showNormal(); | 926 | topLevelWidget()->showNormal(); |
927 | topLevelWidget()->setActiveWindow(); | 927 | topLevelWidget()->setActiveWindow(); |
928 | topLevelWidget()->raise(); | 928 | topLevelWidget()->raise(); |
929 | 929 | ||
930 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 930 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
931 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 931 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
932 | 932 | ||
933 | } | 933 | } |
934 | 934 | ||
935 | void CalendarView::checkNextTimerAlarm() | 935 | void CalendarView::checkNextTimerAlarm() |
936 | { | 936 | { |
937 | mCalendar->checkAlarmForIncidence( 0, true ); | 937 | mCalendar->checkAlarmForIncidence( 0, true ); |
938 | } | 938 | } |
939 | 939 | ||
940 | void CalendarView::computeAlarm( QString msg ) | 940 | void CalendarView::computeAlarm( QString msg ) |
941 | { | 941 | { |
942 | 942 | ||
943 | QString mess = msg; | 943 | QString mess = msg; |
944 | QString mAlarmMessage = mess.mid( 9 ); | 944 | QString mAlarmMessage = mess.mid( 9 ); |
945 | QString filename = MainWindow::resourcePath(); | 945 | QString filename = MainWindow::resourcePath(); |
946 | filename += "koalarm.wav"; | 946 | filename += "koalarm.wav"; |
947 | QString tempfilename; | 947 | QString tempfilename; |
948 | if ( mess.left( 13 ) == "suspend_alarm") { | 948 | if ( mess.left( 13 ) == "suspend_alarm") { |
949 | bool error = false; | 949 | bool error = false; |
950 | int len = mess.mid( 13 ).find("+++"); | 950 | int len = mess.mid( 13 ).find("+++"); |
951 | if ( len < 2 ) | 951 | if ( len < 2 ) |
952 | error = true; | 952 | error = true; |
953 | else { | 953 | else { |
954 | tempfilename = mess.mid( 13, len ); | 954 | tempfilename = mess.mid( 13, len ); |
955 | if ( !QFile::exists( tempfilename ) ) | 955 | if ( !QFile::exists( tempfilename ) ) |
956 | error = true; | 956 | error = true; |
957 | } | 957 | } |
958 | if ( ! error ) { | 958 | if ( ! error ) { |
959 | filename = tempfilename; | 959 | filename = tempfilename; |
960 | } | 960 | } |
961 | mAlarmMessage = mess.mid( 13+len+3 ); | 961 | mAlarmMessage = mess.mid( 13+len+3 ); |
962 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 962 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
963 | startAlarm( mAlarmMessage, filename); | 963 | startAlarm( mAlarmMessage, filename); |
964 | return; | 964 | return; |
965 | } | 965 | } |
966 | if ( mess.left( 11 ) == "timer_alarm") { | 966 | if ( mess.left( 11 ) == "timer_alarm") { |
967 | //mTimerTime = 0; | 967 | //mTimerTime = 0; |
968 | startAlarm( mess.mid( 11 ), filename ); | 968 | startAlarm( mess.mid( 11 ), filename ); |
969 | return; | 969 | return; |
970 | } | 970 | } |
971 | if ( mess.left( 10 ) == "proc_alarm") { | 971 | if ( mess.left( 10 ) == "proc_alarm") { |
972 | bool error = false; | 972 | bool error = false; |
973 | int len = mess.mid( 10 ).find("+++"); | 973 | int len = mess.mid( 10 ).find("+++"); |
974 | if ( len < 2 ) | 974 | if ( len < 2 ) |
975 | error = true; | 975 | error = true; |
976 | else { | 976 | else { |
977 | tempfilename = mess.mid( 10, len ); | 977 | tempfilename = mess.mid( 10, len ); |
978 | if ( !QFile::exists( tempfilename ) ) | 978 | if ( !QFile::exists( tempfilename ) ) |
979 | error = true; | 979 | error = true; |
980 | } | 980 | } |
981 | if ( error ) { | 981 | if ( error ) { |
982 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 982 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
983 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 983 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
984 | } else { | 984 | } else { |
985 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 985 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
986 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 986 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
987 | #ifndef _WIN32_ | 987 | #ifndef _WIN32_ |
988 | if ( vfork () == 0 ) { | 988 | if ( vfork () == 0 ) { |
989 | execl ( tempfilename.latin1(), 0 ); | 989 | execl ( tempfilename.latin1(), 0 ); |
990 | return; | 990 | return; |
991 | } | 991 | } |
992 | #else | 992 | #else |
993 | QProcess* p = new QProcess(); | 993 | QProcess* p = new QProcess(); |
994 | p->addArgument( tempfilename.latin1() ); | 994 | p->addArgument( tempfilename.latin1() ); |
995 | p->start(); | 995 | p->start(); |
996 | return; | 996 | return; |
997 | #endif | 997 | #endif |
998 | 998 | ||
999 | return; | 999 | return; |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1002 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1003 | } | 1003 | } |
1004 | if ( mess.left( 11 ) == "audio_alarm") { | 1004 | if ( mess.left( 11 ) == "audio_alarm") { |
1005 | bool error = false; | 1005 | bool error = false; |
1006 | int len = mess.mid( 11 ).find("+++"); | 1006 | int len = mess.mid( 11 ).find("+++"); |
1007 | if ( len < 2 ) | 1007 | if ( len < 2 ) |
1008 | error = true; | 1008 | error = true; |
1009 | else { | 1009 | else { |
1010 | tempfilename = mess.mid( 11, len ); | 1010 | tempfilename = mess.mid( 11, len ); |
1011 | if ( !QFile::exists( tempfilename ) ) | 1011 | if ( !QFile::exists( tempfilename ) ) |
1012 | error = true; | 1012 | error = true; |
1013 | } | 1013 | } |
1014 | if ( ! error ) { | 1014 | if ( ! error ) { |
1015 | filename = tempfilename; | 1015 | filename = tempfilename; |
1016 | } | 1016 | } |
1017 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1017 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1018 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1018 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1019 | } | 1019 | } |
1020 | if ( mess.left( 9 ) == "cal_alarm") { | 1020 | if ( mess.left( 9 ) == "cal_alarm") { |
1021 | mAlarmMessage = mess.mid( 9 ) ; | 1021 | mAlarmMessage = mess.mid( 9 ) ; |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | startAlarm( mAlarmMessage, filename ); | 1024 | startAlarm( mAlarmMessage, filename ); |
1025 | 1025 | ||
1026 | 1026 | ||
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1029 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1030 | { | 1030 | { |
1031 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1031 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1032 | 1032 | ||
1033 | mSuspendAlarmNotification = noti; | 1033 | mSuspendAlarmNotification = noti; |
1034 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1034 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1035 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1035 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1036 | mSuspendTimer->start( ms , true ); | 1036 | mSuspendTimer->start( ms , true ); |
1037 | 1037 | ||
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1040 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1041 | { | 1041 | { |
1042 | mNextAlarmDateTime = qdt; | 1042 | mNextAlarmDateTime = qdt; |
1043 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1043 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1044 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1044 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1045 | #ifndef DESKTOP_VERSION | 1045 | #ifndef DESKTOP_VERSION |
1046 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1046 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1047 | #endif | 1047 | #endif |
1048 | return; | 1048 | return; |
1049 | } | 1049 | } |
1050 | int maxSec; | 1050 | int maxSec; |
1051 | //maxSec = 5; //testing only | 1051 | //maxSec = 5; //testing only |
1052 | maxSec = 86400+3600; // one day+1hour | 1052 | maxSec = 86400+3600; // one day+1hour |
1053 | mAlarmNotification = noti; | 1053 | mAlarmNotification = noti; |
1054 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1054 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1055 | if ( sec > maxSec ) { | 1055 | if ( sec > maxSec ) { |
1056 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1056 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1057 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1057 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1058 | return; | 1058 | return; |
1059 | } else { | 1059 | } else { |
1060 | mRecheckAlarmTimer->stop(); | 1060 | mRecheckAlarmTimer->stop(); |
1061 | } | 1061 | } |
1062 | //qDebug("Alarm timer started with secs: %d ", sec); | 1062 | //qDebug("Alarm timer started with secs: %d ", sec); |
1063 | mAlarmTimer->start( sec *1000 , true ); | 1063 | mAlarmTimer->start( sec *1000 , true ); |
1064 | 1064 | ||
1065 | } | 1065 | } |
1066 | // called by mRecheckAlarmTimer to get next alarm | 1066 | // called by mRecheckAlarmTimer to get next alarm |
1067 | // we need this, because a QTimer has only a max range of 25 days | 1067 | // we need this, because a QTimer has only a max range of 25 days |
1068 | void CalendarView::recheckTimerAlarm() | 1068 | void CalendarView::recheckTimerAlarm() |
1069 | { | 1069 | { |
1070 | mAlarmTimer->stop(); | 1070 | mAlarmTimer->stop(); |
1071 | mRecheckAlarmTimer->stop(); | 1071 | mRecheckAlarmTimer->stop(); |
1072 | mCalendar->checkAlarmForIncidence( 0, true ); | 1072 | mCalendar->checkAlarmForIncidence( 0, true ); |
1073 | } | 1073 | } |
1074 | #ifndef DESKTOP_VERSION | 1074 | #ifndef DESKTOP_VERSION |
1075 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1075 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1076 | #else | 1076 | #else |
1077 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1077 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1078 | #endif | 1078 | #endif |
1079 | { | 1079 | { |
1080 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1080 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1081 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1081 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1082 | #ifndef DESKTOP_VERSION | 1082 | #ifndef DESKTOP_VERSION |
1083 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1083 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1084 | #endif | 1084 | #endif |
1085 | return; | 1085 | return; |
1086 | } | 1086 | } |
1087 | mAlarmTimer->stop(); | 1087 | mAlarmTimer->stop(); |
1088 | } | 1088 | } |
1089 | void CalendarView::selectWeekNum ( int num ) | 1089 | void CalendarView::selectWeekNum ( int num ) |
1090 | { | 1090 | { |
1091 | dateNavigator()->blockSignals( true ); | 1091 | dateNavigator()->blockSignals( true ); |
1092 | dateNavigator()->selectWeek( num ); | 1092 | dateNavigator()->selectWeek( num ); |
1093 | dateNavigator()->blockSignals( false ); | 1093 | dateNavigator()->blockSignals( false ); |
1094 | mViewManager->showWeekView(); | 1094 | mViewManager->showWeekView(); |
1095 | } | 1095 | } |
1096 | KOViewManager *CalendarView::viewManager() | 1096 | KOViewManager *CalendarView::viewManager() |
1097 | { | 1097 | { |
1098 | return mViewManager; | 1098 | return mViewManager; |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | KODialogManager *CalendarView::dialogManager() | 1101 | KODialogManager *CalendarView::dialogManager() |
1102 | { | 1102 | { |
1103 | return mDialogManager; | 1103 | return mDialogManager; |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | QDate CalendarView::startDate() | 1106 | QDate CalendarView::startDate() |
1107 | { | 1107 | { |
1108 | DateList dates = mNavigator->selectedDates(); | 1108 | DateList dates = mNavigator->selectedDates(); |
1109 | 1109 | ||
1110 | return dates.first(); | 1110 | return dates.first(); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | QDate CalendarView::endDate() | 1113 | QDate CalendarView::endDate() |
1114 | { | 1114 | { |
1115 | DateList dates = mNavigator->selectedDates(); | 1115 | DateList dates = mNavigator->selectedDates(); |
1116 | 1116 | ||
1117 | return dates.last(); | 1117 | return dates.last(); |
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | 1120 | ||
1121 | void CalendarView::createPrinter() | 1121 | void CalendarView::createPrinter() |
1122 | { | 1122 | { |
1123 | #ifndef KORG_NOPRINTER | 1123 | #ifndef KORG_NOPRINTER |
1124 | if (!mCalPrinter) { | 1124 | if (!mCalPrinter) { |
1125 | mCalPrinter = new CalPrinter(this, mCalendar); | 1125 | mCalPrinter = new CalPrinter(this, mCalendar); |
1126 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1126 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1127 | } | 1127 | } |
1128 | #endif | 1128 | #endif |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | 1131 | ||
1132 | //KOPrefs::instance()->mWriteBackFile | 1132 | //KOPrefs::instance()->mWriteBackFile |
1133 | //KOPrefs::instance()->mWriteBackExistingOnly | 1133 | //KOPrefs::instance()->mWriteBackExistingOnly |
1134 | 1134 | ||
1135 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1135 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1136 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1136 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1137 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1137 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1138 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1138 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1139 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1139 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1140 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1140 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1141 | 1141 | ||
1142 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1142 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1143 | { | 1143 | { |
1144 | 1144 | ||
1145 | // 0 equal | 1145 | // 0 equal |
1146 | // 1 take local | 1146 | // 1 take local |
1147 | // 2 take remote | 1147 | // 2 take remote |
1148 | // 3 cancel | 1148 | // 3 cancel |
1149 | QDateTime lastSync = mLastCalendarSync; | 1149 | QDateTime lastSync = mLastCalendarSync; |
1150 | QDateTime localMod = local->lastModified(); | 1150 | QDateTime localMod = local->lastModified(); |
1151 | QDateTime remoteMod = remote->lastModified(); | 1151 | QDateTime remoteMod = remote->lastModified(); |
1152 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1152 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1153 | bool remCh, locCh; | 1153 | bool remCh, locCh; |
1154 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1154 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1155 | //if ( remCh ) | 1155 | //if ( remCh ) |
1156 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1156 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1157 | locCh = ( localMod > mLastCalendarSync ); | 1157 | locCh = ( localMod > mLastCalendarSync ); |
1158 | if ( !remCh && ! locCh ) { | 1158 | if ( !remCh && ! locCh ) { |
1159 | //qDebug("both not changed "); | 1159 | //qDebug("both not changed "); |
1160 | lastSync = localMod.addDays(1); | 1160 | lastSync = localMod.addDays(1); |
1161 | if ( mode <= SYNC_PREF_ASK ) | 1161 | if ( mode <= SYNC_PREF_ASK ) |
1162 | return 0; | 1162 | return 0; |
1163 | } else { | 1163 | } else { |
1164 | if ( locCh ) { | 1164 | if ( locCh ) { |
1165 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1165 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1166 | lastSync = localMod.addDays( -1 ); | 1166 | lastSync = localMod.addDays( -1 ); |
1167 | if ( !remCh ) | 1167 | if ( !remCh ) |
1168 | remoteMod = ( lastSync.addDays( -1 ) ); | 1168 | remoteMod = ( lastSync.addDays( -1 ) ); |
1169 | } else { | 1169 | } else { |
1170 | //qDebug(" not loc changed "); | 1170 | //qDebug(" not loc changed "); |
1171 | lastSync = localMod.addDays( 1 ); | 1171 | lastSync = localMod.addDays( 1 ); |
1172 | if ( remCh ) | 1172 | if ( remCh ) |
1173 | remoteMod =( lastSync.addDays( 1 ) ); | 1173 | remoteMod =( lastSync.addDays( 1 ) ); |
1174 | 1174 | ||
1175 | } | 1175 | } |
1176 | } | 1176 | } |
1177 | full = true; | 1177 | full = true; |
1178 | if ( mode < SYNC_PREF_ASK ) | 1178 | if ( mode < SYNC_PREF_ASK ) |
1179 | mode = SYNC_PREF_ASK; | 1179 | mode = SYNC_PREF_ASK; |
1180 | } else { | 1180 | } else { |
1181 | if ( localMod == remoteMod ) | 1181 | if ( localMod == remoteMod ) |
1182 | // if ( local->revision() == remote->revision() ) | 1182 | // if ( local->revision() == remote->revision() ) |
1183 | return 0; | 1183 | return 0; |
1184 | 1184 | ||
1185 | } | 1185 | } |
1186 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1186 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1187 | 1187 | ||
1188 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1188 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1189 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1189 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1190 | //full = true; //debug only | 1190 | //full = true; //debug only |
1191 | if ( full ) { | 1191 | if ( full ) { |
1192 | bool equ = false; | 1192 | bool equ = false; |
1193 | if ( local->typeID() == eventID ) { | 1193 | if ( local->typeID() == eventID ) { |
1194 | equ = (*((Event*) local) == *((Event*) remote)); | 1194 | equ = (*((Event*) local) == *((Event*) remote)); |
1195 | } | 1195 | } |
1196 | else if ( local->typeID() == todoID ) | 1196 | else if ( local->typeID() == todoID ) |
1197 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1197 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1198 | else if ( local->typeID() == journalID ) | 1198 | else if ( local->typeID() == journalID ) |
1199 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1199 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1200 | if ( equ ) { | 1200 | if ( equ ) { |
1201 | //qDebug("equal "); | 1201 | //qDebug("equal "); |
1202 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1202 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1203 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1203 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1204 | } | 1204 | } |
1205 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1205 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1206 | return 0; | 1206 | return 0; |
1207 | 1207 | ||
1208 | }//else //debug only | 1208 | }//else //debug only |
1209 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1209 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1210 | } | 1210 | } |
1211 | int result; | 1211 | int result; |
1212 | bool localIsNew; | 1212 | bool localIsNew; |
1213 | //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() ); | 1213 | //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() ); |
1214 | 1214 | ||
1215 | 1215 | ||
1216 | // ************************************************ | 1216 | // ************************************************ |
1217 | // ************************************************ | 1217 | // ************************************************ |
1218 | // ************************************************ | 1218 | // ************************************************ |
1219 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1219 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1220 | // BUT remoteMod != localMod | 1220 | // BUT remoteMod != localMod |
1221 | 1221 | ||
1222 | 1222 | ||
1223 | if ( full && mode < SYNC_PREF_NEWEST ) | 1223 | if ( full && mode < SYNC_PREF_NEWEST ) |
1224 | mode = SYNC_PREF_ASK; | 1224 | mode = SYNC_PREF_ASK; |
1225 | 1225 | ||
1226 | switch( mode ) { | 1226 | switch( mode ) { |
1227 | case SYNC_PREF_LOCAL: | 1227 | case SYNC_PREF_LOCAL: |
1228 | if ( lastSync > remoteMod ) | 1228 | if ( lastSync > remoteMod ) |
1229 | return 1; | 1229 | return 1; |
1230 | if ( lastSync > localMod ) | 1230 | if ( lastSync > localMod ) |
1231 | return 2; | 1231 | return 2; |
1232 | return 1; | 1232 | return 1; |
1233 | break; | 1233 | break; |
1234 | case SYNC_PREF_REMOTE: | 1234 | case SYNC_PREF_REMOTE: |
1235 | if ( lastSync > localMod ) | 1235 | if ( lastSync > localMod ) |
1236 | return 2; | 1236 | return 2; |
1237 | if ( lastSync > remoteMod ) | 1237 | if ( lastSync > remoteMod ) |
1238 | return 1; | 1238 | return 1; |
1239 | return 2; | 1239 | return 2; |
1240 | break; | 1240 | break; |
1241 | case SYNC_PREF_NEWEST: | 1241 | case SYNC_PREF_NEWEST: |
1242 | if ( localMod >= remoteMod ) | 1242 | if ( localMod >= remoteMod ) |
1243 | return 1; | 1243 | return 1; |
1244 | else | 1244 | else |
1245 | return 2; | 1245 | return 2; |
1246 | break; | 1246 | break; |
1247 | case SYNC_PREF_ASK: | 1247 | case SYNC_PREF_ASK: |
1248 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1248 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1249 | if ( lastSync > remoteMod && lastSync > localMod) | 1249 | if ( lastSync > remoteMod && lastSync > localMod) |
1250 | return 0; | 1250 | return 0; |
1251 | if ( lastSync > remoteMod ) | 1251 | if ( lastSync > remoteMod ) |
1252 | return 1; | 1252 | return 1; |
1253 | if ( lastSync > localMod ) | 1253 | if ( lastSync > localMod ) |
1254 | return 2; | 1254 | return 2; |
1255 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1255 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1256 | localIsNew = localMod >= remoteMod; | 1256 | localIsNew = localMod >= remoteMod; |
1257 | if ( localIsNew ) | 1257 | if ( localIsNew ) |
1258 | getEventViewerDialog()->setColorMode( 1 ); | 1258 | getEventViewerDialog()->setColorMode( 1 ); |
1259 | else | 1259 | else |
1260 | getEventViewerDialog()->setColorMode( 2 ); | 1260 | getEventViewerDialog()->setColorMode( 2 ); |
1261 | getEventViewerDialog()->setIncidence(local); | 1261 | getEventViewerDialog()->setIncidence(local); |
1262 | if ( localIsNew ) | 1262 | if ( localIsNew ) |
1263 | getEventViewerDialog()->setColorMode( 2 ); | 1263 | getEventViewerDialog()->setColorMode( 2 ); |
1264 | else | 1264 | else |
1265 | getEventViewerDialog()->setColorMode( 1 ); | 1265 | getEventViewerDialog()->setColorMode( 1 ); |
1266 | getEventViewerDialog()->addIncidence(remote); | 1266 | getEventViewerDialog()->addIncidence(remote); |
1267 | getEventViewerDialog()->setColorMode( 0 ); | 1267 | getEventViewerDialog()->setColorMode( 0 ); |
1268 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1268 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1269 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1269 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1270 | getEventViewerDialog()->showMe(); | 1270 | getEventViewerDialog()->showMe(); |
1271 | result = getEventViewerDialog()->executeS( localIsNew ); | 1271 | result = getEventViewerDialog()->executeS( localIsNew ); |
1272 | return result; | 1272 | return result; |
1273 | 1273 | ||
1274 | break; | 1274 | break; |
1275 | case SYNC_PREF_FORCE_LOCAL: | 1275 | case SYNC_PREF_FORCE_LOCAL: |
1276 | return 1; | 1276 | return 1; |
1277 | break; | 1277 | break; |
1278 | case SYNC_PREF_FORCE_REMOTE: | 1278 | case SYNC_PREF_FORCE_REMOTE: |
1279 | return 2; | 1279 | return 2; |
1280 | break; | 1280 | break; |
1281 | 1281 | ||
1282 | default: | 1282 | default: |
1283 | // SYNC_PREF_TAKE_BOTH not implemented | 1283 | // SYNC_PREF_TAKE_BOTH not implemented |
1284 | break; | 1284 | break; |
1285 | } | 1285 | } |
1286 | return 0; | 1286 | return 0; |
1287 | } | 1287 | } |
1288 | Event* CalendarView::getLastSyncEvent() | 1288 | Event* CalendarView::getLastSyncEvent() |
1289 | { | 1289 | { |
1290 | Event* lse; | 1290 | Event* lse; |
1291 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1291 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1292 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1292 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1293 | if (!lse) { | 1293 | if (!lse) { |
1294 | lse = new Event(); | 1294 | lse = new Event(); |
1295 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1295 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1296 | QString sum = ""; | 1296 | QString sum = ""; |
1297 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1297 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1298 | sum = "E: "; | 1298 | sum = "E: "; |
1299 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1299 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1300 | lse->setDtStart( mLastCalendarSync ); | 1300 | lse->setDtStart( mLastCalendarSync ); |
1301 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1301 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1302 | lse->setCategories( i18n("SyncEvent") ); | 1302 | lse->setCategories( i18n("SyncEvent") ); |
1303 | lse->setReadOnly( true ); | 1303 | lse->setReadOnly( true ); |
1304 | mCalendar->addEvent( lse ); | 1304 | mCalendar->addEvent( lse ); |
1305 | } | 1305 | } |
1306 | 1306 | ||
1307 | return lse; | 1307 | return lse; |
1308 | 1308 | ||
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | // we check, if the to delete event has a id for a profile | 1311 | // we check, if the to delete event has a id for a profile |
1312 | // if yes, we set this id in the profile to delete | 1312 | // if yes, we set this id in the profile to delete |
1313 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1313 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1314 | { | 1314 | { |
1315 | if ( lastSync.count() == 0 ) { | 1315 | if ( lastSync.count() == 0 ) { |
1316 | //qDebug(" lastSync.count() == 0"); | 1316 | //qDebug(" lastSync.count() == 0"); |
1317 | return; | 1317 | return; |
1318 | } | 1318 | } |
1319 | if ( toDelete->typeID() == journalID ) | 1319 | if ( toDelete->typeID() == journalID ) |
1320 | return; | 1320 | return; |
1321 | 1321 | ||
1322 | Event* eve = lastSync.first(); | 1322 | Event* eve = lastSync.first(); |
1323 | 1323 | ||
1324 | while ( eve ) { | 1324 | while ( eve ) { |
1325 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1325 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1326 | if ( !id.isEmpty() ) { | 1326 | if ( !id.isEmpty() ) { |
1327 | QString des = eve->description(); | 1327 | QString des = eve->description(); |
1328 | QString pref = "e"; | 1328 | QString pref = "e"; |
1329 | if ( toDelete->typeID() == todoID ) | 1329 | if ( toDelete->typeID() == todoID ) |
1330 | pref = "t"; | 1330 | pref = "t"; |
1331 | des += pref+ id + ","; | 1331 | des += pref+ id + ","; |
1332 | eve->setReadOnly( false ); | 1332 | eve->setReadOnly( false ); |
1333 | eve->setDescription( des ); | 1333 | eve->setDescription( des ); |
1334 | //qDebug("setdes %s ", des.latin1()); | 1334 | //qDebug("setdes %s ", des.latin1()); |
1335 | eve->setReadOnly( true ); | 1335 | eve->setReadOnly( true ); |
1336 | } | 1336 | } |
1337 | eve = lastSync.next(); | 1337 | eve = lastSync.next(); |
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | } | 1340 | } |
1341 | void CalendarView::checkExternalId( Incidence * inc ) | 1341 | void CalendarView::checkExternalId( Incidence * inc ) |
1342 | { | 1342 | { |
1343 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1343 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1344 | checkExternSyncEvent( lastSync, inc ); | 1344 | checkExternSyncEvent( lastSync, inc ); |
1345 | 1345 | ||
1346 | } | 1346 | } |
1347 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1347 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1348 | { | 1348 | { |
1349 | bool syncOK = true; | 1349 | bool syncOK = true; |
1350 | int addedEvent = 0; | 1350 | int addedEvent = 0; |
1351 | int addedEventR = 0; | 1351 | int addedEventR = 0; |
1352 | int deletedEventR = 0; | 1352 | int deletedEventR = 0; |
1353 | int deletedEventL = 0; | 1353 | int deletedEventL = 0; |
1354 | int changedLocal = 0; | 1354 | int changedLocal = 0; |
1355 | int changedRemote = 0; | 1355 | int changedRemote = 0; |
1356 | int filteredIN = 0; | 1356 | int filteredIN = 0; |
1357 | int filteredOUT = 0; | 1357 | int filteredOUT = 0; |
1358 | //QPtrList<Event> el = local->rawEvents(); | 1358 | //QPtrList<Event> el = local->rawEvents(); |
1359 | Event* eventR; | 1359 | Event* eventR; |
1360 | QString uid; | 1360 | QString uid; |
1361 | int take; | 1361 | int take; |
1362 | Event* eventRSync; | 1362 | Event* eventRSync; |
1363 | Event* eventLSync; | 1363 | Event* eventLSync; |
1364 | clearAllViews(); | 1364 | clearAllViews(); |
1365 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1365 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1366 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1366 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1367 | bool fullDateRange = false; | 1367 | bool fullDateRange = false; |
1368 | local->resetTempSyncStat(); | 1368 | local->resetTempSyncStat(); |
1369 | mLastCalendarSync = QDateTime::currentDateTime(); | 1369 | mLastCalendarSync = QDateTime::currentDateTime(); |
1370 | if ( mSyncManager->syncWithDesktop() ) { | 1370 | if ( mSyncManager->syncWithDesktop() ) { |
1371 | remote->resetPilotStat(1); | 1371 | remote->resetPilotStat(1); |
1372 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1372 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1373 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1373 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1374 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1374 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1375 | } else { | 1375 | } else { |
1376 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1376 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1377 | } | 1377 | } |
1378 | } | 1378 | } |
1379 | QDateTime modifiedCalendar = mLastCalendarSync; | 1379 | QDateTime modifiedCalendar = mLastCalendarSync; |
1380 | eventLSync = getLastSyncEvent(); | 1380 | eventLSync = getLastSyncEvent(); |
1381 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1381 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1382 | if ( eventR ) { | 1382 | if ( eventR ) { |
1383 | qDebug("last-syncEvent on remote found "); | 1383 | qDebug("last-syncEvent on remote found "); |
1384 | eventRSync = (Event*) eventR->clone(); | 1384 | eventRSync = (Event*) eventR->clone(); |
1385 | remote->deleteEvent(eventR ); | 1385 | remote->deleteEvent(eventR ); |
1386 | 1386 | ||
1387 | } else { | 1387 | } else { |
1388 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1388 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1389 | eventRSync = (Event*)eventLSync->clone(); | 1389 | eventRSync = (Event*)eventLSync->clone(); |
1390 | } else { | 1390 | } else { |
1391 | fullDateRange = true; | 1391 | fullDateRange = true; |
1392 | eventRSync = new Event(); | 1392 | eventRSync = new Event(); |
1393 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1393 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1394 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1394 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1395 | eventRSync->setDtStart( mLastCalendarSync ); | 1395 | eventRSync->setDtStart( mLastCalendarSync ); |
1396 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1396 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1397 | eventRSync->setCategories( i18n("SyncEvent") ); | 1397 | eventRSync->setCategories( i18n("SyncEvent") ); |
1398 | } | 1398 | } |
1399 | } | 1399 | } |
1400 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1400 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1401 | fullDateRange = true; | 1401 | fullDateRange = true; |
1402 | 1402 | ||
1403 | if ( ! fullDateRange ) { | 1403 | if ( ! fullDateRange ) { |
1404 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1404 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1405 | 1405 | ||
1406 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1406 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1407 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1407 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1408 | fullDateRange = true; | 1408 | fullDateRange = true; |
1409 | } | 1409 | } |
1410 | } | 1410 | } |
1411 | if ( mSyncManager->syncWithDesktop() ) { | 1411 | if ( mSyncManager->syncWithDesktop() ) { |
1412 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1412 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1413 | } | 1413 | } |
1414 | if ( fullDateRange ) | 1414 | if ( fullDateRange ) |
1415 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1415 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1416 | else | 1416 | else |
1417 | mLastCalendarSync = eventLSync->dtStart(); | 1417 | mLastCalendarSync = eventLSync->dtStart(); |
1418 | // for resyncing if own file has changed | 1418 | // for resyncing if own file has changed |
1419 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1419 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1420 | mLastCalendarSync = loadedFileVersion; | 1420 | mLastCalendarSync = loadedFileVersion; |
1421 | //qDebug("setting mLastCalendarSync "); | 1421 | //qDebug("setting mLastCalendarSync "); |
1422 | } | 1422 | } |
1423 | //qDebug("*************************** "); | 1423 | //qDebug("*************************** "); |
1424 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1424 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1425 | QPtrList<Incidence> er = remote->rawIncidences(); | 1425 | QPtrList<Incidence> er = remote->rawIncidences(); |
1426 | Incidence* inR = er.first(); | 1426 | Incidence* inR = er.first(); |
1427 | Incidence* inL; | 1427 | Incidence* inL; |
1428 | QProgressBar bar( er.count(),0 ); | 1428 | QProgressBar bar( er.count(),0 ); |
1429 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1429 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1430 | 1430 | ||
1431 | // ************** setting up filter ************* | 1431 | // ************** setting up filter ************* |
1432 | CalFilter *filterIN = 0; | 1432 | CalFilter *filterIN = 0; |
1433 | CalFilter *filterOUT = 0; | 1433 | CalFilter *filterOUT = 0; |
1434 | CalFilter *filter = mFilters.first(); | 1434 | CalFilter *filter = mFilters.first(); |
1435 | while(filter) { | 1435 | while(filter) { |
1436 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1436 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1437 | filterIN = filter; | 1437 | filterIN = filter; |
1438 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1438 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1439 | filterOUT = filter; | 1439 | filterOUT = filter; |
1440 | filter = mFilters.next(); | 1440 | filter = mFilters.next(); |
1441 | } | 1441 | } |
1442 | int w = 300; | 1442 | int w = 300; |
1443 | if ( QApplication::desktop()->width() < 320 ) | 1443 | if ( QApplication::desktop()->width() < 320 ) |
1444 | w = 220; | 1444 | w = 220; |
1445 | int h = bar.sizeHint().height() ; | 1445 | int h = bar.sizeHint().height() ; |
1446 | int dw = QApplication::desktop()->width(); | 1446 | int dw = QApplication::desktop()->width(); |
1447 | int dh = QApplication::desktop()->height(); | 1447 | int dh = QApplication::desktop()->height(); |
1448 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1448 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1449 | bar.show(); | 1449 | bar.show(); |
1450 | int modulo = (er.count()/10)+1; | 1450 | int modulo = (er.count()/10)+1; |
1451 | int incCounter = 0; | 1451 | int incCounter = 0; |
1452 | while ( inR ) { | 1452 | while ( inR ) { |
1453 | if ( ! bar.isVisible() ) | 1453 | if ( ! bar.isVisible() ) |
1454 | return false; | 1454 | return false; |
1455 | if ( incCounter % modulo == 0 ) | 1455 | if ( incCounter % modulo == 0 ) |
1456 | bar.setProgress( incCounter ); | 1456 | bar.setProgress( incCounter ); |
1457 | ++incCounter; | 1457 | ++incCounter; |
1458 | uid = inR->uid(); | 1458 | uid = inR->uid(); |
1459 | bool skipIncidence = false; | 1459 | bool skipIncidence = false; |
1460 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1460 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1461 | skipIncidence = true; | 1461 | skipIncidence = true; |
1462 | QString idS; | 1462 | QString idS; |
1463 | qApp->processEvents(); | 1463 | qApp->processEvents(); |
1464 | if ( !skipIncidence ) { | 1464 | if ( !skipIncidence ) { |
1465 | inL = local->incidenceForUid( uid , false ); | 1465 | inL = local->incidenceForUid( uid , false ); |
1466 | if ( inL ) { // maybe conflict - same uid in both calendars | 1466 | if ( inL ) { // maybe conflict - same uid in both calendars |
1467 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1467 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1468 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1468 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1469 | if ( take == 3 ) | 1469 | if ( take == 3 ) |
1470 | return false; | 1470 | return false; |
1471 | if ( take == 1 ) {// take local ********************** | 1471 | if ( take == 1 ) {// take local ********************** |
1472 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1472 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1473 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1473 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1474 | else | 1474 | else |
1475 | idS = inR->IDStr(); | 1475 | idS = inR->IDStr(); |
1476 | int calID = inR->calID(); | 1476 | int calID = inR->calID(); |
1477 | remote->deleteIncidence( inR ); | 1477 | remote->deleteIncidence( inR ); |
1478 | inR = inL->clone(); | 1478 | inR = inL->clone(); |
1479 | inR->setCalID( calID ); | 1479 | inR->setCalID( calID ); |
1480 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1480 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1481 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1481 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1482 | inR->setIDStr( idS ); | 1482 | inR->setIDStr( idS ); |
1483 | remote->addIncidence( inR ); | 1483 | remote->addIncidence( inR ); |
1484 | if ( mSyncManager->syncWithDesktop() ) | 1484 | if ( mSyncManager->syncWithDesktop() ) |
1485 | inR->setPilotId( 2 ); | 1485 | inR->setPilotId( 2 ); |
1486 | ++changedRemote; | 1486 | ++changedRemote; |
1487 | } else {// take remote ********************** | 1487 | } else {// take remote ********************** |
1488 | if ( !inL->isReadOnly() ) { | 1488 | if ( !inL->isReadOnly() ) { |
1489 | idS = inL->IDStr(); | 1489 | idS = inL->IDStr(); |
1490 | int pid = inL->pilotId(); | 1490 | int pid = inL->pilotId(); |
1491 | int calID = inL->calID(); | 1491 | int calID = inL->calID(); |
1492 | local->deleteIncidence( inL ); | 1492 | local->deleteIncidence( inL ); |
1493 | inL = inR->clone(); | 1493 | inL = inR->clone(); |
1494 | inL->setCalID( calID ); | 1494 | inL->setCalID( calID ); |
1495 | if ( mSyncManager->syncWithDesktop() ) | 1495 | if ( mSyncManager->syncWithDesktop() ) |
1496 | inL->setPilotId( pid ); | 1496 | inL->setPilotId( pid ); |
1497 | inL->setIDStr( idS ); | 1497 | inL->setIDStr( idS ); |
1498 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1498 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1499 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1499 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1500 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1500 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1501 | } | 1501 | } |
1502 | local->addIncidence( inL ); | 1502 | local->addIncidence( inL ); |
1503 | ++changedLocal; | 1503 | ++changedLocal; |
1504 | } | 1504 | } |
1505 | } | 1505 | } |
1506 | } | 1506 | } |
1507 | } else { // no conflict ********** add or delete remote | 1507 | } else { // no conflict ********** add or delete remote |
1508 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1508 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1509 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1509 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1510 | QString des = eventLSync->description(); | 1510 | QString des = eventLSync->description(); |
1511 | QString pref = "e"; | 1511 | QString pref = "e"; |
1512 | if ( inR->typeID() == todoID ) | 1512 | if ( inR->typeID() == todoID ) |
1513 | pref = "t"; | 1513 | pref = "t"; |
1514 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1514 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1515 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1515 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1516 | //remote->deleteIncidence( inR ); | 1516 | //remote->deleteIncidence( inR ); |
1517 | ++deletedEventR; | 1517 | ++deletedEventR; |
1518 | } else { | 1518 | } else { |
1519 | inR->setLastModified( modifiedCalendar ); | 1519 | inR->setLastModified( modifiedCalendar ); |
1520 | inL = inR->clone(); | 1520 | inL = inR->clone(); |
1521 | inL->setIDStr( ":" ); | 1521 | inL->setIDStr( ":" ); |
1522 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1522 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1523 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1523 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1524 | 1524 | ||
1525 | inL->setCalID( 0 );// add to default cal | 1525 | inL->setCalID( 0 );// add to default cal |
1526 | local->addIncidence( inL ); | 1526 | local->addIncidence( inL ); |
1527 | ++addedEvent; | 1527 | ++addedEvent; |
1528 | 1528 | ||
1529 | } | 1529 | } |
1530 | } else { | 1530 | } else { |
1531 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1531 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1532 | inR->setLastModified( modifiedCalendar ); | 1532 | inR->setLastModified( modifiedCalendar ); |
1533 | inL = inR->clone(); | 1533 | inL = inR->clone(); |
1534 | inL->setIDStr( ":" ); | 1534 | inL->setIDStr( ":" ); |
1535 | inL->setCalID( 0 );// add to default cal | 1535 | inL->setCalID( 0 );// add to default cal |
1536 | local->addIncidence( inL ); | 1536 | local->addIncidence( inL ); |
1537 | ++addedEvent; | 1537 | ++addedEvent; |
1538 | 1538 | ||
1539 | } else { | 1539 | } else { |
1540 | checkExternSyncEvent(eventRSyncSharp, inR); | 1540 | checkExternSyncEvent(eventRSyncSharp, inR); |
1541 | remote->deleteIncidence( inR ); | 1541 | remote->deleteIncidence( inR ); |
1542 | ++deletedEventR; | 1542 | ++deletedEventR; |
1543 | } | 1543 | } |
1544 | } | 1544 | } |
1545 | } else { | 1545 | } else { |
1546 | ++filteredIN; | 1546 | ++filteredIN; |
1547 | } | 1547 | } |
1548 | } | 1548 | } |
1549 | } | 1549 | } |
1550 | inR = er.next(); | 1550 | inR = er.next(); |
1551 | } | 1551 | } |
1552 | QPtrList<Incidence> el = local->rawIncidences(); | 1552 | QPtrList<Incidence> el = local->rawIncidences(); |
1553 | inL = el.first(); | 1553 | inL = el.first(); |
1554 | modulo = (el.count()/10)+1; | 1554 | modulo = (el.count()/10)+1; |
1555 | bar.setCaption (i18n("Add / remove events") ); | 1555 | bar.setCaption (i18n("Add / remove events") ); |
1556 | bar.setTotalSteps ( el.count() ) ; | 1556 | bar.setTotalSteps ( el.count() ) ; |
1557 | bar.show(); | 1557 | bar.show(); |
1558 | incCounter = 0; | 1558 | incCounter = 0; |
1559 | 1559 | ||
1560 | while ( inL ) { | 1560 | while ( inL ) { |
1561 | 1561 | ||
1562 | qApp->processEvents(); | 1562 | qApp->processEvents(); |
1563 | if ( ! bar.isVisible() ) | 1563 | if ( ! bar.isVisible() ) |
1564 | return false; | 1564 | return false; |
1565 | if ( incCounter % modulo == 0 ) | 1565 | if ( incCounter % modulo == 0 ) |
1566 | bar.setProgress( incCounter ); | 1566 | bar.setProgress( incCounter ); |
1567 | ++incCounter; | 1567 | ++incCounter; |
1568 | uid = inL->uid(); | 1568 | uid = inL->uid(); |
1569 | bool skipIncidence = false; | 1569 | bool skipIncidence = false; |
1570 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1570 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1571 | skipIncidence = true; | 1571 | skipIncidence = true; |
1572 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1572 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1573 | skipIncidence = true; | 1573 | skipIncidence = true; |
1574 | if ( !skipIncidence ) { | 1574 | if ( !skipIncidence ) { |
1575 | inR = remote->incidenceForUid( uid , true ); | 1575 | inR = remote->incidenceForUid( uid , true ); |
1576 | if ( ! inR ) { | 1576 | if ( ! inR ) { |
1577 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1577 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1578 | // no conflict ********** add or delete local | 1578 | // no conflict ********** add or delete local |
1579 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1579 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1580 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1580 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1581 | checkExternSyncEvent(eventLSyncSharp, inL); | 1581 | checkExternSyncEvent(eventLSyncSharp, inL); |
1582 | local->deleteIncidence( inL ); | 1582 | local->deleteIncidence( inL ); |
1583 | ++deletedEventL; | 1583 | ++deletedEventL; |
1584 | } else { | 1584 | } else { |
1585 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1585 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1586 | inL->removeID(mCurrentSyncDevice ); | 1586 | inL->removeID(mCurrentSyncDevice ); |
1587 | ++addedEventR; | 1587 | ++addedEventR; |
1588 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1588 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1589 | inL->setLastModified( modifiedCalendar ); | 1589 | inL->setLastModified( modifiedCalendar ); |
1590 | inR = inL->clone(); | 1590 | inR = inL->clone(); |
1591 | inR->setIDStr( ":" ); | 1591 | inR->setIDStr( ":" ); |
1592 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1592 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1593 | inR->setCalID( 0 );// add to default cal | 1593 | inR->setCalID( 0 );// add to default cal |
1594 | remote->addIncidence( inR ); | 1594 | remote->addIncidence( inR ); |
1595 | } | 1595 | } |
1596 | } | 1596 | } |
1597 | } else { | 1597 | } else { |
1598 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1598 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1599 | checkExternSyncEvent(eventLSyncSharp, inL); | 1599 | checkExternSyncEvent(eventLSyncSharp, inL); |
1600 | local->deleteIncidence( inL ); | 1600 | local->deleteIncidence( inL ); |
1601 | ++deletedEventL; | 1601 | ++deletedEventL; |
1602 | } else { | 1602 | } else { |
1603 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1603 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1604 | ++addedEventR; | 1604 | ++addedEventR; |
1605 | inL->setLastModified( modifiedCalendar ); | 1605 | inL->setLastModified( modifiedCalendar ); |
1606 | inR = inL->clone(); | 1606 | inR = inL->clone(); |
1607 | inR->setIDStr( ":" ); | 1607 | inR->setIDStr( ":" ); |
1608 | inR->setCalID( 0 );// add to default cal | 1608 | inR->setCalID( 0 );// add to default cal |
1609 | remote->addIncidence( inR ); | 1609 | remote->addIncidence( inR ); |
1610 | } | 1610 | } |
1611 | } | 1611 | } |
1612 | } | 1612 | } |
1613 | } else { | 1613 | } else { |
1614 | ++filteredOUT; | 1614 | ++filteredOUT; |
1615 | } | 1615 | } |
1616 | } | 1616 | } |
1617 | } | 1617 | } |
1618 | inL = el.next(); | 1618 | inL = el.next(); |
1619 | } | 1619 | } |
1620 | int delFut = 0; | 1620 | int delFut = 0; |
1621 | int remRem = 0; | 1621 | int remRem = 0; |
1622 | if ( mSyncManager->mWriteBackInFuture ) { | 1622 | if ( mSyncManager->mWriteBackInFuture ) { |
1623 | er = remote->rawIncidences(); | 1623 | er = remote->rawIncidences(); |
1624 | remRem = er.count(); | 1624 | remRem = er.count(); |
1625 | inR = er.first(); | 1625 | inR = er.first(); |
1626 | QDateTime dt; | 1626 | QDateTime dt; |
1627 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1627 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1628 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1628 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1629 | while ( inR ) { | 1629 | while ( inR ) { |
1630 | if ( inR->typeID() == todoID ) { | 1630 | if ( inR->typeID() == todoID ) { |
1631 | Todo * t = (Todo*)inR; | 1631 | Todo * t = (Todo*)inR; |
1632 | if ( t->hasDueDate() ) | 1632 | if ( t->hasDueDate() ) |
1633 | dt = t->dtDue(); | 1633 | dt = t->dtDue(); |
1634 | else | 1634 | else |
1635 | dt = cur.addSecs( 62 ); | 1635 | dt = cur.addSecs( 62 ); |
1636 | } | 1636 | } |
1637 | else if (inR->typeID() == eventID ) { | 1637 | else if (inR->typeID() == eventID ) { |
1638 | bool ok; | 1638 | bool ok; |
1639 | dt = inR->getNextOccurence( cur, &ok ); | 1639 | dt = inR->getNextOccurence( cur, &ok ); |
1640 | if ( !ok ) | 1640 | if ( !ok ) |
1641 | dt = cur.addSecs( -62 ); | 1641 | dt = cur.addSecs( -62 ); |
1642 | } | 1642 | } |
1643 | else | 1643 | else |
1644 | dt = inR->dtStart(); | 1644 | dt = inR->dtStart(); |
1645 | if ( dt < cur || dt > end ) { | 1645 | if ( dt < cur || dt > end ) { |
1646 | remote->deleteIncidence( inR ); | 1646 | remote->deleteIncidence( inR ); |
1647 | ++delFut; | 1647 | ++delFut; |
1648 | } | 1648 | } |
1649 | inR = er.next(); | 1649 | inR = er.next(); |
1650 | } | 1650 | } |
1651 | } | 1651 | } |
1652 | bar.hide(); | 1652 | bar.hide(); |
1653 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1653 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1654 | eventLSync->setReadOnly( false ); | 1654 | eventLSync->setReadOnly( false ); |
1655 | eventLSync->setDtStart( mLastCalendarSync ); | 1655 | eventLSync->setDtStart( mLastCalendarSync ); |
1656 | eventRSync->setDtStart( mLastCalendarSync ); | 1656 | eventRSync->setDtStart( mLastCalendarSync ); |
1657 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1657 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1658 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1658 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1659 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1659 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1660 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1660 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1661 | eventLSync->setReadOnly( true ); | 1661 | eventLSync->setReadOnly( true ); |
1662 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1662 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1663 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1663 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1664 | remote->addEvent( eventRSync ); | 1664 | remote->addEvent( eventRSync ); |
1665 | else | 1665 | else |
1666 | delete eventRSync; | 1666 | delete eventRSync; |
1667 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1667 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1668 | QString mes; | 1668 | QString mes; |
1669 | 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 ); | 1669 | 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 ); |
1670 | QString delmess; | 1670 | QString delmess; |
1671 | if ( delFut ) { | 1671 | if ( delFut ) { |
1672 | 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); | 1672 | 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); |
1673 | mes += delmess; | 1673 | mes += delmess; |
1674 | } | 1674 | } |
1675 | mes = i18n("Local calendar changed!\n") +mes; | 1675 | mes = i18n("Local calendar changed!\n") +mes; |
1676 | mCalendar->checkAlarmForIncidence( 0, true ); | 1676 | mCalendar->checkAlarmForIncidence( 0, true ); |
1677 | qDebug( mes ); | 1677 | qDebug( mes ); |
1678 | if ( mSyncManager->mShowSyncSummary ) { | 1678 | if ( mSyncManager->mShowSyncSummary ) { |
1679 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1679 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1680 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1680 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1681 | qDebug("KO: WB cancelled "); | 1681 | qDebug("KO: WB cancelled "); |
1682 | mSyncManager->mWriteBackFile = false; | 1682 | mSyncManager->mWriteBackFile = false; |
1683 | return syncOK; | 1683 | return syncOK; |
1684 | } | 1684 | } |
1685 | } | 1685 | } |
1686 | return syncOK; | 1686 | return syncOK; |
1687 | } | 1687 | } |
1688 | 1688 | ||
1689 | void CalendarView::setSyncDevice( QString s ) | 1689 | void CalendarView::setSyncDevice( QString s ) |
1690 | { | 1690 | { |
1691 | mCurrentSyncDevice= s; | 1691 | mCurrentSyncDevice= s; |
1692 | } | 1692 | } |
1693 | void CalendarView::setSyncName( QString s ) | 1693 | void CalendarView::setSyncName( QString s ) |
1694 | { | 1694 | { |
1695 | mCurrentSyncName= s; | 1695 | mCurrentSyncName= s; |
1696 | } | 1696 | } |
1697 | bool CalendarView::syncCalendar(QString filename, int mode) | 1697 | bool CalendarView::syncCalendar(QString filename, int mode) |
1698 | { | 1698 | { |
1699 | //qDebug("syncCalendar %s ", filename.latin1()); | 1699 | //qDebug("syncCalendar %s ", filename.latin1()); |
1700 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1700 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1701 | CalendarLocal* calendar = new CalendarLocal(); | 1701 | CalendarLocal* calendar = new CalendarLocal(); |
1702 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1702 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1703 | FileStorage* storage = new FileStorage( calendar ); | 1703 | FileStorage* storage = new FileStorage( calendar ); |
1704 | bool syncOK = false; | 1704 | bool syncOK = false; |
1705 | storage->setFileName( filename ); | 1705 | storage->setFileName( filename ); |
1706 | // qDebug("loading ... "); | 1706 | // qDebug("loading ... "); |
1707 | if ( storage->load() ) { | 1707 | if ( storage->load() ) { |
1708 | getEventViewerDialog()->setSyncMode( true ); | 1708 | getEventViewerDialog()->setSyncMode( true ); |
1709 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1709 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1710 | getEventViewerDialog()->setSyncMode( false ); | 1710 | getEventViewerDialog()->setSyncMode( false ); |
1711 | if ( syncOK ) { | 1711 | if ( syncOK ) { |
1712 | if ( mSyncManager->mWriteBackFile ) | 1712 | if ( mSyncManager->mWriteBackFile ) |
1713 | { | 1713 | { |
1714 | storage->setSaveFormat( new ICalFormat() ); | 1714 | storage->setSaveFormat( new ICalFormat() ); |
1715 | storage->save(); | 1715 | storage->save(); |
1716 | } | 1716 | } |
1717 | } | 1717 | } |
1718 | setModified( true ); | 1718 | setModified( true ); |
1719 | } | 1719 | } |
1720 | delete storage; | 1720 | delete storage; |
1721 | delete calendar; | 1721 | delete calendar; |
1722 | if ( syncOK ) | 1722 | if ( syncOK ) |
1723 | updateView(); | 1723 | updateView(); |
1724 | return syncOK; | 1724 | return syncOK; |
1725 | } | 1725 | } |
1726 | 1726 | ||
1727 | void CalendarView::syncExternal( int mode ) | 1727 | void CalendarView::syncExternal( int mode ) |
1728 | { | 1728 | { |
1729 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1729 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1730 | 1730 | ||
1731 | qApp->processEvents(); | 1731 | qApp->processEvents(); |
1732 | CalendarLocal* calendar = new CalendarLocal(); | 1732 | CalendarLocal* calendar = new CalendarLocal(); |
1733 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1733 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1734 | bool syncOK = false; | 1734 | bool syncOK = false; |
1735 | bool loadSuccess = false; | 1735 | bool loadSuccess = false; |
1736 | PhoneFormat* phoneFormat = 0; | 1736 | PhoneFormat* phoneFormat = 0; |
1737 | emit tempDisableBR(true); | 1737 | emit tempDisableBR(true); |
1738 | #ifndef DESKTOP_VERSION | 1738 | #ifndef DESKTOP_VERSION |
1739 | SharpFormat* sharpFormat = 0; | 1739 | SharpFormat* sharpFormat = 0; |
1740 | if ( mode == 0 ) { // sharp | 1740 | if ( mode == 0 ) { // sharp |
1741 | sharpFormat = new SharpFormat () ; | 1741 | sharpFormat = new SharpFormat () ; |
1742 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1742 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1743 | 1743 | ||
1744 | } else | 1744 | } else |
1745 | #endif | 1745 | #endif |
1746 | if ( mode == 1 ) { // phone | 1746 | if ( mode == 1 ) { // phone |
1747 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1747 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1748 | mSyncManager->mPhoneDevice, | 1748 | mSyncManager->mPhoneDevice, |
1749 | mSyncManager->mPhoneConnection, | 1749 | mSyncManager->mPhoneConnection, |
1750 | mSyncManager->mPhoneModel); | 1750 | mSyncManager->mPhoneModel); |
1751 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1751 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1752 | 1752 | ||
1753 | } else { | 1753 | } else { |
1754 | emit tempDisableBR(false); | 1754 | emit tempDisableBR(false); |
1755 | return; | 1755 | return; |
1756 | } | 1756 | } |
1757 | if ( loadSuccess ) { | 1757 | if ( loadSuccess ) { |
1758 | getEventViewerDialog()->setSyncMode( true ); | 1758 | getEventViewerDialog()->setSyncMode( true ); |
1759 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1759 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1760 | getEventViewerDialog()->setSyncMode( false ); | 1760 | getEventViewerDialog()->setSyncMode( false ); |
1761 | qApp->processEvents(); | 1761 | qApp->processEvents(); |
1762 | if ( syncOK ) { | 1762 | if ( syncOK ) { |
1763 | if ( mSyncManager->mWriteBackFile ) | 1763 | if ( mSyncManager->mWriteBackFile ) |
1764 | { | 1764 | { |
1765 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1765 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1766 | Incidence* inc = iL.first(); | 1766 | Incidence* inc = iL.first(); |
1767 | if ( phoneFormat ) { | 1767 | if ( phoneFormat ) { |
1768 | while ( inc ) { | 1768 | while ( inc ) { |
1769 | inc->removeID(mCurrentSyncDevice); | 1769 | inc->removeID(mCurrentSyncDevice); |
1770 | inc = iL.next(); | 1770 | inc = iL.next(); |
1771 | } | 1771 | } |
1772 | } | 1772 | } |
1773 | #ifndef DESKTOP_VERSION | 1773 | #ifndef DESKTOP_VERSION |
1774 | if ( sharpFormat ) | 1774 | if ( sharpFormat ) |
1775 | sharpFormat->save(calendar); | 1775 | sharpFormat->save(calendar); |
1776 | #endif | 1776 | #endif |
1777 | if ( phoneFormat ) | 1777 | if ( phoneFormat ) |
1778 | phoneFormat->save(calendar); | 1778 | phoneFormat->save(calendar); |
1779 | iL = calendar->rawIncidences(); | 1779 | iL = calendar->rawIncidences(); |
1780 | inc = iL.first(); | 1780 | inc = iL.first(); |
1781 | Incidence* loc; | 1781 | Incidence* loc; |
1782 | while ( inc ) { | 1782 | while ( inc ) { |
1783 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1783 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1784 | loc = mCalendar->incidence(inc->uid() ); | 1784 | loc = mCalendar->incidence(inc->uid() ); |
1785 | if ( loc ) { | 1785 | if ( loc ) { |
1786 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1786 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1787 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1787 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1788 | } | 1788 | } |
1789 | } | 1789 | } |
1790 | inc = iL.next(); | 1790 | inc = iL.next(); |
1791 | } | 1791 | } |
1792 | Incidence* lse = getLastSyncEvent(); | 1792 | Incidence* lse = getLastSyncEvent(); |
1793 | if ( lse ) { | 1793 | if ( lse ) { |
1794 | lse->setReadOnly( false ); | 1794 | lse->setReadOnly( false ); |
1795 | lse->setDescription( "" ); | 1795 | lse->setDescription( "" ); |
1796 | lse->setReadOnly( true ); | 1796 | lse->setReadOnly( true ); |
1797 | } | 1797 | } |
1798 | } | 1798 | } |
1799 | } else { | 1799 | } else { |
1800 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1800 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1801 | } | 1801 | } |
1802 | setModified( true ); | 1802 | setModified( true ); |
1803 | } else { | 1803 | } else { |
1804 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1804 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1805 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1805 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1806 | question, i18n("Ok")) ; | 1806 | question, i18n("Ok")) ; |
1807 | 1807 | ||
1808 | } | 1808 | } |
1809 | delete calendar; | 1809 | delete calendar; |
1810 | updateView(); | 1810 | updateView(); |
1811 | emit tempDisableBR(false); | 1811 | emit tempDisableBR(false); |
1812 | return ;//syncOK; | 1812 | return ;//syncOK; |
1813 | 1813 | ||
1814 | } | 1814 | } |
1815 | 1815 | ||
1816 | bool CalendarView::importBday() | 1816 | bool CalendarView::importBday() |
1817 | { | 1817 | { |
1818 | #ifndef KORG_NOKABC | 1818 | #ifndef KORG_NOKABC |
1819 | 1819 | ||
1820 | #ifdef DESKTOP_VERSION | 1820 | #ifdef DESKTOP_VERSION |
1821 | int curCal = mCalendar->defaultCalendar(); | 1821 | int curCal = mCalendar->defaultCalendar(); |
1822 | int bd = mCalEditView->getBirtdayID(); | 1822 | int bd = mCalEditView->getBirtdayID(); |
1823 | if ( bd == 0 ) | 1823 | if ( bd == 0 ) |
1824 | return false; | 1824 | return false; |
1825 | mCalendar->setDefaultCalendar( bd ); | 1825 | mCalendar->setDefaultCalendar( bd ); |
1826 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1826 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1827 | KABC::AddressBook::Iterator it; | 1827 | KABC::AddressBook::Iterator it; |
1828 | int count = 0; | 1828 | int count = 0; |
1829 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1829 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1830 | ++count; | 1830 | ++count; |
1831 | } | 1831 | } |
1832 | QProgressBar bar(count,0 ); | 1832 | QProgressBar bar(count,0 ); |
1833 | int w = 300; | 1833 | int w = 300; |
1834 | if ( QApplication::desktop()->width() < 320 ) | 1834 | if ( QApplication::desktop()->width() < 320 ) |
1835 | w = 220; | 1835 | w = 220; |
1836 | int h = bar.sizeHint().height() ; | 1836 | int h = bar.sizeHint().height() ; |
1837 | int dw = QApplication::desktop()->width(); | 1837 | int dw = QApplication::desktop()->width(); |
1838 | int dh = QApplication::desktop()->height(); | 1838 | int dh = QApplication::desktop()->height(); |
1839 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1839 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1840 | bar.show(); | 1840 | bar.show(); |
1841 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1841 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1842 | qApp->processEvents(); | 1842 | qApp->processEvents(); |
1843 | count = 0; | 1843 | count = 0; |
1844 | int addCount = 0; | 1844 | int addCount = 0; |
1845 | KCal::Attendee* a = 0; | 1845 | KCal::Attendee* a = 0; |
1846 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1846 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1847 | if ( ! bar.isVisible() ) | 1847 | if ( ! bar.isVisible() ) |
1848 | return false; | 1848 | return false; |
1849 | bar.setProgress( count++ ); | 1849 | bar.setProgress( count++ ); |
1850 | qApp->processEvents(); | 1850 | qApp->processEvents(); |
1851 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1851 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1852 | if ( (*it).birthday().date().isValid() ){ | 1852 | if ( (*it).birthday().date().isValid() ){ |
1853 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1853 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1854 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1854 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1855 | ++addCount; | 1855 | ++addCount; |
1856 | } | 1856 | } |
1857 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1857 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1858 | if ( anni.isValid() ){ | 1858 | if ( anni.isValid() ){ |
1859 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1859 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1860 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1860 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1861 | ++addCount; | 1861 | ++addCount; |
1862 | } | 1862 | } |
1863 | } | 1863 | } |
1864 | mCalendar->setDefaultCalendar( curCal ); | 1864 | mCalendar->setDefaultCalendar( curCal ); |
1865 | updateView(); | 1865 | updateView(); |
1866 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1866 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1867 | #else //DESKTOP_VERSION | 1867 | #else //DESKTOP_VERSION |
1868 | 1868 | ||
1869 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1869 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1870 | // the result should now arrive through method insertBirthdays | 1870 | // the result should now arrive through method insertBirthdays |
1871 | 1871 | ||
1872 | #endif //DESKTOP_VERSION | 1872 | #endif //DESKTOP_VERSION |
1873 | 1873 | ||
1874 | #endif //KORG_NOKABC | 1874 | #endif //KORG_NOKABC |
1875 | 1875 | ||
1876 | 1876 | ||
1877 | return true; | 1877 | return true; |
1878 | } | 1878 | } |
1879 | 1879 | ||
1880 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1880 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1881 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1881 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1882 | const QStringList& anniversaryList, const QStringList& realNameList, | 1882 | const QStringList& anniversaryList, const QStringList& realNameList, |
1883 | const QStringList& emailList, const QStringList& assembledNameList, | 1883 | const QStringList& emailList, const QStringList& assembledNameList, |
1884 | const QStringList& uidList) | 1884 | const QStringList& uidList) |
1885 | { | 1885 | { |
1886 | 1886 | ||
1887 | //qDebug("KO::CalendarView::insertBirthdays"); | 1887 | //qDebug("KO::CalendarView::insertBirthdays"); |
1888 | if (uid == this->name()) | 1888 | if (uid == this->name()) |
1889 | { | 1889 | { |
1890 | int curCal = mCalendar->defaultCalendar(); | 1890 | int curCal = mCalendar->defaultCalendar(); |
1891 | int bd = mCalEditView->getBirtdayID(); | 1891 | int bd = mCalEditView->getBirtdayID(); |
1892 | if ( bd == 0 ) | 1892 | if ( bd == 0 ) |
1893 | return; | 1893 | return; |
1894 | mCalendar->setDefaultCalendar( bd ); | 1894 | mCalendar->setDefaultCalendar( bd ); |
1895 | 1895 | ||
1896 | 1896 | ||
1897 | int count = birthdayList.count(); | 1897 | int count = birthdayList.count(); |
1898 | int addCount = 0; | 1898 | int addCount = 0; |
1899 | KCal::Attendee* a = 0; | 1899 | KCal::Attendee* a = 0; |
1900 | 1900 | ||
1901 | //qDebug("CalView 1 %i", count); | 1901 | //qDebug("CalView 1 %i", count); |
1902 | 1902 | ||
1903 | QProgressBar bar(count,0 ); | 1903 | QProgressBar bar(count,0 ); |
1904 | int w = 300; | 1904 | int w = 300; |
1905 | if ( QApplication::desktop()->width() < 320 ) | 1905 | if ( QApplication::desktop()->width() < 320 ) |
1906 | w = 220; | 1906 | w = 220; |
1907 | int h = bar.sizeHint().height() ; | 1907 | int h = bar.sizeHint().height() ; |
1908 | int dw = QApplication::desktop()->width(); | 1908 | int dw = QApplication::desktop()->width(); |
1909 | int dh = QApplication::desktop()->height(); | 1909 | int dh = QApplication::desktop()->height(); |
1910 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1910 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1911 | bar.show(); | 1911 | bar.show(); |
1912 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1912 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1913 | qApp->processEvents(); | 1913 | qApp->processEvents(); |
1914 | 1914 | ||
1915 | QDate birthday; | 1915 | QDate birthday; |
1916 | QDate anniversary; | 1916 | QDate anniversary; |
1917 | QString realName; | 1917 | QString realName; |
1918 | QString email; | 1918 | QString email; |
1919 | QString assembledName; | 1919 | QString assembledName; |
1920 | QString uid; | 1920 | QString uid; |
1921 | bool ok = true; | 1921 | bool ok = true; |
1922 | for ( int i = 0; i < count; i++) | 1922 | for ( int i = 0; i < count; i++) |
1923 | { | 1923 | { |
1924 | if ( ! bar.isVisible() ) | 1924 | if ( ! bar.isVisible() ) |
1925 | return; | 1925 | return; |
1926 | bar.setProgress( i ); | 1926 | bar.setProgress( i ); |
1927 | qApp->processEvents(); | 1927 | qApp->processEvents(); |
1928 | 1928 | ||
1929 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1929 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1930 | if (!ok) { | 1930 | if (!ok) { |
1931 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1931 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1932 | } | 1932 | } |
1933 | 1933 | ||
1934 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1934 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1935 | if (!ok) { | 1935 | if (!ok) { |
1936 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1936 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1937 | } | 1937 | } |
1938 | realName = realNameList[i]; | 1938 | realName = realNameList[i]; |
1939 | email = emailList[i]; | 1939 | email = emailList[i]; |
1940 | assembledName = assembledNameList[i]; | 1940 | assembledName = assembledNameList[i]; |
1941 | uid = uidList[i]; | 1941 | uid = uidList[i]; |
1942 | //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() ); | 1942 | //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() ); |
1943 | 1943 | ||
1944 | if ( birthday.isValid() ){ | 1944 | if ( birthday.isValid() ){ |
1945 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1945 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1946 | KCal::Attendee::ReqParticipant,uid) ; | 1946 | KCal::Attendee::ReqParticipant,uid) ; |
1947 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1947 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1948 | ++addCount; | 1948 | ++addCount; |
1949 | } | 1949 | } |
1950 | 1950 | ||
1951 | if ( anniversary.isValid() ){ | 1951 | if ( anniversary.isValid() ){ |
1952 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1952 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1953 | KCal::Attendee::ReqParticipant,uid) ; | 1953 | KCal::Attendee::ReqParticipant,uid) ; |
1954 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1954 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1955 | ++addCount; | 1955 | ++addCount; |
1956 | } | 1956 | } |
1957 | } | 1957 | } |
1958 | 1958 | ||
1959 | mCalendar->setDefaultCalendar( curCal ); | 1959 | mCalendar->setDefaultCalendar( curCal ); |
1960 | updateView(); | 1960 | updateView(); |
1961 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1961 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1962 | 1962 | ||
1963 | } | 1963 | } |
1964 | 1964 | ||
1965 | } | 1965 | } |
1966 | 1966 | ||
1967 | 1967 | ||
1968 | 1968 | ||
1969 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1969 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1970 | { | 1970 | { |
1971 | //qDebug("addAnni "); | 1971 | //qDebug("addAnni "); |
1972 | Event * ev = new Event(); | 1972 | Event * ev = new Event(); |
1973 | ev->setOrganizer(KOPrefs::instance()->email()); | 1973 | ev->setOrganizer(KOPrefs::instance()->email()); |
1974 | if ( a ) { | 1974 | if ( a ) { |
1975 | ev->addAttendee( a ); | 1975 | ev->addAttendee( a ); |
1976 | } | 1976 | } |
1977 | QString kind; | 1977 | QString kind; |
1978 | if ( birthday ) { | 1978 | if ( birthday ) { |
1979 | kind = i18n( "Birthday" ); | 1979 | kind = i18n( "Birthday" ); |
1980 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1980 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1981 | } | 1981 | } |
1982 | else { | 1982 | else { |
1983 | kind = i18n( "Anniversary" ); | 1983 | kind = i18n( "Anniversary" ); |
1984 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1984 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1985 | } | 1985 | } |
1986 | ev->setCategories( kind ); | 1986 | ev->setCategories( kind ); |
1987 | ev->setDtStart( QDateTime(date) ); | 1987 | ev->setDtStart( QDateTime(date) ); |
1988 | ev->setDtEnd( QDateTime(date) ); | 1988 | ev->setDtEnd( QDateTime(date) ); |
1989 | ev->setFloats( true ); | 1989 | ev->setFloats( true ); |
1990 | Recurrence * rec = ev->recurrence(); | 1990 | Recurrence * rec = ev->recurrence(); |
1991 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1991 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1992 | rec->addYearlyNum( date.month() ); | 1992 | rec->addYearlyNum( date.month() ); |
1993 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1993 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1994 | delete ev; | 1994 | delete ev; |
1995 | return false; | 1995 | return false; |
1996 | } | 1996 | } |
1997 | return true; | 1997 | return true; |
1998 | 1998 | ||
1999 | } | 1999 | } |
2000 | bool CalendarView::importQtopia( const QString &categories, | 2000 | bool CalendarView::importQtopia( const QString &categories, |
2001 | const QString &datebook, | 2001 | const QString &datebook, |
2002 | const QString &todolist ) | 2002 | const QString &todolist ) |
2003 | { | 2003 | { |
2004 | 2004 | ||
2005 | QtopiaFormat qtopiaFormat; | 2005 | QtopiaFormat qtopiaFormat; |
2006 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2006 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2007 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2007 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2008 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2008 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2009 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2009 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2010 | 2010 | ||
2011 | updateView(); | 2011 | updateView(); |
2012 | return true; | 2012 | return true; |
2013 | 2013 | ||
2014 | #if 0 | 2014 | #if 0 |
2015 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2015 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2016 | mCurrentSyncDevice = "qtopia-XML"; | 2016 | mCurrentSyncDevice = "qtopia-XML"; |
2017 | if ( mSyncManager->mAskForPreferences ) | 2017 | if ( mSyncManager->mAskForPreferences ) |
2018 | edit_sync_options(); | 2018 | edit_sync_options(); |
2019 | qApp->processEvents(); | 2019 | qApp->processEvents(); |
2020 | CalendarLocal* calendar = new CalendarLocal(); | 2020 | CalendarLocal* calendar = new CalendarLocal(); |
2021 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2021 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2022 | bool syncOK = false; | 2022 | bool syncOK = false; |
2023 | QtopiaFormat qtopiaFormat; | 2023 | QtopiaFormat qtopiaFormat; |
2024 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2024 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2025 | bool loadOk = true; | 2025 | bool loadOk = true; |
2026 | if ( !categories.isEmpty() ) | 2026 | if ( !categories.isEmpty() ) |
2027 | loadOk = qtopiaFormat.load( calendar, categories ); | 2027 | loadOk = qtopiaFormat.load( calendar, categories ); |
2028 | if ( loadOk && !datebook.isEmpty() ) | 2028 | if ( loadOk && !datebook.isEmpty() ) |
2029 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2029 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2030 | if ( loadOk && !todolist.isEmpty() ) | 2030 | if ( loadOk && !todolist.isEmpty() ) |
2031 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2031 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2032 | 2032 | ||
2033 | if ( loadOk ) { | 2033 | if ( loadOk ) { |
2034 | getEventViewerDialog()->setSyncMode( true ); | 2034 | getEventViewerDialog()->setSyncMode( true ); |
2035 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2035 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2036 | getEventViewerDialog()->setSyncMode( false ); | 2036 | getEventViewerDialog()->setSyncMode( false ); |
2037 | qApp->processEvents(); | 2037 | qApp->processEvents(); |
2038 | if ( syncOK ) { | 2038 | if ( syncOK ) { |
2039 | if ( mSyncManager->mWriteBackFile ) | 2039 | if ( mSyncManager->mWriteBackFile ) |
2040 | { | 2040 | { |
2041 | // write back XML file | 2041 | // write back XML file |
2042 | 2042 | ||
2043 | } | 2043 | } |
2044 | setModified( true ); | 2044 | setModified( true ); |
2045 | } | 2045 | } |
2046 | } else { | 2046 | } else { |
2047 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2047 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2048 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2048 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2049 | question, i18n("Ok")) ; | 2049 | question, i18n("Ok")) ; |
2050 | } | 2050 | } |
2051 | delete calendar; | 2051 | delete calendar; |
2052 | updateView(); | 2052 | updateView(); |
2053 | return syncOK; | 2053 | return syncOK; |
2054 | 2054 | ||
2055 | 2055 | ||
2056 | #endif | 2056 | #endif |
2057 | 2057 | ||
2058 | } | 2058 | } |
2059 | 2059 | ||
2060 | void CalendarView::setSyncEventsReadOnly() | 2060 | void CalendarView::setSyncEventsReadOnly() |
2061 | { | 2061 | { |
2062 | mCalendar->setSyncEventsReadOnly(); | 2062 | mCalendar->setSyncEventsReadOnly(); |
2063 | } | 2063 | } |
2064 | 2064 | ||
2065 | bool CalendarView::loadCalendars() | 2065 | bool CalendarView::loadCalendars() |
2066 | { | 2066 | { |
2067 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2067 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2068 | KopiCalendarFile * cal = calendars.first(); | 2068 | KopiCalendarFile * cal = calendars.first(); |
2069 | mCalendar->setDefaultCalendar( 1 ); | 2069 | mCalendar->setDefaultCalendar( 1 ); |
2070 | openCalendar( MainWindow::defaultFileName(), false ); | 2070 | openCalendar( MainWindow::defaultFileName(), false ); |
2071 | cal = calendars.next(); | 2071 | cal = calendars.next(); |
2072 | while ( cal ) { | 2072 | while ( cal ) { |
2073 | addCalendar( cal ); | 2073 | addCalendar( cal ); |
2074 | cal = calendars.next(); | 2074 | cal = calendars.next(); |
2075 | } | 2075 | } |
2076 | restoreCalendarSettings(); | 2076 | restoreCalendarSettings(); |
2077 | return true; | 2077 | return true; |
2078 | } | 2078 | } |
2079 | bool CalendarView::restoreCalendarSettings() | 2079 | bool CalendarView::restoreCalendarSettings() |
2080 | { | 2080 | { |
2081 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2081 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2082 | KopiCalendarFile * cal = calendars.first(); | 2082 | KopiCalendarFile * cal = calendars.first(); |
2083 | while ( cal ) { | 2083 | while ( cal ) { |
2084 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2084 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2085 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2085 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2086 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2086 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2087 | if ( cal->isStandard ) | 2087 | if ( cal->isStandard ) |
2088 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2088 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2089 | cal = calendars.next(); | 2089 | cal = calendars.next(); |
2090 | } | 2090 | } |
2091 | setSyncEventsReadOnly(); | 2091 | setSyncEventsReadOnly(); |
2092 | mCalendar->reInitAlarmSettings(); | 2092 | mCalendar->reInitAlarmSettings(); |
2093 | updateUnmanagedViews(); | 2093 | updateUnmanagedViews(); |
2094 | updateView(); | 2094 | updateView(); |
2095 | return true; | 2095 | return true; |
2096 | } | 2096 | } |
2097 | void CalendarView::addCalendarId( int id ) | 2097 | void CalendarView::addCalendarId( int id ) |
2098 | { | 2098 | { |
2099 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2099 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2100 | if ( cal ) | 2100 | if ( cal ) |
2101 | addCalendar( cal ); | 2101 | addCalendar( cal ); |
2102 | } | 2102 | } |
2103 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2103 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2104 | { | 2104 | { |
2105 | cal->mErrorOnLoad = false; | 2105 | cal->mErrorOnLoad = false; |
2106 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2106 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2107 | cal->mLoadDt = QDateTime::currentDateTime(); | 2107 | cal->mLoadDt = QDateTime::currentDateTime(); |
2108 | return true; | 2108 | return true; |
2109 | } | 2109 | } |
2110 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2110 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2111 | cal->mErrorOnLoad = true; | 2111 | cal->mErrorOnLoad = true; |
2112 | return false; | 2112 | return false; |
2113 | } | 2113 | } |
2114 | bool CalendarView::openCalendar(QString filename, bool merge) | 2114 | bool CalendarView::openCalendar(QString filename, bool merge) |
2115 | { | 2115 | { |
2116 | 2116 | ||
2117 | if (filename.isEmpty()) { | 2117 | if (filename.isEmpty()) { |
2118 | return false; | 2118 | return false; |
2119 | } | 2119 | } |
2120 | 2120 | ||
2121 | if (!QFile::exists(filename)) { | 2121 | if (!QFile::exists(filename)) { |
2122 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2122 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2123 | return false; | 2123 | return false; |
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | globalFlagBlockAgenda = 1; | 2126 | globalFlagBlockAgenda = 1; |
2127 | clearAllViews(); | 2127 | clearAllViews(); |
2128 | if (!merge) { | 2128 | if (!merge) { |
2129 | mViewManager->setDocumentId( filename ); | 2129 | mViewManager->setDocumentId( filename ); |
2130 | mCalendar->close(); | 2130 | mCalendar->close(); |
2131 | } | 2131 | } |
2132 | mStorage->setFileName( filename ); | 2132 | mStorage->setFileName( filename ); |
2133 | 2133 | ||
2134 | if ( mStorage->load() ) { | 2134 | if ( mStorage->load() ) { |
2135 | if ( merge ) ;//setModified( true ); | 2135 | if ( merge ) ;//setModified( true ); |
2136 | else { | 2136 | else { |
2137 | //setModified( true ); | 2137 | //setModified( true ); |
2138 | mViewManager->setDocumentId( filename ); | 2138 | mViewManager->setDocumentId( filename ); |
2139 | mDialogManager->setDocumentId( filename ); | 2139 | mDialogManager->setDocumentId( filename ); |
2140 | mTodoList->setDocumentId( filename ); | 2140 | mTodoList->setDocumentId( filename ); |
2141 | } | 2141 | } |
2142 | globalFlagBlockAgenda = 2; | 2142 | globalFlagBlockAgenda = 2; |
2143 | // if ( getLastSyncEvent() ) | 2143 | // if ( getLastSyncEvent() ) |
2144 | // getLastSyncEvent()->setReadOnly( true ); | 2144 | // getLastSyncEvent()->setReadOnly( true ); |
2145 | mCalendar->reInitAlarmSettings(); | 2145 | mCalendar->reInitAlarmSettings(); |
2146 | setSyncEventsReadOnly(); | 2146 | setSyncEventsReadOnly(); |
2147 | updateUnmanagedViews(); | 2147 | updateUnmanagedViews(); |
2148 | updateView(); | 2148 | updateView(); |
2149 | if ( filename != MainWindow::defaultFileName() ) { | 2149 | if ( filename != MainWindow::defaultFileName() ) { |
2150 | saveCalendar( MainWindow::defaultFileName() ); | 2150 | saveCalendar( MainWindow::defaultFileName() ); |
2151 | } else { | 2151 | } else { |
2152 | QFileInfo finf ( MainWindow::defaultFileName()); | 2152 | QFileInfo finf ( MainWindow::defaultFileName()); |
2153 | if ( finf.exists() ) { | 2153 | if ( finf.exists() ) { |
2154 | setLoadedFileVersion( finf.lastModified () ); | 2154 | setLoadedFileVersion( finf.lastModified () ); |
2155 | } | 2155 | } |
2156 | } | 2156 | } |
2157 | return true; | 2157 | return true; |
2158 | } else { | 2158 | } else { |
2159 | // while failing to load, the calendar object could | 2159 | // while failing to load, the calendar object could |
2160 | // have become partially populated. Clear it out. | 2160 | // have become partially populated. Clear it out. |
2161 | if ( !merge ) { | 2161 | if ( !merge ) { |
2162 | mCalendar->close(); | 2162 | mCalendar->close(); |
2163 | mViewManager->setDocumentId( filename ); | 2163 | mViewManager->setDocumentId( filename ); |
2164 | mDialogManager->setDocumentId( filename ); | 2164 | mDialogManager->setDocumentId( filename ); |
2165 | mTodoList->setDocumentId( filename ); | 2165 | mTodoList->setDocumentId( filename ); |
2166 | } | 2166 | } |
2167 | 2167 | ||
2168 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2168 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2169 | 2169 | ||
2170 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2170 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2171 | globalFlagBlockAgenda = 2; | 2171 | globalFlagBlockAgenda = 2; |
2172 | mCalendar->reInitAlarmSettings(); | 2172 | mCalendar->reInitAlarmSettings(); |
2173 | setSyncEventsReadOnly(); | 2173 | setSyncEventsReadOnly(); |
2174 | updateUnmanagedViews(); | 2174 | updateUnmanagedViews(); |
2175 | updateView(); | 2175 | updateView(); |
2176 | } | 2176 | } |
2177 | return false; | 2177 | return false; |
2178 | } | 2178 | } |
2179 | void CalendarView::mergeFile( QString fn ) | 2179 | void CalendarView::mergeFile( QString fn ) |
2180 | { | 2180 | { |
2181 | clearAllViews(); | 2181 | clearAllViews(); |
2182 | mCalendar->mergeCalendarFile( fn ); | 2182 | mCalendar->mergeCalendarFile( fn ); |
2183 | mCalendar->reInitAlarmSettings(); | 2183 | mCalendar->reInitAlarmSettings(); |
2184 | setSyncEventsReadOnly(); | 2184 | setSyncEventsReadOnly(); |
2185 | updateUnmanagedViews(); | 2185 | updateUnmanagedViews(); |
2186 | updateView(); | 2186 | updateView(); |
2187 | } | 2187 | } |
2188 | void CalendarView::showOpenError() | 2188 | void CalendarView::showOpenError() |
2189 | { | 2189 | { |
2190 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2190 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2191 | } | 2191 | } |
2192 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2192 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2193 | { | 2193 | { |
2194 | loadedFileVersion = dt; | 2194 | loadedFileVersion = dt; |
2195 | } | 2195 | } |
2196 | bool CalendarView::checkFileChanged(QString fn) | 2196 | bool CalendarView::checkFileChanged(QString fn) |
2197 | { | 2197 | { |
2198 | QFileInfo finf ( fn ); | 2198 | QFileInfo finf ( fn ); |
2199 | if ( !finf.exists() ) | 2199 | if ( !finf.exists() ) |
2200 | return true; | 2200 | return true; |
2201 | QDateTime dt = finf.lastModified (); | 2201 | QDateTime dt = finf.lastModified (); |
2202 | if ( dt <= loadedFileVersion ) | 2202 | if ( dt <= loadedFileVersion ) |
2203 | return false; | 2203 | return false; |
2204 | return true; | 2204 | return true; |
2205 | 2205 | ||
2206 | } | 2206 | } |
2207 | void CalendarView::watchSavedFile() | 2207 | void CalendarView::watchSavedFile() |
2208 | { | 2208 | { |
2209 | QFileInfo finf ( MainWindow::defaultFileName()); | 2209 | QFileInfo finf ( MainWindow::defaultFileName()); |
2210 | if ( !finf.exists() ) | 2210 | if ( !finf.exists() ) |
2211 | return; | 2211 | return; |
2212 | QDateTime dt = finf.lastModified (); | 2212 | QDateTime dt = finf.lastModified (); |
2213 | if ( dt < loadedFileVersion ) { | 2213 | if ( dt < loadedFileVersion ) { |
2214 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2214 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2215 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2215 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2216 | return; | 2216 | return; |
2217 | } | 2217 | } |
2218 | loadedFileVersion = dt; | 2218 | loadedFileVersion = dt; |
2219 | } | 2219 | } |
2220 | bool CalendarView::checkAllFileVersions() | 2220 | bool CalendarView::checkAllFileVersions() |
2221 | { | 2221 | { |
2222 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2222 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2223 | KopiCalendarFile * cal = calendars.first(); | 2223 | KopiCalendarFile * cal = calendars.first(); |
2224 | mCalendar->setDefaultCalendar( 1 ); | 2224 | mCalendar->setDefaultCalendar( 1 ); |
2225 | mCalendar->setDefaultCalendarEnabledOnly(); | 2225 | mCalendar->setDefaultCalendarEnabledOnly(); |
2226 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2226 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2227 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2227 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2228 | restoreCalendarSettings(); | 2228 | restoreCalendarSettings(); |
2229 | return false; | 2229 | return false; |
2230 | } | 2230 | } |
2231 | } | 2231 | } |
2232 | cal = calendars.next(); | 2232 | cal = calendars.next(); |
2233 | QDateTime storeTemp = loadedFileVersion; | 2233 | QDateTime storeTemp = loadedFileVersion; |
2234 | while ( cal ) { | 2234 | while ( cal ) { |
2235 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2235 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2236 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2236 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2237 | mCalendar->setDefaultCalendarEnabledOnly(); | 2237 | mCalendar->setDefaultCalendarEnabledOnly(); |
2238 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2238 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2239 | if ( !checkFileVersion(cal->mFileName )) { | 2239 | if ( !checkFileVersion(cal->mFileName )) { |
2240 | loadedFileVersion = storeTemp; | 2240 | loadedFileVersion = storeTemp; |
2241 | restoreCalendarSettings(); | 2241 | restoreCalendarSettings(); |
2242 | return false; | 2242 | return false; |
2243 | } | 2243 | } |
2244 | } | 2244 | } |
2245 | cal = calendars.next(); | 2245 | cal = calendars.next(); |
2246 | } | 2246 | } |
2247 | loadedFileVersion = storeTemp; | 2247 | loadedFileVersion = storeTemp; |
2248 | return true; | 2248 | return true; |
2249 | } | 2249 | } |
2250 | bool CalendarView::checkFileVersion(QString fn) | 2250 | bool CalendarView::checkFileVersion(QString fn) |
2251 | { | 2251 | { |
2252 | QFileInfo finf ( fn ); | 2252 | QFileInfo finf ( fn ); |
2253 | if ( !finf.exists() ) | 2253 | if ( !finf.exists() ) |
2254 | return true; | 2254 | return true; |
2255 | QDateTime dt = finf.lastModified (); | 2255 | QDateTime dt = finf.lastModified (); |
2256 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2256 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2257 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2257 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2258 | if ( dt <= loadedFileVersion ) | 2258 | if ( dt <= loadedFileVersion ) |
2259 | return true; | 2259 | return true; |
2260 | 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)) , | 2260 | 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)) , |
2261 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2261 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2262 | i18n("Sync+save")); | 2262 | i18n("Sync+save")); |
2263 | 2263 | ||
2264 | if ( km == KMessageBox::Cancel ) | 2264 | if ( km == KMessageBox::Cancel ) |
2265 | return false; | 2265 | return false; |
2266 | if ( km == KMessageBox::Yes ) | 2266 | if ( km == KMessageBox::Yes ) |
2267 | return true; | 2267 | return true; |
2268 | 2268 | ||
2269 | setSyncDevice("deleteaftersync" ); | 2269 | setSyncDevice("deleteaftersync" ); |
2270 | mSyncManager->mAskForPreferences = true; | 2270 | mSyncManager->mAskForPreferences = true; |
2271 | mSyncManager->mSyncAlgoPrefs = 3; | 2271 | mSyncManager->mSyncAlgoPrefs = 3; |
2272 | mSyncManager->mWriteBackFile = false; | 2272 | mSyncManager->mWriteBackFile = false; |
2273 | mSyncManager->mWriteBackExistingOnly = false; | 2273 | mSyncManager->mWriteBackExistingOnly = false; |
2274 | mSyncManager->mShowSyncSummary = false; | 2274 | mSyncManager->mShowSyncSummary = false; |
2275 | syncCalendar( fn, 3 ); | 2275 | syncCalendar( fn, 3 ); |
2276 | Event * e = getLastSyncEvent(); | 2276 | Event * e = getLastSyncEvent(); |
2277 | if ( e ) | 2277 | if ( e ) |
2278 | mCalendar->deleteEvent( e ); | 2278 | mCalendar->deleteEvent( e ); |
2279 | return true; | 2279 | return true; |
2280 | } | 2280 | } |
2281 | bool CalendarView::saveCalendars() | 2281 | bool CalendarView::saveCalendars() |
2282 | { | 2282 | { |
2283 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2283 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2284 | KopiCalendarFile * cal = calendars.first(); | 2284 | KopiCalendarFile * cal = calendars.first(); |
2285 | mCalendar->setDefaultCalendar( 1 ); | 2285 | mCalendar->setDefaultCalendar( 1 ); |
2286 | mCalendar->setDefaultCalendarEnabledOnly(); | 2286 | mCalendar->setDefaultCalendarEnabledOnly(); |
2287 | saveCalendar( MainWindow::defaultFileName() ); | 2287 | saveCalendar( MainWindow::defaultFileName() ); |
2288 | cal = calendars.next(); | 2288 | cal = calendars.next(); |
2289 | while ( cal ) { | 2289 | while ( cal ) { |
2290 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2290 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2291 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2291 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2292 | mCalendar->setDefaultCalendarEnabledOnly(); | 2292 | mCalendar->setDefaultCalendarEnabledOnly(); |
2293 | if ( saveCalendar( cal->mFileName ) ) | 2293 | if ( saveCalendar( cal->mFileName ) ) |
2294 | cal->mLoadDt = QDateTime::currentDateTime(); | 2294 | cal->mLoadDt = QDateTime::currentDateTime(); |
2295 | } | 2295 | } |
2296 | cal = calendars.next(); | 2296 | cal = calendars.next(); |
2297 | } | 2297 | } |
2298 | restoreCalendarSettings(); | 2298 | restoreCalendarSettings(); |
2299 | return true; | 2299 | return true; |
2300 | } | 2300 | } |
2301 | bool CalendarView::saveCalendar( QString filename ) | 2301 | bool CalendarView::saveCalendar( QString filename ) |
2302 | { | 2302 | { |
2303 | 2303 | ||
2304 | // Store back all unsaved data into calendar object | 2304 | // Store back all unsaved data into calendar object |
2305 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2305 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2306 | if ( mViewManager->currentView() ) | 2306 | if ( mViewManager->currentView() ) |
2307 | mViewManager->currentView()->flushView(); | 2307 | mViewManager->currentView()->flushView(); |
2308 | 2308 | ||
2309 | 2309 | ||
2310 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2310 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2311 | mStorage->setSaveFormat( new ICalFormat() ); | 2311 | mStorage->setSaveFormat( new ICalFormat() ); |
2312 | mStorage->setFileName( filename ); | 2312 | mStorage->setFileName( filename ); |
2313 | bool success; | 2313 | bool success; |
2314 | success = mStorage->save(); | 2314 | success = mStorage->save(); |
2315 | if ( !success ) { | 2315 | if ( !success ) { |
2316 | return false; | 2316 | return false; |
2317 | } | 2317 | } |
2318 | if ( filename == MainWindow::defaultFileName() ) { | 2318 | if ( filename == MainWindow::defaultFileName() ) { |
2319 | setLoadedFileVersion( lfv ); | 2319 | setLoadedFileVersion( lfv ); |
2320 | watchSavedFile(); | 2320 | watchSavedFile(); |
2321 | } | 2321 | } |
2322 | return true; | 2322 | return true; |
2323 | } | 2323 | } |
2324 | 2324 | ||
2325 | void CalendarView::closeCalendar() | 2325 | void CalendarView::closeCalendar() |
2326 | { | 2326 | { |
2327 | 2327 | ||
2328 | // child windows no longer valid | 2328 | // child windows no longer valid |
2329 | clearAllViews(); | 2329 | clearAllViews(); |
2330 | emit closingDown(); | 2330 | emit closingDown(); |
2331 | 2331 | ||
2332 | mCalendar->close(); | 2332 | mCalendar->close(); |
2333 | setModified(false); | 2333 | setModified(false); |
2334 | updateView(); | 2334 | updateView(); |
2335 | } | 2335 | } |
2336 | 2336 | ||
2337 | void CalendarView::archiveCalendar() | 2337 | void CalendarView::archiveCalendar() |
2338 | { | 2338 | { |
2339 | mDialogManager->showArchiveDialog(); | 2339 | mDialogManager->showArchiveDialog(); |
2340 | } | 2340 | } |
2341 | 2341 | ||
2342 | 2342 | ||
2343 | void CalendarView::readSettings() | 2343 | void CalendarView::readSettings() |
2344 | { | 2344 | { |
2345 | 2345 | ||
2346 | 2346 | ||
2347 | // mViewManager->showAgendaView(); | 2347 | // mViewManager->showAgendaView(); |
2348 | QString str; | 2348 | QString str; |
2349 | //qDebug("CalendarView::readSettings() "); | 2349 | //qDebug("CalendarView::readSettings() "); |
2350 | // read settings from the KConfig, supplying reasonable | 2350 | // read settings from the KConfig, supplying reasonable |
2351 | // defaults where none are to be found | 2351 | // defaults where none are to be found |
2352 | KConfig *config = KOGlobals::config(); | 2352 | KConfig *config = KOGlobals::config(); |
2353 | #ifndef KORG_NOSPLITTER | 2353 | #ifndef KORG_NOSPLITTER |
2354 | config->setGroup("KOrganizer Geometry"); | 2354 | config->setGroup("KOrganizer Geometry"); |
2355 | 2355 | ||
2356 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2356 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2357 | if (sizes.count() != 2) { | 2357 | if (sizes.count() != 2) { |
2358 | sizes << mDateNavigator->minimumSizeHint().width(); | 2358 | sizes << mDateNavigator->minimumSizeHint().width(); |
2359 | sizes << 300; | 2359 | sizes << 300; |
2360 | } | 2360 | } |
2361 | mPanner->setSizes(sizes); | 2361 | mPanner->setSizes(sizes); |
2362 | 2362 | ||
2363 | sizes = config->readIntListEntry("Separator2"); | 2363 | sizes = config->readIntListEntry("Separator2"); |
2364 | if ( ( mResourceView && sizes.count() == 4 ) || | 2364 | if ( ( mResourceView && sizes.count() == 4 ) || |
2365 | ( !mResourceView && sizes.count() == 3 ) ) { | 2365 | ( !mResourceView && sizes.count() == 3 ) ) { |
2366 | mLeftSplitter->setSizes(sizes); | 2366 | mLeftSplitter->setSizes(sizes); |
2367 | } | 2367 | } |
2368 | #endif | 2368 | #endif |
2369 | globalFlagBlockAgenda = 1; | 2369 | globalFlagBlockAgenda = 1; |
2370 | mViewManager->showAgendaView(); | 2370 | mViewManager->showAgendaView(); |
2371 | //mViewManager->readSettings( config ); | 2371 | //mViewManager->readSettings( config ); |
2372 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2372 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2373 | readFilterSettings(config); | 2373 | readFilterSettings(config); |
2374 | 2374 | ||
2375 | #ifdef DESKTOP_VERSION | 2375 | #ifdef DESKTOP_VERSION |
2376 | config->setGroup("WidgetLayout"); | 2376 | config->setGroup("WidgetLayout"); |
2377 | QStringList list; | 2377 | QStringList list; |
2378 | list = config->readListEntry("MainLayout"); | 2378 | list = config->readListEntry("MainLayout"); |
2379 | int x,y,w,h; | 2379 | int x,y,w,h; |
2380 | if ( ! list.isEmpty() ) { | 2380 | if ( ! list.isEmpty() ) { |
2381 | x = list[0].toInt(); | 2381 | x = list[0].toInt(); |
2382 | y = list[1].toInt(); | 2382 | y = list[1].toInt(); |
2383 | w = list[2].toInt(); | 2383 | w = list[2].toInt(); |
2384 | h = list[3].toInt(); | 2384 | h = list[3].toInt(); |
2385 | KApplication::testCoords( &x,&y,&w,&h ); | 2385 | KApplication::testCoords( &x,&y,&w,&h ); |
2386 | topLevelWidget()->setGeometry(x,y,w,h); | 2386 | topLevelWidget()->setGeometry(x,y,w,h); |
2387 | 2387 | ||
2388 | } else { | 2388 | } else { |
2389 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2389 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2390 | } | 2390 | } |
2391 | list = config->readListEntry("EditEventLayout"); | 2391 | list = config->readListEntry("EditEventLayout"); |
2392 | if ( ! list.isEmpty() ) { | 2392 | if ( ! list.isEmpty() ) { |
2393 | x = list[0].toInt(); | 2393 | x = list[0].toInt(); |
2394 | y = list[1].toInt(); | 2394 | y = list[1].toInt(); |
2395 | w = list[2].toInt(); | 2395 | w = list[2].toInt(); |
2396 | h = list[3].toInt(); | 2396 | h = list[3].toInt(); |
2397 | KApplication::testCoords( &x,&y,&w,&h ); | 2397 | KApplication::testCoords( &x,&y,&w,&h ); |
2398 | mEventEditor->setGeometry(x,y,w,h); | 2398 | mEventEditor->setGeometry(x,y,w,h); |
2399 | 2399 | ||
2400 | } | 2400 | } |
2401 | list = config->readListEntry("EditTodoLayout"); | 2401 | list = config->readListEntry("EditTodoLayout"); |
2402 | if ( ! list.isEmpty() ) { | 2402 | if ( ! list.isEmpty() ) { |
2403 | x = list[0].toInt(); | 2403 | x = list[0].toInt(); |
2404 | y = list[1].toInt(); | 2404 | y = list[1].toInt(); |
2405 | w = list[2].toInt(); | 2405 | w = list[2].toInt(); |
2406 | h = list[3].toInt(); | 2406 | h = list[3].toInt(); |
2407 | KApplication::testCoords( &x,&y,&w,&h ); | 2407 | KApplication::testCoords( &x,&y,&w,&h ); |
2408 | mTodoEditor->setGeometry(x,y,w,h); | 2408 | mTodoEditor->setGeometry(x,y,w,h); |
2409 | 2409 | ||
2410 | } | 2410 | } |
2411 | list = config->readListEntry("ViewerLayout"); | 2411 | list = config->readListEntry("ViewerLayout"); |
2412 | if ( ! list.isEmpty() ) { | 2412 | if ( ! list.isEmpty() ) { |
2413 | x = list[0].toInt(); | 2413 | x = list[0].toInt(); |
2414 | y = list[1].toInt(); | 2414 | y = list[1].toInt(); |
2415 | w = list[2].toInt(); | 2415 | w = list[2].toInt(); |
2416 | h = list[3].toInt(); | 2416 | h = list[3].toInt(); |
2417 | KApplication::testCoords( &x,&y,&w,&h ); | 2417 | KApplication::testCoords( &x,&y,&w,&h ); |
2418 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2418 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2419 | } | 2419 | } |
2420 | #endif | 2420 | #endif |
2421 | config->setGroup( "Views" ); | 2421 | config->setGroup( "Views" ); |
2422 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2422 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2423 | 2423 | ||
2424 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2424 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2425 | 2425 | ||
2426 | int resetval = 0; | 2426 | int resetval = 0; |
2427 | int maxVal = 0; | 2427 | int maxVal = 0; |
2428 | if (sizes.count() != 3) { | 2428 | if (sizes.count() != 3) { |
2429 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2429 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2430 | resetval = mDateNavigator->sizeHint().width()+2; | 2430 | resetval = mDateNavigator->sizeHint().width()+2; |
2431 | } else { | 2431 | } else { |
2432 | resetval = mDateNavigator->sizeHint().height()+2; | 2432 | resetval = mDateNavigator->sizeHint().height()+2; |
2433 | } | 2433 | } |
2434 | } | 2434 | } |
2435 | if ( resetval ) { | 2435 | if ( resetval ) { |
2436 | sizes.clear(); | 2436 | sizes.clear(); |
2437 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2437 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2438 | maxVal = QApplication::desktop()->width() -10; | 2438 | maxVal = QApplication::desktop()->width() -10; |
2439 | } else { | 2439 | } else { |
2440 | maxVal = QApplication::desktop()->height()-10; | 2440 | maxVal = QApplication::desktop()->height()-10; |
2441 | } | 2441 | } |
2442 | sizes << resetval; | 2442 | sizes << resetval; |
2443 | if ( maxVal < resetval + resetval) | 2443 | if ( maxVal < resetval + resetval) |
2444 | resetval = maxVal - resetval; | 2444 | resetval = maxVal - resetval; |
2445 | sizes << resetval; | 2445 | sizes << resetval; |
2446 | sizes << 100; | 2446 | sizes << 100; |
2447 | } | 2447 | } |
2448 | mLeftFrame->setSizes(sizes); | 2448 | mLeftFrame->setSizes(sizes); |
2449 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2449 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2450 | resetval = 0; | 2450 | resetval = 0; |
2451 | maxVal = 0; | 2451 | maxVal = 0; |
2452 | if (sizes.count() != 2) { | 2452 | if (sizes.count() != 2) { |
2453 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2453 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2454 | resetval = mDateNavigator->sizeHint().width()+2; | 2454 | resetval = mDateNavigator->sizeHint().width()+2; |
2455 | } else { | 2455 | } else { |
2456 | resetval = mDateNavigator->sizeHint().height()+2; | 2456 | resetval = mDateNavigator->sizeHint().height()+2; |
2457 | } | 2457 | } |
2458 | } | 2458 | } |
2459 | if ( resetval ) { | 2459 | if ( resetval ) { |
2460 | sizes.clear(); | 2460 | sizes.clear(); |
2461 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2461 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2462 | maxVal = QApplication::desktop()->width() -10; | 2462 | maxVal = QApplication::desktop()->width() -10; |
2463 | } else { | 2463 | } else { |
2464 | maxVal = QApplication::desktop()->height()-10; | 2464 | maxVal = QApplication::desktop()->height()-10; |
2465 | } | 2465 | } |
2466 | sizes << resetval; | 2466 | sizes << resetval; |
2467 | if ( maxVal < resetval + resetval) | 2467 | if ( maxVal < resetval + resetval) |
2468 | resetval = maxVal - resetval; | 2468 | resetval = maxVal - resetval; |
2469 | sizes << resetval; | 2469 | sizes << resetval; |
2470 | } | 2470 | } |
2471 | mMainFrame->setSizes(sizes); | 2471 | mMainFrame->setSizes(sizes); |
2472 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2472 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2473 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2473 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2474 | else mNavigator->selectDates( dateCount ); | 2474 | else mNavigator->selectDates( dateCount ); |
2475 | // mViewManager->readSettings( config ); | 2475 | // mViewManager->readSettings( config ); |
2476 | updateConfig(); | 2476 | updateConfig(); |
2477 | globalFlagBlockAgenda = 2; | 2477 | globalFlagBlockAgenda = 2; |
2478 | mViewManager->readSettings( config ); | 2478 | mViewManager->readSettings( config ); |
2479 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2479 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2480 | } | 2480 | } |
2481 | 2481 | ||
2482 | void CalendarView::checkSuspendAlarm() | 2482 | void CalendarView::checkSuspendAlarm() |
2483 | { | 2483 | { |
2484 | if ( mSuspendTimer->isActive() ) { | 2484 | if ( mSuspendTimer->isActive() ) { |
2485 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2485 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2486 | } | 2486 | } |
2487 | } | 2487 | } |
2488 | void CalendarView::writeSettings() | 2488 | void CalendarView::writeSettings() |
2489 | { | 2489 | { |
2490 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2490 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2491 | 2491 | ||
2492 | KConfig *config = KOGlobals::config(); | 2492 | KConfig *config = KOGlobals::config(); |
2493 | 2493 | ||
2494 | mViewManager->writeSettings( config ); | 2494 | mViewManager->writeSettings( config ); |
2495 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2495 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2496 | mDialogManager->writeSettings( config ); | 2496 | mDialogManager->writeSettings( config ); |
2497 | //KOPrefs::instance()->usrWriteConfig(); | 2497 | //KOPrefs::instance()->usrWriteConfig(); |
2498 | KOPrefs::instance()->writeConfig(); | 2498 | KOPrefs::instance()->writeConfig(); |
2499 | 2499 | ||
2500 | writeFilterSettings(config); | 2500 | writeFilterSettings(config); |
2501 | config->setGroup( "AppRun" ); | 2501 | config->setGroup( "AppRun" ); |
2502 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2502 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2503 | int days = dt.daysTo( QDate::currentDate() ); | 2503 | int days = dt.daysTo( QDate::currentDate() ); |
2504 | dt = dt.addDays( days ); | 2504 | dt = dt.addDays( days ); |
2505 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2505 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2506 | config->writeEntry( "LatestProgramStopDays", days ); | 2506 | config->writeEntry( "LatestProgramStopDays", days ); |
2507 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2507 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2508 | //qDebug("KO: Writing stop time: %d ", secs); | 2508 | //qDebug("KO: Writing stop time: %d ", secs); |
2509 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2509 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2510 | //QDateTime latest = dt.addSecs ( secs ); | 2510 | //QDateTime latest = dt.addSecs ( secs ); |
2511 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2511 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2512 | config->setGroup( "Views" ); | 2512 | config->setGroup( "Views" ); |
2513 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2513 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2514 | 2514 | ||
2515 | #if 0 | 2515 | #if 0 |
2516 | qDebug("********************* "); | 2516 | qDebug("********************* "); |
2517 | qDebug("Testcode secsto "); | 2517 | qDebug("Testcode secsto "); |
2518 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2518 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2519 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2519 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2520 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2520 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2521 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2521 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2522 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2522 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2523 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2523 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2524 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2524 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2525 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2525 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2526 | qDebug("********************* testcode end"); | 2526 | qDebug("********************* testcode end"); |
2527 | 2527 | ||
2528 | #endif | 2528 | #endif |
2529 | 2529 | ||
2530 | QValueList<int> listINT = mLeftFrame->sizes(); | 2530 | QValueList<int> listINT = mLeftFrame->sizes(); |
2531 | config->writeEntry("Left Splitter Frame",listINT); | 2531 | config->writeEntry("Left Splitter Frame",listINT); |
2532 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2532 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2533 | config->writeEntry("Main Splitter Frame",listINT2); | 2533 | config->writeEntry("Main Splitter Frame",listINT2); |
2534 | #ifdef DESKTOP_VERSION | 2534 | #ifdef DESKTOP_VERSION |
2535 | config->setGroup("WidgetLayout"); | 2535 | config->setGroup("WidgetLayout"); |
2536 | QStringList list ;//= config->readListEntry("MainLayout"); | 2536 | QStringList list ;//= config->readListEntry("MainLayout"); |
2537 | int x,y,w,h; | 2537 | int x,y,w,h; |
2538 | QWidget* wid; | 2538 | QWidget* wid; |
2539 | wid = topLevelWidget(); | 2539 | wid = topLevelWidget(); |
2540 | x = wid->geometry().x(); | 2540 | x = wid->geometry().x(); |
2541 | y = wid->geometry().y(); | 2541 | y = wid->geometry().y(); |
2542 | w = wid->width(); | 2542 | w = wid->width(); |
2543 | h = wid->height(); | 2543 | h = wid->height(); |
2544 | list.clear(); | 2544 | list.clear(); |
2545 | list << QString::number( x ); | 2545 | list << QString::number( x ); |
2546 | list << QString::number( y ); | 2546 | list << QString::number( y ); |
2547 | list << QString::number( w ); | 2547 | list << QString::number( w ); |
2548 | list << QString::number( h ); | 2548 | list << QString::number( h ); |
2549 | config->writeEntry("MainLayout",list ); | 2549 | config->writeEntry("MainLayout",list ); |
2550 | 2550 | ||
2551 | wid = mEventEditor; | 2551 | wid = mEventEditor; |
2552 | x = wid->geometry().x(); | 2552 | x = wid->geometry().x(); |
2553 | y = wid->geometry().y(); | 2553 | y = wid->geometry().y(); |
2554 | w = wid->width(); | 2554 | w = wid->width(); |
2555 | h = wid->height(); | 2555 | h = wid->height(); |
2556 | list.clear(); | 2556 | list.clear(); |
2557 | list << QString::number( x ); | 2557 | list << QString::number( x ); |
2558 | list << QString::number( y ); | 2558 | list << QString::number( y ); |
2559 | list << QString::number( w ); | 2559 | list << QString::number( w ); |
2560 | list << QString::number( h ); | 2560 | list << QString::number( h ); |
2561 | config->writeEntry("EditEventLayout",list ); | 2561 | config->writeEntry("EditEventLayout",list ); |
2562 | 2562 | ||
2563 | wid = mTodoEditor; | 2563 | wid = mTodoEditor; |
2564 | x = wid->geometry().x(); | 2564 | x = wid->geometry().x(); |
2565 | y = wid->geometry().y(); | 2565 | y = wid->geometry().y(); |
2566 | w = wid->width(); | 2566 | w = wid->width(); |
2567 | h = wid->height(); | 2567 | h = wid->height(); |
2568 | list.clear(); | 2568 | list.clear(); |
2569 | list << QString::number( x ); | 2569 | list << QString::number( x ); |
2570 | list << QString::number( y ); | 2570 | list << QString::number( y ); |
2571 | list << QString::number( w ); | 2571 | list << QString::number( w ); |
2572 | list << QString::number( h ); | 2572 | list << QString::number( h ); |
2573 | config->writeEntry("EditTodoLayout",list ); | 2573 | config->writeEntry("EditTodoLayout",list ); |
2574 | wid = getEventViewerDialog(); | 2574 | wid = getEventViewerDialog(); |
2575 | x = wid->geometry().x(); | 2575 | x = wid->geometry().x(); |
2576 | y = wid->geometry().y(); | 2576 | y = wid->geometry().y(); |
2577 | w = wid->width(); | 2577 | w = wid->width(); |
2578 | h = wid->height(); | 2578 | h = wid->height(); |
2579 | list.clear(); | 2579 | list.clear(); |
2580 | list << QString::number( x ); | 2580 | list << QString::number( x ); |
2581 | list << QString::number( y ); | 2581 | list << QString::number( y ); |
2582 | list << QString::number( w ); | 2582 | list << QString::number( w ); |
2583 | list << QString::number( h ); | 2583 | list << QString::number( h ); |
2584 | config->writeEntry("ViewerLayout",list ); | 2584 | config->writeEntry("ViewerLayout",list ); |
2585 | wid = mDialogManager->getSearchDialog(); | 2585 | wid = mDialogManager->getSearchDialog(); |
2586 | if ( wid ) { | 2586 | if ( wid ) { |
2587 | x = wid->geometry().x(); | 2587 | x = wid->geometry().x(); |
2588 | y = wid->geometry().y(); | 2588 | y = wid->geometry().y(); |
2589 | w = wid->width(); | 2589 | w = wid->width(); |
2590 | h = wid->height(); | 2590 | h = wid->height(); |
2591 | list.clear(); | 2591 | list.clear(); |
2592 | list << QString::number( x ); | 2592 | list << QString::number( x ); |
2593 | list << QString::number( y ); | 2593 | list << QString::number( y ); |
2594 | list << QString::number( w ); | 2594 | list << QString::number( w ); |
2595 | list << QString::number( h ); | 2595 | list << QString::number( h ); |
2596 | config->writeEntry("SearchLayout",list ); | 2596 | config->writeEntry("SearchLayout",list ); |
2597 | } | 2597 | } |
2598 | #endif | 2598 | #endif |
2599 | 2599 | ||
2600 | 2600 | ||
2601 | config->sync(); | 2601 | config->sync(); |
2602 | } | 2602 | } |
2603 | 2603 | ||
2604 | void CalendarView::readFilterSettings(KConfig *config) | 2604 | void CalendarView::readFilterSettings(KConfig *config) |
2605 | { | 2605 | { |
2606 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2606 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2607 | 2607 | ||
2608 | mFilters.clear(); | 2608 | mFilters.clear(); |
2609 | 2609 | ||
2610 | config->setGroup("General"); | 2610 | config->setGroup("General"); |
2611 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2611 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2612 | 2612 | ||
2613 | QStringList::ConstIterator it = filterList.begin(); | 2613 | QStringList::ConstIterator it = filterList.begin(); |
2614 | QStringList::ConstIterator end = filterList.end(); | 2614 | QStringList::ConstIterator end = filterList.end(); |
2615 | while(it != end) { | 2615 | while(it != end) { |
2616 | // kdDebug() << " filter: " << (*it) << endl; | 2616 | // kdDebug() << " filter: " << (*it) << endl; |
2617 | 2617 | ||
2618 | CalFilter *filter; | 2618 | CalFilter *filter; |
2619 | filter = new CalFilter(*it); | 2619 | filter = new CalFilter(*it); |
2620 | config->setGroup("Filter_" + (*it).utf8()); | 2620 | config->setGroup("Filter_" + (*it).utf8()); |
2621 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2621 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2622 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2622 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2623 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2623 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2624 | mFilters.append(filter); | 2624 | mFilters.append(filter); |
2625 | 2625 | ||
2626 | ++it; | 2626 | ++it; |
2627 | } | 2627 | } |
2628 | 2628 | ||
2629 | if (mFilters.count() == 0) { | 2629 | if (mFilters.count() == 0) { |
2630 | CalFilter *filter = new CalFilter(i18n("Default")); | 2630 | CalFilter *filter = new CalFilter(i18n("Default")); |
2631 | mFilters.append(filter); | 2631 | mFilters.append(filter); |
2632 | } | 2632 | } |
2633 | mFilterView->updateFilters(); | 2633 | mFilterView->updateFilters(); |
2634 | config->setGroup("FilterView"); | 2634 | config->setGroup("FilterView"); |
2635 | 2635 | ||
2636 | mFilterView->blockSignals(true); | 2636 | mFilterView->blockSignals(true); |
2637 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2637 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2638 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2638 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2639 | mFilterView->blockSignals(false); | 2639 | mFilterView->blockSignals(false); |
2640 | // We do it manually to avoid it being done twice by the above calls | 2640 | // We do it manually to avoid it being done twice by the above calls |
2641 | updateFilter(); | 2641 | updateFilter(); |
2642 | } | 2642 | } |
2643 | 2643 | ||
2644 | void CalendarView::writeFilterSettings(KConfig *config) | 2644 | void CalendarView::writeFilterSettings(KConfig *config) |
2645 | { | 2645 | { |
2646 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2646 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2647 | 2647 | ||
2648 | QStringList filterList; | 2648 | QStringList filterList; |
2649 | 2649 | ||
2650 | CalFilter *filter = mFilters.first(); | 2650 | CalFilter *filter = mFilters.first(); |
2651 | while(filter) { | 2651 | while(filter) { |
2652 | // kdDebug() << " fn: " << filter->name() << endl; | 2652 | // kdDebug() << " fn: " << filter->name() << endl; |
2653 | filterList << filter->name(); | 2653 | filterList << filter->name(); |
2654 | config->setGroup("Filter_" + filter->name().utf8()); | 2654 | config->setGroup("Filter_" + filter->name().utf8()); |
2655 | config->writeEntry("Criteria",filter->criteria()); | 2655 | config->writeEntry("Criteria",filter->criteria()); |
2656 | config->writeEntry("CategoryList",filter->categoryList()); | 2656 | config->writeEntry("CategoryList",filter->categoryList()); |
2657 | filter = mFilters.next(); | 2657 | filter = mFilters.next(); |
2658 | } | 2658 | } |
2659 | config->setGroup("General"); | 2659 | config->setGroup("General"); |
2660 | config->writeEntry("CalendarFilters",filterList); | 2660 | config->writeEntry("CalendarFilters",filterList); |
2661 | 2661 | ||
2662 | config->setGroup("FilterView"); | 2662 | config->setGroup("FilterView"); |
2663 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2663 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2664 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2664 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2665 | } | 2665 | } |
2666 | 2666 | ||
2667 | 2667 | ||
2668 | void CalendarView::goToday() | 2668 | void CalendarView::goToday() |
2669 | { | 2669 | { |
2670 | if ( mViewManager->currentView()->isMonthView() ) | 2670 | if ( mViewManager->currentView()->isMonthView() ) |
2671 | mNavigator->selectTodayMonth(); | 2671 | mNavigator->selectTodayMonth(); |
2672 | else | 2672 | else |
2673 | mNavigator->selectToday(); | 2673 | mNavigator->selectToday(); |
2674 | } | 2674 | } |
2675 | 2675 | ||
2676 | void CalendarView::goNext() | 2676 | void CalendarView::goNext() |
2677 | { | 2677 | { |
2678 | mNavigator->selectNext(); | 2678 | mNavigator->selectNext(); |
2679 | } | 2679 | } |
2680 | 2680 | ||
2681 | void CalendarView::goPrevious() | 2681 | void CalendarView::goPrevious() |
2682 | { | 2682 | { |
2683 | mNavigator->selectPrevious(); | 2683 | mNavigator->selectPrevious(); |
2684 | } | 2684 | } |
2685 | void CalendarView::goNextMonth() | 2685 | void CalendarView::goNextMonth() |
2686 | { | 2686 | { |
2687 | mNavigator->selectNextMonth(); | 2687 | mNavigator->selectNextMonth(); |
2688 | } | 2688 | } |
2689 | 2689 | ||
2690 | void CalendarView::goPreviousMonth() | 2690 | void CalendarView::goPreviousMonth() |
2691 | { | 2691 | { |
2692 | mNavigator->selectPreviousMonth(); | 2692 | mNavigator->selectPreviousMonth(); |
2693 | } | 2693 | } |
2694 | 2694 | ||
2695 | void CalendarView::updateConfig() | 2695 | void CalendarView::updateConfig() |
2696 | { | 2696 | { |
2697 | if ( KOPrefs::instance()->mUseAppColors ) | 2697 | if ( KOPrefs::instance()->mUseAppColors ) |
2698 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2698 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2699 | emit configChanged(); | 2699 | emit configChanged(); |
2700 | mTodoList->updateConfig(); | 2700 | mTodoList->updateConfig(); |
2701 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2701 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2702 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2702 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2703 | // To make the "fill window" configurations work | 2703 | // To make the "fill window" configurations work |
2704 | //mViewManager->raiseCurrentView(); | 2704 | //mViewManager->raiseCurrentView(); |
2705 | } | 2705 | } |
2706 | 2706 | ||
2707 | 2707 | ||
2708 | void CalendarView::eventChanged(Event *event) | 2708 | void CalendarView::eventChanged(Event *event) |
2709 | { | 2709 | { |
2710 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2710 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2711 | //updateUnmanagedViews(); | 2711 | //updateUnmanagedViews(); |
2712 | } | 2712 | } |
2713 | 2713 | ||
2714 | void CalendarView::eventAdded(Event *event) | 2714 | void CalendarView::eventAdded(Event *event) |
2715 | { | 2715 | { |
2716 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2716 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2717 | } | 2717 | } |
2718 | 2718 | ||
2719 | void CalendarView::eventToBeDeleted(Event *) | 2719 | void CalendarView::eventToBeDeleted(Event *) |
2720 | { | 2720 | { |
2721 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2721 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2722 | } | 2722 | } |
2723 | 2723 | ||
2724 | void CalendarView::eventDeleted() | 2724 | void CalendarView::eventDeleted() |
2725 | { | 2725 | { |
2726 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2726 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2727 | } | 2727 | } |
2728 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2728 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2729 | { | 2729 | { |
2730 | changeIncidenceDisplay((Incidence *)which, action); | 2730 | changeIncidenceDisplay((Incidence *)which, action); |
2731 | mDateNavigator->updateView(); //LR | 2731 | mDateNavigator->updateView(); //LR |
2732 | //mDialogManager->updateSearchDialog(); | 2732 | //mDialogManager->updateSearchDialog(); |
2733 | 2733 | ||
2734 | if (which) { | 2734 | if (which) { |
2735 | mViewManager->updateWNview(); | 2735 | mViewManager->updateWNview(); |
2736 | //mTodoList->updateView(); | 2736 | //mTodoList->updateView(); |
2737 | } | 2737 | } |
2738 | 2738 | ||
2739 | } | 2739 | } |
2740 | 2740 | ||
2741 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2741 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2742 | { | 2742 | { |
2743 | updateUnmanagedViews(); | 2743 | updateUnmanagedViews(); |
2744 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2744 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2745 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2745 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2746 | mCalendar->checkAlarmForIncidence( 0, true ); | 2746 | mCalendar->checkAlarmForIncidence( 0, true ); |
2747 | if ( mEventViewerDialog ) | 2747 | if ( mEventViewerDialog ) |
2748 | mEventViewerDialog->hide(); | 2748 | mEventViewerDialog->hide(); |
2749 | } | 2749 | } |
2750 | else | 2750 | else |
2751 | mCalendar->checkAlarmForIncidence( which , false ); | 2751 | mCalendar->checkAlarmForIncidence( which , false ); |
2752 | } | 2752 | } |
2753 | 2753 | ||
2754 | // most of the changeEventDisplays() right now just call the view's | 2754 | // most of the changeEventDisplays() right now just call the view's |
2755 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2755 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2756 | void CalendarView::changeEventDisplay(Event *which, int action) | 2756 | void CalendarView::changeEventDisplay(Event *which, int action) |
2757 | { | 2757 | { |
2758 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2758 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2759 | changeIncidenceDisplay((Incidence *)which, action); | 2759 | changeIncidenceDisplay((Incidence *)which, action); |
2760 | static bool clearallviews = false; | 2760 | static bool clearallviews = false; |
2761 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2761 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2762 | if ( clearallviews ) { | 2762 | if ( clearallviews ) { |
2763 | clearAllViews(); | 2763 | clearAllViews(); |
2764 | clearallviews = false; | 2764 | clearallviews = false; |
2765 | } | 2765 | } |
2766 | return; | 2766 | return; |
2767 | } | 2767 | } |
2768 | clearallviews = true; | 2768 | clearallviews = true; |
2769 | mDateNavigator->updateView(); | 2769 | mDateNavigator->updateView(); |
2770 | //mDialogManager->updateSearchDialog(); | 2770 | //mDialogManager->updateSearchDialog(); |
2771 | if (which) { | 2771 | if (which) { |
2772 | // If there is an event view visible update the display | 2772 | // If there is an event view visible update the display |
2773 | mViewManager->currentView()->changeEventDisplay(which,action); | 2773 | mViewManager->currentView()->changeEventDisplay(which,action); |
2774 | // TODO: check, if update needed | 2774 | // TODO: check, if update needed |
2775 | // if (which->getTodoStatus()) { | 2775 | // if (which->getTodoStatus()) { |
2776 | mTodoList->updateView(); | 2776 | mTodoList->updateView(); |
2777 | if ( action != KOGlobals::EVENTDELETED ) { | 2777 | if ( action != KOGlobals::EVENTDELETED ) { |
2778 | mConflictingEvent = which ; | 2778 | mConflictingEvent = which ; |
2779 | int time = 1000; | 2779 | int time = 1000; |
2780 | #ifdef DESKTOP_VERSION | 2780 | #ifdef DESKTOP_VERSION |
2781 | time = 500; | 2781 | time = 500; |
2782 | #endif | 2782 | #endif |
2783 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); | 2783 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); |
2784 | } | 2784 | } |
2785 | // } | 2785 | // } |
2786 | } else { | 2786 | } else { |
2787 | mViewManager->currentView()->updateView(); | 2787 | mViewManager->currentView()->updateView(); |
2788 | } | 2788 | } |
2789 | } | 2789 | } |
2790 | void CalendarView::checkConflictForEvent() | 2790 | void CalendarView::checkConflictForEvent() |
2791 | { | 2791 | { |
2792 | 2792 | ||
2793 | if (!KOPrefs::instance()->mConfirm) | 2793 | if (!KOPrefs::instance()->mConfirm) |
2794 | return; | 2794 | return; |
2795 | if ( ! mConflictingEvent ) return; | 2795 | if ( ! mConflictingEvent ) return; |
2796 | QDateTime current = QDateTime::currentDateTime(); | 2796 | QDateTime current = QDateTime::currentDateTime(); |
2797 | if ( ! mConflictingEvent->matchTime( ¤t, 0 ) ) { | 2797 | if ( ! mConflictingEvent->matchTime( ¤t, 0 ) ) { |
2798 | mConflictingEvent = 0; | 2798 | mConflictingEvent = 0; |
2799 | return; | 2799 | return; |
2800 | } | 2800 | } |
2801 | QPtrList<Event> testlist = mCalendar->events(); | 2801 | QPtrList<Event> testlist = mCalendar->events(); |
2802 | Event * test = testlist.first(); | 2802 | Event * test = testlist.first(); |
2803 | QDateTime conflict; | 2803 | QDateTime conflict; |
2804 | QDateTime retVal; | 2804 | QDateTime retVal; |
2805 | bool found = false; | 2805 | bool found = false; |
2806 | Event * cE = 0; | 2806 | Event * cE = 0; |
2807 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 2807 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
2808 | while ( test ) { | 2808 | while ( test ) { |
2809 | qApp->processEvents(); | 2809 | qApp->processEvents(); |
2810 | bool skip = false; | 2810 | bool skip = false; |
2811 | if ( found ) | 2811 | if ( found ) |
2812 | skip = !test->matchTime( ¤t, &conflict ); | 2812 | skip = !test->matchTime( ¤t, &conflict ); |
2813 | else | 2813 | else |
2814 | skip = !test->matchTime( ¤t, 0 ); | 2814 | skip = !test->matchTime( ¤t, 0 ); |
2815 | if ( !skip && !test->doesFloat() ) { | 2815 | if ( !skip && !test->doesFloat() ) { |
2816 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 2816 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
2817 | if ( ! found ) { | 2817 | if ( ! found ) { |
2818 | conflict = retVal; | 2818 | conflict = retVal; |
2819 | cE = test; | 2819 | cE = test; |
2820 | } else { | 2820 | } else { |
2821 | if ( retVal < conflict ) { | 2821 | if ( retVal < conflict ) { |
2822 | conflict = retVal; | 2822 | conflict = retVal; |
2823 | cE = test; | 2823 | cE = test; |
2824 | } | 2824 | } |
2825 | } | 2825 | } |
2826 | found = true; | 2826 | found = true; |
2827 | } | 2827 | } |
2828 | } | 2828 | } |
2829 | test = testlist.next(); | 2829 | test = testlist.next(); |
2830 | } | 2830 | } |
2831 | topLevelWidget()->setCaption( i18n("KO/Pi") ); | ||
2831 | if ( found ) { | 2832 | if ( found ) { |
2832 | 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()) ) ; | 2833 | 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()) ) ; |
2833 | qApp->processEvents(); | 2834 | qApp->processEvents(); |
2834 | int km = KMessageBox::warningContinueCancel(this,mess, | 2835 | int km = KMessageBox::warningContinueCancel(this,mess, |
2835 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | 2836 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); |
2836 | if ( km != KMessageBox::Continue ) | 2837 | if ( km != KMessageBox::Continue ) { |
2837 | return; | 2838 | return; |
2838 | 2839 | } | |
2839 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 2840 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
2840 | mViewManager->showDayView(); | 2841 | mViewManager->showDayView(); |
2841 | mNavigator->slotDaySelect( conflict.date() ); | 2842 | mNavigator->slotDaySelect( conflict.date() ); |
2842 | int hour = conflict.time().hour(); | 2843 | int hour = conflict.time().hour(); |
2843 | mViewManager->agendaView()->setStartHour( hour ); | 2844 | mViewManager->agendaView()->setStartHour( hour ); |
2844 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 2845 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
2845 | } else | 2846 | } else |
2846 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 2847 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
2847 | mConflictingEvent = 0; | 2848 | mConflictingEvent = 0; |
2848 | return; | 2849 | return; |
2849 | 2850 | ||
2850 | } | 2851 | } |
2851 | 2852 | ||
2852 | void CalendarView::updateTodoViews() | 2853 | void CalendarView::updateTodoViews() |
2853 | { | 2854 | { |
2854 | mTodoList->updateView(); | 2855 | mTodoList->updateView(); |
2855 | mViewManager->currentView()->updateView(); | 2856 | mViewManager->currentView()->updateView(); |
2856 | 2857 | ||
2857 | } | 2858 | } |
2858 | 2859 | ||
2859 | 2860 | ||
2860 | 2861 | ||
2861 | void CalendarView::clearAllViews() | 2862 | void CalendarView::clearAllViews() |
2862 | { | 2863 | { |
2863 | mTodoList->clearList(); | 2864 | mTodoList->clearList(); |
2864 | mViewManager->clearAllViews(); | 2865 | mViewManager->clearAllViews(); |
2865 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2866 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2866 | if ( sd ) { | 2867 | if ( sd ) { |
2867 | KOListView* kol = sd->listview(); | 2868 | KOListView* kol = sd->listview(); |
2868 | if ( kol ) | 2869 | if ( kol ) |
2869 | kol->clearList(); | 2870 | kol->clearList(); |
2870 | } | 2871 | } |
2871 | } | 2872 | } |
2872 | void CalendarView::updateView() | 2873 | void CalendarView::updateView() |
2873 | { | 2874 | { |
2874 | static bool clearallviews = false; | 2875 | static bool clearallviews = false; |
2875 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2876 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2876 | if ( clearallviews ) { | 2877 | if ( clearallviews ) { |
2877 | clearAllViews(); | 2878 | clearAllViews(); |
2878 | clearallviews = false; | 2879 | clearallviews = false; |
2879 | } | 2880 | } |
2880 | return; | 2881 | return; |
2881 | } | 2882 | } |
2882 | clearallviews = true; | 2883 | clearallviews = true; |
2883 | DateList tmpList = mNavigator->selectedDates(); | 2884 | DateList tmpList = mNavigator->selectedDates(); |
2884 | 2885 | ||
2885 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2886 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2886 | mTodoList->updateView(); | 2887 | mTodoList->updateView(); |
2887 | // We assume that the navigator only selects consecutive days. | 2888 | // We assume that the navigator only selects consecutive days. |
2888 | updateView( tmpList.first(), tmpList.last() ); | 2889 | updateView( tmpList.first(), tmpList.last() ); |
2889 | } | 2890 | } |
2890 | 2891 | ||
2891 | void CalendarView::updateUnmanagedViews() | 2892 | void CalendarView::updateUnmanagedViews() |
2892 | { | 2893 | { |
2893 | mDateNavigator->updateDayMatrix(); | 2894 | mDateNavigator->updateDayMatrix(); |
2894 | } | 2895 | } |
2895 | 2896 | ||
2896 | int CalendarView::msgItemDelete(const QString name) | 2897 | int CalendarView::msgItemDelete(const QString name) |
2897 | { | 2898 | { |
2898 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2899 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2899 | i18n("This item will be\npermanently deleted."), | 2900 | i18n("This item will be\npermanently deleted."), |
2900 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2901 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2901 | } | 2902 | } |
2902 | 2903 | ||
2903 | 2904 | ||
2904 | void CalendarView::edit_cut() | 2905 | void CalendarView::edit_cut() |
2905 | { | 2906 | { |
2906 | Event *anEvent=0; | 2907 | Event *anEvent=0; |
2907 | 2908 | ||
2908 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2909 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2909 | 2910 | ||
2910 | if (mViewManager->currentView()->isEventView()) { | 2911 | if (mViewManager->currentView()->isEventView()) { |
2911 | if ( incidence && incidence->typeID() == eventID ) { | 2912 | if ( incidence && incidence->typeID() == eventID ) { |
2912 | anEvent = static_cast<Event *>(incidence); | 2913 | anEvent = static_cast<Event *>(incidence); |
2913 | } | 2914 | } |
2914 | } | 2915 | } |
2915 | 2916 | ||
2916 | if (!anEvent) { | 2917 | if (!anEvent) { |
2917 | KNotifyClient::beep(); | 2918 | KNotifyClient::beep(); |
2918 | return; | 2919 | return; |
2919 | } | 2920 | } |
2920 | DndFactory factory( mCalendar ); | 2921 | DndFactory factory( mCalendar ); |
2921 | factory.cutIncidence(anEvent); | 2922 | factory.cutIncidence(anEvent); |
2922 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2923 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2923 | } | 2924 | } |
2924 | 2925 | ||
2925 | void CalendarView::edit_copy() | 2926 | void CalendarView::edit_copy() |
2926 | { | 2927 | { |
2927 | Event *anEvent=0; | 2928 | Event *anEvent=0; |
2928 | 2929 | ||
2929 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2930 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2930 | 2931 | ||
2931 | if (mViewManager->currentView()->isEventView()) { | 2932 | if (mViewManager->currentView()->isEventView()) { |
2932 | if ( incidence && incidence->typeID() == eventID ) { | 2933 | if ( incidence && incidence->typeID() == eventID ) { |
2933 | anEvent = static_cast<Event *>(incidence); | 2934 | anEvent = static_cast<Event *>(incidence); |
2934 | } | 2935 | } |
2935 | } | 2936 | } |
2936 | 2937 | ||
2937 | if (!anEvent) { | 2938 | if (!anEvent) { |
2938 | KNotifyClient::beep(); | 2939 | KNotifyClient::beep(); |
2939 | return; | 2940 | return; |
2940 | } | 2941 | } |
2941 | DndFactory factory( mCalendar ); | 2942 | DndFactory factory( mCalendar ); |
2942 | factory.copyIncidence(anEvent); | 2943 | factory.copyIncidence(anEvent); |
2943 | } | 2944 | } |
2944 | 2945 | ||
2945 | void CalendarView::edit_paste() | 2946 | void CalendarView::edit_paste() |
2946 | { | 2947 | { |
2947 | QDate date = mNavigator->selectedDates().first(); | 2948 | QDate date = mNavigator->selectedDates().first(); |
2948 | 2949 | ||
2949 | DndFactory factory( mCalendar ); | 2950 | DndFactory factory( mCalendar ); |
2950 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2951 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2951 | 2952 | ||
2952 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2953 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2953 | } | 2954 | } |
2954 | void CalendarView::edit_global_options() | 2955 | void CalendarView::edit_global_options() |
2955 | { | 2956 | { |
2956 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2957 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2957 | emit save(); | 2958 | emit save(); |
2958 | emit saveStopTimer(); | 2959 | emit saveStopTimer(); |
2959 | mDialogManager->showGlobalOptionsDialog(); | 2960 | mDialogManager->showGlobalOptionsDialog(); |
2960 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2961 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2961 | emit saveStopTimer(); | 2962 | emit saveStopTimer(); |
2962 | 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!"), | 2963 | 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!"), |
2963 | i18n("Timezone settings"),i18n("Reload"))) { | 2964 | i18n("Timezone settings"),i18n("Reload"))) { |
2964 | qDebug("KO: TZ reload cancelled "); | 2965 | qDebug("KO: TZ reload cancelled "); |
2965 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2966 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2966 | return; | 2967 | return; |
2967 | } | 2968 | } |
2968 | qDebug("KO: Timezone change "); | 2969 | qDebug("KO: Timezone change "); |
2969 | loadCalendars(); | 2970 | loadCalendars(); |
2970 | setModified(true); | 2971 | setModified(true); |
2971 | } | 2972 | } |
2972 | else | 2973 | else |
2973 | qDebug("KO: No tz change "); | 2974 | qDebug("KO: No tz change "); |
2974 | } | 2975 | } |
2975 | void CalendarView::edit_options() | 2976 | void CalendarView::edit_options() |
2976 | { | 2977 | { |
2977 | mDialogManager->showOptionsDialog(); | 2978 | mDialogManager->showOptionsDialog(); |
2978 | } | 2979 | } |
2979 | 2980 | ||
2980 | 2981 | ||
2981 | void CalendarView::slotSelectPickerDate( QDate d) | 2982 | void CalendarView::slotSelectPickerDate( QDate d) |
2982 | { | 2983 | { |
2983 | mDateFrame->hide(); | 2984 | mDateFrame->hide(); |
2984 | if ( mDatePickerMode == 1 ) { | 2985 | if ( mDatePickerMode == 1 ) { |
2985 | mNavigator->slotDaySelect( d ); | 2986 | mNavigator->slotDaySelect( d ); |
2986 | } else if ( mDatePickerMode == 2 ) { | 2987 | } else if ( mDatePickerMode == 2 ) { |
2987 | if ( mMoveIncidence->typeID() == todoID ) { | 2988 | if ( mMoveIncidence->typeID() == todoID ) { |
2988 | Todo * to = (Todo *) mMoveIncidence; | 2989 | Todo * to = (Todo *) mMoveIncidence; |
2989 | QTime tim; | 2990 | QTime tim; |
2990 | int len = 0; | 2991 | int len = 0; |
2991 | if ( to->hasStartDate() && to->hasDueDate() ) | 2992 | if ( to->hasStartDate() && to->hasDueDate() ) |
2992 | len = to->dtStart().secsTo( to->dtDue()); | 2993 | len = to->dtStart().secsTo( to->dtDue()); |
2993 | if ( to->hasDueDate() ) | 2994 | if ( to->hasDueDate() ) |
2994 | tim = to->dtDue().time(); | 2995 | tim = to->dtDue().time(); |
2995 | else { | 2996 | else { |
2996 | tim = QTime ( 0,0,0 ); | 2997 | tim = QTime ( 0,0,0 ); |
2997 | to->setFloats( true ); | 2998 | to->setFloats( true ); |
2998 | to->setHasDueDate( true ); | 2999 | to->setHasDueDate( true ); |
2999 | } | 3000 | } |
3000 | QDateTime dt ( d,tim ); | 3001 | QDateTime dt ( d,tim ); |
3001 | to->setDtDue( dt ); | 3002 | to->setDtDue( dt ); |
3002 | 3003 | ||
3003 | if ( to->hasStartDate() ) { | 3004 | if ( to->hasStartDate() ) { |
3004 | if ( len>0 ) | 3005 | if ( len>0 ) |
3005 | to->setDtStart(to->dtDue().addSecs( -len )); | 3006 | to->setDtStart(to->dtDue().addSecs( -len )); |
3006 | else | 3007 | else |
3007 | if (to->dtStart() > to->dtDue() ) | 3008 | if (to->dtStart() > to->dtDue() ) |
3008 | to->setDtStart(to->dtDue().addDays( -3 )); | 3009 | to->setDtStart(to->dtDue().addDays( -3 )); |
3009 | } | 3010 | } |
3010 | 3011 | ||
3011 | todoChanged( to ); | 3012 | todoChanged( to ); |
3012 | } else if ( mMoveIncidence->typeID() == eventID ) { | 3013 | } else if ( mMoveIncidence->typeID() == eventID ) { |
3013 | if ( mMoveIncidence->doesRecur() ) { | 3014 | if ( mMoveIncidence->doesRecur() ) { |
3014 | #if 0 | 3015 | #if 0 |
3015 | // PENDING implement this | 3016 | // PENDING implement this |
3016 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 3017 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3017 | mCalendar()->addIncidence( newInc ); | 3018 | mCalendar()->addIncidence( newInc ); |
3018 | if ( mMoveIncidence->typeID() == todoID ) | 3019 | if ( mMoveIncidence->typeID() == todoID ) |
3019 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 3020 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3020 | else | 3021 | else |
3021 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 3022 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3022 | mMoveIncidence = newInc; | 3023 | mMoveIncidence = newInc; |
3023 | 3024 | ||
3024 | #endif | 3025 | #endif |
3025 | } | 3026 | } |
3026 | QTime tim = mMoveIncidence->dtStart().time(); | 3027 | QTime tim = mMoveIncidence->dtStart().time(); |
3027 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 3028 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3028 | QDateTime dt ( d,tim ); | 3029 | QDateTime dt ( d,tim ); |
3029 | mMoveIncidence->setDtStart( dt ); | 3030 | mMoveIncidence->setDtStart( dt ); |
3030 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 3031 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3031 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 3032 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3032 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3033 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3033 | QTime tim = mMoveIncidence->dtStart().time(); | 3034 | QTime tim = mMoveIncidence->dtStart().time(); |
3034 | QDateTime dt ( d,tim ); | 3035 | QDateTime dt ( d,tim ); |
3035 | mMoveIncidence->setDtStart( dt ); | 3036 | mMoveIncidence->setDtStart( dt ); |
3036 | updateView(); | 3037 | updateView(); |
3037 | } | 3038 | } |
3038 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3039 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3039 | } | 3040 | } |
3040 | } | 3041 | } |
3041 | 3042 | ||
3042 | void CalendarView::removeCategories() | 3043 | void CalendarView::removeCategories() |
3043 | { | 3044 | { |
3044 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3045 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3045 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3046 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3046 | QStringList catIncList; | 3047 | QStringList catIncList; |
3047 | QStringList newCatList; | 3048 | QStringList newCatList; |
3048 | Incidence* inc = incList.first(); | 3049 | Incidence* inc = incList.first(); |
3049 | uint i; | 3050 | uint i; |
3050 | while ( inc ) { | 3051 | while ( inc ) { |
3051 | newCatList.clear(); | 3052 | newCatList.clear(); |
3052 | catIncList = inc->categories() ; | 3053 | catIncList = inc->categories() ; |
3053 | for( i = 0; i< catIncList.count(); ++i ) { | 3054 | for( i = 0; i< catIncList.count(); ++i ) { |
3054 | if ( catList.contains (catIncList[i])) | 3055 | if ( catList.contains (catIncList[i])) |
3055 | newCatList.append( catIncList[i] ); | 3056 | newCatList.append( catIncList[i] ); |
3056 | } | 3057 | } |
3057 | newCatList.sort(); | 3058 | newCatList.sort(); |
3058 | inc->setCategories( newCatList.join(",") ); | 3059 | inc->setCategories( newCatList.join(",") ); |
3059 | inc = incList.next(); | 3060 | inc = incList.next(); |
3060 | } | 3061 | } |
3061 | } | 3062 | } |
3062 | 3063 | ||
3063 | int CalendarView::addCategories() | 3064 | int CalendarView::addCategories() |
3064 | { | 3065 | { |
3065 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3066 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3066 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3067 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3067 | QStringList catIncList; | 3068 | QStringList catIncList; |
3068 | Incidence* inc = incList.first(); | 3069 | Incidence* inc = incList.first(); |
3069 | uint i; | 3070 | uint i; |
3070 | int count = 0; | 3071 | int count = 0; |
3071 | while ( inc ) { | 3072 | while ( inc ) { |
3072 | catIncList = inc->categories() ; | 3073 | catIncList = inc->categories() ; |
3073 | for( i = 0; i< catIncList.count(); ++i ) { | 3074 | for( i = 0; i< catIncList.count(); ++i ) { |
3074 | if ( !catList.contains (catIncList[i])) { | 3075 | if ( !catList.contains (catIncList[i])) { |
3075 | catList.append( catIncList[i] ); | 3076 | catList.append( catIncList[i] ); |
3076 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3077 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3077 | ++count; | 3078 | ++count; |
3078 | } | 3079 | } |
3079 | } | 3080 | } |
3080 | inc = incList.next(); | 3081 | inc = incList.next(); |
3081 | } | 3082 | } |
3082 | catList.sort(); | 3083 | catList.sort(); |
3083 | KOPrefs::instance()->mCustomCategories = catList; | 3084 | KOPrefs::instance()->mCustomCategories = catList; |
3084 | return count; | 3085 | return count; |
3085 | } | 3086 | } |
3086 | 3087 | ||
3087 | void CalendarView::editCategories() | 3088 | void CalendarView::editCategories() |
3088 | { | 3089 | { |
3089 | qDebug("CalendarView::editCategories() "); | 3090 | qDebug("CalendarView::editCategories() "); |
3090 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3091 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3091 | ced.exec(); | 3092 | ced.exec(); |
3092 | } | 3093 | } |
3093 | void CalendarView::manageCategories() | 3094 | void CalendarView::manageCategories() |
3094 | { | 3095 | { |
3095 | KOCatPrefs* cp = new KOCatPrefs(); | 3096 | KOCatPrefs* cp = new KOCatPrefs(); |
3096 | cp->show(); | 3097 | cp->show(); |
3097 | int w =cp->sizeHint().width() ; | 3098 | int w =cp->sizeHint().width() ; |
3098 | int h = cp->sizeHint().height() ; | 3099 | int h = cp->sizeHint().height() ; |
3099 | int dw = QApplication::desktop()->width(); | 3100 | int dw = QApplication::desktop()->width(); |
3100 | int dh = QApplication::desktop()->height(); | 3101 | int dh = QApplication::desktop()->height(); |
3101 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3102 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3102 | if ( !cp->exec() ) { | 3103 | if ( !cp->exec() ) { |
3103 | delete cp; | 3104 | delete cp; |
3104 | return; | 3105 | return; |
3105 | } | 3106 | } |
3106 | int count = 0; | 3107 | int count = 0; |
3107 | if ( cp->addCat() ) { | 3108 | if ( cp->addCat() ) { |
3108 | count = addCategories(); | 3109 | count = addCategories(); |
3109 | if ( count ) { | 3110 | if ( count ) { |
3110 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3111 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3111 | writeSettings(); | 3112 | writeSettings(); |
3112 | } else | 3113 | } else |
3113 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3114 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3114 | } else { | 3115 | } else { |
3115 | removeCategories(); | 3116 | removeCategories(); |
3116 | updateView(); | 3117 | updateView(); |
3117 | } | 3118 | } |
3118 | delete cp; | 3119 | delete cp; |
3119 | } | 3120 | } |
3120 | 3121 | ||
3121 | void CalendarView::beamIncidence(Incidence * Inc) | 3122 | void CalendarView::beamIncidence(Incidence * Inc) |
3122 | { | 3123 | { |
3123 | QPtrList<Incidence> delSel ; | 3124 | QPtrList<Incidence> delSel ; |
3124 | delSel.append(Inc); | 3125 | delSel.append(Inc); |
3125 | beamIncidenceList( delSel ); | 3126 | beamIncidenceList( delSel ); |
3126 | } | 3127 | } |
3127 | void CalendarView::beamCalendar() | 3128 | void CalendarView::beamCalendar() |
3128 | { | 3129 | { |
3129 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3130 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3130 | //qDebug("beamCalendar() "); | 3131 | //qDebug("beamCalendar() "); |
3131 | beamIncidenceList( delSel ); | 3132 | beamIncidenceList( delSel ); |
3132 | } | 3133 | } |
3133 | void CalendarView::beamFilteredCalendar() | 3134 | void CalendarView::beamFilteredCalendar() |
3134 | { | 3135 | { |
3135 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3136 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3136 | //qDebug("beamFilteredCalendar() "); | 3137 | //qDebug("beamFilteredCalendar() "); |
3137 | beamIncidenceList( delSel ); | 3138 | beamIncidenceList( delSel ); |
3138 | } | 3139 | } |
3139 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3140 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3140 | { | 3141 | { |
3141 | 3142 | ||
3142 | KOBeamPrefs beamDialog; | 3143 | KOBeamPrefs beamDialog; |
3143 | if ( beamDialog.exec () == QDialog::Rejected ) | 3144 | if ( beamDialog.exec () == QDialog::Rejected ) |
3144 | return; | 3145 | return; |
3145 | #ifdef DESKTOP_VERSION | 3146 | #ifdef DESKTOP_VERSION |
3146 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3147 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3147 | #else | 3148 | #else |
3148 | QString fn = "/tmp/kopibeamfile"; | 3149 | QString fn = "/tmp/kopibeamfile"; |
3149 | #endif | 3150 | #endif |
3150 | QString mes; | 3151 | QString mes; |
3151 | bool createbup = true; | 3152 | bool createbup = true; |
3152 | if ( createbup ) { | 3153 | if ( createbup ) { |
3153 | QString description = "\n"; | 3154 | QString description = "\n"; |
3154 | CalendarLocal* cal = new CalendarLocal(); | 3155 | CalendarLocal* cal = new CalendarLocal(); |
3155 | if ( beamDialog.beamLocal() ) | 3156 | if ( beamDialog.beamLocal() ) |
3156 | cal->setLocalTime(); | 3157 | cal->setLocalTime(); |
3157 | else | 3158 | else |
3158 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3159 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3159 | Incidence *incidence = delSel.first(); | 3160 | Incidence *incidence = delSel.first(); |
3160 | bool addText = false; | 3161 | bool addText = false; |
3161 | if ( delSel.count() < 10 ) | 3162 | if ( delSel.count() < 10 ) |
3162 | addText = true; | 3163 | addText = true; |
3163 | else { | 3164 | else { |
3164 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3165 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3165 | } | 3166 | } |
3166 | while ( incidence ) { | 3167 | while ( incidence ) { |
3167 | Incidence *in = incidence->clone(); | 3168 | Incidence *in = incidence->clone(); |
3168 | if ( ! in->summary().isEmpty() ) { | 3169 | if ( ! in->summary().isEmpty() ) { |
3169 | in->setDescription(""); | 3170 | in->setDescription(""); |
3170 | } else { | 3171 | } else { |
3171 | in->setSummary( in->description().left(20)); | 3172 | in->setSummary( in->description().left(20)); |
3172 | in->setDescription(""); | 3173 | in->setDescription(""); |
3173 | } | 3174 | } |
3174 | if ( addText ) | 3175 | if ( addText ) |
3175 | description += in->summary() + "\n"; | 3176 | description += in->summary() + "\n"; |
3176 | cal->addIncidence( in ); | 3177 | cal->addIncidence( in ); |
3177 | incidence = delSel.next(); | 3178 | incidence = delSel.next(); |
3178 | } | 3179 | } |
3179 | if ( beamDialog.beamVcal() ) { | 3180 | if ( beamDialog.beamVcal() ) { |
3180 | fn += ".vcs"; | 3181 | fn += ".vcs"; |
3181 | FileStorage storage( cal, fn, new VCalFormat ); | 3182 | FileStorage storage( cal, fn, new VCalFormat ); |
3182 | storage.save(); | 3183 | storage.save(); |
3183 | } else { | 3184 | } else { |
3184 | fn += ".ics"; | 3185 | fn += ".ics"; |
3185 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3186 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3186 | storage.save(); | 3187 | storage.save(); |
3187 | } | 3188 | } |
3188 | delete cal; | 3189 | delete cal; |
3189 | mes = i18n("KO/Pi: Ready for beaming"); | 3190 | mes = i18n("KO/Pi: Ready for beaming"); |
3190 | topLevelWidget()->setCaption(mes); | 3191 | topLevelWidget()->setCaption(mes); |
3191 | KApplication::convert2latin1( fn ); | 3192 | KApplication::convert2latin1( fn ); |
3192 | #ifndef DESKTOP_VERSION | 3193 | #ifndef DESKTOP_VERSION |
3193 | Ir *ir = new Ir( this ); | 3194 | Ir *ir = new Ir( this ); |
3194 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3195 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3195 | ir->send( fn, description, "text/x-vCalendar" ); | 3196 | ir->send( fn, description, "text/x-vCalendar" ); |
3196 | #endif | 3197 | #endif |
3197 | } | 3198 | } |
3198 | } | 3199 | } |
3199 | 3200 | ||
3200 | #ifndef DESKTOP_VERSION | 3201 | #ifndef DESKTOP_VERSION |
3201 | void CalendarView::beamDone( Ir *ir ) | 3202 | void CalendarView::beamDone( Ir *ir ) |
3202 | { | 3203 | { |
3203 | delete ir; | 3204 | delete ir; |
3204 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3205 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3205 | topLevelWidget()->raise(); | 3206 | topLevelWidget()->raise(); |
3206 | } | 3207 | } |
3207 | #else | 3208 | #else |
3208 | void CalendarView::beamDone( Ir *){;} | 3209 | void CalendarView::beamDone( Ir *){;} |
3209 | #endif | 3210 | #endif |
3210 | void CalendarView::moveIncidence(Incidence * inc ) | 3211 | void CalendarView::moveIncidence(Incidence * inc ) |
3211 | { | 3212 | { |
3212 | if ( !inc ) return; | 3213 | if ( !inc ) return; |
3213 | showDatePickerPopup(); | 3214 | showDatePickerPopup(); |
3214 | mDatePickerMode = 2; | 3215 | mDatePickerMode = 2; |
3215 | mMoveIncidence = inc ; | 3216 | mMoveIncidence = inc ; |
3216 | QDate da; | 3217 | QDate da; |
3217 | if ( mMoveIncidence->typeID() == todoID ) { | 3218 | if ( mMoveIncidence->typeID() == todoID ) { |
3218 | Todo * to = (Todo *) mMoveIncidence; | 3219 | Todo * to = (Todo *) mMoveIncidence; |
3219 | if ( to->hasDueDate() ) | 3220 | if ( to->hasDueDate() ) |
3220 | da = to->dtDue().date(); | 3221 | da = to->dtDue().date(); |
3221 | else | 3222 | else |
3222 | da = QDate::currentDate(); | 3223 | da = QDate::currentDate(); |
3223 | } else { | 3224 | } else { |
3224 | da = mMoveIncidence->dtStart().date(); | 3225 | da = mMoveIncidence->dtStart().date(); |
3225 | } | 3226 | } |
3226 | //PENDING set date for recurring incidence to date of recurrence | 3227 | //PENDING set date for recurring incidence to date of recurrence |
3227 | //mMoveIncidenceOldDate; | 3228 | //mMoveIncidenceOldDate; |
3228 | mDatePicker->setDate( da ); | 3229 | mDatePicker->setDate( da ); |
3229 | } | 3230 | } |
3230 | void CalendarView::showDatePickerPopup() | 3231 | void CalendarView::showDatePickerPopup() |
3231 | { | 3232 | { |
3232 | if ( mDateFrame->isVisible() ) | 3233 | if ( mDateFrame->isVisible() ) |
3233 | mDateFrame->hide(); | 3234 | mDateFrame->hide(); |
3234 | else { | 3235 | else { |
3235 | int offX = 0, offY = 0; | 3236 | int offX = 0, offY = 0; |
3236 | #ifdef DESKTOP_VERSION | 3237 | #ifdef DESKTOP_VERSION |
3237 | int w =mDatePicker->sizeHint().width() ; | 3238 | int w =mDatePicker->sizeHint().width() ; |
3238 | int h = mDatePicker->sizeHint().height() ; | 3239 | int h = mDatePicker->sizeHint().height() ; |
3239 | int dw = topLevelWidget()->width(); | 3240 | int dw = topLevelWidget()->width(); |
3240 | int dh = topLevelWidget()->height(); | 3241 | int dh = topLevelWidget()->height(); |
3241 | offX = topLevelWidget()->x(); | 3242 | offX = topLevelWidget()->x(); |
3242 | offY = topLevelWidget()->y(); | 3243 | offY = topLevelWidget()->y(); |
3243 | #else | 3244 | #else |
3244 | int w =mDatePicker->sizeHint().width() ; | 3245 | int w =mDatePicker->sizeHint().width() ; |
3245 | int h = mDatePicker->sizeHint().height() ; | 3246 | int h = mDatePicker->sizeHint().height() ; |
3246 | int dw = QApplication::desktop()->width(); | 3247 | int dw = QApplication::desktop()->width(); |
3247 | int dh = QApplication::desktop()->height(); | 3248 | int dh = QApplication::desktop()->height(); |
3248 | #endif | 3249 | #endif |
3249 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3250 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3250 | mDateFrame->show(); | 3251 | mDateFrame->show(); |
3251 | } | 3252 | } |
3252 | } | 3253 | } |
3253 | void CalendarView::showDatePicker( ) | 3254 | void CalendarView::showDatePicker( ) |
3254 | { | 3255 | { |
3255 | showDatePickerPopup(); | 3256 | showDatePickerPopup(); |
3256 | mDatePickerMode = 1; | 3257 | mDatePickerMode = 1; |
3257 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3258 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3258 | } | 3259 | } |
3259 | 3260 | ||
3260 | void CalendarView::showEventEditor() | 3261 | void CalendarView::showEventEditor() |
3261 | { | 3262 | { |
3262 | #ifdef DESKTOP_VERSION | 3263 | #ifdef DESKTOP_VERSION |
3263 | int x,y,w,h; | 3264 | int x,y,w,h; |
3264 | x = mEventEditor->geometry().x(); | 3265 | x = mEventEditor->geometry().x(); |
3265 | y = mEventEditor->geometry().y(); | 3266 | y = mEventEditor->geometry().y(); |
3266 | w = mEventEditor->width(); | 3267 | w = mEventEditor->width(); |
3267 | h = mEventEditor->height(); | 3268 | h = mEventEditor->height(); |
3268 | mEventEditor->show(); | 3269 | mEventEditor->show(); |
3269 | mEventEditor->setGeometry(x,y,w,h); | 3270 | mEventEditor->setGeometry(x,y,w,h); |
3270 | #else | 3271 | #else |
3271 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3272 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3272 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3273 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3273 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3274 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3274 | qApp->processEvents(); | 3275 | qApp->processEvents(); |
3275 | delete mEventEditor; | 3276 | delete mEventEditor; |
3276 | mEventEditor = mDialogManager->getEventEditor(); | 3277 | mEventEditor = mDialogManager->getEventEditor(); |
3277 | topLevelWidget()->setCaption( i18n("") ); | 3278 | topLevelWidget()->setCaption( i18n("") ); |
3278 | } | 3279 | } |
3279 | mEventEditor->showMaximized(); | 3280 | mEventEditor->showMaximized(); |
3280 | #endif | 3281 | #endif |
3281 | } | 3282 | } |
3282 | void CalendarView::showTodoEditor() | 3283 | void CalendarView::showTodoEditor() |
3283 | { | 3284 | { |
3284 | #ifdef DESKTOP_VERSION | 3285 | #ifdef DESKTOP_VERSION |
3285 | int x,y,w,h; | 3286 | int x,y,w,h; |
3286 | x = mTodoEditor->geometry().x(); | 3287 | x = mTodoEditor->geometry().x(); |
3287 | y = mTodoEditor->geometry().y(); | 3288 | y = mTodoEditor->geometry().y(); |
3288 | w = mTodoEditor->width(); | 3289 | w = mTodoEditor->width(); |
3289 | h = mTodoEditor->height(); | 3290 | h = mTodoEditor->height(); |
3290 | mTodoEditor->show(); | 3291 | mTodoEditor->show(); |
3291 | mTodoEditor->setGeometry(x,y,w,h); | 3292 | mTodoEditor->setGeometry(x,y,w,h); |
3292 | #else | 3293 | #else |
3293 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3294 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3294 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3295 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3295 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3296 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3296 | qApp->processEvents(); | 3297 | qApp->processEvents(); |
3297 | delete mTodoEditor; | 3298 | delete mTodoEditor; |
3298 | mTodoEditor = mDialogManager->getTodoEditor(); | 3299 | mTodoEditor = mDialogManager->getTodoEditor(); |
3299 | topLevelWidget()->setCaption( i18n("") ); | 3300 | topLevelWidget()->setCaption( i18n("") ); |
3300 | } | 3301 | } |
3301 | mTodoEditor->showMaximized(); | 3302 | mTodoEditor->showMaximized(); |
3302 | #endif | 3303 | #endif |
3303 | } | 3304 | } |
3304 | 3305 | ||
3305 | void CalendarView::cloneIncidence() | 3306 | void CalendarView::cloneIncidence() |
3306 | { | 3307 | { |
3307 | Incidence *incidence = currentSelection(); | 3308 | Incidence *incidence = currentSelection(); |
3308 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3309 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3309 | if ( incidence ) { | 3310 | if ( incidence ) { |
3310 | cloneIncidence(incidence); | 3311 | cloneIncidence(incidence); |
3311 | } | 3312 | } |
3312 | } | 3313 | } |
3313 | void CalendarView::moveIncidence() | 3314 | void CalendarView::moveIncidence() |
3314 | { | 3315 | { |
3315 | Incidence *incidence = currentSelection(); | 3316 | Incidence *incidence = currentSelection(); |
3316 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3317 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3317 | if ( incidence ) { | 3318 | if ( incidence ) { |
3318 | moveIncidence(incidence); | 3319 | moveIncidence(incidence); |
3319 | } | 3320 | } |
3320 | } | 3321 | } |
3321 | void CalendarView::beamIncidence() | 3322 | void CalendarView::beamIncidence() |
3322 | { | 3323 | { |
3323 | Incidence *incidence = currentSelection(); | 3324 | Incidence *incidence = currentSelection(); |
3324 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3325 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3325 | if ( incidence ) { | 3326 | if ( incidence ) { |
3326 | beamIncidence(incidence); | 3327 | beamIncidence(incidence); |
3327 | } | 3328 | } |
3328 | } | 3329 | } |
3329 | void CalendarView::toggleCancelIncidence() | 3330 | void CalendarView::toggleCancelIncidence() |
3330 | { | 3331 | { |
3331 | Incidence *incidence = currentSelection(); | 3332 | Incidence *incidence = currentSelection(); |
3332 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3333 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3333 | if ( incidence ) { | 3334 | if ( incidence ) { |
3334 | cancelIncidence(incidence); | 3335 | cancelIncidence(incidence); |
3335 | } | 3336 | } |
3336 | } | 3337 | } |
3337 | 3338 | ||
3338 | 3339 | ||
3339 | void CalendarView::cancelIncidence(Incidence * inc ) | 3340 | void CalendarView::cancelIncidence(Incidence * inc ) |
3340 | { | 3341 | { |
3341 | inc->setCancelled( ! inc->cancelled() ); | 3342 | inc->setCancelled( ! inc->cancelled() ); |
3342 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3343 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3343 | updateView(); | 3344 | updateView(); |
3344 | } | 3345 | } |
3345 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3346 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3346 | { | 3347 | { |
3347 | Incidence * newInc = orgInc->clone(); | 3348 | Incidence * newInc = orgInc->clone(); |
3348 | newInc->recreate(); | 3349 | newInc->recreate(); |
3349 | 3350 | ||
3350 | if ( newInc->typeID() == todoID ) { | 3351 | if ( newInc->typeID() == todoID ) { |
3351 | Todo* t = (Todo*) newInc; | 3352 | Todo* t = (Todo*) newInc; |
3352 | bool cloneSub = false; | 3353 | bool cloneSub = false; |
3353 | if ( orgInc->relations().count() ) { | 3354 | if ( orgInc->relations().count() ) { |
3354 | int result = KMessageBox::warningYesNoCancel(this, | 3355 | int result = KMessageBox::warningYesNoCancel(this, |
3355 | 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 ) ), | 3356 | 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 ) ), |
3356 | i18n("Todo has subtodos"), | 3357 | i18n("Todo has subtodos"), |
3357 | i18n("Yes"), | 3358 | i18n("Yes"), |
3358 | i18n("No")); | 3359 | i18n("No")); |
3359 | 3360 | ||
3360 | if ( result == KMessageBox::Cancel ) { | 3361 | if ( result == KMessageBox::Cancel ) { |
3361 | delete t; | 3362 | delete t; |
3362 | return; | 3363 | return; |
3363 | } | 3364 | } |
3364 | if (result == KMessageBox::Yes) cloneSub = true; | 3365 | if (result == KMessageBox::Yes) cloneSub = true; |
3365 | } | 3366 | } |
3366 | showTodoEditor(); | 3367 | showTodoEditor(); |
3367 | mTodoEditor->editTodo( t ); | 3368 | mTodoEditor->editTodo( t ); |
3368 | if ( mTodoEditor->exec() ) { | 3369 | if ( mTodoEditor->exec() ) { |
3369 | if ( cloneSub ) { | 3370 | if ( cloneSub ) { |
3370 | orgInc->cloneRelations( t ); | 3371 | orgInc->cloneRelations( t ); |
3371 | mCalendar->addIncidenceBranch( t ); | 3372 | mCalendar->addIncidenceBranch( t ); |
3372 | updateView(); | 3373 | updateView(); |
3373 | 3374 | ||
3374 | } else { | 3375 | } else { |
3375 | mCalendar->addTodo( t ); | 3376 | mCalendar->addTodo( t ); |
3376 | updateView(); | 3377 | updateView(); |
3377 | } | 3378 | } |
3378 | } else { | 3379 | } else { |
3379 | delete t; | 3380 | delete t; |
3380 | } | 3381 | } |
3381 | } | 3382 | } |
3382 | else if ( newInc->typeID() == eventID ) { | 3383 | else if ( newInc->typeID() == eventID ) { |
3383 | Event* e = (Event*) newInc; | 3384 | Event* e = (Event*) newInc; |
3384 | showEventEditor(); | 3385 | showEventEditor(); |
3385 | mEventEditor->editEvent( e ); | 3386 | mEventEditor->editEvent( e ); |
3386 | if ( mEventEditor->exec() ) { | 3387 | if ( mEventEditor->exec() ) { |
3387 | mCalendar->addEvent( e ); | 3388 | mCalendar->addEvent( e ); |
3388 | updateView(); | 3389 | updateView(); |
3389 | } else { | 3390 | } else { |
3390 | delete e; | 3391 | delete e; |
3391 | } | 3392 | } |
3392 | } if ( newInc->typeID() == journalID ) { | 3393 | } if ( newInc->typeID() == journalID ) { |
3393 | mCalendar->addJournal( (Journal*) newInc ); | 3394 | mCalendar->addJournal( (Journal*) newInc ); |
3394 | editJournal( (Journal*) newInc ); | 3395 | editJournal( (Journal*) newInc ); |
3395 | } | 3396 | } |
3396 | setActiveWindow(); | 3397 | setActiveWindow(); |
3397 | } | 3398 | } |
3398 | 3399 | ||
3399 | void CalendarView::newEvent() | 3400 | void CalendarView::newEvent() |
3400 | { | 3401 | { |
3401 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3402 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3402 | KOAgendaView *aView = mViewManager->agendaView(); | 3403 | KOAgendaView *aView = mViewManager->agendaView(); |
3403 | if (aView) { | 3404 | if (aView) { |
3404 | if (aView->selectionStart().isValid()) { | 3405 | if (aView->selectionStart().isValid()) { |
3405 | if (aView->selectedIsAllDay()) { | 3406 | if (aView->selectedIsAllDay()) { |
3406 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3407 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3407 | } else { | 3408 | } else { |
3408 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3409 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3409 | } | 3410 | } |
3410 | return; | 3411 | return; |
3411 | } | 3412 | } |
3412 | } | 3413 | } |
3413 | 3414 | ||
3414 | QDate date = mNavigator->selectedDates().first(); | 3415 | QDate date = mNavigator->selectedDates().first(); |
3415 | #if 0 | 3416 | #if 0 |
3416 | QDateTime current = QDateTime::currentDateTime(); | 3417 | QDateTime current = QDateTime::currentDateTime(); |
3417 | if ( date <= current.date() ) { | 3418 | if ( date <= current.date() ) { |
3418 | int hour = current.time().hour() +1; | 3419 | int hour = current.time().hour() +1; |
3419 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3420 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3420 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3421 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3421 | } else | 3422 | } else |
3422 | #endif | 3423 | #endif |
3423 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3424 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3424 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3425 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3425 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3426 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3426 | } | 3427 | } |
3427 | 3428 | ||
3428 | void CalendarView::newEvent(QDateTime fh) | 3429 | void CalendarView::newEvent(QDateTime fh) |
3429 | { | 3430 | { |
3430 | newEvent(fh, | 3431 | newEvent(fh, |
3431 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3432 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3432 | } | 3433 | } |
3433 | 3434 | ||
3434 | void CalendarView::newEvent(QDate dt) | 3435 | void CalendarView::newEvent(QDate dt) |
3435 | { | 3436 | { |
3436 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3437 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3437 | QDateTime(dt, QTime(0,0,0)), true); | 3438 | QDateTime(dt, QTime(0,0,0)), true); |
3438 | } | 3439 | } |
3439 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3440 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3440 | { | 3441 | { |
3441 | newEvent(fromHint, toHint, false); | 3442 | newEvent(fromHint, toHint, false); |
3442 | } | 3443 | } |
3443 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3444 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3444 | { | 3445 | { |
3445 | 3446 | ||
3446 | showEventEditor(); | 3447 | showEventEditor(); |
3447 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3448 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3448 | if ( mFilterView->filtersEnabled() ) { | 3449 | if ( mFilterView->filtersEnabled() ) { |
3449 | CalFilter *filter = mFilterView->selectedFilter(); | 3450 | CalFilter *filter = mFilterView->selectedFilter(); |
3450 | if (filter && filter->showCategories()) { | 3451 | if (filter && filter->showCategories()) { |
3451 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3452 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3452 | } | 3453 | } |
3453 | if ( filter ) | 3454 | if ( filter ) |
3454 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3455 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3455 | } | 3456 | } |
3456 | mEventEditor->exec(); | 3457 | mEventEditor->exec(); |
3457 | setActiveWindow(); | 3458 | setActiveWindow(); |
3458 | } | 3459 | } |
3459 | void CalendarView::todoAdded(Todo * t) | 3460 | void CalendarView::todoAdded(Todo * t) |
3460 | { | 3461 | { |
3461 | 3462 | ||
3462 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3463 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3463 | updateTodoViews(); | 3464 | updateTodoViews(); |
3464 | } | 3465 | } |
3465 | void CalendarView::todoChanged(Todo * t) | 3466 | void CalendarView::todoChanged(Todo * t) |
3466 | { | 3467 | { |
3467 | emit todoModified( t, 4 ); | 3468 | emit todoModified( t, 4 ); |
3468 | // updateTodoViews(); | 3469 | // updateTodoViews(); |
3469 | } | 3470 | } |
3470 | void CalendarView::todoToBeDeleted(Todo *) | 3471 | void CalendarView::todoToBeDeleted(Todo *) |
3471 | { | 3472 | { |
3472 | //qDebug("todoToBeDeleted(Todo *) "); | 3473 | //qDebug("todoToBeDeleted(Todo *) "); |
3473 | updateTodoViews(); | 3474 | updateTodoViews(); |
3474 | } | 3475 | } |
3475 | void CalendarView::todoDeleted() | 3476 | void CalendarView::todoDeleted() |
3476 | { | 3477 | { |
3477 | //qDebug(" todoDeleted()"); | 3478 | //qDebug(" todoDeleted()"); |
3478 | updateTodoViews(); | 3479 | updateTodoViews(); |
3479 | } | 3480 | } |
3480 | 3481 | ||
3481 | 3482 | ||
3482 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3483 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3483 | { | 3484 | { |
3484 | showTodoEditor(); | 3485 | showTodoEditor(); |
3485 | mTodoEditor->newTodo(dt,0,allday); | 3486 | mTodoEditor->newTodo(dt,0,allday); |
3486 | if ( mFilterView->filtersEnabled() ) { | 3487 | if ( mFilterView->filtersEnabled() ) { |
3487 | CalFilter *filter = mFilterView->selectedFilter(); | 3488 | CalFilter *filter = mFilterView->selectedFilter(); |
3488 | if (filter && filter->showCategories()) { | 3489 | if (filter && filter->showCategories()) { |
3489 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3490 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3490 | } | 3491 | } |
3491 | if ( filter ) | 3492 | if ( filter ) |
3492 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3493 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3493 | } | 3494 | } |
3494 | mTodoEditor->exec(); | 3495 | mTodoEditor->exec(); |
3495 | setActiveWindow(); | 3496 | setActiveWindow(); |
3496 | } | 3497 | } |
3497 | 3498 | ||
3498 | void CalendarView::newTodo() | 3499 | void CalendarView::newTodo() |
3499 | { | 3500 | { |
3500 | newTodoDateTime( QDateTime(),true ); | 3501 | newTodoDateTime( QDateTime(),true ); |
3501 | } | 3502 | } |
3502 | 3503 | ||
3503 | void CalendarView::newSubTodo() | 3504 | void CalendarView::newSubTodo() |
3504 | { | 3505 | { |
3505 | Todo *todo = selectedTodo(); | 3506 | Todo *todo = selectedTodo(); |
3506 | if ( todo ) newSubTodo( todo ); | 3507 | if ( todo ) newSubTodo( todo ); |
3507 | } | 3508 | } |
3508 | 3509 | ||
3509 | void CalendarView::newSubTodo(Todo *parentEvent) | 3510 | void CalendarView::newSubTodo(Todo *parentEvent) |
3510 | { | 3511 | { |
3511 | 3512 | ||
3512 | showTodoEditor(); | 3513 | showTodoEditor(); |
3513 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3514 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3514 | mTodoEditor->exec(); | 3515 | mTodoEditor->exec(); |
3515 | setActiveWindow(); | 3516 | setActiveWindow(); |
3516 | } | 3517 | } |
3517 | 3518 | ||
3518 | void CalendarView::newFloatingEvent() | 3519 | void CalendarView::newFloatingEvent() |
3519 | { | 3520 | { |
3520 | DateList tmpList = mNavigator->selectedDates(); | 3521 | DateList tmpList = mNavigator->selectedDates(); |
3521 | QDate date = tmpList.first(); | 3522 | QDate date = tmpList.first(); |
3522 | 3523 | ||
3523 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3524 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3524 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3525 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3525 | } | 3526 | } |
3526 | 3527 | ||
3527 | 3528 | ||
3528 | void CalendarView::editEvent( Event *event ) | 3529 | void CalendarView::editEvent( Event *event ) |
3529 | { | 3530 | { |
3530 | 3531 | ||
3531 | if ( !event ) return; | 3532 | if ( !event ) return; |
3532 | if ( event->isReadOnly() ) { | 3533 | if ( event->isReadOnly() ) { |
3533 | showEvent( event ); | 3534 | showEvent( event ); |
3534 | return; | 3535 | return; |
3535 | } | 3536 | } |
3536 | showEventEditor(); | 3537 | showEventEditor(); |
3537 | mEventEditor->editEvent( event , mFlagEditDescription); | 3538 | mEventEditor->editEvent( event , mFlagEditDescription); |
3538 | mEventEditor->exec(); | 3539 | mEventEditor->exec(); |
3539 | setActiveWindow(); | 3540 | setActiveWindow(); |
3540 | 3541 | ||
3541 | } | 3542 | } |
3542 | void CalendarView::editJournal( Journal *jour ) | 3543 | void CalendarView::editJournal( Journal *jour ) |
3543 | { | 3544 | { |
3544 | if ( !jour ) return; | 3545 | if ( !jour ) return; |
3545 | mDialogManager->hideSearchDialog(); | 3546 | mDialogManager->hideSearchDialog(); |
3546 | mViewManager->showJournalView(); | 3547 | mViewManager->showJournalView(); |
3547 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3548 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3548 | } | 3549 | } |
3549 | void CalendarView::editTodo( Todo *todo ) | 3550 | void CalendarView::editTodo( Todo *todo ) |
3550 | { | 3551 | { |
3551 | if ( !todo ) return; | 3552 | if ( !todo ) return; |
3552 | 3553 | ||
3553 | if ( todo->isReadOnly() ) { | 3554 | if ( todo->isReadOnly() ) { |
3554 | showTodo( todo ); | 3555 | showTodo( todo ); |
3555 | return; | 3556 | return; |
3556 | } | 3557 | } |
3557 | showTodoEditor(); | 3558 | showTodoEditor(); |
3558 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3559 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3559 | mTodoEditor->exec(); | 3560 | mTodoEditor->exec(); |
3560 | setActiveWindow(); | 3561 | setActiveWindow(); |
3561 | 3562 | ||
3562 | } | 3563 | } |
3563 | 3564 | ||
3564 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3565 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3565 | { | 3566 | { |
3566 | if ( !mEventViewerDialog ) { | 3567 | if ( !mEventViewerDialog ) { |
3567 | mEventViewerDialog = new KOEventViewerDialog(0); | 3568 | mEventViewerDialog = new KOEventViewerDialog(0); |
3568 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3569 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3569 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3570 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3570 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3571 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3571 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3572 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3572 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3573 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3573 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3574 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3574 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3575 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3575 | this, SLOT( slotViewerClosed() ) ); | 3576 | this, SLOT( slotViewerClosed() ) ); |
3576 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3577 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3577 | this, SLOT( todoChanged(Todo *) ) ); | 3578 | this, SLOT( todoChanged(Todo *) ) ); |
3578 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3579 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3579 | mEventViewerDialog->resize( 640, 480 ); | 3580 | mEventViewerDialog->resize( 640, 480 ); |
3580 | 3581 | ||
3581 | } | 3582 | } |
3582 | return mEventViewerDialog; | 3583 | return mEventViewerDialog; |
3583 | } | 3584 | } |
3584 | void CalendarView::showEvent(Event *event) | 3585 | void CalendarView::showEvent(Event *event) |
3585 | { | 3586 | { |
3586 | getEventViewerDialog()->setEvent(event); | 3587 | getEventViewerDialog()->setEvent(event); |
3587 | getEventViewerDialog()->showMe(); | 3588 | getEventViewerDialog()->showMe(); |
3588 | } | 3589 | } |
3589 | 3590 | ||
3590 | void CalendarView::showTodo(Todo *event) | 3591 | void CalendarView::showTodo(Todo *event) |
3591 | { | 3592 | { |
3592 | getEventViewerDialog()->setTodo(event); | 3593 | getEventViewerDialog()->setTodo(event); |
3593 | getEventViewerDialog()->showMe(); | 3594 | getEventViewerDialog()->showMe(); |
3594 | } | 3595 | } |
3595 | void CalendarView::showJournal( Journal *jour ) | 3596 | void CalendarView::showJournal( Journal *jour ) |
3596 | { | 3597 | { |
3597 | getEventViewerDialog()->setJournal(jour); | 3598 | getEventViewerDialog()->setJournal(jour); |
3598 | getEventViewerDialog()->showMe(); | 3599 | getEventViewerDialog()->showMe(); |
3599 | 3600 | ||
3600 | } | 3601 | } |
3601 | // void CalendarView::todoModified (Todo *event, int changed) | 3602 | // void CalendarView::todoModified (Todo *event, int changed) |
3602 | // { | 3603 | // { |
3603 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3604 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3604 | // // kdDebug() << "Todo modified and open" << endl; | 3605 | // // kdDebug() << "Todo modified and open" << endl; |
3605 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3606 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3606 | // // temp->modified (changed); | 3607 | // // temp->modified (changed); |
3607 | 3608 | ||
3608 | // // } | 3609 | // // } |
3609 | 3610 | ||
3610 | // mViewManager->updateView(); | 3611 | // mViewManager->updateView(); |
3611 | // } | 3612 | // } |
3612 | 3613 | ||
3613 | void CalendarView::appointment_show() | 3614 | void CalendarView::appointment_show() |
3614 | { | 3615 | { |
3615 | Event *anEvent = 0; | 3616 | Event *anEvent = 0; |
3616 | 3617 | ||
3617 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3618 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3618 | 3619 | ||
3619 | if (mViewManager->currentView()->isEventView()) { | 3620 | if (mViewManager->currentView()->isEventView()) { |
3620 | if ( incidence && incidence->typeID() == eventID ) { | 3621 | if ( incidence && incidence->typeID() == eventID ) { |
3621 | anEvent = static_cast<Event *>(incidence); | 3622 | anEvent = static_cast<Event *>(incidence); |
3622 | } | 3623 | } |
3623 | } | 3624 | } |
3624 | 3625 | ||
3625 | if (!anEvent) { | 3626 | if (!anEvent) { |
3626 | KNotifyClient::beep(); | 3627 | KNotifyClient::beep(); |
3627 | return; | 3628 | return; |
3628 | } | 3629 | } |
3629 | 3630 | ||
3630 | showEvent(anEvent); | 3631 | showEvent(anEvent); |
3631 | } | 3632 | } |
3632 | 3633 | ||
3633 | void CalendarView::appointment_edit() | 3634 | void CalendarView::appointment_edit() |
3634 | { | 3635 | { |
3635 | Event *anEvent = 0; | 3636 | Event *anEvent = 0; |
3636 | 3637 | ||
3637 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3638 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3638 | 3639 | ||
3639 | if (mViewManager->currentView()->isEventView()) { | 3640 | if (mViewManager->currentView()->isEventView()) { |
3640 | if ( incidence && incidence->typeID() == eventID ) { | 3641 | if ( incidence && incidence->typeID() == eventID ) { |
3641 | anEvent = static_cast<Event *>(incidence); | 3642 | anEvent = static_cast<Event *>(incidence); |
3642 | } | 3643 | } |
3643 | } | 3644 | } |
3644 | 3645 | ||
3645 | if (!anEvent) { | 3646 | if (!anEvent) { |
3646 | KNotifyClient::beep(); | 3647 | KNotifyClient::beep(); |
3647 | return; | 3648 | return; |
3648 | } | 3649 | } |
3649 | 3650 | ||
3650 | editEvent(anEvent); | 3651 | editEvent(anEvent); |
3651 | } | 3652 | } |
3652 | 3653 | ||
3653 | void CalendarView::appointment_delete() | 3654 | void CalendarView::appointment_delete() |
3654 | { | 3655 | { |
3655 | Event *anEvent = 0; | 3656 | Event *anEvent = 0; |
3656 | 3657 | ||
3657 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3658 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3658 | 3659 | ||
3659 | if (mViewManager->currentView()->isEventView()) { | 3660 | if (mViewManager->currentView()->isEventView()) { |
3660 | if ( incidence && incidence->typeID() == eventID ) { | 3661 | if ( incidence && incidence->typeID() == eventID ) { |
3661 | anEvent = static_cast<Event *>(incidence); | 3662 | anEvent = static_cast<Event *>(incidence); |
3662 | } | 3663 | } |
3663 | } | 3664 | } |
3664 | 3665 | ||
3665 | if (!anEvent) { | 3666 | if (!anEvent) { |
3666 | KNotifyClient::beep(); | 3667 | KNotifyClient::beep(); |
3667 | return; | 3668 | return; |
3668 | } | 3669 | } |
3669 | 3670 | ||
3670 | deleteEvent(anEvent); | 3671 | deleteEvent(anEvent); |
3671 | } | 3672 | } |
3672 | 3673 | ||
3673 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3674 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3674 | { | 3675 | { |
3675 | if (!sub) return; | 3676 | if (!sub) return; |
3676 | if ( sub->relatedTo() == parent ) | 3677 | if ( sub->relatedTo() == parent ) |
3677 | return; | 3678 | return; |
3678 | sub->setRelatedTo(parent); | 3679 | sub->setRelatedTo(parent); |
3679 | sub->updated(); | 3680 | sub->updated(); |
3680 | setModified(true); | 3681 | setModified(true); |
3681 | updateView(); | 3682 | updateView(); |
3682 | } | 3683 | } |
3683 | void CalendarView::todo_unsub(Todo *anTodo ) | 3684 | void CalendarView::todo_unsub(Todo *anTodo ) |
3684 | { | 3685 | { |
3685 | todo_resub( 0, anTodo ); | 3686 | todo_resub( 0, anTodo ); |
3686 | } | 3687 | } |
3687 | 3688 | ||
3688 | void CalendarView::deleteTodo(Todo *todo) | 3689 | void CalendarView::deleteTodo(Todo *todo) |
3689 | { | 3690 | { |
3690 | if (!todo) { | 3691 | if (!todo) { |
3691 | KNotifyClient::beep(); | 3692 | KNotifyClient::beep(); |
3692 | return; | 3693 | return; |
3693 | } | 3694 | } |
3694 | if (KOPrefs::instance()->mConfirm) { | 3695 | if (KOPrefs::instance()->mConfirm) { |
3695 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3696 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3696 | if (!todo->relations().isEmpty()) { | 3697 | if (!todo->relations().isEmpty()) { |
3697 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3698 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3698 | 3699 | ||
3699 | } | 3700 | } |
3700 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3701 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3701 | case KMessageBox::Continue: // OK | 3702 | case KMessageBox::Continue: // OK |
3702 | bool deleteT = false; | 3703 | bool deleteT = false; |
3703 | if (!todo->relations().isEmpty()) { | 3704 | if (!todo->relations().isEmpty()) { |
3704 | deleteT = removeCompletedSubTodos( todo ); | 3705 | deleteT = removeCompletedSubTodos( todo ); |
3705 | } | 3706 | } |
3706 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3707 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3707 | if ( !deleteT ) { | 3708 | if ( !deleteT ) { |
3708 | checkExternalId( todo ); | 3709 | checkExternalId( todo ); |
3709 | calendar()->deleteTodo(todo); | 3710 | calendar()->deleteTodo(todo); |
3710 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3711 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3711 | updateView(); | 3712 | updateView(); |
3712 | } | 3713 | } |
3713 | break; | 3714 | break; |
3714 | } // switch | 3715 | } // switch |
3715 | } else { | 3716 | } else { |
3716 | checkExternalId( todo ); | 3717 | checkExternalId( todo ); |
3717 | mCalendar->deleteTodo(todo); | 3718 | mCalendar->deleteTodo(todo); |
3718 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3719 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3719 | updateView(); | 3720 | updateView(); |
3720 | } | 3721 | } |
3721 | 3722 | ||
3722 | emit updateSearchDialog(); | 3723 | emit updateSearchDialog(); |
3723 | } | 3724 | } |
3724 | void CalendarView::deleteJournal(Journal *jour) | 3725 | void CalendarView::deleteJournal(Journal *jour) |
3725 | { | 3726 | { |
3726 | if (!jour) { | 3727 | if (!jour) { |
3727 | KNotifyClient::beep(); | 3728 | KNotifyClient::beep(); |
3728 | return; | 3729 | return; |
3729 | } | 3730 | } |
3730 | if (KOPrefs::instance()->mConfirm) { | 3731 | if (KOPrefs::instance()->mConfirm) { |
3731 | 3732 | ||
3732 | QString des; | 3733 | QString des; |
3733 | if ( !jour->summary().isEmpty() ) { | 3734 | if ( !jour->summary().isEmpty() ) { |
3734 | des = jour->summary(); | 3735 | des = jour->summary(); |
3735 | } else { | 3736 | } else { |
3736 | des = jour->description().left(30); | 3737 | des = jour->description().left(30); |
3737 | des = des.simplifyWhiteSpace (); | 3738 | des = des.simplifyWhiteSpace (); |
3738 | des.replace (QRegExp ("\\n"),"" ); | 3739 | des.replace (QRegExp ("\\n"),"" ); |
3739 | des.replace (QRegExp ("\\r"),"" ); | 3740 | des.replace (QRegExp ("\\r"),"" ); |
3740 | } | 3741 | } |
3741 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 3742 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3742 | case KMessageBox::Continue: // OK | 3743 | case KMessageBox::Continue: // OK |
3743 | calendar()->deleteJournal(jour); | 3744 | calendar()->deleteJournal(jour); |
3744 | updateView(); | 3745 | updateView(); |
3745 | break; | 3746 | break; |
3746 | } // switch | 3747 | } // switch |
3747 | } else { | 3748 | } else { |
3748 | calendar()->deleteJournal(jour);; | 3749 | calendar()->deleteJournal(jour);; |
3749 | updateView(); | 3750 | updateView(); |
3750 | } | 3751 | } |
3751 | emit updateSearchDialog(); | 3752 | emit updateSearchDialog(); |
3752 | } | 3753 | } |
3753 | 3754 | ||
3754 | void CalendarView::deleteEvent(Event *anEvent) | 3755 | void CalendarView::deleteEvent(Event *anEvent) |
3755 | { | 3756 | { |
3756 | if (!anEvent) { | 3757 | if (!anEvent) { |
3757 | KNotifyClient::beep(); | 3758 | KNotifyClient::beep(); |
3758 | return; | 3759 | return; |
3759 | } | 3760 | } |
3760 | 3761 | ||
3761 | if (anEvent->recurrence()->doesRecur()) { | 3762 | if (anEvent->recurrence()->doesRecur()) { |
3762 | QDate itemDate = mViewManager->currentSelectionDate(); | 3763 | QDate itemDate = mViewManager->currentSelectionDate(); |
3763 | int km; | 3764 | int km; |
3764 | if (!itemDate.isValid()) { | 3765 | if (!itemDate.isValid()) { |
3765 | //kdDebug() << "Date Not Valid" << endl; | 3766 | //kdDebug() << "Date Not Valid" << endl; |
3766 | if (KOPrefs::instance()->mConfirm) { | 3767 | if (KOPrefs::instance()->mConfirm) { |
3767 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3768 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3768 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3769 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3769 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3770 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3770 | if ( km == KMessageBox::Continue ) | 3771 | if ( km == KMessageBox::Continue ) |
3771 | km = KMessageBox::No; // No = all below | 3772 | km = KMessageBox::No; // No = all below |
3772 | } else | 3773 | } else |
3773 | km = KMessageBox::No; | 3774 | km = KMessageBox::No; |
3774 | } else { | 3775 | } else { |
3775 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3776 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3776 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3777 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3777 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3778 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3778 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3779 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3779 | i18n("All")); | 3780 | i18n("All")); |
3780 | } | 3781 | } |
3781 | switch(km) { | 3782 | switch(km) { |
3782 | 3783 | ||
3783 | case KMessageBox::No: // Continue // all | 3784 | case KMessageBox::No: // Continue // all |
3784 | //qDebug("KMessageBox::No "); | 3785 | //qDebug("KMessageBox::No "); |
3785 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3786 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3786 | schedule(Scheduler::Cancel,anEvent); | 3787 | schedule(Scheduler::Cancel,anEvent); |
3787 | 3788 | ||
3788 | checkExternalId( anEvent); | 3789 | checkExternalId( anEvent); |
3789 | mCalendar->deleteEvent(anEvent); | 3790 | mCalendar->deleteEvent(anEvent); |
3790 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3791 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3791 | break; | 3792 | break; |
3792 | 3793 | ||
3793 | // Disabled because it does not work | 3794 | // Disabled because it does not work |
3794 | //#if 0 | 3795 | //#if 0 |
3795 | case KMessageBox::Yes: // just this one | 3796 | case KMessageBox::Yes: // just this one |
3796 | //QDate qd = mNavigator->selectedDates().first(); | 3797 | //QDate qd = mNavigator->selectedDates().first(); |
3797 | //if (!qd.isValid()) { | 3798 | //if (!qd.isValid()) { |
3798 | // kdDebug() << "no date selected, or invalid date" << endl; | 3799 | // kdDebug() << "no date selected, or invalid date" << endl; |
3799 | // KNotifyClient::beep(); | 3800 | // KNotifyClient::beep(); |
3800 | // return; | 3801 | // return; |
3801 | //} | 3802 | //} |
3802 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3803 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3803 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3804 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3804 | anEvent->addExDate(itemDate); | 3805 | anEvent->addExDate(itemDate); |
3805 | int duration = anEvent->recurrence()->duration(); | 3806 | int duration = anEvent->recurrence()->duration(); |
3806 | if ( duration > 0 ) { | 3807 | if ( duration > 0 ) { |
3807 | anEvent->recurrence()->setDuration( duration - 1 ); | 3808 | anEvent->recurrence()->setDuration( duration - 1 ); |
3808 | } | 3809 | } |
3809 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3810 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3810 | } | 3811 | } |
3811 | break; | 3812 | break; |
3812 | //#endif | 3813 | //#endif |
3813 | } // switch | 3814 | } // switch |
3814 | } else { | 3815 | } else { |
3815 | if (KOPrefs::instance()->mConfirm) { | 3816 | if (KOPrefs::instance()->mConfirm) { |
3816 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3817 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3817 | i18n("\nAre you sure you want\nto delete this event?"), | 3818 | i18n("\nAre you sure you want\nto delete this event?"), |
3818 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3819 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3819 | case KMessageBox::Continue: // OK | 3820 | case KMessageBox::Continue: // OK |
3820 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3821 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3821 | schedule(Scheduler::Cancel,anEvent); | 3822 | schedule(Scheduler::Cancel,anEvent); |
3822 | checkExternalId( anEvent); | 3823 | checkExternalId( anEvent); |
3823 | mCalendar->deleteEvent(anEvent); | 3824 | mCalendar->deleteEvent(anEvent); |
3824 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3825 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3825 | break; | 3826 | break; |
3826 | } // switch | 3827 | } // switch |
3827 | } else { | 3828 | } else { |
3828 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3829 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3829 | schedule(Scheduler::Cancel,anEvent); | 3830 | schedule(Scheduler::Cancel,anEvent); |
3830 | checkExternalId( anEvent); | 3831 | checkExternalId( anEvent); |
3831 | mCalendar->deleteEvent(anEvent); | 3832 | mCalendar->deleteEvent(anEvent); |
3832 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3833 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3833 | } | 3834 | } |
3834 | } // if-else | 3835 | } // if-else |
3835 | emit updateSearchDialog(); | 3836 | emit updateSearchDialog(); |
3836 | } | 3837 | } |
3837 | 3838 | ||
3838 | bool CalendarView::deleteEvent(const QString &uid) | 3839 | bool CalendarView::deleteEvent(const QString &uid) |
3839 | { | 3840 | { |
3840 | Event *ev = mCalendar->event(uid); | 3841 | Event *ev = mCalendar->event(uid); |
3841 | if (ev) { | 3842 | if (ev) { |
3842 | deleteEvent(ev); | 3843 | deleteEvent(ev); |
3843 | return true; | 3844 | return true; |
3844 | } else { | 3845 | } else { |
3845 | return false; | 3846 | return false; |
3846 | } | 3847 | } |
3847 | } | 3848 | } |
3848 | 3849 | ||
3849 | /*****************************************************************************/ | 3850 | /*****************************************************************************/ |
3850 | 3851 | ||
3851 | void CalendarView::action_mail() | 3852 | void CalendarView::action_mail() |
3852 | { | 3853 | { |
3853 | #ifndef KORG_NOMAIL | 3854 | #ifndef KORG_NOMAIL |
3854 | KOMailClient mailClient; | 3855 | KOMailClient mailClient; |
3855 | 3856 | ||
3856 | Incidence *incidence = currentSelection(); | 3857 | Incidence *incidence = currentSelection(); |
3857 | 3858 | ||
3858 | if (!incidence) { | 3859 | if (!incidence) { |
3859 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3860 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3860 | return; | 3861 | return; |
3861 | } | 3862 | } |
3862 | if(incidence->attendeeCount() == 0 ) { | 3863 | if(incidence->attendeeCount() == 0 ) { |
3863 | KMessageBox::sorry(this, | 3864 | KMessageBox::sorry(this, |
3864 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3865 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3865 | return; | 3866 | return; |
3866 | } | 3867 | } |
3867 | 3868 | ||
3868 | CalendarLocal cal_tmp; | 3869 | CalendarLocal cal_tmp; |
3869 | Event *event = 0; | 3870 | Event *event = 0; |
3870 | Event *ev = 0; | 3871 | Event *ev = 0; |
3871 | if ( incidence && incidence->typeID() == eventID ) { | 3872 | if ( incidence && incidence->typeID() == eventID ) { |
3872 | event = static_cast<Event *>(incidence); | 3873 | event = static_cast<Event *>(incidence); |
3873 | ev = new Event(*event); | 3874 | ev = new Event(*event); |
3874 | cal_tmp.addEvent(ev); | 3875 | cal_tmp.addEvent(ev); |
3875 | } | 3876 | } |
3876 | ICalFormat mForm(); | 3877 | ICalFormat mForm(); |
3877 | QString attachment = mForm.toString( &cal_tmp ); | 3878 | QString attachment = mForm.toString( &cal_tmp ); |
3878 | if (ev) delete(ev); | 3879 | if (ev) delete(ev); |
3879 | 3880 | ||
3880 | mailClient.mailAttendees(currentSelection(), attachment); | 3881 | mailClient.mailAttendees(currentSelection(), attachment); |
3881 | 3882 | ||
3882 | #endif | 3883 | #endif |
3883 | 3884 | ||
3884 | #if 0 | 3885 | #if 0 |
3885 | Event *anEvent = 0; | 3886 | Event *anEvent = 0; |
3886 | if (mViewManager->currentView()->isEventView()) { | 3887 | if (mViewManager->currentView()->isEventView()) { |
3887 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3888 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3888 | } | 3889 | } |
3889 | 3890 | ||
3890 | if (!anEvent) { | 3891 | if (!anEvent) { |
3891 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3892 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3892 | return; | 3893 | return; |
3893 | } | 3894 | } |
3894 | if(anEvent->attendeeCount() == 0 ) { | 3895 | if(anEvent->attendeeCount() == 0 ) { |
3895 | KMessageBox::sorry(this, | 3896 | KMessageBox::sorry(this, |
3896 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3897 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3897 | return; | 3898 | return; |
3898 | } | 3899 | } |
3899 | 3900 | ||
3900 | mailobject.emailEvent(anEvent); | 3901 | mailobject.emailEvent(anEvent); |
3901 | #endif | 3902 | #endif |
3902 | } | 3903 | } |
3903 | 3904 | ||
3904 | 3905 | ||
3905 | void CalendarView::schedule_publish(Incidence *incidence) | 3906 | void CalendarView::schedule_publish(Incidence *incidence) |
3906 | { | 3907 | { |
3907 | Event *event = 0; | 3908 | Event *event = 0; |
3908 | Todo *todo = 0; | 3909 | Todo *todo = 0; |
3909 | 3910 | ||
3910 | if (incidence == 0) { | 3911 | if (incidence == 0) { |
3911 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3912 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3912 | if (incidence == 0) { | 3913 | if (incidence == 0) { |
3913 | incidence = mTodoList->selectedIncidences().first(); | 3914 | incidence = mTodoList->selectedIncidences().first(); |
3914 | } | 3915 | } |
3915 | } | 3916 | } |
3916 | if ( incidence && incidence->typeID() == eventID ) { | 3917 | if ( incidence && incidence->typeID() == eventID ) { |
3917 | event = static_cast<Event *>(incidence); | 3918 | event = static_cast<Event *>(incidence); |
3918 | } else { | 3919 | } else { |
3919 | if ( incidence && incidence->typeID() == todoID ) { | 3920 | if ( incidence && incidence->typeID() == todoID ) { |
3920 | todo = static_cast<Todo *>(incidence); | 3921 | todo = static_cast<Todo *>(incidence); |
3921 | } | 3922 | } |
3922 | } | 3923 | } |
3923 | 3924 | ||
3924 | if (!event && !todo) { | 3925 | if (!event && !todo) { |
3925 | KMessageBox::sorry(this,i18n("No event selected.")); | 3926 | KMessageBox::sorry(this,i18n("No event selected.")); |
3926 | return; | 3927 | return; |
3927 | } | 3928 | } |
3928 | 3929 | ||
3929 | PublishDialog *publishdlg = new PublishDialog(); | 3930 | PublishDialog *publishdlg = new PublishDialog(); |
3930 | if (incidence->attendeeCount()>0) { | 3931 | if (incidence->attendeeCount()>0) { |
3931 | QPtrList<Attendee> attendees = incidence->attendees(); | 3932 | QPtrList<Attendee> attendees = incidence->attendees(); |
3932 | attendees.first(); | 3933 | attendees.first(); |
3933 | while ( attendees.current()!=0 ) { | 3934 | while ( attendees.current()!=0 ) { |
3934 | publishdlg->addAttendee(attendees.current()); | 3935 | publishdlg->addAttendee(attendees.current()); |
3935 | attendees.next(); | 3936 | attendees.next(); |
3936 | } | 3937 | } |
3937 | } | 3938 | } |
3938 | bool send = true; | 3939 | bool send = true; |
3939 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3940 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3940 | if ( publishdlg->exec() != QDialog::Accepted ) | 3941 | if ( publishdlg->exec() != QDialog::Accepted ) |
3941 | send = false; | 3942 | send = false; |
3942 | } | 3943 | } |
3943 | if ( send ) { | 3944 | if ( send ) { |
3944 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3945 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3945 | if ( event ) { | 3946 | if ( event ) { |
3946 | Event *ev = new Event(*event); | 3947 | Event *ev = new Event(*event); |
3947 | ev->registerObserver(0); | 3948 | ev->registerObserver(0); |
3948 | ev->clearAttendees(); | 3949 | ev->clearAttendees(); |
3949 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3950 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3950 | delete(ev); | 3951 | delete(ev); |
3951 | } | 3952 | } |
3952 | } else { | 3953 | } else { |
3953 | if ( todo ) { | 3954 | if ( todo ) { |
3954 | Todo *ev = new Todo(*todo); | 3955 | Todo *ev = new Todo(*todo); |
3955 | ev->registerObserver(0); | 3956 | ev->registerObserver(0); |
3956 | ev->clearAttendees(); | 3957 | ev->clearAttendees(); |
3957 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3958 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3958 | delete(ev); | 3959 | delete(ev); |
3959 | } | 3960 | } |
3960 | } | 3961 | } |
3961 | } | 3962 | } |
3962 | } | 3963 | } |
3963 | delete publishdlg; | 3964 | delete publishdlg; |
3964 | } | 3965 | } |
3965 | 3966 | ||
3966 | void CalendarView::schedule_request(Incidence *incidence) | 3967 | void CalendarView::schedule_request(Incidence *incidence) |
3967 | { | 3968 | { |
3968 | schedule(Scheduler::Request,incidence); | 3969 | schedule(Scheduler::Request,incidence); |
3969 | } | 3970 | } |
3970 | 3971 | ||
3971 | void CalendarView::schedule_refresh(Incidence *incidence) | 3972 | void CalendarView::schedule_refresh(Incidence *incidence) |
3972 | { | 3973 | { |
3973 | schedule(Scheduler::Refresh,incidence); | 3974 | schedule(Scheduler::Refresh,incidence); |
3974 | } | 3975 | } |
3975 | 3976 | ||
3976 | void CalendarView::schedule_cancel(Incidence *incidence) | 3977 | void CalendarView::schedule_cancel(Incidence *incidence) |
3977 | { | 3978 | { |
3978 | schedule(Scheduler::Cancel,incidence); | 3979 | schedule(Scheduler::Cancel,incidence); |
3979 | } | 3980 | } |
3980 | 3981 | ||
3981 | void CalendarView::schedule_add(Incidence *incidence) | 3982 | void CalendarView::schedule_add(Incidence *incidence) |
3982 | { | 3983 | { |
3983 | schedule(Scheduler::Add,incidence); | 3984 | schedule(Scheduler::Add,incidence); |
3984 | } | 3985 | } |
3985 | 3986 | ||
3986 | void CalendarView::schedule_reply(Incidence *incidence) | 3987 | void CalendarView::schedule_reply(Incidence *incidence) |
3987 | { | 3988 | { |
3988 | schedule(Scheduler::Reply,incidence); | 3989 | schedule(Scheduler::Reply,incidence); |
3989 | } | 3990 | } |
3990 | 3991 | ||
3991 | void CalendarView::schedule_counter(Incidence *incidence) | 3992 | void CalendarView::schedule_counter(Incidence *incidence) |
3992 | { | 3993 | { |
3993 | schedule(Scheduler::Counter,incidence); | 3994 | schedule(Scheduler::Counter,incidence); |
3994 | } | 3995 | } |
3995 | 3996 | ||
3996 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3997 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3997 | { | 3998 | { |
3998 | schedule(Scheduler::Declinecounter,incidence); | 3999 | schedule(Scheduler::Declinecounter,incidence); |
3999 | } | 4000 | } |
4000 | 4001 | ||
4001 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 4002 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
4002 | { | 4003 | { |
4003 | QDateTime start = QDateTime::currentDateTime(); | 4004 | QDateTime start = QDateTime::currentDateTime(); |
4004 | QDateTime end = start.addDays(daysToPublish); | 4005 | QDateTime end = start.addDays(daysToPublish); |
4005 | 4006 | ||
4006 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4007 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
4007 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4008 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
4008 | 4009 | ||
4009 | 4010 | ||
4010 | PublishDialog *publishdlg = new PublishDialog(); | 4011 | PublishDialog *publishdlg = new PublishDialog(); |
4011 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4012 | if ( publishdlg->exec() == QDialog::Accepted ) { |
4012 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4013 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4013 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4014 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
4014 | delete(freebusy); | 4015 | delete(freebusy); |
4015 | } | 4016 | } |
4016 | } | 4017 | } |
4017 | delete publishdlg; | 4018 | delete publishdlg; |
4018 | } | 4019 | } |
4019 | 4020 | ||
4020 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4021 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4021 | { | 4022 | { |
4022 | Event *event = 0; | 4023 | Event *event = 0; |
4023 | Todo *todo = 0; | 4024 | Todo *todo = 0; |
4024 | 4025 | ||
4025 | if (incidence == 0) { | 4026 | if (incidence == 0) { |
4026 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4027 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4027 | if (incidence == 0) { | 4028 | if (incidence == 0) { |
4028 | incidence = mTodoList->selectedIncidences().first(); | 4029 | incidence = mTodoList->selectedIncidences().first(); |
4029 | } | 4030 | } |
4030 | } | 4031 | } |
4031 | if ( incidence && incidence->typeID() == eventID ) { | 4032 | if ( incidence && incidence->typeID() == eventID ) { |
4032 | event = static_cast<Event *>(incidence); | 4033 | event = static_cast<Event *>(incidence); |
4033 | } | 4034 | } |
4034 | if ( incidence && incidence->typeID() == todoID ) { | 4035 | if ( incidence && incidence->typeID() == todoID ) { |
4035 | todo = static_cast<Todo *>(incidence); | 4036 | todo = static_cast<Todo *>(incidence); |
4036 | } | 4037 | } |
4037 | 4038 | ||
4038 | if (!event && !todo) { | 4039 | if (!event && !todo) { |
4039 | KMessageBox::sorry(this,i18n("No event selected.")); | 4040 | KMessageBox::sorry(this,i18n("No event selected.")); |
4040 | return; | 4041 | return; |
4041 | } | 4042 | } |
4042 | 4043 | ||
4043 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4044 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4044 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4045 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4045 | return; | 4046 | return; |
4046 | } | 4047 | } |
4047 | 4048 | ||
4048 | Event *ev = 0; | 4049 | Event *ev = 0; |
4049 | if (event) ev = new Event(*event); | 4050 | if (event) ev = new Event(*event); |
4050 | Todo *to = 0; | 4051 | Todo *to = 0; |
4051 | if (todo) to = new Todo(*todo); | 4052 | if (todo) to = new Todo(*todo); |
4052 | 4053 | ||
4053 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4054 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4054 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4055 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4055 | if (!me) { | 4056 | if (!me) { |
4056 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4057 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4057 | return; | 4058 | return; |
4058 | } | 4059 | } |
4059 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4060 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4060 | StatusDialog *statdlg = new StatusDialog(this); | 4061 | StatusDialog *statdlg = new StatusDialog(this); |
4061 | if (!statdlg->exec()==QDialog::Accepted) return; | 4062 | if (!statdlg->exec()==QDialog::Accepted) return; |
4062 | me->setStatus( statdlg->status() ); | 4063 | me->setStatus( statdlg->status() ); |
4063 | delete(statdlg); | 4064 | delete(statdlg); |
4064 | } | 4065 | } |
4065 | Attendee *menew = new Attendee(*me); | 4066 | Attendee *menew = new Attendee(*me); |
4066 | if (ev) { | 4067 | if (ev) { |
4067 | ev->clearAttendees(); | 4068 | ev->clearAttendees(); |
4068 | ev->addAttendee(menew,false); | 4069 | ev->addAttendee(menew,false); |
4069 | } else { | 4070 | } else { |
4070 | if (to) { | 4071 | if (to) { |
4071 | todo->clearAttendees(); | 4072 | todo->clearAttendees(); |
4072 | todo->addAttendee(menew,false); | 4073 | todo->addAttendee(menew,false); |
4073 | } | 4074 | } |
4074 | } | 4075 | } |
4075 | } | 4076 | } |
4076 | 4077 | ||
4077 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4078 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4078 | if (ev) { | 4079 | if (ev) { |
4079 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4080 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4080 | } else { | 4081 | } else { |
4081 | if (to) { | 4082 | if (to) { |
4082 | if ( !dlg->addMessage(to,method) ) delete(to); | 4083 | if ( !dlg->addMessage(to,method) ) delete(to); |
4083 | } | 4084 | } |
4084 | } | 4085 | } |
4085 | } | 4086 | } |
4086 | 4087 | ||
4087 | void CalendarView::openAddressbook() | 4088 | void CalendarView::openAddressbook() |
4088 | { | 4089 | { |
4089 | KRun::runCommand("kaddressbook"); | 4090 | KRun::runCommand("kaddressbook"); |
4090 | } | 4091 | } |
4091 | 4092 | ||
4092 | void CalendarView::setModified(bool modified) | 4093 | void CalendarView::setModified(bool modified) |
4093 | { | 4094 | { |
4094 | if ( modified ) | 4095 | if ( modified ) |
4095 | emit signalmodified(); | 4096 | emit signalmodified(); |
4096 | if (mModified != modified) { | 4097 | if (mModified != modified) { |
4097 | mModified = modified; | 4098 | mModified = modified; |
4098 | emit modifiedChanged(mModified); | 4099 | emit modifiedChanged(mModified); |
4099 | } | 4100 | } |
4100 | } | 4101 | } |
4101 | 4102 | ||
4102 | bool CalendarView::isReadOnly() | 4103 | bool CalendarView::isReadOnly() |
4103 | { | 4104 | { |
4104 | return mReadOnly; | 4105 | return mReadOnly; |
4105 | } | 4106 | } |
4106 | 4107 | ||
4107 | void CalendarView::setReadOnly(bool readOnly) | 4108 | void CalendarView::setReadOnly(bool readOnly) |
4108 | { | 4109 | { |
4109 | if (mReadOnly != readOnly) { | 4110 | if (mReadOnly != readOnly) { |
4110 | mReadOnly = readOnly; | 4111 | mReadOnly = readOnly; |
4111 | emit readOnlyChanged(mReadOnly); | 4112 | emit readOnlyChanged(mReadOnly); |
4112 | } | 4113 | } |
4113 | } | 4114 | } |
4114 | 4115 | ||
4115 | bool CalendarView::isModified() | 4116 | bool CalendarView::isModified() |
4116 | { | 4117 | { |
4117 | return mModified; | 4118 | return mModified; |
4118 | } | 4119 | } |
4119 | void CalendarView::slotprintSelInc() | 4120 | void CalendarView::slotprintSelInc() |
4120 | { | 4121 | { |
4121 | if ( currentSelection() == 0 ) { | 4122 | if ( currentSelection() == 0 ) { |
4122 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4123 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4123 | return; | 4124 | return; |
4124 | } | 4125 | } |
4125 | showIncidence(); | 4126 | showIncidence(); |
4126 | getEventViewerDialog()->print(); | 4127 | getEventViewerDialog()->print(); |
4127 | 4128 | ||
4128 | } | 4129 | } |
4129 | void CalendarView::printSetup() | 4130 | void CalendarView::printSetup() |
4130 | { | 4131 | { |
4131 | #ifndef KORG_NOPRINTER | 4132 | #ifndef KORG_NOPRINTER |
4132 | createPrinter(); | 4133 | createPrinter(); |
4133 | 4134 | ||
4134 | mCalPrinter->setupPrinter(); | 4135 | mCalPrinter->setupPrinter(); |
4135 | #endif | 4136 | #endif |
4136 | } | 4137 | } |
4137 | 4138 | ||
4138 | void CalendarView::print() | 4139 | void CalendarView::print() |
4139 | { | 4140 | { |
4140 | #ifndef KORG_NOPRINTER | 4141 | #ifndef KORG_NOPRINTER |
4141 | createPrinter(); | 4142 | createPrinter(); |
4142 | 4143 | ||
4143 | DateList tmpDateList = mNavigator->selectedDates(); | 4144 | DateList tmpDateList = mNavigator->selectedDates(); |
4144 | mCalPrinter->print(CalPrinter::Month, | 4145 | mCalPrinter->print(CalPrinter::Month, |
4145 | tmpDateList.first(), tmpDateList.last()); | 4146 | tmpDateList.first(), tmpDateList.last()); |
4146 | #endif | 4147 | #endif |
4147 | } | 4148 | } |
4148 | 4149 | ||
4149 | void CalendarView::printPreview() | 4150 | void CalendarView::printPreview() |
4150 | { | 4151 | { |
4151 | #ifndef KORG_NOPRINTER | 4152 | #ifndef KORG_NOPRINTER |
4152 | kdDebug() << "CalendarView::printPreview()" << endl; | 4153 | kdDebug() << "CalendarView::printPreview()" << endl; |
4153 | 4154 | ||
4154 | createPrinter(); | 4155 | createPrinter(); |
4155 | 4156 | ||
4156 | DateList tmpDateList = mNavigator->selectedDates(); | 4157 | DateList tmpDateList = mNavigator->selectedDates(); |
4157 | 4158 | ||
4158 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4159 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4159 | tmpDateList.last()); | 4160 | tmpDateList.last()); |
4160 | #endif | 4161 | #endif |
4161 | } | 4162 | } |
4162 | 4163 | ||
4163 | void CalendarView::exportICalendar() | 4164 | void CalendarView::exportICalendar() |
4164 | { | 4165 | { |
4165 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 4166 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
4166 | 4167 | ||
4167 | // Force correct extension | 4168 | // Force correct extension |
4168 | if (filename.right(4) != ".ics") filename += ".ics"; | 4169 | if (filename.right(4) != ".ics") filename += ".ics"; |
4169 | 4170 | ||
4170 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4171 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4171 | storage.save(); | 4172 | storage.save(); |
4172 | } | 4173 | } |
4173 | 4174 | ||
4174 | bool CalendarView::exportVCalendar( QString filename ) | 4175 | bool CalendarView::exportVCalendar( QString filename ) |
4175 | { | 4176 | { |
4176 | if (mCalendar->journals().count() > 0) { | 4177 | if (mCalendar->journals().count() > 0) { |
4177 | int result = KMessageBox::warningContinueCancel(this, | 4178 | int result = KMessageBox::warningContinueCancel(this, |
4178 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4179 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4179 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4180 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4180 | true); | 4181 | true); |
4181 | if (result != KMessageBox::Continue) return false; | 4182 | if (result != KMessageBox::Continue) return false; |
4182 | } | 4183 | } |
4183 | 4184 | ||
4184 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4185 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4185 | 4186 | ||
4186 | // Force correct extension | 4187 | // Force correct extension |
4187 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4188 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4188 | 4189 | ||
4189 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4190 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4190 | return storage.save(); | 4191 | return storage.save(); |
4191 | 4192 | ||
4192 | } | 4193 | } |
4193 | 4194 | ||
4194 | void CalendarView::eventUpdated(Incidence *) | 4195 | void CalendarView::eventUpdated(Incidence *) |
4195 | { | 4196 | { |
4196 | setModified(); | 4197 | setModified(); |
4197 | // Don't call updateView here. The code, which has caused the update of the | 4198 | // Don't call updateView here. The code, which has caused the update of the |
4198 | // event is responsible for updating the view. | 4199 | // event is responsible for updating the view. |
4199 | // updateView(); | 4200 | // updateView(); |
4200 | } | 4201 | } |
4201 | 4202 | ||
4202 | void CalendarView::adaptNavigationUnits() | 4203 | void CalendarView::adaptNavigationUnits() |
4203 | { | 4204 | { |
4204 | if (mViewManager->currentView()->isEventView()) { | 4205 | if (mViewManager->currentView()->isEventView()) { |
4205 | int days = mViewManager->currentView()->currentDateCount(); | 4206 | int days = mViewManager->currentView()->currentDateCount(); |
4206 | if (days == 1) { | 4207 | if (days == 1) { |
4207 | emit changeNavStringPrev(i18n("&Previous Day")); | 4208 | emit changeNavStringPrev(i18n("&Previous Day")); |
4208 | emit changeNavStringNext(i18n("&Next Day")); | 4209 | emit changeNavStringNext(i18n("&Next Day")); |
4209 | } else { | 4210 | } else { |
4210 | emit changeNavStringPrev(i18n("&Previous Week")); | 4211 | emit changeNavStringPrev(i18n("&Previous Week")); |
4211 | emit changeNavStringNext(i18n("&Next Week")); | 4212 | emit changeNavStringNext(i18n("&Next Week")); |
4212 | } | 4213 | } |
4213 | } | 4214 | } |
4214 | } | 4215 | } |
4215 | 4216 | ||
4216 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4217 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4217 | { | 4218 | { |
4218 | if ( incidence ) mTodoList->clearSelection(); | 4219 | if ( incidence ) mTodoList->clearSelection(); |
4219 | processIncidenceSelection( incidence ); | 4220 | processIncidenceSelection( incidence ); |
4220 | } | 4221 | } |
4221 | 4222 | ||
4222 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4223 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4223 | { | 4224 | { |
4224 | if ( incidence && mViewManager->currentView() ) { | 4225 | if ( incidence && mViewManager->currentView() ) { |
4225 | mViewManager->currentView()->clearSelection(); | 4226 | mViewManager->currentView()->clearSelection(); |
4226 | } | 4227 | } |
4227 | processIncidenceSelection( incidence ); | 4228 | processIncidenceSelection( incidence ); |
4228 | } | 4229 | } |
4229 | 4230 | ||
4230 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4231 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4231 | { | 4232 | { |
4232 | emit incidenceSelected( incidence ); | 4233 | emit incidenceSelected( incidence ); |
4233 | if ( incidence == mSelectedIncidence ) return; | 4234 | if ( incidence == mSelectedIncidence ) return; |
4234 | mSelectedIncidence = incidence; | 4235 | mSelectedIncidence = incidence; |
4235 | 4236 | ||
4236 | if ( incidence && incidence->typeID() == eventID ) { | 4237 | if ( incidence && incidence->typeID() == eventID ) { |
4237 | Event *event = static_cast<Event *>( incidence ); | 4238 | Event *event = static_cast<Event *>( incidence ); |
4238 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4239 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4239 | emit organizerEventsSelected( true ); | 4240 | emit organizerEventsSelected( true ); |
4240 | } else { | 4241 | } else { |
4241 | emit organizerEventsSelected(false); | 4242 | emit organizerEventsSelected(false); |
4242 | } | 4243 | } |
4243 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4244 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4244 | KOPrefs::instance()->email() ) ) { | 4245 | KOPrefs::instance()->email() ) ) { |
4245 | emit groupEventsSelected( true ); | 4246 | emit groupEventsSelected( true ); |
4246 | } else { | 4247 | } else { |
4247 | emit groupEventsSelected(false); | 4248 | emit groupEventsSelected(false); |
4248 | } | 4249 | } |
4249 | return; | 4250 | return; |
4250 | } else { | 4251 | } else { |
4251 | if ( incidence && incidence->typeID() == todoID ) { | 4252 | if ( incidence && incidence->typeID() == todoID ) { |
4252 | emit todoSelected( true ); | 4253 | emit todoSelected( true ); |
4253 | Todo *event = static_cast<Todo *>( incidence ); | 4254 | Todo *event = static_cast<Todo *>( incidence ); |
4254 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4255 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4255 | emit organizerEventsSelected( true ); | 4256 | emit organizerEventsSelected( true ); |
4256 | } else { | 4257 | } else { |
4257 | emit organizerEventsSelected(false); | 4258 | emit organizerEventsSelected(false); |
4258 | } | 4259 | } |
4259 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4260 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4260 | KOPrefs::instance()->email() ) ) { | 4261 | KOPrefs::instance()->email() ) ) { |
4261 | emit groupEventsSelected( true ); | 4262 | emit groupEventsSelected( true ); |
4262 | } else { | 4263 | } else { |
4263 | emit groupEventsSelected(false); | 4264 | emit groupEventsSelected(false); |
4264 | } | 4265 | } |
4265 | return; | 4266 | return; |
4266 | } else { | 4267 | } else { |
4267 | emit todoSelected( false ); | 4268 | emit todoSelected( false ); |
4268 | emit organizerEventsSelected(false); | 4269 | emit organizerEventsSelected(false); |
4269 | emit groupEventsSelected(false); | 4270 | emit groupEventsSelected(false); |
4270 | } | 4271 | } |
4271 | return; | 4272 | return; |
4272 | } | 4273 | } |
4273 | 4274 | ||
4274 | /* if ( incidence && incidence->typeID() == todoID ) { | 4275 | /* if ( incidence && incidence->typeID() == todoID ) { |
4275 | emit todoSelected( true ); | 4276 | emit todoSelected( true ); |
4276 | } else { | 4277 | } else { |
4277 | emit todoSelected( false ); | 4278 | emit todoSelected( false ); |
4278 | }*/ | 4279 | }*/ |
4279 | } | 4280 | } |
4280 | 4281 | ||
4281 | 4282 | ||
4282 | void CalendarView::checkClipboard() | 4283 | void CalendarView::checkClipboard() |
4283 | { | 4284 | { |
4284 | #ifndef KORG_NODND | 4285 | #ifndef KORG_NODND |
4285 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4286 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4286 | emit pasteEnabled(true); | 4287 | emit pasteEnabled(true); |
4287 | } else { | 4288 | } else { |
4288 | emit pasteEnabled(false); | 4289 | emit pasteEnabled(false); |
4289 | } | 4290 | } |
4290 | #endif | 4291 | #endif |
4291 | } | 4292 | } |
4292 | 4293 | ||
4293 | void CalendarView::showDates(const DateList &selectedDates) | 4294 | void CalendarView::showDates(const DateList &selectedDates) |
4294 | { | 4295 | { |
4295 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4296 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4296 | 4297 | ||
4297 | 4298 | ||
4298 | if ( !mBlockShowDates ) { | 4299 | if ( !mBlockShowDates ) { |
4299 | if ( mViewManager->currentView() ) { | 4300 | if ( mViewManager->currentView() ) { |
4300 | updateView( selectedDates.first(), selectedDates.last() ); | 4301 | updateView( selectedDates.first(), selectedDates.last() ); |
4301 | } else { | 4302 | } else { |
4302 | mViewManager->showAgendaView(); | 4303 | mViewManager->showAgendaView(); |
4303 | } | 4304 | } |
4304 | } | 4305 | } |
4305 | 4306 | ||
4306 | QDate date = selectedDates.first(); | 4307 | QDate date = selectedDates.first(); |
4307 | if ( ! date.isValid() ) { | 4308 | if ( ! date.isValid() ) { |
4308 | topLevelWidget()->setCaption(""); | 4309 | topLevelWidget()->setCaption(""); |
4309 | return; | 4310 | return; |
4310 | } | 4311 | } |
4311 | 4312 | ||
4312 | QString selDates; | 4313 | QString selDates; |
4313 | selDates = KGlobal::locale()->formatDate( date, true); | 4314 | selDates = KGlobal::locale()->formatDate( date, true); |
4314 | if (selectedDates.first() < selectedDates.last() ) | 4315 | if (selectedDates.first() < selectedDates.last() ) |
4315 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4316 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4316 | else { | 4317 | else { |
4317 | QString addString; | 4318 | QString addString; |
4318 | if ( date == QDateTime::currentDateTime().date() ) | 4319 | if ( date == QDateTime::currentDateTime().date() ) |
4319 | addString = i18n("Today"); | 4320 | addString = i18n("Today"); |
4320 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4321 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4321 | addString = i18n("Tomorrow"); | 4322 | addString = i18n("Tomorrow"); |
4322 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4323 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4323 | addString = i18n("Yesterday"); | 4324 | addString = i18n("Yesterday"); |
4324 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4325 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4325 | addString = i18n("Day before yesterday"); | 4326 | addString = i18n("Day before yesterday"); |
4326 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4327 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4327 | addString = i18n("Day after tomorrow"); | 4328 | addString = i18n("Day after tomorrow"); |
4328 | if ( !addString.isEmpty() ) { | 4329 | if ( !addString.isEmpty() ) { |
4329 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4330 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4330 | return; | 4331 | return; |
4331 | } | 4332 | } |
4332 | } | 4333 | } |
4333 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4334 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4334 | 4335 | ||
4335 | } | 4336 | } |
4336 | 4337 | ||
4337 | QPtrList<CalFilter> CalendarView::filters() | 4338 | QPtrList<CalFilter> CalendarView::filters() |
4338 | { | 4339 | { |
4339 | return mFilters; | 4340 | return mFilters; |
4340 | 4341 | ||
4341 | } | 4342 | } |
4342 | void CalendarView::editFilters() | 4343 | void CalendarView::editFilters() |
4343 | { | 4344 | { |
4344 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4345 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4345 | 4346 | ||
4346 | CalFilter *filter = mFilters.first(); | 4347 | CalFilter *filter = mFilters.first(); |
4347 | while(filter) { | 4348 | while(filter) { |
4348 | filter = mFilters.next(); | 4349 | filter = mFilters.next(); |
4349 | } | 4350 | } |
4350 | 4351 | ||
4351 | mDialogManager->showFilterEditDialog(&mFilters); | 4352 | mDialogManager->showFilterEditDialog(&mFilters); |
4352 | updateFilter(); | 4353 | updateFilter(); |
4353 | } | 4354 | } |
4354 | void CalendarView::toggleFilter() | 4355 | void CalendarView::toggleFilter() |
4355 | { | 4356 | { |
4356 | if ( mLeftFrame->isHidden() ) { | 4357 | if ( mLeftFrame->isHidden() ) { |
4357 | toggleExpand(); | 4358 | toggleExpand(); |
4358 | showFilter( true ); | 4359 | showFilter( true ); |
4359 | } else | 4360 | } else |
4360 | showFilter(! mCalEditView->isVisible()); | 4361 | showFilter(! mCalEditView->isVisible()); |
4361 | } | 4362 | } |
4362 | 4363 | ||
4363 | KOFilterView *CalendarView::filterView() | 4364 | KOFilterView *CalendarView::filterView() |
4364 | { | 4365 | { |
4365 | return mFilterView; | 4366 | return mFilterView; |
4366 | } | 4367 | } |
4367 | void CalendarView::selectFilter( int fil ) | 4368 | void CalendarView::selectFilter( int fil ) |
4368 | { | 4369 | { |
4369 | mFilterView->setSelectedFilter( fil ); | 4370 | mFilterView->setSelectedFilter( fil ); |
4370 | updateUnmanagedViews(); | 4371 | updateUnmanagedViews(); |
4371 | } | 4372 | } |
4372 | void CalendarView::showFilter(bool visible) | 4373 | void CalendarView::showFilter(bool visible) |
4373 | { | 4374 | { |
4374 | #if 1 | 4375 | #if 1 |
4375 | if (visible) { | 4376 | if (visible) { |
4376 | mCalEditView->readConfig(); | 4377 | mCalEditView->readConfig(); |
4377 | mCalEditView->show(); | 4378 | mCalEditView->show(); |
4378 | QValueList<int> sizes; | 4379 | QValueList<int> sizes; |
4379 | sizes = mLeftFrame->sizes(); | 4380 | sizes = mLeftFrame->sizes(); |
4380 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4381 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4381 | sizes.clear(); | 4382 | sizes.clear(); |
4382 | sizes << 100; | 4383 | sizes << 100; |
4383 | sizes << 0; | 4384 | sizes << 0; |
4384 | sizes << 0; | 4385 | sizes << 0; |
4385 | sizes << 100; | 4386 | sizes << 100; |
4386 | mLeftFrame->setSizes(sizes); | 4387 | mLeftFrame->setSizes(sizes); |
4387 | } | 4388 | } |
4388 | #if 0 | 4389 | #if 0 |
4389 | sizes = mLeftFrame->sizes(); | 4390 | sizes = mLeftFrame->sizes(); |
4390 | int ccc = 0; | 4391 | int ccc = 0; |
4391 | while ( ccc < sizes.count()) { | 4392 | while ( ccc < sizes.count()) { |
4392 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4393 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4393 | ++ccc; | 4394 | ++ccc; |
4394 | } | 4395 | } |
4395 | #endif | 4396 | #endif |
4396 | 4397 | ||
4397 | } | 4398 | } |
4398 | else { | 4399 | else { |
4399 | mCalEditView->hide(); | 4400 | mCalEditView->hide(); |
4400 | } | 4401 | } |
4401 | #else | 4402 | #else |
4402 | if (visible) mFilterView->show(); | 4403 | if (visible) mFilterView->show(); |
4403 | else mFilterView->hide(); | 4404 | else mFilterView->hide(); |
4404 | #endif | 4405 | #endif |
4405 | } | 4406 | } |
4406 | void CalendarView::toggleFilerEnabled( ) | 4407 | void CalendarView::toggleFilerEnabled( ) |
4407 | { | 4408 | { |
4408 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4409 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4409 | if ( !mFilterView->filtersEnabled() ) | 4410 | if ( !mFilterView->filtersEnabled() ) |
4410 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4411 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4411 | updateUnmanagedViews(); | 4412 | updateUnmanagedViews(); |
4412 | 4413 | ||
4413 | } | 4414 | } |
4414 | void CalendarView::updateFilter() | 4415 | void CalendarView::updateFilter() |
4415 | { | 4416 | { |
4416 | CalFilter *filter = mFilterView->selectedFilter(); | 4417 | CalFilter *filter = mFilterView->selectedFilter(); |
4417 | if (filter) { | 4418 | if (filter) { |
4418 | QString mess; | 4419 | QString mess; |
4419 | if (mFilterView->filtersEnabled()) { | 4420 | if (mFilterView->filtersEnabled()) { |
4420 | mess = i18n("Filter selected: ")+filter->name(); | 4421 | mess = i18n("Filter selected: ")+filter->name(); |
4421 | filter->setEnabled(true); | 4422 | filter->setEnabled(true); |
4422 | } | 4423 | } |
4423 | else filter->setEnabled(false); | 4424 | else filter->setEnabled(false); |
4424 | mCalendar->setFilter(filter); | 4425 | mCalendar->setFilter(filter); |
4425 | updateView(); | 4426 | updateView(); |
4426 | if ( !mess.isEmpty() ) | 4427 | if ( !mess.isEmpty() ) |
4427 | topLevelWidget()->setCaption( mess ); | 4428 | topLevelWidget()->setCaption( mess ); |
4428 | 4429 | ||
4429 | } | 4430 | } |
4430 | emit filtersUpdated(); | 4431 | emit filtersUpdated(); |
4431 | } | 4432 | } |
4432 | 4433 | ||
4433 | void CalendarView::filterEdited() | 4434 | void CalendarView::filterEdited() |
4434 | { | 4435 | { |
4435 | mFilterView->updateFilters(); | 4436 | mFilterView->updateFilters(); |
4436 | updateFilter(); | 4437 | updateFilter(); |
4437 | writeSettings(); | 4438 | writeSettings(); |
4438 | } | 4439 | } |
4439 | 4440 | ||
4440 | 4441 | ||
4441 | void CalendarView::takeOverEvent() | 4442 | void CalendarView::takeOverEvent() |
4442 | { | 4443 | { |
4443 | Incidence *incidence = currentSelection(); | 4444 | Incidence *incidence = currentSelection(); |
4444 | 4445 | ||
4445 | if (!incidence) return; | 4446 | if (!incidence) return; |
4446 | 4447 | ||
4447 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4448 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4448 | incidence->recreate(); | 4449 | incidence->recreate(); |
4449 | incidence->setReadOnly(false); | 4450 | incidence->setReadOnly(false); |
4450 | 4451 | ||
4451 | updateView(); | 4452 | updateView(); |
4452 | } | 4453 | } |
4453 | 4454 | ||
4454 | void CalendarView::takeOverCalendar() | 4455 | void CalendarView::takeOverCalendar() |
4455 | { | 4456 | { |
4456 | // TODO: Create Calendar::allIncidences() function and use it here | 4457 | // TODO: Create Calendar::allIncidences() function and use it here |
4457 | 4458 | ||
4458 | clearAllViews(); | 4459 | clearAllViews(); |
4459 | QPtrList<Event> events = mCalendar->events(); | 4460 | QPtrList<Event> events = mCalendar->events(); |
4460 | for(uint i=0; i<events.count(); ++i) { | 4461 | for(uint i=0; i<events.count(); ++i) { |
4461 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4462 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4462 | events.at(i)->recreate(); | 4463 | events.at(i)->recreate(); |
4463 | events.at(i)->setReadOnly(false); | 4464 | events.at(i)->setReadOnly(false); |
4464 | } | 4465 | } |
4465 | 4466 | ||
4466 | QPtrList<Todo> todos = mCalendar->todos(); | 4467 | QPtrList<Todo> todos = mCalendar->todos(); |
4467 | for(uint i=0; i<todos.count(); ++i) { | 4468 | for(uint i=0; i<todos.count(); ++i) { |
4468 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4469 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4469 | todos.at(i)->recreate(); | 4470 | todos.at(i)->recreate(); |
4470 | todos.at(i)->setReadOnly(false); | 4471 | todos.at(i)->setReadOnly(false); |
4471 | } | 4472 | } |
4472 | 4473 | ||
4473 | QPtrList<Journal> journals = mCalendar->journals(); | 4474 | QPtrList<Journal> journals = mCalendar->journals(); |
4474 | for(uint i=0; i<journals.count(); ++i) { | 4475 | for(uint i=0; i<journals.count(); ++i) { |
4475 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4476 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4476 | journals.at(i)->recreate(); | 4477 | journals.at(i)->recreate(); |
4477 | journals.at(i)->setReadOnly(false); | 4478 | journals.at(i)->setReadOnly(false); |
4478 | } | 4479 | } |
4479 | 4480 | ||
4480 | updateView(); | 4481 | updateView(); |
4481 | } | 4482 | } |
4482 | 4483 | ||
4483 | void CalendarView::showIntro() | 4484 | void CalendarView::showIntro() |
4484 | { | 4485 | { |
4485 | kdDebug() << "To be implemented." << endl; | 4486 | kdDebug() << "To be implemented." << endl; |
4486 | } | 4487 | } |
4487 | 4488 | ||
4488 | QWidgetStack *CalendarView::viewStack() | 4489 | QWidgetStack *CalendarView::viewStack() |
4489 | { | 4490 | { |
4490 | return mRightFrame; | 4491 | return mRightFrame; |
4491 | } | 4492 | } |
4492 | 4493 | ||
4493 | QWidget *CalendarView::leftFrame() | 4494 | QWidget *CalendarView::leftFrame() |
4494 | { | 4495 | { |
4495 | return ( QWidget *)mLeftFrame; | 4496 | return ( QWidget *)mLeftFrame; |
4496 | } | 4497 | } |
4497 | 4498 | ||
4498 | DateNavigator *CalendarView::dateNavigator() | 4499 | DateNavigator *CalendarView::dateNavigator() |
4499 | { | 4500 | { |
4500 | return mNavigator; | 4501 | return mNavigator; |
4501 | } | 4502 | } |
4502 | 4503 | ||
4503 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4504 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4504 | { | 4505 | { |
4505 | return mDateNavigator->navigatorView(); | 4506 | return mDateNavigator->navigatorView(); |
4506 | } | 4507 | } |
4507 | void CalendarView::toggleDateNavigatorWidget() | 4508 | void CalendarView::toggleDateNavigatorWidget() |
4508 | { | 4509 | { |
4509 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4510 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4510 | 4511 | ||
4511 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4512 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4512 | mDateNavigator->hide(); | 4513 | mDateNavigator->hide(); |
4513 | else | 4514 | else |
4514 | mDateNavigator->show(); | 4515 | mDateNavigator->show(); |
4515 | } | 4516 | } |
4516 | void CalendarView::addView(KOrg::BaseView *view) | 4517 | void CalendarView::addView(KOrg::BaseView *view) |
4517 | { | 4518 | { |
4518 | mViewManager->addView(view); | 4519 | mViewManager->addView(view); |
4519 | } | 4520 | } |
4520 | 4521 | ||
4521 | void CalendarView::showView(KOrg::BaseView *view) | 4522 | void CalendarView::showView(KOrg::BaseView *view) |
4522 | { | 4523 | { |
4523 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4524 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4524 | } | 4525 | } |
4525 | 4526 | ||
4526 | Incidence *CalendarView::currentSelection() | 4527 | Incidence *CalendarView::currentSelection() |
4527 | { | 4528 | { |
4528 | return mViewManager->currentSelection(); | 4529 | return mViewManager->currentSelection(); |
4529 | } | 4530 | } |
4530 | void CalendarView::toggleAllDaySize() | 4531 | void CalendarView::toggleAllDaySize() |
4531 | { | 4532 | { |
4532 | /* | 4533 | /* |
4533 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4534 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4534 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4535 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4535 | else | 4536 | else |
4536 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4537 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4537 | */ | 4538 | */ |
4538 | viewManager()->agendaView()->toggleAllDay(); | 4539 | viewManager()->agendaView()->toggleAllDay(); |
4539 | } | 4540 | } |
4540 | void CalendarView::toggleExpand() | 4541 | void CalendarView::toggleExpand() |
4541 | { | 4542 | { |
4542 | // if ( mLeftFrame->isHidden() ) { | 4543 | // if ( mLeftFrame->isHidden() ) { |
4543 | // mLeftFrame->show(); | 4544 | // mLeftFrame->show(); |
4544 | // emit calendarViewExpanded( false ); | 4545 | // emit calendarViewExpanded( false ); |
4545 | // } else { | 4546 | // } else { |
4546 | // mLeftFrame->hide(); | 4547 | // mLeftFrame->hide(); |
4547 | // emit calendarViewExpanded( true ); | 4548 | // emit calendarViewExpanded( true ); |
4548 | // } | 4549 | // } |
4549 | //qDebug(" CalendarView::toggleExpand()"); | 4550 | //qDebug(" CalendarView::toggleExpand()"); |
4550 | globalFlagBlockAgenda = 1; | 4551 | globalFlagBlockAgenda = 1; |
4551 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4552 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4552 | globalFlagBlockAgenda = 5; | 4553 | globalFlagBlockAgenda = 5; |
4553 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4554 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4554 | //mViewManager->showView( 0, true ); | 4555 | //mViewManager->showView( 0, true ); |
4555 | } | 4556 | } |
4556 | 4557 | ||
4557 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4558 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4558 | { | 4559 | { |
4559 | setModified( modified ); | 4560 | setModified( modified ); |
4560 | } | 4561 | } |
4561 | 4562 | ||
4562 | Todo *CalendarView::selectedTodo() | 4563 | Todo *CalendarView::selectedTodo() |
4563 | { | 4564 | { |
4564 | Incidence *incidence = currentSelection(); | 4565 | Incidence *incidence = currentSelection(); |
4565 | if ( incidence && incidence->typeID() == todoID ) { | 4566 | if ( incidence && incidence->typeID() == todoID ) { |
4566 | return static_cast<Todo *>( incidence ); | 4567 | return static_cast<Todo *>( incidence ); |
4567 | } | 4568 | } |
4568 | 4569 | ||
4569 | incidence = mTodoList->selectedIncidences().first(); | 4570 | incidence = mTodoList->selectedIncidences().first(); |
4570 | if ( incidence && incidence->typeID() == todoID ) { | 4571 | if ( incidence && incidence->typeID() == todoID ) { |
4571 | return static_cast<Todo *>( incidence ); | 4572 | return static_cast<Todo *>( incidence ); |
4572 | } | 4573 | } |
4573 | 4574 | ||
4574 | return 0; | 4575 | return 0; |
4575 | } | 4576 | } |
4576 | 4577 | ||
4577 | void CalendarView::showIncidence() | 4578 | void CalendarView::showIncidence() |
4578 | { | 4579 | { |
4579 | mViewerCallerIsSearchDialog = false; | 4580 | mViewerCallerIsSearchDialog = false; |
4580 | Incidence *incidence = currentSelection(); | 4581 | Incidence *incidence = currentSelection(); |
4581 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4582 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4582 | if ( incidence ) { | 4583 | if ( incidence ) { |
4583 | ShowIncidenceVisitor v; | 4584 | ShowIncidenceVisitor v; |
4584 | v.act( incidence, this ); | 4585 | v.act( incidence, this ); |
4585 | } | 4586 | } |
4586 | } | 4587 | } |
4587 | void CalendarView::editIncidenceDescription() | 4588 | void CalendarView::editIncidenceDescription() |
4588 | { | 4589 | { |
4589 | mFlagEditDescription = true; | 4590 | mFlagEditDescription = true; |
4590 | editIncidence(); | 4591 | editIncidence(); |
4591 | mFlagEditDescription = false; | 4592 | mFlagEditDescription = false; |
4592 | } | 4593 | } |
4593 | void CalendarView::editIncidence() | 4594 | void CalendarView::editIncidence() |
4594 | { | 4595 | { |
4595 | // qDebug("editIncidence() "); | 4596 | // qDebug("editIncidence() "); |
4596 | Incidence *incidence = currentSelection(); | 4597 | Incidence *incidence = currentSelection(); |
4597 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4598 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4598 | if ( incidence ) { | 4599 | if ( incidence ) { |
4599 | EditIncidenceVisitor v; | 4600 | EditIncidenceVisitor v; |
4600 | v.act( incidence, this ); | 4601 | v.act( incidence, this ); |
4601 | } | 4602 | } |
4602 | } | 4603 | } |
4603 | 4604 | ||
4604 | void CalendarView::deleteIncidence() | 4605 | void CalendarView::deleteIncidence() |
4605 | { | 4606 | { |
4606 | Incidence *incidence = currentSelection(); | 4607 | Incidence *incidence = currentSelection(); |
4607 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4608 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4608 | if ( incidence ) { | 4609 | if ( incidence ) { |
4609 | deleteIncidence(incidence); | 4610 | deleteIncidence(incidence); |
4610 | } | 4611 | } |
4611 | } | 4612 | } |
4612 | void CalendarView::showIncidence(QString uid) | 4613 | void CalendarView::showIncidence(QString uid) |
4613 | { | 4614 | { |
4614 | Incidence *inc = mCalendar->incidence( uid ); | 4615 | Incidence *inc = mCalendar->incidence( uid ); |
4615 | if ( inc ) | 4616 | if ( inc ) |
4616 | showIncidence( inc ); | 4617 | showIncidence( inc ); |
4617 | } | 4618 | } |
4618 | void CalendarView::showIncidence(Incidence *incidence) | 4619 | void CalendarView::showIncidence(Incidence *incidence) |
4619 | { | 4620 | { |
4620 | mViewerCallerIsSearchDialog = false; | 4621 | mViewerCallerIsSearchDialog = false; |
4621 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4622 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4622 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4623 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4623 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4624 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4624 | mViewerCallerIsSearchDialog = true; | 4625 | mViewerCallerIsSearchDialog = true; |
4625 | } | 4626 | } |
4626 | } | 4627 | } |
4627 | if ( incidence ) { | 4628 | if ( incidence ) { |
4628 | ShowIncidenceVisitor v; | 4629 | ShowIncidenceVisitor v; |
4629 | v.act( incidence, this ); | 4630 | v.act( incidence, this ); |
4630 | } | 4631 | } |
4631 | } | 4632 | } |
4632 | 4633 | ||
4633 | void CalendarView::editIncidence(Incidence *incidence) | 4634 | void CalendarView::editIncidence(Incidence *incidence) |
4634 | { | 4635 | { |
4635 | if ( incidence ) { | 4636 | if ( incidence ) { |
4636 | 4637 | ||
4637 | EditIncidenceVisitor v; | 4638 | EditIncidenceVisitor v; |
4638 | v.act( incidence, this ); | 4639 | v.act( incidence, this ); |
4639 | 4640 | ||
4640 | } | 4641 | } |
4641 | } | 4642 | } |
4642 | 4643 | ||
4643 | void CalendarView::deleteIncidence(Incidence *incidence) | 4644 | void CalendarView::deleteIncidence(Incidence *incidence) |
4644 | { | 4645 | { |
4645 | //qDebug(" CalendarView::deleteIncidence "); | 4646 | //qDebug(" CalendarView::deleteIncidence "); |
4646 | if ( incidence == 0 ) { | 4647 | if ( incidence == 0 ) { |
4647 | updateView(); | 4648 | updateView(); |
4648 | emit updateSearchDialog(); | 4649 | emit updateSearchDialog(); |
4649 | return; | 4650 | return; |
4650 | } | 4651 | } |
4651 | if ( incidence ) { | 4652 | if ( incidence ) { |
4652 | DeleteIncidenceVisitor v; | 4653 | DeleteIncidenceVisitor v; |
4653 | v.act( incidence, this ); | 4654 | v.act( incidence, this ); |
4654 | } | 4655 | } |
4655 | } | 4656 | } |
4656 | 4657 | ||
4657 | 4658 | ||
4658 | void CalendarView::lookForOutgoingMessages() | 4659 | void CalendarView::lookForOutgoingMessages() |
4659 | { | 4660 | { |
4660 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4661 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4661 | ogd->loadMessages(); | 4662 | ogd->loadMessages(); |
4662 | } | 4663 | } |
4663 | 4664 | ||
4664 | void CalendarView::lookForIncomingMessages() | 4665 | void CalendarView::lookForIncomingMessages() |
4665 | { | 4666 | { |
4666 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4667 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4667 | icd->retrieve(); | 4668 | icd->retrieve(); |
4668 | } | 4669 | } |
4669 | 4670 | ||
4670 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4671 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4671 | { | 4672 | { |
4672 | bool deleteTodo = true; | 4673 | bool deleteTodo = true; |
4673 | QPtrList<Incidence> subTodos; | 4674 | QPtrList<Incidence> subTodos; |
4674 | Incidence *aTodo; | 4675 | Incidence *aTodo; |
4675 | subTodos = t->relations(); | 4676 | subTodos = t->relations(); |
4676 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4677 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4677 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4678 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4678 | deleteTodo = false; | 4679 | deleteTodo = false; |
4679 | } | 4680 | } |
4680 | if ( deleteTodo ) { | 4681 | if ( deleteTodo ) { |
4681 | if ( t->isCompleted() && !t->doesRecur()) { | 4682 | if ( t->isCompleted() && !t->doesRecur()) { |
4682 | checkExternalId( t ); | 4683 | checkExternalId( t ); |
4683 | mCalendar->deleteTodo( t ); | 4684 | mCalendar->deleteTodo( t ); |
4684 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4685 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4685 | } | 4686 | } |
4686 | else | 4687 | else |
4687 | deleteTodo = false; | 4688 | deleteTodo = false; |
4688 | } | 4689 | } |
4689 | return deleteTodo; | 4690 | return deleteTodo; |
4690 | 4691 | ||
4691 | } | 4692 | } |
4692 | void CalendarView::purgeCompleted() | 4693 | void CalendarView::purgeCompleted() |
4693 | { | 4694 | { |
4694 | int result = KMessageBox::warningContinueCancel(this, | 4695 | int result = KMessageBox::warningContinueCancel(this, |
4695 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4696 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4696 | 4697 | ||
4697 | if (result == KMessageBox::Continue) { | 4698 | if (result == KMessageBox::Continue) { |
4698 | 4699 | ||
4699 | QPtrList<Todo> todoCal; | 4700 | QPtrList<Todo> todoCal; |
4700 | QPtrList<Todo> rootTodos; | 4701 | QPtrList<Todo> rootTodos; |
4701 | //QPtrList<Incidence> rel; | 4702 | //QPtrList<Incidence> rel; |
4702 | Todo *aTodo; | 4703 | Todo *aTodo; |
4703 | todoCal = calendar()->todos(); | 4704 | todoCal = calendar()->todos(); |
4704 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4705 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4705 | if ( !aTodo->relatedTo() ) | 4706 | if ( !aTodo->relatedTo() ) |
4706 | rootTodos.append( aTodo ); | 4707 | rootTodos.append( aTodo ); |
4707 | } | 4708 | } |
4708 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4709 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4709 | removeCompletedSubTodos( aTodo ); | 4710 | removeCompletedSubTodos( aTodo ); |
4710 | } | 4711 | } |
4711 | 4712 | ||
4712 | updateView(); | 4713 | updateView(); |
4713 | } | 4714 | } |
4714 | } | 4715 | } |
4715 | 4716 | ||
4716 | void CalendarView::slotCalendarChanged() | 4717 | void CalendarView::slotCalendarChanged() |
4717 | { | 4718 | { |
4718 | ; | 4719 | ; |
4719 | } | 4720 | } |
4720 | 4721 | ||
4721 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4722 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4722 | { | 4723 | { |
4723 | //qDebug("CalendarView::keyPressEvent "); | 4724 | //qDebug("CalendarView::keyPressEvent "); |
4724 | e->ignore(); | 4725 | e->ignore(); |
4725 | } | 4726 | } |
4726 | 4727 | ||
4727 | 4728 | ||
4728 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4729 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4729 | { | 4730 | { |
4730 | 4731 | ||
4731 | if ( manager != mSyncManager) | 4732 | if ( manager != mSyncManager) |
4732 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 4733 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
4733 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4734 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4734 | qDebug("KO: SyncKDE request detected!"); | 4735 | qDebug("KO: SyncKDE request detected!"); |
4735 | } | 4736 | } |
4736 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4737 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4737 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4738 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4738 | return syncCalendar( filename, mode ); | 4739 | return syncCalendar( filename, mode ); |
4739 | } | 4740 | } |
4740 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4741 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4741 | { | 4742 | { |
4742 | //mSyncManager = manager; | 4743 | //mSyncManager = manager; |
4743 | if ( manager != mSyncManager) | 4744 | if ( manager != mSyncManager) |
4744 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 4745 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
4745 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4746 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4746 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4747 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4747 | if ( resource == "sharp" ) | 4748 | if ( resource == "sharp" ) |
4748 | syncExternal( 0 ); | 4749 | syncExternal( 0 ); |
4749 | if ( resource == "phone" ) | 4750 | if ( resource == "phone" ) |
4750 | syncExternal( 1 ); | 4751 | syncExternal( 1 ); |
4751 | // pending setmodified | 4752 | // pending setmodified |
4752 | return true; | 4753 | return true; |
4753 | } | 4754 | } |
4754 | void CalendarView::setSyncManager(KSyncManager* manager) | 4755 | void CalendarView::setSyncManager(KSyncManager* manager) |
4755 | { | 4756 | { |
4756 | mSyncManager = manager; | 4757 | mSyncManager = manager; |
4757 | } | 4758 | } |
4758 | 4759 | ||
4759 | void CalendarView::removeSyncInfo( QString syncProfile) | 4760 | void CalendarView::removeSyncInfo( QString syncProfile) |
4760 | { | 4761 | { |
4761 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4762 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4762 | mCalendar->removeSyncInfo( syncProfile ); | 4763 | mCalendar->removeSyncInfo( syncProfile ); |
4763 | 4764 | ||
4764 | } | 4765 | } |
4765 | 4766 | ||
4766 | void CalendarView::undo_delete() | 4767 | void CalendarView::undo_delete() |
4767 | { | 4768 | { |
4768 | //qDebug("undo_delete() "); | 4769 | //qDebug("undo_delete() "); |
4769 | Incidence* undo = mCalendar->undoIncidence(); | 4770 | Incidence* undo = mCalendar->undoIncidence(); |
4770 | if ( !undo ) { | 4771 | if ( !undo ) { |
4771 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4772 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4772 | i18n("KO/Pi")); | 4773 | i18n("KO/Pi")); |
4773 | return; | 4774 | return; |
4774 | } | 4775 | } |
4775 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 4776 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
4776 | i18n("\nAre you sure you want\nto restore this?"), | 4777 | i18n("\nAre you sure you want\nto restore this?"), |
4777 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4778 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4778 | mCalendar->undoDeleteIncidence(); | 4779 | mCalendar->undoDeleteIncidence(); |
4779 | updateView(); | 4780 | updateView(); |
4780 | } | 4781 | } |
4781 | } | 4782 | } |
4782 | 4783 | ||
4783 | void CalendarView::slotViewerClosed() | 4784 | void CalendarView::slotViewerClosed() |
4784 | { | 4785 | { |
4785 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4786 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4786 | } | 4787 | } |
4787 | 4788 | ||
4788 | void CalendarView::resetFocus() | 4789 | void CalendarView::resetFocus() |
4789 | { | 4790 | { |
4790 | if ( mViewerCallerIsSearchDialog ) { | 4791 | if ( mViewerCallerIsSearchDialog ) { |
4791 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4792 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4792 | mDialogManager->getSearchDialog()->raise(); | 4793 | mDialogManager->getSearchDialog()->raise(); |
4793 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4794 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4794 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4795 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4795 | } else | 4796 | } else |
4796 | mViewerCallerIsSearchDialog = false; | 4797 | mViewerCallerIsSearchDialog = false; |
4797 | } | 4798 | } |
4798 | if ( !mViewerCallerIsSearchDialog ) { | 4799 | if ( !mViewerCallerIsSearchDialog ) { |
4799 | //mViewManager->currentView()->setFocus(); | 4800 | //mViewManager->currentView()->setFocus(); |
4800 | //qDebug("sssssssssssssssset focus "); | 4801 | //qDebug("sssssssssssssssset focus "); |
4801 | topLevelWidget()->raise(); | 4802 | topLevelWidget()->raise(); |
4802 | setActiveWindow(); | 4803 | setActiveWindow(); |
4803 | //setFocus(); | 4804 | //setFocus(); |
4804 | } | 4805 | } |
4805 | mViewerCallerIsSearchDialog = false; | 4806 | mViewerCallerIsSearchDialog = false; |
4806 | } | 4807 | } |
4807 | 4808 | ||
4808 | void CalendarView::showNextAlarms() | 4809 | void CalendarView::showNextAlarms() |
4809 | { | 4810 | { |
4810 | QString message; | 4811 | QString message; |
4811 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4812 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4812 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4813 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4813 | QString sum = mCalendar->nextSummary(); | 4814 | QString sum = mCalendar->nextSummary(); |
4814 | QDateTime nextA = mNextAlarmDateTime; | 4815 | QDateTime nextA = mNextAlarmDateTime; |
4815 | QDateTime cur = QDateTime::currentDateTime(); | 4816 | QDateTime cur = QDateTime::currentDateTime(); |
4816 | int secs = cur.secsTo( nextA ); | 4817 | int secs = cur.secsTo( nextA ); |
4817 | int min = secs /60; | 4818 | int min = secs /60; |
4818 | int hours = min /60; | 4819 | int hours = min /60; |
4819 | min = min % 60; | 4820 | min = min % 60; |
4820 | int days = hours /24; | 4821 | int days = hours /24; |
4821 | hours = hours % 24; | 4822 | hours = hours % 24; |
4822 | 4823 | ||
4823 | //message = i18n("The next alarm is in:\n"); | 4824 | //message = i18n("The next alarm is in:\n"); |
4824 | if ( days > 1 ) | 4825 | if ( days > 1 ) |
4825 | message += i18n("%1 days\n").arg( days ); | 4826 | message += i18n("%1 days\n").arg( days ); |
4826 | else if ( days == 1 ) | 4827 | else if ( days == 1 ) |
4827 | message += i18n("1 day\n"); | 4828 | message += i18n("1 day\n"); |
4828 | if ( hours > 1 ) | 4829 | if ( hours > 1 ) |
4829 | message += i18n("%1 hours\n").arg( hours ); | 4830 | message += i18n("%1 hours\n").arg( hours ); |
4830 | else if ( hours == 1 ) | 4831 | else if ( hours == 1 ) |
4831 | message += i18n("1 hour\n"); | 4832 | message += i18n("1 hour\n"); |
4832 | if ( min > 1 ) | 4833 | if ( min > 1 ) |
4833 | message += i18n("%1 minutes\n").arg( min ); | 4834 | message += i18n("%1 minutes\n").arg( min ); |
4834 | else if ( min == 1 ) | 4835 | else if ( min == 1 ) |
4835 | message += i18n("1 minute\n"); | 4836 | message += i18n("1 minute\n"); |
4836 | if ( message.isEmpty() ) | 4837 | if ( message.isEmpty() ) |
4837 | message = i18n("The next alarm is in\nless than one minute!"); | 4838 | message = i18n("The next alarm is in\nless than one minute!"); |
4838 | else | 4839 | else |
4839 | message = i18n("The next alarm is in:\n") + message; | 4840 | message = i18n("The next alarm is in:\n") + message; |
4840 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4841 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4841 | } else { | 4842 | } else { |
4842 | message = i18n("There is no next alarm."); | 4843 | message = i18n("There is no next alarm."); |
4843 | 4844 | ||
4844 | } | 4845 | } |
4845 | #ifdef DESKTOP_VERSION | 4846 | #ifdef DESKTOP_VERSION |
4846 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4847 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4847 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4848 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4848 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4849 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4849 | } | 4850 | } |
4850 | 4851 | ||
4851 | #endif | 4852 | #endif |
4852 | KMessageBox::information( this, message); | 4853 | KMessageBox::information( this, message); |
4853 | } | 4854 | } |
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index 7ce3f1f..6a6fff9 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp | |||
@@ -1,486 +1,490 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qdialog.h> | 29 | #include <qdialog.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | 32 | ||
33 | 33 | ||
34 | #include <libkcal/calfilter.h> | 34 | #include <libkcal/calfilter.h> |
35 | 35 | ||
36 | #include "kofilterview.h" | 36 | #include "kofilterview.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #include <kiconloader.h> | 38 | #include <kiconloader.h> |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | #include <kglobalsettings.h> | 40 | #include <kglobalsettings.h> |
41 | #include <kcolorbutton.h> | 41 | #include <kcolorbutton.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | 43 | ||
44 | 44 | ||
45 | 45 | ||
46 | 46 | ||
47 | 47 | ||
48 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, | 48 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, |
49 | const char* name,WFlags fl ) | 49 | const char* name,WFlags fl ) |
50 | : KOFilterView_base(parent,name,fl) | 50 | : KOFilterView_base(parent,name,fl) |
51 | { | 51 | { |
52 | mFilters = filterList; | 52 | mFilters = filterList; |
53 | 53 | ||
54 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); | 54 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); |
55 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); | 55 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); |
56 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); | 56 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); |
57 | } | 57 | } |
58 | 58 | ||
59 | KOFilterView::~KOFilterView() | 59 | KOFilterView::~KOFilterView() |
60 | { | 60 | { |
61 | // no need to delete child widgets, Qt does it all for us | 61 | // no need to delete child widgets, Qt does it all for us |
62 | } | 62 | } |
63 | 63 | ||
64 | bool KOFilterView::filtersEnabled() | 64 | bool KOFilterView::filtersEnabled() |
65 | { | 65 | { |
66 | return mEnabledCheck->isChecked(); | 66 | return mEnabledCheck->isChecked(); |
67 | } | 67 | } |
68 | 68 | ||
69 | void KOFilterView::setFiltersEnabled(bool set) | 69 | void KOFilterView::setFiltersEnabled(bool set) |
70 | { | 70 | { |
71 | mEnabledCheck->setChecked(set); | 71 | mEnabledCheck->setChecked(set); |
72 | emit filterChanged(); | 72 | emit filterChanged(); |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | void KOFilterView::updateFilters() | 76 | void KOFilterView::updateFilters() |
77 | { | 77 | { |
78 | mSelectionCombo->clear(); | 78 | mSelectionCombo->clear(); |
79 | 79 | ||
80 | CalFilter *filter = mFilters->first(); | 80 | CalFilter *filter = mFilters->first(); |
81 | while(filter) { | 81 | while(filter) { |
82 | mSelectionCombo->insertItem(filter->name()); | 82 | mSelectionCombo->insertItem(filter->name()); |
83 | filter = mFilters->next(); | 83 | filter = mFilters->next(); |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | CalFilter *KOFilterView::selectedFilter() | 87 | CalFilter *KOFilterView::selectedFilter() |
88 | { | 88 | { |
89 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); | 89 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); |
90 | return f; | 90 | return f; |
91 | } | 91 | } |
92 | 92 | ||
93 | void KOFilterView::setSelectedFilter(QString filterName) | 93 | void KOFilterView::setSelectedFilter(QString filterName) |
94 | { | 94 | { |
95 | int filter_num = mSelectionCombo->count(); | 95 | int filter_num = mSelectionCombo->count(); |
96 | int i; | 96 | int i; |
97 | for (i=0;i<filter_num;i++) { | 97 | for (i=0;i<filter_num;i++) { |
98 | if (mSelectionCombo->text(i)==filterName) | 98 | if (mSelectionCombo->text(i)==filterName) |
99 | mSelectionCombo->setCurrentItem(i); | 99 | mSelectionCombo->setCurrentItem(i); |
100 | } | 100 | } |
101 | emit filterChanged(); | 101 | emit filterChanged(); |
102 | } | 102 | } |
103 | void KOFilterView::setSelectedFilter( int fil ) | 103 | void KOFilterView::setSelectedFilter( int fil ) |
104 | { | 104 | { |
105 | if ( fil >= mSelectionCombo->count() ) | 105 | if ( fil >= mSelectionCombo->count() ) |
106 | return; | 106 | return; |
107 | mSelectionCombo->setCurrentItem( fil ); | 107 | mSelectionCombo->setCurrentItem( fil ); |
108 | emit filterChanged(); | 108 | emit filterChanged(); |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | KOCalEditView::KOCalEditView(QWidget* parent, | 113 | KOCalEditView::KOCalEditView(QWidget* parent, |
114 | const char* name ) | 114 | const char* name ) |
115 | : QScrollView(parent,name) | 115 | : QScrollView(parent,name) |
116 | { | 116 | { |
117 | mw = 0; | 117 | mw = 0; |
118 | setResizePolicy( AutoOneFit ); | 118 | setResizePolicy( AutoOneFit ); |
119 | setFrameStyle ( QFrame::Panel | QFrame::Plain ); | 119 | setFrameStyle ( QFrame::Panel | QFrame::Plain ); |
120 | setLineWidth ( 1 ); | 120 | setLineWidth ( 1 ); |
121 | setMidLineWidth ( 1 ); | 121 | setMidLineWidth ( 1 ); |
122 | setFocusPolicy(NoFocus); | 122 | setFocusPolicy(NoFocus); |
123 | } | 123 | } |
124 | 124 | ||
125 | KOCalEditView::~KOCalEditView() | 125 | KOCalEditView::~KOCalEditView() |
126 | { | 126 | { |
127 | // no need to delete child widgets, Qt does it all for us | 127 | // no need to delete child widgets, Qt does it all for us |
128 | } | 128 | } |
129 | void KOCalEditView::selectCal(int id ,bool b) | 129 | void KOCalEditView::selectCal(int id ,bool b) |
130 | { | 130 | { |
131 | KOPrefs::instance()->getCalendar( id )->isEnabled = b; | 131 | KOPrefs::instance()->getCalendar( id )->isEnabled = b; |
132 | emit calendarEnabled ( id, b ); | 132 | emit calendarEnabled ( id, b ); |
133 | emit needsUpdate(); | 133 | emit needsUpdate(); |
134 | 134 | ||
135 | } | 135 | } |
136 | void KOCalEditView::selectStdCal( int id ) | 136 | void KOCalEditView::selectStdCal( int id ) |
137 | { | 137 | { |
138 | KOCalRadioButton* it = mStdandardB.first(); | 138 | KOCalRadioButton* it = mStdandardB.first(); |
139 | while ( it ) { | 139 | while ( it ) { |
140 | it->blockSignals( true ); | 140 | it->blockSignals( true ); |
141 | it->setChecked( it->num() == id ); | 141 | it->setChecked( it->num() == id ); |
142 | it->blockSignals( false ); | 142 | it->blockSignals( false ); |
143 | it = mStdandardB.next(); | 143 | it = mStdandardB.next(); |
144 | } | 144 | } |
145 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 145 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
146 | while ( kkf ) { | 146 | while ( kkf ) { |
147 | kkf->isStandard = (kkf->mCalNumber == id ); | 147 | kkf->isStandard = (kkf->mCalNumber == id ); |
148 | kkf = KOPrefs::instance()->mCalendars.next(); | 148 | kkf = KOPrefs::instance()->mCalendars.next(); |
149 | } | 149 | } |
150 | emit setCalendarDefault ( id ); | 150 | emit setCalendarDefault ( id ); |
151 | } | 151 | } |
152 | 152 | ||
153 | void KOCalEditView::selectCalAlarm(int id ,bool b ) | 153 | void KOCalEditView::selectCalAlarm(int id ,bool b ) |
154 | { | 154 | { |
155 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; | 155 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; |
156 | emit alarmEnabled ( id , b ); | 156 | emit alarmEnabled ( id , b ); |
157 | emit needsUpdate(); | 157 | emit needsUpdate(); |
158 | } | 158 | } |
159 | void KOCalEditView::selectReadOnly(int id ,bool b ) | 159 | void KOCalEditView::selectReadOnly(int id ,bool b ) |
160 | { | 160 | { |
161 | 161 | ||
162 | emit calendarReadonly ( id , b ); | 162 | emit calendarReadonly ( id , b ); |
163 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; | 163 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; |
164 | if ( KOPrefs::instance()->getCalendar( id )->isStandard && b ) { | 164 | if ( KOPrefs::instance()->getCalendar( id )->isStandard && b ) { |
165 | findNewStandard(); | 165 | findNewStandard(); |
166 | } | 166 | } |
167 | if ( !b ){ | 167 | if ( !b ){ |
168 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 168 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
169 | while ( kkf ) { | 169 | while ( kkf ) { |
170 | if (kkf->isReadOnly && kkf->isStandard ) { | 170 | if (kkf->isReadOnly && kkf->isStandard ) { |
171 | selectStdCal( id ); | 171 | selectStdCal( id ); |
172 | break; | 172 | break; |
173 | } | 173 | } |
174 | kkf = KOPrefs::instance()->mCalendars.next(); | 174 | kkf = KOPrefs::instance()->mCalendars.next(); |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | mStdandardB.at(id-1)->setEnabled( !b ); | 178 | mStdandardB.at(id-1)->setEnabled( !b ); |
179 | emit needsUpdate(); | 179 | emit needsUpdate(); |
180 | 180 | ||
181 | } | 181 | } |
182 | void KOCalEditView::findNewStandard() | 182 | void KOCalEditView::findNewStandard() |
183 | { | 183 | { |
184 | bool found = false; | 184 | bool found = false; |
185 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 185 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
186 | while ( kkf ) { | 186 | while ( kkf ) { |
187 | if (!kkf->isReadOnly && !kkf->mErrorOnLoad ) { | 187 | if (!kkf->isReadOnly && !kkf->mErrorOnLoad ) { |
188 | found = true; | 188 | found = true; |
189 | selectStdCal( kkf->mCalNumber ); | 189 | selectStdCal( kkf->mCalNumber ); |
190 | break; | 190 | break; |
191 | } | 191 | } |
192 | kkf = KOPrefs::instance()->mCalendars.next(); | 192 | kkf = KOPrefs::instance()->mCalendars.next(); |
193 | } | 193 | } |
194 | if ( !found ) { | 194 | if ( !found ) { |
195 | KMessageBox::error( this,i18n("\nNO\n WRITEABLE\n CALENDAR\n FOUND!\n\nPlease fix your calendar settings!\n"), | 195 | KMessageBox::error( this,i18n("\nNO\n WRITEABLE\n CALENDAR\n FOUND!\n\nPlease fix your calendar settings!\n"), |
196 | i18n("Houston, we have a problem!") ); | 196 | i18n("Houston, we have a problem!") ); |
197 | 197 | ||
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | void KOCalEditView::setColor( const QColor& c, int id ) | 201 | void KOCalEditView::setColor( const QColor& c, int id ) |
202 | { | 202 | { |
203 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; | 203 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; |
204 | emit needsUpdate(); | 204 | emit needsUpdate(); |
205 | } | 205 | } |
206 | void KOCalEditView::deleteCal( int id ) | 206 | void KOCalEditView::deleteCal( int id ) |
207 | { | 207 | { |
208 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 208 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
209 | QString name = kkf->mName; | 209 | QString name = kkf->mName; |
210 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); | 210 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); |
211 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; | 211 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; |
212 | bool findnewstd = kkf->isStandard; | 212 | bool findnewstd = kkf->isStandard; |
213 | emit removeCalendar ( id ); | 213 | emit removeCalendar ( id ); |
214 | KOPrefs::instance()->mCalendars.remove ( kkf ); | 214 | KOPrefs::instance()->mCalendars.remove ( kkf ); |
215 | if ( findnewstd ) findNewStandard(); | 215 | if ( findnewstd ) findNewStandard(); |
216 | emit needsUpdate(); | 216 | emit needsUpdate(); |
217 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 217 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
218 | } | 218 | } |
219 | void KOCalEditView::infoCal( int id ) | 219 | void KOCalEditView::infoCal( int id ) |
220 | { | 220 | { |
221 | QString name = KOPrefs::instance()->getCalendar( id )->mName; | 221 | QString name = KOPrefs::instance()->getCalendar( id )->mName; |
222 | QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); | 222 | QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); |
223 | if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { | 223 | if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { |
224 | if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { | 224 | if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { |
225 | emit calendarAdded( id ); | 225 | emit calendarAdded( id ); |
226 | emit needsUpdate(); | 226 | emit needsUpdate(); |
227 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 227 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
228 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); | 228 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); |
229 | } | 229 | } |
230 | } | 230 | } |
231 | else | 231 | else |
232 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); | 232 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); |
233 | } | 233 | } |
234 | void KOCalEditView::readConfig() | 234 | void KOCalEditView::readConfig() |
235 | { | 235 | { |
236 | 236 | ||
237 | mStdandardB.clear(); | 237 | mStdandardB.clear(); |
238 | mEnabledB.clear(); | 238 | mEnabledB.clear(); |
239 | mAlarmB.clear(); | 239 | mAlarmB.clear(); |
240 | mROB.clear(); | 240 | mROB.clear(); |
241 | 241 | ||
242 | if ( mw ) delete mw; | 242 | if ( mw ) delete mw; |
243 | mw = new QWidget ( viewport() ); | 243 | mw = new QWidget ( viewport() ); |
244 | addChild(mw); | 244 | addChild(mw); |
245 | int ii = 0; | 245 | int ii = 0; |
246 | mainLayout = new QGridLayout ( mw , 2, 8 ); | 246 | mainLayout = new QGridLayout ( mw , 2, 8 ); |
247 | mainLayout->setMargin( 2 ); | 247 | mainLayout->setMargin( 2 ); |
248 | mainLayout->setSpacing( 2 ); | 248 | mainLayout->setSpacing( 2 ); |
249 | QPushButton * addButT = new QPushButton ( mw ); | 249 | QPushButton * addButT = new QPushButton ( mw ); |
250 | addButT->setFocusPolicy(NoFocus); | 250 | addButT->setFocusPolicy(NoFocus); |
251 | mainLayout->addWidget( addButT,0,0 ); | 251 | mainLayout->addWidget( addButT,0,0 ); |
252 | addButT->setText( "D"); | 252 | addButT->setText( "D"); |
253 | connect(addButT,SIGNAL(clicked()),SLOT(defaultInfo())); | 253 | connect(addButT,SIGNAL(clicked()),SLOT(defaultInfo())); |
254 | //addBut->setPixmap ( SmallIcon("greenhook16")); | 254 | //addBut->setPixmap ( SmallIcon("greenhook16")); |
255 | QPushButton *addBut = new QPushButton ( mw ); | 255 | QPushButton *addBut = new QPushButton ( mw ); |
256 | addBut->setFocusPolicy(NoFocus); | 256 | addBut->setFocusPolicy(NoFocus); |
257 | mainLayout->addWidget( addBut,0,++ii ); | 257 | mainLayout->addWidget( addBut,0,++ii ); |
258 | addBut->setPixmap ( SmallIcon("eye")); | 258 | addBut->setPixmap ( SmallIcon("eye")); |
259 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); | 259 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); |
260 | int max = addBut->sizeHint().height(); | 260 | int max = addBut->sizeHint().height(); |
261 | addBut->setMaximumWidth( max ); | 261 | addBut->setMaximumWidth( max ); |
262 | addButT->setFixedSize( QSize( max, max ) ); | 262 | addButT->setFixedSize( QSize( max, max ) ); |
263 | QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); | 263 | QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); |
264 | mainLayout->addWidget( lab,0,++ii ); | 264 | mainLayout->addWidget( lab,0,++ii ); |
265 | //lab = new QLabel ( i18n(" "), mw ); | 265 | //lab = new QLabel ( i18n(" "), mw ); |
266 | //mainLayout->addWidget( lab,0,++ii ); | 266 | //mainLayout->addWidget( lab,0,++ii ); |
267 | //lab->setFixedWidth( 1 ); | 267 | //lab->setFixedWidth( 1 ); |
268 | addBut = new QPushButton ( mw ); | 268 | addBut = new QPushButton ( mw ); |
269 | addBut->setFocusPolicy(NoFocus); | 269 | addBut->setFocusPolicy(NoFocus); |
270 | mainLayout->addWidget( addBut,0,++ii ); | 270 | mainLayout->addWidget( addBut,0,++ii ); |
271 | addBut->setPixmap ( SmallIcon("bell")); | 271 | addBut->setPixmap ( SmallIcon("bell")); |
272 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); | 272 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); |
273 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 273 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
274 | 274 | ||
275 | addBut = new QPushButton ( mw ); | 275 | addBut = new QPushButton ( mw ); |
276 | addBut->setFocusPolicy(NoFocus); | 276 | addBut->setFocusPolicy(NoFocus); |
277 | mainLayout->addWidget( addBut,0,++ii ); | 277 | mainLayout->addWidget( addBut,0,++ii ); |
278 | addBut->setPixmap ( SmallIcon("pencil")); | 278 | addBut->setPixmap ( SmallIcon("pencil")); |
279 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); | 279 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); |
280 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 280 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
281 | lab = new QLabel ( "", mw ); | 281 | lab = new QLabel ( "", mw ); |
282 | mainLayout->addWidget( lab,0,++ii ); | 282 | mainLayout->addWidget( lab,0,++ii ); |
283 | 283 | ||
284 | addBut = new QPushButton ( mw ); | 284 | addBut = new QPushButton ( mw ); |
285 | addBut->setFocusPolicy(NoFocus); | 285 | addBut->setFocusPolicy(NoFocus); |
286 | mainLayout->addWidget( addBut,0,++ii ); | 286 | mainLayout->addWidget( addBut,0,++ii ); |
287 | addBut->setPixmap ( SmallIcon("plus")); | 287 | addBut->setPixmap ( SmallIcon("plus")); |
288 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); | 288 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); |
289 | 289 | ||
290 | lab = new QLabel ( " ", mw ); | 290 | lab = new QLabel ( " ", mw ); |
291 | mainLayout->addWidget( lab,0,++ii ); | 291 | mainLayout->addWidget( lab,0,++ii ); |
292 | 292 | ||
293 | 293 | ||
294 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 294 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
295 | int row = 1; | 295 | int row = 1; |
296 | bool errorLoadStandard = false; | 296 | bool errorLoadStandard = false; |
297 | while ( kkf ) { | 297 | while ( kkf ) { |
298 | int iii = 0; | 298 | int iii = 0; |
299 | KOCalRadioButton* rb = new KOCalRadioButton( mw ); | 299 | KOCalRadioButton* rb = new KOCalRadioButton( mw ); |
300 | mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb ); | 300 | mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb ); |
301 | rb->setChecked( kkf->isStandard ); | 301 | rb->setChecked( kkf->isStandard ); |
302 | if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) ) | 302 | if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) ) |
303 | errorLoadStandard = true; | 303 | errorLoadStandard = true; |
304 | rb->setNum( kkf->mCalNumber ); | 304 | rb->setNum( kkf->mCalNumber ); |
305 | connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) ); | 305 | connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) ); |
306 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) | 306 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) |
307 | rb->setEnabled( false ); | 307 | rb->setEnabled( false ); |
308 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); | 308 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); |
309 | mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); | 309 | mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); |
310 | cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad ); | 310 | cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad ); |
311 | cb->setNum( kkf->mCalNumber ); | 311 | cb->setNum( kkf->mCalNumber ); |
312 | if ( kkf->mErrorOnLoad ) | 312 | if ( kkf->mErrorOnLoad ) |
313 | cb->setEnabled( false ); | 313 | cb->setEnabled( false ); |
314 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); | 314 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); |
315 | KOCalButton* name = new KOCalButton( mw ); | 315 | KOCalButton* name = new KOCalButton( mw ); |
316 | name->setNum( kkf->mCalNumber ); | 316 | name->setNum( kkf->mCalNumber ); |
317 | name->setText( kkf->mName ); | 317 | name->setText( kkf->mName ); |
318 | mainLayout->addWidget( name,row,++iii ); | 318 | mainLayout->addWidget( name,row,++iii ); |
319 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); | 319 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); |
320 | //lab = new QLabel (" ", mw ); | 320 | //lab = new QLabel (" ", mw ); |
321 | //mainLayout->addWidget( lab,row,++iii ); | 321 | //mainLayout->addWidget( lab,row,++iii ); |
322 | cb = new KOCalCheckButton( mw ); | 322 | cb = new KOCalCheckButton( mw ); |
323 | mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); | 323 | mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); |
324 | cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad); | 324 | cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad); |
325 | cb->setNum( kkf->mCalNumber ); | 325 | cb->setNum( kkf->mCalNumber ); |
326 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); | 326 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); |
327 | if ( kkf->mErrorOnLoad ) | 327 | if ( kkf->mErrorOnLoad ) |
328 | cb->setEnabled( false ); | 328 | cb->setEnabled( false ); |
329 | cb = new KOCalCheckButton( mw ); | 329 | cb = new KOCalCheckButton( mw ); |
330 | mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); | 330 | mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); |
331 | cb->setChecked( kkf->isReadOnly ); | 331 | cb->setChecked( kkf->isReadOnly ); |
332 | cb->setNum( kkf->mCalNumber ); | 332 | cb->setNum( kkf->mCalNumber ); |
333 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); | 333 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); |
334 | if ( kkf->mErrorOnLoad ) | 334 | if ( kkf->mErrorOnLoad ) |
335 | cb->setEnabled( false ); | 335 | cb->setEnabled( false ); |
336 | if ( row > 1) { | 336 | if ( row > 1) { |
337 | KColorButton *colb = new KColorButton( mw ); | 337 | KColorButton *colb = new KColorButton( mw ); |
338 | mainLayout->addWidget( colb,row,++iii ); | 338 | mainLayout->addWidget( colb,row,++iii ); |
339 | colb->setID( kkf->mCalNumber ); | 339 | colb->setID( kkf->mCalNumber ); |
340 | colb->setColor( kkf->mDefaultColor ); | 340 | colb->setColor( kkf->mDefaultColor ); |
341 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); | 341 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); |
342 | KOCalButton* calb = new KOCalButton( mw ); | 342 | KOCalButton* calb = new KOCalButton( mw ); |
343 | mainLayout->addWidget( calb,row,++iii ); | 343 | mainLayout->addWidget( calb,row,++iii ); |
344 | calb->setNum( kkf->mCalNumber ); | 344 | calb->setNum( kkf->mCalNumber ); |
345 | calb->setPixmap ( SmallIcon("minus")); | 345 | calb->setPixmap ( SmallIcon("minus")); |
346 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); | 346 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); |
347 | int hei = calb->sizeHint().height(); | 347 | int hei = calb->sizeHint().height(); |
348 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); | 348 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); |
349 | } | 349 | } |
350 | ++row; | 350 | ++row; |
351 | kkf = KOPrefs::instance()->mCalendars.next(); | 351 | kkf = KOPrefs::instance()->mCalendars.next(); |
352 | } | 352 | } |
353 | if ( errorLoadStandard ) | 353 | if ( errorLoadStandard ) |
354 | findNewStandard(); | 354 | findNewStandard(); |
355 | lab = new QLabel ( "", mw ); | 355 | lab = new QLabel ( "", mw ); |
356 | mainLayout->addWidget( lab,row,0 ); | 356 | mainLayout->addWidget( lab,row,0 ); |
357 | mw->show(); | 357 | mw->show(); |
358 | 358 | ||
359 | } | 359 | } |
360 | 360 | ||
361 | void KOCalEditView::defaultInfo() | 361 | void KOCalEditView::defaultInfo() |
362 | { | 362 | { |
363 | KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); | 363 | KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); |
364 | } | 364 | } |
365 | void KOCalEditView::addCal() | 365 | void KOCalEditView::addCal() |
366 | { | 366 | { |
367 | bool tryagain = true; | 367 | bool tryagain = true; |
368 | QString name, file; | 368 | QString name, file = KGlobalSettings::calendarDir()+"newCal.ics"; |
369 | while ( tryagain ) { | 369 | while ( tryagain ) { |
370 | KONewCalPrefs prefs ( this ); | 370 | KONewCalPrefs prefs ( this ); |
371 | prefs.nameE->setText( name ); | 371 | prefs.nameE->setText( name ); |
372 | prefs.url->setURL( file ); | 372 | prefs.url->setURL( file ); |
373 | if ( ! prefs.exec() ) | 373 | if ( ! prefs.exec() ) |
374 | return; | 374 | return; |
375 | name = prefs.calName(); | 375 | name = prefs.calName(); |
376 | file = prefs.calFileName(); | 376 | file = prefs.calFileName(); |
377 | tryagain = false; | 377 | tryagain = false; |
378 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 378 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
379 | while ( kkf ) { | 379 | while ( kkf ) { |
380 | if ( kkf->mName == name ) { | 380 | if ( kkf->mName == name ) { |
381 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); | 381 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); |
382 | name = ""; | 382 | name = ""; |
383 | tryagain = true; | 383 | tryagain = true; |
384 | break; | 384 | break; |
385 | } | 385 | } |
386 | if ( kkf->mFileName == file ) { | 386 | if ( kkf->mFileName == file ) { |
387 | KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); | 387 | KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); |
388 | tryagain = true; | 388 | tryagain = true; |
389 | file = ""; | 389 | file = KGlobalSettings::calendarDir()+"newCal.ics"; |
390 | break; | 390 | break; |
391 | } | 391 | } |
392 | kkf = KOPrefs::instance()->mCalendars.next(); | 392 | kkf = KOPrefs::instance()->mCalendars.next(); |
393 | } | ||
394 | QFileInfo fi ( file ); | ||
395 | if ( fi.isDir() ) { | ||
396 | tryagain = true; | ||
393 | } | 397 | } |
394 | } | 398 | } |
395 | addCalendar ( name, file ); | 399 | addCalendar ( name, file ); |
396 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); | 400 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); |
397 | } | 401 | } |
398 | int KOCalEditView::addCalendar( QString name, QString file, bool ask ) | 402 | int KOCalEditView::addCalendar( QString name, QString file, bool ask ) |
399 | { | 403 | { |
400 | 404 | ||
401 | QFileInfo fi ( file ); | 405 | QFileInfo fi ( file ); |
402 | QString absFile = file; | 406 | QString absFile = file; |
403 | bool isRelative = false; | 407 | bool isRelative = false; |
404 | if ( fi.isRelative() ) { | 408 | if ( fi.isRelative() ) { |
405 | isRelative = true; | 409 | isRelative = true; |
406 | absFile = KGlobalSettings::calendarDir()+file; | 410 | absFile = KGlobalSettings::calendarDir()+file; |
407 | fi.setFile( absFile ); | 411 | fi.setFile( absFile ); |
408 | } else { | 412 | } else { |
409 | QString cd = KGlobalSettings::calendarDir(); | 413 | QString cd = KGlobalSettings::calendarDir(); |
410 | if ( file.left( cd.length() ) == cd ) { | 414 | if ( file.left( cd.length() ) == cd ) { |
411 | isRelative = true; | 415 | isRelative = true; |
412 | file = fi.fileName (); | 416 | file = fi.fileName (); |
413 | fi.setFile( absFile ); | 417 | fi.setFile( absFile ); |
414 | } | 418 | } |
415 | } | 419 | } |
416 | if (!fi.exists() ) { | 420 | if (!fi.exists() ) { |
417 | if ( ask ) | 421 | if ( ask ) |
418 | if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No ) | 422 | if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No ) |
419 | return 0; | 423 | return 0; |
420 | QFile fileIn( absFile ); | 424 | QFile fileIn( absFile ); |
421 | if (!fileIn.open( IO_WriteOnly ) ) { | 425 | if (!fileIn.open( IO_WriteOnly ) ) { |
422 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); | 426 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); |
423 | return 0; | 427 | return 0; |
424 | } | 428 | } |
425 | QTextStream tsIn( &fileIn ); | 429 | QTextStream tsIn( &fileIn ); |
426 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 430 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
427 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; | 431 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; |
428 | fileIn.close(); | 432 | fileIn.close(); |
429 | } | 433 | } |
430 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); | 434 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); |
431 | kkf->mName = name; | 435 | kkf->mName = name; |
432 | kkf->mFileName = absFile; | 436 | kkf->mFileName = absFile; |
433 | kkf->mSavedFileName = file; | 437 | kkf->mSavedFileName = file; |
434 | kkf->isRelative = isRelative; | 438 | kkf->isRelative = isRelative; |
435 | emit calendarAdded( kkf->mCalNumber ); | 439 | emit calendarAdded( kkf->mCalNumber ); |
436 | if ( ask ) | 440 | if ( ask ) |
437 | emit needsUpdate(); | 441 | emit needsUpdate(); |
438 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 442 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
439 | return kkf->mCalNumber; | 443 | return kkf->mCalNumber; |
440 | } | 444 | } |
441 | int KOCalEditView::getBirtdayID() | 445 | int KOCalEditView::getBirtdayID() |
442 | { | 446 | { |
443 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 447 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
444 | while ( kkf ) { | 448 | while ( kkf ) { |
445 | if ( kkf->mName == i18n("Birthdays") ) | 449 | if ( kkf->mName == i18n("Birthdays") ) |
446 | return kkf->mCalNumber; | 450 | return kkf->mCalNumber; |
447 | kkf = KOPrefs::instance()->mCalendars.next(); | 451 | kkf = KOPrefs::instance()->mCalendars.next(); |
448 | } | 452 | } |
449 | QString file = locateLocal( "data", "korganizer/birthdays.ics" ); | 453 | QString file = locateLocal( "data", "korganizer/birthdays.ics" ); |
450 | return addCalendar( i18n("Birthdays"), file, false ); | 454 | return addCalendar( i18n("Birthdays"), file, false ); |
451 | } | 455 | } |
452 | 456 | ||
453 | void KOCalEditView::enableAll() | 457 | void KOCalEditView::enableAll() |
454 | { | 458 | { |
455 | toggleList( mEnabledB ); | 459 | toggleList( mEnabledB ); |
456 | } | 460 | } |
457 | void KOCalEditView::enableAlarm() | 461 | void KOCalEditView::enableAlarm() |
458 | { | 462 | { |
459 | toggleList( mAlarmB ); | 463 | toggleList( mAlarmB ); |
460 | } | 464 | } |
461 | void KOCalEditView::disableRO() | 465 | void KOCalEditView::disableRO() |
462 | { | 466 | { |
463 | toggleList( mROB, false ); | 467 | toggleList( mROB, false ); |
464 | } | 468 | } |
465 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable ) | 469 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable ) |
466 | { | 470 | { |
467 | bool dis = !enable; | 471 | bool dis = !enable; |
468 | KOCalCheckButton* it = list.first(); | 472 | KOCalCheckButton* it = list.first(); |
469 | while ( it ) { | 473 | while ( it ) { |
470 | if ( !it->isChecked() == enable && it->isEnabled() ) { | 474 | if ( !it->isChecked() == enable && it->isEnabled() ) { |
471 | dis = !dis; | 475 | dis = !dis; |
472 | break; | 476 | break; |
473 | } | 477 | } |
474 | it = list.next(); | 478 | it = list.next(); |
475 | } | 479 | } |
476 | it = list.first(); | 480 | it = list.first(); |
477 | while ( it ) { | 481 | while ( it ) { |
478 | if ( it->isEnabled() ) | 482 | if ( it->isEnabled() ) |
479 | it->setChecked(dis); | 483 | it->setChecked(dis); |
480 | it = list.next(); | 484 | it = list.next(); |
481 | } | 485 | } |
482 | } | 486 | } |
483 | void KOCalEditView::deleteAll() | 487 | void KOCalEditView::deleteAll() |
484 | { | 488 | { |
485 | qDebug("delteAll"); | 489 | qDebug("delteAll"); |
486 | } | 490 | } |