author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /korganizer/calendarview.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | korganizer/calendarview.cpp | 148 |
1 files changed, 77 insertions, 71 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8385bcc..c1a2f76 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,1019 +1,1025 @@ | |||
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) savecale1997, 1998, 1999 | 7 | Copyright (c) savecale1997, 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 <q3buttongroup.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 <q3progressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <q3multilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <q3widgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <q3ptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <q3groupbox.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 | //Added by qt3to4: | ||
52 | #include <Q3VBoxLayout> | ||
53 | #include <QKeyEvent> | ||
54 | #include <Q3Frame> | ||
55 | #include <QLabel> | ||
56 | #include <Q3ValueList> | ||
51 | #endif | 57 | #endif |
52 | 58 | ||
53 | #include <kglobal.h> | 59 | #include <kglobal.h> |
54 | #include <kdebug.h> | 60 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 61 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 62 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 63 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 64 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 65 | #include <kconfig.h> |
60 | 66 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 67 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 68 | #include <krun.h> |
63 | #include <kdirwatch.h> | 69 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 70 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 71 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 72 | #include <libkdepim/kpimglobalprefs.h> |
67 | 73 | ||
68 | #include <libkcal/vcaldrag.h> | 74 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 75 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 76 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 77 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 78 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 79 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 80 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 81 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 82 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 83 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 84 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 85 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 86 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 87 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 88 | #include "../kalarmd/alarmdialog.h" |
83 | 89 | ||
84 | #ifndef DESKTOP_VERSION | 90 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 91 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 92 | #include <externalapphandler.h> |
87 | #endif | 93 | #endif |
88 | #include <libkcal/phoneformat.h> | 94 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 95 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 96 | #include "komailclient.h" |
91 | #endif | 97 | #endif |
92 | #ifndef KORG_NOPRINTER | 98 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 99 | #include "calprinter.h" |
94 | #endif | 100 | #endif |
95 | #ifndef KORG_NOPLUGINS | 101 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 102 | #include "kocore.h" |
97 | #endif | 103 | #endif |
98 | #include "koeventeditor.h" | 104 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 105 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 106 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 107 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 108 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 109 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 110 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 111 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 112 | #include "koagendaview.h" |
107 | #include "koagenda.h" | 113 | #include "koagenda.h" |
108 | #include "kodialogmanager.h" | 114 | #include "kodialogmanager.h" |
109 | #include "outgoingdialog.h" | 115 | #include "outgoingdialog.h" |
110 | #include "incomingdialog.h" | 116 | #include "incomingdialog.h" |
111 | #include "datenavigatorcontainer.h" | 117 | #include "datenavigatorcontainer.h" |
112 | #include "statusdialog.h" | 118 | #include "statusdialog.h" |
113 | #include "kdatenavigator.h" | 119 | #include "kdatenavigator.h" |
114 | #include "kotodoview.h" | 120 | #include "kotodoview.h" |
115 | #include "datenavigator.h" | 121 | #include "datenavigator.h" |
116 | #include "resourceview.h" | 122 | #include "resourceview.h" |
117 | #include "navigatorbar.h" | 123 | #include "navigatorbar.h" |
118 | #include "searchdialog.h" | 124 | #include "searchdialog.h" |
119 | #include "mainwindow.h" | 125 | #include "mainwindow.h" |
120 | #include "categoryeditdialog.h" | 126 | #include "categoryeditdialog.h" |
121 | 127 | ||
122 | #include "calendarview.h" | 128 | #include "calendarview.h" |
123 | #ifndef DESKTOP_VERSION | 129 | #ifndef DESKTOP_VERSION |
124 | #include <qtopia/alarmserver.h> | 130 | #include <qtopia/alarmserver.h> |
125 | #endif | 131 | #endif |
126 | #ifndef _WIN32_ | 132 | #ifndef _WIN32_ |
127 | #include <stdlib.h> | 133 | #include <stdlib.h> |
128 | #include <stdio.h> | 134 | #include <stdio.h> |
129 | #include <unistd.h> | 135 | #include <unistd.h> |
130 | #else | 136 | #else |
131 | #include <qprocess.h> | 137 | #include <q3process.h> |
132 | #endif | 138 | #endif |
133 | 139 | ||
134 | #ifdef DESKTOP_VERSION | 140 | #ifdef DESKTOP_VERSION |
135 | #include <kabc/stdaddressbook.h> | 141 | #include <kabc/stdaddressbook.h> |
136 | #endif | 142 | #endif |
137 | using namespace KOrg; | 143 | using namespace KOrg; |
138 | using namespace KCal; | 144 | using namespace KCal; |
139 | extern int globalFlagBlockAgenda; | 145 | extern int globalFlagBlockAgenda; |
140 | extern int globalFlagBlockStartup; | 146 | extern int globalFlagBlockStartup; |
141 | 147 | ||
142 | 148 | ||
143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 149 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, Q3PtrList<Incidence> alarms,QDateTime start ) : Q3TextBrowser(parent) |
144 | 150 | ||
145 | { | 151 | { |
146 | mAlarms = alarms; | 152 | mAlarms = alarms; |
147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 153 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
148 | QString mText = "<table width=\"100%\">\n"; | 154 | QString mText = "<table width=\"100%\">\n"; |
149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 155 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
150 | #ifdef DESKTOP_VERSION | 156 | #ifdef DESKTOP_VERSION |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 157 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
152 | #else | 158 | #else |
153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 159 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
154 | #endif | 160 | #endif |
155 | // mText += "<img src=\""; | 161 | // mText += "<img src=\""; |
156 | // mText += ipath; | 162 | // mText += ipath; |
157 | // mText += "\">"; | 163 | // mText += "\">"; |
158 | //mEventDate = QDate::currentDate(); | 164 | //mEventDate = QDate::currentDate(); |
159 | #ifdef DESKTOP_VERSION | 165 | #ifdef DESKTOP_VERSION |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 166 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
161 | #else | 167 | #else |
162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 168 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
163 | #endif | 169 | #endif |
164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 170 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
165 | 171 | ||
166 | Incidence * inc = getNextInc( start ); | 172 | Incidence * inc = getNextInc( start ); |
167 | int time = 0; | 173 | int time = 0; |
168 | //mText += "<table>"; | 174 | //mText += "<table>"; |
169 | while ( inc ) { | 175 | while ( inc ) { |
170 | QDateTime dt ; | 176 | QDateTime dt ; |
171 | QString tempText = "<a "; | 177 | QString tempText = "<a "; |
172 | bool ok; | 178 | bool ok; |
173 | dt = inc->getNextOccurence( start, &ok ); | 179 | dt = inc->getNextOccurence( start, &ok ); |
174 | if ( !ok ) continue; | 180 | if ( !ok ) continue; |
175 | if ( inc->typeID() == eventID ) { | 181 | if ( inc->typeID() == eventID ) { |
176 | tempText += "href=\"event:"; | 182 | tempText += "href=\"event:"; |
177 | } else if ( inc->typeID() == todoID ) { | 183 | } else if ( inc->typeID() == todoID ) { |
178 | tempText += "href=\"todo:"; | 184 | tempText += "href=\"todo:"; |
179 | } | 185 | } |
180 | tempText += inc->uid() + "\">"; | 186 | tempText += inc->uid() + "\">"; |
181 | if ( inc->typeID() == todoID ) | 187 | if ( inc->typeID() == todoID ) |
182 | tempText += i18n("Todo: "); | 188 | tempText += i18n("Todo: "); |
183 | if ( inc->summary().length() > 0 ) | 189 | if ( inc->summary().length() > 0 ) |
184 | tempText += inc->summary(); | 190 | tempText += inc->summary(); |
185 | else | 191 | else |
186 | tempText += i18n("-no summary-"); | 192 | tempText += i18n("-no summary-"); |
187 | QString timestr; | 193 | QString timestr; |
188 | if (!inc->doesFloat()) | 194 | if (!inc->doesFloat()) |
189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 195 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | else | 196 | else |
191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 197 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 198 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 199 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
194 | mText += "<table>"; | 200 | mText += "<table>"; |
195 | time = 1; | 201 | time = 1; |
196 | } | 202 | } |
197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 203 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
198 | if ( time > 0 ) | 204 | if ( time > 0 ) |
199 | mText +="</table>"; | 205 | mText +="</table>"; |
200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 206 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
201 | mText += "<table>"; | 207 | mText += "<table>"; |
202 | time = 2; | 208 | time = 2; |
203 | 209 | ||
204 | } | 210 | } |
205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 211 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
206 | if ( time > 0 ) | 212 | if ( time > 0 ) |
207 | mText +="</table>"; | 213 | mText +="</table>"; |
208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 214 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
209 | mText += "<table>"; | 215 | mText += "<table>"; |
210 | time = 3; | 216 | time = 3; |
211 | } | 217 | } |
212 | mText +="<tr><td><b>"; | 218 | mText +="<tr><td><b>"; |
213 | mText += timestr; | 219 | mText += timestr; |
214 | mText += "</b></td><td>"; | 220 | mText += "</b></td><td>"; |
215 | mText += tempText; | 221 | mText += tempText; |
216 | mText += "</td></tr>\n"; | 222 | mText += "</td></tr>\n"; |
217 | inc = getNextInc( start ); | 223 | inc = getNextInc( start ); |
218 | } | 224 | } |
219 | mText +="</table>"; | 225 | mText +="</table>"; |
220 | setText( mText ); | 226 | setText( mText ); |
221 | } | 227 | } |
222 | 228 | ||
223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 229 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
224 | { | 230 | { |
225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 231 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
226 | } | 232 | } |
227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 233 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
228 | { | 234 | { |
229 | QDateTime dt ; | 235 | QDateTime dt ; |
230 | Incidence * retInc; | 236 | Incidence * retInc; |
231 | Incidence * inc = mAlarms.first(); | 237 | Incidence * inc = mAlarms.first(); |
232 | if ( inc == 0 ) | 238 | if ( inc == 0 ) |
233 | return 0; | 239 | return 0; |
234 | bool ok; | 240 | bool ok; |
235 | dt = inc->getNextOccurence( start, &ok ); | 241 | dt = inc->getNextOccurence( start, &ok ); |
236 | if ( ! ok ) return 0; | 242 | if ( ! ok ) return 0; |
237 | QDateTime dtn ; | 243 | QDateTime dtn ; |
238 | retInc = inc; | 244 | retInc = inc; |
239 | inc = mAlarms.next(); | 245 | inc = mAlarms.next(); |
240 | while ( inc ) { | 246 | while ( inc ) { |
241 | dtn = inc->getNextOccurence( start, &ok ); | 247 | dtn = inc->getNextOccurence( start, &ok ); |
242 | if ( ! ok ) return 0; | 248 | if ( ! ok ) return 0; |
243 | if ( dtn < dt ) { | 249 | if ( dtn < dt ) { |
244 | dt = dtn; | 250 | dt = dtn; |
245 | retInc = inc; | 251 | retInc = inc; |
246 | } | 252 | } |
247 | inc = mAlarms.next(); | 253 | inc = mAlarms.next(); |
248 | } | 254 | } |
249 | mAlarms.remove( retInc ); | 255 | mAlarms.remove( retInc ); |
250 | return retInc; | 256 | return retInc; |
251 | 257 | ||
252 | } | 258 | } |
253 | void MissedAlarmTextBrowser::setSource(const QString & n) | 259 | void MissedAlarmTextBrowser::setSource(const QString & n) |
254 | { | 260 | { |
255 | if (n.startsWith("event:")) { | 261 | if (n.startsWith("event:")) { |
256 | #ifdef DESKTOP_VERSION | 262 | #ifdef DESKTOP_VERSION |
257 | emit showIncidence(n.mid(8)); | 263 | emit showIncidence(n.mid(8)); |
258 | #else | 264 | #else |
259 | emit showIncidence(n.mid(6)); | 265 | emit showIncidence(n.mid(6)); |
260 | #endif | 266 | #endif |
261 | return; | 267 | return; |
262 | } else if (n.startsWith("todo:")) { | 268 | } else if (n.startsWith("todo:")) { |
263 | #ifdef DESKTOP_VERSION | 269 | #ifdef DESKTOP_VERSION |
264 | emit showIncidence(n.mid(7)); | 270 | emit showIncidence(n.mid(7)); |
265 | #else | 271 | #else |
266 | emit showIncidence(n.mid(5)); | 272 | emit showIncidence(n.mid(5)); |
267 | #endif | 273 | #endif |
268 | return; | 274 | return; |
269 | } | 275 | } |
270 | } | 276 | } |
271 | 277 | ||
272 | 278 | ||
273 | class KOBeamPrefs : public QDialog | 279 | class KOBeamPrefs : public QDialog |
274 | { | 280 | { |
275 | public: | 281 | public: |
276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 282 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
277 | QDialog( parent, name, true ) | 283 | QDialog( parent, name, true ) |
278 | { | 284 | { |
279 | setCaption( i18n("Beam Options") ); | 285 | setCaption( i18n("Beam Options") ); |
280 | QVBoxLayout* lay = new QVBoxLayout( this ); | 286 | Q3VBoxLayout* lay = new Q3VBoxLayout( this ); |
281 | lay->setSpacing( 3 ); | 287 | lay->setSpacing( 3 ); |
282 | lay->setMargin( 3 ); | 288 | lay->setMargin( 3 ); |
283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 289 | Q3ButtonGroup* format = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("File format"), this ); |
284 | lay->addWidget( format ); | 290 | lay->addWidget( format ); |
285 | format->setExclusive ( true ) ; | 291 | format->setExclusive ( true ) ; |
286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 292 | Q3ButtonGroup* time = new Q3ButtonGroup(1, Qt::Horizontal, i18n("Time format"), this ); |
287 | lay->addWidget( time ); time->setExclusive ( true ) ; | 293 | lay->addWidget( time ); time->setExclusive ( true ) ; |
288 | vcal = new QRadioButton(" vCalendar ", format ); | 294 | vcal = new QRadioButton(" vCalendar ", format ); |
289 | ical = new QRadioButton(" iCalendar ", format ); | 295 | ical = new QRadioButton(" iCalendar ", format ); |
290 | vcal->setChecked( true ); | 296 | vcal->setChecked( true ); |
291 | tz = new QRadioButton(i18n(" With timezone "), time ); | 297 | tz = new QRadioButton(i18n(" With timezone "), time ); |
292 | local = new QRadioButton(i18n(" Local time "), time ); | 298 | local = new QRadioButton(i18n(" Local time "), time ); |
293 | tz->setChecked( true ); | 299 | tz->setChecked( true ); |
294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 300 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
295 | lay->addWidget( ok ); | 301 | lay->addWidget( ok ); |
296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 302 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
297 | lay->addWidget( cancel ); | 303 | lay->addWidget( cancel ); |
298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 304 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 305 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
300 | resize( 200, 200 ); | 306 | resize( 200, 200 ); |
301 | } | 307 | } |
302 | 308 | ||
303 | bool beamVcal() { return vcal->isChecked(); } | 309 | bool beamVcal() { return vcal->isChecked(); } |
304 | bool beamLocal() { return local->isChecked(); } | 310 | bool beamLocal() { return local->isChecked(); } |
305 | private: | 311 | private: |
306 | QRadioButton* vcal, *ical, *local, *tz; | 312 | QRadioButton* vcal, *ical, *local, *tz; |
307 | }; | 313 | }; |
308 | class KOCatPrefs : public QDialog | 314 | class KOCatPrefs : public QDialog |
309 | { | 315 | { |
310 | public: | 316 | public: |
311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 317 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
312 | QDialog( parent, name, true ) | 318 | QDialog( parent, name, true ) |
313 | { | 319 | { |
314 | setCaption( i18n("Manage new Categories") ); | 320 | setCaption( i18n("Manage new Categories") ); |
315 | QVBoxLayout* lay = new QVBoxLayout( this ); | 321 | Q3VBoxLayout* lay = new Q3VBoxLayout( this ); |
316 | lay->setSpacing( 3 ); | 322 | lay->setSpacing( 3 ); |
317 | lay->setMargin( 3 ); | 323 | 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 ); | 324 | 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 ); | 325 | lay->addWidget( lab ); |
320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 326 | Q3ButtonGroup* format = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("New categories not in list:"), this ); |
321 | lay->addWidget( format ); | 327 | lay->addWidget( format ); |
322 | format->setExclusive ( true ) ; | 328 | format->setExclusive ( true ) ; |
323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 329 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 330 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
325 | addCatBut->setChecked( true ); | 331 | addCatBut->setChecked( true ); |
326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 332 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
327 | lay->addWidget( ok ); | 333 | lay->addWidget( ok ); |
328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 334 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
329 | lay->addWidget( cancel ); | 335 | lay->addWidget( cancel ); |
330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 336 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 337 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
332 | resize( 200, 200 ); | 338 | resize( 200, 200 ); |
333 | } | 339 | } |
334 | 340 | ||
335 | bool addCat() { return addCatBut->isChecked(); } | 341 | bool addCat() { return addCatBut->isChecked(); } |
336 | private: | 342 | private: |
337 | QRadioButton* addCatBut; | 343 | QRadioButton* addCatBut; |
338 | }; | 344 | }; |
339 | 345 | ||
340 | 346 | ||
341 | 347 | ||
342 | CalendarView::CalendarView( CalendarResources *calendar, | 348 | CalendarView::CalendarView( CalendarResources *calendar, |
343 | QWidget *parent, const char *name ) | 349 | QWidget *parent, const char *name ) |
344 | : CalendarViewBase( parent, name ), | 350 | : CalendarViewBase( parent, name ), |
345 | mCalendar( calendar ), | 351 | mCalendar( calendar ), |
346 | mResourceManager( calendar->resourceManager() ) | 352 | mResourceManager( calendar->resourceManager() ) |
347 | { | 353 | { |
348 | 354 | ||
349 | mEventEditor = 0; | 355 | mEventEditor = 0; |
350 | mTodoEditor = 0; | 356 | mTodoEditor = 0; |
351 | 357 | ||
352 | init(); | 358 | init(); |
353 | } | 359 | } |
354 | 360 | ||
355 | CalendarView::CalendarView( Calendar *calendar, | 361 | CalendarView::CalendarView( Calendar *calendar, |
356 | QWidget *parent, const char *name ) | 362 | QWidget *parent, const char *name ) |
357 | : CalendarViewBase( parent, name ), | 363 | : CalendarViewBase( parent, name ), |
358 | mCalendar( calendar ), | 364 | mCalendar( calendar ), |
359 | mResourceManager( 0 ) | 365 | mResourceManager( 0 ) |
360 | { | 366 | { |
361 | 367 | ||
362 | mEventEditor = 0; | 368 | mEventEditor = 0; |
363 | mTodoEditor = 0; | 369 | mTodoEditor = 0; |
364 | init(); | 370 | init(); |
365 | } | 371 | } |
366 | 372 | ||
367 | void CalendarView::init() | 373 | void CalendarView::init() |
368 | { | 374 | { |
369 | mMultiResourceSync = false; | 375 | mMultiResourceSync = false; |
370 | flag_blockConflict = false; | 376 | flag_blockConflict = false; |
371 | flag_blockScrollBar = false; | 377 | flag_blockScrollBar = false; |
372 | flag_checkFileFirsttime = true; | 378 | flag_checkFileFirsttime = true; |
373 | flag_clearallviewsEventDisplay = false; | 379 | flag_clearallviewsEventDisplay = false; |
374 | flag_clearallviewsupdateView = false; | 380 | flag_clearallviewsupdateView = false; |
375 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 381 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
376 | setFocusPolicy (NoFocus ); | 382 | setFocusPolicy (Qt::NoFocus ); |
377 | mViewerCallerIsSearchDialog = false; | 383 | mViewerCallerIsSearchDialog = false; |
378 | mBlockShowDates = false; | 384 | mBlockShowDates = false; |
379 | mConflictingEvent = 0; | 385 | mConflictingEvent = 0; |
380 | mDatePickerMode = 0; | 386 | mDatePickerMode = 0; |
381 | mCurrentSyncDevice = ""; | 387 | mCurrentSyncDevice = ""; |
382 | mViewManager = new KOViewManager( this ); | 388 | mViewManager = new KOViewManager( this ); |
383 | mDialogManager = new KODialogManager( this ); | 389 | mDialogManager = new KODialogManager( this ); |
384 | mEventViewerDialog = 0; | 390 | mEventViewerDialog = 0; |
385 | mModified = false; | 391 | mModified = false; |
386 | mReadOnly = false; | 392 | mReadOnly = false; |
387 | mSelectedIncidence = 0; | 393 | mSelectedIncidence = 0; |
388 | mCalPrinter = 0; | 394 | mCalPrinter = 0; |
389 | mFilters.setAutoDelete(true); | 395 | mFilters.setAutoDelete(true); |
390 | 396 | ||
391 | mCalendar->registerObserver( this ); | 397 | mCalendar->registerObserver( this ); |
392 | // TODO: Make sure that view is updated, when calendar is changed. | 398 | // TODO: Make sure that view is updated, when calendar is changed. |
393 | 399 | ||
394 | mStorage = new FileStorage( mCalendar ); | 400 | mStorage = new FileStorage( mCalendar ); |
395 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 401 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
396 | 402 | ||
397 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 403 | Q3BoxLayout *topLayout = (Q3BoxLayout*)layout(); |
398 | #ifndef KORG_NOSPLITTER | 404 | #ifndef KORG_NOSPLITTER |
399 | // create the main layout frames. | 405 | // create the main layout frames. |
400 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 406 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
401 | topLayout->addWidget(mPanner); | 407 | topLayout->addWidget(mPanner); |
402 | 408 | ||
403 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 409 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
404 | "CalendarView::LeftFrame"); | 410 | "CalendarView::LeftFrame"); |
405 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 411 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
406 | 412 | ||
407 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 413 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
408 | "CalendarView::DateNavigator" ); | 414 | "CalendarView::DateNavigator" ); |
409 | 415 | ||
410 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 416 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
411 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 417 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
412 | mTodoList->setNavigator( mNavigator ); | 418 | mTodoList->setNavigator( mNavigator ); |
413 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 419 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
414 | 420 | ||
415 | #ifdef KORG_NORESOURCEVIEW | 421 | #ifdef KORG_NORESOURCEVIEW |
416 | mResourceView = 0; | 422 | mResourceView = 0; |
417 | #else | 423 | #else |
418 | if ( mResourceManager ) { | 424 | if ( mResourceManager ) { |
419 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 425 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
420 | mResourceView->updateView(); | 426 | mResourceView->updateView(); |
421 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 427 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
422 | SLOT( updateView() ) ); | 428 | SLOT( updateView() ) ); |
423 | } else { | 429 | } else { |
424 | mResourceView = 0; | 430 | mResourceView = 0; |
425 | } | 431 | } |
426 | #endif | 432 | #endif |
427 | QWidget *rightBox = new QWidget( mPanner ); | 433 | QWidget *rightBox = new QWidget( mPanner ); |
428 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 434 | Q3BoxLayout *rightLayout = new Q3VBoxLayout( rightBox ); |
429 | 435 | ||
430 | mRightFrame = new QWidgetStack( rightBox ); | 436 | mRightFrame = new Q3WidgetStack( rightBox ); |
431 | rightLayout->addWidget( mRightFrame, 1 ); | 437 | rightLayout->addWidget( mRightFrame, 1 ); |
432 | 438 | ||
433 | mLeftFrame = mLeftSplitter; | 439 | mLeftFrame = mLeftSplitter; |
434 | #else | 440 | #else |
435 | //QWidget *mainBox = new QWidget( this ); | 441 | //QWidget *mainBox = new QWidget( this ); |
436 | //QWidget *leftFrame = new QWidget( mainBox ); | 442 | //QWidget *leftFrame = new QWidget( mainBox ); |
437 | //QBoxLayout * mainBoxLayout; | 443 | //QBoxLayout * mainBoxLayout; |
438 | if ( KOPrefs::instance()->mVerticalScreen ) { | 444 | if ( KOPrefs::instance()->mVerticalScreen ) { |
439 | //mainBoxLayout = new QVBoxLayout(mainBox); | 445 | //mainBoxLayout = new QVBoxLayout(mainBox); |
440 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 446 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 447 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 448 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 449 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 450 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
445 | } else { | 451 | } else { |
446 | //mainBoxLayout = new QHBoxLayout(mainBox); | 452 | //mainBoxLayout = new QHBoxLayout(mainBox); |
447 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 453 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
448 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 454 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
449 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 455 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
450 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 456 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
451 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 457 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
452 | } | 458 | } |
453 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 459 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
454 | //QBoxLayout * leftFrameLayout; | 460 | //QBoxLayout * leftFrameLayout; |
455 | topLayout->addWidget( mMainFrame ); | 461 | topLayout->addWidget( mMainFrame ); |
456 | #ifdef DESKTOP_VERSION | 462 | #ifdef DESKTOP_VERSION |
457 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 463 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,Qt::Horizontal, this ); |
458 | topLayout->addWidget( mDateScrollBar ); | 464 | topLayout->addWidget( mDateScrollBar ); |
459 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 465 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
460 | if ( QApplication::desktop()->width() < 800 ) | 466 | if ( QApplication::desktop()->width() < 800 ) |
461 | mDateScrollBar->hide(); | 467 | mDateScrollBar->hide(); |
462 | #endif | 468 | #endif |
463 | //mainBoxLayout->addWidget (mLeftFrame); | 469 | //mainBoxLayout->addWidget (mLeftFrame); |
464 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 470 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
465 | "CalendarView::DateNavigator" ); | 471 | "CalendarView::DateNavigator" ); |
466 | #if 0 | 472 | #if 0 |
467 | // FIXME | 473 | // FIXME |
468 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 474 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
469 | "CalendarView::DateNavigator", QDate::currentDate()); | 475 | "CalendarView::DateNavigator", QDate::currentDate()); |
470 | #endif | 476 | #endif |
471 | // mDateNavigator->blockSignals( true ); | 477 | // mDateNavigator->blockSignals( true ); |
472 | //leftFrameLayout->addWidget( mDateNavigator ); | 478 | //leftFrameLayout->addWidget( mDateNavigator ); |
473 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 479 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
474 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 480 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
475 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 481 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
476 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 482 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
477 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 483 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
478 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 484 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
479 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 485 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
480 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 486 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
481 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 487 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
482 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 488 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
483 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 489 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
484 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 490 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
485 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 491 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
486 | connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); | 492 | connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); |
487 | 493 | ||
488 | 494 | ||
489 | mTodoList->setNavigator( mNavigator ); | 495 | mTodoList->setNavigator( mNavigator ); |
490 | #if 0 | 496 | #if 0 |
491 | if ( QApplication::desktop()->width() < 480 ) { | 497 | if ( QApplication::desktop()->width() < 480 ) { |
492 | leftFrameLayout->addWidget(mFilterView); | 498 | leftFrameLayout->addWidget(mFilterView); |
493 | leftFrameLayout->addWidget(mTodoList, 2 ); | 499 | leftFrameLayout->addWidget(mTodoList, 2 ); |
494 | 500 | ||
495 | } else { | 501 | } else { |
496 | leftFrameLayout->addWidget(mTodoList,2 ); | 502 | leftFrameLayout->addWidget(mTodoList,2 ); |
497 | leftFrameLayout->addWidget(mFilterView ); | 503 | leftFrameLayout->addWidget(mFilterView ); |
498 | } | 504 | } |
499 | #endif | 505 | #endif |
500 | mFilterView->hide(); | 506 | mFilterView->hide(); |
501 | mCalEditView->hide(); | 507 | mCalEditView->hide(); |
502 | QWidget *rightBox = new QWidget( mMainFrame ); | 508 | QWidget *rightBox = new QWidget( mMainFrame ); |
503 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 509 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
504 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 510 | Q3BoxLayout *rightLayout = new Q3VBoxLayout( rightBox ); |
505 | mRightFrame = new QWidgetStack( rightBox ); | 511 | mRightFrame = new Q3WidgetStack( rightBox ); |
506 | rightLayout->addWidget( mRightFrame, 10 ); | 512 | rightLayout->addWidget( mRightFrame, 10 ); |
507 | 513 | ||
508 | //mLeftFrame = (QWidget *)leftFrame; | 514 | //mLeftFrame = (QWidget *)leftFrame; |
509 | if ( KOPrefs::instance()->mVerticalScreen ) { | 515 | if ( KOPrefs::instance()->mVerticalScreen ) { |
510 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 516 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
511 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 517 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
512 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 518 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
513 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 519 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
514 | } else { | 520 | } else { |
515 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 521 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
516 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 522 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
517 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 523 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
518 | } | 524 | } |
519 | if ( !KOPrefs::instance()->mShowDateNavigator) | 525 | if ( !KOPrefs::instance()->mShowDateNavigator) |
520 | mDateNavigator->hide(); | 526 | mDateNavigator->hide(); |
521 | //qDebug("Calendarview Size %d %d ", width(), height()); | 527 | //qDebug("Calendarview Size %d %d ", width(), height()); |
522 | #endif | 528 | #endif |
523 | 529 | ||
524 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 530 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
525 | SLOT( showDates( const KCal::DateList & ) ) ); | 531 | SLOT( showDates( const KCal::DateList & ) ) ); |
526 | 532 | ||
527 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 533 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
528 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 534 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
529 | 535 | ||
530 | 536 | ||
531 | 537 | ||
532 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 538 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
533 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 539 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
534 | 540 | ||
535 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 541 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
536 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 542 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
537 | 543 | ||
538 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 544 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
539 | mNavigator, SLOT( selectPreviousYear() ) ); | 545 | mNavigator, SLOT( selectPreviousYear() ) ); |
540 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 546 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
541 | mNavigator, SLOT( selectNextYear() ) ); | 547 | mNavigator, SLOT( selectNextYear() ) ); |
542 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 548 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
543 | mNavigator, SLOT( selectPreviousMonth() ) ); | 549 | mNavigator, SLOT( selectPreviousMonth() ) ); |
544 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 550 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
545 | mNavigator, SLOT( selectNextMonth() ) ); | 551 | mNavigator, SLOT( selectNextMonth() ) ); |
546 | 552 | ||
547 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 553 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
548 | mNavigator, SLOT( selectPrevious() ) ); | 554 | mNavigator, SLOT( selectPrevious() ) ); |
549 | connect( mDateNavigator, SIGNAL( goNext() ), | 555 | connect( mDateNavigator, SIGNAL( goNext() ), |
550 | mNavigator, SLOT( selectNext() ) ); | 556 | mNavigator, SLOT( selectNext() ) ); |
551 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 557 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
552 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 558 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
553 | 559 | ||
554 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 560 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
555 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 561 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
556 | #if 0 | 562 | #if 0 |
557 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 563 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
558 | SLOT( incidenceAdded( Incidence *) ) ); | 564 | SLOT( incidenceAdded( Incidence *) ) ); |
559 | #endif | 565 | #endif |
560 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 566 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
561 | 567 | ||
562 | connect( this, SIGNAL( configChanged() ), | 568 | connect( this, SIGNAL( configChanged() ), |
563 | mDateNavigator, SLOT( updateConfig() ) ); | 569 | mDateNavigator, SLOT( updateConfig() ) ); |
564 | 570 | ||
565 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 571 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
566 | SLOT( newTodo() ) ); | 572 | SLOT( newTodo() ) ); |
567 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 573 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
568 | SLOT( newSubTodo( Todo * ) ) ); | 574 | SLOT( newSubTodo( Todo * ) ) ); |
569 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 575 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
570 | SLOT( editTodo( Todo * ) ) ); | 576 | SLOT( editTodo( Todo * ) ) ); |
571 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 577 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
572 | SLOT( showTodo( Todo *) ) ); | 578 | SLOT( showTodo( Todo *) ) ); |
573 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 579 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
574 | SLOT( deleteTodo( Todo *) ) ); | 580 | SLOT( deleteTodo( Todo *) ) ); |
575 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 581 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
576 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 582 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
577 | SLOT( purgeCompleted() ) ); | 583 | SLOT( purgeCompleted() ) ); |
578 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 584 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
579 | SIGNAL( todoModified( Todo *, int ) ) ); | 585 | SIGNAL( todoModified( Todo *, int ) ) ); |
580 | 586 | ||
581 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 587 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
582 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 588 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
583 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 589 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
584 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 590 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
585 | 591 | ||
586 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 592 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
587 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 593 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
588 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 594 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
589 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 595 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
590 | 596 | ||
591 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 597 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
592 | this, SLOT ( todo_unsub( Todo * ) ) ); | 598 | this, SLOT ( todo_unsub( Todo * ) ) ); |
593 | 599 | ||
594 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 600 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
595 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 601 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
596 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 602 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
597 | SLOT( updateTodo( Todo *, int ) ) ); | 603 | SLOT( updateTodo( Todo *, int ) ) ); |
598 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 604 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
599 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 605 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
600 | 606 | ||
601 | 607 | ||
602 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 608 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
603 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 609 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
604 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 610 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
605 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 611 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
606 | 612 | ||
607 | 613 | ||
608 | 614 | ||
609 | 615 | ||
610 | 616 | ||
611 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 617 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
612 | SLOT(checkClipboard())); | 618 | SLOT(checkClipboard())); |
613 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 619 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
614 | SLOT( processTodoListSelection( Incidence * ) ) ); | 620 | SLOT( processTodoListSelection( Incidence * ) ) ); |
615 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 621 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
616 | 622 | ||
617 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 623 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
618 | 624 | ||
619 | mDateFrame = new QVBox(0,0,WType_Popup); | 625 | mDateFrame = new Q3VBox(0,0,Qt::WType_Popup); |
620 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 626 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
621 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 627 | mDateFrame->setFrameStyle( Q3Frame::WinPanel |Q3Frame::Raised ); |
622 | mDateFrame->setLineWidth(3); | 628 | mDateFrame->setLineWidth(3); |
623 | mDateFrame->hide(); | 629 | mDateFrame->hide(); |
624 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 630 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
625 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 631 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
626 | 632 | ||
627 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 633 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
628 | 634 | ||
629 | mEventEditor = mDialogManager->getEventEditor(); | 635 | mEventEditor = mDialogManager->getEventEditor(); |
630 | mTodoEditor = mDialogManager->getTodoEditor(); | 636 | mTodoEditor = mDialogManager->getTodoEditor(); |
631 | 637 | ||
632 | mFlagEditDescription = false; | 638 | mFlagEditDescription = false; |
633 | 639 | ||
634 | mSuspendTimer = new QTimer( this ); | 640 | mSuspendTimer = new QTimer( this ); |
635 | mAlarmTimer = new QTimer( this ); | 641 | mAlarmTimer = new QTimer( this ); |
636 | mRecheckAlarmTimer = new QTimer( this ); | 642 | mRecheckAlarmTimer = new QTimer( this ); |
637 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 643 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
638 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 644 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
639 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 645 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
640 | mAlarmDialog = new AlarmDialog( this ); | 646 | mAlarmDialog = new AlarmDialog( this ); |
641 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 647 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
642 | mAlarmDialog->setServerNotification( false ); | 648 | mAlarmDialog->setServerNotification( false ); |
643 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 649 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
644 | 650 | ||
645 | 651 | ||
646 | #ifndef DESKTOP_VERSION | 652 | #ifndef DESKTOP_VERSION |
647 | //US listen for arriving address resultsets | 653 | //US listen for arriving address resultsets |
648 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 654 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
649 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 655 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
650 | #endif | 656 | #endif |
651 | mDateNavigator->setCalendar( mCalendar ); | 657 | mDateNavigator->setCalendar( mCalendar ); |
652 | } | 658 | } |
653 | 659 | ||
654 | 660 | ||
655 | CalendarView::~CalendarView() | 661 | CalendarView::~CalendarView() |
656 | { | 662 | { |
657 | // kdDebug() << "~CalendarView()" << endl; | 663 | // kdDebug() << "~CalendarView()" << endl; |
658 | //qDebug("CalendarView::~CalendarView() "); | 664 | //qDebug("CalendarView::~CalendarView() "); |
659 | delete mDialogManager; | 665 | delete mDialogManager; |
660 | delete mViewManager; | 666 | delete mViewManager; |
661 | delete mStorage; | 667 | delete mStorage; |
662 | delete mDateFrame ; | 668 | delete mDateFrame ; |
663 | delete mEventViewerDialog; | 669 | delete mEventViewerDialog; |
664 | //kdDebug() << "~CalendarView() done" << endl; | 670 | //kdDebug() << "~CalendarView() done" << endl; |
665 | } | 671 | } |
666 | 672 | ||
667 | 673 | ||
668 | void CalendarView::nextConflict( bool all, bool allday ) | 674 | void CalendarView::nextConflict( bool all, bool allday ) |
669 | { | 675 | { |
670 | if ( flag_blockConflict ) return; | 676 | if ( flag_blockConflict ) return; |
671 | flag_blockConflict = true; | 677 | flag_blockConflict = true; |
672 | QPtrList<Event> testlist = mCalendar->events(); | 678 | Q3PtrList<Event> testlist = mCalendar->events(); |
673 | Event * test = testlist.first(); | 679 | Event * test = testlist.first(); |
674 | while ( test ) { | 680 | while ( test ) { |
675 | test->setTagged( false ); | 681 | test->setTagged( false ); |
676 | test = testlist.next(); | 682 | test = testlist.next(); |
677 | } | 683 | } |
678 | QTime st ( 0,0,0); | 684 | QTime st ( 0,0,0); |
679 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 685 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
680 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 686 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
681 | //qDebug("time %s ", st.toString().latin1()); | 687 | //qDebug("time %s ", st.toString().latin1()); |
682 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 688 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
683 | QDateTime conflict; | 689 | QDateTime conflict; |
684 | QDateTime retVal; | 690 | QDateTime retVal; |
685 | bool found = false; | 691 | bool found = false; |
686 | Event * cE = 0; | 692 | Event * cE = 0; |
687 | Event * cE2 = 0; | 693 | Event * cE2 = 0; |
688 | QPtrList<Event> testlist2 = testlist; | 694 | Q3PtrList<Event> testlist2 = testlist; |
689 | test = testlist.first(); | 695 | test = testlist.first(); |
690 | bool skip = false; | 696 | bool skip = false; |
691 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 697 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
692 | //QTime tm; | 698 | //QTime tm; |
693 | //tm.start(); | 699 | //tm.start(); |
694 | while ( test ) { | 700 | while ( test ) { |
695 | qApp->processEvents(); | 701 | qApp->processEvents(); |
696 | skip = false; | 702 | skip = false; |
697 | if ( !all ) skip = ( allday != test->doesFloat() ); | 703 | if ( !all ) skip = ( allday != test->doesFloat() ); |
698 | if ( !skip ) { | 704 | if ( !skip ) { |
699 | if ( found ) | 705 | if ( found ) |
700 | skip = !test->matchTime( &startDT, &conflict ); | 706 | skip = !test->matchTime( &startDT, &conflict ); |
701 | else | 707 | else |
702 | skip = !test->matchTime( &startDT, 0 ); | 708 | skip = !test->matchTime( &startDT, 0 ); |
703 | } | 709 | } |
704 | if ( !skip ) { | 710 | if ( !skip ) { |
705 | Event * test2 = testlist2.first(); | 711 | Event * test2 = testlist2.first(); |
706 | while ( test2 ) { | 712 | while ( test2 ) { |
707 | skip = test2->isTagged(); | 713 | skip = test2->isTagged(); |
708 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); | 714 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); |
709 | if ( !skip ) { | 715 | if ( !skip ) { |
710 | if ( found ) | 716 | if ( found ) |
711 | skip = !test2->matchTime( &startDT, &conflict ); | 717 | skip = !test2->matchTime( &startDT, &conflict ); |
712 | else | 718 | else |
713 | skip = !test2->matchTime( &startDT, 0 ); | 719 | skip = !test2->matchTime( &startDT, 0 ); |
714 | } | 720 | } |
715 | if ( !skip ) { | 721 | if ( !skip ) { |
716 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 722 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
717 | //qDebug("overlap "); | 723 | //qDebug("overlap "); |
718 | if ( ! found ) { | 724 | if ( ! found ) { |
719 | if ( retVal >= startDT ) { | 725 | if ( retVal >= startDT ) { |
720 | conflict = retVal; | 726 | conflict = retVal; |
721 | cE = test; | 727 | cE = test; |
722 | cE2 = test2; | 728 | cE2 = test2; |
723 | found = true; | 729 | found = true; |
724 | } | 730 | } |
725 | } else { | 731 | } else { |
726 | if ( retVal >= startDT && retVal < conflict ) { | 732 | if ( retVal >= startDT && retVal < conflict ) { |
727 | conflict = retVal; | 733 | conflict = retVal; |
728 | cE = test; | 734 | cE = test; |
729 | cE2 = test2; | 735 | cE2 = test2; |
730 | } | 736 | } |
731 | } | 737 | } |
732 | } | 738 | } |
733 | } | 739 | } |
734 | test2 = testlist2.next(); | 740 | test2 = testlist2.next(); |
735 | } | 741 | } |
736 | } | 742 | } |
737 | test->setTagged( true ); | 743 | test->setTagged( true ); |
738 | test = testlist.next(); | 744 | test = testlist.next(); |
739 | } | 745 | } |
740 | //qDebug("Search time : %d", tm.elapsed()); | 746 | //qDebug("Search time : %d", tm.elapsed()); |
741 | if ( found ) { | 747 | if ( found ) { |
742 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 748 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
743 | mViewManager->showDayView(); | 749 | mViewManager->showDayView(); |
744 | mNavigator->slotDaySelect( conflict.date() ); | 750 | mNavigator->slotDaySelect( conflict.date() ); |
745 | int hour = conflict.time().hour(); | 751 | int hour = conflict.time().hour(); |
746 | mViewManager->agendaView()->setStartHour( hour ); | 752 | mViewManager->agendaView()->setStartHour( hour ); |
747 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 753 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
748 | flag_blockConflict = false; | 754 | flag_blockConflict = false; |
749 | return; | 755 | return; |
750 | } | 756 | } |
751 | 757 | ||
752 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 758 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
753 | //qDebug("No conflict found "); | 759 | //qDebug("No conflict found "); |
754 | flag_blockConflict = false; | 760 | flag_blockConflict = false; |
755 | return; | 761 | return; |
756 | } | 762 | } |
757 | 763 | ||
758 | void CalendarView::conflictAll() | 764 | void CalendarView::conflictAll() |
759 | { | 765 | { |
760 | nextConflict ( true, true ); | 766 | nextConflict ( true, true ); |
761 | } | 767 | } |
762 | void CalendarView::conflictAllday() | 768 | void CalendarView::conflictAllday() |
763 | { | 769 | { |
764 | nextConflict ( false, true ); | 770 | nextConflict ( false, true ); |
765 | } | 771 | } |
766 | void CalendarView::conflictNotAll() | 772 | void CalendarView::conflictNotAll() |
767 | { | 773 | { |
768 | nextConflict ( false, false ); | 774 | nextConflict ( false, false ); |
769 | } | 775 | } |
770 | 776 | ||
771 | void CalendarView::setCalReadOnly( int id, bool readO ) | 777 | void CalendarView::setCalReadOnly( int id, bool readO ) |
772 | { | 778 | { |
773 | if ( readO ) { | 779 | if ( readO ) { |
774 | emit save(); | 780 | emit save(); |
775 | } | 781 | } |
776 | mCalendar->setReadOnly( id, readO ); | 782 | mCalendar->setReadOnly( id, readO ); |
777 | } | 783 | } |
778 | void CalendarView::setScrollBarStep(int val ) | 784 | void CalendarView::setScrollBarStep(int val ) |
779 | { | 785 | { |
780 | #ifdef DESKTOP_VERSION | 786 | #ifdef DESKTOP_VERSION |
781 | mDateScrollBar->setLineStep ( val ); | 787 | mDateScrollBar->setLineStep ( val ); |
782 | #else | 788 | #else |
783 | Q_UNUSED( val ); | 789 | Q_UNUSED( val ); |
784 | #endif | 790 | #endif |
785 | } | 791 | } |
786 | void CalendarView::scrollBarValue(int val ) | 792 | void CalendarView::scrollBarValue(int val ) |
787 | { | 793 | { |
788 | #ifdef DESKTOP_VERSION | 794 | #ifdef DESKTOP_VERSION |
789 | if ( QApplication::desktop()->width() < 800 ) return; | 795 | if ( QApplication::desktop()->width() < 800 ) return; |
790 | if ( flag_blockScrollBar ) return; | 796 | if ( flag_blockScrollBar ) return; |
791 | flag_blockScrollBar = true; | 797 | flag_blockScrollBar = true; |
792 | int count = mNavigator->selectedDates().count(); | 798 | int count = mNavigator->selectedDates().count(); |
793 | int day = mNavigator->selectedDates().first().dayOfYear(); | 799 | int day = mNavigator->selectedDates().first().dayOfYear(); |
794 | int stepdays = val; | 800 | int stepdays = val; |
795 | if ( mDateScrollBar->lineStep () <= count ) { | 801 | if ( mDateScrollBar->lineStep () <= count ) { |
796 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 802 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
797 | //qDebug("VAL %d ",val ); | 803 | //qDebug("VAL %d ",val ); |
798 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 804 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
799 | stepdays = day+stepdays; | 805 | stepdays = day+stepdays; |
800 | if ( stepdays < 0 ) stepdays = 0; | 806 | if ( stepdays < 0 ) stepdays = 0; |
801 | } | 807 | } |
802 | if ( stepdays == day ) { | 808 | if ( stepdays == day ) { |
803 | flag_blockScrollBar = false; | 809 | flag_blockScrollBar = false; |
804 | return; | 810 | return; |
805 | } | 811 | } |
806 | int year = mNavigator->selectedDates().first().year(); | 812 | int year = mNavigator->selectedDates().first().year(); |
807 | QDate d ( year,1,1 ); | 813 | QDate d ( year,1,1 ); |
808 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 814 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
809 | flag_blockScrollBar = false; | 815 | flag_blockScrollBar = false; |
810 | #else | 816 | #else |
811 | Q_UNUSED( val ); | 817 | Q_UNUSED( val ); |
812 | #endif | 818 | #endif |
813 | 819 | ||
814 | } | 820 | } |
815 | void CalendarView::updateView(const QDate &start, const QDate &end) | 821 | void CalendarView::updateView(const QDate &start, const QDate &end) |
816 | { | 822 | { |
817 | #ifdef DESKTOP_VERSION | 823 | #ifdef DESKTOP_VERSION |
818 | if ( ! mDateScrollBar->draggingSlider () ) { | 824 | if ( ! mDateScrollBar->draggingSlider () ) { |
819 | int dof = start.dayOfYear(); | 825 | int dof = start.dayOfYear(); |
820 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 826 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
821 | if ( dof != mDateScrollBar->value() ) { | 827 | if ( dof != mDateScrollBar->value() ) { |
822 | mDateScrollBar->blockSignals( true ); | 828 | mDateScrollBar->blockSignals( true ); |
823 | mDateScrollBar->setValue( start.dayOfYear()); | 829 | mDateScrollBar->setValue( start.dayOfYear()); |
824 | mDateScrollBar->blockSignals( false ); | 830 | mDateScrollBar->blockSignals( false ); |
825 | } | 831 | } |
826 | } | 832 | } |
827 | #endif | 833 | #endif |
828 | mTodoList->updateView(); | 834 | mTodoList->updateView(); |
829 | mViewManager->updateView(start, end); | 835 | mViewManager->updateView(start, end); |
830 | //mDateNavigator->updateView(); | 836 | //mDateNavigator->updateView(); |
831 | } | 837 | } |
832 | 838 | ||
833 | 839 | ||
834 | 840 | ||
835 | void CalendarView::checkFiles() | 841 | void CalendarView::checkFiles() |
836 | { | 842 | { |
837 | QString message; | 843 | QString message; |
838 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 844 | Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
839 | KopiCalendarFile * cal = calendars.first(); | 845 | KopiCalendarFile * cal = calendars.first(); |
840 | while ( cal ) { | 846 | while ( cal ) { |
841 | if ( cal->mErrorOnLoad ) { | 847 | if ( cal->mErrorOnLoad ) { |
842 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 848 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
843 | } | 849 | } |
844 | cal = calendars.next(); | 850 | cal = calendars.next(); |
845 | } | 851 | } |
846 | if ( !message.isEmpty() ) { | 852 | if ( !message.isEmpty() ) { |
847 | 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); | 853 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
848 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); | 854 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); |
849 | } | 855 | } |
850 | if ( flag_checkFileFirsttime ) { | 856 | if ( flag_checkFileFirsttime ) { |
851 | flag_checkFileFirsttime = false; | 857 | flag_checkFileFirsttime = false; |
852 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 858 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
853 | } | 859 | } |
854 | } | 860 | } |
855 | void CalendarView::checkAlarms() | 861 | void CalendarView::checkAlarms() |
856 | { | 862 | { |
857 | KConfig *config = KOGlobals::config(); | 863 | KConfig *config = KOGlobals::config(); |
858 | config->setGroup( "AppRun" ); | 864 | config->setGroup( "AppRun" ); |
859 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 865 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
860 | int daysto = dt.daysTo( QDate::currentDate() ); | 866 | int daysto = dt.daysTo( (QDateTime)QDate::currentDate() ); |
861 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 867 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
862 | dt = dt.addDays( days ); | 868 | dt = dt.addDays( days ); |
863 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 869 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
864 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 870 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
865 | //qDebug("KO: Reading program stop %d ", secs); | 871 | //qDebug("KO: Reading program stop %d ", secs); |
866 | //secs -= ( 3600 * 24*3 ); // debug only | 872 | //secs -= ( 3600 * 24*3 ); // debug only |
867 | QDateTime latest = dt.addSecs ( secs ); | 873 | QDateTime latest = dt.addSecs ( secs ); |
868 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 874 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
869 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 875 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
870 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 876 | Q3PtrList<Incidence> el = mCalendar->rawIncidences(); |
871 | QPtrList<Incidence> al; | 877 | Q3PtrList<Incidence> al; |
872 | Incidence* inL = el.first(); | 878 | Incidence* inL = el.first(); |
873 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 879 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
874 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 880 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
875 | while ( inL ) { | 881 | while ( inL ) { |
876 | bool ok = false; | 882 | bool ok = false; |
877 | int offset = 0; | 883 | int offset = 0; |
878 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 884 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
879 | if ( ok ) { | 885 | if ( ok ) { |
880 | //qDebug("OK %s",next.toString().latin1()); | 886 | //qDebug("OK %s",next.toString().latin1()); |
881 | if ( next < cur ) { | 887 | if ( next < cur ) { |
882 | al.append( inL ); | 888 | al.append( inL ); |
883 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 889 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
884 | } | 890 | } |
885 | } | 891 | } |
886 | inL = el.next(); | 892 | inL = el.next(); |
887 | } | 893 | } |
888 | if ( al.count() ) { | 894 | if ( al.count() ) { |
889 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 895 | QDialog* dia = new QDialog( this, "huhu", false, Qt::WDestructiveClose | Qt::WStyle_StaysOnTop ); |
890 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 896 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
891 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 897 | Q3VBoxLayout* lay = new Q3VBoxLayout( dia ); |
892 | lay->setSpacing( 0 ); | 898 | lay->setSpacing( 0 ); |
893 | lay->setMargin( 0 ); | 899 | lay->setMargin( 0 ); |
894 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 900 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
895 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 901 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
896 | lay->addWidget( matb ); | 902 | lay->addWidget( matb ); |
897 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 903 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
898 | int wid = 210; | 904 | int wid = 210; |
899 | int x = QApplication::desktop()->width() - wid - 7; | 905 | int x = QApplication::desktop()->width() - wid - 7; |
900 | int y = QApplication::desktop()->height() - wid - 70; | 906 | int y = QApplication::desktop()->height() - wid - 70; |
901 | dia->setGeometry ( x,y,wid,wid); | 907 | dia->setGeometry ( x,y,wid,wid); |
902 | } else { | 908 | } else { |
903 | int si = 220; | 909 | int si = 220; |
904 | if ( QApplication::desktop()->width() > 470 ) | 910 | if ( QApplication::desktop()->width() > 470 ) |
905 | si = 400; | 911 | si = 400; |
906 | dia->resize(si,si/2); | 912 | dia->resize(si,si/2); |
907 | } | 913 | } |
908 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 914 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
909 | dia->show(); | 915 | dia->show(); |
910 | 916 | ||
911 | } | 917 | } |
912 | #if 0 | 918 | #if 0 |
913 | // for creating timetracker test data | 919 | // for creating timetracker test data |
914 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); | 920 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); |
915 | Todo * nt; | 921 | Todo * nt; |
916 | mCalendar->close(); | 922 | mCalendar->close(); |
917 | { | 923 | { |
918 | Todo * root1 = new Todo; | 924 | Todo * root1 = new Todo; |
919 | mCalendar->addTodo( root1 ); | 925 | mCalendar->addTodo( root1 ); |
920 | root1->setSummary( "Project1"); | 926 | root1->setSummary( "Project1"); |
921 | root1->setPriority( 1 ); | 927 | root1->setPriority( 1 ); |
922 | root1->setCategories( QString( "Cat_Pro1") ); | 928 | root1->setCategories( QString( "Cat_Pro1") ); |
923 | root1->setDescription( "This is a test description of a root Project" ); | 929 | root1->setDescription( "This is a test description of a root Project" ); |
924 | root1->setPercentComplete( 20 ); | 930 | root1->setPercentComplete( 20 ); |
925 | updateView(); | 931 | updateView(); |
926 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 932 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
927 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 933 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
928 | 934 | ||
929 | nt = new Todo; | 935 | nt = new Todo; |
930 | mCalendar->addTodo( nt ); | 936 | mCalendar->addTodo( nt ); |
931 | nt->setSummary( "Planning Project1"); | 937 | nt->setSummary( "Planning Project1"); |
932 | nt->setPriority( 1 ); | 938 | nt->setPriority( 1 ); |
933 | nt->setDescription( "This is a test description of Planning Project1" ); | 939 | nt->setDescription( "This is a test description of Planning Project1" ); |
934 | nt->setPercentComplete( 20 ); | 940 | nt->setPercentComplete( 20 ); |
935 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); | 941 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); |
936 | 942 | ||
937 | 943 | ||
938 | Todo * sub1 = nt; | 944 | Todo * sub1 = nt; |
939 | sub1->setRelatedTo( root1 ); | 945 | sub1->setRelatedTo( root1 ); |
940 | 946 | ||
941 | nt = new Todo; | 947 | nt = new Todo; |
942 | mCalendar->addTodo( nt ); | 948 | mCalendar->addTodo( nt ); |
943 | nt->setSummary( "Planning Project1: Lutz"); | 949 | nt->setSummary( "Planning Project1: Lutz"); |
944 | nt->setPriority( 1 ); | 950 | nt->setPriority( 1 ); |
945 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 951 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
946 | nt->setPercentComplete( 20 ); | 952 | nt->setPercentComplete( 20 ); |
947 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); | 953 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); |
948 | Todo * workLutz11 = nt; | 954 | Todo * workLutz11 = nt; |
949 | workLutz11->setRelatedTo( sub1 ); | 955 | workLutz11->setRelatedTo( sub1 ); |
950 | 956 | ||
951 | nt = new Todo; | 957 | nt = new Todo; |
952 | mCalendar->addTodo( nt ); | 958 | mCalendar->addTodo( nt ); |
953 | nt->setSummary( "Planning Project1: Norbert"); | 959 | nt->setSummary( "Planning Project1: Norbert"); |
954 | nt->setPriority( 1 ); | 960 | nt->setPriority( 1 ); |
955 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 961 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
956 | nt->setPercentComplete( 20 ); | 962 | nt->setPercentComplete( 20 ); |
957 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); | 963 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); |
958 | Todo * workNorbert11 = nt; | 964 | Todo * workNorbert11 = nt; |
959 | workNorbert11->setRelatedTo( sub1 ); | 965 | workNorbert11->setRelatedTo( sub1 ); |
960 | 966 | ||
961 | nt = new Todo; | 967 | nt = new Todo; |
962 | mCalendar->addTodo( nt ); | 968 | mCalendar->addTodo( nt ); |
963 | nt->setSummary( "Work on 1"); | 969 | nt->setSummary( "Work on 1"); |
964 | nt->setPriority( 1 ); | 970 | nt->setPriority( 1 ); |
965 | nt->setDescription( "This is a test description of Work Project_1" ); | 971 | nt->setDescription( "This is a test description of Work Project_1" ); |
966 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); | 972 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); |
967 | nt->setPercentComplete( 20 ); | 973 | nt->setPercentComplete( 20 ); |
968 | 974 | ||
969 | Todo * sub2 = nt; | 975 | Todo * sub2 = nt; |
970 | sub2->setRelatedTo( root1 ); | 976 | sub2->setRelatedTo( root1 ); |
971 | 977 | ||
972 | 978 | ||
973 | nt = new Todo; | 979 | nt = new Todo; |
974 | mCalendar->addTodo( nt ); | 980 | mCalendar->addTodo( nt ); |
975 | nt->setSummary( "Work on 1: Lutz"); | 981 | nt->setSummary( "Work on 1: Lutz"); |
976 | nt->setPriority( 1 ); | 982 | nt->setPriority( 1 ); |
977 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 983 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
978 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); | 984 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); |
979 | nt->setPercentComplete( 20 ); | 985 | nt->setPercentComplete( 20 ); |
980 | Todo * workLutz12 = nt; | 986 | Todo * workLutz12 = nt; |
981 | workLutz12->setRelatedTo( sub2 ); | 987 | workLutz12->setRelatedTo( sub2 ); |
982 | 988 | ||
983 | nt = new Todo; | 989 | nt = new Todo; |
984 | mCalendar->addTodo( nt ); | 990 | mCalendar->addTodo( nt ); |
985 | nt->setSummary( "Work on 1: Norbert"); | 991 | nt->setSummary( "Work on 1: Norbert"); |
986 | nt->setPriority( 1 ); | 992 | nt->setPriority( 1 ); |
987 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 993 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
988 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); | 994 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); |
989 | nt->setPercentComplete( 20 ); | 995 | nt->setPercentComplete( 20 ); |
990 | Todo * workNorbert12 = nt; | 996 | Todo * workNorbert12 = nt; |
991 | workNorbert12->setRelatedTo( sub2 ); | 997 | workNorbert12->setRelatedTo( sub2 ); |
992 | 998 | ||
993 | int secLenRunning = 7200; | 999 | int secLenRunning = 7200; |
994 | int secLenPausing = 3600 * 3; | 1000 | int secLenPausing = 3600 * 3; |
995 | int dayInterval = 1; | 1001 | int dayInterval = 1; |
996 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); | 1002 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); |
997 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); | 1003 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); |
998 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); | 1004 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); |
999 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); | 1005 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); |
1000 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); | 1006 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); |
1001 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); | 1007 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); |
1002 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); | 1008 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); |
1003 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); | 1009 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); |
1004 | 1010 | ||
1005 | } | 1011 | } |
1006 | 1012 | ||
1007 | { | 1013 | { |
1008 | Todo * root1 = new Todo; | 1014 | Todo * root1 = new Todo; |
1009 | mCalendar->addTodo( root1 ); | 1015 | mCalendar->addTodo( root1 ); |
1010 | root1->setSummary( "Project2"); | 1016 | root1->setSummary( "Project2"); |
1011 | root1->setPriority( 1 ); | 1017 | root1->setPriority( 1 ); |
1012 | root1->setDescription( "This is a test description of a root Project 2" ); | 1018 | root1->setDescription( "This is a test description of a root Project 2" ); |
1013 | root1->setPercentComplete( 20 ); | 1019 | root1->setPercentComplete( 20 ); |
1014 | root1->setCategories( QString( "Cat_Pro2") ); | 1020 | root1->setCategories( QString( "Cat_Pro2") ); |
1015 | updateView(); | 1021 | updateView(); |
1016 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 1022 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
1017 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 1023 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
1018 | int secLenRunning = 7200; | 1024 | int secLenRunning = 7200; |
1019 | int secLenPausing = 3600 * 3; | 1025 | int secLenPausing = 3600 * 3; |
@@ -1091,338 +1097,338 @@ void CalendarView::checkAlarms() | |||
1091 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); | 1097 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); |
1092 | } | 1098 | } |
1093 | updateView(); | 1099 | updateView(); |
1094 | #endif | 1100 | #endif |
1095 | 1101 | ||
1096 | } | 1102 | } |
1097 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) | 1103 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) |
1098 | { | 1104 | { |
1099 | static int ccc = 0; | 1105 | static int ccc = 0; |
1100 | ++ccc; | 1106 | ++ccc; |
1101 | QDateTime t_start = start; | 1107 | QDateTime t_start = start; |
1102 | runT->setPriority( 5 ); | 1108 | runT->setPriority( 5 ); |
1103 | runT->setPercentComplete( 0 ); | 1109 | runT->setPercentComplete( 0 ); |
1104 | int count = 0; | 1110 | int count = 0; |
1105 | int prio = 5; | 1111 | int prio = 5; |
1106 | int complete = 0; | 1112 | int complete = 0; |
1107 | while ( t_start < end ) { | 1113 | while ( t_start < end ) { |
1108 | ++count; | 1114 | ++count; |
1109 | if ( count > ccc ) { | 1115 | if ( count > ccc ) { |
1110 | count = 0; | 1116 | count = 0; |
1111 | --prio; | 1117 | --prio; |
1112 | if ( prio == 0 ) prio = 5; | 1118 | if ( prio == 0 ) prio = 5; |
1113 | complete += 20; | 1119 | complete += 20; |
1114 | if ( complete > 100 ) complete = 0; | 1120 | if ( complete > 100 ) complete = 0; |
1115 | runT->setPriority( prio ); | 1121 | runT->setPriority( prio ); |
1116 | runT->setPercentComplete( complete ); | 1122 | runT->setPercentComplete( complete ); |
1117 | } | 1123 | } |
1118 | runT->setRunning( true ); | 1124 | runT->setRunning( true ); |
1119 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); | 1125 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); |
1120 | if ( dayInterval ) | 1126 | if ( dayInterval ) |
1121 | t_start = t_start.addDays( dayInterval ); | 1127 | t_start = t_start.addDays( dayInterval ); |
1122 | else { | 1128 | else { |
1123 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); | 1129 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); |
1124 | } | 1130 | } |
1125 | } | 1131 | } |
1126 | } | 1132 | } |
1127 | 1133 | ||
1128 | void CalendarView::showDay( QDate d ) | 1134 | void CalendarView::showDay( QDate d ) |
1129 | { | 1135 | { |
1130 | dateNavigator()->blockSignals( true ); | 1136 | dateNavigator()->blockSignals( true ); |
1131 | dateNavigator()->selectDate( d ); | 1137 | dateNavigator()->selectDate( d ); |
1132 | dateNavigator()->blockSignals( false ); | 1138 | dateNavigator()->blockSignals( false ); |
1133 | mViewManager->showDayView(); | 1139 | mViewManager->showDayView(); |
1134 | //dateNavigator()->selectDate( d ); | 1140 | //dateNavigator()->selectDate( d ); |
1135 | } | 1141 | } |
1136 | void CalendarView::timerAlarm() | 1142 | void CalendarView::timerAlarm() |
1137 | { | 1143 | { |
1138 | //qDebug("CalendarView::timerAlarm() "); | 1144 | //qDebug("CalendarView::timerAlarm() "); |
1139 | computeAlarm(mAlarmNotification ); | 1145 | computeAlarm(mAlarmNotification ); |
1140 | } | 1146 | } |
1141 | 1147 | ||
1142 | void CalendarView::suspendAlarm() | 1148 | void CalendarView::suspendAlarm() |
1143 | { | 1149 | { |
1144 | //qDebug(" CalendarView::suspendAlarm() "); | 1150 | //qDebug(" CalendarView::suspendAlarm() "); |
1145 | computeAlarm(mSuspendAlarmNotification ); | 1151 | computeAlarm(mSuspendAlarmNotification ); |
1146 | 1152 | ||
1147 | } | 1153 | } |
1148 | 1154 | ||
1149 | void CalendarView::startAlarm( QString mess , QString filename) | 1155 | void CalendarView::startAlarm( QString mess , QString filename) |
1150 | { | 1156 | { |
1151 | 1157 | ||
1152 | topLevelWidget()->showNormal(); | 1158 | topLevelWidget()->showNormal(); |
1153 | topLevelWidget()->setActiveWindow(); | 1159 | topLevelWidget()->setActiveWindow(); |
1154 | topLevelWidget()->raise(); | 1160 | topLevelWidget()->raise(); |
1155 | 1161 | ||
1156 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 1162 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
1157 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 1163 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
1158 | 1164 | ||
1159 | } | 1165 | } |
1160 | 1166 | ||
1161 | void CalendarView::checkNextTimerAlarm() | 1167 | void CalendarView::checkNextTimerAlarm() |
1162 | { | 1168 | { |
1163 | mCalendar->checkAlarmForIncidence( 0, true ); | 1169 | mCalendar->checkAlarmForIncidence( 0, true ); |
1164 | } | 1170 | } |
1165 | 1171 | ||
1166 | void CalendarView::computeAlarm( QString msg ) | 1172 | void CalendarView::computeAlarm( QString msg ) |
1167 | { | 1173 | { |
1168 | 1174 | ||
1169 | QString mess = msg; | 1175 | QString mess = msg; |
1170 | QString mAlarmMessage = mess.mid( 9 ); | 1176 | QString mAlarmMessage = mess.mid( 9 ); |
1171 | QString filename = MainWindow::resourcePath(); | 1177 | QString filename = MainWindow::resourcePath(); |
1172 | filename += "koalarm.wav"; | 1178 | filename += "koalarm.wav"; |
1173 | QString tempfilename; | 1179 | QString tempfilename; |
1174 | if ( mess.left( 13 ) == "suspend_alarm") { | 1180 | if ( mess.left( 13 ) == "suspend_alarm") { |
1175 | bool error = false; | 1181 | bool error = false; |
1176 | int len = mess.mid( 13 ).find("+++"); | 1182 | int len = mess.mid( 13 ).find("+++"); |
1177 | if ( len < 2 ) | 1183 | if ( len < 2 ) |
1178 | error = true; | 1184 | error = true; |
1179 | else { | 1185 | else { |
1180 | tempfilename = mess.mid( 13, len ); | 1186 | tempfilename = mess.mid( 13, len ); |
1181 | if ( !QFile::exists( tempfilename ) ) | 1187 | if ( !QFile::exists( tempfilename ) ) |
1182 | error = true; | 1188 | error = true; |
1183 | } | 1189 | } |
1184 | if ( ! error ) { | 1190 | if ( ! error ) { |
1185 | filename = tempfilename; | 1191 | filename = tempfilename; |
1186 | } | 1192 | } |
1187 | mAlarmMessage = mess.mid( 13+len+3 ); | 1193 | mAlarmMessage = mess.mid( 13+len+3 ); |
1188 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 1194 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
1189 | startAlarm( mAlarmMessage, filename); | 1195 | startAlarm( mAlarmMessage, filename); |
1190 | return; | 1196 | return; |
1191 | } | 1197 | } |
1192 | if ( mess.left( 11 ) == "timer_alarm") { | 1198 | if ( mess.left( 11 ) == "timer_alarm") { |
1193 | //mTimerTime = 0; | 1199 | //mTimerTime = 0; |
1194 | startAlarm( mess.mid( 11 ), filename ); | 1200 | startAlarm( mess.mid( 11 ), filename ); |
1195 | return; | 1201 | return; |
1196 | } | 1202 | } |
1197 | if ( mess.left( 10 ) == "proc_alarm") { | 1203 | if ( mess.left( 10 ) == "proc_alarm") { |
1198 | bool error = false; | 1204 | bool error = false; |
1199 | int len = mess.mid( 10 ).find("+++"); | 1205 | int len = mess.mid( 10 ).find("+++"); |
1200 | if ( len < 2 ) | 1206 | if ( len < 2 ) |
1201 | error = true; | 1207 | error = true; |
1202 | else { | 1208 | else { |
1203 | tempfilename = mess.mid( 10, len ); | 1209 | tempfilename = mess.mid( 10, len ); |
1204 | if ( !QFile::exists( tempfilename ) ) | 1210 | if ( !QFile::exists( tempfilename ) ) |
1205 | error = true; | 1211 | error = true; |
1206 | } | 1212 | } |
1207 | if ( error ) { | 1213 | if ( error ) { |
1208 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 1214 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1209 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 1215 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1210 | } else { | 1216 | } else { |
1211 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 1217 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1212 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 1218 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1213 | #ifndef _WIN32_ | 1219 | #ifndef _WIN32_ |
1214 | if ( vfork () == 0 ) { | 1220 | if ( vfork () == 0 ) { |
1215 | execl ( tempfilename.latin1(), 0 ); | 1221 | execl ( tempfilename.latin1(), 0 ); |
1216 | return; | 1222 | return; |
1217 | } | 1223 | } |
1218 | #else | 1224 | #else |
1219 | QProcess* p = new QProcess(); | 1225 | Q3Process* p = new Q3Process(); |
1220 | p->addArgument( tempfilename.latin1() ); | 1226 | p->addArgument( tempfilename.latin1() ); |
1221 | p->start(); | 1227 | p->start(); |
1222 | return; | 1228 | return; |
1223 | #endif | 1229 | #endif |
1224 | 1230 | ||
1225 | return; | 1231 | return; |
1226 | } | 1232 | } |
1227 | 1233 | ||
1228 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1234 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1229 | } | 1235 | } |
1230 | if ( mess.left( 11 ) == "audio_alarm") { | 1236 | if ( mess.left( 11 ) == "audio_alarm") { |
1231 | bool error = false; | 1237 | bool error = false; |
1232 | int len = mess.mid( 11 ).find("+++"); | 1238 | int len = mess.mid( 11 ).find("+++"); |
1233 | if ( len < 2 ) | 1239 | if ( len < 2 ) |
1234 | error = true; | 1240 | error = true; |
1235 | else { | 1241 | else { |
1236 | tempfilename = mess.mid( 11, len ); | 1242 | tempfilename = mess.mid( 11, len ); |
1237 | if ( !QFile::exists( tempfilename ) ) | 1243 | if ( !QFile::exists( tempfilename ) ) |
1238 | error = true; | 1244 | error = true; |
1239 | } | 1245 | } |
1240 | if ( ! error ) { | 1246 | if ( ! error ) { |
1241 | filename = tempfilename; | 1247 | filename = tempfilename; |
1242 | } | 1248 | } |
1243 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1249 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1244 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1250 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1245 | } | 1251 | } |
1246 | if ( mess.left( 9 ) == "cal_alarm") { | 1252 | if ( mess.left( 9 ) == "cal_alarm") { |
1247 | mAlarmMessage = mess.mid( 9 ) ; | 1253 | mAlarmMessage = mess.mid( 9 ) ; |
1248 | } | 1254 | } |
1249 | 1255 | ||
1250 | startAlarm( mAlarmMessage, filename ); | 1256 | startAlarm( mAlarmMessage, filename ); |
1251 | 1257 | ||
1252 | 1258 | ||
1253 | } | 1259 | } |
1254 | 1260 | ||
1255 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1261 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1256 | { | 1262 | { |
1257 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1263 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1258 | 1264 | ||
1259 | mSuspendAlarmNotification = noti; | 1265 | mSuspendAlarmNotification = noti; |
1260 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1266 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1261 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1267 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1262 | mSuspendTimer->start( ms , true ); | 1268 | mSuspendTimer->start( ms , true ); |
1263 | #ifdef DESKTOP_VERSION | 1269 | #ifdef DESKTOP_VERSION |
1264 | if ( QApplication::desktop()->width() < 1024 ) { | 1270 | if ( QApplication::desktop()->width() < 1024 ) { |
1265 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1271 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1266 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); | 1272 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); |
1267 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; | 1273 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; |
1268 | QFile file( fn ); | 1274 | QFile file( fn ); |
1269 | if (!file.open( IO_WriteOnly ) ) { | 1275 | if (!file.open( QIODevice::WriteOnly ) ) { |
1270 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1276 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1271 | } else { | 1277 | } else { |
1272 | QTextStream ts( &file ); | 1278 | Q3TextStream ts( &file ); |
1273 | ts << mess; | 1279 | ts << mess; |
1274 | file.close(); | 1280 | file.close(); |
1275 | } | 1281 | } |
1276 | } | 1282 | } |
1277 | #endif | 1283 | #endif |
1278 | 1284 | ||
1279 | } | 1285 | } |
1280 | 1286 | ||
1281 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1287 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1282 | { | 1288 | { |
1283 | mNextAlarmDateTime = qdt; | 1289 | mNextAlarmDateTime = qdt; |
1284 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1290 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1285 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1291 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1286 | #ifndef DESKTOP_VERSION | 1292 | #ifndef DESKTOP_VERSION |
1287 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1293 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1288 | #endif | 1294 | #endif |
1289 | return; | 1295 | return; |
1290 | } | 1296 | } |
1291 | #ifdef DESKTOP_VERSION | 1297 | #ifdef DESKTOP_VERSION |
1292 | if ( QApplication::desktop()->width() < 1024 ) { | 1298 | if ( QApplication::desktop()->width() < 1024 ) { |
1293 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1299 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1294 | //qDebug("nextalarm = \n%s ",mess.latin1() ); | 1300 | //qDebug("nextalarm = \n%s ",mess.latin1() ); |
1295 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; | 1301 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; |
1296 | QFile file( fn ); | 1302 | QFile file( fn ); |
1297 | if (!file.open( IO_WriteOnly ) ) { | 1303 | if (!file.open( QIODevice::WriteOnly ) ) { |
1298 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1304 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1299 | } else { | 1305 | } else { |
1300 | QTextStream ts( &file ); | 1306 | Q3TextStream ts( &file ); |
1301 | ts << mess; | 1307 | ts << mess; |
1302 | file.close(); | 1308 | file.close(); |
1303 | } | 1309 | } |
1304 | } | 1310 | } |
1305 | #endif | 1311 | #endif |
1306 | int maxSec; | 1312 | int maxSec; |
1307 | //maxSec = 5; //testing only | 1313 | //maxSec = 5; //testing only |
1308 | maxSec = 86400+3600; // one day+1hour | 1314 | maxSec = 86400+3600; // one day+1hour |
1309 | mAlarmNotification = noti; | 1315 | mAlarmNotification = noti; |
1310 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1316 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1311 | if ( sec > maxSec ) { | 1317 | if ( sec > maxSec ) { |
1312 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1318 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1313 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1319 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1314 | return; | 1320 | return; |
1315 | } else { | 1321 | } else { |
1316 | mRecheckAlarmTimer->stop(); | 1322 | mRecheckAlarmTimer->stop(); |
1317 | } | 1323 | } |
1318 | //qDebug("Alarm timer started with secs: %d ", sec); | 1324 | //qDebug("Alarm timer started with secs: %d ", sec); |
1319 | mAlarmTimer->start( sec * 1000 , true ); | 1325 | mAlarmTimer->start( sec * 1000 , true ); |
1320 | 1326 | ||
1321 | } | 1327 | } |
1322 | // called by mRecheckAlarmTimer to get next alarm | 1328 | // called by mRecheckAlarmTimer to get next alarm |
1323 | // we need this, because a QTimer has only a max range of 25 days | 1329 | // we need this, because a QTimer has only a max range of 25 days |
1324 | void CalendarView::recheckTimerAlarm() | 1330 | void CalendarView::recheckTimerAlarm() |
1325 | { | 1331 | { |
1326 | mAlarmTimer->stop(); | 1332 | mAlarmTimer->stop(); |
1327 | mRecheckAlarmTimer->stop(); | 1333 | mRecheckAlarmTimer->stop(); |
1328 | mCalendar->checkAlarmForIncidence( 0, true ); | 1334 | mCalendar->checkAlarmForIncidence( 0, true ); |
1329 | } | 1335 | } |
1330 | #ifndef DESKTOP_VERSION | 1336 | #ifndef DESKTOP_VERSION |
1331 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1337 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1332 | #else | 1338 | #else |
1333 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1339 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1334 | #endif | 1340 | #endif |
1335 | { | 1341 | { |
1336 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1342 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1337 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1343 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1338 | #ifndef DESKTOP_VERSION | 1344 | #ifndef DESKTOP_VERSION |
1339 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1345 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1340 | #endif | 1346 | #endif |
1341 | return; | 1347 | return; |
1342 | } | 1348 | } |
1343 | mAlarmTimer->stop(); | 1349 | mAlarmTimer->stop(); |
1344 | } | 1350 | } |
1345 | void CalendarView::selectWeekNum ( int num ) | 1351 | void CalendarView::selectWeekNum ( int num ) |
1346 | { | 1352 | { |
1347 | dateNavigator()->blockSignals( true ); | 1353 | dateNavigator()->blockSignals( true ); |
1348 | dateNavigator()->selectWeek( num ); | 1354 | dateNavigator()->selectWeek( num ); |
1349 | dateNavigator()->blockSignals( false ); | 1355 | dateNavigator()->blockSignals( false ); |
1350 | mViewManager->showWeekView(); | 1356 | mViewManager->showWeekView(); |
1351 | } | 1357 | } |
1352 | KOViewManager *CalendarView::viewManager() | 1358 | KOViewManager *CalendarView::viewManager() |
1353 | { | 1359 | { |
1354 | return mViewManager; | 1360 | return mViewManager; |
1355 | } | 1361 | } |
1356 | 1362 | ||
1357 | KODialogManager *CalendarView::dialogManager() | 1363 | KODialogManager *CalendarView::dialogManager() |
1358 | { | 1364 | { |
1359 | return mDialogManager; | 1365 | return mDialogManager; |
1360 | } | 1366 | } |
1361 | 1367 | ||
1362 | QDate CalendarView::startDate() | 1368 | QDate CalendarView::startDate() |
1363 | { | 1369 | { |
1364 | DateList dates = mNavigator->selectedDates(); | 1370 | DateList dates = mNavigator->selectedDates(); |
1365 | 1371 | ||
1366 | return dates.first(); | 1372 | return dates.first(); |
1367 | } | 1373 | } |
1368 | 1374 | ||
1369 | QDate CalendarView::endDate() | 1375 | QDate CalendarView::endDate() |
1370 | { | 1376 | { |
1371 | DateList dates = mNavigator->selectedDates(); | 1377 | DateList dates = mNavigator->selectedDates(); |
1372 | 1378 | ||
1373 | return dates.last(); | 1379 | return dates.last(); |
1374 | } | 1380 | } |
1375 | 1381 | ||
1376 | 1382 | ||
1377 | void CalendarView::createPrinter() | 1383 | void CalendarView::createPrinter() |
1378 | { | 1384 | { |
1379 | #ifndef KORG_NOPRINTER | 1385 | #ifndef KORG_NOPRINTER |
1380 | if (!mCalPrinter) { | 1386 | if (!mCalPrinter) { |
1381 | mCalPrinter = new CalPrinter(this, mCalendar); | 1387 | mCalPrinter = new CalPrinter(this, mCalendar); |
1382 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1388 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1383 | } | 1389 | } |
1384 | #endif | 1390 | #endif |
1385 | } | 1391 | } |
1386 | 1392 | ||
1387 | 1393 | ||
1388 | //KOPrefs::instance()->mWriteBackFile | 1394 | //KOPrefs::instance()->mWriteBackFile |
1389 | //KOPrefs::instance()->mWriteBackExistingOnly | 1395 | //KOPrefs::instance()->mWriteBackExistingOnly |
1390 | 1396 | ||
1391 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1397 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1392 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1398 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1393 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1399 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1394 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1400 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1395 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1401 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1396 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1402 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1397 | 1403 | ||
1398 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1404 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1399 | { | 1405 | { |
1400 | 1406 | ||
1401 | // 0 equal | 1407 | // 0 equal |
1402 | // 1 take local | 1408 | // 1 take local |
1403 | // 2 take remote | 1409 | // 2 take remote |
1404 | // 3 cancel | 1410 | // 3 cancel |
1405 | QDateTime lastSync = mLastCalendarSync; | 1411 | QDateTime lastSync = mLastCalendarSync; |
1406 | QDateTime localMod = local->lastModified(); | 1412 | QDateTime localMod = local->lastModified(); |
1407 | QDateTime remoteMod = remote->lastModified(); | 1413 | QDateTime remoteMod = remote->lastModified(); |
1408 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1414 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1409 | bool remCh, locCh; | 1415 | bool remCh, locCh; |
1410 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1416 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1411 | //if ( remCh ) | 1417 | //if ( remCh ) |
1412 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1418 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1413 | locCh = ( localMod > mLastCalendarSync ); | 1419 | locCh = ( localMod > mLastCalendarSync ); |
1414 | if ( !remCh && ! locCh ) { | 1420 | if ( !remCh && ! locCh ) { |
1415 | //qDebug("both not changed "); | 1421 | //qDebug("both not changed "); |
1416 | lastSync = localMod.addDays(1); | 1422 | lastSync = localMod.addDays(1); |
1417 | if ( mode <= SYNC_PREF_ASK ) | 1423 | if ( mode <= SYNC_PREF_ASK ) |
1418 | return 0; | 1424 | return 0; |
1419 | } else { | 1425 | } else { |
1420 | if ( locCh ) { | 1426 | if ( locCh ) { |
1421 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1427 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1422 | lastSync = localMod.addDays( -1 ); | 1428 | lastSync = localMod.addDays( -1 ); |
1423 | if ( !remCh ) | 1429 | if ( !remCh ) |
1424 | remoteMod = ( lastSync.addDays( -1 ) ); | 1430 | remoteMod = ( lastSync.addDays( -1 ) ); |
1425 | } else { | 1431 | } else { |
1426 | //qDebug(" not loc changed "); | 1432 | //qDebug(" not loc changed "); |
1427 | lastSync = localMod.addDays( 1 ); | 1433 | lastSync = localMod.addDays( 1 ); |
1428 | if ( remCh ) | 1434 | if ( remCh ) |
@@ -1445,1558 +1451,1558 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
1445 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1451 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1446 | //full = true; //debug only | 1452 | //full = true; //debug only |
1447 | if ( full ) { | 1453 | if ( full ) { |
1448 | bool equ = false; | 1454 | bool equ = false; |
1449 | if ( local->typeID() == eventID ) { | 1455 | if ( local->typeID() == eventID ) { |
1450 | equ = (*((Event*) local) == *((Event*) remote)); | 1456 | equ = (*((Event*) local) == *((Event*) remote)); |
1451 | } | 1457 | } |
1452 | else if ( local->typeID() == todoID ) | 1458 | else if ( local->typeID() == todoID ) |
1453 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1459 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1454 | else if ( local->typeID() == journalID ) | 1460 | else if ( local->typeID() == journalID ) |
1455 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1461 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1456 | if ( equ ) { | 1462 | if ( equ ) { |
1457 | //qDebug("equal "); | 1463 | //qDebug("equal "); |
1458 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1464 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1459 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1465 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1460 | } | 1466 | } |
1461 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1467 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1462 | return 0; | 1468 | return 0; |
1463 | 1469 | ||
1464 | }//else //debug only | 1470 | }//else //debug only |
1465 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1471 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1466 | } | 1472 | } |
1467 | int result; | 1473 | int result; |
1468 | bool localIsNew; | 1474 | bool localIsNew; |
1469 | //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() ); | 1475 | //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() ); |
1470 | 1476 | ||
1471 | 1477 | ||
1472 | // ************************************************ | 1478 | // ************************************************ |
1473 | // ************************************************ | 1479 | // ************************************************ |
1474 | // ************************************************ | 1480 | // ************************************************ |
1475 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1481 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1476 | // BUT remoteMod != localMod | 1482 | // BUT remoteMod != localMod |
1477 | 1483 | ||
1478 | 1484 | ||
1479 | if ( full && mode < SYNC_PREF_NEWEST ) | 1485 | if ( full && mode < SYNC_PREF_NEWEST ) |
1480 | mode = SYNC_PREF_ASK; | 1486 | mode = SYNC_PREF_ASK; |
1481 | 1487 | ||
1482 | switch( mode ) { | 1488 | switch( mode ) { |
1483 | case SYNC_PREF_LOCAL: | 1489 | case SYNC_PREF_LOCAL: |
1484 | if ( lastSync > remoteMod ) | 1490 | if ( lastSync > remoteMod ) |
1485 | return 1; | 1491 | return 1; |
1486 | if ( lastSync > localMod ) | 1492 | if ( lastSync > localMod ) |
1487 | return 2; | 1493 | return 2; |
1488 | return 1; | 1494 | return 1; |
1489 | break; | 1495 | break; |
1490 | case SYNC_PREF_REMOTE: | 1496 | case SYNC_PREF_REMOTE: |
1491 | if ( lastSync > localMod ) | 1497 | if ( lastSync > localMod ) |
1492 | return 2; | 1498 | return 2; |
1493 | if ( lastSync > remoteMod ) | 1499 | if ( lastSync > remoteMod ) |
1494 | return 1; | 1500 | return 1; |
1495 | return 2; | 1501 | return 2; |
1496 | break; | 1502 | break; |
1497 | case SYNC_PREF_NEWEST: | 1503 | case SYNC_PREF_NEWEST: |
1498 | if ( localMod >= remoteMod ) | 1504 | if ( localMod >= remoteMod ) |
1499 | return 1; | 1505 | return 1; |
1500 | else | 1506 | else |
1501 | return 2; | 1507 | return 2; |
1502 | break; | 1508 | break; |
1503 | case SYNC_PREF_ASK: | 1509 | case SYNC_PREF_ASK: |
1504 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1510 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1505 | if ( lastSync > remoteMod && lastSync > localMod) | 1511 | if ( lastSync > remoteMod && lastSync > localMod) |
1506 | return 0; | 1512 | return 0; |
1507 | if ( lastSync > remoteMod ) | 1513 | if ( lastSync > remoteMod ) |
1508 | return 1; | 1514 | return 1; |
1509 | if ( lastSync > localMod ) | 1515 | if ( lastSync > localMod ) |
1510 | return 2; | 1516 | return 2; |
1511 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1517 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1512 | localIsNew = localMod >= remoteMod; | 1518 | localIsNew = localMod >= remoteMod; |
1513 | if ( localIsNew ) | 1519 | if ( localIsNew ) |
1514 | getEventViewerDialog()->setColorMode( 1 ); | 1520 | getEventViewerDialog()->setColorMode( 1 ); |
1515 | else | 1521 | else |
1516 | getEventViewerDialog()->setColorMode( 2 ); | 1522 | getEventViewerDialog()->setColorMode( 2 ); |
1517 | getEventViewerDialog()->setIncidence(local); | 1523 | getEventViewerDialog()->setIncidence(local); |
1518 | if ( localIsNew ) | 1524 | if ( localIsNew ) |
1519 | getEventViewerDialog()->setColorMode( 2 ); | 1525 | getEventViewerDialog()->setColorMode( 2 ); |
1520 | else | 1526 | else |
1521 | getEventViewerDialog()->setColorMode( 1 ); | 1527 | getEventViewerDialog()->setColorMode( 1 ); |
1522 | getEventViewerDialog()->addIncidence(remote); | 1528 | getEventViewerDialog()->addIncidence(remote); |
1523 | getEventViewerDialog()->setColorMode( 0 ); | 1529 | getEventViewerDialog()->setColorMode( 0 ); |
1524 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1530 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1525 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1531 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1526 | getEventViewerDialog()->showMe(); | 1532 | getEventViewerDialog()->showMe(); |
1527 | result = getEventViewerDialog()->executeS( localIsNew ); | 1533 | result = getEventViewerDialog()->executeS( localIsNew ); |
1528 | return result; | 1534 | return result; |
1529 | 1535 | ||
1530 | break; | 1536 | break; |
1531 | case SYNC_PREF_FORCE_LOCAL: | 1537 | case SYNC_PREF_FORCE_LOCAL: |
1532 | return 1; | 1538 | return 1; |
1533 | break; | 1539 | break; |
1534 | case SYNC_PREF_FORCE_REMOTE: | 1540 | case SYNC_PREF_FORCE_REMOTE: |
1535 | return 2; | 1541 | return 2; |
1536 | break; | 1542 | break; |
1537 | 1543 | ||
1538 | default: | 1544 | default: |
1539 | // SYNC_PREF_TAKE_BOTH not implemented | 1545 | // SYNC_PREF_TAKE_BOTH not implemented |
1540 | break; | 1546 | break; |
1541 | } | 1547 | } |
1542 | return 0; | 1548 | return 0; |
1543 | } | 1549 | } |
1544 | Event* CalendarView::getLastSyncEvent() | 1550 | Event* CalendarView::getLastSyncEvent() |
1545 | { | 1551 | { |
1546 | Event* lse; | 1552 | Event* lse; |
1547 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1553 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1548 | mCalendar->setSyncEventsEnabled(); | 1554 | mCalendar->setSyncEventsEnabled(); |
1549 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1555 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1550 | if (!lse) { | 1556 | if (!lse) { |
1551 | qDebug("KO: New last Syncevent created for local: %s",mCurrentSyncDevice.latin1() ); | 1557 | qDebug("KO: New last Syncevent created for local: %s",mCurrentSyncDevice.latin1() ); |
1552 | lse = new Event(); | 1558 | lse = new Event(); |
1553 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1559 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1554 | QString sum = ""; | 1560 | QString sum = ""; |
1555 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1561 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1556 | sum = "E: "; | 1562 | sum = "E: "; |
1557 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1563 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1558 | lse->setDtStart( mLastCalendarSync ); | 1564 | lse->setDtStart( mLastCalendarSync ); |
1559 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1565 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1560 | lse->setCategories( i18n("SyncEvent") ); | 1566 | lse->setCategories( i18n("SyncEvent") ); |
1561 | lse->setReadOnly( true ); | 1567 | lse->setReadOnly( true ); |
1562 | lse->setCalID( 1 ); | 1568 | lse->setCalID( 1 ); |
1563 | mCalendar->addEvent( lse ); | 1569 | mCalendar->addEvent( lse ); |
1564 | } else | 1570 | } else |
1565 | qDebug("KO: Last Syncevent on local found"); | 1571 | qDebug("KO: Last Syncevent on local found"); |
1566 | 1572 | ||
1567 | return lse; | 1573 | return lse; |
1568 | 1574 | ||
1569 | } | 1575 | } |
1570 | 1576 | ||
1571 | // we check, if the to delete event has a id for a profile | 1577 | // we check, if the to delete event has a id for a profile |
1572 | // if yes, we set this id in the profile to delete | 1578 | // if yes, we set this id in the profile to delete |
1573 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1579 | void CalendarView::checkExternSyncEvent( Q3PtrList<Event> lastSync , Incidence* toDelete ) |
1574 | { | 1580 | { |
1575 | if ( lastSync.count() == 0 ) { | 1581 | if ( lastSync.count() == 0 ) { |
1576 | //qDebug(" lastSync.count() == 0"); | 1582 | //qDebug(" lastSync.count() == 0"); |
1577 | return; | 1583 | return; |
1578 | } | 1584 | } |
1579 | if ( toDelete->typeID() == journalID ) | 1585 | if ( toDelete->typeID() == journalID ) |
1580 | return; | 1586 | return; |
1581 | 1587 | ||
1582 | Event* eve = lastSync.first(); | 1588 | Event* eve = lastSync.first(); |
1583 | 1589 | ||
1584 | while ( eve ) { | 1590 | while ( eve ) { |
1585 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1591 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1586 | if ( !id.isEmpty() ) { | 1592 | if ( !id.isEmpty() ) { |
1587 | QString des = eve->description(); | 1593 | QString des = eve->description(); |
1588 | QString pref = "e"; | 1594 | QString pref = "e"; |
1589 | if ( toDelete->typeID() == todoID ) | 1595 | if ( toDelete->typeID() == todoID ) |
1590 | pref = "t"; | 1596 | pref = "t"; |
1591 | des += pref+ id + ","; | 1597 | des += pref+ id + ","; |
1592 | eve->setReadOnly( false ); | 1598 | eve->setReadOnly( false ); |
1593 | eve->setDescription( des ); | 1599 | eve->setDescription( des ); |
1594 | //qDebug("setdes %s ", des.latin1()); | 1600 | //qDebug("setdes %s ", des.latin1()); |
1595 | eve->setReadOnly( true ); | 1601 | eve->setReadOnly( true ); |
1596 | } | 1602 | } |
1597 | eve = lastSync.next(); | 1603 | eve = lastSync.next(); |
1598 | } | 1604 | } |
1599 | 1605 | ||
1600 | } | 1606 | } |
1601 | void CalendarView::checkExternalId( Incidence * inc ) | 1607 | void CalendarView::checkExternalId( Incidence * inc ) |
1602 | { | 1608 | { |
1603 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1609 | Q3PtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1604 | checkExternSyncEvent( lastSync, inc ); | 1610 | checkExternSyncEvent( lastSync, inc ); |
1605 | 1611 | ||
1606 | } | 1612 | } |
1607 | // SSSSSSSSSSSSSSSSSSSSSS | 1613 | // SSSSSSSSSSSSSSSSSSSSSS |
1608 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1614 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1609 | { | 1615 | { |
1610 | 1616 | ||
1611 | bool syncOK = true; | 1617 | bool syncOK = true; |
1612 | int addedEvent = 0; | 1618 | int addedEvent = 0; |
1613 | int addedEventR = 0; | 1619 | int addedEventR = 0; |
1614 | int deletedEventR = 0; | 1620 | int deletedEventR = 0; |
1615 | int deletedEventL = 0; | 1621 | int deletedEventL = 0; |
1616 | int changedLocal = 0; | 1622 | int changedLocal = 0; |
1617 | int changedRemote = 0; | 1623 | int changedRemote = 0; |
1618 | int filteredIN = 0; | 1624 | int filteredIN = 0; |
1619 | int filteredOUT = 0; | 1625 | int filteredOUT = 0; |
1620 | //QPtrList<Event> el = local->rawEvents(); | 1626 | //QPtrList<Event> el = local->rawEvents(); |
1621 | Event* eventR; | 1627 | Event* eventR; |
1622 | QString uid; | 1628 | QString uid; |
1623 | int take; | 1629 | int take; |
1624 | Event* eventRSync; | 1630 | Event* eventRSync; |
1625 | Event* eventLSync; | 1631 | Event* eventLSync; |
1626 | clearAllViews(); | 1632 | clearAllViews(); |
1627 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1633 | Q3PtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1628 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1634 | Q3PtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1629 | bool fullDateRange = false; | 1635 | bool fullDateRange = false; |
1630 | local->resetTempSyncStat(); | 1636 | local->resetTempSyncStat(); |
1631 | mLastCalendarSync = QDateTime::currentDateTime(); | 1637 | mLastCalendarSync = QDateTime::currentDateTime(); |
1632 | if ( mSyncManager->syncWithDesktop() ) { | 1638 | if ( mSyncManager->syncWithDesktop() ) { |
1633 | remote->resetPilotStat(1); | 1639 | remote->resetPilotStat(1); |
1634 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1640 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1635 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1641 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1636 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1642 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1637 | } else { | 1643 | } else { |
1638 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1644 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1639 | } | 1645 | } |
1640 | } | 1646 | } |
1641 | QDateTime modifiedCalendar = mLastCalendarSync; | 1647 | QDateTime modifiedCalendar = mLastCalendarSync; |
1642 | eventLSync = getLastSyncEvent(); | 1648 | eventLSync = getLastSyncEvent(); |
1643 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1649 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1644 | if ( eventR ) { | 1650 | if ( eventR ) { |
1645 | qDebug("KO: Last-syncEvent on remote found "); | 1651 | qDebug("KO: Last-syncEvent on remote found "); |
1646 | eventRSync = (Event*) eventR->clone(); | 1652 | eventRSync = (Event*) eventR->clone(); |
1647 | remote->deleteEvent(eventR ); | 1653 | remote->deleteEvent(eventR ); |
1648 | 1654 | ||
1649 | } else { | 1655 | } else { |
1650 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1656 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1651 | eventRSync = (Event*)eventLSync->clone(); | 1657 | eventRSync = (Event*)eventLSync->clone(); |
1652 | } else { | 1658 | } else { |
1653 | fullDateRange = true; | 1659 | fullDateRange = true; |
1654 | eventRSync = new Event(); | 1660 | eventRSync = new Event(); |
1655 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1661 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1656 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1662 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1657 | eventRSync->setDtStart( mLastCalendarSync ); | 1663 | eventRSync->setDtStart( mLastCalendarSync ); |
1658 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1664 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1659 | eventRSync->setCategories( i18n("SyncEvent") ); | 1665 | eventRSync->setCategories( i18n("SyncEvent") ); |
1660 | } | 1666 | } |
1661 | } | 1667 | } |
1662 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1668 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1663 | fullDateRange = true; | 1669 | fullDateRange = true; |
1664 | 1670 | ||
1665 | if ( ! fullDateRange ) { | 1671 | if ( ! fullDateRange ) { |
1666 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1672 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1667 | 1673 | ||
1668 | qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1674 | qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1669 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1675 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1670 | fullDateRange = true; | 1676 | fullDateRange = true; |
1671 | } | 1677 | } |
1672 | } | 1678 | } |
1673 | if ( mSyncManager->syncWithDesktop() ) { | 1679 | if ( mSyncManager->syncWithDesktop() ) { |
1674 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1680 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1675 | } | 1681 | } |
1676 | if ( fullDateRange ) | 1682 | if ( fullDateRange ) |
1677 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1683 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1678 | else | 1684 | else |
1679 | mLastCalendarSync = eventLSync->dtStart(); | 1685 | mLastCalendarSync = eventLSync->dtStart(); |
1680 | // for resyncing if own file has changed | 1686 | // for resyncing if own file has changed |
1681 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1687 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1682 | mLastCalendarSync = loadedFileVersion; | 1688 | mLastCalendarSync = loadedFileVersion; |
1683 | //qDebug("setting mLastCalendarSync "); | 1689 | //qDebug("setting mLastCalendarSync "); |
1684 | } | 1690 | } |
1685 | //qDebug("*************************** "); | 1691 | //qDebug("*************************** "); |
1686 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1692 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1687 | QPtrList<Incidence> er = remote->rawIncidences(); | 1693 | Q3PtrList<Incidence> er = remote->rawIncidences(); |
1688 | Incidence* inR = er.first(); | 1694 | Incidence* inR = er.first(); |
1689 | Incidence* inL; | 1695 | Incidence* inL; |
1690 | QProgressBar bar( er.count(),0 ); | 1696 | Q3ProgressBar bar( er.count(),0 ); |
1691 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1697 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1692 | 1698 | ||
1693 | // ************** setting up filter ************* | 1699 | // ************** setting up filter ************* |
1694 | CalFilter *filterIN = 0; | 1700 | CalFilter *filterIN = 0; |
1695 | CalFilter *filterOUT = 0; | 1701 | CalFilter *filterOUT = 0; |
1696 | CalFilter *filter = mFilters.first(); | 1702 | CalFilter *filter = mFilters.first(); |
1697 | while(filter) { | 1703 | while(filter) { |
1698 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1704 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1699 | filterIN = filter; | 1705 | filterIN = filter; |
1700 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1706 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1701 | filterOUT = filter; | 1707 | filterOUT = filter; |
1702 | filter = mFilters.next(); | 1708 | filter = mFilters.next(); |
1703 | } | 1709 | } |
1704 | int w = 300; | 1710 | int w = 300; |
1705 | if ( QApplication::desktop()->width() < 320 ) | 1711 | if ( QApplication::desktop()->width() < 320 ) |
1706 | w = 220; | 1712 | w = 220; |
1707 | int h = bar.sizeHint().height() ; | 1713 | int h = bar.sizeHint().height() ; |
1708 | int dw = QApplication::desktop()->width(); | 1714 | int dw = QApplication::desktop()->width(); |
1709 | int dh = QApplication::desktop()->height(); | 1715 | int dh = QApplication::desktop()->height(); |
1710 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1716 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1711 | bar.show(); | 1717 | bar.show(); |
1712 | int modulo = (er.count()/10)+1; | 1718 | int modulo = (er.count()/10)+1; |
1713 | int incCounter = 0; | 1719 | int incCounter = 0; |
1714 | while ( inR ) { | 1720 | while ( inR ) { |
1715 | if ( ! bar.isVisible() ) | 1721 | if ( ! bar.isVisible() ) |
1716 | return false; | 1722 | return false; |
1717 | if ( incCounter % modulo == 0 ) | 1723 | if ( incCounter % modulo == 0 ) |
1718 | bar.setProgress( incCounter ); | 1724 | bar.setProgress( incCounter ); |
1719 | ++incCounter; | 1725 | ++incCounter; |
1720 | uid = inR->uid(); | 1726 | uid = inR->uid(); |
1721 | bool skipIncidence = false; | 1727 | bool skipIncidence = false; |
1722 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1728 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1723 | skipIncidence = true; | 1729 | skipIncidence = true; |
1724 | QString idS; | 1730 | QString idS; |
1725 | qApp->processEvents(); | 1731 | qApp->processEvents(); |
1726 | if ( !skipIncidence ) { | 1732 | if ( !skipIncidence ) { |
1727 | int hasCalId = 0; | 1733 | int hasCalId = 0; |
1728 | inL = local->incidenceForUid( uid , false , true, &hasCalId ); | 1734 | inL = local->incidenceForUid( uid , false , true, &hasCalId ); |
1729 | if ( hasCalId && !inL ) | 1735 | if ( hasCalId && !inL ) |
1730 | inL = local->incidenceForUid( uid , false , true, &hasCalId ); | 1736 | inL = local->incidenceForUid( uid , false , true, &hasCalId ); |
1731 | else | 1737 | else |
1732 | hasCalId = 0; | 1738 | hasCalId = 0; |
1733 | if ( inL ) { // maybe conflict - same uid in both calendars | 1739 | if ( inL ) { // maybe conflict - same uid in both calendars |
1734 | 1740 | ||
1735 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1741 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1736 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1742 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1737 | if ( take == 3 ) | 1743 | if ( take == 3 ) |
1738 | return false; | 1744 | return false; |
1739 | if ( take == 1 ) {// take local ********************** | 1745 | if ( take == 1 ) {// take local ********************** |
1740 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1746 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1741 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1747 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1742 | else | 1748 | else |
1743 | idS = inR->IDStr(); | 1749 | idS = inR->IDStr(); |
1744 | int calID = inR->calID(); | 1750 | int calID = inR->calID(); |
1745 | remote->deleteIncidence( inR ); | 1751 | remote->deleteIncidence( inR ); |
1746 | if ( !hasCalId ) { | 1752 | if ( !hasCalId ) { |
1747 | inR = inL->clone(); | 1753 | inR = inL->clone(); |
1748 | inR->setCalID_block( calID ); | 1754 | inR->setCalID_block( calID ); |
1749 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1755 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1750 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1756 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1751 | inR->setIDStr( idS ); | 1757 | inR->setIDStr( idS ); |
1752 | remote->addIncidence( inR ); | 1758 | remote->addIncidence( inR ); |
1753 | if ( mSyncManager->syncWithDesktop() ) | 1759 | if ( mSyncManager->syncWithDesktop() ) |
1754 | inR->setPilotId( 2 ); | 1760 | inR->setPilotId( 2 ); |
1755 | ++changedRemote; | 1761 | ++changedRemote; |
1756 | } else | 1762 | } else |
1757 | ++deletedEventR; | 1763 | ++deletedEventR; |
1758 | } else {// take remote ********************** | 1764 | } else {// take remote ********************** |
1759 | if ( !inL->isReadOnly() ) { | 1765 | if ( !inL->isReadOnly() ) { |
1760 | idS = inL->IDStr(); | 1766 | idS = inL->IDStr(); |
1761 | int pid = inL->pilotId(); | 1767 | int pid = inL->pilotId(); |
1762 | int calID = inL->calID(); | 1768 | int calID = inL->calID(); |
1763 | if ( hasCalId ) | 1769 | if ( hasCalId ) |
1764 | calID = 0;// add to default calendar | 1770 | calID = 0;// add to default calendar |
1765 | local->deleteIncidence( inL ); | 1771 | local->deleteIncidence( inL ); |
1766 | inL = inR->clone(); | 1772 | inL = inR->clone(); |
1767 | inL->setCalID_block( calID ); | 1773 | inL->setCalID_block( calID ); |
1768 | if ( mSyncManager->syncWithDesktop() ) | 1774 | if ( mSyncManager->syncWithDesktop() ) |
1769 | inL->setPilotId( pid ); | 1775 | inL->setPilotId( pid ); |
1770 | inL->setIDStr( idS ); | 1776 | inL->setIDStr( idS ); |
1771 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1777 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1772 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1778 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1773 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1779 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1774 | } | 1780 | } |
1775 | local->addIncidence( inL ); | 1781 | local->addIncidence( inL ); |
1776 | ++changedLocal; | 1782 | ++changedLocal; |
1777 | } | 1783 | } |
1778 | } | 1784 | } |
1779 | } else { | 1785 | } else { |
1780 | // take == 0; events equal | 1786 | // take == 0; events equal |
1781 | if ( hasCalId ) { | 1787 | if ( hasCalId ) { |
1782 | qDebug("KO: Changing Cal id %d to %d for : %s ", hasCalId, local->defaultCalendar(),inL->summary().latin1()); | 1788 | qDebug("KO: Changing Cal id %d to %d for : %s ", hasCalId, local->defaultCalendar(),inL->summary().latin1()); |
1783 | inL->setCalID( local->defaultCalendar() ); | 1789 | inL->setCalID( local->defaultCalendar() ); |
1784 | } | 1790 | } |
1785 | 1791 | ||
1786 | } | 1792 | } |
1787 | 1793 | ||
1788 | 1794 | ||
1789 | } else { // no conflict ********** add or delete remote | 1795 | } else { // no conflict ********** add or delete remote |
1790 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1796 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1797 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1792 | QString des = eventLSync->description(); | 1798 | QString des = eventLSync->description(); |
1793 | QString pref = "e"; | 1799 | QString pref = "e"; |
1794 | if ( inR->typeID() == todoID ) | 1800 | if ( inR->typeID() == todoID ) |
1795 | pref = "t"; | 1801 | pref = "t"; |
1796 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1802 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1797 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1803 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1798 | //remote->deleteIncidence( inR ); | 1804 | //remote->deleteIncidence( inR ); |
1799 | ++deletedEventR; | 1805 | ++deletedEventR; |
1800 | } else { | 1806 | } else { |
1801 | inR->setLastModified( modifiedCalendar ); | 1807 | inR->setLastModified( modifiedCalendar ); |
1802 | inL = inR->clone(); | 1808 | inL = inR->clone(); |
1803 | inL->setIDStr( ":" ); | 1809 | inL->setIDStr( ":" ); |
1804 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1810 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1805 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1811 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1806 | 1812 | ||
1807 | inL->setCalID_block( 0 );// add to default cal | 1813 | inL->setCalID_block( 0 );// add to default cal |
1808 | local->addIncidence( inL ); | 1814 | local->addIncidence( inL ); |
1809 | ++addedEvent; | 1815 | ++addedEvent; |
1810 | 1816 | ||
1811 | } | 1817 | } |
1812 | } else { | 1818 | } else { |
1813 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1819 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1814 | inR->setLastModified( modifiedCalendar ); | 1820 | inR->setLastModified( modifiedCalendar ); |
1815 | inL = inR->clone(); | 1821 | inL = inR->clone(); |
1816 | inL->setIDStr( ":" ); | 1822 | inL->setIDStr( ":" ); |
1817 | inL->setCalID_block( 0 );// add to default cal | 1823 | inL->setCalID_block( 0 );// add to default cal |
1818 | local->addIncidence( inL ); | 1824 | local->addIncidence( inL ); |
1819 | ++addedEvent; | 1825 | ++addedEvent; |
1820 | 1826 | ||
1821 | } else { | 1827 | } else { |
1822 | checkExternSyncEvent(eventRSyncSharp, inR); | 1828 | checkExternSyncEvent(eventRSyncSharp, inR); |
1823 | remote->deleteIncidence( inR ); | 1829 | remote->deleteIncidence( inR ); |
1824 | ++deletedEventR; | 1830 | ++deletedEventR; |
1825 | } | 1831 | } |
1826 | } | 1832 | } |
1827 | } else { | 1833 | } else { |
1828 | ++filteredIN; | 1834 | ++filteredIN; |
1829 | } | 1835 | } |
1830 | } | 1836 | } |
1831 | } | 1837 | } |
1832 | inR = er.next(); | 1838 | inR = er.next(); |
1833 | } | 1839 | } |
1834 | QPtrList<Incidence> el = local->rawIncidences(); | 1840 | Q3PtrList<Incidence> el = local->rawIncidences(); |
1835 | inL = el.first(); | 1841 | inL = el.first(); |
1836 | modulo = (el.count()/10)+1; | 1842 | modulo = (el.count()/10)+1; |
1837 | bar.setCaption (i18n("Add / remove events") ); | 1843 | bar.setCaption (i18n("Add / remove events") ); |
1838 | bar.setTotalSteps ( el.count() ) ; | 1844 | bar.setTotalSteps ( el.count() ) ; |
1839 | bar.show(); | 1845 | bar.show(); |
1840 | incCounter = 0; | 1846 | incCounter = 0; |
1841 | 1847 | ||
1842 | while ( inL ) { | 1848 | while ( inL ) { |
1843 | 1849 | ||
1844 | qApp->processEvents(); | 1850 | qApp->processEvents(); |
1845 | if ( ! bar.isVisible() ) | 1851 | if ( ! bar.isVisible() ) |
1846 | return false; | 1852 | return false; |
1847 | if ( incCounter % modulo == 0 ) | 1853 | if ( incCounter % modulo == 0 ) |
1848 | bar.setProgress( incCounter ); | 1854 | bar.setProgress( incCounter ); |
1849 | ++incCounter; | 1855 | ++incCounter; |
1850 | uid = inL->uid(); | 1856 | uid = inL->uid(); |
1851 | bool skipIncidence = false; | 1857 | bool skipIncidence = false; |
1852 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1858 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1853 | skipIncidence = true; | 1859 | skipIncidence = true; |
1854 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1860 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1855 | skipIncidence = true; | 1861 | skipIncidence = true; |
1856 | if ( !skipIncidence ) { | 1862 | if ( !skipIncidence ) { |
1857 | inR = remote->incidenceForUid( uid , true, true ); | 1863 | inR = remote->incidenceForUid( uid , true, true ); |
1858 | if ( ! inR ) { | 1864 | if ( ! inR ) { |
1859 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1865 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1860 | // no conflict ********** add or delete local | 1866 | // no conflict ********** add or delete local |
1861 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1867 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1862 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1868 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1863 | checkExternSyncEvent(eventLSyncSharp, inL); | 1869 | checkExternSyncEvent(eventLSyncSharp, inL); |
1864 | local->deleteIncidence( inL ); | 1870 | local->deleteIncidence( inL ); |
1865 | ++deletedEventL; | 1871 | ++deletedEventL; |
1866 | } else { | 1872 | } else { |
1867 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1873 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1868 | inL->removeID(mCurrentSyncDevice ); | 1874 | inL->removeID(mCurrentSyncDevice ); |
1869 | ++addedEventR; | 1875 | ++addedEventR; |
1870 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1876 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1871 | inL->setLastModified( modifiedCalendar ); | 1877 | inL->setLastModified( modifiedCalendar ); |
1872 | inR = inL->clone(); | 1878 | inR = inL->clone(); |
1873 | inR->setIDStr( ":" ); | 1879 | inR->setIDStr( ":" ); |
1874 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1880 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1875 | inR->setCalID_block( 0 );// add to default cal | 1881 | inR->setCalID_block( 0 );// add to default cal |
1876 | remote->addIncidence( inR ); | 1882 | remote->addIncidence( inR ); |
1877 | } | 1883 | } |
1878 | } | 1884 | } |
1879 | } else { | 1885 | } else { |
1880 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1886 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1881 | checkExternSyncEvent(eventLSyncSharp, inL); | 1887 | checkExternSyncEvent(eventLSyncSharp, inL); |
1882 | local->deleteIncidence( inL ); | 1888 | local->deleteIncidence( inL ); |
1883 | ++deletedEventL; | 1889 | ++deletedEventL; |
1884 | } else { | 1890 | } else { |
1885 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1891 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1886 | ++addedEventR; | 1892 | ++addedEventR; |
1887 | inL->setLastModified( modifiedCalendar ); | 1893 | inL->setLastModified( modifiedCalendar ); |
1888 | inR = inL->clone(); | 1894 | inR = inL->clone(); |
1889 | inR->setIDStr( ":" ); | 1895 | inR->setIDStr( ":" ); |
1890 | inR->setCalID_block( 0 );// add to default cal | 1896 | inR->setCalID_block( 0 );// add to default cal |
1891 | remote->addIncidence( inR ); | 1897 | remote->addIncidence( inR ); |
1892 | } | 1898 | } |
1893 | } | 1899 | } |
1894 | } | 1900 | } |
1895 | } else { | 1901 | } else { |
1896 | ++filteredOUT; | 1902 | ++filteredOUT; |
1897 | } | 1903 | } |
1898 | } | 1904 | } |
1899 | } | 1905 | } |
1900 | inL = el.next(); | 1906 | inL = el.next(); |
1901 | } | 1907 | } |
1902 | int delFut = 0; | 1908 | int delFut = 0; |
1903 | int remRem = 0; | 1909 | int remRem = 0; |
1904 | if ( mSyncManager->mWriteBackInFuture ) { | 1910 | if ( mSyncManager->mWriteBackInFuture ) { |
1905 | er = remote->rawIncidences(); | 1911 | er = remote->rawIncidences(); |
1906 | remRem = er.count(); | 1912 | remRem = er.count(); |
1907 | inR = er.first(); | 1913 | inR = er.first(); |
1908 | QDateTime dt; | 1914 | QDateTime dt; |
1909 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1915 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1910 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1916 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1911 | while ( inR ) { | 1917 | while ( inR ) { |
1912 | if ( inR->typeID() == todoID ) { | 1918 | if ( inR->typeID() == todoID ) { |
1913 | Todo * t = (Todo*)inR; | 1919 | Todo * t = (Todo*)inR; |
1914 | if ( t->hasDueDate() ) | 1920 | if ( t->hasDueDate() ) |
1915 | dt = t->dtDue(); | 1921 | dt = t->dtDue(); |
1916 | else | 1922 | else |
1917 | dt = cur.addSecs( 62 ); | 1923 | dt = cur.addSecs( 62 ); |
1918 | } | 1924 | } |
1919 | else if (inR->typeID() == eventID ) { | 1925 | else if (inR->typeID() == eventID ) { |
1920 | bool ok; | 1926 | bool ok; |
1921 | dt = inR->getNextOccurence( cur, &ok ); | 1927 | dt = inR->getNextOccurence( cur, &ok ); |
1922 | if ( !ok ) | 1928 | if ( !ok ) |
1923 | dt = cur.addSecs( -62 ); | 1929 | dt = cur.addSecs( -62 ); |
1924 | } | 1930 | } |
1925 | else | 1931 | else |
1926 | dt = inR->dtStart(); | 1932 | dt = inR->dtStart(); |
1927 | if ( dt < cur || dt > end ) { | 1933 | if ( dt < cur || dt > end ) { |
1928 | remote->deleteIncidence( inR ); | 1934 | remote->deleteIncidence( inR ); |
1929 | ++delFut; | 1935 | ++delFut; |
1930 | } | 1936 | } |
1931 | inR = er.next(); | 1937 | inR = er.next(); |
1932 | } | 1938 | } |
1933 | } | 1939 | } |
1934 | bar.hide(); | 1940 | bar.hide(); |
1935 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1941 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1936 | if ( mMultiResourceSync ) { | 1942 | if ( mMultiResourceSync ) { |
1937 | remote->removeSyncInfo( "" ); //all | 1943 | remote->removeSyncInfo( "" ); //all |
1938 | qDebug("KO: Remoing all sync info on remote "); | 1944 | qDebug("KO: Remoing all sync info on remote "); |
1939 | } else { | 1945 | } else { |
1940 | eventLSync->setReadOnly( false ); | 1946 | eventLSync->setReadOnly( false ); |
1941 | eventLSync->setDtStart( mLastCalendarSync ); | 1947 | eventLSync->setDtStart( mLastCalendarSync ); |
1942 | eventRSync->setDtStart( mLastCalendarSync ); | 1948 | eventRSync->setDtStart( mLastCalendarSync ); |
1943 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1949 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1944 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1950 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1945 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1951 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1946 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1952 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1947 | eventLSync->setReadOnly( true ); | 1953 | eventLSync->setReadOnly( true ); |
1948 | } | 1954 | } |
1949 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1955 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1950 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal... | 1956 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal... |
1951 | remote->addEvent( eventRSync ); | 1957 | remote->addEvent( eventRSync ); |
1952 | else | 1958 | else |
1953 | delete eventRSync; | 1959 | delete eventRSync; |
1954 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1960 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1955 | QString mes; | 1961 | QString mes; |
1956 | 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 ); | 1962 | 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 ); |
1957 | QString delmess; | 1963 | QString delmess; |
1958 | if ( delFut ) { | 1964 | if ( delFut ) { |
1959 | 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); | 1965 | 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); |
1960 | mes += delmess; | 1966 | mes += delmess; |
1961 | } | 1967 | } |
1962 | mes = i18n("Local calendar changed!\n") +mes; | 1968 | mes = i18n("Local calendar changed!\n") +mes; |
1963 | mCalendar->checkAlarmForIncidence( 0, true ); | 1969 | mCalendar->checkAlarmForIncidence( 0, true ); |
1964 | qDebug( mes ); | 1970 | qDebug( mes ); |
1965 | if ( mSyncManager->mShowSyncSummary ) { | 1971 | if ( mSyncManager->mShowSyncSummary ) { |
1966 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1972 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1967 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1973 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1968 | qDebug("KO: WB cancelled "); | 1974 | qDebug("KO: WB cancelled "); |
1969 | mSyncManager->mWriteBackFile = false; | 1975 | mSyncManager->mWriteBackFile = false; |
1970 | return syncOK; | 1976 | return syncOK; |
1971 | } | 1977 | } |
1972 | } | 1978 | } |
1973 | return syncOK; | 1979 | return syncOK; |
1974 | } | 1980 | } |
1975 | 1981 | ||
1976 | void CalendarView::setSyncDevice( QString s ) | 1982 | void CalendarView::setSyncDevice( QString s ) |
1977 | { | 1983 | { |
1978 | mCurrentSyncDevice= s; | 1984 | mCurrentSyncDevice= s; |
1979 | } | 1985 | } |
1980 | void CalendarView::setSyncName( QString s ) | 1986 | void CalendarView::setSyncName( QString s ) |
1981 | { | 1987 | { |
1982 | mCurrentSyncName= s; | 1988 | mCurrentSyncName= s; |
1983 | } | 1989 | } |
1984 | bool CalendarView::syncCalendar(QString filename, int mode) | 1990 | bool CalendarView::syncCalendar(QString filename, int mode) |
1985 | { | 1991 | { |
1986 | //qDebug("syncCalendar %s ", filename.latin1()); | 1992 | //qDebug("syncCalendar %s ", filename.latin1()); |
1987 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1993 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1988 | CalendarLocal* calendar = new CalendarLocal(); | 1994 | CalendarLocal* calendar = new CalendarLocal(); |
1989 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1995 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1990 | FileStorage* storage = new FileStorage( calendar ); | 1996 | FileStorage* storage = new FileStorage( calendar ); |
1991 | bool syncOK = false; | 1997 | bool syncOK = false; |
1992 | storage->setFileName( filename ); | 1998 | storage->setFileName( filename ); |
1993 | // qDebug("loading ... "); | 1999 | // qDebug("loading ... "); |
1994 | if ( storage->load() ) { | 2000 | if ( storage->load() ) { |
1995 | getEventViewerDialog()->setSyncMode( true ); | 2001 | getEventViewerDialog()->setSyncMode( true ); |
1996 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2002 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1997 | getEventViewerDialog()->setSyncMode( false ); | 2003 | getEventViewerDialog()->setSyncMode( false ); |
1998 | if ( syncOK ) { | 2004 | if ( syncOK ) { |
1999 | if ( mSyncManager->mWriteBackFile ) | 2005 | if ( mSyncManager->mWriteBackFile ) |
2000 | { | 2006 | { |
2001 | storage->setSaveFormat( new ICalFormat() ); | 2007 | storage->setSaveFormat( new ICalFormat() ); |
2002 | storage->save(); | 2008 | storage->save(); |
2003 | } | 2009 | } |
2004 | } | 2010 | } |
2005 | setModified( true ); | 2011 | setModified( true ); |
2006 | } | 2012 | } |
2007 | delete storage; | 2013 | delete storage; |
2008 | delete calendar; | 2014 | delete calendar; |
2009 | if ( syncOK ) | 2015 | if ( syncOK ) |
2010 | updateView(); | 2016 | updateView(); |
2011 | return syncOK; | 2017 | return syncOK; |
2012 | } | 2018 | } |
2013 | 2019 | ||
2014 | void CalendarView::syncExternal( int mode ) | 2020 | void CalendarView::syncExternal( int mode ) |
2015 | { | 2021 | { |
2016 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2022 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2017 | qApp->processEvents(); | 2023 | qApp->processEvents(); |
2018 | CalendarLocal* calendar = new CalendarLocal(); | 2024 | CalendarLocal* calendar = new CalendarLocal(); |
2019 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2025 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2020 | bool syncOK = false; | 2026 | bool syncOK = false; |
2021 | bool loadSuccess = false; | 2027 | bool loadSuccess = false; |
2022 | PhoneFormat* phoneFormat = 0; | 2028 | PhoneFormat* phoneFormat = 0; |
2023 | emit tempDisableBR(true); | 2029 | emit tempDisableBR(true); |
2024 | #ifndef DESKTOP_VERSION | 2030 | #ifndef DESKTOP_VERSION |
2025 | SharpFormat* sharpFormat = 0; | 2031 | SharpFormat* sharpFormat = 0; |
2026 | if ( mode == 0 ) { // sharp | 2032 | if ( mode == 0 ) { // sharp |
2027 | sharpFormat = new SharpFormat () ; | 2033 | sharpFormat = new SharpFormat () ; |
2028 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 2034 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
2029 | 2035 | ||
2030 | } else | 2036 | } else |
2031 | #endif | 2037 | #endif |
2032 | if ( mode == 1 ) { // phone | 2038 | if ( mode == 1 ) { // phone |
2033 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 2039 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
2034 | mSyncManager->mPhoneDevice, | 2040 | mSyncManager->mPhoneDevice, |
2035 | mSyncManager->mPhoneConnection, | 2041 | mSyncManager->mPhoneConnection, |
2036 | mSyncManager->mPhoneModel); | 2042 | mSyncManager->mPhoneModel); |
2037 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 2043 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
2038 | 2044 | ||
2039 | } else { | 2045 | } else { |
2040 | emit tempDisableBR(false); | 2046 | emit tempDisableBR(false); |
2041 | return; | 2047 | return; |
2042 | } | 2048 | } |
2043 | if ( loadSuccess ) { | 2049 | if ( loadSuccess ) { |
2044 | getEventViewerDialog()->setSyncMode( true ); | 2050 | getEventViewerDialog()->setSyncMode( true ); |
2045 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2051 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2046 | getEventViewerDialog()->setSyncMode( false ); | 2052 | getEventViewerDialog()->setSyncMode( false ); |
2047 | qApp->processEvents(); | 2053 | qApp->processEvents(); |
2048 | if ( syncOK ) { | 2054 | if ( syncOK ) { |
2049 | if ( mSyncManager->mWriteBackFile ) | 2055 | if ( mSyncManager->mWriteBackFile ) |
2050 | { | 2056 | { |
2051 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 2057 | Q3PtrList<Incidence> iL = mCalendar->rawIncidences(); |
2052 | Incidence* inc = iL.first(); | 2058 | Incidence* inc = iL.first(); |
2053 | if ( phoneFormat ) { | 2059 | if ( phoneFormat ) { |
2054 | while ( inc ) { | 2060 | while ( inc ) { |
2055 | inc->removeID(mCurrentSyncDevice); | 2061 | inc->removeID(mCurrentSyncDevice); |
2056 | inc = iL.next(); | 2062 | inc = iL.next(); |
2057 | } | 2063 | } |
2058 | } | 2064 | } |
2059 | #ifndef DESKTOP_VERSION | 2065 | #ifndef DESKTOP_VERSION |
2060 | if ( sharpFormat ) | 2066 | if ( sharpFormat ) |
2061 | sharpFormat->save(calendar); | 2067 | sharpFormat->save(calendar); |
2062 | #endif | 2068 | #endif |
2063 | if ( phoneFormat ) | 2069 | if ( phoneFormat ) |
2064 | phoneFormat->save(calendar); | 2070 | phoneFormat->save(calendar); |
2065 | iL = calendar->rawIncidences(); | 2071 | iL = calendar->rawIncidences(); |
2066 | inc = iL.first(); | 2072 | inc = iL.first(); |
2067 | Incidence* loc; | 2073 | Incidence* loc; |
2068 | while ( inc ) { | 2074 | while ( inc ) { |
2069 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 2075 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
2070 | loc = mCalendar->incidence(inc->uid() ); | 2076 | loc = mCalendar->incidence(inc->uid() ); |
2071 | if ( loc ) { | 2077 | if ( loc ) { |
2072 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 2078 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
2073 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 2079 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
2074 | } | 2080 | } |
2075 | } | 2081 | } |
2076 | inc = iL.next(); | 2082 | inc = iL.next(); |
2077 | } | 2083 | } |
2078 | Incidence* lse = getLastSyncEvent(); | 2084 | Incidence* lse = getLastSyncEvent(); |
2079 | if ( lse ) { | 2085 | if ( lse ) { |
2080 | lse->setReadOnly( false ); | 2086 | lse->setReadOnly( false ); |
2081 | lse->setDescription( "" ); | 2087 | lse->setDescription( "" ); |
2082 | lse->setReadOnly( true ); | 2088 | lse->setReadOnly( true ); |
2083 | } | 2089 | } |
2084 | } | 2090 | } |
2085 | } else { | 2091 | } else { |
2086 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 2092 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
2087 | } | 2093 | } |
2088 | setModified( true ); | 2094 | setModified( true ); |
2089 | } else { | 2095 | } else { |
2090 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 2096 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
2091 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 2097 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
2092 | question, i18n("Ok")) ; | 2098 | question, i18n("Ok")) ; |
2093 | 2099 | ||
2094 | } | 2100 | } |
2095 | delete calendar; | 2101 | delete calendar; |
2096 | updateView(); | 2102 | updateView(); |
2097 | emit tempDisableBR(false); | 2103 | emit tempDisableBR(false); |
2098 | return ;//syncOK; | 2104 | return ;//syncOK; |
2099 | 2105 | ||
2100 | } | 2106 | } |
2101 | 2107 | ||
2102 | bool CalendarView::importBday() | 2108 | bool CalendarView::importBday() |
2103 | { | 2109 | { |
2104 | #ifndef KORG_NOKABC | 2110 | #ifndef KORG_NOKABC |
2105 | 2111 | ||
2106 | #ifdef DESKTOP_VERSION | 2112 | #ifdef DESKTOP_VERSION |
2107 | int curCal = mCalendar->defaultCalendar(); | 2113 | int curCal = mCalendar->defaultCalendar(); |
2108 | int bd = mCalEditView->getBirtdayID(); | 2114 | int bd = mCalEditView->getBirtdayID(); |
2109 | if ( bd == 0 ) | 2115 | if ( bd == 0 ) |
2110 | return false; | 2116 | return false; |
2111 | mCalendar->setDefaultCalendar( bd ); | 2117 | mCalendar->setDefaultCalendar( bd ); |
2112 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 2118 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
2113 | KABC::AddressBook::Iterator it; | 2119 | KABC::AddressBook::Iterator it; |
2114 | int count = 0; | 2120 | int count = 0; |
2115 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2121 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2116 | ++count; | 2122 | ++count; |
2117 | } | 2123 | } |
2118 | QProgressBar bar(count,0 ); | 2124 | Q3ProgressBar bar(count,0 ); |
2119 | int w = 300; | 2125 | int w = 300; |
2120 | if ( QApplication::desktop()->width() < 320 ) | 2126 | if ( QApplication::desktop()->width() < 320 ) |
2121 | w = 220; | 2127 | w = 220; |
2122 | int h = bar.sizeHint().height() ; | 2128 | int h = bar.sizeHint().height() ; |
2123 | int dw = QApplication::desktop()->width(); | 2129 | int dw = QApplication::desktop()->width(); |
2124 | int dh = QApplication::desktop()->height(); | 2130 | int dh = QApplication::desktop()->height(); |
2125 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2131 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2126 | bar.show(); | 2132 | bar.show(); |
2127 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 2133 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
2128 | qApp->processEvents(); | 2134 | qApp->processEvents(); |
2129 | count = 0; | 2135 | count = 0; |
2130 | int addCount = 0; | 2136 | int addCount = 0; |
2131 | KCal::Attendee* a = 0; | 2137 | KCal::Attendee* a = 0; |
2132 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2138 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2133 | if ( ! bar.isVisible() ) | 2139 | if ( ! bar.isVisible() ) |
2134 | return false; | 2140 | return false; |
2135 | bar.setProgress( count++ ); | 2141 | bar.setProgress( count++ ); |
2136 | qApp->processEvents(); | 2142 | qApp->processEvents(); |
2137 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 2143 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
2138 | if ( (*it).birthday().date().isValid() ){ | 2144 | if ( (*it).birthday().date().isValid() ){ |
2139 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2145 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2140 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 2146 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
2141 | ++addCount; | 2147 | ++addCount; |
2142 | } | 2148 | } |
2143 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 2149 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
2144 | if ( anni.isValid() ){ | 2150 | if ( anni.isValid() ){ |
2145 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2151 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2146 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 2152 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
2147 | ++addCount; | 2153 | ++addCount; |
2148 | } | 2154 | } |
2149 | } | 2155 | } |
2150 | mCalendar->setDefaultCalendar( curCal ); | 2156 | mCalendar->setDefaultCalendar( curCal ); |
2151 | updateView(); | 2157 | updateView(); |
2152 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2158 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2153 | #else //DESKTOP_VERSION | 2159 | #else //DESKTOP_VERSION |
2154 | 2160 | ||
2155 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 2161 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
2156 | // the result should now arrive through method insertBirthdays | 2162 | // the result should now arrive through method insertBirthdays |
2157 | 2163 | ||
2158 | #endif //DESKTOP_VERSION | 2164 | #endif //DESKTOP_VERSION |
2159 | 2165 | ||
2160 | #endif //KORG_NOKABC | 2166 | #endif //KORG_NOKABC |
2161 | 2167 | ||
2162 | 2168 | ||
2163 | return true; | 2169 | return true; |
2164 | } | 2170 | } |
2165 | 2171 | ||
2166 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 2172 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
2167 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 2173 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
2168 | const QStringList& anniversaryList, const QStringList& realNameList, | 2174 | const QStringList& anniversaryList, const QStringList& realNameList, |
2169 | const QStringList& emailList, const QStringList& assembledNameList, | 2175 | const QStringList& emailList, const QStringList& assembledNameList, |
2170 | const QStringList& uidList) | 2176 | const QStringList& uidList) |
2171 | { | 2177 | { |
2172 | 2178 | ||
2173 | //qDebug("KO::CalendarView::insertBirthdays"); | 2179 | //qDebug("KO::CalendarView::insertBirthdays"); |
2174 | if (uid == this->name()) | 2180 | if (uid == this->name()) |
2175 | { | 2181 | { |
2176 | int curCal = mCalendar->defaultCalendar(); | 2182 | int curCal = mCalendar->defaultCalendar(); |
2177 | int bd = mCalEditView->getBirtdayID(); | 2183 | int bd = mCalEditView->getBirtdayID(); |
2178 | if ( bd == 0 ) | 2184 | if ( bd == 0 ) |
2179 | return; | 2185 | return; |
2180 | mCalendar->setDefaultCalendar( bd ); | 2186 | mCalendar->setDefaultCalendar( bd ); |
2181 | 2187 | ||
2182 | 2188 | ||
2183 | int count = birthdayList.count(); | 2189 | int count = birthdayList.count(); |
2184 | int addCount = 0; | 2190 | int addCount = 0; |
2185 | KCal::Attendee* a = 0; | 2191 | KCal::Attendee* a = 0; |
2186 | 2192 | ||
2187 | //qDebug("CalView 1 %i", count); | 2193 | //qDebug("CalView 1 %i", count); |
2188 | 2194 | ||
2189 | QProgressBar bar(count,0 ); | 2195 | Q3ProgressBar bar(count,0 ); |
2190 | int w = 300; | 2196 | int w = 300; |
2191 | if ( QApplication::desktop()->width() < 320 ) | 2197 | if ( QApplication::desktop()->width() < 320 ) |
2192 | w = 220; | 2198 | w = 220; |
2193 | int h = bar.sizeHint().height() ; | 2199 | int h = bar.sizeHint().height() ; |
2194 | int dw = QApplication::desktop()->width(); | 2200 | int dw = QApplication::desktop()->width(); |
2195 | int dh = QApplication::desktop()->height(); | 2201 | int dh = QApplication::desktop()->height(); |
2196 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2202 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2197 | bar.show(); | 2203 | bar.show(); |
2198 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 2204 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
2199 | qApp->processEvents(); | 2205 | qApp->processEvents(); |
2200 | 2206 | ||
2201 | QDate birthday; | 2207 | QDate birthday; |
2202 | QDate anniversary; | 2208 | QDate anniversary; |
2203 | QString realName; | 2209 | QString realName; |
2204 | QString email; | 2210 | QString email; |
2205 | QString assembledName; | 2211 | QString assembledName; |
2206 | QString uid; | 2212 | QString uid; |
2207 | bool ok = true; | 2213 | bool ok = true; |
2208 | for ( int i = 0; i < count; i++) | 2214 | for ( int i = 0; i < count; i++) |
2209 | { | 2215 | { |
2210 | if ( ! bar.isVisible() ) | 2216 | if ( ! bar.isVisible() ) |
2211 | return; | 2217 | return; |
2212 | bar.setProgress( i ); | 2218 | bar.setProgress( i ); |
2213 | qApp->processEvents(); | 2219 | qApp->processEvents(); |
2214 | 2220 | ||
2215 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 2221 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
2216 | if (!ok) { | 2222 | if (!ok) { |
2217 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 2223 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
2218 | } | 2224 | } |
2219 | 2225 | ||
2220 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 2226 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
2221 | if (!ok) { | 2227 | if (!ok) { |
2222 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 2228 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
2223 | } | 2229 | } |
2224 | realName = realNameList[i]; | 2230 | realName = realNameList[i]; |
2225 | email = emailList[i]; | 2231 | email = emailList[i]; |
2226 | assembledName = assembledNameList[i]; | 2232 | assembledName = assembledNameList[i]; |
2227 | uid = uidList[i]; | 2233 | uid = uidList[i]; |
2228 | //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() ); | 2234 | //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() ); |
2229 | 2235 | ||
2230 | if ( birthday.isValid() ){ | 2236 | if ( birthday.isValid() ){ |
2231 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2237 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2232 | KCal::Attendee::ReqParticipant,uid) ; | 2238 | KCal::Attendee::ReqParticipant,uid) ; |
2233 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 2239 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
2234 | ++addCount; | 2240 | ++addCount; |
2235 | } | 2241 | } |
2236 | 2242 | ||
2237 | if ( anniversary.isValid() ){ | 2243 | if ( anniversary.isValid() ){ |
2238 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2244 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2239 | KCal::Attendee::ReqParticipant,uid) ; | 2245 | KCal::Attendee::ReqParticipant,uid) ; |
2240 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 2246 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
2241 | ++addCount; | 2247 | ++addCount; |
2242 | } | 2248 | } |
2243 | } | 2249 | } |
2244 | 2250 | ||
2245 | mCalendar->setDefaultCalendar( curCal ); | 2251 | mCalendar->setDefaultCalendar( curCal ); |
2246 | updateView(); | 2252 | updateView(); |
2247 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2253 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2248 | 2254 | ||
2249 | } | 2255 | } |
2250 | 2256 | ||
2251 | } | 2257 | } |
2252 | 2258 | ||
2253 | 2259 | ||
2254 | 2260 | ||
2255 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 2261 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
2256 | { | 2262 | { |
2257 | //qDebug("addAnni "); | 2263 | //qDebug("addAnni "); |
2258 | Event * ev = new Event(); | 2264 | Event * ev = new Event(); |
2259 | ev->setOrganizer(KOPrefs::instance()->email()); | 2265 | ev->setOrganizer(KOPrefs::instance()->email()); |
2260 | if ( a ) { | 2266 | if ( a ) { |
2261 | ev->addAttendee( a ); | 2267 | ev->addAttendee( a ); |
2262 | } | 2268 | } |
2263 | QString kind; | 2269 | QString kind; |
2264 | if ( birthday ) { | 2270 | if ( birthday ) { |
2265 | kind = i18n( "Birthday" ); | 2271 | kind = i18n( "Birthday" ); |
2266 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 2272 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
2267 | } | 2273 | } |
2268 | else { | 2274 | else { |
2269 | kind = i18n( "Anniversary" ); | 2275 | kind = i18n( "Anniversary" ); |
2270 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 2276 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
2271 | } | 2277 | } |
2272 | ev->setCategories( kind ); | 2278 | ev->setCategories( kind ); |
2273 | ev->setDtStart( QDateTime(date) ); | 2279 | ev->setDtStart( QDateTime(date) ); |
2274 | ev->setDtEnd( QDateTime(date) ); | 2280 | ev->setDtEnd( QDateTime(date) ); |
2275 | ev->setFloats( true ); | 2281 | ev->setFloats( true ); |
2276 | Recurrence * rec = ev->recurrence(); | 2282 | Recurrence * rec = ev->recurrence(); |
2277 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 2283 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
2278 | rec->addYearlyNum( date.month() ); | 2284 | rec->addYearlyNum( date.month() ); |
2279 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 2285 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
2280 | delete ev; | 2286 | delete ev; |
2281 | return false; | 2287 | return false; |
2282 | } | 2288 | } |
2283 | return true; | 2289 | return true; |
2284 | 2290 | ||
2285 | } | 2291 | } |
2286 | bool CalendarView::importQtopia( const QString &categories, | 2292 | bool CalendarView::importQtopia( const QString &categories, |
2287 | const QString &datebook, | 2293 | const QString &datebook, |
2288 | const QString &todolist ) | 2294 | const QString &todolist ) |
2289 | { | 2295 | { |
2290 | 2296 | ||
2291 | QtopiaFormat qtopiaFormat; | 2297 | QtopiaFormat qtopiaFormat; |
2292 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2298 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2293 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2299 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2294 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2300 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2295 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2301 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2296 | 2302 | ||
2297 | updateView(); | 2303 | updateView(); |
2298 | return true; | 2304 | return true; |
2299 | 2305 | ||
2300 | #if 0 | 2306 | #if 0 |
2301 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2307 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2302 | mCurrentSyncDevice = "qtopia-XML"; | 2308 | mCurrentSyncDevice = "qtopia-XML"; |
2303 | if ( mSyncManager->mAskForPreferences ) | 2309 | if ( mSyncManager->mAskForPreferences ) |
2304 | edit_sync_options(); | 2310 | edit_sync_options(); |
2305 | qApp->processEvents(); | 2311 | qApp->processEvents(); |
2306 | CalendarLocal* calendar = new CalendarLocal(); | 2312 | CalendarLocal* calendar = new CalendarLocal(); |
2307 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2313 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2308 | bool syncOK = false; | 2314 | bool syncOK = false; |
2309 | QtopiaFormat qtopiaFormat; | 2315 | QtopiaFormat qtopiaFormat; |
2310 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2316 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2311 | bool loadOk = true; | 2317 | bool loadOk = true; |
2312 | if ( !categories.isEmpty() ) | 2318 | if ( !categories.isEmpty() ) |
2313 | loadOk = qtopiaFormat.load( calendar, categories ); | 2319 | loadOk = qtopiaFormat.load( calendar, categories ); |
2314 | if ( loadOk && !datebook.isEmpty() ) | 2320 | if ( loadOk && !datebook.isEmpty() ) |
2315 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2321 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2316 | if ( loadOk && !todolist.isEmpty() ) | 2322 | if ( loadOk && !todolist.isEmpty() ) |
2317 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2323 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2318 | 2324 | ||
2319 | if ( loadOk ) { | 2325 | if ( loadOk ) { |
2320 | getEventViewerDialog()->setSyncMode( true ); | 2326 | getEventViewerDialog()->setSyncMode( true ); |
2321 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2327 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2322 | getEventViewerDialog()->setSyncMode( false ); | 2328 | getEventViewerDialog()->setSyncMode( false ); |
2323 | qApp->processEvents(); | 2329 | qApp->processEvents(); |
2324 | if ( syncOK ) { | 2330 | if ( syncOK ) { |
2325 | if ( mSyncManager->mWriteBackFile ) | 2331 | if ( mSyncManager->mWriteBackFile ) |
2326 | { | 2332 | { |
2327 | // write back XML file | 2333 | // write back XML file |
2328 | 2334 | ||
2329 | } | 2335 | } |
2330 | setModified( true ); | 2336 | setModified( true ); |
2331 | } | 2337 | } |
2332 | } else { | 2338 | } else { |
2333 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2339 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2334 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2340 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2335 | question, i18n("Ok")) ; | 2341 | question, i18n("Ok")) ; |
2336 | } | 2342 | } |
2337 | delete calendar; | 2343 | delete calendar; |
2338 | updateView(); | 2344 | updateView(); |
2339 | return syncOK; | 2345 | return syncOK; |
2340 | 2346 | ||
2341 | 2347 | ||
2342 | #endif | 2348 | #endif |
2343 | 2349 | ||
2344 | } | 2350 | } |
2345 | 2351 | ||
2346 | void CalendarView::setSyncEventsReadOnly() | 2352 | void CalendarView::setSyncEventsReadOnly() |
2347 | { | 2353 | { |
2348 | mCalendar->setSyncEventsReadOnly(); | 2354 | mCalendar->setSyncEventsReadOnly(); |
2349 | } | 2355 | } |
2350 | 2356 | ||
2351 | bool CalendarView::loadCalendars() | 2357 | bool CalendarView::loadCalendars() |
2352 | { | 2358 | { |
2353 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2359 | Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2354 | KopiCalendarFile * cal = calendars.first(); | 2360 | KopiCalendarFile * cal = calendars.first(); |
2355 | mCalendar->setDefaultCalendar( 1 ); | 2361 | mCalendar->setDefaultCalendar( 1 ); |
2356 | openCalendar( MainWindow::defaultFileName(), false ); | 2362 | openCalendar( MainWindow::defaultFileName(), false ); |
2357 | cal = calendars.next(); | 2363 | cal = calendars.next(); |
2358 | while ( cal ) { | 2364 | while ( cal ) { |
2359 | addCalendar( cal ); | 2365 | addCalendar( cal ); |
2360 | cal = calendars.next(); | 2366 | cal = calendars.next(); |
2361 | } | 2367 | } |
2362 | restoreCalendarSettings(); | 2368 | restoreCalendarSettings(); |
2363 | return true; | 2369 | return true; |
2364 | } | 2370 | } |
2365 | bool CalendarView::restoreCalendarSettings() | 2371 | bool CalendarView::restoreCalendarSettings() |
2366 | { | 2372 | { |
2367 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2373 | Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2368 | KopiCalendarFile * cal = calendars.first(); | 2374 | KopiCalendarFile * cal = calendars.first(); |
2369 | while ( cal ) { | 2375 | while ( cal ) { |
2370 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2376 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2371 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2377 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2372 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2378 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2373 | if ( cal->isStandard ) | 2379 | if ( cal->isStandard ) |
2374 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2380 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2375 | cal = calendars.next(); | 2381 | cal = calendars.next(); |
2376 | } | 2382 | } |
2377 | setSyncEventsReadOnly(); | 2383 | setSyncEventsReadOnly(); |
2378 | mCalendar->reInitAlarmSettings(); | 2384 | mCalendar->reInitAlarmSettings(); |
2379 | updateUnmanagedViews(); | 2385 | updateUnmanagedViews(); |
2380 | updateView(); | 2386 | updateView(); |
2381 | return true; | 2387 | return true; |
2382 | } | 2388 | } |
2383 | void CalendarView::addCalendarId( int id ) | 2389 | void CalendarView::addCalendarId( int id ) |
2384 | { | 2390 | { |
2385 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2391 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2386 | if ( cal ) | 2392 | if ( cal ) |
2387 | addCalendar( cal ); | 2393 | addCalendar( cal ); |
2388 | } | 2394 | } |
2389 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2395 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2390 | { | 2396 | { |
2391 | cal->mErrorOnLoad = false; | 2397 | cal->mErrorOnLoad = false; |
2392 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2398 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2393 | cal->mLoadDt = QDateTime::currentDateTime(); | 2399 | cal->mLoadDt = QDateTime::currentDateTime(); |
2394 | return true; | 2400 | return true; |
2395 | } | 2401 | } |
2396 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2402 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2397 | cal->mErrorOnLoad = true; | 2403 | cal->mErrorOnLoad = true; |
2398 | return false; | 2404 | return false; |
2399 | } | 2405 | } |
2400 | bool CalendarView::openCalendar(QString filename, bool merge) | 2406 | bool CalendarView::openCalendar(QString filename, bool merge) |
2401 | { | 2407 | { |
2402 | 2408 | ||
2403 | if (filename.isEmpty()) { | 2409 | if (filename.isEmpty()) { |
2404 | return false; | 2410 | return false; |
2405 | } | 2411 | } |
2406 | 2412 | ||
2407 | if (!QFile::exists(filename)) { | 2413 | if (!QFile::exists(filename)) { |
2408 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2414 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2409 | return false; | 2415 | return false; |
2410 | } | 2416 | } |
2411 | 2417 | ||
2412 | globalFlagBlockAgenda = 1; | 2418 | globalFlagBlockAgenda = 1; |
2413 | clearAllViews(); | 2419 | clearAllViews(); |
2414 | if (!merge) { | 2420 | if (!merge) { |
2415 | mViewManager->setDocumentId( filename ); | 2421 | mViewManager->setDocumentId( filename ); |
2416 | mCalendar->close(); | 2422 | mCalendar->close(); |
2417 | } | 2423 | } |
2418 | mStorage->setFileName( filename ); | 2424 | mStorage->setFileName( filename ); |
2419 | 2425 | ||
2420 | if ( mStorage->load() ) { | 2426 | if ( mStorage->load() ) { |
2421 | if ( merge ) ;//setModified( true ); | 2427 | if ( merge ) ;//setModified( true ); |
2422 | else { | 2428 | else { |
2423 | //setModified( true ); | 2429 | //setModified( true ); |
2424 | mViewManager->setDocumentId( filename ); | 2430 | mViewManager->setDocumentId( filename ); |
2425 | mDialogManager->setDocumentId( filename ); | 2431 | mDialogManager->setDocumentId( filename ); |
2426 | mTodoList->setDocumentId( filename ); | 2432 | mTodoList->setDocumentId( filename ); |
2427 | } | 2433 | } |
2428 | globalFlagBlockAgenda = 2; | 2434 | globalFlagBlockAgenda = 2; |
2429 | // if ( getLastSyncEvent() ) | 2435 | // if ( getLastSyncEvent() ) |
2430 | // getLastSyncEvent()->setReadOnly( true ); | 2436 | // getLastSyncEvent()->setReadOnly( true ); |
2431 | mCalendar->reInitAlarmSettings(); | 2437 | mCalendar->reInitAlarmSettings(); |
2432 | setSyncEventsReadOnly(); | 2438 | setSyncEventsReadOnly(); |
2433 | //updateUnmanagedViews(); | 2439 | //updateUnmanagedViews(); |
2434 | //updateView(); | 2440 | //updateView(); |
2435 | if ( filename != MainWindow::defaultFileName() ) { | 2441 | if ( filename != MainWindow::defaultFileName() ) { |
2436 | saveCalendar( MainWindow::defaultFileName() ); | 2442 | saveCalendar( MainWindow::defaultFileName() ); |
2437 | } else { | 2443 | } else { |
2438 | QFileInfo finf ( MainWindow::defaultFileName()); | 2444 | QFileInfo finf ( MainWindow::defaultFileName()); |
2439 | if ( finf.exists() ) { | 2445 | if ( finf.exists() ) { |
2440 | setLoadedFileVersion( finf.lastModified () ); | 2446 | setLoadedFileVersion( finf.lastModified () ); |
2441 | } | 2447 | } |
2442 | } | 2448 | } |
2443 | return true; | 2449 | return true; |
2444 | } else { | 2450 | } else { |
2445 | // while failing to load, the calendar object could | 2451 | // while failing to load, the calendar object could |
2446 | // have become partially populated. Clear it out. | 2452 | // have become partially populated. Clear it out. |
2447 | if ( !merge ) { | 2453 | if ( !merge ) { |
2448 | mCalendar->close(); | 2454 | mCalendar->close(); |
2449 | mViewManager->setDocumentId( filename ); | 2455 | mViewManager->setDocumentId( filename ); |
2450 | mDialogManager->setDocumentId( filename ); | 2456 | mDialogManager->setDocumentId( filename ); |
2451 | mTodoList->setDocumentId( filename ); | 2457 | mTodoList->setDocumentId( filename ); |
2452 | } | 2458 | } |
2453 | 2459 | ||
2454 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2460 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2455 | 2461 | ||
2456 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2462 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2457 | globalFlagBlockAgenda = 2; | 2463 | globalFlagBlockAgenda = 2; |
2458 | mCalendar->reInitAlarmSettings(); | 2464 | mCalendar->reInitAlarmSettings(); |
2459 | setSyncEventsReadOnly(); | 2465 | setSyncEventsReadOnly(); |
2460 | updateUnmanagedViews(); | 2466 | updateUnmanagedViews(); |
2461 | updateView(); | 2467 | updateView(); |
2462 | } | 2468 | } |
2463 | return false; | 2469 | return false; |
2464 | } | 2470 | } |
2465 | void CalendarView::mergeFile( QString fn ) | 2471 | void CalendarView::mergeFile( QString fn ) |
2466 | { | 2472 | { |
2467 | clearAllViews(); | 2473 | clearAllViews(); |
2468 | mCalendar->mergeCalendarFile( fn ); | 2474 | mCalendar->mergeCalendarFile( fn ); |
2469 | mCalendar->reInitAlarmSettings(); | 2475 | mCalendar->reInitAlarmSettings(); |
2470 | setSyncEventsReadOnly(); | 2476 | setSyncEventsReadOnly(); |
2471 | updateUnmanagedViews(); | 2477 | updateUnmanagedViews(); |
2472 | updateView(); | 2478 | updateView(); |
2473 | } | 2479 | } |
2474 | void CalendarView::mergeFileResource( QString fn ,QString resource ) | 2480 | void CalendarView::mergeFileResource( QString fn ,QString resource ) |
2475 | { | 2481 | { |
2476 | 2482 | ||
2477 | if ( resource == "ALL" ) { | 2483 | if ( resource == "ALL" ) { |
2478 | mCalendar->setAllCalendarEnabled( true ); | 2484 | mCalendar->setAllCalendarEnabled( true ); |
2479 | mergeFile( fn ); | 2485 | mergeFile( fn ); |
2480 | restoreCalendarSettings(); | 2486 | restoreCalendarSettings(); |
2481 | return; | 2487 | return; |
2482 | } | 2488 | } |
2483 | 2489 | ||
2484 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | 2490 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); |
2485 | if ( !exclusiveResource ) { | 2491 | if ( !exclusiveResource ) { |
2486 | qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() ); | 2492 | qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() ); |
2487 | return; | 2493 | return; |
2488 | } | 2494 | } |
2489 | clearAllViews(); | 2495 | clearAllViews(); |
2490 | mCalendar->setCalendarRemove( exclusiveResource ); | 2496 | mCalendar->setCalendarRemove( exclusiveResource ); |
2491 | mCalendar->setDefaultCalendar(exclusiveResource); | 2497 | mCalendar->setDefaultCalendar(exclusiveResource); |
2492 | mCalendar->setAllCalendarEnabled( true ); | 2498 | mCalendar->setAllCalendarEnabled( true ); |
2493 | if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) { | 2499 | if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) { |
2494 | qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() ); | 2500 | qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() ); |
2495 | } | 2501 | } |
2496 | restoreCalendarSettings(); | 2502 | restoreCalendarSettings(); |
2497 | } | 2503 | } |
2498 | void CalendarView::showOpenError() | 2504 | void CalendarView::showOpenError() |
2499 | { | 2505 | { |
2500 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2506 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2501 | } | 2507 | } |
2502 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2508 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2503 | { | 2509 | { |
2504 | loadedFileVersion = dt; | 2510 | loadedFileVersion = dt; |
2505 | } | 2511 | } |
2506 | bool CalendarView::checkFileChanged(QString fn) | 2512 | bool CalendarView::checkFileChanged(QString fn) |
2507 | { | 2513 | { |
2508 | QFileInfo finf ( fn ); | 2514 | QFileInfo finf ( fn ); |
2509 | if ( !finf.exists() ) | 2515 | if ( !finf.exists() ) |
2510 | return true; | 2516 | return true; |
2511 | QDateTime dt = finf.lastModified (); | 2517 | QDateTime dt = finf.lastModified (); |
2512 | if ( dt <= loadedFileVersion ) | 2518 | if ( dt <= loadedFileVersion ) |
2513 | return false; | 2519 | return false; |
2514 | return true; | 2520 | return true; |
2515 | 2521 | ||
2516 | } | 2522 | } |
2517 | void CalendarView::watchSavedFile() | 2523 | void CalendarView::watchSavedFile() |
2518 | { | 2524 | { |
2519 | QFileInfo finf ( MainWindow::defaultFileName()); | 2525 | QFileInfo finf ( MainWindow::defaultFileName()); |
2520 | if ( !finf.exists() ) | 2526 | if ( !finf.exists() ) |
2521 | return; | 2527 | return; |
2522 | QDateTime dt = finf.lastModified (); | 2528 | QDateTime dt = finf.lastModified (); |
2523 | if ( dt < loadedFileVersion ) { | 2529 | if ( dt < loadedFileVersion ) { |
2524 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2530 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2525 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2531 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2526 | return; | 2532 | return; |
2527 | } | 2533 | } |
2528 | loadedFileVersion = dt; | 2534 | loadedFileVersion = dt; |
2529 | } | 2535 | } |
2530 | bool CalendarView::checkAllFileVersions() | 2536 | bool CalendarView::checkAllFileVersions() |
2531 | { | 2537 | { |
2532 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2538 | Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2533 | KopiCalendarFile * cal = calendars.first(); | 2539 | KopiCalendarFile * cal = calendars.first(); |
2534 | mCalendar->setDefaultCalendar( 1 ); | 2540 | mCalendar->setDefaultCalendar( 1 ); |
2535 | mCalendar->setDefaultCalendarEnabledOnly(); | 2541 | mCalendar->setDefaultCalendarEnabledOnly(); |
2536 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2542 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2537 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2543 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2538 | restoreCalendarSettings(); | 2544 | restoreCalendarSettings(); |
2539 | return false; | 2545 | return false; |
2540 | } | 2546 | } |
2541 | } | 2547 | } |
2542 | cal = calendars.next(); | 2548 | cal = calendars.next(); |
2543 | QDateTime storeTemp = loadedFileVersion; | 2549 | QDateTime storeTemp = loadedFileVersion; |
2544 | while ( cal ) { | 2550 | while ( cal ) { |
2545 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2551 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2546 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2552 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2547 | mCalendar->setDefaultCalendarEnabledOnly(); | 2553 | mCalendar->setDefaultCalendarEnabledOnly(); |
2548 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2554 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2549 | if ( !checkFileVersion(cal->mFileName )) { | 2555 | if ( !checkFileVersion(cal->mFileName )) { |
2550 | loadedFileVersion = storeTemp; | 2556 | loadedFileVersion = storeTemp; |
2551 | restoreCalendarSettings(); | 2557 | restoreCalendarSettings(); |
2552 | return false; | 2558 | return false; |
2553 | } | 2559 | } |
2554 | } | 2560 | } |
2555 | cal = calendars.next(); | 2561 | cal = calendars.next(); |
2556 | } | 2562 | } |
2557 | loadedFileVersion = storeTemp; | 2563 | loadedFileVersion = storeTemp; |
2558 | return true; | 2564 | return true; |
2559 | } | 2565 | } |
2560 | bool CalendarView::checkFileVersion(QString fn) | 2566 | bool CalendarView::checkFileVersion(QString fn) |
2561 | { | 2567 | { |
2562 | QFileInfo finf ( fn ); | 2568 | QFileInfo finf ( fn ); |
2563 | if ( !finf.exists() ) | 2569 | if ( !finf.exists() ) |
2564 | return true; | 2570 | return true; |
2565 | QDateTime dt = finf.lastModified (); | 2571 | QDateTime dt = finf.lastModified (); |
2566 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2572 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2567 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2573 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2568 | if ( dt <= loadedFileVersion ) | 2574 | if ( dt <= loadedFileVersion ) |
2569 | return true; | 2575 | return true; |
2570 | 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)) , | 2576 | 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)) , |
2571 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2577 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2572 | i18n("Sync+save")); | 2578 | i18n("Sync+save")); |
2573 | 2579 | ||
2574 | if ( km == KMessageBox::Cancel ) | 2580 | if ( km == KMessageBox::Cancel ) |
2575 | return false; | 2581 | return false; |
2576 | if ( km == KMessageBox::Yes ) | 2582 | if ( km == KMessageBox::Yes ) |
2577 | return true; | 2583 | return true; |
2578 | 2584 | ||
2579 | setSyncDevice("deleteaftersync" ); | 2585 | setSyncDevice("deleteaftersync" ); |
2580 | mSyncManager->mAskForPreferences = true; | 2586 | mSyncManager->mAskForPreferences = true; |
2581 | mSyncManager->mSyncAlgoPrefs = 3; | 2587 | mSyncManager->mSyncAlgoPrefs = 3; |
2582 | mSyncManager->mWriteBackFile = false; | 2588 | mSyncManager->mWriteBackFile = false; |
2583 | mSyncManager->mWriteBackExistingOnly = false; | 2589 | mSyncManager->mWriteBackExistingOnly = false; |
2584 | mSyncManager->mShowSyncSummary = false; | 2590 | mSyncManager->mShowSyncSummary = false; |
2585 | mMultiResourceSync = false; | 2591 | mMultiResourceSync = false; |
2586 | syncCalendar( fn, 3 ); | 2592 | syncCalendar( fn, 3 ); |
2587 | Event * e = getLastSyncEvent(); | 2593 | Event * e = getLastSyncEvent(); |
2588 | if ( e ) | 2594 | if ( e ) |
2589 | mCalendar->deleteEvent( e ); | 2595 | mCalendar->deleteEvent( e ); |
2590 | return true; | 2596 | return true; |
2591 | } | 2597 | } |
2592 | bool CalendarView::saveCalendars() | 2598 | bool CalendarView::saveCalendars() |
2593 | { | 2599 | { |
2594 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2600 | Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2595 | KopiCalendarFile * cal = calendars.first(); | 2601 | KopiCalendarFile * cal = calendars.first(); |
2596 | mCalendar->setDefaultCalendar( 1 ); | 2602 | mCalendar->setDefaultCalendar( 1 ); |
2597 | mCalendar->setDefaultCalendarEnabledOnly(); | 2603 | mCalendar->setDefaultCalendarEnabledOnly(); |
2598 | QString saveError; | 2604 | QString saveError; |
2599 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) | 2605 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) |
2600 | saveError = cal->mName +"\n"; | 2606 | saveError = cal->mName +"\n"; |
2601 | cal = calendars.next(); | 2607 | cal = calendars.next(); |
2602 | while ( cal ) { | 2608 | while ( cal ) { |
2603 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2609 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2604 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2610 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2605 | mCalendar->setDefaultCalendarEnabledOnly(); | 2611 | mCalendar->setDefaultCalendarEnabledOnly(); |
2606 | if ( saveCalendar( cal->mFileName ) ) | 2612 | if ( saveCalendar( cal->mFileName ) ) |
2607 | cal->mLoadDt = QDateTime::currentDateTime(); | 2613 | cal->mLoadDt = QDateTime::currentDateTime(); |
2608 | else | 2614 | else |
2609 | saveError += cal->mName + "\n"; | 2615 | saveError += cal->mName + "\n"; |
2610 | } | 2616 | } |
2611 | cal = calendars.next(); | 2617 | cal = calendars.next(); |
2612 | } | 2618 | } |
2613 | restoreCalendarSettings(); | 2619 | restoreCalendarSettings(); |
2614 | //saveError = "test error"; | 2620 | //saveError = "test error"; |
2615 | if ( !saveError.isEmpty() ) { | 2621 | if ( !saveError.isEmpty() ) { |
2616 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; | 2622 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; |
2617 | KMessageBox::error(this, saveError, i18n("Error saving data")); | 2623 | KMessageBox::error(this, saveError, i18n("Error saving data")); |
2618 | return false; | 2624 | return false; |
2619 | } | 2625 | } |
2620 | return true; | 2626 | return true; |
2621 | } | 2627 | } |
2622 | bool CalendarView::saveCalendarResource(QString filename, QString resource) | 2628 | bool CalendarView::saveCalendarResource(QString filename, QString resource) |
2623 | { | 2629 | { |
2624 | if ( resource == "ALL" ) { | 2630 | if ( resource == "ALL" ) { |
2625 | mCalendar->setAllCalendarEnabled( true ); | 2631 | mCalendar->setAllCalendarEnabled( true ); |
2626 | bool retval = saveCalendar( filename ); | 2632 | bool retval = saveCalendar( filename ); |
2627 | restoreCalendarSettings(); | 2633 | restoreCalendarSettings(); |
2628 | return retval; | 2634 | return retval; |
2629 | } | 2635 | } |
2630 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | 2636 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); |
2631 | if ( !exclusiveResource ) { | 2637 | if ( !exclusiveResource ) { |
2632 | qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() ); | 2638 | qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() ); |
2633 | return false; | 2639 | return false; |
2634 | } | 2640 | } |
2635 | mCalendar->setDefaultCalendar( exclusiveResource ); | 2641 | mCalendar->setDefaultCalendar( exclusiveResource ); |
2636 | mCalendar->setDefaultCalendarEnabledOnly(); | 2642 | mCalendar->setDefaultCalendarEnabledOnly(); |
2637 | mCalendar->setSyncEventsEnabled(); | 2643 | mCalendar->setSyncEventsEnabled(); |
2638 | bool res = saveCalendar( filename ); | 2644 | bool res = saveCalendar( filename ); |
2639 | restoreCalendarSettings(); | 2645 | restoreCalendarSettings(); |
2640 | return res; | 2646 | return res; |
2641 | 2647 | ||
2642 | } | 2648 | } |
2643 | bool CalendarView::saveCalendar( QString filename ) | 2649 | bool CalendarView::saveCalendar( QString filename ) |
2644 | { | 2650 | { |
2645 | 2651 | ||
2646 | // Store back all unsaved data into calendar object | 2652 | // Store back all unsaved data into calendar object |
2647 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2653 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2648 | if ( mViewManager->currentView() ) | 2654 | if ( mViewManager->currentView() ) |
2649 | mViewManager->currentView()->flushView(); | 2655 | mViewManager->currentView()->flushView(); |
2650 | 2656 | ||
2651 | 2657 | ||
2652 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2658 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2653 | mStorage->setSaveFormat( new ICalFormat() ); | 2659 | mStorage->setSaveFormat( new ICalFormat() ); |
2654 | mStorage->setFileName( filename ); | 2660 | mStorage->setFileName( filename ); |
2655 | bool success; | 2661 | bool success; |
2656 | success = mStorage->save(); | 2662 | success = mStorage->save(); |
2657 | if ( !success ) { | 2663 | if ( !success ) { |
2658 | return false; | 2664 | return false; |
2659 | } | 2665 | } |
2660 | if ( filename == MainWindow::defaultFileName() ) { | 2666 | if ( filename == MainWindow::defaultFileName() ) { |
2661 | setLoadedFileVersion( lfv ); | 2667 | setLoadedFileVersion( lfv ); |
2662 | watchSavedFile(); | 2668 | watchSavedFile(); |
2663 | } | 2669 | } |
2664 | return true; | 2670 | return true; |
2665 | } | 2671 | } |
2666 | 2672 | ||
2667 | void CalendarView::closeCalendar() | 2673 | void CalendarView::closeCalendar() |
2668 | { | 2674 | { |
2669 | 2675 | ||
2670 | // child windows no longer valid | 2676 | // child windows no longer valid |
2671 | clearAllViews(); | 2677 | clearAllViews(); |
2672 | emit closingDown(); | 2678 | emit closingDown(); |
2673 | 2679 | ||
2674 | mCalendar->close(); | 2680 | mCalendar->close(); |
2675 | setModified(false); | 2681 | setModified(false); |
2676 | updateView(); | 2682 | updateView(); |
2677 | } | 2683 | } |
2678 | 2684 | ||
2679 | void CalendarView::archiveCalendar() | 2685 | void CalendarView::archiveCalendar() |
2680 | { | 2686 | { |
2681 | mDialogManager->showArchiveDialog(); | 2687 | mDialogManager->showArchiveDialog(); |
2682 | } | 2688 | } |
2683 | 2689 | ||
2684 | 2690 | ||
2685 | void CalendarView::readSettings() | 2691 | void CalendarView::readSettings() |
2686 | { | 2692 | { |
2687 | 2693 | ||
2688 | 2694 | ||
2689 | // mViewManager->showAgendaView(); | 2695 | // mViewManager->showAgendaView(); |
2690 | QString str; | 2696 | QString str; |
2691 | //qDebug("CalendarView::readSettings() "); | 2697 | //qDebug("CalendarView::readSettings() "); |
2692 | // read settings from the KConfig, supplying reasonable | 2698 | // read settings from the KConfig, supplying reasonable |
2693 | // defaults where none are to be found | 2699 | // defaults where none are to be found |
2694 | KConfig *config = KOGlobals::config(); | 2700 | KConfig *config = KOGlobals::config(); |
2695 | #ifndef KORG_NOSPLITTER | 2701 | #ifndef KORG_NOSPLITTER |
2696 | config->setGroup("KOrganizer Geometry"); | 2702 | config->setGroup("KOrganizer Geometry"); |
2697 | 2703 | ||
2698 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2704 | Q3ValueList<int> sizes = config->readIntListEntry("Separator1"); |
2699 | if (sizes.count() != 2) { | 2705 | if (sizes.count() != 2) { |
2700 | sizes << mDateNavigator->minimumSizeHint().width(); | 2706 | sizes << mDateNavigator->minimumSizeHint().width(); |
2701 | sizes << 300; | 2707 | sizes << 300; |
2702 | } | 2708 | } |
2703 | mPanner->setSizes(sizes); | 2709 | mPanner->setSizes(sizes); |
2704 | 2710 | ||
2705 | sizes = config->readIntListEntry("Separator2"); | 2711 | sizes = config->readIntListEntry("Separator2"); |
2706 | if ( ( mResourceView && sizes.count() == 4 ) || | 2712 | if ( ( mResourceView && sizes.count() == 4 ) || |
2707 | ( !mResourceView && sizes.count() == 3 ) ) { | 2713 | ( !mResourceView && sizes.count() == 3 ) ) { |
2708 | mLeftSplitter->setSizes(sizes); | 2714 | mLeftSplitter->setSizes(sizes); |
2709 | } | 2715 | } |
2710 | #endif | 2716 | #endif |
2711 | globalFlagBlockAgenda = 1; | 2717 | globalFlagBlockAgenda = 1; |
2712 | mViewManager->showAgendaView(); | 2718 | mViewManager->showAgendaView(); |
2713 | //mViewManager->readSettings( config ); | 2719 | //mViewManager->readSettings( config ); |
2714 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2720 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2715 | readFilterSettings(config); | 2721 | readFilterSettings(config); |
2716 | 2722 | ||
2717 | #ifdef DESKTOP_VERSION | 2723 | #ifdef DESKTOP_VERSION |
2718 | config->setGroup("WidgetLayout"); | 2724 | config->setGroup("WidgetLayout"); |
2719 | QStringList list; | 2725 | QStringList list; |
2720 | list = config->readListEntry("MainLayout"); | 2726 | list = config->readListEntry("MainLayout"); |
2721 | int x,y,w,h; | 2727 | int x,y,w,h; |
2722 | if ( ! list.isEmpty() ) { | 2728 | if ( ! list.isEmpty() ) { |
2723 | x = list[0].toInt(); | 2729 | x = list[0].toInt(); |
2724 | y = list[1].toInt(); | 2730 | y = list[1].toInt(); |
2725 | w = list[2].toInt(); | 2731 | w = list[2].toInt(); |
2726 | h = list[3].toInt(); | 2732 | h = list[3].toInt(); |
2727 | KApplication::testCoords( &x,&y,&w,&h ); | 2733 | KApplication::testCoords( &x,&y,&w,&h ); |
2728 | topLevelWidget()->setGeometry(x,y,w,h); | 2734 | topLevelWidget()->setGeometry(x,y,w,h); |
2729 | 2735 | ||
2730 | } else { | 2736 | } else { |
2731 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2737 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2732 | } | 2738 | } |
2733 | list = config->readListEntry("EditEventLayout"); | 2739 | list = config->readListEntry("EditEventLayout"); |
2734 | if ( ! list.isEmpty() ) { | 2740 | if ( ! list.isEmpty() ) { |
2735 | x = list[0].toInt(); | 2741 | x = list[0].toInt(); |
2736 | y = list[1].toInt(); | 2742 | y = list[1].toInt(); |
2737 | w = list[2].toInt(); | 2743 | w = list[2].toInt(); |
2738 | h = list[3].toInt(); | 2744 | h = list[3].toInt(); |
2739 | KApplication::testCoords( &x,&y,&w,&h ); | 2745 | KApplication::testCoords( &x,&y,&w,&h ); |
2740 | mEventEditor->setGeometry(x,y,w,h); | 2746 | mEventEditor->setGeometry(x,y,w,h); |
2741 | 2747 | ||
2742 | } | 2748 | } |
2743 | list = config->readListEntry("EditTodoLayout"); | 2749 | list = config->readListEntry("EditTodoLayout"); |
2744 | if ( ! list.isEmpty() ) { | 2750 | if ( ! list.isEmpty() ) { |
2745 | x = list[0].toInt(); | 2751 | x = list[0].toInt(); |
2746 | y = list[1].toInt(); | 2752 | y = list[1].toInt(); |
2747 | w = list[2].toInt(); | 2753 | w = list[2].toInt(); |
2748 | h = list[3].toInt(); | 2754 | h = list[3].toInt(); |
2749 | KApplication::testCoords( &x,&y,&w,&h ); | 2755 | KApplication::testCoords( &x,&y,&w,&h ); |
2750 | mTodoEditor->setGeometry(x,y,w,h); | 2756 | mTodoEditor->setGeometry(x,y,w,h); |
2751 | 2757 | ||
2752 | } | 2758 | } |
2753 | list = config->readListEntry("ViewerLayout"); | 2759 | list = config->readListEntry("ViewerLayout"); |
2754 | if ( ! list.isEmpty() ) { | 2760 | if ( ! list.isEmpty() ) { |
2755 | x = list[0].toInt(); | 2761 | x = list[0].toInt(); |
2756 | y = list[1].toInt(); | 2762 | y = list[1].toInt(); |
2757 | w = list[2].toInt(); | 2763 | w = list[2].toInt(); |
2758 | h = list[3].toInt(); | 2764 | h = list[3].toInt(); |
2759 | KApplication::testCoords( &x,&y,&w,&h ); | 2765 | KApplication::testCoords( &x,&y,&w,&h ); |
2760 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2766 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2761 | } | 2767 | } |
2762 | #endif | 2768 | #endif |
2763 | config->setGroup( "Views" ); | 2769 | config->setGroup( "Views" ); |
2764 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2770 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2765 | 2771 | ||
2766 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2772 | Q3ValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2767 | 2773 | ||
2768 | int resetval = 0; | 2774 | int resetval = 0; |
2769 | int maxVal = 0; | 2775 | int maxVal = 0; |
2770 | if (sizes.count() != 3) { | 2776 | if (sizes.count() != 3) { |
2771 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2777 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2772 | resetval = mDateNavigator->sizeHint().width()+2; | 2778 | resetval = mDateNavigator->sizeHint().width()+2; |
2773 | } else { | 2779 | } else { |
2774 | resetval = mDateNavigator->sizeHint().height()+2; | 2780 | resetval = mDateNavigator->sizeHint().height()+2; |
2775 | } | 2781 | } |
2776 | } | 2782 | } |
2777 | if ( resetval ) { | 2783 | if ( resetval ) { |
2778 | sizes.clear(); | 2784 | sizes.clear(); |
2779 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2785 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2780 | maxVal = QApplication::desktop()->width() -10; | 2786 | maxVal = QApplication::desktop()->width() -10; |
2781 | } else { | 2787 | } else { |
2782 | maxVal = QApplication::desktop()->height()-10; | 2788 | maxVal = QApplication::desktop()->height()-10; |
2783 | } | 2789 | } |
2784 | sizes << resetval; | 2790 | sizes << resetval; |
2785 | if ( maxVal < resetval + resetval) | 2791 | if ( maxVal < resetval + resetval) |
2786 | resetval = maxVal - resetval; | 2792 | resetval = maxVal - resetval; |
2787 | sizes << resetval; | 2793 | sizes << resetval; |
2788 | sizes << 100; | 2794 | sizes << 100; |
2789 | } | 2795 | } |
2790 | mLeftFrame->setSizes(sizes); | 2796 | mLeftFrame->setSizes(sizes); |
2791 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2797 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2792 | resetval = 0; | 2798 | resetval = 0; |
2793 | maxVal = 0; | 2799 | maxVal = 0; |
2794 | if (sizes.count() != 2) { | 2800 | if (sizes.count() != 2) { |
2795 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2801 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2796 | resetval = mDateNavigator->sizeHint().width()+2; | 2802 | resetval = mDateNavigator->sizeHint().width()+2; |
2797 | } else { | 2803 | } else { |
2798 | resetval = mDateNavigator->sizeHint().height()+2; | 2804 | resetval = mDateNavigator->sizeHint().height()+2; |
2799 | } | 2805 | } |
2800 | } | 2806 | } |
2801 | if ( resetval ) { | 2807 | if ( resetval ) { |
2802 | sizes.clear(); | 2808 | sizes.clear(); |
2803 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2809 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2804 | maxVal = QApplication::desktop()->width() -10; | 2810 | maxVal = QApplication::desktop()->width() -10; |
2805 | } else { | 2811 | } else { |
2806 | maxVal = QApplication::desktop()->height()-10; | 2812 | maxVal = QApplication::desktop()->height()-10; |
2807 | } | 2813 | } |
2808 | sizes << resetval; | 2814 | sizes << resetval; |
2809 | if ( maxVal < resetval + resetval) | 2815 | if ( maxVal < resetval + resetval) |
2810 | resetval = maxVal - resetval; | 2816 | resetval = maxVal - resetval; |
2811 | sizes << resetval; | 2817 | sizes << resetval; |
2812 | } | 2818 | } |
2813 | mMainFrame->setSizes(sizes); | 2819 | mMainFrame->setSizes(sizes); |
2814 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2820 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2815 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2821 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2816 | else mNavigator->selectDates( dateCount ); | 2822 | else mNavigator->selectDates( dateCount ); |
2817 | // mViewManager->readSettings( config ); | 2823 | // mViewManager->readSettings( config ); |
2818 | updateConfig(); | 2824 | updateConfig(); |
2819 | globalFlagBlockAgenda = 2; | 2825 | globalFlagBlockAgenda = 2; |
2820 | mViewManager->readSettings( config ); | 2826 | mViewManager->readSettings( config ); |
2821 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2827 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2822 | } | 2828 | } |
2823 | 2829 | ||
2824 | void CalendarView::checkSuspendAlarm() | 2830 | void CalendarView::checkSuspendAlarm() |
2825 | { | 2831 | { |
2826 | if ( mSuspendTimer->isActive() ) { | 2832 | if ( mSuspendTimer->isActive() ) { |
2827 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2833 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2828 | } | 2834 | } |
2829 | } | 2835 | } |
2830 | void CalendarView::writeSettings() | 2836 | void CalendarView::writeSettings() |
2831 | { | 2837 | { |
2832 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2838 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2833 | 2839 | ||
2834 | KConfig *config = KOGlobals::config(); | 2840 | KConfig *config = KOGlobals::config(); |
2835 | 2841 | ||
2836 | mViewManager->writeSettings( config ); | 2842 | mViewManager->writeSettings( config ); |
2837 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2843 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2838 | mDialogManager->writeSettings( config ); | 2844 | mDialogManager->writeSettings( config ); |
2839 | //KOPrefs::instance()->usrWriteConfig(); | 2845 | //KOPrefs::instance()->usrWriteConfig(); |
2840 | KOPrefs::instance()->writeConfig(); | 2846 | KOPrefs::instance()->writeConfig(); |
2841 | 2847 | ||
2842 | writeFilterSettings(config); | 2848 | writeFilterSettings(config); |
2843 | config->setGroup( "AppRun" ); | 2849 | config->setGroup( "AppRun" ); |
2844 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2850 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2845 | int days = dt.daysTo( QDate::currentDate() ); | 2851 | int days = dt.daysTo( (QDateTime)QDate::currentDate() ); |
2846 | dt = dt.addDays( days ); | 2852 | dt = dt.addDays( days ); |
2847 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2853 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2848 | config->writeEntry( "LatestProgramStopDays", days ); | 2854 | config->writeEntry( "LatestProgramStopDays", days ); |
2849 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2855 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2850 | //qDebug("KO: Writing stop time: %d ", secs); | 2856 | //qDebug("KO: Writing stop time: %d ", secs); |
2851 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2857 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2852 | //QDateTime latest = dt.addSecs ( secs ); | 2858 | //QDateTime latest = dt.addSecs ( secs ); |
2853 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2859 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2854 | config->setGroup( "Views" ); | 2860 | config->setGroup( "Views" ); |
2855 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2861 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2856 | 2862 | ||
2857 | #if 0 | 2863 | #if 0 |
2858 | qDebug("********************* "); | 2864 | qDebug("********************* "); |
2859 | qDebug("Testcode secsto "); | 2865 | qDebug("Testcode secsto "); |
2860 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2866 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2861 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2867 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2862 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2868 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2863 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2869 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2864 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2870 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2865 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2871 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2866 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2872 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2867 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2873 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2868 | qDebug("********************* testcode end"); | 2874 | qDebug("********************* testcode end"); |
2869 | 2875 | ||
2870 | #endif | 2876 | #endif |
2871 | 2877 | ||
2872 | QValueList<int> listINT = mLeftFrame->sizes(); | 2878 | Q3ValueList<int> listINT = mLeftFrame->sizes(); |
2873 | config->writeEntry("Left Splitter Frame",listINT); | 2879 | config->writeEntry("Left Splitter Frame",listINT); |
2874 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2880 | Q3ValueList<int> listINT2 = mMainFrame->sizes(); |
2875 | config->writeEntry("Main Splitter Frame",listINT2); | 2881 | config->writeEntry("Main Splitter Frame",listINT2); |
2876 | #ifdef DESKTOP_VERSION | 2882 | #ifdef DESKTOP_VERSION |
2877 | config->setGroup("WidgetLayout"); | 2883 | config->setGroup("WidgetLayout"); |
2878 | QStringList list ;//= config->readListEntry("MainLayout"); | 2884 | QStringList list ;//= config->readListEntry("MainLayout"); |
2879 | int x,y,w,h; | 2885 | int x,y,w,h; |
2880 | QWidget* wid; | 2886 | QWidget* wid; |
2881 | wid = topLevelWidget(); | 2887 | wid = topLevelWidget(); |
2882 | x = wid->geometry().x(); | 2888 | x = wid->geometry().x(); |
2883 | y = wid->geometry().y(); | 2889 | y = wid->geometry().y(); |
2884 | w = wid->width(); | 2890 | w = wid->width(); |
2885 | h = wid->height(); | 2891 | h = wid->height(); |
2886 | list.clear(); | 2892 | list.clear(); |
2887 | list << QString::number( x ); | 2893 | list << QString::number( x ); |
2888 | list << QString::number( y ); | 2894 | list << QString::number( y ); |
2889 | list << QString::number( w ); | 2895 | list << QString::number( w ); |
2890 | list << QString::number( h ); | 2896 | list << QString::number( h ); |
2891 | config->writeEntry("MainLayout",list ); | 2897 | config->writeEntry("MainLayout",list ); |
2892 | 2898 | ||
2893 | wid = mEventEditor; | 2899 | wid = mEventEditor; |
2894 | x = wid->geometry().x(); | 2900 | x = wid->geometry().x(); |
2895 | y = wid->geometry().y(); | 2901 | y = wid->geometry().y(); |
2896 | w = wid->width(); | 2902 | w = wid->width(); |
2897 | h = wid->height(); | 2903 | h = wid->height(); |
2898 | list.clear(); | 2904 | list.clear(); |
2899 | list << QString::number( x ); | 2905 | list << QString::number( x ); |
2900 | list << QString::number( y ); | 2906 | list << QString::number( y ); |
2901 | list << QString::number( w ); | 2907 | list << QString::number( w ); |
2902 | list << QString::number( h ); | 2908 | list << QString::number( h ); |
2903 | config->writeEntry("EditEventLayout",list ); | 2909 | config->writeEntry("EditEventLayout",list ); |
2904 | 2910 | ||
2905 | wid = mTodoEditor; | 2911 | wid = mTodoEditor; |
2906 | x = wid->geometry().x(); | 2912 | x = wid->geometry().x(); |
2907 | y = wid->geometry().y(); | 2913 | y = wid->geometry().y(); |
2908 | w = wid->width(); | 2914 | w = wid->width(); |
2909 | h = wid->height(); | 2915 | h = wid->height(); |
2910 | list.clear(); | 2916 | list.clear(); |
2911 | list << QString::number( x ); | 2917 | list << QString::number( x ); |
2912 | list << QString::number( y ); | 2918 | list << QString::number( y ); |
2913 | list << QString::number( w ); | 2919 | list << QString::number( w ); |
2914 | list << QString::number( h ); | 2920 | list << QString::number( h ); |
2915 | config->writeEntry("EditTodoLayout",list ); | 2921 | config->writeEntry("EditTodoLayout",list ); |
2916 | wid = getEventViewerDialog(); | 2922 | wid = getEventViewerDialog(); |
2917 | x = wid->geometry().x(); | 2923 | x = wid->geometry().x(); |
2918 | y = wid->geometry().y(); | 2924 | y = wid->geometry().y(); |
2919 | w = wid->width(); | 2925 | w = wid->width(); |
2920 | h = wid->height(); | 2926 | h = wid->height(); |
2921 | list.clear(); | 2927 | list.clear(); |
2922 | list << QString::number( x ); | 2928 | list << QString::number( x ); |
2923 | list << QString::number( y ); | 2929 | list << QString::number( y ); |
2924 | list << QString::number( w ); | 2930 | list << QString::number( w ); |
2925 | list << QString::number( h ); | 2931 | list << QString::number( h ); |
2926 | config->writeEntry("ViewerLayout",list ); | 2932 | config->writeEntry("ViewerLayout",list ); |
2927 | wid = mDialogManager->getSearchDialog(); | 2933 | wid = mDialogManager->getSearchDialog(); |
2928 | if ( wid ) { | 2934 | if ( wid ) { |
2929 | x = wid->geometry().x(); | 2935 | x = wid->geometry().x(); |
2930 | y = wid->geometry().y(); | 2936 | y = wid->geometry().y(); |
2931 | w = wid->width(); | 2937 | w = wid->width(); |
2932 | h = wid->height(); | 2938 | h = wid->height(); |
2933 | list.clear(); | 2939 | list.clear(); |
2934 | list << QString::number( x ); | 2940 | list << QString::number( x ); |
2935 | list << QString::number( y ); | 2941 | list << QString::number( y ); |
2936 | list << QString::number( w ); | 2942 | list << QString::number( w ); |
2937 | list << QString::number( h ); | 2943 | list << QString::number( h ); |
2938 | config->writeEntry("SearchLayout",list ); | 2944 | config->writeEntry("SearchLayout",list ); |
2939 | } | 2945 | } |
2940 | #endif | 2946 | #endif |
2941 | 2947 | ||
2942 | 2948 | ||
2943 | config->sync(); | 2949 | config->sync(); |
2944 | } | 2950 | } |
2945 | 2951 | ||
2946 | void CalendarView::readFilterSettings(KConfig *config) | 2952 | void CalendarView::readFilterSettings(KConfig *config) |
2947 | { | 2953 | { |
2948 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2954 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2949 | 2955 | ||
2950 | mFilters.clear(); | 2956 | mFilters.clear(); |
2951 | 2957 | ||
2952 | config->setGroup("General"); | 2958 | config->setGroup("General"); |
2953 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2959 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2954 | 2960 | ||
2955 | QStringList::ConstIterator it = filterList.begin(); | 2961 | QStringList::ConstIterator it = filterList.begin(); |
2956 | QStringList::ConstIterator end = filterList.end(); | 2962 | QStringList::ConstIterator end = filterList.end(); |
2957 | while(it != end) { | 2963 | while(it != end) { |
2958 | // kdDebug() << " filter: " << (*it) << endl; | 2964 | // kdDebug() << " filter: " << (*it) << endl; |
2959 | 2965 | ||
2960 | CalFilter *filter; | 2966 | CalFilter *filter; |
2961 | filter = new CalFilter(*it); | 2967 | filter = new CalFilter(*it); |
2962 | config->setGroup("Filter_" + (*it).utf8()); | 2968 | config->setGroup("Filter_" + (*it).utf8()); |
2963 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2969 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2964 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2970 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2965 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2971 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2966 | mFilters.append(filter); | 2972 | mFilters.append(filter); |
2967 | 2973 | ||
2968 | ++it; | 2974 | ++it; |
2969 | } | 2975 | } |
2970 | 2976 | ||
2971 | if (mFilters.count() == 0) { | 2977 | if (mFilters.count() == 0) { |
2972 | CalFilter *filter = new CalFilter(i18n("Default")); | 2978 | CalFilter *filter = new CalFilter(i18n("Default")); |
2973 | mFilters.append(filter); | 2979 | mFilters.append(filter); |
2974 | } | 2980 | } |
2975 | mFilterView->updateFilters(); | 2981 | mFilterView->updateFilters(); |
2976 | config->setGroup("FilterView"); | 2982 | config->setGroup("FilterView"); |
2977 | 2983 | ||
2978 | mFilterView->blockSignals(true); | 2984 | mFilterView->blockSignals(true); |
2979 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2985 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2980 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2986 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2981 | mFilterView->blockSignals(false); | 2987 | mFilterView->blockSignals(false); |
2982 | // We do it manually to avoid it being done twice by the above calls | 2988 | // We do it manually to avoid it being done twice by the above calls |
2983 | updateFilter(); | 2989 | updateFilter(); |
2984 | } | 2990 | } |
2985 | 2991 | ||
2986 | void CalendarView::writeFilterSettings(KConfig *config) | 2992 | void CalendarView::writeFilterSettings(KConfig *config) |
2987 | { | 2993 | { |
2988 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2994 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2989 | 2995 | ||
2990 | QStringList filterList; | 2996 | QStringList filterList; |
2991 | 2997 | ||
2992 | CalFilter *filter = mFilters.first(); | 2998 | CalFilter *filter = mFilters.first(); |
2993 | while(filter) { | 2999 | while(filter) { |
2994 | // kdDebug() << " fn: " << filter->name() << endl; | 3000 | // kdDebug() << " fn: " << filter->name() << endl; |
2995 | filterList << filter->name(); | 3001 | filterList << filter->name(); |
2996 | config->setGroup("Filter_" + filter->name().utf8()); | 3002 | config->setGroup("Filter_" + filter->name().utf8()); |
2997 | config->writeEntry("Criteria",filter->criteria()); | 3003 | config->writeEntry("Criteria",filter->criteria()); |
2998 | config->writeEntry("CategoryList",filter->categoryList()); | 3004 | config->writeEntry("CategoryList",filter->categoryList()); |
2999 | filter = mFilters.next(); | 3005 | filter = mFilters.next(); |
3000 | } | 3006 | } |
3001 | config->setGroup("General"); | 3007 | config->setGroup("General"); |
3002 | config->writeEntry("CalendarFilters",filterList); | 3008 | config->writeEntry("CalendarFilters",filterList); |
@@ -3041,257 +3047,257 @@ void CalendarView::updateConfig() | |||
3041 | emit configChanged(); | 3047 | emit configChanged(); |
3042 | mTodoList->updateConfig(); | 3048 | mTodoList->updateConfig(); |
3043 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 3049 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
3044 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3050 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3045 | // To make the "fill window" configurations work | 3051 | // To make the "fill window" configurations work |
3046 | //mViewManager->raiseCurrentView(); | 3052 | //mViewManager->raiseCurrentView(); |
3047 | } | 3053 | } |
3048 | 3054 | ||
3049 | 3055 | ||
3050 | void CalendarView::eventChanged(Event *event) | 3056 | void CalendarView::eventChanged(Event *event) |
3051 | { | 3057 | { |
3052 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 3058 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
3053 | //updateUnmanagedViews(); | 3059 | //updateUnmanagedViews(); |
3054 | } | 3060 | } |
3055 | 3061 | ||
3056 | void CalendarView::eventAdded(Event *event) | 3062 | void CalendarView::eventAdded(Event *event) |
3057 | { | 3063 | { |
3058 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 3064 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
3059 | } | 3065 | } |
3060 | 3066 | ||
3061 | void CalendarView::eventToBeDeleted(Event *) | 3067 | void CalendarView::eventToBeDeleted(Event *) |
3062 | { | 3068 | { |
3063 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 3069 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
3064 | } | 3070 | } |
3065 | 3071 | ||
3066 | void CalendarView::eventDeleted() | 3072 | void CalendarView::eventDeleted() |
3067 | { | 3073 | { |
3068 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 3074 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
3069 | } | 3075 | } |
3070 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 3076 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
3071 | { | 3077 | { |
3072 | changeIncidenceDisplay((Incidence *)which, action); | 3078 | changeIncidenceDisplay((Incidence *)which, action); |
3073 | mDateNavigator->updateView(); //LR | 3079 | mDateNavigator->updateView(); //LR |
3074 | //mDialogManager->updateSearchDialog(); | 3080 | //mDialogManager->updateSearchDialog(); |
3075 | 3081 | ||
3076 | if (which) { | 3082 | if (which) { |
3077 | mViewManager->updateWNview(); | 3083 | mViewManager->updateWNview(); |
3078 | //mTodoList->updateView(); | 3084 | //mTodoList->updateView(); |
3079 | } | 3085 | } |
3080 | 3086 | ||
3081 | } | 3087 | } |
3082 | 3088 | ||
3083 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 3089 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
3084 | { | 3090 | { |
3085 | updateUnmanagedViews(); | 3091 | updateUnmanagedViews(); |
3086 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 3092 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
3087 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 3093 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
3088 | mCalendar->checkAlarmForIncidence( 0, true ); | 3094 | mCalendar->checkAlarmForIncidence( 0, true ); |
3089 | if ( mEventViewerDialog ) | 3095 | if ( mEventViewerDialog ) |
3090 | mEventViewerDialog->hide(); | 3096 | mEventViewerDialog->hide(); |
3091 | } | 3097 | } |
3092 | else | 3098 | else |
3093 | mCalendar->checkAlarmForIncidence( which , false ); | 3099 | mCalendar->checkAlarmForIncidence( which , false ); |
3094 | } | 3100 | } |
3095 | 3101 | ||
3096 | // most of the changeEventDisplays() right now just call the view's | 3102 | // most of the changeEventDisplays() right now just call the view's |
3097 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 3103 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
3098 | void CalendarView::changeEventDisplay(Event *which, int action) | 3104 | void CalendarView::changeEventDisplay(Event *which, int action) |
3099 | { | 3105 | { |
3100 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 3106 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
3101 | changeIncidenceDisplay((Incidence *)which, action); | 3107 | changeIncidenceDisplay((Incidence *)which, action); |
3102 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 3108 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
3103 | if ( flag_clearallviewsEventDisplay ) { | 3109 | if ( flag_clearallviewsEventDisplay ) { |
3104 | clearAllViews(); | 3110 | clearAllViews(); |
3105 | flag_clearallviewsEventDisplay = false; | 3111 | flag_clearallviewsEventDisplay = false; |
3106 | } | 3112 | } |
3107 | return; | 3113 | return; |
3108 | } | 3114 | } |
3109 | flag_clearallviewsEventDisplay = true; | 3115 | flag_clearallviewsEventDisplay = true; |
3110 | mDateNavigator->updateView(); | 3116 | mDateNavigator->updateView(); |
3111 | //mDialogManager->updateSearchDialog(); | 3117 | //mDialogManager->updateSearchDialog(); |
3112 | if (which) { | 3118 | if (which) { |
3113 | // If there is an event view visible update the display | 3119 | // If there is an event view visible update the display |
3114 | mViewManager->currentView()->changeEventDisplay(which,action); | 3120 | mViewManager->currentView()->changeEventDisplay(which,action); |
3115 | // TODO: check, if update needed | 3121 | // TODO: check, if update needed |
3116 | // if (which->getTodoStatus()) { | 3122 | // if (which->getTodoStatus()) { |
3117 | mTodoList->updateView(); | 3123 | mTodoList->updateView(); |
3118 | if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { | 3124 | if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { |
3119 | mConflictingEvent = which ; | 3125 | mConflictingEvent = which ; |
3120 | int time = 1000; | 3126 | int time = 1000; |
3121 | #ifdef DESKTOP_VERSION | 3127 | #ifdef DESKTOP_VERSION |
3122 | time = 500; | 3128 | time = 500; |
3123 | #endif | 3129 | #endif |
3124 | bool checkC = false; | 3130 | bool checkC = false; |
3125 | if ( mConflictingEvent->doesFloat() ) { | 3131 | if ( mConflictingEvent->doesFloat() ) { |
3126 | checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay | 3132 | checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay |
3127 | || KOPrefs::instance()->mCheckConflictsAllDayNonAD; | 3133 | || KOPrefs::instance()->mCheckConflictsAllDayNonAD; |
3128 | } else { | 3134 | } else { |
3129 | checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay | 3135 | checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay |
3130 | || KOPrefs::instance()->mCheckConflictsNonADNonAD; | 3136 | || KOPrefs::instance()->mCheckConflictsNonADNonAD; |
3131 | } | 3137 | } |
3132 | if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) | 3138 | if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) |
3133 | checkC = false; | 3139 | checkC = false; |
3134 | if ( checkC ) | 3140 | if ( checkC ) |
3135 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); | 3141 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); |
3136 | } | 3142 | } |
3137 | // } | 3143 | // } |
3138 | } else { | 3144 | } else { |
3139 | mViewManager->currentView()->updateView(); | 3145 | mViewManager->currentView()->updateView(); |
3140 | } | 3146 | } |
3141 | } | 3147 | } |
3142 | void CalendarView::checkConflictForEvent() | 3148 | void CalendarView::checkConflictForEvent() |
3143 | { | 3149 | { |
3144 | 3150 | ||
3145 | if (!KOPrefs::instance()->mConfirm) | 3151 | if (!KOPrefs::instance()->mConfirm) |
3146 | return; | 3152 | return; |
3147 | if ( ! mConflictingEvent ) return; | 3153 | if ( ! mConflictingEvent ) return; |
3148 | Event * conflictingEvent = mConflictingEvent; | 3154 | Event * conflictingEvent = mConflictingEvent; |
3149 | mConflictingEvent = 0; | 3155 | mConflictingEvent = 0; |
3150 | QDateTime current = QDateTime::currentDateTime(); | 3156 | QDateTime current = QDateTime::currentDateTime(); |
3151 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { | 3157 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { |
3152 | return; | 3158 | return; |
3153 | } | 3159 | } |
3154 | CalFilter *filterIN = 0; | 3160 | CalFilter *filterIN = 0; |
3155 | CalFilter *filterALL = 0; | 3161 | CalFilter *filterALL = 0; |
3156 | CalFilter *filter = mFilters.first(); | 3162 | CalFilter *filter = mFilters.first(); |
3157 | while(filter) { | 3163 | while(filter) { |
3158 | if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) | 3164 | if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) |
3159 | filterIN = filter; | 3165 | filterIN = filter; |
3160 | if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) | 3166 | if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) |
3161 | filterALL = filter; | 3167 | filterALL = filter; |
3162 | filter = mFilters.next(); | 3168 | filter = mFilters.next(); |
3163 | } | 3169 | } |
3164 | if ( filterIN ) { | 3170 | if ( filterIN ) { |
3165 | if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { | 3171 | if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { |
3166 | return; | 3172 | return; |
3167 | } | 3173 | } |
3168 | } | 3174 | } |
3169 | QPtrList<Event> testlist = mCalendar->events(); | 3175 | Q3PtrList<Event> testlist = mCalendar->events(); |
3170 | Event * test = testlist.first(); | 3176 | Event * test = testlist.first(); |
3171 | QDateTime conflict; | 3177 | QDateTime conflict; |
3172 | QDateTime retVal; | 3178 | QDateTime retVal; |
3173 | bool found = false; | 3179 | bool found = false; |
3174 | Event * cE = 0; | 3180 | Event * cE = 0; |
3175 | bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; | 3181 | bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; |
3176 | bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; | 3182 | bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; |
3177 | if ( !conflictingEvent->doesFloat() ) { | 3183 | if ( !conflictingEvent->doesFloat() ) { |
3178 | chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; | 3184 | chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; |
3179 | chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; | 3185 | chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; |
3180 | } | 3186 | } |
3181 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 3187 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
3182 | while ( test ) { | 3188 | while ( test ) { |
3183 | qApp->processEvents(); | 3189 | qApp->processEvents(); |
3184 | bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); | 3190 | bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); |
3185 | 3191 | ||
3186 | if ( !skip ) { | 3192 | if ( !skip ) { |
3187 | if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) | 3193 | if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) |
3188 | skip = true; | 3194 | skip = true; |
3189 | } | 3195 | } |
3190 | if ( !skip ) { | 3196 | if ( !skip ) { |
3191 | if ( filterALL ) { | 3197 | if ( filterALL ) { |
3192 | if ( !filterALL->filterCalendarItem( test ) ) { | 3198 | if ( !filterALL->filterCalendarItem( test ) ) { |
3193 | skip = true; | 3199 | skip = true; |
3194 | } | 3200 | } |
3195 | } | 3201 | } |
3196 | if ( !skip ) { | 3202 | if ( !skip ) { |
3197 | if ( found ) | 3203 | if ( found ) |
3198 | skip = !test->matchTime( ¤t, &conflict ); | 3204 | skip = !test->matchTime( ¤t, &conflict ); |
3199 | else | 3205 | else |
3200 | skip = !test->matchTime( ¤t, 0 ); | 3206 | skip = !test->matchTime( ¤t, 0 ); |
3201 | if ( !skip ) { | 3207 | if ( !skip ) { |
3202 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 3208 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
3203 | if ( ! found ) { | 3209 | if ( ! found ) { |
3204 | conflict = retVal; | 3210 | conflict = retVal; |
3205 | cE = test; | 3211 | cE = test; |
3206 | } else { | 3212 | } else { |
3207 | if ( retVal < conflict ) { | 3213 | if ( retVal < conflict ) { |
3208 | conflict = retVal; | 3214 | conflict = retVal; |
3209 | cE = test; | 3215 | cE = test; |
3210 | } | 3216 | } |
3211 | } | 3217 | } |
3212 | found = true; | 3218 | found = true; |
3213 | } | 3219 | } |
3214 | } | 3220 | } |
3215 | } | 3221 | } |
3216 | } | 3222 | } |
3217 | test = testlist.next(); | 3223 | test = testlist.next(); |
3218 | } | 3224 | } |
3219 | topLevelWidget()->setCaption( i18n("KO/Pi") ); | 3225 | topLevelWidget()->setCaption( i18n("KO/Pi") ); |
3220 | if ( found ) { | 3226 | if ( found ) { |
3221 | 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()) ) ; | 3227 | 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()) ) ; |
3222 | qApp->processEvents(); | 3228 | qApp->processEvents(); |
3223 | int km = KMessageBox::warningContinueCancel(this,mess, | 3229 | int km = KMessageBox::warningContinueCancel(this,mess, |
3224 | i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); | 3230 | i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); |
3225 | if ( km != KMessageBox::Continue ) { | 3231 | if ( km != KMessageBox::Continue ) { |
3226 | return; | 3232 | return; |
3227 | } | 3233 | } |
3228 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 3234 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
3229 | mViewManager->showDayView(); | 3235 | mViewManager->showDayView(); |
3230 | mNavigator->slotDaySelect( conflict.date() ); | 3236 | mNavigator->slotDaySelect( conflict.date() ); |
3231 | int hour = conflict.time().hour(); | 3237 | int hour = conflict.time().hour(); |
3232 | mViewManager->agendaView()->setStartHour( hour ); | 3238 | mViewManager->agendaView()->setStartHour( hour ); |
3233 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 3239 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
3234 | } else | 3240 | } else |
3235 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 3241 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
3236 | return; | 3242 | return; |
3237 | 3243 | ||
3238 | } | 3244 | } |
3239 | 3245 | ||
3240 | void CalendarView::updateTodoViews() | 3246 | void CalendarView::updateTodoViews() |
3241 | { | 3247 | { |
3242 | mTodoList->updateView(); | 3248 | mTodoList->updateView(); |
3243 | mViewManager->currentView()->updateView(); | 3249 | mViewManager->currentView()->updateView(); |
3244 | 3250 | ||
3245 | } | 3251 | } |
3246 | 3252 | ||
3247 | 3253 | ||
3248 | 3254 | ||
3249 | void CalendarView::clearAllViews() | 3255 | void CalendarView::clearAllViews() |
3250 | { | 3256 | { |
3251 | mTodoList->clearList(); | 3257 | mTodoList->clearList(); |
3252 | mViewManager->clearAllViews(); | 3258 | mViewManager->clearAllViews(); |
3253 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 3259 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
3254 | if ( sd ) { | 3260 | if ( sd ) { |
3255 | KOListView* kol = sd->listview(); | 3261 | KOListView* kol = sd->listview(); |
3256 | if ( kol ) | 3262 | if ( kol ) |
3257 | kol->clearList(); | 3263 | kol->clearList(); |
3258 | } | 3264 | } |
3259 | } | 3265 | } |
3260 | void CalendarView::updateView() | 3266 | void CalendarView::updateView() |
3261 | { | 3267 | { |
3262 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 3268 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
3263 | if ( flag_clearallviewsupdateView ) { | 3269 | if ( flag_clearallviewsupdateView ) { |
3264 | clearAllViews(); | 3270 | clearAllViews(); |
3265 | flag_clearallviewsupdateView = false; | 3271 | flag_clearallviewsupdateView = false; |
3266 | } | 3272 | } |
3267 | return; | 3273 | return; |
3268 | } | 3274 | } |
3269 | flag_clearallviewsupdateView = true; | 3275 | flag_clearallviewsupdateView = true; |
3270 | DateList tmpList = mNavigator->selectedDates(); | 3276 | DateList tmpList = mNavigator->selectedDates(); |
3271 | 3277 | ||
3272 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 3278 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
3273 | mTodoList->updateView(); | 3279 | mTodoList->updateView(); |
3274 | // We assume that the navigator only selects consecutive days. | 3280 | // We assume that the navigator only selects consecutive days. |
3275 | updateView( tmpList.first(), tmpList.last() ); | 3281 | updateView( tmpList.first(), tmpList.last() ); |
3276 | } | 3282 | } |
3277 | 3283 | ||
3278 | void CalendarView::updateUnmanagedViews() | 3284 | void CalendarView::updateUnmanagedViews() |
3279 | { | 3285 | { |
3280 | mDateNavigator->updateDayMatrix(); | 3286 | mDateNavigator->updateDayMatrix(); |
3281 | } | 3287 | } |
3282 | 3288 | ||
3283 | int CalendarView::msgItemDelete(const QString name) | 3289 | int CalendarView::msgItemDelete(const QString name) |
3284 | { | 3290 | { |
3285 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 3291 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
3286 | i18n("This item will be\npermanently deleted."), | 3292 | i18n("This item will be\npermanently deleted."), |
3287 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 3293 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
3288 | } | 3294 | } |
3289 | 3295 | ||
3290 | 3296 | ||
3291 | void CalendarView::edit_cut() | 3297 | void CalendarView::edit_cut() |
3292 | { | 3298 | { |
3293 | Event *anEvent=0; | 3299 | Event *anEvent=0; |
3294 | 3300 | ||
3295 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3301 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3296 | 3302 | ||
3297 | if (mViewManager->currentView()->isEventView()) { | 3303 | if (mViewManager->currentView()->isEventView()) { |
@@ -3303,352 +3309,352 @@ void CalendarView::edit_cut() | |||
3303 | if (!anEvent) { | 3309 | if (!anEvent) { |
3304 | KNotifyClient::beep(); | 3310 | KNotifyClient::beep(); |
3305 | return; | 3311 | return; |
3306 | } | 3312 | } |
3307 | DndFactory factory( mCalendar ); | 3313 | DndFactory factory( mCalendar ); |
3308 | factory.cutIncidence(anEvent); | 3314 | factory.cutIncidence(anEvent); |
3309 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3315 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3310 | } | 3316 | } |
3311 | 3317 | ||
3312 | void CalendarView::edit_copy() | 3318 | void CalendarView::edit_copy() |
3313 | { | 3319 | { |
3314 | Event *anEvent=0; | 3320 | Event *anEvent=0; |
3315 | 3321 | ||
3316 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3322 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3317 | 3323 | ||
3318 | if (mViewManager->currentView()->isEventView()) { | 3324 | if (mViewManager->currentView()->isEventView()) { |
3319 | if ( incidence && incidence->typeID() == eventID ) { | 3325 | if ( incidence && incidence->typeID() == eventID ) { |
3320 | anEvent = static_cast<Event *>(incidence); | 3326 | anEvent = static_cast<Event *>(incidence); |
3321 | } | 3327 | } |
3322 | } | 3328 | } |
3323 | 3329 | ||
3324 | if (!anEvent) { | 3330 | if (!anEvent) { |
3325 | KNotifyClient::beep(); | 3331 | KNotifyClient::beep(); |
3326 | return; | 3332 | return; |
3327 | } | 3333 | } |
3328 | DndFactory factory( mCalendar ); | 3334 | DndFactory factory( mCalendar ); |
3329 | factory.copyIncidence(anEvent); | 3335 | factory.copyIncidence(anEvent); |
3330 | } | 3336 | } |
3331 | 3337 | ||
3332 | void CalendarView::edit_paste() | 3338 | void CalendarView::edit_paste() |
3333 | { | 3339 | { |
3334 | QDate date = mNavigator->selectedDates().first(); | 3340 | QDate date = mNavigator->selectedDates().first(); |
3335 | 3341 | ||
3336 | DndFactory factory( mCalendar ); | 3342 | DndFactory factory( mCalendar ); |
3337 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 3343 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
3338 | 3344 | ||
3339 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 3345 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
3340 | } | 3346 | } |
3341 | void CalendarView::edit_global_options() | 3347 | void CalendarView::edit_global_options() |
3342 | { | 3348 | { |
3343 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 3349 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
3344 | emit save(); | 3350 | emit save(); |
3345 | emit saveStopTimer(); | 3351 | emit saveStopTimer(); |
3346 | mDialogManager->showGlobalOptionsDialog(); | 3352 | mDialogManager->showGlobalOptionsDialog(); |
3347 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 3353 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
3348 | emit saveStopTimer(); | 3354 | emit saveStopTimer(); |
3349 | 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!"), | 3355 | 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!"), |
3350 | i18n("Timezone settings"),i18n("Reload"))) { | 3356 | i18n("Timezone settings"),i18n("Reload"))) { |
3351 | qDebug("KO: TZ reload cancelled "); | 3357 | qDebug("KO: TZ reload cancelled "); |
3352 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3358 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3353 | return; | 3359 | return; |
3354 | } | 3360 | } |
3355 | qDebug("KO: Timezone change "); | 3361 | qDebug("KO: Timezone change "); |
3356 | loadCalendars(); | 3362 | loadCalendars(); |
3357 | setModified(true); | 3363 | setModified(true); |
3358 | } | 3364 | } |
3359 | else | 3365 | else |
3360 | qDebug("KO: No tz change "); | 3366 | qDebug("KO: No tz change "); |
3361 | } | 3367 | } |
3362 | void CalendarView::edit_options() | 3368 | void CalendarView::edit_options() |
3363 | { | 3369 | { |
3364 | mDialogManager->showOptionsDialog(); | 3370 | mDialogManager->showOptionsDialog(); |
3365 | } | 3371 | } |
3366 | 3372 | ||
3367 | 3373 | ||
3368 | void CalendarView::slotSelectPickerDate( QDate d) | 3374 | void CalendarView::slotSelectPickerDate( QDate d) |
3369 | { | 3375 | { |
3370 | mDateFrame->hide(); | 3376 | mDateFrame->hide(); |
3371 | if ( mDatePickerMode == 1 ) { | 3377 | if ( mDatePickerMode == 1 ) { |
3372 | mNavigator->slotDaySelect( d ); | 3378 | mNavigator->slotDaySelect( d ); |
3373 | } else if ( mDatePickerMode == 2 ) { | 3379 | } else if ( mDatePickerMode == 2 ) { |
3374 | if ( mMoveIncidence->typeID() == todoID ) { | 3380 | if ( mMoveIncidence->typeID() == todoID ) { |
3375 | Todo * to = (Todo *) mMoveIncidence; | 3381 | Todo * to = (Todo *) mMoveIncidence; |
3376 | QTime tim; | 3382 | QTime tim; |
3377 | int len = 0; | 3383 | int len = 0; |
3378 | if ( to->hasStartDate() && to->hasDueDate() ) | 3384 | if ( to->hasStartDate() && to->hasDueDate() ) |
3379 | len = to->dtStart().secsTo( to->dtDue()); | 3385 | len = to->dtStart().secsTo( to->dtDue()); |
3380 | if ( to->hasDueDate() ) | 3386 | if ( to->hasDueDate() ) |
3381 | tim = to->dtDue().time(); | 3387 | tim = to->dtDue().time(); |
3382 | else { | 3388 | else { |
3383 | tim = QTime ( 0,0,0 ); | 3389 | tim = QTime ( 0,0,0 ); |
3384 | to->setFloats( true ); | 3390 | to->setFloats( true ); |
3385 | to->setHasDueDate( true ); | 3391 | to->setHasDueDate( true ); |
3386 | } | 3392 | } |
3387 | QDateTime dt ( d,tim ); | 3393 | QDateTime dt ( d,tim ); |
3388 | to->setDtDue( dt ); | 3394 | to->setDtDue( dt ); |
3389 | 3395 | ||
3390 | if ( to->hasStartDate() ) { | 3396 | if ( to->hasStartDate() ) { |
3391 | if ( len>0 ) | 3397 | if ( len>0 ) |
3392 | to->setDtStart(to->dtDue().addSecs( -len )); | 3398 | to->setDtStart(to->dtDue().addSecs( -len )); |
3393 | else | 3399 | else |
3394 | if (to->dtStart() > to->dtDue() ) | 3400 | if (to->dtStart() > to->dtDue() ) |
3395 | to->setDtStart(to->dtDue().addDays( -3 )); | 3401 | to->setDtStart(to->dtDue().addDays( -3 )); |
3396 | } | 3402 | } |
3397 | 3403 | ||
3398 | todoChanged( to ); | 3404 | todoChanged( to ); |
3399 | } else if ( mMoveIncidence->typeID() == eventID ) { | 3405 | } else if ( mMoveIncidence->typeID() == eventID ) { |
3400 | if ( mMoveIncidence->doesRecur() ) { | 3406 | if ( mMoveIncidence->doesRecur() ) { |
3401 | #if 0 | 3407 | #if 0 |
3402 | // PENDING implement this | 3408 | // PENDING implement this |
3403 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 3409 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3404 | mCalendar()->addIncidence( newInc ); | 3410 | mCalendar()->addIncidence( newInc ); |
3405 | if ( mMoveIncidence->typeID() == todoID ) | 3411 | if ( mMoveIncidence->typeID() == todoID ) |
3406 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 3412 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3407 | else | 3413 | else |
3408 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 3414 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3409 | mMoveIncidence = newInc; | 3415 | mMoveIncidence = newInc; |
3410 | 3416 | ||
3411 | #endif | 3417 | #endif |
3412 | } | 3418 | } |
3413 | QTime tim = mMoveIncidence->dtStart().time(); | 3419 | QTime tim = mMoveIncidence->dtStart().time(); |
3414 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 3420 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3415 | QDateTime dt ( d,tim ); | 3421 | QDateTime dt ( d,tim ); |
3416 | mMoveIncidence->setDtStart( dt ); | 3422 | mMoveIncidence->setDtStart( dt ); |
3417 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 3423 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3418 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 3424 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3419 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3425 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3420 | QTime tim = mMoveIncidence->dtStart().time(); | 3426 | QTime tim = mMoveIncidence->dtStart().time(); |
3421 | QDateTime dt ( d,tim ); | 3427 | QDateTime dt ( d,tim ); |
3422 | mMoveIncidence->setDtStart( dt ); | 3428 | mMoveIncidence->setDtStart( dt ); |
3423 | updateView(); | 3429 | updateView(); |
3424 | } | 3430 | } |
3425 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3431 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3426 | } | 3432 | } |
3427 | } | 3433 | } |
3428 | 3434 | ||
3429 | void CalendarView::removeCategories() | 3435 | void CalendarView::removeCategories() |
3430 | { | 3436 | { |
3431 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3437 | Q3PtrList<Incidence> incList = mCalendar->rawIncidences(); |
3432 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3438 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3433 | QStringList catIncList; | 3439 | QStringList catIncList; |
3434 | QStringList newCatList; | 3440 | QStringList newCatList; |
3435 | Incidence* inc = incList.first(); | 3441 | Incidence* inc = incList.first(); |
3436 | uint i; | 3442 | uint i; |
3437 | while ( inc ) { | 3443 | while ( inc ) { |
3438 | newCatList.clear(); | 3444 | newCatList.clear(); |
3439 | catIncList = inc->categories() ; | 3445 | catIncList = inc->categories() ; |
3440 | for( i = 0; i< catIncList.count(); ++i ) { | 3446 | for( i = 0; i< catIncList.count(); ++i ) { |
3441 | if ( catList.contains (catIncList[i])) | 3447 | if ( catList.contains (catIncList[i])) |
3442 | newCatList.append( catIncList[i] ); | 3448 | newCatList.append( catIncList[i] ); |
3443 | } | 3449 | } |
3444 | newCatList.sort(); | 3450 | newCatList.sort(); |
3445 | inc->setCategories( newCatList.join(",") ); | 3451 | inc->setCategories( newCatList.join(",") ); |
3446 | inc = incList.next(); | 3452 | inc = incList.next(); |
3447 | } | 3453 | } |
3448 | } | 3454 | } |
3449 | 3455 | ||
3450 | int CalendarView::addCategories() | 3456 | int CalendarView::addCategories() |
3451 | { | 3457 | { |
3452 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3458 | Q3PtrList<Incidence> incList = mCalendar->rawIncidences(); |
3453 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3459 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3454 | QStringList catIncList; | 3460 | QStringList catIncList; |
3455 | Incidence* inc = incList.first(); | 3461 | Incidence* inc = incList.first(); |
3456 | uint i; | 3462 | uint i; |
3457 | int count = 0; | 3463 | int count = 0; |
3458 | while ( inc ) { | 3464 | while ( inc ) { |
3459 | catIncList = inc->categories() ; | 3465 | catIncList = inc->categories() ; |
3460 | for( i = 0; i< catIncList.count(); ++i ) { | 3466 | for( i = 0; i< catIncList.count(); ++i ) { |
3461 | if ( !catList.contains (catIncList[i])) { | 3467 | if ( !catList.contains (catIncList[i])) { |
3462 | catList.append( catIncList[i] ); | 3468 | catList.append( catIncList[i] ); |
3463 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3469 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3464 | ++count; | 3470 | ++count; |
3465 | } | 3471 | } |
3466 | } | 3472 | } |
3467 | inc = incList.next(); | 3473 | inc = incList.next(); |
3468 | } | 3474 | } |
3469 | catList.sort(); | 3475 | catList.sort(); |
3470 | KOPrefs::instance()->mCustomCategories = catList; | 3476 | KOPrefs::instance()->mCustomCategories = catList; |
3471 | return count; | 3477 | return count; |
3472 | } | 3478 | } |
3473 | 3479 | ||
3474 | void CalendarView::editCategories() | 3480 | void CalendarView::editCategories() |
3475 | { | 3481 | { |
3476 | qDebug("CalendarView::editCategories() "); | 3482 | qDebug("CalendarView::editCategories() "); |
3477 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3483 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3478 | ced.exec(); | 3484 | ced.exec(); |
3479 | } | 3485 | } |
3480 | void CalendarView::manageCategories() | 3486 | void CalendarView::manageCategories() |
3481 | { | 3487 | { |
3482 | KOCatPrefs* cp = new KOCatPrefs(); | 3488 | KOCatPrefs* cp = new KOCatPrefs(); |
3483 | cp->show(); | 3489 | cp->show(); |
3484 | int w =cp->sizeHint().width() ; | 3490 | int w =cp->sizeHint().width() ; |
3485 | int h = cp->sizeHint().height() ; | 3491 | int h = cp->sizeHint().height() ; |
3486 | int dw = QApplication::desktop()->width(); | 3492 | int dw = QApplication::desktop()->width(); |
3487 | int dh = QApplication::desktop()->height(); | 3493 | int dh = QApplication::desktop()->height(); |
3488 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3494 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3489 | if ( !cp->exec() ) { | 3495 | if ( !cp->exec() ) { |
3490 | delete cp; | 3496 | delete cp; |
3491 | return; | 3497 | return; |
3492 | } | 3498 | } |
3493 | int count = 0; | 3499 | int count = 0; |
3494 | if ( cp->addCat() ) { | 3500 | if ( cp->addCat() ) { |
3495 | count = addCategories(); | 3501 | count = addCategories(); |
3496 | if ( count ) { | 3502 | if ( count ) { |
3497 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3503 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3498 | writeSettings(); | 3504 | writeSettings(); |
3499 | } else | 3505 | } else |
3500 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3506 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3501 | } else { | 3507 | } else { |
3502 | removeCategories(); | 3508 | removeCategories(); |
3503 | updateView(); | 3509 | updateView(); |
3504 | } | 3510 | } |
3505 | delete cp; | 3511 | delete cp; |
3506 | } | 3512 | } |
3507 | 3513 | ||
3508 | void CalendarView::beamIncidence(Incidence * Inc) | 3514 | void CalendarView::beamIncidence(Incidence * Inc) |
3509 | { | 3515 | { |
3510 | QPtrList<Incidence> delSel ; | 3516 | Q3PtrList<Incidence> delSel ; |
3511 | delSel.append(Inc); | 3517 | delSel.append(Inc); |
3512 | beamIncidenceList( delSel ); | 3518 | beamIncidenceList( delSel ); |
3513 | } | 3519 | } |
3514 | void CalendarView::beamCalendar() | 3520 | void CalendarView::beamCalendar() |
3515 | { | 3521 | { |
3516 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3522 | Q3PtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3517 | //qDebug("beamCalendar() "); | 3523 | //qDebug("beamCalendar() "); |
3518 | beamIncidenceList( delSel ); | 3524 | beamIncidenceList( delSel ); |
3519 | } | 3525 | } |
3520 | void CalendarView::beamFilteredCalendar() | 3526 | void CalendarView::beamFilteredCalendar() |
3521 | { | 3527 | { |
3522 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3528 | Q3PtrList<Incidence> delSel = mCalendar->incidences(); |
3523 | //qDebug("beamFilteredCalendar() "); | 3529 | //qDebug("beamFilteredCalendar() "); |
3524 | beamIncidenceList( delSel ); | 3530 | beamIncidenceList( delSel ); |
3525 | } | 3531 | } |
3526 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3532 | void CalendarView::beamIncidenceList(Q3PtrList<Incidence> delSel ) |
3527 | { | 3533 | { |
3528 | 3534 | ||
3529 | KOBeamPrefs beamDialog; | 3535 | KOBeamPrefs beamDialog; |
3530 | if ( beamDialog.exec () == QDialog::Rejected ) | 3536 | if ( beamDialog.exec () == QDialog::Rejected ) |
3531 | return; | 3537 | return; |
3532 | #ifdef DESKTOP_VERSION | 3538 | #ifdef DESKTOP_VERSION |
3533 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3539 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3534 | #else | 3540 | #else |
3535 | QString fn = "/tmp/kopibeamfile"; | 3541 | QString fn = "/tmp/kopibeamfile"; |
3536 | #endif | 3542 | #endif |
3537 | QString mes; | 3543 | QString mes; |
3538 | bool createbup = true; | 3544 | bool createbup = true; |
3539 | if ( createbup ) { | 3545 | if ( createbup ) { |
3540 | QString description = "\n"; | 3546 | QString description = "\n"; |
3541 | CalendarLocal* cal = new CalendarLocal(); | 3547 | CalendarLocal* cal = new CalendarLocal(); |
3542 | if ( beamDialog.beamLocal() ) | 3548 | if ( beamDialog.beamLocal() ) |
3543 | cal->setLocalTime(); | 3549 | cal->setLocalTime(); |
3544 | else | 3550 | else |
3545 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3551 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3546 | Incidence *incidence = delSel.first(); | 3552 | Incidence *incidence = delSel.first(); |
3547 | bool addText = false; | 3553 | bool addText = false; |
3548 | if ( delSel.count() < 10 ) | 3554 | if ( delSel.count() < 10 ) |
3549 | addText = true; | 3555 | addText = true; |
3550 | else { | 3556 | else { |
3551 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3557 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3552 | } | 3558 | } |
3553 | while ( incidence ) { | 3559 | while ( incidence ) { |
3554 | Incidence *in = incidence->clone(); | 3560 | Incidence *in = incidence->clone(); |
3555 | if ( ! in->summary().isEmpty() ) { | 3561 | if ( ! in->summary().isEmpty() ) { |
3556 | in->setDescription(""); | 3562 | in->setDescription(""); |
3557 | } else { | 3563 | } else { |
3558 | in->setSummary( in->description().left(20)); | 3564 | in->setSummary( in->description().left(20)); |
3559 | in->setDescription(""); | 3565 | in->setDescription(""); |
3560 | } | 3566 | } |
3561 | if ( addText ) | 3567 | if ( addText ) |
3562 | description += in->summary() + "\n"; | 3568 | description += in->summary() + "\n"; |
3563 | cal->addIncidence( in ); | 3569 | cal->addIncidence( in ); |
3564 | incidence = delSel.next(); | 3570 | incidence = delSel.next(); |
3565 | } | 3571 | } |
3566 | if ( beamDialog.beamVcal() ) { | 3572 | if ( beamDialog.beamVcal() ) { |
3567 | fn += ".vcs"; | 3573 | fn += ".vcs"; |
3568 | FileStorage storage( cal, fn, new VCalFormat ); | 3574 | FileStorage storage( cal, fn, new VCalFormat ); |
3569 | storage.save(); | 3575 | storage.save(); |
3570 | } else { | 3576 | } else { |
3571 | fn += ".ics"; | 3577 | fn += ".ics"; |
3572 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3578 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3573 | storage.save(); | 3579 | storage.save(); |
3574 | } | 3580 | } |
3575 | delete cal; | 3581 | delete cal; |
3576 | mes = i18n("KO/Pi: Ready for beaming"); | 3582 | mes = i18n("KO/Pi: Ready for beaming"); |
3577 | topLevelWidget()->setCaption(mes); | 3583 | topLevelWidget()->setCaption(mes); |
3578 | KApplication::convert2latin1( fn ); | 3584 | KApplication::convert2latin1( fn ); |
3579 | #ifndef DESKTOP_VERSION | 3585 | #ifndef DESKTOP_VERSION |
3580 | Ir *ir = new Ir( this ); | 3586 | Ir *ir = new Ir( this ); |
3581 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3587 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3582 | ir->send( fn, description, "text/x-vCalendar" ); | 3588 | ir->send( fn, description, "text/x-vCalendar" ); |
3583 | #endif | 3589 | #endif |
3584 | } | 3590 | } |
3585 | } | 3591 | } |
3586 | 3592 | ||
3587 | #ifndef DESKTOP_VERSION | 3593 | #ifndef DESKTOP_VERSION |
3588 | void CalendarView::beamDone( Ir *ir ) | 3594 | void CalendarView::beamDone( Ir *ir ) |
3589 | { | 3595 | { |
3590 | delete ir; | 3596 | delete ir; |
3591 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3597 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3592 | topLevelWidget()->raise(); | 3598 | topLevelWidget()->raise(); |
3593 | } | 3599 | } |
3594 | #else | 3600 | #else |
3595 | void CalendarView::beamDone( Ir *){;} | 3601 | void CalendarView::beamDone( Ir *){;} |
3596 | #endif | 3602 | #endif |
3597 | void CalendarView::moveIncidence(Incidence * inc ) | 3603 | void CalendarView::moveIncidence(Incidence * inc ) |
3598 | { | 3604 | { |
3599 | if ( !inc ) return; | 3605 | if ( !inc ) return; |
3600 | showDatePickerPopup(); | 3606 | showDatePickerPopup(); |
3601 | mDatePickerMode = 2; | 3607 | mDatePickerMode = 2; |
3602 | mMoveIncidence = inc ; | 3608 | mMoveIncidence = inc ; |
3603 | QDate da; | 3609 | QDate da; |
3604 | if ( mMoveIncidence->typeID() == todoID ) { | 3610 | if ( mMoveIncidence->typeID() == todoID ) { |
3605 | Todo * to = (Todo *) mMoveIncidence; | 3611 | Todo * to = (Todo *) mMoveIncidence; |
3606 | if ( to->hasDueDate() ) | 3612 | if ( to->hasDueDate() ) |
3607 | da = to->dtDue().date(); | 3613 | da = to->dtDue().date(); |
3608 | else | 3614 | else |
3609 | da = QDate::currentDate(); | 3615 | da = QDate::currentDate(); |
3610 | } else { | 3616 | } else { |
3611 | da = mMoveIncidence->dtStart().date(); | 3617 | da = mMoveIncidence->dtStart().date(); |
3612 | } | 3618 | } |
3613 | //PENDING set date for recurring incidence to date of recurrence | 3619 | //PENDING set date for recurring incidence to date of recurrence |
3614 | //mMoveIncidenceOldDate; | 3620 | //mMoveIncidenceOldDate; |
3615 | mDatePicker->setDate( da ); | 3621 | mDatePicker->setDate( da ); |
3616 | } | 3622 | } |
3617 | void CalendarView::showDatePickerPopup() | 3623 | void CalendarView::showDatePickerPopup() |
3618 | { | 3624 | { |
3619 | if ( mDateFrame->isVisible() ) | 3625 | if ( mDateFrame->isVisible() ) |
3620 | mDateFrame->hide(); | 3626 | mDateFrame->hide(); |
3621 | else { | 3627 | else { |
3622 | int offX = 0, offY = 0; | 3628 | int offX = 0, offY = 0; |
3623 | #ifdef DESKTOP_VERSION | 3629 | #ifdef DESKTOP_VERSION |
3624 | int w =mDatePicker->sizeHint().width() ; | 3630 | int w =mDatePicker->sizeHint().width() ; |
3625 | int h = mDatePicker->sizeHint().height() ; | 3631 | int h = mDatePicker->sizeHint().height() ; |
3626 | int dw = topLevelWidget()->width(); | 3632 | int dw = topLevelWidget()->width(); |
3627 | int dh = topLevelWidget()->height(); | 3633 | int dh = topLevelWidget()->height(); |
3628 | offX = topLevelWidget()->x(); | 3634 | offX = topLevelWidget()->x(); |
3629 | offY = topLevelWidget()->y(); | 3635 | offY = topLevelWidget()->y(); |
3630 | #else | 3636 | #else |
3631 | int w =mDatePicker->sizeHint().width() ; | 3637 | int w =mDatePicker->sizeHint().width() ; |
3632 | int h = mDatePicker->sizeHint().height() ; | 3638 | int h = mDatePicker->sizeHint().height() ; |
3633 | int dw = QApplication::desktop()->width(); | 3639 | int dw = QApplication::desktop()->width(); |
3634 | int dh = QApplication::desktop()->height(); | 3640 | int dh = QApplication::desktop()->height(); |
3635 | #endif | 3641 | #endif |
3636 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3642 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3637 | mDateFrame->show(); | 3643 | mDateFrame->show(); |
3638 | } | 3644 | } |
3639 | } | 3645 | } |
3640 | void CalendarView::showDatePicker( ) | 3646 | void CalendarView::showDatePicker( ) |
3641 | { | 3647 | { |
3642 | showDatePickerPopup(); | 3648 | showDatePickerPopup(); |
3643 | mDatePickerMode = 1; | 3649 | mDatePickerMode = 1; |
3644 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3650 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3645 | } | 3651 | } |
3646 | 3652 | ||
3647 | void CalendarView::showEventEditor() | 3653 | void CalendarView::showEventEditor() |
3648 | { | 3654 | { |
3649 | #ifdef DESKTOP_VERSION | 3655 | #ifdef DESKTOP_VERSION |
3650 | int x,y,w,h; | 3656 | int x,y,w,h; |
3651 | x = mEventEditor->geometry().x(); | 3657 | x = mEventEditor->geometry().x(); |
3652 | y = mEventEditor->geometry().y(); | 3658 | y = mEventEditor->geometry().y(); |
3653 | w = mEventEditor->width(); | 3659 | w = mEventEditor->width(); |
3654 | h = mEventEditor->height(); | 3660 | h = mEventEditor->height(); |
@@ -4190,257 +4196,257 @@ void CalendarView::deleteEvent(Event *anEvent) | |||
4190 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 4196 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
4191 | anEvent->addExDate(itemDate); | 4197 | anEvent->addExDate(itemDate); |
4192 | int duration = anEvent->recurrence()->duration(); | 4198 | int duration = anEvent->recurrence()->duration(); |
4193 | if ( duration > 0 ) { | 4199 | if ( duration > 0 ) { |
4194 | anEvent->recurrence()->setDuration( duration - 1 ); | 4200 | anEvent->recurrence()->setDuration( duration - 1 ); |
4195 | } | 4201 | } |
4196 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 4202 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
4197 | } | 4203 | } |
4198 | break; | 4204 | break; |
4199 | //#endif | 4205 | //#endif |
4200 | } // switch | 4206 | } // switch |
4201 | } else { | 4207 | } else { |
4202 | if (KOPrefs::instance()->mConfirm) { | 4208 | if (KOPrefs::instance()->mConfirm) { |
4203 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4209 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4204 | i18n("\nAre you sure you want\nto delete this event?"), | 4210 | i18n("\nAre you sure you want\nto delete this event?"), |
4205 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 4211 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
4206 | case KMessageBox::Continue: // OK | 4212 | case KMessageBox::Continue: // OK |
4207 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4213 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4208 | schedule(Scheduler::Cancel,anEvent); | 4214 | schedule(Scheduler::Cancel,anEvent); |
4209 | checkExternalId( anEvent); | 4215 | checkExternalId( anEvent); |
4210 | mCalendar->deleteEvent(anEvent); | 4216 | mCalendar->deleteEvent(anEvent); |
4211 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4217 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4212 | break; | 4218 | break; |
4213 | } // switch | 4219 | } // switch |
4214 | } else { | 4220 | } else { |
4215 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4221 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4216 | schedule(Scheduler::Cancel,anEvent); | 4222 | schedule(Scheduler::Cancel,anEvent); |
4217 | checkExternalId( anEvent); | 4223 | checkExternalId( anEvent); |
4218 | mCalendar->deleteEvent(anEvent); | 4224 | mCalendar->deleteEvent(anEvent); |
4219 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4225 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4220 | } | 4226 | } |
4221 | } // if-else | 4227 | } // if-else |
4222 | emit updateSearchDialog(); | 4228 | emit updateSearchDialog(); |
4223 | } | 4229 | } |
4224 | 4230 | ||
4225 | bool CalendarView::deleteEvent(const QString &uid) | 4231 | bool CalendarView::deleteEvent(const QString &uid) |
4226 | { | 4232 | { |
4227 | Event *ev = mCalendar->event(uid); | 4233 | Event *ev = mCalendar->event(uid); |
4228 | if (ev) { | 4234 | if (ev) { |
4229 | deleteEvent(ev); | 4235 | deleteEvent(ev); |
4230 | return true; | 4236 | return true; |
4231 | } else { | 4237 | } else { |
4232 | return false; | 4238 | return false; |
4233 | } | 4239 | } |
4234 | } | 4240 | } |
4235 | 4241 | ||
4236 | /*****************************************************************************/ | 4242 | /*****************************************************************************/ |
4237 | 4243 | ||
4238 | void CalendarView::action_mail() | 4244 | void CalendarView::action_mail() |
4239 | { | 4245 | { |
4240 | #ifndef KORG_NOMAIL | 4246 | #ifndef KORG_NOMAIL |
4241 | KOMailClient mailClient; | 4247 | KOMailClient mailClient; |
4242 | 4248 | ||
4243 | Incidence *incidence = currentSelection(); | 4249 | Incidence *incidence = currentSelection(); |
4244 | 4250 | ||
4245 | if (!incidence) { | 4251 | if (!incidence) { |
4246 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4252 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4247 | return; | 4253 | return; |
4248 | } | 4254 | } |
4249 | if(incidence->attendeeCount() == 0 ) { | 4255 | if(incidence->attendeeCount() == 0 ) { |
4250 | KMessageBox::sorry(this, | 4256 | KMessageBox::sorry(this, |
4251 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4257 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4252 | return; | 4258 | return; |
4253 | } | 4259 | } |
4254 | 4260 | ||
4255 | CalendarLocal cal_tmp; | 4261 | CalendarLocal cal_tmp; |
4256 | Event *event = 0; | 4262 | Event *event = 0; |
4257 | Event *ev = 0; | 4263 | Event *ev = 0; |
4258 | if ( incidence && incidence->typeID() == eventID ) { | 4264 | if ( incidence && incidence->typeID() == eventID ) { |
4259 | event = static_cast<Event *>(incidence); | 4265 | event = static_cast<Event *>(incidence); |
4260 | ev = new Event(*event); | 4266 | ev = new Event(*event); |
4261 | cal_tmp.addEvent(ev); | 4267 | cal_tmp.addEvent(ev); |
4262 | } | 4268 | } |
4263 | ICalFormat mForm(); | 4269 | ICalFormat mForm(); |
4264 | QString attachment = mForm.toString( &cal_tmp ); | 4270 | QString attachment = mForm.toString( &cal_tmp ); |
4265 | if (ev) delete(ev); | 4271 | if (ev) delete(ev); |
4266 | 4272 | ||
4267 | mailClient.mailAttendees(currentSelection(), attachment); | 4273 | mailClient.mailAttendees(currentSelection(), attachment); |
4268 | 4274 | ||
4269 | #endif | 4275 | #endif |
4270 | 4276 | ||
4271 | #if 0 | 4277 | #if 0 |
4272 | Event *anEvent = 0; | 4278 | Event *anEvent = 0; |
4273 | if (mViewManager->currentView()->isEventView()) { | 4279 | if (mViewManager->currentView()->isEventView()) { |
4274 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 4280 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
4275 | } | 4281 | } |
4276 | 4282 | ||
4277 | if (!anEvent) { | 4283 | if (!anEvent) { |
4278 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4284 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4279 | return; | 4285 | return; |
4280 | } | 4286 | } |
4281 | if(anEvent->attendeeCount() == 0 ) { | 4287 | if(anEvent->attendeeCount() == 0 ) { |
4282 | KMessageBox::sorry(this, | 4288 | KMessageBox::sorry(this, |
4283 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4289 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4284 | return; | 4290 | return; |
4285 | } | 4291 | } |
4286 | 4292 | ||
4287 | mailobject.emailEvent(anEvent); | 4293 | mailobject.emailEvent(anEvent); |
4288 | #endif | 4294 | #endif |
4289 | } | 4295 | } |
4290 | 4296 | ||
4291 | 4297 | ||
4292 | void CalendarView::schedule_publish(Incidence *incidence) | 4298 | void CalendarView::schedule_publish(Incidence *incidence) |
4293 | { | 4299 | { |
4294 | Event *event = 0; | 4300 | Event *event = 0; |
4295 | Todo *todo = 0; | 4301 | Todo *todo = 0; |
4296 | 4302 | ||
4297 | if (incidence == 0) { | 4303 | if (incidence == 0) { |
4298 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4304 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4299 | if (incidence == 0) { | 4305 | if (incidence == 0) { |
4300 | incidence = mTodoList->selectedIncidences().first(); | 4306 | incidence = mTodoList->selectedIncidences().first(); |
4301 | } | 4307 | } |
4302 | } | 4308 | } |
4303 | if ( incidence && incidence->typeID() == eventID ) { | 4309 | if ( incidence && incidence->typeID() == eventID ) { |
4304 | event = static_cast<Event *>(incidence); | 4310 | event = static_cast<Event *>(incidence); |
4305 | } else { | 4311 | } else { |
4306 | if ( incidence && incidence->typeID() == todoID ) { | 4312 | if ( incidence && incidence->typeID() == todoID ) { |
4307 | todo = static_cast<Todo *>(incidence); | 4313 | todo = static_cast<Todo *>(incidence); |
4308 | } | 4314 | } |
4309 | } | 4315 | } |
4310 | 4316 | ||
4311 | if (!event && !todo) { | 4317 | if (!event && !todo) { |
4312 | KMessageBox::sorry(this,i18n("No event selected.")); | 4318 | KMessageBox::sorry(this,i18n("No event selected.")); |
4313 | return; | 4319 | return; |
4314 | } | 4320 | } |
4315 | 4321 | ||
4316 | PublishDialog *publishdlg = new PublishDialog(); | 4322 | PublishDialog *publishdlg = new PublishDialog(); |
4317 | if (incidence->attendeeCount()>0) { | 4323 | if (incidence->attendeeCount()>0) { |
4318 | QPtrList<Attendee> attendees = incidence->attendees(); | 4324 | Q3PtrList<Attendee> attendees = incidence->attendees(); |
4319 | attendees.first(); | 4325 | attendees.first(); |
4320 | while ( attendees.current()!=0 ) { | 4326 | while ( attendees.current()!=0 ) { |
4321 | publishdlg->addAttendee(attendees.current()); | 4327 | publishdlg->addAttendee(attendees.current()); |
4322 | attendees.next(); | 4328 | attendees.next(); |
4323 | } | 4329 | } |
4324 | } | 4330 | } |
4325 | bool send = true; | 4331 | bool send = true; |
4326 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 4332 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
4327 | if ( publishdlg->exec() != QDialog::Accepted ) | 4333 | if ( publishdlg->exec() != QDialog::Accepted ) |
4328 | send = false; | 4334 | send = false; |
4329 | } | 4335 | } |
4330 | if ( send ) { | 4336 | if ( send ) { |
4331 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4337 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4332 | if ( event ) { | 4338 | if ( event ) { |
4333 | Event *ev = new Event(*event); | 4339 | Event *ev = new Event(*event); |
4334 | ev->registerObserver(0); | 4340 | ev->registerObserver(0); |
4335 | ev->clearAttendees(); | 4341 | ev->clearAttendees(); |
4336 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4342 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4337 | delete(ev); | 4343 | delete(ev); |
4338 | } | 4344 | } |
4339 | } else { | 4345 | } else { |
4340 | if ( todo ) { | 4346 | if ( todo ) { |
4341 | Todo *ev = new Todo(*todo); | 4347 | Todo *ev = new Todo(*todo); |
4342 | ev->registerObserver(0); | 4348 | ev->registerObserver(0); |
4343 | ev->clearAttendees(); | 4349 | ev->clearAttendees(); |
4344 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4350 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4345 | delete(ev); | 4351 | delete(ev); |
4346 | } | 4352 | } |
4347 | } | 4353 | } |
4348 | } | 4354 | } |
4349 | } | 4355 | } |
4350 | delete publishdlg; | 4356 | delete publishdlg; |
4351 | } | 4357 | } |
4352 | 4358 | ||
4353 | void CalendarView::schedule_request(Incidence *incidence) | 4359 | void CalendarView::schedule_request(Incidence *incidence) |
4354 | { | 4360 | { |
4355 | schedule(Scheduler::Request,incidence); | 4361 | schedule(Scheduler::Request,incidence); |
4356 | } | 4362 | } |
4357 | 4363 | ||
4358 | void CalendarView::schedule_refresh(Incidence *incidence) | 4364 | void CalendarView::schedule_refresh(Incidence *incidence) |
4359 | { | 4365 | { |
4360 | schedule(Scheduler::Refresh,incidence); | 4366 | schedule(Scheduler::Refresh,incidence); |
4361 | } | 4367 | } |
4362 | 4368 | ||
4363 | void CalendarView::schedule_cancel(Incidence *incidence) | 4369 | void CalendarView::schedule_cancel(Incidence *incidence) |
4364 | { | 4370 | { |
4365 | schedule(Scheduler::Cancel,incidence); | 4371 | schedule(Scheduler::Cancel,incidence); |
4366 | } | 4372 | } |
4367 | 4373 | ||
4368 | void CalendarView::schedule_add(Incidence *incidence) | 4374 | void CalendarView::schedule_add(Incidence *incidence) |
4369 | { | 4375 | { |
4370 | schedule(Scheduler::Add,incidence); | 4376 | schedule(Scheduler::Add,incidence); |
4371 | } | 4377 | } |
4372 | 4378 | ||
4373 | void CalendarView::schedule_reply(Incidence *incidence) | 4379 | void CalendarView::schedule_reply(Incidence *incidence) |
4374 | { | 4380 | { |
4375 | schedule(Scheduler::Reply,incidence); | 4381 | schedule(Scheduler::Reply,incidence); |
4376 | } | 4382 | } |
4377 | 4383 | ||
4378 | void CalendarView::schedule_counter(Incidence *incidence) | 4384 | void CalendarView::schedule_counter(Incidence *incidence) |
4379 | { | 4385 | { |
4380 | schedule(Scheduler::Counter,incidence); | 4386 | schedule(Scheduler::Counter,incidence); |
4381 | } | 4387 | } |
4382 | 4388 | ||
4383 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 4389 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
4384 | { | 4390 | { |
4385 | schedule(Scheduler::Declinecounter,incidence); | 4391 | schedule(Scheduler::Declinecounter,incidence); |
4386 | } | 4392 | } |
4387 | 4393 | ||
4388 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 4394 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
4389 | { | 4395 | { |
4390 | QDateTime start = QDateTime::currentDateTime(); | 4396 | QDateTime start = QDateTime::currentDateTime(); |
4391 | QDateTime end = start.addDays(daysToPublish); | 4397 | QDateTime end = start.addDays(daysToPublish); |
4392 | 4398 | ||
4393 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4399 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
4394 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4400 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
4395 | 4401 | ||
4396 | 4402 | ||
4397 | PublishDialog *publishdlg = new PublishDialog(); | 4403 | PublishDialog *publishdlg = new PublishDialog(); |
4398 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4404 | if ( publishdlg->exec() == QDialog::Accepted ) { |
4399 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4405 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4400 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4406 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
4401 | delete(freebusy); | 4407 | delete(freebusy); |
4402 | } | 4408 | } |
4403 | } | 4409 | } |
4404 | delete publishdlg; | 4410 | delete publishdlg; |
4405 | } | 4411 | } |
4406 | 4412 | ||
4407 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4413 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4408 | { | 4414 | { |
4409 | Event *event = 0; | 4415 | Event *event = 0; |
4410 | Todo *todo = 0; | 4416 | Todo *todo = 0; |
4411 | 4417 | ||
4412 | if (incidence == 0) { | 4418 | if (incidence == 0) { |
4413 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4419 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4414 | if (incidence == 0) { | 4420 | if (incidence == 0) { |
4415 | incidence = mTodoList->selectedIncidences().first(); | 4421 | incidence = mTodoList->selectedIncidences().first(); |
4416 | } | 4422 | } |
4417 | } | 4423 | } |
4418 | if ( incidence && incidence->typeID() == eventID ) { | 4424 | if ( incidence && incidence->typeID() == eventID ) { |
4419 | event = static_cast<Event *>(incidence); | 4425 | event = static_cast<Event *>(incidence); |
4420 | } | 4426 | } |
4421 | if ( incidence && incidence->typeID() == todoID ) { | 4427 | if ( incidence && incidence->typeID() == todoID ) { |
4422 | todo = static_cast<Todo *>(incidence); | 4428 | todo = static_cast<Todo *>(incidence); |
4423 | } | 4429 | } |
4424 | 4430 | ||
4425 | if (!event && !todo) { | 4431 | if (!event && !todo) { |
4426 | KMessageBox::sorry(this,i18n("No event selected.")); | 4432 | KMessageBox::sorry(this,i18n("No event selected.")); |
4427 | return; | 4433 | return; |
4428 | } | 4434 | } |
4429 | 4435 | ||
4430 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4436 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4431 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4437 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4432 | return; | 4438 | return; |
4433 | } | 4439 | } |
4434 | 4440 | ||
4435 | Event *ev = 0; | 4441 | Event *ev = 0; |
4436 | if (event) ev = new Event(*event); | 4442 | if (event) ev = new Event(*event); |
4437 | Todo *to = 0; | 4443 | Todo *to = 0; |
4438 | if (todo) to = new Todo(*todo); | 4444 | if (todo) to = new Todo(*todo); |
4439 | 4445 | ||
4440 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4446 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4441 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4447 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4442 | if (!me) { | 4448 | if (!me) { |
4443 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4449 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4444 | return; | 4450 | return; |
4445 | } | 4451 | } |
4446 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4452 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
@@ -4599,620 +4605,620 @@ void CalendarView::adaptNavigationUnits() | |||
4599 | } else { | 4605 | } else { |
4600 | emit changeNavStringPrev(i18n("&Previous Week")); | 4606 | emit changeNavStringPrev(i18n("&Previous Week")); |
4601 | emit changeNavStringNext(i18n("&Next Week")); | 4607 | emit changeNavStringNext(i18n("&Next Week")); |
4602 | } | 4608 | } |
4603 | } | 4609 | } |
4604 | } | 4610 | } |
4605 | 4611 | ||
4606 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4612 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4607 | { | 4613 | { |
4608 | if ( incidence ) mTodoList->clearSelection(); | 4614 | if ( incidence ) mTodoList->clearSelection(); |
4609 | processIncidenceSelection( incidence ); | 4615 | processIncidenceSelection( incidence ); |
4610 | } | 4616 | } |
4611 | 4617 | ||
4612 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4618 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4613 | { | 4619 | { |
4614 | if ( incidence && mViewManager->currentView() ) { | 4620 | if ( incidence && mViewManager->currentView() ) { |
4615 | mViewManager->currentView()->clearSelection(); | 4621 | mViewManager->currentView()->clearSelection(); |
4616 | } | 4622 | } |
4617 | processIncidenceSelection( incidence ); | 4623 | processIncidenceSelection( incidence ); |
4618 | } | 4624 | } |
4619 | 4625 | ||
4620 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4626 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4621 | { | 4627 | { |
4622 | emit incidenceSelected( incidence ); | 4628 | emit incidenceSelected( incidence ); |
4623 | if ( incidence == mSelectedIncidence ) return; | 4629 | if ( incidence == mSelectedIncidence ) return; |
4624 | mSelectedIncidence = incidence; | 4630 | mSelectedIncidence = incidence; |
4625 | 4631 | ||
4626 | if ( incidence && incidence->typeID() == eventID ) { | 4632 | if ( incidence && incidence->typeID() == eventID ) { |
4627 | Event *event = static_cast<Event *>( incidence ); | 4633 | Event *event = static_cast<Event *>( incidence ); |
4628 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4634 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4629 | emit organizerEventsSelected( true ); | 4635 | emit organizerEventsSelected( true ); |
4630 | } else { | 4636 | } else { |
4631 | emit organizerEventsSelected(false); | 4637 | emit organizerEventsSelected(false); |
4632 | } | 4638 | } |
4633 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4639 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4634 | KOPrefs::instance()->email() ) ) { | 4640 | KOPrefs::instance()->email() ) ) { |
4635 | emit groupEventsSelected( true ); | 4641 | emit groupEventsSelected( true ); |
4636 | } else { | 4642 | } else { |
4637 | emit groupEventsSelected(false); | 4643 | emit groupEventsSelected(false); |
4638 | } | 4644 | } |
4639 | return; | 4645 | return; |
4640 | } else { | 4646 | } else { |
4641 | if ( incidence && incidence->typeID() == todoID ) { | 4647 | if ( incidence && incidence->typeID() == todoID ) { |
4642 | emit todoSelected( true ); | 4648 | emit todoSelected( true ); |
4643 | Todo *event = static_cast<Todo *>( incidence ); | 4649 | Todo *event = static_cast<Todo *>( incidence ); |
4644 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4650 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4645 | emit organizerEventsSelected( true ); | 4651 | emit organizerEventsSelected( true ); |
4646 | } else { | 4652 | } else { |
4647 | emit organizerEventsSelected(false); | 4653 | emit organizerEventsSelected(false); |
4648 | } | 4654 | } |
4649 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4655 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4650 | KOPrefs::instance()->email() ) ) { | 4656 | KOPrefs::instance()->email() ) ) { |
4651 | emit groupEventsSelected( true ); | 4657 | emit groupEventsSelected( true ); |
4652 | } else { | 4658 | } else { |
4653 | emit groupEventsSelected(false); | 4659 | emit groupEventsSelected(false); |
4654 | } | 4660 | } |
4655 | return; | 4661 | return; |
4656 | } else { | 4662 | } else { |
4657 | emit todoSelected( false ); | 4663 | emit todoSelected( false ); |
4658 | emit organizerEventsSelected(false); | 4664 | emit organizerEventsSelected(false); |
4659 | emit groupEventsSelected(false); | 4665 | emit groupEventsSelected(false); |
4660 | } | 4666 | } |
4661 | return; | 4667 | return; |
4662 | } | 4668 | } |
4663 | 4669 | ||
4664 | /* if ( incidence && incidence->typeID() == todoID ) { | 4670 | /* if ( incidence && incidence->typeID() == todoID ) { |
4665 | emit todoSelected( true ); | 4671 | emit todoSelected( true ); |
4666 | } else { | 4672 | } else { |
4667 | emit todoSelected( false ); | 4673 | emit todoSelected( false ); |
4668 | }*/ | 4674 | }*/ |
4669 | } | 4675 | } |
4670 | 4676 | ||
4671 | 4677 | ||
4672 | void CalendarView::checkClipboard() | 4678 | void CalendarView::checkClipboard() |
4673 | { | 4679 | { |
4674 | #ifndef KORG_NODND | 4680 | #ifndef KORG_NODND |
4675 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4681 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4676 | emit pasteEnabled(true); | 4682 | emit pasteEnabled(true); |
4677 | } else { | 4683 | } else { |
4678 | emit pasteEnabled(false); | 4684 | emit pasteEnabled(false); |
4679 | } | 4685 | } |
4680 | #endif | 4686 | #endif |
4681 | } | 4687 | } |
4682 | 4688 | ||
4683 | void CalendarView::showDates(const DateList &selectedDates) | 4689 | void CalendarView::showDates(const DateList &selectedDates) |
4684 | { | 4690 | { |
4685 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4691 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4686 | 4692 | ||
4687 | 4693 | ||
4688 | if ( !mBlockShowDates ) { | 4694 | if ( !mBlockShowDates ) { |
4689 | if ( mViewManager->currentView() ) { | 4695 | if ( mViewManager->currentView() ) { |
4690 | updateView( selectedDates.first(), selectedDates.last() ); | 4696 | updateView( selectedDates.first(), selectedDates.last() ); |
4691 | } else { | 4697 | } else { |
4692 | mViewManager->showAgendaView(); | 4698 | mViewManager->showAgendaView(); |
4693 | } | 4699 | } |
4694 | } | 4700 | } |
4695 | 4701 | ||
4696 | QDate date = selectedDates.first(); | 4702 | QDate date = selectedDates.first(); |
4697 | if ( ! date.isValid() ) { | 4703 | if ( ! date.isValid() ) { |
4698 | topLevelWidget()->setCaption(""); | 4704 | topLevelWidget()->setCaption(""); |
4699 | return; | 4705 | return; |
4700 | } | 4706 | } |
4701 | 4707 | ||
4702 | QString selDates; | 4708 | QString selDates; |
4703 | selDates = KGlobal::locale()->formatDate( date, true); | 4709 | selDates = KGlobal::locale()->formatDate( date, true); |
4704 | if (selectedDates.first() < selectedDates.last() ) | 4710 | if (selectedDates.first() < selectedDates.last() ) |
4705 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4711 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4706 | else { | 4712 | else { |
4707 | QString addString; | 4713 | QString addString; |
4708 | if ( date == QDateTime::currentDateTime().date() ) | 4714 | if ( date == QDateTime::currentDateTime().date() ) |
4709 | addString = i18n("Today"); | 4715 | addString = i18n("Today"); |
4710 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4716 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4711 | addString = i18n("Tomorrow"); | 4717 | addString = i18n("Tomorrow"); |
4712 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4718 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4713 | addString = i18n("Yesterday"); | 4719 | addString = i18n("Yesterday"); |
4714 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4720 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4715 | addString = i18n("Day before yesterday"); | 4721 | addString = i18n("Day before yesterday"); |
4716 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4722 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4717 | addString = i18n("Day after tomorrow"); | 4723 | addString = i18n("Day after tomorrow"); |
4718 | if ( !addString.isEmpty() ) { | 4724 | if ( !addString.isEmpty() ) { |
4719 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4725 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4720 | return; | 4726 | return; |
4721 | } | 4727 | } |
4722 | } | 4728 | } |
4723 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4729 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4724 | 4730 | ||
4725 | } | 4731 | } |
4726 | 4732 | ||
4727 | QPtrList<CalFilter> CalendarView::filters() | 4733 | Q3PtrList<CalFilter> CalendarView::filters() |
4728 | { | 4734 | { |
4729 | return mFilters; | 4735 | return mFilters; |
4730 | 4736 | ||
4731 | } | 4737 | } |
4732 | void CalendarView::editFilters() | 4738 | void CalendarView::editFilters() |
4733 | { | 4739 | { |
4734 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4740 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4735 | 4741 | ||
4736 | CalFilter *filter = mFilters.first(); | 4742 | CalFilter *filter = mFilters.first(); |
4737 | while(filter) { | 4743 | while(filter) { |
4738 | filter = mFilters.next(); | 4744 | filter = mFilters.next(); |
4739 | } | 4745 | } |
4740 | 4746 | ||
4741 | mDialogManager->showFilterEditDialog(&mFilters); | 4747 | mDialogManager->showFilterEditDialog(&mFilters); |
4742 | updateFilter(); | 4748 | updateFilter(); |
4743 | } | 4749 | } |
4744 | void CalendarView::toggleFilter() | 4750 | void CalendarView::toggleFilter() |
4745 | { | 4751 | { |
4746 | if ( mLeftFrame->isHidden() ) { | 4752 | if ( mLeftFrame->isHidden() ) { |
4747 | toggleExpand(); | 4753 | toggleExpand(); |
4748 | showFilter( true ); | 4754 | showFilter( true ); |
4749 | } else | 4755 | } else |
4750 | showFilter(! mCalEditView->isVisible()); | 4756 | showFilter(! mCalEditView->isVisible()); |
4751 | } | 4757 | } |
4752 | 4758 | ||
4753 | KOFilterView *CalendarView::filterView() | 4759 | KOFilterView *CalendarView::filterView() |
4754 | { | 4760 | { |
4755 | return mFilterView; | 4761 | return mFilterView; |
4756 | } | 4762 | } |
4757 | void CalendarView::selectFilter( int fil ) | 4763 | void CalendarView::selectFilter( int fil ) |
4758 | { | 4764 | { |
4759 | mFilterView->setSelectedFilter( fil ); | 4765 | mFilterView->setSelectedFilter( fil ); |
4760 | updateUnmanagedViews(); | 4766 | updateUnmanagedViews(); |
4761 | } | 4767 | } |
4762 | void CalendarView::showFilter(bool visible) | 4768 | void CalendarView::showFilter(bool visible) |
4763 | { | 4769 | { |
4764 | #if 1 | 4770 | #if 1 |
4765 | if (visible) { | 4771 | if (visible) { |
4766 | mCalEditView->readConfig(); | 4772 | mCalEditView->readConfig(); |
4767 | mCalEditView->show(); | 4773 | mCalEditView->show(); |
4768 | QValueList<int> sizes; | 4774 | Q3ValueList<int> sizes; |
4769 | sizes = mLeftFrame->sizes(); | 4775 | sizes = mLeftFrame->sizes(); |
4770 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4776 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4771 | sizes.clear(); | 4777 | sizes.clear(); |
4772 | sizes << 100; | 4778 | sizes << 100; |
4773 | sizes << 0; | 4779 | sizes << 0; |
4774 | sizes << 0; | 4780 | sizes << 0; |
4775 | sizes << 100; | 4781 | sizes << 100; |
4776 | mLeftFrame->setSizes(sizes); | 4782 | mLeftFrame->setSizes(sizes); |
4777 | } | 4783 | } |
4778 | #if 0 | 4784 | #if 0 |
4779 | sizes = mLeftFrame->sizes(); | 4785 | sizes = mLeftFrame->sizes(); |
4780 | int ccc = 0; | 4786 | int ccc = 0; |
4781 | while ( ccc < sizes.count()) { | 4787 | while ( ccc < sizes.count()) { |
4782 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4788 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4783 | ++ccc; | 4789 | ++ccc; |
4784 | } | 4790 | } |
4785 | #endif | 4791 | #endif |
4786 | 4792 | ||
4787 | } | 4793 | } |
4788 | else { | 4794 | else { |
4789 | mCalEditView->hide(); | 4795 | mCalEditView->hide(); |
4790 | } | 4796 | } |
4791 | #else | 4797 | #else |
4792 | if (visible) mFilterView->show(); | 4798 | if (visible) mFilterView->show(); |
4793 | else mFilterView->hide(); | 4799 | else mFilterView->hide(); |
4794 | #endif | 4800 | #endif |
4795 | } | 4801 | } |
4796 | void CalendarView::toggleFilerEnabled( ) | 4802 | void CalendarView::toggleFilerEnabled( ) |
4797 | { | 4803 | { |
4798 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4804 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4799 | if ( !mFilterView->filtersEnabled() ) | 4805 | if ( !mFilterView->filtersEnabled() ) |
4800 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4806 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4801 | updateUnmanagedViews(); | 4807 | updateUnmanagedViews(); |
4802 | 4808 | ||
4803 | } | 4809 | } |
4804 | void CalendarView::updateFilter() | 4810 | void CalendarView::updateFilter() |
4805 | { | 4811 | { |
4806 | CalFilter *filter = mFilterView->selectedFilter(); | 4812 | CalFilter *filter = mFilterView->selectedFilter(); |
4807 | if (filter) { | 4813 | if (filter) { |
4808 | QString mess; | 4814 | QString mess; |
4809 | if (mFilterView->filtersEnabled()) { | 4815 | if (mFilterView->filtersEnabled()) { |
4810 | mess = i18n("Filter selected: ")+filter->name(); | 4816 | mess = i18n("Filter selected: ")+filter->name(); |
4811 | filter->setEnabled(true); | 4817 | filter->setEnabled(true); |
4812 | } | 4818 | } |
4813 | else filter->setEnabled(false); | 4819 | else filter->setEnabled(false); |
4814 | mCalendar->setFilter(filter); | 4820 | mCalendar->setFilter(filter); |
4815 | updateView(); | 4821 | updateView(); |
4816 | if ( !mess.isEmpty() ) | 4822 | if ( !mess.isEmpty() ) |
4817 | topLevelWidget()->setCaption( mess ); | 4823 | topLevelWidget()->setCaption( mess ); |
4818 | 4824 | ||
4819 | } | 4825 | } |
4820 | emit filtersUpdated(); | 4826 | emit filtersUpdated(); |
4821 | } | 4827 | } |
4822 | 4828 | ||
4823 | void CalendarView::filterEdited() | 4829 | void CalendarView::filterEdited() |
4824 | { | 4830 | { |
4825 | mFilterView->updateFilters(); | 4831 | mFilterView->updateFilters(); |
4826 | updateFilter(); | 4832 | updateFilter(); |
4827 | writeSettings(); | 4833 | writeSettings(); |
4828 | } | 4834 | } |
4829 | 4835 | ||
4830 | 4836 | ||
4831 | void CalendarView::takeOverEvent() | 4837 | void CalendarView::takeOverEvent() |
4832 | { | 4838 | { |
4833 | Incidence *incidence = currentSelection(); | 4839 | Incidence *incidence = currentSelection(); |
4834 | 4840 | ||
4835 | if (!incidence) return; | 4841 | if (!incidence) return; |
4836 | 4842 | ||
4837 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4843 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4838 | incidence->recreate(); | 4844 | incidence->recreate(); |
4839 | incidence->setReadOnly(false); | 4845 | incidence->setReadOnly(false); |
4840 | 4846 | ||
4841 | updateView(); | 4847 | updateView(); |
4842 | } | 4848 | } |
4843 | 4849 | ||
4844 | void CalendarView::takeOverCalendar() | 4850 | void CalendarView::takeOverCalendar() |
4845 | { | 4851 | { |
4846 | // TODO: Create Calendar::allIncidences() function and use it here | 4852 | // TODO: Create Calendar::allIncidences() function and use it here |
4847 | 4853 | ||
4848 | clearAllViews(); | 4854 | clearAllViews(); |
4849 | QPtrList<Event> events = mCalendar->events(); | 4855 | Q3PtrList<Event> events = mCalendar->events(); |
4850 | for(uint i=0; i<events.count(); ++i) { | 4856 | for(uint i=0; i<events.count(); ++i) { |
4851 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4857 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4852 | events.at(i)->recreate(); | 4858 | events.at(i)->recreate(); |
4853 | events.at(i)->setReadOnly(false); | 4859 | events.at(i)->setReadOnly(false); |
4854 | } | 4860 | } |
4855 | 4861 | ||
4856 | QPtrList<Todo> todos = mCalendar->todos(); | 4862 | Q3PtrList<Todo> todos = mCalendar->todos(); |
4857 | for(uint i=0; i<todos.count(); ++i) { | 4863 | for(uint i=0; i<todos.count(); ++i) { |
4858 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4864 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4859 | todos.at(i)->recreate(); | 4865 | todos.at(i)->recreate(); |
4860 | todos.at(i)->setReadOnly(false); | 4866 | todos.at(i)->setReadOnly(false); |
4861 | } | 4867 | } |
4862 | 4868 | ||
4863 | QPtrList<Journal> journals = mCalendar->journals(); | 4869 | Q3PtrList<Journal> journals = mCalendar->journals(); |
4864 | for(uint i=0; i<journals.count(); ++i) { | 4870 | for(uint i=0; i<journals.count(); ++i) { |
4865 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4871 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4866 | journals.at(i)->recreate(); | 4872 | journals.at(i)->recreate(); |
4867 | journals.at(i)->setReadOnly(false); | 4873 | journals.at(i)->setReadOnly(false); |
4868 | } | 4874 | } |
4869 | 4875 | ||
4870 | updateView(); | 4876 | updateView(); |
4871 | } | 4877 | } |
4872 | 4878 | ||
4873 | void CalendarView::showIntro() | 4879 | void CalendarView::showIntro() |
4874 | { | 4880 | { |
4875 | kdDebug() << "To be implemented." << endl; | 4881 | kdDebug() << "To be implemented." << endl; |
4876 | } | 4882 | } |
4877 | 4883 | ||
4878 | QWidgetStack *CalendarView::viewStack() | 4884 | Q3WidgetStack *CalendarView::viewStack() |
4879 | { | 4885 | { |
4880 | return mRightFrame; | 4886 | return mRightFrame; |
4881 | } | 4887 | } |
4882 | 4888 | ||
4883 | QWidget *CalendarView::leftFrame() | 4889 | QWidget *CalendarView::leftFrame() |
4884 | { | 4890 | { |
4885 | return ( QWidget *)mLeftFrame; | 4891 | return ( QWidget *)mLeftFrame; |
4886 | } | 4892 | } |
4887 | 4893 | ||
4888 | DateNavigator *CalendarView::dateNavigator() | 4894 | DateNavigator *CalendarView::dateNavigator() |
4889 | { | 4895 | { |
4890 | return mNavigator; | 4896 | return mNavigator; |
4891 | } | 4897 | } |
4892 | 4898 | ||
4893 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4899 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4894 | { | 4900 | { |
4895 | return mDateNavigator->navigatorView(); | 4901 | return mDateNavigator->navigatorView(); |
4896 | } | 4902 | } |
4897 | void CalendarView::toggleDateNavigatorWidget() | 4903 | void CalendarView::toggleDateNavigatorWidget() |
4898 | { | 4904 | { |
4899 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4905 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4900 | 4906 | ||
4901 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4907 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4902 | mDateNavigator->hide(); | 4908 | mDateNavigator->hide(); |
4903 | else | 4909 | else |
4904 | mDateNavigator->show(); | 4910 | mDateNavigator->show(); |
4905 | } | 4911 | } |
4906 | void CalendarView::addView(KOrg::BaseView *view) | 4912 | void CalendarView::addView(KOrg::BaseView *view) |
4907 | { | 4913 | { |
4908 | mViewManager->addView(view); | 4914 | mViewManager->addView(view); |
4909 | } | 4915 | } |
4910 | 4916 | ||
4911 | void CalendarView::showView(KOrg::BaseView *view) | 4917 | void CalendarView::showView(KOrg::BaseView *view) |
4912 | { | 4918 | { |
4913 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4919 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4914 | } | 4920 | } |
4915 | 4921 | ||
4916 | Incidence *CalendarView::currentSelection() | 4922 | Incidence *CalendarView::currentSelection() |
4917 | { | 4923 | { |
4918 | return mViewManager->currentSelection(); | 4924 | return mViewManager->currentSelection(); |
4919 | } | 4925 | } |
4920 | void CalendarView::toggleAllDaySize() | 4926 | void CalendarView::toggleAllDaySize() |
4921 | { | 4927 | { |
4922 | /* | 4928 | /* |
4923 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4929 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4924 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4930 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4925 | else | 4931 | else |
4926 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4932 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4927 | */ | 4933 | */ |
4928 | viewManager()->agendaView()->toggleAllDay(); | 4934 | viewManager()->agendaView()->toggleAllDay(); |
4929 | } | 4935 | } |
4930 | void CalendarView::toggleExpand() | 4936 | void CalendarView::toggleExpand() |
4931 | { | 4937 | { |
4932 | // if ( mLeftFrame->isHidden() ) { | 4938 | // if ( mLeftFrame->isHidden() ) { |
4933 | // mLeftFrame->show(); | 4939 | // mLeftFrame->show(); |
4934 | // emit calendarViewExpanded( false ); | 4940 | // emit calendarViewExpanded( false ); |
4935 | // } else { | 4941 | // } else { |
4936 | // mLeftFrame->hide(); | 4942 | // mLeftFrame->hide(); |
4937 | // emit calendarViewExpanded( true ); | 4943 | // emit calendarViewExpanded( true ); |
4938 | // } | 4944 | // } |
4939 | //qDebug(" CalendarView::toggleExpand()"); | 4945 | //qDebug(" CalendarView::toggleExpand()"); |
4940 | globalFlagBlockAgenda = 1; | 4946 | globalFlagBlockAgenda = 1; |
4941 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4947 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4942 | globalFlagBlockAgenda = 5; | 4948 | globalFlagBlockAgenda = 5; |
4943 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4949 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4944 | //mViewManager->showView( 0, true ); | 4950 | //mViewManager->showView( 0, true ); |
4945 | } | 4951 | } |
4946 | 4952 | ||
4947 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4953 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4948 | { | 4954 | { |
4949 | setModified( modified ); | 4955 | setModified( modified ); |
4950 | } | 4956 | } |
4951 | 4957 | ||
4952 | Todo *CalendarView::selectedTodo() | 4958 | Todo *CalendarView::selectedTodo() |
4953 | { | 4959 | { |
4954 | Incidence *incidence = currentSelection(); | 4960 | Incidence *incidence = currentSelection(); |
4955 | if ( incidence && incidence->typeID() == todoID ) { | 4961 | if ( incidence && incidence->typeID() == todoID ) { |
4956 | return static_cast<Todo *>( incidence ); | 4962 | return static_cast<Todo *>( incidence ); |
4957 | } | 4963 | } |
4958 | 4964 | ||
4959 | incidence = mTodoList->selectedIncidences().first(); | 4965 | incidence = mTodoList->selectedIncidences().first(); |
4960 | if ( incidence && incidence->typeID() == todoID ) { | 4966 | if ( incidence && incidence->typeID() == todoID ) { |
4961 | return static_cast<Todo *>( incidence ); | 4967 | return static_cast<Todo *>( incidence ); |
4962 | } | 4968 | } |
4963 | 4969 | ||
4964 | return 0; | 4970 | return 0; |
4965 | } | 4971 | } |
4966 | 4972 | ||
4967 | void CalendarView::showIncidence() | 4973 | void CalendarView::showIncidence() |
4968 | { | 4974 | { |
4969 | mViewerCallerIsSearchDialog = false; | 4975 | mViewerCallerIsSearchDialog = false; |
4970 | Incidence *incidence = currentSelection(); | 4976 | Incidence *incidence = currentSelection(); |
4971 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4977 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4972 | if ( incidence ) { | 4978 | if ( incidence ) { |
4973 | ShowIncidenceVisitor v; | 4979 | ShowIncidenceVisitor v; |
4974 | v.act( incidence, this ); | 4980 | v.act( incidence, this ); |
4975 | } | 4981 | } |
4976 | } | 4982 | } |
4977 | void CalendarView::editIncidenceDescription() | 4983 | void CalendarView::editIncidenceDescription() |
4978 | { | 4984 | { |
4979 | mFlagEditDescription = true; | 4985 | mFlagEditDescription = true; |
4980 | editIncidence(); | 4986 | editIncidence(); |
4981 | mFlagEditDescription = false; | 4987 | mFlagEditDescription = false; |
4982 | } | 4988 | } |
4983 | void CalendarView::editIncidence() | 4989 | void CalendarView::editIncidence() |
4984 | { | 4990 | { |
4985 | // qDebug("editIncidence() "); | 4991 | // qDebug("editIncidence() "); |
4986 | Incidence *incidence = currentSelection(); | 4992 | Incidence *incidence = currentSelection(); |
4987 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4993 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4988 | if ( incidence ) { | 4994 | if ( incidence ) { |
4989 | EditIncidenceVisitor v; | 4995 | EditIncidenceVisitor v; |
4990 | v.act( incidence, this ); | 4996 | v.act( incidence, this ); |
4991 | } | 4997 | } |
4992 | } | 4998 | } |
4993 | 4999 | ||
4994 | void CalendarView::deleteIncidence() | 5000 | void CalendarView::deleteIncidence() |
4995 | { | 5001 | { |
4996 | Incidence *incidence = currentSelection(); | 5002 | Incidence *incidence = currentSelection(); |
4997 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 5003 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4998 | if ( incidence ) { | 5004 | if ( incidence ) { |
4999 | deleteIncidence(incidence); | 5005 | deleteIncidence(incidence); |
5000 | } | 5006 | } |
5001 | } | 5007 | } |
5002 | void CalendarView::showIncidence(QString uid) | 5008 | void CalendarView::showIncidence(QString uid) |
5003 | { | 5009 | { |
5004 | Incidence *inc = mCalendar->incidence( uid ); | 5010 | Incidence *inc = mCalendar->incidence( uid ); |
5005 | if ( inc ) | 5011 | if ( inc ) |
5006 | showIncidence( inc ); | 5012 | showIncidence( inc ); |
5007 | } | 5013 | } |
5008 | void CalendarView::showIncidence(Incidence *incidence) | 5014 | void CalendarView::showIncidence(Incidence *incidence) |
5009 | { | 5015 | { |
5010 | mViewerCallerIsSearchDialog = false; | 5016 | mViewerCallerIsSearchDialog = false; |
5011 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 5017 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
5012 | if ( sender() && mDialogManager->getSearchDialog() ) { | 5018 | if ( sender() && mDialogManager->getSearchDialog() ) { |
5013 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 5019 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
5014 | mViewerCallerIsSearchDialog = true; | 5020 | mViewerCallerIsSearchDialog = true; |
5015 | } | 5021 | } |
5016 | } | 5022 | } |
5017 | if ( incidence ) { | 5023 | if ( incidence ) { |
5018 | ShowIncidenceVisitor v; | 5024 | ShowIncidenceVisitor v; |
5019 | v.act( incidence, this ); | 5025 | v.act( incidence, this ); |
5020 | } | 5026 | } |
5021 | } | 5027 | } |
5022 | 5028 | ||
5023 | void CalendarView::editIncidence(Incidence *incidence) | 5029 | void CalendarView::editIncidence(Incidence *incidence) |
5024 | { | 5030 | { |
5025 | if ( incidence ) { | 5031 | if ( incidence ) { |
5026 | 5032 | ||
5027 | EditIncidenceVisitor v; | 5033 | EditIncidenceVisitor v; |
5028 | v.act( incidence, this ); | 5034 | v.act( incidence, this ); |
5029 | 5035 | ||
5030 | } | 5036 | } |
5031 | } | 5037 | } |
5032 | 5038 | ||
5033 | void CalendarView::deleteIncidence(Incidence *incidence) | 5039 | void CalendarView::deleteIncidence(Incidence *incidence) |
5034 | { | 5040 | { |
5035 | //qDebug(" CalendarView::deleteIncidence "); | 5041 | //qDebug(" CalendarView::deleteIncidence "); |
5036 | if ( incidence == 0 ) { | 5042 | if ( incidence == 0 ) { |
5037 | updateView(); | 5043 | updateView(); |
5038 | emit updateSearchDialog(); | 5044 | emit updateSearchDialog(); |
5039 | return; | 5045 | return; |
5040 | } | 5046 | } |
5041 | if ( incidence ) { | 5047 | if ( incidence ) { |
5042 | DeleteIncidenceVisitor v; | 5048 | DeleteIncidenceVisitor v; |
5043 | v.act( incidence, this ); | 5049 | v.act( incidence, this ); |
5044 | } | 5050 | } |
5045 | } | 5051 | } |
5046 | 5052 | ||
5047 | 5053 | ||
5048 | void CalendarView::lookForOutgoingMessages() | 5054 | void CalendarView::lookForOutgoingMessages() |
5049 | { | 5055 | { |
5050 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 5056 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
5051 | ogd->loadMessages(); | 5057 | ogd->loadMessages(); |
5052 | } | 5058 | } |
5053 | 5059 | ||
5054 | void CalendarView::lookForIncomingMessages() | 5060 | void CalendarView::lookForIncomingMessages() |
5055 | { | 5061 | { |
5056 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 5062 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
5057 | icd->retrieve(); | 5063 | icd->retrieve(); |
5058 | } | 5064 | } |
5059 | 5065 | ||
5060 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 5066 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
5061 | { | 5067 | { |
5062 | bool deleteTodo = true; | 5068 | bool deleteTodo = true; |
5063 | QPtrList<Incidence> subTodos; | 5069 | Q3PtrList<Incidence> subTodos; |
5064 | Incidence *aTodo; | 5070 | Incidence *aTodo; |
5065 | subTodos = t->relations(); | 5071 | subTodos = t->relations(); |
5066 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 5072 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
5067 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 5073 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
5068 | deleteTodo = false; | 5074 | deleteTodo = false; |
5069 | } | 5075 | } |
5070 | if ( deleteTodo ) { | 5076 | if ( deleteTodo ) { |
5071 | if ( t->isCompleted() && !t->doesRecur()) { | 5077 | if ( t->isCompleted() && !t->doesRecur()) { |
5072 | checkExternalId( t ); | 5078 | checkExternalId( t ); |
5073 | mCalendar->deleteTodo( t ); | 5079 | mCalendar->deleteTodo( t ); |
5074 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 5080 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
5075 | } | 5081 | } |
5076 | else | 5082 | else |
5077 | deleteTodo = false; | 5083 | deleteTodo = false; |
5078 | } | 5084 | } |
5079 | return deleteTodo; | 5085 | return deleteTodo; |
5080 | 5086 | ||
5081 | } | 5087 | } |
5082 | void CalendarView::purgeCompleted() | 5088 | void CalendarView::purgeCompleted() |
5083 | { | 5089 | { |
5084 | int result = KMessageBox::warningContinueCancel(this, | 5090 | int result = KMessageBox::warningContinueCancel(this, |
5085 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 5091 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
5086 | 5092 | ||
5087 | if (result == KMessageBox::Continue) { | 5093 | if (result == KMessageBox::Continue) { |
5088 | 5094 | ||
5089 | QPtrList<Todo> todoCal; | 5095 | Q3PtrList<Todo> todoCal; |
5090 | QPtrList<Todo> rootTodos; | 5096 | Q3PtrList<Todo> rootTodos; |
5091 | //QPtrList<Incidence> rel; | 5097 | //QPtrList<Incidence> rel; |
5092 | Todo *aTodo; | 5098 | Todo *aTodo; |
5093 | todoCal = calendar()->todos(); | 5099 | todoCal = calendar()->todos(); |
5094 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 5100 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
5095 | if ( !aTodo->relatedTo() ) | 5101 | if ( !aTodo->relatedTo() ) |
5096 | rootTodos.append( aTodo ); | 5102 | rootTodos.append( aTodo ); |
5097 | } | 5103 | } |
5098 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 5104 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
5099 | removeCompletedSubTodos( aTodo ); | 5105 | removeCompletedSubTodos( aTodo ); |
5100 | } | 5106 | } |
5101 | 5107 | ||
5102 | updateView(); | 5108 | updateView(); |
5103 | } | 5109 | } |
5104 | } | 5110 | } |
5105 | 5111 | ||
5106 | void CalendarView::slotCalendarChanged() | 5112 | void CalendarView::slotCalendarChanged() |
5107 | { | 5113 | { |
5108 | ; | 5114 | ; |
5109 | } | 5115 | } |
5110 | 5116 | ||
5111 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 5117 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
5112 | { | 5118 | { |
5113 | //qDebug("CalendarView::keyPressEvent "); | 5119 | //qDebug("CalendarView::keyPressEvent "); |
5114 | e->ignore(); | 5120 | e->ignore(); |
5115 | } | 5121 | } |
5116 | 5122 | ||
5117 | void CalendarView::multiResourceSyncStart( bool start ) | 5123 | void CalendarView::multiResourceSyncStart( bool start ) |
5118 | { | 5124 | { |
5119 | mMultiResourceSync = start; | 5125 | mMultiResourceSync = start; |
5120 | 5126 | ||
5121 | } | 5127 | } |
5122 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) | 5128 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
5123 | { | 5129 | { |
5124 | 5130 | ||
5125 | if ( manager != mSyncManager) | 5131 | if ( manager != mSyncManager) |
5126 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 5132 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
5127 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 5133 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
5128 | qDebug("KO: SyncKDE request detected!"); | 5134 | qDebug("KO: SyncKDE request detected!"); |
5129 | } | 5135 | } |
5130 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5136 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5131 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5137 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5132 | if ( !resource.isEmpty() ) { | 5138 | if ( !resource.isEmpty() ) { |
5133 | int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | 5139 | int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); |
5134 | qDebug( "KO: Sync request for resource: %s", resource.latin1() ); | 5140 | qDebug( "KO: Sync request for resource: %s", resource.latin1() ); |
5135 | 5141 | ||
5136 | if ( !exclusiveSyncResource ) { | 5142 | if ( !exclusiveSyncResource ) { |
5137 | qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); | 5143 | qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); |
5138 | return false; | 5144 | return false; |
5139 | } | 5145 | } |
5140 | mCalendar->setDefaultCalendar( exclusiveSyncResource ); | 5146 | mCalendar->setDefaultCalendar( exclusiveSyncResource ); |
5141 | mCalendar->setDefaultCalendarEnabledOnly(); | 5147 | mCalendar->setDefaultCalendarEnabledOnly(); |
5142 | } | 5148 | } |
5143 | bool result = syncCalendar( filename, mode ); | 5149 | bool result = syncCalendar( filename, mode ); |
5144 | if ( !resource.isEmpty() ) | 5150 | if ( !resource.isEmpty() ) |
5145 | restoreCalendarSettings(); | 5151 | restoreCalendarSettings(); |
5146 | return result; | 5152 | return result; |
5147 | } | 5153 | } |
5148 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 5154 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
5149 | { | 5155 | { |
5150 | //mSyncManager = manager; | 5156 | //mSyncManager = manager; |
5151 | if ( manager != mSyncManager) | 5157 | if ( manager != mSyncManager) |
5152 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 5158 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
5153 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5159 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5154 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5160 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5155 | if ( resource == "sharp" ) | 5161 | if ( resource == "sharp" ) |
5156 | syncExternal( 0 ); | 5162 | syncExternal( 0 ); |
5157 | if ( resource == "phone" ) | 5163 | if ( resource == "phone" ) |
5158 | syncExternal( 1 ); | 5164 | syncExternal( 1 ); |
5159 | // pending setmodified | 5165 | // pending setmodified |
5160 | return true; | 5166 | return true; |
5161 | } | 5167 | } |
5162 | void CalendarView::setSyncManager(KSyncManager* manager) | 5168 | void CalendarView::setSyncManager(KSyncManager* manager) |
5163 | { | 5169 | { |
5164 | mSyncManager = manager; | 5170 | mSyncManager = manager; |
5165 | } | 5171 | } |
5166 | 5172 | ||
5167 | void CalendarView::removeSyncInfo( QString syncProfile) | 5173 | void CalendarView::removeSyncInfo( QString syncProfile) |
5168 | { | 5174 | { |
5169 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 5175 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
5170 | mCalendar->removeSyncInfo( syncProfile ); | 5176 | mCalendar->removeSyncInfo( syncProfile ); |
5171 | 5177 | ||
5172 | } | 5178 | } |
5173 | 5179 | ||
5174 | void CalendarView::undo_delete() | 5180 | void CalendarView::undo_delete() |
5175 | { | 5181 | { |
5176 | //qDebug("undo_delete() "); | 5182 | //qDebug("undo_delete() "); |
5177 | Incidence* undo = mCalendar->undoIncidence(); | 5183 | Incidence* undo = mCalendar->undoIncidence(); |
5178 | if ( !undo ) { | 5184 | if ( !undo ) { |
5179 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 5185 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
5180 | i18n("KO/Pi")); | 5186 | i18n("KO/Pi")); |
5181 | return; | 5187 | return; |
5182 | } | 5188 | } |
5183 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 5189 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
5184 | i18n("\nAre you sure you want\nto restore this?"), | 5190 | i18n("\nAre you sure you want\nto restore this?"), |
5185 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 5191 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
5186 | mCalendar->undoDeleteIncidence(); | 5192 | mCalendar->undoDeleteIncidence(); |
5187 | updateView(); | 5193 | updateView(); |
5188 | } | 5194 | } |
5189 | } | 5195 | } |
5190 | 5196 | ||
5191 | void CalendarView::slotViewerClosed() | 5197 | void CalendarView::slotViewerClosed() |
5192 | { | 5198 | { |
5193 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 5199 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
5194 | } | 5200 | } |
5195 | 5201 | ||
5196 | void CalendarView::resetFocus() | 5202 | void CalendarView::resetFocus() |
5197 | { | 5203 | { |
5198 | if ( mViewerCallerIsSearchDialog ) { | 5204 | if ( mViewerCallerIsSearchDialog ) { |
5199 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 5205 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
5200 | mDialogManager->getSearchDialog()->raise(); | 5206 | mDialogManager->getSearchDialog()->raise(); |
5201 | mDialogManager->getSearchDialog()->setActiveWindow(); | 5207 | mDialogManager->getSearchDialog()->setActiveWindow(); |
5202 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 5208 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
5203 | } else | 5209 | } else |
5204 | mViewerCallerIsSearchDialog = false; | 5210 | mViewerCallerIsSearchDialog = false; |
5205 | } | 5211 | } |
5206 | if ( !mViewerCallerIsSearchDialog ) { | 5212 | if ( !mViewerCallerIsSearchDialog ) { |
5207 | //mViewManager->currentView()->setFocus(); | 5213 | //mViewManager->currentView()->setFocus(); |
5208 | //qDebug("sssssssssssssssset focus "); | 5214 | //qDebug("sssssssssssssssset focus "); |
5209 | topLevelWidget()->raise(); | 5215 | topLevelWidget()->raise(); |
5210 | setActiveWindow(); | 5216 | setActiveWindow(); |
5211 | //setFocus(); | 5217 | //setFocus(); |
5212 | } | 5218 | } |
5213 | mViewerCallerIsSearchDialog = false; | 5219 | mViewerCallerIsSearchDialog = false; |
5214 | } | 5220 | } |
5215 | 5221 | ||
5216 | void CalendarView::showNextAlarms() | 5222 | void CalendarView::showNextAlarms() |
5217 | { | 5223 | { |
5218 | QString message; | 5224 | QString message; |