-rw-r--r-- | korganizer/calendarview.cpp | 19 | ||||
-rw-r--r-- | korganizer/calendarview.h | 2 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 10 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 |
4 files changed, 28 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 31e103d..8965d3b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,5176 +1,5189 @@ | |||
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 | flag_blockConflict = false; | 369 | flag_blockConflict = false; |
370 | flag_blockScrollBar = false; | 370 | flag_blockScrollBar = false; |
371 | flag_checkFileFirsttime = true; | 371 | flag_checkFileFirsttime = true; |
372 | flag_clearallviewsEventDisplay = false; | 372 | flag_clearallviewsEventDisplay = false; |
373 | flag_clearallviewsupdateView = false; | 373 | flag_clearallviewsupdateView = false; |
374 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 374 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
375 | setFocusPolicy (NoFocus ); | 375 | setFocusPolicy (NoFocus ); |
376 | mViewerCallerIsSearchDialog = false; | 376 | mViewerCallerIsSearchDialog = false; |
377 | mBlockShowDates = false; | 377 | mBlockShowDates = false; |
378 | mConflictingEvent = 0; | 378 | mConflictingEvent = 0; |
379 | mDatePickerMode = 0; | 379 | mDatePickerMode = 0; |
380 | mCurrentSyncDevice = ""; | 380 | mCurrentSyncDevice = ""; |
381 | mViewManager = new KOViewManager( this ); | 381 | mViewManager = new KOViewManager( this ); |
382 | mDialogManager = new KODialogManager( this ); | 382 | mDialogManager = new KODialogManager( this ); |
383 | mEventViewerDialog = 0; | 383 | mEventViewerDialog = 0; |
384 | mModified = false; | 384 | mModified = false; |
385 | mReadOnly = false; | 385 | mReadOnly = false; |
386 | mSelectedIncidence = 0; | 386 | mSelectedIncidence = 0; |
387 | mCalPrinter = 0; | 387 | mCalPrinter = 0; |
388 | mFilters.setAutoDelete(true); | 388 | mFilters.setAutoDelete(true); |
389 | 389 | ||
390 | mCalendar->registerObserver( this ); | 390 | mCalendar->registerObserver( this ); |
391 | // TODO: Make sure that view is updated, when calendar is changed. | 391 | // TODO: Make sure that view is updated, when calendar is changed. |
392 | 392 | ||
393 | mStorage = new FileStorage( mCalendar ); | 393 | mStorage = new FileStorage( mCalendar ); |
394 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 394 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
395 | 395 | ||
396 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 396 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
397 | #ifndef KORG_NOSPLITTER | 397 | #ifndef KORG_NOSPLITTER |
398 | // create the main layout frames. | 398 | // create the main layout frames. |
399 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 399 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
400 | topLayout->addWidget(mPanner); | 400 | topLayout->addWidget(mPanner); |
401 | 401 | ||
402 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 402 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
403 | "CalendarView::LeftFrame"); | 403 | "CalendarView::LeftFrame"); |
404 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 404 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
405 | 405 | ||
406 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 406 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
407 | "CalendarView::DateNavigator" ); | 407 | "CalendarView::DateNavigator" ); |
408 | 408 | ||
409 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 409 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
410 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 410 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
411 | mTodoList->setNavigator( mNavigator ); | 411 | mTodoList->setNavigator( mNavigator ); |
412 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 412 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
413 | 413 | ||
414 | #ifdef KORG_NORESOURCEVIEW | 414 | #ifdef KORG_NORESOURCEVIEW |
415 | mResourceView = 0; | 415 | mResourceView = 0; |
416 | #else | 416 | #else |
417 | if ( mResourceManager ) { | 417 | if ( mResourceManager ) { |
418 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 418 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
419 | mResourceView->updateView(); | 419 | mResourceView->updateView(); |
420 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 420 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
421 | SLOT( updateView() ) ); | 421 | SLOT( updateView() ) ); |
422 | } else { | 422 | } else { |
423 | mResourceView = 0; | 423 | mResourceView = 0; |
424 | } | 424 | } |
425 | #endif | 425 | #endif |
426 | QWidget *rightBox = new QWidget( mPanner ); | 426 | QWidget *rightBox = new QWidget( mPanner ); |
427 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 427 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
428 | 428 | ||
429 | mRightFrame = new QWidgetStack( rightBox ); | 429 | mRightFrame = new QWidgetStack( rightBox ); |
430 | rightLayout->addWidget( mRightFrame, 1 ); | 430 | rightLayout->addWidget( mRightFrame, 1 ); |
431 | 431 | ||
432 | mLeftFrame = mLeftSplitter; | 432 | mLeftFrame = mLeftSplitter; |
433 | #else | 433 | #else |
434 | //QWidget *mainBox = new QWidget( this ); | 434 | //QWidget *mainBox = new QWidget( this ); |
435 | //QWidget *leftFrame = new QWidget( mainBox ); | 435 | //QWidget *leftFrame = new QWidget( mainBox ); |
436 | //QBoxLayout * mainBoxLayout; | 436 | //QBoxLayout * mainBoxLayout; |
437 | if ( KOPrefs::instance()->mVerticalScreen ) { | 437 | if ( KOPrefs::instance()->mVerticalScreen ) { |
438 | //mainBoxLayout = new QVBoxLayout(mainBox); | 438 | //mainBoxLayout = new QVBoxLayout(mainBox); |
439 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 439 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
440 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 440 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
441 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 441 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
442 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 442 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
443 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 443 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
444 | } else { | 444 | } else { |
445 | //mainBoxLayout = new QHBoxLayout(mainBox); | 445 | //mainBoxLayout = new QHBoxLayout(mainBox); |
446 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 446 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
447 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 447 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
448 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 448 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
449 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 449 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
450 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 450 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
451 | } | 451 | } |
452 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 452 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
453 | //QBoxLayout * leftFrameLayout; | 453 | //QBoxLayout * leftFrameLayout; |
454 | topLayout->addWidget( mMainFrame ); | 454 | topLayout->addWidget( mMainFrame ); |
455 | #ifdef DESKTOP_VERSION | 455 | #ifdef DESKTOP_VERSION |
456 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 456 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
457 | topLayout->addWidget( mDateScrollBar ); | 457 | topLayout->addWidget( mDateScrollBar ); |
458 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 458 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
459 | if ( QApplication::desktop()->width() < 800 ) | 459 | if ( QApplication::desktop()->width() < 800 ) |
460 | mDateScrollBar->hide(); | 460 | mDateScrollBar->hide(); |
461 | #endif | 461 | #endif |
462 | //mainBoxLayout->addWidget (mLeftFrame); | 462 | //mainBoxLayout->addWidget (mLeftFrame); |
463 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 463 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
464 | "CalendarView::DateNavigator" ); | 464 | "CalendarView::DateNavigator" ); |
465 | #if 0 | 465 | #if 0 |
466 | // FIXME | 466 | // FIXME |
467 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 467 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
468 | "CalendarView::DateNavigator", QDate::currentDate()); | 468 | "CalendarView::DateNavigator", QDate::currentDate()); |
469 | #endif | 469 | #endif |
470 | // mDateNavigator->blockSignals( true ); | 470 | // mDateNavigator->blockSignals( true ); |
471 | //leftFrameLayout->addWidget( mDateNavigator ); | 471 | //leftFrameLayout->addWidget( mDateNavigator ); |
472 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 472 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
473 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 473 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
474 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 474 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
475 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 475 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
476 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 476 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
477 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 477 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
478 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 478 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
479 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 479 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
480 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 480 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
481 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 481 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
482 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 482 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
483 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 483 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
484 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 484 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
485 | connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); | 485 | connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); |
486 | 486 | ||
487 | 487 | ||
488 | mTodoList->setNavigator( mNavigator ); | 488 | mTodoList->setNavigator( mNavigator ); |
489 | #if 0 | 489 | #if 0 |
490 | if ( QApplication::desktop()->width() < 480 ) { | 490 | if ( QApplication::desktop()->width() < 480 ) { |
491 | leftFrameLayout->addWidget(mFilterView); | 491 | leftFrameLayout->addWidget(mFilterView); |
492 | leftFrameLayout->addWidget(mTodoList, 2 ); | 492 | leftFrameLayout->addWidget(mTodoList, 2 ); |
493 | 493 | ||
494 | } else { | 494 | } else { |
495 | leftFrameLayout->addWidget(mTodoList,2 ); | 495 | leftFrameLayout->addWidget(mTodoList,2 ); |
496 | leftFrameLayout->addWidget(mFilterView ); | 496 | leftFrameLayout->addWidget(mFilterView ); |
497 | } | 497 | } |
498 | #endif | 498 | #endif |
499 | mFilterView->hide(); | 499 | mFilterView->hide(); |
500 | mCalEditView->hide(); | 500 | mCalEditView->hide(); |
501 | QWidget *rightBox = new QWidget( mMainFrame ); | 501 | QWidget *rightBox = new QWidget( mMainFrame ); |
502 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 502 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
503 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 503 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
504 | mRightFrame = new QWidgetStack( rightBox ); | 504 | mRightFrame = new QWidgetStack( rightBox ); |
505 | rightLayout->addWidget( mRightFrame, 10 ); | 505 | rightLayout->addWidget( mRightFrame, 10 ); |
506 | 506 | ||
507 | //mLeftFrame = (QWidget *)leftFrame; | 507 | //mLeftFrame = (QWidget *)leftFrame; |
508 | if ( KOPrefs::instance()->mVerticalScreen ) { | 508 | if ( KOPrefs::instance()->mVerticalScreen ) { |
509 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 509 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
510 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 510 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
511 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 511 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
512 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 512 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
513 | } else { | 513 | } else { |
514 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 514 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
515 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 515 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
516 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 516 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
517 | } | 517 | } |
518 | if ( !KOPrefs::instance()->mShowDateNavigator) | 518 | if ( !KOPrefs::instance()->mShowDateNavigator) |
519 | mDateNavigator->hide(); | 519 | mDateNavigator->hide(); |
520 | //qDebug("Calendarview Size %d %d ", width(), height()); | 520 | //qDebug("Calendarview Size %d %d ", width(), height()); |
521 | #endif | 521 | #endif |
522 | 522 | ||
523 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 523 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
524 | SLOT( showDates( const KCal::DateList & ) ) ); | 524 | SLOT( showDates( const KCal::DateList & ) ) ); |
525 | 525 | ||
526 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 526 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
527 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 527 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
528 | 528 | ||
529 | 529 | ||
530 | 530 | ||
531 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 531 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
532 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 532 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
533 | 533 | ||
534 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 534 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
535 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 535 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
536 | 536 | ||
537 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 537 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
538 | mNavigator, SLOT( selectPreviousYear() ) ); | 538 | mNavigator, SLOT( selectPreviousYear() ) ); |
539 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 539 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
540 | mNavigator, SLOT( selectNextYear() ) ); | 540 | mNavigator, SLOT( selectNextYear() ) ); |
541 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 541 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
542 | mNavigator, SLOT( selectPreviousMonth() ) ); | 542 | mNavigator, SLOT( selectPreviousMonth() ) ); |
543 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 543 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
544 | mNavigator, SLOT( selectNextMonth() ) ); | 544 | mNavigator, SLOT( selectNextMonth() ) ); |
545 | 545 | ||
546 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 546 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
547 | mNavigator, SLOT( selectPrevious() ) ); | 547 | mNavigator, SLOT( selectPrevious() ) ); |
548 | connect( mDateNavigator, SIGNAL( goNext() ), | 548 | connect( mDateNavigator, SIGNAL( goNext() ), |
549 | mNavigator, SLOT( selectNext() ) ); | 549 | mNavigator, SLOT( selectNext() ) ); |
550 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 550 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
551 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 551 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
552 | 552 | ||
553 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 553 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
554 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 554 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
555 | #if 0 | 555 | #if 0 |
556 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 556 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
557 | SLOT( incidenceAdded( Incidence *) ) ); | 557 | SLOT( incidenceAdded( Incidence *) ) ); |
558 | #endif | 558 | #endif |
559 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 559 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
560 | 560 | ||
561 | connect( this, SIGNAL( configChanged() ), | 561 | connect( this, SIGNAL( configChanged() ), |
562 | mDateNavigator, SLOT( updateConfig() ) ); | 562 | mDateNavigator, SLOT( updateConfig() ) ); |
563 | 563 | ||
564 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 564 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
565 | SLOT( newTodo() ) ); | 565 | SLOT( newTodo() ) ); |
566 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 566 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
567 | SLOT( newSubTodo( Todo * ) ) ); | 567 | SLOT( newSubTodo( Todo * ) ) ); |
568 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 568 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
569 | SLOT( editTodo( Todo * ) ) ); | 569 | SLOT( editTodo( Todo * ) ) ); |
570 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 570 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
571 | SLOT( showTodo( Todo *) ) ); | 571 | SLOT( showTodo( Todo *) ) ); |
572 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 572 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
573 | SLOT( deleteTodo( Todo *) ) ); | 573 | SLOT( deleteTodo( Todo *) ) ); |
574 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 574 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
575 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 575 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
576 | SLOT( purgeCompleted() ) ); | 576 | SLOT( purgeCompleted() ) ); |
577 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 577 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
578 | SIGNAL( todoModified( Todo *, int ) ) ); | 578 | SIGNAL( todoModified( Todo *, int ) ) ); |
579 | 579 | ||
580 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
581 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 581 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
582 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 582 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
583 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 583 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
584 | 584 | ||
585 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 585 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
586 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 586 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
587 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 587 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
588 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 588 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
589 | 589 | ||
590 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 590 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
591 | this, SLOT ( todo_unsub( Todo * ) ) ); | 591 | this, SLOT ( todo_unsub( Todo * ) ) ); |
592 | 592 | ||
593 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 593 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
594 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 594 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
595 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 595 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
596 | SLOT( updateTodo( Todo *, int ) ) ); | 596 | SLOT( updateTodo( Todo *, int ) ) ); |
597 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 597 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
598 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 598 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
599 | 599 | ||
600 | 600 | ||
601 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 601 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
602 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 602 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
603 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 603 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
604 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 604 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
605 | 605 | ||
606 | 606 | ||
607 | 607 | ||
608 | 608 | ||
609 | 609 | ||
610 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 610 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
611 | SLOT(checkClipboard())); | 611 | SLOT(checkClipboard())); |
612 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 612 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
613 | SLOT( processTodoListSelection( Incidence * ) ) ); | 613 | SLOT( processTodoListSelection( Incidence * ) ) ); |
614 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 614 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
615 | 615 | ||
616 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 616 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
617 | 617 | ||
618 | mDateFrame = new QVBox(0,0,WType_Popup); | 618 | mDateFrame = new QVBox(0,0,WType_Popup); |
619 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 619 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
620 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 620 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
621 | mDateFrame->setLineWidth(3); | 621 | mDateFrame->setLineWidth(3); |
622 | mDateFrame->hide(); | 622 | mDateFrame->hide(); |
623 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 623 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
624 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 624 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
625 | 625 | ||
626 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 626 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
627 | 627 | ||
628 | mEventEditor = mDialogManager->getEventEditor(); | 628 | mEventEditor = mDialogManager->getEventEditor(); |
629 | mTodoEditor = mDialogManager->getTodoEditor(); | 629 | mTodoEditor = mDialogManager->getTodoEditor(); |
630 | 630 | ||
631 | mFlagEditDescription = false; | 631 | mFlagEditDescription = false; |
632 | 632 | ||
633 | mSuspendTimer = new QTimer( this ); | 633 | mSuspendTimer = new QTimer( this ); |
634 | mAlarmTimer = new QTimer( this ); | 634 | mAlarmTimer = new QTimer( this ); |
635 | mRecheckAlarmTimer = new QTimer( this ); | 635 | mRecheckAlarmTimer = new QTimer( this ); |
636 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 636 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
637 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 637 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
638 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 638 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
639 | mAlarmDialog = new AlarmDialog( this ); | 639 | mAlarmDialog = new AlarmDialog( this ); |
640 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 640 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
641 | mAlarmDialog->setServerNotification( false ); | 641 | mAlarmDialog->setServerNotification( false ); |
642 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 642 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
643 | 643 | ||
644 | 644 | ||
645 | #ifndef DESKTOP_VERSION | 645 | #ifndef DESKTOP_VERSION |
646 | //US listen for arriving address resultsets | 646 | //US listen for arriving address resultsets |
647 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 647 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
648 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 648 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
649 | #endif | 649 | #endif |
650 | mDateNavigator->setCalendar( mCalendar ); | 650 | mDateNavigator->setCalendar( mCalendar ); |
651 | } | 651 | } |
652 | 652 | ||
653 | 653 | ||
654 | CalendarView::~CalendarView() | 654 | CalendarView::~CalendarView() |
655 | { | 655 | { |
656 | // kdDebug() << "~CalendarView()" << endl; | 656 | // kdDebug() << "~CalendarView()" << endl; |
657 | //qDebug("CalendarView::~CalendarView() "); | 657 | //qDebug("CalendarView::~CalendarView() "); |
658 | delete mDialogManager; | 658 | delete mDialogManager; |
659 | delete mViewManager; | 659 | delete mViewManager; |
660 | delete mStorage; | 660 | delete mStorage; |
661 | delete mDateFrame ; | 661 | delete mDateFrame ; |
662 | delete mEventViewerDialog; | 662 | delete mEventViewerDialog; |
663 | //kdDebug() << "~CalendarView() done" << endl; | 663 | //kdDebug() << "~CalendarView() done" << endl; |
664 | } | 664 | } |
665 | 665 | ||
666 | 666 | ||
667 | void CalendarView::nextConflict( bool all, bool allday ) | 667 | void CalendarView::nextConflict( bool all, bool allday ) |
668 | { | 668 | { |
669 | if ( flag_blockConflict ) return; | 669 | if ( flag_blockConflict ) return; |
670 | flag_blockConflict = true; | 670 | flag_blockConflict = true; |
671 | QPtrList<Event> testlist = mCalendar->events(); | 671 | QPtrList<Event> testlist = mCalendar->events(); |
672 | Event * test = testlist.first(); | 672 | Event * test = testlist.first(); |
673 | while ( test ) { | 673 | while ( test ) { |
674 | test->setTagged( false ); | 674 | test->setTagged( false ); |
675 | test = testlist.next(); | 675 | test = testlist.next(); |
676 | } | 676 | } |
677 | QTime st ( 0,0,0); | 677 | QTime st ( 0,0,0); |
678 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 678 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
679 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 679 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
680 | //qDebug("time %s ", st.toString().latin1()); | 680 | //qDebug("time %s ", st.toString().latin1()); |
681 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 681 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
682 | QDateTime conflict; | 682 | QDateTime conflict; |
683 | QDateTime retVal; | 683 | QDateTime retVal; |
684 | bool found = false; | 684 | bool found = false; |
685 | Event * cE = 0; | 685 | Event * cE = 0; |
686 | Event * cE2 = 0; | 686 | Event * cE2 = 0; |
687 | QPtrList<Event> testlist2 = testlist; | 687 | QPtrList<Event> testlist2 = testlist; |
688 | test = testlist.first(); | 688 | test = testlist.first(); |
689 | bool skip = false; | 689 | bool skip = false; |
690 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 690 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
691 | //QTime tm; | 691 | //QTime tm; |
692 | //tm.start(); | 692 | //tm.start(); |
693 | while ( test ) { | 693 | while ( test ) { |
694 | qApp->processEvents(); | 694 | qApp->processEvents(); |
695 | skip = false; | 695 | skip = false; |
696 | if ( !all ) skip = ( allday != test->doesFloat() ); | 696 | if ( !all ) skip = ( allday != test->doesFloat() ); |
697 | if ( !skip ) { | 697 | if ( !skip ) { |
698 | if ( found ) | 698 | if ( found ) |
699 | skip = !test->matchTime( &startDT, &conflict ); | 699 | skip = !test->matchTime( &startDT, &conflict ); |
700 | else | 700 | else |
701 | skip = !test->matchTime( &startDT, 0 ); | 701 | skip = !test->matchTime( &startDT, 0 ); |
702 | } | 702 | } |
703 | if ( !skip ) { | 703 | if ( !skip ) { |
704 | Event * test2 = testlist2.first(); | 704 | Event * test2 = testlist2.first(); |
705 | while ( test2 ) { | 705 | while ( test2 ) { |
706 | skip = test2->isTagged(); | 706 | skip = test2->isTagged(); |
707 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); | 707 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); |
708 | if ( !skip ) { | 708 | if ( !skip ) { |
709 | if ( found ) | 709 | if ( found ) |
710 | skip = !test2->matchTime( &startDT, &conflict ); | 710 | skip = !test2->matchTime( &startDT, &conflict ); |
711 | else | 711 | else |
712 | skip = !test2->matchTime( &startDT, 0 ); | 712 | skip = !test2->matchTime( &startDT, 0 ); |
713 | } | 713 | } |
714 | if ( !skip ) { | 714 | if ( !skip ) { |
715 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 715 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
716 | //qDebug("overlap "); | 716 | //qDebug("overlap "); |
717 | if ( ! found ) { | 717 | if ( ! found ) { |
718 | if ( retVal >= startDT ) { | 718 | if ( retVal >= startDT ) { |
719 | conflict = retVal; | 719 | conflict = retVal; |
720 | cE = test; | 720 | cE = test; |
721 | cE2 = test2; | 721 | cE2 = test2; |
722 | found = true; | 722 | found = true; |
723 | } | 723 | } |
724 | } else { | 724 | } else { |
725 | if ( retVal >= startDT && retVal < conflict ) { | 725 | if ( retVal >= startDT && retVal < conflict ) { |
726 | conflict = retVal; | 726 | conflict = retVal; |
727 | cE = test; | 727 | cE = test; |
728 | cE2 = test2; | 728 | cE2 = test2; |
729 | } | 729 | } |
730 | } | 730 | } |
731 | } | 731 | } |
732 | } | 732 | } |
733 | test2 = testlist2.next(); | 733 | test2 = testlist2.next(); |
734 | } | 734 | } |
735 | } | 735 | } |
736 | test->setTagged( true ); | 736 | test->setTagged( true ); |
737 | test = testlist.next(); | 737 | test = testlist.next(); |
738 | } | 738 | } |
739 | //qDebug("Search time : %d", tm.elapsed()); | 739 | //qDebug("Search time : %d", tm.elapsed()); |
740 | if ( found ) { | 740 | if ( found ) { |
741 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 741 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
742 | mViewManager->showDayView(); | 742 | mViewManager->showDayView(); |
743 | mNavigator->slotDaySelect( conflict.date() ); | 743 | mNavigator->slotDaySelect( conflict.date() ); |
744 | int hour = conflict.time().hour(); | 744 | int hour = conflict.time().hour(); |
745 | mViewManager->agendaView()->setStartHour( hour ); | 745 | mViewManager->agendaView()->setStartHour( hour ); |
746 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 746 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
747 | flag_blockConflict = false; | 747 | flag_blockConflict = false; |
748 | return; | 748 | return; |
749 | } | 749 | } |
750 | 750 | ||
751 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 751 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
752 | //qDebug("No conflict found "); | 752 | //qDebug("No conflict found "); |
753 | flag_blockConflict = false; | 753 | flag_blockConflict = false; |
754 | return; | 754 | return; |
755 | } | 755 | } |
756 | 756 | ||
757 | void CalendarView::conflictAll() | 757 | void CalendarView::conflictAll() |
758 | { | 758 | { |
759 | nextConflict ( true, true ); | 759 | nextConflict ( true, true ); |
760 | } | 760 | } |
761 | void CalendarView::conflictAllday() | 761 | void CalendarView::conflictAllday() |
762 | { | 762 | { |
763 | nextConflict ( false, true ); | 763 | nextConflict ( false, true ); |
764 | } | 764 | } |
765 | void CalendarView::conflictNotAll() | 765 | void CalendarView::conflictNotAll() |
766 | { | 766 | { |
767 | nextConflict ( false, false ); | 767 | nextConflict ( false, false ); |
768 | } | 768 | } |
769 | 769 | ||
770 | void CalendarView::setCalReadOnly( int id, bool readO ) | 770 | void CalendarView::setCalReadOnly( int id, bool readO ) |
771 | { | 771 | { |
772 | if ( readO ) { | 772 | if ( readO ) { |
773 | emit save(); | 773 | emit save(); |
774 | } | 774 | } |
775 | mCalendar->setReadOnly( id, readO ); | 775 | mCalendar->setReadOnly( id, readO ); |
776 | } | 776 | } |
777 | void CalendarView::setScrollBarStep(int val ) | 777 | void CalendarView::setScrollBarStep(int val ) |
778 | { | 778 | { |
779 | #ifdef DESKTOP_VERSION | 779 | #ifdef DESKTOP_VERSION |
780 | mDateScrollBar->setLineStep ( val ); | 780 | mDateScrollBar->setLineStep ( val ); |
781 | #endif | 781 | #endif |
782 | } | 782 | } |
783 | void CalendarView::scrollBarValue(int val ) | 783 | void CalendarView::scrollBarValue(int val ) |
784 | { | 784 | { |
785 | #ifdef DESKTOP_VERSION | 785 | #ifdef DESKTOP_VERSION |
786 | if ( QApplication::desktop()->width() < 800 ) return; | 786 | if ( QApplication::desktop()->width() < 800 ) return; |
787 | if ( flag_blockScrollBar ) return; | 787 | if ( flag_blockScrollBar ) return; |
788 | flag_blockScrollBar = true; | 788 | flag_blockScrollBar = true; |
789 | int count = mNavigator->selectedDates().count(); | 789 | int count = mNavigator->selectedDates().count(); |
790 | int day = mNavigator->selectedDates().first().dayOfYear(); | 790 | int day = mNavigator->selectedDates().first().dayOfYear(); |
791 | int stepdays = val; | 791 | int stepdays = val; |
792 | if ( mDateScrollBar->lineStep () <= count ) { | 792 | if ( mDateScrollBar->lineStep () <= count ) { |
793 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 793 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
794 | //qDebug("VAL %d ",val ); | 794 | //qDebug("VAL %d ",val ); |
795 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 795 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
796 | stepdays = day+stepdays; | 796 | stepdays = day+stepdays; |
797 | if ( stepdays < 0 ) stepdays = 0; | 797 | if ( stepdays < 0 ) stepdays = 0; |
798 | } | 798 | } |
799 | if ( stepdays == day ) { | 799 | if ( stepdays == day ) { |
800 | flag_blockScrollBar = false; | 800 | flag_blockScrollBar = false; |
801 | return; | 801 | return; |
802 | } | 802 | } |
803 | int year = mNavigator->selectedDates().first().year(); | 803 | int year = mNavigator->selectedDates().first().year(); |
804 | QDate d ( year,1,1 ); | 804 | QDate d ( year,1,1 ); |
805 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 805 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
806 | flag_blockScrollBar = false; | 806 | flag_blockScrollBar = false; |
807 | #endif | 807 | #endif |
808 | 808 | ||
809 | } | 809 | } |
810 | void CalendarView::updateView(const QDate &start, const QDate &end) | 810 | void CalendarView::updateView(const QDate &start, const QDate &end) |
811 | { | 811 | { |
812 | #ifdef DESKTOP_VERSION | 812 | #ifdef DESKTOP_VERSION |
813 | if ( ! mDateScrollBar->draggingSlider () ) { | 813 | if ( ! mDateScrollBar->draggingSlider () ) { |
814 | int dof = start.dayOfYear(); | 814 | int dof = start.dayOfYear(); |
815 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 815 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
816 | if ( dof != mDateScrollBar->value() ) { | 816 | if ( dof != mDateScrollBar->value() ) { |
817 | mDateScrollBar->blockSignals( true ); | 817 | mDateScrollBar->blockSignals( true ); |
818 | mDateScrollBar->setValue( start.dayOfYear()); | 818 | mDateScrollBar->setValue( start.dayOfYear()); |
819 | mDateScrollBar->blockSignals( false ); | 819 | mDateScrollBar->blockSignals( false ); |
820 | } | 820 | } |
821 | } | 821 | } |
822 | #endif | 822 | #endif |
823 | mTodoList->updateView(); | 823 | mTodoList->updateView(); |
824 | mViewManager->updateView(start, end); | 824 | mViewManager->updateView(start, end); |
825 | //mDateNavigator->updateView(); | 825 | //mDateNavigator->updateView(); |
826 | } | 826 | } |
827 | 827 | ||
828 | 828 | ||
829 | 829 | ||
830 | void CalendarView::checkFiles() | 830 | void CalendarView::checkFiles() |
831 | { | 831 | { |
832 | QString message; | 832 | QString message; |
833 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 833 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
834 | KopiCalendarFile * cal = calendars.first(); | 834 | KopiCalendarFile * cal = calendars.first(); |
835 | while ( cal ) { | 835 | while ( cal ) { |
836 | if ( cal->mErrorOnLoad ) { | 836 | if ( cal->mErrorOnLoad ) { |
837 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 837 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
838 | } | 838 | } |
839 | cal = calendars.next(); | 839 | cal = calendars.next(); |
840 | } | 840 | } |
841 | if ( !message.isEmpty() ) { | 841 | if ( !message.isEmpty() ) { |
842 | 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); | 842 | 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); |
843 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); | 843 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); |
844 | } | 844 | } |
845 | if ( flag_checkFileFirsttime ) { | 845 | if ( flag_checkFileFirsttime ) { |
846 | flag_checkFileFirsttime = false; | 846 | flag_checkFileFirsttime = false; |
847 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 847 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
848 | } | 848 | } |
849 | } | 849 | } |
850 | void CalendarView::checkAlarms() | 850 | void CalendarView::checkAlarms() |
851 | { | 851 | { |
852 | KConfig *config = KOGlobals::config(); | 852 | KConfig *config = KOGlobals::config(); |
853 | config->setGroup( "AppRun" ); | 853 | config->setGroup( "AppRun" ); |
854 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 854 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
855 | int daysto = dt.daysTo( QDate::currentDate() ); | 855 | int daysto = dt.daysTo( QDate::currentDate() ); |
856 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 856 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
857 | dt = dt.addDays( days ); | 857 | dt = dt.addDays( days ); |
858 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 858 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
859 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 859 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
860 | //qDebug("KO: Reading program stop %d ", secs); | 860 | //qDebug("KO: Reading program stop %d ", secs); |
861 | //secs -= ( 3600 * 24*3 ); // debug only | 861 | //secs -= ( 3600 * 24*3 ); // debug only |
862 | QDateTime latest = dt.addSecs ( secs ); | 862 | QDateTime latest = dt.addSecs ( secs ); |
863 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 863 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
864 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 864 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
865 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 865 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
866 | QPtrList<Incidence> al; | 866 | QPtrList<Incidence> al; |
867 | Incidence* inL = el.first(); | 867 | Incidence* inL = el.first(); |
868 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 868 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
869 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 869 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
870 | while ( inL ) { | 870 | while ( inL ) { |
871 | bool ok = false; | 871 | bool ok = false; |
872 | int offset = 0; | 872 | int offset = 0; |
873 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 873 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
874 | if ( ok ) { | 874 | if ( ok ) { |
875 | //qDebug("OK %s",next.toString().latin1()); | 875 | //qDebug("OK %s",next.toString().latin1()); |
876 | if ( next < cur ) { | 876 | if ( next < cur ) { |
877 | al.append( inL ); | 877 | al.append( inL ); |
878 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 878 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
879 | } | 879 | } |
880 | } | 880 | } |
881 | inL = el.next(); | 881 | inL = el.next(); |
882 | } | 882 | } |
883 | if ( al.count() ) { | 883 | if ( al.count() ) { |
884 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 884 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
885 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 885 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
886 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 886 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
887 | lay->setSpacing( 0 ); | 887 | lay->setSpacing( 0 ); |
888 | lay->setMargin( 0 ); | 888 | lay->setMargin( 0 ); |
889 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 889 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
890 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 890 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
891 | lay->addWidget( matb ); | 891 | lay->addWidget( matb ); |
892 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 892 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
893 | int wid = 210; | 893 | int wid = 210; |
894 | int x = QApplication::desktop()->width() - wid - 7; | 894 | int x = QApplication::desktop()->width() - wid - 7; |
895 | int y = QApplication::desktop()->height() - wid - 70; | 895 | int y = QApplication::desktop()->height() - wid - 70; |
896 | dia->setGeometry ( x,y,wid,wid); | 896 | dia->setGeometry ( x,y,wid,wid); |
897 | } else { | 897 | } else { |
898 | int si = 220; | 898 | int si = 220; |
899 | if ( QApplication::desktop()->width() > 470 ) | 899 | if ( QApplication::desktop()->width() > 470 ) |
900 | si = 400; | 900 | si = 400; |
901 | dia->resize(si,si/2); | 901 | dia->resize(si,si/2); |
902 | } | 902 | } |
903 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 903 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
904 | dia->show(); | 904 | dia->show(); |
905 | 905 | ||
906 | } | 906 | } |
907 | #if 0 | 907 | #if 0 |
908 | // for creating timetracker test data | 908 | // for creating timetracker test data |
909 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); | 909 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); |
910 | Todo * nt; | 910 | Todo * nt; |
911 | mCalendar->close(); | 911 | mCalendar->close(); |
912 | { | 912 | { |
913 | Todo * root1 = new Todo; | 913 | Todo * root1 = new Todo; |
914 | mCalendar->addTodo( root1 ); | 914 | mCalendar->addTodo( root1 ); |
915 | root1->setSummary( "Project1"); | 915 | root1->setSummary( "Project1"); |
916 | root1->setPriority( 1 ); | 916 | root1->setPriority( 1 ); |
917 | root1->setCategories( QString( "Cat_Pro1") ); | 917 | root1->setCategories( QString( "Cat_Pro1") ); |
918 | root1->setDescription( "This is a test description of a root Project" ); | 918 | root1->setDescription( "This is a test description of a root Project" ); |
919 | root1->setPercentComplete( 20 ); | 919 | root1->setPercentComplete( 20 ); |
920 | updateView(); | 920 | updateView(); |
921 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 921 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
922 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 922 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
923 | 923 | ||
924 | nt = new Todo; | 924 | nt = new Todo; |
925 | mCalendar->addTodo( nt ); | 925 | mCalendar->addTodo( nt ); |
926 | nt->setSummary( "Planning Project1"); | 926 | nt->setSummary( "Planning Project1"); |
927 | nt->setPriority( 1 ); | 927 | nt->setPriority( 1 ); |
928 | nt->setDescription( "This is a test description of Planning Project1" ); | 928 | nt->setDescription( "This is a test description of Planning Project1" ); |
929 | nt->setPercentComplete( 20 ); | 929 | nt->setPercentComplete( 20 ); |
930 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); | 930 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); |
931 | 931 | ||
932 | 932 | ||
933 | Todo * sub1 = nt; | 933 | Todo * sub1 = nt; |
934 | sub1->setRelatedTo( root1 ); | 934 | sub1->setRelatedTo( root1 ); |
935 | 935 | ||
936 | nt = new Todo; | 936 | nt = new Todo; |
937 | mCalendar->addTodo( nt ); | 937 | mCalendar->addTodo( nt ); |
938 | nt->setSummary( "Planning Project1: Lutz"); | 938 | nt->setSummary( "Planning Project1: Lutz"); |
939 | nt->setPriority( 1 ); | 939 | nt->setPriority( 1 ); |
940 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 940 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
941 | nt->setPercentComplete( 20 ); | 941 | nt->setPercentComplete( 20 ); |
942 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); | 942 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); |
943 | Todo * workLutz11 = nt; | 943 | Todo * workLutz11 = nt; |
944 | workLutz11->setRelatedTo( sub1 ); | 944 | workLutz11->setRelatedTo( sub1 ); |
945 | 945 | ||
946 | nt = new Todo; | 946 | nt = new Todo; |
947 | mCalendar->addTodo( nt ); | 947 | mCalendar->addTodo( nt ); |
948 | nt->setSummary( "Planning Project1: Norbert"); | 948 | nt->setSummary( "Planning Project1: Norbert"); |
949 | nt->setPriority( 1 ); | 949 | nt->setPriority( 1 ); |
950 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 950 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
951 | nt->setPercentComplete( 20 ); | 951 | nt->setPercentComplete( 20 ); |
952 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); | 952 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); |
953 | Todo * workNorbert11 = nt; | 953 | Todo * workNorbert11 = nt; |
954 | workNorbert11->setRelatedTo( sub1 ); | 954 | workNorbert11->setRelatedTo( sub1 ); |
955 | 955 | ||
956 | nt = new Todo; | 956 | nt = new Todo; |
957 | mCalendar->addTodo( nt ); | 957 | mCalendar->addTodo( nt ); |
958 | nt->setSummary( "Work on 1"); | 958 | nt->setSummary( "Work on 1"); |
959 | nt->setPriority( 1 ); | 959 | nt->setPriority( 1 ); |
960 | nt->setDescription( "This is a test description of Work Project_1" ); | 960 | nt->setDescription( "This is a test description of Work Project_1" ); |
961 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); | 961 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); |
962 | nt->setPercentComplete( 20 ); | 962 | nt->setPercentComplete( 20 ); |
963 | 963 | ||
964 | Todo * sub2 = nt; | 964 | Todo * sub2 = nt; |
965 | sub2->setRelatedTo( root1 ); | 965 | sub2->setRelatedTo( root1 ); |
966 | 966 | ||
967 | 967 | ||
968 | nt = new Todo; | 968 | nt = new Todo; |
969 | mCalendar->addTodo( nt ); | 969 | mCalendar->addTodo( nt ); |
970 | nt->setSummary( "Work on 1: Lutz"); | 970 | nt->setSummary( "Work on 1: Lutz"); |
971 | nt->setPriority( 1 ); | 971 | nt->setPriority( 1 ); |
972 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 972 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
973 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); | 973 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); |
974 | nt->setPercentComplete( 20 ); | 974 | nt->setPercentComplete( 20 ); |
975 | Todo * workLutz12 = nt; | 975 | Todo * workLutz12 = nt; |
976 | workLutz12->setRelatedTo( sub2 ); | 976 | workLutz12->setRelatedTo( sub2 ); |
977 | 977 | ||
978 | nt = new Todo; | 978 | nt = new Todo; |
979 | mCalendar->addTodo( nt ); | 979 | mCalendar->addTodo( nt ); |
980 | nt->setSummary( "Work on 1: Norbert"); | 980 | nt->setSummary( "Work on 1: Norbert"); |
981 | nt->setPriority( 1 ); | 981 | nt->setPriority( 1 ); |
982 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 982 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
983 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); | 983 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); |
984 | nt->setPercentComplete( 20 ); | 984 | nt->setPercentComplete( 20 ); |
985 | Todo * workNorbert12 = nt; | 985 | Todo * workNorbert12 = nt; |
986 | workNorbert12->setRelatedTo( sub2 ); | 986 | workNorbert12->setRelatedTo( sub2 ); |
987 | 987 | ||
988 | int secLenRunning = 7200; | 988 | int secLenRunning = 7200; |
989 | int secLenPausing = 3600 * 3; | 989 | int secLenPausing = 3600 * 3; |
990 | int dayInterval = 1; | 990 | int dayInterval = 1; |
991 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); | 991 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); |
992 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); | 992 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); |
993 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); | 993 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); |
994 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); | 994 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); |
995 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); | 995 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); |
996 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); | 996 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); |
997 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); | 997 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); |
998 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); | 998 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); |
999 | 999 | ||
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | { | 1002 | { |
1003 | Todo * root1 = new Todo; | 1003 | Todo * root1 = new Todo; |
1004 | mCalendar->addTodo( root1 ); | 1004 | mCalendar->addTodo( root1 ); |
1005 | root1->setSummary( "Project2"); | 1005 | root1->setSummary( "Project2"); |
1006 | root1->setPriority( 1 ); | 1006 | root1->setPriority( 1 ); |
1007 | root1->setDescription( "This is a test description of a root Project 2" ); | 1007 | root1->setDescription( "This is a test description of a root Project 2" ); |
1008 | root1->setPercentComplete( 20 ); | 1008 | root1->setPercentComplete( 20 ); |
1009 | root1->setCategories( QString( "Cat_Pro2") ); | 1009 | root1->setCategories( QString( "Cat_Pro2") ); |
1010 | updateView(); | 1010 | updateView(); |
1011 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 1011 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
1012 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 1012 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
1013 | int secLenRunning = 7200; | 1013 | int secLenRunning = 7200; |
1014 | int secLenPausing = 3600 * 3; | 1014 | int secLenPausing = 3600 * 3; |
1015 | int dayInterval = 1; | 1015 | int dayInterval = 1; |
1016 | 1016 | ||
1017 | nt = new Todo; | 1017 | nt = new Todo; |
1018 | mCalendar->addTodo( nt ); | 1018 | mCalendar->addTodo( nt ); |
1019 | nt->setSummary( "Planning Project2"); | 1019 | nt->setSummary( "Planning Project2"); |
1020 | nt->setPriority( 1 ); | 1020 | nt->setPriority( 1 ); |
1021 | nt->setDescription( "This is a test description of Planning_Project_2" ); | 1021 | nt->setDescription( "This is a test description of Planning_Project_2" ); |
1022 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); | 1022 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); |
1023 | nt->setPercentComplete( 20 ); | 1023 | nt->setPercentComplete( 20 ); |
1024 | 1024 | ||
1025 | 1025 | ||
1026 | Todo * sub1 = nt; | 1026 | Todo * sub1 = nt; |
1027 | sub1->setRelatedTo( root1 ); | 1027 | sub1->setRelatedTo( root1 ); |
1028 | 1028 | ||
1029 | nt = new Todo; | 1029 | nt = new Todo; |
1030 | mCalendar->addTodo( nt ); | 1030 | mCalendar->addTodo( nt ); |
1031 | nt->setSummary( "Planning Project2: Lutz"); | 1031 | nt->setSummary( "Planning Project2: Lutz"); |
1032 | nt->setPriority( 1 ); | 1032 | nt->setPriority( 1 ); |
1033 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1033 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1034 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); | 1034 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); |
1035 | nt->setPercentComplete( 20 ); | 1035 | nt->setPercentComplete( 20 ); |
1036 | Todo * workLutz11 = nt; | 1036 | Todo * workLutz11 = nt; |
1037 | workLutz11->setRelatedTo( sub1 ); | 1037 | workLutz11->setRelatedTo( sub1 ); |
1038 | 1038 | ||
1039 | nt = new Todo; | 1039 | nt = new Todo; |
1040 | mCalendar->addTodo( nt ); | 1040 | mCalendar->addTodo( nt ); |
1041 | nt->setSummary( "Planning Project2: Norbert"); | 1041 | nt->setSummary( "Planning Project2: Norbert"); |
1042 | nt->setPriority( 1 ); | 1042 | nt->setPriority( 1 ); |
1043 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1043 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1044 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); | 1044 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); |
1045 | nt->setPercentComplete( 20 ); | 1045 | nt->setPercentComplete( 20 ); |
1046 | Todo * workNorbert11 = nt; | 1046 | Todo * workNorbert11 = nt; |
1047 | workNorbert11->setRelatedTo( sub1 ); | 1047 | workNorbert11->setRelatedTo( sub1 ); |
1048 | 1048 | ||
1049 | nt = new Todo; | 1049 | nt = new Todo; |
1050 | mCalendar->addTodo( nt ); | 1050 | mCalendar->addTodo( nt ); |
1051 | nt->setSummary( "Work on 2"); | 1051 | nt->setSummary( "Work on 2"); |
1052 | nt->setPriority( 1 ); | 1052 | nt->setPriority( 1 ); |
1053 | nt->setDescription( "This is a test description of Work Project_2" ); | 1053 | nt->setDescription( "This is a test description of Work Project_2" ); |
1054 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); | 1054 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); |
1055 | nt->setPercentComplete( 20 ); | 1055 | nt->setPercentComplete( 20 ); |
1056 | 1056 | ||
1057 | Todo * sub2 = nt; | 1057 | Todo * sub2 = nt; |
1058 | sub2->setRelatedTo( root1 ); | 1058 | sub2->setRelatedTo( root1 ); |
1059 | 1059 | ||
1060 | 1060 | ||
1061 | nt = new Todo; | 1061 | nt = new Todo; |
1062 | mCalendar->addTodo( nt ); | 1062 | mCalendar->addTodo( nt ); |
1063 | nt->setSummary( "Work on 2: Lutz"); | 1063 | nt->setSummary( "Work on 2: Lutz"); |
1064 | nt->setPriority( 1 ); | 1064 | nt->setPriority( 1 ); |
1065 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1065 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1066 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); | 1066 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); |
1067 | nt->setPercentComplete( 20 ); | 1067 | nt->setPercentComplete( 20 ); |
1068 | Todo * workLutz12 = nt; | 1068 | Todo * workLutz12 = nt; |
1069 | workLutz12->setRelatedTo( sub2 ); | 1069 | workLutz12->setRelatedTo( sub2 ); |
1070 | 1070 | ||
1071 | nt = new Todo; | 1071 | nt = new Todo; |
1072 | mCalendar->addTodo( nt ); | 1072 | mCalendar->addTodo( nt ); |
1073 | nt->setSummary( "Work on 2: Norbert"); | 1073 | nt->setSummary( "Work on 2: Norbert"); |
1074 | nt->setPriority( 1 ); | 1074 | nt->setPriority( 1 ); |
1075 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1075 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1076 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); | 1076 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); |
1077 | nt->setPercentComplete( 20 ); | 1077 | nt->setPercentComplete( 20 ); |
1078 | Todo * workNorbert12 = nt; | 1078 | Todo * workNorbert12 = nt; |
1079 | workNorbert12->setRelatedTo( sub2 ); | 1079 | workNorbert12->setRelatedTo( sub2 ); |
1080 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); | 1080 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); |
1081 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); | 1081 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); |
1082 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); | 1082 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); |
1083 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); | 1083 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); |
1084 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); | 1084 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); |
1085 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); | 1085 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); |
1086 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); | 1086 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); |
1087 | } | 1087 | } |
1088 | updateView(); | 1088 | updateView(); |
1089 | #endif | 1089 | #endif |
1090 | 1090 | ||
1091 | } | 1091 | } |
1092 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) | 1092 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) |
1093 | { | 1093 | { |
1094 | static int ccc = 0; | 1094 | static int ccc = 0; |
1095 | ++ccc; | 1095 | ++ccc; |
1096 | QDateTime t_start = start; | 1096 | QDateTime t_start = start; |
1097 | runT->setPriority( 5 ); | 1097 | runT->setPriority( 5 ); |
1098 | runT->setPercentComplete( 0 ); | 1098 | runT->setPercentComplete( 0 ); |
1099 | int count = 0; | 1099 | int count = 0; |
1100 | int prio = 5; | 1100 | int prio = 5; |
1101 | int complete = 0; | 1101 | int complete = 0; |
1102 | while ( t_start < end ) { | 1102 | while ( t_start < end ) { |
1103 | ++count; | 1103 | ++count; |
1104 | if ( count > ccc ) { | 1104 | if ( count > ccc ) { |
1105 | count = 0; | 1105 | count = 0; |
1106 | --prio; | 1106 | --prio; |
1107 | if ( prio == 0 ) prio = 5; | 1107 | if ( prio == 0 ) prio = 5; |
1108 | complete += 20; | 1108 | complete += 20; |
1109 | if ( complete > 100 ) complete = 0; | 1109 | if ( complete > 100 ) complete = 0; |
1110 | runT->setPriority( prio ); | 1110 | runT->setPriority( prio ); |
1111 | runT->setPercentComplete( complete ); | 1111 | runT->setPercentComplete( complete ); |
1112 | } | 1112 | } |
1113 | runT->setRunning( true ); | 1113 | runT->setRunning( true ); |
1114 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); | 1114 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); |
1115 | if ( dayInterval ) | 1115 | if ( dayInterval ) |
1116 | t_start = t_start.addDays( dayInterval ); | 1116 | t_start = t_start.addDays( dayInterval ); |
1117 | else { | 1117 | else { |
1118 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); | 1118 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); |
1119 | } | 1119 | } |
1120 | } | 1120 | } |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | void CalendarView::showDay( QDate d ) | 1123 | void CalendarView::showDay( QDate d ) |
1124 | { | 1124 | { |
1125 | dateNavigator()->blockSignals( true ); | 1125 | dateNavigator()->blockSignals( true ); |
1126 | dateNavigator()->selectDate( d ); | 1126 | dateNavigator()->selectDate( d ); |
1127 | dateNavigator()->blockSignals( false ); | 1127 | dateNavigator()->blockSignals( false ); |
1128 | mViewManager->showDayView(); | 1128 | mViewManager->showDayView(); |
1129 | //dateNavigator()->selectDate( d ); | 1129 | //dateNavigator()->selectDate( d ); |
1130 | } | 1130 | } |
1131 | void CalendarView::timerAlarm() | 1131 | void CalendarView::timerAlarm() |
1132 | { | 1132 | { |
1133 | //qDebug("CalendarView::timerAlarm() "); | 1133 | //qDebug("CalendarView::timerAlarm() "); |
1134 | computeAlarm(mAlarmNotification ); | 1134 | computeAlarm(mAlarmNotification ); |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | void CalendarView::suspendAlarm() | 1137 | void CalendarView::suspendAlarm() |
1138 | { | 1138 | { |
1139 | //qDebug(" CalendarView::suspendAlarm() "); | 1139 | //qDebug(" CalendarView::suspendAlarm() "); |
1140 | computeAlarm(mSuspendAlarmNotification ); | 1140 | computeAlarm(mSuspendAlarmNotification ); |
1141 | 1141 | ||
1142 | } | 1142 | } |
1143 | 1143 | ||
1144 | void CalendarView::startAlarm( QString mess , QString filename) | 1144 | void CalendarView::startAlarm( QString mess , QString filename) |
1145 | { | 1145 | { |
1146 | 1146 | ||
1147 | topLevelWidget()->showNormal(); | 1147 | topLevelWidget()->showNormal(); |
1148 | topLevelWidget()->setActiveWindow(); | 1148 | topLevelWidget()->setActiveWindow(); |
1149 | topLevelWidget()->raise(); | 1149 | topLevelWidget()->raise(); |
1150 | 1150 | ||
1151 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 1151 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
1152 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 1152 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
1153 | 1153 | ||
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | void CalendarView::checkNextTimerAlarm() | 1156 | void CalendarView::checkNextTimerAlarm() |
1157 | { | 1157 | { |
1158 | mCalendar->checkAlarmForIncidence( 0, true ); | 1158 | mCalendar->checkAlarmForIncidence( 0, true ); |
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | void CalendarView::computeAlarm( QString msg ) | 1161 | void CalendarView::computeAlarm( QString msg ) |
1162 | { | 1162 | { |
1163 | 1163 | ||
1164 | QString mess = msg; | 1164 | QString mess = msg; |
1165 | QString mAlarmMessage = mess.mid( 9 ); | 1165 | QString mAlarmMessage = mess.mid( 9 ); |
1166 | QString filename = MainWindow::resourcePath(); | 1166 | QString filename = MainWindow::resourcePath(); |
1167 | filename += "koalarm.wav"; | 1167 | filename += "koalarm.wav"; |
1168 | QString tempfilename; | 1168 | QString tempfilename; |
1169 | if ( mess.left( 13 ) == "suspend_alarm") { | 1169 | if ( mess.left( 13 ) == "suspend_alarm") { |
1170 | bool error = false; | 1170 | bool error = false; |
1171 | int len = mess.mid( 13 ).find("+++"); | 1171 | int len = mess.mid( 13 ).find("+++"); |
1172 | if ( len < 2 ) | 1172 | if ( len < 2 ) |
1173 | error = true; | 1173 | error = true; |
1174 | else { | 1174 | else { |
1175 | tempfilename = mess.mid( 13, len ); | 1175 | tempfilename = mess.mid( 13, len ); |
1176 | if ( !QFile::exists( tempfilename ) ) | 1176 | if ( !QFile::exists( tempfilename ) ) |
1177 | error = true; | 1177 | error = true; |
1178 | } | 1178 | } |
1179 | if ( ! error ) { | 1179 | if ( ! error ) { |
1180 | filename = tempfilename; | 1180 | filename = tempfilename; |
1181 | } | 1181 | } |
1182 | mAlarmMessage = mess.mid( 13+len+3 ); | 1182 | mAlarmMessage = mess.mid( 13+len+3 ); |
1183 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 1183 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
1184 | startAlarm( mAlarmMessage, filename); | 1184 | startAlarm( mAlarmMessage, filename); |
1185 | return; | 1185 | return; |
1186 | } | 1186 | } |
1187 | if ( mess.left( 11 ) == "timer_alarm") { | 1187 | if ( mess.left( 11 ) == "timer_alarm") { |
1188 | //mTimerTime = 0; | 1188 | //mTimerTime = 0; |
1189 | startAlarm( mess.mid( 11 ), filename ); | 1189 | startAlarm( mess.mid( 11 ), filename ); |
1190 | return; | 1190 | return; |
1191 | } | 1191 | } |
1192 | if ( mess.left( 10 ) == "proc_alarm") { | 1192 | if ( mess.left( 10 ) == "proc_alarm") { |
1193 | bool error = false; | 1193 | bool error = false; |
1194 | int len = mess.mid( 10 ).find("+++"); | 1194 | int len = mess.mid( 10 ).find("+++"); |
1195 | if ( len < 2 ) | 1195 | if ( len < 2 ) |
1196 | error = true; | 1196 | error = true; |
1197 | else { | 1197 | else { |
1198 | tempfilename = mess.mid( 10, len ); | 1198 | tempfilename = mess.mid( 10, len ); |
1199 | if ( !QFile::exists( tempfilename ) ) | 1199 | if ( !QFile::exists( tempfilename ) ) |
1200 | error = true; | 1200 | error = true; |
1201 | } | 1201 | } |
1202 | if ( error ) { | 1202 | if ( error ) { |
1203 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 1203 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1204 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 1204 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1205 | } else { | 1205 | } else { |
1206 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 1206 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1207 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 1207 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1208 | #ifndef _WIN32_ | 1208 | #ifndef _WIN32_ |
1209 | if ( vfork () == 0 ) { | 1209 | if ( vfork () == 0 ) { |
1210 | execl ( tempfilename.latin1(), 0 ); | 1210 | execl ( tempfilename.latin1(), 0 ); |
1211 | return; | 1211 | return; |
1212 | } | 1212 | } |
1213 | #else | 1213 | #else |
1214 | QProcess* p = new QProcess(); | 1214 | QProcess* p = new QProcess(); |
1215 | p->addArgument( tempfilename.latin1() ); | 1215 | p->addArgument( tempfilename.latin1() ); |
1216 | p->start(); | 1216 | p->start(); |
1217 | return; | 1217 | return; |
1218 | #endif | 1218 | #endif |
1219 | 1219 | ||
1220 | return; | 1220 | return; |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1223 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1224 | } | 1224 | } |
1225 | if ( mess.left( 11 ) == "audio_alarm") { | 1225 | if ( mess.left( 11 ) == "audio_alarm") { |
1226 | bool error = false; | 1226 | bool error = false; |
1227 | int len = mess.mid( 11 ).find("+++"); | 1227 | int len = mess.mid( 11 ).find("+++"); |
1228 | if ( len < 2 ) | 1228 | if ( len < 2 ) |
1229 | error = true; | 1229 | error = true; |
1230 | else { | 1230 | else { |
1231 | tempfilename = mess.mid( 11, len ); | 1231 | tempfilename = mess.mid( 11, len ); |
1232 | if ( !QFile::exists( tempfilename ) ) | 1232 | if ( !QFile::exists( tempfilename ) ) |
1233 | error = true; | 1233 | error = true; |
1234 | } | 1234 | } |
1235 | if ( ! error ) { | 1235 | if ( ! error ) { |
1236 | filename = tempfilename; | 1236 | filename = tempfilename; |
1237 | } | 1237 | } |
1238 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1238 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1239 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1239 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1240 | } | 1240 | } |
1241 | if ( mess.left( 9 ) == "cal_alarm") { | 1241 | if ( mess.left( 9 ) == "cal_alarm") { |
1242 | mAlarmMessage = mess.mid( 9 ) ; | 1242 | mAlarmMessage = mess.mid( 9 ) ; |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | startAlarm( mAlarmMessage, filename ); | 1245 | startAlarm( mAlarmMessage, filename ); |
1246 | 1246 | ||
1247 | 1247 | ||
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1250 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1251 | { | 1251 | { |
1252 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1252 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1253 | 1253 | ||
1254 | mSuspendAlarmNotification = noti; | 1254 | mSuspendAlarmNotification = noti; |
1255 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1255 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1256 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1256 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1257 | mSuspendTimer->start( ms , true ); | 1257 | mSuspendTimer->start( ms , true ); |
1258 | #ifdef DESKTOP_VERSION | 1258 | #ifdef DESKTOP_VERSION |
1259 | if ( QApplication::desktop()->width() < 1024 ) { | 1259 | if ( QApplication::desktop()->width() < 1024 ) { |
1260 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1260 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1261 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); | 1261 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); |
1262 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; | 1262 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; |
1263 | QFile file( fn ); | 1263 | QFile file( fn ); |
1264 | if (!file.open( IO_WriteOnly ) ) { | 1264 | if (!file.open( IO_WriteOnly ) ) { |
1265 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1265 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1266 | } else { | 1266 | } else { |
1267 | QTextStream ts( &file ); | 1267 | QTextStream ts( &file ); |
1268 | ts << mess; | 1268 | ts << mess; |
1269 | file.close(); | 1269 | file.close(); |
1270 | } | 1270 | } |
1271 | } | 1271 | } |
1272 | #endif | 1272 | #endif |
1273 | 1273 | ||
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1276 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1277 | { | 1277 | { |
1278 | mNextAlarmDateTime = qdt; | 1278 | mNextAlarmDateTime = qdt; |
1279 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1279 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1280 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1280 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1281 | #ifndef DESKTOP_VERSION | 1281 | #ifndef DESKTOP_VERSION |
1282 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1282 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1283 | #endif | 1283 | #endif |
1284 | return; | 1284 | return; |
1285 | } | 1285 | } |
1286 | #ifdef DESKTOP_VERSION | 1286 | #ifdef DESKTOP_VERSION |
1287 | if ( QApplication::desktop()->width() < 1024 ) { | 1287 | if ( QApplication::desktop()->width() < 1024 ) { |
1288 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1288 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1289 | //qDebug("nextalarm = \n%s ",mess.latin1() ); | 1289 | //qDebug("nextalarm = \n%s ",mess.latin1() ); |
1290 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; | 1290 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; |
1291 | QFile file( fn ); | 1291 | QFile file( fn ); |
1292 | if (!file.open( IO_WriteOnly ) ) { | 1292 | if (!file.open( IO_WriteOnly ) ) { |
1293 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1293 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1294 | } else { | 1294 | } else { |
1295 | QTextStream ts( &file ); | 1295 | QTextStream ts( &file ); |
1296 | ts << mess; | 1296 | ts << mess; |
1297 | file.close(); | 1297 | file.close(); |
1298 | } | 1298 | } |
1299 | } | 1299 | } |
1300 | #endif | 1300 | #endif |
1301 | int maxSec; | 1301 | int maxSec; |
1302 | //maxSec = 5; //testing only | 1302 | //maxSec = 5; //testing only |
1303 | maxSec = 86400+3600; // one day+1hour | 1303 | maxSec = 86400+3600; // one day+1hour |
1304 | mAlarmNotification = noti; | 1304 | mAlarmNotification = noti; |
1305 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1305 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1306 | if ( sec > maxSec ) { | 1306 | if ( sec > maxSec ) { |
1307 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1307 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1308 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1308 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1309 | return; | 1309 | return; |
1310 | } else { | 1310 | } else { |
1311 | mRecheckAlarmTimer->stop(); | 1311 | mRecheckAlarmTimer->stop(); |
1312 | } | 1312 | } |
1313 | //qDebug("Alarm timer started with secs: %d ", sec); | 1313 | //qDebug("Alarm timer started with secs: %d ", sec); |
1314 | mAlarmTimer->start( sec * 1000 , true ); | 1314 | mAlarmTimer->start( sec * 1000 , true ); |
1315 | 1315 | ||
1316 | } | 1316 | } |
1317 | // called by mRecheckAlarmTimer to get next alarm | 1317 | // called by mRecheckAlarmTimer to get next alarm |
1318 | // we need this, because a QTimer has only a max range of 25 days | 1318 | // we need this, because a QTimer has only a max range of 25 days |
1319 | void CalendarView::recheckTimerAlarm() | 1319 | void CalendarView::recheckTimerAlarm() |
1320 | { | 1320 | { |
1321 | mAlarmTimer->stop(); | 1321 | mAlarmTimer->stop(); |
1322 | mRecheckAlarmTimer->stop(); | 1322 | mRecheckAlarmTimer->stop(); |
1323 | mCalendar->checkAlarmForIncidence( 0, true ); | 1323 | mCalendar->checkAlarmForIncidence( 0, true ); |
1324 | } | 1324 | } |
1325 | #ifndef DESKTOP_VERSION | 1325 | #ifndef DESKTOP_VERSION |
1326 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1326 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1327 | #else | 1327 | #else |
1328 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1328 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1329 | #endif | 1329 | #endif |
1330 | { | 1330 | { |
1331 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1331 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1332 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1332 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1333 | #ifndef DESKTOP_VERSION | 1333 | #ifndef DESKTOP_VERSION |
1334 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1334 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1335 | #endif | 1335 | #endif |
1336 | return; | 1336 | return; |
1337 | } | 1337 | } |
1338 | mAlarmTimer->stop(); | 1338 | mAlarmTimer->stop(); |
1339 | } | 1339 | } |
1340 | void CalendarView::selectWeekNum ( int num ) | 1340 | void CalendarView::selectWeekNum ( int num ) |
1341 | { | 1341 | { |
1342 | dateNavigator()->blockSignals( true ); | 1342 | dateNavigator()->blockSignals( true ); |
1343 | dateNavigator()->selectWeek( num ); | 1343 | dateNavigator()->selectWeek( num ); |
1344 | dateNavigator()->blockSignals( false ); | 1344 | dateNavigator()->blockSignals( false ); |
1345 | mViewManager->showWeekView(); | 1345 | mViewManager->showWeekView(); |
1346 | } | 1346 | } |
1347 | KOViewManager *CalendarView::viewManager() | 1347 | KOViewManager *CalendarView::viewManager() |
1348 | { | 1348 | { |
1349 | return mViewManager; | 1349 | return mViewManager; |
1350 | } | 1350 | } |
1351 | 1351 | ||
1352 | KODialogManager *CalendarView::dialogManager() | 1352 | KODialogManager *CalendarView::dialogManager() |
1353 | { | 1353 | { |
1354 | return mDialogManager; | 1354 | return mDialogManager; |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | QDate CalendarView::startDate() | 1357 | QDate CalendarView::startDate() |
1358 | { | 1358 | { |
1359 | DateList dates = mNavigator->selectedDates(); | 1359 | DateList dates = mNavigator->selectedDates(); |
1360 | 1360 | ||
1361 | return dates.first(); | 1361 | return dates.first(); |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | QDate CalendarView::endDate() | 1364 | QDate CalendarView::endDate() |
1365 | { | 1365 | { |
1366 | DateList dates = mNavigator->selectedDates(); | 1366 | DateList dates = mNavigator->selectedDates(); |
1367 | 1367 | ||
1368 | return dates.last(); | 1368 | return dates.last(); |
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | 1371 | ||
1372 | void CalendarView::createPrinter() | 1372 | void CalendarView::createPrinter() |
1373 | { | 1373 | { |
1374 | #ifndef KORG_NOPRINTER | 1374 | #ifndef KORG_NOPRINTER |
1375 | if (!mCalPrinter) { | 1375 | if (!mCalPrinter) { |
1376 | mCalPrinter = new CalPrinter(this, mCalendar); | 1376 | mCalPrinter = new CalPrinter(this, mCalendar); |
1377 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1377 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1378 | } | 1378 | } |
1379 | #endif | 1379 | #endif |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | 1382 | ||
1383 | //KOPrefs::instance()->mWriteBackFile | 1383 | //KOPrefs::instance()->mWriteBackFile |
1384 | //KOPrefs::instance()->mWriteBackExistingOnly | 1384 | //KOPrefs::instance()->mWriteBackExistingOnly |
1385 | 1385 | ||
1386 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1386 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1387 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1387 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1388 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1388 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1389 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1389 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1390 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1390 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1391 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1391 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1392 | 1392 | ||
1393 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1393 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1394 | { | 1394 | { |
1395 | 1395 | ||
1396 | // 0 equal | 1396 | // 0 equal |
1397 | // 1 take local | 1397 | // 1 take local |
1398 | // 2 take remote | 1398 | // 2 take remote |
1399 | // 3 cancel | 1399 | // 3 cancel |
1400 | QDateTime lastSync = mLastCalendarSync; | 1400 | QDateTime lastSync = mLastCalendarSync; |
1401 | QDateTime localMod = local->lastModified(); | 1401 | QDateTime localMod = local->lastModified(); |
1402 | QDateTime remoteMod = remote->lastModified(); | 1402 | QDateTime remoteMod = remote->lastModified(); |
1403 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1403 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1404 | bool remCh, locCh; | 1404 | bool remCh, locCh; |
1405 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1405 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1406 | //if ( remCh ) | 1406 | //if ( remCh ) |
1407 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1407 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1408 | locCh = ( localMod > mLastCalendarSync ); | 1408 | locCh = ( localMod > mLastCalendarSync ); |
1409 | if ( !remCh && ! locCh ) { | 1409 | if ( !remCh && ! locCh ) { |
1410 | //qDebug("both not changed "); | 1410 | //qDebug("both not changed "); |
1411 | lastSync = localMod.addDays(1); | 1411 | lastSync = localMod.addDays(1); |
1412 | if ( mode <= SYNC_PREF_ASK ) | 1412 | if ( mode <= SYNC_PREF_ASK ) |
1413 | return 0; | 1413 | return 0; |
1414 | } else { | 1414 | } else { |
1415 | if ( locCh ) { | 1415 | if ( locCh ) { |
1416 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1416 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1417 | lastSync = localMod.addDays( -1 ); | 1417 | lastSync = localMod.addDays( -1 ); |
1418 | if ( !remCh ) | 1418 | if ( !remCh ) |
1419 | remoteMod = ( lastSync.addDays( -1 ) ); | 1419 | remoteMod = ( lastSync.addDays( -1 ) ); |
1420 | } else { | 1420 | } else { |
1421 | //qDebug(" not loc changed "); | 1421 | //qDebug(" not loc changed "); |
1422 | lastSync = localMod.addDays( 1 ); | 1422 | lastSync = localMod.addDays( 1 ); |
1423 | if ( remCh ) | 1423 | if ( remCh ) |
1424 | remoteMod =( lastSync.addDays( 1 ) ); | 1424 | remoteMod =( lastSync.addDays( 1 ) ); |
1425 | 1425 | ||
1426 | } | 1426 | } |
1427 | } | 1427 | } |
1428 | full = true; | 1428 | full = true; |
1429 | if ( mode < SYNC_PREF_ASK ) | 1429 | if ( mode < SYNC_PREF_ASK ) |
1430 | mode = SYNC_PREF_ASK; | 1430 | mode = SYNC_PREF_ASK; |
1431 | } else { | 1431 | } else { |
1432 | if ( localMod == remoteMod ) | 1432 | if ( localMod == remoteMod ) |
1433 | // if ( local->revision() == remote->revision() ) | 1433 | // if ( local->revision() == remote->revision() ) |
1434 | return 0; | 1434 | return 0; |
1435 | 1435 | ||
1436 | } | 1436 | } |
1437 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1437 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1438 | 1438 | ||
1439 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1439 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1440 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1440 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1441 | //full = true; //debug only | 1441 | //full = true; //debug only |
1442 | if ( full ) { | 1442 | if ( full ) { |
1443 | bool equ = false; | 1443 | bool equ = false; |
1444 | if ( local->typeID() == eventID ) { | 1444 | if ( local->typeID() == eventID ) { |
1445 | equ = (*((Event*) local) == *((Event*) remote)); | 1445 | equ = (*((Event*) local) == *((Event*) remote)); |
1446 | } | 1446 | } |
1447 | else if ( local->typeID() == todoID ) | 1447 | else if ( local->typeID() == todoID ) |
1448 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1448 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1449 | else if ( local->typeID() == journalID ) | 1449 | else if ( local->typeID() == journalID ) |
1450 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1450 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1451 | if ( equ ) { | 1451 | if ( equ ) { |
1452 | //qDebug("equal "); | 1452 | //qDebug("equal "); |
1453 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1453 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1454 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1454 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1455 | } | 1455 | } |
1456 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1456 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1457 | return 0; | 1457 | return 0; |
1458 | 1458 | ||
1459 | }//else //debug only | 1459 | }//else //debug only |
1460 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1460 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1461 | } | 1461 | } |
1462 | int result; | 1462 | int result; |
1463 | bool localIsNew; | 1463 | bool localIsNew; |
1464 | //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() ); | 1464 | //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() ); |
1465 | 1465 | ||
1466 | 1466 | ||
1467 | // ************************************************ | 1467 | // ************************************************ |
1468 | // ************************************************ | 1468 | // ************************************************ |
1469 | // ************************************************ | 1469 | // ************************************************ |
1470 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1470 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1471 | // BUT remoteMod != localMod | 1471 | // BUT remoteMod != localMod |
1472 | 1472 | ||
1473 | 1473 | ||
1474 | if ( full && mode < SYNC_PREF_NEWEST ) | 1474 | if ( full && mode < SYNC_PREF_NEWEST ) |
1475 | mode = SYNC_PREF_ASK; | 1475 | mode = SYNC_PREF_ASK; |
1476 | 1476 | ||
1477 | switch( mode ) { | 1477 | switch( mode ) { |
1478 | case SYNC_PREF_LOCAL: | 1478 | case SYNC_PREF_LOCAL: |
1479 | if ( lastSync > remoteMod ) | 1479 | if ( lastSync > remoteMod ) |
1480 | return 1; | 1480 | return 1; |
1481 | if ( lastSync > localMod ) | 1481 | if ( lastSync > localMod ) |
1482 | return 2; | 1482 | return 2; |
1483 | return 1; | 1483 | return 1; |
1484 | break; | 1484 | break; |
1485 | case SYNC_PREF_REMOTE: | 1485 | case SYNC_PREF_REMOTE: |
1486 | if ( lastSync > localMod ) | 1486 | if ( lastSync > localMod ) |
1487 | return 2; | 1487 | return 2; |
1488 | if ( lastSync > remoteMod ) | 1488 | if ( lastSync > remoteMod ) |
1489 | return 1; | 1489 | return 1; |
1490 | return 2; | 1490 | return 2; |
1491 | break; | 1491 | break; |
1492 | case SYNC_PREF_NEWEST: | 1492 | case SYNC_PREF_NEWEST: |
1493 | if ( localMod >= remoteMod ) | 1493 | if ( localMod >= remoteMod ) |
1494 | return 1; | 1494 | return 1; |
1495 | else | 1495 | else |
1496 | return 2; | 1496 | return 2; |
1497 | break; | 1497 | break; |
1498 | case SYNC_PREF_ASK: | 1498 | case SYNC_PREF_ASK: |
1499 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1499 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1500 | if ( lastSync > remoteMod && lastSync > localMod) | 1500 | if ( lastSync > remoteMod && lastSync > localMod) |
1501 | return 0; | 1501 | return 0; |
1502 | if ( lastSync > remoteMod ) | 1502 | if ( lastSync > remoteMod ) |
1503 | return 1; | 1503 | return 1; |
1504 | if ( lastSync > localMod ) | 1504 | if ( lastSync > localMod ) |
1505 | return 2; | 1505 | return 2; |
1506 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1506 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1507 | localIsNew = localMod >= remoteMod; | 1507 | localIsNew = localMod >= remoteMod; |
1508 | if ( localIsNew ) | 1508 | if ( localIsNew ) |
1509 | getEventViewerDialog()->setColorMode( 1 ); | 1509 | getEventViewerDialog()->setColorMode( 1 ); |
1510 | else | 1510 | else |
1511 | getEventViewerDialog()->setColorMode( 2 ); | 1511 | getEventViewerDialog()->setColorMode( 2 ); |
1512 | getEventViewerDialog()->setIncidence(local); | 1512 | getEventViewerDialog()->setIncidence(local); |
1513 | if ( localIsNew ) | 1513 | if ( localIsNew ) |
1514 | getEventViewerDialog()->setColorMode( 2 ); | 1514 | getEventViewerDialog()->setColorMode( 2 ); |
1515 | else | 1515 | else |
1516 | getEventViewerDialog()->setColorMode( 1 ); | 1516 | getEventViewerDialog()->setColorMode( 1 ); |
1517 | getEventViewerDialog()->addIncidence(remote); | 1517 | getEventViewerDialog()->addIncidence(remote); |
1518 | getEventViewerDialog()->setColorMode( 0 ); | 1518 | getEventViewerDialog()->setColorMode( 0 ); |
1519 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1519 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1520 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1520 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1521 | getEventViewerDialog()->showMe(); | 1521 | getEventViewerDialog()->showMe(); |
1522 | result = getEventViewerDialog()->executeS( localIsNew ); | 1522 | result = getEventViewerDialog()->executeS( localIsNew ); |
1523 | return result; | 1523 | return result; |
1524 | 1524 | ||
1525 | break; | 1525 | break; |
1526 | case SYNC_PREF_FORCE_LOCAL: | 1526 | case SYNC_PREF_FORCE_LOCAL: |
1527 | return 1; | 1527 | return 1; |
1528 | break; | 1528 | break; |
1529 | case SYNC_PREF_FORCE_REMOTE: | 1529 | case SYNC_PREF_FORCE_REMOTE: |
1530 | return 2; | 1530 | return 2; |
1531 | break; | 1531 | break; |
1532 | 1532 | ||
1533 | default: | 1533 | default: |
1534 | // SYNC_PREF_TAKE_BOTH not implemented | 1534 | // SYNC_PREF_TAKE_BOTH not implemented |
1535 | break; | 1535 | break; |
1536 | } | 1536 | } |
1537 | return 0; | 1537 | return 0; |
1538 | } | 1538 | } |
1539 | Event* CalendarView::getLastSyncEvent() | 1539 | Event* CalendarView::getLastSyncEvent() |
1540 | { | 1540 | { |
1541 | Event* lse; | 1541 | Event* lse; |
1542 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1542 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1543 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1543 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1544 | if (!lse) { | 1544 | if (!lse) { |
1545 | lse = new Event(); | 1545 | lse = new Event(); |
1546 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1546 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1547 | QString sum = ""; | 1547 | QString sum = ""; |
1548 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1548 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1549 | sum = "E: "; | 1549 | sum = "E: "; |
1550 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1550 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1551 | lse->setDtStart( mLastCalendarSync ); | 1551 | lse->setDtStart( mLastCalendarSync ); |
1552 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1552 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1553 | lse->setCategories( i18n("SyncEvent") ); | 1553 | lse->setCategories( i18n("SyncEvent") ); |
1554 | lse->setReadOnly( true ); | 1554 | lse->setReadOnly( true ); |
1555 | mCalendar->addEvent( lse ); | 1555 | mCalendar->addEvent( lse ); |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | return lse; | 1558 | return lse; |
1559 | 1559 | ||
1560 | } | 1560 | } |
1561 | 1561 | ||
1562 | // we check, if the to delete event has a id for a profile | 1562 | // we check, if the to delete event has a id for a profile |
1563 | // if yes, we set this id in the profile to delete | 1563 | // if yes, we set this id in the profile to delete |
1564 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1564 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1565 | { | 1565 | { |
1566 | if ( lastSync.count() == 0 ) { | 1566 | if ( lastSync.count() == 0 ) { |
1567 | //qDebug(" lastSync.count() == 0"); | 1567 | //qDebug(" lastSync.count() == 0"); |
1568 | return; | 1568 | return; |
1569 | } | 1569 | } |
1570 | if ( toDelete->typeID() == journalID ) | 1570 | if ( toDelete->typeID() == journalID ) |
1571 | return; | 1571 | return; |
1572 | 1572 | ||
1573 | Event* eve = lastSync.first(); | 1573 | Event* eve = lastSync.first(); |
1574 | 1574 | ||
1575 | while ( eve ) { | 1575 | while ( eve ) { |
1576 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1576 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1577 | if ( !id.isEmpty() ) { | 1577 | if ( !id.isEmpty() ) { |
1578 | QString des = eve->description(); | 1578 | QString des = eve->description(); |
1579 | QString pref = "e"; | 1579 | QString pref = "e"; |
1580 | if ( toDelete->typeID() == todoID ) | 1580 | if ( toDelete->typeID() == todoID ) |
1581 | pref = "t"; | 1581 | pref = "t"; |
1582 | des += pref+ id + ","; | 1582 | des += pref+ id + ","; |
1583 | eve->setReadOnly( false ); | 1583 | eve->setReadOnly( false ); |
1584 | eve->setDescription( des ); | 1584 | eve->setDescription( des ); |
1585 | //qDebug("setdes %s ", des.latin1()); | 1585 | //qDebug("setdes %s ", des.latin1()); |
1586 | eve->setReadOnly( true ); | 1586 | eve->setReadOnly( true ); |
1587 | } | 1587 | } |
1588 | eve = lastSync.next(); | 1588 | eve = lastSync.next(); |
1589 | } | 1589 | } |
1590 | 1590 | ||
1591 | } | 1591 | } |
1592 | void CalendarView::checkExternalId( Incidence * inc ) | 1592 | void CalendarView::checkExternalId( Incidence * inc ) |
1593 | { | 1593 | { |
1594 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1594 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1595 | checkExternSyncEvent( lastSync, inc ); | 1595 | checkExternSyncEvent( lastSync, inc ); |
1596 | 1596 | ||
1597 | } | 1597 | } |
1598 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1598 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1599 | { | 1599 | { |
1600 | bool syncOK = true; | 1600 | bool syncOK = true; |
1601 | int addedEvent = 0; | 1601 | int addedEvent = 0; |
1602 | int addedEventR = 0; | 1602 | int addedEventR = 0; |
1603 | int deletedEventR = 0; | 1603 | int deletedEventR = 0; |
1604 | int deletedEventL = 0; | 1604 | int deletedEventL = 0; |
1605 | int changedLocal = 0; | 1605 | int changedLocal = 0; |
1606 | int changedRemote = 0; | 1606 | int changedRemote = 0; |
1607 | int filteredIN = 0; | 1607 | int filteredIN = 0; |
1608 | int filteredOUT = 0; | 1608 | int filteredOUT = 0; |
1609 | //QPtrList<Event> el = local->rawEvents(); | 1609 | //QPtrList<Event> el = local->rawEvents(); |
1610 | Event* eventR; | 1610 | Event* eventR; |
1611 | QString uid; | 1611 | QString uid; |
1612 | int take; | 1612 | int take; |
1613 | Event* eventRSync; | 1613 | Event* eventRSync; |
1614 | Event* eventLSync; | 1614 | Event* eventLSync; |
1615 | clearAllViews(); | 1615 | clearAllViews(); |
1616 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1616 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1617 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1617 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1618 | bool fullDateRange = false; | 1618 | bool fullDateRange = false; |
1619 | local->resetTempSyncStat(); | 1619 | local->resetTempSyncStat(); |
1620 | mLastCalendarSync = QDateTime::currentDateTime(); | 1620 | mLastCalendarSync = QDateTime::currentDateTime(); |
1621 | if ( mSyncManager->syncWithDesktop() ) { | 1621 | if ( mSyncManager->syncWithDesktop() ) { |
1622 | remote->resetPilotStat(1); | 1622 | remote->resetPilotStat(1); |
1623 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1623 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1624 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1624 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1625 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1625 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1626 | } else { | 1626 | } else { |
1627 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1627 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1628 | } | 1628 | } |
1629 | } | 1629 | } |
1630 | QDateTime modifiedCalendar = mLastCalendarSync; | 1630 | QDateTime modifiedCalendar = mLastCalendarSync; |
1631 | eventLSync = getLastSyncEvent(); | 1631 | eventLSync = getLastSyncEvent(); |
1632 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1632 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1633 | if ( eventR ) { | 1633 | if ( eventR ) { |
1634 | qDebug("last-syncEvent on remote found "); | 1634 | qDebug("last-syncEvent on remote found "); |
1635 | eventRSync = (Event*) eventR->clone(); | 1635 | eventRSync = (Event*) eventR->clone(); |
1636 | remote->deleteEvent(eventR ); | 1636 | remote->deleteEvent(eventR ); |
1637 | 1637 | ||
1638 | } else { | 1638 | } else { |
1639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1640 | eventRSync = (Event*)eventLSync->clone(); | 1640 | eventRSync = (Event*)eventLSync->clone(); |
1641 | } else { | 1641 | } else { |
1642 | fullDateRange = true; | 1642 | fullDateRange = true; |
1643 | eventRSync = new Event(); | 1643 | eventRSync = new Event(); |
1644 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1644 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1645 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1645 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1646 | eventRSync->setDtStart( mLastCalendarSync ); | 1646 | eventRSync->setDtStart( mLastCalendarSync ); |
1647 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1647 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1648 | eventRSync->setCategories( i18n("SyncEvent") ); | 1648 | eventRSync->setCategories( i18n("SyncEvent") ); |
1649 | } | 1649 | } |
1650 | } | 1650 | } |
1651 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1651 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1652 | fullDateRange = true; | 1652 | fullDateRange = true; |
1653 | 1653 | ||
1654 | if ( ! fullDateRange ) { | 1654 | if ( ! fullDateRange ) { |
1655 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1655 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1656 | 1656 | ||
1657 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1657 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1658 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1658 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1659 | fullDateRange = true; | 1659 | fullDateRange = true; |
1660 | } | 1660 | } |
1661 | } | 1661 | } |
1662 | if ( mSyncManager->syncWithDesktop() ) { | 1662 | if ( mSyncManager->syncWithDesktop() ) { |
1663 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1663 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1664 | } | 1664 | } |
1665 | if ( fullDateRange ) | 1665 | if ( fullDateRange ) |
1666 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1666 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1667 | else | 1667 | else |
1668 | mLastCalendarSync = eventLSync->dtStart(); | 1668 | mLastCalendarSync = eventLSync->dtStart(); |
1669 | // for resyncing if own file has changed | 1669 | // for resyncing if own file has changed |
1670 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1670 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1671 | mLastCalendarSync = loadedFileVersion; | 1671 | mLastCalendarSync = loadedFileVersion; |
1672 | //qDebug("setting mLastCalendarSync "); | 1672 | //qDebug("setting mLastCalendarSync "); |
1673 | } | 1673 | } |
1674 | //qDebug("*************************** "); | 1674 | //qDebug("*************************** "); |
1675 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1675 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1676 | QPtrList<Incidence> er = remote->rawIncidences(); | 1676 | QPtrList<Incidence> er = remote->rawIncidences(); |
1677 | Incidence* inR = er.first(); | 1677 | Incidence* inR = er.first(); |
1678 | Incidence* inL; | 1678 | Incidence* inL; |
1679 | QProgressBar bar( er.count(),0 ); | 1679 | QProgressBar bar( er.count(),0 ); |
1680 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1680 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1681 | 1681 | ||
1682 | // ************** setting up filter ************* | 1682 | // ************** setting up filter ************* |
1683 | CalFilter *filterIN = 0; | 1683 | CalFilter *filterIN = 0; |
1684 | CalFilter *filterOUT = 0; | 1684 | CalFilter *filterOUT = 0; |
1685 | CalFilter *filter = mFilters.first(); | 1685 | CalFilter *filter = mFilters.first(); |
1686 | while(filter) { | 1686 | while(filter) { |
1687 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1687 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1688 | filterIN = filter; | 1688 | filterIN = filter; |
1689 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1689 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1690 | filterOUT = filter; | 1690 | filterOUT = filter; |
1691 | filter = mFilters.next(); | 1691 | filter = mFilters.next(); |
1692 | } | 1692 | } |
1693 | int w = 300; | 1693 | int w = 300; |
1694 | if ( QApplication::desktop()->width() < 320 ) | 1694 | if ( QApplication::desktop()->width() < 320 ) |
1695 | w = 220; | 1695 | w = 220; |
1696 | int h = bar.sizeHint().height() ; | 1696 | int h = bar.sizeHint().height() ; |
1697 | int dw = QApplication::desktop()->width(); | 1697 | int dw = QApplication::desktop()->width(); |
1698 | int dh = QApplication::desktop()->height(); | 1698 | int dh = QApplication::desktop()->height(); |
1699 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1699 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1700 | bar.show(); | 1700 | bar.show(); |
1701 | int modulo = (er.count()/10)+1; | 1701 | int modulo = (er.count()/10)+1; |
1702 | int incCounter = 0; | 1702 | int incCounter = 0; |
1703 | while ( inR ) { | 1703 | while ( inR ) { |
1704 | if ( ! bar.isVisible() ) | 1704 | if ( ! bar.isVisible() ) |
1705 | return false; | 1705 | return false; |
1706 | if ( incCounter % modulo == 0 ) | 1706 | if ( incCounter % modulo == 0 ) |
1707 | bar.setProgress( incCounter ); | 1707 | bar.setProgress( incCounter ); |
1708 | ++incCounter; | 1708 | ++incCounter; |
1709 | uid = inR->uid(); | 1709 | uid = inR->uid(); |
1710 | bool skipIncidence = false; | 1710 | bool skipIncidence = false; |
1711 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1711 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1712 | skipIncidence = true; | 1712 | skipIncidence = true; |
1713 | QString idS; | 1713 | QString idS; |
1714 | qApp->processEvents(); | 1714 | qApp->processEvents(); |
1715 | if ( !skipIncidence ) { | 1715 | if ( !skipIncidence ) { |
1716 | inL = local->incidenceForUid( uid , false ); | 1716 | inL = local->incidenceForUid( uid , false ); |
1717 | if ( inL ) { // maybe conflict - same uid in both calendars | 1717 | if ( inL ) { // maybe conflict - same uid in both calendars |
1718 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1718 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1719 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1719 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1720 | if ( take == 3 ) | 1720 | if ( take == 3 ) |
1721 | return false; | 1721 | return false; |
1722 | if ( take == 1 ) {// take local ********************** | 1722 | if ( take == 1 ) {// take local ********************** |
1723 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1723 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1724 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1724 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1725 | else | 1725 | else |
1726 | idS = inR->IDStr(); | 1726 | idS = inR->IDStr(); |
1727 | int calID = inR->calID(); | 1727 | int calID = inR->calID(); |
1728 | remote->deleteIncidence( inR ); | 1728 | remote->deleteIncidence( inR ); |
1729 | inR = inL->clone(); | 1729 | inR = inL->clone(); |
1730 | inR->setCalID( calID ); | 1730 | inR->setCalID( calID ); |
1731 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1731 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1732 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1732 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1733 | inR->setIDStr( idS ); | 1733 | inR->setIDStr( idS ); |
1734 | remote->addIncidence( inR ); | 1734 | remote->addIncidence( inR ); |
1735 | if ( mSyncManager->syncWithDesktop() ) | 1735 | if ( mSyncManager->syncWithDesktop() ) |
1736 | inR->setPilotId( 2 ); | 1736 | inR->setPilotId( 2 ); |
1737 | ++changedRemote; | 1737 | ++changedRemote; |
1738 | } else {// take remote ********************** | 1738 | } else {// take remote ********************** |
1739 | if ( !inL->isReadOnly() ) { | 1739 | if ( !inL->isReadOnly() ) { |
1740 | idS = inL->IDStr(); | 1740 | idS = inL->IDStr(); |
1741 | int pid = inL->pilotId(); | 1741 | int pid = inL->pilotId(); |
1742 | int calID = inL->calID(); | 1742 | int calID = inL->calID(); |
1743 | local->deleteIncidence( inL ); | 1743 | local->deleteIncidence( inL ); |
1744 | inL = inR->clone(); | 1744 | inL = inR->clone(); |
1745 | inL->setCalID( calID ); | 1745 | inL->setCalID( calID ); |
1746 | if ( mSyncManager->syncWithDesktop() ) | 1746 | if ( mSyncManager->syncWithDesktop() ) |
1747 | inL->setPilotId( pid ); | 1747 | inL->setPilotId( pid ); |
1748 | inL->setIDStr( idS ); | 1748 | inL->setIDStr( idS ); |
1749 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1749 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1750 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1750 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1751 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1751 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1752 | } | 1752 | } |
1753 | local->addIncidence( inL ); | 1753 | local->addIncidence( inL ); |
1754 | ++changedLocal; | 1754 | ++changedLocal; |
1755 | } | 1755 | } |
1756 | } | 1756 | } |
1757 | } | 1757 | } |
1758 | } else { // no conflict ********** add or delete remote | 1758 | } else { // no conflict ********** add or delete remote |
1759 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1759 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1760 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1760 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1761 | QString des = eventLSync->description(); | 1761 | QString des = eventLSync->description(); |
1762 | QString pref = "e"; | 1762 | QString pref = "e"; |
1763 | if ( inR->typeID() == todoID ) | 1763 | if ( inR->typeID() == todoID ) |
1764 | pref = "t"; | 1764 | pref = "t"; |
1765 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1765 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1766 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1766 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1767 | //remote->deleteIncidence( inR ); | 1767 | //remote->deleteIncidence( inR ); |
1768 | ++deletedEventR; | 1768 | ++deletedEventR; |
1769 | } else { | 1769 | } else { |
1770 | inR->setLastModified( modifiedCalendar ); | 1770 | inR->setLastModified( modifiedCalendar ); |
1771 | inL = inR->clone(); | 1771 | inL = inR->clone(); |
1772 | inL->setIDStr( ":" ); | 1772 | inL->setIDStr( ":" ); |
1773 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1773 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1774 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1774 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1775 | 1775 | ||
1776 | inL->setCalID( 0 );// add to default cal | 1776 | inL->setCalID( 0 );// add to default cal |
1777 | local->addIncidence( inL ); | 1777 | local->addIncidence( inL ); |
1778 | ++addedEvent; | 1778 | ++addedEvent; |
1779 | 1779 | ||
1780 | } | 1780 | } |
1781 | } else { | 1781 | } else { |
1782 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1782 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1783 | inR->setLastModified( modifiedCalendar ); | 1783 | inR->setLastModified( modifiedCalendar ); |
1784 | inL = inR->clone(); | 1784 | inL = inR->clone(); |
1785 | inL->setIDStr( ":" ); | 1785 | inL->setIDStr( ":" ); |
1786 | inL->setCalID( 0 );// add to default cal | 1786 | inL->setCalID( 0 );// add to default cal |
1787 | local->addIncidence( inL ); | 1787 | local->addIncidence( inL ); |
1788 | ++addedEvent; | 1788 | ++addedEvent; |
1789 | 1789 | ||
1790 | } else { | 1790 | } else { |
1791 | checkExternSyncEvent(eventRSyncSharp, inR); | 1791 | checkExternSyncEvent(eventRSyncSharp, inR); |
1792 | remote->deleteIncidence( inR ); | 1792 | remote->deleteIncidence( inR ); |
1793 | ++deletedEventR; | 1793 | ++deletedEventR; |
1794 | } | 1794 | } |
1795 | } | 1795 | } |
1796 | } else { | 1796 | } else { |
1797 | ++filteredIN; | 1797 | ++filteredIN; |
1798 | } | 1798 | } |
1799 | } | 1799 | } |
1800 | } | 1800 | } |
1801 | inR = er.next(); | 1801 | inR = er.next(); |
1802 | } | 1802 | } |
1803 | QPtrList<Incidence> el = local->rawIncidences(); | 1803 | QPtrList<Incidence> el = local->rawIncidences(); |
1804 | inL = el.first(); | 1804 | inL = el.first(); |
1805 | modulo = (el.count()/10)+1; | 1805 | modulo = (el.count()/10)+1; |
1806 | bar.setCaption (i18n("Add / remove events") ); | 1806 | bar.setCaption (i18n("Add / remove events") ); |
1807 | bar.setTotalSteps ( el.count() ) ; | 1807 | bar.setTotalSteps ( el.count() ) ; |
1808 | bar.show(); | 1808 | bar.show(); |
1809 | incCounter = 0; | 1809 | incCounter = 0; |
1810 | 1810 | ||
1811 | while ( inL ) { | 1811 | while ( inL ) { |
1812 | 1812 | ||
1813 | qApp->processEvents(); | 1813 | qApp->processEvents(); |
1814 | if ( ! bar.isVisible() ) | 1814 | if ( ! bar.isVisible() ) |
1815 | return false; | 1815 | return false; |
1816 | if ( incCounter % modulo == 0 ) | 1816 | if ( incCounter % modulo == 0 ) |
1817 | bar.setProgress( incCounter ); | 1817 | bar.setProgress( incCounter ); |
1818 | ++incCounter; | 1818 | ++incCounter; |
1819 | uid = inL->uid(); | 1819 | uid = inL->uid(); |
1820 | bool skipIncidence = false; | 1820 | bool skipIncidence = false; |
1821 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1821 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1822 | skipIncidence = true; | 1822 | skipIncidence = true; |
1823 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1823 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1824 | skipIncidence = true; | 1824 | skipIncidence = true; |
1825 | if ( !skipIncidence ) { | 1825 | if ( !skipIncidence ) { |
1826 | inR = remote->incidenceForUid( uid , true ); | 1826 | inR = remote->incidenceForUid( uid , true ); |
1827 | if ( ! inR ) { | 1827 | if ( ! inR ) { |
1828 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1828 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1829 | // no conflict ********** add or delete local | 1829 | // no conflict ********** add or delete local |
1830 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1830 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1831 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1831 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1832 | checkExternSyncEvent(eventLSyncSharp, inL); | 1832 | checkExternSyncEvent(eventLSyncSharp, inL); |
1833 | local->deleteIncidence( inL ); | 1833 | local->deleteIncidence( inL ); |
1834 | ++deletedEventL; | 1834 | ++deletedEventL; |
1835 | } else { | 1835 | } else { |
1836 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1836 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1837 | inL->removeID(mCurrentSyncDevice ); | 1837 | inL->removeID(mCurrentSyncDevice ); |
1838 | ++addedEventR; | 1838 | ++addedEventR; |
1839 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1839 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1840 | inL->setLastModified( modifiedCalendar ); | 1840 | inL->setLastModified( modifiedCalendar ); |
1841 | inR = inL->clone(); | 1841 | inR = inL->clone(); |
1842 | inR->setIDStr( ":" ); | 1842 | inR->setIDStr( ":" ); |
1843 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1843 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1844 | inR->setCalID( 0 );// add to default cal | 1844 | inR->setCalID( 0 );// add to default cal |
1845 | remote->addIncidence( inR ); | 1845 | remote->addIncidence( inR ); |
1846 | } | 1846 | } |
1847 | } | 1847 | } |
1848 | } else { | 1848 | } else { |
1849 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1849 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1850 | checkExternSyncEvent(eventLSyncSharp, inL); | 1850 | checkExternSyncEvent(eventLSyncSharp, inL); |
1851 | local->deleteIncidence( inL ); | 1851 | local->deleteIncidence( inL ); |
1852 | ++deletedEventL; | 1852 | ++deletedEventL; |
1853 | } else { | 1853 | } else { |
1854 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1854 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1855 | ++addedEventR; | 1855 | ++addedEventR; |
1856 | inL->setLastModified( modifiedCalendar ); | 1856 | inL->setLastModified( modifiedCalendar ); |
1857 | inR = inL->clone(); | 1857 | inR = inL->clone(); |
1858 | inR->setIDStr( ":" ); | 1858 | inR->setIDStr( ":" ); |
1859 | inR->setCalID( 0 );// add to default cal | 1859 | inR->setCalID( 0 );// add to default cal |
1860 | remote->addIncidence( inR ); | 1860 | remote->addIncidence( inR ); |
1861 | } | 1861 | } |
1862 | } | 1862 | } |
1863 | } | 1863 | } |
1864 | } else { | 1864 | } else { |
1865 | ++filteredOUT; | 1865 | ++filteredOUT; |
1866 | } | 1866 | } |
1867 | } | 1867 | } |
1868 | } | 1868 | } |
1869 | inL = el.next(); | 1869 | inL = el.next(); |
1870 | } | 1870 | } |
1871 | int delFut = 0; | 1871 | int delFut = 0; |
1872 | int remRem = 0; | 1872 | int remRem = 0; |
1873 | if ( mSyncManager->mWriteBackInFuture ) { | 1873 | if ( mSyncManager->mWriteBackInFuture ) { |
1874 | er = remote->rawIncidences(); | 1874 | er = remote->rawIncidences(); |
1875 | remRem = er.count(); | 1875 | remRem = er.count(); |
1876 | inR = er.first(); | 1876 | inR = er.first(); |
1877 | QDateTime dt; | 1877 | QDateTime dt; |
1878 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1878 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1879 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1879 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1880 | while ( inR ) { | 1880 | while ( inR ) { |
1881 | if ( inR->typeID() == todoID ) { | 1881 | if ( inR->typeID() == todoID ) { |
1882 | Todo * t = (Todo*)inR; | 1882 | Todo * t = (Todo*)inR; |
1883 | if ( t->hasDueDate() ) | 1883 | if ( t->hasDueDate() ) |
1884 | dt = t->dtDue(); | 1884 | dt = t->dtDue(); |
1885 | else | 1885 | else |
1886 | dt = cur.addSecs( 62 ); | 1886 | dt = cur.addSecs( 62 ); |
1887 | } | 1887 | } |
1888 | else if (inR->typeID() == eventID ) { | 1888 | else if (inR->typeID() == eventID ) { |
1889 | bool ok; | 1889 | bool ok; |
1890 | dt = inR->getNextOccurence( cur, &ok ); | 1890 | dt = inR->getNextOccurence( cur, &ok ); |
1891 | if ( !ok ) | 1891 | if ( !ok ) |
1892 | dt = cur.addSecs( -62 ); | 1892 | dt = cur.addSecs( -62 ); |
1893 | } | 1893 | } |
1894 | else | 1894 | else |
1895 | dt = inR->dtStart(); | 1895 | dt = inR->dtStart(); |
1896 | if ( dt < cur || dt > end ) { | 1896 | if ( dt < cur || dt > end ) { |
1897 | remote->deleteIncidence( inR ); | 1897 | remote->deleteIncidence( inR ); |
1898 | ++delFut; | 1898 | ++delFut; |
1899 | } | 1899 | } |
1900 | inR = er.next(); | 1900 | inR = er.next(); |
1901 | } | 1901 | } |
1902 | } | 1902 | } |
1903 | bar.hide(); | 1903 | bar.hide(); |
1904 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1904 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1905 | eventLSync->setReadOnly( false ); | 1905 | eventLSync->setReadOnly( false ); |
1906 | eventLSync->setDtStart( mLastCalendarSync ); | 1906 | eventLSync->setDtStart( mLastCalendarSync ); |
1907 | eventRSync->setDtStart( mLastCalendarSync ); | 1907 | eventRSync->setDtStart( mLastCalendarSync ); |
1908 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1908 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1909 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1909 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1910 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1910 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1911 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1911 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1912 | eventLSync->setReadOnly( true ); | 1912 | eventLSync->setReadOnly( true ); |
1913 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1913 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1914 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1914 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1915 | remote->addEvent( eventRSync ); | 1915 | remote->addEvent( eventRSync ); |
1916 | else | 1916 | else |
1917 | delete eventRSync; | 1917 | delete eventRSync; |
1918 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1918 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1919 | QString mes; | 1919 | QString mes; |
1920 | 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 ); | 1920 | 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 ); |
1921 | QString delmess; | 1921 | QString delmess; |
1922 | if ( delFut ) { | 1922 | if ( delFut ) { |
1923 | 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); | 1923 | 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); |
1924 | mes += delmess; | 1924 | mes += delmess; |
1925 | } | 1925 | } |
1926 | mes = i18n("Local calendar changed!\n") +mes; | 1926 | mes = i18n("Local calendar changed!\n") +mes; |
1927 | mCalendar->checkAlarmForIncidence( 0, true ); | 1927 | mCalendar->checkAlarmForIncidence( 0, true ); |
1928 | qDebug( mes ); | 1928 | qDebug( mes ); |
1929 | if ( mSyncManager->mShowSyncSummary ) { | 1929 | if ( mSyncManager->mShowSyncSummary ) { |
1930 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1930 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1931 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1931 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1932 | qDebug("KO: WB cancelled "); | 1932 | qDebug("KO: WB cancelled "); |
1933 | mSyncManager->mWriteBackFile = false; | 1933 | mSyncManager->mWriteBackFile = false; |
1934 | return syncOK; | 1934 | return syncOK; |
1935 | } | 1935 | } |
1936 | } | 1936 | } |
1937 | return syncOK; | 1937 | return syncOK; |
1938 | } | 1938 | } |
1939 | 1939 | ||
1940 | void CalendarView::setSyncDevice( QString s ) | 1940 | void CalendarView::setSyncDevice( QString s ) |
1941 | { | 1941 | { |
1942 | mCurrentSyncDevice= s; | 1942 | mCurrentSyncDevice= s; |
1943 | } | 1943 | } |
1944 | void CalendarView::setSyncName( QString s ) | 1944 | void CalendarView::setSyncName( QString s ) |
1945 | { | 1945 | { |
1946 | mCurrentSyncName= s; | 1946 | mCurrentSyncName= s; |
1947 | } | 1947 | } |
1948 | bool CalendarView::syncCalendar(QString filename, int mode) | 1948 | bool CalendarView::syncCalendar(QString filename, int mode) |
1949 | { | 1949 | { |
1950 | //qDebug("syncCalendar %s ", filename.latin1()); | 1950 | //qDebug("syncCalendar %s ", filename.latin1()); |
1951 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1951 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1952 | CalendarLocal* calendar = new CalendarLocal(); | 1952 | CalendarLocal* calendar = new CalendarLocal(); |
1953 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1953 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1954 | FileStorage* storage = new FileStorage( calendar ); | 1954 | FileStorage* storage = new FileStorage( calendar ); |
1955 | bool syncOK = false; | 1955 | bool syncOK = false; |
1956 | storage->setFileName( filename ); | 1956 | storage->setFileName( filename ); |
1957 | // qDebug("loading ... "); | 1957 | // qDebug("loading ... "); |
1958 | if ( storage->load() ) { | 1958 | if ( storage->load() ) { |
1959 | getEventViewerDialog()->setSyncMode( true ); | 1959 | getEventViewerDialog()->setSyncMode( true ); |
1960 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1960 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1961 | getEventViewerDialog()->setSyncMode( false ); | 1961 | getEventViewerDialog()->setSyncMode( false ); |
1962 | if ( syncOK ) { | 1962 | if ( syncOK ) { |
1963 | if ( mSyncManager->mWriteBackFile ) | 1963 | if ( mSyncManager->mWriteBackFile ) |
1964 | { | 1964 | { |
1965 | storage->setSaveFormat( new ICalFormat() ); | 1965 | storage->setSaveFormat( new ICalFormat() ); |
1966 | storage->save(); | 1966 | storage->save(); |
1967 | } | 1967 | } |
1968 | } | 1968 | } |
1969 | setModified( true ); | 1969 | setModified( true ); |
1970 | } | 1970 | } |
1971 | delete storage; | 1971 | delete storage; |
1972 | delete calendar; | 1972 | delete calendar; |
1973 | if ( syncOK ) | 1973 | if ( syncOK ) |
1974 | updateView(); | 1974 | updateView(); |
1975 | return syncOK; | 1975 | return syncOK; |
1976 | } | 1976 | } |
1977 | 1977 | ||
1978 | void CalendarView::syncExternal( int mode ) | 1978 | void CalendarView::syncExternal( int mode ) |
1979 | { | 1979 | { |
1980 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1980 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1981 | |||
1982 | qApp->processEvents(); | 1981 | qApp->processEvents(); |
1983 | CalendarLocal* calendar = new CalendarLocal(); | 1982 | CalendarLocal* calendar = new CalendarLocal(); |
1984 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1983 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1985 | bool syncOK = false; | 1984 | bool syncOK = false; |
1986 | bool loadSuccess = false; | 1985 | bool loadSuccess = false; |
1987 | PhoneFormat* phoneFormat = 0; | 1986 | PhoneFormat* phoneFormat = 0; |
1988 | emit tempDisableBR(true); | 1987 | emit tempDisableBR(true); |
1989 | #ifndef DESKTOP_VERSION | 1988 | #ifndef DESKTOP_VERSION |
1990 | SharpFormat* sharpFormat = 0; | 1989 | SharpFormat* sharpFormat = 0; |
1991 | if ( mode == 0 ) { // sharp | 1990 | if ( mode == 0 ) { // sharp |
1992 | sharpFormat = new SharpFormat () ; | 1991 | sharpFormat = new SharpFormat () ; |
1993 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1992 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1994 | 1993 | ||
1995 | } else | 1994 | } else |
1996 | #endif | 1995 | #endif |
1997 | if ( mode == 1 ) { // phone | 1996 | if ( mode == 1 ) { // phone |
1998 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1997 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1999 | mSyncManager->mPhoneDevice, | 1998 | mSyncManager->mPhoneDevice, |
2000 | mSyncManager->mPhoneConnection, | 1999 | mSyncManager->mPhoneConnection, |
2001 | mSyncManager->mPhoneModel); | 2000 | mSyncManager->mPhoneModel); |
2002 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 2001 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
2003 | 2002 | ||
2004 | } else { | 2003 | } else { |
2005 | emit tempDisableBR(false); | 2004 | emit tempDisableBR(false); |
2006 | return; | 2005 | return; |
2007 | } | 2006 | } |
2008 | if ( loadSuccess ) { | 2007 | if ( loadSuccess ) { |
2009 | getEventViewerDialog()->setSyncMode( true ); | 2008 | getEventViewerDialog()->setSyncMode( true ); |
2010 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2009 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2011 | getEventViewerDialog()->setSyncMode( false ); | 2010 | getEventViewerDialog()->setSyncMode( false ); |
2012 | qApp->processEvents(); | 2011 | qApp->processEvents(); |
2013 | if ( syncOK ) { | 2012 | if ( syncOK ) { |
2014 | if ( mSyncManager->mWriteBackFile ) | 2013 | if ( mSyncManager->mWriteBackFile ) |
2015 | { | 2014 | { |
2016 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 2015 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
2017 | Incidence* inc = iL.first(); | 2016 | Incidence* inc = iL.first(); |
2018 | if ( phoneFormat ) { | 2017 | if ( phoneFormat ) { |
2019 | while ( inc ) { | 2018 | while ( inc ) { |
2020 | inc->removeID(mCurrentSyncDevice); | 2019 | inc->removeID(mCurrentSyncDevice); |
2021 | inc = iL.next(); | 2020 | inc = iL.next(); |
2022 | } | 2021 | } |
2023 | } | 2022 | } |
2024 | #ifndef DESKTOP_VERSION | 2023 | #ifndef DESKTOP_VERSION |
2025 | if ( sharpFormat ) | 2024 | if ( sharpFormat ) |
2026 | sharpFormat->save(calendar); | 2025 | sharpFormat->save(calendar); |
2027 | #endif | 2026 | #endif |
2028 | if ( phoneFormat ) | 2027 | if ( phoneFormat ) |
2029 | phoneFormat->save(calendar); | 2028 | phoneFormat->save(calendar); |
2030 | iL = calendar->rawIncidences(); | 2029 | iL = calendar->rawIncidences(); |
2031 | inc = iL.first(); | 2030 | inc = iL.first(); |
2032 | Incidence* loc; | 2031 | Incidence* loc; |
2033 | while ( inc ) { | 2032 | while ( inc ) { |
2034 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 2033 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
2035 | loc = mCalendar->incidence(inc->uid() ); | 2034 | loc = mCalendar->incidence(inc->uid() ); |
2036 | if ( loc ) { | 2035 | if ( loc ) { |
2037 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 2036 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
2038 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 2037 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
2039 | } | 2038 | } |
2040 | } | 2039 | } |
2041 | inc = iL.next(); | 2040 | inc = iL.next(); |
2042 | } | 2041 | } |
2043 | Incidence* lse = getLastSyncEvent(); | 2042 | Incidence* lse = getLastSyncEvent(); |
2044 | if ( lse ) { | 2043 | if ( lse ) { |
2045 | lse->setReadOnly( false ); | 2044 | lse->setReadOnly( false ); |
2046 | lse->setDescription( "" ); | 2045 | lse->setDescription( "" ); |
2047 | lse->setReadOnly( true ); | 2046 | lse->setReadOnly( true ); |
2048 | } | 2047 | } |
2049 | } | 2048 | } |
2050 | } else { | 2049 | } else { |
2051 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 2050 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
2052 | } | 2051 | } |
2053 | setModified( true ); | 2052 | setModified( true ); |
2054 | } else { | 2053 | } else { |
2055 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 2054 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
2056 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 2055 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
2057 | question, i18n("Ok")) ; | 2056 | question, i18n("Ok")) ; |
2058 | 2057 | ||
2059 | } | 2058 | } |
2060 | delete calendar; | 2059 | delete calendar; |
2061 | updateView(); | 2060 | updateView(); |
2062 | emit tempDisableBR(false); | 2061 | emit tempDisableBR(false); |
2063 | return ;//syncOK; | 2062 | return ;//syncOK; |
2064 | 2063 | ||
2065 | } | 2064 | } |
2066 | 2065 | ||
2067 | bool CalendarView::importBday() | 2066 | bool CalendarView::importBday() |
2068 | { | 2067 | { |
2069 | #ifndef KORG_NOKABC | 2068 | #ifndef KORG_NOKABC |
2070 | 2069 | ||
2071 | #ifdef DESKTOP_VERSION | 2070 | #ifdef DESKTOP_VERSION |
2072 | int curCal = mCalendar->defaultCalendar(); | 2071 | int curCal = mCalendar->defaultCalendar(); |
2073 | int bd = mCalEditView->getBirtdayID(); | 2072 | int bd = mCalEditView->getBirtdayID(); |
2074 | if ( bd == 0 ) | 2073 | if ( bd == 0 ) |
2075 | return false; | 2074 | return false; |
2076 | mCalendar->setDefaultCalendar( bd ); | 2075 | mCalendar->setDefaultCalendar( bd ); |
2077 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 2076 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
2078 | KABC::AddressBook::Iterator it; | 2077 | KABC::AddressBook::Iterator it; |
2079 | int count = 0; | 2078 | int count = 0; |
2080 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2079 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2081 | ++count; | 2080 | ++count; |
2082 | } | 2081 | } |
2083 | QProgressBar bar(count,0 ); | 2082 | QProgressBar bar(count,0 ); |
2084 | int w = 300; | 2083 | int w = 300; |
2085 | if ( QApplication::desktop()->width() < 320 ) | 2084 | if ( QApplication::desktop()->width() < 320 ) |
2086 | w = 220; | 2085 | w = 220; |
2087 | int h = bar.sizeHint().height() ; | 2086 | int h = bar.sizeHint().height() ; |
2088 | int dw = QApplication::desktop()->width(); | 2087 | int dw = QApplication::desktop()->width(); |
2089 | int dh = QApplication::desktop()->height(); | 2088 | int dh = QApplication::desktop()->height(); |
2090 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2089 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2091 | bar.show(); | 2090 | bar.show(); |
2092 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 2091 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
2093 | qApp->processEvents(); | 2092 | qApp->processEvents(); |
2094 | count = 0; | 2093 | count = 0; |
2095 | int addCount = 0; | 2094 | int addCount = 0; |
2096 | KCal::Attendee* a = 0; | 2095 | KCal::Attendee* a = 0; |
2097 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2096 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2098 | if ( ! bar.isVisible() ) | 2097 | if ( ! bar.isVisible() ) |
2099 | return false; | 2098 | return false; |
2100 | bar.setProgress( count++ ); | 2099 | bar.setProgress( count++ ); |
2101 | qApp->processEvents(); | 2100 | qApp->processEvents(); |
2102 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 2101 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
2103 | if ( (*it).birthday().date().isValid() ){ | 2102 | if ( (*it).birthday().date().isValid() ){ |
2104 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2103 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2105 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 2104 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
2106 | ++addCount; | 2105 | ++addCount; |
2107 | } | 2106 | } |
2108 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 2107 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
2109 | if ( anni.isValid() ){ | 2108 | if ( anni.isValid() ){ |
2110 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2109 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2111 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 2110 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
2112 | ++addCount; | 2111 | ++addCount; |
2113 | } | 2112 | } |
2114 | } | 2113 | } |
2115 | mCalendar->setDefaultCalendar( curCal ); | 2114 | mCalendar->setDefaultCalendar( curCal ); |
2116 | updateView(); | 2115 | updateView(); |
2117 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2116 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2118 | #else //DESKTOP_VERSION | 2117 | #else //DESKTOP_VERSION |
2119 | 2118 | ||
2120 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 2119 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
2121 | // the result should now arrive through method insertBirthdays | 2120 | // the result should now arrive through method insertBirthdays |
2122 | 2121 | ||
2123 | #endif //DESKTOP_VERSION | 2122 | #endif //DESKTOP_VERSION |
2124 | 2123 | ||
2125 | #endif //KORG_NOKABC | 2124 | #endif //KORG_NOKABC |
2126 | 2125 | ||
2127 | 2126 | ||
2128 | return true; | 2127 | return true; |
2129 | } | 2128 | } |
2130 | 2129 | ||
2131 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 2130 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
2132 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 2131 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
2133 | const QStringList& anniversaryList, const QStringList& realNameList, | 2132 | const QStringList& anniversaryList, const QStringList& realNameList, |
2134 | const QStringList& emailList, const QStringList& assembledNameList, | 2133 | const QStringList& emailList, const QStringList& assembledNameList, |
2135 | const QStringList& uidList) | 2134 | const QStringList& uidList) |
2136 | { | 2135 | { |
2137 | 2136 | ||
2138 | //qDebug("KO::CalendarView::insertBirthdays"); | 2137 | //qDebug("KO::CalendarView::insertBirthdays"); |
2139 | if (uid == this->name()) | 2138 | if (uid == this->name()) |
2140 | { | 2139 | { |
2141 | int curCal = mCalendar->defaultCalendar(); | 2140 | int curCal = mCalendar->defaultCalendar(); |
2142 | int bd = mCalEditView->getBirtdayID(); | 2141 | int bd = mCalEditView->getBirtdayID(); |
2143 | if ( bd == 0 ) | 2142 | if ( bd == 0 ) |
2144 | return; | 2143 | return; |
2145 | mCalendar->setDefaultCalendar( bd ); | 2144 | mCalendar->setDefaultCalendar( bd ); |
2146 | 2145 | ||
2147 | 2146 | ||
2148 | int count = birthdayList.count(); | 2147 | int count = birthdayList.count(); |
2149 | int addCount = 0; | 2148 | int addCount = 0; |
2150 | KCal::Attendee* a = 0; | 2149 | KCal::Attendee* a = 0; |
2151 | 2150 | ||
2152 | //qDebug("CalView 1 %i", count); | 2151 | //qDebug("CalView 1 %i", count); |
2153 | 2152 | ||
2154 | QProgressBar bar(count,0 ); | 2153 | QProgressBar bar(count,0 ); |
2155 | int w = 300; | 2154 | int w = 300; |
2156 | if ( QApplication::desktop()->width() < 320 ) | 2155 | if ( QApplication::desktop()->width() < 320 ) |
2157 | w = 220; | 2156 | w = 220; |
2158 | int h = bar.sizeHint().height() ; | 2157 | int h = bar.sizeHint().height() ; |
2159 | int dw = QApplication::desktop()->width(); | 2158 | int dw = QApplication::desktop()->width(); |
2160 | int dh = QApplication::desktop()->height(); | 2159 | int dh = QApplication::desktop()->height(); |
2161 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2160 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2162 | bar.show(); | 2161 | bar.show(); |
2163 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 2162 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
2164 | qApp->processEvents(); | 2163 | qApp->processEvents(); |
2165 | 2164 | ||
2166 | QDate birthday; | 2165 | QDate birthday; |
2167 | QDate anniversary; | 2166 | QDate anniversary; |
2168 | QString realName; | 2167 | QString realName; |
2169 | QString email; | 2168 | QString email; |
2170 | QString assembledName; | 2169 | QString assembledName; |
2171 | QString uid; | 2170 | QString uid; |
2172 | bool ok = true; | 2171 | bool ok = true; |
2173 | for ( int i = 0; i < count; i++) | 2172 | for ( int i = 0; i < count; i++) |
2174 | { | 2173 | { |
2175 | if ( ! bar.isVisible() ) | 2174 | if ( ! bar.isVisible() ) |
2176 | return; | 2175 | return; |
2177 | bar.setProgress( i ); | 2176 | bar.setProgress( i ); |
2178 | qApp->processEvents(); | 2177 | qApp->processEvents(); |
2179 | 2178 | ||
2180 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 2179 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
2181 | if (!ok) { | 2180 | if (!ok) { |
2182 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 2181 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
2183 | } | 2182 | } |
2184 | 2183 | ||
2185 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 2184 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
2186 | if (!ok) { | 2185 | if (!ok) { |
2187 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 2186 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
2188 | } | 2187 | } |
2189 | realName = realNameList[i]; | 2188 | realName = realNameList[i]; |
2190 | email = emailList[i]; | 2189 | email = emailList[i]; |
2191 | assembledName = assembledNameList[i]; | 2190 | assembledName = assembledNameList[i]; |
2192 | uid = uidList[i]; | 2191 | uid = uidList[i]; |
2193 | //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() ); | 2192 | //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() ); |
2194 | 2193 | ||
2195 | if ( birthday.isValid() ){ | 2194 | if ( birthday.isValid() ){ |
2196 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2195 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2197 | KCal::Attendee::ReqParticipant,uid) ; | 2196 | KCal::Attendee::ReqParticipant,uid) ; |
2198 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 2197 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
2199 | ++addCount; | 2198 | ++addCount; |
2200 | } | 2199 | } |
2201 | 2200 | ||
2202 | if ( anniversary.isValid() ){ | 2201 | if ( anniversary.isValid() ){ |
2203 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2202 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2204 | KCal::Attendee::ReqParticipant,uid) ; | 2203 | KCal::Attendee::ReqParticipant,uid) ; |
2205 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 2204 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
2206 | ++addCount; | 2205 | ++addCount; |
2207 | } | 2206 | } |
2208 | } | 2207 | } |
2209 | 2208 | ||
2210 | mCalendar->setDefaultCalendar( curCal ); | 2209 | mCalendar->setDefaultCalendar( curCal ); |
2211 | updateView(); | 2210 | updateView(); |
2212 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2211 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2213 | 2212 | ||
2214 | } | 2213 | } |
2215 | 2214 | ||
2216 | } | 2215 | } |
2217 | 2216 | ||
2218 | 2217 | ||
2219 | 2218 | ||
2220 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 2219 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
2221 | { | 2220 | { |
2222 | //qDebug("addAnni "); | 2221 | //qDebug("addAnni "); |
2223 | Event * ev = new Event(); | 2222 | Event * ev = new Event(); |
2224 | ev->setOrganizer(KOPrefs::instance()->email()); | 2223 | ev->setOrganizer(KOPrefs::instance()->email()); |
2225 | if ( a ) { | 2224 | if ( a ) { |
2226 | ev->addAttendee( a ); | 2225 | ev->addAttendee( a ); |
2227 | } | 2226 | } |
2228 | QString kind; | 2227 | QString kind; |
2229 | if ( birthday ) { | 2228 | if ( birthday ) { |
2230 | kind = i18n( "Birthday" ); | 2229 | kind = i18n( "Birthday" ); |
2231 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 2230 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
2232 | } | 2231 | } |
2233 | else { | 2232 | else { |
2234 | kind = i18n( "Anniversary" ); | 2233 | kind = i18n( "Anniversary" ); |
2235 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 2234 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
2236 | } | 2235 | } |
2237 | ev->setCategories( kind ); | 2236 | ev->setCategories( kind ); |
2238 | ev->setDtStart( QDateTime(date) ); | 2237 | ev->setDtStart( QDateTime(date) ); |
2239 | ev->setDtEnd( QDateTime(date) ); | 2238 | ev->setDtEnd( QDateTime(date) ); |
2240 | ev->setFloats( true ); | 2239 | ev->setFloats( true ); |
2241 | Recurrence * rec = ev->recurrence(); | 2240 | Recurrence * rec = ev->recurrence(); |
2242 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 2241 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
2243 | rec->addYearlyNum( date.month() ); | 2242 | rec->addYearlyNum( date.month() ); |
2244 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 2243 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
2245 | delete ev; | 2244 | delete ev; |
2246 | return false; | 2245 | return false; |
2247 | } | 2246 | } |
2248 | return true; | 2247 | return true; |
2249 | 2248 | ||
2250 | } | 2249 | } |
2251 | bool CalendarView::importQtopia( const QString &categories, | 2250 | bool CalendarView::importQtopia( const QString &categories, |
2252 | const QString &datebook, | 2251 | const QString &datebook, |
2253 | const QString &todolist ) | 2252 | const QString &todolist ) |
2254 | { | 2253 | { |
2255 | 2254 | ||
2256 | QtopiaFormat qtopiaFormat; | 2255 | QtopiaFormat qtopiaFormat; |
2257 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2256 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2258 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2257 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2259 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2258 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2260 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2259 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2261 | 2260 | ||
2262 | updateView(); | 2261 | updateView(); |
2263 | return true; | 2262 | return true; |
2264 | 2263 | ||
2265 | #if 0 | 2264 | #if 0 |
2266 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2265 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2267 | mCurrentSyncDevice = "qtopia-XML"; | 2266 | mCurrentSyncDevice = "qtopia-XML"; |
2268 | if ( mSyncManager->mAskForPreferences ) | 2267 | if ( mSyncManager->mAskForPreferences ) |
2269 | edit_sync_options(); | 2268 | edit_sync_options(); |
2270 | qApp->processEvents(); | 2269 | qApp->processEvents(); |
2271 | CalendarLocal* calendar = new CalendarLocal(); | 2270 | CalendarLocal* calendar = new CalendarLocal(); |
2272 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2271 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2273 | bool syncOK = false; | 2272 | bool syncOK = false; |
2274 | QtopiaFormat qtopiaFormat; | 2273 | QtopiaFormat qtopiaFormat; |
2275 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2274 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2276 | bool loadOk = true; | 2275 | bool loadOk = true; |
2277 | if ( !categories.isEmpty() ) | 2276 | if ( !categories.isEmpty() ) |
2278 | loadOk = qtopiaFormat.load( calendar, categories ); | 2277 | loadOk = qtopiaFormat.load( calendar, categories ); |
2279 | if ( loadOk && !datebook.isEmpty() ) | 2278 | if ( loadOk && !datebook.isEmpty() ) |
2280 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2279 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2281 | if ( loadOk && !todolist.isEmpty() ) | 2280 | if ( loadOk && !todolist.isEmpty() ) |
2282 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2281 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2283 | 2282 | ||
2284 | if ( loadOk ) { | 2283 | if ( loadOk ) { |
2285 | getEventViewerDialog()->setSyncMode( true ); | 2284 | getEventViewerDialog()->setSyncMode( true ); |
2286 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2285 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2287 | getEventViewerDialog()->setSyncMode( false ); | 2286 | getEventViewerDialog()->setSyncMode( false ); |
2288 | qApp->processEvents(); | 2287 | qApp->processEvents(); |
2289 | if ( syncOK ) { | 2288 | if ( syncOK ) { |
2290 | if ( mSyncManager->mWriteBackFile ) | 2289 | if ( mSyncManager->mWriteBackFile ) |
2291 | { | 2290 | { |
2292 | // write back XML file | 2291 | // write back XML file |
2293 | 2292 | ||
2294 | } | 2293 | } |
2295 | setModified( true ); | 2294 | setModified( true ); |
2296 | } | 2295 | } |
2297 | } else { | 2296 | } else { |
2298 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2297 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2299 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2298 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2300 | question, i18n("Ok")) ; | 2299 | question, i18n("Ok")) ; |
2301 | } | 2300 | } |
2302 | delete calendar; | 2301 | delete calendar; |
2303 | updateView(); | 2302 | updateView(); |
2304 | return syncOK; | 2303 | return syncOK; |
2305 | 2304 | ||
2306 | 2305 | ||
2307 | #endif | 2306 | #endif |
2308 | 2307 | ||
2309 | } | 2308 | } |
2310 | 2309 | ||
2311 | void CalendarView::setSyncEventsReadOnly() | 2310 | void CalendarView::setSyncEventsReadOnly() |
2312 | { | 2311 | { |
2313 | mCalendar->setSyncEventsReadOnly(); | 2312 | mCalendar->setSyncEventsReadOnly(); |
2314 | } | 2313 | } |
2315 | 2314 | ||
2316 | bool CalendarView::loadCalendars() | 2315 | bool CalendarView::loadCalendars() |
2317 | { | 2316 | { |
2318 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2317 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2319 | KopiCalendarFile * cal = calendars.first(); | 2318 | KopiCalendarFile * cal = calendars.first(); |
2320 | mCalendar->setDefaultCalendar( 1 ); | 2319 | mCalendar->setDefaultCalendar( 1 ); |
2321 | openCalendar( MainWindow::defaultFileName(), false ); | 2320 | openCalendar( MainWindow::defaultFileName(), false ); |
2322 | cal = calendars.next(); | 2321 | cal = calendars.next(); |
2323 | while ( cal ) { | 2322 | while ( cal ) { |
2324 | addCalendar( cal ); | 2323 | addCalendar( cal ); |
2325 | cal = calendars.next(); | 2324 | cal = calendars.next(); |
2326 | } | 2325 | } |
2327 | restoreCalendarSettings(); | 2326 | restoreCalendarSettings(); |
2328 | return true; | 2327 | return true; |
2329 | } | 2328 | } |
2330 | bool CalendarView::restoreCalendarSettings() | 2329 | bool CalendarView::restoreCalendarSettings() |
2331 | { | 2330 | { |
2332 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2331 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2333 | KopiCalendarFile * cal = calendars.first(); | 2332 | KopiCalendarFile * cal = calendars.first(); |
2334 | while ( cal ) { | 2333 | while ( cal ) { |
2335 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2334 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2336 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2335 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2337 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2336 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2338 | if ( cal->isStandard ) | 2337 | if ( cal->isStandard ) |
2339 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2338 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2340 | cal = calendars.next(); | 2339 | cal = calendars.next(); |
2341 | } | 2340 | } |
2342 | setSyncEventsReadOnly(); | 2341 | setSyncEventsReadOnly(); |
2343 | mCalendar->reInitAlarmSettings(); | 2342 | mCalendar->reInitAlarmSettings(); |
2344 | updateUnmanagedViews(); | 2343 | updateUnmanagedViews(); |
2345 | updateView(); | 2344 | updateView(); |
2346 | return true; | 2345 | return true; |
2347 | } | 2346 | } |
2348 | void CalendarView::addCalendarId( int id ) | 2347 | void CalendarView::addCalendarId( int id ) |
2349 | { | 2348 | { |
2350 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2349 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2351 | if ( cal ) | 2350 | if ( cal ) |
2352 | addCalendar( cal ); | 2351 | addCalendar( cal ); |
2353 | } | 2352 | } |
2354 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2353 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2355 | { | 2354 | { |
2356 | cal->mErrorOnLoad = false; | 2355 | cal->mErrorOnLoad = false; |
2357 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2356 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2358 | cal->mLoadDt = QDateTime::currentDateTime(); | 2357 | cal->mLoadDt = QDateTime::currentDateTime(); |
2359 | return true; | 2358 | return true; |
2360 | } | 2359 | } |
2361 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2360 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2362 | cal->mErrorOnLoad = true; | 2361 | cal->mErrorOnLoad = true; |
2363 | return false; | 2362 | return false; |
2364 | } | 2363 | } |
2365 | bool CalendarView::openCalendar(QString filename, bool merge) | 2364 | bool CalendarView::openCalendar(QString filename, bool merge) |
2366 | { | 2365 | { |
2367 | 2366 | ||
2368 | if (filename.isEmpty()) { | 2367 | if (filename.isEmpty()) { |
2369 | return false; | 2368 | return false; |
2370 | } | 2369 | } |
2371 | 2370 | ||
2372 | if (!QFile::exists(filename)) { | 2371 | if (!QFile::exists(filename)) { |
2373 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2372 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2374 | return false; | 2373 | return false; |
2375 | } | 2374 | } |
2376 | 2375 | ||
2377 | globalFlagBlockAgenda = 1; | 2376 | globalFlagBlockAgenda = 1; |
2378 | clearAllViews(); | 2377 | clearAllViews(); |
2379 | if (!merge) { | 2378 | if (!merge) { |
2380 | mViewManager->setDocumentId( filename ); | 2379 | mViewManager->setDocumentId( filename ); |
2381 | mCalendar->close(); | 2380 | mCalendar->close(); |
2382 | } | 2381 | } |
2383 | mStorage->setFileName( filename ); | 2382 | mStorage->setFileName( filename ); |
2384 | 2383 | ||
2385 | if ( mStorage->load() ) { | 2384 | if ( mStorage->load() ) { |
2386 | if ( merge ) ;//setModified( true ); | 2385 | if ( merge ) ;//setModified( true ); |
2387 | else { | 2386 | else { |
2388 | //setModified( true ); | 2387 | //setModified( true ); |
2389 | mViewManager->setDocumentId( filename ); | 2388 | mViewManager->setDocumentId( filename ); |
2390 | mDialogManager->setDocumentId( filename ); | 2389 | mDialogManager->setDocumentId( filename ); |
2391 | mTodoList->setDocumentId( filename ); | 2390 | mTodoList->setDocumentId( filename ); |
2392 | } | 2391 | } |
2393 | globalFlagBlockAgenda = 2; | 2392 | globalFlagBlockAgenda = 2; |
2394 | // if ( getLastSyncEvent() ) | 2393 | // if ( getLastSyncEvent() ) |
2395 | // getLastSyncEvent()->setReadOnly( true ); | 2394 | // getLastSyncEvent()->setReadOnly( true ); |
2396 | mCalendar->reInitAlarmSettings(); | 2395 | mCalendar->reInitAlarmSettings(); |
2397 | setSyncEventsReadOnly(); | 2396 | setSyncEventsReadOnly(); |
2398 | //updateUnmanagedViews(); | 2397 | //updateUnmanagedViews(); |
2399 | //updateView(); | 2398 | //updateView(); |
2400 | if ( filename != MainWindow::defaultFileName() ) { | 2399 | if ( filename != MainWindow::defaultFileName() ) { |
2401 | saveCalendar( MainWindow::defaultFileName() ); | 2400 | saveCalendar( MainWindow::defaultFileName() ); |
2402 | } else { | 2401 | } else { |
2403 | QFileInfo finf ( MainWindow::defaultFileName()); | 2402 | QFileInfo finf ( MainWindow::defaultFileName()); |
2404 | if ( finf.exists() ) { | 2403 | if ( finf.exists() ) { |
2405 | setLoadedFileVersion( finf.lastModified () ); | 2404 | setLoadedFileVersion( finf.lastModified () ); |
2406 | } | 2405 | } |
2407 | } | 2406 | } |
2408 | return true; | 2407 | return true; |
2409 | } else { | 2408 | } else { |
2410 | // while failing to load, the calendar object could | 2409 | // while failing to load, the calendar object could |
2411 | // have become partially populated. Clear it out. | 2410 | // have become partially populated. Clear it out. |
2412 | if ( !merge ) { | 2411 | if ( !merge ) { |
2413 | mCalendar->close(); | 2412 | mCalendar->close(); |
2414 | mViewManager->setDocumentId( filename ); | 2413 | mViewManager->setDocumentId( filename ); |
2415 | mDialogManager->setDocumentId( filename ); | 2414 | mDialogManager->setDocumentId( filename ); |
2416 | mTodoList->setDocumentId( filename ); | 2415 | mTodoList->setDocumentId( filename ); |
2417 | } | 2416 | } |
2418 | 2417 | ||
2419 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2418 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2420 | 2419 | ||
2421 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2420 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2422 | globalFlagBlockAgenda = 2; | 2421 | globalFlagBlockAgenda = 2; |
2423 | mCalendar->reInitAlarmSettings(); | 2422 | mCalendar->reInitAlarmSettings(); |
2424 | setSyncEventsReadOnly(); | 2423 | setSyncEventsReadOnly(); |
2425 | updateUnmanagedViews(); | 2424 | updateUnmanagedViews(); |
2426 | updateView(); | 2425 | updateView(); |
2427 | } | 2426 | } |
2428 | return false; | 2427 | return false; |
2429 | } | 2428 | } |
2430 | void CalendarView::mergeFile( QString fn ) | 2429 | void CalendarView::mergeFile( QString fn ) |
2431 | { | 2430 | { |
2432 | clearAllViews(); | 2431 | clearAllViews(); |
2433 | mCalendar->mergeCalendarFile( fn ); | 2432 | mCalendar->mergeCalendarFile( fn ); |
2434 | mCalendar->reInitAlarmSettings(); | 2433 | mCalendar->reInitAlarmSettings(); |
2435 | setSyncEventsReadOnly(); | 2434 | setSyncEventsReadOnly(); |
2436 | updateUnmanagedViews(); | 2435 | updateUnmanagedViews(); |
2437 | updateView(); | 2436 | updateView(); |
2438 | } | 2437 | } |
2439 | void CalendarView::showOpenError() | 2438 | void CalendarView::showOpenError() |
2440 | { | 2439 | { |
2441 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2440 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2442 | } | 2441 | } |
2443 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2442 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2444 | { | 2443 | { |
2445 | loadedFileVersion = dt; | 2444 | loadedFileVersion = dt; |
2446 | } | 2445 | } |
2447 | bool CalendarView::checkFileChanged(QString fn) | 2446 | bool CalendarView::checkFileChanged(QString fn) |
2448 | { | 2447 | { |
2449 | QFileInfo finf ( fn ); | 2448 | QFileInfo finf ( fn ); |
2450 | if ( !finf.exists() ) | 2449 | if ( !finf.exists() ) |
2451 | return true; | 2450 | return true; |
2452 | QDateTime dt = finf.lastModified (); | 2451 | QDateTime dt = finf.lastModified (); |
2453 | if ( dt <= loadedFileVersion ) | 2452 | if ( dt <= loadedFileVersion ) |
2454 | return false; | 2453 | return false; |
2455 | return true; | 2454 | return true; |
2456 | 2455 | ||
2457 | } | 2456 | } |
2458 | void CalendarView::watchSavedFile() | 2457 | void CalendarView::watchSavedFile() |
2459 | { | 2458 | { |
2460 | QFileInfo finf ( MainWindow::defaultFileName()); | 2459 | QFileInfo finf ( MainWindow::defaultFileName()); |
2461 | if ( !finf.exists() ) | 2460 | if ( !finf.exists() ) |
2462 | return; | 2461 | return; |
2463 | QDateTime dt = finf.lastModified (); | 2462 | QDateTime dt = finf.lastModified (); |
2464 | if ( dt < loadedFileVersion ) { | 2463 | if ( dt < loadedFileVersion ) { |
2465 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2464 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2466 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2465 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2467 | return; | 2466 | return; |
2468 | } | 2467 | } |
2469 | loadedFileVersion = dt; | 2468 | loadedFileVersion = dt; |
2470 | } | 2469 | } |
2471 | bool CalendarView::checkAllFileVersions() | 2470 | bool CalendarView::checkAllFileVersions() |
2472 | { | 2471 | { |
2473 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2472 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2474 | KopiCalendarFile * cal = calendars.first(); | 2473 | KopiCalendarFile * cal = calendars.first(); |
2475 | mCalendar->setDefaultCalendar( 1 ); | 2474 | mCalendar->setDefaultCalendar( 1 ); |
2476 | mCalendar->setDefaultCalendarEnabledOnly(); | 2475 | mCalendar->setDefaultCalendarEnabledOnly(); |
2477 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2476 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2478 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2477 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2479 | restoreCalendarSettings(); | 2478 | restoreCalendarSettings(); |
2480 | return false; | 2479 | return false; |
2481 | } | 2480 | } |
2482 | } | 2481 | } |
2483 | cal = calendars.next(); | 2482 | cal = calendars.next(); |
2484 | QDateTime storeTemp = loadedFileVersion; | 2483 | QDateTime storeTemp = loadedFileVersion; |
2485 | while ( cal ) { | 2484 | while ( cal ) { |
2486 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2485 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2487 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2486 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2488 | mCalendar->setDefaultCalendarEnabledOnly(); | 2487 | mCalendar->setDefaultCalendarEnabledOnly(); |
2489 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2488 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2490 | if ( !checkFileVersion(cal->mFileName )) { | 2489 | if ( !checkFileVersion(cal->mFileName )) { |
2491 | loadedFileVersion = storeTemp; | 2490 | loadedFileVersion = storeTemp; |
2492 | restoreCalendarSettings(); | 2491 | restoreCalendarSettings(); |
2493 | return false; | 2492 | return false; |
2494 | } | 2493 | } |
2495 | } | 2494 | } |
2496 | cal = calendars.next(); | 2495 | cal = calendars.next(); |
2497 | } | 2496 | } |
2498 | loadedFileVersion = storeTemp; | 2497 | loadedFileVersion = storeTemp; |
2499 | return true; | 2498 | return true; |
2500 | } | 2499 | } |
2501 | bool CalendarView::checkFileVersion(QString fn) | 2500 | bool CalendarView::checkFileVersion(QString fn) |
2502 | { | 2501 | { |
2503 | QFileInfo finf ( fn ); | 2502 | QFileInfo finf ( fn ); |
2504 | if ( !finf.exists() ) | 2503 | if ( !finf.exists() ) |
2505 | return true; | 2504 | return true; |
2506 | QDateTime dt = finf.lastModified (); | 2505 | QDateTime dt = finf.lastModified (); |
2507 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2506 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2508 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2507 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2509 | if ( dt <= loadedFileVersion ) | 2508 | if ( dt <= loadedFileVersion ) |
2510 | return true; | 2509 | return true; |
2511 | 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)) , | 2510 | 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)) , |
2512 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2511 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2513 | i18n("Sync+save")); | 2512 | i18n("Sync+save")); |
2514 | 2513 | ||
2515 | if ( km == KMessageBox::Cancel ) | 2514 | if ( km == KMessageBox::Cancel ) |
2516 | return false; | 2515 | return false; |
2517 | if ( km == KMessageBox::Yes ) | 2516 | if ( km == KMessageBox::Yes ) |
2518 | return true; | 2517 | return true; |
2519 | 2518 | ||
2520 | setSyncDevice("deleteaftersync" ); | 2519 | setSyncDevice("deleteaftersync" ); |
2521 | mSyncManager->mAskForPreferences = true; | 2520 | mSyncManager->mAskForPreferences = true; |
2522 | mSyncManager->mSyncAlgoPrefs = 3; | 2521 | mSyncManager->mSyncAlgoPrefs = 3; |
2523 | mSyncManager->mWriteBackFile = false; | 2522 | mSyncManager->mWriteBackFile = false; |
2524 | mSyncManager->mWriteBackExistingOnly = false; | 2523 | mSyncManager->mWriteBackExistingOnly = false; |
2525 | mSyncManager->mShowSyncSummary = false; | 2524 | mSyncManager->mShowSyncSummary = false; |
2526 | syncCalendar( fn, 3 ); | 2525 | syncCalendar( fn, 3 ); |
2527 | Event * e = getLastSyncEvent(); | 2526 | Event * e = getLastSyncEvent(); |
2528 | if ( e ) | 2527 | if ( e ) |
2529 | mCalendar->deleteEvent( e ); | 2528 | mCalendar->deleteEvent( e ); |
2530 | return true; | 2529 | return true; |
2531 | } | 2530 | } |
2532 | bool CalendarView::saveCalendars() | 2531 | bool CalendarView::saveCalendars() |
2533 | { | 2532 | { |
2534 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2533 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2535 | KopiCalendarFile * cal = calendars.first(); | 2534 | KopiCalendarFile * cal = calendars.first(); |
2536 | mCalendar->setDefaultCalendar( 1 ); | 2535 | mCalendar->setDefaultCalendar( 1 ); |
2537 | mCalendar->setDefaultCalendarEnabledOnly(); | 2536 | mCalendar->setDefaultCalendarEnabledOnly(); |
2538 | QString saveError; | 2537 | QString saveError; |
2539 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) | 2538 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) |
2540 | saveError = cal->mName +"\n"; | 2539 | saveError = cal->mName +"\n"; |
2541 | cal = calendars.next(); | 2540 | cal = calendars.next(); |
2542 | while ( cal ) { | 2541 | while ( cal ) { |
2543 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2542 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2544 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2543 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2545 | mCalendar->setDefaultCalendarEnabledOnly(); | 2544 | mCalendar->setDefaultCalendarEnabledOnly(); |
2546 | if ( saveCalendar( cal->mFileName ) ) | 2545 | if ( saveCalendar( cal->mFileName ) ) |
2547 | cal->mLoadDt = QDateTime::currentDateTime(); | 2546 | cal->mLoadDt = QDateTime::currentDateTime(); |
2548 | else | 2547 | else |
2549 | saveError += cal->mName + "\n"; | 2548 | saveError += cal->mName + "\n"; |
2550 | } | 2549 | } |
2551 | cal = calendars.next(); | 2550 | cal = calendars.next(); |
2552 | } | 2551 | } |
2553 | restoreCalendarSettings(); | 2552 | restoreCalendarSettings(); |
2554 | //saveError = "test error"; | 2553 | //saveError = "test error"; |
2555 | if ( !saveError.isEmpty() ) { | 2554 | if ( !saveError.isEmpty() ) { |
2556 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; | 2555 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; |
2557 | KMessageBox::error(this, saveError, i18n("Error saving data")); | 2556 | KMessageBox::error(this, saveError, i18n("Error saving data")); |
2558 | return false; | 2557 | return false; |
2559 | } | 2558 | } |
2560 | return true; | 2559 | return true; |
2561 | } | 2560 | } |
2562 | bool CalendarView::saveCalendar( QString filename ) | 2561 | bool CalendarView::saveCalendar( QString filename ) |
2563 | { | 2562 | { |
2564 | 2563 | ||
2565 | // Store back all unsaved data into calendar object | 2564 | // Store back all unsaved data into calendar object |
2566 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2565 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2567 | if ( mViewManager->currentView() ) | 2566 | if ( mViewManager->currentView() ) |
2568 | mViewManager->currentView()->flushView(); | 2567 | mViewManager->currentView()->flushView(); |
2569 | 2568 | ||
2570 | 2569 | ||
2571 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2570 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2572 | mStorage->setSaveFormat( new ICalFormat() ); | 2571 | mStorage->setSaveFormat( new ICalFormat() ); |
2573 | mStorage->setFileName( filename ); | 2572 | mStorage->setFileName( filename ); |
2574 | bool success; | 2573 | bool success; |
2575 | success = mStorage->save(); | 2574 | success = mStorage->save(); |
2576 | if ( !success ) { | 2575 | if ( !success ) { |
2577 | return false; | 2576 | return false; |
2578 | } | 2577 | } |
2579 | if ( filename == MainWindow::defaultFileName() ) { | 2578 | if ( filename == MainWindow::defaultFileName() ) { |
2580 | setLoadedFileVersion( lfv ); | 2579 | setLoadedFileVersion( lfv ); |
2581 | watchSavedFile(); | 2580 | watchSavedFile(); |
2582 | } | 2581 | } |
2583 | return true; | 2582 | return true; |
2584 | } | 2583 | } |
2585 | 2584 | ||
2586 | void CalendarView::closeCalendar() | 2585 | void CalendarView::closeCalendar() |
2587 | { | 2586 | { |
2588 | 2587 | ||
2589 | // child windows no longer valid | 2588 | // child windows no longer valid |
2590 | clearAllViews(); | 2589 | clearAllViews(); |
2591 | emit closingDown(); | 2590 | emit closingDown(); |
2592 | 2591 | ||
2593 | mCalendar->close(); | 2592 | mCalendar->close(); |
2594 | setModified(false); | 2593 | setModified(false); |
2595 | updateView(); | 2594 | updateView(); |
2596 | } | 2595 | } |
2597 | 2596 | ||
2598 | void CalendarView::archiveCalendar() | 2597 | void CalendarView::archiveCalendar() |
2599 | { | 2598 | { |
2600 | mDialogManager->showArchiveDialog(); | 2599 | mDialogManager->showArchiveDialog(); |
2601 | } | 2600 | } |
2602 | 2601 | ||
2603 | 2602 | ||
2604 | void CalendarView::readSettings() | 2603 | void CalendarView::readSettings() |
2605 | { | 2604 | { |
2606 | 2605 | ||
2607 | 2606 | ||
2608 | // mViewManager->showAgendaView(); | 2607 | // mViewManager->showAgendaView(); |
2609 | QString str; | 2608 | QString str; |
2610 | //qDebug("CalendarView::readSettings() "); | 2609 | //qDebug("CalendarView::readSettings() "); |
2611 | // read settings from the KConfig, supplying reasonable | 2610 | // read settings from the KConfig, supplying reasonable |
2612 | // defaults where none are to be found | 2611 | // defaults where none are to be found |
2613 | KConfig *config = KOGlobals::config(); | 2612 | KConfig *config = KOGlobals::config(); |
2614 | #ifndef KORG_NOSPLITTER | 2613 | #ifndef KORG_NOSPLITTER |
2615 | config->setGroup("KOrganizer Geometry"); | 2614 | config->setGroup("KOrganizer Geometry"); |
2616 | 2615 | ||
2617 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2616 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2618 | if (sizes.count() != 2) { | 2617 | if (sizes.count() != 2) { |
2619 | sizes << mDateNavigator->minimumSizeHint().width(); | 2618 | sizes << mDateNavigator->minimumSizeHint().width(); |
2620 | sizes << 300; | 2619 | sizes << 300; |
2621 | } | 2620 | } |
2622 | mPanner->setSizes(sizes); | 2621 | mPanner->setSizes(sizes); |
2623 | 2622 | ||
2624 | sizes = config->readIntListEntry("Separator2"); | 2623 | sizes = config->readIntListEntry("Separator2"); |
2625 | if ( ( mResourceView && sizes.count() == 4 ) || | 2624 | if ( ( mResourceView && sizes.count() == 4 ) || |
2626 | ( !mResourceView && sizes.count() == 3 ) ) { | 2625 | ( !mResourceView && sizes.count() == 3 ) ) { |
2627 | mLeftSplitter->setSizes(sizes); | 2626 | mLeftSplitter->setSizes(sizes); |
2628 | } | 2627 | } |
2629 | #endif | 2628 | #endif |
2630 | globalFlagBlockAgenda = 1; | 2629 | globalFlagBlockAgenda = 1; |
2631 | mViewManager->showAgendaView(); | 2630 | mViewManager->showAgendaView(); |
2632 | //mViewManager->readSettings( config ); | 2631 | //mViewManager->readSettings( config ); |
2633 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2632 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2634 | readFilterSettings(config); | 2633 | readFilterSettings(config); |
2635 | 2634 | ||
2636 | #ifdef DESKTOP_VERSION | 2635 | #ifdef DESKTOP_VERSION |
2637 | config->setGroup("WidgetLayout"); | 2636 | config->setGroup("WidgetLayout"); |
2638 | QStringList list; | 2637 | QStringList list; |
2639 | list = config->readListEntry("MainLayout"); | 2638 | list = config->readListEntry("MainLayout"); |
2640 | int x,y,w,h; | 2639 | int x,y,w,h; |
2641 | if ( ! list.isEmpty() ) { | 2640 | if ( ! list.isEmpty() ) { |
2642 | x = list[0].toInt(); | 2641 | x = list[0].toInt(); |
2643 | y = list[1].toInt(); | 2642 | y = list[1].toInt(); |
2644 | w = list[2].toInt(); | 2643 | w = list[2].toInt(); |
2645 | h = list[3].toInt(); | 2644 | h = list[3].toInt(); |
2646 | KApplication::testCoords( &x,&y,&w,&h ); | 2645 | KApplication::testCoords( &x,&y,&w,&h ); |
2647 | topLevelWidget()->setGeometry(x,y,w,h); | 2646 | topLevelWidget()->setGeometry(x,y,w,h); |
2648 | 2647 | ||
2649 | } else { | 2648 | } else { |
2650 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2649 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2651 | } | 2650 | } |
2652 | list = config->readListEntry("EditEventLayout"); | 2651 | list = config->readListEntry("EditEventLayout"); |
2653 | if ( ! list.isEmpty() ) { | 2652 | if ( ! list.isEmpty() ) { |
2654 | x = list[0].toInt(); | 2653 | x = list[0].toInt(); |
2655 | y = list[1].toInt(); | 2654 | y = list[1].toInt(); |
2656 | w = list[2].toInt(); | 2655 | w = list[2].toInt(); |
2657 | h = list[3].toInt(); | 2656 | h = list[3].toInt(); |
2658 | KApplication::testCoords( &x,&y,&w,&h ); | 2657 | KApplication::testCoords( &x,&y,&w,&h ); |
2659 | mEventEditor->setGeometry(x,y,w,h); | 2658 | mEventEditor->setGeometry(x,y,w,h); |
2660 | 2659 | ||
2661 | } | 2660 | } |
2662 | list = config->readListEntry("EditTodoLayout"); | 2661 | list = config->readListEntry("EditTodoLayout"); |
2663 | if ( ! list.isEmpty() ) { | 2662 | if ( ! list.isEmpty() ) { |
2664 | x = list[0].toInt(); | 2663 | x = list[0].toInt(); |
2665 | y = list[1].toInt(); | 2664 | y = list[1].toInt(); |
2666 | w = list[2].toInt(); | 2665 | w = list[2].toInt(); |
2667 | h = list[3].toInt(); | 2666 | h = list[3].toInt(); |
2668 | KApplication::testCoords( &x,&y,&w,&h ); | 2667 | KApplication::testCoords( &x,&y,&w,&h ); |
2669 | mTodoEditor->setGeometry(x,y,w,h); | 2668 | mTodoEditor->setGeometry(x,y,w,h); |
2670 | 2669 | ||
2671 | } | 2670 | } |
2672 | list = config->readListEntry("ViewerLayout"); | 2671 | list = config->readListEntry("ViewerLayout"); |
2673 | if ( ! list.isEmpty() ) { | 2672 | if ( ! list.isEmpty() ) { |
2674 | x = list[0].toInt(); | 2673 | x = list[0].toInt(); |
2675 | y = list[1].toInt(); | 2674 | y = list[1].toInt(); |
2676 | w = list[2].toInt(); | 2675 | w = list[2].toInt(); |
2677 | h = list[3].toInt(); | 2676 | h = list[3].toInt(); |
2678 | KApplication::testCoords( &x,&y,&w,&h ); | 2677 | KApplication::testCoords( &x,&y,&w,&h ); |
2679 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2678 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2680 | } | 2679 | } |
2681 | #endif | 2680 | #endif |
2682 | config->setGroup( "Views" ); | 2681 | config->setGroup( "Views" ); |
2683 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2682 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2684 | 2683 | ||
2685 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2684 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2686 | 2685 | ||
2687 | int resetval = 0; | 2686 | int resetval = 0; |
2688 | int maxVal = 0; | 2687 | int maxVal = 0; |
2689 | if (sizes.count() != 3) { | 2688 | if (sizes.count() != 3) { |
2690 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2689 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2691 | resetval = mDateNavigator->sizeHint().width()+2; | 2690 | resetval = mDateNavigator->sizeHint().width()+2; |
2692 | } else { | 2691 | } else { |
2693 | resetval = mDateNavigator->sizeHint().height()+2; | 2692 | resetval = mDateNavigator->sizeHint().height()+2; |
2694 | } | 2693 | } |
2695 | } | 2694 | } |
2696 | if ( resetval ) { | 2695 | if ( resetval ) { |
2697 | sizes.clear(); | 2696 | sizes.clear(); |
2698 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2697 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2699 | maxVal = QApplication::desktop()->width() -10; | 2698 | maxVal = QApplication::desktop()->width() -10; |
2700 | } else { | 2699 | } else { |
2701 | maxVal = QApplication::desktop()->height()-10; | 2700 | maxVal = QApplication::desktop()->height()-10; |
2702 | } | 2701 | } |
2703 | sizes << resetval; | 2702 | sizes << resetval; |
2704 | if ( maxVal < resetval + resetval) | 2703 | if ( maxVal < resetval + resetval) |
2705 | resetval = maxVal - resetval; | 2704 | resetval = maxVal - resetval; |
2706 | sizes << resetval; | 2705 | sizes << resetval; |
2707 | sizes << 100; | 2706 | sizes << 100; |
2708 | } | 2707 | } |
2709 | mLeftFrame->setSizes(sizes); | 2708 | mLeftFrame->setSizes(sizes); |
2710 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2709 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2711 | resetval = 0; | 2710 | resetval = 0; |
2712 | maxVal = 0; | 2711 | maxVal = 0; |
2713 | if (sizes.count() != 2) { | 2712 | if (sizes.count() != 2) { |
2714 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2713 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2715 | resetval = mDateNavigator->sizeHint().width()+2; | 2714 | resetval = mDateNavigator->sizeHint().width()+2; |
2716 | } else { | 2715 | } else { |
2717 | resetval = mDateNavigator->sizeHint().height()+2; | 2716 | resetval = mDateNavigator->sizeHint().height()+2; |
2718 | } | 2717 | } |
2719 | } | 2718 | } |
2720 | if ( resetval ) { | 2719 | if ( resetval ) { |
2721 | sizes.clear(); | 2720 | sizes.clear(); |
2722 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2721 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2723 | maxVal = QApplication::desktop()->width() -10; | 2722 | maxVal = QApplication::desktop()->width() -10; |
2724 | } else { | 2723 | } else { |
2725 | maxVal = QApplication::desktop()->height()-10; | 2724 | maxVal = QApplication::desktop()->height()-10; |
2726 | } | 2725 | } |
2727 | sizes << resetval; | 2726 | sizes << resetval; |
2728 | if ( maxVal < resetval + resetval) | 2727 | if ( maxVal < resetval + resetval) |
2729 | resetval = maxVal - resetval; | 2728 | resetval = maxVal - resetval; |
2730 | sizes << resetval; | 2729 | sizes << resetval; |
2731 | } | 2730 | } |
2732 | mMainFrame->setSizes(sizes); | 2731 | mMainFrame->setSizes(sizes); |
2733 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2732 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2734 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2733 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2735 | else mNavigator->selectDates( dateCount ); | 2734 | else mNavigator->selectDates( dateCount ); |
2736 | // mViewManager->readSettings( config ); | 2735 | // mViewManager->readSettings( config ); |
2737 | updateConfig(); | 2736 | updateConfig(); |
2738 | globalFlagBlockAgenda = 2; | 2737 | globalFlagBlockAgenda = 2; |
2739 | mViewManager->readSettings( config ); | 2738 | mViewManager->readSettings( config ); |
2740 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2739 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2741 | } | 2740 | } |
2742 | 2741 | ||
2743 | void CalendarView::checkSuspendAlarm() | 2742 | void CalendarView::checkSuspendAlarm() |
2744 | { | 2743 | { |
2745 | if ( mSuspendTimer->isActive() ) { | 2744 | if ( mSuspendTimer->isActive() ) { |
2746 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2745 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2747 | } | 2746 | } |
2748 | } | 2747 | } |
2749 | void CalendarView::writeSettings() | 2748 | void CalendarView::writeSettings() |
2750 | { | 2749 | { |
2751 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2750 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2752 | 2751 | ||
2753 | KConfig *config = KOGlobals::config(); | 2752 | KConfig *config = KOGlobals::config(); |
2754 | 2753 | ||
2755 | mViewManager->writeSettings( config ); | 2754 | mViewManager->writeSettings( config ); |
2756 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2755 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2757 | mDialogManager->writeSettings( config ); | 2756 | mDialogManager->writeSettings( config ); |
2758 | //KOPrefs::instance()->usrWriteConfig(); | 2757 | //KOPrefs::instance()->usrWriteConfig(); |
2759 | KOPrefs::instance()->writeConfig(); | 2758 | KOPrefs::instance()->writeConfig(); |
2760 | 2759 | ||
2761 | writeFilterSettings(config); | 2760 | writeFilterSettings(config); |
2762 | config->setGroup( "AppRun" ); | 2761 | config->setGroup( "AppRun" ); |
2763 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2762 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2764 | int days = dt.daysTo( QDate::currentDate() ); | 2763 | int days = dt.daysTo( QDate::currentDate() ); |
2765 | dt = dt.addDays( days ); | 2764 | dt = dt.addDays( days ); |
2766 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2765 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2767 | config->writeEntry( "LatestProgramStopDays", days ); | 2766 | config->writeEntry( "LatestProgramStopDays", days ); |
2768 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2767 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2769 | //qDebug("KO: Writing stop time: %d ", secs); | 2768 | //qDebug("KO: Writing stop time: %d ", secs); |
2770 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2769 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2771 | //QDateTime latest = dt.addSecs ( secs ); | 2770 | //QDateTime latest = dt.addSecs ( secs ); |
2772 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2771 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2773 | config->setGroup( "Views" ); | 2772 | config->setGroup( "Views" ); |
2774 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2773 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2775 | 2774 | ||
2776 | #if 0 | 2775 | #if 0 |
2777 | qDebug("********************* "); | 2776 | qDebug("********************* "); |
2778 | qDebug("Testcode secsto "); | 2777 | qDebug("Testcode secsto "); |
2779 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2778 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2780 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2779 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2781 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2780 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2782 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2781 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2783 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2782 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2784 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2783 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2785 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2784 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2786 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2785 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2787 | qDebug("********************* testcode end"); | 2786 | qDebug("********************* testcode end"); |
2788 | 2787 | ||
2789 | #endif | 2788 | #endif |
2790 | 2789 | ||
2791 | QValueList<int> listINT = mLeftFrame->sizes(); | 2790 | QValueList<int> listINT = mLeftFrame->sizes(); |
2792 | config->writeEntry("Left Splitter Frame",listINT); | 2791 | config->writeEntry("Left Splitter Frame",listINT); |
2793 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2792 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2794 | config->writeEntry("Main Splitter Frame",listINT2); | 2793 | config->writeEntry("Main Splitter Frame",listINT2); |
2795 | #ifdef DESKTOP_VERSION | 2794 | #ifdef DESKTOP_VERSION |
2796 | config->setGroup("WidgetLayout"); | 2795 | config->setGroup("WidgetLayout"); |
2797 | QStringList list ;//= config->readListEntry("MainLayout"); | 2796 | QStringList list ;//= config->readListEntry("MainLayout"); |
2798 | int x,y,w,h; | 2797 | int x,y,w,h; |
2799 | QWidget* wid; | 2798 | QWidget* wid; |
2800 | wid = topLevelWidget(); | 2799 | wid = topLevelWidget(); |
2801 | x = wid->geometry().x(); | 2800 | x = wid->geometry().x(); |
2802 | y = wid->geometry().y(); | 2801 | y = wid->geometry().y(); |
2803 | w = wid->width(); | 2802 | w = wid->width(); |
2804 | h = wid->height(); | 2803 | h = wid->height(); |
2805 | list.clear(); | 2804 | list.clear(); |
2806 | list << QString::number( x ); | 2805 | list << QString::number( x ); |
2807 | list << QString::number( y ); | 2806 | list << QString::number( y ); |
2808 | list << QString::number( w ); | 2807 | list << QString::number( w ); |
2809 | list << QString::number( h ); | 2808 | list << QString::number( h ); |
2810 | config->writeEntry("MainLayout",list ); | 2809 | config->writeEntry("MainLayout",list ); |
2811 | 2810 | ||
2812 | wid = mEventEditor; | 2811 | wid = mEventEditor; |
2813 | x = wid->geometry().x(); | 2812 | x = wid->geometry().x(); |
2814 | y = wid->geometry().y(); | 2813 | y = wid->geometry().y(); |
2815 | w = wid->width(); | 2814 | w = wid->width(); |
2816 | h = wid->height(); | 2815 | h = wid->height(); |
2817 | list.clear(); | 2816 | list.clear(); |
2818 | list << QString::number( x ); | 2817 | list << QString::number( x ); |
2819 | list << QString::number( y ); | 2818 | list << QString::number( y ); |
2820 | list << QString::number( w ); | 2819 | list << QString::number( w ); |
2821 | list << QString::number( h ); | 2820 | list << QString::number( h ); |
2822 | config->writeEntry("EditEventLayout",list ); | 2821 | config->writeEntry("EditEventLayout",list ); |
2823 | 2822 | ||
2824 | wid = mTodoEditor; | 2823 | wid = mTodoEditor; |
2825 | x = wid->geometry().x(); | 2824 | x = wid->geometry().x(); |
2826 | y = wid->geometry().y(); | 2825 | y = wid->geometry().y(); |
2827 | w = wid->width(); | 2826 | w = wid->width(); |
2828 | h = wid->height(); | 2827 | h = wid->height(); |
2829 | list.clear(); | 2828 | list.clear(); |
2830 | list << QString::number( x ); | 2829 | list << QString::number( x ); |
2831 | list << QString::number( y ); | 2830 | list << QString::number( y ); |
2832 | list << QString::number( w ); | 2831 | list << QString::number( w ); |
2833 | list << QString::number( h ); | 2832 | list << QString::number( h ); |
2834 | config->writeEntry("EditTodoLayout",list ); | 2833 | config->writeEntry("EditTodoLayout",list ); |
2835 | wid = getEventViewerDialog(); | 2834 | wid = getEventViewerDialog(); |
2836 | x = wid->geometry().x(); | 2835 | x = wid->geometry().x(); |
2837 | y = wid->geometry().y(); | 2836 | y = wid->geometry().y(); |
2838 | w = wid->width(); | 2837 | w = wid->width(); |
2839 | h = wid->height(); | 2838 | h = wid->height(); |
2840 | list.clear(); | 2839 | list.clear(); |
2841 | list << QString::number( x ); | 2840 | list << QString::number( x ); |
2842 | list << QString::number( y ); | 2841 | list << QString::number( y ); |
2843 | list << QString::number( w ); | 2842 | list << QString::number( w ); |
2844 | list << QString::number( h ); | 2843 | list << QString::number( h ); |
2845 | config->writeEntry("ViewerLayout",list ); | 2844 | config->writeEntry("ViewerLayout",list ); |
2846 | wid = mDialogManager->getSearchDialog(); | 2845 | wid = mDialogManager->getSearchDialog(); |
2847 | if ( wid ) { | 2846 | if ( wid ) { |
2848 | x = wid->geometry().x(); | 2847 | x = wid->geometry().x(); |
2849 | y = wid->geometry().y(); | 2848 | y = wid->geometry().y(); |
2850 | w = wid->width(); | 2849 | w = wid->width(); |
2851 | h = wid->height(); | 2850 | h = wid->height(); |
2852 | list.clear(); | 2851 | list.clear(); |
2853 | list << QString::number( x ); | 2852 | list << QString::number( x ); |
2854 | list << QString::number( y ); | 2853 | list << QString::number( y ); |
2855 | list << QString::number( w ); | 2854 | list << QString::number( w ); |
2856 | list << QString::number( h ); | 2855 | list << QString::number( h ); |
2857 | config->writeEntry("SearchLayout",list ); | 2856 | config->writeEntry("SearchLayout",list ); |
2858 | } | 2857 | } |
2859 | #endif | 2858 | #endif |
2860 | 2859 | ||
2861 | 2860 | ||
2862 | config->sync(); | 2861 | config->sync(); |
2863 | } | 2862 | } |
2864 | 2863 | ||
2865 | void CalendarView::readFilterSettings(KConfig *config) | 2864 | void CalendarView::readFilterSettings(KConfig *config) |
2866 | { | 2865 | { |
2867 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2866 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2868 | 2867 | ||
2869 | mFilters.clear(); | 2868 | mFilters.clear(); |
2870 | 2869 | ||
2871 | config->setGroup("General"); | 2870 | config->setGroup("General"); |
2872 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2871 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2873 | 2872 | ||
2874 | QStringList::ConstIterator it = filterList.begin(); | 2873 | QStringList::ConstIterator it = filterList.begin(); |
2875 | QStringList::ConstIterator end = filterList.end(); | 2874 | QStringList::ConstIterator end = filterList.end(); |
2876 | while(it != end) { | 2875 | while(it != end) { |
2877 | // kdDebug() << " filter: " << (*it) << endl; | 2876 | // kdDebug() << " filter: " << (*it) << endl; |
2878 | 2877 | ||
2879 | CalFilter *filter; | 2878 | CalFilter *filter; |
2880 | filter = new CalFilter(*it); | 2879 | filter = new CalFilter(*it); |
2881 | config->setGroup("Filter_" + (*it).utf8()); | 2880 | config->setGroup("Filter_" + (*it).utf8()); |
2882 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2881 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2883 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2882 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2884 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2883 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2885 | mFilters.append(filter); | 2884 | mFilters.append(filter); |
2886 | 2885 | ||
2887 | ++it; | 2886 | ++it; |
2888 | } | 2887 | } |
2889 | 2888 | ||
2890 | if (mFilters.count() == 0) { | 2889 | if (mFilters.count() == 0) { |
2891 | CalFilter *filter = new CalFilter(i18n("Default")); | 2890 | CalFilter *filter = new CalFilter(i18n("Default")); |
2892 | mFilters.append(filter); | 2891 | mFilters.append(filter); |
2893 | } | 2892 | } |
2894 | mFilterView->updateFilters(); | 2893 | mFilterView->updateFilters(); |
2895 | config->setGroup("FilterView"); | 2894 | config->setGroup("FilterView"); |
2896 | 2895 | ||
2897 | mFilterView->blockSignals(true); | 2896 | mFilterView->blockSignals(true); |
2898 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2897 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2899 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2898 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2900 | mFilterView->blockSignals(false); | 2899 | mFilterView->blockSignals(false); |
2901 | // We do it manually to avoid it being done twice by the above calls | 2900 | // We do it manually to avoid it being done twice by the above calls |
2902 | updateFilter(); | 2901 | updateFilter(); |
2903 | } | 2902 | } |
2904 | 2903 | ||
2905 | void CalendarView::writeFilterSettings(KConfig *config) | 2904 | void CalendarView::writeFilterSettings(KConfig *config) |
2906 | { | 2905 | { |
2907 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2906 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2908 | 2907 | ||
2909 | QStringList filterList; | 2908 | QStringList filterList; |
2910 | 2909 | ||
2911 | CalFilter *filter = mFilters.first(); | 2910 | CalFilter *filter = mFilters.first(); |
2912 | while(filter) { | 2911 | while(filter) { |
2913 | // kdDebug() << " fn: " << filter->name() << endl; | 2912 | // kdDebug() << " fn: " << filter->name() << endl; |
2914 | filterList << filter->name(); | 2913 | filterList << filter->name(); |
2915 | config->setGroup("Filter_" + filter->name().utf8()); | 2914 | config->setGroup("Filter_" + filter->name().utf8()); |
2916 | config->writeEntry("Criteria",filter->criteria()); | 2915 | config->writeEntry("Criteria",filter->criteria()); |
2917 | config->writeEntry("CategoryList",filter->categoryList()); | 2916 | config->writeEntry("CategoryList",filter->categoryList()); |
2918 | filter = mFilters.next(); | 2917 | filter = mFilters.next(); |
2919 | } | 2918 | } |
2920 | config->setGroup("General"); | 2919 | config->setGroup("General"); |
2921 | config->writeEntry("CalendarFilters",filterList); | 2920 | config->writeEntry("CalendarFilters",filterList); |
2922 | 2921 | ||
2923 | config->setGroup("FilterView"); | 2922 | config->setGroup("FilterView"); |
2924 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2923 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2925 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2924 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2926 | } | 2925 | } |
2927 | 2926 | ||
2928 | 2927 | ||
2929 | void CalendarView::goToday() | 2928 | void CalendarView::goToday() |
2930 | { | 2929 | { |
2931 | if ( mViewManager->currentView()->isMonthView() ) | 2930 | if ( mViewManager->currentView()->isMonthView() ) |
2932 | mNavigator->selectTodayMonth(); | 2931 | mNavigator->selectTodayMonth(); |
2933 | else | 2932 | else |
2934 | mNavigator->selectToday(); | 2933 | mNavigator->selectToday(); |
2935 | } | 2934 | } |
2936 | 2935 | ||
2937 | void CalendarView::goNext() | 2936 | void CalendarView::goNext() |
2938 | { | 2937 | { |
2939 | mNavigator->selectNext(); | 2938 | mNavigator->selectNext(); |
2940 | } | 2939 | } |
2941 | 2940 | ||
2942 | void CalendarView::goPrevious() | 2941 | void CalendarView::goPrevious() |
2943 | { | 2942 | { |
2944 | mNavigator->selectPrevious(); | 2943 | mNavigator->selectPrevious(); |
2945 | } | 2944 | } |
2946 | void CalendarView::goNextMonth() | 2945 | void CalendarView::goNextMonth() |
2947 | { | 2946 | { |
2948 | mNavigator->selectNextMonth(); | 2947 | mNavigator->selectNextMonth(); |
2949 | } | 2948 | } |
2950 | 2949 | ||
2951 | void CalendarView::goPreviousMonth() | 2950 | void CalendarView::goPreviousMonth() |
2952 | { | 2951 | { |
2953 | mNavigator->selectPreviousMonth(); | 2952 | mNavigator->selectPreviousMonth(); |
2954 | } | 2953 | } |
2955 | 2954 | ||
2956 | void CalendarView::updateConfig() | 2955 | void CalendarView::updateConfig() |
2957 | { | 2956 | { |
2958 | if ( KOPrefs::instance()->mUseAppColors ) | 2957 | if ( KOPrefs::instance()->mUseAppColors ) |
2959 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2958 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2960 | emit configChanged(); | 2959 | emit configChanged(); |
2961 | mTodoList->updateConfig(); | 2960 | mTodoList->updateConfig(); |
2962 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2961 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2963 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2962 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2964 | // To make the "fill window" configurations work | 2963 | // To make the "fill window" configurations work |
2965 | //mViewManager->raiseCurrentView(); | 2964 | //mViewManager->raiseCurrentView(); |
2966 | } | 2965 | } |
2967 | 2966 | ||
2968 | 2967 | ||
2969 | void CalendarView::eventChanged(Event *event) | 2968 | void CalendarView::eventChanged(Event *event) |
2970 | { | 2969 | { |
2971 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2970 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2972 | //updateUnmanagedViews(); | 2971 | //updateUnmanagedViews(); |
2973 | } | 2972 | } |
2974 | 2973 | ||
2975 | void CalendarView::eventAdded(Event *event) | 2974 | void CalendarView::eventAdded(Event *event) |
2976 | { | 2975 | { |
2977 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2976 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2978 | } | 2977 | } |
2979 | 2978 | ||
2980 | void CalendarView::eventToBeDeleted(Event *) | 2979 | void CalendarView::eventToBeDeleted(Event *) |
2981 | { | 2980 | { |
2982 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2981 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2983 | } | 2982 | } |
2984 | 2983 | ||
2985 | void CalendarView::eventDeleted() | 2984 | void CalendarView::eventDeleted() |
2986 | { | 2985 | { |
2987 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2986 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2988 | } | 2987 | } |
2989 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2988 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2990 | { | 2989 | { |
2991 | changeIncidenceDisplay((Incidence *)which, action); | 2990 | changeIncidenceDisplay((Incidence *)which, action); |
2992 | mDateNavigator->updateView(); //LR | 2991 | mDateNavigator->updateView(); //LR |
2993 | //mDialogManager->updateSearchDialog(); | 2992 | //mDialogManager->updateSearchDialog(); |
2994 | 2993 | ||
2995 | if (which) { | 2994 | if (which) { |
2996 | mViewManager->updateWNview(); | 2995 | mViewManager->updateWNview(); |
2997 | //mTodoList->updateView(); | 2996 | //mTodoList->updateView(); |
2998 | } | 2997 | } |
2999 | 2998 | ||
3000 | } | 2999 | } |
3001 | 3000 | ||
3002 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 3001 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
3003 | { | 3002 | { |
3004 | updateUnmanagedViews(); | 3003 | updateUnmanagedViews(); |
3005 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 3004 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
3006 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 3005 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
3007 | mCalendar->checkAlarmForIncidence( 0, true ); | 3006 | mCalendar->checkAlarmForIncidence( 0, true ); |
3008 | if ( mEventViewerDialog ) | 3007 | if ( mEventViewerDialog ) |
3009 | mEventViewerDialog->hide(); | 3008 | mEventViewerDialog->hide(); |
3010 | } | 3009 | } |
3011 | else | 3010 | else |
3012 | mCalendar->checkAlarmForIncidence( which , false ); | 3011 | mCalendar->checkAlarmForIncidence( which , false ); |
3013 | } | 3012 | } |
3014 | 3013 | ||
3015 | // most of the changeEventDisplays() right now just call the view's | 3014 | // most of the changeEventDisplays() right now just call the view's |
3016 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 3015 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
3017 | void CalendarView::changeEventDisplay(Event *which, int action) | 3016 | void CalendarView::changeEventDisplay(Event *which, int action) |
3018 | { | 3017 | { |
3019 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 3018 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
3020 | changeIncidenceDisplay((Incidence *)which, action); | 3019 | changeIncidenceDisplay((Incidence *)which, action); |
3021 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 3020 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
3022 | if ( flag_clearallviewsEventDisplay ) { | 3021 | if ( flag_clearallviewsEventDisplay ) { |
3023 | clearAllViews(); | 3022 | clearAllViews(); |
3024 | flag_clearallviewsEventDisplay = false; | 3023 | flag_clearallviewsEventDisplay = false; |
3025 | } | 3024 | } |
3026 | return; | 3025 | return; |
3027 | } | 3026 | } |
3028 | flag_clearallviewsEventDisplay = true; | 3027 | flag_clearallviewsEventDisplay = true; |
3029 | mDateNavigator->updateView(); | 3028 | mDateNavigator->updateView(); |
3030 | //mDialogManager->updateSearchDialog(); | 3029 | //mDialogManager->updateSearchDialog(); |
3031 | if (which) { | 3030 | if (which) { |
3032 | // If there is an event view visible update the display | 3031 | // If there is an event view visible update the display |
3033 | mViewManager->currentView()->changeEventDisplay(which,action); | 3032 | mViewManager->currentView()->changeEventDisplay(which,action); |
3034 | // TODO: check, if update needed | 3033 | // TODO: check, if update needed |
3035 | // if (which->getTodoStatus()) { | 3034 | // if (which->getTodoStatus()) { |
3036 | mTodoList->updateView(); | 3035 | mTodoList->updateView(); |
3037 | if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { | 3036 | if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { |
3038 | mConflictingEvent = which ; | 3037 | mConflictingEvent = which ; |
3039 | int time = 1000; | 3038 | int time = 1000; |
3040 | #ifdef DESKTOP_VERSION | 3039 | #ifdef DESKTOP_VERSION |
3041 | time = 500; | 3040 | time = 500; |
3042 | #endif | 3041 | #endif |
3043 | bool checkC = false; | 3042 | bool checkC = false; |
3044 | if ( mConflictingEvent->doesFloat() ) { | 3043 | if ( mConflictingEvent->doesFloat() ) { |
3045 | checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay | 3044 | checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay |
3046 | || KOPrefs::instance()->mCheckConflictsAllDayNonAD; | 3045 | || KOPrefs::instance()->mCheckConflictsAllDayNonAD; |
3047 | } else { | 3046 | } else { |
3048 | checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay | 3047 | checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay |
3049 | || KOPrefs::instance()->mCheckConflictsNonADNonAD; | 3048 | || KOPrefs::instance()->mCheckConflictsNonADNonAD; |
3050 | } | 3049 | } |
3051 | if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) | 3050 | if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) |
3052 | checkC = false; | 3051 | checkC = false; |
3053 | if ( checkC ) | 3052 | if ( checkC ) |
3054 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); | 3053 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); |
3055 | } | 3054 | } |
3056 | // } | 3055 | // } |
3057 | } else { | 3056 | } else { |
3058 | mViewManager->currentView()->updateView(); | 3057 | mViewManager->currentView()->updateView(); |
3059 | } | 3058 | } |
3060 | } | 3059 | } |
3061 | void CalendarView::checkConflictForEvent() | 3060 | void CalendarView::checkConflictForEvent() |
3062 | { | 3061 | { |
3063 | 3062 | ||
3064 | if (!KOPrefs::instance()->mConfirm) | 3063 | if (!KOPrefs::instance()->mConfirm) |
3065 | return; | 3064 | return; |
3066 | if ( ! mConflictingEvent ) return; | 3065 | if ( ! mConflictingEvent ) return; |
3067 | Event * conflictingEvent = mConflictingEvent; | 3066 | Event * conflictingEvent = mConflictingEvent; |
3068 | mConflictingEvent = 0; | 3067 | mConflictingEvent = 0; |
3069 | QDateTime current = QDateTime::currentDateTime(); | 3068 | QDateTime current = QDateTime::currentDateTime(); |
3070 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { | 3069 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { |
3071 | return; | 3070 | return; |
3072 | } | 3071 | } |
3073 | CalFilter *filterIN = 0; | 3072 | CalFilter *filterIN = 0; |
3074 | CalFilter *filterALL = 0; | 3073 | CalFilter *filterALL = 0; |
3075 | CalFilter *filter = mFilters.first(); | 3074 | CalFilter *filter = mFilters.first(); |
3076 | while(filter) { | 3075 | while(filter) { |
3077 | if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) | 3076 | if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) |
3078 | filterIN = filter; | 3077 | filterIN = filter; |
3079 | if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) | 3078 | if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) |
3080 | filterALL = filter; | 3079 | filterALL = filter; |
3081 | filter = mFilters.next(); | 3080 | filter = mFilters.next(); |
3082 | } | 3081 | } |
3083 | if ( filterIN ) { | 3082 | if ( filterIN ) { |
3084 | if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { | 3083 | if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { |
3085 | return; | 3084 | return; |
3086 | } | 3085 | } |
3087 | } | 3086 | } |
3088 | QPtrList<Event> testlist = mCalendar->events(); | 3087 | QPtrList<Event> testlist = mCalendar->events(); |
3089 | Event * test = testlist.first(); | 3088 | Event * test = testlist.first(); |
3090 | QDateTime conflict; | 3089 | QDateTime conflict; |
3091 | QDateTime retVal; | 3090 | QDateTime retVal; |
3092 | bool found = false; | 3091 | bool found = false; |
3093 | Event * cE = 0; | 3092 | Event * cE = 0; |
3094 | bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; | 3093 | bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; |
3095 | bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; | 3094 | bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; |
3096 | if ( !conflictingEvent->doesFloat() ) { | 3095 | if ( !conflictingEvent->doesFloat() ) { |
3097 | chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; | 3096 | chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; |
3098 | chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; | 3097 | chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; |
3099 | } | 3098 | } |
3100 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 3099 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
3101 | while ( test ) { | 3100 | while ( test ) { |
3102 | qApp->processEvents(); | 3101 | qApp->processEvents(); |
3103 | bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); | 3102 | bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); |
3104 | 3103 | ||
3105 | if ( !skip ) { | 3104 | if ( !skip ) { |
3106 | if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) | 3105 | if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) |
3107 | skip = true; | 3106 | skip = true; |
3108 | } | 3107 | } |
3109 | if ( !skip ) { | 3108 | if ( !skip ) { |
3110 | if ( filterALL ) { | 3109 | if ( filterALL ) { |
3111 | if ( !filterALL->filterCalendarItem( test ) ) { | 3110 | if ( !filterALL->filterCalendarItem( test ) ) { |
3112 | skip = true; | 3111 | skip = true; |
3113 | } | 3112 | } |
3114 | } | 3113 | } |
3115 | if ( !skip ) { | 3114 | if ( !skip ) { |
3116 | if ( found ) | 3115 | if ( found ) |
3117 | skip = !test->matchTime( ¤t, &conflict ); | 3116 | skip = !test->matchTime( ¤t, &conflict ); |
3118 | else | 3117 | else |
3119 | skip = !test->matchTime( ¤t, 0 ); | 3118 | skip = !test->matchTime( ¤t, 0 ); |
3120 | if ( !skip ) { | 3119 | if ( !skip ) { |
3121 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 3120 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
3122 | if ( ! found ) { | 3121 | if ( ! found ) { |
3123 | conflict = retVal; | 3122 | conflict = retVal; |
3124 | cE = test; | 3123 | cE = test; |
3125 | } else { | 3124 | } else { |
3126 | if ( retVal < conflict ) { | 3125 | if ( retVal < conflict ) { |
3127 | conflict = retVal; | 3126 | conflict = retVal; |
3128 | cE = test; | 3127 | cE = test; |
3129 | } | 3128 | } |
3130 | } | 3129 | } |
3131 | found = true; | 3130 | found = true; |
3132 | } | 3131 | } |
3133 | } | 3132 | } |
3134 | } | 3133 | } |
3135 | } | 3134 | } |
3136 | test = testlist.next(); | 3135 | test = testlist.next(); |
3137 | } | 3136 | } |
3138 | topLevelWidget()->setCaption( i18n("KO/Pi") ); | 3137 | topLevelWidget()->setCaption( i18n("KO/Pi") ); |
3139 | if ( found ) { | 3138 | if ( found ) { |
3140 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 3139 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
3141 | qApp->processEvents(); | 3140 | qApp->processEvents(); |
3142 | int km = KMessageBox::warningContinueCancel(this,mess, | 3141 | int km = KMessageBox::warningContinueCancel(this,mess, |
3143 | i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); | 3142 | i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); |
3144 | if ( km != KMessageBox::Continue ) { | 3143 | if ( km != KMessageBox::Continue ) { |
3145 | return; | 3144 | return; |
3146 | } | 3145 | } |
3147 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 3146 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
3148 | mViewManager->showDayView(); | 3147 | mViewManager->showDayView(); |
3149 | mNavigator->slotDaySelect( conflict.date() ); | 3148 | mNavigator->slotDaySelect( conflict.date() ); |
3150 | int hour = conflict.time().hour(); | 3149 | int hour = conflict.time().hour(); |
3151 | mViewManager->agendaView()->setStartHour( hour ); | 3150 | mViewManager->agendaView()->setStartHour( hour ); |
3152 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 3151 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
3153 | } else | 3152 | } else |
3154 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 3153 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
3155 | return; | 3154 | return; |
3156 | 3155 | ||
3157 | } | 3156 | } |
3158 | 3157 | ||
3159 | void CalendarView::updateTodoViews() | 3158 | void CalendarView::updateTodoViews() |
3160 | { | 3159 | { |
3161 | mTodoList->updateView(); | 3160 | mTodoList->updateView(); |
3162 | mViewManager->currentView()->updateView(); | 3161 | mViewManager->currentView()->updateView(); |
3163 | 3162 | ||
3164 | } | 3163 | } |
3165 | 3164 | ||
3166 | 3165 | ||
3167 | 3166 | ||
3168 | void CalendarView::clearAllViews() | 3167 | void CalendarView::clearAllViews() |
3169 | { | 3168 | { |
3170 | mTodoList->clearList(); | 3169 | mTodoList->clearList(); |
3171 | mViewManager->clearAllViews(); | 3170 | mViewManager->clearAllViews(); |
3172 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 3171 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
3173 | if ( sd ) { | 3172 | if ( sd ) { |
3174 | KOListView* kol = sd->listview(); | 3173 | KOListView* kol = sd->listview(); |
3175 | if ( kol ) | 3174 | if ( kol ) |
3176 | kol->clearList(); | 3175 | kol->clearList(); |
3177 | } | 3176 | } |
3178 | } | 3177 | } |
3179 | void CalendarView::updateView() | 3178 | void CalendarView::updateView() |
3180 | { | 3179 | { |
3181 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 3180 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
3182 | if ( flag_clearallviewsupdateView ) { | 3181 | if ( flag_clearallviewsupdateView ) { |
3183 | clearAllViews(); | 3182 | clearAllViews(); |
3184 | flag_clearallviewsupdateView = false; | 3183 | flag_clearallviewsupdateView = false; |
3185 | } | 3184 | } |
3186 | return; | 3185 | return; |
3187 | } | 3186 | } |
3188 | flag_clearallviewsupdateView = true; | 3187 | flag_clearallviewsupdateView = true; |
3189 | DateList tmpList = mNavigator->selectedDates(); | 3188 | DateList tmpList = mNavigator->selectedDates(); |
3190 | 3189 | ||
3191 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 3190 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
3192 | mTodoList->updateView(); | 3191 | mTodoList->updateView(); |
3193 | // We assume that the navigator only selects consecutive days. | 3192 | // We assume that the navigator only selects consecutive days. |
3194 | updateView( tmpList.first(), tmpList.last() ); | 3193 | updateView( tmpList.first(), tmpList.last() ); |
3195 | } | 3194 | } |
3196 | 3195 | ||
3197 | void CalendarView::updateUnmanagedViews() | 3196 | void CalendarView::updateUnmanagedViews() |
3198 | { | 3197 | { |
3199 | mDateNavigator->updateDayMatrix(); | 3198 | mDateNavigator->updateDayMatrix(); |
3200 | } | 3199 | } |
3201 | 3200 | ||
3202 | int CalendarView::msgItemDelete(const QString name) | 3201 | int CalendarView::msgItemDelete(const QString name) |
3203 | { | 3202 | { |
3204 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 3203 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
3205 | i18n("This item will be\npermanently deleted."), | 3204 | i18n("This item will be\npermanently deleted."), |
3206 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 3205 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
3207 | } | 3206 | } |
3208 | 3207 | ||
3209 | 3208 | ||
3210 | void CalendarView::edit_cut() | 3209 | void CalendarView::edit_cut() |
3211 | { | 3210 | { |
3212 | Event *anEvent=0; | 3211 | Event *anEvent=0; |
3213 | 3212 | ||
3214 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3213 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3215 | 3214 | ||
3216 | if (mViewManager->currentView()->isEventView()) { | 3215 | if (mViewManager->currentView()->isEventView()) { |
3217 | if ( incidence && incidence->typeID() == eventID ) { | 3216 | if ( incidence && incidence->typeID() == eventID ) { |
3218 | anEvent = static_cast<Event *>(incidence); | 3217 | anEvent = static_cast<Event *>(incidence); |
3219 | } | 3218 | } |
3220 | } | 3219 | } |
3221 | 3220 | ||
3222 | if (!anEvent) { | 3221 | if (!anEvent) { |
3223 | KNotifyClient::beep(); | 3222 | KNotifyClient::beep(); |
3224 | return; | 3223 | return; |
3225 | } | 3224 | } |
3226 | DndFactory factory( mCalendar ); | 3225 | DndFactory factory( mCalendar ); |
3227 | factory.cutIncidence(anEvent); | 3226 | factory.cutIncidence(anEvent); |
3228 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3227 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3229 | } | 3228 | } |
3230 | 3229 | ||
3231 | void CalendarView::edit_copy() | 3230 | void CalendarView::edit_copy() |
3232 | { | 3231 | { |
3233 | Event *anEvent=0; | 3232 | Event *anEvent=0; |
3234 | 3233 | ||
3235 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3234 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3236 | 3235 | ||
3237 | if (mViewManager->currentView()->isEventView()) { | 3236 | if (mViewManager->currentView()->isEventView()) { |
3238 | if ( incidence && incidence->typeID() == eventID ) { | 3237 | if ( incidence && incidence->typeID() == eventID ) { |
3239 | anEvent = static_cast<Event *>(incidence); | 3238 | anEvent = static_cast<Event *>(incidence); |
3240 | } | 3239 | } |
3241 | } | 3240 | } |
3242 | 3241 | ||
3243 | if (!anEvent) { | 3242 | if (!anEvent) { |
3244 | KNotifyClient::beep(); | 3243 | KNotifyClient::beep(); |
3245 | return; | 3244 | return; |
3246 | } | 3245 | } |
3247 | DndFactory factory( mCalendar ); | 3246 | DndFactory factory( mCalendar ); |
3248 | factory.copyIncidence(anEvent); | 3247 | factory.copyIncidence(anEvent); |
3249 | } | 3248 | } |
3250 | 3249 | ||
3251 | void CalendarView::edit_paste() | 3250 | void CalendarView::edit_paste() |
3252 | { | 3251 | { |
3253 | QDate date = mNavigator->selectedDates().first(); | 3252 | QDate date = mNavigator->selectedDates().first(); |
3254 | 3253 | ||
3255 | DndFactory factory( mCalendar ); | 3254 | DndFactory factory( mCalendar ); |
3256 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 3255 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
3257 | 3256 | ||
3258 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 3257 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
3259 | } | 3258 | } |
3260 | void CalendarView::edit_global_options() | 3259 | void CalendarView::edit_global_options() |
3261 | { | 3260 | { |
3262 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 3261 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
3263 | emit save(); | 3262 | emit save(); |
3264 | emit saveStopTimer(); | 3263 | emit saveStopTimer(); |
3265 | mDialogManager->showGlobalOptionsDialog(); | 3264 | mDialogManager->showGlobalOptionsDialog(); |
3266 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 3265 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
3267 | emit saveStopTimer(); | 3266 | emit saveStopTimer(); |
3268 | 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!"), | 3267 | 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!"), |
3269 | i18n("Timezone settings"),i18n("Reload"))) { | 3268 | i18n("Timezone settings"),i18n("Reload"))) { |
3270 | qDebug("KO: TZ reload cancelled "); | 3269 | qDebug("KO: TZ reload cancelled "); |
3271 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3270 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3272 | return; | 3271 | return; |
3273 | } | 3272 | } |
3274 | qDebug("KO: Timezone change "); | 3273 | qDebug("KO: Timezone change "); |
3275 | loadCalendars(); | 3274 | loadCalendars(); |
3276 | setModified(true); | 3275 | setModified(true); |
3277 | } | 3276 | } |
3278 | else | 3277 | else |
3279 | qDebug("KO: No tz change "); | 3278 | qDebug("KO: No tz change "); |
3280 | } | 3279 | } |
3281 | void CalendarView::edit_options() | 3280 | void CalendarView::edit_options() |
3282 | { | 3281 | { |
3283 | mDialogManager->showOptionsDialog(); | 3282 | mDialogManager->showOptionsDialog(); |
3284 | } | 3283 | } |
3285 | 3284 | ||
3286 | 3285 | ||
3287 | void CalendarView::slotSelectPickerDate( QDate d) | 3286 | void CalendarView::slotSelectPickerDate( QDate d) |
3288 | { | 3287 | { |
3289 | mDateFrame->hide(); | 3288 | mDateFrame->hide(); |
3290 | if ( mDatePickerMode == 1 ) { | 3289 | if ( mDatePickerMode == 1 ) { |
3291 | mNavigator->slotDaySelect( d ); | 3290 | mNavigator->slotDaySelect( d ); |
3292 | } else if ( mDatePickerMode == 2 ) { | 3291 | } else if ( mDatePickerMode == 2 ) { |
3293 | if ( mMoveIncidence->typeID() == todoID ) { | 3292 | if ( mMoveIncidence->typeID() == todoID ) { |
3294 | Todo * to = (Todo *) mMoveIncidence; | 3293 | Todo * to = (Todo *) mMoveIncidence; |
3295 | QTime tim; | 3294 | QTime tim; |
3296 | int len = 0; | 3295 | int len = 0; |
3297 | if ( to->hasStartDate() && to->hasDueDate() ) | 3296 | if ( to->hasStartDate() && to->hasDueDate() ) |
3298 | len = to->dtStart().secsTo( to->dtDue()); | 3297 | len = to->dtStart().secsTo( to->dtDue()); |
3299 | if ( to->hasDueDate() ) | 3298 | if ( to->hasDueDate() ) |
3300 | tim = to->dtDue().time(); | 3299 | tim = to->dtDue().time(); |
3301 | else { | 3300 | else { |
3302 | tim = QTime ( 0,0,0 ); | 3301 | tim = QTime ( 0,0,0 ); |
3303 | to->setFloats( true ); | 3302 | to->setFloats( true ); |
3304 | to->setHasDueDate( true ); | 3303 | to->setHasDueDate( true ); |
3305 | } | 3304 | } |
3306 | QDateTime dt ( d,tim ); | 3305 | QDateTime dt ( d,tim ); |
3307 | to->setDtDue( dt ); | 3306 | to->setDtDue( dt ); |
3308 | 3307 | ||
3309 | if ( to->hasStartDate() ) { | 3308 | if ( to->hasStartDate() ) { |
3310 | if ( len>0 ) | 3309 | if ( len>0 ) |
3311 | to->setDtStart(to->dtDue().addSecs( -len )); | 3310 | to->setDtStart(to->dtDue().addSecs( -len )); |
3312 | else | 3311 | else |
3313 | if (to->dtStart() > to->dtDue() ) | 3312 | if (to->dtStart() > to->dtDue() ) |
3314 | to->setDtStart(to->dtDue().addDays( -3 )); | 3313 | to->setDtStart(to->dtDue().addDays( -3 )); |
3315 | } | 3314 | } |
3316 | 3315 | ||
3317 | todoChanged( to ); | 3316 | todoChanged( to ); |
3318 | } else if ( mMoveIncidence->typeID() == eventID ) { | 3317 | } else if ( mMoveIncidence->typeID() == eventID ) { |
3319 | if ( mMoveIncidence->doesRecur() ) { | 3318 | if ( mMoveIncidence->doesRecur() ) { |
3320 | #if 0 | 3319 | #if 0 |
3321 | // PENDING implement this | 3320 | // PENDING implement this |
3322 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 3321 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3323 | mCalendar()->addIncidence( newInc ); | 3322 | mCalendar()->addIncidence( newInc ); |
3324 | if ( mMoveIncidence->typeID() == todoID ) | 3323 | if ( mMoveIncidence->typeID() == todoID ) |
3325 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 3324 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3326 | else | 3325 | else |
3327 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 3326 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3328 | mMoveIncidence = newInc; | 3327 | mMoveIncidence = newInc; |
3329 | 3328 | ||
3330 | #endif | 3329 | #endif |
3331 | } | 3330 | } |
3332 | QTime tim = mMoveIncidence->dtStart().time(); | 3331 | QTime tim = mMoveIncidence->dtStart().time(); |
3333 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 3332 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3334 | QDateTime dt ( d,tim ); | 3333 | QDateTime dt ( d,tim ); |
3335 | mMoveIncidence->setDtStart( dt ); | 3334 | mMoveIncidence->setDtStart( dt ); |
3336 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 3335 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3337 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 3336 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3338 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3337 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3339 | QTime tim = mMoveIncidence->dtStart().time(); | 3338 | QTime tim = mMoveIncidence->dtStart().time(); |
3340 | QDateTime dt ( d,tim ); | 3339 | QDateTime dt ( d,tim ); |
3341 | mMoveIncidence->setDtStart( dt ); | 3340 | mMoveIncidence->setDtStart( dt ); |
3342 | updateView(); | 3341 | updateView(); |
3343 | } | 3342 | } |
3344 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3343 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3345 | } | 3344 | } |
3346 | } | 3345 | } |
3347 | 3346 | ||
3348 | void CalendarView::removeCategories() | 3347 | void CalendarView::removeCategories() |
3349 | { | 3348 | { |
3350 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3349 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3351 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3350 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3352 | QStringList catIncList; | 3351 | QStringList catIncList; |
3353 | QStringList newCatList; | 3352 | QStringList newCatList; |
3354 | Incidence* inc = incList.first(); | 3353 | Incidence* inc = incList.first(); |
3355 | uint i; | 3354 | uint i; |
3356 | while ( inc ) { | 3355 | while ( inc ) { |
3357 | newCatList.clear(); | 3356 | newCatList.clear(); |
3358 | catIncList = inc->categories() ; | 3357 | catIncList = inc->categories() ; |
3359 | for( i = 0; i< catIncList.count(); ++i ) { | 3358 | for( i = 0; i< catIncList.count(); ++i ) { |
3360 | if ( catList.contains (catIncList[i])) | 3359 | if ( catList.contains (catIncList[i])) |
3361 | newCatList.append( catIncList[i] ); | 3360 | newCatList.append( catIncList[i] ); |
3362 | } | 3361 | } |
3363 | newCatList.sort(); | 3362 | newCatList.sort(); |
3364 | inc->setCategories( newCatList.join(",") ); | 3363 | inc->setCategories( newCatList.join(",") ); |
3365 | inc = incList.next(); | 3364 | inc = incList.next(); |
3366 | } | 3365 | } |
3367 | } | 3366 | } |
3368 | 3367 | ||
3369 | int CalendarView::addCategories() | 3368 | int CalendarView::addCategories() |
3370 | { | 3369 | { |
3371 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3370 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3372 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3371 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3373 | QStringList catIncList; | 3372 | QStringList catIncList; |
3374 | Incidence* inc = incList.first(); | 3373 | Incidence* inc = incList.first(); |
3375 | uint i; | 3374 | uint i; |
3376 | int count = 0; | 3375 | int count = 0; |
3377 | while ( inc ) { | 3376 | while ( inc ) { |
3378 | catIncList = inc->categories() ; | 3377 | catIncList = inc->categories() ; |
3379 | for( i = 0; i< catIncList.count(); ++i ) { | 3378 | for( i = 0; i< catIncList.count(); ++i ) { |
3380 | if ( !catList.contains (catIncList[i])) { | 3379 | if ( !catList.contains (catIncList[i])) { |
3381 | catList.append( catIncList[i] ); | 3380 | catList.append( catIncList[i] ); |
3382 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3381 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3383 | ++count; | 3382 | ++count; |
3384 | } | 3383 | } |
3385 | } | 3384 | } |
3386 | inc = incList.next(); | 3385 | inc = incList.next(); |
3387 | } | 3386 | } |
3388 | catList.sort(); | 3387 | catList.sort(); |
3389 | KOPrefs::instance()->mCustomCategories = catList; | 3388 | KOPrefs::instance()->mCustomCategories = catList; |
3390 | return count; | 3389 | return count; |
3391 | } | 3390 | } |
3392 | 3391 | ||
3393 | void CalendarView::editCategories() | 3392 | void CalendarView::editCategories() |
3394 | { | 3393 | { |
3395 | qDebug("CalendarView::editCategories() "); | 3394 | qDebug("CalendarView::editCategories() "); |
3396 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3395 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3397 | ced.exec(); | 3396 | ced.exec(); |
3398 | } | 3397 | } |
3399 | void CalendarView::manageCategories() | 3398 | void CalendarView::manageCategories() |
3400 | { | 3399 | { |
3401 | KOCatPrefs* cp = new KOCatPrefs(); | 3400 | KOCatPrefs* cp = new KOCatPrefs(); |
3402 | cp->show(); | 3401 | cp->show(); |
3403 | int w =cp->sizeHint().width() ; | 3402 | int w =cp->sizeHint().width() ; |
3404 | int h = cp->sizeHint().height() ; | 3403 | int h = cp->sizeHint().height() ; |
3405 | int dw = QApplication::desktop()->width(); | 3404 | int dw = QApplication::desktop()->width(); |
3406 | int dh = QApplication::desktop()->height(); | 3405 | int dh = QApplication::desktop()->height(); |
3407 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3406 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3408 | if ( !cp->exec() ) { | 3407 | if ( !cp->exec() ) { |
3409 | delete cp; | 3408 | delete cp; |
3410 | return; | 3409 | return; |
3411 | } | 3410 | } |
3412 | int count = 0; | 3411 | int count = 0; |
3413 | if ( cp->addCat() ) { | 3412 | if ( cp->addCat() ) { |
3414 | count = addCategories(); | 3413 | count = addCategories(); |
3415 | if ( count ) { | 3414 | if ( count ) { |
3416 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3415 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3417 | writeSettings(); | 3416 | writeSettings(); |
3418 | } else | 3417 | } else |
3419 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3418 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3420 | } else { | 3419 | } else { |
3421 | removeCategories(); | 3420 | removeCategories(); |
3422 | updateView(); | 3421 | updateView(); |
3423 | } | 3422 | } |
3424 | delete cp; | 3423 | delete cp; |
3425 | } | 3424 | } |
3426 | 3425 | ||
3427 | void CalendarView::beamIncidence(Incidence * Inc) | 3426 | void CalendarView::beamIncidence(Incidence * Inc) |
3428 | { | 3427 | { |
3429 | QPtrList<Incidence> delSel ; | 3428 | QPtrList<Incidence> delSel ; |
3430 | delSel.append(Inc); | 3429 | delSel.append(Inc); |
3431 | beamIncidenceList( delSel ); | 3430 | beamIncidenceList( delSel ); |
3432 | } | 3431 | } |
3433 | void CalendarView::beamCalendar() | 3432 | void CalendarView::beamCalendar() |
3434 | { | 3433 | { |
3435 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3434 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3436 | //qDebug("beamCalendar() "); | 3435 | //qDebug("beamCalendar() "); |
3437 | beamIncidenceList( delSel ); | 3436 | beamIncidenceList( delSel ); |
3438 | } | 3437 | } |
3439 | void CalendarView::beamFilteredCalendar() | 3438 | void CalendarView::beamFilteredCalendar() |
3440 | { | 3439 | { |
3441 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3440 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3442 | //qDebug("beamFilteredCalendar() "); | 3441 | //qDebug("beamFilteredCalendar() "); |
3443 | beamIncidenceList( delSel ); | 3442 | beamIncidenceList( delSel ); |
3444 | } | 3443 | } |
3445 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3444 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3446 | { | 3445 | { |
3447 | 3446 | ||
3448 | KOBeamPrefs beamDialog; | 3447 | KOBeamPrefs beamDialog; |
3449 | if ( beamDialog.exec () == QDialog::Rejected ) | 3448 | if ( beamDialog.exec () == QDialog::Rejected ) |
3450 | return; | 3449 | return; |
3451 | #ifdef DESKTOP_VERSION | 3450 | #ifdef DESKTOP_VERSION |
3452 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3451 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3453 | #else | 3452 | #else |
3454 | QString fn = "/tmp/kopibeamfile"; | 3453 | QString fn = "/tmp/kopibeamfile"; |
3455 | #endif | 3454 | #endif |
3456 | QString mes; | 3455 | QString mes; |
3457 | bool createbup = true; | 3456 | bool createbup = true; |
3458 | if ( createbup ) { | 3457 | if ( createbup ) { |
3459 | QString description = "\n"; | 3458 | QString description = "\n"; |
3460 | CalendarLocal* cal = new CalendarLocal(); | 3459 | CalendarLocal* cal = new CalendarLocal(); |
3461 | if ( beamDialog.beamLocal() ) | 3460 | if ( beamDialog.beamLocal() ) |
3462 | cal->setLocalTime(); | 3461 | cal->setLocalTime(); |
3463 | else | 3462 | else |
3464 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3463 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3465 | Incidence *incidence = delSel.first(); | 3464 | Incidence *incidence = delSel.first(); |
3466 | bool addText = false; | 3465 | bool addText = false; |
3467 | if ( delSel.count() < 10 ) | 3466 | if ( delSel.count() < 10 ) |
3468 | addText = true; | 3467 | addText = true; |
3469 | else { | 3468 | else { |
3470 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3469 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3471 | } | 3470 | } |
3472 | while ( incidence ) { | 3471 | while ( incidence ) { |
3473 | Incidence *in = incidence->clone(); | 3472 | Incidence *in = incidence->clone(); |
3474 | if ( ! in->summary().isEmpty() ) { | 3473 | if ( ! in->summary().isEmpty() ) { |
3475 | in->setDescription(""); | 3474 | in->setDescription(""); |
3476 | } else { | 3475 | } else { |
3477 | in->setSummary( in->description().left(20)); | 3476 | in->setSummary( in->description().left(20)); |
3478 | in->setDescription(""); | 3477 | in->setDescription(""); |
3479 | } | 3478 | } |
3480 | if ( addText ) | 3479 | if ( addText ) |
3481 | description += in->summary() + "\n"; | 3480 | description += in->summary() + "\n"; |
3482 | cal->addIncidence( in ); | 3481 | cal->addIncidence( in ); |
3483 | incidence = delSel.next(); | 3482 | incidence = delSel.next(); |
3484 | } | 3483 | } |
3485 | if ( beamDialog.beamVcal() ) { | 3484 | if ( beamDialog.beamVcal() ) { |
3486 | fn += ".vcs"; | 3485 | fn += ".vcs"; |
3487 | FileStorage storage( cal, fn, new VCalFormat ); | 3486 | FileStorage storage( cal, fn, new VCalFormat ); |
3488 | storage.save(); | 3487 | storage.save(); |
3489 | } else { | 3488 | } else { |
3490 | fn += ".ics"; | 3489 | fn += ".ics"; |
3491 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3490 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3492 | storage.save(); | 3491 | storage.save(); |
3493 | } | 3492 | } |
3494 | delete cal; | 3493 | delete cal; |
3495 | mes = i18n("KO/Pi: Ready for beaming"); | 3494 | mes = i18n("KO/Pi: Ready for beaming"); |
3496 | topLevelWidget()->setCaption(mes); | 3495 | topLevelWidget()->setCaption(mes); |
3497 | KApplication::convert2latin1( fn ); | 3496 | KApplication::convert2latin1( fn ); |
3498 | #ifndef DESKTOP_VERSION | 3497 | #ifndef DESKTOP_VERSION |
3499 | Ir *ir = new Ir( this ); | 3498 | Ir *ir = new Ir( this ); |
3500 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3499 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3501 | ir->send( fn, description, "text/x-vCalendar" ); | 3500 | ir->send( fn, description, "text/x-vCalendar" ); |
3502 | #endif | 3501 | #endif |
3503 | } | 3502 | } |
3504 | } | 3503 | } |
3505 | 3504 | ||
3506 | #ifndef DESKTOP_VERSION | 3505 | #ifndef DESKTOP_VERSION |
3507 | void CalendarView::beamDone( Ir *ir ) | 3506 | void CalendarView::beamDone( Ir *ir ) |
3508 | { | 3507 | { |
3509 | delete ir; | 3508 | delete ir; |
3510 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3509 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3511 | topLevelWidget()->raise(); | 3510 | topLevelWidget()->raise(); |
3512 | } | 3511 | } |
3513 | #else | 3512 | #else |
3514 | void CalendarView::beamDone( Ir *){;} | 3513 | void CalendarView::beamDone( Ir *){;} |
3515 | #endif | 3514 | #endif |
3516 | void CalendarView::moveIncidence(Incidence * inc ) | 3515 | void CalendarView::moveIncidence(Incidence * inc ) |
3517 | { | 3516 | { |
3518 | if ( !inc ) return; | 3517 | if ( !inc ) return; |
3519 | showDatePickerPopup(); | 3518 | showDatePickerPopup(); |
3520 | mDatePickerMode = 2; | 3519 | mDatePickerMode = 2; |
3521 | mMoveIncidence = inc ; | 3520 | mMoveIncidence = inc ; |
3522 | QDate da; | 3521 | QDate da; |
3523 | if ( mMoveIncidence->typeID() == todoID ) { | 3522 | if ( mMoveIncidence->typeID() == todoID ) { |
3524 | Todo * to = (Todo *) mMoveIncidence; | 3523 | Todo * to = (Todo *) mMoveIncidence; |
3525 | if ( to->hasDueDate() ) | 3524 | if ( to->hasDueDate() ) |
3526 | da = to->dtDue().date(); | 3525 | da = to->dtDue().date(); |
3527 | else | 3526 | else |
3528 | da = QDate::currentDate(); | 3527 | da = QDate::currentDate(); |
3529 | } else { | 3528 | } else { |
3530 | da = mMoveIncidence->dtStart().date(); | 3529 | da = mMoveIncidence->dtStart().date(); |
3531 | } | 3530 | } |
3532 | //PENDING set date for recurring incidence to date of recurrence | 3531 | //PENDING set date for recurring incidence to date of recurrence |
3533 | //mMoveIncidenceOldDate; | 3532 | //mMoveIncidenceOldDate; |
3534 | mDatePicker->setDate( da ); | 3533 | mDatePicker->setDate( da ); |
3535 | } | 3534 | } |
3536 | void CalendarView::showDatePickerPopup() | 3535 | void CalendarView::showDatePickerPopup() |
3537 | { | 3536 | { |
3538 | if ( mDateFrame->isVisible() ) | 3537 | if ( mDateFrame->isVisible() ) |
3539 | mDateFrame->hide(); | 3538 | mDateFrame->hide(); |
3540 | else { | 3539 | else { |
3541 | int offX = 0, offY = 0; | 3540 | int offX = 0, offY = 0; |
3542 | #ifdef DESKTOP_VERSION | 3541 | #ifdef DESKTOP_VERSION |
3543 | int w =mDatePicker->sizeHint().width() ; | 3542 | int w =mDatePicker->sizeHint().width() ; |
3544 | int h = mDatePicker->sizeHint().height() ; | 3543 | int h = mDatePicker->sizeHint().height() ; |
3545 | int dw = topLevelWidget()->width(); | 3544 | int dw = topLevelWidget()->width(); |
3546 | int dh = topLevelWidget()->height(); | 3545 | int dh = topLevelWidget()->height(); |
3547 | offX = topLevelWidget()->x(); | 3546 | offX = topLevelWidget()->x(); |
3548 | offY = topLevelWidget()->y(); | 3547 | offY = topLevelWidget()->y(); |
3549 | #else | 3548 | #else |
3550 | int w =mDatePicker->sizeHint().width() ; | 3549 | int w =mDatePicker->sizeHint().width() ; |
3551 | int h = mDatePicker->sizeHint().height() ; | 3550 | int h = mDatePicker->sizeHint().height() ; |
3552 | int dw = QApplication::desktop()->width(); | 3551 | int dw = QApplication::desktop()->width(); |
3553 | int dh = QApplication::desktop()->height(); | 3552 | int dh = QApplication::desktop()->height(); |
3554 | #endif | 3553 | #endif |
3555 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3554 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3556 | mDateFrame->show(); | 3555 | mDateFrame->show(); |
3557 | } | 3556 | } |
3558 | } | 3557 | } |
3559 | void CalendarView::showDatePicker( ) | 3558 | void CalendarView::showDatePicker( ) |
3560 | { | 3559 | { |
3561 | showDatePickerPopup(); | 3560 | showDatePickerPopup(); |
3562 | mDatePickerMode = 1; | 3561 | mDatePickerMode = 1; |
3563 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3562 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3564 | } | 3563 | } |
3565 | 3564 | ||
3566 | void CalendarView::showEventEditor() | 3565 | void CalendarView::showEventEditor() |
3567 | { | 3566 | { |
3568 | #ifdef DESKTOP_VERSION | 3567 | #ifdef DESKTOP_VERSION |
3569 | int x,y,w,h; | 3568 | int x,y,w,h; |
3570 | x = mEventEditor->geometry().x(); | 3569 | x = mEventEditor->geometry().x(); |
3571 | y = mEventEditor->geometry().y(); | 3570 | y = mEventEditor->geometry().y(); |
3572 | w = mEventEditor->width(); | 3571 | w = mEventEditor->width(); |
3573 | h = mEventEditor->height(); | 3572 | h = mEventEditor->height(); |
3574 | mEventEditor->show(); | 3573 | mEventEditor->show(); |
3575 | mEventEditor->setGeometry(x,y,w,h); | 3574 | mEventEditor->setGeometry(x,y,w,h); |
3576 | #else | 3575 | #else |
3577 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3576 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3578 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3577 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3579 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3578 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3580 | qApp->processEvents(); | 3579 | qApp->processEvents(); |
3581 | delete mEventEditor; | 3580 | delete mEventEditor; |
3582 | mEventEditor = mDialogManager->getEventEditor(); | 3581 | mEventEditor = mDialogManager->getEventEditor(); |
3583 | topLevelWidget()->setCaption( i18n("") ); | 3582 | topLevelWidget()->setCaption( i18n("") ); |
3584 | } | 3583 | } |
3585 | mEventEditor->showMaximized(); | 3584 | mEventEditor->showMaximized(); |
3586 | #endif | 3585 | #endif |
3587 | } | 3586 | } |
3588 | void CalendarView::showTodoEditor() | 3587 | void CalendarView::showTodoEditor() |
3589 | { | 3588 | { |
3590 | #ifdef DESKTOP_VERSION | 3589 | #ifdef DESKTOP_VERSION |
3591 | int x,y,w,h; | 3590 | int x,y,w,h; |
3592 | x = mTodoEditor->geometry().x(); | 3591 | x = mTodoEditor->geometry().x(); |
3593 | y = mTodoEditor->geometry().y(); | 3592 | y = mTodoEditor->geometry().y(); |
3594 | w = mTodoEditor->width(); | 3593 | w = mTodoEditor->width(); |
3595 | h = mTodoEditor->height(); | 3594 | h = mTodoEditor->height(); |
3596 | mTodoEditor->show(); | 3595 | mTodoEditor->show(); |
3597 | mTodoEditor->setGeometry(x,y,w,h); | 3596 | mTodoEditor->setGeometry(x,y,w,h); |
3598 | #else | 3597 | #else |
3599 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3598 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3600 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3599 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3601 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3600 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3602 | qApp->processEvents(); | 3601 | qApp->processEvents(); |
3603 | delete mTodoEditor; | 3602 | delete mTodoEditor; |
3604 | mTodoEditor = mDialogManager->getTodoEditor(); | 3603 | mTodoEditor = mDialogManager->getTodoEditor(); |
3605 | topLevelWidget()->setCaption( i18n("") ); | 3604 | topLevelWidget()->setCaption( i18n("") ); |
3606 | } | 3605 | } |
3607 | mTodoEditor->showMaximized(); | 3606 | mTodoEditor->showMaximized(); |
3608 | #endif | 3607 | #endif |
3609 | } | 3608 | } |
3610 | 3609 | ||
3611 | void CalendarView::cloneIncidence() | 3610 | void CalendarView::cloneIncidence() |
3612 | { | 3611 | { |
3613 | Incidence *incidence = currentSelection(); | 3612 | Incidence *incidence = currentSelection(); |
3614 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3613 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3615 | if ( incidence ) { | 3614 | if ( incidence ) { |
3616 | cloneIncidence(incidence); | 3615 | cloneIncidence(incidence); |
3617 | } | 3616 | } |
3618 | } | 3617 | } |
3619 | void CalendarView::moveIncidence() | 3618 | void CalendarView::moveIncidence() |
3620 | { | 3619 | { |
3621 | Incidence *incidence = currentSelection(); | 3620 | Incidence *incidence = currentSelection(); |
3622 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3621 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3623 | if ( incidence ) { | 3622 | if ( incidence ) { |
3624 | moveIncidence(incidence); | 3623 | moveIncidence(incidence); |
3625 | } | 3624 | } |
3626 | } | 3625 | } |
3627 | void CalendarView::beamIncidence() | 3626 | void CalendarView::beamIncidence() |
3628 | { | 3627 | { |
3629 | Incidence *incidence = currentSelection(); | 3628 | Incidence *incidence = currentSelection(); |
3630 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3629 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3631 | if ( incidence ) { | 3630 | if ( incidence ) { |
3632 | beamIncidence(incidence); | 3631 | beamIncidence(incidence); |
3633 | } | 3632 | } |
3634 | } | 3633 | } |
3635 | void CalendarView::toggleCancelIncidence() | 3634 | void CalendarView::toggleCancelIncidence() |
3636 | { | 3635 | { |
3637 | Incidence *incidence = currentSelection(); | 3636 | Incidence *incidence = currentSelection(); |
3638 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3637 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3639 | if ( incidence ) { | 3638 | if ( incidence ) { |
3640 | cancelIncidence(incidence); | 3639 | cancelIncidence(incidence); |
3641 | } | 3640 | } |
3642 | } | 3641 | } |
3643 | 3642 | ||
3644 | 3643 | ||
3645 | void CalendarView::cancelIncidence(Incidence * inc ) | 3644 | void CalendarView::cancelIncidence(Incidence * inc ) |
3646 | { | 3645 | { |
3647 | inc->setCancelled( ! inc->cancelled() ); | 3646 | inc->setCancelled( ! inc->cancelled() ); |
3648 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3647 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3649 | updateView(); | 3648 | updateView(); |
3650 | } | 3649 | } |
3651 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3650 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3652 | { | 3651 | { |
3653 | Incidence * newInc = orgInc->clone(); | 3652 | Incidence * newInc = orgInc->clone(); |
3654 | newInc->recreate(); | 3653 | newInc->recreate(); |
3655 | 3654 | ||
3656 | if ( newInc->typeID() == todoID ) { | 3655 | if ( newInc->typeID() == todoID ) { |
3657 | Todo* t = (Todo*) newInc; | 3656 | Todo* t = (Todo*) newInc; |
3658 | bool cloneSub = false; | 3657 | bool cloneSub = false; |
3659 | if ( orgInc->relations().count() ) { | 3658 | if ( orgInc->relations().count() ) { |
3660 | int result = KMessageBox::warningYesNoCancel(this, | 3659 | int result = KMessageBox::warningYesNoCancel(this, |
3661 | 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 ) ), | 3660 | 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 ) ), |
3662 | i18n("Todo has subtodos"), | 3661 | i18n("Todo has subtodos"), |
3663 | i18n("Yes"), | 3662 | i18n("Yes"), |
3664 | i18n("No")); | 3663 | i18n("No")); |
3665 | 3664 | ||
3666 | if ( result == KMessageBox::Cancel ) { | 3665 | if ( result == KMessageBox::Cancel ) { |
3667 | delete t; | 3666 | delete t; |
3668 | return; | 3667 | return; |
3669 | } | 3668 | } |
3670 | if (result == KMessageBox::Yes) cloneSub = true; | 3669 | if (result == KMessageBox::Yes) cloneSub = true; |
3671 | } | 3670 | } |
3672 | showTodoEditor(); | 3671 | showTodoEditor(); |
3673 | mTodoEditor->editTodo( t ); | 3672 | mTodoEditor->editTodo( t ); |
3674 | if ( mTodoEditor->exec() ) { | 3673 | if ( mTodoEditor->exec() ) { |
3675 | if ( cloneSub ) { | 3674 | if ( cloneSub ) { |
3676 | orgInc->cloneRelations( t ); | 3675 | orgInc->cloneRelations( t ); |
3677 | mCalendar->addIncidenceBranch( t ); | 3676 | mCalendar->addIncidenceBranch( t ); |
3678 | updateView(); | 3677 | updateView(); |
3679 | 3678 | ||
3680 | } else { | 3679 | } else { |
3681 | mCalendar->addTodo( t ); | 3680 | mCalendar->addTodo( t ); |
3682 | updateView(); | 3681 | updateView(); |
3683 | } | 3682 | } |
3684 | } else { | 3683 | } else { |
3685 | delete t; | 3684 | delete t; |
3686 | } | 3685 | } |
3687 | } | 3686 | } |
3688 | else if ( newInc->typeID() == eventID ) { | 3687 | else if ( newInc->typeID() == eventID ) { |
3689 | Event* e = (Event*) newInc; | 3688 | Event* e = (Event*) newInc; |
3690 | showEventEditor(); | 3689 | showEventEditor(); |
3691 | mEventEditor->editEvent( e ); | 3690 | mEventEditor->editEvent( e ); |
3692 | if ( mEventEditor->exec() ) { | 3691 | if ( mEventEditor->exec() ) { |
3693 | mCalendar->addEvent( e ); | 3692 | mCalendar->addEvent( e ); |
3694 | updateView(); | 3693 | updateView(); |
3695 | } else { | 3694 | } else { |
3696 | delete e; | 3695 | delete e; |
3697 | } | 3696 | } |
3698 | } else if ( newInc->typeID() == journalID ) { | 3697 | } else if ( newInc->typeID() == journalID ) { |
3699 | mCalendar->addJournal( (Journal*) newInc ); | 3698 | mCalendar->addJournal( (Journal*) newInc ); |
3700 | editJournal( (Journal*) newInc ); | 3699 | editJournal( (Journal*) newInc ); |
3701 | } | 3700 | } |
3702 | setActiveWindow(); | 3701 | setActiveWindow(); |
3703 | } | 3702 | } |
3704 | 3703 | ||
3705 | void CalendarView::newEvent() | 3704 | void CalendarView::newEvent() |
3706 | { | 3705 | { |
3707 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3706 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3708 | KOAgendaView *aView = mViewManager->agendaView(); | 3707 | KOAgendaView *aView = mViewManager->agendaView(); |
3709 | if (aView) { | 3708 | if (aView) { |
3710 | if (aView->selectionStart().isValid()) { | 3709 | if (aView->selectionStart().isValid()) { |
3711 | if (aView->selectedIsAllDay()) { | 3710 | if (aView->selectedIsAllDay()) { |
3712 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3711 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3713 | } else { | 3712 | } else { |
3714 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3713 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3715 | } | 3714 | } |
3716 | return; | 3715 | return; |
3717 | } | 3716 | } |
3718 | } | 3717 | } |
3719 | 3718 | ||
3720 | QDate date = mNavigator->selectedDates().first(); | 3719 | QDate date = mNavigator->selectedDates().first(); |
3721 | #if 0 | 3720 | #if 0 |
3722 | QDateTime current = QDateTime::currentDateTime(); | 3721 | QDateTime current = QDateTime::currentDateTime(); |
3723 | if ( date <= current.date() ) { | 3722 | if ( date <= current.date() ) { |
3724 | int hour = current.time().hour() +1; | 3723 | int hour = current.time().hour() +1; |
3725 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3724 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3726 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3725 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3727 | } else | 3726 | } else |
3728 | #endif | 3727 | #endif |
3729 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3728 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3730 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3729 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3731 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3730 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3732 | } | 3731 | } |
3733 | 3732 | ||
3734 | void CalendarView::newEvent(QDateTime fh) | 3733 | void CalendarView::newEvent(QDateTime fh) |
3735 | { | 3734 | { |
3736 | newEvent(fh, | 3735 | newEvent(fh, |
3737 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3736 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3738 | } | 3737 | } |
3739 | 3738 | ||
3740 | void CalendarView::newEvent(QDate dt) | 3739 | void CalendarView::newEvent(QDate dt) |
3741 | { | 3740 | { |
3742 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3741 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3743 | QDateTime(dt, QTime(0,0,0)), true); | 3742 | QDateTime(dt, QTime(0,0,0)), true); |
3744 | } | 3743 | } |
3745 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3744 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3746 | { | 3745 | { |
3747 | newEvent(fromHint, toHint, false); | 3746 | newEvent(fromHint, toHint, false); |
3748 | } | 3747 | } |
3749 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3748 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3750 | { | 3749 | { |
3751 | 3750 | ||
3752 | showEventEditor(); | 3751 | showEventEditor(); |
3753 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3752 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3754 | if ( mFilterView->filtersEnabled() ) { | 3753 | if ( mFilterView->filtersEnabled() ) { |
3755 | CalFilter *filter = mFilterView->selectedFilter(); | 3754 | CalFilter *filter = mFilterView->selectedFilter(); |
3756 | if (filter && filter->showCategories()) { | 3755 | if (filter && filter->showCategories()) { |
3757 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3756 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3758 | } | 3757 | } |
3759 | if ( filter ) | 3758 | if ( filter ) |
3760 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3759 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3761 | } | 3760 | } |
3762 | mEventEditor->exec(); | 3761 | mEventEditor->exec(); |
3763 | setActiveWindow(); | 3762 | setActiveWindow(); |
3764 | } | 3763 | } |
3765 | void CalendarView::todoAdded(Todo * t) | 3764 | void CalendarView::todoAdded(Todo * t) |
3766 | { | 3765 | { |
3767 | 3766 | ||
3768 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3767 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3769 | updateTodoViews(); | 3768 | updateTodoViews(); |
3770 | } | 3769 | } |
3771 | void CalendarView::todoChanged(Todo * t) | 3770 | void CalendarView::todoChanged(Todo * t) |
3772 | { | 3771 | { |
3773 | emit todoModified( t, 4 ); | 3772 | emit todoModified( t, 4 ); |
3774 | // updateTodoViews(); | 3773 | // updateTodoViews(); |
3775 | } | 3774 | } |
3776 | void CalendarView::todoToBeDeleted(Todo *) | 3775 | void CalendarView::todoToBeDeleted(Todo *) |
3777 | { | 3776 | { |
3778 | //qDebug("todoToBeDeleted(Todo *) "); | 3777 | //qDebug("todoToBeDeleted(Todo *) "); |
3779 | updateTodoViews(); | 3778 | updateTodoViews(); |
3780 | } | 3779 | } |
3781 | void CalendarView::todoDeleted() | 3780 | void CalendarView::todoDeleted() |
3782 | { | 3781 | { |
3783 | //qDebug(" todoDeleted()"); | 3782 | //qDebug(" todoDeleted()"); |
3784 | updateTodoViews(); | 3783 | updateTodoViews(); |
3785 | } | 3784 | } |
3786 | 3785 | ||
3787 | 3786 | ||
3788 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3787 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3789 | { | 3788 | { |
3790 | showTodoEditor(); | 3789 | showTodoEditor(); |
3791 | mTodoEditor->newTodo(dt,0,allday); | 3790 | mTodoEditor->newTodo(dt,0,allday); |
3792 | if ( mFilterView->filtersEnabled() ) { | 3791 | if ( mFilterView->filtersEnabled() ) { |
3793 | CalFilter *filter = mFilterView->selectedFilter(); | 3792 | CalFilter *filter = mFilterView->selectedFilter(); |
3794 | if (filter && filter->showCategories()) { | 3793 | if (filter && filter->showCategories()) { |
3795 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3794 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3796 | } | 3795 | } |
3797 | if ( filter ) | 3796 | if ( filter ) |
3798 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3797 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3799 | } | 3798 | } |
3800 | mTodoEditor->exec(); | 3799 | mTodoEditor->exec(); |
3801 | setActiveWindow(); | 3800 | setActiveWindow(); |
3802 | } | 3801 | } |
3803 | 3802 | ||
3804 | void CalendarView::newTodo() | 3803 | void CalendarView::newTodo() |
3805 | { | 3804 | { |
3806 | newTodoDateTime( QDateTime(),true ); | 3805 | newTodoDateTime( QDateTime(),true ); |
3807 | } | 3806 | } |
3808 | 3807 | ||
3809 | void CalendarView::newSubTodo() | 3808 | void CalendarView::newSubTodo() |
3810 | { | 3809 | { |
3811 | Todo *todo = selectedTodo(); | 3810 | Todo *todo = selectedTodo(); |
3812 | if ( todo ) newSubTodo( todo ); | 3811 | if ( todo ) newSubTodo( todo ); |
3813 | } | 3812 | } |
3814 | 3813 | ||
3815 | void CalendarView::newSubTodo(Todo *parentEvent) | 3814 | void CalendarView::newSubTodo(Todo *parentEvent) |
3816 | { | 3815 | { |
3817 | 3816 | ||
3818 | showTodoEditor(); | 3817 | showTodoEditor(); |
3819 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3818 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3820 | mTodoEditor->exec(); | 3819 | mTodoEditor->exec(); |
3821 | setActiveWindow(); | 3820 | setActiveWindow(); |
3822 | } | 3821 | } |
3823 | 3822 | ||
3824 | void CalendarView::newFloatingEvent() | 3823 | void CalendarView::newFloatingEvent() |
3825 | { | 3824 | { |
3826 | DateList tmpList = mNavigator->selectedDates(); | 3825 | DateList tmpList = mNavigator->selectedDates(); |
3827 | QDate date = tmpList.first(); | 3826 | QDate date = tmpList.first(); |
3828 | 3827 | ||
3829 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3828 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3830 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3829 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3831 | } | 3830 | } |
3832 | 3831 | ||
3833 | 3832 | ||
3834 | void CalendarView::editEvent( Event *event ) | 3833 | void CalendarView::editEvent( Event *event ) |
3835 | { | 3834 | { |
3836 | 3835 | ||
3837 | if ( !event ) return; | 3836 | if ( !event ) return; |
3838 | if ( event->isReadOnly() ) { | 3837 | if ( event->isReadOnly() ) { |
3839 | showEvent( event ); | 3838 | showEvent( event ); |
3840 | return; | 3839 | return; |
3841 | } | 3840 | } |
3842 | showEventEditor(); | 3841 | showEventEditor(); |
3843 | mEventEditor->editEvent( event , mFlagEditDescription); | 3842 | mEventEditor->editEvent( event , mFlagEditDescription); |
3844 | mEventEditor->exec(); | 3843 | mEventEditor->exec(); |
3845 | setActiveWindow(); | 3844 | setActiveWindow(); |
3846 | 3845 | ||
3847 | } | 3846 | } |
3848 | void CalendarView::editJournal( Journal *jour ) | 3847 | void CalendarView::editJournal( Journal *jour ) |
3849 | { | 3848 | { |
3850 | if ( !jour ) return; | 3849 | if ( !jour ) return; |
3851 | mDialogManager->hideSearchDialog(); | 3850 | mDialogManager->hideSearchDialog(); |
3852 | mViewManager->showJournalView(); | 3851 | mViewManager->showJournalView(); |
3853 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3852 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3854 | } | 3853 | } |
3855 | void CalendarView::editTodo( Todo *todo ) | 3854 | void CalendarView::editTodo( Todo *todo ) |
3856 | { | 3855 | { |
3857 | if ( !todo ) return; | 3856 | if ( !todo ) return; |
3858 | 3857 | ||
3859 | if ( todo->isReadOnly() ) { | 3858 | if ( todo->isReadOnly() ) { |
3860 | showTodo( todo ); | 3859 | showTodo( todo ); |
3861 | return; | 3860 | return; |
3862 | } | 3861 | } |
3863 | showTodoEditor(); | 3862 | showTodoEditor(); |
3864 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3863 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3865 | mTodoEditor->exec(); | 3864 | mTodoEditor->exec(); |
3866 | setActiveWindow(); | 3865 | setActiveWindow(); |
3867 | 3866 | ||
3868 | } | 3867 | } |
3869 | 3868 | ||
3870 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3869 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3871 | { | 3870 | { |
3872 | if ( !mEventViewerDialog ) { | 3871 | if ( !mEventViewerDialog ) { |
3873 | mEventViewerDialog = new KOEventViewerDialog(0); | 3872 | mEventViewerDialog = new KOEventViewerDialog(0); |
3874 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3873 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3875 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3874 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3876 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3875 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3877 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3876 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3878 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3877 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3879 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3878 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3880 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3879 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3881 | this, SLOT( slotViewerClosed() ) ); | 3880 | this, SLOT( slotViewerClosed() ) ); |
3882 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3881 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3883 | this, SLOT( todoChanged(Todo *) ) ); | 3882 | this, SLOT( todoChanged(Todo *) ) ); |
3884 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3883 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3885 | mEventViewerDialog->resize( 640, 480 ); | 3884 | mEventViewerDialog->resize( 640, 480 ); |
3886 | 3885 | ||
3887 | } | 3886 | } |
3888 | return mEventViewerDialog; | 3887 | return mEventViewerDialog; |
3889 | } | 3888 | } |
3890 | void CalendarView::showEvent(Event *event) | 3889 | void CalendarView::showEvent(Event *event) |
3891 | { | 3890 | { |
3892 | getEventViewerDialog()->setEvent(event); | 3891 | getEventViewerDialog()->setEvent(event); |
3893 | getEventViewerDialog()->showMe(); | 3892 | getEventViewerDialog()->showMe(); |
3894 | } | 3893 | } |
3895 | 3894 | ||
3896 | void CalendarView::showTodo(Todo *event) | 3895 | void CalendarView::showTodo(Todo *event) |
3897 | { | 3896 | { |
3898 | getEventViewerDialog()->setTodo(event); | 3897 | getEventViewerDialog()->setTodo(event); |
3899 | getEventViewerDialog()->showMe(); | 3898 | getEventViewerDialog()->showMe(); |
3900 | } | 3899 | } |
3901 | void CalendarView::showJournal( Journal *jour ) | 3900 | void CalendarView::showJournal( Journal *jour ) |
3902 | { | 3901 | { |
3903 | getEventViewerDialog()->setJournal(jour); | 3902 | getEventViewerDialog()->setJournal(jour); |
3904 | getEventViewerDialog()->showMe(); | 3903 | getEventViewerDialog()->showMe(); |
3905 | 3904 | ||
3906 | } | 3905 | } |
3907 | // void CalendarView::todoModified (Todo *event, int changed) | 3906 | // void CalendarView::todoModified (Todo *event, int changed) |
3908 | // { | 3907 | // { |
3909 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3908 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3910 | // // kdDebug() << "Todo modified and open" << endl; | 3909 | // // kdDebug() << "Todo modified and open" << endl; |
3911 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3910 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3912 | // // temp->modified (changed); | 3911 | // // temp->modified (changed); |
3913 | 3912 | ||
3914 | // // } | 3913 | // // } |
3915 | 3914 | ||
3916 | // mViewManager->updateView(); | 3915 | // mViewManager->updateView(); |
3917 | // } | 3916 | // } |
3918 | 3917 | ||
3919 | void CalendarView::appointment_show() | 3918 | void CalendarView::appointment_show() |
3920 | { | 3919 | { |
3921 | Event *anEvent = 0; | 3920 | Event *anEvent = 0; |
3922 | 3921 | ||
3923 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3922 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3924 | 3923 | ||
3925 | if (mViewManager->currentView()->isEventView()) { | 3924 | if (mViewManager->currentView()->isEventView()) { |
3926 | if ( incidence && incidence->typeID() == eventID ) { | 3925 | if ( incidence && incidence->typeID() == eventID ) { |
3927 | anEvent = static_cast<Event *>(incidence); | 3926 | anEvent = static_cast<Event *>(incidence); |
3928 | } | 3927 | } |
3929 | } | 3928 | } |
3930 | 3929 | ||
3931 | if (!anEvent) { | 3930 | if (!anEvent) { |
3932 | KNotifyClient::beep(); | 3931 | KNotifyClient::beep(); |
3933 | return; | 3932 | return; |
3934 | } | 3933 | } |
3935 | 3934 | ||
3936 | showEvent(anEvent); | 3935 | showEvent(anEvent); |
3937 | } | 3936 | } |
3938 | 3937 | ||
3939 | void CalendarView::appointment_edit() | 3938 | void CalendarView::appointment_edit() |
3940 | { | 3939 | { |
3941 | Event *anEvent = 0; | 3940 | Event *anEvent = 0; |
3942 | 3941 | ||
3943 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3942 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3944 | 3943 | ||
3945 | if (mViewManager->currentView()->isEventView()) { | 3944 | if (mViewManager->currentView()->isEventView()) { |
3946 | if ( incidence && incidence->typeID() == eventID ) { | 3945 | if ( incidence && incidence->typeID() == eventID ) { |
3947 | anEvent = static_cast<Event *>(incidence); | 3946 | anEvent = static_cast<Event *>(incidence); |
3948 | } | 3947 | } |
3949 | } | 3948 | } |
3950 | 3949 | ||
3951 | if (!anEvent) { | 3950 | if (!anEvent) { |
3952 | KNotifyClient::beep(); | 3951 | KNotifyClient::beep(); |
3953 | return; | 3952 | return; |
3954 | } | 3953 | } |
3955 | 3954 | ||
3956 | editEvent(anEvent); | 3955 | editEvent(anEvent); |
3957 | } | 3956 | } |
3958 | 3957 | ||
3959 | void CalendarView::appointment_delete() | 3958 | void CalendarView::appointment_delete() |
3960 | { | 3959 | { |
3961 | Event *anEvent = 0; | 3960 | Event *anEvent = 0; |
3962 | 3961 | ||
3963 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3962 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3964 | 3963 | ||
3965 | if (mViewManager->currentView()->isEventView()) { | 3964 | if (mViewManager->currentView()->isEventView()) { |
3966 | if ( incidence && incidence->typeID() == eventID ) { | 3965 | if ( incidence && incidence->typeID() == eventID ) { |
3967 | anEvent = static_cast<Event *>(incidence); | 3966 | anEvent = static_cast<Event *>(incidence); |
3968 | } | 3967 | } |
3969 | } | 3968 | } |
3970 | 3969 | ||
3971 | if (!anEvent) { | 3970 | if (!anEvent) { |
3972 | KNotifyClient::beep(); | 3971 | KNotifyClient::beep(); |
3973 | return; | 3972 | return; |
3974 | } | 3973 | } |
3975 | 3974 | ||
3976 | deleteEvent(anEvent); | 3975 | deleteEvent(anEvent); |
3977 | } | 3976 | } |
3978 | 3977 | ||
3979 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3978 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3980 | { | 3979 | { |
3981 | if (!sub) return; | 3980 | if (!sub) return; |
3982 | if ( sub->relatedTo() == parent ) | 3981 | if ( sub->relatedTo() == parent ) |
3983 | return; | 3982 | return; |
3984 | sub->setRelatedTo(parent); | 3983 | sub->setRelatedTo(parent); |
3985 | sub->updated(); | 3984 | sub->updated(); |
3986 | setModified(true); | 3985 | setModified(true); |
3987 | updateView(); | 3986 | updateView(); |
3988 | } | 3987 | } |
3989 | void CalendarView::todo_unsub(Todo *anTodo ) | 3988 | void CalendarView::todo_unsub(Todo *anTodo ) |
3990 | { | 3989 | { |
3991 | todo_resub( 0, anTodo ); | 3990 | todo_resub( 0, anTodo ); |
3992 | } | 3991 | } |
3993 | 3992 | ||
3994 | void CalendarView::deleteTodo(Todo *todo) | 3993 | void CalendarView::deleteTodo(Todo *todo) |
3995 | { | 3994 | { |
3996 | if (!todo) { | 3995 | if (!todo) { |
3997 | KNotifyClient::beep(); | 3996 | KNotifyClient::beep(); |
3998 | return; | 3997 | return; |
3999 | } | 3998 | } |
4000 | if (KOPrefs::instance()->mConfirm) { | 3999 | if (KOPrefs::instance()->mConfirm) { |
4001 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 4000 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
4002 | if (!todo->relations().isEmpty()) { | 4001 | if (!todo->relations().isEmpty()) { |
4003 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 4002 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
4004 | 4003 | ||
4005 | } | 4004 | } |
4006 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 4005 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
4007 | case KMessageBox::Continue: // OK | 4006 | case KMessageBox::Continue: // OK |
4008 | bool deleteT = false; | 4007 | bool deleteT = false; |
4009 | if (!todo->relations().isEmpty()) { | 4008 | if (!todo->relations().isEmpty()) { |
4010 | deleteT = removeCompletedSubTodos( todo ); | 4009 | deleteT = removeCompletedSubTodos( todo ); |
4011 | } | 4010 | } |
4012 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 4011 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
4013 | if ( !deleteT ) { | 4012 | if ( !deleteT ) { |
4014 | checkExternalId( todo ); | 4013 | checkExternalId( todo ); |
4015 | calendar()->deleteTodo(todo); | 4014 | calendar()->deleteTodo(todo); |
4016 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4015 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4017 | } | 4016 | } |
4018 | updateView(); | 4017 | updateView(); |
4019 | break; | 4018 | break; |
4020 | } // switch | 4019 | } // switch |
4021 | } else { | 4020 | } else { |
4022 | checkExternalId( todo ); | 4021 | checkExternalId( todo ); |
4023 | mCalendar->deleteTodo(todo); | 4022 | mCalendar->deleteTodo(todo); |
4024 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4023 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4025 | updateView(); | 4024 | updateView(); |
4026 | } | 4025 | } |
4027 | 4026 | ||
4028 | emit updateSearchDialog(); | 4027 | emit updateSearchDialog(); |
4029 | } | 4028 | } |
4030 | void CalendarView::deleteJournal(Journal *jour) | 4029 | void CalendarView::deleteJournal(Journal *jour) |
4031 | { | 4030 | { |
4032 | if (!jour) { | 4031 | if (!jour) { |
4033 | KNotifyClient::beep(); | 4032 | KNotifyClient::beep(); |
4034 | return; | 4033 | return; |
4035 | } | 4034 | } |
4036 | if (KOPrefs::instance()->mConfirm) { | 4035 | if (KOPrefs::instance()->mConfirm) { |
4037 | 4036 | ||
4038 | QString des; | 4037 | QString des; |
4039 | if ( !jour->summary().isEmpty() ) { | 4038 | if ( !jour->summary().isEmpty() ) { |
4040 | des = jour->summary(); | 4039 | des = jour->summary(); |
4041 | } else { | 4040 | } else { |
4042 | des = jour->description().left(30); | 4041 | des = jour->description().left(30); |
4043 | des = des.simplifyWhiteSpace (); | 4042 | des = des.simplifyWhiteSpace (); |
4044 | des.replace (QRegExp ("\\n"),"" ); | 4043 | des.replace (QRegExp ("\\n"),"" ); |
4045 | des.replace (QRegExp ("\\r"),"" ); | 4044 | des.replace (QRegExp ("\\r"),"" ); |
4046 | } | 4045 | } |
4047 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 4046 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
4048 | case KMessageBox::Continue: // OK | 4047 | case KMessageBox::Continue: // OK |
4049 | calendar()->deleteJournal(jour); | 4048 | calendar()->deleteJournal(jour); |
4050 | updateView(); | 4049 | updateView(); |
4051 | break; | 4050 | break; |
4052 | } // switch | 4051 | } // switch |
4053 | } else { | 4052 | } else { |
4054 | calendar()->deleteJournal(jour);; | 4053 | calendar()->deleteJournal(jour);; |
4055 | updateView(); | 4054 | updateView(); |
4056 | } | 4055 | } |
4057 | emit updateSearchDialog(); | 4056 | emit updateSearchDialog(); |
4058 | } | 4057 | } |
4059 | 4058 | ||
4060 | void CalendarView::deleteEvent(Event *anEvent) | 4059 | void CalendarView::deleteEvent(Event *anEvent) |
4061 | { | 4060 | { |
4062 | if (!anEvent) { | 4061 | if (!anEvent) { |
4063 | KNotifyClient::beep(); | 4062 | KNotifyClient::beep(); |
4064 | return; | 4063 | return; |
4065 | } | 4064 | } |
4066 | 4065 | ||
4067 | if (anEvent->doesRecur()) { | 4066 | if (anEvent->doesRecur()) { |
4068 | QDate itemDate = mViewManager->currentSelectionDate(); | 4067 | QDate itemDate = mViewManager->currentSelectionDate(); |
4069 | int km; | 4068 | int km; |
4070 | if (!itemDate.isValid()) { | 4069 | if (!itemDate.isValid()) { |
4071 | //kdDebug() << "Date Not Valid" << endl; | 4070 | //kdDebug() << "Date Not Valid" << endl; |
4072 | if (KOPrefs::instance()->mConfirm) { | 4071 | if (KOPrefs::instance()->mConfirm) { |
4073 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4072 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4074 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 4073 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
4075 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 4074 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
4076 | if ( km == KMessageBox::Continue ) | 4075 | if ( km == KMessageBox::Continue ) |
4077 | km = KMessageBox::No; // No = all below | 4076 | km = KMessageBox::No; // No = all below |
4078 | } else | 4077 | } else |
4079 | km = KMessageBox::No; | 4078 | km = KMessageBox::No; |
4080 | } else { | 4079 | } else { |
4081 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4080 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4082 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 4081 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
4083 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 4082 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
4084 | i18n("KO/Pi Confirmation"),i18n("Current"), | 4083 | i18n("KO/Pi Confirmation"),i18n("Current"), |
4085 | i18n("All")); | 4084 | i18n("All")); |
4086 | } | 4085 | } |
4087 | switch(km) { | 4086 | switch(km) { |
4088 | 4087 | ||
4089 | case KMessageBox::No: // Continue // all | 4088 | case KMessageBox::No: // Continue // all |
4090 | //qDebug("KMessageBox::No "); | 4089 | //qDebug("KMessageBox::No "); |
4091 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4090 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4092 | schedule(Scheduler::Cancel,anEvent); | 4091 | schedule(Scheduler::Cancel,anEvent); |
4093 | 4092 | ||
4094 | checkExternalId( anEvent); | 4093 | checkExternalId( anEvent); |
4095 | mCalendar->deleteEvent(anEvent); | 4094 | mCalendar->deleteEvent(anEvent); |
4096 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 4095 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
4097 | break; | 4096 | break; |
4098 | 4097 | ||
4099 | // Disabled because it does not work | 4098 | // Disabled because it does not work |
4100 | //#if 0 | 4099 | //#if 0 |
4101 | case KMessageBox::Yes: // just this one | 4100 | case KMessageBox::Yes: // just this one |
4102 | //QDate qd = mNavigator->selectedDates().first(); | 4101 | //QDate qd = mNavigator->selectedDates().first(); |
4103 | //if (!qd.isValid()) { | 4102 | //if (!qd.isValid()) { |
4104 | // kdDebug() << "no date selected, or invalid date" << endl; | 4103 | // kdDebug() << "no date selected, or invalid date" << endl; |
4105 | // KNotifyClient::beep(); | 4104 | // KNotifyClient::beep(); |
4106 | // return; | 4105 | // return; |
4107 | //} | 4106 | //} |
4108 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 4107 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
4109 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 4108 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
4110 | anEvent->addExDate(itemDate); | 4109 | anEvent->addExDate(itemDate); |
4111 | int duration = anEvent->recurrence()->duration(); | 4110 | int duration = anEvent->recurrence()->duration(); |
4112 | if ( duration > 0 ) { | 4111 | if ( duration > 0 ) { |
4113 | anEvent->recurrence()->setDuration( duration - 1 ); | 4112 | anEvent->recurrence()->setDuration( duration - 1 ); |
4114 | } | 4113 | } |
4115 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 4114 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
4116 | } | 4115 | } |
4117 | break; | 4116 | break; |
4118 | //#endif | 4117 | //#endif |
4119 | } // switch | 4118 | } // switch |
4120 | } else { | 4119 | } else { |
4121 | if (KOPrefs::instance()->mConfirm) { | 4120 | if (KOPrefs::instance()->mConfirm) { |
4122 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4121 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4123 | i18n("\nAre you sure you want\nto delete this event?"), | 4122 | i18n("\nAre you sure you want\nto delete this event?"), |
4124 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 4123 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
4125 | case KMessageBox::Continue: // OK | 4124 | case KMessageBox::Continue: // OK |
4126 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4125 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4127 | schedule(Scheduler::Cancel,anEvent); | 4126 | schedule(Scheduler::Cancel,anEvent); |
4128 | checkExternalId( anEvent); | 4127 | checkExternalId( anEvent); |
4129 | mCalendar->deleteEvent(anEvent); | 4128 | mCalendar->deleteEvent(anEvent); |
4130 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4129 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4131 | break; | 4130 | break; |
4132 | } // switch | 4131 | } // switch |
4133 | } else { | 4132 | } else { |
4134 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4133 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4135 | schedule(Scheduler::Cancel,anEvent); | 4134 | schedule(Scheduler::Cancel,anEvent); |
4136 | checkExternalId( anEvent); | 4135 | checkExternalId( anEvent); |
4137 | mCalendar->deleteEvent(anEvent); | 4136 | mCalendar->deleteEvent(anEvent); |
4138 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4137 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4139 | } | 4138 | } |
4140 | } // if-else | 4139 | } // if-else |
4141 | emit updateSearchDialog(); | 4140 | emit updateSearchDialog(); |
4142 | } | 4141 | } |
4143 | 4142 | ||
4144 | bool CalendarView::deleteEvent(const QString &uid) | 4143 | bool CalendarView::deleteEvent(const QString &uid) |
4145 | { | 4144 | { |
4146 | Event *ev = mCalendar->event(uid); | 4145 | Event *ev = mCalendar->event(uid); |
4147 | if (ev) { | 4146 | if (ev) { |
4148 | deleteEvent(ev); | 4147 | deleteEvent(ev); |
4149 | return true; | 4148 | return true; |
4150 | } else { | 4149 | } else { |
4151 | return false; | 4150 | return false; |
4152 | } | 4151 | } |
4153 | } | 4152 | } |
4154 | 4153 | ||
4155 | /*****************************************************************************/ | 4154 | /*****************************************************************************/ |
4156 | 4155 | ||
4157 | void CalendarView::action_mail() | 4156 | void CalendarView::action_mail() |
4158 | { | 4157 | { |
4159 | #ifndef KORG_NOMAIL | 4158 | #ifndef KORG_NOMAIL |
4160 | KOMailClient mailClient; | 4159 | KOMailClient mailClient; |
4161 | 4160 | ||
4162 | Incidence *incidence = currentSelection(); | 4161 | Incidence *incidence = currentSelection(); |
4163 | 4162 | ||
4164 | if (!incidence) { | 4163 | if (!incidence) { |
4165 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4164 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4166 | return; | 4165 | return; |
4167 | } | 4166 | } |
4168 | if(incidence->attendeeCount() == 0 ) { | 4167 | if(incidence->attendeeCount() == 0 ) { |
4169 | KMessageBox::sorry(this, | 4168 | KMessageBox::sorry(this, |
4170 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4169 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4171 | return; | 4170 | return; |
4172 | } | 4171 | } |
4173 | 4172 | ||
4174 | CalendarLocal cal_tmp; | 4173 | CalendarLocal cal_tmp; |
4175 | Event *event = 0; | 4174 | Event *event = 0; |
4176 | Event *ev = 0; | 4175 | Event *ev = 0; |
4177 | if ( incidence && incidence->typeID() == eventID ) { | 4176 | if ( incidence && incidence->typeID() == eventID ) { |
4178 | event = static_cast<Event *>(incidence); | 4177 | event = static_cast<Event *>(incidence); |
4179 | ev = new Event(*event); | 4178 | ev = new Event(*event); |
4180 | cal_tmp.addEvent(ev); | 4179 | cal_tmp.addEvent(ev); |
4181 | } | 4180 | } |
4182 | ICalFormat mForm(); | 4181 | ICalFormat mForm(); |
4183 | QString attachment = mForm.toString( &cal_tmp ); | 4182 | QString attachment = mForm.toString( &cal_tmp ); |
4184 | if (ev) delete(ev); | 4183 | if (ev) delete(ev); |
4185 | 4184 | ||
4186 | mailClient.mailAttendees(currentSelection(), attachment); | 4185 | mailClient.mailAttendees(currentSelection(), attachment); |
4187 | 4186 | ||
4188 | #endif | 4187 | #endif |
4189 | 4188 | ||
4190 | #if 0 | 4189 | #if 0 |
4191 | Event *anEvent = 0; | 4190 | Event *anEvent = 0; |
4192 | if (mViewManager->currentView()->isEventView()) { | 4191 | if (mViewManager->currentView()->isEventView()) { |
4193 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 4192 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
4194 | } | 4193 | } |
4195 | 4194 | ||
4196 | if (!anEvent) { | 4195 | if (!anEvent) { |
4197 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4196 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4198 | return; | 4197 | return; |
4199 | } | 4198 | } |
4200 | if(anEvent->attendeeCount() == 0 ) { | 4199 | if(anEvent->attendeeCount() == 0 ) { |
4201 | KMessageBox::sorry(this, | 4200 | KMessageBox::sorry(this, |
4202 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4201 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4203 | return; | 4202 | return; |
4204 | } | 4203 | } |
4205 | 4204 | ||
4206 | mailobject.emailEvent(anEvent); | 4205 | mailobject.emailEvent(anEvent); |
4207 | #endif | 4206 | #endif |
4208 | } | 4207 | } |
4209 | 4208 | ||
4210 | 4209 | ||
4211 | void CalendarView::schedule_publish(Incidence *incidence) | 4210 | void CalendarView::schedule_publish(Incidence *incidence) |
4212 | { | 4211 | { |
4213 | Event *event = 0; | 4212 | Event *event = 0; |
4214 | Todo *todo = 0; | 4213 | Todo *todo = 0; |
4215 | 4214 | ||
4216 | if (incidence == 0) { | 4215 | if (incidence == 0) { |
4217 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4216 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4218 | if (incidence == 0) { | 4217 | if (incidence == 0) { |
4219 | incidence = mTodoList->selectedIncidences().first(); | 4218 | incidence = mTodoList->selectedIncidences().first(); |
4220 | } | 4219 | } |
4221 | } | 4220 | } |
4222 | if ( incidence && incidence->typeID() == eventID ) { | 4221 | if ( incidence && incidence->typeID() == eventID ) { |
4223 | event = static_cast<Event *>(incidence); | 4222 | event = static_cast<Event *>(incidence); |
4224 | } else { | 4223 | } else { |
4225 | if ( incidence && incidence->typeID() == todoID ) { | 4224 | if ( incidence && incidence->typeID() == todoID ) { |
4226 | todo = static_cast<Todo *>(incidence); | 4225 | todo = static_cast<Todo *>(incidence); |
4227 | } | 4226 | } |
4228 | } | 4227 | } |
4229 | 4228 | ||
4230 | if (!event && !todo) { | 4229 | if (!event && !todo) { |
4231 | KMessageBox::sorry(this,i18n("No event selected.")); | 4230 | KMessageBox::sorry(this,i18n("No event selected.")); |
4232 | return; | 4231 | return; |
4233 | } | 4232 | } |
4234 | 4233 | ||
4235 | PublishDialog *publishdlg = new PublishDialog(); | 4234 | PublishDialog *publishdlg = new PublishDialog(); |
4236 | if (incidence->attendeeCount()>0) { | 4235 | if (incidence->attendeeCount()>0) { |
4237 | QPtrList<Attendee> attendees = incidence->attendees(); | 4236 | QPtrList<Attendee> attendees = incidence->attendees(); |
4238 | attendees.first(); | 4237 | attendees.first(); |
4239 | while ( attendees.current()!=0 ) { | 4238 | while ( attendees.current()!=0 ) { |
4240 | publishdlg->addAttendee(attendees.current()); | 4239 | publishdlg->addAttendee(attendees.current()); |
4241 | attendees.next(); | 4240 | attendees.next(); |
4242 | } | 4241 | } |
4243 | } | 4242 | } |
4244 | bool send = true; | 4243 | bool send = true; |
4245 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 4244 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
4246 | if ( publishdlg->exec() != QDialog::Accepted ) | 4245 | if ( publishdlg->exec() != QDialog::Accepted ) |
4247 | send = false; | 4246 | send = false; |
4248 | } | 4247 | } |
4249 | if ( send ) { | 4248 | if ( send ) { |
4250 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4249 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4251 | if ( event ) { | 4250 | if ( event ) { |
4252 | Event *ev = new Event(*event); | 4251 | Event *ev = new Event(*event); |
4253 | ev->registerObserver(0); | 4252 | ev->registerObserver(0); |
4254 | ev->clearAttendees(); | 4253 | ev->clearAttendees(); |
4255 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4254 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4256 | delete(ev); | 4255 | delete(ev); |
4257 | } | 4256 | } |
4258 | } else { | 4257 | } else { |
4259 | if ( todo ) { | 4258 | if ( todo ) { |
4260 | Todo *ev = new Todo(*todo); | 4259 | Todo *ev = new Todo(*todo); |
4261 | ev->registerObserver(0); | 4260 | ev->registerObserver(0); |
4262 | ev->clearAttendees(); | 4261 | ev->clearAttendees(); |
4263 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4262 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4264 | delete(ev); | 4263 | delete(ev); |
4265 | } | 4264 | } |
4266 | } | 4265 | } |
4267 | } | 4266 | } |
4268 | } | 4267 | } |
4269 | delete publishdlg; | 4268 | delete publishdlg; |
4270 | } | 4269 | } |
4271 | 4270 | ||
4272 | void CalendarView::schedule_request(Incidence *incidence) | 4271 | void CalendarView::schedule_request(Incidence *incidence) |
4273 | { | 4272 | { |
4274 | schedule(Scheduler::Request,incidence); | 4273 | schedule(Scheduler::Request,incidence); |
4275 | } | 4274 | } |
4276 | 4275 | ||
4277 | void CalendarView::schedule_refresh(Incidence *incidence) | 4276 | void CalendarView::schedule_refresh(Incidence *incidence) |
4278 | { | 4277 | { |
4279 | schedule(Scheduler::Refresh,incidence); | 4278 | schedule(Scheduler::Refresh,incidence); |
4280 | } | 4279 | } |
4281 | 4280 | ||
4282 | void CalendarView::schedule_cancel(Incidence *incidence) | 4281 | void CalendarView::schedule_cancel(Incidence *incidence) |
4283 | { | 4282 | { |
4284 | schedule(Scheduler::Cancel,incidence); | 4283 | schedule(Scheduler::Cancel,incidence); |
4285 | } | 4284 | } |
4286 | 4285 | ||
4287 | void CalendarView::schedule_add(Incidence *incidence) | 4286 | void CalendarView::schedule_add(Incidence *incidence) |
4288 | { | 4287 | { |
4289 | schedule(Scheduler::Add,incidence); | 4288 | schedule(Scheduler::Add,incidence); |
4290 | } | 4289 | } |
4291 | 4290 | ||
4292 | void CalendarView::schedule_reply(Incidence *incidence) | 4291 | void CalendarView::schedule_reply(Incidence *incidence) |
4293 | { | 4292 | { |
4294 | schedule(Scheduler::Reply,incidence); | 4293 | schedule(Scheduler::Reply,incidence); |
4295 | } | 4294 | } |
4296 | 4295 | ||
4297 | void CalendarView::schedule_counter(Incidence *incidence) | 4296 | void CalendarView::schedule_counter(Incidence *incidence) |
4298 | { | 4297 | { |
4299 | schedule(Scheduler::Counter,incidence); | 4298 | schedule(Scheduler::Counter,incidence); |
4300 | } | 4299 | } |
4301 | 4300 | ||
4302 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 4301 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
4303 | { | 4302 | { |
4304 | schedule(Scheduler::Declinecounter,incidence); | 4303 | schedule(Scheduler::Declinecounter,incidence); |
4305 | } | 4304 | } |
4306 | 4305 | ||
4307 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 4306 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
4308 | { | 4307 | { |
4309 | QDateTime start = QDateTime::currentDateTime(); | 4308 | QDateTime start = QDateTime::currentDateTime(); |
4310 | QDateTime end = start.addDays(daysToPublish); | 4309 | QDateTime end = start.addDays(daysToPublish); |
4311 | 4310 | ||
4312 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4311 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
4313 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4312 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
4314 | 4313 | ||
4315 | 4314 | ||
4316 | PublishDialog *publishdlg = new PublishDialog(); | 4315 | PublishDialog *publishdlg = new PublishDialog(); |
4317 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4316 | if ( publishdlg->exec() == QDialog::Accepted ) { |
4318 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4317 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4319 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4318 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
4320 | delete(freebusy); | 4319 | delete(freebusy); |
4321 | } | 4320 | } |
4322 | } | 4321 | } |
4323 | delete publishdlg; | 4322 | delete publishdlg; |
4324 | } | 4323 | } |
4325 | 4324 | ||
4326 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4325 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4327 | { | 4326 | { |
4328 | Event *event = 0; | 4327 | Event *event = 0; |
4329 | Todo *todo = 0; | 4328 | Todo *todo = 0; |
4330 | 4329 | ||
4331 | if (incidence == 0) { | 4330 | if (incidence == 0) { |
4332 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4331 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4333 | if (incidence == 0) { | 4332 | if (incidence == 0) { |
4334 | incidence = mTodoList->selectedIncidences().first(); | 4333 | incidence = mTodoList->selectedIncidences().first(); |
4335 | } | 4334 | } |
4336 | } | 4335 | } |
4337 | if ( incidence && incidence->typeID() == eventID ) { | 4336 | if ( incidence && incidence->typeID() == eventID ) { |
4338 | event = static_cast<Event *>(incidence); | 4337 | event = static_cast<Event *>(incidence); |
4339 | } | 4338 | } |
4340 | if ( incidence && incidence->typeID() == todoID ) { | 4339 | if ( incidence && incidence->typeID() == todoID ) { |
4341 | todo = static_cast<Todo *>(incidence); | 4340 | todo = static_cast<Todo *>(incidence); |
4342 | } | 4341 | } |
4343 | 4342 | ||
4344 | if (!event && !todo) { | 4343 | if (!event && !todo) { |
4345 | KMessageBox::sorry(this,i18n("No event selected.")); | 4344 | KMessageBox::sorry(this,i18n("No event selected.")); |
4346 | return; | 4345 | return; |
4347 | } | 4346 | } |
4348 | 4347 | ||
4349 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4348 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4350 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4349 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4351 | return; | 4350 | return; |
4352 | } | 4351 | } |
4353 | 4352 | ||
4354 | Event *ev = 0; | 4353 | Event *ev = 0; |
4355 | if (event) ev = new Event(*event); | 4354 | if (event) ev = new Event(*event); |
4356 | Todo *to = 0; | 4355 | Todo *to = 0; |
4357 | if (todo) to = new Todo(*todo); | 4356 | if (todo) to = new Todo(*todo); |
4358 | 4357 | ||
4359 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4358 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4360 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4359 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4361 | if (!me) { | 4360 | if (!me) { |
4362 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4361 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4363 | return; | 4362 | return; |
4364 | } | 4363 | } |
4365 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4364 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4366 | StatusDialog *statdlg = new StatusDialog(this); | 4365 | StatusDialog *statdlg = new StatusDialog(this); |
4367 | if (!statdlg->exec()==QDialog::Accepted) return; | 4366 | if (!statdlg->exec()==QDialog::Accepted) return; |
4368 | me->setStatus( statdlg->status() ); | 4367 | me->setStatus( statdlg->status() ); |
4369 | delete(statdlg); | 4368 | delete(statdlg); |
4370 | } | 4369 | } |
4371 | Attendee *menew = new Attendee(*me); | 4370 | Attendee *menew = new Attendee(*me); |
4372 | if (ev) { | 4371 | if (ev) { |
4373 | ev->clearAttendees(); | 4372 | ev->clearAttendees(); |
4374 | ev->addAttendee(menew,false); | 4373 | ev->addAttendee(menew,false); |
4375 | } else { | 4374 | } else { |
4376 | if (to) { | 4375 | if (to) { |
4377 | todo->clearAttendees(); | 4376 | todo->clearAttendees(); |
4378 | todo->addAttendee(menew,false); | 4377 | todo->addAttendee(menew,false); |
4379 | } | 4378 | } |
4380 | } | 4379 | } |
4381 | } | 4380 | } |
4382 | 4381 | ||
4383 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4382 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4384 | if (ev) { | 4383 | if (ev) { |
4385 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4384 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4386 | } else { | 4385 | } else { |
4387 | if (to) { | 4386 | if (to) { |
4388 | if ( !dlg->addMessage(to,method) ) delete(to); | 4387 | if ( !dlg->addMessage(to,method) ) delete(to); |
4389 | } | 4388 | } |
4390 | } | 4389 | } |
4391 | } | 4390 | } |
4392 | 4391 | ||
4393 | void CalendarView::openAddressbook() | 4392 | void CalendarView::openAddressbook() |
4394 | { | 4393 | { |
4395 | KRun::runCommand("kaddressbook"); | 4394 | KRun::runCommand("kaddressbook"); |
4396 | } | 4395 | } |
4397 | 4396 | ||
4398 | void CalendarView::setModified(bool modified) | 4397 | void CalendarView::setModified(bool modified) |
4399 | { | 4398 | { |
4400 | //qDebug("CalendarView::setModified %d ", modified); | 4399 | //qDebug("CalendarView::setModified %d ", modified); |
4401 | if ( modified ) | 4400 | if ( modified ) |
4402 | emit signalmodified(); | 4401 | emit signalmodified(); |
4403 | mModified = modified; | 4402 | mModified = modified; |
4404 | if ( mModified ) | 4403 | if ( mModified ) |
4405 | emit modifiedChanged(mModified); | 4404 | emit modifiedChanged(mModified); |
4406 | 4405 | ||
4407 | } | 4406 | } |
4408 | 4407 | ||
4409 | bool CalendarView::isReadOnly() | 4408 | bool CalendarView::isReadOnly() |
4410 | { | 4409 | { |
4411 | return mReadOnly; | 4410 | return mReadOnly; |
4412 | } | 4411 | } |
4413 | 4412 | ||
4414 | void CalendarView::setReadOnly(bool readOnly) | 4413 | void CalendarView::setReadOnly(bool readOnly) |
4415 | { | 4414 | { |
4416 | if (mReadOnly != readOnly) { | 4415 | if (mReadOnly != readOnly) { |
4417 | mReadOnly = readOnly; | 4416 | mReadOnly = readOnly; |
4418 | emit readOnlyChanged(mReadOnly); | 4417 | emit readOnlyChanged(mReadOnly); |
4419 | } | 4418 | } |
4420 | } | 4419 | } |
4421 | 4420 | ||
4422 | bool CalendarView::isModified() | 4421 | bool CalendarView::isModified() |
4423 | { | 4422 | { |
4424 | return mModified; | 4423 | return mModified; |
4425 | } | 4424 | } |
4426 | void CalendarView::slotprintSelInc() | 4425 | void CalendarView::slotprintSelInc() |
4427 | { | 4426 | { |
4428 | if ( currentSelection() == 0 ) { | 4427 | if ( currentSelection() == 0 ) { |
4429 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4428 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4430 | return; | 4429 | return; |
4431 | } | 4430 | } |
4432 | showIncidence(); | 4431 | showIncidence(); |
4433 | getEventViewerDialog()->print(); | 4432 | getEventViewerDialog()->print(); |
4434 | 4433 | ||
4435 | } | 4434 | } |
4436 | void CalendarView::printSetup() | 4435 | void CalendarView::printSetup() |
4437 | { | 4436 | { |
4438 | #ifndef KORG_NOPRINTER | 4437 | #ifndef KORG_NOPRINTER |
4439 | createPrinter(); | 4438 | createPrinter(); |
4440 | 4439 | ||
4441 | mCalPrinter->setupPrinter(); | 4440 | mCalPrinter->setupPrinter(); |
4442 | #endif | 4441 | #endif |
4443 | } | 4442 | } |
4444 | 4443 | ||
4445 | void CalendarView::print() | 4444 | void CalendarView::print() |
4446 | { | 4445 | { |
4447 | #ifndef KORG_NOPRINTER | 4446 | #ifndef KORG_NOPRINTER |
4448 | createPrinter(); | 4447 | createPrinter(); |
4449 | 4448 | ||
4450 | DateList tmpDateList = mNavigator->selectedDates(); | 4449 | DateList tmpDateList = mNavigator->selectedDates(); |
4451 | mCalPrinter->print(CalPrinter::Month, | 4450 | mCalPrinter->print(CalPrinter::Month, |
4452 | tmpDateList.first(), tmpDateList.last()); | 4451 | tmpDateList.first(), tmpDateList.last()); |
4453 | #endif | 4452 | #endif |
4454 | } | 4453 | } |
4455 | 4454 | ||
4456 | void CalendarView::printPreview() | 4455 | void CalendarView::printPreview() |
4457 | { | 4456 | { |
4458 | #ifndef KORG_NOPRINTER | 4457 | #ifndef KORG_NOPRINTER |
4459 | kdDebug() << "CalendarView::printPreview()" << endl; | 4458 | kdDebug() << "CalendarView::printPreview()" << endl; |
4460 | 4459 | ||
4461 | createPrinter(); | 4460 | createPrinter(); |
4462 | 4461 | ||
4463 | DateList tmpDateList = mNavigator->selectedDates(); | 4462 | DateList tmpDateList = mNavigator->selectedDates(); |
4464 | 4463 | ||
4465 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4464 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4466 | tmpDateList.last()); | 4465 | tmpDateList.last()); |
4467 | #endif | 4466 | #endif |
4468 | } | 4467 | } |
4469 | bool CalendarView::exportICalendar( QString filename ) | 4468 | bool CalendarView::exportICalendar( QString filename ) |
4470 | { | 4469 | { |
4471 | // Force correct extension | 4470 | // Force correct extension |
4472 | if (filename.right(4) != ".ics") filename += ".ics"; | 4471 | if (filename.right(4) != ".ics") filename += ".ics"; |
4473 | 4472 | ||
4474 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4473 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4475 | return storage.save(); | 4474 | return storage.save(); |
4476 | } | 4475 | } |
4477 | 4476 | ||
4478 | bool CalendarView::exportICalendar() | 4477 | bool CalendarView::exportICalendar() |
4479 | { | 4478 | { |
4480 | return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); | 4479 | return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); |
4481 | } | 4480 | } |
4482 | 4481 | ||
4483 | bool CalendarView::exportVCalendar( QString filename ) | 4482 | bool CalendarView::exportVCalendar( QString filename ) |
4484 | { | 4483 | { |
4485 | if (mCalendar->journals().count() > 0) { | 4484 | if (mCalendar->journals().count() > 0) { |
4486 | int result = KMessageBox::warningContinueCancel(this, | 4485 | int result = KMessageBox::warningContinueCancel(this, |
4487 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4486 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4488 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4487 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4489 | true); | 4488 | true); |
4490 | if (result != KMessageBox::Continue) return false; | 4489 | if (result != KMessageBox::Continue) return false; |
4491 | } | 4490 | } |
4492 | 4491 | ||
4493 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4492 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4494 | 4493 | ||
4495 | // Force correct extension | 4494 | // Force correct extension |
4496 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4495 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4497 | 4496 | ||
4498 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4497 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4499 | return storage.save(); | 4498 | return storage.save(); |
4500 | 4499 | ||
4501 | } | 4500 | } |
4502 | 4501 | ||
4503 | void CalendarView::eventUpdated(Incidence *) | 4502 | void CalendarView::eventUpdated(Incidence *) |
4504 | { | 4503 | { |
4505 | setModified(); | 4504 | setModified(); |
4506 | // Don't call updateView here. The code, which has caused the update of the | 4505 | // Don't call updateView here. The code, which has caused the update of the |
4507 | // event is responsible for updating the view. | 4506 | // event is responsible for updating the view. |
4508 | // updateView(); | 4507 | // updateView(); |
4509 | } | 4508 | } |
4510 | 4509 | ||
4511 | void CalendarView::adaptNavigationUnits() | 4510 | void CalendarView::adaptNavigationUnits() |
4512 | { | 4511 | { |
4513 | if (mViewManager->currentView()->isEventView()) { | 4512 | if (mViewManager->currentView()->isEventView()) { |
4514 | int days = mViewManager->currentView()->currentDateCount(); | 4513 | int days = mViewManager->currentView()->currentDateCount(); |
4515 | if (days == 1) { | 4514 | if (days == 1) { |
4516 | emit changeNavStringPrev(i18n("&Previous Day")); | 4515 | emit changeNavStringPrev(i18n("&Previous Day")); |
4517 | emit changeNavStringNext(i18n("&Next Day")); | 4516 | emit changeNavStringNext(i18n("&Next Day")); |
4518 | } else { | 4517 | } else { |
4519 | emit changeNavStringPrev(i18n("&Previous Week")); | 4518 | emit changeNavStringPrev(i18n("&Previous Week")); |
4520 | emit changeNavStringNext(i18n("&Next Week")); | 4519 | emit changeNavStringNext(i18n("&Next Week")); |
4521 | } | 4520 | } |
4522 | } | 4521 | } |
4523 | } | 4522 | } |
4524 | 4523 | ||
4525 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4524 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4526 | { | 4525 | { |
4527 | if ( incidence ) mTodoList->clearSelection(); | 4526 | if ( incidence ) mTodoList->clearSelection(); |
4528 | processIncidenceSelection( incidence ); | 4527 | processIncidenceSelection( incidence ); |
4529 | } | 4528 | } |
4530 | 4529 | ||
4531 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4530 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4532 | { | 4531 | { |
4533 | if ( incidence && mViewManager->currentView() ) { | 4532 | if ( incidence && mViewManager->currentView() ) { |
4534 | mViewManager->currentView()->clearSelection(); | 4533 | mViewManager->currentView()->clearSelection(); |
4535 | } | 4534 | } |
4536 | processIncidenceSelection( incidence ); | 4535 | processIncidenceSelection( incidence ); |
4537 | } | 4536 | } |
4538 | 4537 | ||
4539 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4538 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4540 | { | 4539 | { |
4541 | emit incidenceSelected( incidence ); | 4540 | emit incidenceSelected( incidence ); |
4542 | if ( incidence == mSelectedIncidence ) return; | 4541 | if ( incidence == mSelectedIncidence ) return; |
4543 | mSelectedIncidence = incidence; | 4542 | mSelectedIncidence = incidence; |
4544 | 4543 | ||
4545 | if ( incidence && incidence->typeID() == eventID ) { | 4544 | if ( incidence && incidence->typeID() == eventID ) { |
4546 | Event *event = static_cast<Event *>( incidence ); | 4545 | Event *event = static_cast<Event *>( incidence ); |
4547 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4546 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4548 | emit organizerEventsSelected( true ); | 4547 | emit organizerEventsSelected( true ); |
4549 | } else { | 4548 | } else { |
4550 | emit organizerEventsSelected(false); | 4549 | emit organizerEventsSelected(false); |
4551 | } | 4550 | } |
4552 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4551 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4553 | KOPrefs::instance()->email() ) ) { | 4552 | KOPrefs::instance()->email() ) ) { |
4554 | emit groupEventsSelected( true ); | 4553 | emit groupEventsSelected( true ); |
4555 | } else { | 4554 | } else { |
4556 | emit groupEventsSelected(false); | 4555 | emit groupEventsSelected(false); |
4557 | } | 4556 | } |
4558 | return; | 4557 | return; |
4559 | } else { | 4558 | } else { |
4560 | if ( incidence && incidence->typeID() == todoID ) { | 4559 | if ( incidence && incidence->typeID() == todoID ) { |
4561 | emit todoSelected( true ); | 4560 | emit todoSelected( true ); |
4562 | Todo *event = static_cast<Todo *>( incidence ); | 4561 | Todo *event = static_cast<Todo *>( incidence ); |
4563 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4562 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4564 | emit organizerEventsSelected( true ); | 4563 | emit organizerEventsSelected( true ); |
4565 | } else { | 4564 | } else { |
4566 | emit organizerEventsSelected(false); | 4565 | emit organizerEventsSelected(false); |
4567 | } | 4566 | } |
4568 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4567 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4569 | KOPrefs::instance()->email() ) ) { | 4568 | KOPrefs::instance()->email() ) ) { |
4570 | emit groupEventsSelected( true ); | 4569 | emit groupEventsSelected( true ); |
4571 | } else { | 4570 | } else { |
4572 | emit groupEventsSelected(false); | 4571 | emit groupEventsSelected(false); |
4573 | } | 4572 | } |
4574 | return; | 4573 | return; |
4575 | } else { | 4574 | } else { |
4576 | emit todoSelected( false ); | 4575 | emit todoSelected( false ); |
4577 | emit organizerEventsSelected(false); | 4576 | emit organizerEventsSelected(false); |
4578 | emit groupEventsSelected(false); | 4577 | emit groupEventsSelected(false); |
4579 | } | 4578 | } |
4580 | return; | 4579 | return; |
4581 | } | 4580 | } |
4582 | 4581 | ||
4583 | /* if ( incidence && incidence->typeID() == todoID ) { | 4582 | /* if ( incidence && incidence->typeID() == todoID ) { |
4584 | emit todoSelected( true ); | 4583 | emit todoSelected( true ); |
4585 | } else { | 4584 | } else { |
4586 | emit todoSelected( false ); | 4585 | emit todoSelected( false ); |
4587 | }*/ | 4586 | }*/ |
4588 | } | 4587 | } |
4589 | 4588 | ||
4590 | 4589 | ||
4591 | void CalendarView::checkClipboard() | 4590 | void CalendarView::checkClipboard() |
4592 | { | 4591 | { |
4593 | #ifndef KORG_NODND | 4592 | #ifndef KORG_NODND |
4594 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4593 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4595 | emit pasteEnabled(true); | 4594 | emit pasteEnabled(true); |
4596 | } else { | 4595 | } else { |
4597 | emit pasteEnabled(false); | 4596 | emit pasteEnabled(false); |
4598 | } | 4597 | } |
4599 | #endif | 4598 | #endif |
4600 | } | 4599 | } |
4601 | 4600 | ||
4602 | void CalendarView::showDates(const DateList &selectedDates) | 4601 | void CalendarView::showDates(const DateList &selectedDates) |
4603 | { | 4602 | { |
4604 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4603 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4605 | 4604 | ||
4606 | 4605 | ||
4607 | if ( !mBlockShowDates ) { | 4606 | if ( !mBlockShowDates ) { |
4608 | if ( mViewManager->currentView() ) { | 4607 | if ( mViewManager->currentView() ) { |
4609 | updateView( selectedDates.first(), selectedDates.last() ); | 4608 | updateView( selectedDates.first(), selectedDates.last() ); |
4610 | } else { | 4609 | } else { |
4611 | mViewManager->showAgendaView(); | 4610 | mViewManager->showAgendaView(); |
4612 | } | 4611 | } |
4613 | } | 4612 | } |
4614 | 4613 | ||
4615 | QDate date = selectedDates.first(); | 4614 | QDate date = selectedDates.first(); |
4616 | if ( ! date.isValid() ) { | 4615 | if ( ! date.isValid() ) { |
4617 | topLevelWidget()->setCaption(""); | 4616 | topLevelWidget()->setCaption(""); |
4618 | return; | 4617 | return; |
4619 | } | 4618 | } |
4620 | 4619 | ||
4621 | QString selDates; | 4620 | QString selDates; |
4622 | selDates = KGlobal::locale()->formatDate( date, true); | 4621 | selDates = KGlobal::locale()->formatDate( date, true); |
4623 | if (selectedDates.first() < selectedDates.last() ) | 4622 | if (selectedDates.first() < selectedDates.last() ) |
4624 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4623 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4625 | else { | 4624 | else { |
4626 | QString addString; | 4625 | QString addString; |
4627 | if ( date == QDateTime::currentDateTime().date() ) | 4626 | if ( date == QDateTime::currentDateTime().date() ) |
4628 | addString = i18n("Today"); | 4627 | addString = i18n("Today"); |
4629 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4628 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4630 | addString = i18n("Tomorrow"); | 4629 | addString = i18n("Tomorrow"); |
4631 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4630 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4632 | addString = i18n("Yesterday"); | 4631 | addString = i18n("Yesterday"); |
4633 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4632 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4634 | addString = i18n("Day before yesterday"); | 4633 | addString = i18n("Day before yesterday"); |
4635 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4634 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4636 | addString = i18n("Day after tomorrow"); | 4635 | addString = i18n("Day after tomorrow"); |
4637 | if ( !addString.isEmpty() ) { | 4636 | if ( !addString.isEmpty() ) { |
4638 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4637 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4639 | return; | 4638 | return; |
4640 | } | 4639 | } |
4641 | } | 4640 | } |
4642 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4641 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4643 | 4642 | ||
4644 | } | 4643 | } |
4645 | 4644 | ||
4646 | QPtrList<CalFilter> CalendarView::filters() | 4645 | QPtrList<CalFilter> CalendarView::filters() |
4647 | { | 4646 | { |
4648 | return mFilters; | 4647 | return mFilters; |
4649 | 4648 | ||
4650 | } | 4649 | } |
4651 | void CalendarView::editFilters() | 4650 | void CalendarView::editFilters() |
4652 | { | 4651 | { |
4653 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4652 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4654 | 4653 | ||
4655 | CalFilter *filter = mFilters.first(); | 4654 | CalFilter *filter = mFilters.first(); |
4656 | while(filter) { | 4655 | while(filter) { |
4657 | filter = mFilters.next(); | 4656 | filter = mFilters.next(); |
4658 | } | 4657 | } |
4659 | 4658 | ||
4660 | mDialogManager->showFilterEditDialog(&mFilters); | 4659 | mDialogManager->showFilterEditDialog(&mFilters); |
4661 | updateFilter(); | 4660 | updateFilter(); |
4662 | } | 4661 | } |
4663 | void CalendarView::toggleFilter() | 4662 | void CalendarView::toggleFilter() |
4664 | { | 4663 | { |
4665 | if ( mLeftFrame->isHidden() ) { | 4664 | if ( mLeftFrame->isHidden() ) { |
4666 | toggleExpand(); | 4665 | toggleExpand(); |
4667 | showFilter( true ); | 4666 | showFilter( true ); |
4668 | } else | 4667 | } else |
4669 | showFilter(! mCalEditView->isVisible()); | 4668 | showFilter(! mCalEditView->isVisible()); |
4670 | } | 4669 | } |
4671 | 4670 | ||
4672 | KOFilterView *CalendarView::filterView() | 4671 | KOFilterView *CalendarView::filterView() |
4673 | { | 4672 | { |
4674 | return mFilterView; | 4673 | return mFilterView; |
4675 | } | 4674 | } |
4676 | void CalendarView::selectFilter( int fil ) | 4675 | void CalendarView::selectFilter( int fil ) |
4677 | { | 4676 | { |
4678 | mFilterView->setSelectedFilter( fil ); | 4677 | mFilterView->setSelectedFilter( fil ); |
4679 | updateUnmanagedViews(); | 4678 | updateUnmanagedViews(); |
4680 | } | 4679 | } |
4681 | void CalendarView::showFilter(bool visible) | 4680 | void CalendarView::showFilter(bool visible) |
4682 | { | 4681 | { |
4683 | #if 1 | 4682 | #if 1 |
4684 | if (visible) { | 4683 | if (visible) { |
4685 | mCalEditView->readConfig(); | 4684 | mCalEditView->readConfig(); |
4686 | mCalEditView->show(); | 4685 | mCalEditView->show(); |
4687 | QValueList<int> sizes; | 4686 | QValueList<int> sizes; |
4688 | sizes = mLeftFrame->sizes(); | 4687 | sizes = mLeftFrame->sizes(); |
4689 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4688 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4690 | sizes.clear(); | 4689 | sizes.clear(); |
4691 | sizes << 100; | 4690 | sizes << 100; |
4692 | sizes << 0; | 4691 | sizes << 0; |
4693 | sizes << 0; | 4692 | sizes << 0; |
4694 | sizes << 100; | 4693 | sizes << 100; |
4695 | mLeftFrame->setSizes(sizes); | 4694 | mLeftFrame->setSizes(sizes); |
4696 | } | 4695 | } |
4697 | #if 0 | 4696 | #if 0 |
4698 | sizes = mLeftFrame->sizes(); | 4697 | sizes = mLeftFrame->sizes(); |
4699 | int ccc = 0; | 4698 | int ccc = 0; |
4700 | while ( ccc < sizes.count()) { | 4699 | while ( ccc < sizes.count()) { |
4701 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4700 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4702 | ++ccc; | 4701 | ++ccc; |
4703 | } | 4702 | } |
4704 | #endif | 4703 | #endif |
4705 | 4704 | ||
4706 | } | 4705 | } |
4707 | else { | 4706 | else { |
4708 | mCalEditView->hide(); | 4707 | mCalEditView->hide(); |
4709 | } | 4708 | } |
4710 | #else | 4709 | #else |
4711 | if (visible) mFilterView->show(); | 4710 | if (visible) mFilterView->show(); |
4712 | else mFilterView->hide(); | 4711 | else mFilterView->hide(); |
4713 | #endif | 4712 | #endif |
4714 | } | 4713 | } |
4715 | void CalendarView::toggleFilerEnabled( ) | 4714 | void CalendarView::toggleFilerEnabled( ) |
4716 | { | 4715 | { |
4717 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4716 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4718 | if ( !mFilterView->filtersEnabled() ) | 4717 | if ( !mFilterView->filtersEnabled() ) |
4719 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4718 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4720 | updateUnmanagedViews(); | 4719 | updateUnmanagedViews(); |
4721 | 4720 | ||
4722 | } | 4721 | } |
4723 | void CalendarView::updateFilter() | 4722 | void CalendarView::updateFilter() |
4724 | { | 4723 | { |
4725 | CalFilter *filter = mFilterView->selectedFilter(); | 4724 | CalFilter *filter = mFilterView->selectedFilter(); |
4726 | if (filter) { | 4725 | if (filter) { |
4727 | QString mess; | 4726 | QString mess; |
4728 | if (mFilterView->filtersEnabled()) { | 4727 | if (mFilterView->filtersEnabled()) { |
4729 | mess = i18n("Filter selected: ")+filter->name(); | 4728 | mess = i18n("Filter selected: ")+filter->name(); |
4730 | filter->setEnabled(true); | 4729 | filter->setEnabled(true); |
4731 | } | 4730 | } |
4732 | else filter->setEnabled(false); | 4731 | else filter->setEnabled(false); |
4733 | mCalendar->setFilter(filter); | 4732 | mCalendar->setFilter(filter); |
4734 | updateView(); | 4733 | updateView(); |
4735 | if ( !mess.isEmpty() ) | 4734 | if ( !mess.isEmpty() ) |
4736 | topLevelWidget()->setCaption( mess ); | 4735 | topLevelWidget()->setCaption( mess ); |
4737 | 4736 | ||
4738 | } | 4737 | } |
4739 | emit filtersUpdated(); | 4738 | emit filtersUpdated(); |
4740 | } | 4739 | } |
4741 | 4740 | ||
4742 | void CalendarView::filterEdited() | 4741 | void CalendarView::filterEdited() |
4743 | { | 4742 | { |
4744 | mFilterView->updateFilters(); | 4743 | mFilterView->updateFilters(); |
4745 | updateFilter(); | 4744 | updateFilter(); |
4746 | writeSettings(); | 4745 | writeSettings(); |
4747 | } | 4746 | } |
4748 | 4747 | ||
4749 | 4748 | ||
4750 | void CalendarView::takeOverEvent() | 4749 | void CalendarView::takeOverEvent() |
4751 | { | 4750 | { |
4752 | Incidence *incidence = currentSelection(); | 4751 | Incidence *incidence = currentSelection(); |
4753 | 4752 | ||
4754 | if (!incidence) return; | 4753 | if (!incidence) return; |
4755 | 4754 | ||
4756 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4755 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4757 | incidence->recreate(); | 4756 | incidence->recreate(); |
4758 | incidence->setReadOnly(false); | 4757 | incidence->setReadOnly(false); |
4759 | 4758 | ||
4760 | updateView(); | 4759 | updateView(); |
4761 | } | 4760 | } |
4762 | 4761 | ||
4763 | void CalendarView::takeOverCalendar() | 4762 | void CalendarView::takeOverCalendar() |
4764 | { | 4763 | { |
4765 | // TODO: Create Calendar::allIncidences() function and use it here | 4764 | // TODO: Create Calendar::allIncidences() function and use it here |
4766 | 4765 | ||
4767 | clearAllViews(); | 4766 | clearAllViews(); |
4768 | QPtrList<Event> events = mCalendar->events(); | 4767 | QPtrList<Event> events = mCalendar->events(); |
4769 | for(uint i=0; i<events.count(); ++i) { | 4768 | for(uint i=0; i<events.count(); ++i) { |
4770 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4769 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4771 | events.at(i)->recreate(); | 4770 | events.at(i)->recreate(); |
4772 | events.at(i)->setReadOnly(false); | 4771 | events.at(i)->setReadOnly(false); |
4773 | } | 4772 | } |
4774 | 4773 | ||
4775 | QPtrList<Todo> todos = mCalendar->todos(); | 4774 | QPtrList<Todo> todos = mCalendar->todos(); |
4776 | for(uint i=0; i<todos.count(); ++i) { | 4775 | for(uint i=0; i<todos.count(); ++i) { |
4777 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4776 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4778 | todos.at(i)->recreate(); | 4777 | todos.at(i)->recreate(); |
4779 | todos.at(i)->setReadOnly(false); | 4778 | todos.at(i)->setReadOnly(false); |
4780 | } | 4779 | } |
4781 | 4780 | ||
4782 | QPtrList<Journal> journals = mCalendar->journals(); | 4781 | QPtrList<Journal> journals = mCalendar->journals(); |
4783 | for(uint i=0; i<journals.count(); ++i) { | 4782 | for(uint i=0; i<journals.count(); ++i) { |
4784 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4783 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4785 | journals.at(i)->recreate(); | 4784 | journals.at(i)->recreate(); |
4786 | journals.at(i)->setReadOnly(false); | 4785 | journals.at(i)->setReadOnly(false); |
4787 | } | 4786 | } |
4788 | 4787 | ||
4789 | updateView(); | 4788 | updateView(); |
4790 | } | 4789 | } |
4791 | 4790 | ||
4792 | void CalendarView::showIntro() | 4791 | void CalendarView::showIntro() |
4793 | { | 4792 | { |
4794 | kdDebug() << "To be implemented." << endl; | 4793 | kdDebug() << "To be implemented." << endl; |
4795 | } | 4794 | } |
4796 | 4795 | ||
4797 | QWidgetStack *CalendarView::viewStack() | 4796 | QWidgetStack *CalendarView::viewStack() |
4798 | { | 4797 | { |
4799 | return mRightFrame; | 4798 | return mRightFrame; |
4800 | } | 4799 | } |
4801 | 4800 | ||
4802 | QWidget *CalendarView::leftFrame() | 4801 | QWidget *CalendarView::leftFrame() |
4803 | { | 4802 | { |
4804 | return ( QWidget *)mLeftFrame; | 4803 | return ( QWidget *)mLeftFrame; |
4805 | } | 4804 | } |
4806 | 4805 | ||
4807 | DateNavigator *CalendarView::dateNavigator() | 4806 | DateNavigator *CalendarView::dateNavigator() |
4808 | { | 4807 | { |
4809 | return mNavigator; | 4808 | return mNavigator; |
4810 | } | 4809 | } |
4811 | 4810 | ||
4812 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4811 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4813 | { | 4812 | { |
4814 | return mDateNavigator->navigatorView(); | 4813 | return mDateNavigator->navigatorView(); |
4815 | } | 4814 | } |
4816 | void CalendarView::toggleDateNavigatorWidget() | 4815 | void CalendarView::toggleDateNavigatorWidget() |
4817 | { | 4816 | { |
4818 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4817 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4819 | 4818 | ||
4820 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4819 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4821 | mDateNavigator->hide(); | 4820 | mDateNavigator->hide(); |
4822 | else | 4821 | else |
4823 | mDateNavigator->show(); | 4822 | mDateNavigator->show(); |
4824 | } | 4823 | } |
4825 | void CalendarView::addView(KOrg::BaseView *view) | 4824 | void CalendarView::addView(KOrg::BaseView *view) |
4826 | { | 4825 | { |
4827 | mViewManager->addView(view); | 4826 | mViewManager->addView(view); |
4828 | } | 4827 | } |
4829 | 4828 | ||
4830 | void CalendarView::showView(KOrg::BaseView *view) | 4829 | void CalendarView::showView(KOrg::BaseView *view) |
4831 | { | 4830 | { |
4832 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4831 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4833 | } | 4832 | } |
4834 | 4833 | ||
4835 | Incidence *CalendarView::currentSelection() | 4834 | Incidence *CalendarView::currentSelection() |
4836 | { | 4835 | { |
4837 | return mViewManager->currentSelection(); | 4836 | return mViewManager->currentSelection(); |
4838 | } | 4837 | } |
4839 | void CalendarView::toggleAllDaySize() | 4838 | void CalendarView::toggleAllDaySize() |
4840 | { | 4839 | { |
4841 | /* | 4840 | /* |
4842 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4841 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4843 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4842 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4844 | else | 4843 | else |
4845 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4844 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4846 | */ | 4845 | */ |
4847 | viewManager()->agendaView()->toggleAllDay(); | 4846 | viewManager()->agendaView()->toggleAllDay(); |
4848 | } | 4847 | } |
4849 | void CalendarView::toggleExpand() | 4848 | void CalendarView::toggleExpand() |
4850 | { | 4849 | { |
4851 | // if ( mLeftFrame->isHidden() ) { | 4850 | // if ( mLeftFrame->isHidden() ) { |
4852 | // mLeftFrame->show(); | 4851 | // mLeftFrame->show(); |
4853 | // emit calendarViewExpanded( false ); | 4852 | // emit calendarViewExpanded( false ); |
4854 | // } else { | 4853 | // } else { |
4855 | // mLeftFrame->hide(); | 4854 | // mLeftFrame->hide(); |
4856 | // emit calendarViewExpanded( true ); | 4855 | // emit calendarViewExpanded( true ); |
4857 | // } | 4856 | // } |
4858 | //qDebug(" CalendarView::toggleExpand()"); | 4857 | //qDebug(" CalendarView::toggleExpand()"); |
4859 | globalFlagBlockAgenda = 1; | 4858 | globalFlagBlockAgenda = 1; |
4860 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4859 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4861 | globalFlagBlockAgenda = 5; | 4860 | globalFlagBlockAgenda = 5; |
4862 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4861 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4863 | //mViewManager->showView( 0, true ); | 4862 | //mViewManager->showView( 0, true ); |
4864 | } | 4863 | } |
4865 | 4864 | ||
4866 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4865 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4867 | { | 4866 | { |
4868 | setModified( modified ); | 4867 | setModified( modified ); |
4869 | } | 4868 | } |
4870 | 4869 | ||
4871 | Todo *CalendarView::selectedTodo() | 4870 | Todo *CalendarView::selectedTodo() |
4872 | { | 4871 | { |
4873 | Incidence *incidence = currentSelection(); | 4872 | Incidence *incidence = currentSelection(); |
4874 | if ( incidence && incidence->typeID() == todoID ) { | 4873 | if ( incidence && incidence->typeID() == todoID ) { |
4875 | return static_cast<Todo *>( incidence ); | 4874 | return static_cast<Todo *>( incidence ); |
4876 | } | 4875 | } |
4877 | 4876 | ||
4878 | incidence = mTodoList->selectedIncidences().first(); | 4877 | incidence = mTodoList->selectedIncidences().first(); |
4879 | if ( incidence && incidence->typeID() == todoID ) { | 4878 | if ( incidence && incidence->typeID() == todoID ) { |
4880 | return static_cast<Todo *>( incidence ); | 4879 | return static_cast<Todo *>( incidence ); |
4881 | } | 4880 | } |
4882 | 4881 | ||
4883 | return 0; | 4882 | return 0; |
4884 | } | 4883 | } |
4885 | 4884 | ||
4886 | void CalendarView::showIncidence() | 4885 | void CalendarView::showIncidence() |
4887 | { | 4886 | { |
4888 | mViewerCallerIsSearchDialog = false; | 4887 | mViewerCallerIsSearchDialog = false; |
4889 | Incidence *incidence = currentSelection(); | 4888 | Incidence *incidence = currentSelection(); |
4890 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4889 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4891 | if ( incidence ) { | 4890 | if ( incidence ) { |
4892 | ShowIncidenceVisitor v; | 4891 | ShowIncidenceVisitor v; |
4893 | v.act( incidence, this ); | 4892 | v.act( incidence, this ); |
4894 | } | 4893 | } |
4895 | } | 4894 | } |
4896 | void CalendarView::editIncidenceDescription() | 4895 | void CalendarView::editIncidenceDescription() |
4897 | { | 4896 | { |
4898 | mFlagEditDescription = true; | 4897 | mFlagEditDescription = true; |
4899 | editIncidence(); | 4898 | editIncidence(); |
4900 | mFlagEditDescription = false; | 4899 | mFlagEditDescription = false; |
4901 | } | 4900 | } |
4902 | void CalendarView::editIncidence() | 4901 | void CalendarView::editIncidence() |
4903 | { | 4902 | { |
4904 | // qDebug("editIncidence() "); | 4903 | // qDebug("editIncidence() "); |
4905 | Incidence *incidence = currentSelection(); | 4904 | Incidence *incidence = currentSelection(); |
4906 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4905 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4907 | if ( incidence ) { | 4906 | if ( incidence ) { |
4908 | EditIncidenceVisitor v; | 4907 | EditIncidenceVisitor v; |
4909 | v.act( incidence, this ); | 4908 | v.act( incidence, this ); |
4910 | } | 4909 | } |
4911 | } | 4910 | } |
4912 | 4911 | ||
4913 | void CalendarView::deleteIncidence() | 4912 | void CalendarView::deleteIncidence() |
4914 | { | 4913 | { |
4915 | Incidence *incidence = currentSelection(); | 4914 | Incidence *incidence = currentSelection(); |
4916 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4915 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4917 | if ( incidence ) { | 4916 | if ( incidence ) { |
4918 | deleteIncidence(incidence); | 4917 | deleteIncidence(incidence); |
4919 | } | 4918 | } |
4920 | } | 4919 | } |
4921 | void CalendarView::showIncidence(QString uid) | 4920 | void CalendarView::showIncidence(QString uid) |
4922 | { | 4921 | { |
4923 | Incidence *inc = mCalendar->incidence( uid ); | 4922 | Incidence *inc = mCalendar->incidence( uid ); |
4924 | if ( inc ) | 4923 | if ( inc ) |
4925 | showIncidence( inc ); | 4924 | showIncidence( inc ); |
4926 | } | 4925 | } |
4927 | void CalendarView::showIncidence(Incidence *incidence) | 4926 | void CalendarView::showIncidence(Incidence *incidence) |
4928 | { | 4927 | { |
4929 | mViewerCallerIsSearchDialog = false; | 4928 | mViewerCallerIsSearchDialog = false; |
4930 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4929 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4931 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4930 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4932 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4931 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4933 | mViewerCallerIsSearchDialog = true; | 4932 | mViewerCallerIsSearchDialog = true; |
4934 | } | 4933 | } |
4935 | } | 4934 | } |
4936 | if ( incidence ) { | 4935 | if ( incidence ) { |
4937 | ShowIncidenceVisitor v; | 4936 | ShowIncidenceVisitor v; |
4938 | v.act( incidence, this ); | 4937 | v.act( incidence, this ); |
4939 | } | 4938 | } |
4940 | } | 4939 | } |
4941 | 4940 | ||
4942 | void CalendarView::editIncidence(Incidence *incidence) | 4941 | void CalendarView::editIncidence(Incidence *incidence) |
4943 | { | 4942 | { |
4944 | if ( incidence ) { | 4943 | if ( incidence ) { |
4945 | 4944 | ||
4946 | EditIncidenceVisitor v; | 4945 | EditIncidenceVisitor v; |
4947 | v.act( incidence, this ); | 4946 | v.act( incidence, this ); |
4948 | 4947 | ||
4949 | } | 4948 | } |
4950 | } | 4949 | } |
4951 | 4950 | ||
4952 | void CalendarView::deleteIncidence(Incidence *incidence) | 4951 | void CalendarView::deleteIncidence(Incidence *incidence) |
4953 | { | 4952 | { |
4954 | //qDebug(" CalendarView::deleteIncidence "); | 4953 | //qDebug(" CalendarView::deleteIncidence "); |
4955 | if ( incidence == 0 ) { | 4954 | if ( incidence == 0 ) { |
4956 | updateView(); | 4955 | updateView(); |
4957 | emit updateSearchDialog(); | 4956 | emit updateSearchDialog(); |
4958 | return; | 4957 | return; |
4959 | } | 4958 | } |
4960 | if ( incidence ) { | 4959 | if ( incidence ) { |
4961 | DeleteIncidenceVisitor v; | 4960 | DeleteIncidenceVisitor v; |
4962 | v.act( incidence, this ); | 4961 | v.act( incidence, this ); |
4963 | } | 4962 | } |
4964 | } | 4963 | } |
4965 | 4964 | ||
4966 | 4965 | ||
4967 | void CalendarView::lookForOutgoingMessages() | 4966 | void CalendarView::lookForOutgoingMessages() |
4968 | { | 4967 | { |
4969 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4968 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4970 | ogd->loadMessages(); | 4969 | ogd->loadMessages(); |
4971 | } | 4970 | } |
4972 | 4971 | ||
4973 | void CalendarView::lookForIncomingMessages() | 4972 | void CalendarView::lookForIncomingMessages() |
4974 | { | 4973 | { |
4975 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4974 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4976 | icd->retrieve(); | 4975 | icd->retrieve(); |
4977 | } | 4976 | } |
4978 | 4977 | ||
4979 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4978 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4980 | { | 4979 | { |
4981 | bool deleteTodo = true; | 4980 | bool deleteTodo = true; |
4982 | QPtrList<Incidence> subTodos; | 4981 | QPtrList<Incidence> subTodos; |
4983 | Incidence *aTodo; | 4982 | Incidence *aTodo; |
4984 | subTodos = t->relations(); | 4983 | subTodos = t->relations(); |
4985 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4984 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4986 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4985 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4987 | deleteTodo = false; | 4986 | deleteTodo = false; |
4988 | } | 4987 | } |
4989 | if ( deleteTodo ) { | 4988 | if ( deleteTodo ) { |
4990 | if ( t->isCompleted() && !t->doesRecur()) { | 4989 | if ( t->isCompleted() && !t->doesRecur()) { |
4991 | checkExternalId( t ); | 4990 | checkExternalId( t ); |
4992 | mCalendar->deleteTodo( t ); | 4991 | mCalendar->deleteTodo( t ); |
4993 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4992 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4994 | } | 4993 | } |
4995 | else | 4994 | else |
4996 | deleteTodo = false; | 4995 | deleteTodo = false; |
4997 | } | 4996 | } |
4998 | return deleteTodo; | 4997 | return deleteTodo; |
4999 | 4998 | ||
5000 | } | 4999 | } |
5001 | void CalendarView::purgeCompleted() | 5000 | void CalendarView::purgeCompleted() |
5002 | { | 5001 | { |
5003 | int result = KMessageBox::warningContinueCancel(this, | 5002 | int result = KMessageBox::warningContinueCancel(this, |
5004 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 5003 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
5005 | 5004 | ||
5006 | if (result == KMessageBox::Continue) { | 5005 | if (result == KMessageBox::Continue) { |
5007 | 5006 | ||
5008 | QPtrList<Todo> todoCal; | 5007 | QPtrList<Todo> todoCal; |
5009 | QPtrList<Todo> rootTodos; | 5008 | QPtrList<Todo> rootTodos; |
5010 | //QPtrList<Incidence> rel; | 5009 | //QPtrList<Incidence> rel; |
5011 | Todo *aTodo; | 5010 | Todo *aTodo; |
5012 | todoCal = calendar()->todos(); | 5011 | todoCal = calendar()->todos(); |
5013 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 5012 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
5014 | if ( !aTodo->relatedTo() ) | 5013 | if ( !aTodo->relatedTo() ) |
5015 | rootTodos.append( aTodo ); | 5014 | rootTodos.append( aTodo ); |
5016 | } | 5015 | } |
5017 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 5016 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
5018 | removeCompletedSubTodos( aTodo ); | 5017 | removeCompletedSubTodos( aTodo ); |
5019 | } | 5018 | } |
5020 | 5019 | ||
5021 | updateView(); | 5020 | updateView(); |
5022 | } | 5021 | } |
5023 | } | 5022 | } |
5024 | 5023 | ||
5025 | void CalendarView::slotCalendarChanged() | 5024 | void CalendarView::slotCalendarChanged() |
5026 | { | 5025 | { |
5027 | ; | 5026 | ; |
5028 | } | 5027 | } |
5029 | 5028 | ||
5030 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 5029 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
5031 | { | 5030 | { |
5032 | //qDebug("CalendarView::keyPressEvent "); | 5031 | //qDebug("CalendarView::keyPressEvent "); |
5033 | e->ignore(); | 5032 | e->ignore(); |
5034 | } | 5033 | } |
5035 | 5034 | ||
5036 | 5035 | ||
5037 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 5036 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
5038 | { | 5037 | { |
5039 | 5038 | ||
5040 | if ( manager != mSyncManager) | 5039 | if ( manager != mSyncManager) |
5041 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 5040 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
5042 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 5041 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
5043 | qDebug("KO: SyncKDE request detected!"); | 5042 | qDebug("KO: SyncKDE request detected!"); |
5044 | } | 5043 | } |
5045 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5044 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5046 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5045 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5047 | return syncCalendar( filename, mode ); | 5046 | if ( !resource.isEmpty() ) { |
5047 | int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | ||
5048 | qDebug( "KO: Sync request for resource: %s", resource.latin1() ); | ||
5049 | |||
5050 | if ( !exclusiveSyncResource ) { | ||
5051 | qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); | ||
5052 | return false; | ||
5053 | } | ||
5054 | mCalendar->setDefaultCalendar( exclusiveSyncResource ); | ||
5055 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
5056 | } | ||
5057 | bool result = syncCalendar( filename, mode ); | ||
5058 | if ( !resource.isEmpty() ) | ||
5059 | restoreCalendarSettings(); | ||
5060 | return result; | ||
5048 | } | 5061 | } |
5049 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 5062 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
5050 | { | 5063 | { |
5051 | //mSyncManager = manager; | 5064 | //mSyncManager = manager; |
5052 | if ( manager != mSyncManager) | 5065 | if ( manager != mSyncManager) |
5053 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 5066 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
5054 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5067 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5055 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5068 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5056 | if ( resource == "sharp" ) | 5069 | if ( resource == "sharp" ) |
5057 | syncExternal( 0 ); | 5070 | syncExternal( 0 ); |
5058 | if ( resource == "phone" ) | 5071 | if ( resource == "phone" ) |
5059 | syncExternal( 1 ); | 5072 | syncExternal( 1 ); |
5060 | // pending setmodified | 5073 | // pending setmodified |
5061 | return true; | 5074 | return true; |
5062 | } | 5075 | } |
5063 | void CalendarView::setSyncManager(KSyncManager* manager) | 5076 | void CalendarView::setSyncManager(KSyncManager* manager) |
5064 | { | 5077 | { |
5065 | mSyncManager = manager; | 5078 | mSyncManager = manager; |
5066 | } | 5079 | } |
5067 | 5080 | ||
5068 | void CalendarView::removeSyncInfo( QString syncProfile) | 5081 | void CalendarView::removeSyncInfo( QString syncProfile) |
5069 | { | 5082 | { |
5070 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 5083 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
5071 | mCalendar->removeSyncInfo( syncProfile ); | 5084 | mCalendar->removeSyncInfo( syncProfile ); |
5072 | 5085 | ||
5073 | } | 5086 | } |
5074 | 5087 | ||
5075 | void CalendarView::undo_delete() | 5088 | void CalendarView::undo_delete() |
5076 | { | 5089 | { |
5077 | //qDebug("undo_delete() "); | 5090 | //qDebug("undo_delete() "); |
5078 | Incidence* undo = mCalendar->undoIncidence(); | 5091 | Incidence* undo = mCalendar->undoIncidence(); |
5079 | if ( !undo ) { | 5092 | if ( !undo ) { |
5080 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 5093 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
5081 | i18n("KO/Pi")); | 5094 | i18n("KO/Pi")); |
5082 | return; | 5095 | return; |
5083 | } | 5096 | } |
5084 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 5097 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
5085 | i18n("\nAre you sure you want\nto restore this?"), | 5098 | i18n("\nAre you sure you want\nto restore this?"), |
5086 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 5099 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
5087 | mCalendar->undoDeleteIncidence(); | 5100 | mCalendar->undoDeleteIncidence(); |
5088 | updateView(); | 5101 | updateView(); |
5089 | } | 5102 | } |
5090 | } | 5103 | } |
5091 | 5104 | ||
5092 | void CalendarView::slotViewerClosed() | 5105 | void CalendarView::slotViewerClosed() |
5093 | { | 5106 | { |
5094 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 5107 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
5095 | } | 5108 | } |
5096 | 5109 | ||
5097 | void CalendarView::resetFocus() | 5110 | void CalendarView::resetFocus() |
5098 | { | 5111 | { |
5099 | if ( mViewerCallerIsSearchDialog ) { | 5112 | if ( mViewerCallerIsSearchDialog ) { |
5100 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 5113 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
5101 | mDialogManager->getSearchDialog()->raise(); | 5114 | mDialogManager->getSearchDialog()->raise(); |
5102 | mDialogManager->getSearchDialog()->setActiveWindow(); | 5115 | mDialogManager->getSearchDialog()->setActiveWindow(); |
5103 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 5116 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
5104 | } else | 5117 | } else |
5105 | mViewerCallerIsSearchDialog = false; | 5118 | mViewerCallerIsSearchDialog = false; |
5106 | } | 5119 | } |
5107 | if ( !mViewerCallerIsSearchDialog ) { | 5120 | if ( !mViewerCallerIsSearchDialog ) { |
5108 | //mViewManager->currentView()->setFocus(); | 5121 | //mViewManager->currentView()->setFocus(); |
5109 | //qDebug("sssssssssssssssset focus "); | 5122 | //qDebug("sssssssssssssssset focus "); |
5110 | topLevelWidget()->raise(); | 5123 | topLevelWidget()->raise(); |
5111 | setActiveWindow(); | 5124 | setActiveWindow(); |
5112 | //setFocus(); | 5125 | //setFocus(); |
5113 | } | 5126 | } |
5114 | mViewerCallerIsSearchDialog = false; | 5127 | mViewerCallerIsSearchDialog = false; |
5115 | } | 5128 | } |
5116 | 5129 | ||
5117 | void CalendarView::showNextAlarms() | 5130 | void CalendarView::showNextAlarms() |
5118 | { | 5131 | { |
5119 | QString message; | 5132 | QString message; |
5120 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 5133 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
5121 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 5134 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
5122 | QString sum = mCalendar->nextSummary(); | 5135 | QString sum = mCalendar->nextSummary(); |
5123 | QDateTime nextA = mNextAlarmDateTime; | 5136 | QDateTime nextA = mNextAlarmDateTime; |
5124 | QDateTime cur = QDateTime::currentDateTime(); | 5137 | QDateTime cur = QDateTime::currentDateTime(); |
5125 | int secs = cur.secsTo( nextA ); | 5138 | int secs = cur.secsTo( nextA ); |
5126 | int min = secs /60; | 5139 | int min = secs /60; |
5127 | int hours = min /60; | 5140 | int hours = min /60; |
5128 | min = min % 60; | 5141 | min = min % 60; |
5129 | int days = hours /24; | 5142 | int days = hours /24; |
5130 | hours = hours % 24; | 5143 | hours = hours % 24; |
5131 | 5144 | ||
5132 | //message = i18n("The next alarm is in:\n"); | 5145 | //message = i18n("The next alarm is in:\n"); |
5133 | if ( days > 1 ) | 5146 | if ( days > 1 ) |
5134 | message += i18n("%1 days\n").arg( days ); | 5147 | message += i18n("%1 days\n").arg( days ); |
5135 | else if ( days == 1 ) | 5148 | else if ( days == 1 ) |
5136 | message += i18n("1 day\n"); | 5149 | message += i18n("1 day\n"); |
5137 | if ( hours > 1 ) | 5150 | if ( hours > 1 ) |
5138 | message += i18n("%1 hours\n").arg( hours ); | 5151 | message += i18n("%1 hours\n").arg( hours ); |
5139 | else if ( hours == 1 ) | 5152 | else if ( hours == 1 ) |
5140 | message += i18n("1 hour\n"); | 5153 | message += i18n("1 hour\n"); |
5141 | if ( min > 1 ) | 5154 | if ( min > 1 ) |
5142 | message += i18n("%1 minutes\n").arg( min ); | 5155 | message += i18n("%1 minutes\n").arg( min ); |
5143 | else if ( min == 1 ) | 5156 | else if ( min == 1 ) |
5144 | message += i18n("1 minute\n"); | 5157 | message += i18n("1 minute\n"); |
5145 | if ( message.isEmpty() ) | 5158 | if ( message.isEmpty() ) |
5146 | message = i18n("The next alarm is in\nless than one minute!"); | 5159 | message = i18n("The next alarm is in\nless than one minute!"); |
5147 | else | 5160 | else |
5148 | message = i18n("The next alarm is in:\n") + message; | 5161 | message = i18n("The next alarm is in:\n") + message; |
5149 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 5162 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
5150 | } else { | 5163 | } else { |
5151 | message = i18n("There is no next alarm."); | 5164 | message = i18n("There is no next alarm."); |
5152 | 5165 | ||
5153 | } | 5166 | } |
5154 | #ifdef DESKTOP_VERSION | 5167 | #ifdef DESKTOP_VERSION |
5155 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 5168 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
5156 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 5169 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
5157 | message += i18n("Enable it in the settings menu, TAB alarm."); | 5170 | message += i18n("Enable it in the settings menu, TAB alarm."); |
5158 | } | 5171 | } |
5159 | 5172 | ||
5160 | #endif | 5173 | #endif |
5161 | KMessageBox::information( this, message); | 5174 | KMessageBox::information( this, message); |
5162 | } | 5175 | } |
5163 | 5176 | ||
5164 | void CalendarView::displayCalendarInfo( int id ) | 5177 | void CalendarView::displayCalendarInfo( int id ) |
5165 | { | 5178 | { |
5166 | int e, t,j; | 5179 | int e, t,j; |
5167 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 5180 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
5168 | QString name = kkf->mName; | 5181 | QString name = kkf->mName; |
5169 | mCalendar->getIncidenceCount( id, e, t, j ); | 5182 | mCalendar->getIncidenceCount( id, e, t, j ); |
5170 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); | 5183 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); |
5171 | QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); | 5184 | QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); |
5172 | mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); | 5185 | mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); |
5173 | KMessageBox::information( this, mess ); | 5186 | KMessageBox::information( this, mess ); |
5174 | 5187 | ||
5175 | 5188 | ||
5176 | } | 5189 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 80f7ed4..f85b6a3 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,675 +1,675 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #include <qscrollbar.h> | 33 | #include <qscrollbar.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qtopia/ir.h> | 35 | #include <qtopia/ir.h> |
36 | #else | 36 | #else |
37 | #define Ir char | 37 | #define Ir char |
38 | #endif | 38 | #endif |
39 | #include <libkcal/calendar.h> | 39 | #include <libkcal/calendar.h> |
40 | #include <libkcal/scheduler.h> | 40 | #include <libkcal/scheduler.h> |
41 | #include <libkcal/calendarresources.h> | 41 | #include <libkcal/calendarresources.h> |
42 | #include <libkcal/resourcecalendar.h> | 42 | #include <libkcal/resourcecalendar.h> |
43 | #include <KDGanttMinimizeSplitter.h> | 43 | #include <KDGanttMinimizeSplitter.h> |
44 | 44 | ||
45 | #include <korganizer/calendarviewbase.h> | 45 | #include <korganizer/calendarviewbase.h> |
46 | 46 | ||
47 | #include <ksyncmanager.h> | 47 | #include <ksyncmanager.h> |
48 | //#include <koprefs.h> | 48 | //#include <koprefs.h> |
49 | 49 | ||
50 | class QWidgetStack; | 50 | class QWidgetStack; |
51 | class QSplitter; | 51 | class QSplitter; |
52 | class KopiCalendarFile; | 52 | class KopiCalendarFile; |
53 | class CalPrinter; | 53 | class CalPrinter; |
54 | class KOFilterView; | 54 | class KOFilterView; |
55 | class KOCalEditView; | 55 | class KOCalEditView; |
56 | class KOViewManager; | 56 | class KOViewManager; |
57 | class KODialogManager; | 57 | class KODialogManager; |
58 | class KOTodoView; | 58 | class KOTodoView; |
59 | class KDateNavigator; | 59 | class KDateNavigator; |
60 | class DateNavigatorContainer; | 60 | class DateNavigatorContainer; |
61 | class DateNavigator; | 61 | class DateNavigator; |
62 | class KOIncidenceEditor; | 62 | class KOIncidenceEditor; |
63 | class KDatePicker; | 63 | class KDatePicker; |
64 | class ResourceView; | 64 | class ResourceView; |
65 | class KOEventEditor; | 65 | class KOEventEditor; |
66 | class KOTodoEditor ; | 66 | class KOTodoEditor ; |
67 | class KOEventViewerDialog; | 67 | class KOEventViewerDialog; |
68 | class KOBeamPrefs; | 68 | class KOBeamPrefs; |
69 | class KSyncProfile; | 69 | class KSyncProfile; |
70 | class AlarmDialog; | 70 | class AlarmDialog; |
71 | class KCal::Attendee; | 71 | class KCal::Attendee; |
72 | 72 | ||
73 | namespace KCal { class FileStorage; } | 73 | namespace KCal { class FileStorage; } |
74 | 74 | ||
75 | using namespace KCal; | 75 | using namespace KCal; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | This is the main calendar widget. It provides the different vies on t he | 78 | This is the main calendar widget. It provides the different vies on t he |
79 | calendar data as well as the date navigator. It also handles synchronisation | 79 | calendar data as well as the date navigator. It also handles synchronisation |
80 | of the different views and controls the different dialogs like preferences, | 80 | of the different views and controls the different dialogs like preferences, |
81 | event editor, search dialog etc. | 81 | event editor, search dialog etc. |
82 | 82 | ||
83 | @short main calendar view widget | 83 | @short main calendar view widget |
84 | @author Cornelius Schumacher | 84 | @author Cornelius Schumacher |
85 | */ | 85 | */ |
86 | 86 | ||
87 | #include <qtextbrowser.h> | 87 | #include <qtextbrowser.h> |
88 | #include <qtextcodec.h> | 88 | #include <qtextcodec.h> |
89 | 89 | ||
90 | class MissedAlarmTextBrowser : public QTextBrowser { | 90 | class MissedAlarmTextBrowser : public QTextBrowser { |
91 | Q_OBJECT | 91 | Q_OBJECT |
92 | public: | 92 | public: |
93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); | 93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); |
94 | ~MissedAlarmTextBrowser(); | 94 | ~MissedAlarmTextBrowser(); |
95 | void setSource(const QString & n); | 95 | void setSource(const QString & n); |
96 | 96 | ||
97 | private: | 97 | private: |
98 | Incidence * getNextInc(QDateTime start ); | 98 | Incidence * getNextInc(QDateTime start ); |
99 | QPtrList<Incidence> mAlarms; | 99 | QPtrList<Incidence> mAlarms; |
100 | signals: | 100 | signals: |
101 | void showIncidence( QString uid); | 101 | void showIncidence( QString uid); |
102 | }; | 102 | }; |
103 | 103 | ||
104 | 104 | ||
105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
106 | { | 106 | { |
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | public: | 108 | public: |
109 | /** | 109 | /** |
110 | Constructs a new calendar view widget. | 110 | Constructs a new calendar view widget. |
111 | 111 | ||
112 | @param calendar calendar document | 112 | @param calendar calendar document |
113 | @param parent parent window | 113 | @param parent parent window |
114 | @param name Qt internal widget object name | 114 | @param name Qt internal widget object name |
115 | */ | 115 | */ |
116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
117 | const char *name = 0 ); | 117 | const char *name = 0 ); |
118 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 118 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
119 | const char *name = 0 ); | 119 | const char *name = 0 ); |
120 | virtual ~CalendarView(); | 120 | virtual ~CalendarView(); |
121 | 121 | ||
122 | Calendar *calendar() { return mCalendar; } | 122 | Calendar *calendar() { return mCalendar; } |
123 | 123 | ||
124 | KOViewManager *viewManager(); | 124 | KOViewManager *viewManager(); |
125 | KODialogManager *dialogManager(); | 125 | KODialogManager *dialogManager(); |
126 | 126 | ||
127 | QDate startDate(); | 127 | QDate startDate(); |
128 | QDate endDate(); | 128 | QDate endDate(); |
129 | 129 | ||
130 | QWidgetStack *viewStack(); | 130 | QWidgetStack *viewStack(); |
131 | QWidget *leftFrame(); | 131 | QWidget *leftFrame(); |
132 | 132 | ||
133 | DateNavigator *dateNavigator(); | 133 | DateNavigator *dateNavigator(); |
134 | KDateNavigator *dateNavigatorWidget(); | 134 | KDateNavigator *dateNavigatorWidget(); |
135 | 135 | ||
136 | void addView(KOrg::BaseView *); | 136 | void addView(KOrg::BaseView *); |
137 | void showView(KOrg::BaseView *); | 137 | void showView(KOrg::BaseView *); |
138 | KOEventViewerDialog* getEventViewerDialog(); | 138 | KOEventViewerDialog* getEventViewerDialog(); |
139 | Incidence *currentSelection(); | 139 | Incidence *currentSelection(); |
140 | void checkSuspendAlarm(); | 140 | void checkSuspendAlarm(); |
141 | void mergeFile( QString fn ); | 141 | void mergeFile( QString fn ); |
142 | 142 | ||
143 | signals: | 143 | signals: |
144 | void save (); | 144 | void save (); |
145 | void saveStopTimer (); | 145 | void saveStopTimer (); |
146 | void tempDisableBR(bool); | 146 | void tempDisableBR(bool); |
147 | /** This todo has been modified */ | 147 | /** This todo has been modified */ |
148 | void todoModified(Todo *, int); | 148 | void todoModified(Todo *, int); |
149 | 149 | ||
150 | /** when change is made to options dialog, the topwidget will catch this | 150 | /** when change is made to options dialog, the topwidget will catch this |
151 | * and emit this signal which notifies all widgets which have registered | 151 | * and emit this signal which notifies all widgets which have registered |
152 | * for notification to update their settings. */ | 152 | * for notification to update their settings. */ |
153 | void configChanged(); | 153 | void configChanged(); |
154 | /** emitted when the topwidget is closing down, so that any attached | 154 | /** emitted when the topwidget is closing down, so that any attached |
155 | child windows can also close. */ | 155 | child windows can also close. */ |
156 | void closingDown(); | 156 | void closingDown(); |
157 | /** emitted right before we die */ | 157 | /** emitted right before we die */ |
158 | void closed(QWidget *); | 158 | void closed(QWidget *); |
159 | 159 | ||
160 | /** Emitted when state of modified flag changes */ | 160 | /** Emitted when state of modified flag changes */ |
161 | void modifiedChanged(bool); | 161 | void modifiedChanged(bool); |
162 | void signalmodified(); | 162 | void signalmodified(); |
163 | 163 | ||
164 | /** Emitted when state of read-only flag changes */ | 164 | /** Emitted when state of read-only flag changes */ |
165 | void readOnlyChanged(bool); | 165 | void readOnlyChanged(bool); |
166 | 166 | ||
167 | /** Emitted when the unit of navigation changes */ | 167 | /** Emitted when the unit of navigation changes */ |
168 | void changeNavStringPrev(const QString &); | 168 | void changeNavStringPrev(const QString &); |
169 | void changeNavStringNext(const QString &); | 169 | void changeNavStringNext(const QString &); |
170 | 170 | ||
171 | /** Emitted when state of events selection has changed and user is organizer*/ | 171 | /** Emitted when state of events selection has changed and user is organizer*/ |
172 | void organizerEventsSelected(bool); | 172 | void organizerEventsSelected(bool); |
173 | /** Emitted when state of events selection has changed and user is attendee*/ | 173 | /** Emitted when state of events selection has changed and user is attendee*/ |
174 | void groupEventsSelected(bool); | 174 | void groupEventsSelected(bool); |
175 | /** | 175 | /** |
176 | Emitted when an incidence gets selected. If the selection is cleared the | 176 | Emitted when an incidence gets selected. If the selection is cleared the |
177 | signal is emitted with 0 as argument. | 177 | signal is emitted with 0 as argument. |
178 | */ | 178 | */ |
179 | void incidenceSelected( Incidence * ); | 179 | void incidenceSelected( Incidence * ); |
180 | /** Emitted, when a todoitem is selected or deselected. */ | 180 | /** Emitted, when a todoitem is selected or deselected. */ |
181 | void todoSelected( bool ); | 181 | void todoSelected( bool ); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | Emitted, when clipboard content changes. Parameter indicates if paste | 184 | Emitted, when clipboard content changes. Parameter indicates if paste |
185 | is possible or not. | 185 | is possible or not. |
186 | */ | 186 | */ |
187 | void pasteEnabled(bool); | 187 | void pasteEnabled(bool); |
188 | 188 | ||
189 | /** Emitted, when the number of incoming messages has changed. */ | 189 | /** Emitted, when the number of incoming messages has changed. */ |
190 | void numIncomingChanged(int); | 190 | void numIncomingChanged(int); |
191 | 191 | ||
192 | /** Emitted, when the number of outgoing messages has changed. */ | 192 | /** Emitted, when the number of outgoing messages has changed. */ |
193 | void numOutgoingChanged(int); | 193 | void numOutgoingChanged(int); |
194 | 194 | ||
195 | /** Send status message, which can e.g. be displayed in the status bar. */ | 195 | /** Send status message, which can e.g. be displayed in the status bar. */ |
196 | void statusMessage(const QString &); | 196 | void statusMessage(const QString &); |
197 | 197 | ||
198 | void calendarViewExpanded( bool ); | 198 | void calendarViewExpanded( bool ); |
199 | void updateSearchDialog(); | 199 | void updateSearchDialog(); |
200 | void filtersUpdated(); | 200 | void filtersUpdated(); |
201 | 201 | ||
202 | 202 | ||
203 | public slots: | 203 | public slots: |
204 | void displayCalendarInfo( int id ); | 204 | void displayCalendarInfo( int id ); |
205 | void nextConflict( bool all, bool allday ); | 205 | void nextConflict( bool all, bool allday ); |
206 | void conflictAll(); | 206 | void conflictAll(); |
207 | void conflictAllday(); | 207 | void conflictAllday(); |
208 | void conflictNotAll(); | 208 | void conflictNotAll(); |
209 | void setCalReadOnly( int id, bool readO ); | 209 | void setCalReadOnly( int id, bool readO ); |
210 | void checkAlarms(); | 210 | void checkAlarms(); |
211 | void checkFiles(); | 211 | void checkFiles(); |
212 | void slotprintSelInc(); | 212 | void slotprintSelInc(); |
213 | void showNextAlarms(); | 213 | void showNextAlarms(); |
214 | void showOpenError(); | 214 | void showOpenError(); |
215 | void watchSavedFile(); | 215 | void watchSavedFile(); |
216 | void recheckTimerAlarm(); | 216 | void recheckTimerAlarm(); |
217 | void checkNextTimerAlarm(); | 217 | void checkNextTimerAlarm(); |
218 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 218 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
219 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 219 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
220 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 220 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
221 | 221 | ||
222 | /** options dialog made a changed to the configuration. we catch this | 222 | /** options dialog made a changed to the configuration. we catch this |
223 | * and notify all widgets which need to update their configuration. */ | 223 | * and notify all widgets which need to update their configuration. */ |
224 | void updateConfig(); | 224 | void updateConfig(); |
225 | 225 | ||
226 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 226 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
227 | const QStringList& anniversaryList, const QStringList& realNameList, | 227 | const QStringList& anniversaryList, const QStringList& realNameList, |
228 | const QStringList& emailList, const QStringList& assembledNameList, | 228 | const QStringList& emailList, const QStringList& assembledNameList, |
229 | const QStringList& uidList); | 229 | const QStringList& uidList); |
230 | 230 | ||
231 | /** | 231 | /** |
232 | Load calendar from file \a filename. If \a merge is true, load | 232 | Load calendar from file \a filename. If \a merge is true, load |
233 | calendar into existing one, if it is false, clear calendar, before | 233 | calendar into existing one, if it is false, clear calendar, before |
234 | loading. Return true, if calendar could be successfully loaded. | 234 | loading. Return true, if calendar could be successfully loaded. |
235 | */ | 235 | */ |
236 | bool openCalendar(QString filename, bool merge=false); | 236 | bool openCalendar(QString filename, bool merge=false); |
237 | bool loadCalendars(); | 237 | bool loadCalendars(); |
238 | bool saveCalendars(); | 238 | bool saveCalendars(); |
239 | bool restoreCalendarSettings(); | 239 | bool restoreCalendarSettings(); |
240 | bool addCalendar( KopiCalendarFile * ); | 240 | bool addCalendar( KopiCalendarFile * ); |
241 | void addCalendarId( int id ); | 241 | void addCalendarId( int id ); |
242 | bool syncCalendar(QString filename,int mode = 0 ); | 242 | bool syncCalendar(QString filename,int mode = 0 ); |
243 | 243 | ||
244 | /** | 244 | /** |
245 | Save calendar data to file. Return true if calendar could be | 245 | Save calendar data to file. Return true if calendar could be |
246 | successfully saved. | 246 | successfully saved. |
247 | */ | 247 | */ |
248 | bool saveCalendar(QString filename); | 248 | bool saveCalendar(QString filename); |
249 | 249 | ||
250 | /** | 250 | /** |
251 | Close calendar. Clear calendar data and reset views to display an empty | 251 | Close calendar. Clear calendar data and reset views to display an empty |
252 | calendar. | 252 | calendar. |
253 | */ | 253 | */ |
254 | void closeCalendar(); | 254 | void closeCalendar(); |
255 | 255 | ||
256 | /** Archive old events of calendar */ | 256 | /** Archive old events of calendar */ |
257 | void archiveCalendar(); | 257 | void archiveCalendar(); |
258 | 258 | ||
259 | void showIncidence(); | 259 | void showIncidence(); |
260 | void editIncidence(); | 260 | void editIncidence(); |
261 | void editIncidenceDescription(); | 261 | void editIncidenceDescription(); |
262 | void deleteIncidence(); | 262 | void deleteIncidence(); |
263 | void cloneIncidence(); | 263 | void cloneIncidence(); |
264 | void moveIncidence(); | 264 | void moveIncidence(); |
265 | void beamIncidence(); | 265 | void beamIncidence(); |
266 | void toggleCancelIncidence(); | 266 | void toggleCancelIncidence(); |
267 | 267 | ||
268 | /** create an editeventwin with supplied date/time, and if bool is true, | 268 | /** create an editeventwin with supplied date/time, and if bool is true, |
269 | * make the event take all day. */ | 269 | * make the event take all day. */ |
270 | void newEvent(QDateTime, QDateTime, bool allDay ); | 270 | void newEvent(QDateTime, QDateTime, bool allDay ); |
271 | void newEvent(QDateTime, QDateTime); | 271 | void newEvent(QDateTime, QDateTime); |
272 | void newEvent(QDateTime fh); | 272 | void newEvent(QDateTime fh); |
273 | void newEvent(QDate dt); | 273 | void newEvent(QDate dt); |
274 | /** create new event without having a date hint. Takes current date as | 274 | /** create new event without having a date hint. Takes current date as |
275 | default hint. */ | 275 | default hint. */ |
276 | void newEvent(); | 276 | void newEvent(); |
277 | void newFloatingEvent(); | 277 | void newFloatingEvent(); |
278 | 278 | ||
279 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 279 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
280 | void showIncidence(Incidence *); | 280 | void showIncidence(Incidence *); |
281 | void showIncidence(QString uid); | 281 | void showIncidence(QString uid); |
282 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 282 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
283 | void editIncidence(Incidence *); | 283 | void editIncidence(Incidence *); |
284 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 284 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
285 | void deleteIncidence(Incidence *); | 285 | void deleteIncidence(Incidence *); |
286 | void cloneIncidence(Incidence *); | 286 | void cloneIncidence(Incidence *); |
287 | void cancelIncidence(Incidence *); | 287 | void cancelIncidence(Incidence *); |
288 | /** Create an editor for the supplied event. */ | 288 | /** Create an editor for the supplied event. */ |
289 | void editEvent(Event *); | 289 | void editEvent(Event *); |
290 | /** Delete the supplied event. */ | 290 | /** Delete the supplied event. */ |
291 | void deleteEvent(Event *); | 291 | void deleteEvent(Event *); |
292 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 292 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
293 | found. */ | 293 | found. */ |
294 | bool deleteEvent(const QString &uid); | 294 | bool deleteEvent(const QString &uid); |
295 | /** Create a read-only viewer dialog for the supplied event. */ | 295 | /** Create a read-only viewer dialog for the supplied event. */ |
296 | void showEvent(Event *); | 296 | void showEvent(Event *); |
297 | 297 | ||
298 | void editJournal(Journal *); | 298 | void editJournal(Journal *); |
299 | void showJournal(Journal *); | 299 | void showJournal(Journal *); |
300 | void deleteJournal(Journal *); | 300 | void deleteJournal(Journal *); |
301 | /** Create an editor dialog for a todo */ | 301 | /** Create an editor dialog for a todo */ |
302 | void editTodo(Todo *); | 302 | void editTodo(Todo *); |
303 | /** Create a read-only viewer dialog for the supplied todo */ | 303 | /** Create a read-only viewer dialog for the supplied todo */ |
304 | void showTodo(Todo *); | 304 | void showTodo(Todo *); |
305 | /** create new todo */ | 305 | /** create new todo */ |
306 | void newTodo(); | 306 | void newTodo(); |
307 | void newTodoDateTime(QDateTime, bool allday); | 307 | void newTodoDateTime(QDateTime, bool allday); |
308 | /** create new todo with a parent todo */ | 308 | /** create new todo with a parent todo */ |
309 | void newSubTodo(); | 309 | void newSubTodo(); |
310 | /** create new todo with a parent todo */ | 310 | /** create new todo with a parent todo */ |
311 | void newSubTodo(Todo *); | 311 | void newSubTodo(Todo *); |
312 | /** Delete todo */ | 312 | /** Delete todo */ |
313 | void deleteTodo(Todo *); | 313 | void deleteTodo(Todo *); |
314 | 314 | ||
315 | 315 | ||
316 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 316 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
317 | * emitted as result. */ | 317 | * emitted as result. */ |
318 | void checkClipboard(); | 318 | void checkClipboard(); |
319 | 319 | ||
320 | /** using the KConfig associated with the kapp variable, read in the | 320 | /** using the KConfig associated with the kapp variable, read in the |
321 | * settings from the config file. | 321 | * settings from the config file. |
322 | */ | 322 | */ |
323 | void readSettings(); | 323 | void readSettings(); |
324 | 324 | ||
325 | /** write current state to config file. */ | 325 | /** write current state to config file. */ |
326 | void writeSettings(); | 326 | void writeSettings(); |
327 | 327 | ||
328 | /** read settings for calendar filters */ | 328 | /** read settings for calendar filters */ |
329 | void readFilterSettings(KConfig *config); | 329 | void readFilterSettings(KConfig *config); |
330 | 330 | ||
331 | /** write settings for calendar filters */ | 331 | /** write settings for calendar filters */ |
332 | void writeFilterSettings(KConfig *config); | 332 | void writeFilterSettings(KConfig *config); |
333 | 333 | ||
334 | /** passes on the message that an event has changed to the currently | 334 | /** passes on the message that an event has changed to the currently |
335 | * activated view so that it can make appropriate display changes. */ | 335 | * activated view so that it can make appropriate display changes. */ |
336 | void changeEventDisplay(Event *, int); | 336 | void changeEventDisplay(Event *, int); |
337 | void changeIncidenceDisplay(Incidence *, int); | 337 | void changeIncidenceDisplay(Incidence *, int); |
338 | void changeTodoDisplay(Todo *, int); | 338 | void changeTodoDisplay(Todo *, int); |
339 | 339 | ||
340 | void eventAdded(Event *); | 340 | void eventAdded(Event *); |
341 | void eventChanged(Event *); | 341 | void eventChanged(Event *); |
342 | void eventToBeDeleted(Event *); | 342 | void eventToBeDeleted(Event *); |
343 | void eventDeleted(); | 343 | void eventDeleted(); |
344 | 344 | ||
345 | void todoAdded(Todo *); | 345 | void todoAdded(Todo *); |
346 | void todoChanged(Todo *); | 346 | void todoChanged(Todo *); |
347 | void todoToBeDeleted(Todo *); | 347 | void todoToBeDeleted(Todo *); |
348 | void todoDeleted(); | 348 | void todoDeleted(); |
349 | 349 | ||
350 | void updateView(const QDate &start, const QDate &end); | 350 | void updateView(const QDate &start, const QDate &end); |
351 | void updateView(); | 351 | void updateView(); |
352 | void clearAllViews(); | 352 | void clearAllViews(); |
353 | 353 | ||
354 | /** Full update of visible todo views */ | 354 | /** Full update of visible todo views */ |
355 | void updateTodoViews(); | 355 | void updateTodoViews(); |
356 | 356 | ||
357 | void updateUnmanagedViews(); | 357 | void updateUnmanagedViews(); |
358 | 358 | ||
359 | /** cut the current appointment to the clipboard */ | 359 | /** cut the current appointment to the clipboard */ |
360 | void edit_cut(); | 360 | void edit_cut(); |
361 | 361 | ||
362 | /** copy the current appointment(s) to the clipboard */ | 362 | /** copy the current appointment(s) to the clipboard */ |
363 | void edit_copy(); | 363 | void edit_copy(); |
364 | 364 | ||
365 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 365 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
366 | void edit_paste(); | 366 | void edit_paste(); |
367 | 367 | ||
368 | /** edit viewing and configuration options. */ | 368 | /** edit viewing and configuration options. */ |
369 | void edit_options(); | 369 | void edit_options(); |
370 | void edit_global_options(); | 370 | void edit_global_options(); |
371 | /** | 371 | /** |
372 | Functions for printing, previewing a print, and setting up printing | 372 | Functions for printing, previewing a print, and setting up printing |
373 | parameters. | 373 | parameters. |
374 | */ | 374 | */ |
375 | void print(); | 375 | void print(); |
376 | void printSetup(); | 376 | void printSetup(); |
377 | void printPreview(); | 377 | void printPreview(); |
378 | 378 | ||
379 | /** Export as iCalendar file */ | 379 | /** Export as iCalendar file */ |
380 | bool exportICalendar(); | 380 | bool exportICalendar(); |
381 | bool exportICalendar( QString fn ); | 381 | bool exportICalendar( QString fn ); |
382 | 382 | ||
383 | /** Export as vCalendar file */ | 383 | /** Export as vCalendar file */ |
384 | bool exportVCalendar( QString fn); | 384 | bool exportVCalendar( QString fn); |
385 | 385 | ||
386 | /** pop up a dialog to show an existing appointment. */ | 386 | /** pop up a dialog to show an existing appointment. */ |
387 | void appointment_show(); | 387 | void appointment_show(); |
388 | /** | 388 | /** |
389 | * pop up an Appointment Dialog to edit an existing appointment.Get | 389 | * pop up an Appointment Dialog to edit an existing appointment.Get |
390 | * information on the appointment from the list of unique IDs that is | 390 | * information on the appointment from the list of unique IDs that is |
391 | * currently in the View, called currIds. | 391 | * currently in the View, called currIds. |
392 | */ | 392 | */ |
393 | void appointment_edit(); | 393 | void appointment_edit(); |
394 | /** | 394 | /** |
395 | * pop up dialog confirming deletion of currently selected event in the | 395 | * pop up dialog confirming deletion of currently selected event in the |
396 | * View. | 396 | * View. |
397 | */ | 397 | */ |
398 | void appointment_delete(); | 398 | void appointment_delete(); |
399 | 399 | ||
400 | /** mails the currently selected event to a particular user as a vCalendar | 400 | /** mails the currently selected event to a particular user as a vCalendar |
401 | attachment. */ | 401 | attachment. */ |
402 | void action_mail(); | 402 | void action_mail(); |
403 | 403 | ||
404 | /* frees a subtodo from it's relation */ | 404 | /* frees a subtodo from it's relation */ |
405 | void todo_unsub( Todo * ); | 405 | void todo_unsub( Todo * ); |
406 | void todo_resub( Todo * parent, Todo * sub ); | 406 | void todo_resub( Todo * parent, Todo * sub ); |
407 | 407 | ||
408 | /** Take ownership of selected event. */ | 408 | /** Take ownership of selected event. */ |
409 | void takeOverEvent(); | 409 | void takeOverEvent(); |
410 | 410 | ||
411 | /** Take ownership of all events in calendar. */ | 411 | /** Take ownership of all events in calendar. */ |
412 | void takeOverCalendar(); | 412 | void takeOverCalendar(); |
413 | 413 | ||
414 | /** query whether or not the calendar is "dirty". */ | 414 | /** query whether or not the calendar is "dirty". */ |
415 | bool isModified(); | 415 | bool isModified(); |
416 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 416 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
417 | void setModified(bool modified=true); | 417 | void setModified(bool modified=true); |
418 | 418 | ||
419 | /** query if the calendar is read-only. */ | 419 | /** query if the calendar is read-only. */ |
420 | bool isReadOnly(); | 420 | bool isReadOnly(); |
421 | /** set state of calendar to read-only */ | 421 | /** set state of calendar to read-only */ |
422 | void setReadOnly(bool readOnly=true); | 422 | void setReadOnly(bool readOnly=true); |
423 | 423 | ||
424 | void eventUpdated(Incidence *); | 424 | void eventUpdated(Incidence *); |
425 | 425 | ||
426 | /* iTIP scheduling actions */ | 426 | /* iTIP scheduling actions */ |
427 | void schedule_publish(Incidence *incidence = 0); | 427 | void schedule_publish(Incidence *incidence = 0); |
428 | void schedule_request(Incidence *incidence = 0); | 428 | void schedule_request(Incidence *incidence = 0); |
429 | void schedule_refresh(Incidence *incidence = 0); | 429 | void schedule_refresh(Incidence *incidence = 0); |
430 | void schedule_cancel(Incidence *incidence = 0); | 430 | void schedule_cancel(Incidence *incidence = 0); |
431 | void schedule_add(Incidence *incidence = 0); | 431 | void schedule_add(Incidence *incidence = 0); |
432 | void schedule_reply(Incidence *incidence = 0); | 432 | void schedule_reply(Incidence *incidence = 0); |
433 | void schedule_counter(Incidence *incidence = 0); | 433 | void schedule_counter(Incidence *incidence = 0); |
434 | void schedule_declinecounter(Incidence *incidence = 0); | 434 | void schedule_declinecounter(Incidence *incidence = 0); |
435 | void schedule_publish_freebusy(int daysToPublish = 30); | 435 | void schedule_publish_freebusy(int daysToPublish = 30); |
436 | 436 | ||
437 | void openAddressbook(); | 437 | void openAddressbook(); |
438 | 438 | ||
439 | void editFilters(); | 439 | void editFilters(); |
440 | void toggleFilerEnabled(); | 440 | void toggleFilerEnabled(); |
441 | QPtrList<CalFilter> filters(); | 441 | QPtrList<CalFilter> filters(); |
442 | void toggleFilter(); | 442 | void toggleFilter(); |
443 | void showFilter(bool visible); | 443 | void showFilter(bool visible); |
444 | void updateFilter(); | 444 | void updateFilter(); |
445 | void filterEdited(); | 445 | void filterEdited(); |
446 | void selectFilter( int ); | 446 | void selectFilter( int ); |
447 | KOFilterView *filterView(); | 447 | KOFilterView *filterView(); |
448 | 448 | ||
449 | void showIntro(); | 449 | void showIntro(); |
450 | 450 | ||
451 | /** Move the curdatepient view date to today */ | 451 | /** Move the curdatepient view date to today */ |
452 | void goToday(); | 452 | void goToday(); |
453 | 453 | ||
454 | /** Move to the next date(s) in the current view */ | 454 | /** Move to the next date(s) in the current view */ |
455 | void goNext(); | 455 | void goNext(); |
456 | 456 | ||
457 | /** Move to the previous date(s) in the current view */ | 457 | /** Move to the previous date(s) in the current view */ |
458 | void goPrevious(); | 458 | void goPrevious(); |
459 | /** Move to the next date(s) in the current view */ | 459 | /** Move to the next date(s) in the current view */ |
460 | void goNextMonth(); | 460 | void goNextMonth(); |
461 | 461 | ||
462 | /** Move to the previous date(s) in the current view */ | 462 | /** Move to the previous date(s) in the current view */ |
463 | void goPreviousMonth(); | 463 | void goPreviousMonth(); |
464 | 464 | ||
465 | void toggleExpand(); | 465 | void toggleExpand(); |
466 | void toggleDateNavigatorWidget(); | 466 | void toggleDateNavigatorWidget(); |
467 | void toggleAllDaySize(); | 467 | void toggleAllDaySize(); |
468 | 468 | ||
469 | /** Look for new messages in the inbox */ | 469 | /** Look for new messages in the inbox */ |
470 | void lookForIncomingMessages(); | 470 | void lookForIncomingMessages(); |
471 | /** Look for new messages in the outbox */ | 471 | /** Look for new messages in the outbox */ |
472 | void lookForOutgoingMessages(); | 472 | void lookForOutgoingMessages(); |
473 | 473 | ||
474 | void processMainViewSelection( Incidence * ); | 474 | void processMainViewSelection( Incidence * ); |
475 | void processTodoListSelection( Incidence * ); | 475 | void processTodoListSelection( Incidence * ); |
476 | 476 | ||
477 | void processIncidenceSelection( Incidence * ); | 477 | void processIncidenceSelection( Incidence * ); |
478 | 478 | ||
479 | void purgeCompleted(); | 479 | void purgeCompleted(); |
480 | bool removeCompletedSubTodos( Todo* ); | 480 | bool removeCompletedSubTodos( Todo* ); |
481 | void slotCalendarChanged(); | 481 | void slotCalendarChanged(); |
482 | bool importBday(); | 482 | bool importBday(); |
483 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 483 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
484 | bool importQtopia( const QString &categoriesFile, | 484 | bool importQtopia( const QString &categoriesFile, |
485 | const QString &datebookFile, | 485 | const QString &datebookFile, |
486 | const QString &tasklistFile ); | 486 | const QString &tasklistFile ); |
487 | void syncExternal( int mode ); | 487 | void syncExternal( int mode ); |
488 | void slotSelectPickerDate( QDate ) ; | 488 | void slotSelectPickerDate( QDate ) ; |
489 | void showDatePicker() ; | 489 | void showDatePicker() ; |
490 | void showDatePickerPopup() ; | 490 | void showDatePickerPopup() ; |
491 | void moveIncidence(Incidence *) ; | 491 | void moveIncidence(Incidence *) ; |
492 | void beamIncidence(Incidence *) ; | 492 | void beamIncidence(Incidence *) ; |
493 | void beamCalendar() ; | 493 | void beamCalendar() ; |
494 | void beamFilteredCalendar() ; | 494 | void beamFilteredCalendar() ; |
495 | void beamIncidenceList(QPtrList<Incidence>) ; | 495 | void beamIncidenceList(QPtrList<Incidence>) ; |
496 | void manageCategories(); | 496 | void manageCategories(); |
497 | void editCategories(); | 497 | void editCategories(); |
498 | int addCategories(); | 498 | int addCategories(); |
499 | void removeCategories(); | 499 | void removeCategories(); |
500 | void setSyncDevice( QString ); | 500 | void setSyncDevice( QString ); |
501 | void setSyncName( QString ); | 501 | void setSyncName( QString ); |
502 | void showDay( QDate ); | 502 | void showDay( QDate ); |
503 | void undo_delete(); | 503 | void undo_delete(); |
504 | protected slots: | 504 | protected slots: |
505 | void resetFocus(); | 505 | void resetFocus(); |
506 | void scrollBarValue(int); | 506 | void scrollBarValue(int); |
507 | void slotViewerClosed(); | 507 | void slotViewerClosed(); |
508 | void timerAlarm(); | 508 | void timerAlarm(); |
509 | void suspendAlarm(); | 509 | void suspendAlarm(); |
510 | void beamDone( Ir *ir ); | 510 | void beamDone( Ir *ir ); |
511 | /** Select a view or adapt the current view to display the specified dates. */ | 511 | /** Select a view or adapt the current view to display the specified dates. */ |
512 | void showDates( const KCal::DateList & ); | 512 | void showDates( const KCal::DateList & ); |
513 | void selectWeekNum ( int ); | 513 | void selectWeekNum ( int ); |
514 | void checkConflictForEvent(); | 514 | void checkConflictForEvent(); |
515 | 515 | ||
516 | public: | 516 | public: |
517 | void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); | 517 | void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); |
518 | // show a standard warning | 518 | // show a standard warning |
519 | // returns KMsgBox::yesNoCancel() | 519 | // returns KMsgBox::yesNoCancel() |
520 | int msgCalModified(); | 520 | int msgCalModified(); |
521 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 521 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource); |
522 | 522 | ||
523 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 523 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
524 | virtual void removeSyncInfo( QString syncProfile); | 524 | virtual void removeSyncInfo( QString syncProfile); |
525 | void setSyncManager(KSyncManager* manager); | 525 | void setSyncManager(KSyncManager* manager); |
526 | void setLoadedFileVersion(QDateTime); | 526 | void setLoadedFileVersion(QDateTime); |
527 | bool checkFileVersion(QString fn); | 527 | bool checkFileVersion(QString fn); |
528 | bool checkAllFileVersions(); | 528 | bool checkAllFileVersions(); |
529 | bool checkFileChanged(QString fn); | 529 | bool checkFileChanged(QString fn); |
530 | Event* getLastSyncEvent(); | 530 | Event* getLastSyncEvent(); |
531 | /** Adapt navigation units correpsonding to step size of navigation of the | 531 | /** Adapt navigation units correpsonding to step size of navigation of the |
532 | * current view. | 532 | * current view. |
533 | */ | 533 | */ |
534 | void adaptNavigationUnits(); | 534 | void adaptNavigationUnits(); |
535 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 535 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
536 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 536 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
537 | //Attendee* getYourAttendee(Event *event); | 537 | //Attendee* getYourAttendee(Event *event); |
538 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 538 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
539 | void setScrollBarStep(int val ); | 539 | void setScrollBarStep(int val ); |
540 | 540 | ||
541 | protected: | 541 | protected: |
542 | Event *mConflictingEvent; | 542 | Event *mConflictingEvent; |
543 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 543 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
544 | 544 | ||
545 | // returns KMsgBox::OKCandel() | 545 | // returns KMsgBox::OKCandel() |
546 | int msgItemDelete(const QString name); | 546 | int msgItemDelete(const QString name); |
547 | void showEventEditor(); | 547 | void showEventEditor(); |
548 | void showTodoEditor(); | 548 | void showTodoEditor(); |
549 | Todo *selectedTodo(); | 549 | Todo *selectedTodo(); |
550 | private: | 550 | private: |
551 | #ifdef DESKTOP_VERSION | 551 | #ifdef DESKTOP_VERSION |
552 | QScrollBar * mDateScrollBar; | 552 | QScrollBar * mDateScrollBar; |
553 | #endif | 553 | #endif |
554 | bool flag_blockConflict; | 554 | bool flag_blockConflict; |
555 | bool flag_blockScrollBar; | 555 | bool flag_blockScrollBar; |
556 | bool flag_checkFileFirsttime; | 556 | bool flag_checkFileFirsttime; |
557 | bool flag_clearallviewsEventDisplay; | 557 | bool flag_clearallviewsEventDisplay; |
558 | bool flag_clearallviewsupdateView; | 558 | bool flag_clearallviewsupdateView; |
559 | QDateTime mNextAlarmDateTime; | 559 | QDateTime mNextAlarmDateTime; |
560 | bool mViewerCallerIsSearchDialog; | 560 | bool mViewerCallerIsSearchDialog; |
561 | bool mBlockShowDates; | 561 | bool mBlockShowDates; |
562 | KSyncManager* mSyncManager; | 562 | KSyncManager* mSyncManager; |
563 | AlarmDialog * mAlarmDialog; | 563 | AlarmDialog * mAlarmDialog; |
564 | QString mAlarmNotification; | 564 | QString mAlarmNotification; |
565 | QString mSuspendAlarmNotification; | 565 | QString mSuspendAlarmNotification; |
566 | QTimer* mSuspendTimer; | 566 | QTimer* mSuspendTimer; |
567 | QTimer* mAlarmTimer; | 567 | QTimer* mAlarmTimer; |
568 | QTimer* mRecheckAlarmTimer; | 568 | QTimer* mRecheckAlarmTimer; |
569 | void computeAlarm( QString ); | 569 | void computeAlarm( QString ); |
570 | void startAlarm( QString, QString ); | 570 | void startAlarm( QString, QString ); |
571 | void setSyncEventsReadOnly(); | 571 | void setSyncEventsReadOnly(); |
572 | 572 | ||
573 | QDateTime loadedFileVersion; | 573 | QDateTime loadedFileVersion; |
574 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 574 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
575 | void checkExternalId( Incidence * inc ); | 575 | void checkExternalId( Incidence * inc ); |
576 | int mGlobalSyncMode; | 576 | int mGlobalSyncMode; |
577 | QString mCurrentSyncDevice; | 577 | QString mCurrentSyncDevice; |
578 | QString mCurrentSyncName; | 578 | QString mCurrentSyncName; |
579 | void init(); | 579 | void init(); |
580 | int mDatePickerMode; | 580 | int mDatePickerMode; |
581 | bool mFlagEditDescription; | 581 | bool mFlagEditDescription; |
582 | QDateTime mLastCalendarSync; | 582 | QDateTime mLastCalendarSync; |
583 | void createPrinter(); | 583 | void createPrinter(); |
584 | 584 | ||
585 | void calendarModified( bool, Calendar * ); | 585 | void calendarModified( bool, Calendar * ); |
586 | 586 | ||
587 | CalPrinter *mCalPrinter; | 587 | CalPrinter *mCalPrinter; |
588 | 588 | ||
589 | QSplitter *mPanner; | 589 | QSplitter *mPanner; |
590 | QSplitter *mLeftSplitter; | 590 | QSplitter *mLeftSplitter; |
591 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; | 591 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; |
592 | QWidgetStack *mRightFrame; | 592 | QWidgetStack *mRightFrame; |
593 | 593 | ||
594 | KDatePicker* mDatePicker; | 594 | KDatePicker* mDatePicker; |
595 | QVBox* mDateFrame; | 595 | QVBox* mDateFrame; |
596 | 596 | ||
597 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. | 597 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. |
598 | 598 | ||
599 | KOFilterView *mFilterView; | 599 | KOFilterView *mFilterView; |
600 | KOCalEditView *mCalEditView; | 600 | KOCalEditView *mCalEditView; |
601 | 601 | ||
602 | ResourceView *mResourceView; | 602 | ResourceView *mResourceView; |
603 | 603 | ||
604 | // calendar object for this viewing instance | 604 | // calendar object for this viewing instance |
605 | Calendar *mCalendar; | 605 | Calendar *mCalendar; |
606 | 606 | ||
607 | CalendarResourceManager *mResourceManager; | 607 | CalendarResourceManager *mResourceManager; |
608 | 608 | ||
609 | FileStorage *mStorage; | 609 | FileStorage *mStorage; |
610 | 610 | ||
611 | DateNavigator *mNavigator; | 611 | DateNavigator *mNavigator; |
612 | 612 | ||
613 | KOViewManager *mViewManager; | 613 | KOViewManager *mViewManager; |
614 | KODialogManager *mDialogManager; | 614 | KODialogManager *mDialogManager; |
615 | 615 | ||
616 | // Calendar filters | 616 | // Calendar filters |
617 | QPtrList<CalFilter> mFilters; | 617 | QPtrList<CalFilter> mFilters; |
618 | 618 | ||
619 | // various housekeeping variables. | 619 | // various housekeeping variables. |
620 | bool mModified; // flag indicating if calendar is modified | 620 | bool mModified; // flag indicating if calendar is modified |
621 | bool mReadOnly; // flag indicating if calendar is read-only | 621 | bool mReadOnly; // flag indicating if calendar is read-only |
622 | QDate mSaveSingleDate; | 622 | QDate mSaveSingleDate; |
623 | 623 | ||
624 | Incidence *mSelectedIncidence; | 624 | Incidence *mSelectedIncidence; |
625 | Incidence *mMoveIncidence; | 625 | Incidence *mMoveIncidence; |
626 | QDate mMoveIncidenceOldDate; | 626 | QDate mMoveIncidenceOldDate; |
627 | KOTodoView *mTodoList; | 627 | KOTodoView *mTodoList; |
628 | KOEventEditor * mEventEditor; | 628 | KOEventEditor * mEventEditor; |
629 | KOTodoEditor * mTodoEditor; | 629 | KOTodoEditor * mTodoEditor; |
630 | KOEventViewerDialog * mEventViewerDialog; | 630 | KOEventViewerDialog * mEventViewerDialog; |
631 | void keyPressEvent ( QKeyEvent *e) ; | 631 | void keyPressEvent ( QKeyEvent *e) ; |
632 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 632 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
633 | }; | 633 | }; |
634 | 634 | ||
635 | 635 | ||
636 | class CalendarViewVisitor : public Incidence::Visitor | 636 | class CalendarViewVisitor : public Incidence::Visitor |
637 | { | 637 | { |
638 | public: | 638 | public: |
639 | CalendarViewVisitor() : mView( 0 ) {} | 639 | CalendarViewVisitor() : mView( 0 ) {} |
640 | 640 | ||
641 | bool act( Incidence *incidence, CalendarView *view ) | 641 | bool act( Incidence *incidence, CalendarView *view ) |
642 | { | 642 | { |
643 | mView = view; | 643 | mView = view; |
644 | return incidence->accept( *this ); | 644 | return incidence->accept( *this ); |
645 | } | 645 | } |
646 | 646 | ||
647 | protected: | 647 | protected: |
648 | CalendarView *mView; | 648 | CalendarView *mView; |
649 | }; | 649 | }; |
650 | 650 | ||
651 | class ShowIncidenceVisitor : public CalendarViewVisitor | 651 | class ShowIncidenceVisitor : public CalendarViewVisitor |
652 | { | 652 | { |
653 | protected: | 653 | protected: |
654 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 654 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
655 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 655 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
656 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 656 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
657 | }; | 657 | }; |
658 | 658 | ||
659 | class EditIncidenceVisitor : public CalendarViewVisitor | 659 | class EditIncidenceVisitor : public CalendarViewVisitor |
660 | { | 660 | { |
661 | protected: | 661 | protected: |
662 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 662 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
663 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 663 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
664 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 664 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
665 | }; | 665 | }; |
666 | 666 | ||
667 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 667 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
668 | { | 668 | { |
669 | protected: | 669 | protected: |
670 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 670 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
671 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 671 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
672 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 672 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
673 | }; | 673 | }; |
674 | 674 | ||
675 | #endif | 675 | #endif |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 1b0e5f4..31ef338 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,636 +1,646 @@ | |||
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 <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kglobalsettings.h> | 39 | #include <kglobalsettings.h> |
40 | #include <kconfig.h> | 40 | #include <kconfig.h> |
41 | #include <klocale.h> | 41 | #include <klocale.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kemailsettings.h> | 43 | #include <kemailsettings.h> |
44 | #include <kstaticdeleter.h> | 44 | #include <kstaticdeleter.h> |
45 | #include <libkdepim/kpimglobalprefs.h> | 45 | #include <libkdepim/kpimglobalprefs.h> |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "mainwindow.h" | 48 | #include "mainwindow.h" |
49 | 49 | ||
50 | KOPrefs *KOPrefs::mInstance = 0; | 50 | KOPrefs *KOPrefs::mInstance = 0; |
51 | static KStaticDeleter<KOPrefs> insd; | 51 | static KStaticDeleter<KOPrefs> insd; |
52 | 52 | ||
53 | KOPrefs::KOPrefs() : | 53 | KOPrefs::KOPrefs() : |
54 | KPimPrefs("korganizerrc") | 54 | KPimPrefs("korganizerrc") |
55 | { | 55 | { |
56 | mGlobalUpdateDisabled = false; | 56 | mGlobalUpdateDisabled = false; |
57 | mCategoryColors.setAutoDelete(true); | 57 | mCategoryColors.setAutoDelete(true); |
58 | fillMailDefaults(); | 58 | fillMailDefaults(); |
59 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 59 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
60 | QColor defaultHolidayColor = QColor(255,0,0); | 60 | QColor defaultHolidayColor = QColor(255,0,0); |
61 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 61 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
62 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 62 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
63 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 63 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
64 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 64 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
65 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 65 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
66 | QColor defaultTodoRunColor = QColor(99,194,30); | 66 | QColor defaultTodoRunColor = QColor(99,194,30); |
67 | KPrefs::setCurrentGroup("General"); | 67 | KPrefs::setCurrentGroup("General"); |
68 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 68 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
69 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 69 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
70 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 70 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
71 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 71 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
72 | addItemBool("ShowIconList",&mShowIconList,true); | 72 | addItemBool("ShowIconList",&mShowIconList,true); |
73 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 73 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
74 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 74 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
75 | addItemBool("ShowIconDay6",&mShowIconDay6,true); | 75 | addItemBool("ShowIconDay6",&mShowIconDay6,true); |
76 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 76 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
77 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 77 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
78 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 78 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
79 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 79 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
80 | addItemBool("ShowIconBack",&mShowIconBack,true); | 80 | addItemBool("ShowIconBack",&mShowIconBack,true); |
81 | addItemBool("ShowIconToday",&mShowIconToday,true); | 81 | addItemBool("ShowIconToday",&mShowIconToday,true); |
82 | addItemBool("ShowIconForward",&mShowIconForward,true); | 82 | addItemBool("ShowIconForward",&mShowIconForward,true); |
83 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 83 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
84 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); | 84 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); |
85 | addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); | 85 | addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); |
86 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 86 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
87 | addItemBool("ShowIconNext",&mShowIconNext,true); | 87 | addItemBool("ShowIconNext",&mShowIconNext,true); |
88 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 88 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
89 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 89 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
90 | addItemBool("ShowIconFilter",&mShowIconFilter,false); | 90 | addItemBool("ShowIconFilter",&mShowIconFilter,false); |
91 | addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); | 91 | addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); |
92 | 92 | ||
93 | bool addIcons = false; | 93 | bool addIcons = false; |
94 | #ifdef DESKTOP_VERSION | 94 | #ifdef DESKTOP_VERSION |
95 | addIcons = true; | 95 | addIcons = true; |
96 | #endif | 96 | #endif |
97 | addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); | 97 | addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); |
98 | addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); | 98 | addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); |
99 | addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); | 99 | addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); |
100 | addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); | 100 | addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); |
101 | 101 | ||
102 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); | 102 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); |
103 | 103 | ||
104 | addItemBool("AskForQuit",&mAskForQuit,false); | 104 | addItemBool("AskForQuit",&mAskForQuit,false); |
105 | 105 | ||
106 | #ifndef DESKTOP_VERSION | 106 | #ifndef DESKTOP_VERSION |
107 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 107 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
108 | #else | 108 | #else |
109 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 109 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
110 | #endif | 110 | #endif |
111 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 111 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
112 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 112 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
113 | addItemBool("ToolBarHorV",&mToolBarHorV, true ); | 113 | addItemBool("ToolBarHorV",&mToolBarHorV, true ); |
114 | addItemBool("ToolBarUpV",&mToolBarUpV, false ); | 114 | addItemBool("ToolBarUpV",&mToolBarUpV, false ); |
115 | addItemBool("ToolBarHorN",&mToolBarHorN, true ); | 115 | addItemBool("ToolBarHorN",&mToolBarHorN, true ); |
116 | addItemBool("ToolBarUpN",&mToolBarUpN, false ); | 116 | addItemBool("ToolBarUpN",&mToolBarUpN, false ); |
117 | addItemBool("ToolBarHorF",&mToolBarHorF, true ); | 117 | addItemBool("ToolBarHorF",&mToolBarHorF, true ); |
118 | addItemBool("ToolBarUpF",&mToolBarUpF, false ); | 118 | addItemBool("ToolBarUpF",&mToolBarUpF, false ); |
119 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 119 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
120 | addItemBool("WhatsNextTime2Lines",&mWhatsNextTime2Lines, false ); | 120 | addItemBool("WhatsNextTime2Lines",&mWhatsNextTime2Lines, false ); |
121 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 121 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
122 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 122 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
123 | 123 | ||
124 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 124 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
125 | addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); | 125 | addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); |
126 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); | 126 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); |
127 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); | 127 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); |
128 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 128 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
129 | addItemInt("AllDay Size",&mAllDaySize,28); | 129 | addItemInt("AllDay Size",&mAllDaySize,28); |
130 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 130 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
131 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 131 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
132 | 132 | ||
133 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 133 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
134 | addItemStringList("EventSummary User",&mEventSummaryUser); | 134 | addItemStringList("EventSummary User",&mEventSummaryUser); |
135 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 135 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
136 | addItemStringList("JournalSummary User",&mJournalSummaryUser); | 136 | addItemStringList("JournalSummary User",&mJournalSummaryUser); |
137 | 137 | ||
138 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 138 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
139 | addItemBool("Enable Project View",&mEnableProjectView,false); | 139 | addItemBool("Enable Project View",&mEnableProjectView,false); |
140 | addItemBool("Auto Save",&mAutoSave,false); | 140 | addItemBool("Auto Save",&mAutoSave,false); |
141 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 141 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
142 | addItemBool("Confirm Deletes",&mConfirm,true); | 142 | addItemBool("Confirm Deletes",&mConfirm,true); |
143 | addItemString("Archive File",&mArchiveFile); | 143 | addItemString("Archive File",&mArchiveFile); |
144 | addItemString("Html Export File",&mHtmlExportFile, | 144 | addItemString("Html Export File",&mHtmlExportFile, |
145 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 145 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
146 | addItemBool("Html With Save",&mHtmlWithSave,false); | 146 | addItemBool("Html With Save",&mHtmlWithSave,false); |
147 | 147 | ||
148 | KPrefs::setCurrentGroup("Personal Settings"); | 148 | KPrefs::setCurrentGroup("Personal Settings"); |
149 | 149 | ||
150 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 150 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
151 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 151 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
152 | addItemBool("Bcc",&mBcc,false); | 152 | addItemBool("Bcc",&mBcc,false); |
153 | 153 | ||
154 | KPrefs::setCurrentGroup("Time & Date"); | 154 | KPrefs::setCurrentGroup("Time & Date"); |
155 | 155 | ||
156 | 156 | ||
157 | addItemInt("Default Start Time",&mStartTime,10); | 157 | addItemInt("Default Start Time",&mStartTime,10); |
158 | addItemInt("Default Duration",&mDefaultDuration,2); | 158 | addItemInt("Default Duration",&mDefaultDuration,2); |
159 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 159 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
160 | KPrefs::setCurrentGroup("AlarmSettings"); | 160 | KPrefs::setCurrentGroup("AlarmSettings"); |
161 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 161 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
162 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 162 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
163 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 163 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
164 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 164 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
165 | 165 | ||
166 | 166 | ||
167 | KPrefs::setCurrentGroup("Calendar"); | 167 | KPrefs::setCurrentGroup("Calendar"); |
168 | 168 | ||
169 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 169 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
170 | 170 | ||
171 | KPrefs::setCurrentGroup("Fonts"); | 171 | KPrefs::setCurrentGroup("Fonts"); |
172 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 172 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
173 | QFont fon = KGlobalSettings::generalFont(); | 173 | QFont fon = KGlobalSettings::generalFont(); |
174 | addItemFont("TimeBar Font",&mTimeBarFont,fon ); | 174 | addItemFont("TimeBar Font",&mTimeBarFont,fon ); |
175 | addItemFont("MonthView Font",&mMonthViewFont,fon); | 175 | addItemFont("MonthView Font",&mMonthViewFont,fon); |
176 | addItemFont("AgendaView Font",&mAgendaViewFont,fon); | 176 | addItemFont("AgendaView Font",&mAgendaViewFont,fon); |
177 | addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); | 177 | addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); |
178 | addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); | 178 | addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); |
179 | addItemFont("TodoView Font",&mTodoViewFont,fon); | 179 | addItemFont("TodoView Font",&mTodoViewFont,fon); |
180 | addItemFont("ListView Font",&mListViewFont,fon); | 180 | addItemFont("ListView Font",&mListViewFont,fon); |
181 | addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); | 181 | addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); |
182 | addItemFont("EditBox Font",&mEditBoxFont,fon); | 182 | addItemFont("EditBox Font",&mEditBoxFont,fon); |
183 | addItemFont("JournalView Font",&mJornalViewFont,fon); | 183 | addItemFont("JournalView Font",&mJornalViewFont,fon); |
184 | addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); | 184 | addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); |
185 | addItemFont("EventView Font",&mEventViewFont,fon); | 185 | addItemFont("EventView Font",&mEventViewFont,fon); |
186 | 186 | ||
187 | KPrefs::setCurrentGroup("RemoteSyncing"); | 187 | KPrefs::setCurrentGroup("RemoteSyncing"); |
188 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 188 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
189 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 189 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
190 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 190 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
191 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 191 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
192 | 192 | ||
193 | #ifdef _WIN32_ | 193 | #ifdef _WIN32_ |
194 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 194 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
195 | #else | 195 | #else |
196 | QString hdp= locateLocal("data","korganizer")+"/"; | 196 | QString hdp= locateLocal("data","korganizer")+"/"; |
197 | #endif | 197 | #endif |
198 | 198 | ||
199 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 199 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
200 | 200 | ||
201 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 201 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
202 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 202 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
203 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 203 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
204 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 204 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
205 | 205 | ||
206 | 206 | ||
207 | KPrefs::setCurrentGroup("Locale"); | 207 | KPrefs::setCurrentGroup("Locale"); |
208 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 208 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
209 | 209 | ||
210 | 210 | ||
211 | KPrefs::setCurrentGroup("Colors"); | 211 | KPrefs::setCurrentGroup("Colors"); |
212 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 212 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
213 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 213 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
214 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 214 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
215 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); | 215 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); |
216 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 216 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
217 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 217 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
218 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 218 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
219 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 219 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
220 | addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); | 220 | addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); |
221 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 221 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
222 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 222 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
223 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 223 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
224 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 224 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
225 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 225 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
226 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); | 226 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); |
227 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 227 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
228 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 228 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
229 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 229 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
230 | addItemBool("UseAppColors",&mUseAppColors,false); | 230 | addItemBool("UseAppColors",&mUseAppColors,false); |
231 | 231 | ||
232 | 232 | ||
233 | KPrefs::setCurrentGroup("Conflicts"); | 233 | KPrefs::setCurrentGroup("Conflicts"); |
234 | addItemBool("EnableAutoDetect",&mDetectConflicts,true); | 234 | addItemBool("EnableAutoDetect",&mDetectConflicts,true); |
235 | addItemBool("CheckConflictsFree",&mIncludeFree,true); | 235 | addItemBool("CheckConflictsFree",&mIncludeFree,true); |
236 | addItemBool("CheckConflictsAllDayAllDay",&mCheckConflictsAllDayAllDay,false); | 236 | addItemBool("CheckConflictsAllDayAllDay",&mCheckConflictsAllDayAllDay,false); |
237 | addItemBool("CheckConflictsAllDayNonAD",&mCheckConflictsAllDayNonAD,false); | 237 | addItemBool("CheckConflictsAllDayNonAD",&mCheckConflictsAllDayNonAD,false); |
238 | addItemBool("CheckConflictsNonADAllDay",&mCheckConflictsNonADAllDay,false); | 238 | addItemBool("CheckConflictsNonADAllDay",&mCheckConflictsNonADAllDay,false); |
239 | addItemBool("CheckConflictsNonADNonAD",&mCheckConflictsNonADNonAD,true); | 239 | addItemBool("CheckConflictsNonADNonAD",&mCheckConflictsNonADNonAD,true); |
240 | addItemString("FilterConflictEditItem", &mFilterConflictEditItem ,"nofilter" ); | 240 | addItemString("FilterConflictEditItem", &mFilterConflictEditItem ,"nofilter" ); |
241 | addItemString("FilterConflictAllItem", &mFilterConflictAllItem ,"nofilter" ); | 241 | addItemString("FilterConflictAllItem", &mFilterConflictAllItem ,"nofilter" ); |
242 | 242 | ||
243 | KPrefs::setCurrentGroup("Views"); | 243 | KPrefs::setCurrentGroup("Views"); |
244 | addItemBool("Block Popup Menu",&mBlockPopupMenu,false); | 244 | addItemBool("Block Popup Menu",&mBlockPopupMenu,false); |
245 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); | 245 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); |
246 | addItemInt("Hour Size",&mHourSize,8); | 246 | addItemInt("Hour Size",&mHourSize,8); |
247 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 247 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
248 | addItemBool("ShowLongAllday",&mLongAllday,true); | 248 | addItemBool("ShowLongAllday",&mLongAllday,true); |
249 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 249 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
250 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 250 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
251 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 251 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
252 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 252 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
253 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 253 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
254 | addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); | 254 | addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); |
255 | #ifdef DESKTOP_VERION | 255 | #ifdef DESKTOP_VERION |
256 | addItemBool("Enable ToolTips",&mEnableToolTips,true); | 256 | addItemBool("Enable ToolTips",&mEnableToolTips,true); |
257 | #else | 257 | #else |
258 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 258 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
259 | #endif | 259 | #endif |
260 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 260 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
261 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 261 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
262 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 262 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
263 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 263 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
264 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); | 264 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); |
265 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 265 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
266 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 266 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
267 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 267 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
268 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 268 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
269 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; | 269 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; |
270 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); | 270 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); |
271 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 271 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
272 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 272 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
273 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 273 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
274 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 274 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
275 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 275 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
276 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); | 276 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); |
277 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); | 277 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); |
278 | addItemBool("MonthViewWeekRowlayout",&mMonthViewWeekRowlayout,false); | 278 | addItemBool("MonthViewWeekRowlayout",&mMonthViewWeekRowlayout,false); |
279 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 279 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
280 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 280 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
281 | #ifdef DESKTOP_VERSION | 281 | #ifdef DESKTOP_VERSION |
282 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 282 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
283 | #else | 283 | #else |
284 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 284 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
285 | #endif | 285 | #endif |
286 | addItemInt("Day Begins",&mDayBegins,7); | 286 | addItemInt("Day Begins",&mDayBegins,7); |
287 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 287 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
288 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 288 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
289 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 289 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
290 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 290 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
291 | 291 | ||
292 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 292 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
293 | addItemBool("Full View Month",&mFullViewMonth,true); | 293 | addItemBool("Full View Month",&mFullViewMonth,true); |
294 | addItemBool("Full View Todo",&mFullViewTodo,true); | 294 | addItemBool("Full View Todo",&mFullViewTodo,true); |
295 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 295 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
296 | 296 | ||
297 | addItemInt("Next X Days",&mNextXDays,3); | 297 | addItemInt("Next X Days",&mNextXDays,3); |
298 | 298 | ||
299 | KPrefs::setCurrentGroup("Printer"); | 299 | KPrefs::setCurrentGroup("Printer"); |
300 | 300 | ||
301 | KPrefs::setCurrentGroup("Layout"); | 301 | KPrefs::setCurrentGroup("Layout"); |
302 | 302 | ||
303 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 303 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
304 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 304 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
305 | 305 | ||
306 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 306 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
307 | 307 | ||
308 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 308 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
309 | 309 | ||
310 | KPrefs::setCurrentGroup("Group Scheduling"); | 310 | KPrefs::setCurrentGroup("Group Scheduling"); |
311 | 311 | ||
312 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 312 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
313 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 313 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
314 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 314 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
315 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 315 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
316 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 316 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
317 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 317 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
318 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 318 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
319 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 319 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
320 | 320 | ||
321 | KPrefs::setCurrentGroup( "Editors" ); | 321 | KPrefs::setCurrentGroup( "Editors" ); |
322 | 322 | ||
323 | addItemStringList( "EventTemplates", &mEventTemplates ); | 323 | addItemStringList( "EventTemplates", &mEventTemplates ); |
324 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 324 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
325 | 325 | ||
326 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 326 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
327 | 327 | ||
328 | KPrefs::setCurrentGroup( "ViewOptions" ); | 328 | KPrefs::setCurrentGroup( "ViewOptions" ); |
329 | addItemBool("EVshowDetails",&mEVshowDetails,true); | 329 | addItemBool("EVshowDetails",&mEVshowDetails,true); |
330 | addItemBool("EVshowCreated",&mEVshowCreated,true); | 330 | addItemBool("EVshowCreated",&mEVshowCreated,true); |
331 | addItemBool("EVshowChanged",&mEVshowChanged,true); | 331 | addItemBool("EVshowChanged",&mEVshowChanged,true); |
332 | addItemBool("WTshowDetails",&mWTshowDetails,false); | 332 | addItemBool("WTshowDetails",&mWTshowDetails,false); |
333 | addItemBool("WTshowCreated",&mWTshowCreated,false); | 333 | addItemBool("WTshowCreated",&mWTshowCreated,false); |
334 | addItemBool("WTshowChanged",&mWTshowChanged,false); | 334 | addItemBool("WTshowChanged",&mWTshowChanged,false); |
335 | mCalendars.setAutoDelete( true ); | 335 | mCalendars.setAutoDelete( true ); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | KOPrefs::~KOPrefs() | 339 | KOPrefs::~KOPrefs() |
340 | { | 340 | { |
341 | if (mInstance == this) | 341 | if (mInstance == this) |
342 | mInstance = insd.setObject(0); | 342 | mInstance = insd.setObject(0); |
343 | mCalendars.setAutoDelete( true ); | 343 | mCalendars.setAutoDelete( true ); |
344 | mCalendars.clear(); | 344 | mCalendars.clear(); |
345 | //qDebug("KOPrefs::~KOPrefs() "); | 345 | //qDebug("KOPrefs::~KOPrefs() "); |
346 | } | 346 | } |
347 | 347 | ||
348 | 348 | ||
349 | KOPrefs *KOPrefs::instance() | 349 | KOPrefs *KOPrefs::instance() |
350 | { | 350 | { |
351 | if (!mInstance) { | 351 | if (!mInstance) { |
352 | mInstance = insd.setObject(new KOPrefs()); | 352 | mInstance = insd.setObject(new KOPrefs()); |
353 | mInstance->readConfig(); | 353 | mInstance->readConfig(); |
354 | } | 354 | } |
355 | 355 | ||
356 | return mInstance; | 356 | return mInstance; |
357 | } | 357 | } |
358 | 358 | ||
359 | void KOPrefs::usrSetDefaults() | 359 | void KOPrefs::usrSetDefaults() |
360 | { | 360 | { |
361 | 361 | ||
362 | } | 362 | } |
363 | 363 | ||
364 | void KOPrefs::fillMailDefaults() | 364 | void KOPrefs::fillMailDefaults() |
365 | { | 365 | { |
366 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 366 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
367 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 367 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
368 | } | 368 | } |
369 | 369 | ||
370 | void KOPrefs::setTimeZoneIdDefault() | 370 | void KOPrefs::setTimeZoneIdDefault() |
371 | { | 371 | { |
372 | ; | 372 | ; |
373 | } | 373 | } |
374 | 374 | ||
375 | void KOPrefs::setAllDefaults() | 375 | void KOPrefs::setAllDefaults() |
376 | { | 376 | { |
377 | setCategoryDefaults(); | 377 | setCategoryDefaults(); |
378 | mEventSummaryUser = getDefaultList() ; | 378 | mEventSummaryUser = getDefaultList() ; |
379 | mTodoSummaryUser = getDefaultList() ; | 379 | mTodoSummaryUser = getDefaultList() ; |
380 | mJournalSummaryUser = getDefaultList() ; | 380 | mJournalSummaryUser = getDefaultList() ; |
381 | mLocationDefaults = getLocationDefaultList(); | 381 | mLocationDefaults = getLocationDefaultList(); |
382 | } | 382 | } |
383 | 383 | ||
384 | void KOPrefs::setCategoryDefaults() | 384 | void KOPrefs::setCategoryDefaults() |
385 | { | 385 | { |
386 | mCustomCategories.clear(); | 386 | mCustomCategories.clear(); |
387 | mCustomCategories = getDefaultList(); | 387 | mCustomCategories = getDefaultList(); |
388 | 388 | ||
389 | QStringList::Iterator it; | 389 | QStringList::Iterator it; |
390 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 390 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
391 | setCategoryColor(*it,mDefaultCategoryColor); | 391 | setCategoryColor(*it,mDefaultCategoryColor); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | QStringList KOPrefs::getLocationDefaultList() | 394 | QStringList KOPrefs::getLocationDefaultList() |
395 | { | 395 | { |
396 | QStringList retval ; | 396 | QStringList retval ; |
397 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 397 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
398 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") | 398 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") |
399 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 399 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
400 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 400 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
401 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 401 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
402 | 402 | ||
403 | retval.sort(); | 403 | retval.sort(); |
404 | return retval; | 404 | return retval; |
405 | } | 405 | } |
406 | QStringList KOPrefs::getDefaultList() | 406 | QStringList KOPrefs::getDefaultList() |
407 | { | 407 | { |
408 | QStringList retval ; | 408 | QStringList retval ; |
409 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") | 409 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") |
410 | << i18n("Break") | 410 | << i18n("Break") |
411 | << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") | 411 | << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") |
412 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") | 412 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") |
413 | << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") | 413 | << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") |
414 | << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") | 414 | << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") |
415 | << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") | 415 | << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") |
416 | << i18n("Vacation") ; | 416 | << i18n("Vacation") ; |
417 | retval.sort(); | 417 | retval.sort(); |
418 | //qDebug("cat %s ", retval.join("-").latin1()); | 418 | //qDebug("cat %s ", retval.join("-").latin1()); |
419 | return retval; | 419 | return retval; |
420 | } | 420 | } |
421 | // << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") | 421 | // << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") |
422 | void KOPrefs::usrReadConfig() | 422 | void KOPrefs::usrReadConfig() |
423 | { | 423 | { |
424 | config()->setGroup("General"); | 424 | config()->setGroup("General"); |
425 | 425 | ||
426 | //qDebug("KOPrefs::usrReadConfig() "); | 426 | //qDebug("KOPrefs::usrReadConfig() "); |
427 | mCustomCategories = config()->readListEntry("Custom Categories"); | 427 | mCustomCategories = config()->readListEntry("Custom Categories"); |
428 | mOldLoadedLanguage = mOldLanguage ; | 428 | mOldLoadedLanguage = mOldLanguage ; |
429 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 429 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
430 | if (mLocationDefaults.isEmpty()) { | 430 | if (mLocationDefaults.isEmpty()) { |
431 | mLocationDefaults = getLocationDefaultList(); | 431 | mLocationDefaults = getLocationDefaultList(); |
432 | } | 432 | } |
433 | 433 | ||
434 | if (mEventSummaryUser.isEmpty()) { | 434 | if (mEventSummaryUser.isEmpty()) { |
435 | mEventSummaryUser = getDefaultList() ; | 435 | mEventSummaryUser = getDefaultList() ; |
436 | } | 436 | } |
437 | if (mTodoSummaryUser.isEmpty()) { | 437 | if (mTodoSummaryUser.isEmpty()) { |
438 | mTodoSummaryUser = getDefaultList() ; | 438 | mTodoSummaryUser = getDefaultList() ; |
439 | } | 439 | } |
440 | 440 | ||
441 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 441 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
442 | 442 | ||
443 | config()->setGroup("Personal Settings"); | 443 | config()->setGroup("Personal Settings"); |
444 | mName = config()->readEntry("user_name",""); | 444 | mName = config()->readEntry("user_name",""); |
445 | mEmail = config()->readEntry("user_email",""); | 445 | mEmail = config()->readEntry("user_email",""); |
446 | fillMailDefaults(); | 446 | fillMailDefaults(); |
447 | 447 | ||
448 | config()->setGroup("Category Colors"); | 448 | config()->setGroup("Category Colors"); |
449 | QStringList::Iterator it; | 449 | QStringList::Iterator it; |
450 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 450 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
451 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 451 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
452 | 452 | ||
453 | } | 453 | } |
454 | KConfig fc (locateLocal("config","kopicalendarrc")); | 454 | KConfig fc (locateLocal("config","kopicalendarrc")); |
455 | fc.setGroup("CC"); | 455 | fc.setGroup("CC"); |
456 | int numCals = fc.readNumEntry("NumberCalendars",0 ); | 456 | int numCals = fc.readNumEntry("NumberCalendars",0 ); |
457 | mNextAvailableCalendar = 1; | 457 | mNextAvailableCalendar = 1; |
458 | if ( numCals == 0 ) { | 458 | if ( numCals == 0 ) { |
459 | KopiCalendarFile *kkf = getNewCalendar(); | 459 | KopiCalendarFile *kkf = getNewCalendar(); |
460 | kkf->isStandard = true; | 460 | kkf->isStandard = true; |
461 | kkf->mName = i18n("Standard"); | 461 | kkf->mName = i18n("Standard"); |
462 | kkf->mFileName = QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); | 462 | kkf->mFileName = QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); |
463 | } | 463 | } |
464 | while ( mNextAvailableCalendar <= numCals ) { | 464 | while ( mNextAvailableCalendar <= numCals ) { |
465 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); | 465 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); |
466 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); | 466 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); |
467 | KopiCalendarFile *kkf = getNewCalendar(); | 467 | KopiCalendarFile *kkf = getNewCalendar(); |
468 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); | 468 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); |
469 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); | 469 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); |
470 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); | 470 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); |
471 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); | 471 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); |
472 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); | 472 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); |
473 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); | 473 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); |
474 | kkf->mFileName = QDir::convertSeparators( fc.readEntry( prefix+"_FileName", kkf->mFileName) ); | 474 | kkf->mFileName = QDir::convertSeparators( fc.readEntry( prefix+"_FileName", kkf->mFileName) ); |
475 | kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) ); | 475 | kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) ); |
476 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); | 476 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); |
477 | if ( kkf->mCalNumber == 1 ) { | 477 | if ( kkf->mCalNumber == 1 ) { |
478 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | 478 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); |
479 | } | 479 | } |
480 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); | 480 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); |
481 | if ( kkf->mName == i18n("Birthdays") ) { | 481 | if ( kkf->mName == i18n("Birthdays") ) { |
482 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); | 482 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); |
483 | } | 483 | } |
484 | if ( kkf->isRelative ) | 484 | if ( kkf->isRelative ) |
485 | kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); | 485 | kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); |
486 | } | 486 | } |
487 | 487 | ||
488 | KPimPrefs::usrReadConfig(); | 488 | KPimPrefs::usrReadConfig(); |
489 | } | 489 | } |
490 | 490 | ||
491 | KopiCalendarFile * KOPrefs::getCalendar( int num ) | 491 | KopiCalendarFile * KOPrefs::getCalendar( int num ) |
492 | { | 492 | { |
493 | return mDefCalColors[num-1]; | 493 | return mDefCalColors[num-1]; |
494 | } | 494 | } |
495 | 495 | ||
496 | KopiCalendarFile * KOPrefs::getNewCalendar() | 496 | KopiCalendarFile * KOPrefs::getNewCalendar() |
497 | { | 497 | { |
498 | KopiCalendarFile * kkf = new KopiCalendarFile(); | 498 | KopiCalendarFile * kkf = new KopiCalendarFile(); |
499 | kkf->mCalNumber = mNextAvailableCalendar; | 499 | kkf->mCalNumber = mNextAvailableCalendar; |
500 | mDefCalColors.resize( mNextAvailableCalendar ); | 500 | mDefCalColors.resize( mNextAvailableCalendar ); |
501 | mDefCalColors[mNextAvailableCalendar-1] = kkf; | 501 | mDefCalColors[mNextAvailableCalendar-1] = kkf; |
502 | ++mNextAvailableCalendar; | 502 | ++mNextAvailableCalendar; |
503 | kkf->mDefaultColor = mEventColor; | 503 | kkf->mDefaultColor = mEventColor; |
504 | kkf->mName = i18n("New Calendar"); | 504 | kkf->mName = i18n("New Calendar"); |
505 | mCalendars.append( kkf ); | 505 | mCalendars.append( kkf ); |
506 | return kkf; | 506 | return kkf; |
507 | } | 507 | } |
508 | void KOPrefs::deleteCalendar( int num ) | 508 | void KOPrefs::deleteCalendar( int num ) |
509 | { | 509 | { |
510 | KopiCalendarFile * kkf = mCalendars.first(); | 510 | KopiCalendarFile * kkf = mCalendars.first(); |
511 | while ( kkf ) { | 511 | while ( kkf ) { |
512 | if ( kkf->mCalNumber == num ) { | 512 | if ( kkf->mCalNumber == num ) { |
513 | qDebug("KOPrefs::deleteCalendar %d ", num ); | 513 | qDebug("KOPrefs::deleteCalendar %d ", num ); |
514 | mCalendars.remove( kkf ); | 514 | mCalendars.remove( kkf ); |
515 | delete kkf; | 515 | delete kkf; |
516 | return; | 516 | return; |
517 | } | 517 | } |
518 | kkf = mCalendars.next(); | 518 | kkf = mCalendars.next(); |
519 | } | 519 | } |
520 | } | 520 | } |
521 | int KOPrefs::getCalendarID( const QString & name ) | 521 | int KOPrefs::getCalendarID( const QString & name ) |
522 | { | 522 | { |
523 | KopiCalendarFile * kkf = mCalendars.first(); | 523 | KopiCalendarFile * kkf = mCalendars.first(); |
524 | while ( kkf ) { | 524 | while ( kkf ) { |
525 | if ( name == kkf->mName) | 525 | if ( name == kkf->mName) |
526 | return kkf->mCalNumber; | 526 | return kkf->mCalNumber; |
527 | kkf = mCalendars.next(); | 527 | kkf = mCalendars.next(); |
528 | } | 528 | } |
529 | return 1; | 529 | return 1; |
530 | } | 530 | } |
531 | int KOPrefs::getFuzzyCalendarID( const QString & name ) | ||
532 | { | ||
533 | KopiCalendarFile * kkf = mCalendars.first(); | ||
534 | while ( kkf ) { | ||
535 | if ( name.lower() == kkf->mName.lower()) | ||
536 | return kkf->mCalNumber; | ||
537 | kkf = mCalendars.next(); | ||
538 | } | ||
539 | return 0; | ||
540 | } | ||
531 | QString KOPrefs::calName( int calNum) const | 541 | QString KOPrefs::calName( int calNum) const |
532 | { | 542 | { |
533 | return (mDefCalColors[calNum-1])->mName; | 543 | return (mDefCalColors[calNum-1])->mName; |
534 | } | 544 | } |
535 | QColor KOPrefs::defaultColor( int calNum ) const | 545 | QColor KOPrefs::defaultColor( int calNum ) const |
536 | { | 546 | { |
537 | if ( calNum == 1 ) return mEventColor; | 547 | if ( calNum == 1 ) return mEventColor; |
538 | return (mDefCalColors[calNum-1])->mDefaultColor; | 548 | return (mDefCalColors[calNum-1])->mDefaultColor; |
539 | } | 549 | } |
540 | void KOPrefs::usrWriteConfig() | 550 | void KOPrefs::usrWriteConfig() |
541 | { | 551 | { |
542 | config()->setGroup("General"); | 552 | config()->setGroup("General"); |
543 | config()->writeEntry("Custom Categories",mCustomCategories); | 553 | config()->writeEntry("Custom Categories",mCustomCategories); |
544 | 554 | ||
545 | config()->setGroup("Personal Settings"); | 555 | config()->setGroup("Personal Settings"); |
546 | config()->writeEntry("user_name",mName); | 556 | config()->writeEntry("user_name",mName); |
547 | config()->writeEntry("user_email",mEmail); | 557 | config()->writeEntry("user_email",mEmail); |
548 | 558 | ||
549 | config()->setGroup("Category Colors"); | 559 | config()->setGroup("Category Colors"); |
550 | QDictIterator<QColor> it(mCategoryColors); | 560 | QDictIterator<QColor> it(mCategoryColors); |
551 | while (it.current()) { | 561 | while (it.current()) { |
552 | config()->writeEntry(it.currentKey(),*(it.current())); | 562 | config()->writeEntry(it.currentKey(),*(it.current())); |
553 | ++it; | 563 | ++it; |
554 | } | 564 | } |
555 | KConfig fc (locateLocal("config","kopicalendarrc")); | 565 | KConfig fc (locateLocal("config","kopicalendarrc")); |
556 | fc.setGroup("CC"); | 566 | fc.setGroup("CC"); |
557 | fc.deleteGroup( "CC"); | 567 | fc.deleteGroup( "CC"); |
558 | fc.setGroup("CC"); | 568 | fc.setGroup("CC"); |
559 | fc.writeEntry("NumberCalendars",mCalendars.count()); | 569 | fc.writeEntry("NumberCalendars",mCalendars.count()); |
560 | int numCal = 1; | 570 | int numCal = 1; |
561 | int writeCal = 0; | 571 | int writeCal = 0; |
562 | while ( numCal < mNextAvailableCalendar ) { | 572 | while ( numCal < mNextAvailableCalendar ) { |
563 | KopiCalendarFile * kkf = mCalendars.first(); | 573 | KopiCalendarFile * kkf = mCalendars.first(); |
564 | while ( kkf ) { | 574 | while ( kkf ) { |
565 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); | 575 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); |
566 | if ( kkf->mCalNumber == numCal ) { | 576 | if ( kkf->mCalNumber == numCal ) { |
567 | ++writeCal; | 577 | ++writeCal; |
568 | //qDebug("Write calendar %d %d ", numCal , writeCal); | 578 | //qDebug("Write calendar %d %d ", numCal , writeCal); |
569 | QString prefix = "Cal_" + QString::number( writeCal ); | 579 | QString prefix = "Cal_" + QString::number( writeCal ); |
570 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); | 580 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); |
571 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); | 581 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); |
572 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); | 582 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); |
573 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); | 583 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); |
574 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); | 584 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); |
575 | fc.writeEntry( prefix+"_Name", kkf->mName); | 585 | fc.writeEntry( prefix+"_Name", kkf->mName); |
576 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); | 586 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); |
577 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); | 587 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); |
578 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); | 588 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); |
579 | } | 589 | } |
580 | kkf = mCalendars.next(); | 590 | kkf = mCalendars.next(); |
581 | } | 591 | } |
582 | ++numCal; | 592 | ++numCal; |
583 | } | 593 | } |
584 | fc.sync(); | 594 | fc.sync(); |
585 | KPimPrefs::usrWriteConfig(); | 595 | KPimPrefs::usrWriteConfig(); |
586 | } | 596 | } |
587 | 597 | ||
588 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 598 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
589 | { | 599 | { |
590 | mCategoryColors.replace(cat,new QColor(color)); | 600 | mCategoryColors.replace(cat,new QColor(color)); |
591 | } | 601 | } |
592 | 602 | ||
593 | QColor *KOPrefs::categoryColor(QString cat) | 603 | QColor *KOPrefs::categoryColor(QString cat) |
594 | { | 604 | { |
595 | QColor *color = 0; | 605 | QColor *color = 0; |
596 | 606 | ||
597 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 607 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
598 | 608 | ||
599 | if (color) return color; | 609 | if (color) return color; |
600 | else return &mDefaultCategoryColor; | 610 | else return &mDefaultCategoryColor; |
601 | } | 611 | } |
602 | 612 | ||
603 | void KOPrefs::setFullName(const QString &name) | 613 | void KOPrefs::setFullName(const QString &name) |
604 | { | 614 | { |
605 | mName = name; | 615 | mName = name; |
606 | } | 616 | } |
607 | 617 | ||
608 | void KOPrefs::setEmail(const QString &email) | 618 | void KOPrefs::setEmail(const QString &email) |
609 | { | 619 | { |
610 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 620 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
611 | mEmail = email; | 621 | mEmail = email; |
612 | } | 622 | } |
613 | 623 | ||
614 | QString KOPrefs::fullName() | 624 | QString KOPrefs::fullName() |
615 | { | 625 | { |
616 | if (mEmailControlCenter) { | 626 | if (mEmailControlCenter) { |
617 | KEMailSettings settings; | 627 | KEMailSettings settings; |
618 | return settings.getSetting(KEMailSettings::RealName); | 628 | return settings.getSetting(KEMailSettings::RealName); |
619 | } else { | 629 | } else { |
620 | return mName; | 630 | return mName; |
621 | } | 631 | } |
622 | } | 632 | } |
623 | 633 | ||
624 | QString KOPrefs::email() | 634 | QString KOPrefs::email() |
625 | { | 635 | { |
626 | if (mEmailControlCenter) { | 636 | if (mEmailControlCenter) { |
627 | KEMailSettings settings; | 637 | KEMailSettings settings; |
628 | return settings.getSetting(KEMailSettings::EmailAddress); | 638 | return settings.getSetting(KEMailSettings::EmailAddress); |
629 | } else { | 639 | } else { |
630 | return mEmail; | 640 | return mEmail; |
631 | } | 641 | } |
632 | } | 642 | } |
633 | KConfig* KOPrefs::getConfig() | 643 | KConfig* KOPrefs::getConfig() |
634 | { | 644 | { |
635 | return config(); | 645 | return config(); |
636 | } | 646 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index bac8010..70da096 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -1,376 +1,377 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,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 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | 26 | ||
27 | #include <libkdepim/kpimprefs.h> | 27 | #include <libkdepim/kpimprefs.h> |
28 | #include <qdict.h> | 28 | #include <qdict.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qobject.h> | 30 | #include <qobject.h> |
31 | 31 | ||
32 | class KConfig; | 32 | class KConfig; |
33 | class QFont; | 33 | class QFont; |
34 | class QColor; | 34 | class QColor; |
35 | class QStringList; | 35 | class QStringList; |
36 | 36 | ||
37 | #define VIEW_WN_VIEW 1 | 37 | #define VIEW_WN_VIEW 1 |
38 | #define VIEW_NX_VIEW 2 | 38 | #define VIEW_NX_VIEW 2 |
39 | #define VIEW_J_VIEW 3 | 39 | #define VIEW_J_VIEW 3 |
40 | #define VIEW_A_VIEW 4 | 40 | #define VIEW_A_VIEW 4 |
41 | #define VIEW_ML_VIEW 5 | 41 | #define VIEW_ML_VIEW 5 |
42 | #define VIEW_M_VIEW 6 | 42 | #define VIEW_M_VIEW 6 |
43 | #define VIEW_L_VIEW 7 | 43 | #define VIEW_L_VIEW 7 |
44 | #define VIEW_T_VIEW 8 | 44 | #define VIEW_T_VIEW 8 |
45 | 45 | ||
46 | class KopiCalendarFile : public QObject | 46 | class KopiCalendarFile : public QObject |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | KopiCalendarFile( ) : QObject( ) | 49 | KopiCalendarFile( ) : QObject( ) |
50 | { | 50 | { |
51 | isStandard = false; | 51 | isStandard = false; |
52 | isEnabled = true; | 52 | isEnabled = true; |
53 | isAlarmEnabled = true; | 53 | isAlarmEnabled = true; |
54 | isReadOnly = false; | 54 | isReadOnly = false; |
55 | mName = "Calendar"; | 55 | mName = "Calendar"; |
56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; | 56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; |
57 | mSavedFileName = "icalfile.ics"; | 57 | mSavedFileName = "icalfile.ics"; |
58 | mCalNumber = 0; | 58 | mCalNumber = 0; |
59 | mDefaultColor = Qt::red; | 59 | mDefaultColor = Qt::red; |
60 | mErrorOnLoad = false; | 60 | mErrorOnLoad = false; |
61 | isRelative = false; | 61 | isRelative = false; |
62 | } | 62 | } |
63 | bool isStandard; | 63 | bool isStandard; |
64 | bool isEnabled; | 64 | bool isEnabled; |
65 | bool isAlarmEnabled; | 65 | bool isAlarmEnabled; |
66 | bool isReadOnly; | 66 | bool isReadOnly; |
67 | bool mErrorOnLoad; | 67 | bool mErrorOnLoad; |
68 | QString mName; | 68 | QString mName; |
69 | QString mFileName; | 69 | QString mFileName; |
70 | QString mSavedFileName; | 70 | QString mSavedFileName; |
71 | bool isRelative; | 71 | bool isRelative; |
72 | int mCalNumber; | 72 | int mCalNumber; |
73 | QColor mDefaultColor; | 73 | QColor mDefaultColor; |
74 | QDateTime mLoadDt; | 74 | QDateTime mLoadDt; |
75 | }; | 75 | }; |
76 | class KOPrefs : public KPimPrefs | 76 | class KOPrefs : public KPimPrefs |
77 | { | 77 | { |
78 | public: | 78 | public: |
79 | enum { FormatVCalendar, FormatICalendar }; | 79 | enum { FormatVCalendar, FormatICalendar }; |
80 | enum { MailClientKMail, MailClientSendmail }; | 80 | enum { MailClientKMail, MailClientSendmail }; |
81 | enum { IMIPDummy, IMIPKMail }; | 81 | enum { IMIPDummy, IMIPKMail }; |
82 | enum { IMIPOutbox, IMIPdirectsend }; | 82 | enum { IMIPOutbox, IMIPdirectsend }; |
83 | enum { neverAuto, addressbookAuto, selectedAuto }; | 83 | enum { neverAuto, addressbookAuto, selectedAuto }; |
84 | enum { standardDestination, askDestination }; | 84 | enum { standardDestination, askDestination }; |
85 | 85 | ||
86 | virtual ~KOPrefs(); | 86 | virtual ~KOPrefs(); |
87 | 87 | ||
88 | /** Get instance of KOPrefs. It is made sure that there is only one | 88 | /** Get instance of KOPrefs. It is made sure that there is only one |
89 | instance. */ | 89 | instance. */ |
90 | static KOPrefs *instance(); | 90 | static KOPrefs *instance(); |
91 | 91 | ||
92 | /** Set preferences to default values */ | 92 | /** Set preferences to default values */ |
93 | void usrSetDefaults(); | 93 | void usrSetDefaults(); |
94 | 94 | ||
95 | /** Read preferences from config file */ | 95 | /** Read preferences from config file */ |
96 | void usrReadConfig(); | 96 | void usrReadConfig(); |
97 | 97 | ||
98 | /** Write preferences to config file */ | 98 | /** Write preferences to config file */ |
99 | void usrWriteConfig(); | 99 | void usrWriteConfig(); |
100 | void setCategoryDefaults(); | 100 | void setCategoryDefaults(); |
101 | void setAllDefaults(); | 101 | void setAllDefaults(); |
102 | KopiCalendarFile * getNewCalendar(); | 102 | KopiCalendarFile * getNewCalendar(); |
103 | KopiCalendarFile * getCalendar( int ); | 103 | KopiCalendarFile * getCalendar( int ); |
104 | void deleteCalendar( int ); | 104 | void deleteCalendar( int ); |
105 | QColor defaultColor( int ) const; | 105 | QColor defaultColor( int ) const; |
106 | QString calName( int ) const; | 106 | QString calName( int ) const; |
107 | int getCalendarID( const QString & name ); | 107 | int getCalendarID( const QString & name ); |
108 | int getFuzzyCalendarID( const QString & name ); | ||
108 | protected: | 109 | protected: |
109 | void setTimeZoneIdDefault(); | 110 | void setTimeZoneIdDefault(); |
110 | 111 | ||
111 | /** Fill empty mail fields with default values. */ | 112 | /** Fill empty mail fields with default values. */ |
112 | void fillMailDefaults(); | 113 | void fillMailDefaults(); |
113 | 114 | ||
114 | private: | 115 | private: |
115 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 116 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
116 | object. */ | 117 | object. */ |
117 | KOPrefs(); | 118 | KOPrefs(); |
118 | 119 | ||
119 | static KOPrefs *mInstance; | 120 | static KOPrefs *mInstance; |
120 | QStringList getDefaultList(); | 121 | QStringList getDefaultList(); |
121 | QStringList getLocationDefaultList(); | 122 | QStringList getLocationDefaultList(); |
122 | public: | 123 | public: |
123 | // preferences data | 124 | // preferences data |
124 | KConfig* getConfig(); | 125 | KConfig* getConfig(); |
125 | void setFullName(const QString &); | 126 | void setFullName(const QString &); |
126 | QString fullName(); | 127 | QString fullName(); |
127 | void setEmail(const QString &); | 128 | void setEmail(const QString &); |
128 | QString email(); | 129 | QString email(); |
129 | 130 | ||
130 | QString mAdditional; | 131 | QString mAdditional; |
131 | 132 | ||
132 | bool mEmailControlCenter; | 133 | bool mEmailControlCenter; |
133 | 134 | ||
134 | bool mBcc; | 135 | bool mBcc; |
135 | bool mAutoSave; | 136 | bool mAutoSave; |
136 | int mAutoSaveInterval; | 137 | int mAutoSaveInterval; |
137 | bool mConfirm; | 138 | bool mConfirm; |
138 | 139 | ||
139 | bool mEnableGroupScheduling; | 140 | bool mEnableGroupScheduling; |
140 | bool mEnableProjectView; | 141 | bool mEnableProjectView; |
141 | 142 | ||
142 | int mDefaultFormat; | 143 | int mDefaultFormat; |
143 | int mMailClient; | 144 | int mMailClient; |
144 | 145 | ||
145 | int mStartTime; | 146 | int mStartTime; |
146 | int mDefaultDuration; | 147 | int mDefaultDuration; |
147 | int mAlarmTime; | 148 | int mAlarmTime; |
148 | 149 | ||
149 | int mWorkingHoursStart; | 150 | int mWorkingHoursStart; |
150 | int mWorkingHoursEnd; | 151 | int mWorkingHoursEnd; |
151 | bool mExcludeHolidays; | 152 | bool mExcludeHolidays; |
152 | bool mExcludeSaturdays; | 153 | bool mExcludeSaturdays; |
153 | bool mMarcusBainsShowSeconds; | 154 | bool mMarcusBainsShowSeconds; |
154 | 155 | ||
155 | QFont mTimeBarFont; | 156 | QFont mTimeBarFont; |
156 | QFont mMonthViewFont; | 157 | QFont mMonthViewFont; |
157 | QFont mAgendaViewFont; | 158 | QFont mAgendaViewFont; |
158 | QFont mMarcusBainsFont; | 159 | QFont mMarcusBainsFont; |
159 | QFont mTimeLabelsFont; | 160 | QFont mTimeLabelsFont; |
160 | QFont mTodoViewFont; | 161 | QFont mTodoViewFont; |
161 | QFont mListViewFont; | 162 | QFont mListViewFont; |
162 | QFont mDateNavigatorFont; | 163 | QFont mDateNavigatorFont; |
163 | QFont mEditBoxFont; | 164 | QFont mEditBoxFont; |
164 | QFont mJornalViewFont; | 165 | QFont mJornalViewFont; |
165 | QFont mWhatsNextFont; | 166 | QFont mWhatsNextFont; |
166 | QFont mEventViewFont; | 167 | QFont mEventViewFont; |
167 | 168 | ||
168 | 169 | ||
169 | 170 | ||
170 | 171 | ||
171 | QColor mHolidayColor; | 172 | QColor mHolidayColor; |
172 | QColor mHighlightColor; | 173 | QColor mHighlightColor; |
173 | QColor mEventColor; | 174 | QColor mEventColor; |
174 | QColor mTodoDoneColor; | 175 | QColor mTodoDoneColor; |
175 | QColor mAgendaBgColor; | 176 | QColor mAgendaBgColor; |
176 | QColor mWorkingHoursColor; | 177 | QColor mWorkingHoursColor; |
177 | QColor mTodoDueTodayColor; | 178 | QColor mTodoDueTodayColor; |
178 | QColor mTodoOverdueColor; | 179 | QColor mTodoOverdueColor; |
179 | QColor mTodoRunColor; | 180 | QColor mTodoRunColor; |
180 | QColor mMonthViewEvenColor; | 181 | QColor mMonthViewEvenColor; |
181 | QColor mMonthViewOddColor; | 182 | QColor mMonthViewOddColor; |
182 | QColor mMonthViewHolidayColor; | 183 | QColor mMonthViewHolidayColor; |
183 | bool mMonthViewUsesDayColors; | 184 | bool mMonthViewUsesDayColors; |
184 | bool mMonthViewSatSunTog; | 185 | bool mMonthViewSatSunTog; |
185 | bool mMonthViewWeek; | 186 | bool mMonthViewWeek; |
186 | bool mMonthViewWeekRowlayout; | 187 | bool mMonthViewWeekRowlayout; |
187 | QColor mAppColor1; | 188 | QColor mAppColor1; |
188 | QColor mAppColor2; | 189 | QColor mAppColor2; |
189 | bool mUseAppColors; | 190 | bool mUseAppColors; |
190 | 191 | ||
191 | int mDayBegins; | 192 | int mDayBegins; |
192 | int mHourSize; | 193 | int mHourSize; |
193 | int mAllDaySize; | 194 | int mAllDaySize; |
194 | bool mShowFullMenu; | 195 | bool mShowFullMenu; |
195 | bool mDailyRecur; | 196 | bool mDailyRecur; |
196 | bool mWeeklyRecur; | 197 | bool mWeeklyRecur; |
197 | bool mLongAllday; | 198 | bool mLongAllday; |
198 | bool mMonthDailyRecur; | 199 | bool mMonthDailyRecur; |
199 | bool mMonthWeeklyRecur; | 200 | bool mMonthWeeklyRecur; |
200 | bool mMonthShowIcons; | 201 | bool mMonthShowIcons; |
201 | bool mMonthShowTimes; | 202 | bool mMonthShowTimes; |
202 | bool mMonthShowShort; | 203 | bool mMonthShowShort; |
203 | bool mEnableToolTips; | 204 | bool mEnableToolTips; |
204 | bool mEnableMonthScroll; | 205 | bool mEnableMonthScroll; |
205 | bool mFullViewMonth; | 206 | bool mFullViewMonth; |
206 | bool mMonthViewUsesCategoryColor; | 207 | bool mMonthViewUsesCategoryColor; |
207 | bool mFullViewTodo; | 208 | bool mFullViewTodo; |
208 | bool mShowCompletedTodo; | 209 | bool mShowCompletedTodo; |
209 | bool mMarcusBainsEnabled; | 210 | bool mMarcusBainsEnabled; |
210 | int mNextXDays; | 211 | int mNextXDays; |
211 | int mWhatsNextDays; | 212 | int mWhatsNextDays; |
212 | bool mWhatsNextTime2Lines; | 213 | bool mWhatsNextTime2Lines; |
213 | int mWhatsNextPrios; | 214 | int mWhatsNextPrios; |
214 | bool mEnableQuickTodo; | 215 | bool mEnableQuickTodo; |
215 | 216 | ||
216 | bool mCompactDialogs; | 217 | bool mCompactDialogs; |
217 | bool mVerticalScreen; | 218 | bool mVerticalScreen; |
218 | 219 | ||
219 | bool mShowIconNewTodo; | 220 | bool mShowIconNewTodo; |
220 | bool mShowIconNewEvent; | 221 | bool mShowIconNewEvent; |
221 | bool mShowIconSearch; | 222 | bool mShowIconSearch; |
222 | bool mShowIconList; | 223 | bool mShowIconList; |
223 | bool mShowIconDay1; | 224 | bool mShowIconDay1; |
224 | bool mShowIconDay5; | 225 | bool mShowIconDay5; |
225 | bool mShowIconDay6; | 226 | bool mShowIconDay6; |
226 | bool mShowIconDay7; | 227 | bool mShowIconDay7; |
227 | bool mShowIconMonth; | 228 | bool mShowIconMonth; |
228 | bool mShowIconTodoview; | 229 | bool mShowIconTodoview; |
229 | bool mShowIconBackFast; | 230 | bool mShowIconBackFast; |
230 | bool mShowIconBack; | 231 | bool mShowIconBack; |
231 | bool mShowIconToday; | 232 | bool mShowIconToday; |
232 | bool mShowIconForward; | 233 | bool mShowIconForward; |
233 | bool mShowIconForwardFast; | 234 | bool mShowIconForwardFast; |
234 | bool mShowIconWhatsThis; | 235 | bool mShowIconWhatsThis; |
235 | bool mShowIconWeekNum; | 236 | bool mShowIconWeekNum; |
236 | bool mShowIconNextDays; | 237 | bool mShowIconNextDays; |
237 | bool mShowIconNext; | 238 | bool mShowIconNext; |
238 | bool mShowIconJournal; | 239 | bool mShowIconJournal; |
239 | bool mShowIconFilter; | 240 | bool mShowIconFilter; |
240 | bool mShowIconOnetoolbar; | 241 | bool mShowIconOnetoolbar; |
241 | bool mShowIconNavigator; | 242 | bool mShowIconNavigator; |
242 | bool mShowIconAllday; | 243 | bool mShowIconAllday; |
243 | bool mShowIconFilterview; | 244 | bool mShowIconFilterview; |
244 | bool mShowIconToggleFull; | 245 | bool mShowIconToggleFull; |
245 | 246 | ||
246 | bool mShowIconStretch; | 247 | bool mShowIconStretch; |
247 | 248 | ||
248 | bool mToolBarHor; | 249 | bool mToolBarHor; |
249 | bool mToolBarUp; | 250 | bool mToolBarUp; |
250 | bool mToolBarHorV; | 251 | bool mToolBarHorV; |
251 | bool mToolBarUpV; | 252 | bool mToolBarUpV; |
252 | bool mToolBarHorN; | 253 | bool mToolBarHorN; |
253 | bool mToolBarUpN; | 254 | bool mToolBarUpN; |
254 | bool mToolBarHorF; | 255 | bool mToolBarHorF; |
255 | bool mToolBarUpF; | 256 | bool mToolBarUpF; |
256 | bool mToolBarMiniIcons; | 257 | bool mToolBarMiniIcons; |
257 | 258 | ||
258 | bool mAskForQuit; | 259 | bool mAskForQuit; |
259 | bool mUsePassWd; | 260 | bool mUsePassWd; |
260 | bool mShowSyncEvents; | 261 | bool mShowSyncEvents; |
261 | bool mShowTodoInAgenda; | 262 | bool mShowTodoInAgenda; |
262 | bool mShowCompletedTodoInAgenda; | 263 | bool mShowCompletedTodoInAgenda; |
263 | bool mShowTimeInAgenda; | 264 | bool mShowTimeInAgenda; |
264 | bool mHideNonStartedTodos; | 265 | bool mHideNonStartedTodos; |
265 | 266 | ||
266 | bool mBlockPopupMenu; | 267 | bool mBlockPopupMenu; |
267 | 268 | ||
268 | int mLastSyncTime; | 269 | int mLastSyncTime; |
269 | void setCategoryColor(QString cat,const QColor & color); | 270 | void setCategoryColor(QString cat,const QColor & color); |
270 | QColor *categoryColor(QString cat); | 271 | QColor *categoryColor(QString cat); |
271 | 272 | ||
272 | QString mArchiveFile; | 273 | QString mArchiveFile; |
273 | QString mHtmlExportFile; | 274 | QString mHtmlExportFile; |
274 | bool mHtmlWithSave; | 275 | bool mHtmlWithSave; |
275 | 276 | ||
276 | QStringList mSelectedPlugins; | 277 | QStringList mSelectedPlugins; |
277 | 278 | ||
278 | QString mLastImportFile; | 279 | QString mLastImportFile; |
279 | QString mLastVcalFile; | 280 | QString mLastVcalFile; |
280 | QString mLastSaveFile; | 281 | QString mLastSaveFile; |
281 | QString mLastLoadFile; | 282 | QString mLastLoadFile; |
282 | 283 | ||
283 | 284 | ||
284 | QString mDefaultAlarmFile; | 285 | QString mDefaultAlarmFile; |
285 | int mIMIPScheduler; | 286 | int mIMIPScheduler; |
286 | int mIMIPSend; | 287 | int mIMIPSend; |
287 | QStringList mAdditionalMails; | 288 | QStringList mAdditionalMails; |
288 | int mIMIPAutoRefresh; | 289 | int mIMIPAutoRefresh; |
289 | int mIMIPAutoInsertReply; | 290 | int mIMIPAutoInsertReply; |
290 | int mIMIPAutoInsertRequest; | 291 | int mIMIPAutoInsertRequest; |
291 | int mIMIPAutoFreeBusy; | 292 | int mIMIPAutoFreeBusy; |
292 | int mIMIPAutoFreeBusyReply; | 293 | int mIMIPAutoFreeBusyReply; |
293 | 294 | ||
294 | QStringList mTodoTemplates; | 295 | QStringList mTodoTemplates; |
295 | QStringList mEventTemplates; | 296 | QStringList mEventTemplates; |
296 | 297 | ||
297 | int mDestination; | 298 | int mDestination; |
298 | 299 | ||
299 | 300 | ||
300 | bool mEditOnDoubleClick; | 301 | bool mEditOnDoubleClick; |
301 | bool mViewChangeHoldFullscreen; | 302 | bool mViewChangeHoldFullscreen; |
302 | bool mViewChangeHoldNonFullscreen; | 303 | bool mViewChangeHoldNonFullscreen; |
303 | bool mCenterOnCurrentTime; | 304 | bool mCenterOnCurrentTime; |
304 | bool mSetTimeToDayStartAt; | 305 | bool mSetTimeToDayStartAt; |
305 | bool mHighlightCurrentDay; | 306 | bool mHighlightCurrentDay; |
306 | bool mUseHighlightLightColor; | 307 | bool mUseHighlightLightColor; |
307 | bool mListViewMonthTimespan; | 308 | bool mListViewMonthTimespan; |
308 | bool mWNViewShowsParents; | 309 | bool mWNViewShowsParents; |
309 | bool mWNViewShowsPast; | 310 | bool mWNViewShowsPast; |
310 | bool mWNViewShowLocation; | 311 | bool mWNViewShowLocation; |
311 | bool mTodoViewShowsPercentage; | 312 | bool mTodoViewShowsPercentage; |
312 | bool mTodoViewUsesCatColors; | 313 | bool mTodoViewUsesCatColors; |
313 | bool mMonthViewUsesBigFont; | 314 | bool mMonthViewUsesBigFont; |
314 | bool mTodoViewUsesSmallFont; | 315 | bool mTodoViewUsesSmallFont; |
315 | bool mTodoViewUsesForegroundColor; | 316 | bool mTodoViewUsesForegroundColor; |
316 | bool mMonthViewUsesForegroundColor; | 317 | bool mMonthViewUsesForegroundColor; |
317 | 318 | ||
318 | bool mHightlightDateTimeEdit; | 319 | bool mHightlightDateTimeEdit; |
319 | bool mShortDateInViewer; | 320 | bool mShortDateInViewer; |
320 | 321 | ||
321 | bool mShowDateNavigator; | 322 | bool mShowDateNavigator; |
322 | 323 | ||
323 | QStringList mLocationDefaults; | 324 | QStringList mLocationDefaults; |
324 | QStringList mEventSummaryUser; | 325 | QStringList mEventSummaryUser; |
325 | QStringList mTodoSummaryUser; | 326 | QStringList mTodoSummaryUser; |
326 | QStringList mJournalSummaryUser; | 327 | QStringList mJournalSummaryUser; |
327 | 328 | ||
328 | bool mUseInternalAlarmNotification; | 329 | bool mUseInternalAlarmNotification; |
329 | int mAlarmPlayBeeps; | 330 | int mAlarmPlayBeeps; |
330 | int mAlarmSuspendTime; | 331 | int mAlarmSuspendTime; |
331 | int mAlarmSuspendCount; | 332 | int mAlarmSuspendCount; |
332 | int mAlarmBeepInterval; | 333 | int mAlarmBeepInterval; |
333 | int mOldLanguage; | 334 | int mOldLanguage; |
334 | int mOldLoadedLanguage; | 335 | int mOldLoadedLanguage; |
335 | 336 | ||
336 | 337 | ||
337 | QString mActiveSyncPort; | 338 | QString mActiveSyncPort; |
338 | QString mActiveSyncIP; | 339 | QString mActiveSyncIP; |
339 | 340 | ||
340 | // settings for eventviewer | 341 | // settings for eventviewer |
341 | bool mEVshowDetails; | 342 | bool mEVshowDetails; |
342 | bool mEVshowCreated; | 343 | bool mEVshowCreated; |
343 | bool mEVshowChanged; | 344 | bool mEVshowChanged; |
344 | bool mWTshowDetails; | 345 | bool mWTshowDetails; |
345 | bool mWTshowCreated; | 346 | bool mWTshowCreated; |
346 | bool mWTshowChanged; | 347 | bool mWTshowChanged; |
347 | 348 | ||
348 | int mCurrentDisplayedView; | 349 | int mCurrentDisplayedView; |
349 | QPtrList<KopiCalendarFile> mCalendars; | 350 | QPtrList<KopiCalendarFile> mCalendars; |
350 | int mNextAvailableCalendar; | 351 | int mNextAvailableCalendar; |
351 | bool mGlobalUpdateDisabled; | 352 | bool mGlobalUpdateDisabled; |
352 | 353 | ||
353 | 354 | ||
354 | bool mDetectConflicts; | 355 | bool mDetectConflicts; |
355 | bool mIncludeFree; | 356 | bool mIncludeFree; |
356 | bool mCheckConflictsAllDayAllDay; | 357 | bool mCheckConflictsAllDayAllDay; |
357 | bool mCheckConflictsAllDayNonAD; | 358 | bool mCheckConflictsAllDayNonAD; |
358 | bool mCheckConflictsNonADAllDay; | 359 | bool mCheckConflictsNonADAllDay; |
359 | bool mCheckConflictsNonADNonAD; | 360 | bool mCheckConflictsNonADNonAD; |
360 | QString mFilterConflictEditItem; | 361 | QString mFilterConflictEditItem; |
361 | QString mFilterConflictAllItem; | 362 | QString mFilterConflictAllItem; |
362 | 363 | ||
363 | private: | 364 | private: |
364 | QDict<QColor> mCategoryColors; | 365 | QDict<QColor> mCategoryColors; |
365 | QArray<KopiCalendarFile*> mDefCalColors; | 366 | QArray<KopiCalendarFile*> mDefCalColors; |
366 | QColor mDefaultCategoryColor; | 367 | QColor mDefaultCategoryColor; |
367 | 368 | ||
368 | QFont mDefaultTimeBarFont; | 369 | QFont mDefaultTimeBarFont; |
369 | QFont mDefaultViewFont; | 370 | QFont mDefaultViewFont; |
370 | QFont mDefaultMonthViewFont; | 371 | QFont mDefaultMonthViewFont; |
371 | 372 | ||
372 | QString mName; | 373 | QString mName; |
373 | QString mEmail; | 374 | QString mEmail; |
374 | }; | 375 | }; |
375 | 376 | ||
376 | #endif | 377 | #endif |