author | zautrix <zautrix> | 2005-06-04 10:29:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-04 10:29:18 (UTC) |
commit | a7939017000e165e711e3f0cffeab46852a9fb2e (patch) (unidiff) | |
tree | 6b1c0d44051039e47f7b7f6cf55e25af9a6e7024 /korganizer | |
parent | d40cf5135c640506011334364274b8ee5df9998b (diff) | |
download | kdepimpi-a7939017000e165e711e3f0cffeab46852a9fb2e.zip kdepimpi-a7939017000e165e711e3f0cffeab46852a9fb2e.tar.gz kdepimpi-a7939017000e165e711e3f0cffeab46852a9fb2e.tar.bz2 |
fixes
-rw-r--r-- | korganizer/calendarview.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 42166ab..608b73b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3740 +1,3754 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
142 | 142 | ||
143 | { | 143 | { |
144 | mAlarms = alarms; | 144 | mAlarms = alarms; |
145 | setBackgroundColor( QColor( 86, 153, 205 ) ); | 145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
146 | QString mText = "<table width=\"100%\">\n"; | 146 | QString mText = "<table width=\"100%\">\n"; |
147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
148 | #ifdef DESKTOP_VERSION | 148 | #ifdef DESKTOP_VERSION |
149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
150 | #else | 150 | #else |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
152 | #endif | 152 | #endif |
153 | // mText += "<img src=\""; | 153 | // mText += "<img src=\""; |
154 | // mText += ipath; | 154 | // mText += ipath; |
155 | // mText += "\">"; | 155 | // mText += "\">"; |
156 | //mEventDate = QDate::currentDate(); | 156 | //mEventDate = QDate::currentDate(); |
157 | #ifdef DESKTOP_VERSION | 157 | #ifdef DESKTOP_VERSION |
158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
159 | #else | 159 | #else |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
161 | #endif | 161 | #endif |
162 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
163 | 163 | ||
164 | Incidence * inc = getNextInc( start ); | 164 | Incidence * inc = getNextInc( start ); |
165 | int time = 0; | 165 | int time = 0; |
166 | mText += "<table>"; | 166 | //mText += "<table>"; |
167 | while ( inc ) { | 167 | while ( inc ) { |
168 | QDateTime dt ; | 168 | QDateTime dt ; |
169 | QString tempText = "<a "; | 169 | QString tempText = "<a "; |
170 | bool ok; | 170 | bool ok; |
171 | dt = inc->getNextOccurence( start, &ok ); | 171 | dt = inc->getNextOccurence( start, &ok ); |
172 | if ( !ok ) continue; | 172 | if ( !ok ) continue; |
173 | if ( inc->type() == "Event" ) { | 173 | if ( inc->type() == "Event" ) { |
174 | tempText += "href=\"event:"; | 174 | tempText += "href=\"event:"; |
175 | } else if ( inc->type() == "Todo" ) { | 175 | } else if ( inc->type() == "Todo" ) { |
176 | tempText += "href=\"todo:"; | 176 | tempText += "href=\"todo:"; |
177 | } | 177 | } |
178 | tempText += inc->uid() + "\">"; | 178 | tempText += inc->uid() + "\">"; |
179 | if ( inc->type() == "Todo" ) | 179 | if ( inc->type() == "Todo" ) |
180 | tempText += i18n("Todo: "); | 180 | tempText += i18n("Todo: "); |
181 | if ( inc->summary().length() > 0 ) | 181 | if ( inc->summary().length() > 0 ) |
182 | tempText += inc->summary(); | 182 | tempText += inc->summary(); |
183 | else | 183 | else |
184 | tempText += i18n("-no summary-"); | 184 | tempText += i18n("-no summary-"); |
185 | QString timestr; | 185 | QString timestr; |
186 | if (!inc->doesFloat()) | 186 | if (!inc->doesFloat()) |
187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
188 | else | 188 | else |
189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | if ( dt.date() == QDate::currentDate() && time == 0 ) { | 190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | ||
192 | mText += "<table>"; | ||
191 | time = 1; | 193 | time = 1; |
192 | mText +="</table>"; | 194 | } |
195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | ||
196 | if ( time > 0 ) | ||
197 | mText +="</table>"; | ||
193 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
194 | mText += "<table>"; | 199 | mText += "<table>"; |
200 | time = 2; | ||
195 | 201 | ||
196 | } | 202 | } |
197 | if ( dt.date() > QDate::currentDate() && time != 2 ) { | 203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
198 | time = 2; | 204 | if ( time > 0 ) |
199 | mText +="</table>"; | 205 | mText +="</table>"; |
200 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
201 | mText += "<table>"; | 207 | mText += "<table>"; |
208 | time = 3; | ||
202 | } | 209 | } |
203 | mText +="<tr><td><b>"; | 210 | mText +="<tr><td><b>"; |
204 | mText += timestr; | 211 | mText += timestr; |
205 | mText += "</b></td><td>"; | 212 | mText += "</b></td><td>"; |
206 | mText += tempText; | 213 | mText += tempText; |
207 | mText += "</td></tr>\n"; | 214 | mText += "</td></tr>\n"; |
208 | inc = getNextInc( start ); | 215 | inc = getNextInc( start ); |
209 | } | 216 | } |
210 | mText +="</table>"; | 217 | mText +="</table>"; |
211 | setText( mText ); | 218 | setText( mText ); |
212 | } | 219 | } |
213 | 220 | ||
214 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
215 | { | 222 | { |
216 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
217 | } | 224 | } |
218 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
219 | { | 226 | { |
220 | QDateTime dt ; | 227 | QDateTime dt ; |
221 | Incidence * retInc; | 228 | Incidence * retInc; |
222 | Incidence * inc = mAlarms.first(); | 229 | Incidence * inc = mAlarms.first(); |
223 | if ( inc == 0 ) | 230 | if ( inc == 0 ) |
224 | return 0; | 231 | return 0; |
225 | bool ok; | 232 | bool ok; |
226 | dt = inc->getNextOccurence( start, &ok ); | 233 | dt = inc->getNextOccurence( start, &ok ); |
227 | if ( ! ok ) return 0; | 234 | if ( ! ok ) return 0; |
228 | QDateTime dtn ; | 235 | QDateTime dtn ; |
229 | retInc = inc; | 236 | retInc = inc; |
230 | inc = mAlarms.next(); | 237 | inc = mAlarms.next(); |
231 | while ( inc ) { | 238 | while ( inc ) { |
232 | dtn = inc->getNextOccurence( start, &ok ); | 239 | dtn = inc->getNextOccurence( start, &ok ); |
233 | if ( ! ok ) return 0; | 240 | if ( ! ok ) return 0; |
234 | if ( dtn < dt ) { | 241 | if ( dtn < dt ) { |
235 | dt = dtn; | 242 | dt = dtn; |
236 | retInc = inc; | 243 | retInc = inc; |
237 | } | 244 | } |
238 | inc = mAlarms.next(); | 245 | inc = mAlarms.next(); |
239 | } | 246 | } |
240 | mAlarms.remove( retInc ); | 247 | mAlarms.remove( retInc ); |
241 | return retInc; | 248 | return retInc; |
242 | 249 | ||
243 | } | 250 | } |
244 | void MissedAlarmTextBrowser::setSource(const QString & n) | 251 | void MissedAlarmTextBrowser::setSource(const QString & n) |
245 | { | 252 | { |
246 | if (n.startsWith("event:")) { | 253 | if (n.startsWith("event:")) { |
247 | #ifdef DESKTOP_VERSION | 254 | #ifdef DESKTOP_VERSION |
248 | emit showIncidence(n.mid(8)); | 255 | emit showIncidence(n.mid(8)); |
249 | #else | 256 | #else |
250 | emit showIncidence(n.mid(6)); | 257 | emit showIncidence(n.mid(6)); |
251 | #endif | 258 | #endif |
252 | return; | 259 | return; |
253 | } else if (n.startsWith("todo:")) { | 260 | } else if (n.startsWith("todo:")) { |
254 | #ifdef DESKTOP_VERSION | 261 | #ifdef DESKTOP_VERSION |
255 | emit showIncidence(n.mid(7)); | 262 | emit showIncidence(n.mid(7)); |
256 | #else | 263 | #else |
257 | emit showIncidence(n.mid(5)); | 264 | emit showIncidence(n.mid(5)); |
258 | #endif | 265 | #endif |
259 | return; | 266 | return; |
260 | } | 267 | } |
261 | } | 268 | } |
262 | 269 | ||
263 | 270 | ||
264 | class KOBeamPrefs : public QDialog | 271 | class KOBeamPrefs : public QDialog |
265 | { | 272 | { |
266 | public: | 273 | public: |
267 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
268 | QDialog( parent, name, true ) | 275 | QDialog( parent, name, true ) |
269 | { | 276 | { |
270 | setCaption( i18n("Beam Options") ); | 277 | setCaption( i18n("Beam Options") ); |
271 | QVBoxLayout* lay = new QVBoxLayout( this ); | 278 | QVBoxLayout* lay = new QVBoxLayout( this ); |
272 | lay->setSpacing( 3 ); | 279 | lay->setSpacing( 3 ); |
273 | lay->setMargin( 3 ); | 280 | lay->setMargin( 3 ); |
274 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
275 | lay->addWidget( format ); | 282 | lay->addWidget( format ); |
276 | format->setExclusive ( true ) ; | 283 | format->setExclusive ( true ) ; |
277 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
278 | lay->addWidget( time ); time->setExclusive ( true ) ; | 285 | lay->addWidget( time ); time->setExclusive ( true ) ; |
279 | vcal = new QRadioButton(" vCalendar ", format ); | 286 | vcal = new QRadioButton(" vCalendar ", format ); |
280 | ical = new QRadioButton(" iCalendar ", format ); | 287 | ical = new QRadioButton(" iCalendar ", format ); |
281 | vcal->setChecked( true ); | 288 | vcal->setChecked( true ); |
282 | tz = new QRadioButton(i18n(" With timezone "), time ); | 289 | tz = new QRadioButton(i18n(" With timezone "), time ); |
283 | local = new QRadioButton(i18n(" Local time "), time ); | 290 | local = new QRadioButton(i18n(" Local time "), time ); |
284 | tz->setChecked( true ); | 291 | tz->setChecked( true ); |
285 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
286 | lay->addWidget( ok ); | 293 | lay->addWidget( ok ); |
287 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
288 | lay->addWidget( cancel ); | 295 | lay->addWidget( cancel ); |
289 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
290 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
291 | resize( 200, 200 ); | 298 | resize( 200, 200 ); |
292 | } | 299 | } |
293 | 300 | ||
294 | bool beamVcal() { return vcal->isChecked(); } | 301 | bool beamVcal() { return vcal->isChecked(); } |
295 | bool beamLocal() { return local->isChecked(); } | 302 | bool beamLocal() { return local->isChecked(); } |
296 | private: | 303 | private: |
297 | QRadioButton* vcal, *ical, *local, *tz; | 304 | QRadioButton* vcal, *ical, *local, *tz; |
298 | }; | 305 | }; |
299 | class KOCatPrefs : public QDialog | 306 | class KOCatPrefs : public QDialog |
300 | { | 307 | { |
301 | public: | 308 | public: |
302 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
303 | QDialog( parent, name, true ) | 310 | QDialog( parent, name, true ) |
304 | { | 311 | { |
305 | setCaption( i18n("Manage new Categories") ); | 312 | setCaption( i18n("Manage new Categories") ); |
306 | QVBoxLayout* lay = new QVBoxLayout( this ); | 313 | QVBoxLayout* lay = new QVBoxLayout( this ); |
307 | lay->setSpacing( 3 ); | 314 | lay->setSpacing( 3 ); |
308 | lay->setMargin( 3 ); | 315 | lay->setMargin( 3 ); |
309 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
310 | lay->addWidget( lab ); | 317 | lay->addWidget( lab ); |
311 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
312 | lay->addWidget( format ); | 319 | lay->addWidget( format ); |
313 | format->setExclusive ( true ) ; | 320 | format->setExclusive ( true ) ; |
314 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
315 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
316 | addCatBut->setChecked( true ); | 323 | addCatBut->setChecked( true ); |
317 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
318 | lay->addWidget( ok ); | 325 | lay->addWidget( ok ); |
319 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
320 | lay->addWidget( cancel ); | 327 | lay->addWidget( cancel ); |
321 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
322 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
323 | resize( 200, 200 ); | 330 | resize( 200, 200 ); |
324 | } | 331 | } |
325 | 332 | ||
326 | bool addCat() { return addCatBut->isChecked(); } | 333 | bool addCat() { return addCatBut->isChecked(); } |
327 | private: | 334 | private: |
328 | QRadioButton* addCatBut; | 335 | QRadioButton* addCatBut; |
329 | }; | 336 | }; |
330 | 337 | ||
331 | 338 | ||
332 | 339 | ||
333 | CalendarView::CalendarView( CalendarResources *calendar, | 340 | CalendarView::CalendarView( CalendarResources *calendar, |
334 | QWidget *parent, const char *name ) | 341 | QWidget *parent, const char *name ) |
335 | : CalendarViewBase( parent, name ), | 342 | : CalendarViewBase( parent, name ), |
336 | mCalendar( calendar ), | 343 | mCalendar( calendar ), |
337 | mResourceManager( calendar->resourceManager() ) | 344 | mResourceManager( calendar->resourceManager() ) |
338 | { | 345 | { |
339 | 346 | ||
340 | mEventEditor = 0; | 347 | mEventEditor = 0; |
341 | mTodoEditor = 0; | 348 | mTodoEditor = 0; |
342 | 349 | ||
343 | init(); | 350 | init(); |
344 | } | 351 | } |
345 | 352 | ||
346 | CalendarView::CalendarView( Calendar *calendar, | 353 | CalendarView::CalendarView( Calendar *calendar, |
347 | QWidget *parent, const char *name ) | 354 | QWidget *parent, const char *name ) |
348 | : CalendarViewBase( parent, name ), | 355 | : CalendarViewBase( parent, name ), |
349 | mCalendar( calendar ), | 356 | mCalendar( calendar ), |
350 | mResourceManager( 0 ) | 357 | mResourceManager( 0 ) |
351 | { | 358 | { |
352 | 359 | ||
353 | mEventEditor = 0; | 360 | mEventEditor = 0; |
354 | mTodoEditor = 0; | 361 | mTodoEditor = 0; |
355 | init(); | 362 | init(); |
356 | } | 363 | } |
357 | 364 | ||
358 | void CalendarView::init() | 365 | void CalendarView::init() |
359 | { | 366 | { |
360 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 367 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
361 | setFocusPolicy ( NoFocus ); | 368 | setFocusPolicy ( NoFocus ); |
362 | mViewerCallerIsSearchDialog = false; | 369 | mViewerCallerIsSearchDialog = false; |
363 | mBlockShowDates = false; | 370 | mBlockShowDates = false; |
364 | beamDialog = new KOBeamPrefs(); | 371 | beamDialog = new KOBeamPrefs(); |
365 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
366 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
367 | writeLocale(); | 374 | writeLocale(); |
368 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
369 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
370 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
371 | mModified = false; | 378 | mModified = false; |
372 | mReadOnly = false; | 379 | mReadOnly = false; |
373 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
374 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
375 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
376 | 383 | ||
377 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
378 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
379 | 386 | ||
380 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
381 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
382 | 389 | ||
383 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
384 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
385 | // create the main layout frames. | 392 | // create the main layout frames. |
386 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
387 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
388 | 395 | ||
389 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
390 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
391 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
392 | 399 | ||
393 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
394 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
395 | 402 | ||
396 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
397 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
398 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
399 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
400 | 407 | ||
401 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
402 | mResourceView = 0; | 409 | mResourceView = 0; |
403 | #else | 410 | #else |
404 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
405 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
406 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
407 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
408 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
409 | } else { | 416 | } else { |
410 | mResourceView = 0; | 417 | mResourceView = 0; |
411 | } | 418 | } |
412 | #endif | 419 | #endif |
413 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
414 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
415 | 422 | ||
416 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
417 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
418 | 425 | ||
419 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
420 | #else | 427 | #else |
421 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
422 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
423 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
424 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
425 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
426 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
427 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
428 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
429 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
430 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
431 | } else { | 438 | } else { |
432 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
433 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
438 | } | 445 | } |
439 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
440 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
441 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
442 | //mainBoxLayout->addWidget (mLeftFrame); | 449 | //mainBoxLayout->addWidget (mLeftFrame); |
443 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
444 | "CalendarView::DateNavigator" ); | 451 | "CalendarView::DateNavigator" ); |
445 | #if 0 | 452 | #if 0 |
446 | // FIXME | 453 | // FIXME |
447 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
448 | "CalendarView::DateNavigator", QDate::currentDate()); | 455 | "CalendarView::DateNavigator", QDate::currentDate()); |
449 | #endif | 456 | #endif |
450 | // mDateNavigator->blockSignals( true ); | 457 | // mDateNavigator->blockSignals( true ); |
451 | //leftFrameLayout->addWidget( mDateNavigator ); | 458 | //leftFrameLayout->addWidget( mDateNavigator ); |
452 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
453 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
454 | mTodoList->setNavigator( mNavigator ); | 461 | mTodoList->setNavigator( mNavigator ); |
455 | #if 0 | 462 | #if 0 |
456 | if ( QApplication::desktop()->width() < 480 ) { | 463 | if ( QApplication::desktop()->width() < 480 ) { |
457 | leftFrameLayout->addWidget(mFilterView); | 464 | leftFrameLayout->addWidget(mFilterView); |
458 | leftFrameLayout->addWidget(mTodoList, 2 ); | 465 | leftFrameLayout->addWidget(mTodoList, 2 ); |
459 | 466 | ||
460 | } else { | 467 | } else { |
461 | leftFrameLayout->addWidget(mTodoList,2 ); | 468 | leftFrameLayout->addWidget(mTodoList,2 ); |
462 | leftFrameLayout->addWidget(mFilterView ); | 469 | leftFrameLayout->addWidget(mFilterView ); |
463 | } | 470 | } |
464 | #endif | 471 | #endif |
465 | mFilterView->hide(); | 472 | mFilterView->hide(); |
466 | QWidget *rightBox = new QWidget( mMainFrame ); | 473 | QWidget *rightBox = new QWidget( mMainFrame ); |
467 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 474 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
468 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 475 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
469 | mRightFrame = new QWidgetStack( rightBox ); | 476 | mRightFrame = new QWidgetStack( rightBox ); |
470 | rightLayout->addWidget( mRightFrame, 10 ); | 477 | rightLayout->addWidget( mRightFrame, 10 ); |
471 | 478 | ||
472 | //mLeftFrame = (QWidget *)leftFrame; | 479 | //mLeftFrame = (QWidget *)leftFrame; |
473 | if ( KOPrefs::instance()->mVerticalScreen ) { | 480 | if ( KOPrefs::instance()->mVerticalScreen ) { |
474 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 481 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
475 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 482 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
476 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 483 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
477 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 484 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
478 | } else { | 485 | } else { |
479 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 486 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
480 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 487 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
481 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 488 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
482 | } | 489 | } |
483 | if ( !KOPrefs::instance()->mShowDateNavigator) | 490 | if ( !KOPrefs::instance()->mShowDateNavigator) |
484 | mDateNavigator->hide(); | 491 | mDateNavigator->hide(); |
485 | //qDebug("Calendarview Size %d %d ", width(), height()); | 492 | //qDebug("Calendarview Size %d %d ", width(), height()); |
486 | #endif | 493 | #endif |
487 | 494 | ||
488 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 495 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
489 | SLOT( showDates( const KCal::DateList & ) ) ); | 496 | SLOT( showDates( const KCal::DateList & ) ) ); |
490 | 497 | ||
491 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 498 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
492 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 499 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
493 | 500 | ||
494 | 501 | ||
495 | 502 | ||
496 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 503 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
497 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 504 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
498 | 505 | ||
499 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 506 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
500 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 507 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
501 | 508 | ||
502 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 509 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
503 | mNavigator, SLOT( selectPreviousYear() ) ); | 510 | mNavigator, SLOT( selectPreviousYear() ) ); |
504 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 511 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
505 | mNavigator, SLOT( selectNextYear() ) ); | 512 | mNavigator, SLOT( selectNextYear() ) ); |
506 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 513 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
507 | mNavigator, SLOT( selectPreviousMonth() ) ); | 514 | mNavigator, SLOT( selectPreviousMonth() ) ); |
508 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 515 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
509 | mNavigator, SLOT( selectNextMonth() ) ); | 516 | mNavigator, SLOT( selectNextMonth() ) ); |
510 | 517 | ||
511 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 518 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
512 | mNavigator, SLOT( selectPrevious() ) ); | 519 | mNavigator, SLOT( selectPrevious() ) ); |
513 | connect( mDateNavigator, SIGNAL( goNext() ), | 520 | connect( mDateNavigator, SIGNAL( goNext() ), |
514 | mNavigator, SLOT( selectNext() ) ); | 521 | mNavigator, SLOT( selectNext() ) ); |
515 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 522 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
516 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 523 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
517 | 524 | ||
518 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 525 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
519 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 526 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
520 | #if 0 | 527 | #if 0 |
521 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 528 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
522 | SLOT( incidenceAdded( Incidence *) ) ); | 529 | SLOT( incidenceAdded( Incidence *) ) ); |
523 | #endif | 530 | #endif |
524 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 531 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
525 | 532 | ||
526 | connect( this, SIGNAL( configChanged() ), | 533 | connect( this, SIGNAL( configChanged() ), |
527 | mDateNavigator, SLOT( updateConfig() ) ); | 534 | mDateNavigator, SLOT( updateConfig() ) ); |
528 | 535 | ||
529 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 536 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
530 | SLOT( newTodo() ) ); | 537 | SLOT( newTodo() ) ); |
531 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 538 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
532 | SLOT( newSubTodo( Todo * ) ) ); | 539 | SLOT( newSubTodo( Todo * ) ) ); |
533 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 540 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
534 | SLOT( editTodo( Todo * ) ) ); | 541 | SLOT( editTodo( Todo * ) ) ); |
535 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 542 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
536 | SLOT( showTodo( Todo *) ) ); | 543 | SLOT( showTodo( Todo *) ) ); |
537 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 544 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
538 | SLOT( deleteTodo( Todo *) ) ); | 545 | SLOT( deleteTodo( Todo *) ) ); |
539 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 546 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
540 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 547 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
541 | SLOT( purgeCompleted() ) ); | 548 | SLOT( purgeCompleted() ) ); |
542 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 549 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
543 | SIGNAL( todoModified( Todo *, int ) ) ); | 550 | SIGNAL( todoModified( Todo *, int ) ) ); |
544 | 551 | ||
545 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 552 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
546 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 553 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
547 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 554 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
548 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 555 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
549 | 556 | ||
550 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 557 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
551 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 558 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
552 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 559 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
553 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 560 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
554 | 561 | ||
555 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 562 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
556 | this, SLOT ( todo_unsub( Todo * ) ) ); | 563 | this, SLOT ( todo_unsub( Todo * ) ) ); |
557 | 564 | ||
558 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 565 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
559 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 566 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
560 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 567 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
561 | SLOT( updateTodo( Todo *, int ) ) ); | 568 | SLOT( updateTodo( Todo *, int ) ) ); |
562 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 569 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
563 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 570 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
564 | 571 | ||
565 | 572 | ||
566 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 573 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
567 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 574 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
568 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 575 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
569 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 576 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
570 | 577 | ||
571 | 578 | ||
572 | 579 | ||
573 | 580 | ||
574 | 581 | ||
575 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 582 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
576 | SLOT(checkClipboard())); | 583 | SLOT(checkClipboard())); |
577 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 584 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
578 | SLOT( processTodoListSelection( Incidence * ) ) ); | 585 | SLOT( processTodoListSelection( Incidence * ) ) ); |
579 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 586 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
580 | 587 | ||
581 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 588 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
582 | 589 | ||
583 | mDateFrame = new QVBox(0,0,WType_Popup); | 590 | mDateFrame = new QVBox(0,0,WType_Popup); |
584 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 591 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
585 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 592 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
586 | mDateFrame->setLineWidth(3); | 593 | mDateFrame->setLineWidth(3); |
587 | mDateFrame->hide(); | 594 | mDateFrame->hide(); |
588 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 595 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
589 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 596 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
590 | 597 | ||
591 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 598 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
592 | 599 | ||
593 | mEventEditor = mDialogManager->getEventEditor(); | 600 | mEventEditor = mDialogManager->getEventEditor(); |
594 | mTodoEditor = mDialogManager->getTodoEditor(); | 601 | mTodoEditor = mDialogManager->getTodoEditor(); |
595 | 602 | ||
596 | mFlagEditDescription = false; | 603 | mFlagEditDescription = false; |
597 | 604 | ||
598 | mSuspendTimer = new QTimer( this ); | 605 | mSuspendTimer = new QTimer( this ); |
599 | mAlarmTimer = new QTimer( this ); | 606 | mAlarmTimer = new QTimer( this ); |
600 | mRecheckAlarmTimer = new QTimer( this ); | 607 | mRecheckAlarmTimer = new QTimer( this ); |
601 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 608 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
602 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 609 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
603 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 610 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
604 | mAlarmDialog = new AlarmDialog( this ); | 611 | mAlarmDialog = new AlarmDialog( this ); |
605 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 612 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
606 | mAlarmDialog->setServerNotification( false ); | 613 | mAlarmDialog->setServerNotification( false ); |
607 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 614 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
608 | 615 | ||
609 | 616 | ||
610 | #ifndef DESKTOP_VERSION | 617 | #ifndef DESKTOP_VERSION |
611 | //US listen for arriving address resultsets | 618 | //US listen for arriving address resultsets |
612 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 619 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
613 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 620 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
614 | #endif | 621 | #endif |
615 | mDateNavigator->setCalendar( mCalendar ); | 622 | mDateNavigator->setCalendar( mCalendar ); |
616 | } | 623 | } |
617 | 624 | ||
618 | 625 | ||
619 | CalendarView::~CalendarView() | 626 | CalendarView::~CalendarView() |
620 | { | 627 | { |
621 | // kdDebug() << "~CalendarView()" << endl; | 628 | // kdDebug() << "~CalendarView()" << endl; |
622 | //qDebug("CalendarView::~CalendarView() "); | 629 | //qDebug("CalendarView::~CalendarView() "); |
623 | delete mDialogManager; | 630 | delete mDialogManager; |
624 | delete mViewManager; | 631 | delete mViewManager; |
625 | delete mStorage; | 632 | delete mStorage; |
626 | delete mDateFrame ; | 633 | delete mDateFrame ; |
627 | delete beamDialog; | 634 | delete beamDialog; |
628 | delete mEventViewerDialog; | 635 | delete mEventViewerDialog; |
629 | //kdDebug() << "~CalendarView() done" << endl; | 636 | //kdDebug() << "~CalendarView() done" << endl; |
630 | } | 637 | } |
631 | void CalendarView::checkAlarms() | 638 | void CalendarView::checkAlarms() |
632 | { | 639 | { |
633 | KConfig *config = KOGlobals::config(); | 640 | KConfig *config = KOGlobals::config(); |
634 | config->setGroup( "AppRun" ); | 641 | config->setGroup( "AppRun" ); |
635 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 642 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
636 | int secs = config->readNumEntry( "LatestProgramStop" ) - 30; | 643 | int secs = config->readNumEntry( "LatestProgramStop" ) - 30; |
637 | secs -= ( 3600 * 24*3 ); // debug only | 644 | //secs -= ( 3600 * 24*3 ); // debug only |
638 | QDateTime latest = dt.addSecs ( secs ); | 645 | QDateTime latest = dt.addSecs ( secs ); |
639 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 646 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
640 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 647 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
641 | QPtrList<Incidence> al; | 648 | QPtrList<Incidence> al; |
642 | Incidence* inL = el.first(); | 649 | Incidence* inL = el.first(); |
643 | while ( inL ) { | 650 | while ( inL ) { |
644 | bool ok = false; | 651 | bool ok = false; |
645 | int offset = 0; | 652 | int offset = 0; |
646 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 653 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
647 | if ( ok ) { | 654 | if ( ok ) { |
648 | //qDebug("OK %s",next.toString().latin1()); | 655 | //qDebug("OK %s",next.toString().latin1()); |
649 | if ( next < QDateTime::currentDateTime() ) { | 656 | if ( next < QDateTime::currentDateTime() ) { |
650 | al.append( inL ); | 657 | al.append( inL ); |
651 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 658 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
652 | } | 659 | } |
653 | } | 660 | } |
654 | inL = el.next(); | 661 | inL = el.next(); |
655 | } | 662 | } |
656 | if ( al.count() ) { | 663 | if ( al.count() ) { |
657 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 664 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
658 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 665 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
659 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 666 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
660 | lay->setSpacing( 0 ); | 667 | lay->setSpacing( 0 ); |
661 | lay->setMargin( 0 ); | 668 | lay->setMargin( 0 ); |
662 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 669 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
663 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 670 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
664 | lay->addWidget( matb ); | 671 | lay->addWidget( matb ); |
665 | int si = 220; | 672 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
666 | if ( QApplication::desktop()->width() > 470 ) | 673 | int wid = 210; |
667 | si = 400; | 674 | int x = QApplication::desktop()->width() - wid - 7; |
668 | dia->resize(si,si/2); | 675 | int y = QApplication::desktop()->height() - wid - 70; |
676 | dia->setGeometry ( x,y,wid,wid); | ||
677 | } else { | ||
678 | int si = 220; | ||
679 | if ( QApplication::desktop()->width() > 470 ) | ||
680 | si = 400; | ||
681 | dia->resize(si,si/2); | ||
682 | } | ||
669 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 683 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
670 | dia->show(); | 684 | dia->show(); |
671 | 685 | ||
672 | } | 686 | } |
673 | } | 687 | } |
674 | void CalendarView::showDay( QDate d ) | 688 | void CalendarView::showDay( QDate d ) |
675 | { | 689 | { |
676 | dateNavigator()->blockSignals( true ); | 690 | dateNavigator()->blockSignals( true ); |
677 | dateNavigator()->selectDate( d ); | 691 | dateNavigator()->selectDate( d ); |
678 | dateNavigator()->blockSignals( false ); | 692 | dateNavigator()->blockSignals( false ); |
679 | mViewManager->showDayView(); | 693 | mViewManager->showDayView(); |
680 | //dateNavigator()->selectDate( d ); | 694 | //dateNavigator()->selectDate( d ); |
681 | } | 695 | } |
682 | void CalendarView::timerAlarm() | 696 | void CalendarView::timerAlarm() |
683 | { | 697 | { |
684 | //qDebug("CalendarView::timerAlarm() "); | 698 | //qDebug("CalendarView::timerAlarm() "); |
685 | computeAlarm(mAlarmNotification ); | 699 | computeAlarm(mAlarmNotification ); |
686 | } | 700 | } |
687 | 701 | ||
688 | void CalendarView::suspendAlarm() | 702 | void CalendarView::suspendAlarm() |
689 | { | 703 | { |
690 | //qDebug(" CalendarView::suspendAlarm() "); | 704 | //qDebug(" CalendarView::suspendAlarm() "); |
691 | computeAlarm(mSuspendAlarmNotification ); | 705 | computeAlarm(mSuspendAlarmNotification ); |
692 | 706 | ||
693 | } | 707 | } |
694 | 708 | ||
695 | void CalendarView::startAlarm( QString mess , QString filename) | 709 | void CalendarView::startAlarm( QString mess , QString filename) |
696 | { | 710 | { |
697 | 711 | ||
698 | topLevelWidget()->showNormal(); | 712 | topLevelWidget()->showNormal(); |
699 | topLevelWidget()->setActiveWindow(); | 713 | topLevelWidget()->setActiveWindow(); |
700 | topLevelWidget()->raise(); | 714 | topLevelWidget()->raise(); |
701 | 715 | ||
702 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 716 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
703 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 717 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
704 | 718 | ||
705 | } | 719 | } |
706 | 720 | ||
707 | void CalendarView::checkNextTimerAlarm() | 721 | void CalendarView::checkNextTimerAlarm() |
708 | { | 722 | { |
709 | mCalendar->checkAlarmForIncidence( 0, true ); | 723 | mCalendar->checkAlarmForIncidence( 0, true ); |
710 | } | 724 | } |
711 | 725 | ||
712 | void CalendarView::computeAlarm( QString msg ) | 726 | void CalendarView::computeAlarm( QString msg ) |
713 | { | 727 | { |
714 | 728 | ||
715 | QString mess = msg; | 729 | QString mess = msg; |
716 | QString mAlarmMessage = mess.mid( 9 ); | 730 | QString mAlarmMessage = mess.mid( 9 ); |
717 | QString filename = MainWindow::resourcePath(); | 731 | QString filename = MainWindow::resourcePath(); |
718 | filename += "koalarm.wav"; | 732 | filename += "koalarm.wav"; |
719 | QString tempfilename; | 733 | QString tempfilename; |
720 | if ( mess.left( 13 ) == "suspend_alarm") { | 734 | if ( mess.left( 13 ) == "suspend_alarm") { |
721 | bool error = false; | 735 | bool error = false; |
722 | int len = mess.mid( 13 ).find("+++"); | 736 | int len = mess.mid( 13 ).find("+++"); |
723 | if ( len < 2 ) | 737 | if ( len < 2 ) |
724 | error = true; | 738 | error = true; |
725 | else { | 739 | else { |
726 | tempfilename = mess.mid( 13, len ); | 740 | tempfilename = mess.mid( 13, len ); |
727 | if ( !QFile::exists( tempfilename ) ) | 741 | if ( !QFile::exists( tempfilename ) ) |
728 | error = true; | 742 | error = true; |
729 | } | 743 | } |
730 | if ( ! error ) { | 744 | if ( ! error ) { |
731 | filename = tempfilename; | 745 | filename = tempfilename; |
732 | } | 746 | } |
733 | mAlarmMessage = mess.mid( 13+len+3 ); | 747 | mAlarmMessage = mess.mid( 13+len+3 ); |
734 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 748 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
735 | startAlarm( mAlarmMessage, filename); | 749 | startAlarm( mAlarmMessage, filename); |
736 | return; | 750 | return; |
737 | } | 751 | } |
738 | if ( mess.left( 11 ) == "timer_alarm") { | 752 | if ( mess.left( 11 ) == "timer_alarm") { |
739 | //mTimerTime = 0; | 753 | //mTimerTime = 0; |
740 | startAlarm( mess.mid( 11 ), filename ); | 754 | startAlarm( mess.mid( 11 ), filename ); |
741 | return; | 755 | return; |
742 | } | 756 | } |
743 | if ( mess.left( 10 ) == "proc_alarm") { | 757 | if ( mess.left( 10 ) == "proc_alarm") { |
744 | bool error = false; | 758 | bool error = false; |
745 | int len = mess.mid( 10 ).find("+++"); | 759 | int len = mess.mid( 10 ).find("+++"); |
746 | if ( len < 2 ) | 760 | if ( len < 2 ) |
747 | error = true; | 761 | error = true; |
748 | else { | 762 | else { |
749 | tempfilename = mess.mid( 10, len ); | 763 | tempfilename = mess.mid( 10, len ); |
750 | if ( !QFile::exists( tempfilename ) ) | 764 | if ( !QFile::exists( tempfilename ) ) |
751 | error = true; | 765 | error = true; |
752 | } | 766 | } |
753 | if ( error ) { | 767 | if ( error ) { |
754 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 768 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
755 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 769 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
756 | } else { | 770 | } else { |
757 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 771 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
758 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 772 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
759 | #ifndef _WIN32_ | 773 | #ifndef _WIN32_ |
760 | if ( vfork () == 0 ) { | 774 | if ( vfork () == 0 ) { |
761 | execl ( tempfilename.latin1(), 0 ); | 775 | execl ( tempfilename.latin1(), 0 ); |
762 | return; | 776 | return; |
763 | } | 777 | } |
764 | #else | 778 | #else |
765 | QProcess* p = new QProcess(); | 779 | QProcess* p = new QProcess(); |
766 | p->addArgument( tempfilename.latin1() ); | 780 | p->addArgument( tempfilename.latin1() ); |
767 | p->start(); | 781 | p->start(); |
768 | return; | 782 | return; |
769 | #endif | 783 | #endif |
770 | 784 | ||
771 | return; | 785 | return; |
772 | } | 786 | } |
773 | 787 | ||
774 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 788 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
775 | } | 789 | } |
776 | if ( mess.left( 11 ) == "audio_alarm") { | 790 | if ( mess.left( 11 ) == "audio_alarm") { |
777 | bool error = false; | 791 | bool error = false; |
778 | int len = mess.mid( 11 ).find("+++"); | 792 | int len = mess.mid( 11 ).find("+++"); |
779 | if ( len < 2 ) | 793 | if ( len < 2 ) |
780 | error = true; | 794 | error = true; |
781 | else { | 795 | else { |
782 | tempfilename = mess.mid( 11, len ); | 796 | tempfilename = mess.mid( 11, len ); |
783 | if ( !QFile::exists( tempfilename ) ) | 797 | if ( !QFile::exists( tempfilename ) ) |
784 | error = true; | 798 | error = true; |
785 | } | 799 | } |
786 | if ( ! error ) { | 800 | if ( ! error ) { |
787 | filename = tempfilename; | 801 | filename = tempfilename; |
788 | } | 802 | } |
789 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 803 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
790 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 804 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
791 | } | 805 | } |
792 | if ( mess.left( 9 ) == "cal_alarm") { | 806 | if ( mess.left( 9 ) == "cal_alarm") { |
793 | mAlarmMessage = mess.mid( 9 ) ; | 807 | mAlarmMessage = mess.mid( 9 ) ; |
794 | } | 808 | } |
795 | 809 | ||
796 | startAlarm( mAlarmMessage, filename ); | 810 | startAlarm( mAlarmMessage, filename ); |
797 | 811 | ||
798 | 812 | ||
799 | } | 813 | } |
800 | 814 | ||
801 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 815 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
802 | { | 816 | { |
803 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 817 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
804 | 818 | ||
805 | mSuspendAlarmNotification = noti; | 819 | mSuspendAlarmNotification = noti; |
806 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 820 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
807 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 821 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
808 | mSuspendTimer->start( ms , true ); | 822 | mSuspendTimer->start( ms , true ); |
809 | 823 | ||
810 | } | 824 | } |
811 | 825 | ||
812 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 826 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
813 | { | 827 | { |
814 | mNextAlarmDateTime = qdt; | 828 | mNextAlarmDateTime = qdt; |
815 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 829 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
816 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 830 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
817 | #ifndef DESKTOP_VERSION | 831 | #ifndef DESKTOP_VERSION |
818 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 832 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
819 | #endif | 833 | #endif |
820 | return; | 834 | return; |
821 | } | 835 | } |
822 | int maxSec; | 836 | int maxSec; |
823 | //maxSec = 5; //testing only | 837 | //maxSec = 5; //testing only |
824 | maxSec = 86400+3600; // one day+1hour | 838 | maxSec = 86400+3600; // one day+1hour |
825 | mAlarmNotification = noti; | 839 | mAlarmNotification = noti; |
826 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 840 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
827 | if ( sec > maxSec ) { | 841 | if ( sec > maxSec ) { |
828 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 842 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
829 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 843 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
830 | return; | 844 | return; |
831 | } else { | 845 | } else { |
832 | mRecheckAlarmTimer->stop(); | 846 | mRecheckAlarmTimer->stop(); |
833 | } | 847 | } |
834 | //qDebug("Alarm timer started with secs: %d ", sec); | 848 | //qDebug("Alarm timer started with secs: %d ", sec); |
835 | mAlarmTimer->start( sec *1000 , true ); | 849 | mAlarmTimer->start( sec *1000 , true ); |
836 | 850 | ||
837 | } | 851 | } |
838 | // called by mRecheckAlarmTimer to get next alarm | 852 | // called by mRecheckAlarmTimer to get next alarm |
839 | // we need this, because a QTimer has only a max range of 25 days | 853 | // we need this, because a QTimer has only a max range of 25 days |
840 | void CalendarView::recheckTimerAlarm() | 854 | void CalendarView::recheckTimerAlarm() |
841 | { | 855 | { |
842 | mAlarmTimer->stop(); | 856 | mAlarmTimer->stop(); |
843 | mRecheckAlarmTimer->stop(); | 857 | mRecheckAlarmTimer->stop(); |
844 | mCalendar->checkAlarmForIncidence( 0, true ); | 858 | mCalendar->checkAlarmForIncidence( 0, true ); |
845 | } | 859 | } |
846 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 860 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
847 | { | 861 | { |
848 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 862 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
849 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 863 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
850 | #ifndef DESKTOP_VERSION | 864 | #ifndef DESKTOP_VERSION |
851 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 865 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
852 | #endif | 866 | #endif |
853 | return; | 867 | return; |
854 | } | 868 | } |
855 | mAlarmTimer->stop(); | 869 | mAlarmTimer->stop(); |
856 | } | 870 | } |
857 | void CalendarView::selectWeekNum ( int num ) | 871 | void CalendarView::selectWeekNum ( int num ) |
858 | { | 872 | { |
859 | dateNavigator()->blockSignals( true ); | 873 | dateNavigator()->blockSignals( true ); |
860 | dateNavigator()->selectWeek( num ); | 874 | dateNavigator()->selectWeek( num ); |
861 | dateNavigator()->blockSignals( false ); | 875 | dateNavigator()->blockSignals( false ); |
862 | mViewManager->showWeekView(); | 876 | mViewManager->showWeekView(); |
863 | } | 877 | } |
864 | KOViewManager *CalendarView::viewManager() | 878 | KOViewManager *CalendarView::viewManager() |
865 | { | 879 | { |
866 | return mViewManager; | 880 | return mViewManager; |
867 | } | 881 | } |
868 | 882 | ||
869 | KODialogManager *CalendarView::dialogManager() | 883 | KODialogManager *CalendarView::dialogManager() |
870 | { | 884 | { |
871 | return mDialogManager; | 885 | return mDialogManager; |
872 | } | 886 | } |
873 | 887 | ||
874 | QDate CalendarView::startDate() | 888 | QDate CalendarView::startDate() |
875 | { | 889 | { |
876 | DateList dates = mNavigator->selectedDates(); | 890 | DateList dates = mNavigator->selectedDates(); |
877 | 891 | ||
878 | return dates.first(); | 892 | return dates.first(); |
879 | } | 893 | } |
880 | 894 | ||
881 | QDate CalendarView::endDate() | 895 | QDate CalendarView::endDate() |
882 | { | 896 | { |
883 | DateList dates = mNavigator->selectedDates(); | 897 | DateList dates = mNavigator->selectedDates(); |
884 | 898 | ||
885 | return dates.last(); | 899 | return dates.last(); |
886 | } | 900 | } |
887 | 901 | ||
888 | 902 | ||
889 | void CalendarView::createPrinter() | 903 | void CalendarView::createPrinter() |
890 | { | 904 | { |
891 | #ifndef KORG_NOPRINTER | 905 | #ifndef KORG_NOPRINTER |
892 | if (!mCalPrinter) { | 906 | if (!mCalPrinter) { |
893 | mCalPrinter = new CalPrinter(this, mCalendar); | 907 | mCalPrinter = new CalPrinter(this, mCalendar); |
894 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 908 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
895 | } | 909 | } |
896 | #endif | 910 | #endif |
897 | } | 911 | } |
898 | 912 | ||
899 | 913 | ||
900 | //KOPrefs::instance()->mWriteBackFile | 914 | //KOPrefs::instance()->mWriteBackFile |
901 | //KOPrefs::instance()->mWriteBackExistingOnly | 915 | //KOPrefs::instance()->mWriteBackExistingOnly |
902 | 916 | ||
903 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 917 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
904 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 918 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
905 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 919 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
906 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 920 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
907 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 921 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
908 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 922 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
909 | 923 | ||
910 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 924 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
911 | { | 925 | { |
912 | 926 | ||
913 | // 0 equal | 927 | // 0 equal |
914 | // 1 take local | 928 | // 1 take local |
915 | // 2 take remote | 929 | // 2 take remote |
916 | // 3 cancel | 930 | // 3 cancel |
917 | QDateTime lastSync = mLastCalendarSync; | 931 | QDateTime lastSync = mLastCalendarSync; |
918 | QDateTime localMod = local->lastModified(); | 932 | QDateTime localMod = local->lastModified(); |
919 | QDateTime remoteMod = remote->lastModified(); | 933 | QDateTime remoteMod = remote->lastModified(); |
920 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 934 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
921 | bool remCh, locCh; | 935 | bool remCh, locCh; |
922 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 936 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
923 | //if ( remCh ) | 937 | //if ( remCh ) |
924 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 938 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
925 | locCh = ( localMod > mLastCalendarSync ); | 939 | locCh = ( localMod > mLastCalendarSync ); |
926 | if ( !remCh && ! locCh ) { | 940 | if ( !remCh && ! locCh ) { |
927 | //qDebug("both not changed "); | 941 | //qDebug("both not changed "); |
928 | lastSync = localMod.addDays(1); | 942 | lastSync = localMod.addDays(1); |
929 | if ( mode <= SYNC_PREF_ASK ) | 943 | if ( mode <= SYNC_PREF_ASK ) |
930 | return 0; | 944 | return 0; |
931 | } else { | 945 | } else { |
932 | if ( locCh ) { | 946 | if ( locCh ) { |
933 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 947 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
934 | lastSync = localMod.addDays( -1 ); | 948 | lastSync = localMod.addDays( -1 ); |
935 | if ( !remCh ) | 949 | if ( !remCh ) |
936 | remoteMod = ( lastSync.addDays( -1 ) ); | 950 | remoteMod = ( lastSync.addDays( -1 ) ); |
937 | } else { | 951 | } else { |
938 | //qDebug(" not loc changed "); | 952 | //qDebug(" not loc changed "); |
939 | lastSync = localMod.addDays( 1 ); | 953 | lastSync = localMod.addDays( 1 ); |
940 | if ( remCh ) | 954 | if ( remCh ) |
941 | remoteMod =( lastSync.addDays( 1 ) ); | 955 | remoteMod =( lastSync.addDays( 1 ) ); |
942 | 956 | ||
943 | } | 957 | } |
944 | } | 958 | } |
945 | full = true; | 959 | full = true; |
946 | if ( mode < SYNC_PREF_ASK ) | 960 | if ( mode < SYNC_PREF_ASK ) |
947 | mode = SYNC_PREF_ASK; | 961 | mode = SYNC_PREF_ASK; |
948 | } else { | 962 | } else { |
949 | if ( localMod == remoteMod ) | 963 | if ( localMod == remoteMod ) |
950 | // if ( local->revision() == remote->revision() ) | 964 | // if ( local->revision() == remote->revision() ) |
951 | return 0; | 965 | return 0; |
952 | 966 | ||
953 | } | 967 | } |
954 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 968 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
955 | 969 | ||
956 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 970 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
957 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 971 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
958 | //full = true; //debug only | 972 | //full = true; //debug only |
959 | if ( full ) { | 973 | if ( full ) { |
960 | bool equ = false; | 974 | bool equ = false; |
961 | if ( local->type() == "Event" ) { | 975 | if ( local->type() == "Event" ) { |
962 | equ = (*((Event*) local) == *((Event*) remote)); | 976 | equ = (*((Event*) local) == *((Event*) remote)); |
963 | } | 977 | } |
964 | else if ( local->type() =="Todo" ) | 978 | else if ( local->type() =="Todo" ) |
965 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 979 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
966 | else if ( local->type() =="Journal" ) | 980 | else if ( local->type() =="Journal" ) |
967 | equ = (*((Journal*) local) == *((Journal*) remote)); | 981 | equ = (*((Journal*) local) == *((Journal*) remote)); |
968 | if ( equ ) { | 982 | if ( equ ) { |
969 | //qDebug("equal "); | 983 | //qDebug("equal "); |
970 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 984 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
971 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 985 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
972 | } | 986 | } |
973 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 987 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
974 | return 0; | 988 | return 0; |
975 | 989 | ||
976 | }//else //debug only | 990 | }//else //debug only |
977 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 991 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
978 | } | 992 | } |
979 | int result; | 993 | int result; |
980 | bool localIsNew; | 994 | bool localIsNew; |
981 | //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() ); | 995 | //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() ); |
982 | 996 | ||
983 | 997 | ||
984 | // ************************************************ | 998 | // ************************************************ |
985 | // ************************************************ | 999 | // ************************************************ |
986 | // ************************************************ | 1000 | // ************************************************ |
987 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1001 | // We may have that lastSync > remoteMod AND lastSync > localMod |
988 | // BUT remoteMod != localMod | 1002 | // BUT remoteMod != localMod |
989 | 1003 | ||
990 | 1004 | ||
991 | if ( full && mode < SYNC_PREF_NEWEST ) | 1005 | if ( full && mode < SYNC_PREF_NEWEST ) |
992 | mode = SYNC_PREF_ASK; | 1006 | mode = SYNC_PREF_ASK; |
993 | 1007 | ||
994 | switch( mode ) { | 1008 | switch( mode ) { |
995 | case SYNC_PREF_LOCAL: | 1009 | case SYNC_PREF_LOCAL: |
996 | if ( lastSync > remoteMod ) | 1010 | if ( lastSync > remoteMod ) |
997 | return 1; | 1011 | return 1; |
998 | if ( lastSync > localMod ) | 1012 | if ( lastSync > localMod ) |
999 | return 2; | 1013 | return 2; |
1000 | return 1; | 1014 | return 1; |
1001 | break; | 1015 | break; |
1002 | case SYNC_PREF_REMOTE: | 1016 | case SYNC_PREF_REMOTE: |
1003 | if ( lastSync > localMod ) | 1017 | if ( lastSync > localMod ) |
1004 | return 2; | 1018 | return 2; |
1005 | if ( lastSync > remoteMod ) | 1019 | if ( lastSync > remoteMod ) |
1006 | return 1; | 1020 | return 1; |
1007 | return 2; | 1021 | return 2; |
1008 | break; | 1022 | break; |
1009 | case SYNC_PREF_NEWEST: | 1023 | case SYNC_PREF_NEWEST: |
1010 | if ( localMod >= remoteMod ) | 1024 | if ( localMod >= remoteMod ) |
1011 | return 1; | 1025 | return 1; |
1012 | else | 1026 | else |
1013 | return 2; | 1027 | return 2; |
1014 | break; | 1028 | break; |
1015 | case SYNC_PREF_ASK: | 1029 | case SYNC_PREF_ASK: |
1016 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1030 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1017 | if ( lastSync > remoteMod && lastSync > localMod) | 1031 | if ( lastSync > remoteMod && lastSync > localMod) |
1018 | return 0; | 1032 | return 0; |
1019 | if ( lastSync > remoteMod ) | 1033 | if ( lastSync > remoteMod ) |
1020 | return 1; | 1034 | return 1; |
1021 | if ( lastSync > localMod ) | 1035 | if ( lastSync > localMod ) |
1022 | return 2; | 1036 | return 2; |
1023 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1037 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1024 | localIsNew = localMod >= remoteMod; | 1038 | localIsNew = localMod >= remoteMod; |
1025 | if ( localIsNew ) | 1039 | if ( localIsNew ) |
1026 | getEventViewerDialog()->setColorMode( 1 ); | 1040 | getEventViewerDialog()->setColorMode( 1 ); |
1027 | else | 1041 | else |
1028 | getEventViewerDialog()->setColorMode( 2 ); | 1042 | getEventViewerDialog()->setColorMode( 2 ); |
1029 | getEventViewerDialog()->setIncidence(local); | 1043 | getEventViewerDialog()->setIncidence(local); |
1030 | if ( localIsNew ) | 1044 | if ( localIsNew ) |
1031 | getEventViewerDialog()->setColorMode( 2 ); | 1045 | getEventViewerDialog()->setColorMode( 2 ); |
1032 | else | 1046 | else |
1033 | getEventViewerDialog()->setColorMode( 1 ); | 1047 | getEventViewerDialog()->setColorMode( 1 ); |
1034 | getEventViewerDialog()->addIncidence(remote); | 1048 | getEventViewerDialog()->addIncidence(remote); |
1035 | getEventViewerDialog()->setColorMode( 0 ); | 1049 | getEventViewerDialog()->setColorMode( 0 ); |
1036 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1050 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1037 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1051 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1038 | getEventViewerDialog()->showMe(); | 1052 | getEventViewerDialog()->showMe(); |
1039 | result = getEventViewerDialog()->executeS( localIsNew ); | 1053 | result = getEventViewerDialog()->executeS( localIsNew ); |
1040 | return result; | 1054 | return result; |
1041 | 1055 | ||
1042 | break; | 1056 | break; |
1043 | case SYNC_PREF_FORCE_LOCAL: | 1057 | case SYNC_PREF_FORCE_LOCAL: |
1044 | return 1; | 1058 | return 1; |
1045 | break; | 1059 | break; |
1046 | case SYNC_PREF_FORCE_REMOTE: | 1060 | case SYNC_PREF_FORCE_REMOTE: |
1047 | return 2; | 1061 | return 2; |
1048 | break; | 1062 | break; |
1049 | 1063 | ||
1050 | default: | 1064 | default: |
1051 | // SYNC_PREF_TAKE_BOTH not implemented | 1065 | // SYNC_PREF_TAKE_BOTH not implemented |
1052 | break; | 1066 | break; |
1053 | } | 1067 | } |
1054 | return 0; | 1068 | return 0; |
1055 | } | 1069 | } |
1056 | Event* CalendarView::getLastSyncEvent() | 1070 | Event* CalendarView::getLastSyncEvent() |
1057 | { | 1071 | { |
1058 | Event* lse; | 1072 | Event* lse; |
1059 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1073 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1060 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1074 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1061 | if (!lse) { | 1075 | if (!lse) { |
1062 | lse = new Event(); | 1076 | lse = new Event(); |
1063 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1077 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1064 | QString sum = ""; | 1078 | QString sum = ""; |
1065 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1079 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1066 | sum = "E: "; | 1080 | sum = "E: "; |
1067 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1081 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1068 | lse->setDtStart( mLastCalendarSync ); | 1082 | lse->setDtStart( mLastCalendarSync ); |
1069 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1083 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1070 | lse->setCategories( i18n("SyncEvent") ); | 1084 | lse->setCategories( i18n("SyncEvent") ); |
1071 | lse->setReadOnly( true ); | 1085 | lse->setReadOnly( true ); |
1072 | mCalendar->addEvent( lse ); | 1086 | mCalendar->addEvent( lse ); |
1073 | } | 1087 | } |
1074 | 1088 | ||
1075 | return lse; | 1089 | return lse; |
1076 | 1090 | ||
1077 | } | 1091 | } |
1078 | 1092 | ||
1079 | // we check, if the to delete event has a id for a profile | 1093 | // we check, if the to delete event has a id for a profile |
1080 | // if yes, we set this id in the profile to delete | 1094 | // if yes, we set this id in the profile to delete |
1081 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1095 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1082 | { | 1096 | { |
1083 | if ( lastSync.count() == 0 ) { | 1097 | if ( lastSync.count() == 0 ) { |
1084 | //qDebug(" lastSync.count() == 0"); | 1098 | //qDebug(" lastSync.count() == 0"); |
1085 | return; | 1099 | return; |
1086 | } | 1100 | } |
1087 | if ( toDelete->type() == "Journal" ) | 1101 | if ( toDelete->type() == "Journal" ) |
1088 | return; | 1102 | return; |
1089 | 1103 | ||
1090 | Event* eve = lastSync.first(); | 1104 | Event* eve = lastSync.first(); |
1091 | 1105 | ||
1092 | while ( eve ) { | 1106 | while ( eve ) { |
1093 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1107 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1094 | if ( !id.isEmpty() ) { | 1108 | if ( !id.isEmpty() ) { |
1095 | QString des = eve->description(); | 1109 | QString des = eve->description(); |
1096 | QString pref = "e"; | 1110 | QString pref = "e"; |
1097 | if ( toDelete->type() == "Todo" ) | 1111 | if ( toDelete->type() == "Todo" ) |
1098 | pref = "t"; | 1112 | pref = "t"; |
1099 | des += pref+ id + ","; | 1113 | des += pref+ id + ","; |
1100 | eve->setReadOnly( false ); | 1114 | eve->setReadOnly( false ); |
1101 | eve->setDescription( des ); | 1115 | eve->setDescription( des ); |
1102 | //qDebug("setdes %s ", des.latin1()); | 1116 | //qDebug("setdes %s ", des.latin1()); |
1103 | eve->setReadOnly( true ); | 1117 | eve->setReadOnly( true ); |
1104 | } | 1118 | } |
1105 | eve = lastSync.next(); | 1119 | eve = lastSync.next(); |
1106 | } | 1120 | } |
1107 | 1121 | ||
1108 | } | 1122 | } |
1109 | void CalendarView::checkExternalId( Incidence * inc ) | 1123 | void CalendarView::checkExternalId( Incidence * inc ) |
1110 | { | 1124 | { |
1111 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1125 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1112 | checkExternSyncEvent( lastSync, inc ); | 1126 | checkExternSyncEvent( lastSync, inc ); |
1113 | 1127 | ||
1114 | } | 1128 | } |
1115 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1129 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1116 | { | 1130 | { |
1117 | bool syncOK = true; | 1131 | bool syncOK = true; |
1118 | int addedEvent = 0; | 1132 | int addedEvent = 0; |
1119 | int addedEventR = 0; | 1133 | int addedEventR = 0; |
1120 | int deletedEventR = 0; | 1134 | int deletedEventR = 0; |
1121 | int deletedEventL = 0; | 1135 | int deletedEventL = 0; |
1122 | int changedLocal = 0; | 1136 | int changedLocal = 0; |
1123 | int changedRemote = 0; | 1137 | int changedRemote = 0; |
1124 | int filteredIN = 0; | 1138 | int filteredIN = 0; |
1125 | int filteredOUT = 0; | 1139 | int filteredOUT = 0; |
1126 | //QPtrList<Event> el = local->rawEvents(); | 1140 | //QPtrList<Event> el = local->rawEvents(); |
1127 | Event* eventR; | 1141 | Event* eventR; |
1128 | QString uid; | 1142 | QString uid; |
1129 | int take; | 1143 | int take; |
1130 | Event* eventL; | 1144 | Event* eventL; |
1131 | Event* eventRSync; | 1145 | Event* eventRSync; |
1132 | Event* eventLSync; | 1146 | Event* eventLSync; |
1133 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1147 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1134 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1148 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1135 | bool fullDateRange = false; | 1149 | bool fullDateRange = false; |
1136 | local->resetTempSyncStat(); | 1150 | local->resetTempSyncStat(); |
1137 | mLastCalendarSync = QDateTime::currentDateTime(); | 1151 | mLastCalendarSync = QDateTime::currentDateTime(); |
1138 | if ( mSyncManager->syncWithDesktop() ) { | 1152 | if ( mSyncManager->syncWithDesktop() ) { |
1139 | remote->resetPilotStat(1); | 1153 | remote->resetPilotStat(1); |
1140 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1154 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1141 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1155 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1142 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1156 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1143 | } else { | 1157 | } else { |
1144 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1158 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1145 | } | 1159 | } |
1146 | } | 1160 | } |
1147 | QDateTime modifiedCalendar = mLastCalendarSync; | 1161 | QDateTime modifiedCalendar = mLastCalendarSync; |
1148 | eventLSync = getLastSyncEvent(); | 1162 | eventLSync = getLastSyncEvent(); |
1149 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1163 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1150 | if ( eventR ) { | 1164 | if ( eventR ) { |
1151 | eventRSync = (Event*) eventR->clone(); | 1165 | eventRSync = (Event*) eventR->clone(); |
1152 | remote->deleteEvent(eventR ); | 1166 | remote->deleteEvent(eventR ); |
1153 | 1167 | ||
1154 | } else { | 1168 | } else { |
1155 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1169 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1156 | eventRSync = (Event*)eventLSync->clone(); | 1170 | eventRSync = (Event*)eventLSync->clone(); |
1157 | } else { | 1171 | } else { |
1158 | fullDateRange = true; | 1172 | fullDateRange = true; |
1159 | eventRSync = new Event(); | 1173 | eventRSync = new Event(); |
1160 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1174 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1161 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1175 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1162 | eventRSync->setDtStart( mLastCalendarSync ); | 1176 | eventRSync->setDtStart( mLastCalendarSync ); |
1163 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1177 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1164 | eventRSync->setCategories( i18n("SyncEvent") ); | 1178 | eventRSync->setCategories( i18n("SyncEvent") ); |
1165 | } | 1179 | } |
1166 | } | 1180 | } |
1167 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1181 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1168 | fullDateRange = true; | 1182 | fullDateRange = true; |
1169 | 1183 | ||
1170 | if ( ! fullDateRange ) { | 1184 | if ( ! fullDateRange ) { |
1171 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1185 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1172 | 1186 | ||
1173 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1187 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1174 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1188 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1175 | fullDateRange = true; | 1189 | fullDateRange = true; |
1176 | } | 1190 | } |
1177 | } | 1191 | } |
1178 | if ( mSyncManager->syncWithDesktop() ) { | 1192 | if ( mSyncManager->syncWithDesktop() ) { |
1179 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1193 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1180 | } | 1194 | } |
1181 | if ( fullDateRange ) | 1195 | if ( fullDateRange ) |
1182 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1196 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1183 | else | 1197 | else |
1184 | mLastCalendarSync = eventLSync->dtStart(); | 1198 | mLastCalendarSync = eventLSync->dtStart(); |
1185 | // for resyncing if own file has changed | 1199 | // for resyncing if own file has changed |
1186 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1200 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1187 | mLastCalendarSync = loadedFileVersion; | 1201 | mLastCalendarSync = loadedFileVersion; |
1188 | //qDebug("setting mLastCalendarSync "); | 1202 | //qDebug("setting mLastCalendarSync "); |
1189 | } | 1203 | } |
1190 | //qDebug("*************************** "); | 1204 | //qDebug("*************************** "); |
1191 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1205 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1192 | QPtrList<Incidence> er = remote->rawIncidences(); | 1206 | QPtrList<Incidence> er = remote->rawIncidences(); |
1193 | Incidence* inR = er.first(); | 1207 | Incidence* inR = er.first(); |
1194 | Incidence* inL; | 1208 | Incidence* inL; |
1195 | QProgressBar bar( er.count(),0 ); | 1209 | QProgressBar bar( er.count(),0 ); |
1196 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1210 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1197 | 1211 | ||
1198 | // ************** setting up filter ************* | 1212 | // ************** setting up filter ************* |
1199 | CalFilter *filterIN = 0; | 1213 | CalFilter *filterIN = 0; |
1200 | CalFilter *filterOUT = 0; | 1214 | CalFilter *filterOUT = 0; |
1201 | CalFilter *filter = mFilters.first(); | 1215 | CalFilter *filter = mFilters.first(); |
1202 | while(filter) { | 1216 | while(filter) { |
1203 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1217 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1204 | filterIN = filter; | 1218 | filterIN = filter; |
1205 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1219 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1206 | filterOUT = filter; | 1220 | filterOUT = filter; |
1207 | filter = mFilters.next(); | 1221 | filter = mFilters.next(); |
1208 | } | 1222 | } |
1209 | int w = 300; | 1223 | int w = 300; |
1210 | if ( QApplication::desktop()->width() < 320 ) | 1224 | if ( QApplication::desktop()->width() < 320 ) |
1211 | w = 220; | 1225 | w = 220; |
1212 | int h = bar.sizeHint().height() ; | 1226 | int h = bar.sizeHint().height() ; |
1213 | int dw = QApplication::desktop()->width(); | 1227 | int dw = QApplication::desktop()->width(); |
1214 | int dh = QApplication::desktop()->height(); | 1228 | int dh = QApplication::desktop()->height(); |
1215 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1229 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1216 | bar.show(); | 1230 | bar.show(); |
1217 | int modulo = (er.count()/10)+1; | 1231 | int modulo = (er.count()/10)+1; |
1218 | int incCounter = 0; | 1232 | int incCounter = 0; |
1219 | while ( inR ) { | 1233 | while ( inR ) { |
1220 | if ( ! bar.isVisible() ) | 1234 | if ( ! bar.isVisible() ) |
1221 | return false; | 1235 | return false; |
1222 | if ( incCounter % modulo == 0 ) | 1236 | if ( incCounter % modulo == 0 ) |
1223 | bar.setProgress( incCounter ); | 1237 | bar.setProgress( incCounter ); |
1224 | ++incCounter; | 1238 | ++incCounter; |
1225 | uid = inR->uid(); | 1239 | uid = inR->uid(); |
1226 | bool skipIncidence = false; | 1240 | bool skipIncidence = false; |
1227 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1241 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1228 | skipIncidence = true; | 1242 | skipIncidence = true; |
1229 | QString idS; | 1243 | QString idS; |
1230 | qApp->processEvents(); | 1244 | qApp->processEvents(); |
1231 | if ( !skipIncidence ) { | 1245 | if ( !skipIncidence ) { |
1232 | inL = local->incidence( uid ); | 1246 | inL = local->incidence( uid ); |
1233 | if ( inL ) { // maybe conflict - same uid in both calendars | 1247 | if ( inL ) { // maybe conflict - same uid in both calendars |
1234 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1248 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1235 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1249 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1236 | if ( take == 3 ) | 1250 | if ( take == 3 ) |
1237 | return false; | 1251 | return false; |
1238 | if ( take == 1 ) {// take local ********************** | 1252 | if ( take == 1 ) {// take local ********************** |
1239 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1253 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1240 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1254 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1241 | else | 1255 | else |
1242 | idS = inR->IDStr(); | 1256 | idS = inR->IDStr(); |
1243 | remote->deleteIncidence( inR ); | 1257 | remote->deleteIncidence( inR ); |
1244 | inR = inL->clone(); | 1258 | inR = inL->clone(); |
1245 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1259 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1246 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1260 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1247 | inR->setIDStr( idS ); | 1261 | inR->setIDStr( idS ); |
1248 | remote->addIncidence( inR ); | 1262 | remote->addIncidence( inR ); |
1249 | if ( mSyncManager->syncWithDesktop() ) | 1263 | if ( mSyncManager->syncWithDesktop() ) |
1250 | inR->setPilotId( 2 ); | 1264 | inR->setPilotId( 2 ); |
1251 | ++changedRemote; | 1265 | ++changedRemote; |
1252 | } else {// take remote ********************** | 1266 | } else {// take remote ********************** |
1253 | idS = inL->IDStr(); | 1267 | idS = inL->IDStr(); |
1254 | int pid = inL->pilotId(); | 1268 | int pid = inL->pilotId(); |
1255 | local->deleteIncidence( inL ); | 1269 | local->deleteIncidence( inL ); |
1256 | inL = inR->clone(); | 1270 | inL = inR->clone(); |
1257 | if ( mSyncManager->syncWithDesktop() ) | 1271 | if ( mSyncManager->syncWithDesktop() ) |
1258 | inL->setPilotId( pid ); | 1272 | inL->setPilotId( pid ); |
1259 | inL->setIDStr( idS ); | 1273 | inL->setIDStr( idS ); |
1260 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1274 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1261 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1275 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1262 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1276 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1263 | } | 1277 | } |
1264 | local->addIncidence( inL ); | 1278 | local->addIncidence( inL ); |
1265 | ++changedLocal; | 1279 | ++changedLocal; |
1266 | } | 1280 | } |
1267 | } | 1281 | } |
1268 | } else { // no conflict ********** add or delete remote | 1282 | } else { // no conflict ********** add or delete remote |
1269 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1283 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1270 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1284 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1271 | QString des = eventLSync->description(); | 1285 | QString des = eventLSync->description(); |
1272 | QString pref = "e"; | 1286 | QString pref = "e"; |
1273 | if ( inR->type() == "Todo" ) | 1287 | if ( inR->type() == "Todo" ) |
1274 | pref = "t"; | 1288 | pref = "t"; |
1275 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1289 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1276 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1290 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1277 | //remote->deleteIncidence( inR ); | 1291 | //remote->deleteIncidence( inR ); |
1278 | ++deletedEventR; | 1292 | ++deletedEventR; |
1279 | } else { | 1293 | } else { |
1280 | inR->setLastModified( modifiedCalendar ); | 1294 | inR->setLastModified( modifiedCalendar ); |
1281 | inL = inR->clone(); | 1295 | inL = inR->clone(); |
1282 | inL->setIDStr( ":" ); | 1296 | inL->setIDStr( ":" ); |
1283 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1297 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1284 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1298 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1285 | local->addIncidence( inL ); | 1299 | local->addIncidence( inL ); |
1286 | ++addedEvent; | 1300 | ++addedEvent; |
1287 | 1301 | ||
1288 | } | 1302 | } |
1289 | } else { | 1303 | } else { |
1290 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1304 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1291 | inR->setLastModified( modifiedCalendar ); | 1305 | inR->setLastModified( modifiedCalendar ); |
1292 | inL = inR->clone(); | 1306 | inL = inR->clone(); |
1293 | inL->setIDStr( ":" ); | 1307 | inL->setIDStr( ":" ); |
1294 | local->addIncidence( inL ); | 1308 | local->addIncidence( inL ); |
1295 | ++addedEvent; | 1309 | ++addedEvent; |
1296 | 1310 | ||
1297 | } else { | 1311 | } else { |
1298 | checkExternSyncEvent(eventRSyncSharp, inR); | 1312 | checkExternSyncEvent(eventRSyncSharp, inR); |
1299 | remote->deleteIncidence( inR ); | 1313 | remote->deleteIncidence( inR ); |
1300 | ++deletedEventR; | 1314 | ++deletedEventR; |
1301 | } | 1315 | } |
1302 | } | 1316 | } |
1303 | } else { | 1317 | } else { |
1304 | ++filteredIN; | 1318 | ++filteredIN; |
1305 | } | 1319 | } |
1306 | } | 1320 | } |
1307 | } | 1321 | } |
1308 | inR = er.next(); | 1322 | inR = er.next(); |
1309 | } | 1323 | } |
1310 | QPtrList<Incidence> el = local->rawIncidences(); | 1324 | QPtrList<Incidence> el = local->rawIncidences(); |
1311 | inL = el.first(); | 1325 | inL = el.first(); |
1312 | modulo = (el.count()/10)+1; | 1326 | modulo = (el.count()/10)+1; |
1313 | bar.setCaption (i18n("Add / remove events") ); | 1327 | bar.setCaption (i18n("Add / remove events") ); |
1314 | bar.setTotalSteps ( el.count() ) ; | 1328 | bar.setTotalSteps ( el.count() ) ; |
1315 | bar.show(); | 1329 | bar.show(); |
1316 | incCounter = 0; | 1330 | incCounter = 0; |
1317 | 1331 | ||
1318 | while ( inL ) { | 1332 | while ( inL ) { |
1319 | 1333 | ||
1320 | qApp->processEvents(); | 1334 | qApp->processEvents(); |
1321 | if ( ! bar.isVisible() ) | 1335 | if ( ! bar.isVisible() ) |
1322 | return false; | 1336 | return false; |
1323 | if ( incCounter % modulo == 0 ) | 1337 | if ( incCounter % modulo == 0 ) |
1324 | bar.setProgress( incCounter ); | 1338 | bar.setProgress( incCounter ); |
1325 | ++incCounter; | 1339 | ++incCounter; |
1326 | uid = inL->uid(); | 1340 | uid = inL->uid(); |
1327 | bool skipIncidence = false; | 1341 | bool skipIncidence = false; |
1328 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1342 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1329 | skipIncidence = true; | 1343 | skipIncidence = true; |
1330 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1344 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1331 | skipIncidence = true; | 1345 | skipIncidence = true; |
1332 | if ( !skipIncidence ) { | 1346 | if ( !skipIncidence ) { |
1333 | inR = remote->incidence( uid ); | 1347 | inR = remote->incidence( uid ); |
1334 | if ( ! inR ) { | 1348 | if ( ! inR ) { |
1335 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1349 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1336 | // no conflict ********** add or delete local | 1350 | // no conflict ********** add or delete local |
1337 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1351 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1338 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1352 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1339 | checkExternSyncEvent(eventLSyncSharp, inL); | 1353 | checkExternSyncEvent(eventLSyncSharp, inL); |
1340 | local->deleteIncidence( inL ); | 1354 | local->deleteIncidence( inL ); |
1341 | ++deletedEventL; | 1355 | ++deletedEventL; |
1342 | } else { | 1356 | } else { |
1343 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1357 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1344 | inL->removeID(mCurrentSyncDevice ); | 1358 | inL->removeID(mCurrentSyncDevice ); |
1345 | ++addedEventR; | 1359 | ++addedEventR; |
1346 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1360 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1347 | inL->setLastModified( modifiedCalendar ); | 1361 | inL->setLastModified( modifiedCalendar ); |
1348 | inR = inL->clone(); | 1362 | inR = inL->clone(); |
1349 | inR->setIDStr( ":" ); | 1363 | inR->setIDStr( ":" ); |
1350 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1364 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1351 | remote->addIncidence( inR ); | 1365 | remote->addIncidence( inR ); |
1352 | } | 1366 | } |
1353 | } | 1367 | } |
1354 | } else { | 1368 | } else { |
1355 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1369 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1356 | checkExternSyncEvent(eventLSyncSharp, inL); | 1370 | checkExternSyncEvent(eventLSyncSharp, inL); |
1357 | local->deleteIncidence( inL ); | 1371 | local->deleteIncidence( inL ); |
1358 | ++deletedEventL; | 1372 | ++deletedEventL; |
1359 | } else { | 1373 | } else { |
1360 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1374 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1361 | ++addedEventR; | 1375 | ++addedEventR; |
1362 | inL->setLastModified( modifiedCalendar ); | 1376 | inL->setLastModified( modifiedCalendar ); |
1363 | inR = inL->clone(); | 1377 | inR = inL->clone(); |
1364 | inR->setIDStr( ":" ); | 1378 | inR->setIDStr( ":" ); |
1365 | remote->addIncidence( inR ); | 1379 | remote->addIncidence( inR ); |
1366 | } | 1380 | } |
1367 | } | 1381 | } |
1368 | } | 1382 | } |
1369 | } else { | 1383 | } else { |
1370 | ++filteredOUT; | 1384 | ++filteredOUT; |
1371 | } | 1385 | } |
1372 | } | 1386 | } |
1373 | } | 1387 | } |
1374 | inL = el.next(); | 1388 | inL = el.next(); |
1375 | } | 1389 | } |
1376 | int delFut = 0; | 1390 | int delFut = 0; |
1377 | int remRem = 0; | 1391 | int remRem = 0; |
1378 | if ( mSyncManager->mWriteBackInFuture ) { | 1392 | if ( mSyncManager->mWriteBackInFuture ) { |
1379 | er = remote->rawIncidences(); | 1393 | er = remote->rawIncidences(); |
1380 | remRem = er.count(); | 1394 | remRem = er.count(); |
1381 | inR = er.first(); | 1395 | inR = er.first(); |
1382 | QDateTime dt; | 1396 | QDateTime dt; |
1383 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1397 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1384 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1398 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1385 | while ( inR ) { | 1399 | while ( inR ) { |
1386 | if ( inR->type() == "Todo" ) { | 1400 | if ( inR->type() == "Todo" ) { |
1387 | Todo * t = (Todo*)inR; | 1401 | Todo * t = (Todo*)inR; |
1388 | if ( t->hasDueDate() ) | 1402 | if ( t->hasDueDate() ) |
1389 | dt = t->dtDue(); | 1403 | dt = t->dtDue(); |
1390 | else | 1404 | else |
1391 | dt = cur.addSecs( 62 ); | 1405 | dt = cur.addSecs( 62 ); |
1392 | } | 1406 | } |
1393 | else if (inR->type() == "Event" ) { | 1407 | else if (inR->type() == "Event" ) { |
1394 | bool ok; | 1408 | bool ok; |
1395 | dt = inR->getNextOccurence( cur, &ok ); | 1409 | dt = inR->getNextOccurence( cur, &ok ); |
1396 | if ( !ok ) | 1410 | if ( !ok ) |
1397 | dt = cur.addSecs( -62 ); | 1411 | dt = cur.addSecs( -62 ); |
1398 | } | 1412 | } |
1399 | else | 1413 | else |
1400 | dt = inR->dtStart(); | 1414 | dt = inR->dtStart(); |
1401 | if ( dt < cur || dt > end ) { | 1415 | if ( dt < cur || dt > end ) { |
1402 | remote->deleteIncidence( inR ); | 1416 | remote->deleteIncidence( inR ); |
1403 | ++delFut; | 1417 | ++delFut; |
1404 | } | 1418 | } |
1405 | inR = er.next(); | 1419 | inR = er.next(); |
1406 | } | 1420 | } |
1407 | } | 1421 | } |
1408 | bar.hide(); | 1422 | bar.hide(); |
1409 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1423 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1410 | eventLSync->setReadOnly( false ); | 1424 | eventLSync->setReadOnly( false ); |
1411 | eventLSync->setDtStart( mLastCalendarSync ); | 1425 | eventLSync->setDtStart( mLastCalendarSync ); |
1412 | eventRSync->setDtStart( mLastCalendarSync ); | 1426 | eventRSync->setDtStart( mLastCalendarSync ); |
1413 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1427 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1414 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1428 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1415 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1429 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1416 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1430 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1417 | eventLSync->setReadOnly( true ); | 1431 | eventLSync->setReadOnly( true ); |
1418 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1432 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1419 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1433 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1420 | remote->addEvent( eventRSync ); | 1434 | remote->addEvent( eventRSync ); |
1421 | else | 1435 | else |
1422 | delete eventRSync; | 1436 | delete eventRSync; |
1423 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1437 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1424 | QString mes; | 1438 | QString mes; |
1425 | 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 ); | 1439 | 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 ); |
1426 | QString delmess; | 1440 | QString delmess; |
1427 | if ( delFut ) { | 1441 | if ( delFut ) { |
1428 | 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); | 1442 | 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); |
1429 | mes += delmess; | 1443 | mes += delmess; |
1430 | } | 1444 | } |
1431 | mes = i18n("Local calendar changed!\n") +mes; | 1445 | mes = i18n("Local calendar changed!\n") +mes; |
1432 | mCalendar->checkAlarmForIncidence( 0, true ); | 1446 | mCalendar->checkAlarmForIncidence( 0, true ); |
1433 | qDebug( mes ); | 1447 | qDebug( mes ); |
1434 | if ( mSyncManager->mShowSyncSummary ) { | 1448 | if ( mSyncManager->mShowSyncSummary ) { |
1435 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1449 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1436 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1450 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1437 | qDebug("KO: WB cancelled "); | 1451 | qDebug("KO: WB cancelled "); |
1438 | mSyncManager->mWriteBackFile = false; | 1452 | mSyncManager->mWriteBackFile = false; |
1439 | return syncOK; | 1453 | return syncOK; |
1440 | } | 1454 | } |
1441 | } | 1455 | } |
1442 | return syncOK; | 1456 | return syncOK; |
1443 | } | 1457 | } |
1444 | 1458 | ||
1445 | void CalendarView::setSyncDevice( QString s ) | 1459 | void CalendarView::setSyncDevice( QString s ) |
1446 | { | 1460 | { |
1447 | mCurrentSyncDevice= s; | 1461 | mCurrentSyncDevice= s; |
1448 | } | 1462 | } |
1449 | void CalendarView::setSyncName( QString s ) | 1463 | void CalendarView::setSyncName( QString s ) |
1450 | { | 1464 | { |
1451 | mCurrentSyncName= s; | 1465 | mCurrentSyncName= s; |
1452 | } | 1466 | } |
1453 | bool CalendarView::syncCalendar(QString filename, int mode) | 1467 | bool CalendarView::syncCalendar(QString filename, int mode) |
1454 | { | 1468 | { |
1455 | //qDebug("syncCalendar %s ", filename.latin1()); | 1469 | //qDebug("syncCalendar %s ", filename.latin1()); |
1456 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1470 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1457 | CalendarLocal* calendar = new CalendarLocal(); | 1471 | CalendarLocal* calendar = new CalendarLocal(); |
1458 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1472 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1459 | FileStorage* storage = new FileStorage( calendar ); | 1473 | FileStorage* storage = new FileStorage( calendar ); |
1460 | bool syncOK = false; | 1474 | bool syncOK = false; |
1461 | storage->setFileName( filename ); | 1475 | storage->setFileName( filename ); |
1462 | // qDebug("loading ... "); | 1476 | // qDebug("loading ... "); |
1463 | if ( storage->load() ) { | 1477 | if ( storage->load() ) { |
1464 | getEventViewerDialog()->setSyncMode( true ); | 1478 | getEventViewerDialog()->setSyncMode( true ); |
1465 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1479 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1466 | getEventViewerDialog()->setSyncMode( false ); | 1480 | getEventViewerDialog()->setSyncMode( false ); |
1467 | if ( syncOK ) { | 1481 | if ( syncOK ) { |
1468 | if ( mSyncManager->mWriteBackFile ) | 1482 | if ( mSyncManager->mWriteBackFile ) |
1469 | { | 1483 | { |
1470 | storage->setSaveFormat( new ICalFormat() ); | 1484 | storage->setSaveFormat( new ICalFormat() ); |
1471 | storage->save(); | 1485 | storage->save(); |
1472 | } | 1486 | } |
1473 | } | 1487 | } |
1474 | setModified( true ); | 1488 | setModified( true ); |
1475 | } | 1489 | } |
1476 | delete storage; | 1490 | delete storage; |
1477 | delete calendar; | 1491 | delete calendar; |
1478 | if ( syncOK ) | 1492 | if ( syncOK ) |
1479 | updateView(); | 1493 | updateView(); |
1480 | return syncOK; | 1494 | return syncOK; |
1481 | } | 1495 | } |
1482 | 1496 | ||
1483 | void CalendarView::syncExternal( int mode ) | 1497 | void CalendarView::syncExternal( int mode ) |
1484 | { | 1498 | { |
1485 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1499 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1486 | 1500 | ||
1487 | qApp->processEvents(); | 1501 | qApp->processEvents(); |
1488 | CalendarLocal* calendar = new CalendarLocal(); | 1502 | CalendarLocal* calendar = new CalendarLocal(); |
1489 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1503 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1490 | bool syncOK = false; | 1504 | bool syncOK = false; |
1491 | bool loadSuccess = false; | 1505 | bool loadSuccess = false; |
1492 | PhoneFormat* phoneFormat = 0; | 1506 | PhoneFormat* phoneFormat = 0; |
1493 | emit tempDisableBR(true); | 1507 | emit tempDisableBR(true); |
1494 | #ifndef DESKTOP_VERSION | 1508 | #ifndef DESKTOP_VERSION |
1495 | SharpFormat* sharpFormat = 0; | 1509 | SharpFormat* sharpFormat = 0; |
1496 | if ( mode == 0 ) { // sharp | 1510 | if ( mode == 0 ) { // sharp |
1497 | sharpFormat = new SharpFormat () ; | 1511 | sharpFormat = new SharpFormat () ; |
1498 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1512 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1499 | 1513 | ||
1500 | } else | 1514 | } else |
1501 | #endif | 1515 | #endif |
1502 | if ( mode == 1 ) { // phone | 1516 | if ( mode == 1 ) { // phone |
1503 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1517 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1504 | mSyncManager->mPhoneDevice, | 1518 | mSyncManager->mPhoneDevice, |
1505 | mSyncManager->mPhoneConnection, | 1519 | mSyncManager->mPhoneConnection, |
1506 | mSyncManager->mPhoneModel); | 1520 | mSyncManager->mPhoneModel); |
1507 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1521 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1508 | 1522 | ||
1509 | } else { | 1523 | } else { |
1510 | emit tempDisableBR(false); | 1524 | emit tempDisableBR(false); |
1511 | return; | 1525 | return; |
1512 | } | 1526 | } |
1513 | if ( loadSuccess ) { | 1527 | if ( loadSuccess ) { |
1514 | getEventViewerDialog()->setSyncMode( true ); | 1528 | getEventViewerDialog()->setSyncMode( true ); |
1515 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1529 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1516 | getEventViewerDialog()->setSyncMode( false ); | 1530 | getEventViewerDialog()->setSyncMode( false ); |
1517 | qApp->processEvents(); | 1531 | qApp->processEvents(); |
1518 | if ( syncOK ) { | 1532 | if ( syncOK ) { |
1519 | if ( mSyncManager->mWriteBackFile ) | 1533 | if ( mSyncManager->mWriteBackFile ) |
1520 | { | 1534 | { |
1521 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1535 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1522 | Incidence* inc = iL.first(); | 1536 | Incidence* inc = iL.first(); |
1523 | if ( phoneFormat ) { | 1537 | if ( phoneFormat ) { |
1524 | while ( inc ) { | 1538 | while ( inc ) { |
1525 | inc->removeID(mCurrentSyncDevice); | 1539 | inc->removeID(mCurrentSyncDevice); |
1526 | inc = iL.next(); | 1540 | inc = iL.next(); |
1527 | } | 1541 | } |
1528 | } | 1542 | } |
1529 | #ifndef DESKTOP_VERSION | 1543 | #ifndef DESKTOP_VERSION |
1530 | if ( sharpFormat ) | 1544 | if ( sharpFormat ) |
1531 | sharpFormat->save(calendar); | 1545 | sharpFormat->save(calendar); |
1532 | #endif | 1546 | #endif |
1533 | if ( phoneFormat ) | 1547 | if ( phoneFormat ) |
1534 | phoneFormat->save(calendar); | 1548 | phoneFormat->save(calendar); |
1535 | iL = calendar->rawIncidences(); | 1549 | iL = calendar->rawIncidences(); |
1536 | inc = iL.first(); | 1550 | inc = iL.first(); |
1537 | Incidence* loc; | 1551 | Incidence* loc; |
1538 | while ( inc ) { | 1552 | while ( inc ) { |
1539 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1553 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1540 | loc = mCalendar->incidence(inc->uid() ); | 1554 | loc = mCalendar->incidence(inc->uid() ); |
1541 | if ( loc ) { | 1555 | if ( loc ) { |
1542 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1556 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1543 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1557 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1544 | } | 1558 | } |
1545 | } | 1559 | } |
1546 | inc = iL.next(); | 1560 | inc = iL.next(); |
1547 | } | 1561 | } |
1548 | Incidence* lse = getLastSyncEvent(); | 1562 | Incidence* lse = getLastSyncEvent(); |
1549 | if ( lse ) { | 1563 | if ( lse ) { |
1550 | lse->setReadOnly( false ); | 1564 | lse->setReadOnly( false ); |
1551 | lse->setDescription( "" ); | 1565 | lse->setDescription( "" ); |
1552 | lse->setReadOnly( true ); | 1566 | lse->setReadOnly( true ); |
1553 | } | 1567 | } |
1554 | } | 1568 | } |
1555 | } else { | 1569 | } else { |
1556 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1570 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1557 | } | 1571 | } |
1558 | setModified( true ); | 1572 | setModified( true ); |
1559 | } else { | 1573 | } else { |
1560 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1574 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1561 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1575 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1562 | question, i18n("Ok")) ; | 1576 | question, i18n("Ok")) ; |
1563 | 1577 | ||
1564 | } | 1578 | } |
1565 | delete calendar; | 1579 | delete calendar; |
1566 | updateView(); | 1580 | updateView(); |
1567 | emit tempDisableBR(false); | 1581 | emit tempDisableBR(false); |
1568 | return ;//syncOK; | 1582 | return ;//syncOK; |
1569 | 1583 | ||
1570 | } | 1584 | } |
1571 | 1585 | ||
1572 | bool CalendarView::importBday() | 1586 | bool CalendarView::importBday() |
1573 | { | 1587 | { |
1574 | #ifndef KORG_NOKABC | 1588 | #ifndef KORG_NOKABC |
1575 | 1589 | ||
1576 | #ifdef DESKTOP_VERSION | 1590 | #ifdef DESKTOP_VERSION |
1577 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1591 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1578 | KABC::AddressBook::Iterator it; | 1592 | KABC::AddressBook::Iterator it; |
1579 | int count = 0; | 1593 | int count = 0; |
1580 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1594 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1581 | ++count; | 1595 | ++count; |
1582 | } | 1596 | } |
1583 | QProgressBar bar(count,0 ); | 1597 | QProgressBar bar(count,0 ); |
1584 | int w = 300; | 1598 | int w = 300; |
1585 | if ( QApplication::desktop()->width() < 320 ) | 1599 | if ( QApplication::desktop()->width() < 320 ) |
1586 | w = 220; | 1600 | w = 220; |
1587 | int h = bar.sizeHint().height() ; | 1601 | int h = bar.sizeHint().height() ; |
1588 | int dw = QApplication::desktop()->width(); | 1602 | int dw = QApplication::desktop()->width(); |
1589 | int dh = QApplication::desktop()->height(); | 1603 | int dh = QApplication::desktop()->height(); |
1590 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1604 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1591 | bar.show(); | 1605 | bar.show(); |
1592 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1606 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1593 | qApp->processEvents(); | 1607 | qApp->processEvents(); |
1594 | count = 0; | 1608 | count = 0; |
1595 | int addCount = 0; | 1609 | int addCount = 0; |
1596 | KCal::Attendee* a = 0; | 1610 | KCal::Attendee* a = 0; |
1597 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1611 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1598 | if ( ! bar.isVisible() ) | 1612 | if ( ! bar.isVisible() ) |
1599 | return false; | 1613 | return false; |
1600 | bar.setProgress( count++ ); | 1614 | bar.setProgress( count++ ); |
1601 | qApp->processEvents(); | 1615 | qApp->processEvents(); |
1602 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1616 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1603 | if ( (*it).birthday().date().isValid() ){ | 1617 | if ( (*it).birthday().date().isValid() ){ |
1604 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1618 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1605 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1619 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1606 | ++addCount; | 1620 | ++addCount; |
1607 | } | 1621 | } |
1608 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1622 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1609 | if ( anni.isValid() ){ | 1623 | if ( anni.isValid() ){ |
1610 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1624 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1611 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1625 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1612 | ++addCount; | 1626 | ++addCount; |
1613 | } | 1627 | } |
1614 | } | 1628 | } |
1615 | updateView(); | 1629 | updateView(); |
1616 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1630 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1617 | #else //DESKTOP_VERSION | 1631 | #else //DESKTOP_VERSION |
1618 | 1632 | ||
1619 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1633 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1620 | // the result should now arrive through method insertBirthdays | 1634 | // the result should now arrive through method insertBirthdays |
1621 | 1635 | ||
1622 | #endif //DESKTOP_VERSION | 1636 | #endif //DESKTOP_VERSION |
1623 | 1637 | ||
1624 | #endif //KORG_NOKABC | 1638 | #endif //KORG_NOKABC |
1625 | 1639 | ||
1626 | 1640 | ||
1627 | return true; | 1641 | return true; |
1628 | } | 1642 | } |
1629 | 1643 | ||
1630 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1644 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1631 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1645 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1632 | const QStringList& anniversaryList, const QStringList& realNameList, | 1646 | const QStringList& anniversaryList, const QStringList& realNameList, |
1633 | const QStringList& emailList, const QStringList& assembledNameList, | 1647 | const QStringList& emailList, const QStringList& assembledNameList, |
1634 | const QStringList& uidList) | 1648 | const QStringList& uidList) |
1635 | { | 1649 | { |
1636 | //qDebug("KO::CalendarView::insertBirthdays"); | 1650 | //qDebug("KO::CalendarView::insertBirthdays"); |
1637 | if (uid == this->name()) | 1651 | if (uid == this->name()) |
1638 | { | 1652 | { |
1639 | int count = birthdayList.count(); | 1653 | int count = birthdayList.count(); |
1640 | int addCount = 0; | 1654 | int addCount = 0; |
1641 | KCal::Attendee* a = 0; | 1655 | KCal::Attendee* a = 0; |
1642 | 1656 | ||
1643 | //qDebug("CalView 1 %i", count); | 1657 | //qDebug("CalView 1 %i", count); |
1644 | 1658 | ||
1645 | QProgressBar bar(count,0 ); | 1659 | QProgressBar bar(count,0 ); |
1646 | int w = 300; | 1660 | int w = 300; |
1647 | if ( QApplication::desktop()->width() < 320 ) | 1661 | if ( QApplication::desktop()->width() < 320 ) |
1648 | w = 220; | 1662 | w = 220; |
1649 | int h = bar.sizeHint().height() ; | 1663 | int h = bar.sizeHint().height() ; |
1650 | int dw = QApplication::desktop()->width(); | 1664 | int dw = QApplication::desktop()->width(); |
1651 | int dh = QApplication::desktop()->height(); | 1665 | int dh = QApplication::desktop()->height(); |
1652 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1666 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1653 | bar.show(); | 1667 | bar.show(); |
1654 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1668 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1655 | qApp->processEvents(); | 1669 | qApp->processEvents(); |
1656 | 1670 | ||
1657 | QDate birthday; | 1671 | QDate birthday; |
1658 | QDate anniversary; | 1672 | QDate anniversary; |
1659 | QString realName; | 1673 | QString realName; |
1660 | QString email; | 1674 | QString email; |
1661 | QString assembledName; | 1675 | QString assembledName; |
1662 | QString uid; | 1676 | QString uid; |
1663 | bool ok = true; | 1677 | bool ok = true; |
1664 | for ( int i = 0; i < count; i++) | 1678 | for ( int i = 0; i < count; i++) |
1665 | { | 1679 | { |
1666 | if ( ! bar.isVisible() ) | 1680 | if ( ! bar.isVisible() ) |
1667 | return; | 1681 | return; |
1668 | bar.setProgress( i ); | 1682 | bar.setProgress( i ); |
1669 | qApp->processEvents(); | 1683 | qApp->processEvents(); |
1670 | 1684 | ||
1671 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1685 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1672 | if (!ok) { | 1686 | if (!ok) { |
1673 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1687 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1674 | } | 1688 | } |
1675 | 1689 | ||
1676 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1690 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1677 | if (!ok) { | 1691 | if (!ok) { |
1678 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1692 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1679 | } | 1693 | } |
1680 | realName = realNameList[i]; | 1694 | realName = realNameList[i]; |
1681 | email = emailList[i]; | 1695 | email = emailList[i]; |
1682 | assembledName = assembledNameList[i]; | 1696 | assembledName = assembledNameList[i]; |
1683 | uid = uidList[i]; | 1697 | uid = uidList[i]; |
1684 | //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() ); | 1698 | //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() ); |
1685 | 1699 | ||
1686 | if ( birthday.isValid() ){ | 1700 | if ( birthday.isValid() ){ |
1687 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1701 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1688 | KCal::Attendee::ReqParticipant,uid) ; | 1702 | KCal::Attendee::ReqParticipant,uid) ; |
1689 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1703 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1690 | ++addCount; | 1704 | ++addCount; |
1691 | } | 1705 | } |
1692 | 1706 | ||
1693 | if ( anniversary.isValid() ){ | 1707 | if ( anniversary.isValid() ){ |
1694 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1708 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1695 | KCal::Attendee::ReqParticipant,uid) ; | 1709 | KCal::Attendee::ReqParticipant,uid) ; |
1696 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1710 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1697 | ++addCount; | 1711 | ++addCount; |
1698 | } | 1712 | } |
1699 | } | 1713 | } |
1700 | 1714 | ||
1701 | updateView(); | 1715 | updateView(); |
1702 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1716 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1703 | 1717 | ||
1704 | } | 1718 | } |
1705 | 1719 | ||
1706 | } | 1720 | } |
1707 | 1721 | ||
1708 | 1722 | ||
1709 | 1723 | ||
1710 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1724 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1711 | { | 1725 | { |
1712 | //qDebug("addAnni "); | 1726 | //qDebug("addAnni "); |
1713 | Event * ev = new Event(); | 1727 | Event * ev = new Event(); |
1714 | ev->setOrganizer(KOPrefs::instance()->email()); | 1728 | ev->setOrganizer(KOPrefs::instance()->email()); |
1715 | if ( a ) { | 1729 | if ( a ) { |
1716 | ev->addAttendee( a ); | 1730 | ev->addAttendee( a ); |
1717 | } | 1731 | } |
1718 | QString kind; | 1732 | QString kind; |
1719 | if ( birthday ) { | 1733 | if ( birthday ) { |
1720 | kind = i18n( "Birthday" ); | 1734 | kind = i18n( "Birthday" ); |
1721 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1735 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1722 | } | 1736 | } |
1723 | else { | 1737 | else { |
1724 | kind = i18n( "Anniversary" ); | 1738 | kind = i18n( "Anniversary" ); |
1725 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1739 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1726 | } | 1740 | } |
1727 | ev->setCategories( kind ); | 1741 | ev->setCategories( kind ); |
1728 | ev->setDtStart( QDateTime(date) ); | 1742 | ev->setDtStart( QDateTime(date) ); |
1729 | ev->setDtEnd( QDateTime(date) ); | 1743 | ev->setDtEnd( QDateTime(date) ); |
1730 | ev->setFloats( true ); | 1744 | ev->setFloats( true ); |
1731 | Recurrence * rec = ev->recurrence(); | 1745 | Recurrence * rec = ev->recurrence(); |
1732 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1746 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1733 | rec->addYearlyNum( date.month() ); | 1747 | rec->addYearlyNum( date.month() ); |
1734 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1748 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1735 | delete ev; | 1749 | delete ev; |
1736 | return false; | 1750 | return false; |
1737 | } | 1751 | } |
1738 | return true; | 1752 | return true; |
1739 | 1753 | ||
1740 | } | 1754 | } |
1741 | bool CalendarView::importQtopia( const QString &categories, | 1755 | bool CalendarView::importQtopia( const QString &categories, |
1742 | const QString &datebook, | 1756 | const QString &datebook, |
1743 | const QString &todolist ) | 1757 | const QString &todolist ) |
1744 | { | 1758 | { |
1745 | 1759 | ||
1746 | QtopiaFormat qtopiaFormat; | 1760 | QtopiaFormat qtopiaFormat; |
1747 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1761 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1748 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1762 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1749 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1763 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1750 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1764 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1751 | 1765 | ||
1752 | updateView(); | 1766 | updateView(); |
1753 | return true; | 1767 | return true; |
1754 | 1768 | ||
1755 | #if 0 | 1769 | #if 0 |
1756 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1770 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1757 | mCurrentSyncDevice = "qtopia-XML"; | 1771 | mCurrentSyncDevice = "qtopia-XML"; |
1758 | if ( mSyncManager->mAskForPreferences ) | 1772 | if ( mSyncManager->mAskForPreferences ) |
1759 | edit_sync_options(); | 1773 | edit_sync_options(); |
1760 | qApp->processEvents(); | 1774 | qApp->processEvents(); |
1761 | CalendarLocal* calendar = new CalendarLocal(); | 1775 | CalendarLocal* calendar = new CalendarLocal(); |
1762 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1776 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1763 | bool syncOK = false; | 1777 | bool syncOK = false; |
1764 | QtopiaFormat qtopiaFormat; | 1778 | QtopiaFormat qtopiaFormat; |
1765 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1779 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1766 | bool loadOk = true; | 1780 | bool loadOk = true; |
1767 | if ( !categories.isEmpty() ) | 1781 | if ( !categories.isEmpty() ) |
1768 | loadOk = qtopiaFormat.load( calendar, categories ); | 1782 | loadOk = qtopiaFormat.load( calendar, categories ); |
1769 | if ( loadOk && !datebook.isEmpty() ) | 1783 | if ( loadOk && !datebook.isEmpty() ) |
1770 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1784 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1771 | if ( loadOk && !todolist.isEmpty() ) | 1785 | if ( loadOk && !todolist.isEmpty() ) |
1772 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1786 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1773 | 1787 | ||
1774 | if ( loadOk ) { | 1788 | if ( loadOk ) { |
1775 | getEventViewerDialog()->setSyncMode( true ); | 1789 | getEventViewerDialog()->setSyncMode( true ); |
1776 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1790 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1777 | getEventViewerDialog()->setSyncMode( false ); | 1791 | getEventViewerDialog()->setSyncMode( false ); |
1778 | qApp->processEvents(); | 1792 | qApp->processEvents(); |
1779 | if ( syncOK ) { | 1793 | if ( syncOK ) { |
1780 | if ( mSyncManager->mWriteBackFile ) | 1794 | if ( mSyncManager->mWriteBackFile ) |
1781 | { | 1795 | { |
1782 | // write back XML file | 1796 | // write back XML file |
1783 | 1797 | ||
1784 | } | 1798 | } |
1785 | setModified( true ); | 1799 | setModified( true ); |
1786 | } | 1800 | } |
1787 | } else { | 1801 | } else { |
1788 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1802 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1789 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1803 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1790 | question, i18n("Ok")) ; | 1804 | question, i18n("Ok")) ; |
1791 | } | 1805 | } |
1792 | delete calendar; | 1806 | delete calendar; |
1793 | updateView(); | 1807 | updateView(); |
1794 | return syncOK; | 1808 | return syncOK; |
1795 | 1809 | ||
1796 | 1810 | ||
1797 | #endif | 1811 | #endif |
1798 | 1812 | ||
1799 | } | 1813 | } |
1800 | 1814 | ||
1801 | void CalendarView::setSyncEventsReadOnly() | 1815 | void CalendarView::setSyncEventsReadOnly() |
1802 | { | 1816 | { |
1803 | Event * ev; | 1817 | Event * ev; |
1804 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1818 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1805 | ev = eL.first(); | 1819 | ev = eL.first(); |
1806 | while ( ev ) { | 1820 | while ( ev ) { |
1807 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1821 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1808 | ev->setReadOnly( true ); | 1822 | ev->setReadOnly( true ); |
1809 | ev = eL.next(); | 1823 | ev = eL.next(); |
1810 | } | 1824 | } |
1811 | } | 1825 | } |
1812 | bool CalendarView::openCalendar(QString filename, bool merge) | 1826 | bool CalendarView::openCalendar(QString filename, bool merge) |
1813 | { | 1827 | { |
1814 | 1828 | ||
1815 | if (filename.isEmpty()) { | 1829 | if (filename.isEmpty()) { |
1816 | return false; | 1830 | return false; |
1817 | } | 1831 | } |
1818 | 1832 | ||
1819 | if (!QFile::exists(filename)) { | 1833 | if (!QFile::exists(filename)) { |
1820 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1834 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1821 | return false; | 1835 | return false; |
1822 | } | 1836 | } |
1823 | 1837 | ||
1824 | globalFlagBlockAgenda = 1; | 1838 | globalFlagBlockAgenda = 1; |
1825 | if (!merge) { | 1839 | if (!merge) { |
1826 | mTodoList->clearList(); | 1840 | mTodoList->clearList(); |
1827 | mViewManager->setDocumentId( filename ); | 1841 | mViewManager->setDocumentId( filename ); |
1828 | mCalendar->close(); | 1842 | mCalendar->close(); |
1829 | } | 1843 | } |
1830 | mStorage->setFileName( filename ); | 1844 | mStorage->setFileName( filename ); |
1831 | 1845 | ||
1832 | if ( mStorage->load() ) { | 1846 | if ( mStorage->load() ) { |
1833 | if ( merge ) ;//setModified( true ); | 1847 | if ( merge ) ;//setModified( true ); |
1834 | else { | 1848 | else { |
1835 | //setModified( true ); | 1849 | //setModified( true ); |
1836 | mViewManager->setDocumentId( filename ); | 1850 | mViewManager->setDocumentId( filename ); |
1837 | mDialogManager->setDocumentId( filename ); | 1851 | mDialogManager->setDocumentId( filename ); |
1838 | mTodoList->setDocumentId( filename ); | 1852 | mTodoList->setDocumentId( filename ); |
1839 | } | 1853 | } |
1840 | globalFlagBlockAgenda = 2; | 1854 | globalFlagBlockAgenda = 2; |
1841 | // if ( getLastSyncEvent() ) | 1855 | // if ( getLastSyncEvent() ) |
1842 | // getLastSyncEvent()->setReadOnly( true ); | 1856 | // getLastSyncEvent()->setReadOnly( true ); |
1843 | mCalendar->reInitAlarmSettings(); | 1857 | mCalendar->reInitAlarmSettings(); |
1844 | setSyncEventsReadOnly(); | 1858 | setSyncEventsReadOnly(); |
1845 | updateUnmanagedViews(); | 1859 | updateUnmanagedViews(); |
1846 | updateView(); | 1860 | updateView(); |
1847 | if ( filename != MainWindow::defaultFileName() ) { | 1861 | if ( filename != MainWindow::defaultFileName() ) { |
1848 | saveCalendar( MainWindow::defaultFileName() ); | 1862 | saveCalendar( MainWindow::defaultFileName() ); |
1849 | } else { | 1863 | } else { |
1850 | QFileInfo finf ( MainWindow::defaultFileName()); | 1864 | QFileInfo finf ( MainWindow::defaultFileName()); |
1851 | if ( finf.exists() ) { | 1865 | if ( finf.exists() ) { |
1852 | setLoadedFileVersion( finf.lastModified () ); | 1866 | setLoadedFileVersion( finf.lastModified () ); |
1853 | } | 1867 | } |
1854 | } | 1868 | } |
1855 | return true; | 1869 | return true; |
1856 | } else { | 1870 | } else { |
1857 | // while failing to load, the calendar object could | 1871 | // while failing to load, the calendar object could |
1858 | // have become partially populated. Clear it out. | 1872 | // have become partially populated. Clear it out. |
1859 | if ( !merge ) { | 1873 | if ( !merge ) { |
1860 | mCalendar->close(); | 1874 | mCalendar->close(); |
1861 | mViewManager->setDocumentId( filename ); | 1875 | mViewManager->setDocumentId( filename ); |
1862 | mDialogManager->setDocumentId( filename ); | 1876 | mDialogManager->setDocumentId( filename ); |
1863 | mTodoList->setDocumentId( filename ); | 1877 | mTodoList->setDocumentId( filename ); |
1864 | } | 1878 | } |
1865 | 1879 | ||
1866 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1880 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1867 | 1881 | ||
1868 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1882 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1869 | globalFlagBlockAgenda = 2; | 1883 | globalFlagBlockAgenda = 2; |
1870 | mCalendar->reInitAlarmSettings(); | 1884 | mCalendar->reInitAlarmSettings(); |
1871 | setSyncEventsReadOnly(); | 1885 | setSyncEventsReadOnly(); |
1872 | updateUnmanagedViews(); | 1886 | updateUnmanagedViews(); |
1873 | updateView(); | 1887 | updateView(); |
1874 | } | 1888 | } |
1875 | return false; | 1889 | return false; |
1876 | } | 1890 | } |
1877 | void CalendarView::showOpenError() | 1891 | void CalendarView::showOpenError() |
1878 | { | 1892 | { |
1879 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1893 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1880 | } | 1894 | } |
1881 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1895 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1882 | { | 1896 | { |
1883 | loadedFileVersion = dt; | 1897 | loadedFileVersion = dt; |
1884 | } | 1898 | } |
1885 | bool CalendarView::checkFileChanged(QString fn) | 1899 | bool CalendarView::checkFileChanged(QString fn) |
1886 | { | 1900 | { |
1887 | QFileInfo finf ( fn ); | 1901 | QFileInfo finf ( fn ); |
1888 | if ( !finf.exists() ) | 1902 | if ( !finf.exists() ) |
1889 | return true; | 1903 | return true; |
1890 | QDateTime dt = finf.lastModified (); | 1904 | QDateTime dt = finf.lastModified (); |
1891 | if ( dt <= loadedFileVersion ) | 1905 | if ( dt <= loadedFileVersion ) |
1892 | return false; | 1906 | return false; |
1893 | return true; | 1907 | return true; |
1894 | 1908 | ||
1895 | } | 1909 | } |
1896 | void CalendarView::watchSavedFile() | 1910 | void CalendarView::watchSavedFile() |
1897 | { | 1911 | { |
1898 | QFileInfo finf ( MainWindow::defaultFileName()); | 1912 | QFileInfo finf ( MainWindow::defaultFileName()); |
1899 | if ( !finf.exists() ) | 1913 | if ( !finf.exists() ) |
1900 | return; | 1914 | return; |
1901 | QDateTime dt = finf.lastModified (); | 1915 | QDateTime dt = finf.lastModified (); |
1902 | if ( dt < loadedFileVersion ) { | 1916 | if ( dt < loadedFileVersion ) { |
1903 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1917 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1904 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1918 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1905 | return; | 1919 | return; |
1906 | } | 1920 | } |
1907 | loadedFileVersion = dt; | 1921 | loadedFileVersion = dt; |
1908 | } | 1922 | } |
1909 | 1923 | ||
1910 | bool CalendarView::checkFileVersion(QString fn) | 1924 | bool CalendarView::checkFileVersion(QString fn) |
1911 | { | 1925 | { |
1912 | QFileInfo finf ( fn ); | 1926 | QFileInfo finf ( fn ); |
1913 | if ( !finf.exists() ) | 1927 | if ( !finf.exists() ) |
1914 | return true; | 1928 | return true; |
1915 | QDateTime dt = finf.lastModified (); | 1929 | QDateTime dt = finf.lastModified (); |
1916 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1930 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1917 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1931 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1918 | if ( dt <= loadedFileVersion ) | 1932 | if ( dt <= loadedFileVersion ) |
1919 | return true; | 1933 | return true; |
1920 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1934 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1921 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1935 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1922 | i18n("Sync+save")); | 1936 | i18n("Sync+save")); |
1923 | 1937 | ||
1924 | if ( km == KMessageBox::Cancel ) | 1938 | if ( km == KMessageBox::Cancel ) |
1925 | return false; | 1939 | return false; |
1926 | if ( km == KMessageBox::Yes ) | 1940 | if ( km == KMessageBox::Yes ) |
1927 | return true; | 1941 | return true; |
1928 | 1942 | ||
1929 | setSyncDevice("deleteaftersync" ); | 1943 | setSyncDevice("deleteaftersync" ); |
1930 | mSyncManager->mAskForPreferences = true; | 1944 | mSyncManager->mAskForPreferences = true; |
1931 | mSyncManager->mSyncAlgoPrefs = 3; | 1945 | mSyncManager->mSyncAlgoPrefs = 3; |
1932 | mSyncManager->mWriteBackFile = false; | 1946 | mSyncManager->mWriteBackFile = false; |
1933 | mSyncManager->mWriteBackExistingOnly = false; | 1947 | mSyncManager->mWriteBackExistingOnly = false; |
1934 | mSyncManager->mShowSyncSummary = false; | 1948 | mSyncManager->mShowSyncSummary = false; |
1935 | syncCalendar( fn, 3 ); | 1949 | syncCalendar( fn, 3 ); |
1936 | Event * e = getLastSyncEvent(); | 1950 | Event * e = getLastSyncEvent(); |
1937 | mCalendar->deleteEvent ( e ); | 1951 | mCalendar->deleteEvent ( e ); |
1938 | updateView(); | 1952 | updateView(); |
1939 | return true; | 1953 | return true; |
1940 | } | 1954 | } |
1941 | 1955 | ||
1942 | bool CalendarView::saveCalendar( QString filename ) | 1956 | bool CalendarView::saveCalendar( QString filename ) |
1943 | { | 1957 | { |
1944 | 1958 | ||
1945 | // Store back all unsaved data into calendar object | 1959 | // Store back all unsaved data into calendar object |
1946 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1960 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1947 | if ( mViewManager->currentView() ) | 1961 | if ( mViewManager->currentView() ) |
1948 | mViewManager->currentView()->flushView(); | 1962 | mViewManager->currentView()->flushView(); |
1949 | 1963 | ||
1950 | 1964 | ||
1951 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1965 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1952 | mStorage->setSaveFormat( new ICalFormat() ); | 1966 | mStorage->setSaveFormat( new ICalFormat() ); |
1953 | mStorage->setFileName( filename ); | 1967 | mStorage->setFileName( filename ); |
1954 | bool success; | 1968 | bool success; |
1955 | success = mStorage->save(); | 1969 | success = mStorage->save(); |
1956 | if ( !success ) { | 1970 | if ( !success ) { |
1957 | return false; | 1971 | return false; |
1958 | } | 1972 | } |
1959 | if ( filename == MainWindow::defaultFileName() ) { | 1973 | if ( filename == MainWindow::defaultFileName() ) { |
1960 | setLoadedFileVersion( lfv ); | 1974 | setLoadedFileVersion( lfv ); |
1961 | watchSavedFile(); | 1975 | watchSavedFile(); |
1962 | } | 1976 | } |
1963 | return true; | 1977 | return true; |
1964 | } | 1978 | } |
1965 | 1979 | ||
1966 | void CalendarView::closeCalendar() | 1980 | void CalendarView::closeCalendar() |
1967 | { | 1981 | { |
1968 | 1982 | ||
1969 | // child windows no longer valid | 1983 | // child windows no longer valid |
1970 | emit closingDown(); | 1984 | emit closingDown(); |
1971 | 1985 | ||
1972 | mCalendar->close(); | 1986 | mCalendar->close(); |
1973 | setModified(false); | 1987 | setModified(false); |
1974 | updateView(); | 1988 | updateView(); |
1975 | } | 1989 | } |
1976 | 1990 | ||
1977 | void CalendarView::archiveCalendar() | 1991 | void CalendarView::archiveCalendar() |
1978 | { | 1992 | { |
1979 | mDialogManager->showArchiveDialog(); | 1993 | mDialogManager->showArchiveDialog(); |
1980 | } | 1994 | } |
1981 | 1995 | ||
1982 | 1996 | ||
1983 | void CalendarView::readSettings() | 1997 | void CalendarView::readSettings() |
1984 | { | 1998 | { |
1985 | 1999 | ||
1986 | 2000 | ||
1987 | // mViewManager->showAgendaView(); | 2001 | // mViewManager->showAgendaView(); |
1988 | QString str; | 2002 | QString str; |
1989 | //qDebug("CalendarView::readSettings() "); | 2003 | //qDebug("CalendarView::readSettings() "); |
1990 | // read settings from the KConfig, supplying reasonable | 2004 | // read settings from the KConfig, supplying reasonable |
1991 | // defaults where none are to be found | 2005 | // defaults where none are to be found |
1992 | KConfig *config = KOGlobals::config(); | 2006 | KConfig *config = KOGlobals::config(); |
1993 | #ifndef KORG_NOSPLITTER | 2007 | #ifndef KORG_NOSPLITTER |
1994 | config->setGroup("KOrganizer Geometry"); | 2008 | config->setGroup("KOrganizer Geometry"); |
1995 | 2009 | ||
1996 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2010 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1997 | if (sizes.count() != 2) { | 2011 | if (sizes.count() != 2) { |
1998 | sizes << mDateNavigator->minimumSizeHint().width(); | 2012 | sizes << mDateNavigator->minimumSizeHint().width(); |
1999 | sizes << 300; | 2013 | sizes << 300; |
2000 | } | 2014 | } |
2001 | mPanner->setSizes(sizes); | 2015 | mPanner->setSizes(sizes); |
2002 | 2016 | ||
2003 | sizes = config->readIntListEntry("Separator2"); | 2017 | sizes = config->readIntListEntry("Separator2"); |
2004 | if ( ( mResourceView && sizes.count() == 4 ) || | 2018 | if ( ( mResourceView && sizes.count() == 4 ) || |
2005 | ( !mResourceView && sizes.count() == 3 ) ) { | 2019 | ( !mResourceView && sizes.count() == 3 ) ) { |
2006 | mLeftSplitter->setSizes(sizes); | 2020 | mLeftSplitter->setSizes(sizes); |
2007 | } | 2021 | } |
2008 | #endif | 2022 | #endif |
2009 | globalFlagBlockAgenda = 1; | 2023 | globalFlagBlockAgenda = 1; |
2010 | mViewManager->showAgendaView(); | 2024 | mViewManager->showAgendaView(); |
2011 | //mViewManager->readSettings( config ); | 2025 | //mViewManager->readSettings( config ); |
2012 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2026 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2013 | readFilterSettings(config); | 2027 | readFilterSettings(config); |
2014 | 2028 | ||
2015 | #ifdef DESKTOP_VERSION | 2029 | #ifdef DESKTOP_VERSION |
2016 | config->setGroup("WidgetLayout"); | 2030 | config->setGroup("WidgetLayout"); |
2017 | QStringList list; | 2031 | QStringList list; |
2018 | list = config->readListEntry("MainLayout"); | 2032 | list = config->readListEntry("MainLayout"); |
2019 | int x,y,w,h; | 2033 | int x,y,w,h; |
2020 | if ( ! list.isEmpty() ) { | 2034 | if ( ! list.isEmpty() ) { |
2021 | x = list[0].toInt(); | 2035 | x = list[0].toInt(); |
2022 | y = list[1].toInt(); | 2036 | y = list[1].toInt(); |
2023 | w = list[2].toInt(); | 2037 | w = list[2].toInt(); |
2024 | h = list[3].toInt(); | 2038 | h = list[3].toInt(); |
2025 | KApplication::testCoords( &x,&y,&w,&h ); | 2039 | KApplication::testCoords( &x,&y,&w,&h ); |
2026 | topLevelWidget()->setGeometry(x,y,w,h); | 2040 | topLevelWidget()->setGeometry(x,y,w,h); |
2027 | 2041 | ||
2028 | } else { | 2042 | } else { |
2029 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2043 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2030 | } | 2044 | } |
2031 | list = config->readListEntry("EditEventLayout"); | 2045 | list = config->readListEntry("EditEventLayout"); |
2032 | if ( ! list.isEmpty() ) { | 2046 | if ( ! list.isEmpty() ) { |
2033 | x = list[0].toInt(); | 2047 | x = list[0].toInt(); |
2034 | y = list[1].toInt(); | 2048 | y = list[1].toInt(); |
2035 | w = list[2].toInt(); | 2049 | w = list[2].toInt(); |
2036 | h = list[3].toInt(); | 2050 | h = list[3].toInt(); |
2037 | KApplication::testCoords( &x,&y,&w,&h ); | 2051 | KApplication::testCoords( &x,&y,&w,&h ); |
2038 | mEventEditor->setGeometry(x,y,w,h); | 2052 | mEventEditor->setGeometry(x,y,w,h); |
2039 | 2053 | ||
2040 | } | 2054 | } |
2041 | list = config->readListEntry("EditTodoLayout"); | 2055 | list = config->readListEntry("EditTodoLayout"); |
2042 | if ( ! list.isEmpty() ) { | 2056 | if ( ! list.isEmpty() ) { |
2043 | x = list[0].toInt(); | 2057 | x = list[0].toInt(); |
2044 | y = list[1].toInt(); | 2058 | y = list[1].toInt(); |
2045 | w = list[2].toInt(); | 2059 | w = list[2].toInt(); |
2046 | h = list[3].toInt(); | 2060 | h = list[3].toInt(); |
2047 | KApplication::testCoords( &x,&y,&w,&h ); | 2061 | KApplication::testCoords( &x,&y,&w,&h ); |
2048 | mTodoEditor->setGeometry(x,y,w,h); | 2062 | mTodoEditor->setGeometry(x,y,w,h); |
2049 | 2063 | ||
2050 | } | 2064 | } |
2051 | list = config->readListEntry("ViewerLayout"); | 2065 | list = config->readListEntry("ViewerLayout"); |
2052 | if ( ! list.isEmpty() ) { | 2066 | if ( ! list.isEmpty() ) { |
2053 | x = list[0].toInt(); | 2067 | x = list[0].toInt(); |
2054 | y = list[1].toInt(); | 2068 | y = list[1].toInt(); |
2055 | w = list[2].toInt(); | 2069 | w = list[2].toInt(); |
2056 | h = list[3].toInt(); | 2070 | h = list[3].toInt(); |
2057 | KApplication::testCoords( &x,&y,&w,&h ); | 2071 | KApplication::testCoords( &x,&y,&w,&h ); |
2058 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2072 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2059 | } | 2073 | } |
2060 | #endif | 2074 | #endif |
2061 | config->setGroup( "Views" ); | 2075 | config->setGroup( "Views" ); |
2062 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2076 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2063 | 2077 | ||
2064 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2078 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2065 | 2079 | ||
2066 | int resetval = 0; | 2080 | int resetval = 0; |
2067 | int maxVal = 0; | 2081 | int maxVal = 0; |
2068 | if (sizes.count() != 3) { | 2082 | if (sizes.count() != 3) { |
2069 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2083 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2070 | resetval = mDateNavigator->sizeHint().width()+2; | 2084 | resetval = mDateNavigator->sizeHint().width()+2; |
2071 | } else { | 2085 | } else { |
2072 | resetval = mDateNavigator->sizeHint().height()+2; | 2086 | resetval = mDateNavigator->sizeHint().height()+2; |
2073 | } | 2087 | } |
2074 | } | 2088 | } |
2075 | if ( resetval ) { | 2089 | if ( resetval ) { |
2076 | sizes.clear(); | 2090 | sizes.clear(); |
2077 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2091 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2078 | maxVal = QApplication::desktop()->width() -10; | 2092 | maxVal = QApplication::desktop()->width() -10; |
2079 | } else { | 2093 | } else { |
2080 | maxVal = QApplication::desktop()->height()-10; | 2094 | maxVal = QApplication::desktop()->height()-10; |
2081 | } | 2095 | } |
2082 | sizes << resetval; | 2096 | sizes << resetval; |
2083 | if ( maxVal < resetval + resetval) | 2097 | if ( maxVal < resetval + resetval) |
2084 | resetval = maxVal - resetval; | 2098 | resetval = maxVal - resetval; |
2085 | sizes << resetval; | 2099 | sizes << resetval; |
2086 | sizes << 100; | 2100 | sizes << 100; |
2087 | } | 2101 | } |
2088 | mLeftFrame->setSizes(sizes); | 2102 | mLeftFrame->setSizes(sizes); |
2089 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2103 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2090 | resetval = 0; | 2104 | resetval = 0; |
2091 | maxVal = 0; | 2105 | maxVal = 0; |
2092 | if (sizes.count() != 2) { | 2106 | if (sizes.count() != 2) { |
2093 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2107 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2094 | resetval = mDateNavigator->sizeHint().width()+2; | 2108 | resetval = mDateNavigator->sizeHint().width()+2; |
2095 | } else { | 2109 | } else { |
2096 | resetval = mDateNavigator->sizeHint().height()+2; | 2110 | resetval = mDateNavigator->sizeHint().height()+2; |
2097 | } | 2111 | } |
2098 | } | 2112 | } |
2099 | if ( resetval ) { | 2113 | if ( resetval ) { |
2100 | sizes.clear(); | 2114 | sizes.clear(); |
2101 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2115 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2102 | maxVal = QApplication::desktop()->width() -10; | 2116 | maxVal = QApplication::desktop()->width() -10; |
2103 | } else { | 2117 | } else { |
2104 | maxVal = QApplication::desktop()->height()-10; | 2118 | maxVal = QApplication::desktop()->height()-10; |
2105 | } | 2119 | } |
2106 | sizes << resetval; | 2120 | sizes << resetval; |
2107 | if ( maxVal < resetval + resetval) | 2121 | if ( maxVal < resetval + resetval) |
2108 | resetval = maxVal - resetval; | 2122 | resetval = maxVal - resetval; |
2109 | sizes << resetval; | 2123 | sizes << resetval; |
2110 | } | 2124 | } |
2111 | mMainFrame->setSizes(sizes); | 2125 | mMainFrame->setSizes(sizes); |
2112 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2126 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2113 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2127 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2114 | else mNavigator->selectDates( dateCount ); | 2128 | else mNavigator->selectDates( dateCount ); |
2115 | // mViewManager->readSettings( config ); | 2129 | // mViewManager->readSettings( config ); |
2116 | updateConfig(); | 2130 | updateConfig(); |
2117 | globalFlagBlockAgenda = 2; | 2131 | globalFlagBlockAgenda = 2; |
2118 | mViewManager->readSettings( config ); | 2132 | mViewManager->readSettings( config ); |
2119 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2133 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2120 | } | 2134 | } |
2121 | 2135 | ||
2122 | 2136 | ||
2123 | void CalendarView::writeSettings() | 2137 | void CalendarView::writeSettings() |
2124 | { | 2138 | { |
2125 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2139 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2126 | 2140 | ||
2127 | KConfig *config = KOGlobals::config(); | 2141 | KConfig *config = KOGlobals::config(); |
2128 | 2142 | ||
2129 | mViewManager->writeSettings( config ); | 2143 | mViewManager->writeSettings( config ); |
2130 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2144 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2131 | mDialogManager->writeSettings( config ); | 2145 | mDialogManager->writeSettings( config ); |
2132 | //KOPrefs::instance()->usrWriteConfig(); | 2146 | //KOPrefs::instance()->usrWriteConfig(); |
2133 | KOPrefs::instance()->writeConfig(); | 2147 | KOPrefs::instance()->writeConfig(); |
2134 | 2148 | ||
2135 | writeFilterSettings(config); | 2149 | writeFilterSettings(config); |
2136 | config->setGroup( "AppRun" ); | 2150 | config->setGroup( "AppRun" ); |
2137 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2151 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2138 | config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) ); | 2152 | config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) ); |
2139 | config->setGroup( "Views" ); | 2153 | config->setGroup( "Views" ); |
2140 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2154 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2141 | 2155 | ||
2142 | QValueList<int> listINT = mLeftFrame->sizes(); | 2156 | QValueList<int> listINT = mLeftFrame->sizes(); |
2143 | config->writeEntry("Left Splitter Frame",listINT); | 2157 | config->writeEntry("Left Splitter Frame",listINT); |
2144 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2158 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2145 | config->writeEntry("Main Splitter Frame",listINT2); | 2159 | config->writeEntry("Main Splitter Frame",listINT2); |
2146 | #ifdef DESKTOP_VERSION | 2160 | #ifdef DESKTOP_VERSION |
2147 | config->setGroup("WidgetLayout"); | 2161 | config->setGroup("WidgetLayout"); |
2148 | QStringList list ;//= config->readListEntry("MainLayout"); | 2162 | QStringList list ;//= config->readListEntry("MainLayout"); |
2149 | int x,y,w,h; | 2163 | int x,y,w,h; |
2150 | QWidget* wid; | 2164 | QWidget* wid; |
2151 | wid = topLevelWidget(); | 2165 | wid = topLevelWidget(); |
2152 | x = wid->geometry().x(); | 2166 | x = wid->geometry().x(); |
2153 | y = wid->geometry().y(); | 2167 | y = wid->geometry().y(); |
2154 | w = wid->width(); | 2168 | w = wid->width(); |
2155 | h = wid->height(); | 2169 | h = wid->height(); |
2156 | list.clear(); | 2170 | list.clear(); |
2157 | list << QString::number( x ); | 2171 | list << QString::number( x ); |
2158 | list << QString::number( y ); | 2172 | list << QString::number( y ); |
2159 | list << QString::number( w ); | 2173 | list << QString::number( w ); |
2160 | list << QString::number( h ); | 2174 | list << QString::number( h ); |
2161 | config->writeEntry("MainLayout",list ); | 2175 | config->writeEntry("MainLayout",list ); |
2162 | 2176 | ||
2163 | wid = mEventEditor; | 2177 | wid = mEventEditor; |
2164 | x = wid->geometry().x(); | 2178 | x = wid->geometry().x(); |
2165 | y = wid->geometry().y(); | 2179 | y = wid->geometry().y(); |
2166 | w = wid->width(); | 2180 | w = wid->width(); |
2167 | h = wid->height(); | 2181 | h = wid->height(); |
2168 | list.clear(); | 2182 | list.clear(); |
2169 | list << QString::number( x ); | 2183 | list << QString::number( x ); |
2170 | list << QString::number( y ); | 2184 | list << QString::number( y ); |
2171 | list << QString::number( w ); | 2185 | list << QString::number( w ); |
2172 | list << QString::number( h ); | 2186 | list << QString::number( h ); |
2173 | config->writeEntry("EditEventLayout",list ); | 2187 | config->writeEntry("EditEventLayout",list ); |
2174 | 2188 | ||
2175 | wid = mTodoEditor; | 2189 | wid = mTodoEditor; |
2176 | x = wid->geometry().x(); | 2190 | x = wid->geometry().x(); |
2177 | y = wid->geometry().y(); | 2191 | y = wid->geometry().y(); |
2178 | w = wid->width(); | 2192 | w = wid->width(); |
2179 | h = wid->height(); | 2193 | h = wid->height(); |
2180 | list.clear(); | 2194 | list.clear(); |
2181 | list << QString::number( x ); | 2195 | list << QString::number( x ); |
2182 | list << QString::number( y ); | 2196 | list << QString::number( y ); |
2183 | list << QString::number( w ); | 2197 | list << QString::number( w ); |
2184 | list << QString::number( h ); | 2198 | list << QString::number( h ); |
2185 | config->writeEntry("EditTodoLayout",list ); | 2199 | config->writeEntry("EditTodoLayout",list ); |
2186 | wid = getEventViewerDialog(); | 2200 | wid = getEventViewerDialog(); |
2187 | x = wid->geometry().x(); | 2201 | x = wid->geometry().x(); |
2188 | y = wid->geometry().y(); | 2202 | y = wid->geometry().y(); |
2189 | w = wid->width(); | 2203 | w = wid->width(); |
2190 | h = wid->height(); | 2204 | h = wid->height(); |
2191 | list.clear(); | 2205 | list.clear(); |
2192 | list << QString::number( x ); | 2206 | list << QString::number( x ); |
2193 | list << QString::number( y ); | 2207 | list << QString::number( y ); |
2194 | list << QString::number( w ); | 2208 | list << QString::number( w ); |
2195 | list << QString::number( h ); | 2209 | list << QString::number( h ); |
2196 | config->writeEntry("ViewerLayout",list ); | 2210 | config->writeEntry("ViewerLayout",list ); |
2197 | wid = mDialogManager->getSearchDialog(); | 2211 | wid = mDialogManager->getSearchDialog(); |
2198 | if ( wid ) { | 2212 | if ( wid ) { |
2199 | x = wid->geometry().x(); | 2213 | x = wid->geometry().x(); |
2200 | y = wid->geometry().y(); | 2214 | y = wid->geometry().y(); |
2201 | w = wid->width(); | 2215 | w = wid->width(); |
2202 | h = wid->height(); | 2216 | h = wid->height(); |
2203 | list.clear(); | 2217 | list.clear(); |
2204 | list << QString::number( x ); | 2218 | list << QString::number( x ); |
2205 | list << QString::number( y ); | 2219 | list << QString::number( y ); |
2206 | list << QString::number( w ); | 2220 | list << QString::number( w ); |
2207 | list << QString::number( h ); | 2221 | list << QString::number( h ); |
2208 | config->writeEntry("SearchLayout",list ); | 2222 | config->writeEntry("SearchLayout",list ); |
2209 | } | 2223 | } |
2210 | #endif | 2224 | #endif |
2211 | 2225 | ||
2212 | 2226 | ||
2213 | config->sync(); | 2227 | config->sync(); |
2214 | } | 2228 | } |
2215 | 2229 | ||
2216 | void CalendarView::readFilterSettings(KConfig *config) | 2230 | void CalendarView::readFilterSettings(KConfig *config) |
2217 | { | 2231 | { |
2218 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2232 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2219 | 2233 | ||
2220 | mFilters.clear(); | 2234 | mFilters.clear(); |
2221 | 2235 | ||
2222 | config->setGroup("General"); | 2236 | config->setGroup("General"); |
2223 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2237 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2224 | 2238 | ||
2225 | QStringList::ConstIterator it = filterList.begin(); | 2239 | QStringList::ConstIterator it = filterList.begin(); |
2226 | QStringList::ConstIterator end = filterList.end(); | 2240 | QStringList::ConstIterator end = filterList.end(); |
2227 | while(it != end) { | 2241 | while(it != end) { |
2228 | // kdDebug() << " filter: " << (*it) << endl; | 2242 | // kdDebug() << " filter: " << (*it) << endl; |
2229 | 2243 | ||
2230 | CalFilter *filter; | 2244 | CalFilter *filter; |
2231 | filter = new CalFilter(*it); | 2245 | filter = new CalFilter(*it); |
2232 | config->setGroup("Filter_" + (*it).utf8()); | 2246 | config->setGroup("Filter_" + (*it).utf8()); |
2233 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2247 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2234 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2248 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2235 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2249 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2236 | mFilters.append(filter); | 2250 | mFilters.append(filter); |
2237 | 2251 | ||
2238 | ++it; | 2252 | ++it; |
2239 | } | 2253 | } |
2240 | 2254 | ||
2241 | if (mFilters.count() == 0) { | 2255 | if (mFilters.count() == 0) { |
2242 | CalFilter *filter = new CalFilter(i18n("Default")); | 2256 | CalFilter *filter = new CalFilter(i18n("Default")); |
2243 | mFilters.append(filter); | 2257 | mFilters.append(filter); |
2244 | } | 2258 | } |
2245 | mFilterView->updateFilters(); | 2259 | mFilterView->updateFilters(); |
2246 | config->setGroup("FilterView"); | 2260 | config->setGroup("FilterView"); |
2247 | 2261 | ||
2248 | mFilterView->blockSignals(true); | 2262 | mFilterView->blockSignals(true); |
2249 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2263 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2250 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2264 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2251 | mFilterView->blockSignals(false); | 2265 | mFilterView->blockSignals(false); |
2252 | // We do it manually to avoid it being done twice by the above calls | 2266 | // We do it manually to avoid it being done twice by the above calls |
2253 | updateFilter(); | 2267 | updateFilter(); |
2254 | } | 2268 | } |
2255 | 2269 | ||
2256 | void CalendarView::writeFilterSettings(KConfig *config) | 2270 | void CalendarView::writeFilterSettings(KConfig *config) |
2257 | { | 2271 | { |
2258 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2272 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2259 | 2273 | ||
2260 | QStringList filterList; | 2274 | QStringList filterList; |
2261 | 2275 | ||
2262 | CalFilter *filter = mFilters.first(); | 2276 | CalFilter *filter = mFilters.first(); |
2263 | while(filter) { | 2277 | while(filter) { |
2264 | // kdDebug() << " fn: " << filter->name() << endl; | 2278 | // kdDebug() << " fn: " << filter->name() << endl; |
2265 | filterList << filter->name(); | 2279 | filterList << filter->name(); |
2266 | config->setGroup("Filter_" + filter->name().utf8()); | 2280 | config->setGroup("Filter_" + filter->name().utf8()); |
2267 | config->writeEntry("Criteria",filter->criteria()); | 2281 | config->writeEntry("Criteria",filter->criteria()); |
2268 | config->writeEntry("CategoryList",filter->categoryList()); | 2282 | config->writeEntry("CategoryList",filter->categoryList()); |
2269 | filter = mFilters.next(); | 2283 | filter = mFilters.next(); |
2270 | } | 2284 | } |
2271 | config->setGroup("General"); | 2285 | config->setGroup("General"); |
2272 | config->writeEntry("CalendarFilters",filterList); | 2286 | config->writeEntry("CalendarFilters",filterList); |
2273 | 2287 | ||
2274 | config->setGroup("FilterView"); | 2288 | config->setGroup("FilterView"); |
2275 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2289 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2276 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2290 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2277 | } | 2291 | } |
2278 | 2292 | ||
2279 | 2293 | ||
2280 | void CalendarView::goToday() | 2294 | void CalendarView::goToday() |
2281 | { | 2295 | { |
2282 | if ( mViewManager->currentView()->isMonthView() ) | 2296 | if ( mViewManager->currentView()->isMonthView() ) |
2283 | mNavigator->selectTodayMonth(); | 2297 | mNavigator->selectTodayMonth(); |
2284 | else | 2298 | else |
2285 | mNavigator->selectToday(); | 2299 | mNavigator->selectToday(); |
2286 | } | 2300 | } |
2287 | 2301 | ||
2288 | void CalendarView::goNext() | 2302 | void CalendarView::goNext() |
2289 | { | 2303 | { |
2290 | mNavigator->selectNext(); | 2304 | mNavigator->selectNext(); |
2291 | } | 2305 | } |
2292 | 2306 | ||
2293 | void CalendarView::goPrevious() | 2307 | void CalendarView::goPrevious() |
2294 | { | 2308 | { |
2295 | mNavigator->selectPrevious(); | 2309 | mNavigator->selectPrevious(); |
2296 | } | 2310 | } |
2297 | void CalendarView::goNextMonth() | 2311 | void CalendarView::goNextMonth() |
2298 | { | 2312 | { |
2299 | mNavigator->selectNextMonth(); | 2313 | mNavigator->selectNextMonth(); |
2300 | } | 2314 | } |
2301 | 2315 | ||
2302 | void CalendarView::goPreviousMonth() | 2316 | void CalendarView::goPreviousMonth() |
2303 | { | 2317 | { |
2304 | mNavigator->selectPreviousMonth(); | 2318 | mNavigator->selectPreviousMonth(); |
2305 | } | 2319 | } |
2306 | void CalendarView::writeLocale() | 2320 | void CalendarView::writeLocale() |
2307 | { | 2321 | { |
2308 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2322 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2309 | #if 0 | 2323 | #if 0 |
2310 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2324 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2311 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2325 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2312 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2326 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2313 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2327 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2314 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2328 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2315 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2329 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2316 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2330 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2317 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2331 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2318 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2332 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2319 | KOPrefs::instance()->mDaylightsavingStart, | 2333 | KOPrefs::instance()->mDaylightsavingStart, |
2320 | KOPrefs::instance()->mDaylightsavingEnd ); | 2334 | KOPrefs::instance()->mDaylightsavingEnd ); |
2321 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2335 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2322 | #endif | 2336 | #endif |
2323 | } | 2337 | } |
2324 | void CalendarView::updateConfig() | 2338 | void CalendarView::updateConfig() |
2325 | { | 2339 | { |
2326 | writeLocale(); | 2340 | writeLocale(); |
2327 | if ( KOPrefs::instance()->mUseAppColors ) | 2341 | if ( KOPrefs::instance()->mUseAppColors ) |
2328 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2342 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2329 | emit configChanged(); | 2343 | emit configChanged(); |
2330 | mTodoList->updateConfig(); | 2344 | mTodoList->updateConfig(); |
2331 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2345 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2332 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2346 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2333 | // To make the "fill window" configurations work | 2347 | // To make the "fill window" configurations work |
2334 | //mViewManager->raiseCurrentView(); | 2348 | //mViewManager->raiseCurrentView(); |
2335 | } | 2349 | } |
2336 | 2350 | ||
2337 | 2351 | ||
2338 | void CalendarView::eventChanged(Event *event) | 2352 | void CalendarView::eventChanged(Event *event) |
2339 | { | 2353 | { |
2340 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2354 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2341 | //updateUnmanagedViews(); | 2355 | //updateUnmanagedViews(); |
2342 | } | 2356 | } |
2343 | 2357 | ||
2344 | void CalendarView::eventAdded(Event *event) | 2358 | void CalendarView::eventAdded(Event *event) |
2345 | { | 2359 | { |
2346 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2360 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2347 | } | 2361 | } |
2348 | 2362 | ||
2349 | void CalendarView::eventToBeDeleted(Event *) | 2363 | void CalendarView::eventToBeDeleted(Event *) |
2350 | { | 2364 | { |
2351 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2365 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2352 | } | 2366 | } |
2353 | 2367 | ||
2354 | void CalendarView::eventDeleted() | 2368 | void CalendarView::eventDeleted() |
2355 | { | 2369 | { |
2356 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2370 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2357 | } | 2371 | } |
2358 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2372 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2359 | { | 2373 | { |
2360 | changeIncidenceDisplay((Incidence *)which, action); | 2374 | changeIncidenceDisplay((Incidence *)which, action); |
2361 | mDateNavigator->updateView(); //LR | 2375 | mDateNavigator->updateView(); //LR |
2362 | //mDialogManager->updateSearchDialog(); | 2376 | //mDialogManager->updateSearchDialog(); |
2363 | 2377 | ||
2364 | if (which) { | 2378 | if (which) { |
2365 | mViewManager->updateWNview(); | 2379 | mViewManager->updateWNview(); |
2366 | //mTodoList->updateView(); | 2380 | //mTodoList->updateView(); |
2367 | } | 2381 | } |
2368 | 2382 | ||
2369 | } | 2383 | } |
2370 | 2384 | ||
2371 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2385 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2372 | { | 2386 | { |
2373 | updateUnmanagedViews(); | 2387 | updateUnmanagedViews(); |
2374 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2388 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2375 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2389 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2376 | mCalendar->checkAlarmForIncidence( 0, true ); | 2390 | mCalendar->checkAlarmForIncidence( 0, true ); |
2377 | if ( mEventViewerDialog ) | 2391 | if ( mEventViewerDialog ) |
2378 | mEventViewerDialog->hide(); | 2392 | mEventViewerDialog->hide(); |
2379 | } | 2393 | } |
2380 | else | 2394 | else |
2381 | mCalendar->checkAlarmForIncidence( which , false ); | 2395 | mCalendar->checkAlarmForIncidence( which , false ); |
2382 | } | 2396 | } |
2383 | 2397 | ||
2384 | // most of the changeEventDisplays() right now just call the view's | 2398 | // most of the changeEventDisplays() right now just call the view's |
2385 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2399 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2386 | void CalendarView::changeEventDisplay(Event *which, int action) | 2400 | void CalendarView::changeEventDisplay(Event *which, int action) |
2387 | { | 2401 | { |
2388 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2402 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2389 | changeIncidenceDisplay((Incidence *)which, action); | 2403 | changeIncidenceDisplay((Incidence *)which, action); |
2390 | mDateNavigator->updateView(); | 2404 | mDateNavigator->updateView(); |
2391 | //mDialogManager->updateSearchDialog(); | 2405 | //mDialogManager->updateSearchDialog(); |
2392 | 2406 | ||
2393 | if (which) { | 2407 | if (which) { |
2394 | // If there is an event view visible update the display | 2408 | // If there is an event view visible update the display |
2395 | mViewManager->currentView()->changeEventDisplay(which,action); | 2409 | mViewManager->currentView()->changeEventDisplay(which,action); |
2396 | // TODO: check, if update needed | 2410 | // TODO: check, if update needed |
2397 | // if (which->getTodoStatus()) { | 2411 | // if (which->getTodoStatus()) { |
2398 | mTodoList->updateView(); | 2412 | mTodoList->updateView(); |
2399 | // } | 2413 | // } |
2400 | } else { | 2414 | } else { |
2401 | mViewManager->currentView()->updateView(); | 2415 | mViewManager->currentView()->updateView(); |
2402 | } | 2416 | } |
2403 | } | 2417 | } |
2404 | 2418 | ||
2405 | 2419 | ||
2406 | void CalendarView::updateTodoViews() | 2420 | void CalendarView::updateTodoViews() |
2407 | { | 2421 | { |
2408 | mTodoList->updateView(); | 2422 | mTodoList->updateView(); |
2409 | mViewManager->currentView()->updateView(); | 2423 | mViewManager->currentView()->updateView(); |
2410 | 2424 | ||
2411 | } | 2425 | } |
2412 | 2426 | ||
2413 | 2427 | ||
2414 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2428 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2415 | { | 2429 | { |
2416 | mTodoList->updateView(); | 2430 | mTodoList->updateView(); |
2417 | mViewManager->updateView(start, end); | 2431 | mViewManager->updateView(start, end); |
2418 | //mDateNavigator->updateView(); | 2432 | //mDateNavigator->updateView(); |
2419 | } | 2433 | } |
2420 | 2434 | ||
2421 | void CalendarView::updateView() | 2435 | void CalendarView::updateView() |
2422 | { | 2436 | { |
2423 | DateList tmpList = mNavigator->selectedDates(); | 2437 | DateList tmpList = mNavigator->selectedDates(); |
2424 | 2438 | ||
2425 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2439 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2426 | mTodoList->updateView(); | 2440 | mTodoList->updateView(); |
2427 | // We assume that the navigator only selects consecutive days. | 2441 | // We assume that the navigator only selects consecutive days. |
2428 | updateView( tmpList.first(), tmpList.last() ); | 2442 | updateView( tmpList.first(), tmpList.last() ); |
2429 | } | 2443 | } |
2430 | 2444 | ||
2431 | void CalendarView::updateUnmanagedViews() | 2445 | void CalendarView::updateUnmanagedViews() |
2432 | { | 2446 | { |
2433 | mDateNavigator->updateDayMatrix(); | 2447 | mDateNavigator->updateDayMatrix(); |
2434 | } | 2448 | } |
2435 | 2449 | ||
2436 | int CalendarView::msgItemDelete(const QString name) | 2450 | int CalendarView::msgItemDelete(const QString name) |
2437 | { | 2451 | { |
2438 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2452 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2439 | i18n("This item will be\npermanently deleted."), | 2453 | i18n("This item will be\npermanently deleted."), |
2440 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2454 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2441 | } | 2455 | } |
2442 | 2456 | ||
2443 | 2457 | ||
2444 | void CalendarView::edit_cut() | 2458 | void CalendarView::edit_cut() |
2445 | { | 2459 | { |
2446 | Event *anEvent=0; | 2460 | Event *anEvent=0; |
2447 | 2461 | ||
2448 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2462 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2449 | 2463 | ||
2450 | if (mViewManager->currentView()->isEventView()) { | 2464 | if (mViewManager->currentView()->isEventView()) { |
2451 | if ( incidence && incidence->type() == "Event" ) { | 2465 | if ( incidence && incidence->type() == "Event" ) { |
2452 | anEvent = static_cast<Event *>(incidence); | 2466 | anEvent = static_cast<Event *>(incidence); |
2453 | } | 2467 | } |
2454 | } | 2468 | } |
2455 | 2469 | ||
2456 | if (!anEvent) { | 2470 | if (!anEvent) { |
2457 | KNotifyClient::beep(); | 2471 | KNotifyClient::beep(); |
2458 | return; | 2472 | return; |
2459 | } | 2473 | } |
2460 | DndFactory factory( mCalendar ); | 2474 | DndFactory factory( mCalendar ); |
2461 | factory.cutIncidence(anEvent); | 2475 | factory.cutIncidence(anEvent); |
2462 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2476 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2463 | } | 2477 | } |
2464 | 2478 | ||
2465 | void CalendarView::edit_copy() | 2479 | void CalendarView::edit_copy() |
2466 | { | 2480 | { |
2467 | Event *anEvent=0; | 2481 | Event *anEvent=0; |
2468 | 2482 | ||
2469 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2483 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2470 | 2484 | ||
2471 | if (mViewManager->currentView()->isEventView()) { | 2485 | if (mViewManager->currentView()->isEventView()) { |
2472 | if ( incidence && incidence->type() == "Event" ) { | 2486 | if ( incidence && incidence->type() == "Event" ) { |
2473 | anEvent = static_cast<Event *>(incidence); | 2487 | anEvent = static_cast<Event *>(incidence); |
2474 | } | 2488 | } |
2475 | } | 2489 | } |
2476 | 2490 | ||
2477 | if (!anEvent) { | 2491 | if (!anEvent) { |
2478 | KNotifyClient::beep(); | 2492 | KNotifyClient::beep(); |
2479 | return; | 2493 | return; |
2480 | } | 2494 | } |
2481 | DndFactory factory( mCalendar ); | 2495 | DndFactory factory( mCalendar ); |
2482 | factory.copyIncidence(anEvent); | 2496 | factory.copyIncidence(anEvent); |
2483 | } | 2497 | } |
2484 | 2498 | ||
2485 | void CalendarView::edit_paste() | 2499 | void CalendarView::edit_paste() |
2486 | { | 2500 | { |
2487 | QDate date = mNavigator->selectedDates().first(); | 2501 | QDate date = mNavigator->selectedDates().first(); |
2488 | 2502 | ||
2489 | DndFactory factory( mCalendar ); | 2503 | DndFactory factory( mCalendar ); |
2490 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2504 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2491 | 2505 | ||
2492 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2506 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2493 | } | 2507 | } |
2494 | 2508 | ||
2495 | void CalendarView::edit_options() | 2509 | void CalendarView::edit_options() |
2496 | { | 2510 | { |
2497 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2511 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2498 | emit save(); | 2512 | emit save(); |
2499 | emit saveStopTimer(); | 2513 | emit saveStopTimer(); |
2500 | mDialogManager->showOptionsDialog(); | 2514 | mDialogManager->showOptionsDialog(); |
2501 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2515 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2502 | emit saveStopTimer(); | 2516 | emit saveStopTimer(); |
2503 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2517 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2504 | i18n("Timezone settings"),i18n("Reload"))) { | 2518 | i18n("Timezone settings"),i18n("Reload"))) { |
2505 | qDebug("KO: TZ reload cancelled "); | 2519 | qDebug("KO: TZ reload cancelled "); |
2506 | return; | 2520 | return; |
2507 | } | 2521 | } |
2508 | qDebug("KO: Timezone change "); | 2522 | qDebug("KO: Timezone change "); |
2509 | openCalendar( MainWindow::defaultFileName() ); | 2523 | openCalendar( MainWindow::defaultFileName() ); |
2510 | setModified(true); | 2524 | setModified(true); |
2511 | } | 2525 | } |
2512 | else | 2526 | else |
2513 | qDebug("KO: No tz change "); | 2527 | qDebug("KO: No tz change "); |
2514 | 2528 | ||
2515 | } | 2529 | } |
2516 | 2530 | ||
2517 | 2531 | ||
2518 | void CalendarView::slotSelectPickerDate( QDate d) | 2532 | void CalendarView::slotSelectPickerDate( QDate d) |
2519 | { | 2533 | { |
2520 | mDateFrame->hide(); | 2534 | mDateFrame->hide(); |
2521 | if ( mDatePickerMode == 1 ) { | 2535 | if ( mDatePickerMode == 1 ) { |
2522 | mNavigator->slotDaySelect( d ); | 2536 | mNavigator->slotDaySelect( d ); |
2523 | } else if ( mDatePickerMode == 2 ) { | 2537 | } else if ( mDatePickerMode == 2 ) { |
2524 | if ( mMoveIncidence->type() == "Todo" ) { | 2538 | if ( mMoveIncidence->type() == "Todo" ) { |
2525 | Todo * to = (Todo *) mMoveIncidence; | 2539 | Todo * to = (Todo *) mMoveIncidence; |
2526 | QTime tim; | 2540 | QTime tim; |
2527 | int len = 0; | 2541 | int len = 0; |
2528 | if ( to->hasStartDate() && to->hasDueDate() ) | 2542 | if ( to->hasStartDate() && to->hasDueDate() ) |
2529 | len = to->dtStart().secsTo( to->dtDue()); | 2543 | len = to->dtStart().secsTo( to->dtDue()); |
2530 | if ( to->hasDueDate() ) | 2544 | if ( to->hasDueDate() ) |
2531 | tim = to->dtDue().time(); | 2545 | tim = to->dtDue().time(); |
2532 | else { | 2546 | else { |
2533 | tim = QTime ( 0,0,0 ); | 2547 | tim = QTime ( 0,0,0 ); |
2534 | to->setFloats( true ); | 2548 | to->setFloats( true ); |
2535 | to->setHasDueDate( true ); | 2549 | to->setHasDueDate( true ); |
2536 | } | 2550 | } |
2537 | QDateTime dt ( d,tim ); | 2551 | QDateTime dt ( d,tim ); |
2538 | to->setDtDue( dt ); | 2552 | to->setDtDue( dt ); |
2539 | 2553 | ||
2540 | if ( to->hasStartDate() ) { | 2554 | if ( to->hasStartDate() ) { |
2541 | if ( len>0 ) | 2555 | if ( len>0 ) |
2542 | to->setDtStart(to->dtDue().addSecs( -len )); | 2556 | to->setDtStart(to->dtDue().addSecs( -len )); |
2543 | else | 2557 | else |
2544 | if (to->dtStart() > to->dtDue() ) | 2558 | if (to->dtStart() > to->dtDue() ) |
2545 | to->setDtStart(to->dtDue().addDays( -3 )); | 2559 | to->setDtStart(to->dtDue().addDays( -3 )); |
2546 | } | 2560 | } |
2547 | 2561 | ||
2548 | todoChanged( to ); | 2562 | todoChanged( to ); |
2549 | } else { | 2563 | } else { |
2550 | if ( mMoveIncidence->doesRecur() ) { | 2564 | if ( mMoveIncidence->doesRecur() ) { |
2551 | #if 0 | 2565 | #if 0 |
2552 | // PENDING implement this | 2566 | // PENDING implement this |
2553 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2567 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2554 | mCalendar()->addIncidence( newInc ); | 2568 | mCalendar()->addIncidence( newInc ); |
2555 | if ( mMoveIncidence->type() == "Todo" ) | 2569 | if ( mMoveIncidence->type() == "Todo" ) |
2556 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2570 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2557 | else | 2571 | else |
2558 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2572 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2559 | mMoveIncidence = newInc; | 2573 | mMoveIncidence = newInc; |
2560 | 2574 | ||
2561 | #endif | 2575 | #endif |
2562 | } | 2576 | } |
2563 | QTime tim = mMoveIncidence->dtStart().time(); | 2577 | QTime tim = mMoveIncidence->dtStart().time(); |
2564 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2578 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2565 | QDateTime dt ( d,tim ); | 2579 | QDateTime dt ( d,tim ); |
2566 | mMoveIncidence->setDtStart( dt ); | 2580 | mMoveIncidence->setDtStart( dt ); |
2567 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2581 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2568 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2582 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2569 | } | 2583 | } |
2570 | 2584 | ||
2571 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2585 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2572 | } | 2586 | } |
2573 | } | 2587 | } |
2574 | 2588 | ||
2575 | void CalendarView::removeCategories() | 2589 | void CalendarView::removeCategories() |
2576 | { | 2590 | { |
2577 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2591 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2578 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2592 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2579 | QStringList catIncList; | 2593 | QStringList catIncList; |
2580 | QStringList newCatList; | 2594 | QStringList newCatList; |
2581 | Incidence* inc = incList.first(); | 2595 | Incidence* inc = incList.first(); |
2582 | int i; | 2596 | int i; |
2583 | int count = 0; | 2597 | int count = 0; |
2584 | while ( inc ) { | 2598 | while ( inc ) { |
2585 | newCatList.clear(); | 2599 | newCatList.clear(); |
2586 | catIncList = inc->categories() ; | 2600 | catIncList = inc->categories() ; |
2587 | for( i = 0; i< catIncList.count(); ++i ) { | 2601 | for( i = 0; i< catIncList.count(); ++i ) { |
2588 | if ( catList.contains (catIncList[i])) | 2602 | if ( catList.contains (catIncList[i])) |
2589 | newCatList.append( catIncList[i] ); | 2603 | newCatList.append( catIncList[i] ); |
2590 | } | 2604 | } |
2591 | newCatList.sort(); | 2605 | newCatList.sort(); |
2592 | inc->setCategories( newCatList.join(",") ); | 2606 | inc->setCategories( newCatList.join(",") ); |
2593 | inc = incList.next(); | 2607 | inc = incList.next(); |
2594 | } | 2608 | } |
2595 | } | 2609 | } |
2596 | 2610 | ||
2597 | int CalendarView::addCategories() | 2611 | int CalendarView::addCategories() |
2598 | { | 2612 | { |
2599 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2613 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2600 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2614 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2601 | QStringList catIncList; | 2615 | QStringList catIncList; |
2602 | Incidence* inc = incList.first(); | 2616 | Incidence* inc = incList.first(); |
2603 | int i; | 2617 | int i; |
2604 | int count = 0; | 2618 | int count = 0; |
2605 | while ( inc ) { | 2619 | while ( inc ) { |
2606 | catIncList = inc->categories() ; | 2620 | catIncList = inc->categories() ; |
2607 | for( i = 0; i< catIncList.count(); ++i ) { | 2621 | for( i = 0; i< catIncList.count(); ++i ) { |
2608 | if ( !catList.contains (catIncList[i])) { | 2622 | if ( !catList.contains (catIncList[i])) { |
2609 | catList.append( catIncList[i] ); | 2623 | catList.append( catIncList[i] ); |
2610 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2624 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2611 | ++count; | 2625 | ++count; |
2612 | } | 2626 | } |
2613 | } | 2627 | } |
2614 | inc = incList.next(); | 2628 | inc = incList.next(); |
2615 | } | 2629 | } |
2616 | catList.sort(); | 2630 | catList.sort(); |
2617 | KOPrefs::instance()->mCustomCategories = catList; | 2631 | KOPrefs::instance()->mCustomCategories = catList; |
2618 | return count; | 2632 | return count; |
2619 | } | 2633 | } |
2620 | 2634 | ||
2621 | void CalendarView::manageCategories() | 2635 | void CalendarView::manageCategories() |
2622 | { | 2636 | { |
2623 | KOCatPrefs* cp = new KOCatPrefs(); | 2637 | KOCatPrefs* cp = new KOCatPrefs(); |
2624 | cp->show(); | 2638 | cp->show(); |
2625 | int w =cp->sizeHint().width() ; | 2639 | int w =cp->sizeHint().width() ; |
2626 | int h = cp->sizeHint().height() ; | 2640 | int h = cp->sizeHint().height() ; |
2627 | int dw = QApplication::desktop()->width(); | 2641 | int dw = QApplication::desktop()->width(); |
2628 | int dh = QApplication::desktop()->height(); | 2642 | int dh = QApplication::desktop()->height(); |
2629 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2643 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2630 | if ( !cp->exec() ) { | 2644 | if ( !cp->exec() ) { |
2631 | delete cp; | 2645 | delete cp; |
2632 | return; | 2646 | return; |
2633 | } | 2647 | } |
2634 | int count = 0; | 2648 | int count = 0; |
2635 | if ( cp->addCat() ) { | 2649 | if ( cp->addCat() ) { |
2636 | count = addCategories(); | 2650 | count = addCategories(); |
2637 | if ( count ) { | 2651 | if ( count ) { |
2638 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2652 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2639 | writeSettings(); | 2653 | writeSettings(); |
2640 | } else | 2654 | } else |
2641 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2655 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2642 | } else { | 2656 | } else { |
2643 | removeCategories(); | 2657 | removeCategories(); |
2644 | updateView(); | 2658 | updateView(); |
2645 | } | 2659 | } |
2646 | delete cp; | 2660 | delete cp; |
2647 | } | 2661 | } |
2648 | 2662 | ||
2649 | void CalendarView::beamIncidence(Incidence * Inc) | 2663 | void CalendarView::beamIncidence(Incidence * Inc) |
2650 | { | 2664 | { |
2651 | QPtrList<Incidence> delSel ; | 2665 | QPtrList<Incidence> delSel ; |
2652 | delSel.append(Inc); | 2666 | delSel.append(Inc); |
2653 | beamIncidenceList( delSel ); | 2667 | beamIncidenceList( delSel ); |
2654 | } | 2668 | } |
2655 | void CalendarView::beamCalendar() | 2669 | void CalendarView::beamCalendar() |
2656 | { | 2670 | { |
2657 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2671 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2658 | //qDebug("beamCalendar() "); | 2672 | //qDebug("beamCalendar() "); |
2659 | beamIncidenceList( delSel ); | 2673 | beamIncidenceList( delSel ); |
2660 | } | 2674 | } |
2661 | void CalendarView::beamFilteredCalendar() | 2675 | void CalendarView::beamFilteredCalendar() |
2662 | { | 2676 | { |
2663 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2677 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2664 | //qDebug("beamFilteredCalendar() "); | 2678 | //qDebug("beamFilteredCalendar() "); |
2665 | beamIncidenceList( delSel ); | 2679 | beamIncidenceList( delSel ); |
2666 | } | 2680 | } |
2667 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2681 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2668 | { | 2682 | { |
2669 | if ( beamDialog->exec () == QDialog::Rejected ) | 2683 | if ( beamDialog->exec () == QDialog::Rejected ) |
2670 | return; | 2684 | return; |
2671 | #ifdef DESKTOP_VERSION | 2685 | #ifdef DESKTOP_VERSION |
2672 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2686 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2673 | #else | 2687 | #else |
2674 | QString fn = "/tmp/kopibeamfile"; | 2688 | QString fn = "/tmp/kopibeamfile"; |
2675 | #endif | 2689 | #endif |
2676 | QString mes; | 2690 | QString mes; |
2677 | bool createbup = true; | 2691 | bool createbup = true; |
2678 | if ( createbup ) { | 2692 | if ( createbup ) { |
2679 | QString description = "\n"; | 2693 | QString description = "\n"; |
2680 | CalendarLocal* cal = new CalendarLocal(); | 2694 | CalendarLocal* cal = new CalendarLocal(); |
2681 | if ( beamDialog->beamLocal() ) | 2695 | if ( beamDialog->beamLocal() ) |
2682 | cal->setLocalTime(); | 2696 | cal->setLocalTime(); |
2683 | else | 2697 | else |
2684 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2698 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2685 | Incidence *incidence = delSel.first(); | 2699 | Incidence *incidence = delSel.first(); |
2686 | bool addText = false; | 2700 | bool addText = false; |
2687 | if ( delSel.count() < 10 ) | 2701 | if ( delSel.count() < 10 ) |
2688 | addText = true; | 2702 | addText = true; |
2689 | else { | 2703 | else { |
2690 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2704 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2691 | } | 2705 | } |
2692 | while ( incidence ) { | 2706 | while ( incidence ) { |
2693 | Incidence *in = incidence->clone(); | 2707 | Incidence *in = incidence->clone(); |
2694 | if ( ! in->summary().isEmpty() ) { | 2708 | if ( ! in->summary().isEmpty() ) { |
2695 | in->setDescription(""); | 2709 | in->setDescription(""); |
2696 | } else { | 2710 | } else { |
2697 | in->setSummary( in->description().left(20)); | 2711 | in->setSummary( in->description().left(20)); |
2698 | in->setDescription(""); | 2712 | in->setDescription(""); |
2699 | } | 2713 | } |
2700 | if ( addText ) | 2714 | if ( addText ) |
2701 | description += in->summary() + "\n"; | 2715 | description += in->summary() + "\n"; |
2702 | cal->addIncidence( in ); | 2716 | cal->addIncidence( in ); |
2703 | incidence = delSel.next(); | 2717 | incidence = delSel.next(); |
2704 | } | 2718 | } |
2705 | if ( beamDialog->beamVcal() ) { | 2719 | if ( beamDialog->beamVcal() ) { |
2706 | fn += ".vcs"; | 2720 | fn += ".vcs"; |
2707 | FileStorage storage( cal, fn, new VCalFormat ); | 2721 | FileStorage storage( cal, fn, new VCalFormat ); |
2708 | storage.save(); | 2722 | storage.save(); |
2709 | } else { | 2723 | } else { |
2710 | fn += ".ics"; | 2724 | fn += ".ics"; |
2711 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2725 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2712 | storage.save(); | 2726 | storage.save(); |
2713 | } | 2727 | } |
2714 | delete cal; | 2728 | delete cal; |
2715 | mes = i18n("KO/Pi: Ready for beaming"); | 2729 | mes = i18n("KO/Pi: Ready for beaming"); |
2716 | topLevelWidget()->setCaption(mes); | 2730 | topLevelWidget()->setCaption(mes); |
2717 | KApplication::convert2latin1( fn ); | 2731 | KApplication::convert2latin1( fn ); |
2718 | #ifndef DESKTOP_VERSION | 2732 | #ifndef DESKTOP_VERSION |
2719 | Ir *ir = new Ir( this ); | 2733 | Ir *ir = new Ir( this ); |
2720 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2734 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2721 | ir->send( fn, description, "text/x-vCalendar" ); | 2735 | ir->send( fn, description, "text/x-vCalendar" ); |
2722 | #endif | 2736 | #endif |
2723 | } | 2737 | } |
2724 | } | 2738 | } |
2725 | void CalendarView::beamDone( Ir *ir ) | 2739 | void CalendarView::beamDone( Ir *ir ) |
2726 | { | 2740 | { |
2727 | #ifndef DESKTOP_VERSION | 2741 | #ifndef DESKTOP_VERSION |
2728 | delete ir; | 2742 | delete ir; |
2729 | #endif | 2743 | #endif |
2730 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2744 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2731 | topLevelWidget()->raise(); | 2745 | topLevelWidget()->raise(); |
2732 | } | 2746 | } |
2733 | 2747 | ||
2734 | void CalendarView::moveIncidence(Incidence * inc ) | 2748 | void CalendarView::moveIncidence(Incidence * inc ) |
2735 | { | 2749 | { |
2736 | if ( !inc ) return; | 2750 | if ( !inc ) return; |
2737 | showDatePickerPopup(); | 2751 | showDatePickerPopup(); |
2738 | mDatePickerMode = 2; | 2752 | mDatePickerMode = 2; |
2739 | mMoveIncidence = inc ; | 2753 | mMoveIncidence = inc ; |
2740 | QDate da; | 2754 | QDate da; |
2741 | if ( mMoveIncidence->type() == "Todo" ) { | 2755 | if ( mMoveIncidence->type() == "Todo" ) { |
2742 | Todo * to = (Todo *) mMoveIncidence; | 2756 | Todo * to = (Todo *) mMoveIncidence; |
2743 | if ( to->hasDueDate() ) | 2757 | if ( to->hasDueDate() ) |
2744 | da = to->dtDue().date(); | 2758 | da = to->dtDue().date(); |
2745 | else | 2759 | else |
2746 | da = QDate::currentDate(); | 2760 | da = QDate::currentDate(); |
2747 | } else { | 2761 | } else { |
2748 | da = mMoveIncidence->dtStart().date(); | 2762 | da = mMoveIncidence->dtStart().date(); |
2749 | } | 2763 | } |
2750 | //PENDING set date for recurring incidence to date of recurrence | 2764 | //PENDING set date for recurring incidence to date of recurrence |
2751 | //mMoveIncidenceOldDate; | 2765 | //mMoveIncidenceOldDate; |
2752 | mDatePicker->setDate( da ); | 2766 | mDatePicker->setDate( da ); |
2753 | } | 2767 | } |
2754 | void CalendarView::showDatePickerPopup() | 2768 | void CalendarView::showDatePickerPopup() |
2755 | { | 2769 | { |
2756 | if ( mDateFrame->isVisible() ) | 2770 | if ( mDateFrame->isVisible() ) |
2757 | mDateFrame->hide(); | 2771 | mDateFrame->hide(); |
2758 | else { | 2772 | else { |
2759 | int offX = 0, offY = 0; | 2773 | int offX = 0, offY = 0; |
2760 | #ifdef DESKTOP_VERSION | 2774 | #ifdef DESKTOP_VERSION |
2761 | int w =mDatePicker->sizeHint().width() ; | 2775 | int w =mDatePicker->sizeHint().width() ; |
2762 | int h = mDatePicker->sizeHint().height() ; | 2776 | int h = mDatePicker->sizeHint().height() ; |
2763 | int dw = topLevelWidget()->width(); | 2777 | int dw = topLevelWidget()->width(); |
2764 | int dh = topLevelWidget()->height(); | 2778 | int dh = topLevelWidget()->height(); |
2765 | offX = topLevelWidget()->x(); | 2779 | offX = topLevelWidget()->x(); |
2766 | offY = topLevelWidget()->y(); | 2780 | offY = topLevelWidget()->y(); |
2767 | #else | 2781 | #else |
2768 | int w =mDatePicker->sizeHint().width() ; | 2782 | int w =mDatePicker->sizeHint().width() ; |
2769 | int h = mDatePicker->sizeHint().height() ; | 2783 | int h = mDatePicker->sizeHint().height() ; |
2770 | int dw = QApplication::desktop()->width(); | 2784 | int dw = QApplication::desktop()->width(); |
2771 | int dh = QApplication::desktop()->height(); | 2785 | int dh = QApplication::desktop()->height(); |
2772 | #endif | 2786 | #endif |
2773 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2787 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2774 | mDateFrame->show(); | 2788 | mDateFrame->show(); |
2775 | } | 2789 | } |
2776 | } | 2790 | } |
2777 | void CalendarView::showDatePicker( ) | 2791 | void CalendarView::showDatePicker( ) |
2778 | { | 2792 | { |
2779 | showDatePickerPopup(); | 2793 | showDatePickerPopup(); |
2780 | mDatePickerMode = 1; | 2794 | mDatePickerMode = 1; |
2781 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2795 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2782 | } | 2796 | } |
2783 | 2797 | ||
2784 | void CalendarView::showEventEditor() | 2798 | void CalendarView::showEventEditor() |
2785 | { | 2799 | { |
2786 | #ifdef DESKTOP_VERSION | 2800 | #ifdef DESKTOP_VERSION |
2787 | int x,y,w,h; | 2801 | int x,y,w,h; |
2788 | x = mEventEditor->geometry().x(); | 2802 | x = mEventEditor->geometry().x(); |
2789 | y = mEventEditor->geometry().y(); | 2803 | y = mEventEditor->geometry().y(); |
2790 | w = mEventEditor->width(); | 2804 | w = mEventEditor->width(); |
2791 | h = mEventEditor->height(); | 2805 | h = mEventEditor->height(); |
2792 | mEventEditor->show(); | 2806 | mEventEditor->show(); |
2793 | mEventEditor->setGeometry(x,y,w,h); | 2807 | mEventEditor->setGeometry(x,y,w,h); |
2794 | #else | 2808 | #else |
2795 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2809 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2796 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2810 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2797 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2811 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2798 | qApp->processEvents(); | 2812 | qApp->processEvents(); |
2799 | delete mEventEditor; | 2813 | delete mEventEditor; |
2800 | mEventEditor = mDialogManager->getEventEditor(); | 2814 | mEventEditor = mDialogManager->getEventEditor(); |
2801 | topLevelWidget()->setCaption( i18n("") ); | 2815 | topLevelWidget()->setCaption( i18n("") ); |
2802 | } | 2816 | } |
2803 | mEventEditor->showMaximized(); | 2817 | mEventEditor->showMaximized(); |
2804 | #endif | 2818 | #endif |
2805 | } | 2819 | } |
2806 | void CalendarView::showTodoEditor() | 2820 | void CalendarView::showTodoEditor() |
2807 | { | 2821 | { |
2808 | #ifdef DESKTOP_VERSION | 2822 | #ifdef DESKTOP_VERSION |
2809 | int x,y,w,h; | 2823 | int x,y,w,h; |
2810 | x = mTodoEditor->geometry().x(); | 2824 | x = mTodoEditor->geometry().x(); |
2811 | y = mTodoEditor->geometry().y(); | 2825 | y = mTodoEditor->geometry().y(); |
2812 | w = mTodoEditor->width(); | 2826 | w = mTodoEditor->width(); |
2813 | h = mTodoEditor->height(); | 2827 | h = mTodoEditor->height(); |
2814 | mTodoEditor->show(); | 2828 | mTodoEditor->show(); |
2815 | mTodoEditor->setGeometry(x,y,w,h); | 2829 | mTodoEditor->setGeometry(x,y,w,h); |
2816 | #else | 2830 | #else |
2817 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2831 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2818 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2832 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2819 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2833 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2820 | qApp->processEvents(); | 2834 | qApp->processEvents(); |
2821 | delete mTodoEditor; | 2835 | delete mTodoEditor; |
2822 | mTodoEditor = mDialogManager->getTodoEditor(); | 2836 | mTodoEditor = mDialogManager->getTodoEditor(); |
2823 | topLevelWidget()->setCaption( i18n("") ); | 2837 | topLevelWidget()->setCaption( i18n("") ); |
2824 | } | 2838 | } |
2825 | mTodoEditor->showMaximized(); | 2839 | mTodoEditor->showMaximized(); |
2826 | #endif | 2840 | #endif |
2827 | } | 2841 | } |
2828 | 2842 | ||
2829 | void CalendarView::cloneIncidence() | 2843 | void CalendarView::cloneIncidence() |
2830 | { | 2844 | { |
2831 | Incidence *incidence = currentSelection(); | 2845 | Incidence *incidence = currentSelection(); |
2832 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2846 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2833 | if ( incidence ) { | 2847 | if ( incidence ) { |
2834 | cloneIncidence(incidence); | 2848 | cloneIncidence(incidence); |
2835 | } | 2849 | } |
2836 | } | 2850 | } |
2837 | void CalendarView::moveIncidence() | 2851 | void CalendarView::moveIncidence() |
2838 | { | 2852 | { |
2839 | Incidence *incidence = currentSelection(); | 2853 | Incidence *incidence = currentSelection(); |
2840 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2854 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2841 | if ( incidence ) { | 2855 | if ( incidence ) { |
2842 | moveIncidence(incidence); | 2856 | moveIncidence(incidence); |
2843 | } | 2857 | } |
2844 | } | 2858 | } |
2845 | void CalendarView::beamIncidence() | 2859 | void CalendarView::beamIncidence() |
2846 | { | 2860 | { |
2847 | Incidence *incidence = currentSelection(); | 2861 | Incidence *incidence = currentSelection(); |
2848 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2862 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2849 | if ( incidence ) { | 2863 | if ( incidence ) { |
2850 | beamIncidence(incidence); | 2864 | beamIncidence(incidence); |
2851 | } | 2865 | } |
2852 | } | 2866 | } |
2853 | void CalendarView::toggleCancelIncidence() | 2867 | void CalendarView::toggleCancelIncidence() |
2854 | { | 2868 | { |
2855 | Incidence *incidence = currentSelection(); | 2869 | Incidence *incidence = currentSelection(); |
2856 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2870 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2857 | if ( incidence ) { | 2871 | if ( incidence ) { |
2858 | cancelIncidence(incidence); | 2872 | cancelIncidence(incidence); |
2859 | } | 2873 | } |
2860 | } | 2874 | } |
2861 | 2875 | ||
2862 | 2876 | ||
2863 | void CalendarView::cancelIncidence(Incidence * inc ) | 2877 | void CalendarView::cancelIncidence(Incidence * inc ) |
2864 | { | 2878 | { |
2865 | inc->setCancelled( ! inc->cancelled() ); | 2879 | inc->setCancelled( ! inc->cancelled() ); |
2866 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2880 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2867 | updateView(); | 2881 | updateView(); |
2868 | } | 2882 | } |
2869 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2883 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2870 | { | 2884 | { |
2871 | Incidence * newInc = orgInc->clone(); | 2885 | Incidence * newInc = orgInc->clone(); |
2872 | newInc->recreate(); | 2886 | newInc->recreate(); |
2873 | 2887 | ||
2874 | if ( newInc->type() == "Todo" ) { | 2888 | if ( newInc->type() == "Todo" ) { |
2875 | Todo* t = (Todo*) newInc; | 2889 | Todo* t = (Todo*) newInc; |
2876 | bool cloneSub = false; | 2890 | bool cloneSub = false; |
2877 | if ( orgInc->relations().count() ) { | 2891 | if ( orgInc->relations().count() ) { |
2878 | int result = KMessageBox::warningYesNoCancel(this, | 2892 | int result = KMessageBox::warningYesNoCancel(this, |
2879 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), | 2893 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), |
2880 | i18n("Todo has subtodos"), | 2894 | i18n("Todo has subtodos"), |
2881 | i18n("Yes"), | 2895 | i18n("Yes"), |
2882 | i18n("No")); | 2896 | i18n("No")); |
2883 | 2897 | ||
2884 | if ( result == KMessageBox::Cancel ) { | 2898 | if ( result == KMessageBox::Cancel ) { |
2885 | delete t; | 2899 | delete t; |
2886 | return; | 2900 | return; |
2887 | } | 2901 | } |
2888 | if (result == KMessageBox::Yes) cloneSub = true; | 2902 | if (result == KMessageBox::Yes) cloneSub = true; |
2889 | } | 2903 | } |
2890 | showTodoEditor(); | 2904 | showTodoEditor(); |
2891 | mTodoEditor->editTodo( t ); | 2905 | mTodoEditor->editTodo( t ); |
2892 | if ( mTodoEditor->exec() ) { | 2906 | if ( mTodoEditor->exec() ) { |
2893 | if ( cloneSub ) { | 2907 | if ( cloneSub ) { |
2894 | orgInc->cloneRelations( t ); | 2908 | orgInc->cloneRelations( t ); |
2895 | mCalendar->addIncidenceBranch( t ); | 2909 | mCalendar->addIncidenceBranch( t ); |
2896 | updateView(); | 2910 | updateView(); |
2897 | 2911 | ||
2898 | } else { | 2912 | } else { |
2899 | mCalendar->addTodo( t ); | 2913 | mCalendar->addTodo( t ); |
2900 | updateView(); | 2914 | updateView(); |
2901 | } | 2915 | } |
2902 | } else { | 2916 | } else { |
2903 | delete t; | 2917 | delete t; |
2904 | } | 2918 | } |
2905 | } | 2919 | } |
2906 | else { | 2920 | else { |
2907 | Event* e = (Event*) newInc; | 2921 | Event* e = (Event*) newInc; |
2908 | showEventEditor(); | 2922 | showEventEditor(); |
2909 | mEventEditor->editEvent( e ); | 2923 | mEventEditor->editEvent( e ); |
2910 | if ( mEventEditor->exec() ) { | 2924 | if ( mEventEditor->exec() ) { |
2911 | mCalendar->addEvent( e ); | 2925 | mCalendar->addEvent( e ); |
2912 | updateView(); | 2926 | updateView(); |
2913 | } else { | 2927 | } else { |
2914 | delete e; | 2928 | delete e; |
2915 | } | 2929 | } |
2916 | } | 2930 | } |
2917 | setActiveWindow(); | 2931 | setActiveWindow(); |
2918 | } | 2932 | } |
2919 | 2933 | ||
2920 | void CalendarView::newEvent() | 2934 | void CalendarView::newEvent() |
2921 | { | 2935 | { |
2922 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2936 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2923 | KOAgendaView *aView = mViewManager->agendaView(); | 2937 | KOAgendaView *aView = mViewManager->agendaView(); |
2924 | if (aView) { | 2938 | if (aView) { |
2925 | if (aView->selectionStart().isValid()) { | 2939 | if (aView->selectionStart().isValid()) { |
2926 | if (aView->selectedIsAllDay()) { | 2940 | if (aView->selectedIsAllDay()) { |
2927 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2941 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2928 | } else { | 2942 | } else { |
2929 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2943 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2930 | } | 2944 | } |
2931 | return; | 2945 | return; |
2932 | } | 2946 | } |
2933 | } | 2947 | } |
2934 | 2948 | ||
2935 | QDate date = mNavigator->selectedDates().first(); | 2949 | QDate date = mNavigator->selectedDates().first(); |
2936 | QDateTime current = QDateTime::currentDateTime(); | 2950 | QDateTime current = QDateTime::currentDateTime(); |
2937 | if ( date <= current.date() ) { | 2951 | if ( date <= current.date() ) { |
2938 | int hour = current.time().hour() +1; | 2952 | int hour = current.time().hour() +1; |
2939 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2953 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2940 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2954 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2941 | } else | 2955 | } else |
2942 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2956 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2943 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2957 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2944 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2958 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2945 | } | 2959 | } |
2946 | 2960 | ||
2947 | void CalendarView::newEvent(QDateTime fh) | 2961 | void CalendarView::newEvent(QDateTime fh) |
2948 | { | 2962 | { |
2949 | newEvent(fh, | 2963 | newEvent(fh, |
2950 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2964 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2951 | } | 2965 | } |
2952 | 2966 | ||
2953 | void CalendarView::newEvent(QDate dt) | 2967 | void CalendarView::newEvent(QDate dt) |
2954 | { | 2968 | { |
2955 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2969 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2956 | QDateTime(dt, QTime(0,0,0)), true); | 2970 | QDateTime(dt, QTime(0,0,0)), true); |
2957 | } | 2971 | } |
2958 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2972 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2959 | { | 2973 | { |
2960 | newEvent(fromHint, toHint, false); | 2974 | newEvent(fromHint, toHint, false); |
2961 | } | 2975 | } |
2962 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2976 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2963 | { | 2977 | { |
2964 | 2978 | ||
2965 | showEventEditor(); | 2979 | showEventEditor(); |
2966 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2980 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2967 | if ( mFilterView->filtersEnabled() ) { | 2981 | if ( mFilterView->filtersEnabled() ) { |
2968 | CalFilter *filter = mFilterView->selectedFilter(); | 2982 | CalFilter *filter = mFilterView->selectedFilter(); |
2969 | if (filter && filter->showCategories()) { | 2983 | if (filter && filter->showCategories()) { |
2970 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2984 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2971 | } | 2985 | } |
2972 | if ( filter ) | 2986 | if ( filter ) |
2973 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2987 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2974 | } | 2988 | } |
2975 | mEventEditor->exec(); | 2989 | mEventEditor->exec(); |
2976 | setActiveWindow(); | 2990 | setActiveWindow(); |
2977 | } | 2991 | } |
2978 | void CalendarView::todoAdded(Todo * t) | 2992 | void CalendarView::todoAdded(Todo * t) |
2979 | { | 2993 | { |
2980 | 2994 | ||
2981 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2995 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2982 | updateTodoViews(); | 2996 | updateTodoViews(); |
2983 | } | 2997 | } |
2984 | void CalendarView::todoChanged(Todo * t) | 2998 | void CalendarView::todoChanged(Todo * t) |
2985 | { | 2999 | { |
2986 | emit todoModified( t, 4 ); | 3000 | emit todoModified( t, 4 ); |
2987 | // updateTodoViews(); | 3001 | // updateTodoViews(); |
2988 | } | 3002 | } |
2989 | void CalendarView::todoToBeDeleted(Todo *) | 3003 | void CalendarView::todoToBeDeleted(Todo *) |
2990 | { | 3004 | { |
2991 | //qDebug("todoToBeDeleted(Todo *) "); | 3005 | //qDebug("todoToBeDeleted(Todo *) "); |
2992 | updateTodoViews(); | 3006 | updateTodoViews(); |
2993 | } | 3007 | } |
2994 | void CalendarView::todoDeleted() | 3008 | void CalendarView::todoDeleted() |
2995 | { | 3009 | { |
2996 | //qDebug(" todoDeleted()"); | 3010 | //qDebug(" todoDeleted()"); |
2997 | updateTodoViews(); | 3011 | updateTodoViews(); |
2998 | } | 3012 | } |
2999 | 3013 | ||
3000 | 3014 | ||
3001 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3015 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3002 | { | 3016 | { |
3003 | showTodoEditor(); | 3017 | showTodoEditor(); |
3004 | mTodoEditor->newTodo(dt,0,allday); | 3018 | mTodoEditor->newTodo(dt,0,allday); |
3005 | if ( mFilterView->filtersEnabled() ) { | 3019 | if ( mFilterView->filtersEnabled() ) { |
3006 | CalFilter *filter = mFilterView->selectedFilter(); | 3020 | CalFilter *filter = mFilterView->selectedFilter(); |
3007 | if (filter && filter->showCategories()) { | 3021 | if (filter && filter->showCategories()) { |
3008 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3022 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3009 | } | 3023 | } |
3010 | if ( filter ) | 3024 | if ( filter ) |
3011 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3025 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3012 | } | 3026 | } |
3013 | mTodoEditor->exec(); | 3027 | mTodoEditor->exec(); |
3014 | setActiveWindow(); | 3028 | setActiveWindow(); |
3015 | } | 3029 | } |
3016 | 3030 | ||
3017 | void CalendarView::newTodo() | 3031 | void CalendarView::newTodo() |
3018 | { | 3032 | { |
3019 | newTodoDateTime( QDateTime(),true ); | 3033 | newTodoDateTime( QDateTime(),true ); |
3020 | } | 3034 | } |
3021 | 3035 | ||
3022 | void CalendarView::newSubTodo() | 3036 | void CalendarView::newSubTodo() |
3023 | { | 3037 | { |
3024 | Todo *todo = selectedTodo(); | 3038 | Todo *todo = selectedTodo(); |
3025 | if ( todo ) newSubTodo( todo ); | 3039 | if ( todo ) newSubTodo( todo ); |
3026 | } | 3040 | } |
3027 | 3041 | ||
3028 | void CalendarView::newSubTodo(Todo *parentEvent) | 3042 | void CalendarView::newSubTodo(Todo *parentEvent) |
3029 | { | 3043 | { |
3030 | 3044 | ||
3031 | showTodoEditor(); | 3045 | showTodoEditor(); |
3032 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3046 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3033 | mTodoEditor->exec(); | 3047 | mTodoEditor->exec(); |
3034 | setActiveWindow(); | 3048 | setActiveWindow(); |
3035 | } | 3049 | } |
3036 | 3050 | ||
3037 | void CalendarView::newFloatingEvent() | 3051 | void CalendarView::newFloatingEvent() |
3038 | { | 3052 | { |
3039 | DateList tmpList = mNavigator->selectedDates(); | 3053 | DateList tmpList = mNavigator->selectedDates(); |
3040 | QDate date = tmpList.first(); | 3054 | QDate date = tmpList.first(); |
3041 | 3055 | ||
3042 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3056 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3043 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3057 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3044 | } | 3058 | } |
3045 | 3059 | ||
3046 | 3060 | ||
3047 | void CalendarView::editEvent( Event *event ) | 3061 | void CalendarView::editEvent( Event *event ) |
3048 | { | 3062 | { |
3049 | 3063 | ||
3050 | if ( !event ) return; | 3064 | if ( !event ) return; |
3051 | if ( event->isReadOnly() ) { | 3065 | if ( event->isReadOnly() ) { |
3052 | showEvent( event ); | 3066 | showEvent( event ); |
3053 | return; | 3067 | return; |
3054 | } | 3068 | } |
3055 | showEventEditor(); | 3069 | showEventEditor(); |
3056 | mEventEditor->editEvent( event , mFlagEditDescription); | 3070 | mEventEditor->editEvent( event , mFlagEditDescription); |
3057 | mEventEditor->exec(); | 3071 | mEventEditor->exec(); |
3058 | setActiveWindow(); | 3072 | setActiveWindow(); |
3059 | 3073 | ||
3060 | } | 3074 | } |
3061 | void CalendarView::editJournal( Journal *jour ) | 3075 | void CalendarView::editJournal( Journal *jour ) |
3062 | { | 3076 | { |
3063 | if ( !jour ) return; | 3077 | if ( !jour ) return; |
3064 | mDialogManager->hideSearchDialog(); | 3078 | mDialogManager->hideSearchDialog(); |
3065 | mViewManager->showJournalView(); | 3079 | mViewManager->showJournalView(); |
3066 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3080 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3067 | } | 3081 | } |
3068 | void CalendarView::editTodo( Todo *todo ) | 3082 | void CalendarView::editTodo( Todo *todo ) |
3069 | { | 3083 | { |
3070 | if ( !todo ) return; | 3084 | if ( !todo ) return; |
3071 | 3085 | ||
3072 | if ( todo->isReadOnly() ) { | 3086 | if ( todo->isReadOnly() ) { |
3073 | showTodo( todo ); | 3087 | showTodo( todo ); |
3074 | return; | 3088 | return; |
3075 | } | 3089 | } |
3076 | showTodoEditor(); | 3090 | showTodoEditor(); |
3077 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3091 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3078 | mTodoEditor->exec(); | 3092 | mTodoEditor->exec(); |
3079 | setActiveWindow(); | 3093 | setActiveWindow(); |
3080 | 3094 | ||
3081 | } | 3095 | } |
3082 | 3096 | ||
3083 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3097 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3084 | { | 3098 | { |
3085 | if ( !mEventViewerDialog ) { | 3099 | if ( !mEventViewerDialog ) { |
3086 | mEventViewerDialog = new KOEventViewerDialog(0); | 3100 | mEventViewerDialog = new KOEventViewerDialog(0); |
3087 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3101 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3088 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3102 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3089 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3103 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3090 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3104 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3091 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3105 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3092 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3106 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3093 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3107 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3094 | this, SLOT( slotViewerClosed() ) ); | 3108 | this, SLOT( slotViewerClosed() ) ); |
3095 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3109 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3096 | this, SLOT( todoChanged(Todo *) ) ); | 3110 | this, SLOT( todoChanged(Todo *) ) ); |
3097 | mEventViewerDialog->resize( 640, 480 ); | 3111 | mEventViewerDialog->resize( 640, 480 ); |
3098 | 3112 | ||
3099 | } | 3113 | } |
3100 | return mEventViewerDialog; | 3114 | return mEventViewerDialog; |
3101 | } | 3115 | } |
3102 | void CalendarView::showEvent(Event *event) | 3116 | void CalendarView::showEvent(Event *event) |
3103 | { | 3117 | { |
3104 | getEventViewerDialog()->setEvent(event); | 3118 | getEventViewerDialog()->setEvent(event); |
3105 | getEventViewerDialog()->showMe(); | 3119 | getEventViewerDialog()->showMe(); |
3106 | } | 3120 | } |
3107 | 3121 | ||
3108 | void CalendarView::showTodo(Todo *event) | 3122 | void CalendarView::showTodo(Todo *event) |
3109 | { | 3123 | { |
3110 | getEventViewerDialog()->setTodo(event); | 3124 | getEventViewerDialog()->setTodo(event); |
3111 | getEventViewerDialog()->showMe(); | 3125 | getEventViewerDialog()->showMe(); |
3112 | } | 3126 | } |
3113 | void CalendarView::showJournal( Journal *jour ) | 3127 | void CalendarView::showJournal( Journal *jour ) |
3114 | { | 3128 | { |
3115 | getEventViewerDialog()->setJournal(jour); | 3129 | getEventViewerDialog()->setJournal(jour); |
3116 | getEventViewerDialog()->showMe(); | 3130 | getEventViewerDialog()->showMe(); |
3117 | 3131 | ||
3118 | } | 3132 | } |
3119 | // void CalendarView::todoModified (Todo *event, int changed) | 3133 | // void CalendarView::todoModified (Todo *event, int changed) |
3120 | // { | 3134 | // { |
3121 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3135 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3122 | // // kdDebug() << "Todo modified and open" << endl; | 3136 | // // kdDebug() << "Todo modified and open" << endl; |
3123 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3137 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3124 | // // temp->modified (changed); | 3138 | // // temp->modified (changed); |
3125 | 3139 | ||
3126 | // // } | 3140 | // // } |
3127 | 3141 | ||
3128 | // mViewManager->updateView(); | 3142 | // mViewManager->updateView(); |
3129 | // } | 3143 | // } |
3130 | 3144 | ||
3131 | void CalendarView::appointment_show() | 3145 | void CalendarView::appointment_show() |
3132 | { | 3146 | { |
3133 | Event *anEvent = 0; | 3147 | Event *anEvent = 0; |
3134 | 3148 | ||
3135 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3149 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3136 | 3150 | ||
3137 | if (mViewManager->currentView()->isEventView()) { | 3151 | if (mViewManager->currentView()->isEventView()) { |
3138 | if ( incidence && incidence->type() == "Event" ) { | 3152 | if ( incidence && incidence->type() == "Event" ) { |
3139 | anEvent = static_cast<Event *>(incidence); | 3153 | anEvent = static_cast<Event *>(incidence); |
3140 | } | 3154 | } |
3141 | } | 3155 | } |
3142 | 3156 | ||
3143 | if (!anEvent) { | 3157 | if (!anEvent) { |
3144 | KNotifyClient::beep(); | 3158 | KNotifyClient::beep(); |
3145 | return; | 3159 | return; |
3146 | } | 3160 | } |
3147 | 3161 | ||
3148 | showEvent(anEvent); | 3162 | showEvent(anEvent); |
3149 | } | 3163 | } |
3150 | 3164 | ||
3151 | void CalendarView::appointment_edit() | 3165 | void CalendarView::appointment_edit() |
3152 | { | 3166 | { |
3153 | Event *anEvent = 0; | 3167 | Event *anEvent = 0; |
3154 | 3168 | ||
3155 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3169 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3156 | 3170 | ||
3157 | if (mViewManager->currentView()->isEventView()) { | 3171 | if (mViewManager->currentView()->isEventView()) { |
3158 | if ( incidence && incidence->type() == "Event" ) { | 3172 | if ( incidence && incidence->type() == "Event" ) { |
3159 | anEvent = static_cast<Event *>(incidence); | 3173 | anEvent = static_cast<Event *>(incidence); |
3160 | } | 3174 | } |
3161 | } | 3175 | } |
3162 | 3176 | ||
3163 | if (!anEvent) { | 3177 | if (!anEvent) { |
3164 | KNotifyClient::beep(); | 3178 | KNotifyClient::beep(); |
3165 | return; | 3179 | return; |
3166 | } | 3180 | } |
3167 | 3181 | ||
3168 | editEvent(anEvent); | 3182 | editEvent(anEvent); |
3169 | } | 3183 | } |
3170 | 3184 | ||
3171 | void CalendarView::appointment_delete() | 3185 | void CalendarView::appointment_delete() |
3172 | { | 3186 | { |
3173 | Event *anEvent = 0; | 3187 | Event *anEvent = 0; |
3174 | 3188 | ||
3175 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3189 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3176 | 3190 | ||
3177 | if (mViewManager->currentView()->isEventView()) { | 3191 | if (mViewManager->currentView()->isEventView()) { |
3178 | if ( incidence && incidence->type() == "Event" ) { | 3192 | if ( incidence && incidence->type() == "Event" ) { |
3179 | anEvent = static_cast<Event *>(incidence); | 3193 | anEvent = static_cast<Event *>(incidence); |
3180 | } | 3194 | } |
3181 | } | 3195 | } |
3182 | 3196 | ||
3183 | if (!anEvent) { | 3197 | if (!anEvent) { |
3184 | KNotifyClient::beep(); | 3198 | KNotifyClient::beep(); |
3185 | return; | 3199 | return; |
3186 | } | 3200 | } |
3187 | 3201 | ||
3188 | deleteEvent(anEvent); | 3202 | deleteEvent(anEvent); |
3189 | } | 3203 | } |
3190 | 3204 | ||
3191 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3205 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3192 | { | 3206 | { |
3193 | if (!sub) return; | 3207 | if (!sub) return; |
3194 | if ( sub->relatedTo() == parent ) | 3208 | if ( sub->relatedTo() == parent ) |
3195 | return; | 3209 | return; |
3196 | sub->setRelatedTo(parent); | 3210 | sub->setRelatedTo(parent); |
3197 | sub->updated(); | 3211 | sub->updated(); |
3198 | setModified(true); | 3212 | setModified(true); |
3199 | updateView(); | 3213 | updateView(); |
3200 | } | 3214 | } |
3201 | void CalendarView::todo_unsub(Todo *anTodo ) | 3215 | void CalendarView::todo_unsub(Todo *anTodo ) |
3202 | { | 3216 | { |
3203 | todo_resub( 0, anTodo ); | 3217 | todo_resub( 0, anTodo ); |
3204 | } | 3218 | } |
3205 | 3219 | ||
3206 | void CalendarView::deleteTodo(Todo *todo) | 3220 | void CalendarView::deleteTodo(Todo *todo) |
3207 | { | 3221 | { |
3208 | if (!todo) { | 3222 | if (!todo) { |
3209 | KNotifyClient::beep(); | 3223 | KNotifyClient::beep(); |
3210 | return; | 3224 | return; |
3211 | } | 3225 | } |
3212 | if (KOPrefs::instance()->mConfirm) { | 3226 | if (KOPrefs::instance()->mConfirm) { |
3213 | QString text = todo->summary().left(20); | 3227 | QString text = todo->summary().left(20); |
3214 | if (!todo->relations().isEmpty()) { | 3228 | if (!todo->relations().isEmpty()) { |
3215 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3229 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3216 | 3230 | ||
3217 | } | 3231 | } |
3218 | switch (msgItemDelete(text)) { | 3232 | switch (msgItemDelete(text)) { |
3219 | case KMessageBox::Continue: // OK | 3233 | case KMessageBox::Continue: // OK |
3220 | bool deleteT = false; | 3234 | bool deleteT = false; |
3221 | if (!todo->relations().isEmpty()) { | 3235 | if (!todo->relations().isEmpty()) { |
3222 | deleteT = removeCompletedSubTodos( todo ); | 3236 | deleteT = removeCompletedSubTodos( todo ); |
3223 | } | 3237 | } |
3224 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3238 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3225 | if ( !deleteT ) { | 3239 | if ( !deleteT ) { |
3226 | checkExternalId( todo ); | 3240 | checkExternalId( todo ); |
3227 | calendar()->deleteTodo(todo); | 3241 | calendar()->deleteTodo(todo); |
3228 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3242 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3229 | updateView(); | 3243 | updateView(); |
3230 | } | 3244 | } |
3231 | break; | 3245 | break; |
3232 | } // switch | 3246 | } // switch |
3233 | } else { | 3247 | } else { |
3234 | checkExternalId( todo ); | 3248 | checkExternalId( todo ); |
3235 | mCalendar->deleteTodo(todo); | 3249 | mCalendar->deleteTodo(todo); |
3236 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3250 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3237 | updateView(); | 3251 | updateView(); |
3238 | } | 3252 | } |
3239 | 3253 | ||
3240 | emit updateSearchDialog(); | 3254 | emit updateSearchDialog(); |
3241 | } | 3255 | } |
3242 | void CalendarView::deleteJournal(Journal *jour) | 3256 | void CalendarView::deleteJournal(Journal *jour) |
3243 | { | 3257 | { |
3244 | if (!jour) { | 3258 | if (!jour) { |
3245 | KNotifyClient::beep(); | 3259 | KNotifyClient::beep(); |
3246 | return; | 3260 | return; |
3247 | } | 3261 | } |
3248 | if (KOPrefs::instance()->mConfirm) { | 3262 | if (KOPrefs::instance()->mConfirm) { |
3249 | switch (msgItemDelete( jour->description().left(20))) { | 3263 | switch (msgItemDelete( jour->description().left(20))) { |
3250 | case KMessageBox::Continue: // OK | 3264 | case KMessageBox::Continue: // OK |
3251 | calendar()->deleteJournal(jour); | 3265 | calendar()->deleteJournal(jour); |
3252 | updateView(); | 3266 | updateView(); |
3253 | break; | 3267 | break; |
3254 | } // switch | 3268 | } // switch |
3255 | } else { | 3269 | } else { |
3256 | calendar()->deleteJournal(jour);; | 3270 | calendar()->deleteJournal(jour);; |
3257 | updateView(); | 3271 | updateView(); |
3258 | } | 3272 | } |
3259 | emit updateSearchDialog(); | 3273 | emit updateSearchDialog(); |
3260 | } | 3274 | } |
3261 | 3275 | ||
3262 | void CalendarView::deleteEvent(Event *anEvent) | 3276 | void CalendarView::deleteEvent(Event *anEvent) |
3263 | { | 3277 | { |
3264 | if (!anEvent) { | 3278 | if (!anEvent) { |
3265 | KNotifyClient::beep(); | 3279 | KNotifyClient::beep(); |
3266 | return; | 3280 | return; |
3267 | } | 3281 | } |
3268 | 3282 | ||
3269 | if (anEvent->recurrence()->doesRecur()) { | 3283 | if (anEvent->recurrence()->doesRecur()) { |
3270 | QDate itemDate = mViewManager->currentSelectionDate(); | 3284 | QDate itemDate = mViewManager->currentSelectionDate(); |
3271 | int km; | 3285 | int km; |
3272 | if (!itemDate.isValid()) { | 3286 | if (!itemDate.isValid()) { |
3273 | //kdDebug() << "Date Not Valid" << endl; | 3287 | //kdDebug() << "Date Not Valid" << endl; |
3274 | if (KOPrefs::instance()->mConfirm) { | 3288 | if (KOPrefs::instance()->mConfirm) { |
3275 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3289 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3276 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3290 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3277 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3291 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3278 | if ( km == KMessageBox::Continue ) | 3292 | if ( km == KMessageBox::Continue ) |
3279 | km = KMessageBox::No; // No = all below | 3293 | km = KMessageBox::No; // No = all below |
3280 | } else | 3294 | } else |
3281 | km = KMessageBox::No; | 3295 | km = KMessageBox::No; |
3282 | } else { | 3296 | } else { |
3283 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3297 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3284 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3298 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3285 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3299 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3286 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3300 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3287 | i18n("All")); | 3301 | i18n("All")); |
3288 | } | 3302 | } |
3289 | switch(km) { | 3303 | switch(km) { |
3290 | 3304 | ||
3291 | case KMessageBox::No: // Continue // all | 3305 | case KMessageBox::No: // Continue // all |
3292 | //qDebug("KMessageBox::No "); | 3306 | //qDebug("KMessageBox::No "); |
3293 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3307 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3294 | schedule(Scheduler::Cancel,anEvent); | 3308 | schedule(Scheduler::Cancel,anEvent); |
3295 | 3309 | ||
3296 | checkExternalId( anEvent); | 3310 | checkExternalId( anEvent); |
3297 | mCalendar->deleteEvent(anEvent); | 3311 | mCalendar->deleteEvent(anEvent); |
3298 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3312 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3299 | break; | 3313 | break; |
3300 | 3314 | ||
3301 | // Disabled because it does not work | 3315 | // Disabled because it does not work |
3302 | //#if 0 | 3316 | //#if 0 |
3303 | case KMessageBox::Yes: // just this one | 3317 | case KMessageBox::Yes: // just this one |
3304 | //QDate qd = mNavigator->selectedDates().first(); | 3318 | //QDate qd = mNavigator->selectedDates().first(); |
3305 | //if (!qd.isValid()) { | 3319 | //if (!qd.isValid()) { |
3306 | // kdDebug() << "no date selected, or invalid date" << endl; | 3320 | // kdDebug() << "no date selected, or invalid date" << endl; |
3307 | // KNotifyClient::beep(); | 3321 | // KNotifyClient::beep(); |
3308 | // return; | 3322 | // return; |
3309 | //} | 3323 | //} |
3310 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3324 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3311 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3325 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3312 | anEvent->addExDate(itemDate); | 3326 | anEvent->addExDate(itemDate); |
3313 | int duration = anEvent->recurrence()->duration(); | 3327 | int duration = anEvent->recurrence()->duration(); |
3314 | if ( duration > 0 ) { | 3328 | if ( duration > 0 ) { |
3315 | anEvent->recurrence()->setDuration( duration - 1 ); | 3329 | anEvent->recurrence()->setDuration( duration - 1 ); |
3316 | } | 3330 | } |
3317 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3331 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3318 | } | 3332 | } |
3319 | break; | 3333 | break; |
3320 | //#endif | 3334 | //#endif |
3321 | } // switch | 3335 | } // switch |
3322 | } else { | 3336 | } else { |
3323 | if (KOPrefs::instance()->mConfirm) { | 3337 | if (KOPrefs::instance()->mConfirm) { |
3324 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3338 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3325 | i18n("\nAre you sure you want\nto delete this event?"), | 3339 | i18n("\nAre you sure you want\nto delete this event?"), |
3326 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3340 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3327 | case KMessageBox::Continue: // OK | 3341 | case KMessageBox::Continue: // OK |
3328 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3342 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3329 | schedule(Scheduler::Cancel,anEvent); | 3343 | schedule(Scheduler::Cancel,anEvent); |
3330 | checkExternalId( anEvent); | 3344 | checkExternalId( anEvent); |
3331 | mCalendar->deleteEvent(anEvent); | 3345 | mCalendar->deleteEvent(anEvent); |
3332 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3346 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3333 | break; | 3347 | break; |
3334 | } // switch | 3348 | } // switch |
3335 | } else { | 3349 | } else { |
3336 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3350 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3337 | schedule(Scheduler::Cancel,anEvent); | 3351 | schedule(Scheduler::Cancel,anEvent); |
3338 | checkExternalId( anEvent); | 3352 | checkExternalId( anEvent); |
3339 | mCalendar->deleteEvent(anEvent); | 3353 | mCalendar->deleteEvent(anEvent); |
3340 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3354 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3341 | } | 3355 | } |
3342 | } // if-else | 3356 | } // if-else |
3343 | emit updateSearchDialog(); | 3357 | emit updateSearchDialog(); |
3344 | } | 3358 | } |
3345 | 3359 | ||
3346 | bool CalendarView::deleteEvent(const QString &uid) | 3360 | bool CalendarView::deleteEvent(const QString &uid) |
3347 | { | 3361 | { |
3348 | Event *ev = mCalendar->event(uid); | 3362 | Event *ev = mCalendar->event(uid); |
3349 | if (ev) { | 3363 | if (ev) { |
3350 | deleteEvent(ev); | 3364 | deleteEvent(ev); |
3351 | return true; | 3365 | return true; |
3352 | } else { | 3366 | } else { |
3353 | return false; | 3367 | return false; |
3354 | } | 3368 | } |
3355 | } | 3369 | } |
3356 | 3370 | ||
3357 | /*****************************************************************************/ | 3371 | /*****************************************************************************/ |
3358 | 3372 | ||
3359 | void CalendarView::action_mail() | 3373 | void CalendarView::action_mail() |
3360 | { | 3374 | { |
3361 | #ifndef KORG_NOMAIL | 3375 | #ifndef KORG_NOMAIL |
3362 | KOMailClient mailClient; | 3376 | KOMailClient mailClient; |
3363 | 3377 | ||
3364 | Incidence *incidence = currentSelection(); | 3378 | Incidence *incidence = currentSelection(); |
3365 | 3379 | ||
3366 | if (!incidence) { | 3380 | if (!incidence) { |
3367 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3381 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3368 | return; | 3382 | return; |
3369 | } | 3383 | } |
3370 | if(incidence->attendeeCount() == 0 ) { | 3384 | if(incidence->attendeeCount() == 0 ) { |
3371 | KMessageBox::sorry(this, | 3385 | KMessageBox::sorry(this, |
3372 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3386 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3373 | return; | 3387 | return; |
3374 | } | 3388 | } |
3375 | 3389 | ||
3376 | CalendarLocal cal_tmp; | 3390 | CalendarLocal cal_tmp; |
3377 | Event *event = 0; | 3391 | Event *event = 0; |
3378 | Event *ev = 0; | 3392 | Event *ev = 0; |
3379 | if ( incidence && incidence->type() == "Event" ) { | 3393 | if ( incidence && incidence->type() == "Event" ) { |
3380 | event = static_cast<Event *>(incidence); | 3394 | event = static_cast<Event *>(incidence); |
3381 | ev = new Event(*event); | 3395 | ev = new Event(*event); |
3382 | cal_tmp.addEvent(ev); | 3396 | cal_tmp.addEvent(ev); |
3383 | } | 3397 | } |
3384 | ICalFormat mForm(); | 3398 | ICalFormat mForm(); |
3385 | QString attachment = mForm.toString( &cal_tmp ); | 3399 | QString attachment = mForm.toString( &cal_tmp ); |
3386 | if (ev) delete(ev); | 3400 | if (ev) delete(ev); |
3387 | 3401 | ||
3388 | mailClient.mailAttendees(currentSelection(), attachment); | 3402 | mailClient.mailAttendees(currentSelection(), attachment); |
3389 | 3403 | ||
3390 | #endif | 3404 | #endif |
3391 | 3405 | ||
3392 | #if 0 | 3406 | #if 0 |
3393 | Event *anEvent = 0; | 3407 | Event *anEvent = 0; |
3394 | if (mViewManager->currentView()->isEventView()) { | 3408 | if (mViewManager->currentView()->isEventView()) { |
3395 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3409 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3396 | } | 3410 | } |
3397 | 3411 | ||
3398 | if (!anEvent) { | 3412 | if (!anEvent) { |
3399 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3413 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3400 | return; | 3414 | return; |
3401 | } | 3415 | } |
3402 | if(anEvent->attendeeCount() == 0 ) { | 3416 | if(anEvent->attendeeCount() == 0 ) { |
3403 | KMessageBox::sorry(this, | 3417 | KMessageBox::sorry(this, |
3404 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3418 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3405 | return; | 3419 | return; |
3406 | } | 3420 | } |
3407 | 3421 | ||
3408 | mailobject.emailEvent(anEvent); | 3422 | mailobject.emailEvent(anEvent); |
3409 | #endif | 3423 | #endif |
3410 | } | 3424 | } |
3411 | 3425 | ||
3412 | 3426 | ||
3413 | void CalendarView::schedule_publish(Incidence *incidence) | 3427 | void CalendarView::schedule_publish(Incidence *incidence) |
3414 | { | 3428 | { |
3415 | Event *event = 0; | 3429 | Event *event = 0; |
3416 | Todo *todo = 0; | 3430 | Todo *todo = 0; |
3417 | 3431 | ||
3418 | if (incidence == 0) { | 3432 | if (incidence == 0) { |
3419 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3433 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3420 | if (incidence == 0) { | 3434 | if (incidence == 0) { |
3421 | incidence = mTodoList->selectedIncidences().first(); | 3435 | incidence = mTodoList->selectedIncidences().first(); |
3422 | } | 3436 | } |
3423 | } | 3437 | } |
3424 | if ( incidence && incidence->type() == "Event" ) { | 3438 | if ( incidence && incidence->type() == "Event" ) { |
3425 | event = static_cast<Event *>(incidence); | 3439 | event = static_cast<Event *>(incidence); |
3426 | } else { | 3440 | } else { |
3427 | if ( incidence && incidence->type() == "Todo" ) { | 3441 | if ( incidence && incidence->type() == "Todo" ) { |
3428 | todo = static_cast<Todo *>(incidence); | 3442 | todo = static_cast<Todo *>(incidence); |
3429 | } | 3443 | } |
3430 | } | 3444 | } |
3431 | 3445 | ||
3432 | if (!event && !todo) { | 3446 | if (!event && !todo) { |
3433 | KMessageBox::sorry(this,i18n("No event selected.")); | 3447 | KMessageBox::sorry(this,i18n("No event selected.")); |
3434 | return; | 3448 | return; |
3435 | } | 3449 | } |
3436 | 3450 | ||
3437 | PublishDialog *publishdlg = new PublishDialog(); | 3451 | PublishDialog *publishdlg = new PublishDialog(); |
3438 | if (incidence->attendeeCount()>0) { | 3452 | if (incidence->attendeeCount()>0) { |
3439 | QPtrList<Attendee> attendees = incidence->attendees(); | 3453 | QPtrList<Attendee> attendees = incidence->attendees(); |
3440 | attendees.first(); | 3454 | attendees.first(); |
3441 | while ( attendees.current()!=0 ) { | 3455 | while ( attendees.current()!=0 ) { |
3442 | publishdlg->addAttendee(attendees.current()); | 3456 | publishdlg->addAttendee(attendees.current()); |
3443 | attendees.next(); | 3457 | attendees.next(); |
3444 | } | 3458 | } |
3445 | } | 3459 | } |
3446 | bool send = true; | 3460 | bool send = true; |
3447 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3461 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3448 | if ( publishdlg->exec() != QDialog::Accepted ) | 3462 | if ( publishdlg->exec() != QDialog::Accepted ) |
3449 | send = false; | 3463 | send = false; |
3450 | } | 3464 | } |
3451 | if ( send ) { | 3465 | if ( send ) { |
3452 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3466 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3453 | if ( event ) { | 3467 | if ( event ) { |
3454 | Event *ev = new Event(*event); | 3468 | Event *ev = new Event(*event); |
3455 | ev->registerObserver(0); | 3469 | ev->registerObserver(0); |
3456 | ev->clearAttendees(); | 3470 | ev->clearAttendees(); |
3457 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3471 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3458 | delete(ev); | 3472 | delete(ev); |
3459 | } | 3473 | } |
3460 | } else { | 3474 | } else { |
3461 | if ( todo ) { | 3475 | if ( todo ) { |
3462 | Todo *ev = new Todo(*todo); | 3476 | Todo *ev = new Todo(*todo); |
3463 | ev->registerObserver(0); | 3477 | ev->registerObserver(0); |
3464 | ev->clearAttendees(); | 3478 | ev->clearAttendees(); |
3465 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3479 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3466 | delete(ev); | 3480 | delete(ev); |
3467 | } | 3481 | } |
3468 | } | 3482 | } |
3469 | } | 3483 | } |
3470 | } | 3484 | } |
3471 | delete publishdlg; | 3485 | delete publishdlg; |
3472 | } | 3486 | } |
3473 | 3487 | ||
3474 | void CalendarView::schedule_request(Incidence *incidence) | 3488 | void CalendarView::schedule_request(Incidence *incidence) |
3475 | { | 3489 | { |
3476 | schedule(Scheduler::Request,incidence); | 3490 | schedule(Scheduler::Request,incidence); |
3477 | } | 3491 | } |
3478 | 3492 | ||
3479 | void CalendarView::schedule_refresh(Incidence *incidence) | 3493 | void CalendarView::schedule_refresh(Incidence *incidence) |
3480 | { | 3494 | { |
3481 | schedule(Scheduler::Refresh,incidence); | 3495 | schedule(Scheduler::Refresh,incidence); |
3482 | } | 3496 | } |
3483 | 3497 | ||
3484 | void CalendarView::schedule_cancel(Incidence *incidence) | 3498 | void CalendarView::schedule_cancel(Incidence *incidence) |
3485 | { | 3499 | { |
3486 | schedule(Scheduler::Cancel,incidence); | 3500 | schedule(Scheduler::Cancel,incidence); |
3487 | } | 3501 | } |
3488 | 3502 | ||
3489 | void CalendarView::schedule_add(Incidence *incidence) | 3503 | void CalendarView::schedule_add(Incidence *incidence) |
3490 | { | 3504 | { |
3491 | schedule(Scheduler::Add,incidence); | 3505 | schedule(Scheduler::Add,incidence); |
3492 | } | 3506 | } |
3493 | 3507 | ||
3494 | void CalendarView::schedule_reply(Incidence *incidence) | 3508 | void CalendarView::schedule_reply(Incidence *incidence) |
3495 | { | 3509 | { |
3496 | schedule(Scheduler::Reply,incidence); | 3510 | schedule(Scheduler::Reply,incidence); |
3497 | } | 3511 | } |
3498 | 3512 | ||
3499 | void CalendarView::schedule_counter(Incidence *incidence) | 3513 | void CalendarView::schedule_counter(Incidence *incidence) |
3500 | { | 3514 | { |
3501 | schedule(Scheduler::Counter,incidence); | 3515 | schedule(Scheduler::Counter,incidence); |
3502 | } | 3516 | } |
3503 | 3517 | ||
3504 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3518 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3505 | { | 3519 | { |
3506 | schedule(Scheduler::Declinecounter,incidence); | 3520 | schedule(Scheduler::Declinecounter,incidence); |
3507 | } | 3521 | } |
3508 | 3522 | ||
3509 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3523 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3510 | { | 3524 | { |
3511 | QDateTime start = QDateTime::currentDateTime(); | 3525 | QDateTime start = QDateTime::currentDateTime(); |
3512 | QDateTime end = start.addDays(daysToPublish); | 3526 | QDateTime end = start.addDays(daysToPublish); |
3513 | 3527 | ||
3514 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3528 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3515 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3529 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3516 | 3530 | ||
3517 | 3531 | ||
3518 | PublishDialog *publishdlg = new PublishDialog(); | 3532 | PublishDialog *publishdlg = new PublishDialog(); |
3519 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3533 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3520 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3534 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3521 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3535 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3522 | delete(freebusy); | 3536 | delete(freebusy); |
3523 | } | 3537 | } |
3524 | } | 3538 | } |
3525 | delete publishdlg; | 3539 | delete publishdlg; |
3526 | } | 3540 | } |
3527 | 3541 | ||
3528 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3542 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3529 | { | 3543 | { |
3530 | Event *event = 0; | 3544 | Event *event = 0; |
3531 | Todo *todo = 0; | 3545 | Todo *todo = 0; |
3532 | 3546 | ||
3533 | if (incidence == 0) { | 3547 | if (incidence == 0) { |
3534 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3548 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3535 | if (incidence == 0) { | 3549 | if (incidence == 0) { |
3536 | incidence = mTodoList->selectedIncidences().first(); | 3550 | incidence = mTodoList->selectedIncidences().first(); |
3537 | } | 3551 | } |
3538 | } | 3552 | } |
3539 | if ( incidence && incidence->type() == "Event" ) { | 3553 | if ( incidence && incidence->type() == "Event" ) { |
3540 | event = static_cast<Event *>(incidence); | 3554 | event = static_cast<Event *>(incidence); |
3541 | } | 3555 | } |
3542 | if ( incidence && incidence->type() == "Todo" ) { | 3556 | if ( incidence && incidence->type() == "Todo" ) { |
3543 | todo = static_cast<Todo *>(incidence); | 3557 | todo = static_cast<Todo *>(incidence); |
3544 | } | 3558 | } |
3545 | 3559 | ||
3546 | if (!event && !todo) { | 3560 | if (!event && !todo) { |
3547 | KMessageBox::sorry(this,i18n("No event selected.")); | 3561 | KMessageBox::sorry(this,i18n("No event selected.")); |
3548 | return; | 3562 | return; |
3549 | } | 3563 | } |
3550 | 3564 | ||
3551 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3565 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3552 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3566 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3553 | return; | 3567 | return; |
3554 | } | 3568 | } |
3555 | 3569 | ||
3556 | Event *ev = 0; | 3570 | Event *ev = 0; |
3557 | if (event) ev = new Event(*event); | 3571 | if (event) ev = new Event(*event); |
3558 | Todo *to = 0; | 3572 | Todo *to = 0; |
3559 | if (todo) to = new Todo(*todo); | 3573 | if (todo) to = new Todo(*todo); |
3560 | 3574 | ||
3561 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3575 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3562 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3576 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3563 | if (!me) { | 3577 | if (!me) { |
3564 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3578 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3565 | return; | 3579 | return; |
3566 | } | 3580 | } |
3567 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3581 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3568 | StatusDialog *statdlg = new StatusDialog(this); | 3582 | StatusDialog *statdlg = new StatusDialog(this); |
3569 | if (!statdlg->exec()==QDialog::Accepted) return; | 3583 | if (!statdlg->exec()==QDialog::Accepted) return; |
3570 | me->setStatus( statdlg->status() ); | 3584 | me->setStatus( statdlg->status() ); |
3571 | delete(statdlg); | 3585 | delete(statdlg); |
3572 | } | 3586 | } |
3573 | Attendee *menew = new Attendee(*me); | 3587 | Attendee *menew = new Attendee(*me); |
3574 | if (ev) { | 3588 | if (ev) { |
3575 | ev->clearAttendees(); | 3589 | ev->clearAttendees(); |
3576 | ev->addAttendee(menew,false); | 3590 | ev->addAttendee(menew,false); |
3577 | } else { | 3591 | } else { |
3578 | if (to) { | 3592 | if (to) { |
3579 | todo->clearAttendees(); | 3593 | todo->clearAttendees(); |
3580 | todo->addAttendee(menew,false); | 3594 | todo->addAttendee(menew,false); |
3581 | } | 3595 | } |
3582 | } | 3596 | } |
3583 | } | 3597 | } |
3584 | 3598 | ||
3585 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3599 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3586 | if (ev) { | 3600 | if (ev) { |
3587 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3601 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3588 | } else { | 3602 | } else { |
3589 | if (to) { | 3603 | if (to) { |
3590 | if ( !dlg->addMessage(to,method) ) delete(to); | 3604 | if ( !dlg->addMessage(to,method) ) delete(to); |
3591 | } | 3605 | } |
3592 | } | 3606 | } |
3593 | } | 3607 | } |
3594 | 3608 | ||
3595 | void CalendarView::openAddressbook() | 3609 | void CalendarView::openAddressbook() |
3596 | { | 3610 | { |
3597 | KRun::runCommand("kaddressbook"); | 3611 | KRun::runCommand("kaddressbook"); |
3598 | } | 3612 | } |
3599 | 3613 | ||
3600 | void CalendarView::setModified(bool modified) | 3614 | void CalendarView::setModified(bool modified) |
3601 | { | 3615 | { |
3602 | if ( modified ) | 3616 | if ( modified ) |
3603 | emit signalmodified(); | 3617 | emit signalmodified(); |
3604 | if (mModified != modified) { | 3618 | if (mModified != modified) { |
3605 | mModified = modified; | 3619 | mModified = modified; |
3606 | emit modifiedChanged(mModified); | 3620 | emit modifiedChanged(mModified); |
3607 | } | 3621 | } |
3608 | } | 3622 | } |
3609 | 3623 | ||
3610 | bool CalendarView::isReadOnly() | 3624 | bool CalendarView::isReadOnly() |
3611 | { | 3625 | { |
3612 | return mReadOnly; | 3626 | return mReadOnly; |
3613 | } | 3627 | } |
3614 | 3628 | ||
3615 | void CalendarView::setReadOnly(bool readOnly) | 3629 | void CalendarView::setReadOnly(bool readOnly) |
3616 | { | 3630 | { |
3617 | if (mReadOnly != readOnly) { | 3631 | if (mReadOnly != readOnly) { |
3618 | mReadOnly = readOnly; | 3632 | mReadOnly = readOnly; |
3619 | emit readOnlyChanged(mReadOnly); | 3633 | emit readOnlyChanged(mReadOnly); |
3620 | } | 3634 | } |
3621 | } | 3635 | } |
3622 | 3636 | ||
3623 | bool CalendarView::isModified() | 3637 | bool CalendarView::isModified() |
3624 | { | 3638 | { |
3625 | return mModified; | 3639 | return mModified; |
3626 | } | 3640 | } |
3627 | void CalendarView::slotprintSelInc() | 3641 | void CalendarView::slotprintSelInc() |
3628 | { | 3642 | { |
3629 | if ( currentSelection() == 0 ) { | 3643 | if ( currentSelection() == 0 ) { |
3630 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 3644 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
3631 | return; | 3645 | return; |
3632 | } | 3646 | } |
3633 | showIncidence(); | 3647 | showIncidence(); |
3634 | getEventViewerDialog()->print(); | 3648 | getEventViewerDialog()->print(); |
3635 | 3649 | ||
3636 | } | 3650 | } |
3637 | void CalendarView::printSetup() | 3651 | void CalendarView::printSetup() |
3638 | { | 3652 | { |
3639 | #ifndef KORG_NOPRINTER | 3653 | #ifndef KORG_NOPRINTER |
3640 | createPrinter(); | 3654 | createPrinter(); |
3641 | 3655 | ||
3642 | mCalPrinter->setupPrinter(); | 3656 | mCalPrinter->setupPrinter(); |
3643 | #endif | 3657 | #endif |
3644 | } | 3658 | } |
3645 | 3659 | ||
3646 | void CalendarView::print() | 3660 | void CalendarView::print() |
3647 | { | 3661 | { |
3648 | #ifndef KORG_NOPRINTER | 3662 | #ifndef KORG_NOPRINTER |
3649 | createPrinter(); | 3663 | createPrinter(); |
3650 | 3664 | ||
3651 | DateList tmpDateList = mNavigator->selectedDates(); | 3665 | DateList tmpDateList = mNavigator->selectedDates(); |
3652 | mCalPrinter->print(CalPrinter::Month, | 3666 | mCalPrinter->print(CalPrinter::Month, |
3653 | tmpDateList.first(), tmpDateList.last()); | 3667 | tmpDateList.first(), tmpDateList.last()); |
3654 | #endif | 3668 | #endif |
3655 | } | 3669 | } |
3656 | 3670 | ||
3657 | void CalendarView::printPreview() | 3671 | void CalendarView::printPreview() |
3658 | { | 3672 | { |
3659 | #ifndef KORG_NOPRINTER | 3673 | #ifndef KORG_NOPRINTER |
3660 | kdDebug() << "CalendarView::printPreview()" << endl; | 3674 | kdDebug() << "CalendarView::printPreview()" << endl; |
3661 | 3675 | ||
3662 | createPrinter(); | 3676 | createPrinter(); |
3663 | 3677 | ||
3664 | DateList tmpDateList = mNavigator->selectedDates(); | 3678 | DateList tmpDateList = mNavigator->selectedDates(); |
3665 | 3679 | ||
3666 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3680 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3667 | tmpDateList.last()); | 3681 | tmpDateList.last()); |
3668 | #endif | 3682 | #endif |
3669 | } | 3683 | } |
3670 | 3684 | ||
3671 | void CalendarView::exportICalendar() | 3685 | void CalendarView::exportICalendar() |
3672 | { | 3686 | { |
3673 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3687 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3674 | 3688 | ||
3675 | // Force correct extension | 3689 | // Force correct extension |
3676 | if (filename.right(4) != ".ics") filename += ".ics"; | 3690 | if (filename.right(4) != ".ics") filename += ".ics"; |
3677 | 3691 | ||
3678 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3692 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3679 | storage.save(); | 3693 | storage.save(); |
3680 | } | 3694 | } |
3681 | 3695 | ||
3682 | bool CalendarView::exportVCalendar( QString filename ) | 3696 | bool CalendarView::exportVCalendar( QString filename ) |
3683 | { | 3697 | { |
3684 | if (mCalendar->journals().count() > 0) { | 3698 | if (mCalendar->journals().count() > 0) { |
3685 | int result = KMessageBox::warningContinueCancel(this, | 3699 | int result = KMessageBox::warningContinueCancel(this, |
3686 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3700 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3687 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3701 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3688 | true); | 3702 | true); |
3689 | if (result != KMessageBox::Continue) return false; | 3703 | if (result != KMessageBox::Continue) return false; |
3690 | } | 3704 | } |
3691 | 3705 | ||
3692 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3706 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3693 | 3707 | ||
3694 | // Force correct extension | 3708 | // Force correct extension |
3695 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3709 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3696 | 3710 | ||
3697 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3711 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3698 | return storage.save(); | 3712 | return storage.save(); |
3699 | 3713 | ||
3700 | } | 3714 | } |
3701 | 3715 | ||
3702 | void CalendarView::eventUpdated(Incidence *) | 3716 | void CalendarView::eventUpdated(Incidence *) |
3703 | { | 3717 | { |
3704 | setModified(); | 3718 | setModified(); |
3705 | // Don't call updateView here. The code, which has caused the update of the | 3719 | // Don't call updateView here. The code, which has caused the update of the |
3706 | // event is responsible for updating the view. | 3720 | // event is responsible for updating the view. |
3707 | // updateView(); | 3721 | // updateView(); |
3708 | } | 3722 | } |
3709 | 3723 | ||
3710 | void CalendarView::adaptNavigationUnits() | 3724 | void CalendarView::adaptNavigationUnits() |
3711 | { | 3725 | { |
3712 | if (mViewManager->currentView()->isEventView()) { | 3726 | if (mViewManager->currentView()->isEventView()) { |
3713 | int days = mViewManager->currentView()->currentDateCount(); | 3727 | int days = mViewManager->currentView()->currentDateCount(); |
3714 | if (days == 1) { | 3728 | if (days == 1) { |
3715 | emit changeNavStringPrev(i18n("&Previous Day")); | 3729 | emit changeNavStringPrev(i18n("&Previous Day")); |
3716 | emit changeNavStringNext(i18n("&Next Day")); | 3730 | emit changeNavStringNext(i18n("&Next Day")); |
3717 | } else { | 3731 | } else { |
3718 | emit changeNavStringPrev(i18n("&Previous Week")); | 3732 | emit changeNavStringPrev(i18n("&Previous Week")); |
3719 | emit changeNavStringNext(i18n("&Next Week")); | 3733 | emit changeNavStringNext(i18n("&Next Week")); |
3720 | } | 3734 | } |
3721 | } | 3735 | } |
3722 | } | 3736 | } |
3723 | 3737 | ||
3724 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3738 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3725 | { | 3739 | { |
3726 | if ( incidence ) mTodoList->clearSelection(); | 3740 | if ( incidence ) mTodoList->clearSelection(); |
3727 | processIncidenceSelection( incidence ); | 3741 | processIncidenceSelection( incidence ); |
3728 | } | 3742 | } |
3729 | 3743 | ||
3730 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3744 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3731 | { | 3745 | { |
3732 | if ( incidence && mViewManager->currentView() ) { | 3746 | if ( incidence && mViewManager->currentView() ) { |
3733 | mViewManager->currentView()->clearSelection(); | 3747 | mViewManager->currentView()->clearSelection(); |
3734 | } | 3748 | } |
3735 | processIncidenceSelection( incidence ); | 3749 | processIncidenceSelection( incidence ); |
3736 | } | 3750 | } |
3737 | 3751 | ||
3738 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3752 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3739 | { | 3753 | { |
3740 | if ( incidence == mSelectedIncidence ) return; | 3754 | if ( incidence == mSelectedIncidence ) return; |