author | zautrix <zautrix> | 2005-06-11 09:22:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-11 09:22:29 (UTC) |
commit | d4501288ba7414ba89a791dd2c306e9f74eeb3fa (patch) (unidiff) | |
tree | a99b30c87947a22f9c2da3ab5426f4e5ed8de9ab | |
parent | b214921b2072079ec59a87ac84231f83532009d5 (diff) | |
download | kdepimpi-d4501288ba7414ba89a791dd2c306e9f74eeb3fa.zip kdepimpi-d4501288ba7414ba89a791dd2c306e9f74eeb3fa.tar.gz kdepimpi-d4501288ba7414ba89a791dd2c306e9f74eeb3fa.tar.bz2 |
fixx
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/kofilterview.cpp | 2 | ||||
-rw-r--r-- | korganizer/kofilterview.h | 50 |
3 files changed, 54 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index ea100d1..8d992b9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,2009 +1,2010 @@ | |||
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 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 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->typeID() == eventID ) { | 173 | if ( inc->typeID() == eventID ) { |
174 | tempText += "href=\"event:"; | 174 | tempText += "href=\"event:"; |
175 | } else if ( inc->typeID() == todoID ) { | 175 | } else if ( inc->typeID() == todoID ) { |
176 | tempText += "href=\"todo:"; | 176 | tempText += "href=\"todo:"; |
177 | } | 177 | } |
178 | tempText += inc->uid() + "\">"; | 178 | tempText += inc->uid() + "\">"; |
179 | if ( inc->typeID() == todoID ) | 179 | if ( inc->typeID() == todoID ) |
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>"; | 191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
192 | mText += "<table>"; | 192 | mText += "<table>"; |
193 | time = 1; | 193 | time = 1; |
194 | } | 194 | } |
195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
196 | if ( time > 0 ) | 196 | if ( time > 0 ) |
197 | mText +="</table>"; | 197 | mText +="</table>"; |
198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
199 | mText += "<table>"; | 199 | mText += "<table>"; |
200 | time = 2; | 200 | time = 2; |
201 | 201 | ||
202 | } | 202 | } |
203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
204 | if ( time > 0 ) | 204 | if ( time > 0 ) |
205 | mText +="</table>"; | 205 | mText +="</table>"; |
206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
207 | mText += "<table>"; | 207 | mText += "<table>"; |
208 | time = 3; | 208 | time = 3; |
209 | } | 209 | } |
210 | mText +="<tr><td><b>"; | 210 | mText +="<tr><td><b>"; |
211 | mText += timestr; | 211 | mText += timestr; |
212 | mText += "</b></td><td>"; | 212 | mText += "</b></td><td>"; |
213 | mText += tempText; | 213 | mText += tempText; |
214 | mText += "</td></tr>\n"; | 214 | mText += "</td></tr>\n"; |
215 | inc = getNextInc( start ); | 215 | inc = getNextInc( start ); |
216 | } | 216 | } |
217 | mText +="</table>"; | 217 | mText +="</table>"; |
218 | setText( mText ); | 218 | setText( mText ); |
219 | } | 219 | } |
220 | 220 | ||
221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
222 | { | 222 | { |
223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
224 | } | 224 | } |
225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
226 | { | 226 | { |
227 | QDateTime dt ; | 227 | QDateTime dt ; |
228 | Incidence * retInc; | 228 | Incidence * retInc; |
229 | Incidence * inc = mAlarms.first(); | 229 | Incidence * inc = mAlarms.first(); |
230 | if ( inc == 0 ) | 230 | if ( inc == 0 ) |
231 | return 0; | 231 | return 0; |
232 | bool ok; | 232 | bool ok; |
233 | dt = inc->getNextOccurence( start, &ok ); | 233 | dt = inc->getNextOccurence( start, &ok ); |
234 | if ( ! ok ) return 0; | 234 | if ( ! ok ) return 0; |
235 | QDateTime dtn ; | 235 | QDateTime dtn ; |
236 | retInc = inc; | 236 | retInc = inc; |
237 | inc = mAlarms.next(); | 237 | inc = mAlarms.next(); |
238 | while ( inc ) { | 238 | while ( inc ) { |
239 | dtn = inc->getNextOccurence( start, &ok ); | 239 | dtn = inc->getNextOccurence( start, &ok ); |
240 | if ( ! ok ) return 0; | 240 | if ( ! ok ) return 0; |
241 | if ( dtn < dt ) { | 241 | if ( dtn < dt ) { |
242 | dt = dtn; | 242 | dt = dtn; |
243 | retInc = inc; | 243 | retInc = inc; |
244 | } | 244 | } |
245 | inc = mAlarms.next(); | 245 | inc = mAlarms.next(); |
246 | } | 246 | } |
247 | mAlarms.remove( retInc ); | 247 | mAlarms.remove( retInc ); |
248 | return retInc; | 248 | return retInc; |
249 | 249 | ||
250 | } | 250 | } |
251 | void MissedAlarmTextBrowser::setSource(const QString & n) | 251 | void MissedAlarmTextBrowser::setSource(const QString & n) |
252 | { | 252 | { |
253 | if (n.startsWith("event:")) { | 253 | if (n.startsWith("event:")) { |
254 | #ifdef DESKTOP_VERSION | 254 | #ifdef DESKTOP_VERSION |
255 | emit showIncidence(n.mid(8)); | 255 | emit showIncidence(n.mid(8)); |
256 | #else | 256 | #else |
257 | emit showIncidence(n.mid(6)); | 257 | emit showIncidence(n.mid(6)); |
258 | #endif | 258 | #endif |
259 | return; | 259 | return; |
260 | } else if (n.startsWith("todo:")) { | 260 | } else if (n.startsWith("todo:")) { |
261 | #ifdef DESKTOP_VERSION | 261 | #ifdef DESKTOP_VERSION |
262 | emit showIncidence(n.mid(7)); | 262 | emit showIncidence(n.mid(7)); |
263 | #else | 263 | #else |
264 | emit showIncidence(n.mid(5)); | 264 | emit showIncidence(n.mid(5)); |
265 | #endif | 265 | #endif |
266 | return; | 266 | return; |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | class KOBeamPrefs : public QDialog | 271 | class KOBeamPrefs : public QDialog |
272 | { | 272 | { |
273 | public: | 273 | public: |
274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
275 | QDialog( parent, name, true ) | 275 | QDialog( parent, name, true ) |
276 | { | 276 | { |
277 | setCaption( i18n("Beam Options") ); | 277 | setCaption( i18n("Beam Options") ); |
278 | QVBoxLayout* lay = new QVBoxLayout( this ); | 278 | QVBoxLayout* lay = new QVBoxLayout( this ); |
279 | lay->setSpacing( 3 ); | 279 | lay->setSpacing( 3 ); |
280 | lay->setMargin( 3 ); | 280 | lay->setMargin( 3 ); |
281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
282 | lay->addWidget( format ); | 282 | lay->addWidget( format ); |
283 | format->setExclusive ( true ) ; | 283 | format->setExclusive ( true ) ; |
284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
285 | lay->addWidget( time ); time->setExclusive ( true ) ; | 285 | lay->addWidget( time ); time->setExclusive ( true ) ; |
286 | vcal = new QRadioButton(" vCalendar ", format ); | 286 | vcal = new QRadioButton(" vCalendar ", format ); |
287 | ical = new QRadioButton(" iCalendar ", format ); | 287 | ical = new QRadioButton(" iCalendar ", format ); |
288 | vcal->setChecked( true ); | 288 | vcal->setChecked( true ); |
289 | tz = new QRadioButton(i18n(" With timezone "), time ); | 289 | tz = new QRadioButton(i18n(" With timezone "), time ); |
290 | local = new QRadioButton(i18n(" Local time "), time ); | 290 | local = new QRadioButton(i18n(" Local time "), time ); |
291 | tz->setChecked( true ); | 291 | tz->setChecked( true ); |
292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
293 | lay->addWidget( ok ); | 293 | lay->addWidget( ok ); |
294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
295 | lay->addWidget( cancel ); | 295 | lay->addWidget( cancel ); |
296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
298 | resize( 200, 200 ); | 298 | resize( 200, 200 ); |
299 | } | 299 | } |
300 | 300 | ||
301 | bool beamVcal() { return vcal->isChecked(); } | 301 | bool beamVcal() { return vcal->isChecked(); } |
302 | bool beamLocal() { return local->isChecked(); } | 302 | bool beamLocal() { return local->isChecked(); } |
303 | private: | 303 | private: |
304 | QRadioButton* vcal, *ical, *local, *tz; | 304 | QRadioButton* vcal, *ical, *local, *tz; |
305 | }; | 305 | }; |
306 | class KOCatPrefs : public QDialog | 306 | class KOCatPrefs : public QDialog |
307 | { | 307 | { |
308 | public: | 308 | public: |
309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
310 | QDialog( parent, name, true ) | 310 | QDialog( parent, name, true ) |
311 | { | 311 | { |
312 | setCaption( i18n("Manage new Categories") ); | 312 | setCaption( i18n("Manage new Categories") ); |
313 | QVBoxLayout* lay = new QVBoxLayout( this ); | 313 | QVBoxLayout* lay = new QVBoxLayout( this ); |
314 | lay->setSpacing( 3 ); | 314 | lay->setSpacing( 3 ); |
315 | lay->setMargin( 3 ); | 315 | lay->setMargin( 3 ); |
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 ); | 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 ); |
317 | lay->addWidget( lab ); | 317 | lay->addWidget( lab ); |
318 | 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 ); |
319 | lay->addWidget( format ); | 319 | lay->addWidget( format ); |
320 | format->setExclusive ( true ) ; | 320 | format->setExclusive ( true ) ; |
321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
323 | addCatBut->setChecked( true ); | 323 | addCatBut->setChecked( true ); |
324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
325 | lay->addWidget( ok ); | 325 | lay->addWidget( ok ); |
326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
327 | lay->addWidget( cancel ); | 327 | lay->addWidget( cancel ); |
328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
330 | resize( 200, 200 ); | 330 | resize( 200, 200 ); |
331 | } | 331 | } |
332 | 332 | ||
333 | bool addCat() { return addCatBut->isChecked(); } | 333 | bool addCat() { return addCatBut->isChecked(); } |
334 | private: | 334 | private: |
335 | QRadioButton* addCatBut; | 335 | QRadioButton* addCatBut; |
336 | }; | 336 | }; |
337 | 337 | ||
338 | 338 | ||
339 | 339 | ||
340 | CalendarView::CalendarView( CalendarResources *calendar, | 340 | CalendarView::CalendarView( CalendarResources *calendar, |
341 | QWidget *parent, const char *name ) | 341 | QWidget *parent, const char *name ) |
342 | : CalendarViewBase( parent, name ), | 342 | : CalendarViewBase( parent, name ), |
343 | mCalendar( calendar ), | 343 | mCalendar( calendar ), |
344 | mResourceManager( calendar->resourceManager() ) | 344 | mResourceManager( calendar->resourceManager() ) |
345 | { | 345 | { |
346 | 346 | ||
347 | mEventEditor = 0; | 347 | mEventEditor = 0; |
348 | mTodoEditor = 0; | 348 | mTodoEditor = 0; |
349 | 349 | ||
350 | init(); | 350 | init(); |
351 | } | 351 | } |
352 | 352 | ||
353 | CalendarView::CalendarView( Calendar *calendar, | 353 | CalendarView::CalendarView( Calendar *calendar, |
354 | QWidget *parent, const char *name ) | 354 | QWidget *parent, const char *name ) |
355 | : CalendarViewBase( parent, name ), | 355 | : CalendarViewBase( parent, name ), |
356 | mCalendar( calendar ), | 356 | mCalendar( calendar ), |
357 | mResourceManager( 0 ) | 357 | mResourceManager( 0 ) |
358 | { | 358 | { |
359 | 359 | ||
360 | mEventEditor = 0; | 360 | mEventEditor = 0; |
361 | mTodoEditor = 0; | 361 | mTodoEditor = 0; |
362 | init(); | 362 | init(); |
363 | } | 363 | } |
364 | 364 | ||
365 | void CalendarView::init() | 365 | void CalendarView::init() |
366 | { | 366 | { |
367 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 367 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
368 | setFocusPolicy ( NoFocus ); | 368 | setFocusPolicy ( NoFocus ); |
369 | mViewerCallerIsSearchDialog = false; | 369 | mViewerCallerIsSearchDialog = false; |
370 | mBlockShowDates = false; | 370 | mBlockShowDates = false; |
371 | beamDialog = new KOBeamPrefs(); | 371 | beamDialog = new KOBeamPrefs(); |
372 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
373 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
374 | writeLocale(); | 374 | writeLocale(); |
375 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
378 | mModified = false; | 378 | mModified = false; |
379 | mReadOnly = false; | 379 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
383 | 383 | ||
384 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 386 | ||
387 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 389 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 392 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
395 | 395 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 399 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
402 | 402 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 407 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 409 | mResourceView = 0; |
410 | #else | 410 | #else |
411 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
416 | } else { | 416 | } else { |
417 | mResourceView = 0; | 417 | mResourceView = 0; |
418 | } | 418 | } |
419 | #endif | 419 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 422 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 425 | ||
426 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
427 | #else | 427 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 438 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 445 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
449 | //mainBoxLayout->addWidget (mLeftFrame); | 449 | //mainBoxLayout->addWidget (mLeftFrame); |
450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
451 | "CalendarView::DateNavigator" ); | 451 | "CalendarView::DateNavigator" ); |
452 | #if 0 | 452 | #if 0 |
453 | // FIXME | 453 | // FIXME |
454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
455 | "CalendarView::DateNavigator", QDate::currentDate()); | 455 | "CalendarView::DateNavigator", QDate::currentDate()); |
456 | #endif | 456 | #endif |
457 | // mDateNavigator->blockSignals( true ); | 457 | // mDateNavigator->blockSignals( true ); |
458 | //leftFrameLayout->addWidget( mDateNavigator ); | 458 | //leftFrameLayout->addWidget( mDateNavigator ); |
459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
462 | mTodoList->setNavigator( mNavigator ); | 462 | mTodoList->setNavigator( mNavigator ); |
463 | #if 0 | 463 | #if 0 |
464 | if ( QApplication::desktop()->width() < 480 ) { | 464 | if ( QApplication::desktop()->width() < 480 ) { |
465 | leftFrameLayout->addWidget(mFilterView); | 465 | leftFrameLayout->addWidget(mFilterView); |
466 | leftFrameLayout->addWidget(mTodoList, 2 ); | 466 | leftFrameLayout->addWidget(mTodoList, 2 ); |
467 | 467 | ||
468 | } else { | 468 | } else { |
469 | leftFrameLayout->addWidget(mTodoList,2 ); | 469 | leftFrameLayout->addWidget(mTodoList,2 ); |
470 | leftFrameLayout->addWidget(mFilterView ); | 470 | leftFrameLayout->addWidget(mFilterView ); |
471 | } | 471 | } |
472 | #endif | 472 | #endif |
473 | mFilterView->hide(); | 473 | mFilterView->hide(); |
474 | mCalEditView->hide(); | ||
474 | QWidget *rightBox = new QWidget( mMainFrame ); | 475 | QWidget *rightBox = new QWidget( mMainFrame ); |
475 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 476 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
476 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 477 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
477 | mRightFrame = new QWidgetStack( rightBox ); | 478 | mRightFrame = new QWidgetStack( rightBox ); |
478 | rightLayout->addWidget( mRightFrame, 10 ); | 479 | rightLayout->addWidget( mRightFrame, 10 ); |
479 | 480 | ||
480 | //mLeftFrame = (QWidget *)leftFrame; | 481 | //mLeftFrame = (QWidget *)leftFrame; |
481 | if ( KOPrefs::instance()->mVerticalScreen ) { | 482 | if ( KOPrefs::instance()->mVerticalScreen ) { |
482 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 483 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
483 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 484 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
484 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 485 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
485 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 486 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
486 | } else { | 487 | } else { |
487 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 488 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
488 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 489 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
489 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 490 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
490 | } | 491 | } |
491 | if ( !KOPrefs::instance()->mShowDateNavigator) | 492 | if ( !KOPrefs::instance()->mShowDateNavigator) |
492 | mDateNavigator->hide(); | 493 | mDateNavigator->hide(); |
493 | //qDebug("Calendarview Size %d %d ", width(), height()); | 494 | //qDebug("Calendarview Size %d %d ", width(), height()); |
494 | #endif | 495 | #endif |
495 | 496 | ||
496 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 497 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
497 | SLOT( showDates( const KCal::DateList & ) ) ); | 498 | SLOT( showDates( const KCal::DateList & ) ) ); |
498 | 499 | ||
499 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 500 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
500 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 501 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
501 | 502 | ||
502 | 503 | ||
503 | 504 | ||
504 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 505 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
505 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 506 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
506 | 507 | ||
507 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 508 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
508 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 509 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
509 | 510 | ||
510 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 511 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
511 | mNavigator, SLOT( selectPreviousYear() ) ); | 512 | mNavigator, SLOT( selectPreviousYear() ) ); |
512 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 513 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
513 | mNavigator, SLOT( selectNextYear() ) ); | 514 | mNavigator, SLOT( selectNextYear() ) ); |
514 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 515 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
515 | mNavigator, SLOT( selectPreviousMonth() ) ); | 516 | mNavigator, SLOT( selectPreviousMonth() ) ); |
516 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 517 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
517 | mNavigator, SLOT( selectNextMonth() ) ); | 518 | mNavigator, SLOT( selectNextMonth() ) ); |
518 | 519 | ||
519 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 520 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
520 | mNavigator, SLOT( selectPrevious() ) ); | 521 | mNavigator, SLOT( selectPrevious() ) ); |
521 | connect( mDateNavigator, SIGNAL( goNext() ), | 522 | connect( mDateNavigator, SIGNAL( goNext() ), |
522 | mNavigator, SLOT( selectNext() ) ); | 523 | mNavigator, SLOT( selectNext() ) ); |
523 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 524 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
524 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 525 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
525 | 526 | ||
526 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 527 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
527 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 528 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
528 | #if 0 | 529 | #if 0 |
529 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 530 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
530 | SLOT( incidenceAdded( Incidence *) ) ); | 531 | SLOT( incidenceAdded( Incidence *) ) ); |
531 | #endif | 532 | #endif |
532 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 533 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
533 | 534 | ||
534 | connect( this, SIGNAL( configChanged() ), | 535 | connect( this, SIGNAL( configChanged() ), |
535 | mDateNavigator, SLOT( updateConfig() ) ); | 536 | mDateNavigator, SLOT( updateConfig() ) ); |
536 | 537 | ||
537 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 538 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
538 | SLOT( newTodo() ) ); | 539 | SLOT( newTodo() ) ); |
539 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 540 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
540 | SLOT( newSubTodo( Todo * ) ) ); | 541 | SLOT( newSubTodo( Todo * ) ) ); |
541 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 542 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
542 | SLOT( editTodo( Todo * ) ) ); | 543 | SLOT( editTodo( Todo * ) ) ); |
543 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 544 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
544 | SLOT( showTodo( Todo *) ) ); | 545 | SLOT( showTodo( Todo *) ) ); |
545 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 546 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
546 | SLOT( deleteTodo( Todo *) ) ); | 547 | SLOT( deleteTodo( Todo *) ) ); |
547 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 548 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
548 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 549 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
549 | SLOT( purgeCompleted() ) ); | 550 | SLOT( purgeCompleted() ) ); |
550 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 551 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
551 | SIGNAL( todoModified( Todo *, int ) ) ); | 552 | SIGNAL( todoModified( Todo *, int ) ) ); |
552 | 553 | ||
553 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 554 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
554 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 555 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
555 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 556 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
556 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 557 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
557 | 558 | ||
558 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 559 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
559 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 560 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
560 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 561 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
561 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 562 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
562 | 563 | ||
563 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 564 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
564 | this, SLOT ( todo_unsub( Todo * ) ) ); | 565 | this, SLOT ( todo_unsub( Todo * ) ) ); |
565 | 566 | ||
566 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 567 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
567 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 568 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
568 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 569 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
569 | SLOT( updateTodo( Todo *, int ) ) ); | 570 | SLOT( updateTodo( Todo *, int ) ) ); |
570 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 571 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
571 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 572 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
572 | 573 | ||
573 | 574 | ||
574 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 575 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
575 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 576 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
576 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 577 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
577 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 578 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
578 | 579 | ||
579 | 580 | ||
580 | 581 | ||
581 | 582 | ||
582 | 583 | ||
583 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 584 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
584 | SLOT(checkClipboard())); | 585 | SLOT(checkClipboard())); |
585 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 586 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
586 | SLOT( processTodoListSelection( Incidence * ) ) ); | 587 | SLOT( processTodoListSelection( Incidence * ) ) ); |
587 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 588 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
588 | 589 | ||
589 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 590 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
590 | 591 | ||
591 | mDateFrame = new QVBox(0,0,WType_Popup); | 592 | mDateFrame = new QVBox(0,0,WType_Popup); |
592 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 593 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
593 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 594 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
594 | mDateFrame->setLineWidth(3); | 595 | mDateFrame->setLineWidth(3); |
595 | mDateFrame->hide(); | 596 | mDateFrame->hide(); |
596 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 597 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
597 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 598 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
598 | 599 | ||
599 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 600 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
600 | 601 | ||
601 | mEventEditor = mDialogManager->getEventEditor(); | 602 | mEventEditor = mDialogManager->getEventEditor(); |
602 | mTodoEditor = mDialogManager->getTodoEditor(); | 603 | mTodoEditor = mDialogManager->getTodoEditor(); |
603 | 604 | ||
604 | mFlagEditDescription = false; | 605 | mFlagEditDescription = false; |
605 | 606 | ||
606 | mSuspendTimer = new QTimer( this ); | 607 | mSuspendTimer = new QTimer( this ); |
607 | mAlarmTimer = new QTimer( this ); | 608 | mAlarmTimer = new QTimer( this ); |
608 | mRecheckAlarmTimer = new QTimer( this ); | 609 | mRecheckAlarmTimer = new QTimer( this ); |
609 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 610 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
610 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 611 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
611 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 612 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
612 | mAlarmDialog = new AlarmDialog( this ); | 613 | mAlarmDialog = new AlarmDialog( this ); |
613 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 614 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
614 | mAlarmDialog->setServerNotification( false ); | 615 | mAlarmDialog->setServerNotification( false ); |
615 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 616 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
616 | 617 | ||
617 | 618 | ||
618 | #ifndef DESKTOP_VERSION | 619 | #ifndef DESKTOP_VERSION |
619 | //US listen for arriving address resultsets | 620 | //US listen for arriving address resultsets |
620 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 621 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
621 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 622 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
622 | #endif | 623 | #endif |
623 | mDateNavigator->setCalendar( mCalendar ); | 624 | mDateNavigator->setCalendar( mCalendar ); |
624 | } | 625 | } |
625 | 626 | ||
626 | 627 | ||
627 | CalendarView::~CalendarView() | 628 | CalendarView::~CalendarView() |
628 | { | 629 | { |
629 | // kdDebug() << "~CalendarView()" << endl; | 630 | // kdDebug() << "~CalendarView()" << endl; |
630 | //qDebug("CalendarView::~CalendarView() "); | 631 | //qDebug("CalendarView::~CalendarView() "); |
631 | delete mDialogManager; | 632 | delete mDialogManager; |
632 | delete mViewManager; | 633 | delete mViewManager; |
633 | delete mStorage; | 634 | delete mStorage; |
634 | delete mDateFrame ; | 635 | delete mDateFrame ; |
635 | delete beamDialog; | 636 | delete beamDialog; |
636 | delete mEventViewerDialog; | 637 | delete mEventViewerDialog; |
637 | //kdDebug() << "~CalendarView() done" << endl; | 638 | //kdDebug() << "~CalendarView() done" << endl; |
638 | } | 639 | } |
639 | void CalendarView::checkAlarms() | 640 | void CalendarView::checkAlarms() |
640 | { | 641 | { |
641 | KConfig *config = KOGlobals::config(); | 642 | KConfig *config = KOGlobals::config(); |
642 | config->setGroup( "AppRun" ); | 643 | config->setGroup( "AppRun" ); |
643 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 644 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
644 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 645 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
645 | int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; | 646 | int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; |
646 | //secs -= ( 3600 * 24*3 ); // debug only | 647 | //secs -= ( 3600 * 24*3 ); // debug only |
647 | QDateTime latest = dt.addSecs ( secs ); | 648 | QDateTime latest = dt.addSecs ( secs ); |
648 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 649 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
649 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 650 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
650 | QPtrList<Incidence> al; | 651 | QPtrList<Incidence> al; |
651 | Incidence* inL = el.first(); | 652 | Incidence* inL = el.first(); |
652 | while ( inL ) { | 653 | while ( inL ) { |
653 | bool ok = false; | 654 | bool ok = false; |
654 | int offset = 0; | 655 | int offset = 0; |
655 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 656 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
656 | if ( ok ) { | 657 | if ( ok ) { |
657 | //qDebug("OK %s",next.toString().latin1()); | 658 | //qDebug("OK %s",next.toString().latin1()); |
658 | if ( next < QDateTime::currentDateTime() ) { | 659 | if ( next < QDateTime::currentDateTime() ) { |
659 | al.append( inL ); | 660 | al.append( inL ); |
660 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 661 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
661 | } | 662 | } |
662 | } | 663 | } |
663 | inL = el.next(); | 664 | inL = el.next(); |
664 | } | 665 | } |
665 | if ( al.count() ) { | 666 | if ( al.count() ) { |
666 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 667 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
667 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 668 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
668 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 669 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
669 | lay->setSpacing( 0 ); | 670 | lay->setSpacing( 0 ); |
670 | lay->setMargin( 0 ); | 671 | lay->setMargin( 0 ); |
671 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 672 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
672 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 673 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
673 | lay->addWidget( matb ); | 674 | lay->addWidget( matb ); |
674 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 675 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
675 | int wid = 210; | 676 | int wid = 210; |
676 | int x = QApplication::desktop()->width() - wid - 7; | 677 | int x = QApplication::desktop()->width() - wid - 7; |
677 | int y = QApplication::desktop()->height() - wid - 70; | 678 | int y = QApplication::desktop()->height() - wid - 70; |
678 | dia->setGeometry ( x,y,wid,wid); | 679 | dia->setGeometry ( x,y,wid,wid); |
679 | } else { | 680 | } else { |
680 | int si = 220; | 681 | int si = 220; |
681 | if ( QApplication::desktop()->width() > 470 ) | 682 | if ( QApplication::desktop()->width() > 470 ) |
682 | si = 400; | 683 | si = 400; |
683 | dia->resize(si,si/2); | 684 | dia->resize(si,si/2); |
684 | } | 685 | } |
685 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 686 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
686 | dia->show(); | 687 | dia->show(); |
687 | 688 | ||
688 | } | 689 | } |
689 | } | 690 | } |
690 | void CalendarView::showDay( QDate d ) | 691 | void CalendarView::showDay( QDate d ) |
691 | { | 692 | { |
692 | dateNavigator()->blockSignals( true ); | 693 | dateNavigator()->blockSignals( true ); |
693 | dateNavigator()->selectDate( d ); | 694 | dateNavigator()->selectDate( d ); |
694 | dateNavigator()->blockSignals( false ); | 695 | dateNavigator()->blockSignals( false ); |
695 | mViewManager->showDayView(); | 696 | mViewManager->showDayView(); |
696 | //dateNavigator()->selectDate( d ); | 697 | //dateNavigator()->selectDate( d ); |
697 | } | 698 | } |
698 | void CalendarView::timerAlarm() | 699 | void CalendarView::timerAlarm() |
699 | { | 700 | { |
700 | //qDebug("CalendarView::timerAlarm() "); | 701 | //qDebug("CalendarView::timerAlarm() "); |
701 | computeAlarm(mAlarmNotification ); | 702 | computeAlarm(mAlarmNotification ); |
702 | } | 703 | } |
703 | 704 | ||
704 | void CalendarView::suspendAlarm() | 705 | void CalendarView::suspendAlarm() |
705 | { | 706 | { |
706 | //qDebug(" CalendarView::suspendAlarm() "); | 707 | //qDebug(" CalendarView::suspendAlarm() "); |
707 | computeAlarm(mSuspendAlarmNotification ); | 708 | computeAlarm(mSuspendAlarmNotification ); |
708 | 709 | ||
709 | } | 710 | } |
710 | 711 | ||
711 | void CalendarView::startAlarm( QString mess , QString filename) | 712 | void CalendarView::startAlarm( QString mess , QString filename) |
712 | { | 713 | { |
713 | 714 | ||
714 | topLevelWidget()->showNormal(); | 715 | topLevelWidget()->showNormal(); |
715 | topLevelWidget()->setActiveWindow(); | 716 | topLevelWidget()->setActiveWindow(); |
716 | topLevelWidget()->raise(); | 717 | topLevelWidget()->raise(); |
717 | 718 | ||
718 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 719 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
719 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 720 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
720 | 721 | ||
721 | } | 722 | } |
722 | 723 | ||
723 | void CalendarView::checkNextTimerAlarm() | 724 | void CalendarView::checkNextTimerAlarm() |
724 | { | 725 | { |
725 | mCalendar->checkAlarmForIncidence( 0, true ); | 726 | mCalendar->checkAlarmForIncidence( 0, true ); |
726 | } | 727 | } |
727 | 728 | ||
728 | void CalendarView::computeAlarm( QString msg ) | 729 | void CalendarView::computeAlarm( QString msg ) |
729 | { | 730 | { |
730 | 731 | ||
731 | QString mess = msg; | 732 | QString mess = msg; |
732 | QString mAlarmMessage = mess.mid( 9 ); | 733 | QString mAlarmMessage = mess.mid( 9 ); |
733 | QString filename = MainWindow::resourcePath(); | 734 | QString filename = MainWindow::resourcePath(); |
734 | filename += "koalarm.wav"; | 735 | filename += "koalarm.wav"; |
735 | QString tempfilename; | 736 | QString tempfilename; |
736 | if ( mess.left( 13 ) == "suspend_alarm") { | 737 | if ( mess.left( 13 ) == "suspend_alarm") { |
737 | bool error = false; | 738 | bool error = false; |
738 | int len = mess.mid( 13 ).find("+++"); | 739 | int len = mess.mid( 13 ).find("+++"); |
739 | if ( len < 2 ) | 740 | if ( len < 2 ) |
740 | error = true; | 741 | error = true; |
741 | else { | 742 | else { |
742 | tempfilename = mess.mid( 13, len ); | 743 | tempfilename = mess.mid( 13, len ); |
743 | if ( !QFile::exists( tempfilename ) ) | 744 | if ( !QFile::exists( tempfilename ) ) |
744 | error = true; | 745 | error = true; |
745 | } | 746 | } |
746 | if ( ! error ) { | 747 | if ( ! error ) { |
747 | filename = tempfilename; | 748 | filename = tempfilename; |
748 | } | 749 | } |
749 | mAlarmMessage = mess.mid( 13+len+3 ); | 750 | mAlarmMessage = mess.mid( 13+len+3 ); |
750 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 751 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
751 | startAlarm( mAlarmMessage, filename); | 752 | startAlarm( mAlarmMessage, filename); |
752 | return; | 753 | return; |
753 | } | 754 | } |
754 | if ( mess.left( 11 ) == "timer_alarm") { | 755 | if ( mess.left( 11 ) == "timer_alarm") { |
755 | //mTimerTime = 0; | 756 | //mTimerTime = 0; |
756 | startAlarm( mess.mid( 11 ), filename ); | 757 | startAlarm( mess.mid( 11 ), filename ); |
757 | return; | 758 | return; |
758 | } | 759 | } |
759 | if ( mess.left( 10 ) == "proc_alarm") { | 760 | if ( mess.left( 10 ) == "proc_alarm") { |
760 | bool error = false; | 761 | bool error = false; |
761 | int len = mess.mid( 10 ).find("+++"); | 762 | int len = mess.mid( 10 ).find("+++"); |
762 | if ( len < 2 ) | 763 | if ( len < 2 ) |
763 | error = true; | 764 | error = true; |
764 | else { | 765 | else { |
765 | tempfilename = mess.mid( 10, len ); | 766 | tempfilename = mess.mid( 10, len ); |
766 | if ( !QFile::exists( tempfilename ) ) | 767 | if ( !QFile::exists( tempfilename ) ) |
767 | error = true; | 768 | error = true; |
768 | } | 769 | } |
769 | if ( error ) { | 770 | if ( error ) { |
770 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 771 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
771 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 772 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
772 | } else { | 773 | } else { |
773 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 774 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
774 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 775 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
775 | #ifndef _WIN32_ | 776 | #ifndef _WIN32_ |
776 | if ( vfork () == 0 ) { | 777 | if ( vfork () == 0 ) { |
777 | execl ( tempfilename.latin1(), 0 ); | 778 | execl ( tempfilename.latin1(), 0 ); |
778 | return; | 779 | return; |
779 | } | 780 | } |
780 | #else | 781 | #else |
781 | QProcess* p = new QProcess(); | 782 | QProcess* p = new QProcess(); |
782 | p->addArgument( tempfilename.latin1() ); | 783 | p->addArgument( tempfilename.latin1() ); |
783 | p->start(); | 784 | p->start(); |
784 | return; | 785 | return; |
785 | #endif | 786 | #endif |
786 | 787 | ||
787 | return; | 788 | return; |
788 | } | 789 | } |
789 | 790 | ||
790 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 791 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
791 | } | 792 | } |
792 | if ( mess.left( 11 ) == "audio_alarm") { | 793 | if ( mess.left( 11 ) == "audio_alarm") { |
793 | bool error = false; | 794 | bool error = false; |
794 | int len = mess.mid( 11 ).find("+++"); | 795 | int len = mess.mid( 11 ).find("+++"); |
795 | if ( len < 2 ) | 796 | if ( len < 2 ) |
796 | error = true; | 797 | error = true; |
797 | else { | 798 | else { |
798 | tempfilename = mess.mid( 11, len ); | 799 | tempfilename = mess.mid( 11, len ); |
799 | if ( !QFile::exists( tempfilename ) ) | 800 | if ( !QFile::exists( tempfilename ) ) |
800 | error = true; | 801 | error = true; |
801 | } | 802 | } |
802 | if ( ! error ) { | 803 | if ( ! error ) { |
803 | filename = tempfilename; | 804 | filename = tempfilename; |
804 | } | 805 | } |
805 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 806 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
806 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 807 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
807 | } | 808 | } |
808 | if ( mess.left( 9 ) == "cal_alarm") { | 809 | if ( mess.left( 9 ) == "cal_alarm") { |
809 | mAlarmMessage = mess.mid( 9 ) ; | 810 | mAlarmMessage = mess.mid( 9 ) ; |
810 | } | 811 | } |
811 | 812 | ||
812 | startAlarm( mAlarmMessage, filename ); | 813 | startAlarm( mAlarmMessage, filename ); |
813 | 814 | ||
814 | 815 | ||
815 | } | 816 | } |
816 | 817 | ||
817 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 818 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
818 | { | 819 | { |
819 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 820 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
820 | 821 | ||
821 | mSuspendAlarmNotification = noti; | 822 | mSuspendAlarmNotification = noti; |
822 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 823 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
823 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 824 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
824 | mSuspendTimer->start( ms , true ); | 825 | mSuspendTimer->start( ms , true ); |
825 | 826 | ||
826 | } | 827 | } |
827 | 828 | ||
828 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 829 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
829 | { | 830 | { |
830 | mNextAlarmDateTime = qdt; | 831 | mNextAlarmDateTime = qdt; |
831 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 832 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
832 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 833 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
833 | #ifndef DESKTOP_VERSION | 834 | #ifndef DESKTOP_VERSION |
834 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 835 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
835 | #endif | 836 | #endif |
836 | return; | 837 | return; |
837 | } | 838 | } |
838 | int maxSec; | 839 | int maxSec; |
839 | //maxSec = 5; //testing only | 840 | //maxSec = 5; //testing only |
840 | maxSec = 86400+3600; // one day+1hour | 841 | maxSec = 86400+3600; // one day+1hour |
841 | mAlarmNotification = noti; | 842 | mAlarmNotification = noti; |
842 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 843 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
843 | if ( sec > maxSec ) { | 844 | if ( sec > maxSec ) { |
844 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 845 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
845 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 846 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
846 | return; | 847 | return; |
847 | } else { | 848 | } else { |
848 | mRecheckAlarmTimer->stop(); | 849 | mRecheckAlarmTimer->stop(); |
849 | } | 850 | } |
850 | //qDebug("Alarm timer started with secs: %d ", sec); | 851 | //qDebug("Alarm timer started with secs: %d ", sec); |
851 | mAlarmTimer->start( sec *1000 , true ); | 852 | mAlarmTimer->start( sec *1000 , true ); |
852 | 853 | ||
853 | } | 854 | } |
854 | // called by mRecheckAlarmTimer to get next alarm | 855 | // called by mRecheckAlarmTimer to get next alarm |
855 | // we need this, because a QTimer has only a max range of 25 days | 856 | // we need this, because a QTimer has only a max range of 25 days |
856 | void CalendarView::recheckTimerAlarm() | 857 | void CalendarView::recheckTimerAlarm() |
857 | { | 858 | { |
858 | mAlarmTimer->stop(); | 859 | mAlarmTimer->stop(); |
859 | mRecheckAlarmTimer->stop(); | 860 | mRecheckAlarmTimer->stop(); |
860 | mCalendar->checkAlarmForIncidence( 0, true ); | 861 | mCalendar->checkAlarmForIncidence( 0, true ); |
861 | } | 862 | } |
862 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 863 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
863 | { | 864 | { |
864 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 865 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
865 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 866 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
866 | #ifndef DESKTOP_VERSION | 867 | #ifndef DESKTOP_VERSION |
867 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 868 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
868 | #endif | 869 | #endif |
869 | return; | 870 | return; |
870 | } | 871 | } |
871 | mAlarmTimer->stop(); | 872 | mAlarmTimer->stop(); |
872 | } | 873 | } |
873 | void CalendarView::selectWeekNum ( int num ) | 874 | void CalendarView::selectWeekNum ( int num ) |
874 | { | 875 | { |
875 | dateNavigator()->blockSignals( true ); | 876 | dateNavigator()->blockSignals( true ); |
876 | dateNavigator()->selectWeek( num ); | 877 | dateNavigator()->selectWeek( num ); |
877 | dateNavigator()->blockSignals( false ); | 878 | dateNavigator()->blockSignals( false ); |
878 | mViewManager->showWeekView(); | 879 | mViewManager->showWeekView(); |
879 | } | 880 | } |
880 | KOViewManager *CalendarView::viewManager() | 881 | KOViewManager *CalendarView::viewManager() |
881 | { | 882 | { |
882 | return mViewManager; | 883 | return mViewManager; |
883 | } | 884 | } |
884 | 885 | ||
885 | KODialogManager *CalendarView::dialogManager() | 886 | KODialogManager *CalendarView::dialogManager() |
886 | { | 887 | { |
887 | return mDialogManager; | 888 | return mDialogManager; |
888 | } | 889 | } |
889 | 890 | ||
890 | QDate CalendarView::startDate() | 891 | QDate CalendarView::startDate() |
891 | { | 892 | { |
892 | DateList dates = mNavigator->selectedDates(); | 893 | DateList dates = mNavigator->selectedDates(); |
893 | 894 | ||
894 | return dates.first(); | 895 | return dates.first(); |
895 | } | 896 | } |
896 | 897 | ||
897 | QDate CalendarView::endDate() | 898 | QDate CalendarView::endDate() |
898 | { | 899 | { |
899 | DateList dates = mNavigator->selectedDates(); | 900 | DateList dates = mNavigator->selectedDates(); |
900 | 901 | ||
901 | return dates.last(); | 902 | return dates.last(); |
902 | } | 903 | } |
903 | 904 | ||
904 | 905 | ||
905 | void CalendarView::createPrinter() | 906 | void CalendarView::createPrinter() |
906 | { | 907 | { |
907 | #ifndef KORG_NOPRINTER | 908 | #ifndef KORG_NOPRINTER |
908 | if (!mCalPrinter) { | 909 | if (!mCalPrinter) { |
909 | mCalPrinter = new CalPrinter(this, mCalendar); | 910 | mCalPrinter = new CalPrinter(this, mCalendar); |
910 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 911 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
911 | } | 912 | } |
912 | #endif | 913 | #endif |
913 | } | 914 | } |
914 | 915 | ||
915 | 916 | ||
916 | //KOPrefs::instance()->mWriteBackFile | 917 | //KOPrefs::instance()->mWriteBackFile |
917 | //KOPrefs::instance()->mWriteBackExistingOnly | 918 | //KOPrefs::instance()->mWriteBackExistingOnly |
918 | 919 | ||
919 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 920 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
920 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 921 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
921 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 922 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
922 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 923 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
923 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 924 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
924 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 925 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
925 | 926 | ||
926 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 927 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
927 | { | 928 | { |
928 | 929 | ||
929 | // 0 equal | 930 | // 0 equal |
930 | // 1 take local | 931 | // 1 take local |
931 | // 2 take remote | 932 | // 2 take remote |
932 | // 3 cancel | 933 | // 3 cancel |
933 | QDateTime lastSync = mLastCalendarSync; | 934 | QDateTime lastSync = mLastCalendarSync; |
934 | QDateTime localMod = local->lastModified(); | 935 | QDateTime localMod = local->lastModified(); |
935 | QDateTime remoteMod = remote->lastModified(); | 936 | QDateTime remoteMod = remote->lastModified(); |
936 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 937 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
937 | bool remCh, locCh; | 938 | bool remCh, locCh; |
938 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 939 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
939 | //if ( remCh ) | 940 | //if ( remCh ) |
940 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 941 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
941 | locCh = ( localMod > mLastCalendarSync ); | 942 | locCh = ( localMod > mLastCalendarSync ); |
942 | if ( !remCh && ! locCh ) { | 943 | if ( !remCh && ! locCh ) { |
943 | //qDebug("both not changed "); | 944 | //qDebug("both not changed "); |
944 | lastSync = localMod.addDays(1); | 945 | lastSync = localMod.addDays(1); |
945 | if ( mode <= SYNC_PREF_ASK ) | 946 | if ( mode <= SYNC_PREF_ASK ) |
946 | return 0; | 947 | return 0; |
947 | } else { | 948 | } else { |
948 | if ( locCh ) { | 949 | if ( locCh ) { |
949 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 950 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
950 | lastSync = localMod.addDays( -1 ); | 951 | lastSync = localMod.addDays( -1 ); |
951 | if ( !remCh ) | 952 | if ( !remCh ) |
952 | remoteMod = ( lastSync.addDays( -1 ) ); | 953 | remoteMod = ( lastSync.addDays( -1 ) ); |
953 | } else { | 954 | } else { |
954 | //qDebug(" not loc changed "); | 955 | //qDebug(" not loc changed "); |
955 | lastSync = localMod.addDays( 1 ); | 956 | lastSync = localMod.addDays( 1 ); |
956 | if ( remCh ) | 957 | if ( remCh ) |
957 | remoteMod =( lastSync.addDays( 1 ) ); | 958 | remoteMod =( lastSync.addDays( 1 ) ); |
958 | 959 | ||
959 | } | 960 | } |
960 | } | 961 | } |
961 | full = true; | 962 | full = true; |
962 | if ( mode < SYNC_PREF_ASK ) | 963 | if ( mode < SYNC_PREF_ASK ) |
963 | mode = SYNC_PREF_ASK; | 964 | mode = SYNC_PREF_ASK; |
964 | } else { | 965 | } else { |
965 | if ( localMod == remoteMod ) | 966 | if ( localMod == remoteMod ) |
966 | // if ( local->revision() == remote->revision() ) | 967 | // if ( local->revision() == remote->revision() ) |
967 | return 0; | 968 | return 0; |
968 | 969 | ||
969 | } | 970 | } |
970 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 971 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
971 | 972 | ||
972 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 973 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
973 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 974 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
974 | //full = true; //debug only | 975 | //full = true; //debug only |
975 | if ( full ) { | 976 | if ( full ) { |
976 | bool equ = false; | 977 | bool equ = false; |
977 | if ( local->typeID() == eventID ) { | 978 | if ( local->typeID() == eventID ) { |
978 | equ = (*((Event*) local) == *((Event*) remote)); | 979 | equ = (*((Event*) local) == *((Event*) remote)); |
979 | } | 980 | } |
980 | else if ( local->typeID() == todoID ) | 981 | else if ( local->typeID() == todoID ) |
981 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 982 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
982 | else if ( local->typeID() == journalID ) | 983 | else if ( local->typeID() == journalID ) |
983 | equ = (*((Journal*) local) == *((Journal*) remote)); | 984 | equ = (*((Journal*) local) == *((Journal*) remote)); |
984 | if ( equ ) { | 985 | if ( equ ) { |
985 | //qDebug("equal "); | 986 | //qDebug("equal "); |
986 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 987 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
987 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 988 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
988 | } | 989 | } |
989 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 990 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
990 | return 0; | 991 | return 0; |
991 | 992 | ||
992 | }//else //debug only | 993 | }//else //debug only |
993 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 994 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
994 | } | 995 | } |
995 | int result; | 996 | int result; |
996 | bool localIsNew; | 997 | bool localIsNew; |
997 | //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() ); | 998 | //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() ); |
998 | 999 | ||
999 | 1000 | ||
1000 | // ************************************************ | 1001 | // ************************************************ |
1001 | // ************************************************ | 1002 | // ************************************************ |
1002 | // ************************************************ | 1003 | // ************************************************ |
1003 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1004 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1004 | // BUT remoteMod != localMod | 1005 | // BUT remoteMod != localMod |
1005 | 1006 | ||
1006 | 1007 | ||
1007 | if ( full && mode < SYNC_PREF_NEWEST ) | 1008 | if ( full && mode < SYNC_PREF_NEWEST ) |
1008 | mode = SYNC_PREF_ASK; | 1009 | mode = SYNC_PREF_ASK; |
1009 | 1010 | ||
1010 | switch( mode ) { | 1011 | switch( mode ) { |
1011 | case SYNC_PREF_LOCAL: | 1012 | case SYNC_PREF_LOCAL: |
1012 | if ( lastSync > remoteMod ) | 1013 | if ( lastSync > remoteMod ) |
1013 | return 1; | 1014 | return 1; |
1014 | if ( lastSync > localMod ) | 1015 | if ( lastSync > localMod ) |
1015 | return 2; | 1016 | return 2; |
1016 | return 1; | 1017 | return 1; |
1017 | break; | 1018 | break; |
1018 | case SYNC_PREF_REMOTE: | 1019 | case SYNC_PREF_REMOTE: |
1019 | if ( lastSync > localMod ) | 1020 | if ( lastSync > localMod ) |
1020 | return 2; | 1021 | return 2; |
1021 | if ( lastSync > remoteMod ) | 1022 | if ( lastSync > remoteMod ) |
1022 | return 1; | 1023 | return 1; |
1023 | return 2; | 1024 | return 2; |
1024 | break; | 1025 | break; |
1025 | case SYNC_PREF_NEWEST: | 1026 | case SYNC_PREF_NEWEST: |
1026 | if ( localMod >= remoteMod ) | 1027 | if ( localMod >= remoteMod ) |
1027 | return 1; | 1028 | return 1; |
1028 | else | 1029 | else |
1029 | return 2; | 1030 | return 2; |
1030 | break; | 1031 | break; |
1031 | case SYNC_PREF_ASK: | 1032 | case SYNC_PREF_ASK: |
1032 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1033 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1033 | if ( lastSync > remoteMod && lastSync > localMod) | 1034 | if ( lastSync > remoteMod && lastSync > localMod) |
1034 | return 0; | 1035 | return 0; |
1035 | if ( lastSync > remoteMod ) | 1036 | if ( lastSync > remoteMod ) |
1036 | return 1; | 1037 | return 1; |
1037 | if ( lastSync > localMod ) | 1038 | if ( lastSync > localMod ) |
1038 | return 2; | 1039 | return 2; |
1039 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1040 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1040 | localIsNew = localMod >= remoteMod; | 1041 | localIsNew = localMod >= remoteMod; |
1041 | if ( localIsNew ) | 1042 | if ( localIsNew ) |
1042 | getEventViewerDialog()->setColorMode( 1 ); | 1043 | getEventViewerDialog()->setColorMode( 1 ); |
1043 | else | 1044 | else |
1044 | getEventViewerDialog()->setColorMode( 2 ); | 1045 | getEventViewerDialog()->setColorMode( 2 ); |
1045 | getEventViewerDialog()->setIncidence(local); | 1046 | getEventViewerDialog()->setIncidence(local); |
1046 | if ( localIsNew ) | 1047 | if ( localIsNew ) |
1047 | getEventViewerDialog()->setColorMode( 2 ); | 1048 | getEventViewerDialog()->setColorMode( 2 ); |
1048 | else | 1049 | else |
1049 | getEventViewerDialog()->setColorMode( 1 ); | 1050 | getEventViewerDialog()->setColorMode( 1 ); |
1050 | getEventViewerDialog()->addIncidence(remote); | 1051 | getEventViewerDialog()->addIncidence(remote); |
1051 | getEventViewerDialog()->setColorMode( 0 ); | 1052 | getEventViewerDialog()->setColorMode( 0 ); |
1052 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1053 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1053 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1054 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1054 | getEventViewerDialog()->showMe(); | 1055 | getEventViewerDialog()->showMe(); |
1055 | result = getEventViewerDialog()->executeS( localIsNew ); | 1056 | result = getEventViewerDialog()->executeS( localIsNew ); |
1056 | return result; | 1057 | return result; |
1057 | 1058 | ||
1058 | break; | 1059 | break; |
1059 | case SYNC_PREF_FORCE_LOCAL: | 1060 | case SYNC_PREF_FORCE_LOCAL: |
1060 | return 1; | 1061 | return 1; |
1061 | break; | 1062 | break; |
1062 | case SYNC_PREF_FORCE_REMOTE: | 1063 | case SYNC_PREF_FORCE_REMOTE: |
1063 | return 2; | 1064 | return 2; |
1064 | break; | 1065 | break; |
1065 | 1066 | ||
1066 | default: | 1067 | default: |
1067 | // SYNC_PREF_TAKE_BOTH not implemented | 1068 | // SYNC_PREF_TAKE_BOTH not implemented |
1068 | break; | 1069 | break; |
1069 | } | 1070 | } |
1070 | return 0; | 1071 | return 0; |
1071 | } | 1072 | } |
1072 | Event* CalendarView::getLastSyncEvent() | 1073 | Event* CalendarView::getLastSyncEvent() |
1073 | { | 1074 | { |
1074 | Event* lse; | 1075 | Event* lse; |
1075 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1076 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1076 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1077 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1077 | if (!lse) { | 1078 | if (!lse) { |
1078 | lse = new Event(); | 1079 | lse = new Event(); |
1079 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1080 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1080 | QString sum = ""; | 1081 | QString sum = ""; |
1081 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1082 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1082 | sum = "E: "; | 1083 | sum = "E: "; |
1083 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1084 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1084 | lse->setDtStart( mLastCalendarSync ); | 1085 | lse->setDtStart( mLastCalendarSync ); |
1085 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1086 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1086 | lse->setCategories( i18n("SyncEvent") ); | 1087 | lse->setCategories( i18n("SyncEvent") ); |
1087 | lse->setReadOnly( true ); | 1088 | lse->setReadOnly( true ); |
1088 | mCalendar->addEvent( lse ); | 1089 | mCalendar->addEvent( lse ); |
1089 | } | 1090 | } |
1090 | 1091 | ||
1091 | return lse; | 1092 | return lse; |
1092 | 1093 | ||
1093 | } | 1094 | } |
1094 | 1095 | ||
1095 | // we check, if the to delete event has a id for a profile | 1096 | // we check, if the to delete event has a id for a profile |
1096 | // if yes, we set this id in the profile to delete | 1097 | // if yes, we set this id in the profile to delete |
1097 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1098 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1098 | { | 1099 | { |
1099 | if ( lastSync.count() == 0 ) { | 1100 | if ( lastSync.count() == 0 ) { |
1100 | //qDebug(" lastSync.count() == 0"); | 1101 | //qDebug(" lastSync.count() == 0"); |
1101 | return; | 1102 | return; |
1102 | } | 1103 | } |
1103 | if ( toDelete->typeID() == journalID ) | 1104 | if ( toDelete->typeID() == journalID ) |
1104 | return; | 1105 | return; |
1105 | 1106 | ||
1106 | Event* eve = lastSync.first(); | 1107 | Event* eve = lastSync.first(); |
1107 | 1108 | ||
1108 | while ( eve ) { | 1109 | while ( eve ) { |
1109 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1110 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1110 | if ( !id.isEmpty() ) { | 1111 | if ( !id.isEmpty() ) { |
1111 | QString des = eve->description(); | 1112 | QString des = eve->description(); |
1112 | QString pref = "e"; | 1113 | QString pref = "e"; |
1113 | if ( toDelete->typeID() == todoID ) | 1114 | if ( toDelete->typeID() == todoID ) |
1114 | pref = "t"; | 1115 | pref = "t"; |
1115 | des += pref+ id + ","; | 1116 | des += pref+ id + ","; |
1116 | eve->setReadOnly( false ); | 1117 | eve->setReadOnly( false ); |
1117 | eve->setDescription( des ); | 1118 | eve->setDescription( des ); |
1118 | //qDebug("setdes %s ", des.latin1()); | 1119 | //qDebug("setdes %s ", des.latin1()); |
1119 | eve->setReadOnly( true ); | 1120 | eve->setReadOnly( true ); |
1120 | } | 1121 | } |
1121 | eve = lastSync.next(); | 1122 | eve = lastSync.next(); |
1122 | } | 1123 | } |
1123 | 1124 | ||
1124 | } | 1125 | } |
1125 | void CalendarView::checkExternalId( Incidence * inc ) | 1126 | void CalendarView::checkExternalId( Incidence * inc ) |
1126 | { | 1127 | { |
1127 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1128 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1128 | checkExternSyncEvent( lastSync, inc ); | 1129 | checkExternSyncEvent( lastSync, inc ); |
1129 | 1130 | ||
1130 | } | 1131 | } |
1131 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1132 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1132 | { | 1133 | { |
1133 | bool syncOK = true; | 1134 | bool syncOK = true; |
1134 | int addedEvent = 0; | 1135 | int addedEvent = 0; |
1135 | int addedEventR = 0; | 1136 | int addedEventR = 0; |
1136 | int deletedEventR = 0; | 1137 | int deletedEventR = 0; |
1137 | int deletedEventL = 0; | 1138 | int deletedEventL = 0; |
1138 | int changedLocal = 0; | 1139 | int changedLocal = 0; |
1139 | int changedRemote = 0; | 1140 | int changedRemote = 0; |
1140 | int filteredIN = 0; | 1141 | int filteredIN = 0; |
1141 | int filteredOUT = 0; | 1142 | int filteredOUT = 0; |
1142 | //QPtrList<Event> el = local->rawEvents(); | 1143 | //QPtrList<Event> el = local->rawEvents(); |
1143 | Event* eventR; | 1144 | Event* eventR; |
1144 | QString uid; | 1145 | QString uid; |
1145 | int take; | 1146 | int take; |
1146 | Event* eventL; | 1147 | Event* eventL; |
1147 | Event* eventRSync; | 1148 | Event* eventRSync; |
1148 | Event* eventLSync; | 1149 | Event* eventLSync; |
1149 | clearAllViews(); | 1150 | clearAllViews(); |
1150 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1151 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1151 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1152 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1152 | bool fullDateRange = false; | 1153 | bool fullDateRange = false; |
1153 | local->resetTempSyncStat(); | 1154 | local->resetTempSyncStat(); |
1154 | mLastCalendarSync = QDateTime::currentDateTime(); | 1155 | mLastCalendarSync = QDateTime::currentDateTime(); |
1155 | if ( mSyncManager->syncWithDesktop() ) { | 1156 | if ( mSyncManager->syncWithDesktop() ) { |
1156 | remote->resetPilotStat(1); | 1157 | remote->resetPilotStat(1); |
1157 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1158 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1158 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1159 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1159 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1160 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1160 | } else { | 1161 | } else { |
1161 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1162 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1162 | } | 1163 | } |
1163 | } | 1164 | } |
1164 | QDateTime modifiedCalendar = mLastCalendarSync; | 1165 | QDateTime modifiedCalendar = mLastCalendarSync; |
1165 | eventLSync = getLastSyncEvent(); | 1166 | eventLSync = getLastSyncEvent(); |
1166 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1167 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1167 | if ( eventR ) { | 1168 | if ( eventR ) { |
1168 | eventRSync = (Event*) eventR->clone(); | 1169 | eventRSync = (Event*) eventR->clone(); |
1169 | remote->deleteEvent(eventR ); | 1170 | remote->deleteEvent(eventR ); |
1170 | 1171 | ||
1171 | } else { | 1172 | } else { |
1172 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1173 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1173 | eventRSync = (Event*)eventLSync->clone(); | 1174 | eventRSync = (Event*)eventLSync->clone(); |
1174 | } else { | 1175 | } else { |
1175 | fullDateRange = true; | 1176 | fullDateRange = true; |
1176 | eventRSync = new Event(); | 1177 | eventRSync = new Event(); |
1177 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1178 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1178 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1179 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1179 | eventRSync->setDtStart( mLastCalendarSync ); | 1180 | eventRSync->setDtStart( mLastCalendarSync ); |
1180 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1181 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1181 | eventRSync->setCategories( i18n("SyncEvent") ); | 1182 | eventRSync->setCategories( i18n("SyncEvent") ); |
1182 | } | 1183 | } |
1183 | } | 1184 | } |
1184 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1185 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1185 | fullDateRange = true; | 1186 | fullDateRange = true; |
1186 | 1187 | ||
1187 | if ( ! fullDateRange ) { | 1188 | if ( ! fullDateRange ) { |
1188 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1189 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1189 | 1190 | ||
1190 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1191 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1191 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1192 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1192 | fullDateRange = true; | 1193 | fullDateRange = true; |
1193 | } | 1194 | } |
1194 | } | 1195 | } |
1195 | if ( mSyncManager->syncWithDesktop() ) { | 1196 | if ( mSyncManager->syncWithDesktop() ) { |
1196 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1197 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1197 | } | 1198 | } |
1198 | if ( fullDateRange ) | 1199 | if ( fullDateRange ) |
1199 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1200 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1200 | else | 1201 | else |
1201 | mLastCalendarSync = eventLSync->dtStart(); | 1202 | mLastCalendarSync = eventLSync->dtStart(); |
1202 | // for resyncing if own file has changed | 1203 | // for resyncing if own file has changed |
1203 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1204 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1204 | mLastCalendarSync = loadedFileVersion; | 1205 | mLastCalendarSync = loadedFileVersion; |
1205 | //qDebug("setting mLastCalendarSync "); | 1206 | //qDebug("setting mLastCalendarSync "); |
1206 | } | 1207 | } |
1207 | //qDebug("*************************** "); | 1208 | //qDebug("*************************** "); |
1208 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1209 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1209 | QPtrList<Incidence> er = remote->rawIncidences(); | 1210 | QPtrList<Incidence> er = remote->rawIncidences(); |
1210 | Incidence* inR = er.first(); | 1211 | Incidence* inR = er.first(); |
1211 | Incidence* inL; | 1212 | Incidence* inL; |
1212 | QProgressBar bar( er.count(),0 ); | 1213 | QProgressBar bar( er.count(),0 ); |
1213 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1214 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1214 | 1215 | ||
1215 | // ************** setting up filter ************* | 1216 | // ************** setting up filter ************* |
1216 | CalFilter *filterIN = 0; | 1217 | CalFilter *filterIN = 0; |
1217 | CalFilter *filterOUT = 0; | 1218 | CalFilter *filterOUT = 0; |
1218 | CalFilter *filter = mFilters.first(); | 1219 | CalFilter *filter = mFilters.first(); |
1219 | while(filter) { | 1220 | while(filter) { |
1220 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1221 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1221 | filterIN = filter; | 1222 | filterIN = filter; |
1222 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1223 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1223 | filterOUT = filter; | 1224 | filterOUT = filter; |
1224 | filter = mFilters.next(); | 1225 | filter = mFilters.next(); |
1225 | } | 1226 | } |
1226 | int w = 300; | 1227 | int w = 300; |
1227 | if ( QApplication::desktop()->width() < 320 ) | 1228 | if ( QApplication::desktop()->width() < 320 ) |
1228 | w = 220; | 1229 | w = 220; |
1229 | int h = bar.sizeHint().height() ; | 1230 | int h = bar.sizeHint().height() ; |
1230 | int dw = QApplication::desktop()->width(); | 1231 | int dw = QApplication::desktop()->width(); |
1231 | int dh = QApplication::desktop()->height(); | 1232 | int dh = QApplication::desktop()->height(); |
1232 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1233 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1233 | bar.show(); | 1234 | bar.show(); |
1234 | int modulo = (er.count()/10)+1; | 1235 | int modulo = (er.count()/10)+1; |
1235 | int incCounter = 0; | 1236 | int incCounter = 0; |
1236 | while ( inR ) { | 1237 | while ( inR ) { |
1237 | if ( ! bar.isVisible() ) | 1238 | if ( ! bar.isVisible() ) |
1238 | return false; | 1239 | return false; |
1239 | if ( incCounter % modulo == 0 ) | 1240 | if ( incCounter % modulo == 0 ) |
1240 | bar.setProgress( incCounter ); | 1241 | bar.setProgress( incCounter ); |
1241 | ++incCounter; | 1242 | ++incCounter; |
1242 | uid = inR->uid(); | 1243 | uid = inR->uid(); |
1243 | bool skipIncidence = false; | 1244 | bool skipIncidence = false; |
1244 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1245 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1245 | skipIncidence = true; | 1246 | skipIncidence = true; |
1246 | QString idS; | 1247 | QString idS; |
1247 | qApp->processEvents(); | 1248 | qApp->processEvents(); |
1248 | if ( !skipIncidence ) { | 1249 | if ( !skipIncidence ) { |
1249 | inL = local->incidence( uid ); | 1250 | inL = local->incidence( uid ); |
1250 | if ( inL ) { // maybe conflict - same uid in both calendars | 1251 | if ( inL ) { // maybe conflict - same uid in both calendars |
1251 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1252 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1252 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1253 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1253 | if ( take == 3 ) | 1254 | if ( take == 3 ) |
1254 | return false; | 1255 | return false; |
1255 | if ( take == 1 ) {// take local ********************** | 1256 | if ( take == 1 ) {// take local ********************** |
1256 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1257 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1257 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1258 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1258 | else | 1259 | else |
1259 | idS = inR->IDStr(); | 1260 | idS = inR->IDStr(); |
1260 | remote->deleteIncidence( inR ); | 1261 | remote->deleteIncidence( inR ); |
1261 | inR = inL->clone(); | 1262 | inR = inL->clone(); |
1262 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1263 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1263 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1264 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1264 | inR->setIDStr( idS ); | 1265 | inR->setIDStr( idS ); |
1265 | remote->addIncidence( inR ); | 1266 | remote->addIncidence( inR ); |
1266 | if ( mSyncManager->syncWithDesktop() ) | 1267 | if ( mSyncManager->syncWithDesktop() ) |
1267 | inR->setPilotId( 2 ); | 1268 | inR->setPilotId( 2 ); |
1268 | ++changedRemote; | 1269 | ++changedRemote; |
1269 | } else {// take remote ********************** | 1270 | } else {// take remote ********************** |
1270 | idS = inL->IDStr(); | 1271 | idS = inL->IDStr(); |
1271 | int pid = inL->pilotId(); | 1272 | int pid = inL->pilotId(); |
1272 | local->deleteIncidence( inL ); | 1273 | local->deleteIncidence( inL ); |
1273 | inL = inR->clone(); | 1274 | inL = inR->clone(); |
1274 | if ( mSyncManager->syncWithDesktop() ) | 1275 | if ( mSyncManager->syncWithDesktop() ) |
1275 | inL->setPilotId( pid ); | 1276 | inL->setPilotId( pid ); |
1276 | inL->setIDStr( idS ); | 1277 | inL->setIDStr( idS ); |
1277 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1278 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1278 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1279 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1279 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1280 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1280 | } | 1281 | } |
1281 | local->addIncidence( inL ); | 1282 | local->addIncidence( inL ); |
1282 | ++changedLocal; | 1283 | ++changedLocal; |
1283 | } | 1284 | } |
1284 | } | 1285 | } |
1285 | } else { // no conflict ********** add or delete remote | 1286 | } else { // no conflict ********** add or delete remote |
1286 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1287 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1287 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1288 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1288 | QString des = eventLSync->description(); | 1289 | QString des = eventLSync->description(); |
1289 | QString pref = "e"; | 1290 | QString pref = "e"; |
1290 | if ( inR->typeID() == todoID ) | 1291 | if ( inR->typeID() == todoID ) |
1291 | pref = "t"; | 1292 | pref = "t"; |
1292 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1293 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1293 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1294 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1294 | //remote->deleteIncidence( inR ); | 1295 | //remote->deleteIncidence( inR ); |
1295 | ++deletedEventR; | 1296 | ++deletedEventR; |
1296 | } else { | 1297 | } else { |
1297 | inR->setLastModified( modifiedCalendar ); | 1298 | inR->setLastModified( modifiedCalendar ); |
1298 | inL = inR->clone(); | 1299 | inL = inR->clone(); |
1299 | inL->setIDStr( ":" ); | 1300 | inL->setIDStr( ":" ); |
1300 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1301 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1301 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1302 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1302 | local->addIncidence( inL ); | 1303 | local->addIncidence( inL ); |
1303 | ++addedEvent; | 1304 | ++addedEvent; |
1304 | 1305 | ||
1305 | } | 1306 | } |
1306 | } else { | 1307 | } else { |
1307 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1308 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1308 | inR->setLastModified( modifiedCalendar ); | 1309 | inR->setLastModified( modifiedCalendar ); |
1309 | inL = inR->clone(); | 1310 | inL = inR->clone(); |
1310 | inL->setIDStr( ":" ); | 1311 | inL->setIDStr( ":" ); |
1311 | local->addIncidence( inL ); | 1312 | local->addIncidence( inL ); |
1312 | ++addedEvent; | 1313 | ++addedEvent; |
1313 | 1314 | ||
1314 | } else { | 1315 | } else { |
1315 | checkExternSyncEvent(eventRSyncSharp, inR); | 1316 | checkExternSyncEvent(eventRSyncSharp, inR); |
1316 | remote->deleteIncidence( inR ); | 1317 | remote->deleteIncidence( inR ); |
1317 | ++deletedEventR; | 1318 | ++deletedEventR; |
1318 | } | 1319 | } |
1319 | } | 1320 | } |
1320 | } else { | 1321 | } else { |
1321 | ++filteredIN; | 1322 | ++filteredIN; |
1322 | } | 1323 | } |
1323 | } | 1324 | } |
1324 | } | 1325 | } |
1325 | inR = er.next(); | 1326 | inR = er.next(); |
1326 | } | 1327 | } |
1327 | QPtrList<Incidence> el = local->rawIncidences(); | 1328 | QPtrList<Incidence> el = local->rawIncidences(); |
1328 | inL = el.first(); | 1329 | inL = el.first(); |
1329 | modulo = (el.count()/10)+1; | 1330 | modulo = (el.count()/10)+1; |
1330 | bar.setCaption (i18n("Add / remove events") ); | 1331 | bar.setCaption (i18n("Add / remove events") ); |
1331 | bar.setTotalSteps ( el.count() ) ; | 1332 | bar.setTotalSteps ( el.count() ) ; |
1332 | bar.show(); | 1333 | bar.show(); |
1333 | incCounter = 0; | 1334 | incCounter = 0; |
1334 | 1335 | ||
1335 | while ( inL ) { | 1336 | while ( inL ) { |
1336 | 1337 | ||
1337 | qApp->processEvents(); | 1338 | qApp->processEvents(); |
1338 | if ( ! bar.isVisible() ) | 1339 | if ( ! bar.isVisible() ) |
1339 | return false; | 1340 | return false; |
1340 | if ( incCounter % modulo == 0 ) | 1341 | if ( incCounter % modulo == 0 ) |
1341 | bar.setProgress( incCounter ); | 1342 | bar.setProgress( incCounter ); |
1342 | ++incCounter; | 1343 | ++incCounter; |
1343 | uid = inL->uid(); | 1344 | uid = inL->uid(); |
1344 | bool skipIncidence = false; | 1345 | bool skipIncidence = false; |
1345 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1346 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1346 | skipIncidence = true; | 1347 | skipIncidence = true; |
1347 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1348 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1348 | skipIncidence = true; | 1349 | skipIncidence = true; |
1349 | if ( !skipIncidence ) { | 1350 | if ( !skipIncidence ) { |
1350 | inR = remote->incidence( uid ); | 1351 | inR = remote->incidence( uid ); |
1351 | if ( ! inR ) { | 1352 | if ( ! inR ) { |
1352 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1353 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1353 | // no conflict ********** add or delete local | 1354 | // no conflict ********** add or delete local |
1354 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1355 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1355 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1356 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1356 | checkExternSyncEvent(eventLSyncSharp, inL); | 1357 | checkExternSyncEvent(eventLSyncSharp, inL); |
1357 | local->deleteIncidence( inL ); | 1358 | local->deleteIncidence( inL ); |
1358 | ++deletedEventL; | 1359 | ++deletedEventL; |
1359 | } else { | 1360 | } else { |
1360 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1361 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1361 | inL->removeID(mCurrentSyncDevice ); | 1362 | inL->removeID(mCurrentSyncDevice ); |
1362 | ++addedEventR; | 1363 | ++addedEventR; |
1363 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1364 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1364 | inL->setLastModified( modifiedCalendar ); | 1365 | inL->setLastModified( modifiedCalendar ); |
1365 | inR = inL->clone(); | 1366 | inR = inL->clone(); |
1366 | inR->setIDStr( ":" ); | 1367 | inR->setIDStr( ":" ); |
1367 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1368 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1368 | remote->addIncidence( inR ); | 1369 | remote->addIncidence( inR ); |
1369 | } | 1370 | } |
1370 | } | 1371 | } |
1371 | } else { | 1372 | } else { |
1372 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1373 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1373 | checkExternSyncEvent(eventLSyncSharp, inL); | 1374 | checkExternSyncEvent(eventLSyncSharp, inL); |
1374 | local->deleteIncidence( inL ); | 1375 | local->deleteIncidence( inL ); |
1375 | ++deletedEventL; | 1376 | ++deletedEventL; |
1376 | } else { | 1377 | } else { |
1377 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1378 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1378 | ++addedEventR; | 1379 | ++addedEventR; |
1379 | inL->setLastModified( modifiedCalendar ); | 1380 | inL->setLastModified( modifiedCalendar ); |
1380 | inR = inL->clone(); | 1381 | inR = inL->clone(); |
1381 | inR->setIDStr( ":" ); | 1382 | inR->setIDStr( ":" ); |
1382 | remote->addIncidence( inR ); | 1383 | remote->addIncidence( inR ); |
1383 | } | 1384 | } |
1384 | } | 1385 | } |
1385 | } | 1386 | } |
1386 | } else { | 1387 | } else { |
1387 | ++filteredOUT; | 1388 | ++filteredOUT; |
1388 | } | 1389 | } |
1389 | } | 1390 | } |
1390 | } | 1391 | } |
1391 | inL = el.next(); | 1392 | inL = el.next(); |
1392 | } | 1393 | } |
1393 | int delFut = 0; | 1394 | int delFut = 0; |
1394 | int remRem = 0; | 1395 | int remRem = 0; |
1395 | if ( mSyncManager->mWriteBackInFuture ) { | 1396 | if ( mSyncManager->mWriteBackInFuture ) { |
1396 | er = remote->rawIncidences(); | 1397 | er = remote->rawIncidences(); |
1397 | remRem = er.count(); | 1398 | remRem = er.count(); |
1398 | inR = er.first(); | 1399 | inR = er.first(); |
1399 | QDateTime dt; | 1400 | QDateTime dt; |
1400 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1401 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1401 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1402 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1402 | while ( inR ) { | 1403 | while ( inR ) { |
1403 | if ( inR->typeID() == todoID ) { | 1404 | if ( inR->typeID() == todoID ) { |
1404 | Todo * t = (Todo*)inR; | 1405 | Todo * t = (Todo*)inR; |
1405 | if ( t->hasDueDate() ) | 1406 | if ( t->hasDueDate() ) |
1406 | dt = t->dtDue(); | 1407 | dt = t->dtDue(); |
1407 | else | 1408 | else |
1408 | dt = cur.addSecs( 62 ); | 1409 | dt = cur.addSecs( 62 ); |
1409 | } | 1410 | } |
1410 | else if (inR->typeID() == eventID ) { | 1411 | else if (inR->typeID() == eventID ) { |
1411 | bool ok; | 1412 | bool ok; |
1412 | dt = inR->getNextOccurence( cur, &ok ); | 1413 | dt = inR->getNextOccurence( cur, &ok ); |
1413 | if ( !ok ) | 1414 | if ( !ok ) |
1414 | dt = cur.addSecs( -62 ); | 1415 | dt = cur.addSecs( -62 ); |
1415 | } | 1416 | } |
1416 | else | 1417 | else |
1417 | dt = inR->dtStart(); | 1418 | dt = inR->dtStart(); |
1418 | if ( dt < cur || dt > end ) { | 1419 | if ( dt < cur || dt > end ) { |
1419 | remote->deleteIncidence( inR ); | 1420 | remote->deleteIncidence( inR ); |
1420 | ++delFut; | 1421 | ++delFut; |
1421 | } | 1422 | } |
1422 | inR = er.next(); | 1423 | inR = er.next(); |
1423 | } | 1424 | } |
1424 | } | 1425 | } |
1425 | bar.hide(); | 1426 | bar.hide(); |
1426 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1427 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1427 | eventLSync->setReadOnly( false ); | 1428 | eventLSync->setReadOnly( false ); |
1428 | eventLSync->setDtStart( mLastCalendarSync ); | 1429 | eventLSync->setDtStart( mLastCalendarSync ); |
1429 | eventRSync->setDtStart( mLastCalendarSync ); | 1430 | eventRSync->setDtStart( mLastCalendarSync ); |
1430 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1431 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1431 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1432 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1432 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1433 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1433 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1434 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1434 | eventLSync->setReadOnly( true ); | 1435 | eventLSync->setReadOnly( true ); |
1435 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1436 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1436 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1437 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1437 | remote->addEvent( eventRSync ); | 1438 | remote->addEvent( eventRSync ); |
1438 | else | 1439 | else |
1439 | delete eventRSync; | 1440 | delete eventRSync; |
1440 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1441 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1441 | QString mes; | 1442 | QString mes; |
1442 | 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 ); | 1443 | 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 ); |
1443 | QString delmess; | 1444 | QString delmess; |
1444 | if ( delFut ) { | 1445 | if ( delFut ) { |
1445 | 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); | 1446 | 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); |
1446 | mes += delmess; | 1447 | mes += delmess; |
1447 | } | 1448 | } |
1448 | mes = i18n("Local calendar changed!\n") +mes; | 1449 | mes = i18n("Local calendar changed!\n") +mes; |
1449 | mCalendar->checkAlarmForIncidence( 0, true ); | 1450 | mCalendar->checkAlarmForIncidence( 0, true ); |
1450 | qDebug( mes ); | 1451 | qDebug( mes ); |
1451 | if ( mSyncManager->mShowSyncSummary ) { | 1452 | if ( mSyncManager->mShowSyncSummary ) { |
1452 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1453 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1453 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1454 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1454 | qDebug("KO: WB cancelled "); | 1455 | qDebug("KO: WB cancelled "); |
1455 | mSyncManager->mWriteBackFile = false; | 1456 | mSyncManager->mWriteBackFile = false; |
1456 | return syncOK; | 1457 | return syncOK; |
1457 | } | 1458 | } |
1458 | } | 1459 | } |
1459 | return syncOK; | 1460 | return syncOK; |
1460 | } | 1461 | } |
1461 | 1462 | ||
1462 | void CalendarView::setSyncDevice( QString s ) | 1463 | void CalendarView::setSyncDevice( QString s ) |
1463 | { | 1464 | { |
1464 | mCurrentSyncDevice= s; | 1465 | mCurrentSyncDevice= s; |
1465 | } | 1466 | } |
1466 | void CalendarView::setSyncName( QString s ) | 1467 | void CalendarView::setSyncName( QString s ) |
1467 | { | 1468 | { |
1468 | mCurrentSyncName= s; | 1469 | mCurrentSyncName= s; |
1469 | } | 1470 | } |
1470 | bool CalendarView::syncCalendar(QString filename, int mode) | 1471 | bool CalendarView::syncCalendar(QString filename, int mode) |
1471 | { | 1472 | { |
1472 | //qDebug("syncCalendar %s ", filename.latin1()); | 1473 | //qDebug("syncCalendar %s ", filename.latin1()); |
1473 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1474 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1474 | CalendarLocal* calendar = new CalendarLocal(); | 1475 | CalendarLocal* calendar = new CalendarLocal(); |
1475 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1476 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1476 | FileStorage* storage = new FileStorage( calendar ); | 1477 | FileStorage* storage = new FileStorage( calendar ); |
1477 | bool syncOK = false; | 1478 | bool syncOK = false; |
1478 | storage->setFileName( filename ); | 1479 | storage->setFileName( filename ); |
1479 | // qDebug("loading ... "); | 1480 | // qDebug("loading ... "); |
1480 | if ( storage->load() ) { | 1481 | if ( storage->load() ) { |
1481 | getEventViewerDialog()->setSyncMode( true ); | 1482 | getEventViewerDialog()->setSyncMode( true ); |
1482 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1483 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1483 | getEventViewerDialog()->setSyncMode( false ); | 1484 | getEventViewerDialog()->setSyncMode( false ); |
1484 | if ( syncOK ) { | 1485 | if ( syncOK ) { |
1485 | if ( mSyncManager->mWriteBackFile ) | 1486 | if ( mSyncManager->mWriteBackFile ) |
1486 | { | 1487 | { |
1487 | storage->setSaveFormat( new ICalFormat() ); | 1488 | storage->setSaveFormat( new ICalFormat() ); |
1488 | storage->save(); | 1489 | storage->save(); |
1489 | } | 1490 | } |
1490 | } | 1491 | } |
1491 | setModified( true ); | 1492 | setModified( true ); |
1492 | } | 1493 | } |
1493 | delete storage; | 1494 | delete storage; |
1494 | delete calendar; | 1495 | delete calendar; |
1495 | if ( syncOK ) | 1496 | if ( syncOK ) |
1496 | updateView(); | 1497 | updateView(); |
1497 | return syncOK; | 1498 | return syncOK; |
1498 | } | 1499 | } |
1499 | 1500 | ||
1500 | void CalendarView::syncExternal( int mode ) | 1501 | void CalendarView::syncExternal( int mode ) |
1501 | { | 1502 | { |
1502 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1503 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1503 | 1504 | ||
1504 | qApp->processEvents(); | 1505 | qApp->processEvents(); |
1505 | CalendarLocal* calendar = new CalendarLocal(); | 1506 | CalendarLocal* calendar = new CalendarLocal(); |
1506 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1507 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1507 | bool syncOK = false; | 1508 | bool syncOK = false; |
1508 | bool loadSuccess = false; | 1509 | bool loadSuccess = false; |
1509 | PhoneFormat* phoneFormat = 0; | 1510 | PhoneFormat* phoneFormat = 0; |
1510 | emit tempDisableBR(true); | 1511 | emit tempDisableBR(true); |
1511 | #ifndef DESKTOP_VERSION | 1512 | #ifndef DESKTOP_VERSION |
1512 | SharpFormat* sharpFormat = 0; | 1513 | SharpFormat* sharpFormat = 0; |
1513 | if ( mode == 0 ) { // sharp | 1514 | if ( mode == 0 ) { // sharp |
1514 | sharpFormat = new SharpFormat () ; | 1515 | sharpFormat = new SharpFormat () ; |
1515 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1516 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1516 | 1517 | ||
1517 | } else | 1518 | } else |
1518 | #endif | 1519 | #endif |
1519 | if ( mode == 1 ) { // phone | 1520 | if ( mode == 1 ) { // phone |
1520 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1521 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1521 | mSyncManager->mPhoneDevice, | 1522 | mSyncManager->mPhoneDevice, |
1522 | mSyncManager->mPhoneConnection, | 1523 | mSyncManager->mPhoneConnection, |
1523 | mSyncManager->mPhoneModel); | 1524 | mSyncManager->mPhoneModel); |
1524 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1525 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1525 | 1526 | ||
1526 | } else { | 1527 | } else { |
1527 | emit tempDisableBR(false); | 1528 | emit tempDisableBR(false); |
1528 | return; | 1529 | return; |
1529 | } | 1530 | } |
1530 | if ( loadSuccess ) { | 1531 | if ( loadSuccess ) { |
1531 | getEventViewerDialog()->setSyncMode( true ); | 1532 | getEventViewerDialog()->setSyncMode( true ); |
1532 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1533 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1533 | getEventViewerDialog()->setSyncMode( false ); | 1534 | getEventViewerDialog()->setSyncMode( false ); |
1534 | qApp->processEvents(); | 1535 | qApp->processEvents(); |
1535 | if ( syncOK ) { | 1536 | if ( syncOK ) { |
1536 | if ( mSyncManager->mWriteBackFile ) | 1537 | if ( mSyncManager->mWriteBackFile ) |
1537 | { | 1538 | { |
1538 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1539 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1539 | Incidence* inc = iL.first(); | 1540 | Incidence* inc = iL.first(); |
1540 | if ( phoneFormat ) { | 1541 | if ( phoneFormat ) { |
1541 | while ( inc ) { | 1542 | while ( inc ) { |
1542 | inc->removeID(mCurrentSyncDevice); | 1543 | inc->removeID(mCurrentSyncDevice); |
1543 | inc = iL.next(); | 1544 | inc = iL.next(); |
1544 | } | 1545 | } |
1545 | } | 1546 | } |
1546 | #ifndef DESKTOP_VERSION | 1547 | #ifndef DESKTOP_VERSION |
1547 | if ( sharpFormat ) | 1548 | if ( sharpFormat ) |
1548 | sharpFormat->save(calendar); | 1549 | sharpFormat->save(calendar); |
1549 | #endif | 1550 | #endif |
1550 | if ( phoneFormat ) | 1551 | if ( phoneFormat ) |
1551 | phoneFormat->save(calendar); | 1552 | phoneFormat->save(calendar); |
1552 | iL = calendar->rawIncidences(); | 1553 | iL = calendar->rawIncidences(); |
1553 | inc = iL.first(); | 1554 | inc = iL.first(); |
1554 | Incidence* loc; | 1555 | Incidence* loc; |
1555 | while ( inc ) { | 1556 | while ( inc ) { |
1556 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1557 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1557 | loc = mCalendar->incidence(inc->uid() ); | 1558 | loc = mCalendar->incidence(inc->uid() ); |
1558 | if ( loc ) { | 1559 | if ( loc ) { |
1559 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1560 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1560 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1561 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1561 | } | 1562 | } |
1562 | } | 1563 | } |
1563 | inc = iL.next(); | 1564 | inc = iL.next(); |
1564 | } | 1565 | } |
1565 | Incidence* lse = getLastSyncEvent(); | 1566 | Incidence* lse = getLastSyncEvent(); |
1566 | if ( lse ) { | 1567 | if ( lse ) { |
1567 | lse->setReadOnly( false ); | 1568 | lse->setReadOnly( false ); |
1568 | lse->setDescription( "" ); | 1569 | lse->setDescription( "" ); |
1569 | lse->setReadOnly( true ); | 1570 | lse->setReadOnly( true ); |
1570 | } | 1571 | } |
1571 | } | 1572 | } |
1572 | } else { | 1573 | } else { |
1573 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1574 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1574 | } | 1575 | } |
1575 | setModified( true ); | 1576 | setModified( true ); |
1576 | } else { | 1577 | } else { |
1577 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1578 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1578 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1579 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1579 | question, i18n("Ok")) ; | 1580 | question, i18n("Ok")) ; |
1580 | 1581 | ||
1581 | } | 1582 | } |
1582 | delete calendar; | 1583 | delete calendar; |
1583 | updateView(); | 1584 | updateView(); |
1584 | emit tempDisableBR(false); | 1585 | emit tempDisableBR(false); |
1585 | return ;//syncOK; | 1586 | return ;//syncOK; |
1586 | 1587 | ||
1587 | } | 1588 | } |
1588 | 1589 | ||
1589 | bool CalendarView::importBday() | 1590 | bool CalendarView::importBday() |
1590 | { | 1591 | { |
1591 | #ifndef KORG_NOKABC | 1592 | #ifndef KORG_NOKABC |
1592 | 1593 | ||
1593 | #ifdef DESKTOP_VERSION | 1594 | #ifdef DESKTOP_VERSION |
1594 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1595 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1595 | KABC::AddressBook::Iterator it; | 1596 | KABC::AddressBook::Iterator it; |
1596 | int count = 0; | 1597 | int count = 0; |
1597 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1598 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1598 | ++count; | 1599 | ++count; |
1599 | } | 1600 | } |
1600 | QProgressBar bar(count,0 ); | 1601 | QProgressBar bar(count,0 ); |
1601 | int w = 300; | 1602 | int w = 300; |
1602 | if ( QApplication::desktop()->width() < 320 ) | 1603 | if ( QApplication::desktop()->width() < 320 ) |
1603 | w = 220; | 1604 | w = 220; |
1604 | int h = bar.sizeHint().height() ; | 1605 | int h = bar.sizeHint().height() ; |
1605 | int dw = QApplication::desktop()->width(); | 1606 | int dw = QApplication::desktop()->width(); |
1606 | int dh = QApplication::desktop()->height(); | 1607 | int dh = QApplication::desktop()->height(); |
1607 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1608 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1608 | bar.show(); | 1609 | bar.show(); |
1609 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1610 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1610 | qApp->processEvents(); | 1611 | qApp->processEvents(); |
1611 | count = 0; | 1612 | count = 0; |
1612 | int addCount = 0; | 1613 | int addCount = 0; |
1613 | KCal::Attendee* a = 0; | 1614 | KCal::Attendee* a = 0; |
1614 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1615 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1615 | if ( ! bar.isVisible() ) | 1616 | if ( ! bar.isVisible() ) |
1616 | return false; | 1617 | return false; |
1617 | bar.setProgress( count++ ); | 1618 | bar.setProgress( count++ ); |
1618 | qApp->processEvents(); | 1619 | qApp->processEvents(); |
1619 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1620 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1620 | if ( (*it).birthday().date().isValid() ){ | 1621 | if ( (*it).birthday().date().isValid() ){ |
1621 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1622 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1622 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1623 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1623 | ++addCount; | 1624 | ++addCount; |
1624 | } | 1625 | } |
1625 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1626 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1626 | if ( anni.isValid() ){ | 1627 | if ( anni.isValid() ){ |
1627 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1628 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1628 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1629 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1629 | ++addCount; | 1630 | ++addCount; |
1630 | } | 1631 | } |
1631 | } | 1632 | } |
1632 | updateView(); | 1633 | updateView(); |
1633 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1634 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1634 | #else //DESKTOP_VERSION | 1635 | #else //DESKTOP_VERSION |
1635 | 1636 | ||
1636 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1637 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1637 | // the result should now arrive through method insertBirthdays | 1638 | // the result should now arrive through method insertBirthdays |
1638 | 1639 | ||
1639 | #endif //DESKTOP_VERSION | 1640 | #endif //DESKTOP_VERSION |
1640 | 1641 | ||
1641 | #endif //KORG_NOKABC | 1642 | #endif //KORG_NOKABC |
1642 | 1643 | ||
1643 | 1644 | ||
1644 | return true; | 1645 | return true; |
1645 | } | 1646 | } |
1646 | 1647 | ||
1647 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1648 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1648 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1649 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1649 | const QStringList& anniversaryList, const QStringList& realNameList, | 1650 | const QStringList& anniversaryList, const QStringList& realNameList, |
1650 | const QStringList& emailList, const QStringList& assembledNameList, | 1651 | const QStringList& emailList, const QStringList& assembledNameList, |
1651 | const QStringList& uidList) | 1652 | const QStringList& uidList) |
1652 | { | 1653 | { |
1653 | //qDebug("KO::CalendarView::insertBirthdays"); | 1654 | //qDebug("KO::CalendarView::insertBirthdays"); |
1654 | if (uid == this->name()) | 1655 | if (uid == this->name()) |
1655 | { | 1656 | { |
1656 | int count = birthdayList.count(); | 1657 | int count = birthdayList.count(); |
1657 | int addCount = 0; | 1658 | int addCount = 0; |
1658 | KCal::Attendee* a = 0; | 1659 | KCal::Attendee* a = 0; |
1659 | 1660 | ||
1660 | //qDebug("CalView 1 %i", count); | 1661 | //qDebug("CalView 1 %i", count); |
1661 | 1662 | ||
1662 | QProgressBar bar(count,0 ); | 1663 | QProgressBar bar(count,0 ); |
1663 | int w = 300; | 1664 | int w = 300; |
1664 | if ( QApplication::desktop()->width() < 320 ) | 1665 | if ( QApplication::desktop()->width() < 320 ) |
1665 | w = 220; | 1666 | w = 220; |
1666 | int h = bar.sizeHint().height() ; | 1667 | int h = bar.sizeHint().height() ; |
1667 | int dw = QApplication::desktop()->width(); | 1668 | int dw = QApplication::desktop()->width(); |
1668 | int dh = QApplication::desktop()->height(); | 1669 | int dh = QApplication::desktop()->height(); |
1669 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1670 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1670 | bar.show(); | 1671 | bar.show(); |
1671 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1672 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1672 | qApp->processEvents(); | 1673 | qApp->processEvents(); |
1673 | 1674 | ||
1674 | QDate birthday; | 1675 | QDate birthday; |
1675 | QDate anniversary; | 1676 | QDate anniversary; |
1676 | QString realName; | 1677 | QString realName; |
1677 | QString email; | 1678 | QString email; |
1678 | QString assembledName; | 1679 | QString assembledName; |
1679 | QString uid; | 1680 | QString uid; |
1680 | bool ok = true; | 1681 | bool ok = true; |
1681 | for ( int i = 0; i < count; i++) | 1682 | for ( int i = 0; i < count; i++) |
1682 | { | 1683 | { |
1683 | if ( ! bar.isVisible() ) | 1684 | if ( ! bar.isVisible() ) |
1684 | return; | 1685 | return; |
1685 | bar.setProgress( i ); | 1686 | bar.setProgress( i ); |
1686 | qApp->processEvents(); | 1687 | qApp->processEvents(); |
1687 | 1688 | ||
1688 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1689 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1689 | if (!ok) { | 1690 | if (!ok) { |
1690 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1691 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1691 | } | 1692 | } |
1692 | 1693 | ||
1693 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1694 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1694 | if (!ok) { | 1695 | if (!ok) { |
1695 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1696 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1696 | } | 1697 | } |
1697 | realName = realNameList[i]; | 1698 | realName = realNameList[i]; |
1698 | email = emailList[i]; | 1699 | email = emailList[i]; |
1699 | assembledName = assembledNameList[i]; | 1700 | assembledName = assembledNameList[i]; |
1700 | uid = uidList[i]; | 1701 | uid = uidList[i]; |
1701 | //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() ); | 1702 | //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() ); |
1702 | 1703 | ||
1703 | if ( birthday.isValid() ){ | 1704 | if ( birthday.isValid() ){ |
1704 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1705 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1705 | KCal::Attendee::ReqParticipant,uid) ; | 1706 | KCal::Attendee::ReqParticipant,uid) ; |
1706 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1707 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1707 | ++addCount; | 1708 | ++addCount; |
1708 | } | 1709 | } |
1709 | 1710 | ||
1710 | if ( anniversary.isValid() ){ | 1711 | if ( anniversary.isValid() ){ |
1711 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1712 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1712 | KCal::Attendee::ReqParticipant,uid) ; | 1713 | KCal::Attendee::ReqParticipant,uid) ; |
1713 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1714 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1714 | ++addCount; | 1715 | ++addCount; |
1715 | } | 1716 | } |
1716 | } | 1717 | } |
1717 | 1718 | ||
1718 | updateView(); | 1719 | updateView(); |
1719 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1720 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1720 | 1721 | ||
1721 | } | 1722 | } |
1722 | 1723 | ||
1723 | } | 1724 | } |
1724 | 1725 | ||
1725 | 1726 | ||
1726 | 1727 | ||
1727 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1728 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1728 | { | 1729 | { |
1729 | //qDebug("addAnni "); | 1730 | //qDebug("addAnni "); |
1730 | Event * ev = new Event(); | 1731 | Event * ev = new Event(); |
1731 | ev->setOrganizer(KOPrefs::instance()->email()); | 1732 | ev->setOrganizer(KOPrefs::instance()->email()); |
1732 | if ( a ) { | 1733 | if ( a ) { |
1733 | ev->addAttendee( a ); | 1734 | ev->addAttendee( a ); |
1734 | } | 1735 | } |
1735 | QString kind; | 1736 | QString kind; |
1736 | if ( birthday ) { | 1737 | if ( birthday ) { |
1737 | kind = i18n( "Birthday" ); | 1738 | kind = i18n( "Birthday" ); |
1738 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1739 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1739 | } | 1740 | } |
1740 | else { | 1741 | else { |
1741 | kind = i18n( "Anniversary" ); | 1742 | kind = i18n( "Anniversary" ); |
1742 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1743 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1743 | } | 1744 | } |
1744 | ev->setCategories( kind ); | 1745 | ev->setCategories( kind ); |
1745 | ev->setDtStart( QDateTime(date) ); | 1746 | ev->setDtStart( QDateTime(date) ); |
1746 | ev->setDtEnd( QDateTime(date) ); | 1747 | ev->setDtEnd( QDateTime(date) ); |
1747 | ev->setFloats( true ); | 1748 | ev->setFloats( true ); |
1748 | Recurrence * rec = ev->recurrence(); | 1749 | Recurrence * rec = ev->recurrence(); |
1749 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1750 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1750 | rec->addYearlyNum( date.month() ); | 1751 | rec->addYearlyNum( date.month() ); |
1751 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1752 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1752 | delete ev; | 1753 | delete ev; |
1753 | return false; | 1754 | return false; |
1754 | } | 1755 | } |
1755 | return true; | 1756 | return true; |
1756 | 1757 | ||
1757 | } | 1758 | } |
1758 | bool CalendarView::importQtopia( const QString &categories, | 1759 | bool CalendarView::importQtopia( const QString &categories, |
1759 | const QString &datebook, | 1760 | const QString &datebook, |
1760 | const QString &todolist ) | 1761 | const QString &todolist ) |
1761 | { | 1762 | { |
1762 | 1763 | ||
1763 | QtopiaFormat qtopiaFormat; | 1764 | QtopiaFormat qtopiaFormat; |
1764 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1765 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1765 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1766 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1766 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1767 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1767 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1768 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1768 | 1769 | ||
1769 | updateView(); | 1770 | updateView(); |
1770 | return true; | 1771 | return true; |
1771 | 1772 | ||
1772 | #if 0 | 1773 | #if 0 |
1773 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1774 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1774 | mCurrentSyncDevice = "qtopia-XML"; | 1775 | mCurrentSyncDevice = "qtopia-XML"; |
1775 | if ( mSyncManager->mAskForPreferences ) | 1776 | if ( mSyncManager->mAskForPreferences ) |
1776 | edit_sync_options(); | 1777 | edit_sync_options(); |
1777 | qApp->processEvents(); | 1778 | qApp->processEvents(); |
1778 | CalendarLocal* calendar = new CalendarLocal(); | 1779 | CalendarLocal* calendar = new CalendarLocal(); |
1779 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1780 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1780 | bool syncOK = false; | 1781 | bool syncOK = false; |
1781 | QtopiaFormat qtopiaFormat; | 1782 | QtopiaFormat qtopiaFormat; |
1782 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1783 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1783 | bool loadOk = true; | 1784 | bool loadOk = true; |
1784 | if ( !categories.isEmpty() ) | 1785 | if ( !categories.isEmpty() ) |
1785 | loadOk = qtopiaFormat.load( calendar, categories ); | 1786 | loadOk = qtopiaFormat.load( calendar, categories ); |
1786 | if ( loadOk && !datebook.isEmpty() ) | 1787 | if ( loadOk && !datebook.isEmpty() ) |
1787 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1788 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1788 | if ( loadOk && !todolist.isEmpty() ) | 1789 | if ( loadOk && !todolist.isEmpty() ) |
1789 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1790 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1790 | 1791 | ||
1791 | if ( loadOk ) { | 1792 | if ( loadOk ) { |
1792 | getEventViewerDialog()->setSyncMode( true ); | 1793 | getEventViewerDialog()->setSyncMode( true ); |
1793 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1794 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1794 | getEventViewerDialog()->setSyncMode( false ); | 1795 | getEventViewerDialog()->setSyncMode( false ); |
1795 | qApp->processEvents(); | 1796 | qApp->processEvents(); |
1796 | if ( syncOK ) { | 1797 | if ( syncOK ) { |
1797 | if ( mSyncManager->mWriteBackFile ) | 1798 | if ( mSyncManager->mWriteBackFile ) |
1798 | { | 1799 | { |
1799 | // write back XML file | 1800 | // write back XML file |
1800 | 1801 | ||
1801 | } | 1802 | } |
1802 | setModified( true ); | 1803 | setModified( true ); |
1803 | } | 1804 | } |
1804 | } else { | 1805 | } else { |
1805 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1806 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1806 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1807 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1807 | question, i18n("Ok")) ; | 1808 | question, i18n("Ok")) ; |
1808 | } | 1809 | } |
1809 | delete calendar; | 1810 | delete calendar; |
1810 | updateView(); | 1811 | updateView(); |
1811 | return syncOK; | 1812 | return syncOK; |
1812 | 1813 | ||
1813 | 1814 | ||
1814 | #endif | 1815 | #endif |
1815 | 1816 | ||
1816 | } | 1817 | } |
1817 | 1818 | ||
1818 | void CalendarView::setSyncEventsReadOnly() | 1819 | void CalendarView::setSyncEventsReadOnly() |
1819 | { | 1820 | { |
1820 | Event * ev; | 1821 | Event * ev; |
1821 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1822 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1822 | ev = eL.first(); | 1823 | ev = eL.first(); |
1823 | while ( ev ) { | 1824 | while ( ev ) { |
1824 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1825 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1825 | ev->setReadOnly( true ); | 1826 | ev->setReadOnly( true ); |
1826 | ev = eL.next(); | 1827 | ev = eL.next(); |
1827 | } | 1828 | } |
1828 | } | 1829 | } |
1829 | bool CalendarView::openCalendar(QString filename, bool merge) | 1830 | bool CalendarView::openCalendar(QString filename, bool merge) |
1830 | { | 1831 | { |
1831 | 1832 | ||
1832 | if (filename.isEmpty()) { | 1833 | if (filename.isEmpty()) { |
1833 | return false; | 1834 | return false; |
1834 | } | 1835 | } |
1835 | 1836 | ||
1836 | if (!QFile::exists(filename)) { | 1837 | if (!QFile::exists(filename)) { |
1837 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1838 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1838 | return false; | 1839 | return false; |
1839 | } | 1840 | } |
1840 | 1841 | ||
1841 | globalFlagBlockAgenda = 1; | 1842 | globalFlagBlockAgenda = 1; |
1842 | clearAllViews(); | 1843 | clearAllViews(); |
1843 | if (!merge) { | 1844 | if (!merge) { |
1844 | mViewManager->setDocumentId( filename ); | 1845 | mViewManager->setDocumentId( filename ); |
1845 | mCalendar->close(); | 1846 | mCalendar->close(); |
1846 | } | 1847 | } |
1847 | mStorage->setFileName( filename ); | 1848 | mStorage->setFileName( filename ); |
1848 | 1849 | ||
1849 | if ( mStorage->load() ) { | 1850 | if ( mStorage->load() ) { |
1850 | if ( merge ) ;//setModified( true ); | 1851 | if ( merge ) ;//setModified( true ); |
1851 | else { | 1852 | else { |
1852 | //setModified( true ); | 1853 | //setModified( true ); |
1853 | mViewManager->setDocumentId( filename ); | 1854 | mViewManager->setDocumentId( filename ); |
1854 | mDialogManager->setDocumentId( filename ); | 1855 | mDialogManager->setDocumentId( filename ); |
1855 | mTodoList->setDocumentId( filename ); | 1856 | mTodoList->setDocumentId( filename ); |
1856 | } | 1857 | } |
1857 | globalFlagBlockAgenda = 2; | 1858 | globalFlagBlockAgenda = 2; |
1858 | // if ( getLastSyncEvent() ) | 1859 | // if ( getLastSyncEvent() ) |
1859 | // getLastSyncEvent()->setReadOnly( true ); | 1860 | // getLastSyncEvent()->setReadOnly( true ); |
1860 | mCalendar->reInitAlarmSettings(); | 1861 | mCalendar->reInitAlarmSettings(); |
1861 | setSyncEventsReadOnly(); | 1862 | setSyncEventsReadOnly(); |
1862 | updateUnmanagedViews(); | 1863 | updateUnmanagedViews(); |
1863 | updateView(); | 1864 | updateView(); |
1864 | if ( filename != MainWindow::defaultFileName() ) { | 1865 | if ( filename != MainWindow::defaultFileName() ) { |
1865 | saveCalendar( MainWindow::defaultFileName() ); | 1866 | saveCalendar( MainWindow::defaultFileName() ); |
1866 | } else { | 1867 | } else { |
1867 | QFileInfo finf ( MainWindow::defaultFileName()); | 1868 | QFileInfo finf ( MainWindow::defaultFileName()); |
1868 | if ( finf.exists() ) { | 1869 | if ( finf.exists() ) { |
1869 | setLoadedFileVersion( finf.lastModified () ); | 1870 | setLoadedFileVersion( finf.lastModified () ); |
1870 | } | 1871 | } |
1871 | } | 1872 | } |
1872 | return true; | 1873 | return true; |
1873 | } else { | 1874 | } else { |
1874 | // while failing to load, the calendar object could | 1875 | // while failing to load, the calendar object could |
1875 | // have become partially populated. Clear it out. | 1876 | // have become partially populated. Clear it out. |
1876 | if ( !merge ) { | 1877 | if ( !merge ) { |
1877 | mCalendar->close(); | 1878 | mCalendar->close(); |
1878 | mViewManager->setDocumentId( filename ); | 1879 | mViewManager->setDocumentId( filename ); |
1879 | mDialogManager->setDocumentId( filename ); | 1880 | mDialogManager->setDocumentId( filename ); |
1880 | mTodoList->setDocumentId( filename ); | 1881 | mTodoList->setDocumentId( filename ); |
1881 | } | 1882 | } |
1882 | 1883 | ||
1883 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1884 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1884 | 1885 | ||
1885 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1886 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1886 | globalFlagBlockAgenda = 2; | 1887 | globalFlagBlockAgenda = 2; |
1887 | mCalendar->reInitAlarmSettings(); | 1888 | mCalendar->reInitAlarmSettings(); |
1888 | setSyncEventsReadOnly(); | 1889 | setSyncEventsReadOnly(); |
1889 | updateUnmanagedViews(); | 1890 | updateUnmanagedViews(); |
1890 | updateView(); | 1891 | updateView(); |
1891 | } | 1892 | } |
1892 | return false; | 1893 | return false; |
1893 | } | 1894 | } |
1894 | void CalendarView::showOpenError() | 1895 | void CalendarView::showOpenError() |
1895 | { | 1896 | { |
1896 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1897 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1897 | } | 1898 | } |
1898 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1899 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1899 | { | 1900 | { |
1900 | loadedFileVersion = dt; | 1901 | loadedFileVersion = dt; |
1901 | } | 1902 | } |
1902 | bool CalendarView::checkFileChanged(QString fn) | 1903 | bool CalendarView::checkFileChanged(QString fn) |
1903 | { | 1904 | { |
1904 | QFileInfo finf ( fn ); | 1905 | QFileInfo finf ( fn ); |
1905 | if ( !finf.exists() ) | 1906 | if ( !finf.exists() ) |
1906 | return true; | 1907 | return true; |
1907 | QDateTime dt = finf.lastModified (); | 1908 | QDateTime dt = finf.lastModified (); |
1908 | if ( dt <= loadedFileVersion ) | 1909 | if ( dt <= loadedFileVersion ) |
1909 | return false; | 1910 | return false; |
1910 | return true; | 1911 | return true; |
1911 | 1912 | ||
1912 | } | 1913 | } |
1913 | void CalendarView::watchSavedFile() | 1914 | void CalendarView::watchSavedFile() |
1914 | { | 1915 | { |
1915 | QFileInfo finf ( MainWindow::defaultFileName()); | 1916 | QFileInfo finf ( MainWindow::defaultFileName()); |
1916 | if ( !finf.exists() ) | 1917 | if ( !finf.exists() ) |
1917 | return; | 1918 | return; |
1918 | QDateTime dt = finf.lastModified (); | 1919 | QDateTime dt = finf.lastModified (); |
1919 | if ( dt < loadedFileVersion ) { | 1920 | if ( dt < loadedFileVersion ) { |
1920 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1921 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1921 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1922 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1922 | return; | 1923 | return; |
1923 | } | 1924 | } |
1924 | loadedFileVersion = dt; | 1925 | loadedFileVersion = dt; |
1925 | } | 1926 | } |
1926 | 1927 | ||
1927 | bool CalendarView::checkFileVersion(QString fn) | 1928 | bool CalendarView::checkFileVersion(QString fn) |
1928 | { | 1929 | { |
1929 | QFileInfo finf ( fn ); | 1930 | QFileInfo finf ( fn ); |
1930 | if ( !finf.exists() ) | 1931 | if ( !finf.exists() ) |
1931 | return true; | 1932 | return true; |
1932 | QDateTime dt = finf.lastModified (); | 1933 | QDateTime dt = finf.lastModified (); |
1933 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1934 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1934 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1935 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1935 | if ( dt <= loadedFileVersion ) | 1936 | if ( dt <= loadedFileVersion ) |
1936 | return true; | 1937 | return true; |
1937 | 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)) , | 1938 | 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)) , |
1938 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1939 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1939 | i18n("Sync+save")); | 1940 | i18n("Sync+save")); |
1940 | 1941 | ||
1941 | if ( km == KMessageBox::Cancel ) | 1942 | if ( km == KMessageBox::Cancel ) |
1942 | return false; | 1943 | return false; |
1943 | if ( km == KMessageBox::Yes ) | 1944 | if ( km == KMessageBox::Yes ) |
1944 | return true; | 1945 | return true; |
1945 | 1946 | ||
1946 | setSyncDevice("deleteaftersync" ); | 1947 | setSyncDevice("deleteaftersync" ); |
1947 | mSyncManager->mAskForPreferences = true; | 1948 | mSyncManager->mAskForPreferences = true; |
1948 | mSyncManager->mSyncAlgoPrefs = 3; | 1949 | mSyncManager->mSyncAlgoPrefs = 3; |
1949 | mSyncManager->mWriteBackFile = false; | 1950 | mSyncManager->mWriteBackFile = false; |
1950 | mSyncManager->mWriteBackExistingOnly = false; | 1951 | mSyncManager->mWriteBackExistingOnly = false; |
1951 | mSyncManager->mShowSyncSummary = false; | 1952 | mSyncManager->mShowSyncSummary = false; |
1952 | syncCalendar( fn, 3 ); | 1953 | syncCalendar( fn, 3 ); |
1953 | Event * e = getLastSyncEvent(); | 1954 | Event * e = getLastSyncEvent(); |
1954 | if ( e ) | 1955 | if ( e ) |
1955 | deleteEvent ( e ); | 1956 | deleteEvent ( e ); |
1956 | updateView(); | 1957 | updateView(); |
1957 | return true; | 1958 | return true; |
1958 | } | 1959 | } |
1959 | 1960 | ||
1960 | bool CalendarView::saveCalendar( QString filename ) | 1961 | bool CalendarView::saveCalendar( QString filename ) |
1961 | { | 1962 | { |
1962 | 1963 | ||
1963 | // Store back all unsaved data into calendar object | 1964 | // Store back all unsaved data into calendar object |
1964 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1965 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1965 | if ( mViewManager->currentView() ) | 1966 | if ( mViewManager->currentView() ) |
1966 | mViewManager->currentView()->flushView(); | 1967 | mViewManager->currentView()->flushView(); |
1967 | 1968 | ||
1968 | 1969 | ||
1969 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1970 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1970 | mStorage->setSaveFormat( new ICalFormat() ); | 1971 | mStorage->setSaveFormat( new ICalFormat() ); |
1971 | mStorage->setFileName( filename ); | 1972 | mStorage->setFileName( filename ); |
1972 | bool success; | 1973 | bool success; |
1973 | success = mStorage->save(); | 1974 | success = mStorage->save(); |
1974 | if ( !success ) { | 1975 | if ( !success ) { |
1975 | return false; | 1976 | return false; |
1976 | } | 1977 | } |
1977 | if ( filename == MainWindow::defaultFileName() ) { | 1978 | if ( filename == MainWindow::defaultFileName() ) { |
1978 | setLoadedFileVersion( lfv ); | 1979 | setLoadedFileVersion( lfv ); |
1979 | watchSavedFile(); | 1980 | watchSavedFile(); |
1980 | } | 1981 | } |
1981 | return true; | 1982 | return true; |
1982 | } | 1983 | } |
1983 | 1984 | ||
1984 | void CalendarView::closeCalendar() | 1985 | void CalendarView::closeCalendar() |
1985 | { | 1986 | { |
1986 | 1987 | ||
1987 | // child windows no longer valid | 1988 | // child windows no longer valid |
1988 | clearAllViews(); | 1989 | clearAllViews(); |
1989 | emit closingDown(); | 1990 | emit closingDown(); |
1990 | 1991 | ||
1991 | mCalendar->close(); | 1992 | mCalendar->close(); |
1992 | setModified(false); | 1993 | setModified(false); |
1993 | updateView(); | 1994 | updateView(); |
1994 | } | 1995 | } |
1995 | 1996 | ||
1996 | void CalendarView::archiveCalendar() | 1997 | void CalendarView::archiveCalendar() |
1997 | { | 1998 | { |
1998 | mDialogManager->showArchiveDialog(); | 1999 | mDialogManager->showArchiveDialog(); |
1999 | } | 2000 | } |
2000 | 2001 | ||
2001 | 2002 | ||
2002 | void CalendarView::readSettings() | 2003 | void CalendarView::readSettings() |
2003 | { | 2004 | { |
2004 | 2005 | ||
2005 | 2006 | ||
2006 | // mViewManager->showAgendaView(); | 2007 | // mViewManager->showAgendaView(); |
2007 | QString str; | 2008 | QString str; |
2008 | //qDebug("CalendarView::readSettings() "); | 2009 | //qDebug("CalendarView::readSettings() "); |
2009 | // read settings from the KConfig, supplying reasonable | 2010 | // read settings from the KConfig, supplying reasonable |
@@ -2376,1988 +2377,1989 @@ void CalendarView::eventDeleted() | |||
2376 | } | 2377 | } |
2377 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2378 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2378 | { | 2379 | { |
2379 | changeIncidenceDisplay((Incidence *)which, action); | 2380 | changeIncidenceDisplay((Incidence *)which, action); |
2380 | mDateNavigator->updateView(); //LR | 2381 | mDateNavigator->updateView(); //LR |
2381 | //mDialogManager->updateSearchDialog(); | 2382 | //mDialogManager->updateSearchDialog(); |
2382 | 2383 | ||
2383 | if (which) { | 2384 | if (which) { |
2384 | mViewManager->updateWNview(); | 2385 | mViewManager->updateWNview(); |
2385 | //mTodoList->updateView(); | 2386 | //mTodoList->updateView(); |
2386 | } | 2387 | } |
2387 | 2388 | ||
2388 | } | 2389 | } |
2389 | 2390 | ||
2390 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2391 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2391 | { | 2392 | { |
2392 | updateUnmanagedViews(); | 2393 | updateUnmanagedViews(); |
2393 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2394 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2394 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2395 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2395 | mCalendar->checkAlarmForIncidence( 0, true ); | 2396 | mCalendar->checkAlarmForIncidence( 0, true ); |
2396 | if ( mEventViewerDialog ) | 2397 | if ( mEventViewerDialog ) |
2397 | mEventViewerDialog->hide(); | 2398 | mEventViewerDialog->hide(); |
2398 | } | 2399 | } |
2399 | else | 2400 | else |
2400 | mCalendar->checkAlarmForIncidence( which , false ); | 2401 | mCalendar->checkAlarmForIncidence( which , false ); |
2401 | } | 2402 | } |
2402 | 2403 | ||
2403 | // most of the changeEventDisplays() right now just call the view's | 2404 | // most of the changeEventDisplays() right now just call the view's |
2404 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2405 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2405 | void CalendarView::changeEventDisplay(Event *which, int action) | 2406 | void CalendarView::changeEventDisplay(Event *which, int action) |
2406 | { | 2407 | { |
2407 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2408 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2408 | changeIncidenceDisplay((Incidence *)which, action); | 2409 | changeIncidenceDisplay((Incidence *)which, action); |
2409 | mDateNavigator->updateView(); | 2410 | mDateNavigator->updateView(); |
2410 | //mDialogManager->updateSearchDialog(); | 2411 | //mDialogManager->updateSearchDialog(); |
2411 | 2412 | ||
2412 | if (which) { | 2413 | if (which) { |
2413 | // If there is an event view visible update the display | 2414 | // If there is an event view visible update the display |
2414 | mViewManager->currentView()->changeEventDisplay(which,action); | 2415 | mViewManager->currentView()->changeEventDisplay(which,action); |
2415 | // TODO: check, if update needed | 2416 | // TODO: check, if update needed |
2416 | // if (which->getTodoStatus()) { | 2417 | // if (which->getTodoStatus()) { |
2417 | mTodoList->updateView(); | 2418 | mTodoList->updateView(); |
2418 | // } | 2419 | // } |
2419 | } else { | 2420 | } else { |
2420 | mViewManager->currentView()->updateView(); | 2421 | mViewManager->currentView()->updateView(); |
2421 | } | 2422 | } |
2422 | } | 2423 | } |
2423 | 2424 | ||
2424 | 2425 | ||
2425 | void CalendarView::updateTodoViews() | 2426 | void CalendarView::updateTodoViews() |
2426 | { | 2427 | { |
2427 | mTodoList->updateView(); | 2428 | mTodoList->updateView(); |
2428 | mViewManager->currentView()->updateView(); | 2429 | mViewManager->currentView()->updateView(); |
2429 | 2430 | ||
2430 | } | 2431 | } |
2431 | 2432 | ||
2432 | 2433 | ||
2433 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2434 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2434 | { | 2435 | { |
2435 | mTodoList->updateView(); | 2436 | mTodoList->updateView(); |
2436 | mViewManager->updateView(start, end); | 2437 | mViewManager->updateView(start, end); |
2437 | //mDateNavigator->updateView(); | 2438 | //mDateNavigator->updateView(); |
2438 | } | 2439 | } |
2439 | 2440 | ||
2440 | void CalendarView::clearAllViews() | 2441 | void CalendarView::clearAllViews() |
2441 | { | 2442 | { |
2442 | mTodoList->clearList(); | 2443 | mTodoList->clearList(); |
2443 | mViewManager->clearAllViews(); | 2444 | mViewManager->clearAllViews(); |
2444 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2445 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2445 | if ( sd ) { | 2446 | if ( sd ) { |
2446 | KOListView* kol = sd->listview(); | 2447 | KOListView* kol = sd->listview(); |
2447 | if ( kol ) | 2448 | if ( kol ) |
2448 | kol->clearList(); | 2449 | kol->clearList(); |
2449 | } | 2450 | } |
2450 | } | 2451 | } |
2451 | void CalendarView::updateView() | 2452 | void CalendarView::updateView() |
2452 | { | 2453 | { |
2453 | DateList tmpList = mNavigator->selectedDates(); | 2454 | DateList tmpList = mNavigator->selectedDates(); |
2454 | 2455 | ||
2455 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2456 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2456 | mTodoList->updateView(); | 2457 | mTodoList->updateView(); |
2457 | // We assume that the navigator only selects consecutive days. | 2458 | // We assume that the navigator only selects consecutive days. |
2458 | updateView( tmpList.first(), tmpList.last() ); | 2459 | updateView( tmpList.first(), tmpList.last() ); |
2459 | } | 2460 | } |
2460 | 2461 | ||
2461 | void CalendarView::updateUnmanagedViews() | 2462 | void CalendarView::updateUnmanagedViews() |
2462 | { | 2463 | { |
2463 | mDateNavigator->updateDayMatrix(); | 2464 | mDateNavigator->updateDayMatrix(); |
2464 | } | 2465 | } |
2465 | 2466 | ||
2466 | int CalendarView::msgItemDelete(const QString name) | 2467 | int CalendarView::msgItemDelete(const QString name) |
2467 | { | 2468 | { |
2468 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2469 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2469 | i18n("This item will be\npermanently deleted."), | 2470 | i18n("This item will be\npermanently deleted."), |
2470 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2471 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2471 | } | 2472 | } |
2472 | 2473 | ||
2473 | 2474 | ||
2474 | void CalendarView::edit_cut() | 2475 | void CalendarView::edit_cut() |
2475 | { | 2476 | { |
2476 | Event *anEvent=0; | 2477 | Event *anEvent=0; |
2477 | 2478 | ||
2478 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2479 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2479 | 2480 | ||
2480 | if (mViewManager->currentView()->isEventView()) { | 2481 | if (mViewManager->currentView()->isEventView()) { |
2481 | if ( incidence && incidence->typeID() == eventID ) { | 2482 | if ( incidence && incidence->typeID() == eventID ) { |
2482 | anEvent = static_cast<Event *>(incidence); | 2483 | anEvent = static_cast<Event *>(incidence); |
2483 | } | 2484 | } |
2484 | } | 2485 | } |
2485 | 2486 | ||
2486 | if (!anEvent) { | 2487 | if (!anEvent) { |
2487 | KNotifyClient::beep(); | 2488 | KNotifyClient::beep(); |
2488 | return; | 2489 | return; |
2489 | } | 2490 | } |
2490 | DndFactory factory( mCalendar ); | 2491 | DndFactory factory( mCalendar ); |
2491 | factory.cutIncidence(anEvent); | 2492 | factory.cutIncidence(anEvent); |
2492 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2493 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2493 | } | 2494 | } |
2494 | 2495 | ||
2495 | void CalendarView::edit_copy() | 2496 | void CalendarView::edit_copy() |
2496 | { | 2497 | { |
2497 | Event *anEvent=0; | 2498 | Event *anEvent=0; |
2498 | 2499 | ||
2499 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2500 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2500 | 2501 | ||
2501 | if (mViewManager->currentView()->isEventView()) { | 2502 | if (mViewManager->currentView()->isEventView()) { |
2502 | if ( incidence && incidence->typeID() == eventID ) { | 2503 | if ( incidence && incidence->typeID() == eventID ) { |
2503 | anEvent = static_cast<Event *>(incidence); | 2504 | anEvent = static_cast<Event *>(incidence); |
2504 | } | 2505 | } |
2505 | } | 2506 | } |
2506 | 2507 | ||
2507 | if (!anEvent) { | 2508 | if (!anEvent) { |
2508 | KNotifyClient::beep(); | 2509 | KNotifyClient::beep(); |
2509 | return; | 2510 | return; |
2510 | } | 2511 | } |
2511 | DndFactory factory( mCalendar ); | 2512 | DndFactory factory( mCalendar ); |
2512 | factory.copyIncidence(anEvent); | 2513 | factory.copyIncidence(anEvent); |
2513 | } | 2514 | } |
2514 | 2515 | ||
2515 | void CalendarView::edit_paste() | 2516 | void CalendarView::edit_paste() |
2516 | { | 2517 | { |
2517 | QDate date = mNavigator->selectedDates().first(); | 2518 | QDate date = mNavigator->selectedDates().first(); |
2518 | 2519 | ||
2519 | DndFactory factory( mCalendar ); | 2520 | DndFactory factory( mCalendar ); |
2520 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2521 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2521 | 2522 | ||
2522 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2523 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2523 | } | 2524 | } |
2524 | void CalendarView::edit_global_options() | 2525 | void CalendarView::edit_global_options() |
2525 | { | 2526 | { |
2526 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2527 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2527 | emit save(); | 2528 | emit save(); |
2528 | emit saveStopTimer(); | 2529 | emit saveStopTimer(); |
2529 | mDialogManager->showGlobalOptionsDialog(); | 2530 | mDialogManager->showGlobalOptionsDialog(); |
2530 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2531 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2531 | emit saveStopTimer(); | 2532 | emit saveStopTimer(); |
2532 | 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!"), | 2533 | 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!"), |
2533 | i18n("Timezone settings"),i18n("Reload"))) { | 2534 | i18n("Timezone settings"),i18n("Reload"))) { |
2534 | qDebug("KO: TZ reload cancelled "); | 2535 | qDebug("KO: TZ reload cancelled "); |
2535 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2536 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2536 | return; | 2537 | return; |
2537 | } | 2538 | } |
2538 | qDebug("KO: Timezone change "); | 2539 | qDebug("KO: Timezone change "); |
2539 | openCalendar( MainWindow::defaultFileName() ); | 2540 | openCalendar( MainWindow::defaultFileName() ); |
2540 | setModified(true); | 2541 | setModified(true); |
2541 | } | 2542 | } |
2542 | else | 2543 | else |
2543 | qDebug("KO: No tz change "); | 2544 | qDebug("KO: No tz change "); |
2544 | } | 2545 | } |
2545 | void CalendarView::edit_options() | 2546 | void CalendarView::edit_options() |
2546 | { | 2547 | { |
2547 | mDialogManager->showOptionsDialog(); | 2548 | mDialogManager->showOptionsDialog(); |
2548 | } | 2549 | } |
2549 | 2550 | ||
2550 | 2551 | ||
2551 | void CalendarView::slotSelectPickerDate( QDate d) | 2552 | void CalendarView::slotSelectPickerDate( QDate d) |
2552 | { | 2553 | { |
2553 | mDateFrame->hide(); | 2554 | mDateFrame->hide(); |
2554 | if ( mDatePickerMode == 1 ) { | 2555 | if ( mDatePickerMode == 1 ) { |
2555 | mNavigator->slotDaySelect( d ); | 2556 | mNavigator->slotDaySelect( d ); |
2556 | } else if ( mDatePickerMode == 2 ) { | 2557 | } else if ( mDatePickerMode == 2 ) { |
2557 | if ( mMoveIncidence->typeID() == todoID ) { | 2558 | if ( mMoveIncidence->typeID() == todoID ) { |
2558 | Todo * to = (Todo *) mMoveIncidence; | 2559 | Todo * to = (Todo *) mMoveIncidence; |
2559 | QTime tim; | 2560 | QTime tim; |
2560 | int len = 0; | 2561 | int len = 0; |
2561 | if ( to->hasStartDate() && to->hasDueDate() ) | 2562 | if ( to->hasStartDate() && to->hasDueDate() ) |
2562 | len = to->dtStart().secsTo( to->dtDue()); | 2563 | len = to->dtStart().secsTo( to->dtDue()); |
2563 | if ( to->hasDueDate() ) | 2564 | if ( to->hasDueDate() ) |
2564 | tim = to->dtDue().time(); | 2565 | tim = to->dtDue().time(); |
2565 | else { | 2566 | else { |
2566 | tim = QTime ( 0,0,0 ); | 2567 | tim = QTime ( 0,0,0 ); |
2567 | to->setFloats( true ); | 2568 | to->setFloats( true ); |
2568 | to->setHasDueDate( true ); | 2569 | to->setHasDueDate( true ); |
2569 | } | 2570 | } |
2570 | QDateTime dt ( d,tim ); | 2571 | QDateTime dt ( d,tim ); |
2571 | to->setDtDue( dt ); | 2572 | to->setDtDue( dt ); |
2572 | 2573 | ||
2573 | if ( to->hasStartDate() ) { | 2574 | if ( to->hasStartDate() ) { |
2574 | if ( len>0 ) | 2575 | if ( len>0 ) |
2575 | to->setDtStart(to->dtDue().addSecs( -len )); | 2576 | to->setDtStart(to->dtDue().addSecs( -len )); |
2576 | else | 2577 | else |
2577 | if (to->dtStart() > to->dtDue() ) | 2578 | if (to->dtStart() > to->dtDue() ) |
2578 | to->setDtStart(to->dtDue().addDays( -3 )); | 2579 | to->setDtStart(to->dtDue().addDays( -3 )); |
2579 | } | 2580 | } |
2580 | 2581 | ||
2581 | todoChanged( to ); | 2582 | todoChanged( to ); |
2582 | } else { | 2583 | } else { |
2583 | if ( mMoveIncidence->doesRecur() ) { | 2584 | if ( mMoveIncidence->doesRecur() ) { |
2584 | #if 0 | 2585 | #if 0 |
2585 | // PENDING implement this | 2586 | // PENDING implement this |
2586 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2587 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2587 | mCalendar()->addIncidence( newInc ); | 2588 | mCalendar()->addIncidence( newInc ); |
2588 | if ( mMoveIncidence->typeID() == todoID ) | 2589 | if ( mMoveIncidence->typeID() == todoID ) |
2589 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2590 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2590 | else | 2591 | else |
2591 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2592 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2592 | mMoveIncidence = newInc; | 2593 | mMoveIncidence = newInc; |
2593 | 2594 | ||
2594 | #endif | 2595 | #endif |
2595 | } | 2596 | } |
2596 | QTime tim = mMoveIncidence->dtStart().time(); | 2597 | QTime tim = mMoveIncidence->dtStart().time(); |
2597 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2598 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2598 | QDateTime dt ( d,tim ); | 2599 | QDateTime dt ( d,tim ); |
2599 | mMoveIncidence->setDtStart( dt ); | 2600 | mMoveIncidence->setDtStart( dt ); |
2600 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2601 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2601 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2602 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2602 | } | 2603 | } |
2603 | 2604 | ||
2604 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2605 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2605 | } | 2606 | } |
2606 | } | 2607 | } |
2607 | 2608 | ||
2608 | void CalendarView::removeCategories() | 2609 | void CalendarView::removeCategories() |
2609 | { | 2610 | { |
2610 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2611 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2611 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2612 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2612 | QStringList catIncList; | 2613 | QStringList catIncList; |
2613 | QStringList newCatList; | 2614 | QStringList newCatList; |
2614 | Incidence* inc = incList.first(); | 2615 | Incidence* inc = incList.first(); |
2615 | int i; | 2616 | int i; |
2616 | int count = 0; | 2617 | int count = 0; |
2617 | while ( inc ) { | 2618 | while ( inc ) { |
2618 | newCatList.clear(); | 2619 | newCatList.clear(); |
2619 | catIncList = inc->categories() ; | 2620 | catIncList = inc->categories() ; |
2620 | for( i = 0; i< catIncList.count(); ++i ) { | 2621 | for( i = 0; i< catIncList.count(); ++i ) { |
2621 | if ( catList.contains (catIncList[i])) | 2622 | if ( catList.contains (catIncList[i])) |
2622 | newCatList.append( catIncList[i] ); | 2623 | newCatList.append( catIncList[i] ); |
2623 | } | 2624 | } |
2624 | newCatList.sort(); | 2625 | newCatList.sort(); |
2625 | inc->setCategories( newCatList.join(",") ); | 2626 | inc->setCategories( newCatList.join(",") ); |
2626 | inc = incList.next(); | 2627 | inc = incList.next(); |
2627 | } | 2628 | } |
2628 | } | 2629 | } |
2629 | 2630 | ||
2630 | int CalendarView::addCategories() | 2631 | int CalendarView::addCategories() |
2631 | { | 2632 | { |
2632 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2633 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2633 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2634 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2634 | QStringList catIncList; | 2635 | QStringList catIncList; |
2635 | Incidence* inc = incList.first(); | 2636 | Incidence* inc = incList.first(); |
2636 | int i; | 2637 | int i; |
2637 | int count = 0; | 2638 | int count = 0; |
2638 | while ( inc ) { | 2639 | while ( inc ) { |
2639 | catIncList = inc->categories() ; | 2640 | catIncList = inc->categories() ; |
2640 | for( i = 0; i< catIncList.count(); ++i ) { | 2641 | for( i = 0; i< catIncList.count(); ++i ) { |
2641 | if ( !catList.contains (catIncList[i])) { | 2642 | if ( !catList.contains (catIncList[i])) { |
2642 | catList.append( catIncList[i] ); | 2643 | catList.append( catIncList[i] ); |
2643 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2644 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2644 | ++count; | 2645 | ++count; |
2645 | } | 2646 | } |
2646 | } | 2647 | } |
2647 | inc = incList.next(); | 2648 | inc = incList.next(); |
2648 | } | 2649 | } |
2649 | catList.sort(); | 2650 | catList.sort(); |
2650 | KOPrefs::instance()->mCustomCategories = catList; | 2651 | KOPrefs::instance()->mCustomCategories = catList; |
2651 | return count; | 2652 | return count; |
2652 | } | 2653 | } |
2653 | 2654 | ||
2654 | void CalendarView::manageCategories() | 2655 | void CalendarView::manageCategories() |
2655 | { | 2656 | { |
2656 | KOCatPrefs* cp = new KOCatPrefs(); | 2657 | KOCatPrefs* cp = new KOCatPrefs(); |
2657 | cp->show(); | 2658 | cp->show(); |
2658 | int w =cp->sizeHint().width() ; | 2659 | int w =cp->sizeHint().width() ; |
2659 | int h = cp->sizeHint().height() ; | 2660 | int h = cp->sizeHint().height() ; |
2660 | int dw = QApplication::desktop()->width(); | 2661 | int dw = QApplication::desktop()->width(); |
2661 | int dh = QApplication::desktop()->height(); | 2662 | int dh = QApplication::desktop()->height(); |
2662 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2663 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2663 | if ( !cp->exec() ) { | 2664 | if ( !cp->exec() ) { |
2664 | delete cp; | 2665 | delete cp; |
2665 | return; | 2666 | return; |
2666 | } | 2667 | } |
2667 | int count = 0; | 2668 | int count = 0; |
2668 | if ( cp->addCat() ) { | 2669 | if ( cp->addCat() ) { |
2669 | count = addCategories(); | 2670 | count = addCategories(); |
2670 | if ( count ) { | 2671 | if ( count ) { |
2671 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2672 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2672 | writeSettings(); | 2673 | writeSettings(); |
2673 | } else | 2674 | } else |
2674 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2675 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2675 | } else { | 2676 | } else { |
2676 | removeCategories(); | 2677 | removeCategories(); |
2677 | updateView(); | 2678 | updateView(); |
2678 | } | 2679 | } |
2679 | delete cp; | 2680 | delete cp; |
2680 | } | 2681 | } |
2681 | 2682 | ||
2682 | void CalendarView::beamIncidence(Incidence * Inc) | 2683 | void CalendarView::beamIncidence(Incidence * Inc) |
2683 | { | 2684 | { |
2684 | QPtrList<Incidence> delSel ; | 2685 | QPtrList<Incidence> delSel ; |
2685 | delSel.append(Inc); | 2686 | delSel.append(Inc); |
2686 | beamIncidenceList( delSel ); | 2687 | beamIncidenceList( delSel ); |
2687 | } | 2688 | } |
2688 | void CalendarView::beamCalendar() | 2689 | void CalendarView::beamCalendar() |
2689 | { | 2690 | { |
2690 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2691 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2691 | //qDebug("beamCalendar() "); | 2692 | //qDebug("beamCalendar() "); |
2692 | beamIncidenceList( delSel ); | 2693 | beamIncidenceList( delSel ); |
2693 | } | 2694 | } |
2694 | void CalendarView::beamFilteredCalendar() | 2695 | void CalendarView::beamFilteredCalendar() |
2695 | { | 2696 | { |
2696 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2697 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2697 | //qDebug("beamFilteredCalendar() "); | 2698 | //qDebug("beamFilteredCalendar() "); |
2698 | beamIncidenceList( delSel ); | 2699 | beamIncidenceList( delSel ); |
2699 | } | 2700 | } |
2700 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2701 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2701 | { | 2702 | { |
2702 | if ( beamDialog->exec () == QDialog::Rejected ) | 2703 | if ( beamDialog->exec () == QDialog::Rejected ) |
2703 | return; | 2704 | return; |
2704 | #ifdef DESKTOP_VERSION | 2705 | #ifdef DESKTOP_VERSION |
2705 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2706 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2706 | #else | 2707 | #else |
2707 | QString fn = "/tmp/kopibeamfile"; | 2708 | QString fn = "/tmp/kopibeamfile"; |
2708 | #endif | 2709 | #endif |
2709 | QString mes; | 2710 | QString mes; |
2710 | bool createbup = true; | 2711 | bool createbup = true; |
2711 | if ( createbup ) { | 2712 | if ( createbup ) { |
2712 | QString description = "\n"; | 2713 | QString description = "\n"; |
2713 | CalendarLocal* cal = new CalendarLocal(); | 2714 | CalendarLocal* cal = new CalendarLocal(); |
2714 | if ( beamDialog->beamLocal() ) | 2715 | if ( beamDialog->beamLocal() ) |
2715 | cal->setLocalTime(); | 2716 | cal->setLocalTime(); |
2716 | else | 2717 | else |
2717 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2718 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2718 | Incidence *incidence = delSel.first(); | 2719 | Incidence *incidence = delSel.first(); |
2719 | bool addText = false; | 2720 | bool addText = false; |
2720 | if ( delSel.count() < 10 ) | 2721 | if ( delSel.count() < 10 ) |
2721 | addText = true; | 2722 | addText = true; |
2722 | else { | 2723 | else { |
2723 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2724 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2724 | } | 2725 | } |
2725 | while ( incidence ) { | 2726 | while ( incidence ) { |
2726 | Incidence *in = incidence->clone(); | 2727 | Incidence *in = incidence->clone(); |
2727 | if ( ! in->summary().isEmpty() ) { | 2728 | if ( ! in->summary().isEmpty() ) { |
2728 | in->setDescription(""); | 2729 | in->setDescription(""); |
2729 | } else { | 2730 | } else { |
2730 | in->setSummary( in->description().left(20)); | 2731 | in->setSummary( in->description().left(20)); |
2731 | in->setDescription(""); | 2732 | in->setDescription(""); |
2732 | } | 2733 | } |
2733 | if ( addText ) | 2734 | if ( addText ) |
2734 | description += in->summary() + "\n"; | 2735 | description += in->summary() + "\n"; |
2735 | cal->addIncidence( in ); | 2736 | cal->addIncidence( in ); |
2736 | incidence = delSel.next(); | 2737 | incidence = delSel.next(); |
2737 | } | 2738 | } |
2738 | if ( beamDialog->beamVcal() ) { | 2739 | if ( beamDialog->beamVcal() ) { |
2739 | fn += ".vcs"; | 2740 | fn += ".vcs"; |
2740 | FileStorage storage( cal, fn, new VCalFormat ); | 2741 | FileStorage storage( cal, fn, new VCalFormat ); |
2741 | storage.save(); | 2742 | storage.save(); |
2742 | } else { | 2743 | } else { |
2743 | fn += ".ics"; | 2744 | fn += ".ics"; |
2744 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2745 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2745 | storage.save(); | 2746 | storage.save(); |
2746 | } | 2747 | } |
2747 | delete cal; | 2748 | delete cal; |
2748 | mes = i18n("KO/Pi: Ready for beaming"); | 2749 | mes = i18n("KO/Pi: Ready for beaming"); |
2749 | topLevelWidget()->setCaption(mes); | 2750 | topLevelWidget()->setCaption(mes); |
2750 | KApplication::convert2latin1( fn ); | 2751 | KApplication::convert2latin1( fn ); |
2751 | #ifndef DESKTOP_VERSION | 2752 | #ifndef DESKTOP_VERSION |
2752 | Ir *ir = new Ir( this ); | 2753 | Ir *ir = new Ir( this ); |
2753 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2754 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2754 | ir->send( fn, description, "text/x-vCalendar" ); | 2755 | ir->send( fn, description, "text/x-vCalendar" ); |
2755 | #endif | 2756 | #endif |
2756 | } | 2757 | } |
2757 | } | 2758 | } |
2758 | void CalendarView::beamDone( Ir *ir ) | 2759 | void CalendarView::beamDone( Ir *ir ) |
2759 | { | 2760 | { |
2760 | #ifndef DESKTOP_VERSION | 2761 | #ifndef DESKTOP_VERSION |
2761 | delete ir; | 2762 | delete ir; |
2762 | #endif | 2763 | #endif |
2763 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2764 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2764 | topLevelWidget()->raise(); | 2765 | topLevelWidget()->raise(); |
2765 | } | 2766 | } |
2766 | 2767 | ||
2767 | void CalendarView::moveIncidence(Incidence * inc ) | 2768 | void CalendarView::moveIncidence(Incidence * inc ) |
2768 | { | 2769 | { |
2769 | if ( !inc ) return; | 2770 | if ( !inc ) return; |
2770 | showDatePickerPopup(); | 2771 | showDatePickerPopup(); |
2771 | mDatePickerMode = 2; | 2772 | mDatePickerMode = 2; |
2772 | mMoveIncidence = inc ; | 2773 | mMoveIncidence = inc ; |
2773 | QDate da; | 2774 | QDate da; |
2774 | if ( mMoveIncidence->typeID() == todoID ) { | 2775 | if ( mMoveIncidence->typeID() == todoID ) { |
2775 | Todo * to = (Todo *) mMoveIncidence; | 2776 | Todo * to = (Todo *) mMoveIncidence; |
2776 | if ( to->hasDueDate() ) | 2777 | if ( to->hasDueDate() ) |
2777 | da = to->dtDue().date(); | 2778 | da = to->dtDue().date(); |
2778 | else | 2779 | else |
2779 | da = QDate::currentDate(); | 2780 | da = QDate::currentDate(); |
2780 | } else { | 2781 | } else { |
2781 | da = mMoveIncidence->dtStart().date(); | 2782 | da = mMoveIncidence->dtStart().date(); |
2782 | } | 2783 | } |
2783 | //PENDING set date for recurring incidence to date of recurrence | 2784 | //PENDING set date for recurring incidence to date of recurrence |
2784 | //mMoveIncidenceOldDate; | 2785 | //mMoveIncidenceOldDate; |
2785 | mDatePicker->setDate( da ); | 2786 | mDatePicker->setDate( da ); |
2786 | } | 2787 | } |
2787 | void CalendarView::showDatePickerPopup() | 2788 | void CalendarView::showDatePickerPopup() |
2788 | { | 2789 | { |
2789 | if ( mDateFrame->isVisible() ) | 2790 | if ( mDateFrame->isVisible() ) |
2790 | mDateFrame->hide(); | 2791 | mDateFrame->hide(); |
2791 | else { | 2792 | else { |
2792 | int offX = 0, offY = 0; | 2793 | int offX = 0, offY = 0; |
2793 | #ifdef DESKTOP_VERSION | 2794 | #ifdef DESKTOP_VERSION |
2794 | int w =mDatePicker->sizeHint().width() ; | 2795 | int w =mDatePicker->sizeHint().width() ; |
2795 | int h = mDatePicker->sizeHint().height() ; | 2796 | int h = mDatePicker->sizeHint().height() ; |
2796 | int dw = topLevelWidget()->width(); | 2797 | int dw = topLevelWidget()->width(); |
2797 | int dh = topLevelWidget()->height(); | 2798 | int dh = topLevelWidget()->height(); |
2798 | offX = topLevelWidget()->x(); | 2799 | offX = topLevelWidget()->x(); |
2799 | offY = topLevelWidget()->y(); | 2800 | offY = topLevelWidget()->y(); |
2800 | #else | 2801 | #else |
2801 | int w =mDatePicker->sizeHint().width() ; | 2802 | int w =mDatePicker->sizeHint().width() ; |
2802 | int h = mDatePicker->sizeHint().height() ; | 2803 | int h = mDatePicker->sizeHint().height() ; |
2803 | int dw = QApplication::desktop()->width(); | 2804 | int dw = QApplication::desktop()->width(); |
2804 | int dh = QApplication::desktop()->height(); | 2805 | int dh = QApplication::desktop()->height(); |
2805 | #endif | 2806 | #endif |
2806 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2807 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2807 | mDateFrame->show(); | 2808 | mDateFrame->show(); |
2808 | } | 2809 | } |
2809 | } | 2810 | } |
2810 | void CalendarView::showDatePicker( ) | 2811 | void CalendarView::showDatePicker( ) |
2811 | { | 2812 | { |
2812 | showDatePickerPopup(); | 2813 | showDatePickerPopup(); |
2813 | mDatePickerMode = 1; | 2814 | mDatePickerMode = 1; |
2814 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2815 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2815 | } | 2816 | } |
2816 | 2817 | ||
2817 | void CalendarView::showEventEditor() | 2818 | void CalendarView::showEventEditor() |
2818 | { | 2819 | { |
2819 | #ifdef DESKTOP_VERSION | 2820 | #ifdef DESKTOP_VERSION |
2820 | int x,y,w,h; | 2821 | int x,y,w,h; |
2821 | x = mEventEditor->geometry().x(); | 2822 | x = mEventEditor->geometry().x(); |
2822 | y = mEventEditor->geometry().y(); | 2823 | y = mEventEditor->geometry().y(); |
2823 | w = mEventEditor->width(); | 2824 | w = mEventEditor->width(); |
2824 | h = mEventEditor->height(); | 2825 | h = mEventEditor->height(); |
2825 | mEventEditor->show(); | 2826 | mEventEditor->show(); |
2826 | mEventEditor->setGeometry(x,y,w,h); | 2827 | mEventEditor->setGeometry(x,y,w,h); |
2827 | #else | 2828 | #else |
2828 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2829 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2829 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2830 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2830 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2831 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2831 | qApp->processEvents(); | 2832 | qApp->processEvents(); |
2832 | delete mEventEditor; | 2833 | delete mEventEditor; |
2833 | mEventEditor = mDialogManager->getEventEditor(); | 2834 | mEventEditor = mDialogManager->getEventEditor(); |
2834 | topLevelWidget()->setCaption( i18n("") ); | 2835 | topLevelWidget()->setCaption( i18n("") ); |
2835 | } | 2836 | } |
2836 | mEventEditor->showMaximized(); | 2837 | mEventEditor->showMaximized(); |
2837 | #endif | 2838 | #endif |
2838 | } | 2839 | } |
2839 | void CalendarView::showTodoEditor() | 2840 | void CalendarView::showTodoEditor() |
2840 | { | 2841 | { |
2841 | #ifdef DESKTOP_VERSION | 2842 | #ifdef DESKTOP_VERSION |
2842 | int x,y,w,h; | 2843 | int x,y,w,h; |
2843 | x = mTodoEditor->geometry().x(); | 2844 | x = mTodoEditor->geometry().x(); |
2844 | y = mTodoEditor->geometry().y(); | 2845 | y = mTodoEditor->geometry().y(); |
2845 | w = mTodoEditor->width(); | 2846 | w = mTodoEditor->width(); |
2846 | h = mTodoEditor->height(); | 2847 | h = mTodoEditor->height(); |
2847 | mTodoEditor->show(); | 2848 | mTodoEditor->show(); |
2848 | mTodoEditor->setGeometry(x,y,w,h); | 2849 | mTodoEditor->setGeometry(x,y,w,h); |
2849 | #else | 2850 | #else |
2850 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2851 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2851 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2852 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2852 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2853 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2853 | qApp->processEvents(); | 2854 | qApp->processEvents(); |
2854 | delete mTodoEditor; | 2855 | delete mTodoEditor; |
2855 | mTodoEditor = mDialogManager->getTodoEditor(); | 2856 | mTodoEditor = mDialogManager->getTodoEditor(); |
2856 | topLevelWidget()->setCaption( i18n("") ); | 2857 | topLevelWidget()->setCaption( i18n("") ); |
2857 | } | 2858 | } |
2858 | mTodoEditor->showMaximized(); | 2859 | mTodoEditor->showMaximized(); |
2859 | #endif | 2860 | #endif |
2860 | } | 2861 | } |
2861 | 2862 | ||
2862 | void CalendarView::cloneIncidence() | 2863 | void CalendarView::cloneIncidence() |
2863 | { | 2864 | { |
2864 | Incidence *incidence = currentSelection(); | 2865 | Incidence *incidence = currentSelection(); |
2865 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2866 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2866 | if ( incidence ) { | 2867 | if ( incidence ) { |
2867 | cloneIncidence(incidence); | 2868 | cloneIncidence(incidence); |
2868 | } | 2869 | } |
2869 | } | 2870 | } |
2870 | void CalendarView::moveIncidence() | 2871 | void CalendarView::moveIncidence() |
2871 | { | 2872 | { |
2872 | Incidence *incidence = currentSelection(); | 2873 | Incidence *incidence = currentSelection(); |
2873 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2874 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2874 | if ( incidence ) { | 2875 | if ( incidence ) { |
2875 | moveIncidence(incidence); | 2876 | moveIncidence(incidence); |
2876 | } | 2877 | } |
2877 | } | 2878 | } |
2878 | void CalendarView::beamIncidence() | 2879 | void CalendarView::beamIncidence() |
2879 | { | 2880 | { |
2880 | Incidence *incidence = currentSelection(); | 2881 | Incidence *incidence = currentSelection(); |
2881 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2882 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2882 | if ( incidence ) { | 2883 | if ( incidence ) { |
2883 | beamIncidence(incidence); | 2884 | beamIncidence(incidence); |
2884 | } | 2885 | } |
2885 | } | 2886 | } |
2886 | void CalendarView::toggleCancelIncidence() | 2887 | void CalendarView::toggleCancelIncidence() |
2887 | { | 2888 | { |
2888 | Incidence *incidence = currentSelection(); | 2889 | Incidence *incidence = currentSelection(); |
2889 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2890 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2890 | if ( incidence ) { | 2891 | if ( incidence ) { |
2891 | cancelIncidence(incidence); | 2892 | cancelIncidence(incidence); |
2892 | } | 2893 | } |
2893 | } | 2894 | } |
2894 | 2895 | ||
2895 | 2896 | ||
2896 | void CalendarView::cancelIncidence(Incidence * inc ) | 2897 | void CalendarView::cancelIncidence(Incidence * inc ) |
2897 | { | 2898 | { |
2898 | inc->setCancelled( ! inc->cancelled() ); | 2899 | inc->setCancelled( ! inc->cancelled() ); |
2899 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2900 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2900 | updateView(); | 2901 | updateView(); |
2901 | } | 2902 | } |
2902 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2903 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2903 | { | 2904 | { |
2904 | Incidence * newInc = orgInc->clone(); | 2905 | Incidence * newInc = orgInc->clone(); |
2905 | newInc->recreate(); | 2906 | newInc->recreate(); |
2906 | 2907 | ||
2907 | if ( newInc->typeID() == todoID ) { | 2908 | if ( newInc->typeID() == todoID ) { |
2908 | Todo* t = (Todo*) newInc; | 2909 | Todo* t = (Todo*) newInc; |
2909 | bool cloneSub = false; | 2910 | bool cloneSub = false; |
2910 | if ( orgInc->relations().count() ) { | 2911 | if ( orgInc->relations().count() ) { |
2911 | int result = KMessageBox::warningYesNoCancel(this, | 2912 | int result = KMessageBox::warningYesNoCancel(this, |
2912 | 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 ) ), | 2913 | 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 ) ), |
2913 | i18n("Todo has subtodos"), | 2914 | i18n("Todo has subtodos"), |
2914 | i18n("Yes"), | 2915 | i18n("Yes"), |
2915 | i18n("No")); | 2916 | i18n("No")); |
2916 | 2917 | ||
2917 | if ( result == KMessageBox::Cancel ) { | 2918 | if ( result == KMessageBox::Cancel ) { |
2918 | delete t; | 2919 | delete t; |
2919 | return; | 2920 | return; |
2920 | } | 2921 | } |
2921 | if (result == KMessageBox::Yes) cloneSub = true; | 2922 | if (result == KMessageBox::Yes) cloneSub = true; |
2922 | } | 2923 | } |
2923 | showTodoEditor(); | 2924 | showTodoEditor(); |
2924 | mTodoEditor->editTodo( t ); | 2925 | mTodoEditor->editTodo( t ); |
2925 | if ( mTodoEditor->exec() ) { | 2926 | if ( mTodoEditor->exec() ) { |
2926 | if ( cloneSub ) { | 2927 | if ( cloneSub ) { |
2927 | orgInc->cloneRelations( t ); | 2928 | orgInc->cloneRelations( t ); |
2928 | mCalendar->addIncidenceBranch( t ); | 2929 | mCalendar->addIncidenceBranch( t ); |
2929 | updateView(); | 2930 | updateView(); |
2930 | 2931 | ||
2931 | } else { | 2932 | } else { |
2932 | mCalendar->addTodo( t ); | 2933 | mCalendar->addTodo( t ); |
2933 | updateView(); | 2934 | updateView(); |
2934 | } | 2935 | } |
2935 | } else { | 2936 | } else { |
2936 | delete t; | 2937 | delete t; |
2937 | } | 2938 | } |
2938 | } | 2939 | } |
2939 | else { | 2940 | else { |
2940 | Event* e = (Event*) newInc; | 2941 | Event* e = (Event*) newInc; |
2941 | showEventEditor(); | 2942 | showEventEditor(); |
2942 | mEventEditor->editEvent( e ); | 2943 | mEventEditor->editEvent( e ); |
2943 | if ( mEventEditor->exec() ) { | 2944 | if ( mEventEditor->exec() ) { |
2944 | mCalendar->addEvent( e ); | 2945 | mCalendar->addEvent( e ); |
2945 | updateView(); | 2946 | updateView(); |
2946 | } else { | 2947 | } else { |
2947 | delete e; | 2948 | delete e; |
2948 | } | 2949 | } |
2949 | } | 2950 | } |
2950 | setActiveWindow(); | 2951 | setActiveWindow(); |
2951 | } | 2952 | } |
2952 | 2953 | ||
2953 | void CalendarView::newEvent() | 2954 | void CalendarView::newEvent() |
2954 | { | 2955 | { |
2955 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2956 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2956 | KOAgendaView *aView = mViewManager->agendaView(); | 2957 | KOAgendaView *aView = mViewManager->agendaView(); |
2957 | if (aView) { | 2958 | if (aView) { |
2958 | if (aView->selectionStart().isValid()) { | 2959 | if (aView->selectionStart().isValid()) { |
2959 | if (aView->selectedIsAllDay()) { | 2960 | if (aView->selectedIsAllDay()) { |
2960 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2961 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2961 | } else { | 2962 | } else { |
2962 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2963 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2963 | } | 2964 | } |
2964 | return; | 2965 | return; |
2965 | } | 2966 | } |
2966 | } | 2967 | } |
2967 | 2968 | ||
2968 | QDate date = mNavigator->selectedDates().first(); | 2969 | QDate date = mNavigator->selectedDates().first(); |
2969 | QDateTime current = QDateTime::currentDateTime(); | 2970 | QDateTime current = QDateTime::currentDateTime(); |
2970 | if ( date <= current.date() ) { | 2971 | if ( date <= current.date() ) { |
2971 | int hour = current.time().hour() +1; | 2972 | int hour = current.time().hour() +1; |
2972 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2973 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2973 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2974 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2974 | } else | 2975 | } else |
2975 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2976 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2976 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2977 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2977 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2978 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2978 | } | 2979 | } |
2979 | 2980 | ||
2980 | void CalendarView::newEvent(QDateTime fh) | 2981 | void CalendarView::newEvent(QDateTime fh) |
2981 | { | 2982 | { |
2982 | newEvent(fh, | 2983 | newEvent(fh, |
2983 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2984 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2984 | } | 2985 | } |
2985 | 2986 | ||
2986 | void CalendarView::newEvent(QDate dt) | 2987 | void CalendarView::newEvent(QDate dt) |
2987 | { | 2988 | { |
2988 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2989 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2989 | QDateTime(dt, QTime(0,0,0)), true); | 2990 | QDateTime(dt, QTime(0,0,0)), true); |
2990 | } | 2991 | } |
2991 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2992 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2992 | { | 2993 | { |
2993 | newEvent(fromHint, toHint, false); | 2994 | newEvent(fromHint, toHint, false); |
2994 | } | 2995 | } |
2995 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2996 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2996 | { | 2997 | { |
2997 | 2998 | ||
2998 | showEventEditor(); | 2999 | showEventEditor(); |
2999 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3000 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3000 | if ( mFilterView->filtersEnabled() ) { | 3001 | if ( mFilterView->filtersEnabled() ) { |
3001 | CalFilter *filter = mFilterView->selectedFilter(); | 3002 | CalFilter *filter = mFilterView->selectedFilter(); |
3002 | if (filter && filter->showCategories()) { | 3003 | if (filter && filter->showCategories()) { |
3003 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3004 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3004 | } | 3005 | } |
3005 | if ( filter ) | 3006 | if ( filter ) |
3006 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3007 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3007 | } | 3008 | } |
3008 | mEventEditor->exec(); | 3009 | mEventEditor->exec(); |
3009 | setActiveWindow(); | 3010 | setActiveWindow(); |
3010 | } | 3011 | } |
3011 | void CalendarView::todoAdded(Todo * t) | 3012 | void CalendarView::todoAdded(Todo * t) |
3012 | { | 3013 | { |
3013 | 3014 | ||
3014 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3015 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3015 | updateTodoViews(); | 3016 | updateTodoViews(); |
3016 | } | 3017 | } |
3017 | void CalendarView::todoChanged(Todo * t) | 3018 | void CalendarView::todoChanged(Todo * t) |
3018 | { | 3019 | { |
3019 | emit todoModified( t, 4 ); | 3020 | emit todoModified( t, 4 ); |
3020 | // updateTodoViews(); | 3021 | // updateTodoViews(); |
3021 | } | 3022 | } |
3022 | void CalendarView::todoToBeDeleted(Todo *) | 3023 | void CalendarView::todoToBeDeleted(Todo *) |
3023 | { | 3024 | { |
3024 | //qDebug("todoToBeDeleted(Todo *) "); | 3025 | //qDebug("todoToBeDeleted(Todo *) "); |
3025 | updateTodoViews(); | 3026 | updateTodoViews(); |
3026 | } | 3027 | } |
3027 | void CalendarView::todoDeleted() | 3028 | void CalendarView::todoDeleted() |
3028 | { | 3029 | { |
3029 | //qDebug(" todoDeleted()"); | 3030 | //qDebug(" todoDeleted()"); |
3030 | updateTodoViews(); | 3031 | updateTodoViews(); |
3031 | } | 3032 | } |
3032 | 3033 | ||
3033 | 3034 | ||
3034 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3035 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3035 | { | 3036 | { |
3036 | showTodoEditor(); | 3037 | showTodoEditor(); |
3037 | mTodoEditor->newTodo(dt,0,allday); | 3038 | mTodoEditor->newTodo(dt,0,allday); |
3038 | if ( mFilterView->filtersEnabled() ) { | 3039 | if ( mFilterView->filtersEnabled() ) { |
3039 | CalFilter *filter = mFilterView->selectedFilter(); | 3040 | CalFilter *filter = mFilterView->selectedFilter(); |
3040 | if (filter && filter->showCategories()) { | 3041 | if (filter && filter->showCategories()) { |
3041 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3042 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3042 | } | 3043 | } |
3043 | if ( filter ) | 3044 | if ( filter ) |
3044 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3045 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3045 | } | 3046 | } |
3046 | mTodoEditor->exec(); | 3047 | mTodoEditor->exec(); |
3047 | setActiveWindow(); | 3048 | setActiveWindow(); |
3048 | } | 3049 | } |
3049 | 3050 | ||
3050 | void CalendarView::newTodo() | 3051 | void CalendarView::newTodo() |
3051 | { | 3052 | { |
3052 | newTodoDateTime( QDateTime(),true ); | 3053 | newTodoDateTime( QDateTime(),true ); |
3053 | } | 3054 | } |
3054 | 3055 | ||
3055 | void CalendarView::newSubTodo() | 3056 | void CalendarView::newSubTodo() |
3056 | { | 3057 | { |
3057 | Todo *todo = selectedTodo(); | 3058 | Todo *todo = selectedTodo(); |
3058 | if ( todo ) newSubTodo( todo ); | 3059 | if ( todo ) newSubTodo( todo ); |
3059 | } | 3060 | } |
3060 | 3061 | ||
3061 | void CalendarView::newSubTodo(Todo *parentEvent) | 3062 | void CalendarView::newSubTodo(Todo *parentEvent) |
3062 | { | 3063 | { |
3063 | 3064 | ||
3064 | showTodoEditor(); | 3065 | showTodoEditor(); |
3065 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3066 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3066 | mTodoEditor->exec(); | 3067 | mTodoEditor->exec(); |
3067 | setActiveWindow(); | 3068 | setActiveWindow(); |
3068 | } | 3069 | } |
3069 | 3070 | ||
3070 | void CalendarView::newFloatingEvent() | 3071 | void CalendarView::newFloatingEvent() |
3071 | { | 3072 | { |
3072 | DateList tmpList = mNavigator->selectedDates(); | 3073 | DateList tmpList = mNavigator->selectedDates(); |
3073 | QDate date = tmpList.first(); | 3074 | QDate date = tmpList.first(); |
3074 | 3075 | ||
3075 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3076 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3076 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3077 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3077 | } | 3078 | } |
3078 | 3079 | ||
3079 | 3080 | ||
3080 | void CalendarView::editEvent( Event *event ) | 3081 | void CalendarView::editEvent( Event *event ) |
3081 | { | 3082 | { |
3082 | 3083 | ||
3083 | if ( !event ) return; | 3084 | if ( !event ) return; |
3084 | if ( event->isReadOnly() ) { | 3085 | if ( event->isReadOnly() ) { |
3085 | showEvent( event ); | 3086 | showEvent( event ); |
3086 | return; | 3087 | return; |
3087 | } | 3088 | } |
3088 | showEventEditor(); | 3089 | showEventEditor(); |
3089 | mEventEditor->editEvent( event , mFlagEditDescription); | 3090 | mEventEditor->editEvent( event , mFlagEditDescription); |
3090 | mEventEditor->exec(); | 3091 | mEventEditor->exec(); |
3091 | setActiveWindow(); | 3092 | setActiveWindow(); |
3092 | 3093 | ||
3093 | } | 3094 | } |
3094 | void CalendarView::editJournal( Journal *jour ) | 3095 | void CalendarView::editJournal( Journal *jour ) |
3095 | { | 3096 | { |
3096 | if ( !jour ) return; | 3097 | if ( !jour ) return; |
3097 | mDialogManager->hideSearchDialog(); | 3098 | mDialogManager->hideSearchDialog(); |
3098 | mViewManager->showJournalView(); | 3099 | mViewManager->showJournalView(); |
3099 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3100 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3100 | } | 3101 | } |
3101 | void CalendarView::editTodo( Todo *todo ) | 3102 | void CalendarView::editTodo( Todo *todo ) |
3102 | { | 3103 | { |
3103 | if ( !todo ) return; | 3104 | if ( !todo ) return; |
3104 | 3105 | ||
3105 | if ( todo->isReadOnly() ) { | 3106 | if ( todo->isReadOnly() ) { |
3106 | showTodo( todo ); | 3107 | showTodo( todo ); |
3107 | return; | 3108 | return; |
3108 | } | 3109 | } |
3109 | showTodoEditor(); | 3110 | showTodoEditor(); |
3110 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3111 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3111 | mTodoEditor->exec(); | 3112 | mTodoEditor->exec(); |
3112 | setActiveWindow(); | 3113 | setActiveWindow(); |
3113 | 3114 | ||
3114 | } | 3115 | } |
3115 | 3116 | ||
3116 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3117 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3117 | { | 3118 | { |
3118 | if ( !mEventViewerDialog ) { | 3119 | if ( !mEventViewerDialog ) { |
3119 | mEventViewerDialog = new KOEventViewerDialog(0); | 3120 | mEventViewerDialog = new KOEventViewerDialog(0); |
3120 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3121 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3121 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3122 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3122 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3123 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3123 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3124 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3124 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3125 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3125 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3126 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3126 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3127 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3127 | this, SLOT( slotViewerClosed() ) ); | 3128 | this, SLOT( slotViewerClosed() ) ); |
3128 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3129 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3129 | this, SLOT( todoChanged(Todo *) ) ); | 3130 | this, SLOT( todoChanged(Todo *) ) ); |
3130 | mEventViewerDialog->resize( 640, 480 ); | 3131 | mEventViewerDialog->resize( 640, 480 ); |
3131 | 3132 | ||
3132 | } | 3133 | } |
3133 | return mEventViewerDialog; | 3134 | return mEventViewerDialog; |
3134 | } | 3135 | } |
3135 | void CalendarView::showEvent(Event *event) | 3136 | void CalendarView::showEvent(Event *event) |
3136 | { | 3137 | { |
3137 | getEventViewerDialog()->setEvent(event); | 3138 | getEventViewerDialog()->setEvent(event); |
3138 | getEventViewerDialog()->showMe(); | 3139 | getEventViewerDialog()->showMe(); |
3139 | } | 3140 | } |
3140 | 3141 | ||
3141 | void CalendarView::showTodo(Todo *event) | 3142 | void CalendarView::showTodo(Todo *event) |
3142 | { | 3143 | { |
3143 | getEventViewerDialog()->setTodo(event); | 3144 | getEventViewerDialog()->setTodo(event); |
3144 | getEventViewerDialog()->showMe(); | 3145 | getEventViewerDialog()->showMe(); |
3145 | } | 3146 | } |
3146 | void CalendarView::showJournal( Journal *jour ) | 3147 | void CalendarView::showJournal( Journal *jour ) |
3147 | { | 3148 | { |
3148 | getEventViewerDialog()->setJournal(jour); | 3149 | getEventViewerDialog()->setJournal(jour); |
3149 | getEventViewerDialog()->showMe(); | 3150 | getEventViewerDialog()->showMe(); |
3150 | 3151 | ||
3151 | } | 3152 | } |
3152 | // void CalendarView::todoModified (Todo *event, int changed) | 3153 | // void CalendarView::todoModified (Todo *event, int changed) |
3153 | // { | 3154 | // { |
3154 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3155 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3155 | // // kdDebug() << "Todo modified and open" << endl; | 3156 | // // kdDebug() << "Todo modified and open" << endl; |
3156 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3157 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3157 | // // temp->modified (changed); | 3158 | // // temp->modified (changed); |
3158 | 3159 | ||
3159 | // // } | 3160 | // // } |
3160 | 3161 | ||
3161 | // mViewManager->updateView(); | 3162 | // mViewManager->updateView(); |
3162 | // } | 3163 | // } |
3163 | 3164 | ||
3164 | void CalendarView::appointment_show() | 3165 | void CalendarView::appointment_show() |
3165 | { | 3166 | { |
3166 | Event *anEvent = 0; | 3167 | Event *anEvent = 0; |
3167 | 3168 | ||
3168 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3169 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3169 | 3170 | ||
3170 | if (mViewManager->currentView()->isEventView()) { | 3171 | if (mViewManager->currentView()->isEventView()) { |
3171 | if ( incidence && incidence->typeID() == eventID ) { | 3172 | if ( incidence && incidence->typeID() == eventID ) { |
3172 | anEvent = static_cast<Event *>(incidence); | 3173 | anEvent = static_cast<Event *>(incidence); |
3173 | } | 3174 | } |
3174 | } | 3175 | } |
3175 | 3176 | ||
3176 | if (!anEvent) { | 3177 | if (!anEvent) { |
3177 | KNotifyClient::beep(); | 3178 | KNotifyClient::beep(); |
3178 | return; | 3179 | return; |
3179 | } | 3180 | } |
3180 | 3181 | ||
3181 | showEvent(anEvent); | 3182 | showEvent(anEvent); |
3182 | } | 3183 | } |
3183 | 3184 | ||
3184 | void CalendarView::appointment_edit() | 3185 | void CalendarView::appointment_edit() |
3185 | { | 3186 | { |
3186 | Event *anEvent = 0; | 3187 | Event *anEvent = 0; |
3187 | 3188 | ||
3188 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3189 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3189 | 3190 | ||
3190 | if (mViewManager->currentView()->isEventView()) { | 3191 | if (mViewManager->currentView()->isEventView()) { |
3191 | if ( incidence && incidence->typeID() == eventID ) { | 3192 | if ( incidence && incidence->typeID() == eventID ) { |
3192 | anEvent = static_cast<Event *>(incidence); | 3193 | anEvent = static_cast<Event *>(incidence); |
3193 | } | 3194 | } |
3194 | } | 3195 | } |
3195 | 3196 | ||
3196 | if (!anEvent) { | 3197 | if (!anEvent) { |
3197 | KNotifyClient::beep(); | 3198 | KNotifyClient::beep(); |
3198 | return; | 3199 | return; |
3199 | } | 3200 | } |
3200 | 3201 | ||
3201 | editEvent(anEvent); | 3202 | editEvent(anEvent); |
3202 | } | 3203 | } |
3203 | 3204 | ||
3204 | void CalendarView::appointment_delete() | 3205 | void CalendarView::appointment_delete() |
3205 | { | 3206 | { |
3206 | Event *anEvent = 0; | 3207 | Event *anEvent = 0; |
3207 | 3208 | ||
3208 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3209 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3209 | 3210 | ||
3210 | if (mViewManager->currentView()->isEventView()) { | 3211 | if (mViewManager->currentView()->isEventView()) { |
3211 | if ( incidence && incidence->typeID() == eventID ) { | 3212 | if ( incidence && incidence->typeID() == eventID ) { |
3212 | anEvent = static_cast<Event *>(incidence); | 3213 | anEvent = static_cast<Event *>(incidence); |
3213 | } | 3214 | } |
3214 | } | 3215 | } |
3215 | 3216 | ||
3216 | if (!anEvent) { | 3217 | if (!anEvent) { |
3217 | KNotifyClient::beep(); | 3218 | KNotifyClient::beep(); |
3218 | return; | 3219 | return; |
3219 | } | 3220 | } |
3220 | 3221 | ||
3221 | deleteEvent(anEvent); | 3222 | deleteEvent(anEvent); |
3222 | } | 3223 | } |
3223 | 3224 | ||
3224 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3225 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3225 | { | 3226 | { |
3226 | if (!sub) return; | 3227 | if (!sub) return; |
3227 | if ( sub->relatedTo() == parent ) | 3228 | if ( sub->relatedTo() == parent ) |
3228 | return; | 3229 | return; |
3229 | sub->setRelatedTo(parent); | 3230 | sub->setRelatedTo(parent); |
3230 | sub->updated(); | 3231 | sub->updated(); |
3231 | setModified(true); | 3232 | setModified(true); |
3232 | updateView(); | 3233 | updateView(); |
3233 | } | 3234 | } |
3234 | void CalendarView::todo_unsub(Todo *anTodo ) | 3235 | void CalendarView::todo_unsub(Todo *anTodo ) |
3235 | { | 3236 | { |
3236 | todo_resub( 0, anTodo ); | 3237 | todo_resub( 0, anTodo ); |
3237 | } | 3238 | } |
3238 | 3239 | ||
3239 | void CalendarView::deleteTodo(Todo *todo) | 3240 | void CalendarView::deleteTodo(Todo *todo) |
3240 | { | 3241 | { |
3241 | if (!todo) { | 3242 | if (!todo) { |
3242 | KNotifyClient::beep(); | 3243 | KNotifyClient::beep(); |
3243 | return; | 3244 | return; |
3244 | } | 3245 | } |
3245 | if (KOPrefs::instance()->mConfirm) { | 3246 | if (KOPrefs::instance()->mConfirm) { |
3246 | QString text = todo->summary().left(20); | 3247 | QString text = todo->summary().left(20); |
3247 | if (!todo->relations().isEmpty()) { | 3248 | if (!todo->relations().isEmpty()) { |
3248 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3249 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3249 | 3250 | ||
3250 | } | 3251 | } |
3251 | switch (msgItemDelete(text)) { | 3252 | switch (msgItemDelete(text)) { |
3252 | case KMessageBox::Continue: // OK | 3253 | case KMessageBox::Continue: // OK |
3253 | bool deleteT = false; | 3254 | bool deleteT = false; |
3254 | if (!todo->relations().isEmpty()) { | 3255 | if (!todo->relations().isEmpty()) { |
3255 | deleteT = removeCompletedSubTodos( todo ); | 3256 | deleteT = removeCompletedSubTodos( todo ); |
3256 | } | 3257 | } |
3257 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3258 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3258 | if ( !deleteT ) { | 3259 | if ( !deleteT ) { |
3259 | checkExternalId( todo ); | 3260 | checkExternalId( todo ); |
3260 | calendar()->deleteTodo(todo); | 3261 | calendar()->deleteTodo(todo); |
3261 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3262 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3262 | updateView(); | 3263 | updateView(); |
3263 | } | 3264 | } |
3264 | break; | 3265 | break; |
3265 | } // switch | 3266 | } // switch |
3266 | } else { | 3267 | } else { |
3267 | checkExternalId( todo ); | 3268 | checkExternalId( todo ); |
3268 | mCalendar->deleteTodo(todo); | 3269 | mCalendar->deleteTodo(todo); |
3269 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3270 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3270 | updateView(); | 3271 | updateView(); |
3271 | } | 3272 | } |
3272 | 3273 | ||
3273 | emit updateSearchDialog(); | 3274 | emit updateSearchDialog(); |
3274 | } | 3275 | } |
3275 | void CalendarView::deleteJournal(Journal *jour) | 3276 | void CalendarView::deleteJournal(Journal *jour) |
3276 | { | 3277 | { |
3277 | if (!jour) { | 3278 | if (!jour) { |
3278 | KNotifyClient::beep(); | 3279 | KNotifyClient::beep(); |
3279 | return; | 3280 | return; |
3280 | } | 3281 | } |
3281 | if (KOPrefs::instance()->mConfirm) { | 3282 | if (KOPrefs::instance()->mConfirm) { |
3282 | switch (msgItemDelete( jour->description().left(20))) { | 3283 | switch (msgItemDelete( jour->description().left(20))) { |
3283 | case KMessageBox::Continue: // OK | 3284 | case KMessageBox::Continue: // OK |
3284 | calendar()->deleteJournal(jour); | 3285 | calendar()->deleteJournal(jour); |
3285 | updateView(); | 3286 | updateView(); |
3286 | break; | 3287 | break; |
3287 | } // switch | 3288 | } // switch |
3288 | } else { | 3289 | } else { |
3289 | calendar()->deleteJournal(jour);; | 3290 | calendar()->deleteJournal(jour);; |
3290 | updateView(); | 3291 | updateView(); |
3291 | } | 3292 | } |
3292 | emit updateSearchDialog(); | 3293 | emit updateSearchDialog(); |
3293 | } | 3294 | } |
3294 | 3295 | ||
3295 | void CalendarView::deleteEvent(Event *anEvent) | 3296 | void CalendarView::deleteEvent(Event *anEvent) |
3296 | { | 3297 | { |
3297 | if (!anEvent) { | 3298 | if (!anEvent) { |
3298 | KNotifyClient::beep(); | 3299 | KNotifyClient::beep(); |
3299 | return; | 3300 | return; |
3300 | } | 3301 | } |
3301 | 3302 | ||
3302 | if (anEvent->recurrence()->doesRecur()) { | 3303 | if (anEvent->recurrence()->doesRecur()) { |
3303 | QDate itemDate = mViewManager->currentSelectionDate(); | 3304 | QDate itemDate = mViewManager->currentSelectionDate(); |
3304 | int km; | 3305 | int km; |
3305 | if (!itemDate.isValid()) { | 3306 | if (!itemDate.isValid()) { |
3306 | //kdDebug() << "Date Not Valid" << endl; | 3307 | //kdDebug() << "Date Not Valid" << endl; |
3307 | if (KOPrefs::instance()->mConfirm) { | 3308 | if (KOPrefs::instance()->mConfirm) { |
3308 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3309 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3309 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3310 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3310 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3311 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3311 | if ( km == KMessageBox::Continue ) | 3312 | if ( km == KMessageBox::Continue ) |
3312 | km = KMessageBox::No; // No = all below | 3313 | km = KMessageBox::No; // No = all below |
3313 | } else | 3314 | } else |
3314 | km = KMessageBox::No; | 3315 | km = KMessageBox::No; |
3315 | } else { | 3316 | } else { |
3316 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3317 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3317 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3318 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3318 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3319 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3319 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3320 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3320 | i18n("All")); | 3321 | i18n("All")); |
3321 | } | 3322 | } |
3322 | switch(km) { | 3323 | switch(km) { |
3323 | 3324 | ||
3324 | case KMessageBox::No: // Continue // all | 3325 | case KMessageBox::No: // Continue // all |
3325 | //qDebug("KMessageBox::No "); | 3326 | //qDebug("KMessageBox::No "); |
3326 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3327 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3327 | schedule(Scheduler::Cancel,anEvent); | 3328 | schedule(Scheduler::Cancel,anEvent); |
3328 | 3329 | ||
3329 | checkExternalId( anEvent); | 3330 | checkExternalId( anEvent); |
3330 | mCalendar->deleteEvent(anEvent); | 3331 | mCalendar->deleteEvent(anEvent); |
3331 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3332 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3332 | break; | 3333 | break; |
3333 | 3334 | ||
3334 | // Disabled because it does not work | 3335 | // Disabled because it does not work |
3335 | //#if 0 | 3336 | //#if 0 |
3336 | case KMessageBox::Yes: // just this one | 3337 | case KMessageBox::Yes: // just this one |
3337 | //QDate qd = mNavigator->selectedDates().first(); | 3338 | //QDate qd = mNavigator->selectedDates().first(); |
3338 | //if (!qd.isValid()) { | 3339 | //if (!qd.isValid()) { |
3339 | // kdDebug() << "no date selected, or invalid date" << endl; | 3340 | // kdDebug() << "no date selected, or invalid date" << endl; |
3340 | // KNotifyClient::beep(); | 3341 | // KNotifyClient::beep(); |
3341 | // return; | 3342 | // return; |
3342 | //} | 3343 | //} |
3343 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3344 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3344 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3345 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3345 | anEvent->addExDate(itemDate); | 3346 | anEvent->addExDate(itemDate); |
3346 | int duration = anEvent->recurrence()->duration(); | 3347 | int duration = anEvent->recurrence()->duration(); |
3347 | if ( duration > 0 ) { | 3348 | if ( duration > 0 ) { |
3348 | anEvent->recurrence()->setDuration( duration - 1 ); | 3349 | anEvent->recurrence()->setDuration( duration - 1 ); |
3349 | } | 3350 | } |
3350 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3351 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3351 | } | 3352 | } |
3352 | break; | 3353 | break; |
3353 | //#endif | 3354 | //#endif |
3354 | } // switch | 3355 | } // switch |
3355 | } else { | 3356 | } else { |
3356 | if (KOPrefs::instance()->mConfirm) { | 3357 | if (KOPrefs::instance()->mConfirm) { |
3357 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3358 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3358 | i18n("\nAre you sure you want\nto delete this event?"), | 3359 | i18n("\nAre you sure you want\nto delete this event?"), |
3359 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3360 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3360 | case KMessageBox::Continue: // OK | 3361 | case KMessageBox::Continue: // OK |
3361 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3362 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3362 | schedule(Scheduler::Cancel,anEvent); | 3363 | schedule(Scheduler::Cancel,anEvent); |
3363 | checkExternalId( anEvent); | 3364 | checkExternalId( anEvent); |
3364 | mCalendar->deleteEvent(anEvent); | 3365 | mCalendar->deleteEvent(anEvent); |
3365 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3366 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3366 | break; | 3367 | break; |
3367 | } // switch | 3368 | } // switch |
3368 | } else { | 3369 | } else { |
3369 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3370 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3370 | schedule(Scheduler::Cancel,anEvent); | 3371 | schedule(Scheduler::Cancel,anEvent); |
3371 | checkExternalId( anEvent); | 3372 | checkExternalId( anEvent); |
3372 | mCalendar->deleteEvent(anEvent); | 3373 | mCalendar->deleteEvent(anEvent); |
3373 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3374 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3374 | } | 3375 | } |
3375 | } // if-else | 3376 | } // if-else |
3376 | emit updateSearchDialog(); | 3377 | emit updateSearchDialog(); |
3377 | } | 3378 | } |
3378 | 3379 | ||
3379 | bool CalendarView::deleteEvent(const QString &uid) | 3380 | bool CalendarView::deleteEvent(const QString &uid) |
3380 | { | 3381 | { |
3381 | Event *ev = mCalendar->event(uid); | 3382 | Event *ev = mCalendar->event(uid); |
3382 | if (ev) { | 3383 | if (ev) { |
3383 | deleteEvent(ev); | 3384 | deleteEvent(ev); |
3384 | return true; | 3385 | return true; |
3385 | } else { | 3386 | } else { |
3386 | return false; | 3387 | return false; |
3387 | } | 3388 | } |
3388 | } | 3389 | } |
3389 | 3390 | ||
3390 | /*****************************************************************************/ | 3391 | /*****************************************************************************/ |
3391 | 3392 | ||
3392 | void CalendarView::action_mail() | 3393 | void CalendarView::action_mail() |
3393 | { | 3394 | { |
3394 | #ifndef KORG_NOMAIL | 3395 | #ifndef KORG_NOMAIL |
3395 | KOMailClient mailClient; | 3396 | KOMailClient mailClient; |
3396 | 3397 | ||
3397 | Incidence *incidence = currentSelection(); | 3398 | Incidence *incidence = currentSelection(); |
3398 | 3399 | ||
3399 | if (!incidence) { | 3400 | if (!incidence) { |
3400 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3401 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3401 | return; | 3402 | return; |
3402 | } | 3403 | } |
3403 | if(incidence->attendeeCount() == 0 ) { | 3404 | if(incidence->attendeeCount() == 0 ) { |
3404 | KMessageBox::sorry(this, | 3405 | KMessageBox::sorry(this, |
3405 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3406 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3406 | return; | 3407 | return; |
3407 | } | 3408 | } |
3408 | 3409 | ||
3409 | CalendarLocal cal_tmp; | 3410 | CalendarLocal cal_tmp; |
3410 | Event *event = 0; | 3411 | Event *event = 0; |
3411 | Event *ev = 0; | 3412 | Event *ev = 0; |
3412 | if ( incidence && incidence->typeID() == eventID ) { | 3413 | if ( incidence && incidence->typeID() == eventID ) { |
3413 | event = static_cast<Event *>(incidence); | 3414 | event = static_cast<Event *>(incidence); |
3414 | ev = new Event(*event); | 3415 | ev = new Event(*event); |
3415 | cal_tmp.addEvent(ev); | 3416 | cal_tmp.addEvent(ev); |
3416 | } | 3417 | } |
3417 | ICalFormat mForm(); | 3418 | ICalFormat mForm(); |
3418 | QString attachment = mForm.toString( &cal_tmp ); | 3419 | QString attachment = mForm.toString( &cal_tmp ); |
3419 | if (ev) delete(ev); | 3420 | if (ev) delete(ev); |
3420 | 3421 | ||
3421 | mailClient.mailAttendees(currentSelection(), attachment); | 3422 | mailClient.mailAttendees(currentSelection(), attachment); |
3422 | 3423 | ||
3423 | #endif | 3424 | #endif |
3424 | 3425 | ||
3425 | #if 0 | 3426 | #if 0 |
3426 | Event *anEvent = 0; | 3427 | Event *anEvent = 0; |
3427 | if (mViewManager->currentView()->isEventView()) { | 3428 | if (mViewManager->currentView()->isEventView()) { |
3428 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3429 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3429 | } | 3430 | } |
3430 | 3431 | ||
3431 | if (!anEvent) { | 3432 | if (!anEvent) { |
3432 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3433 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3433 | return; | 3434 | return; |
3434 | } | 3435 | } |
3435 | if(anEvent->attendeeCount() == 0 ) { | 3436 | if(anEvent->attendeeCount() == 0 ) { |
3436 | KMessageBox::sorry(this, | 3437 | KMessageBox::sorry(this, |
3437 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3438 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3438 | return; | 3439 | return; |
3439 | } | 3440 | } |
3440 | 3441 | ||
3441 | mailobject.emailEvent(anEvent); | 3442 | mailobject.emailEvent(anEvent); |
3442 | #endif | 3443 | #endif |
3443 | } | 3444 | } |
3444 | 3445 | ||
3445 | 3446 | ||
3446 | void CalendarView::schedule_publish(Incidence *incidence) | 3447 | void CalendarView::schedule_publish(Incidence *incidence) |
3447 | { | 3448 | { |
3448 | Event *event = 0; | 3449 | Event *event = 0; |
3449 | Todo *todo = 0; | 3450 | Todo *todo = 0; |
3450 | 3451 | ||
3451 | if (incidence == 0) { | 3452 | if (incidence == 0) { |
3452 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3453 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3453 | if (incidence == 0) { | 3454 | if (incidence == 0) { |
3454 | incidence = mTodoList->selectedIncidences().first(); | 3455 | incidence = mTodoList->selectedIncidences().first(); |
3455 | } | 3456 | } |
3456 | } | 3457 | } |
3457 | if ( incidence && incidence->typeID() == eventID ) { | 3458 | if ( incidence && incidence->typeID() == eventID ) { |
3458 | event = static_cast<Event *>(incidence); | 3459 | event = static_cast<Event *>(incidence); |
3459 | } else { | 3460 | } else { |
3460 | if ( incidence && incidence->typeID() == todoID ) { | 3461 | if ( incidence && incidence->typeID() == todoID ) { |
3461 | todo = static_cast<Todo *>(incidence); | 3462 | todo = static_cast<Todo *>(incidence); |
3462 | } | 3463 | } |
3463 | } | 3464 | } |
3464 | 3465 | ||
3465 | if (!event && !todo) { | 3466 | if (!event && !todo) { |
3466 | KMessageBox::sorry(this,i18n("No event selected.")); | 3467 | KMessageBox::sorry(this,i18n("No event selected.")); |
3467 | return; | 3468 | return; |
3468 | } | 3469 | } |
3469 | 3470 | ||
3470 | PublishDialog *publishdlg = new PublishDialog(); | 3471 | PublishDialog *publishdlg = new PublishDialog(); |
3471 | if (incidence->attendeeCount()>0) { | 3472 | if (incidence->attendeeCount()>0) { |
3472 | QPtrList<Attendee> attendees = incidence->attendees(); | 3473 | QPtrList<Attendee> attendees = incidence->attendees(); |
3473 | attendees.first(); | 3474 | attendees.first(); |
3474 | while ( attendees.current()!=0 ) { | 3475 | while ( attendees.current()!=0 ) { |
3475 | publishdlg->addAttendee(attendees.current()); | 3476 | publishdlg->addAttendee(attendees.current()); |
3476 | attendees.next(); | 3477 | attendees.next(); |
3477 | } | 3478 | } |
3478 | } | 3479 | } |
3479 | bool send = true; | 3480 | bool send = true; |
3480 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3481 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3481 | if ( publishdlg->exec() != QDialog::Accepted ) | 3482 | if ( publishdlg->exec() != QDialog::Accepted ) |
3482 | send = false; | 3483 | send = false; |
3483 | } | 3484 | } |
3484 | if ( send ) { | 3485 | if ( send ) { |
3485 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3486 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3486 | if ( event ) { | 3487 | if ( event ) { |
3487 | Event *ev = new Event(*event); | 3488 | Event *ev = new Event(*event); |
3488 | ev->registerObserver(0); | 3489 | ev->registerObserver(0); |
3489 | ev->clearAttendees(); | 3490 | ev->clearAttendees(); |
3490 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3491 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3491 | delete(ev); | 3492 | delete(ev); |
3492 | } | 3493 | } |
3493 | } else { | 3494 | } else { |
3494 | if ( todo ) { | 3495 | if ( todo ) { |
3495 | Todo *ev = new Todo(*todo); | 3496 | Todo *ev = new Todo(*todo); |
3496 | ev->registerObserver(0); | 3497 | ev->registerObserver(0); |
3497 | ev->clearAttendees(); | 3498 | ev->clearAttendees(); |
3498 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3499 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3499 | delete(ev); | 3500 | delete(ev); |
3500 | } | 3501 | } |
3501 | } | 3502 | } |
3502 | } | 3503 | } |
3503 | } | 3504 | } |
3504 | delete publishdlg; | 3505 | delete publishdlg; |
3505 | } | 3506 | } |
3506 | 3507 | ||
3507 | void CalendarView::schedule_request(Incidence *incidence) | 3508 | void CalendarView::schedule_request(Incidence *incidence) |
3508 | { | 3509 | { |
3509 | schedule(Scheduler::Request,incidence); | 3510 | schedule(Scheduler::Request,incidence); |
3510 | } | 3511 | } |
3511 | 3512 | ||
3512 | void CalendarView::schedule_refresh(Incidence *incidence) | 3513 | void CalendarView::schedule_refresh(Incidence *incidence) |
3513 | { | 3514 | { |
3514 | schedule(Scheduler::Refresh,incidence); | 3515 | schedule(Scheduler::Refresh,incidence); |
3515 | } | 3516 | } |
3516 | 3517 | ||
3517 | void CalendarView::schedule_cancel(Incidence *incidence) | 3518 | void CalendarView::schedule_cancel(Incidence *incidence) |
3518 | { | 3519 | { |
3519 | schedule(Scheduler::Cancel,incidence); | 3520 | schedule(Scheduler::Cancel,incidence); |
3520 | } | 3521 | } |
3521 | 3522 | ||
3522 | void CalendarView::schedule_add(Incidence *incidence) | 3523 | void CalendarView::schedule_add(Incidence *incidence) |
3523 | { | 3524 | { |
3524 | schedule(Scheduler::Add,incidence); | 3525 | schedule(Scheduler::Add,incidence); |
3525 | } | 3526 | } |
3526 | 3527 | ||
3527 | void CalendarView::schedule_reply(Incidence *incidence) | 3528 | void CalendarView::schedule_reply(Incidence *incidence) |
3528 | { | 3529 | { |
3529 | schedule(Scheduler::Reply,incidence); | 3530 | schedule(Scheduler::Reply,incidence); |
3530 | } | 3531 | } |
3531 | 3532 | ||
3532 | void CalendarView::schedule_counter(Incidence *incidence) | 3533 | void CalendarView::schedule_counter(Incidence *incidence) |
3533 | { | 3534 | { |
3534 | schedule(Scheduler::Counter,incidence); | 3535 | schedule(Scheduler::Counter,incidence); |
3535 | } | 3536 | } |
3536 | 3537 | ||
3537 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3538 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3538 | { | 3539 | { |
3539 | schedule(Scheduler::Declinecounter,incidence); | 3540 | schedule(Scheduler::Declinecounter,incidence); |
3540 | } | 3541 | } |
3541 | 3542 | ||
3542 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3543 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3543 | { | 3544 | { |
3544 | QDateTime start = QDateTime::currentDateTime(); | 3545 | QDateTime start = QDateTime::currentDateTime(); |
3545 | QDateTime end = start.addDays(daysToPublish); | 3546 | QDateTime end = start.addDays(daysToPublish); |
3546 | 3547 | ||
3547 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3548 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3548 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3549 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3549 | 3550 | ||
3550 | 3551 | ||
3551 | PublishDialog *publishdlg = new PublishDialog(); | 3552 | PublishDialog *publishdlg = new PublishDialog(); |
3552 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3553 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3553 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3554 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3554 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3555 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3555 | delete(freebusy); | 3556 | delete(freebusy); |
3556 | } | 3557 | } |
3557 | } | 3558 | } |
3558 | delete publishdlg; | 3559 | delete publishdlg; |
3559 | } | 3560 | } |
3560 | 3561 | ||
3561 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3562 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3562 | { | 3563 | { |
3563 | Event *event = 0; | 3564 | Event *event = 0; |
3564 | Todo *todo = 0; | 3565 | Todo *todo = 0; |
3565 | 3566 | ||
3566 | if (incidence == 0) { | 3567 | if (incidence == 0) { |
3567 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3568 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3568 | if (incidence == 0) { | 3569 | if (incidence == 0) { |
3569 | incidence = mTodoList->selectedIncidences().first(); | 3570 | incidence = mTodoList->selectedIncidences().first(); |
3570 | } | 3571 | } |
3571 | } | 3572 | } |
3572 | if ( incidence && incidence->typeID() == eventID ) { | 3573 | if ( incidence && incidence->typeID() == eventID ) { |
3573 | event = static_cast<Event *>(incidence); | 3574 | event = static_cast<Event *>(incidence); |
3574 | } | 3575 | } |
3575 | if ( incidence && incidence->typeID() == todoID ) { | 3576 | if ( incidence && incidence->typeID() == todoID ) { |
3576 | todo = static_cast<Todo *>(incidence); | 3577 | todo = static_cast<Todo *>(incidence); |
3577 | } | 3578 | } |
3578 | 3579 | ||
3579 | if (!event && !todo) { | 3580 | if (!event && !todo) { |
3580 | KMessageBox::sorry(this,i18n("No event selected.")); | 3581 | KMessageBox::sorry(this,i18n("No event selected.")); |
3581 | return; | 3582 | return; |
3582 | } | 3583 | } |
3583 | 3584 | ||
3584 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3585 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3585 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3586 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3586 | return; | 3587 | return; |
3587 | } | 3588 | } |
3588 | 3589 | ||
3589 | Event *ev = 0; | 3590 | Event *ev = 0; |
3590 | if (event) ev = new Event(*event); | 3591 | if (event) ev = new Event(*event); |
3591 | Todo *to = 0; | 3592 | Todo *to = 0; |
3592 | if (todo) to = new Todo(*todo); | 3593 | if (todo) to = new Todo(*todo); |
3593 | 3594 | ||
3594 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3595 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3595 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3596 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3596 | if (!me) { | 3597 | if (!me) { |
3597 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3598 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3598 | return; | 3599 | return; |
3599 | } | 3600 | } |
3600 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3601 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3601 | StatusDialog *statdlg = new StatusDialog(this); | 3602 | StatusDialog *statdlg = new StatusDialog(this); |
3602 | if (!statdlg->exec()==QDialog::Accepted) return; | 3603 | if (!statdlg->exec()==QDialog::Accepted) return; |
3603 | me->setStatus( statdlg->status() ); | 3604 | me->setStatus( statdlg->status() ); |
3604 | delete(statdlg); | 3605 | delete(statdlg); |
3605 | } | 3606 | } |
3606 | Attendee *menew = new Attendee(*me); | 3607 | Attendee *menew = new Attendee(*me); |
3607 | if (ev) { | 3608 | if (ev) { |
3608 | ev->clearAttendees(); | 3609 | ev->clearAttendees(); |
3609 | ev->addAttendee(menew,false); | 3610 | ev->addAttendee(menew,false); |
3610 | } else { | 3611 | } else { |
3611 | if (to) { | 3612 | if (to) { |
3612 | todo->clearAttendees(); | 3613 | todo->clearAttendees(); |
3613 | todo->addAttendee(menew,false); | 3614 | todo->addAttendee(menew,false); |
3614 | } | 3615 | } |
3615 | } | 3616 | } |
3616 | } | 3617 | } |
3617 | 3618 | ||
3618 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3619 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3619 | if (ev) { | 3620 | if (ev) { |
3620 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3621 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3621 | } else { | 3622 | } else { |
3622 | if (to) { | 3623 | if (to) { |
3623 | if ( !dlg->addMessage(to,method) ) delete(to); | 3624 | if ( !dlg->addMessage(to,method) ) delete(to); |
3624 | } | 3625 | } |
3625 | } | 3626 | } |
3626 | } | 3627 | } |
3627 | 3628 | ||
3628 | void CalendarView::openAddressbook() | 3629 | void CalendarView::openAddressbook() |
3629 | { | 3630 | { |
3630 | KRun::runCommand("kaddressbook"); | 3631 | KRun::runCommand("kaddressbook"); |
3631 | } | 3632 | } |
3632 | 3633 | ||
3633 | void CalendarView::setModified(bool modified) | 3634 | void CalendarView::setModified(bool modified) |
3634 | { | 3635 | { |
3635 | if ( modified ) | 3636 | if ( modified ) |
3636 | emit signalmodified(); | 3637 | emit signalmodified(); |
3637 | if (mModified != modified) { | 3638 | if (mModified != modified) { |
3638 | mModified = modified; | 3639 | mModified = modified; |
3639 | emit modifiedChanged(mModified); | 3640 | emit modifiedChanged(mModified); |
3640 | } | 3641 | } |
3641 | } | 3642 | } |
3642 | 3643 | ||
3643 | bool CalendarView::isReadOnly() | 3644 | bool CalendarView::isReadOnly() |
3644 | { | 3645 | { |
3645 | return mReadOnly; | 3646 | return mReadOnly; |
3646 | } | 3647 | } |
3647 | 3648 | ||
3648 | void CalendarView::setReadOnly(bool readOnly) | 3649 | void CalendarView::setReadOnly(bool readOnly) |
3649 | { | 3650 | { |
3650 | if (mReadOnly != readOnly) { | 3651 | if (mReadOnly != readOnly) { |
3651 | mReadOnly = readOnly; | 3652 | mReadOnly = readOnly; |
3652 | emit readOnlyChanged(mReadOnly); | 3653 | emit readOnlyChanged(mReadOnly); |
3653 | } | 3654 | } |
3654 | } | 3655 | } |
3655 | 3656 | ||
3656 | bool CalendarView::isModified() | 3657 | bool CalendarView::isModified() |
3657 | { | 3658 | { |
3658 | return mModified; | 3659 | return mModified; |
3659 | } | 3660 | } |
3660 | void CalendarView::slotprintSelInc() | 3661 | void CalendarView::slotprintSelInc() |
3661 | { | 3662 | { |
3662 | if ( currentSelection() == 0 ) { | 3663 | if ( currentSelection() == 0 ) { |
3663 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 3664 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
3664 | return; | 3665 | return; |
3665 | } | 3666 | } |
3666 | showIncidence(); | 3667 | showIncidence(); |
3667 | getEventViewerDialog()->print(); | 3668 | getEventViewerDialog()->print(); |
3668 | 3669 | ||
3669 | } | 3670 | } |
3670 | void CalendarView::printSetup() | 3671 | void CalendarView::printSetup() |
3671 | { | 3672 | { |
3672 | #ifndef KORG_NOPRINTER | 3673 | #ifndef KORG_NOPRINTER |
3673 | createPrinter(); | 3674 | createPrinter(); |
3674 | 3675 | ||
3675 | mCalPrinter->setupPrinter(); | 3676 | mCalPrinter->setupPrinter(); |
3676 | #endif | 3677 | #endif |
3677 | } | 3678 | } |
3678 | 3679 | ||
3679 | void CalendarView::print() | 3680 | void CalendarView::print() |
3680 | { | 3681 | { |
3681 | #ifndef KORG_NOPRINTER | 3682 | #ifndef KORG_NOPRINTER |
3682 | createPrinter(); | 3683 | createPrinter(); |
3683 | 3684 | ||
3684 | DateList tmpDateList = mNavigator->selectedDates(); | 3685 | DateList tmpDateList = mNavigator->selectedDates(); |
3685 | mCalPrinter->print(CalPrinter::Month, | 3686 | mCalPrinter->print(CalPrinter::Month, |
3686 | tmpDateList.first(), tmpDateList.last()); | 3687 | tmpDateList.first(), tmpDateList.last()); |
3687 | #endif | 3688 | #endif |
3688 | } | 3689 | } |
3689 | 3690 | ||
3690 | void CalendarView::printPreview() | 3691 | void CalendarView::printPreview() |
3691 | { | 3692 | { |
3692 | #ifndef KORG_NOPRINTER | 3693 | #ifndef KORG_NOPRINTER |
3693 | kdDebug() << "CalendarView::printPreview()" << endl; | 3694 | kdDebug() << "CalendarView::printPreview()" << endl; |
3694 | 3695 | ||
3695 | createPrinter(); | 3696 | createPrinter(); |
3696 | 3697 | ||
3697 | DateList tmpDateList = mNavigator->selectedDates(); | 3698 | DateList tmpDateList = mNavigator->selectedDates(); |
3698 | 3699 | ||
3699 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3700 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3700 | tmpDateList.last()); | 3701 | tmpDateList.last()); |
3701 | #endif | 3702 | #endif |
3702 | } | 3703 | } |
3703 | 3704 | ||
3704 | void CalendarView::exportICalendar() | 3705 | void CalendarView::exportICalendar() |
3705 | { | 3706 | { |
3706 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3707 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3707 | 3708 | ||
3708 | // Force correct extension | 3709 | // Force correct extension |
3709 | if (filename.right(4) != ".ics") filename += ".ics"; | 3710 | if (filename.right(4) != ".ics") filename += ".ics"; |
3710 | 3711 | ||
3711 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3712 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3712 | storage.save(); | 3713 | storage.save(); |
3713 | } | 3714 | } |
3714 | 3715 | ||
3715 | bool CalendarView::exportVCalendar( QString filename ) | 3716 | bool CalendarView::exportVCalendar( QString filename ) |
3716 | { | 3717 | { |
3717 | if (mCalendar->journals().count() > 0) { | 3718 | if (mCalendar->journals().count() > 0) { |
3718 | int result = KMessageBox::warningContinueCancel(this, | 3719 | int result = KMessageBox::warningContinueCancel(this, |
3719 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3720 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3720 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3721 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3721 | true); | 3722 | true); |
3722 | if (result != KMessageBox::Continue) return false; | 3723 | if (result != KMessageBox::Continue) return false; |
3723 | } | 3724 | } |
3724 | 3725 | ||
3725 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3726 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3726 | 3727 | ||
3727 | // Force correct extension | 3728 | // Force correct extension |
3728 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3729 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3729 | 3730 | ||
3730 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3731 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3731 | return storage.save(); | 3732 | return storage.save(); |
3732 | 3733 | ||
3733 | } | 3734 | } |
3734 | 3735 | ||
3735 | void CalendarView::eventUpdated(Incidence *) | 3736 | void CalendarView::eventUpdated(Incidence *) |
3736 | { | 3737 | { |
3737 | setModified(); | 3738 | setModified(); |
3738 | // Don't call updateView here. The code, which has caused the update of the | 3739 | // Don't call updateView here. The code, which has caused the update of the |
3739 | // event is responsible for updating the view. | 3740 | // event is responsible for updating the view. |
3740 | // updateView(); | 3741 | // updateView(); |
3741 | } | 3742 | } |
3742 | 3743 | ||
3743 | void CalendarView::adaptNavigationUnits() | 3744 | void CalendarView::adaptNavigationUnits() |
3744 | { | 3745 | { |
3745 | if (mViewManager->currentView()->isEventView()) { | 3746 | if (mViewManager->currentView()->isEventView()) { |
3746 | int days = mViewManager->currentView()->currentDateCount(); | 3747 | int days = mViewManager->currentView()->currentDateCount(); |
3747 | if (days == 1) { | 3748 | if (days == 1) { |
3748 | emit changeNavStringPrev(i18n("&Previous Day")); | 3749 | emit changeNavStringPrev(i18n("&Previous Day")); |
3749 | emit changeNavStringNext(i18n("&Next Day")); | 3750 | emit changeNavStringNext(i18n("&Next Day")); |
3750 | } else { | 3751 | } else { |
3751 | emit changeNavStringPrev(i18n("&Previous Week")); | 3752 | emit changeNavStringPrev(i18n("&Previous Week")); |
3752 | emit changeNavStringNext(i18n("&Next Week")); | 3753 | emit changeNavStringNext(i18n("&Next Week")); |
3753 | } | 3754 | } |
3754 | } | 3755 | } |
3755 | } | 3756 | } |
3756 | 3757 | ||
3757 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3758 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3758 | { | 3759 | { |
3759 | if ( incidence ) mTodoList->clearSelection(); | 3760 | if ( incidence ) mTodoList->clearSelection(); |
3760 | processIncidenceSelection( incidence ); | 3761 | processIncidenceSelection( incidence ); |
3761 | } | 3762 | } |
3762 | 3763 | ||
3763 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3764 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3764 | { | 3765 | { |
3765 | if ( incidence && mViewManager->currentView() ) { | 3766 | if ( incidence && mViewManager->currentView() ) { |
3766 | mViewManager->currentView()->clearSelection(); | 3767 | mViewManager->currentView()->clearSelection(); |
3767 | } | 3768 | } |
3768 | processIncidenceSelection( incidence ); | 3769 | processIncidenceSelection( incidence ); |
3769 | } | 3770 | } |
3770 | 3771 | ||
3771 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3772 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3772 | { | 3773 | { |
3773 | if ( incidence == mSelectedIncidence ) return; | 3774 | if ( incidence == mSelectedIncidence ) return; |
3774 | 3775 | ||
3775 | mSelectedIncidence = incidence; | 3776 | mSelectedIncidence = incidence; |
3776 | 3777 | ||
3777 | emit incidenceSelected( mSelectedIncidence ); | 3778 | emit incidenceSelected( mSelectedIncidence ); |
3778 | 3779 | ||
3779 | if ( incidence && incidence->typeID() == eventID ) { | 3780 | if ( incidence && incidence->typeID() == eventID ) { |
3780 | Event *event = static_cast<Event *>( incidence ); | 3781 | Event *event = static_cast<Event *>( incidence ); |
3781 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3782 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3782 | emit organizerEventsSelected( true ); | 3783 | emit organizerEventsSelected( true ); |
3783 | } else { | 3784 | } else { |
3784 | emit organizerEventsSelected(false); | 3785 | emit organizerEventsSelected(false); |
3785 | } | 3786 | } |
3786 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3787 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3787 | KOPrefs::instance()->email() ) ) { | 3788 | KOPrefs::instance()->email() ) ) { |
3788 | emit groupEventsSelected( true ); | 3789 | emit groupEventsSelected( true ); |
3789 | } else { | 3790 | } else { |
3790 | emit groupEventsSelected(false); | 3791 | emit groupEventsSelected(false); |
3791 | } | 3792 | } |
3792 | return; | 3793 | return; |
3793 | } else { | 3794 | } else { |
3794 | if ( incidence && incidence->typeID() == todoID ) { | 3795 | if ( incidence && incidence->typeID() == todoID ) { |
3795 | emit todoSelected( true ); | 3796 | emit todoSelected( true ); |
3796 | Todo *event = static_cast<Todo *>( incidence ); | 3797 | Todo *event = static_cast<Todo *>( incidence ); |
3797 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3798 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3798 | emit organizerEventsSelected( true ); | 3799 | emit organizerEventsSelected( true ); |
3799 | } else { | 3800 | } else { |
3800 | emit organizerEventsSelected(false); | 3801 | emit organizerEventsSelected(false); |
3801 | } | 3802 | } |
3802 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3803 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3803 | KOPrefs::instance()->email() ) ) { | 3804 | KOPrefs::instance()->email() ) ) { |
3804 | emit groupEventsSelected( true ); | 3805 | emit groupEventsSelected( true ); |
3805 | } else { | 3806 | } else { |
3806 | emit groupEventsSelected(false); | 3807 | emit groupEventsSelected(false); |
3807 | } | 3808 | } |
3808 | return; | 3809 | return; |
3809 | } else { | 3810 | } else { |
3810 | emit todoSelected( false ); | 3811 | emit todoSelected( false ); |
3811 | emit organizerEventsSelected(false); | 3812 | emit organizerEventsSelected(false); |
3812 | emit groupEventsSelected(false); | 3813 | emit groupEventsSelected(false); |
3813 | } | 3814 | } |
3814 | return; | 3815 | return; |
3815 | } | 3816 | } |
3816 | 3817 | ||
3817 | /* if ( incidence && incidence->typeID() == todoID ) { | 3818 | /* if ( incidence && incidence->typeID() == todoID ) { |
3818 | emit todoSelected( true ); | 3819 | emit todoSelected( true ); |
3819 | } else { | 3820 | } else { |
3820 | emit todoSelected( false ); | 3821 | emit todoSelected( false ); |
3821 | }*/ | 3822 | }*/ |
3822 | } | 3823 | } |
3823 | 3824 | ||
3824 | 3825 | ||
3825 | void CalendarView::checkClipboard() | 3826 | void CalendarView::checkClipboard() |
3826 | { | 3827 | { |
3827 | #ifndef KORG_NODND | 3828 | #ifndef KORG_NODND |
3828 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3829 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3829 | emit pasteEnabled(true); | 3830 | emit pasteEnabled(true); |
3830 | } else { | 3831 | } else { |
3831 | emit pasteEnabled(false); | 3832 | emit pasteEnabled(false); |
3832 | } | 3833 | } |
3833 | #endif | 3834 | #endif |
3834 | } | 3835 | } |
3835 | 3836 | ||
3836 | void CalendarView::showDates(const DateList &selectedDates) | 3837 | void CalendarView::showDates(const DateList &selectedDates) |
3837 | { | 3838 | { |
3838 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3839 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3839 | 3840 | ||
3840 | 3841 | ||
3841 | if ( !mBlockShowDates ) { | 3842 | if ( !mBlockShowDates ) { |
3842 | if ( mViewManager->currentView() ) { | 3843 | if ( mViewManager->currentView() ) { |
3843 | updateView( selectedDates.first(), selectedDates.last() ); | 3844 | updateView( selectedDates.first(), selectedDates.last() ); |
3844 | } else { | 3845 | } else { |
3845 | mViewManager->showAgendaView(); | 3846 | mViewManager->showAgendaView(); |
3846 | } | 3847 | } |
3847 | } | 3848 | } |
3848 | 3849 | ||
3849 | QDate date = selectedDates.first(); | 3850 | QDate date = selectedDates.first(); |
3850 | if ( ! date.isValid() ) { | 3851 | if ( ! date.isValid() ) { |
3851 | topLevelWidget()->setCaption(""); | 3852 | topLevelWidget()->setCaption(""); |
3852 | return; | 3853 | return; |
3853 | } | 3854 | } |
3854 | 3855 | ||
3855 | QString selDates; | 3856 | QString selDates; |
3856 | selDates = KGlobal::locale()->formatDate( date, true); | 3857 | selDates = KGlobal::locale()->formatDate( date, true); |
3857 | if (selectedDates.first() < selectedDates.last() ) | 3858 | if (selectedDates.first() < selectedDates.last() ) |
3858 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3859 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3859 | else { | 3860 | else { |
3860 | QString addString; | 3861 | QString addString; |
3861 | if ( date == QDateTime::currentDateTime().date() ) | 3862 | if ( date == QDateTime::currentDateTime().date() ) |
3862 | addString = i18n("Today"); | 3863 | addString = i18n("Today"); |
3863 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 3864 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
3864 | addString = i18n("Tomorrow"); | 3865 | addString = i18n("Tomorrow"); |
3865 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 3866 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
3866 | addString = i18n("Yesterday"); | 3867 | addString = i18n("Yesterday"); |
3867 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 3868 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
3868 | addString = i18n("Day before yesterday"); | 3869 | addString = i18n("Day before yesterday"); |
3869 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 3870 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
3870 | addString = i18n("Day after tomorrow"); | 3871 | addString = i18n("Day after tomorrow"); |
3871 | if ( !addString.isEmpty() ) { | 3872 | if ( !addString.isEmpty() ) { |
3872 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3873 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3873 | return; | 3874 | return; |
3874 | } | 3875 | } |
3875 | } | 3876 | } |
3876 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3877 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3877 | 3878 | ||
3878 | } | 3879 | } |
3879 | 3880 | ||
3880 | QPtrList<CalFilter> CalendarView::filters() | 3881 | QPtrList<CalFilter> CalendarView::filters() |
3881 | { | 3882 | { |
3882 | return mFilters; | 3883 | return mFilters; |
3883 | 3884 | ||
3884 | } | 3885 | } |
3885 | void CalendarView::editFilters() | 3886 | void CalendarView::editFilters() |
3886 | { | 3887 | { |
3887 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3888 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3888 | 3889 | ||
3889 | CalFilter *filter = mFilters.first(); | 3890 | CalFilter *filter = mFilters.first(); |
3890 | while(filter) { | 3891 | while(filter) { |
3891 | kdDebug() << " Filter: " << filter->name() << endl; | 3892 | kdDebug() << " Filter: " << filter->name() << endl; |
3892 | filter = mFilters.next(); | 3893 | filter = mFilters.next(); |
3893 | } | 3894 | } |
3894 | 3895 | ||
3895 | mDialogManager->showFilterEditDialog(&mFilters); | 3896 | mDialogManager->showFilterEditDialog(&mFilters); |
3896 | } | 3897 | } |
3897 | void CalendarView::toggleFilter() | 3898 | void CalendarView::toggleFilter() |
3898 | { | 3899 | { |
3899 | showFilter(! mFilterView->isVisible()); | 3900 | showFilter(! mFilterView->isVisible()); |
3900 | } | 3901 | } |
3901 | 3902 | ||
3902 | KOFilterView *CalendarView::filterView() | 3903 | KOFilterView *CalendarView::filterView() |
3903 | { | 3904 | { |
3904 | return mFilterView; | 3905 | return mFilterView; |
3905 | } | 3906 | } |
3906 | void CalendarView::selectFilter( int fil ) | 3907 | void CalendarView::selectFilter( int fil ) |
3907 | { | 3908 | { |
3908 | mFilterView->setSelectedFilter( fil ); | 3909 | mFilterView->setSelectedFilter( fil ); |
3909 | } | 3910 | } |
3910 | void CalendarView::showFilter(bool visible) | 3911 | void CalendarView::showFilter(bool visible) |
3911 | { | 3912 | { |
3913 | #if 0 | ||
3912 | if (visible) mCalEditView->show(); | 3914 | if (visible) mCalEditView->show(); |
3913 | else mCalEditView->hide(); | 3915 | else mCalEditView->hide(); |
3914 | #if 0 | 3916 | #else |
3915 | if (visible) mFilterView->show(); | 3917 | if (visible) mFilterView->show(); |
3916 | else mFilterView->hide(); | 3918 | else mFilterView->hide(); |
3917 | #endif | 3919 | #endif |
3918 | } | 3920 | } |
3919 | void CalendarView::toggleFilerEnabled( ) | 3921 | void CalendarView::toggleFilerEnabled( ) |
3920 | { | 3922 | { |
3921 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3923 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3922 | if ( !mFilterView->filtersEnabled() ) | 3924 | if ( !mFilterView->filtersEnabled() ) |
3923 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3925 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3924 | 3926 | ||
3925 | } | 3927 | } |
3926 | void CalendarView::updateFilter() | 3928 | void CalendarView::updateFilter() |
3927 | { | 3929 | { |
3928 | CalFilter *filter = mFilterView->selectedFilter(); | 3930 | CalFilter *filter = mFilterView->selectedFilter(); |
3929 | if (filter) { | 3931 | if (filter) { |
3930 | QString mess; | 3932 | QString mess; |
3931 | if (mFilterView->filtersEnabled()) { | 3933 | if (mFilterView->filtersEnabled()) { |
3932 | mess = i18n("Filter selected: ")+filter->name(); | 3934 | mess = i18n("Filter selected: ")+filter->name(); |
3933 | filter->setEnabled(true); | 3935 | filter->setEnabled(true); |
3934 | } | 3936 | } |
3935 | else filter->setEnabled(false); | 3937 | else filter->setEnabled(false); |
3936 | mCalendar->setFilter(filter); | 3938 | mCalendar->setFilter(filter); |
3937 | updateView(); | 3939 | updateView(); |
3938 | if ( !mess.isEmpty() ) | 3940 | if ( !mess.isEmpty() ) |
3939 | topLevelWidget()->setCaption( mess ); | 3941 | topLevelWidget()->setCaption( mess ); |
3940 | 3942 | ||
3941 | } | 3943 | } |
3942 | } | 3944 | } |
3943 | 3945 | ||
3944 | void CalendarView::filterEdited() | 3946 | void CalendarView::filterEdited() |
3945 | { | 3947 | { |
3946 | mFilterView->updateFilters(); | 3948 | mFilterView->updateFilters(); |
3947 | updateFilter(); | 3949 | updateFilter(); |
3948 | writeSettings(); | 3950 | writeSettings(); |
3949 | } | 3951 | } |
3950 | 3952 | ||
3951 | 3953 | ||
3952 | void CalendarView::takeOverEvent() | 3954 | void CalendarView::takeOverEvent() |
3953 | { | 3955 | { |
3954 | Incidence *incidence = currentSelection(); | 3956 | Incidence *incidence = currentSelection(); |
3955 | 3957 | ||
3956 | if (!incidence) return; | 3958 | if (!incidence) return; |
3957 | 3959 | ||
3958 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3960 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3959 | incidence->recreate(); | 3961 | incidence->recreate(); |
3960 | incidence->setReadOnly(false); | 3962 | incidence->setReadOnly(false); |
3961 | 3963 | ||
3962 | updateView(); | 3964 | updateView(); |
3963 | } | 3965 | } |
3964 | 3966 | ||
3965 | void CalendarView::takeOverCalendar() | 3967 | void CalendarView::takeOverCalendar() |
3966 | { | 3968 | { |
3967 | // TODO: Create Calendar::allIncidences() function and use it here | 3969 | // TODO: Create Calendar::allIncidences() function and use it here |
3968 | 3970 | ||
3969 | clearAllViews(); | 3971 | clearAllViews(); |
3970 | QPtrList<Event> events = mCalendar->events(); | 3972 | QPtrList<Event> events = mCalendar->events(); |
3971 | for(uint i=0; i<events.count(); ++i) { | 3973 | for(uint i=0; i<events.count(); ++i) { |
3972 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3974 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3973 | events.at(i)->recreate(); | 3975 | events.at(i)->recreate(); |
3974 | events.at(i)->setReadOnly(false); | 3976 | events.at(i)->setReadOnly(false); |
3975 | } | 3977 | } |
3976 | 3978 | ||
3977 | QPtrList<Todo> todos = mCalendar->todos(); | 3979 | QPtrList<Todo> todos = mCalendar->todos(); |
3978 | for(uint i=0; i<todos.count(); ++i) { | 3980 | for(uint i=0; i<todos.count(); ++i) { |
3979 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3981 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3980 | todos.at(i)->recreate(); | 3982 | todos.at(i)->recreate(); |
3981 | todos.at(i)->setReadOnly(false); | 3983 | todos.at(i)->setReadOnly(false); |
3982 | } | 3984 | } |
3983 | 3985 | ||
3984 | QPtrList<Journal> journals = mCalendar->journals(); | 3986 | QPtrList<Journal> journals = mCalendar->journals(); |
3985 | for(uint i=0; i<journals.count(); ++i) { | 3987 | for(uint i=0; i<journals.count(); ++i) { |
3986 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3988 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3987 | journals.at(i)->recreate(); | 3989 | journals.at(i)->recreate(); |
3988 | journals.at(i)->setReadOnly(false); | 3990 | journals.at(i)->setReadOnly(false); |
3989 | } | 3991 | } |
3990 | 3992 | ||
3991 | updateView(); | 3993 | updateView(); |
3992 | } | 3994 | } |
3993 | 3995 | ||
3994 | void CalendarView::showIntro() | 3996 | void CalendarView::showIntro() |
3995 | { | 3997 | { |
3996 | kdDebug() << "To be implemented." << endl; | 3998 | kdDebug() << "To be implemented." << endl; |
3997 | } | 3999 | } |
3998 | 4000 | ||
3999 | QWidgetStack *CalendarView::viewStack() | 4001 | QWidgetStack *CalendarView::viewStack() |
4000 | { | 4002 | { |
4001 | return mRightFrame; | 4003 | return mRightFrame; |
4002 | } | 4004 | } |
4003 | 4005 | ||
4004 | QWidget *CalendarView::leftFrame() | 4006 | QWidget *CalendarView::leftFrame() |
4005 | { | 4007 | { |
4006 | return ( QWidget *)mLeftFrame; | 4008 | return ( QWidget *)mLeftFrame; |
4007 | } | 4009 | } |
4008 | 4010 | ||
4009 | DateNavigator *CalendarView::dateNavigator() | 4011 | DateNavigator *CalendarView::dateNavigator() |
4010 | { | 4012 | { |
4011 | return mNavigator; | 4013 | return mNavigator; |
4012 | } | 4014 | } |
4013 | 4015 | ||
4014 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4016 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4015 | { | 4017 | { |
4016 | return mDateNavigator->navigatorView(); | 4018 | return mDateNavigator->navigatorView(); |
4017 | } | 4019 | } |
4018 | void CalendarView::toggleDateNavigatorWidget() | 4020 | void CalendarView::toggleDateNavigatorWidget() |
4019 | { | 4021 | { |
4020 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4022 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4021 | 4023 | ||
4022 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4024 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4023 | mDateNavigator->hide(); | 4025 | mDateNavigator->hide(); |
4024 | else | 4026 | else |
4025 | mDateNavigator->show(); | 4027 | mDateNavigator->show(); |
4026 | } | 4028 | } |
4027 | void CalendarView::addView(KOrg::BaseView *view) | 4029 | void CalendarView::addView(KOrg::BaseView *view) |
4028 | { | 4030 | { |
4029 | mViewManager->addView(view); | 4031 | mViewManager->addView(view); |
4030 | } | 4032 | } |
4031 | 4033 | ||
4032 | void CalendarView::showView(KOrg::BaseView *view) | 4034 | void CalendarView::showView(KOrg::BaseView *view) |
4033 | { | 4035 | { |
4034 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4036 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4035 | } | 4037 | } |
4036 | 4038 | ||
4037 | Incidence *CalendarView::currentSelection() | 4039 | Incidence *CalendarView::currentSelection() |
4038 | { | 4040 | { |
4039 | return mViewManager->currentSelection(); | 4041 | return mViewManager->currentSelection(); |
4040 | } | 4042 | } |
4041 | void CalendarView::toggleAllDaySize() | 4043 | void CalendarView::toggleAllDaySize() |
4042 | { | 4044 | { |
4043 | /* | 4045 | /* |
4044 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4046 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4045 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4047 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4046 | else | 4048 | else |
4047 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4049 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4048 | */ | 4050 | */ |
4049 | viewManager()->agendaView()->toggleAllDay(); | 4051 | viewManager()->agendaView()->toggleAllDay(); |
4050 | } | 4052 | } |
4051 | void CalendarView::toggleExpand() | 4053 | void CalendarView::toggleExpand() |
4052 | { | 4054 | { |
4053 | // if ( mLeftFrame->isHidden() ) { | 4055 | // if ( mLeftFrame->isHidden() ) { |
4054 | // mLeftFrame->show(); | 4056 | // mLeftFrame->show(); |
4055 | // emit calendarViewExpanded( false ); | 4057 | // emit calendarViewExpanded( false ); |
4056 | // } else { | 4058 | // } else { |
4057 | // mLeftFrame->hide(); | 4059 | // mLeftFrame->hide(); |
4058 | // emit calendarViewExpanded( true ); | 4060 | // emit calendarViewExpanded( true ); |
4059 | // } | 4061 | // } |
4060 | //qDebug(" CalendarView::toggleExpand()"); | 4062 | //qDebug(" CalendarView::toggleExpand()"); |
4061 | globalFlagBlockAgenda = 1; | 4063 | globalFlagBlockAgenda = 1; |
4062 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4064 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4063 | globalFlagBlockAgenda = 5; | 4065 | globalFlagBlockAgenda = 5; |
4064 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4066 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4065 | //mViewManager->showView( 0, true ); | 4067 | //mViewManager->showView( 0, true ); |
4066 | } | 4068 | } |
4067 | 4069 | ||
4068 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4070 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4069 | { | 4071 | { |
4070 | setModified( modified ); | 4072 | setModified( modified ); |
4071 | } | 4073 | } |
4072 | 4074 | ||
4073 | Todo *CalendarView::selectedTodo() | 4075 | Todo *CalendarView::selectedTodo() |
4074 | { | 4076 | { |
4075 | Incidence *incidence = currentSelection(); | 4077 | Incidence *incidence = currentSelection(); |
4076 | if ( incidence && incidence->typeID() == todoID ) { | 4078 | if ( incidence && incidence->typeID() == todoID ) { |
4077 | return static_cast<Todo *>( incidence ); | 4079 | return static_cast<Todo *>( incidence ); |
4078 | } | 4080 | } |
4079 | 4081 | ||
4080 | incidence = mTodoList->selectedIncidences().first(); | 4082 | incidence = mTodoList->selectedIncidences().first(); |
4081 | if ( incidence && incidence->typeID() == todoID ) { | 4083 | if ( incidence && incidence->typeID() == todoID ) { |
4082 | return static_cast<Todo *>( incidence ); | 4084 | return static_cast<Todo *>( incidence ); |
4083 | } | 4085 | } |
4084 | 4086 | ||
4085 | return 0; | 4087 | return 0; |
4086 | } | 4088 | } |
4087 | 4089 | ||
4088 | void CalendarView::dialogClosing(Incidence *in) | 4090 | void CalendarView::dialogClosing(Incidence *in) |
4089 | { | 4091 | { |
4090 | // mDialogList.remove(in); | 4092 | // mDialogList.remove(in); |
4091 | } | 4093 | } |
4092 | 4094 | ||
4093 | void CalendarView::showIncidence() | 4095 | void CalendarView::showIncidence() |
4094 | { | 4096 | { |
4095 | mViewerCallerIsSearchDialog = false; | 4097 | mViewerCallerIsSearchDialog = false; |
4096 | Incidence *incidence = currentSelection(); | 4098 | Incidence *incidence = currentSelection(); |
4097 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4099 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4098 | if ( incidence ) { | 4100 | if ( incidence ) { |
4099 | ShowIncidenceVisitor v; | 4101 | ShowIncidenceVisitor v; |
4100 | v.act( incidence, this ); | 4102 | v.act( incidence, this ); |
4101 | } | 4103 | } |
4102 | } | 4104 | } |
4103 | void CalendarView::editIncidenceDescription() | 4105 | void CalendarView::editIncidenceDescription() |
4104 | { | 4106 | { |
4105 | mFlagEditDescription = true; | 4107 | mFlagEditDescription = true; |
4106 | editIncidence(); | 4108 | editIncidence(); |
4107 | mFlagEditDescription = false; | 4109 | mFlagEditDescription = false; |
4108 | } | 4110 | } |
4109 | void CalendarView::editIncidence() | 4111 | void CalendarView::editIncidence() |
4110 | { | 4112 | { |
4111 | // qDebug("editIncidence() "); | 4113 | // qDebug("editIncidence() "); |
4112 | Incidence *incidence = currentSelection(); | 4114 | Incidence *incidence = currentSelection(); |
4113 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4115 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4114 | if ( incidence ) { | 4116 | if ( incidence ) { |
4115 | EditIncidenceVisitor v; | 4117 | EditIncidenceVisitor v; |
4116 | v.act( incidence, this ); | 4118 | v.act( incidence, this ); |
4117 | } | 4119 | } |
4118 | } | 4120 | } |
4119 | 4121 | ||
4120 | void CalendarView::deleteIncidence() | 4122 | void CalendarView::deleteIncidence() |
4121 | { | 4123 | { |
4122 | Incidence *incidence = currentSelection(); | 4124 | Incidence *incidence = currentSelection(); |
4123 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4125 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4124 | if ( incidence ) { | 4126 | if ( incidence ) { |
4125 | deleteIncidence(incidence); | 4127 | deleteIncidence(incidence); |
4126 | } | 4128 | } |
4127 | } | 4129 | } |
4128 | void CalendarView::showIncidence(QString uid) | 4130 | void CalendarView::showIncidence(QString uid) |
4129 | { | 4131 | { |
4130 | Incidence *inc = mCalendar->incidence( uid ); | 4132 | Incidence *inc = mCalendar->incidence( uid ); |
4131 | if ( inc ) | 4133 | if ( inc ) |
4132 | showIncidence( inc ); | 4134 | showIncidence( inc ); |
4133 | } | 4135 | } |
4134 | void CalendarView::showIncidence(Incidence *incidence) | 4136 | void CalendarView::showIncidence(Incidence *incidence) |
4135 | { | 4137 | { |
4136 | mViewerCallerIsSearchDialog = false; | 4138 | mViewerCallerIsSearchDialog = false; |
4137 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4139 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4138 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4140 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4139 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4141 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4140 | mViewerCallerIsSearchDialog = true; | 4142 | mViewerCallerIsSearchDialog = true; |
4141 | } | 4143 | } |
4142 | } | 4144 | } |
4143 | if ( incidence ) { | 4145 | if ( incidence ) { |
4144 | ShowIncidenceVisitor v; | 4146 | ShowIncidenceVisitor v; |
4145 | v.act( incidence, this ); | 4147 | v.act( incidence, this ); |
4146 | } | 4148 | } |
4147 | } | 4149 | } |
4148 | 4150 | ||
4149 | void CalendarView::editIncidence(Incidence *incidence) | 4151 | void CalendarView::editIncidence(Incidence *incidence) |
4150 | { | 4152 | { |
4151 | if ( incidence ) { | 4153 | if ( incidence ) { |
4152 | 4154 | ||
4153 | EditIncidenceVisitor v; | 4155 | EditIncidenceVisitor v; |
4154 | v.act( incidence, this ); | 4156 | v.act( incidence, this ); |
4155 | 4157 | ||
4156 | } | 4158 | } |
4157 | } | 4159 | } |
4158 | 4160 | ||
4159 | void CalendarView::deleteIncidence(Incidence *incidence) | 4161 | void CalendarView::deleteIncidence(Incidence *incidence) |
4160 | { | 4162 | { |
4161 | //qDebug(" CalendarView::deleteIncidence "); | 4163 | //qDebug(" CalendarView::deleteIncidence "); |
4162 | if ( incidence ) { | 4164 | if ( incidence ) { |
4163 | DeleteIncidenceVisitor v; | 4165 | DeleteIncidenceVisitor v; |
4164 | v.act( incidence, this ); | 4166 | v.act( incidence, this ); |
4165 | } | 4167 | } |
4166 | } | 4168 | } |
4167 | 4169 | ||
4168 | 4170 | ||
4169 | void CalendarView::lookForOutgoingMessages() | 4171 | void CalendarView::lookForOutgoingMessages() |
4170 | { | 4172 | { |
4171 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4173 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4172 | ogd->loadMessages(); | 4174 | ogd->loadMessages(); |
4173 | } | 4175 | } |
4174 | 4176 | ||
4175 | void CalendarView::lookForIncomingMessages() | 4177 | void CalendarView::lookForIncomingMessages() |
4176 | { | 4178 | { |
4177 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4179 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4178 | icd->retrieve(); | 4180 | icd->retrieve(); |
4179 | } | 4181 | } |
4180 | 4182 | ||
4181 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4183 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4182 | { | 4184 | { |
4183 | bool deleteTodo = true; | 4185 | bool deleteTodo = true; |
4184 | QPtrList<Incidence> subTodos; | 4186 | QPtrList<Incidence> subTodos; |
4185 | Incidence *aTodo; | 4187 | Incidence *aTodo; |
4186 | subTodos = t->relations(); | 4188 | subTodos = t->relations(); |
4187 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4189 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4188 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4190 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4189 | deleteTodo = false; | 4191 | deleteTodo = false; |
4190 | } | 4192 | } |
4191 | if ( deleteTodo ) { | 4193 | if ( deleteTodo ) { |
4192 | if ( t->isCompleted() && !t->doesRecur()) { | 4194 | if ( t->isCompleted() && !t->doesRecur()) { |
4193 | checkExternalId( t ); | 4195 | checkExternalId( t ); |
4194 | mCalendar->deleteTodo( t ); | 4196 | mCalendar->deleteTodo( t ); |
4195 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4197 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4196 | } | 4198 | } |
4197 | else | 4199 | else |
4198 | deleteTodo = false; | 4200 | deleteTodo = false; |
4199 | } | 4201 | } |
4200 | return deleteTodo; | 4202 | return deleteTodo; |
4201 | 4203 | ||
4202 | } | 4204 | } |
4203 | void CalendarView::purgeCompleted() | 4205 | void CalendarView::purgeCompleted() |
4204 | { | 4206 | { |
4205 | int result = KMessageBox::warningContinueCancel(this, | 4207 | int result = KMessageBox::warningContinueCancel(this, |
4206 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4208 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4207 | 4209 | ||
4208 | if (result == KMessageBox::Continue) { | 4210 | if (result == KMessageBox::Continue) { |
4209 | 4211 | ||
4210 | QPtrList<Todo> todoCal; | 4212 | QPtrList<Todo> todoCal; |
4211 | QPtrList<Todo> rootTodos; | 4213 | QPtrList<Todo> rootTodos; |
4212 | //QPtrList<Incidence> rel; | 4214 | //QPtrList<Incidence> rel; |
4213 | Todo *aTodo;//, *rTodo; | 4215 | Todo *aTodo;//, *rTodo; |
4214 | Incidence *rIncidence; | 4216 | Incidence *rIncidence; |
4215 | bool childDelete = false; | 4217 | bool childDelete = false; |
4216 | bool deletedOne = true; | 4218 | bool deletedOne = true; |
4217 | todoCal = calendar()->todos(); | 4219 | todoCal = calendar()->todos(); |
4218 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4220 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4219 | if ( !aTodo->relatedTo() ) | 4221 | if ( !aTodo->relatedTo() ) |
4220 | rootTodos.append( aTodo ); | 4222 | rootTodos.append( aTodo ); |
4221 | } | 4223 | } |
4222 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4224 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4223 | removeCompletedSubTodos( aTodo ); | 4225 | removeCompletedSubTodos( aTodo ); |
4224 | } | 4226 | } |
4225 | 4227 | ||
4226 | updateView(); | 4228 | updateView(); |
4227 | } | 4229 | } |
4228 | } | 4230 | } |
4229 | 4231 | ||
4230 | void CalendarView::slotCalendarChanged() | 4232 | void CalendarView::slotCalendarChanged() |
4231 | { | 4233 | { |
4232 | ; | 4234 | ; |
4233 | } | 4235 | } |
4234 | 4236 | ||
4235 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4237 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4236 | { | 4238 | { |
4237 | //qDebug(" alendarView::keyPressEvent "); | 4239 | //qDebug(" alendarView::keyPressEvent "); |
4238 | e->ignore(); | 4240 | e->ignore(); |
4239 | } | 4241 | } |
4240 | 4242 | ||
4241 | 4243 | ||
4242 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4244 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4243 | { | 4245 | { |
4244 | // mSyncManager = manager; | 4246 | // mSyncManager = manager; |
4245 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4247 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4246 | qDebug("KO: SyncKDE request detected!"); | 4248 | qDebug("KO: SyncKDE request detected!"); |
4247 | } | 4249 | } |
4248 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4250 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4249 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4251 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4250 | return syncCalendar( filename, mode ); | 4252 | return syncCalendar( filename, mode ); |
4251 | } | 4253 | } |
4252 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4254 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4253 | { | 4255 | { |
4254 | //mSyncManager = manager; | 4256 | //mSyncManager = manager; |
4255 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4257 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4256 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4258 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4257 | if ( resource == "sharp" ) | 4259 | if ( resource == "sharp" ) |
4258 | syncExternal( 0 ); | 4260 | syncExternal( 0 ); |
4259 | if ( resource == "phone" ) | 4261 | if ( resource == "phone" ) |
4260 | syncExternal( 1 ); | 4262 | syncExternal( 1 ); |
4261 | // pending setmodified | 4263 | // pending setmodified |
4262 | return true; | 4264 | return true; |
4263 | } | 4265 | } |
4264 | void CalendarView::setSyncManager(KSyncManager* manager) | 4266 | void CalendarView::setSyncManager(KSyncManager* manager) |
4265 | { | 4267 | { |
4266 | mSyncManager = manager; | 4268 | mSyncManager = manager; |
4267 | } | 4269 | } |
4268 | 4270 | ||
4269 | void CalendarView::removeSyncInfo( QString syncProfile) | 4271 | void CalendarView::removeSyncInfo( QString syncProfile) |
4270 | { | 4272 | { |
4271 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4273 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4272 | mCalendar->removeSyncInfo( syncProfile ); | 4274 | mCalendar->removeSyncInfo( syncProfile ); |
4273 | 4275 | ||
4274 | } | 4276 | } |
4275 | 4277 | ||
4276 | void CalendarView::undo_delete() | 4278 | void CalendarView::undo_delete() |
4277 | { | 4279 | { |
4278 | //qDebug("undo_delete() "); | 4280 | //qDebug("undo_delete() "); |
4279 | Incidence* undo = mCalendar->undoIncidence(); | 4281 | Incidence* undo = mCalendar->undoIncidence(); |
4280 | if ( !undo ) { | 4282 | if ( !undo ) { |
4281 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4283 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4282 | i18n("KO/Pi")); | 4284 | i18n("KO/Pi")); |
4283 | return; | 4285 | return; |
4284 | } | 4286 | } |
4285 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 4287 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
4286 | i18n("\nAre you sure you want\nto restore this?"), | 4288 | i18n("\nAre you sure you want\nto restore this?"), |
4287 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4289 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4288 | mCalendar->undoDeleteIncidence(); | 4290 | mCalendar->undoDeleteIncidence(); |
4289 | updateView(); | 4291 | updateView(); |
4290 | } | 4292 | } |
4291 | } | 4293 | } |
4292 | 4294 | ||
4293 | void CalendarView::slotViewerClosed() | 4295 | void CalendarView::slotViewerClosed() |
4294 | { | 4296 | { |
4295 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4297 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4296 | } | 4298 | } |
4297 | 4299 | ||
4298 | void CalendarView::resetFocus() | 4300 | void CalendarView::resetFocus() |
4299 | { | 4301 | { |
4300 | if ( mViewerCallerIsSearchDialog ) { | 4302 | if ( mViewerCallerIsSearchDialog ) { |
4301 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4303 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4302 | mDialogManager->getSearchDialog()->raise(); | 4304 | mDialogManager->getSearchDialog()->raise(); |
4303 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4305 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4304 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4306 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4305 | } else | 4307 | } else |
4306 | mViewerCallerIsSearchDialog = false; | 4308 | mViewerCallerIsSearchDialog = false; |
4307 | } | 4309 | } |
4308 | if ( !mViewerCallerIsSearchDialog ) { | 4310 | if ( !mViewerCallerIsSearchDialog ) { |
4309 | //mViewManager->currentView()->setFocus(); | 4311 | //mViewManager->currentView()->setFocus(); |
4310 | //qDebug("sssssssssssssssset focus "); | 4312 | //qDebug("sssssssssssssssset focus "); |
4311 | topLevelWidget()->raise(); | 4313 | topLevelWidget()->raise(); |
4312 | setActiveWindow(); | 4314 | setActiveWindow(); |
4313 | //setFocus(); | 4315 | //setFocus(); |
4314 | } | 4316 | } |
4315 | mViewerCallerIsSearchDialog = false; | 4317 | mViewerCallerIsSearchDialog = false; |
4316 | } | 4318 | } |
4317 | 4319 | ||
4318 | void CalendarView::showNextAlarms() | 4320 | void CalendarView::showNextAlarms() |
4319 | { | 4321 | { |
4320 | QString message; | 4322 | QString message; |
4321 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4323 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4322 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4324 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4323 | QString sum = mCalendar->nextSummary(); | 4325 | QString sum = mCalendar->nextSummary(); |
4324 | QDateTime nextA = mNextAlarmDateTime; | 4326 | QDateTime nextA = mNextAlarmDateTime; |
4325 | QDateTime cur = QDateTime::currentDateTime(); | 4327 | QDateTime cur = QDateTime::currentDateTime(); |
4326 | int secs = cur.secsTo( nextA ); | 4328 | int secs = cur.secsTo( nextA ); |
4327 | int min = secs /60; | 4329 | int min = secs /60; |
4328 | int hours = min /60; | 4330 | int hours = min /60; |
4329 | min = min % 60; | 4331 | min = min % 60; |
4330 | int days = hours /24; | 4332 | int days = hours /24; |
4331 | hours = hours % 24; | 4333 | hours = hours % 24; |
4332 | 4334 | ||
4333 | //message = i18n("The next alarm is in:\n"); | 4335 | //message = i18n("The next alarm is in:\n"); |
4334 | if ( days > 1 ) | 4336 | if ( days > 1 ) |
4335 | message += i18n("%1 days\n").arg( days ); | 4337 | message += i18n("%1 days\n").arg( days ); |
4336 | else if ( days == 1 ) | 4338 | else if ( days == 1 ) |
4337 | message += i18n("1 day\n"); | 4339 | message += i18n("1 day\n"); |
4338 | if ( hours > 1 ) | 4340 | if ( hours > 1 ) |
4339 | message += i18n("%1 hours\n").arg( hours ); | 4341 | message += i18n("%1 hours\n").arg( hours ); |
4340 | else if ( hours == 1 ) | 4342 | else if ( hours == 1 ) |
4341 | message += i18n("1 hour\n"); | 4343 | message += i18n("1 hour\n"); |
4342 | if ( min > 1 ) | 4344 | if ( min > 1 ) |
4343 | message += i18n("%1 minutes\n").arg( min ); | 4345 | message += i18n("%1 minutes\n").arg( min ); |
4344 | else if ( min == 1 ) | 4346 | else if ( min == 1 ) |
4345 | message += i18n("1 minute\n"); | 4347 | message += i18n("1 minute\n"); |
4346 | if ( message.isEmpty() ) | 4348 | if ( message.isEmpty() ) |
4347 | message = i18n("The next alarm is in\nless than one minute!"); | 4349 | message = i18n("The next alarm is in\nless than one minute!"); |
4348 | else | 4350 | else |
4349 | message = i18n("The next alarm is in:\n") + message; | 4351 | message = i18n("The next alarm is in:\n") + message; |
4350 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4352 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4351 | } else { | 4353 | } else { |
4352 | message = i18n("There is no next alarm."); | 4354 | message = i18n("There is no next alarm."); |
4353 | 4355 | ||
4354 | } | 4356 | } |
4355 | #ifdef DESKTOP_VERSION | 4357 | #ifdef DESKTOP_VERSION |
4356 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4358 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4357 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4359 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4358 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4360 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4359 | } | 4361 | } |
4360 | 4362 | ||
4361 | #endif | 4363 | #endif |
4362 | KMessageBox::information( this, message); | 4364 | KMessageBox::information( this, message); |
4363 | } | 4365 | } |
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index 1bfe4dd..dc6237b 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp | |||
@@ -1,176 +1,176 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | 29 | ||
30 | 30 | ||
31 | #include <libkcal/calfilter.h> | 31 | #include <libkcal/calfilter.h> |
32 | 32 | ||
33 | #include "kofilterview.h" | 33 | #include "kofilterview.h" |
34 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
35 | #include <kglobal.h> | 35 | #include <kglobal.h> |
36 | 36 | ||
37 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, | 37 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, |
38 | const char* name,WFlags fl ) | 38 | const char* name,WFlags fl ) |
39 | : KOFilterView_base(parent,name,fl) | 39 | : KOFilterView_base(parent,name,fl) |
40 | { | 40 | { |
41 | mFilters = filterList; | 41 | mFilters = filterList; |
42 | 42 | ||
43 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); | 43 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); |
44 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); | 44 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); |
45 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); | 45 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); |
46 | } | 46 | } |
47 | 47 | ||
48 | KOFilterView::~KOFilterView() | 48 | KOFilterView::~KOFilterView() |
49 | { | 49 | { |
50 | // no need to delete child widgets, Qt does it all for us | 50 | // no need to delete child widgets, Qt does it all for us |
51 | } | 51 | } |
52 | 52 | ||
53 | bool KOFilterView::filtersEnabled() | 53 | bool KOFilterView::filtersEnabled() |
54 | { | 54 | { |
55 | return mEnabledCheck->isChecked(); | 55 | return mEnabledCheck->isChecked(); |
56 | } | 56 | } |
57 | 57 | ||
58 | void KOFilterView::setFiltersEnabled(bool set) | 58 | void KOFilterView::setFiltersEnabled(bool set) |
59 | { | 59 | { |
60 | mEnabledCheck->setChecked(set); | 60 | mEnabledCheck->setChecked(set); |
61 | emit filterChanged(); | 61 | emit filterChanged(); |
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
65 | void KOFilterView::updateFilters() | 65 | void KOFilterView::updateFilters() |
66 | { | 66 | { |
67 | mSelectionCombo->clear(); | 67 | mSelectionCombo->clear(); |
68 | 68 | ||
69 | CalFilter *filter = mFilters->first(); | 69 | CalFilter *filter = mFilters->first(); |
70 | while(filter) { | 70 | while(filter) { |
71 | mSelectionCombo->insertItem(filter->name()); | 71 | mSelectionCombo->insertItem(filter->name()); |
72 | filter = mFilters->next(); | 72 | filter = mFilters->next(); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | CalFilter *KOFilterView::selectedFilter() | 76 | CalFilter *KOFilterView::selectedFilter() |
77 | { | 77 | { |
78 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); | 78 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); |
79 | return f; | 79 | return f; |
80 | } | 80 | } |
81 | 81 | ||
82 | void KOFilterView::setSelectedFilter(QString filterName) | 82 | void KOFilterView::setSelectedFilter(QString filterName) |
83 | { | 83 | { |
84 | int filter_num = mSelectionCombo->count(); | 84 | int filter_num = mSelectionCombo->count(); |
85 | int i; | 85 | int i; |
86 | for (i=0;i<filter_num;i++) { | 86 | for (i=0;i<filter_num;i++) { |
87 | if (mSelectionCombo->text(i)==filterName) | 87 | if (mSelectionCombo->text(i)==filterName) |
88 | mSelectionCombo->setCurrentItem(i); | 88 | mSelectionCombo->setCurrentItem(i); |
89 | } | 89 | } |
90 | emit filterChanged(); | 90 | emit filterChanged(); |
91 | } | 91 | } |
92 | void KOFilterView::setSelectedFilter( int fil ) | 92 | void KOFilterView::setSelectedFilter( int fil ) |
93 | { | 93 | { |
94 | if ( fil >= mSelectionCombo->count() ) | 94 | if ( fil >= mSelectionCombo->count() ) |
95 | return; | 95 | return; |
96 | mSelectionCombo->setCurrentItem( fil ); | 96 | mSelectionCombo->setCurrentItem( fil ); |
97 | emit filterChanged(); | 97 | emit filterChanged(); |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | 101 | ||
102 | KOCalEditView::KOCalEditView(QWidget* parent, | 102 | KOCalEditView::KOCalEditView(QWidget* parent, |
103 | const char* name ) | 103 | const char* name ) |
104 | : QWidget(parent,name) | 104 | : QWidget(parent,name) |
105 | { | 105 | { |
106 | /* | 106 | /* |
107 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); | 107 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); |
108 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); | 108 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); |
109 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editCalEdits())); | 109 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editCalEdits())); |
110 | */ | 110 | */ |
111 | QGridLayout* mainLayout = new QGridLayout ( this , 2, 6 ); | 111 | QGridLayout* mainLayout = new QGridLayout ( this , 2, 6 ); |
112 | QPushButton * addBut = new QPushButton ( this ); | 112 | QPushButton * addBut = new QPushButton ( this ); |
113 | mainLayout->addWidget( addBut,0,0 ); | 113 | mainLayout->addWidget( addBut,0,0 ); |
114 | addBut->setPixmap ( SmallIcon("plus")); | 114 | addBut->setPixmap ( SmallIcon("plus")); |
115 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); | 115 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); |
116 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 116 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
117 | 117 | ||
118 | addBut = new QPushButton ( this ); | 118 | addBut = new QPushButton ( this ); |
119 | mainLayout->addWidget( addBut,0,1 ); | 119 | mainLayout->addWidget( addBut,0,1 ); |
120 | addBut->setPixmap ( SmallIcon("eye")); | 120 | addBut->setPixmap ( SmallIcon("eye")); |
121 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); | 121 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); |
122 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 122 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
123 | 123 | ||
124 | QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", this ); | 124 | QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", this ); |
125 | mainLayout->addWidget( lab,0,2 ); | 125 | mainLayout->addWidget( lab,0,2 ); |
126 | 126 | ||
127 | addBut = new QPushButton ( this ); | 127 | addBut = new QPushButton ( this ); |
128 | mainLayout->addWidget( addBut,0,3 ); | 128 | mainLayout->addWidget( addBut,0,3 ); |
129 | addBut->setPixmap ( SmallIcon("bell")); | 129 | addBut->setPixmap ( SmallIcon("bell")); |
130 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); | 130 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); |
131 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 131 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
132 | 132 | ||
133 | addBut = new QPushButton ( this ); | 133 | addBut = new QPushButton ( this ); |
134 | mainLayout->addWidget( addBut,0,4 ); | 134 | mainLayout->addWidget( addBut,0,4 ); |
135 | addBut->setPixmap ( SmallIcon("pencil")); | 135 | addBut->setPixmap ( SmallIcon("pencil")); |
136 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); | 136 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); |
137 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 137 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
138 | 138 | ||
139 | addBut = new QPushButton ( this ); | 139 | addBut = new QPushButton ( this ); |
140 | mainLayout->addWidget( addBut,0,5 ); | 140 | mainLayout->addWidget( addBut,0,5 ); |
141 | addBut->setPixmap ( SmallIcon("trash")); | 141 | addBut->setPixmap ( SmallIcon("minus")); |
142 | connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); | 142 | connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); |
143 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 143 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
144 | 144 | ||
145 | 145 | ||
146 | 146 | ||
147 | } | 147 | } |
148 | 148 | ||
149 | KOCalEditView::~KOCalEditView() | 149 | KOCalEditView::~KOCalEditView() |
150 | { | 150 | { |
151 | // no need to delete child widgets, Qt does it all for us | 151 | // no need to delete child widgets, Qt does it all for us |
152 | } | 152 | } |
153 | void KOCalEditView::readConfig( KConfig *) | 153 | void KOCalEditView::readConfig( KConfig *) |
154 | { | 154 | { |
155 | 155 | ||
156 | } | 156 | } |
157 | void KOCalEditView::addCal() | 157 | void KOCalEditView::addCal() |
158 | { | 158 | { |
159 | qDebug("addcal "); | 159 | qDebug("addcal "); |
160 | } | 160 | } |
161 | void KOCalEditView::enableAll() | 161 | void KOCalEditView::enableAll() |
162 | { | 162 | { |
163 | qDebug("enableAll"); | 163 | qDebug("enableAll"); |
164 | } | 164 | } |
165 | void KOCalEditView::enableAlarm() | 165 | void KOCalEditView::enableAlarm() |
166 | { | 166 | { |
167 | qDebug("enableAlarm"); | 167 | qDebug("enableAlarm"); |
168 | } | 168 | } |
169 | void KOCalEditView::disableRO() | 169 | void KOCalEditView::disableRO() |
170 | { | 170 | { |
171 | qDebug("OCalEditView::disableRO() "); | 171 | qDebug("OCalEditView::disableRO() "); |
172 | } | 172 | } |
173 | void KOCalEditView::deleteAll() | 173 | void KOCalEditView::deleteAll() |
174 | { | 174 | { |
175 | qDebug("delteAll"); | 175 | qDebug("delteAll"); |
176 | } | 176 | } |
diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h index d434c52..060108f 100644 --- a/korganizer/kofilterview.h +++ b/korganizer/kofilterview.h | |||
@@ -1,83 +1,133 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOFILTERVIEW_H | 23 | #ifndef KOFILTERVIEW_H |
24 | #define KOFILTERVIEW_H | 24 | #define KOFILTERVIEW_H |
25 | 25 | ||
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qcheckbox.h> | ||
28 | #include <qpushbutton.h> | ||
27 | #include <kconfig.h> | 29 | #include <kconfig.h> |
28 | #include "kofilterview_base.h" | 30 | #include "kofilterview_base.h" |
29 | 31 | ||
30 | #include <libkcal/calfilter.h> | 32 | #include <libkcal/calfilter.h> |
31 | 33 | ||
32 | using namespace KCal; | 34 | using namespace KCal; |
33 | 35 | ||
34 | class KOFilterView : public KOFilterView_base | 36 | class KOFilterView : public KOFilterView_base |
35 | { | 37 | { |
36 | Q_OBJECT | 38 | Q_OBJECT |
37 | public: | 39 | public: |
38 | KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0); | 40 | KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0); |
39 | ~KOFilterView(); | 41 | ~KOFilterView(); |
40 | 42 | ||
41 | void updateFilters(); | 43 | void updateFilters(); |
42 | 44 | ||
43 | bool filtersEnabled(); | 45 | bool filtersEnabled(); |
44 | void setFiltersEnabled(bool); | 46 | void setFiltersEnabled(bool); |
45 | CalFilter *selectedFilter(); | 47 | CalFilter *selectedFilter(); |
46 | void setSelectedFilter(QString); | 48 | void setSelectedFilter(QString); |
47 | void setSelectedFilter( int ); | 49 | void setSelectedFilter( int ); |
48 | 50 | ||
49 | signals: | 51 | signals: |
50 | void filterChanged(); | 52 | void filterChanged(); |
51 | void editFilters(); | 53 | void editFilters(); |
52 | 54 | ||
53 | private: | 55 | private: |
54 | QPtrList<CalFilter> *mFilters; | 56 | QPtrList<CalFilter> *mFilters; |
55 | }; | 57 | }; |
56 | 58 | ||
57 | class KOCalEditView : public QWidget | 59 | class KOCalEditView : public QWidget |
58 | { | 60 | { |
59 | Q_OBJECT | 61 | Q_OBJECT |
60 | public: | 62 | public: |
61 | KOCalEditView( QWidget* parent=0,const char* name=0); | 63 | KOCalEditView( QWidget* parent=0,const char* name=0); |
62 | ~KOCalEditView(); | 64 | ~KOCalEditView(); |
63 | 65 | ||
64 | void readConfig( KConfig *); | 66 | void readConfig( KConfig *); |
65 | public slots: | 67 | public slots: |
66 | void addCal(); | 68 | void addCal(); |
67 | void enableAll(); | 69 | void enableAll(); |
68 | void enableAlarm(); | 70 | void enableAlarm(); |
69 | void disableRO(); | 71 | void disableRO(); |
70 | void deleteAll(); | 72 | void deleteAll(); |
71 | signals: | 73 | signals: |
72 | void alarmEnabled ( int cal, bool enable ); | 74 | void alarmEnabled ( int cal, bool enable ); |
73 | void calendarEnabled ( int cal, bool enable ); | 75 | void calendarEnabled ( int cal, bool enable ); |
74 | void calendarReadonly ( int cal, bool readonly ); | 76 | void calendarReadonly ( int cal, bool readonly ); |
75 | void setCalendarDefault ( int cal ); | 77 | void setCalendarDefault ( int cal ); |
76 | void removeCalendar ( int cal ); | 78 | void removeCalendar ( int cal ); |
77 | 79 | ||
78 | private: | 80 | private: |
79 | }; | 81 | }; |
80 | 82 | ||
83 | class KOCalButton : public QPushButton | ||
84 | { | ||
85 | Q_OBJECT | ||
86 | public: | ||
87 | KOCalButton( QWidget *parent=0, const char *name=0 ) : | ||
88 | QPushButton( parent, name) | ||
89 | { | ||
90 | connect( this, SIGNAL( clicked() ), | ||
91 | SLOT( bottonClicked() )); | ||
92 | mNumber = -1; | ||
93 | } | ||
94 | void setNum ( int num ) {mNumber = num; } | ||
95 | signals: | ||
96 | void selectNum ( int ); | ||
97 | private: | ||
98 | int mNumber; | ||
99 | void keyPressEvent ( QKeyEvent * e ) | ||
100 | { | ||
101 | e->ignore(); | ||
102 | } | ||
103 | |||
104 | private slots : | ||
105 | void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); } | ||
106 | }; | ||
107 | class KOCalCheckButton : public QCheckBox | ||
108 | { | ||
109 | Q_OBJECT | ||
110 | public: | ||
111 | KOCalCheckButton( QWidget *parent=0, const char *name=0 ) : | ||
112 | QCheckBox( parent, name) | ||
113 | { | ||
114 | connect( this, SIGNAL( toggled ( bool ) ), | ||
115 | SLOT( bottonClicked( bool ) )); | ||
116 | mNumber = -1; | ||
117 | } | ||
118 | void setNum ( int num ) {mNumber = num; } | ||
119 | signals: | ||
120 | void selectNum ( int, bool ); | ||
121 | private: | ||
122 | int mNumber; | ||
123 | void keyPressEvent ( QKeyEvent * e ) | ||
124 | { | ||
125 | e->ignore(); | ||
126 | } | ||
127 | |||
128 | private slots : | ||
129 | void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); } | ||
130 | }; | ||
81 | 131 | ||
82 | 132 | ||
83 | #endif // KOFILTERVIEW_H | 133 | #endif // KOFILTERVIEW_H |