-rw-r--r-- | korganizer/calendarview.cpp | 7 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 6 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 2 | ||||
-rw-r--r-- | korganizer/koprefs.h | 2 | ||||
-rw-r--r-- | korganizer/koprefsdialog.cpp | 15 |
5 files changed, 29 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 9928b48..14094bb 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,5150 +1,5157 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "koagenda.h" | 107 | #include "koagenda.h" |
108 | #include "kodialogmanager.h" | 108 | #include "kodialogmanager.h" |
109 | #include "outgoingdialog.h" | 109 | #include "outgoingdialog.h" |
110 | #include "incomingdialog.h" | 110 | #include "incomingdialog.h" |
111 | #include "datenavigatorcontainer.h" | 111 | #include "datenavigatorcontainer.h" |
112 | #include "statusdialog.h" | 112 | #include "statusdialog.h" |
113 | #include "kdatenavigator.h" | 113 | #include "kdatenavigator.h" |
114 | #include "kotodoview.h" | 114 | #include "kotodoview.h" |
115 | #include "datenavigator.h" | 115 | #include "datenavigator.h" |
116 | #include "resourceview.h" | 116 | #include "resourceview.h" |
117 | #include "navigatorbar.h" | 117 | #include "navigatorbar.h" |
118 | #include "searchdialog.h" | 118 | #include "searchdialog.h" |
119 | #include "mainwindow.h" | 119 | #include "mainwindow.h" |
120 | #include "categoryeditdialog.h" | 120 | #include "categoryeditdialog.h" |
121 | 121 | ||
122 | #include "calendarview.h" | 122 | #include "calendarview.h" |
123 | #ifndef DESKTOP_VERSION | 123 | #ifndef DESKTOP_VERSION |
124 | #include <qtopia/alarmserver.h> | 124 | #include <qtopia/alarmserver.h> |
125 | #endif | 125 | #endif |
126 | #ifndef _WIN32_ | 126 | #ifndef _WIN32_ |
127 | #include <stdlib.h> | 127 | #include <stdlib.h> |
128 | #include <stdio.h> | 128 | #include <stdio.h> |
129 | #include <unistd.h> | 129 | #include <unistd.h> |
130 | #else | 130 | #else |
131 | #include <qprocess.h> | 131 | #include <qprocess.h> |
132 | #endif | 132 | #endif |
133 | 133 | ||
134 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
135 | #include <kabc/stdaddressbook.h> | 135 | #include <kabc/stdaddressbook.h> |
136 | #endif | 136 | #endif |
137 | using namespace KOrg; | 137 | using namespace KOrg; |
138 | using namespace KCal; | 138 | using namespace KCal; |
139 | extern int globalFlagBlockAgenda; | 139 | extern int globalFlagBlockAgenda; |
140 | extern int globalFlagBlockStartup; | 140 | extern int globalFlagBlockStartup; |
141 | 141 | ||
142 | 142 | ||
143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
144 | 144 | ||
145 | { | 145 | { |
146 | mAlarms = alarms; | 146 | mAlarms = alarms; |
147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
148 | QString mText = "<table width=\"100%\">\n"; | 148 | QString mText = "<table width=\"100%\">\n"; |
149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
150 | #ifdef DESKTOP_VERSION | 150 | #ifdef DESKTOP_VERSION |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
152 | #else | 152 | #else |
153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
154 | #endif | 154 | #endif |
155 | // mText += "<img src=\""; | 155 | // mText += "<img src=\""; |
156 | // mText += ipath; | 156 | // mText += ipath; |
157 | // mText += "\">"; | 157 | // mText += "\">"; |
158 | //mEventDate = QDate::currentDate(); | 158 | //mEventDate = QDate::currentDate(); |
159 | #ifdef DESKTOP_VERSION | 159 | #ifdef DESKTOP_VERSION |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
161 | #else | 161 | #else |
162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
163 | #endif | 163 | #endif |
164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
165 | 165 | ||
166 | Incidence * inc = getNextInc( start ); | 166 | Incidence * inc = getNextInc( start ); |
167 | int time = 0; | 167 | int time = 0; |
168 | //mText += "<table>"; | 168 | //mText += "<table>"; |
169 | while ( inc ) { | 169 | while ( inc ) { |
170 | QDateTime dt ; | 170 | QDateTime dt ; |
171 | QString tempText = "<a "; | 171 | QString tempText = "<a "; |
172 | bool ok; | 172 | bool ok; |
173 | dt = inc->getNextOccurence( start, &ok ); | 173 | dt = inc->getNextOccurence( start, &ok ); |
174 | if ( !ok ) continue; | 174 | if ( !ok ) continue; |
175 | if ( inc->typeID() == eventID ) { | 175 | if ( inc->typeID() == eventID ) { |
176 | tempText += "href=\"event:"; | 176 | tempText += "href=\"event:"; |
177 | } else if ( inc->typeID() == todoID ) { | 177 | } else if ( inc->typeID() == todoID ) { |
178 | tempText += "href=\"todo:"; | 178 | tempText += "href=\"todo:"; |
179 | } | 179 | } |
180 | tempText += inc->uid() + "\">"; | 180 | tempText += inc->uid() + "\">"; |
181 | if ( inc->typeID() == todoID ) | 181 | if ( inc->typeID() == todoID ) |
182 | tempText += i18n("Todo: "); | 182 | tempText += i18n("Todo: "); |
183 | if ( inc->summary().length() > 0 ) | 183 | if ( inc->summary().length() > 0 ) |
184 | tempText += inc->summary(); | 184 | tempText += inc->summary(); |
185 | else | 185 | else |
186 | tempText += i18n("-no summary-"); | 186 | tempText += i18n("-no summary-"); |
187 | QString timestr; | 187 | QString timestr; |
188 | if (!inc->doesFloat()) | 188 | if (!inc->doesFloat()) |
189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | else | 190 | else |
191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
194 | mText += "<table>"; | 194 | mText += "<table>"; |
195 | time = 1; | 195 | time = 1; |
196 | } | 196 | } |
197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
198 | if ( time > 0 ) | 198 | if ( time > 0 ) |
199 | mText +="</table>"; | 199 | mText +="</table>"; |
200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
201 | mText += "<table>"; | 201 | mText += "<table>"; |
202 | time = 2; | 202 | time = 2; |
203 | 203 | ||
204 | } | 204 | } |
205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
206 | if ( time > 0 ) | 206 | if ( time > 0 ) |
207 | mText +="</table>"; | 207 | mText +="</table>"; |
208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
209 | mText += "<table>"; | 209 | mText += "<table>"; |
210 | time = 3; | 210 | time = 3; |
211 | } | 211 | } |
212 | mText +="<tr><td><b>"; | 212 | mText +="<tr><td><b>"; |
213 | mText += timestr; | 213 | mText += timestr; |
214 | mText += "</b></td><td>"; | 214 | mText += "</b></td><td>"; |
215 | mText += tempText; | 215 | mText += tempText; |
216 | mText += "</td></tr>\n"; | 216 | mText += "</td></tr>\n"; |
217 | inc = getNextInc( start ); | 217 | inc = getNextInc( start ); |
218 | } | 218 | } |
219 | mText +="</table>"; | 219 | mText +="</table>"; |
220 | setText( mText ); | 220 | setText( mText ); |
221 | } | 221 | } |
222 | 222 | ||
223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
224 | { | 224 | { |
225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
226 | } | 226 | } |
227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
228 | { | 228 | { |
229 | QDateTime dt ; | 229 | QDateTime dt ; |
230 | Incidence * retInc; | 230 | Incidence * retInc; |
231 | Incidence * inc = mAlarms.first(); | 231 | Incidence * inc = mAlarms.first(); |
232 | if ( inc == 0 ) | 232 | if ( inc == 0 ) |
233 | return 0; | 233 | return 0; |
234 | bool ok; | 234 | bool ok; |
235 | dt = inc->getNextOccurence( start, &ok ); | 235 | dt = inc->getNextOccurence( start, &ok ); |
236 | if ( ! ok ) return 0; | 236 | if ( ! ok ) return 0; |
237 | QDateTime dtn ; | 237 | QDateTime dtn ; |
238 | retInc = inc; | 238 | retInc = inc; |
239 | inc = mAlarms.next(); | 239 | inc = mAlarms.next(); |
240 | while ( inc ) { | 240 | while ( inc ) { |
241 | dtn = inc->getNextOccurence( start, &ok ); | 241 | dtn = inc->getNextOccurence( start, &ok ); |
242 | if ( ! ok ) return 0; | 242 | if ( ! ok ) return 0; |
243 | if ( dtn < dt ) { | 243 | if ( dtn < dt ) { |
244 | dt = dtn; | 244 | dt = dtn; |
245 | retInc = inc; | 245 | retInc = inc; |
246 | } | 246 | } |
247 | inc = mAlarms.next(); | 247 | inc = mAlarms.next(); |
248 | } | 248 | } |
249 | mAlarms.remove( retInc ); | 249 | mAlarms.remove( retInc ); |
250 | return retInc; | 250 | return retInc; |
251 | 251 | ||
252 | } | 252 | } |
253 | void MissedAlarmTextBrowser::setSource(const QString & n) | 253 | void MissedAlarmTextBrowser::setSource(const QString & n) |
254 | { | 254 | { |
255 | if (n.startsWith("event:")) { | 255 | if (n.startsWith("event:")) { |
256 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
257 | emit showIncidence(n.mid(8)); | 257 | emit showIncidence(n.mid(8)); |
258 | #else | 258 | #else |
259 | emit showIncidence(n.mid(6)); | 259 | emit showIncidence(n.mid(6)); |
260 | #endif | 260 | #endif |
261 | return; | 261 | return; |
262 | } else if (n.startsWith("todo:")) { | 262 | } else if (n.startsWith("todo:")) { |
263 | #ifdef DESKTOP_VERSION | 263 | #ifdef DESKTOP_VERSION |
264 | emit showIncidence(n.mid(7)); | 264 | emit showIncidence(n.mid(7)); |
265 | #else | 265 | #else |
266 | emit showIncidence(n.mid(5)); | 266 | emit showIncidence(n.mid(5)); |
267 | #endif | 267 | #endif |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | class KOBeamPrefs : public QDialog | 273 | class KOBeamPrefs : public QDialog |
274 | { | 274 | { |
275 | public: | 275 | public: |
276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
277 | QDialog( parent, name, true ) | 277 | QDialog( parent, name, true ) |
278 | { | 278 | { |
279 | setCaption( i18n("Beam Options") ); | 279 | setCaption( i18n("Beam Options") ); |
280 | QVBoxLayout* lay = new QVBoxLayout( this ); | 280 | QVBoxLayout* lay = new QVBoxLayout( this ); |
281 | lay->setSpacing( 3 ); | 281 | lay->setSpacing( 3 ); |
282 | lay->setMargin( 3 ); | 282 | lay->setMargin( 3 ); |
283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
284 | lay->addWidget( format ); | 284 | lay->addWidget( format ); |
285 | format->setExclusive ( true ) ; | 285 | format->setExclusive ( true ) ; |
286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
287 | lay->addWidget( time ); time->setExclusive ( true ) ; | 287 | lay->addWidget( time ); time->setExclusive ( true ) ; |
288 | vcal = new QRadioButton(" vCalendar ", format ); | 288 | vcal = new QRadioButton(" vCalendar ", format ); |
289 | ical = new QRadioButton(" iCalendar ", format ); | 289 | ical = new QRadioButton(" iCalendar ", format ); |
290 | vcal->setChecked( true ); | 290 | vcal->setChecked( true ); |
291 | tz = new QRadioButton(i18n(" With timezone "), time ); | 291 | tz = new QRadioButton(i18n(" With timezone "), time ); |
292 | local = new QRadioButton(i18n(" Local time "), time ); | 292 | local = new QRadioButton(i18n(" Local time "), time ); |
293 | tz->setChecked( true ); | 293 | tz->setChecked( true ); |
294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
295 | lay->addWidget( ok ); | 295 | lay->addWidget( ok ); |
296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
297 | lay->addWidget( cancel ); | 297 | lay->addWidget( cancel ); |
298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
300 | resize( 200, 200 ); | 300 | resize( 200, 200 ); |
301 | } | 301 | } |
302 | 302 | ||
303 | bool beamVcal() { return vcal->isChecked(); } | 303 | bool beamVcal() { return vcal->isChecked(); } |
304 | bool beamLocal() { return local->isChecked(); } | 304 | bool beamLocal() { return local->isChecked(); } |
305 | private: | 305 | private: |
306 | QRadioButton* vcal, *ical, *local, *tz; | 306 | QRadioButton* vcal, *ical, *local, *tz; |
307 | }; | 307 | }; |
308 | class KOCatPrefs : public QDialog | 308 | class KOCatPrefs : public QDialog |
309 | { | 309 | { |
310 | public: | 310 | public: |
311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
312 | QDialog( parent, name, true ) | 312 | QDialog( parent, name, true ) |
313 | { | 313 | { |
314 | setCaption( i18n("Manage new Categories") ); | 314 | setCaption( i18n("Manage new Categories") ); |
315 | QVBoxLayout* lay = new QVBoxLayout( this ); | 315 | QVBoxLayout* lay = new QVBoxLayout( this ); |
316 | lay->setSpacing( 3 ); | 316 | lay->setSpacing( 3 ); |
317 | lay->setMargin( 3 ); | 317 | lay->setMargin( 3 ); |
318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); | 318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); |
319 | lay->addWidget( lab ); | 319 | lay->addWidget( lab ); |
320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
321 | lay->addWidget( format ); | 321 | lay->addWidget( format ); |
322 | format->setExclusive ( true ) ; | 322 | format->setExclusive ( true ) ; |
323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
325 | addCatBut->setChecked( true ); | 325 | addCatBut->setChecked( true ); |
326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
327 | lay->addWidget( ok ); | 327 | lay->addWidget( ok ); |
328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
329 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
332 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
333 | } | 333 | } |
334 | 334 | ||
335 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
336 | private: | 336 | private: |
337 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | 340 | ||
341 | 341 | ||
342 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
343 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
344 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
345 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
346 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
347 | { | 347 | { |
348 | 348 | ||
349 | mEventEditor = 0; | 349 | mEventEditor = 0; |
350 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
351 | 351 | ||
352 | init(); | 352 | init(); |
353 | } | 353 | } |
354 | 354 | ||
355 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
356 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
357 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
358 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
359 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
360 | { | 360 | { |
361 | 361 | ||
362 | mEventEditor = 0; | 362 | mEventEditor = 0; |
363 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
364 | init(); | 364 | init(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void CalendarView::init() | 367 | void CalendarView::init() |
368 | { | 368 | { |
369 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 369 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
370 | setFocusPolicy (NoFocus ); | 370 | setFocusPolicy (NoFocus ); |
371 | mViewerCallerIsSearchDialog = false; | 371 | mViewerCallerIsSearchDialog = false; |
372 | mBlockShowDates = false; | 372 | mBlockShowDates = false; |
373 | mConflictingEvent = 0; | 373 | mConflictingEvent = 0; |
374 | mDatePickerMode = 0; | 374 | mDatePickerMode = 0; |
375 | mCurrentSyncDevice = ""; | 375 | mCurrentSyncDevice = ""; |
376 | mViewManager = new KOViewManager( this ); | 376 | mViewManager = new KOViewManager( this ); |
377 | mDialogManager = new KODialogManager( this ); | 377 | mDialogManager = new KODialogManager( this ); |
378 | mEventViewerDialog = 0; | 378 | mEventViewerDialog = 0; |
379 | mModified = false; | 379 | mModified = false; |
380 | mReadOnly = false; | 380 | mReadOnly = false; |
381 | mSelectedIncidence = 0; | 381 | mSelectedIncidence = 0; |
382 | mCalPrinter = 0; | 382 | mCalPrinter = 0; |
383 | mFilters.setAutoDelete(true); | 383 | mFilters.setAutoDelete(true); |
384 | 384 | ||
385 | mCalendar->registerObserver( this ); | 385 | mCalendar->registerObserver( this ); |
386 | // TODO: Make sure that view is updated, when calendar is changed. | 386 | // TODO: Make sure that view is updated, when calendar is changed. |
387 | 387 | ||
388 | mStorage = new FileStorage( mCalendar ); | 388 | mStorage = new FileStorage( mCalendar ); |
389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
390 | 390 | ||
391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
392 | #ifndef KORG_NOSPLITTER | 392 | #ifndef KORG_NOSPLITTER |
393 | // create the main layout frames. | 393 | // create the main layout frames. |
394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
395 | topLayout->addWidget(mPanner); | 395 | topLayout->addWidget(mPanner); |
396 | 396 | ||
397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
398 | "CalendarView::LeftFrame"); | 398 | "CalendarView::LeftFrame"); |
399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
400 | 400 | ||
401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
402 | "CalendarView::DateNavigator" ); | 402 | "CalendarView::DateNavigator" ); |
403 | 403 | ||
404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
406 | mTodoList->setNavigator( mNavigator ); | 406 | mTodoList->setNavigator( mNavigator ); |
407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
408 | 408 | ||
409 | #ifdef KORG_NORESOURCEVIEW | 409 | #ifdef KORG_NORESOURCEVIEW |
410 | mResourceView = 0; | 410 | mResourceView = 0; |
411 | #else | 411 | #else |
412 | if ( mResourceManager ) { | 412 | if ( mResourceManager ) { |
413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
414 | mResourceView->updateView(); | 414 | mResourceView->updateView(); |
415 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 415 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
416 | SLOT( updateView() ) ); | 416 | SLOT( updateView() ) ); |
417 | } else { | 417 | } else { |
418 | mResourceView = 0; | 418 | mResourceView = 0; |
419 | } | 419 | } |
420 | #endif | 420 | #endif |
421 | QWidget *rightBox = new QWidget( mPanner ); | 421 | QWidget *rightBox = new QWidget( mPanner ); |
422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
423 | 423 | ||
424 | mRightFrame = new QWidgetStack( rightBox ); | 424 | mRightFrame = new QWidgetStack( rightBox ); |
425 | rightLayout->addWidget( mRightFrame, 1 ); | 425 | rightLayout->addWidget( mRightFrame, 1 ); |
426 | 426 | ||
427 | mLeftFrame = mLeftSplitter; | 427 | mLeftFrame = mLeftSplitter; |
428 | #else | 428 | #else |
429 | //QWidget *mainBox = new QWidget( this ); | 429 | //QWidget *mainBox = new QWidget( this ); |
430 | //QWidget *leftFrame = new QWidget( mainBox ); | 430 | //QWidget *leftFrame = new QWidget( mainBox ); |
431 | //QBoxLayout * mainBoxLayout; | 431 | //QBoxLayout * mainBoxLayout; |
432 | if ( KOPrefs::instance()->mVerticalScreen ) { | 432 | if ( KOPrefs::instance()->mVerticalScreen ) { |
433 | //mainBoxLayout = new QVBoxLayout(mainBox); | 433 | //mainBoxLayout = new QVBoxLayout(mainBox); |
434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
439 | } else { | 439 | } else { |
440 | //mainBoxLayout = new QHBoxLayout(mainBox); | 440 | //mainBoxLayout = new QHBoxLayout(mainBox); |
441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
446 | } | 446 | } |
447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
448 | //QBoxLayout * leftFrameLayout; | 448 | //QBoxLayout * leftFrameLayout; |
449 | topLayout->addWidget( mMainFrame ); | 449 | topLayout->addWidget( mMainFrame ); |
450 | #ifdef DESKTOP_VERSION | 450 | #ifdef DESKTOP_VERSION |
451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
452 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
454 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
455 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
456 | #endif | 456 | #endif |
457 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
459 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
460 | #if 0 | 460 | #if 0 |
461 | // FIXME | 461 | // FIXME |
462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
463 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
464 | #endif | 464 | #endif |
465 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
466 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
480 | 480 | ||
481 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
482 | #if 0 | 482 | #if 0 |
483 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
484 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
485 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
486 | 486 | ||
487 | } else { | 487 | } else { |
488 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
489 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
490 | } | 490 | } |
491 | #endif | 491 | #endif |
492 | mFilterView->hide(); | 492 | mFilterView->hide(); |
493 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
494 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
495 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
497 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
498 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
499 | 499 | ||
500 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
501 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
506 | } else { | 506 | } else { |
507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
510 | } | 510 | } |
511 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
512 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
513 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
517 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
518 | 518 | ||
519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
521 | 521 | ||
522 | 522 | ||
523 | 523 | ||
524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
529 | 529 | ||
530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
531 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
532 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
533 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
535 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
537 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
538 | 538 | ||
539 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
540 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
541 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
542 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
545 | 545 | ||
546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
548 | #if 0 | 548 | #if 0 |
549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
550 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
551 | #endif | 551 | #endif |
552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
553 | 553 | ||
554 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
555 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
558 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
560 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
562 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
564 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
566 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
569 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
571 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
572 | 572 | ||
573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
576 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
577 | 577 | ||
578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
579 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
581 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
582 | 582 | ||
583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
584 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
585 | 585 | ||
586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
589 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
592 | 592 | ||
593 | 593 | ||
594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | 602 | ||
603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
604 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
606 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
608 | 608 | ||
609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
610 | 610 | ||
611 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
614 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
615 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
616 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
618 | 618 | ||
619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
620 | 620 | ||
621 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
622 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
623 | 623 | ||
624 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
625 | 625 | ||
626 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
627 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
628 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
632 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
634 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
636 | 636 | ||
637 | 637 | ||
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
642 | #endif | 642 | #endif |
643 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
648 | { | 648 | { |
649 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
650 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
651 | delete mDialogManager; | 651 | delete mDialogManager; |
652 | delete mViewManager; | 652 | delete mViewManager; |
653 | delete mStorage; | 653 | delete mStorage; |
654 | delete mDateFrame ; | 654 | delete mDateFrame ; |
655 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
656 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
657 | } | 657 | } |
658 | 658 | ||
659 | 659 | ||
660 | void CalendarView::nextConflict( bool all, bool allday ) | 660 | void CalendarView::nextConflict( bool all, bool allday ) |
661 | { | 661 | { |
662 | static bool block = false; | 662 | static bool block = false; |
663 | if ( block ) return; | 663 | if ( block ) return; |
664 | block = true; | 664 | block = true; |
665 | QPtrList<Event> testlist = mCalendar->events(); | 665 | QPtrList<Event> testlist = mCalendar->events(); |
666 | Event * test = testlist.first(); | 666 | Event * test = testlist.first(); |
667 | while ( test ) { | 667 | while ( test ) { |
668 | test->setTagged( false ); | 668 | test->setTagged( false ); |
669 | test = testlist.next(); | 669 | test = testlist.next(); |
670 | } | 670 | } |
671 | QTime st ( 0,0,0); | 671 | QTime st ( 0,0,0); |
672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
673 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 673 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
674 | //qDebug("time %s ", st.toString().latin1()); | 674 | //qDebug("time %s ", st.toString().latin1()); |
675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
676 | QDateTime conflict; | 676 | QDateTime conflict; |
677 | QDateTime retVal; | 677 | QDateTime retVal; |
678 | bool found = false; | 678 | bool found = false; |
679 | Event * cE = 0; | 679 | Event * cE = 0; |
680 | Event * cE2 = 0; | 680 | Event * cE2 = 0; |
681 | QPtrList<Event> testlist2 = testlist; | 681 | QPtrList<Event> testlist2 = testlist; |
682 | test = testlist.first(); | 682 | test = testlist.first(); |
683 | bool skip = false; | 683 | bool skip = false; |
684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
685 | //QTime tm; | 685 | //QTime tm; |
686 | //tm.start(); | 686 | //tm.start(); |
687 | while ( test ) { | 687 | while ( test ) { |
688 | qApp->processEvents(); | 688 | qApp->processEvents(); |
689 | skip = false; | 689 | skip = false; |
690 | if ( !all ) skip = ( allday != test->doesFloat() ); | 690 | if ( !all ) skip = ( allday != test->doesFloat() ); |
691 | if ( !skip ) { | 691 | if ( !skip ) { |
692 | if ( found ) | 692 | if ( found ) |
693 | skip = !test->matchTime( &startDT, &conflict ); | 693 | skip = !test->matchTime( &startDT, &conflict ); |
694 | else | 694 | else |
695 | skip = !test->matchTime( &startDT, 0 ); | 695 | skip = !test->matchTime( &startDT, 0 ); |
696 | } | 696 | } |
697 | if ( !skip ) { | 697 | if ( !skip ) { |
698 | Event * test2 = testlist2.first(); | 698 | Event * test2 = testlist2.first(); |
699 | while ( test2 ) { | 699 | while ( test2 ) { |
700 | skip = test2->isTagged(); | 700 | skip = test2->isTagged(); |
701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); | 701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); |
702 | if ( !skip ) { | 702 | if ( !skip ) { |
703 | if ( found ) | 703 | if ( found ) |
704 | skip = !test2->matchTime( &startDT, &conflict ); | 704 | skip = !test2->matchTime( &startDT, &conflict ); |
705 | else | 705 | else |
706 | skip = !test2->matchTime( &startDT, 0 ); | 706 | skip = !test2->matchTime( &startDT, 0 ); |
707 | } | 707 | } |
708 | if ( !skip ) { | 708 | if ( !skip ) { |
709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
710 | //qDebug("overlap "); | 710 | //qDebug("overlap "); |
711 | if ( ! found ) { | 711 | if ( ! found ) { |
712 | if ( retVal >= startDT ) { | 712 | if ( retVal >= startDT ) { |
713 | conflict = retVal; | 713 | conflict = retVal; |
714 | cE = test; | 714 | cE = test; |
715 | cE2 = test2; | 715 | cE2 = test2; |
716 | found = true; | 716 | found = true; |
717 | } | 717 | } |
718 | } else { | 718 | } else { |
719 | if ( retVal >= startDT && retVal < conflict ) { | 719 | if ( retVal >= startDT && retVal < conflict ) { |
720 | conflict = retVal; | 720 | conflict = retVal; |
721 | cE = test; | 721 | cE = test; |
722 | cE2 = test2; | 722 | cE2 = test2; |
723 | } | 723 | } |
724 | } | 724 | } |
725 | } | 725 | } |
726 | } | 726 | } |
727 | test2 = testlist2.next(); | 727 | test2 = testlist2.next(); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | test->setTagged( true ); | 730 | test->setTagged( true ); |
731 | test = testlist.next(); | 731 | test = testlist.next(); |
732 | } | 732 | } |
733 | //qDebug("Search time : %d", tm.elapsed()); | 733 | //qDebug("Search time : %d", tm.elapsed()); |
734 | if ( found ) { | 734 | if ( found ) { |
735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
736 | mViewManager->showDayView(); | 736 | mViewManager->showDayView(); |
737 | mNavigator->slotDaySelect( conflict.date() ); | 737 | mNavigator->slotDaySelect( conflict.date() ); |
738 | int hour = conflict.time().hour(); | 738 | int hour = conflict.time().hour(); |
739 | mViewManager->agendaView()->setStartHour( hour ); | 739 | mViewManager->agendaView()->setStartHour( hour ); |
740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
741 | block = false; | 741 | block = false; |
742 | return; | 742 | return; |
743 | } | 743 | } |
744 | 744 | ||
745 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 745 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
746 | //qDebug("No conflict found "); | 746 | //qDebug("No conflict found "); |
747 | block = false; | 747 | block = false; |
748 | return; | 748 | return; |
749 | } | 749 | } |
750 | 750 | ||
751 | void CalendarView::conflictAll() | 751 | void CalendarView::conflictAll() |
752 | { | 752 | { |
753 | nextConflict ( true, true ); | 753 | nextConflict ( true, true ); |
754 | } | 754 | } |
755 | void CalendarView::conflictAllday() | 755 | void CalendarView::conflictAllday() |
756 | { | 756 | { |
757 | nextConflict ( false, true ); | 757 | nextConflict ( false, true ); |
758 | } | 758 | } |
759 | void CalendarView::conflictNotAll() | 759 | void CalendarView::conflictNotAll() |
760 | { | 760 | { |
761 | nextConflict ( false, false ); | 761 | nextConflict ( false, false ); |
762 | } | 762 | } |
763 | 763 | ||
764 | void CalendarView::setCalReadOnly( int id, bool readO ) | 764 | void CalendarView::setCalReadOnly( int id, bool readO ) |
765 | { | 765 | { |
766 | if ( readO ) { | 766 | if ( readO ) { |
767 | emit save(); | 767 | emit save(); |
768 | } | 768 | } |
769 | mCalendar->setReadOnly( id, readO ); | 769 | mCalendar->setReadOnly( id, readO ); |
770 | } | 770 | } |
771 | void CalendarView::setScrollBarStep(int val ) | 771 | void CalendarView::setScrollBarStep(int val ) |
772 | { | 772 | { |
773 | #ifdef DESKTOP_VERSION | 773 | #ifdef DESKTOP_VERSION |
774 | mDateScrollBar->setLineStep ( val ); | 774 | mDateScrollBar->setLineStep ( val ); |
775 | #endif | 775 | #endif |
776 | } | 776 | } |
777 | void CalendarView::scrollBarValue(int val ) | 777 | void CalendarView::scrollBarValue(int val ) |
778 | { | 778 | { |
779 | #ifdef DESKTOP_VERSION | 779 | #ifdef DESKTOP_VERSION |
780 | if ( QApplication::desktop()->width() < 800 ) return; | 780 | if ( QApplication::desktop()->width() < 800 ) return; |
781 | static bool block = false; | 781 | static bool block = false; |
782 | if ( block ) return; | 782 | if ( block ) return; |
783 | block = true; | 783 | block = true; |
784 | int count = mNavigator->selectedDates().count(); | 784 | int count = mNavigator->selectedDates().count(); |
785 | int day = mNavigator->selectedDates().first().dayOfYear(); | 785 | int day = mNavigator->selectedDates().first().dayOfYear(); |
786 | int stepdays = val; | 786 | int stepdays = val; |
787 | if ( mDateScrollBar->lineStep () <= count ) { | 787 | if ( mDateScrollBar->lineStep () <= count ) { |
788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
789 | //qDebug("VAL %d ",val ); | 789 | //qDebug("VAL %d ",val ); |
790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
791 | stepdays = day+stepdays; | 791 | stepdays = day+stepdays; |
792 | if ( stepdays < 0 ) stepdays = 0; | 792 | if ( stepdays < 0 ) stepdays = 0; |
793 | } | 793 | } |
794 | if ( stepdays == day ) { | 794 | if ( stepdays == day ) { |
795 | block = false; | 795 | block = false; |
796 | return; | 796 | return; |
797 | } | 797 | } |
798 | int year = mNavigator->selectedDates().first().year(); | 798 | int year = mNavigator->selectedDates().first().year(); |
799 | QDate d ( year,1,1 ); | 799 | QDate d ( year,1,1 ); |
800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
801 | block = false; | 801 | block = false; |
802 | #endif | 802 | #endif |
803 | 803 | ||
804 | } | 804 | } |
805 | void CalendarView::updateView(const QDate &start, const QDate &end) | 805 | void CalendarView::updateView(const QDate &start, const QDate &end) |
806 | { | 806 | { |
807 | #ifdef DESKTOP_VERSION | 807 | #ifdef DESKTOP_VERSION |
808 | if ( ! mDateScrollBar->draggingSlider () ) { | 808 | if ( ! mDateScrollBar->draggingSlider () ) { |
809 | int dof = start.dayOfYear(); | 809 | int dof = start.dayOfYear(); |
810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
811 | if ( dof != mDateScrollBar->value() ) { | 811 | if ( dof != mDateScrollBar->value() ) { |
812 | mDateScrollBar->blockSignals( true ); | 812 | mDateScrollBar->blockSignals( true ); |
813 | mDateScrollBar->setValue( start.dayOfYear()); | 813 | mDateScrollBar->setValue( start.dayOfYear()); |
814 | mDateScrollBar->blockSignals( false ); | 814 | mDateScrollBar->blockSignals( false ); |
815 | } | 815 | } |
816 | } | 816 | } |
817 | #endif | 817 | #endif |
818 | mTodoList->updateView(); | 818 | mTodoList->updateView(); |
819 | mViewManager->updateView(start, end); | 819 | mViewManager->updateView(start, end); |
820 | //mDateNavigator->updateView(); | 820 | //mDateNavigator->updateView(); |
821 | } | 821 | } |
822 | 822 | ||
823 | 823 | ||
824 | 824 | ||
825 | void CalendarView::checkFiles() | 825 | void CalendarView::checkFiles() |
826 | { | 826 | { |
827 | QString message; | 827 | QString message; |
828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
829 | KopiCalendarFile * cal = calendars.first(); | 829 | KopiCalendarFile * cal = calendars.first(); |
830 | while ( cal ) { | 830 | while ( cal ) { |
831 | if ( cal->mErrorOnLoad ) { | 831 | if ( cal->mErrorOnLoad ) { |
832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
833 | } | 833 | } |
834 | cal = calendars.next(); | 834 | cal = calendars.next(); |
835 | } | 835 | } |
836 | if ( !message.isEmpty() ) { | 836 | if ( !message.isEmpty() ) { |
837 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); | 837 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
838 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); | 838 | KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); |
839 | } | 839 | } |
840 | static bool firstTime = true; | 840 | static bool firstTime = true; |
841 | if ( firstTime ) { | 841 | if ( firstTime ) { |
842 | firstTime = false; | 842 | firstTime = false; |
843 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 843 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
844 | } | 844 | } |
845 | } | 845 | } |
846 | void CalendarView::checkAlarms() | 846 | void CalendarView::checkAlarms() |
847 | { | 847 | { |
848 | KConfig *config = KOGlobals::config(); | 848 | KConfig *config = KOGlobals::config(); |
849 | config->setGroup( "AppRun" ); | 849 | config->setGroup( "AppRun" ); |
850 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 850 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
851 | int daysto = dt.daysTo( QDate::currentDate() ); | 851 | int daysto = dt.daysTo( QDate::currentDate() ); |
852 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 852 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
853 | dt = dt.addDays( days ); | 853 | dt = dt.addDays( days ); |
854 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 854 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
855 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 855 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
856 | //qDebug("KO: Reading program stop %d ", secs); | 856 | //qDebug("KO: Reading program stop %d ", secs); |
857 | //secs -= ( 3600 * 24*3 ); // debug only | 857 | //secs -= ( 3600 * 24*3 ); // debug only |
858 | QDateTime latest = dt.addSecs ( secs ); | 858 | QDateTime latest = dt.addSecs ( secs ); |
859 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 859 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
860 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 860 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
861 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 861 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
862 | QPtrList<Incidence> al; | 862 | QPtrList<Incidence> al; |
863 | Incidence* inL = el.first(); | 863 | Incidence* inL = el.first(); |
864 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 864 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
865 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 865 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
866 | while ( inL ) { | 866 | while ( inL ) { |
867 | bool ok = false; | 867 | bool ok = false; |
868 | int offset = 0; | 868 | int offset = 0; |
869 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 869 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
870 | if ( ok ) { | 870 | if ( ok ) { |
871 | //qDebug("OK %s",next.toString().latin1()); | 871 | //qDebug("OK %s",next.toString().latin1()); |
872 | if ( next < cur ) { | 872 | if ( next < cur ) { |
873 | al.append( inL ); | 873 | al.append( inL ); |
874 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 874 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
875 | } | 875 | } |
876 | } | 876 | } |
877 | inL = el.next(); | 877 | inL = el.next(); |
878 | } | 878 | } |
879 | if ( al.count() ) { | 879 | if ( al.count() ) { |
880 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 880 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
881 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 881 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
882 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 882 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
883 | lay->setSpacing( 0 ); | 883 | lay->setSpacing( 0 ); |
884 | lay->setMargin( 0 ); | 884 | lay->setMargin( 0 ); |
885 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 885 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
886 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 886 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
887 | lay->addWidget( matb ); | 887 | lay->addWidget( matb ); |
888 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 888 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
889 | int wid = 210; | 889 | int wid = 210; |
890 | int x = QApplication::desktop()->width() - wid - 7; | 890 | int x = QApplication::desktop()->width() - wid - 7; |
891 | int y = QApplication::desktop()->height() - wid - 70; | 891 | int y = QApplication::desktop()->height() - wid - 70; |
892 | dia->setGeometry ( x,y,wid,wid); | 892 | dia->setGeometry ( x,y,wid,wid); |
893 | } else { | 893 | } else { |
894 | int si = 220; | 894 | int si = 220; |
895 | if ( QApplication::desktop()->width() > 470 ) | 895 | if ( QApplication::desktop()->width() > 470 ) |
896 | si = 400; | 896 | si = 400; |
897 | dia->resize(si,si/2); | 897 | dia->resize(si,si/2); |
898 | } | 898 | } |
899 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 899 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
900 | dia->show(); | 900 | dia->show(); |
901 | 901 | ||
902 | } | 902 | } |
903 | #if 0 | 903 | #if 0 |
904 | // for creating timetracker test data | 904 | // for creating timetracker test data |
905 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); | 905 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); |
906 | Todo * nt; | 906 | Todo * nt; |
907 | mCalendar->close(); | 907 | mCalendar->close(); |
908 | { | 908 | { |
909 | Todo * root1 = new Todo; | 909 | Todo * root1 = new Todo; |
910 | mCalendar->addTodo( root1 ); | 910 | mCalendar->addTodo( root1 ); |
911 | root1->setSummary( "Project1"); | 911 | root1->setSummary( "Project1"); |
912 | root1->setPriority( 1 ); | 912 | root1->setPriority( 1 ); |
913 | root1->setCategories( QString( "Cat_Pro1") ); | 913 | root1->setCategories( QString( "Cat_Pro1") ); |
914 | root1->setDescription( "This is a test description of a root Project" ); | 914 | root1->setDescription( "This is a test description of a root Project" ); |
915 | root1->setPercentComplete( 20 ); | 915 | root1->setPercentComplete( 20 ); |
916 | updateView(); | 916 | updateView(); |
917 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 917 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
918 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 918 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
919 | 919 | ||
920 | nt = new Todo; | 920 | nt = new Todo; |
921 | mCalendar->addTodo( nt ); | 921 | mCalendar->addTodo( nt ); |
922 | nt->setSummary( "Planning Project1"); | 922 | nt->setSummary( "Planning Project1"); |
923 | nt->setPriority( 1 ); | 923 | nt->setPriority( 1 ); |
924 | nt->setDescription( "This is a test description of Planning Project1" ); | 924 | nt->setDescription( "This is a test description of Planning Project1" ); |
925 | nt->setPercentComplete( 20 ); | 925 | nt->setPercentComplete( 20 ); |
926 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); | 926 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); |
927 | 927 | ||
928 | 928 | ||
929 | Todo * sub1 = nt; | 929 | Todo * sub1 = nt; |
930 | sub1->setRelatedTo( root1 ); | 930 | sub1->setRelatedTo( root1 ); |
931 | 931 | ||
932 | nt = new Todo; | 932 | nt = new Todo; |
933 | mCalendar->addTodo( nt ); | 933 | mCalendar->addTodo( nt ); |
934 | nt->setSummary( "Planning Project1: Lutz"); | 934 | nt->setSummary( "Planning Project1: Lutz"); |
935 | nt->setPriority( 1 ); | 935 | nt->setPriority( 1 ); |
936 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 936 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
937 | nt->setPercentComplete( 20 ); | 937 | nt->setPercentComplete( 20 ); |
938 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); | 938 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); |
939 | Todo * workLutz11 = nt; | 939 | Todo * workLutz11 = nt; |
940 | workLutz11->setRelatedTo( sub1 ); | 940 | workLutz11->setRelatedTo( sub1 ); |
941 | 941 | ||
942 | nt = new Todo; | 942 | nt = new Todo; |
943 | mCalendar->addTodo( nt ); | 943 | mCalendar->addTodo( nt ); |
944 | nt->setSummary( "Planning Project1: Norbert"); | 944 | nt->setSummary( "Planning Project1: Norbert"); |
945 | nt->setPriority( 1 ); | 945 | nt->setPriority( 1 ); |
946 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 946 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
947 | nt->setPercentComplete( 20 ); | 947 | nt->setPercentComplete( 20 ); |
948 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); | 948 | nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); |
949 | Todo * workNorbert11 = nt; | 949 | Todo * workNorbert11 = nt; |
950 | workNorbert11->setRelatedTo( sub1 ); | 950 | workNorbert11->setRelatedTo( sub1 ); |
951 | 951 | ||
952 | nt = new Todo; | 952 | nt = new Todo; |
953 | mCalendar->addTodo( nt ); | 953 | mCalendar->addTodo( nt ); |
954 | nt->setSummary( "Work on 1"); | 954 | nt->setSummary( "Work on 1"); |
955 | nt->setPriority( 1 ); | 955 | nt->setPriority( 1 ); |
956 | nt->setDescription( "This is a test description of Work Project_1" ); | 956 | nt->setDescription( "This is a test description of Work Project_1" ); |
957 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); | 957 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); |
958 | nt->setPercentComplete( 20 ); | 958 | nt->setPercentComplete( 20 ); |
959 | 959 | ||
960 | Todo * sub2 = nt; | 960 | Todo * sub2 = nt; |
961 | sub2->setRelatedTo( root1 ); | 961 | sub2->setRelatedTo( root1 ); |
962 | 962 | ||
963 | 963 | ||
964 | nt = new Todo; | 964 | nt = new Todo; |
965 | mCalendar->addTodo( nt ); | 965 | mCalendar->addTodo( nt ); |
966 | nt->setSummary( "Work on 1: Lutz"); | 966 | nt->setSummary( "Work on 1: Lutz"); |
967 | nt->setPriority( 1 ); | 967 | nt->setPriority( 1 ); |
968 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 968 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
969 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); | 969 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); |
970 | nt->setPercentComplete( 20 ); | 970 | nt->setPercentComplete( 20 ); |
971 | Todo * workLutz12 = nt; | 971 | Todo * workLutz12 = nt; |
972 | workLutz12->setRelatedTo( sub2 ); | 972 | workLutz12->setRelatedTo( sub2 ); |
973 | 973 | ||
974 | nt = new Todo; | 974 | nt = new Todo; |
975 | mCalendar->addTodo( nt ); | 975 | mCalendar->addTodo( nt ); |
976 | nt->setSummary( "Work on 1: Norbert"); | 976 | nt->setSummary( "Work on 1: Norbert"); |
977 | nt->setPriority( 1 ); | 977 | nt->setPriority( 1 ); |
978 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 978 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
979 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); | 979 | nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); |
980 | nt->setPercentComplete( 20 ); | 980 | nt->setPercentComplete( 20 ); |
981 | Todo * workNorbert12 = nt; | 981 | Todo * workNorbert12 = nt; |
982 | workNorbert12->setRelatedTo( sub2 ); | 982 | workNorbert12->setRelatedTo( sub2 ); |
983 | 983 | ||
984 | int secLenRunning = 7200; | 984 | int secLenRunning = 7200; |
985 | int secLenPausing = 3600 * 3; | 985 | int secLenPausing = 3600 * 3; |
986 | int dayInterval = 1; | 986 | int dayInterval = 1; |
987 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); | 987 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); |
988 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); | 988 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); |
989 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); | 989 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); |
990 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); | 990 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); |
991 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); | 991 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); |
992 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); | 992 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); |
993 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); | 993 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); |
994 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); | 994 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); |
995 | 995 | ||
996 | } | 996 | } |
997 | 997 | ||
998 | { | 998 | { |
999 | Todo * root1 = new Todo; | 999 | Todo * root1 = new Todo; |
1000 | mCalendar->addTodo( root1 ); | 1000 | mCalendar->addTodo( root1 ); |
1001 | root1->setSummary( "Project2"); | 1001 | root1->setSummary( "Project2"); |
1002 | root1->setPriority( 1 ); | 1002 | root1->setPriority( 1 ); |
1003 | root1->setDescription( "This is a test description of a root Project 2" ); | 1003 | root1->setDescription( "This is a test description of a root Project 2" ); |
1004 | root1->setPercentComplete( 20 ); | 1004 | root1->setPercentComplete( 20 ); |
1005 | root1->setCategories( QString( "Cat_Pro2") ); | 1005 | root1->setCategories( QString( "Cat_Pro2") ); |
1006 | updateView(); | 1006 | updateView(); |
1007 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 1007 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
1008 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); | 1008 | QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); |
1009 | int secLenRunning = 7200; | 1009 | int secLenRunning = 7200; |
1010 | int secLenPausing = 3600 * 3; | 1010 | int secLenPausing = 3600 * 3; |
1011 | int dayInterval = 1; | 1011 | int dayInterval = 1; |
1012 | 1012 | ||
1013 | nt = new Todo; | 1013 | nt = new Todo; |
1014 | mCalendar->addTodo( nt ); | 1014 | mCalendar->addTodo( nt ); |
1015 | nt->setSummary( "Planning Project2"); | 1015 | nt->setSummary( "Planning Project2"); |
1016 | nt->setPriority( 1 ); | 1016 | nt->setPriority( 1 ); |
1017 | nt->setDescription( "This is a test description of Planning_Project_2" ); | 1017 | nt->setDescription( "This is a test description of Planning_Project_2" ); |
1018 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); | 1018 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); |
1019 | nt->setPercentComplete( 20 ); | 1019 | nt->setPercentComplete( 20 ); |
1020 | 1020 | ||
1021 | 1021 | ||
1022 | Todo * sub1 = nt; | 1022 | Todo * sub1 = nt; |
1023 | sub1->setRelatedTo( root1 ); | 1023 | sub1->setRelatedTo( root1 ); |
1024 | 1024 | ||
1025 | nt = new Todo; | 1025 | nt = new Todo; |
1026 | mCalendar->addTodo( nt ); | 1026 | mCalendar->addTodo( nt ); |
1027 | nt->setSummary( "Planning Project2: Lutz"); | 1027 | nt->setSummary( "Planning Project2: Lutz"); |
1028 | nt->setPriority( 1 ); | 1028 | nt->setPriority( 1 ); |
1029 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1029 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1030 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); | 1030 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); |
1031 | nt->setPercentComplete( 20 ); | 1031 | nt->setPercentComplete( 20 ); |
1032 | Todo * workLutz11 = nt; | 1032 | Todo * workLutz11 = nt; |
1033 | workLutz11->setRelatedTo( sub1 ); | 1033 | workLutz11->setRelatedTo( sub1 ); |
1034 | 1034 | ||
1035 | nt = new Todo; | 1035 | nt = new Todo; |
1036 | mCalendar->addTodo( nt ); | 1036 | mCalendar->addTodo( nt ); |
1037 | nt->setSummary( "Planning Project2: Norbert"); | 1037 | nt->setSummary( "Planning Project2: Norbert"); |
1038 | nt->setPriority( 1 ); | 1038 | nt->setPriority( 1 ); |
1039 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1039 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1040 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); | 1040 | nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); |
1041 | nt->setPercentComplete( 20 ); | 1041 | nt->setPercentComplete( 20 ); |
1042 | Todo * workNorbert11 = nt; | 1042 | Todo * workNorbert11 = nt; |
1043 | workNorbert11->setRelatedTo( sub1 ); | 1043 | workNorbert11->setRelatedTo( sub1 ); |
1044 | 1044 | ||
1045 | nt = new Todo; | 1045 | nt = new Todo; |
1046 | mCalendar->addTodo( nt ); | 1046 | mCalendar->addTodo( nt ); |
1047 | nt->setSummary( "Work on 2"); | 1047 | nt->setSummary( "Work on 2"); |
1048 | nt->setPriority( 1 ); | 1048 | nt->setPriority( 1 ); |
1049 | nt->setDescription( "This is a test description of Work Project_2" ); | 1049 | nt->setDescription( "This is a test description of Work Project_2" ); |
1050 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); | 1050 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); |
1051 | nt->setPercentComplete( 20 ); | 1051 | nt->setPercentComplete( 20 ); |
1052 | 1052 | ||
1053 | Todo * sub2 = nt; | 1053 | Todo * sub2 = nt; |
1054 | sub2->setRelatedTo( root1 ); | 1054 | sub2->setRelatedTo( root1 ); |
1055 | 1055 | ||
1056 | 1056 | ||
1057 | nt = new Todo; | 1057 | nt = new Todo; |
1058 | mCalendar->addTodo( nt ); | 1058 | mCalendar->addTodo( nt ); |
1059 | nt->setSummary( "Work on 2: Lutz"); | 1059 | nt->setSummary( "Work on 2: Lutz"); |
1060 | nt->setPriority( 1 ); | 1060 | nt->setPriority( 1 ); |
1061 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1061 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1062 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); | 1062 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); |
1063 | nt->setPercentComplete( 20 ); | 1063 | nt->setPercentComplete( 20 ); |
1064 | Todo * workLutz12 = nt; | 1064 | Todo * workLutz12 = nt; |
1065 | workLutz12->setRelatedTo( sub2 ); | 1065 | workLutz12->setRelatedTo( sub2 ); |
1066 | 1066 | ||
1067 | nt = new Todo; | 1067 | nt = new Todo; |
1068 | mCalendar->addTodo( nt ); | 1068 | mCalendar->addTodo( nt ); |
1069 | nt->setSummary( "Work on 2: Norbert"); | 1069 | nt->setSummary( "Work on 2: Norbert"); |
1070 | nt->setPriority( 1 ); | 1070 | nt->setPriority( 1 ); |
1071 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1071 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1072 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); | 1072 | nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); |
1073 | nt->setPercentComplete( 20 ); | 1073 | nt->setPercentComplete( 20 ); |
1074 | Todo * workNorbert12 = nt; | 1074 | Todo * workNorbert12 = nt; |
1075 | workNorbert12->setRelatedTo( sub2 ); | 1075 | workNorbert12->setRelatedTo( sub2 ); |
1076 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); | 1076 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); |
1077 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); | 1077 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); |
1078 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); | 1078 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); |
1079 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); | 1079 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); |
1080 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); | 1080 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); |
1081 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); | 1081 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); |
1082 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); | 1082 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); |
1083 | } | 1083 | } |
1084 | updateView(); | 1084 | updateView(); |
1085 | #endif | 1085 | #endif |
1086 | 1086 | ||
1087 | } | 1087 | } |
1088 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) | 1088 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) |
1089 | { | 1089 | { |
1090 | static int ccc = 0; | 1090 | static int ccc = 0; |
1091 | ++ccc; | 1091 | ++ccc; |
1092 | QDateTime t_start = start; | 1092 | QDateTime t_start = start; |
1093 | runT->setPriority( 5 ); | 1093 | runT->setPriority( 5 ); |
1094 | runT->setPercentComplete( 0 ); | 1094 | runT->setPercentComplete( 0 ); |
1095 | int count = 0; | 1095 | int count = 0; |
1096 | int prio = 5; | 1096 | int prio = 5; |
1097 | int complete = 0; | 1097 | int complete = 0; |
1098 | while ( t_start < end ) { | 1098 | while ( t_start < end ) { |
1099 | ++count; | 1099 | ++count; |
1100 | if ( count > ccc ) { | 1100 | if ( count > ccc ) { |
1101 | count = 0; | 1101 | count = 0; |
1102 | --prio; | 1102 | --prio; |
1103 | if ( prio == 0 ) prio = 5; | 1103 | if ( prio == 0 ) prio = 5; |
1104 | complete += 20; | 1104 | complete += 20; |
1105 | if ( complete > 100 ) complete = 0; | 1105 | if ( complete > 100 ) complete = 0; |
1106 | runT->setPriority( prio ); | 1106 | runT->setPriority( prio ); |
1107 | runT->setPercentComplete( complete ); | 1107 | runT->setPercentComplete( complete ); |
1108 | } | 1108 | } |
1109 | runT->setRunning( true ); | 1109 | runT->setRunning( true ); |
1110 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); | 1110 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); |
1111 | if ( dayInterval ) | 1111 | if ( dayInterval ) |
1112 | t_start = t_start.addDays( dayInterval ); | 1112 | t_start = t_start.addDays( dayInterval ); |
1113 | else { | 1113 | else { |
1114 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); | 1114 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | void CalendarView::showDay( QDate d ) | 1119 | void CalendarView::showDay( QDate d ) |
1120 | { | 1120 | { |
1121 | dateNavigator()->blockSignals( true ); | 1121 | dateNavigator()->blockSignals( true ); |
1122 | dateNavigator()->selectDate( d ); | 1122 | dateNavigator()->selectDate( d ); |
1123 | dateNavigator()->blockSignals( false ); | 1123 | dateNavigator()->blockSignals( false ); |
1124 | mViewManager->showDayView(); | 1124 | mViewManager->showDayView(); |
1125 | //dateNavigator()->selectDate( d ); | 1125 | //dateNavigator()->selectDate( d ); |
1126 | } | 1126 | } |
1127 | void CalendarView::timerAlarm() | 1127 | void CalendarView::timerAlarm() |
1128 | { | 1128 | { |
1129 | //qDebug("CalendarView::timerAlarm() "); | 1129 | //qDebug("CalendarView::timerAlarm() "); |
1130 | computeAlarm(mAlarmNotification ); | 1130 | computeAlarm(mAlarmNotification ); |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | void CalendarView::suspendAlarm() | 1133 | void CalendarView::suspendAlarm() |
1134 | { | 1134 | { |
1135 | //qDebug(" CalendarView::suspendAlarm() "); | 1135 | //qDebug(" CalendarView::suspendAlarm() "); |
1136 | computeAlarm(mSuspendAlarmNotification ); | 1136 | computeAlarm(mSuspendAlarmNotification ); |
1137 | 1137 | ||
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | void CalendarView::startAlarm( QString mess , QString filename) | 1140 | void CalendarView::startAlarm( QString mess , QString filename) |
1141 | { | 1141 | { |
1142 | 1142 | ||
1143 | topLevelWidget()->showNormal(); | 1143 | topLevelWidget()->showNormal(); |
1144 | topLevelWidget()->setActiveWindow(); | 1144 | topLevelWidget()->setActiveWindow(); |
1145 | topLevelWidget()->raise(); | 1145 | topLevelWidget()->raise(); |
1146 | 1146 | ||
1147 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 1147 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
1148 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 1148 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
1149 | 1149 | ||
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | void CalendarView::checkNextTimerAlarm() | 1152 | void CalendarView::checkNextTimerAlarm() |
1153 | { | 1153 | { |
1154 | mCalendar->checkAlarmForIncidence( 0, true ); | 1154 | mCalendar->checkAlarmForIncidence( 0, true ); |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | void CalendarView::computeAlarm( QString msg ) | 1157 | void CalendarView::computeAlarm( QString msg ) |
1158 | { | 1158 | { |
1159 | 1159 | ||
1160 | QString mess = msg; | 1160 | QString mess = msg; |
1161 | QString mAlarmMessage = mess.mid( 9 ); | 1161 | QString mAlarmMessage = mess.mid( 9 ); |
1162 | QString filename = MainWindow::resourcePath(); | 1162 | QString filename = MainWindow::resourcePath(); |
1163 | filename += "koalarm.wav"; | 1163 | filename += "koalarm.wav"; |
1164 | QString tempfilename; | 1164 | QString tempfilename; |
1165 | if ( mess.left( 13 ) == "suspend_alarm") { | 1165 | if ( mess.left( 13 ) == "suspend_alarm") { |
1166 | bool error = false; | 1166 | bool error = false; |
1167 | int len = mess.mid( 13 ).find("+++"); | 1167 | int len = mess.mid( 13 ).find("+++"); |
1168 | if ( len < 2 ) | 1168 | if ( len < 2 ) |
1169 | error = true; | 1169 | error = true; |
1170 | else { | 1170 | else { |
1171 | tempfilename = mess.mid( 13, len ); | 1171 | tempfilename = mess.mid( 13, len ); |
1172 | if ( !QFile::exists( tempfilename ) ) | 1172 | if ( !QFile::exists( tempfilename ) ) |
1173 | error = true; | 1173 | error = true; |
1174 | } | 1174 | } |
1175 | if ( ! error ) { | 1175 | if ( ! error ) { |
1176 | filename = tempfilename; | 1176 | filename = tempfilename; |
1177 | } | 1177 | } |
1178 | mAlarmMessage = mess.mid( 13+len+3 ); | 1178 | mAlarmMessage = mess.mid( 13+len+3 ); |
1179 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 1179 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
1180 | startAlarm( mAlarmMessage, filename); | 1180 | startAlarm( mAlarmMessage, filename); |
1181 | return; | 1181 | return; |
1182 | } | 1182 | } |
1183 | if ( mess.left( 11 ) == "timer_alarm") { | 1183 | if ( mess.left( 11 ) == "timer_alarm") { |
1184 | //mTimerTime = 0; | 1184 | //mTimerTime = 0; |
1185 | startAlarm( mess.mid( 11 ), filename ); | 1185 | startAlarm( mess.mid( 11 ), filename ); |
1186 | return; | 1186 | return; |
1187 | } | 1187 | } |
1188 | if ( mess.left( 10 ) == "proc_alarm") { | 1188 | if ( mess.left( 10 ) == "proc_alarm") { |
1189 | bool error = false; | 1189 | bool error = false; |
1190 | int len = mess.mid( 10 ).find("+++"); | 1190 | int len = mess.mid( 10 ).find("+++"); |
1191 | if ( len < 2 ) | 1191 | if ( len < 2 ) |
1192 | error = true; | 1192 | error = true; |
1193 | else { | 1193 | else { |
1194 | tempfilename = mess.mid( 10, len ); | 1194 | tempfilename = mess.mid( 10, len ); |
1195 | if ( !QFile::exists( tempfilename ) ) | 1195 | if ( !QFile::exists( tempfilename ) ) |
1196 | error = true; | 1196 | error = true; |
1197 | } | 1197 | } |
1198 | if ( error ) { | 1198 | if ( error ) { |
1199 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 1199 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1200 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 1200 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1201 | } else { | 1201 | } else { |
1202 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 1202 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1203 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 1203 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1204 | #ifndef _WIN32_ | 1204 | #ifndef _WIN32_ |
1205 | if ( vfork () == 0 ) { | 1205 | if ( vfork () == 0 ) { |
1206 | execl ( tempfilename.latin1(), 0 ); | 1206 | execl ( tempfilename.latin1(), 0 ); |
1207 | return; | 1207 | return; |
1208 | } | 1208 | } |
1209 | #else | 1209 | #else |
1210 | QProcess* p = new QProcess(); | 1210 | QProcess* p = new QProcess(); |
1211 | p->addArgument( tempfilename.latin1() ); | 1211 | p->addArgument( tempfilename.latin1() ); |
1212 | p->start(); | 1212 | p->start(); |
1213 | return; | 1213 | return; |
1214 | #endif | 1214 | #endif |
1215 | 1215 | ||
1216 | return; | 1216 | return; |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1219 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1220 | } | 1220 | } |
1221 | if ( mess.left( 11 ) == "audio_alarm") { | 1221 | if ( mess.left( 11 ) == "audio_alarm") { |
1222 | bool error = false; | 1222 | bool error = false; |
1223 | int len = mess.mid( 11 ).find("+++"); | 1223 | int len = mess.mid( 11 ).find("+++"); |
1224 | if ( len < 2 ) | 1224 | if ( len < 2 ) |
1225 | error = true; | 1225 | error = true; |
1226 | else { | 1226 | else { |
1227 | tempfilename = mess.mid( 11, len ); | 1227 | tempfilename = mess.mid( 11, len ); |
1228 | if ( !QFile::exists( tempfilename ) ) | 1228 | if ( !QFile::exists( tempfilename ) ) |
1229 | error = true; | 1229 | error = true; |
1230 | } | 1230 | } |
1231 | if ( ! error ) { | 1231 | if ( ! error ) { |
1232 | filename = tempfilename; | 1232 | filename = tempfilename; |
1233 | } | 1233 | } |
1234 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1234 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1235 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1235 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1236 | } | 1236 | } |
1237 | if ( mess.left( 9 ) == "cal_alarm") { | 1237 | if ( mess.left( 9 ) == "cal_alarm") { |
1238 | mAlarmMessage = mess.mid( 9 ) ; | 1238 | mAlarmMessage = mess.mid( 9 ) ; |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | startAlarm( mAlarmMessage, filename ); | 1241 | startAlarm( mAlarmMessage, filename ); |
1242 | 1242 | ||
1243 | 1243 | ||
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1246 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1247 | { | 1247 | { |
1248 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1248 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1249 | 1249 | ||
1250 | mSuspendAlarmNotification = noti; | 1250 | mSuspendAlarmNotification = noti; |
1251 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1251 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1252 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1252 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1253 | mSuspendTimer->start( ms , true ); | 1253 | mSuspendTimer->start( ms , true ); |
1254 | #ifdef DESKTOP_VERSION | 1254 | #ifdef DESKTOP_VERSION |
1255 | if ( QApplication::desktop()->width() < 1024 ) { | 1255 | if ( QApplication::desktop()->width() < 1024 ) { |
1256 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1256 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1257 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); | 1257 | //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); |
1258 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; | 1258 | QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; |
1259 | QFile file( fn ); | 1259 | QFile file( fn ); |
1260 | if (!file.open( IO_WriteOnly ) ) { | 1260 | if (!file.open( IO_WriteOnly ) ) { |
1261 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1261 | qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1262 | } else { | 1262 | } else { |
1263 | QTextStream ts( &file ); | 1263 | QTextStream ts( &file ); |
1264 | ts << mess; | 1264 | ts << mess; |
1265 | file.close(); | 1265 | file.close(); |
1266 | } | 1266 | } |
1267 | } | 1267 | } |
1268 | #endif | 1268 | #endif |
1269 | 1269 | ||
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1272 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1273 | { | 1273 | { |
1274 | mNextAlarmDateTime = qdt; | 1274 | mNextAlarmDateTime = qdt; |
1275 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1275 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1276 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1276 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1277 | #ifndef DESKTOP_VERSION | 1277 | #ifndef DESKTOP_VERSION |
1278 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1278 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1279 | #endif | 1279 | #endif |
1280 | return; | 1280 | return; |
1281 | } | 1281 | } |
1282 | #ifdef DESKTOP_VERSION | 1282 | #ifdef DESKTOP_VERSION |
1283 | if ( QApplication::desktop()->width() < 1024 ) { | 1283 | if ( QApplication::desktop()->width() < 1024 ) { |
1284 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; | 1284 | QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; |
1285 | //qDebug("nextalarm = \n%s ",mess.latin1() ); | 1285 | //qDebug("nextalarm = \n%s ",mess.latin1() ); |
1286 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; | 1286 | QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; |
1287 | QFile file( fn ); | 1287 | QFile file( fn ); |
1288 | if (!file.open( IO_WriteOnly ) ) { | 1288 | if (!file.open( IO_WriteOnly ) ) { |
1289 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); | 1289 | qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); |
1290 | } else { | 1290 | } else { |
1291 | QTextStream ts( &file ); | 1291 | QTextStream ts( &file ); |
1292 | ts << mess; | 1292 | ts << mess; |
1293 | file.close(); | 1293 | file.close(); |
1294 | } | 1294 | } |
1295 | } | 1295 | } |
1296 | #endif | 1296 | #endif |
1297 | int maxSec; | 1297 | int maxSec; |
1298 | //maxSec = 5; //testing only | 1298 | //maxSec = 5; //testing only |
1299 | maxSec = 86400+3600; // one day+1hour | 1299 | maxSec = 86400+3600; // one day+1hour |
1300 | mAlarmNotification = noti; | 1300 | mAlarmNotification = noti; |
1301 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1301 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1302 | if ( sec > maxSec ) { | 1302 | if ( sec > maxSec ) { |
1303 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1303 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1304 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1304 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1305 | return; | 1305 | return; |
1306 | } else { | 1306 | } else { |
1307 | mRecheckAlarmTimer->stop(); | 1307 | mRecheckAlarmTimer->stop(); |
1308 | } | 1308 | } |
1309 | //qDebug("Alarm timer started with secs: %d ", sec); | 1309 | //qDebug("Alarm timer started with secs: %d ", sec); |
1310 | mAlarmTimer->start( sec * 1000 , true ); | 1310 | mAlarmTimer->start( sec * 1000 , true ); |
1311 | 1311 | ||
1312 | } | 1312 | } |
1313 | // called by mRecheckAlarmTimer to get next alarm | 1313 | // called by mRecheckAlarmTimer to get next alarm |
1314 | // we need this, because a QTimer has only a max range of 25 days | 1314 | // we need this, because a QTimer has only a max range of 25 days |
1315 | void CalendarView::recheckTimerAlarm() | 1315 | void CalendarView::recheckTimerAlarm() |
1316 | { | 1316 | { |
1317 | mAlarmTimer->stop(); | 1317 | mAlarmTimer->stop(); |
1318 | mRecheckAlarmTimer->stop(); | 1318 | mRecheckAlarmTimer->stop(); |
1319 | mCalendar->checkAlarmForIncidence( 0, true ); | 1319 | mCalendar->checkAlarmForIncidence( 0, true ); |
1320 | } | 1320 | } |
1321 | #ifndef DESKTOP_VERSION | 1321 | #ifndef DESKTOP_VERSION |
1322 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1322 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1323 | #else | 1323 | #else |
1324 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1324 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1325 | #endif | 1325 | #endif |
1326 | { | 1326 | { |
1327 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1327 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1328 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1328 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1329 | #ifndef DESKTOP_VERSION | 1329 | #ifndef DESKTOP_VERSION |
1330 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1330 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1331 | #endif | 1331 | #endif |
1332 | return; | 1332 | return; |
1333 | } | 1333 | } |
1334 | mAlarmTimer->stop(); | 1334 | mAlarmTimer->stop(); |
1335 | } | 1335 | } |
1336 | void CalendarView::selectWeekNum ( int num ) | 1336 | void CalendarView::selectWeekNum ( int num ) |
1337 | { | 1337 | { |
1338 | dateNavigator()->blockSignals( true ); | 1338 | dateNavigator()->blockSignals( true ); |
1339 | dateNavigator()->selectWeek( num ); | 1339 | dateNavigator()->selectWeek( num ); |
1340 | dateNavigator()->blockSignals( false ); | 1340 | dateNavigator()->blockSignals( false ); |
1341 | mViewManager->showWeekView(); | 1341 | mViewManager->showWeekView(); |
1342 | } | 1342 | } |
1343 | KOViewManager *CalendarView::viewManager() | 1343 | KOViewManager *CalendarView::viewManager() |
1344 | { | 1344 | { |
1345 | return mViewManager; | 1345 | return mViewManager; |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | KODialogManager *CalendarView::dialogManager() | 1348 | KODialogManager *CalendarView::dialogManager() |
1349 | { | 1349 | { |
1350 | return mDialogManager; | 1350 | return mDialogManager; |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | QDate CalendarView::startDate() | 1353 | QDate CalendarView::startDate() |
1354 | { | 1354 | { |
1355 | DateList dates = mNavigator->selectedDates(); | 1355 | DateList dates = mNavigator->selectedDates(); |
1356 | 1356 | ||
1357 | return dates.first(); | 1357 | return dates.first(); |
1358 | } | 1358 | } |
1359 | 1359 | ||
1360 | QDate CalendarView::endDate() | 1360 | QDate CalendarView::endDate() |
1361 | { | 1361 | { |
1362 | DateList dates = mNavigator->selectedDates(); | 1362 | DateList dates = mNavigator->selectedDates(); |
1363 | 1363 | ||
1364 | return dates.last(); | 1364 | return dates.last(); |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | 1367 | ||
1368 | void CalendarView::createPrinter() | 1368 | void CalendarView::createPrinter() |
1369 | { | 1369 | { |
1370 | #ifndef KORG_NOPRINTER | 1370 | #ifndef KORG_NOPRINTER |
1371 | if (!mCalPrinter) { | 1371 | if (!mCalPrinter) { |
1372 | mCalPrinter = new CalPrinter(this, mCalendar); | 1372 | mCalPrinter = new CalPrinter(this, mCalendar); |
1373 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1373 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1374 | } | 1374 | } |
1375 | #endif | 1375 | #endif |
1376 | } | 1376 | } |
1377 | 1377 | ||
1378 | 1378 | ||
1379 | //KOPrefs::instance()->mWriteBackFile | 1379 | //KOPrefs::instance()->mWriteBackFile |
1380 | //KOPrefs::instance()->mWriteBackExistingOnly | 1380 | //KOPrefs::instance()->mWriteBackExistingOnly |
1381 | 1381 | ||
1382 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1382 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1383 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1383 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1384 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1384 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1385 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1385 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1386 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1386 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1387 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1387 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1388 | 1388 | ||
1389 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1389 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1390 | { | 1390 | { |
1391 | 1391 | ||
1392 | // 0 equal | 1392 | // 0 equal |
1393 | // 1 take local | 1393 | // 1 take local |
1394 | // 2 take remote | 1394 | // 2 take remote |
1395 | // 3 cancel | 1395 | // 3 cancel |
1396 | QDateTime lastSync = mLastCalendarSync; | 1396 | QDateTime lastSync = mLastCalendarSync; |
1397 | QDateTime localMod = local->lastModified(); | 1397 | QDateTime localMod = local->lastModified(); |
1398 | QDateTime remoteMod = remote->lastModified(); | 1398 | QDateTime remoteMod = remote->lastModified(); |
1399 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1399 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1400 | bool remCh, locCh; | 1400 | bool remCh, locCh; |
1401 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1401 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1402 | //if ( remCh ) | 1402 | //if ( remCh ) |
1403 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1403 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1404 | locCh = ( localMod > mLastCalendarSync ); | 1404 | locCh = ( localMod > mLastCalendarSync ); |
1405 | if ( !remCh && ! locCh ) { | 1405 | if ( !remCh && ! locCh ) { |
1406 | //qDebug("both not changed "); | 1406 | //qDebug("both not changed "); |
1407 | lastSync = localMod.addDays(1); | 1407 | lastSync = localMod.addDays(1); |
1408 | if ( mode <= SYNC_PREF_ASK ) | 1408 | if ( mode <= SYNC_PREF_ASK ) |
1409 | return 0; | 1409 | return 0; |
1410 | } else { | 1410 | } else { |
1411 | if ( locCh ) { | 1411 | if ( locCh ) { |
1412 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1412 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1413 | lastSync = localMod.addDays( -1 ); | 1413 | lastSync = localMod.addDays( -1 ); |
1414 | if ( !remCh ) | 1414 | if ( !remCh ) |
1415 | remoteMod = ( lastSync.addDays( -1 ) ); | 1415 | remoteMod = ( lastSync.addDays( -1 ) ); |
1416 | } else { | 1416 | } else { |
1417 | //qDebug(" not loc changed "); | 1417 | //qDebug(" not loc changed "); |
1418 | lastSync = localMod.addDays( 1 ); | 1418 | lastSync = localMod.addDays( 1 ); |
1419 | if ( remCh ) | 1419 | if ( remCh ) |
1420 | remoteMod =( lastSync.addDays( 1 ) ); | 1420 | remoteMod =( lastSync.addDays( 1 ) ); |
1421 | 1421 | ||
1422 | } | 1422 | } |
1423 | } | 1423 | } |
1424 | full = true; | 1424 | full = true; |
1425 | if ( mode < SYNC_PREF_ASK ) | 1425 | if ( mode < SYNC_PREF_ASK ) |
1426 | mode = SYNC_PREF_ASK; | 1426 | mode = SYNC_PREF_ASK; |
1427 | } else { | 1427 | } else { |
1428 | if ( localMod == remoteMod ) | 1428 | if ( localMod == remoteMod ) |
1429 | // if ( local->revision() == remote->revision() ) | 1429 | // if ( local->revision() == remote->revision() ) |
1430 | return 0; | 1430 | return 0; |
1431 | 1431 | ||
1432 | } | 1432 | } |
1433 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1433 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1434 | 1434 | ||
1435 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1435 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1436 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1436 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1437 | //full = true; //debug only | 1437 | //full = true; //debug only |
1438 | if ( full ) { | 1438 | if ( full ) { |
1439 | bool equ = false; | 1439 | bool equ = false; |
1440 | if ( local->typeID() == eventID ) { | 1440 | if ( local->typeID() == eventID ) { |
1441 | equ = (*((Event*) local) == *((Event*) remote)); | 1441 | equ = (*((Event*) local) == *((Event*) remote)); |
1442 | } | 1442 | } |
1443 | else if ( local->typeID() == todoID ) | 1443 | else if ( local->typeID() == todoID ) |
1444 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1444 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1445 | else if ( local->typeID() == journalID ) | 1445 | else if ( local->typeID() == journalID ) |
1446 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1446 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1447 | if ( equ ) { | 1447 | if ( equ ) { |
1448 | //qDebug("equal "); | 1448 | //qDebug("equal "); |
1449 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1449 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1450 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1450 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1451 | } | 1451 | } |
1452 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1452 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1453 | return 0; | 1453 | return 0; |
1454 | 1454 | ||
1455 | }//else //debug only | 1455 | }//else //debug only |
1456 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1456 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1457 | } | 1457 | } |
1458 | int result; | 1458 | int result; |
1459 | bool localIsNew; | 1459 | bool localIsNew; |
1460 | //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() ); | 1460 | //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() ); |
1461 | 1461 | ||
1462 | 1462 | ||
1463 | // ************************************************ | 1463 | // ************************************************ |
1464 | // ************************************************ | 1464 | // ************************************************ |
1465 | // ************************************************ | 1465 | // ************************************************ |
1466 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1466 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1467 | // BUT remoteMod != localMod | 1467 | // BUT remoteMod != localMod |
1468 | 1468 | ||
1469 | 1469 | ||
1470 | if ( full && mode < SYNC_PREF_NEWEST ) | 1470 | if ( full && mode < SYNC_PREF_NEWEST ) |
1471 | mode = SYNC_PREF_ASK; | 1471 | mode = SYNC_PREF_ASK; |
1472 | 1472 | ||
1473 | switch( mode ) { | 1473 | switch( mode ) { |
1474 | case SYNC_PREF_LOCAL: | 1474 | case SYNC_PREF_LOCAL: |
1475 | if ( lastSync > remoteMod ) | 1475 | if ( lastSync > remoteMod ) |
1476 | return 1; | 1476 | return 1; |
1477 | if ( lastSync > localMod ) | 1477 | if ( lastSync > localMod ) |
1478 | return 2; | 1478 | return 2; |
1479 | return 1; | 1479 | return 1; |
1480 | break; | 1480 | break; |
1481 | case SYNC_PREF_REMOTE: | 1481 | case SYNC_PREF_REMOTE: |
1482 | if ( lastSync > localMod ) | 1482 | if ( lastSync > localMod ) |
1483 | return 2; | 1483 | return 2; |
1484 | if ( lastSync > remoteMod ) | 1484 | if ( lastSync > remoteMod ) |
1485 | return 1; | 1485 | return 1; |
1486 | return 2; | 1486 | return 2; |
1487 | break; | 1487 | break; |
1488 | case SYNC_PREF_NEWEST: | 1488 | case SYNC_PREF_NEWEST: |
1489 | if ( localMod >= remoteMod ) | 1489 | if ( localMod >= remoteMod ) |
1490 | return 1; | 1490 | return 1; |
1491 | else | 1491 | else |
1492 | return 2; | 1492 | return 2; |
1493 | break; | 1493 | break; |
1494 | case SYNC_PREF_ASK: | 1494 | case SYNC_PREF_ASK: |
1495 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1495 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1496 | if ( lastSync > remoteMod && lastSync > localMod) | 1496 | if ( lastSync > remoteMod && lastSync > localMod) |
1497 | return 0; | 1497 | return 0; |
1498 | if ( lastSync > remoteMod ) | 1498 | if ( lastSync > remoteMod ) |
1499 | return 1; | 1499 | return 1; |
1500 | if ( lastSync > localMod ) | 1500 | if ( lastSync > localMod ) |
1501 | return 2; | 1501 | return 2; |
1502 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1502 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1503 | localIsNew = localMod >= remoteMod; | 1503 | localIsNew = localMod >= remoteMod; |
1504 | if ( localIsNew ) | 1504 | if ( localIsNew ) |
1505 | getEventViewerDialog()->setColorMode( 1 ); | 1505 | getEventViewerDialog()->setColorMode( 1 ); |
1506 | else | 1506 | else |
1507 | getEventViewerDialog()->setColorMode( 2 ); | 1507 | getEventViewerDialog()->setColorMode( 2 ); |
1508 | getEventViewerDialog()->setIncidence(local); | 1508 | getEventViewerDialog()->setIncidence(local); |
1509 | if ( localIsNew ) | 1509 | if ( localIsNew ) |
1510 | getEventViewerDialog()->setColorMode( 2 ); | 1510 | getEventViewerDialog()->setColorMode( 2 ); |
1511 | else | 1511 | else |
1512 | getEventViewerDialog()->setColorMode( 1 ); | 1512 | getEventViewerDialog()->setColorMode( 1 ); |
1513 | getEventViewerDialog()->addIncidence(remote); | 1513 | getEventViewerDialog()->addIncidence(remote); |
1514 | getEventViewerDialog()->setColorMode( 0 ); | 1514 | getEventViewerDialog()->setColorMode( 0 ); |
1515 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1515 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1516 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1516 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1517 | getEventViewerDialog()->showMe(); | 1517 | getEventViewerDialog()->showMe(); |
1518 | result = getEventViewerDialog()->executeS( localIsNew ); | 1518 | result = getEventViewerDialog()->executeS( localIsNew ); |
1519 | return result; | 1519 | return result; |
1520 | 1520 | ||
1521 | break; | 1521 | break; |
1522 | case SYNC_PREF_FORCE_LOCAL: | 1522 | case SYNC_PREF_FORCE_LOCAL: |
1523 | return 1; | 1523 | return 1; |
1524 | break; | 1524 | break; |
1525 | case SYNC_PREF_FORCE_REMOTE: | 1525 | case SYNC_PREF_FORCE_REMOTE: |
1526 | return 2; | 1526 | return 2; |
1527 | break; | 1527 | break; |
1528 | 1528 | ||
1529 | default: | 1529 | default: |
1530 | // SYNC_PREF_TAKE_BOTH not implemented | 1530 | // SYNC_PREF_TAKE_BOTH not implemented |
1531 | break; | 1531 | break; |
1532 | } | 1532 | } |
1533 | return 0; | 1533 | return 0; |
1534 | } | 1534 | } |
1535 | Event* CalendarView::getLastSyncEvent() | 1535 | Event* CalendarView::getLastSyncEvent() |
1536 | { | 1536 | { |
1537 | Event* lse; | 1537 | Event* lse; |
1538 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1538 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1539 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1539 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1540 | if (!lse) { | 1540 | if (!lse) { |
1541 | lse = new Event(); | 1541 | lse = new Event(); |
1542 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1542 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1543 | QString sum = ""; | 1543 | QString sum = ""; |
1544 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1544 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1545 | sum = "E: "; | 1545 | sum = "E: "; |
1546 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1546 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1547 | lse->setDtStart( mLastCalendarSync ); | 1547 | lse->setDtStart( mLastCalendarSync ); |
1548 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1548 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1549 | lse->setCategories( i18n("SyncEvent") ); | 1549 | lse->setCategories( i18n("SyncEvent") ); |
1550 | lse->setReadOnly( true ); | 1550 | lse->setReadOnly( true ); |
1551 | mCalendar->addEvent( lse ); | 1551 | mCalendar->addEvent( lse ); |
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | return lse; | 1554 | return lse; |
1555 | 1555 | ||
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | // we check, if the to delete event has a id for a profile | 1558 | // we check, if the to delete event has a id for a profile |
1559 | // if yes, we set this id in the profile to delete | 1559 | // if yes, we set this id in the profile to delete |
1560 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1560 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1561 | { | 1561 | { |
1562 | if ( lastSync.count() == 0 ) { | 1562 | if ( lastSync.count() == 0 ) { |
1563 | //qDebug(" lastSync.count() == 0"); | 1563 | //qDebug(" lastSync.count() == 0"); |
1564 | return; | 1564 | return; |
1565 | } | 1565 | } |
1566 | if ( toDelete->typeID() == journalID ) | 1566 | if ( toDelete->typeID() == journalID ) |
1567 | return; | 1567 | return; |
1568 | 1568 | ||
1569 | Event* eve = lastSync.first(); | 1569 | Event* eve = lastSync.first(); |
1570 | 1570 | ||
1571 | while ( eve ) { | 1571 | while ( eve ) { |
1572 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1572 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1573 | if ( !id.isEmpty() ) { | 1573 | if ( !id.isEmpty() ) { |
1574 | QString des = eve->description(); | 1574 | QString des = eve->description(); |
1575 | QString pref = "e"; | 1575 | QString pref = "e"; |
1576 | if ( toDelete->typeID() == todoID ) | 1576 | if ( toDelete->typeID() == todoID ) |
1577 | pref = "t"; | 1577 | pref = "t"; |
1578 | des += pref+ id + ","; | 1578 | des += pref+ id + ","; |
1579 | eve->setReadOnly( false ); | 1579 | eve->setReadOnly( false ); |
1580 | eve->setDescription( des ); | 1580 | eve->setDescription( des ); |
1581 | //qDebug("setdes %s ", des.latin1()); | 1581 | //qDebug("setdes %s ", des.latin1()); |
1582 | eve->setReadOnly( true ); | 1582 | eve->setReadOnly( true ); |
1583 | } | 1583 | } |
1584 | eve = lastSync.next(); | 1584 | eve = lastSync.next(); |
1585 | } | 1585 | } |
1586 | 1586 | ||
1587 | } | 1587 | } |
1588 | void CalendarView::checkExternalId( Incidence * inc ) | 1588 | void CalendarView::checkExternalId( Incidence * inc ) |
1589 | { | 1589 | { |
1590 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1590 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1591 | checkExternSyncEvent( lastSync, inc ); | 1591 | checkExternSyncEvent( lastSync, inc ); |
1592 | 1592 | ||
1593 | } | 1593 | } |
1594 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1594 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1595 | { | 1595 | { |
1596 | bool syncOK = true; | 1596 | bool syncOK = true; |
1597 | int addedEvent = 0; | 1597 | int addedEvent = 0; |
1598 | int addedEventR = 0; | 1598 | int addedEventR = 0; |
1599 | int deletedEventR = 0; | 1599 | int deletedEventR = 0; |
1600 | int deletedEventL = 0; | 1600 | int deletedEventL = 0; |
1601 | int changedLocal = 0; | 1601 | int changedLocal = 0; |
1602 | int changedRemote = 0; | 1602 | int changedRemote = 0; |
1603 | int filteredIN = 0; | 1603 | int filteredIN = 0; |
1604 | int filteredOUT = 0; | 1604 | int filteredOUT = 0; |
1605 | //QPtrList<Event> el = local->rawEvents(); | 1605 | //QPtrList<Event> el = local->rawEvents(); |
1606 | Event* eventR; | 1606 | Event* eventR; |
1607 | QString uid; | 1607 | QString uid; |
1608 | int take; | 1608 | int take; |
1609 | Event* eventRSync; | 1609 | Event* eventRSync; |
1610 | Event* eventLSync; | 1610 | Event* eventLSync; |
1611 | clearAllViews(); | 1611 | clearAllViews(); |
1612 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1612 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1613 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1613 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1614 | bool fullDateRange = false; | 1614 | bool fullDateRange = false; |
1615 | local->resetTempSyncStat(); | 1615 | local->resetTempSyncStat(); |
1616 | mLastCalendarSync = QDateTime::currentDateTime(); | 1616 | mLastCalendarSync = QDateTime::currentDateTime(); |
1617 | if ( mSyncManager->syncWithDesktop() ) { | 1617 | if ( mSyncManager->syncWithDesktop() ) { |
1618 | remote->resetPilotStat(1); | 1618 | remote->resetPilotStat(1); |
1619 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1619 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1620 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1620 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1621 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1621 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1622 | } else { | 1622 | } else { |
1623 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1623 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1624 | } | 1624 | } |
1625 | } | 1625 | } |
1626 | QDateTime modifiedCalendar = mLastCalendarSync; | 1626 | QDateTime modifiedCalendar = mLastCalendarSync; |
1627 | eventLSync = getLastSyncEvent(); | 1627 | eventLSync = getLastSyncEvent(); |
1628 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1628 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1629 | if ( eventR ) { | 1629 | if ( eventR ) { |
1630 | qDebug("last-syncEvent on remote found "); | 1630 | qDebug("last-syncEvent on remote found "); |
1631 | eventRSync = (Event*) eventR->clone(); | 1631 | eventRSync = (Event*) eventR->clone(); |
1632 | remote->deleteEvent(eventR ); | 1632 | remote->deleteEvent(eventR ); |
1633 | 1633 | ||
1634 | } else { | 1634 | } else { |
1635 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1635 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1636 | eventRSync = (Event*)eventLSync->clone(); | 1636 | eventRSync = (Event*)eventLSync->clone(); |
1637 | } else { | 1637 | } else { |
1638 | fullDateRange = true; | 1638 | fullDateRange = true; |
1639 | eventRSync = new Event(); | 1639 | eventRSync = new Event(); |
1640 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1640 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1641 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1641 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1642 | eventRSync->setDtStart( mLastCalendarSync ); | 1642 | eventRSync->setDtStart( mLastCalendarSync ); |
1643 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1643 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1644 | eventRSync->setCategories( i18n("SyncEvent") ); | 1644 | eventRSync->setCategories( i18n("SyncEvent") ); |
1645 | } | 1645 | } |
1646 | } | 1646 | } |
1647 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1647 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1648 | fullDateRange = true; | 1648 | fullDateRange = true; |
1649 | 1649 | ||
1650 | if ( ! fullDateRange ) { | 1650 | if ( ! fullDateRange ) { |
1651 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1651 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1652 | 1652 | ||
1653 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1653 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1654 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1654 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1655 | fullDateRange = true; | 1655 | fullDateRange = true; |
1656 | } | 1656 | } |
1657 | } | 1657 | } |
1658 | if ( mSyncManager->syncWithDesktop() ) { | 1658 | if ( mSyncManager->syncWithDesktop() ) { |
1659 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1659 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1660 | } | 1660 | } |
1661 | if ( fullDateRange ) | 1661 | if ( fullDateRange ) |
1662 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1662 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1663 | else | 1663 | else |
1664 | mLastCalendarSync = eventLSync->dtStart(); | 1664 | mLastCalendarSync = eventLSync->dtStart(); |
1665 | // for resyncing if own file has changed | 1665 | // for resyncing if own file has changed |
1666 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1666 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1667 | mLastCalendarSync = loadedFileVersion; | 1667 | mLastCalendarSync = loadedFileVersion; |
1668 | //qDebug("setting mLastCalendarSync "); | 1668 | //qDebug("setting mLastCalendarSync "); |
1669 | } | 1669 | } |
1670 | //qDebug("*************************** "); | 1670 | //qDebug("*************************** "); |
1671 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1671 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1672 | QPtrList<Incidence> er = remote->rawIncidences(); | 1672 | QPtrList<Incidence> er = remote->rawIncidences(); |
1673 | Incidence* inR = er.first(); | 1673 | Incidence* inR = er.first(); |
1674 | Incidence* inL; | 1674 | Incidence* inL; |
1675 | QProgressBar bar( er.count(),0 ); | 1675 | QProgressBar bar( er.count(),0 ); |
1676 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1676 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1677 | 1677 | ||
1678 | // ************** setting up filter ************* | 1678 | // ************** setting up filter ************* |
1679 | CalFilter *filterIN = 0; | 1679 | CalFilter *filterIN = 0; |
1680 | CalFilter *filterOUT = 0; | 1680 | CalFilter *filterOUT = 0; |
1681 | CalFilter *filter = mFilters.first(); | 1681 | CalFilter *filter = mFilters.first(); |
1682 | while(filter) { | 1682 | while(filter) { |
1683 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1683 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1684 | filterIN = filter; | 1684 | filterIN = filter; |
1685 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1685 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1686 | filterOUT = filter; | 1686 | filterOUT = filter; |
1687 | filter = mFilters.next(); | 1687 | filter = mFilters.next(); |
1688 | } | 1688 | } |
1689 | int w = 300; | 1689 | int w = 300; |
1690 | if ( QApplication::desktop()->width() < 320 ) | 1690 | if ( QApplication::desktop()->width() < 320 ) |
1691 | w = 220; | 1691 | w = 220; |
1692 | int h = bar.sizeHint().height() ; | 1692 | int h = bar.sizeHint().height() ; |
1693 | int dw = QApplication::desktop()->width(); | 1693 | int dw = QApplication::desktop()->width(); |
1694 | int dh = QApplication::desktop()->height(); | 1694 | int dh = QApplication::desktop()->height(); |
1695 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1695 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1696 | bar.show(); | 1696 | bar.show(); |
1697 | int modulo = (er.count()/10)+1; | 1697 | int modulo = (er.count()/10)+1; |
1698 | int incCounter = 0; | 1698 | int incCounter = 0; |
1699 | while ( inR ) { | 1699 | while ( inR ) { |
1700 | if ( ! bar.isVisible() ) | 1700 | if ( ! bar.isVisible() ) |
1701 | return false; | 1701 | return false; |
1702 | if ( incCounter % modulo == 0 ) | 1702 | if ( incCounter % modulo == 0 ) |
1703 | bar.setProgress( incCounter ); | 1703 | bar.setProgress( incCounter ); |
1704 | ++incCounter; | 1704 | ++incCounter; |
1705 | uid = inR->uid(); | 1705 | uid = inR->uid(); |
1706 | bool skipIncidence = false; | 1706 | bool skipIncidence = false; |
1707 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1707 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1708 | skipIncidence = true; | 1708 | skipIncidence = true; |
1709 | QString idS; | 1709 | QString idS; |
1710 | qApp->processEvents(); | 1710 | qApp->processEvents(); |
1711 | if ( !skipIncidence ) { | 1711 | if ( !skipIncidence ) { |
1712 | inL = local->incidenceForUid( uid , false ); | 1712 | inL = local->incidenceForUid( uid , false ); |
1713 | if ( inL ) { // maybe conflict - same uid in both calendars | 1713 | if ( inL ) { // maybe conflict - same uid in both calendars |
1714 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1714 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1715 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1715 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1716 | if ( take == 3 ) | 1716 | if ( take == 3 ) |
1717 | return false; | 1717 | return false; |
1718 | if ( take == 1 ) {// take local ********************** | 1718 | if ( take == 1 ) {// take local ********************** |
1719 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1719 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1720 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1720 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1721 | else | 1721 | else |
1722 | idS = inR->IDStr(); | 1722 | idS = inR->IDStr(); |
1723 | int calID = inR->calID(); | 1723 | int calID = inR->calID(); |
1724 | remote->deleteIncidence( inR ); | 1724 | remote->deleteIncidence( inR ); |
1725 | inR = inL->clone(); | 1725 | inR = inL->clone(); |
1726 | inR->setCalID( calID ); | 1726 | inR->setCalID( calID ); |
1727 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1727 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1728 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1728 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1729 | inR->setIDStr( idS ); | 1729 | inR->setIDStr( idS ); |
1730 | remote->addIncidence( inR ); | 1730 | remote->addIncidence( inR ); |
1731 | if ( mSyncManager->syncWithDesktop() ) | 1731 | if ( mSyncManager->syncWithDesktop() ) |
1732 | inR->setPilotId( 2 ); | 1732 | inR->setPilotId( 2 ); |
1733 | ++changedRemote; | 1733 | ++changedRemote; |
1734 | } else {// take remote ********************** | 1734 | } else {// take remote ********************** |
1735 | if ( !inL->isReadOnly() ) { | 1735 | if ( !inL->isReadOnly() ) { |
1736 | idS = inL->IDStr(); | 1736 | idS = inL->IDStr(); |
1737 | int pid = inL->pilotId(); | 1737 | int pid = inL->pilotId(); |
1738 | int calID = inL->calID(); | 1738 | int calID = inL->calID(); |
1739 | local->deleteIncidence( inL ); | 1739 | local->deleteIncidence( inL ); |
1740 | inL = inR->clone(); | 1740 | inL = inR->clone(); |
1741 | inL->setCalID( calID ); | 1741 | inL->setCalID( calID ); |
1742 | if ( mSyncManager->syncWithDesktop() ) | 1742 | if ( mSyncManager->syncWithDesktop() ) |
1743 | inL->setPilotId( pid ); | 1743 | inL->setPilotId( pid ); |
1744 | inL->setIDStr( idS ); | 1744 | inL->setIDStr( idS ); |
1745 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1745 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1746 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1746 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1747 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1747 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1748 | } | 1748 | } |
1749 | local->addIncidence( inL ); | 1749 | local->addIncidence( inL ); |
1750 | ++changedLocal; | 1750 | ++changedLocal; |
1751 | } | 1751 | } |
1752 | } | 1752 | } |
1753 | } | 1753 | } |
1754 | } else { // no conflict ********** add or delete remote | 1754 | } else { // no conflict ********** add or delete remote |
1755 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1755 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1756 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1756 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1757 | QString des = eventLSync->description(); | 1757 | QString des = eventLSync->description(); |
1758 | QString pref = "e"; | 1758 | QString pref = "e"; |
1759 | if ( inR->typeID() == todoID ) | 1759 | if ( inR->typeID() == todoID ) |
1760 | pref = "t"; | 1760 | pref = "t"; |
1761 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1761 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1762 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1762 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1763 | //remote->deleteIncidence( inR ); | 1763 | //remote->deleteIncidence( inR ); |
1764 | ++deletedEventR; | 1764 | ++deletedEventR; |
1765 | } else { | 1765 | } else { |
1766 | inR->setLastModified( modifiedCalendar ); | 1766 | inR->setLastModified( modifiedCalendar ); |
1767 | inL = inR->clone(); | 1767 | inL = inR->clone(); |
1768 | inL->setIDStr( ":" ); | 1768 | inL->setIDStr( ":" ); |
1769 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1769 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1770 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1770 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1771 | 1771 | ||
1772 | inL->setCalID( 0 );// add to default cal | 1772 | inL->setCalID( 0 );// add to default cal |
1773 | local->addIncidence( inL ); | 1773 | local->addIncidence( inL ); |
1774 | ++addedEvent; | 1774 | ++addedEvent; |
1775 | 1775 | ||
1776 | } | 1776 | } |
1777 | } else { | 1777 | } else { |
1778 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1778 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1779 | inR->setLastModified( modifiedCalendar ); | 1779 | inR->setLastModified( modifiedCalendar ); |
1780 | inL = inR->clone(); | 1780 | inL = inR->clone(); |
1781 | inL->setIDStr( ":" ); | 1781 | inL->setIDStr( ":" ); |
1782 | inL->setCalID( 0 );// add to default cal | 1782 | inL->setCalID( 0 );// add to default cal |
1783 | local->addIncidence( inL ); | 1783 | local->addIncidence( inL ); |
1784 | ++addedEvent; | 1784 | ++addedEvent; |
1785 | 1785 | ||
1786 | } else { | 1786 | } else { |
1787 | checkExternSyncEvent(eventRSyncSharp, inR); | 1787 | checkExternSyncEvent(eventRSyncSharp, inR); |
1788 | remote->deleteIncidence( inR ); | 1788 | remote->deleteIncidence( inR ); |
1789 | ++deletedEventR; | 1789 | ++deletedEventR; |
1790 | } | 1790 | } |
1791 | } | 1791 | } |
1792 | } else { | 1792 | } else { |
1793 | ++filteredIN; | 1793 | ++filteredIN; |
1794 | } | 1794 | } |
1795 | } | 1795 | } |
1796 | } | 1796 | } |
1797 | inR = er.next(); | 1797 | inR = er.next(); |
1798 | } | 1798 | } |
1799 | QPtrList<Incidence> el = local->rawIncidences(); | 1799 | QPtrList<Incidence> el = local->rawIncidences(); |
1800 | inL = el.first(); | 1800 | inL = el.first(); |
1801 | modulo = (el.count()/10)+1; | 1801 | modulo = (el.count()/10)+1; |
1802 | bar.setCaption (i18n("Add / remove events") ); | 1802 | bar.setCaption (i18n("Add / remove events") ); |
1803 | bar.setTotalSteps ( el.count() ) ; | 1803 | bar.setTotalSteps ( el.count() ) ; |
1804 | bar.show(); | 1804 | bar.show(); |
1805 | incCounter = 0; | 1805 | incCounter = 0; |
1806 | 1806 | ||
1807 | while ( inL ) { | 1807 | while ( inL ) { |
1808 | 1808 | ||
1809 | qApp->processEvents(); | 1809 | qApp->processEvents(); |
1810 | if ( ! bar.isVisible() ) | 1810 | if ( ! bar.isVisible() ) |
1811 | return false; | 1811 | return false; |
1812 | if ( incCounter % modulo == 0 ) | 1812 | if ( incCounter % modulo == 0 ) |
1813 | bar.setProgress( incCounter ); | 1813 | bar.setProgress( incCounter ); |
1814 | ++incCounter; | 1814 | ++incCounter; |
1815 | uid = inL->uid(); | 1815 | uid = inL->uid(); |
1816 | bool skipIncidence = false; | 1816 | bool skipIncidence = false; |
1817 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1817 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1818 | skipIncidence = true; | 1818 | skipIncidence = true; |
1819 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1819 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1820 | skipIncidence = true; | 1820 | skipIncidence = true; |
1821 | if ( !skipIncidence ) { | 1821 | if ( !skipIncidence ) { |
1822 | inR = remote->incidenceForUid( uid , true ); | 1822 | inR = remote->incidenceForUid( uid , true ); |
1823 | if ( ! inR ) { | 1823 | if ( ! inR ) { |
1824 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1824 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1825 | // no conflict ********** add or delete local | 1825 | // no conflict ********** add or delete local |
1826 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1826 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1827 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1827 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1828 | checkExternSyncEvent(eventLSyncSharp, inL); | 1828 | checkExternSyncEvent(eventLSyncSharp, inL); |
1829 | local->deleteIncidence( inL ); | 1829 | local->deleteIncidence( inL ); |
1830 | ++deletedEventL; | 1830 | ++deletedEventL; |
1831 | } else { | 1831 | } else { |
1832 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1832 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1833 | inL->removeID(mCurrentSyncDevice ); | 1833 | inL->removeID(mCurrentSyncDevice ); |
1834 | ++addedEventR; | 1834 | ++addedEventR; |
1835 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1835 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1836 | inL->setLastModified( modifiedCalendar ); | 1836 | inL->setLastModified( modifiedCalendar ); |
1837 | inR = inL->clone(); | 1837 | inR = inL->clone(); |
1838 | inR->setIDStr( ":" ); | 1838 | inR->setIDStr( ":" ); |
1839 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1839 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1840 | inR->setCalID( 0 );// add to default cal | 1840 | inR->setCalID( 0 );// add to default cal |
1841 | remote->addIncidence( inR ); | 1841 | remote->addIncidence( inR ); |
1842 | } | 1842 | } |
1843 | } | 1843 | } |
1844 | } else { | 1844 | } else { |
1845 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1845 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1846 | checkExternSyncEvent(eventLSyncSharp, inL); | 1846 | checkExternSyncEvent(eventLSyncSharp, inL); |
1847 | local->deleteIncidence( inL ); | 1847 | local->deleteIncidence( inL ); |
1848 | ++deletedEventL; | 1848 | ++deletedEventL; |
1849 | } else { | 1849 | } else { |
1850 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1850 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1851 | ++addedEventR; | 1851 | ++addedEventR; |
1852 | inL->setLastModified( modifiedCalendar ); | 1852 | inL->setLastModified( modifiedCalendar ); |
1853 | inR = inL->clone(); | 1853 | inR = inL->clone(); |
1854 | inR->setIDStr( ":" ); | 1854 | inR->setIDStr( ":" ); |
1855 | inR->setCalID( 0 );// add to default cal | 1855 | inR->setCalID( 0 );// add to default cal |
1856 | remote->addIncidence( inR ); | 1856 | remote->addIncidence( inR ); |
1857 | } | 1857 | } |
1858 | } | 1858 | } |
1859 | } | 1859 | } |
1860 | } else { | 1860 | } else { |
1861 | ++filteredOUT; | 1861 | ++filteredOUT; |
1862 | } | 1862 | } |
1863 | } | 1863 | } |
1864 | } | 1864 | } |
1865 | inL = el.next(); | 1865 | inL = el.next(); |
1866 | } | 1866 | } |
1867 | int delFut = 0; | 1867 | int delFut = 0; |
1868 | int remRem = 0; | 1868 | int remRem = 0; |
1869 | if ( mSyncManager->mWriteBackInFuture ) { | 1869 | if ( mSyncManager->mWriteBackInFuture ) { |
1870 | er = remote->rawIncidences(); | 1870 | er = remote->rawIncidences(); |
1871 | remRem = er.count(); | 1871 | remRem = er.count(); |
1872 | inR = er.first(); | 1872 | inR = er.first(); |
1873 | QDateTime dt; | 1873 | QDateTime dt; |
1874 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1874 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1875 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1875 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1876 | while ( inR ) { | 1876 | while ( inR ) { |
1877 | if ( inR->typeID() == todoID ) { | 1877 | if ( inR->typeID() == todoID ) { |
1878 | Todo * t = (Todo*)inR; | 1878 | Todo * t = (Todo*)inR; |
1879 | if ( t->hasDueDate() ) | 1879 | if ( t->hasDueDate() ) |
1880 | dt = t->dtDue(); | 1880 | dt = t->dtDue(); |
1881 | else | 1881 | else |
1882 | dt = cur.addSecs( 62 ); | 1882 | dt = cur.addSecs( 62 ); |
1883 | } | 1883 | } |
1884 | else if (inR->typeID() == eventID ) { | 1884 | else if (inR->typeID() == eventID ) { |
1885 | bool ok; | 1885 | bool ok; |
1886 | dt = inR->getNextOccurence( cur, &ok ); | 1886 | dt = inR->getNextOccurence( cur, &ok ); |
1887 | if ( !ok ) | 1887 | if ( !ok ) |
1888 | dt = cur.addSecs( -62 ); | 1888 | dt = cur.addSecs( -62 ); |
1889 | } | 1889 | } |
1890 | else | 1890 | else |
1891 | dt = inR->dtStart(); | 1891 | dt = inR->dtStart(); |
1892 | if ( dt < cur || dt > end ) { | 1892 | if ( dt < cur || dt > end ) { |
1893 | remote->deleteIncidence( inR ); | 1893 | remote->deleteIncidence( inR ); |
1894 | ++delFut; | 1894 | ++delFut; |
1895 | } | 1895 | } |
1896 | inR = er.next(); | 1896 | inR = er.next(); |
1897 | } | 1897 | } |
1898 | } | 1898 | } |
1899 | bar.hide(); | 1899 | bar.hide(); |
1900 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1900 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1901 | eventLSync->setReadOnly( false ); | 1901 | eventLSync->setReadOnly( false ); |
1902 | eventLSync->setDtStart( mLastCalendarSync ); | 1902 | eventLSync->setDtStart( mLastCalendarSync ); |
1903 | eventRSync->setDtStart( mLastCalendarSync ); | 1903 | eventRSync->setDtStart( mLastCalendarSync ); |
1904 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1904 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1905 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1905 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1906 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1906 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1907 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1907 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1908 | eventLSync->setReadOnly( true ); | 1908 | eventLSync->setReadOnly( true ); |
1909 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1909 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1910 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1910 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1911 | remote->addEvent( eventRSync ); | 1911 | remote->addEvent( eventRSync ); |
1912 | else | 1912 | else |
1913 | delete eventRSync; | 1913 | delete eventRSync; |
1914 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1914 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1915 | QString mes; | 1915 | QString mes; |
1916 | 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 ); | 1916 | 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 ); |
1917 | QString delmess; | 1917 | QString delmess; |
1918 | if ( delFut ) { | 1918 | if ( delFut ) { |
1919 | 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); | 1919 | 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); |
1920 | mes += delmess; | 1920 | mes += delmess; |
1921 | } | 1921 | } |
1922 | mes = i18n("Local calendar changed!\n") +mes; | 1922 | mes = i18n("Local calendar changed!\n") +mes; |
1923 | mCalendar->checkAlarmForIncidence( 0, true ); | 1923 | mCalendar->checkAlarmForIncidence( 0, true ); |
1924 | qDebug( mes ); | 1924 | qDebug( mes ); |
1925 | if ( mSyncManager->mShowSyncSummary ) { | 1925 | if ( mSyncManager->mShowSyncSummary ) { |
1926 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1926 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1927 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1927 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1928 | qDebug("KO: WB cancelled "); | 1928 | qDebug("KO: WB cancelled "); |
1929 | mSyncManager->mWriteBackFile = false; | 1929 | mSyncManager->mWriteBackFile = false; |
1930 | return syncOK; | 1930 | return syncOK; |
1931 | } | 1931 | } |
1932 | } | 1932 | } |
1933 | return syncOK; | 1933 | return syncOK; |
1934 | } | 1934 | } |
1935 | 1935 | ||
1936 | void CalendarView::setSyncDevice( QString s ) | 1936 | void CalendarView::setSyncDevice( QString s ) |
1937 | { | 1937 | { |
1938 | mCurrentSyncDevice= s; | 1938 | mCurrentSyncDevice= s; |
1939 | } | 1939 | } |
1940 | void CalendarView::setSyncName( QString s ) | 1940 | void CalendarView::setSyncName( QString s ) |
1941 | { | 1941 | { |
1942 | mCurrentSyncName= s; | 1942 | mCurrentSyncName= s; |
1943 | } | 1943 | } |
1944 | bool CalendarView::syncCalendar(QString filename, int mode) | 1944 | bool CalendarView::syncCalendar(QString filename, int mode) |
1945 | { | 1945 | { |
1946 | //qDebug("syncCalendar %s ", filename.latin1()); | 1946 | //qDebug("syncCalendar %s ", filename.latin1()); |
1947 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1947 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1948 | CalendarLocal* calendar = new CalendarLocal(); | 1948 | CalendarLocal* calendar = new CalendarLocal(); |
1949 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1949 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1950 | FileStorage* storage = new FileStorage( calendar ); | 1950 | FileStorage* storage = new FileStorage( calendar ); |
1951 | bool syncOK = false; | 1951 | bool syncOK = false; |
1952 | storage->setFileName( filename ); | 1952 | storage->setFileName( filename ); |
1953 | // qDebug("loading ... "); | 1953 | // qDebug("loading ... "); |
1954 | if ( storage->load() ) { | 1954 | if ( storage->load() ) { |
1955 | getEventViewerDialog()->setSyncMode( true ); | 1955 | getEventViewerDialog()->setSyncMode( true ); |
1956 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1956 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1957 | getEventViewerDialog()->setSyncMode( false ); | 1957 | getEventViewerDialog()->setSyncMode( false ); |
1958 | if ( syncOK ) { | 1958 | if ( syncOK ) { |
1959 | if ( mSyncManager->mWriteBackFile ) | 1959 | if ( mSyncManager->mWriteBackFile ) |
1960 | { | 1960 | { |
1961 | storage->setSaveFormat( new ICalFormat() ); | 1961 | storage->setSaveFormat( new ICalFormat() ); |
1962 | storage->save(); | 1962 | storage->save(); |
1963 | } | 1963 | } |
1964 | } | 1964 | } |
1965 | setModified( true ); | 1965 | setModified( true ); |
1966 | } | 1966 | } |
1967 | delete storage; | 1967 | delete storage; |
1968 | delete calendar; | 1968 | delete calendar; |
1969 | if ( syncOK ) | 1969 | if ( syncOK ) |
1970 | updateView(); | 1970 | updateView(); |
1971 | return syncOK; | 1971 | return syncOK; |
1972 | } | 1972 | } |
1973 | 1973 | ||
1974 | void CalendarView::syncExternal( int mode ) | 1974 | void CalendarView::syncExternal( int mode ) |
1975 | { | 1975 | { |
1976 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1976 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1977 | 1977 | ||
1978 | qApp->processEvents(); | 1978 | qApp->processEvents(); |
1979 | CalendarLocal* calendar = new CalendarLocal(); | 1979 | CalendarLocal* calendar = new CalendarLocal(); |
1980 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1980 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1981 | bool syncOK = false; | 1981 | bool syncOK = false; |
1982 | bool loadSuccess = false; | 1982 | bool loadSuccess = false; |
1983 | PhoneFormat* phoneFormat = 0; | 1983 | PhoneFormat* phoneFormat = 0; |
1984 | emit tempDisableBR(true); | 1984 | emit tempDisableBR(true); |
1985 | #ifndef DESKTOP_VERSION | 1985 | #ifndef DESKTOP_VERSION |
1986 | SharpFormat* sharpFormat = 0; | 1986 | SharpFormat* sharpFormat = 0; |
1987 | if ( mode == 0 ) { // sharp | 1987 | if ( mode == 0 ) { // sharp |
1988 | sharpFormat = new SharpFormat () ; | 1988 | sharpFormat = new SharpFormat () ; |
1989 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1989 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1990 | 1990 | ||
1991 | } else | 1991 | } else |
1992 | #endif | 1992 | #endif |
1993 | if ( mode == 1 ) { // phone | 1993 | if ( mode == 1 ) { // phone |
1994 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1994 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1995 | mSyncManager->mPhoneDevice, | 1995 | mSyncManager->mPhoneDevice, |
1996 | mSyncManager->mPhoneConnection, | 1996 | mSyncManager->mPhoneConnection, |
1997 | mSyncManager->mPhoneModel); | 1997 | mSyncManager->mPhoneModel); |
1998 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1998 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1999 | 1999 | ||
2000 | } else { | 2000 | } else { |
2001 | emit tempDisableBR(false); | 2001 | emit tempDisableBR(false); |
2002 | return; | 2002 | return; |
2003 | } | 2003 | } |
2004 | if ( loadSuccess ) { | 2004 | if ( loadSuccess ) { |
2005 | getEventViewerDialog()->setSyncMode( true ); | 2005 | getEventViewerDialog()->setSyncMode( true ); |
2006 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2006 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2007 | getEventViewerDialog()->setSyncMode( false ); | 2007 | getEventViewerDialog()->setSyncMode( false ); |
2008 | qApp->processEvents(); | 2008 | qApp->processEvents(); |
2009 | if ( syncOK ) { | 2009 | if ( syncOK ) { |
2010 | if ( mSyncManager->mWriteBackFile ) | 2010 | if ( mSyncManager->mWriteBackFile ) |
2011 | { | 2011 | { |
2012 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 2012 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
2013 | Incidence* inc = iL.first(); | 2013 | Incidence* inc = iL.first(); |
2014 | if ( phoneFormat ) { | 2014 | if ( phoneFormat ) { |
2015 | while ( inc ) { | 2015 | while ( inc ) { |
2016 | inc->removeID(mCurrentSyncDevice); | 2016 | inc->removeID(mCurrentSyncDevice); |
2017 | inc = iL.next(); | 2017 | inc = iL.next(); |
2018 | } | 2018 | } |
2019 | } | 2019 | } |
2020 | #ifndef DESKTOP_VERSION | 2020 | #ifndef DESKTOP_VERSION |
2021 | if ( sharpFormat ) | 2021 | if ( sharpFormat ) |
2022 | sharpFormat->save(calendar); | 2022 | sharpFormat->save(calendar); |
2023 | #endif | 2023 | #endif |
2024 | if ( phoneFormat ) | 2024 | if ( phoneFormat ) |
2025 | phoneFormat->save(calendar); | 2025 | phoneFormat->save(calendar); |
2026 | iL = calendar->rawIncidences(); | 2026 | iL = calendar->rawIncidences(); |
2027 | inc = iL.first(); | 2027 | inc = iL.first(); |
2028 | Incidence* loc; | 2028 | Incidence* loc; |
2029 | while ( inc ) { | 2029 | while ( inc ) { |
2030 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 2030 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
2031 | loc = mCalendar->incidence(inc->uid() ); | 2031 | loc = mCalendar->incidence(inc->uid() ); |
2032 | if ( loc ) { | 2032 | if ( loc ) { |
2033 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 2033 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
2034 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 2034 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
2035 | } | 2035 | } |
2036 | } | 2036 | } |
2037 | inc = iL.next(); | 2037 | inc = iL.next(); |
2038 | } | 2038 | } |
2039 | Incidence* lse = getLastSyncEvent(); | 2039 | Incidence* lse = getLastSyncEvent(); |
2040 | if ( lse ) { | 2040 | if ( lse ) { |
2041 | lse->setReadOnly( false ); | 2041 | lse->setReadOnly( false ); |
2042 | lse->setDescription( "" ); | 2042 | lse->setDescription( "" ); |
2043 | lse->setReadOnly( true ); | 2043 | lse->setReadOnly( true ); |
2044 | } | 2044 | } |
2045 | } | 2045 | } |
2046 | } else { | 2046 | } else { |
2047 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 2047 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
2048 | } | 2048 | } |
2049 | setModified( true ); | 2049 | setModified( true ); |
2050 | } else { | 2050 | } else { |
2051 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 2051 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
2052 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 2052 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
2053 | question, i18n("Ok")) ; | 2053 | question, i18n("Ok")) ; |
2054 | 2054 | ||
2055 | } | 2055 | } |
2056 | delete calendar; | 2056 | delete calendar; |
2057 | updateView(); | 2057 | updateView(); |
2058 | emit tempDisableBR(false); | 2058 | emit tempDisableBR(false); |
2059 | return ;//syncOK; | 2059 | return ;//syncOK; |
2060 | 2060 | ||
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | bool CalendarView::importBday() | 2063 | bool CalendarView::importBday() |
2064 | { | 2064 | { |
2065 | #ifndef KORG_NOKABC | 2065 | #ifndef KORG_NOKABC |
2066 | 2066 | ||
2067 | #ifdef DESKTOP_VERSION | 2067 | #ifdef DESKTOP_VERSION |
2068 | int curCal = mCalendar->defaultCalendar(); | 2068 | int curCal = mCalendar->defaultCalendar(); |
2069 | int bd = mCalEditView->getBirtdayID(); | 2069 | int bd = mCalEditView->getBirtdayID(); |
2070 | if ( bd == 0 ) | 2070 | if ( bd == 0 ) |
2071 | return false; | 2071 | return false; |
2072 | mCalendar->setDefaultCalendar( bd ); | 2072 | mCalendar->setDefaultCalendar( bd ); |
2073 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 2073 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
2074 | KABC::AddressBook::Iterator it; | 2074 | KABC::AddressBook::Iterator it; |
2075 | int count = 0; | 2075 | int count = 0; |
2076 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2076 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2077 | ++count; | 2077 | ++count; |
2078 | } | 2078 | } |
2079 | QProgressBar bar(count,0 ); | 2079 | QProgressBar bar(count,0 ); |
2080 | int w = 300; | 2080 | int w = 300; |
2081 | if ( QApplication::desktop()->width() < 320 ) | 2081 | if ( QApplication::desktop()->width() < 320 ) |
2082 | w = 220; | 2082 | w = 220; |
2083 | int h = bar.sizeHint().height() ; | 2083 | int h = bar.sizeHint().height() ; |
2084 | int dw = QApplication::desktop()->width(); | 2084 | int dw = QApplication::desktop()->width(); |
2085 | int dh = QApplication::desktop()->height(); | 2085 | int dh = QApplication::desktop()->height(); |
2086 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2086 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2087 | bar.show(); | 2087 | bar.show(); |
2088 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 2088 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
2089 | qApp->processEvents(); | 2089 | qApp->processEvents(); |
2090 | count = 0; | 2090 | count = 0; |
2091 | int addCount = 0; | 2091 | int addCount = 0; |
2092 | KCal::Attendee* a = 0; | 2092 | KCal::Attendee* a = 0; |
2093 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 2093 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
2094 | if ( ! bar.isVisible() ) | 2094 | if ( ! bar.isVisible() ) |
2095 | return false; | 2095 | return false; |
2096 | bar.setProgress( count++ ); | 2096 | bar.setProgress( count++ ); |
2097 | qApp->processEvents(); | 2097 | qApp->processEvents(); |
2098 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 2098 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
2099 | if ( (*it).birthday().date().isValid() ){ | 2099 | if ( (*it).birthday().date().isValid() ){ |
2100 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2100 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2101 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 2101 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
2102 | ++addCount; | 2102 | ++addCount; |
2103 | } | 2103 | } |
2104 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 2104 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
2105 | if ( anni.isValid() ){ | 2105 | if ( anni.isValid() ){ |
2106 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 2106 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
2107 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 2107 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
2108 | ++addCount; | 2108 | ++addCount; |
2109 | } | 2109 | } |
2110 | } | 2110 | } |
2111 | mCalendar->setDefaultCalendar( curCal ); | 2111 | mCalendar->setDefaultCalendar( curCal ); |
2112 | updateView(); | 2112 | updateView(); |
2113 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2113 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2114 | #else //DESKTOP_VERSION | 2114 | #else //DESKTOP_VERSION |
2115 | 2115 | ||
2116 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 2116 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
2117 | // the result should now arrive through method insertBirthdays | 2117 | // the result should now arrive through method insertBirthdays |
2118 | 2118 | ||
2119 | #endif //DESKTOP_VERSION | 2119 | #endif //DESKTOP_VERSION |
2120 | 2120 | ||
2121 | #endif //KORG_NOKABC | 2121 | #endif //KORG_NOKABC |
2122 | 2122 | ||
2123 | 2123 | ||
2124 | return true; | 2124 | return true; |
2125 | } | 2125 | } |
2126 | 2126 | ||
2127 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 2127 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
2128 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 2128 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
2129 | const QStringList& anniversaryList, const QStringList& realNameList, | 2129 | const QStringList& anniversaryList, const QStringList& realNameList, |
2130 | const QStringList& emailList, const QStringList& assembledNameList, | 2130 | const QStringList& emailList, const QStringList& assembledNameList, |
2131 | const QStringList& uidList) | 2131 | const QStringList& uidList) |
2132 | { | 2132 | { |
2133 | 2133 | ||
2134 | //qDebug("KO::CalendarView::insertBirthdays"); | 2134 | //qDebug("KO::CalendarView::insertBirthdays"); |
2135 | if (uid == this->name()) | 2135 | if (uid == this->name()) |
2136 | { | 2136 | { |
2137 | int curCal = mCalendar->defaultCalendar(); | 2137 | int curCal = mCalendar->defaultCalendar(); |
2138 | int bd = mCalEditView->getBirtdayID(); | 2138 | int bd = mCalEditView->getBirtdayID(); |
2139 | if ( bd == 0 ) | 2139 | if ( bd == 0 ) |
2140 | return; | 2140 | return; |
2141 | mCalendar->setDefaultCalendar( bd ); | 2141 | mCalendar->setDefaultCalendar( bd ); |
2142 | 2142 | ||
2143 | 2143 | ||
2144 | int count = birthdayList.count(); | 2144 | int count = birthdayList.count(); |
2145 | int addCount = 0; | 2145 | int addCount = 0; |
2146 | KCal::Attendee* a = 0; | 2146 | KCal::Attendee* a = 0; |
2147 | 2147 | ||
2148 | //qDebug("CalView 1 %i", count); | 2148 | //qDebug("CalView 1 %i", count); |
2149 | 2149 | ||
2150 | QProgressBar bar(count,0 ); | 2150 | QProgressBar bar(count,0 ); |
2151 | int w = 300; | 2151 | int w = 300; |
2152 | if ( QApplication::desktop()->width() < 320 ) | 2152 | if ( QApplication::desktop()->width() < 320 ) |
2153 | w = 220; | 2153 | w = 220; |
2154 | int h = bar.sizeHint().height() ; | 2154 | int h = bar.sizeHint().height() ; |
2155 | int dw = QApplication::desktop()->width(); | 2155 | int dw = QApplication::desktop()->width(); |
2156 | int dh = QApplication::desktop()->height(); | 2156 | int dh = QApplication::desktop()->height(); |
2157 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2157 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2158 | bar.show(); | 2158 | bar.show(); |
2159 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 2159 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
2160 | qApp->processEvents(); | 2160 | qApp->processEvents(); |
2161 | 2161 | ||
2162 | QDate birthday; | 2162 | QDate birthday; |
2163 | QDate anniversary; | 2163 | QDate anniversary; |
2164 | QString realName; | 2164 | QString realName; |
2165 | QString email; | 2165 | QString email; |
2166 | QString assembledName; | 2166 | QString assembledName; |
2167 | QString uid; | 2167 | QString uid; |
2168 | bool ok = true; | 2168 | bool ok = true; |
2169 | for ( int i = 0; i < count; i++) | 2169 | for ( int i = 0; i < count; i++) |
2170 | { | 2170 | { |
2171 | if ( ! bar.isVisible() ) | 2171 | if ( ! bar.isVisible() ) |
2172 | return; | 2172 | return; |
2173 | bar.setProgress( i ); | 2173 | bar.setProgress( i ); |
2174 | qApp->processEvents(); | 2174 | qApp->processEvents(); |
2175 | 2175 | ||
2176 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 2176 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
2177 | if (!ok) { | 2177 | if (!ok) { |
2178 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 2178 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
2179 | } | 2179 | } |
2180 | 2180 | ||
2181 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 2181 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
2182 | if (!ok) { | 2182 | if (!ok) { |
2183 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 2183 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
2184 | } | 2184 | } |
2185 | realName = realNameList[i]; | 2185 | realName = realNameList[i]; |
2186 | email = emailList[i]; | 2186 | email = emailList[i]; |
2187 | assembledName = assembledNameList[i]; | 2187 | assembledName = assembledNameList[i]; |
2188 | uid = uidList[i]; | 2188 | uid = uidList[i]; |
2189 | //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() ); | 2189 | //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() ); |
2190 | 2190 | ||
2191 | if ( birthday.isValid() ){ | 2191 | if ( birthday.isValid() ){ |
2192 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2192 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2193 | KCal::Attendee::ReqParticipant,uid) ; | 2193 | KCal::Attendee::ReqParticipant,uid) ; |
2194 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 2194 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
2195 | ++addCount; | 2195 | ++addCount; |
2196 | } | 2196 | } |
2197 | 2197 | ||
2198 | if ( anniversary.isValid() ){ | 2198 | if ( anniversary.isValid() ){ |
2199 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 2199 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
2200 | KCal::Attendee::ReqParticipant,uid) ; | 2200 | KCal::Attendee::ReqParticipant,uid) ; |
2201 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 2201 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
2202 | ++addCount; | 2202 | ++addCount; |
2203 | } | 2203 | } |
2204 | } | 2204 | } |
2205 | 2205 | ||
2206 | mCalendar->setDefaultCalendar( curCal ); | 2206 | mCalendar->setDefaultCalendar( curCal ); |
2207 | updateView(); | 2207 | updateView(); |
2208 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 2208 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
2209 | 2209 | ||
2210 | } | 2210 | } |
2211 | 2211 | ||
2212 | } | 2212 | } |
2213 | 2213 | ||
2214 | 2214 | ||
2215 | 2215 | ||
2216 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 2216 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
2217 | { | 2217 | { |
2218 | //qDebug("addAnni "); | 2218 | //qDebug("addAnni "); |
2219 | Event * ev = new Event(); | 2219 | Event * ev = new Event(); |
2220 | ev->setOrganizer(KOPrefs::instance()->email()); | 2220 | ev->setOrganizer(KOPrefs::instance()->email()); |
2221 | if ( a ) { | 2221 | if ( a ) { |
2222 | ev->addAttendee( a ); | 2222 | ev->addAttendee( a ); |
2223 | } | 2223 | } |
2224 | QString kind; | 2224 | QString kind; |
2225 | if ( birthday ) { | 2225 | if ( birthday ) { |
2226 | kind = i18n( "Birthday" ); | 2226 | kind = i18n( "Birthday" ); |
2227 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 2227 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
2228 | } | 2228 | } |
2229 | else { | 2229 | else { |
2230 | kind = i18n( "Anniversary" ); | 2230 | kind = i18n( "Anniversary" ); |
2231 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 2231 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
2232 | } | 2232 | } |
2233 | ev->setCategories( kind ); | 2233 | ev->setCategories( kind ); |
2234 | ev->setDtStart( QDateTime(date) ); | 2234 | ev->setDtStart( QDateTime(date) ); |
2235 | ev->setDtEnd( QDateTime(date) ); | 2235 | ev->setDtEnd( QDateTime(date) ); |
2236 | ev->setFloats( true ); | 2236 | ev->setFloats( true ); |
2237 | Recurrence * rec = ev->recurrence(); | 2237 | Recurrence * rec = ev->recurrence(); |
2238 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 2238 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
2239 | rec->addYearlyNum( date.month() ); | 2239 | rec->addYearlyNum( date.month() ); |
2240 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 2240 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
2241 | delete ev; | 2241 | delete ev; |
2242 | return false; | 2242 | return false; |
2243 | } | 2243 | } |
2244 | return true; | 2244 | return true; |
2245 | 2245 | ||
2246 | } | 2246 | } |
2247 | bool CalendarView::importQtopia( const QString &categories, | 2247 | bool CalendarView::importQtopia( const QString &categories, |
2248 | const QString &datebook, | 2248 | const QString &datebook, |
2249 | const QString &todolist ) | 2249 | const QString &todolist ) |
2250 | { | 2250 | { |
2251 | 2251 | ||
2252 | QtopiaFormat qtopiaFormat; | 2252 | QtopiaFormat qtopiaFormat; |
2253 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2253 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2254 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 2254 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2255 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 2255 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2256 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 2256 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2257 | 2257 | ||
2258 | updateView(); | 2258 | updateView(); |
2259 | return true; | 2259 | return true; |
2260 | 2260 | ||
2261 | #if 0 | 2261 | #if 0 |
2262 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 2262 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2263 | mCurrentSyncDevice = "qtopia-XML"; | 2263 | mCurrentSyncDevice = "qtopia-XML"; |
2264 | if ( mSyncManager->mAskForPreferences ) | 2264 | if ( mSyncManager->mAskForPreferences ) |
2265 | edit_sync_options(); | 2265 | edit_sync_options(); |
2266 | qApp->processEvents(); | 2266 | qApp->processEvents(); |
2267 | CalendarLocal* calendar = new CalendarLocal(); | 2267 | CalendarLocal* calendar = new CalendarLocal(); |
2268 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2268 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2269 | bool syncOK = false; | 2269 | bool syncOK = false; |
2270 | QtopiaFormat qtopiaFormat; | 2270 | QtopiaFormat qtopiaFormat; |
2271 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 2271 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2272 | bool loadOk = true; | 2272 | bool loadOk = true; |
2273 | if ( !categories.isEmpty() ) | 2273 | if ( !categories.isEmpty() ) |
2274 | loadOk = qtopiaFormat.load( calendar, categories ); | 2274 | loadOk = qtopiaFormat.load( calendar, categories ); |
2275 | if ( loadOk && !datebook.isEmpty() ) | 2275 | if ( loadOk && !datebook.isEmpty() ) |
2276 | loadOk = qtopiaFormat.load( calendar, datebook ); | 2276 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2277 | if ( loadOk && !todolist.isEmpty() ) | 2277 | if ( loadOk && !todolist.isEmpty() ) |
2278 | loadOk = qtopiaFormat.load( calendar, todolist ); | 2278 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2279 | 2279 | ||
2280 | if ( loadOk ) { | 2280 | if ( loadOk ) { |
2281 | getEventViewerDialog()->setSyncMode( true ); | 2281 | getEventViewerDialog()->setSyncMode( true ); |
2282 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2282 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2283 | getEventViewerDialog()->setSyncMode( false ); | 2283 | getEventViewerDialog()->setSyncMode( false ); |
2284 | qApp->processEvents(); | 2284 | qApp->processEvents(); |
2285 | if ( syncOK ) { | 2285 | if ( syncOK ) { |
2286 | if ( mSyncManager->mWriteBackFile ) | 2286 | if ( mSyncManager->mWriteBackFile ) |
2287 | { | 2287 | { |
2288 | // write back XML file | 2288 | // write back XML file |
2289 | 2289 | ||
2290 | } | 2290 | } |
2291 | setModified( true ); | 2291 | setModified( true ); |
2292 | } | 2292 | } |
2293 | } else { | 2293 | } else { |
2294 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2294 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2295 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2295 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2296 | question, i18n("Ok")) ; | 2296 | question, i18n("Ok")) ; |
2297 | } | 2297 | } |
2298 | delete calendar; | 2298 | delete calendar; |
2299 | updateView(); | 2299 | updateView(); |
2300 | return syncOK; | 2300 | return syncOK; |
2301 | 2301 | ||
2302 | 2302 | ||
2303 | #endif | 2303 | #endif |
2304 | 2304 | ||
2305 | } | 2305 | } |
2306 | 2306 | ||
2307 | void CalendarView::setSyncEventsReadOnly() | 2307 | void CalendarView::setSyncEventsReadOnly() |
2308 | { | 2308 | { |
2309 | mCalendar->setSyncEventsReadOnly(); | 2309 | mCalendar->setSyncEventsReadOnly(); |
2310 | } | 2310 | } |
2311 | 2311 | ||
2312 | bool CalendarView::loadCalendars() | 2312 | bool CalendarView::loadCalendars() |
2313 | { | 2313 | { |
2314 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2314 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2315 | KopiCalendarFile * cal = calendars.first(); | 2315 | KopiCalendarFile * cal = calendars.first(); |
2316 | mCalendar->setDefaultCalendar( 1 ); | 2316 | mCalendar->setDefaultCalendar( 1 ); |
2317 | openCalendar( MainWindow::defaultFileName(), false ); | 2317 | openCalendar( MainWindow::defaultFileName(), false ); |
2318 | cal = calendars.next(); | 2318 | cal = calendars.next(); |
2319 | while ( cal ) { | 2319 | while ( cal ) { |
2320 | addCalendar( cal ); | 2320 | addCalendar( cal ); |
2321 | cal = calendars.next(); | 2321 | cal = calendars.next(); |
2322 | } | 2322 | } |
2323 | restoreCalendarSettings(); | 2323 | restoreCalendarSettings(); |
2324 | return true; | 2324 | return true; |
2325 | } | 2325 | } |
2326 | bool CalendarView::restoreCalendarSettings() | 2326 | bool CalendarView::restoreCalendarSettings() |
2327 | { | 2327 | { |
2328 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2328 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2329 | KopiCalendarFile * cal = calendars.first(); | 2329 | KopiCalendarFile * cal = calendars.first(); |
2330 | while ( cal ) { | 2330 | while ( cal ) { |
2331 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2331 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2332 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2332 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2333 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2333 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2334 | if ( cal->isStandard ) | 2334 | if ( cal->isStandard ) |
2335 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2335 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2336 | cal = calendars.next(); | 2336 | cal = calendars.next(); |
2337 | } | 2337 | } |
2338 | setSyncEventsReadOnly(); | 2338 | setSyncEventsReadOnly(); |
2339 | mCalendar->reInitAlarmSettings(); | 2339 | mCalendar->reInitAlarmSettings(); |
2340 | updateUnmanagedViews(); | 2340 | updateUnmanagedViews(); |
2341 | updateView(); | 2341 | updateView(); |
2342 | return true; | 2342 | return true; |
2343 | } | 2343 | } |
2344 | void CalendarView::addCalendarId( int id ) | 2344 | void CalendarView::addCalendarId( int id ) |
2345 | { | 2345 | { |
2346 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2346 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2347 | if ( cal ) | 2347 | if ( cal ) |
2348 | addCalendar( cal ); | 2348 | addCalendar( cal ); |
2349 | } | 2349 | } |
2350 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2350 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2351 | { | 2351 | { |
2352 | cal->mErrorOnLoad = false; | 2352 | cal->mErrorOnLoad = false; |
2353 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2353 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2354 | cal->mLoadDt = QDateTime::currentDateTime(); | 2354 | cal->mLoadDt = QDateTime::currentDateTime(); |
2355 | return true; | 2355 | return true; |
2356 | } | 2356 | } |
2357 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2357 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2358 | cal->mErrorOnLoad = true; | 2358 | cal->mErrorOnLoad = true; |
2359 | return false; | 2359 | return false; |
2360 | } | 2360 | } |
2361 | bool CalendarView::openCalendar(QString filename, bool merge) | 2361 | bool CalendarView::openCalendar(QString filename, bool merge) |
2362 | { | 2362 | { |
2363 | 2363 | ||
2364 | if (filename.isEmpty()) { | 2364 | if (filename.isEmpty()) { |
2365 | return false; | 2365 | return false; |
2366 | } | 2366 | } |
2367 | 2367 | ||
2368 | if (!QFile::exists(filename)) { | 2368 | if (!QFile::exists(filename)) { |
2369 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2369 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2370 | return false; | 2370 | return false; |
2371 | } | 2371 | } |
2372 | 2372 | ||
2373 | globalFlagBlockAgenda = 1; | 2373 | globalFlagBlockAgenda = 1; |
2374 | clearAllViews(); | 2374 | clearAllViews(); |
2375 | if (!merge) { | 2375 | if (!merge) { |
2376 | mViewManager->setDocumentId( filename ); | 2376 | mViewManager->setDocumentId( filename ); |
2377 | mCalendar->close(); | 2377 | mCalendar->close(); |
2378 | } | 2378 | } |
2379 | mStorage->setFileName( filename ); | 2379 | mStorage->setFileName( filename ); |
2380 | 2380 | ||
2381 | if ( mStorage->load() ) { | 2381 | if ( mStorage->load() ) { |
2382 | if ( merge ) ;//setModified( true ); | 2382 | if ( merge ) ;//setModified( true ); |
2383 | else { | 2383 | else { |
2384 | //setModified( true ); | 2384 | //setModified( true ); |
2385 | mViewManager->setDocumentId( filename ); | 2385 | mViewManager->setDocumentId( filename ); |
2386 | mDialogManager->setDocumentId( filename ); | 2386 | mDialogManager->setDocumentId( filename ); |
2387 | mTodoList->setDocumentId( filename ); | 2387 | mTodoList->setDocumentId( filename ); |
2388 | } | 2388 | } |
2389 | globalFlagBlockAgenda = 2; | 2389 | globalFlagBlockAgenda = 2; |
2390 | // if ( getLastSyncEvent() ) | 2390 | // if ( getLastSyncEvent() ) |
2391 | // getLastSyncEvent()->setReadOnly( true ); | 2391 | // getLastSyncEvent()->setReadOnly( true ); |
2392 | mCalendar->reInitAlarmSettings(); | 2392 | mCalendar->reInitAlarmSettings(); |
2393 | setSyncEventsReadOnly(); | 2393 | setSyncEventsReadOnly(); |
2394 | //updateUnmanagedViews(); | 2394 | //updateUnmanagedViews(); |
2395 | //updateView(); | 2395 | //updateView(); |
2396 | if ( filename != MainWindow::defaultFileName() ) { | 2396 | if ( filename != MainWindow::defaultFileName() ) { |
2397 | saveCalendar( MainWindow::defaultFileName() ); | 2397 | saveCalendar( MainWindow::defaultFileName() ); |
2398 | } else { | 2398 | } else { |
2399 | QFileInfo finf ( MainWindow::defaultFileName()); | 2399 | QFileInfo finf ( MainWindow::defaultFileName()); |
2400 | if ( finf.exists() ) { | 2400 | if ( finf.exists() ) { |
2401 | setLoadedFileVersion( finf.lastModified () ); | 2401 | setLoadedFileVersion( finf.lastModified () ); |
2402 | } | 2402 | } |
2403 | } | 2403 | } |
2404 | return true; | 2404 | return true; |
2405 | } else { | 2405 | } else { |
2406 | // while failing to load, the calendar object could | 2406 | // while failing to load, the calendar object could |
2407 | // have become partially populated. Clear it out. | 2407 | // have become partially populated. Clear it out. |
2408 | if ( !merge ) { | 2408 | if ( !merge ) { |
2409 | mCalendar->close(); | 2409 | mCalendar->close(); |
2410 | mViewManager->setDocumentId( filename ); | 2410 | mViewManager->setDocumentId( filename ); |
2411 | mDialogManager->setDocumentId( filename ); | 2411 | mDialogManager->setDocumentId( filename ); |
2412 | mTodoList->setDocumentId( filename ); | 2412 | mTodoList->setDocumentId( filename ); |
2413 | } | 2413 | } |
2414 | 2414 | ||
2415 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2415 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2416 | 2416 | ||
2417 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2417 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2418 | globalFlagBlockAgenda = 2; | 2418 | globalFlagBlockAgenda = 2; |
2419 | mCalendar->reInitAlarmSettings(); | 2419 | mCalendar->reInitAlarmSettings(); |
2420 | setSyncEventsReadOnly(); | 2420 | setSyncEventsReadOnly(); |
2421 | updateUnmanagedViews(); | 2421 | updateUnmanagedViews(); |
2422 | updateView(); | 2422 | updateView(); |
2423 | } | 2423 | } |
2424 | return false; | 2424 | return false; |
2425 | } | 2425 | } |
2426 | void CalendarView::mergeFile( QString fn ) | 2426 | void CalendarView::mergeFile( QString fn ) |
2427 | { | 2427 | { |
2428 | clearAllViews(); | 2428 | clearAllViews(); |
2429 | mCalendar->mergeCalendarFile( fn ); | 2429 | mCalendar->mergeCalendarFile( fn ); |
2430 | mCalendar->reInitAlarmSettings(); | 2430 | mCalendar->reInitAlarmSettings(); |
2431 | setSyncEventsReadOnly(); | 2431 | setSyncEventsReadOnly(); |
2432 | updateUnmanagedViews(); | 2432 | updateUnmanagedViews(); |
2433 | updateView(); | 2433 | updateView(); |
2434 | } | 2434 | } |
2435 | void CalendarView::showOpenError() | 2435 | void CalendarView::showOpenError() |
2436 | { | 2436 | { |
2437 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2437 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2438 | } | 2438 | } |
2439 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2439 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2440 | { | 2440 | { |
2441 | loadedFileVersion = dt; | 2441 | loadedFileVersion = dt; |
2442 | } | 2442 | } |
2443 | bool CalendarView::checkFileChanged(QString fn) | 2443 | bool CalendarView::checkFileChanged(QString fn) |
2444 | { | 2444 | { |
2445 | QFileInfo finf ( fn ); | 2445 | QFileInfo finf ( fn ); |
2446 | if ( !finf.exists() ) | 2446 | if ( !finf.exists() ) |
2447 | return true; | 2447 | return true; |
2448 | QDateTime dt = finf.lastModified (); | 2448 | QDateTime dt = finf.lastModified (); |
2449 | if ( dt <= loadedFileVersion ) | 2449 | if ( dt <= loadedFileVersion ) |
2450 | return false; | 2450 | return false; |
2451 | return true; | 2451 | return true; |
2452 | 2452 | ||
2453 | } | 2453 | } |
2454 | void CalendarView::watchSavedFile() | 2454 | void CalendarView::watchSavedFile() |
2455 | { | 2455 | { |
2456 | QFileInfo finf ( MainWindow::defaultFileName()); | 2456 | QFileInfo finf ( MainWindow::defaultFileName()); |
2457 | if ( !finf.exists() ) | 2457 | if ( !finf.exists() ) |
2458 | return; | 2458 | return; |
2459 | QDateTime dt = finf.lastModified (); | 2459 | QDateTime dt = finf.lastModified (); |
2460 | if ( dt < loadedFileVersion ) { | 2460 | if ( dt < loadedFileVersion ) { |
2461 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2461 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2462 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2462 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2463 | return; | 2463 | return; |
2464 | } | 2464 | } |
2465 | loadedFileVersion = dt; | 2465 | loadedFileVersion = dt; |
2466 | } | 2466 | } |
2467 | bool CalendarView::checkAllFileVersions() | 2467 | bool CalendarView::checkAllFileVersions() |
2468 | { | 2468 | { |
2469 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2469 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2470 | KopiCalendarFile * cal = calendars.first(); | 2470 | KopiCalendarFile * cal = calendars.first(); |
2471 | mCalendar->setDefaultCalendar( 1 ); | 2471 | mCalendar->setDefaultCalendar( 1 ); |
2472 | mCalendar->setDefaultCalendarEnabledOnly(); | 2472 | mCalendar->setDefaultCalendarEnabledOnly(); |
2473 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2473 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2474 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2474 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2475 | restoreCalendarSettings(); | 2475 | restoreCalendarSettings(); |
2476 | return false; | 2476 | return false; |
2477 | } | 2477 | } |
2478 | } | 2478 | } |
2479 | cal = calendars.next(); | 2479 | cal = calendars.next(); |
2480 | QDateTime storeTemp = loadedFileVersion; | 2480 | QDateTime storeTemp = loadedFileVersion; |
2481 | while ( cal ) { | 2481 | while ( cal ) { |
2482 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2482 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2483 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2483 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2484 | mCalendar->setDefaultCalendarEnabledOnly(); | 2484 | mCalendar->setDefaultCalendarEnabledOnly(); |
2485 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2485 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2486 | if ( !checkFileVersion(cal->mFileName )) { | 2486 | if ( !checkFileVersion(cal->mFileName )) { |
2487 | loadedFileVersion = storeTemp; | 2487 | loadedFileVersion = storeTemp; |
2488 | restoreCalendarSettings(); | 2488 | restoreCalendarSettings(); |
2489 | return false; | 2489 | return false; |
2490 | } | 2490 | } |
2491 | } | 2491 | } |
2492 | cal = calendars.next(); | 2492 | cal = calendars.next(); |
2493 | } | 2493 | } |
2494 | loadedFileVersion = storeTemp; | 2494 | loadedFileVersion = storeTemp; |
2495 | return true; | 2495 | return true; |
2496 | } | 2496 | } |
2497 | bool CalendarView::checkFileVersion(QString fn) | 2497 | bool CalendarView::checkFileVersion(QString fn) |
2498 | { | 2498 | { |
2499 | QFileInfo finf ( fn ); | 2499 | QFileInfo finf ( fn ); |
2500 | if ( !finf.exists() ) | 2500 | if ( !finf.exists() ) |
2501 | return true; | 2501 | return true; |
2502 | QDateTime dt = finf.lastModified (); | 2502 | QDateTime dt = finf.lastModified (); |
2503 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2503 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2504 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2504 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2505 | if ( dt <= loadedFileVersion ) | 2505 | if ( dt <= loadedFileVersion ) |
2506 | return true; | 2506 | return true; |
2507 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2507 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2508 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2508 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2509 | i18n("Sync+save")); | 2509 | i18n("Sync+save")); |
2510 | 2510 | ||
2511 | if ( km == KMessageBox::Cancel ) | 2511 | if ( km == KMessageBox::Cancel ) |
2512 | return false; | 2512 | return false; |
2513 | if ( km == KMessageBox::Yes ) | 2513 | if ( km == KMessageBox::Yes ) |
2514 | return true; | 2514 | return true; |
2515 | 2515 | ||
2516 | setSyncDevice("deleteaftersync" ); | 2516 | setSyncDevice("deleteaftersync" ); |
2517 | mSyncManager->mAskForPreferences = true; | 2517 | mSyncManager->mAskForPreferences = true; |
2518 | mSyncManager->mSyncAlgoPrefs = 3; | 2518 | mSyncManager->mSyncAlgoPrefs = 3; |
2519 | mSyncManager->mWriteBackFile = false; | 2519 | mSyncManager->mWriteBackFile = false; |
2520 | mSyncManager->mWriteBackExistingOnly = false; | 2520 | mSyncManager->mWriteBackExistingOnly = false; |
2521 | mSyncManager->mShowSyncSummary = false; | 2521 | mSyncManager->mShowSyncSummary = false; |
2522 | syncCalendar( fn, 3 ); | 2522 | syncCalendar( fn, 3 ); |
2523 | Event * e = getLastSyncEvent(); | 2523 | Event * e = getLastSyncEvent(); |
2524 | if ( e ) | 2524 | if ( e ) |
2525 | mCalendar->deleteEvent( e ); | 2525 | mCalendar->deleteEvent( e ); |
2526 | return true; | 2526 | return true; |
2527 | } | 2527 | } |
2528 | bool CalendarView::saveCalendars() | 2528 | bool CalendarView::saveCalendars() |
2529 | { | 2529 | { |
2530 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2530 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2531 | KopiCalendarFile * cal = calendars.first(); | 2531 | KopiCalendarFile * cal = calendars.first(); |
2532 | mCalendar->setDefaultCalendar( 1 ); | 2532 | mCalendar->setDefaultCalendar( 1 ); |
2533 | mCalendar->setDefaultCalendarEnabledOnly(); | 2533 | mCalendar->setDefaultCalendarEnabledOnly(); |
2534 | QString saveError; | 2534 | QString saveError; |
2535 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) | 2535 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) |
2536 | saveError = cal->mName +"\n"; | 2536 | saveError = cal->mName +"\n"; |
2537 | cal = calendars.next(); | 2537 | cal = calendars.next(); |
2538 | while ( cal ) { | 2538 | while ( cal ) { |
2539 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2539 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2540 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2540 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2541 | mCalendar->setDefaultCalendarEnabledOnly(); | 2541 | mCalendar->setDefaultCalendarEnabledOnly(); |
2542 | if ( saveCalendar( cal->mFileName ) ) | 2542 | if ( saveCalendar( cal->mFileName ) ) |
2543 | cal->mLoadDt = QDateTime::currentDateTime(); | 2543 | cal->mLoadDt = QDateTime::currentDateTime(); |
2544 | else | 2544 | else |
2545 | saveError += cal->mName + "\n"; | 2545 | saveError += cal->mName + "\n"; |
2546 | } | 2546 | } |
2547 | cal = calendars.next(); | 2547 | cal = calendars.next(); |
2548 | } | 2548 | } |
2549 | restoreCalendarSettings(); | 2549 | restoreCalendarSettings(); |
2550 | if ( !saveError.isEmpty() ) { | 2550 | if ( !saveError.isEmpty() ) { |
2551 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; | 2551 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; |
2552 | KMessageBox::error(this, saveError, i18n("Error saving data")); | 2552 | KMessageBox::error(this, saveError, i18n("Error saving data")); |
2553 | return false; | 2553 | return false; |
2554 | } | 2554 | } |
2555 | return true; | 2555 | return true; |
2556 | } | 2556 | } |
2557 | bool CalendarView::saveCalendar( QString filename ) | 2557 | bool CalendarView::saveCalendar( QString filename ) |
2558 | { | 2558 | { |
2559 | 2559 | ||
2560 | // Store back all unsaved data into calendar object | 2560 | // Store back all unsaved data into calendar object |
2561 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2561 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2562 | if ( mViewManager->currentView() ) | 2562 | if ( mViewManager->currentView() ) |
2563 | mViewManager->currentView()->flushView(); | 2563 | mViewManager->currentView()->flushView(); |
2564 | 2564 | ||
2565 | 2565 | ||
2566 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2566 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2567 | mStorage->setSaveFormat( new ICalFormat() ); | 2567 | mStorage->setSaveFormat( new ICalFormat() ); |
2568 | mStorage->setFileName( filename ); | 2568 | mStorage->setFileName( filename ); |
2569 | bool success; | 2569 | bool success; |
2570 | success = mStorage->save(); | 2570 | success = mStorage->save(); |
2571 | if ( !success ) { | 2571 | if ( !success ) { |
2572 | return false; | 2572 | return false; |
2573 | } | 2573 | } |
2574 | if ( filename == MainWindow::defaultFileName() ) { | 2574 | if ( filename == MainWindow::defaultFileName() ) { |
2575 | setLoadedFileVersion( lfv ); | 2575 | setLoadedFileVersion( lfv ); |
2576 | watchSavedFile(); | 2576 | watchSavedFile(); |
2577 | } | 2577 | } |
2578 | return true; | 2578 | return true; |
2579 | } | 2579 | } |
2580 | 2580 | ||
2581 | void CalendarView::closeCalendar() | 2581 | void CalendarView::closeCalendar() |
2582 | { | 2582 | { |
2583 | 2583 | ||
2584 | // child windows no longer valid | 2584 | // child windows no longer valid |
2585 | clearAllViews(); | 2585 | clearAllViews(); |
2586 | emit closingDown(); | 2586 | emit closingDown(); |
2587 | 2587 | ||
2588 | mCalendar->close(); | 2588 | mCalendar->close(); |
2589 | setModified(false); | 2589 | setModified(false); |
2590 | updateView(); | 2590 | updateView(); |
2591 | } | 2591 | } |
2592 | 2592 | ||
2593 | void CalendarView::archiveCalendar() | 2593 | void CalendarView::archiveCalendar() |
2594 | { | 2594 | { |
2595 | mDialogManager->showArchiveDialog(); | 2595 | mDialogManager->showArchiveDialog(); |
2596 | } | 2596 | } |
2597 | 2597 | ||
2598 | 2598 | ||
2599 | void CalendarView::readSettings() | 2599 | void CalendarView::readSettings() |
2600 | { | 2600 | { |
2601 | 2601 | ||
2602 | 2602 | ||
2603 | // mViewManager->showAgendaView(); | 2603 | // mViewManager->showAgendaView(); |
2604 | QString str; | 2604 | QString str; |
2605 | //qDebug("CalendarView::readSettings() "); | 2605 | //qDebug("CalendarView::readSettings() "); |
2606 | // read settings from the KConfig, supplying reasonable | 2606 | // read settings from the KConfig, supplying reasonable |
2607 | // defaults where none are to be found | 2607 | // defaults where none are to be found |
2608 | KConfig *config = KOGlobals::config(); | 2608 | KConfig *config = KOGlobals::config(); |
2609 | #ifndef KORG_NOSPLITTER | 2609 | #ifndef KORG_NOSPLITTER |
2610 | config->setGroup("KOrganizer Geometry"); | 2610 | config->setGroup("KOrganizer Geometry"); |
2611 | 2611 | ||
2612 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2612 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2613 | if (sizes.count() != 2) { | 2613 | if (sizes.count() != 2) { |
2614 | sizes << mDateNavigator->minimumSizeHint().width(); | 2614 | sizes << mDateNavigator->minimumSizeHint().width(); |
2615 | sizes << 300; | 2615 | sizes << 300; |
2616 | } | 2616 | } |
2617 | mPanner->setSizes(sizes); | 2617 | mPanner->setSizes(sizes); |
2618 | 2618 | ||
2619 | sizes = config->readIntListEntry("Separator2"); | 2619 | sizes = config->readIntListEntry("Separator2"); |
2620 | if ( ( mResourceView && sizes.count() == 4 ) || | 2620 | if ( ( mResourceView && sizes.count() == 4 ) || |
2621 | ( !mResourceView && sizes.count() == 3 ) ) { | 2621 | ( !mResourceView && sizes.count() == 3 ) ) { |
2622 | mLeftSplitter->setSizes(sizes); | 2622 | mLeftSplitter->setSizes(sizes); |
2623 | } | 2623 | } |
2624 | #endif | 2624 | #endif |
2625 | globalFlagBlockAgenda = 1; | 2625 | globalFlagBlockAgenda = 1; |
2626 | mViewManager->showAgendaView(); | 2626 | mViewManager->showAgendaView(); |
2627 | //mViewManager->readSettings( config ); | 2627 | //mViewManager->readSettings( config ); |
2628 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2628 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2629 | readFilterSettings(config); | 2629 | readFilterSettings(config); |
2630 | 2630 | ||
2631 | #ifdef DESKTOP_VERSION | 2631 | #ifdef DESKTOP_VERSION |
2632 | config->setGroup("WidgetLayout"); | 2632 | config->setGroup("WidgetLayout"); |
2633 | QStringList list; | 2633 | QStringList list; |
2634 | list = config->readListEntry("MainLayout"); | 2634 | list = config->readListEntry("MainLayout"); |
2635 | int x,y,w,h; | 2635 | int x,y,w,h; |
2636 | if ( ! list.isEmpty() ) { | 2636 | if ( ! list.isEmpty() ) { |
2637 | x = list[0].toInt(); | 2637 | x = list[0].toInt(); |
2638 | y = list[1].toInt(); | 2638 | y = list[1].toInt(); |
2639 | w = list[2].toInt(); | 2639 | w = list[2].toInt(); |
2640 | h = list[3].toInt(); | 2640 | h = list[3].toInt(); |
2641 | KApplication::testCoords( &x,&y,&w,&h ); | 2641 | KApplication::testCoords( &x,&y,&w,&h ); |
2642 | topLevelWidget()->setGeometry(x,y,w,h); | 2642 | topLevelWidget()->setGeometry(x,y,w,h); |
2643 | 2643 | ||
2644 | } else { | 2644 | } else { |
2645 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2645 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2646 | } | 2646 | } |
2647 | list = config->readListEntry("EditEventLayout"); | 2647 | list = config->readListEntry("EditEventLayout"); |
2648 | if ( ! list.isEmpty() ) { | 2648 | if ( ! list.isEmpty() ) { |
2649 | x = list[0].toInt(); | 2649 | x = list[0].toInt(); |
2650 | y = list[1].toInt(); | 2650 | y = list[1].toInt(); |
2651 | w = list[2].toInt(); | 2651 | w = list[2].toInt(); |
2652 | h = list[3].toInt(); | 2652 | h = list[3].toInt(); |
2653 | KApplication::testCoords( &x,&y,&w,&h ); | 2653 | KApplication::testCoords( &x,&y,&w,&h ); |
2654 | mEventEditor->setGeometry(x,y,w,h); | 2654 | mEventEditor->setGeometry(x,y,w,h); |
2655 | 2655 | ||
2656 | } | 2656 | } |
2657 | list = config->readListEntry("EditTodoLayout"); | 2657 | list = config->readListEntry("EditTodoLayout"); |
2658 | if ( ! list.isEmpty() ) { | 2658 | if ( ! list.isEmpty() ) { |
2659 | x = list[0].toInt(); | 2659 | x = list[0].toInt(); |
2660 | y = list[1].toInt(); | 2660 | y = list[1].toInt(); |
2661 | w = list[2].toInt(); | 2661 | w = list[2].toInt(); |
2662 | h = list[3].toInt(); | 2662 | h = list[3].toInt(); |
2663 | KApplication::testCoords( &x,&y,&w,&h ); | 2663 | KApplication::testCoords( &x,&y,&w,&h ); |
2664 | mTodoEditor->setGeometry(x,y,w,h); | 2664 | mTodoEditor->setGeometry(x,y,w,h); |
2665 | 2665 | ||
2666 | } | 2666 | } |
2667 | list = config->readListEntry("ViewerLayout"); | 2667 | list = config->readListEntry("ViewerLayout"); |
2668 | if ( ! list.isEmpty() ) { | 2668 | if ( ! list.isEmpty() ) { |
2669 | x = list[0].toInt(); | 2669 | x = list[0].toInt(); |
2670 | y = list[1].toInt(); | 2670 | y = list[1].toInt(); |
2671 | w = list[2].toInt(); | 2671 | w = list[2].toInt(); |
2672 | h = list[3].toInt(); | 2672 | h = list[3].toInt(); |
2673 | KApplication::testCoords( &x,&y,&w,&h ); | 2673 | KApplication::testCoords( &x,&y,&w,&h ); |
2674 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2674 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2675 | } | 2675 | } |
2676 | #endif | 2676 | #endif |
2677 | config->setGroup( "Views" ); | 2677 | config->setGroup( "Views" ); |
2678 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2678 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2679 | 2679 | ||
2680 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2680 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2681 | 2681 | ||
2682 | int resetval = 0; | 2682 | int resetval = 0; |
2683 | int maxVal = 0; | 2683 | int maxVal = 0; |
2684 | if (sizes.count() != 3) { | 2684 | if (sizes.count() != 3) { |
2685 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2685 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2686 | resetval = mDateNavigator->sizeHint().width()+2; | 2686 | resetval = mDateNavigator->sizeHint().width()+2; |
2687 | } else { | 2687 | } else { |
2688 | resetval = mDateNavigator->sizeHint().height()+2; | 2688 | resetval = mDateNavigator->sizeHint().height()+2; |
2689 | } | 2689 | } |
2690 | } | 2690 | } |
2691 | if ( resetval ) { | 2691 | if ( resetval ) { |
2692 | sizes.clear(); | 2692 | sizes.clear(); |
2693 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2693 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2694 | maxVal = QApplication::desktop()->width() -10; | 2694 | maxVal = QApplication::desktop()->width() -10; |
2695 | } else { | 2695 | } else { |
2696 | maxVal = QApplication::desktop()->height()-10; | 2696 | maxVal = QApplication::desktop()->height()-10; |
2697 | } | 2697 | } |
2698 | sizes << resetval; | 2698 | sizes << resetval; |
2699 | if ( maxVal < resetval + resetval) | 2699 | if ( maxVal < resetval + resetval) |
2700 | resetval = maxVal - resetval; | 2700 | resetval = maxVal - resetval; |
2701 | sizes << resetval; | 2701 | sizes << resetval; |
2702 | sizes << 100; | 2702 | sizes << 100; |
2703 | } | 2703 | } |
2704 | mLeftFrame->setSizes(sizes); | 2704 | mLeftFrame->setSizes(sizes); |
2705 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2705 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2706 | resetval = 0; | 2706 | resetval = 0; |
2707 | maxVal = 0; | 2707 | maxVal = 0; |
2708 | if (sizes.count() != 2) { | 2708 | if (sizes.count() != 2) { |
2709 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2709 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2710 | resetval = mDateNavigator->sizeHint().width()+2; | 2710 | resetval = mDateNavigator->sizeHint().width()+2; |
2711 | } else { | 2711 | } else { |
2712 | resetval = mDateNavigator->sizeHint().height()+2; | 2712 | resetval = mDateNavigator->sizeHint().height()+2; |
2713 | } | 2713 | } |
2714 | } | 2714 | } |
2715 | if ( resetval ) { | 2715 | if ( resetval ) { |
2716 | sizes.clear(); | 2716 | sizes.clear(); |
2717 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2717 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2718 | maxVal = QApplication::desktop()->width() -10; | 2718 | maxVal = QApplication::desktop()->width() -10; |
2719 | } else { | 2719 | } else { |
2720 | maxVal = QApplication::desktop()->height()-10; | 2720 | maxVal = QApplication::desktop()->height()-10; |
2721 | } | 2721 | } |
2722 | sizes << resetval; | 2722 | sizes << resetval; |
2723 | if ( maxVal < resetval + resetval) | 2723 | if ( maxVal < resetval + resetval) |
2724 | resetval = maxVal - resetval; | 2724 | resetval = maxVal - resetval; |
2725 | sizes << resetval; | 2725 | sizes << resetval; |
2726 | } | 2726 | } |
2727 | mMainFrame->setSizes(sizes); | 2727 | mMainFrame->setSizes(sizes); |
2728 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2728 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2729 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2729 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2730 | else mNavigator->selectDates( dateCount ); | 2730 | else mNavigator->selectDates( dateCount ); |
2731 | // mViewManager->readSettings( config ); | 2731 | // mViewManager->readSettings( config ); |
2732 | updateConfig(); | 2732 | updateConfig(); |
2733 | globalFlagBlockAgenda = 2; | 2733 | globalFlagBlockAgenda = 2; |
2734 | mViewManager->readSettings( config ); | 2734 | mViewManager->readSettings( config ); |
2735 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2735 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2736 | } | 2736 | } |
2737 | 2737 | ||
2738 | void CalendarView::checkSuspendAlarm() | 2738 | void CalendarView::checkSuspendAlarm() |
2739 | { | 2739 | { |
2740 | if ( mSuspendTimer->isActive() ) { | 2740 | if ( mSuspendTimer->isActive() ) { |
2741 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2741 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2742 | } | 2742 | } |
2743 | } | 2743 | } |
2744 | void CalendarView::writeSettings() | 2744 | void CalendarView::writeSettings() |
2745 | { | 2745 | { |
2746 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2746 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2747 | 2747 | ||
2748 | KConfig *config = KOGlobals::config(); | 2748 | KConfig *config = KOGlobals::config(); |
2749 | 2749 | ||
2750 | mViewManager->writeSettings( config ); | 2750 | mViewManager->writeSettings( config ); |
2751 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2751 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2752 | mDialogManager->writeSettings( config ); | 2752 | mDialogManager->writeSettings( config ); |
2753 | //KOPrefs::instance()->usrWriteConfig(); | 2753 | //KOPrefs::instance()->usrWriteConfig(); |
2754 | KOPrefs::instance()->writeConfig(); | 2754 | KOPrefs::instance()->writeConfig(); |
2755 | 2755 | ||
2756 | writeFilterSettings(config); | 2756 | writeFilterSettings(config); |
2757 | config->setGroup( "AppRun" ); | 2757 | config->setGroup( "AppRun" ); |
2758 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2758 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2759 | int days = dt.daysTo( QDate::currentDate() ); | 2759 | int days = dt.daysTo( QDate::currentDate() ); |
2760 | dt = dt.addDays( days ); | 2760 | dt = dt.addDays( days ); |
2761 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2761 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2762 | config->writeEntry( "LatestProgramStopDays", days ); | 2762 | config->writeEntry( "LatestProgramStopDays", days ); |
2763 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2763 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2764 | //qDebug("KO: Writing stop time: %d ", secs); | 2764 | //qDebug("KO: Writing stop time: %d ", secs); |
2765 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2765 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2766 | //QDateTime latest = dt.addSecs ( secs ); | 2766 | //QDateTime latest = dt.addSecs ( secs ); |
2767 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2767 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2768 | config->setGroup( "Views" ); | 2768 | config->setGroup( "Views" ); |
2769 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2769 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2770 | 2770 | ||
2771 | #if 0 | 2771 | #if 0 |
2772 | qDebug("********************* "); | 2772 | qDebug("********************* "); |
2773 | qDebug("Testcode secsto "); | 2773 | qDebug("Testcode secsto "); |
2774 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2774 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2775 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2775 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2776 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2776 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2777 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2777 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2778 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2778 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2779 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2779 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2780 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2780 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2781 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2781 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2782 | qDebug("********************* testcode end"); | 2782 | qDebug("********************* testcode end"); |
2783 | 2783 | ||
2784 | #endif | 2784 | #endif |
2785 | 2785 | ||
2786 | QValueList<int> listINT = mLeftFrame->sizes(); | 2786 | QValueList<int> listINT = mLeftFrame->sizes(); |
2787 | config->writeEntry("Left Splitter Frame",listINT); | 2787 | config->writeEntry("Left Splitter Frame",listINT); |
2788 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2788 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2789 | config->writeEntry("Main Splitter Frame",listINT2); | 2789 | config->writeEntry("Main Splitter Frame",listINT2); |
2790 | #ifdef DESKTOP_VERSION | 2790 | #ifdef DESKTOP_VERSION |
2791 | config->setGroup("WidgetLayout"); | 2791 | config->setGroup("WidgetLayout"); |
2792 | QStringList list ;//= config->readListEntry("MainLayout"); | 2792 | QStringList list ;//= config->readListEntry("MainLayout"); |
2793 | int x,y,w,h; | 2793 | int x,y,w,h; |
2794 | QWidget* wid; | 2794 | QWidget* wid; |
2795 | wid = topLevelWidget(); | 2795 | wid = topLevelWidget(); |
2796 | x = wid->geometry().x(); | 2796 | x = wid->geometry().x(); |
2797 | y = wid->geometry().y(); | 2797 | y = wid->geometry().y(); |
2798 | w = wid->width(); | 2798 | w = wid->width(); |
2799 | h = wid->height(); | 2799 | h = wid->height(); |
2800 | list.clear(); | 2800 | list.clear(); |
2801 | list << QString::number( x ); | 2801 | list << QString::number( x ); |
2802 | list << QString::number( y ); | 2802 | list << QString::number( y ); |
2803 | list << QString::number( w ); | 2803 | list << QString::number( w ); |
2804 | list << QString::number( h ); | 2804 | list << QString::number( h ); |
2805 | config->writeEntry("MainLayout",list ); | 2805 | config->writeEntry("MainLayout",list ); |
2806 | 2806 | ||
2807 | wid = mEventEditor; | 2807 | wid = mEventEditor; |
2808 | x = wid->geometry().x(); | 2808 | x = wid->geometry().x(); |
2809 | y = wid->geometry().y(); | 2809 | y = wid->geometry().y(); |
2810 | w = wid->width(); | 2810 | w = wid->width(); |
2811 | h = wid->height(); | 2811 | h = wid->height(); |
2812 | list.clear(); | 2812 | list.clear(); |
2813 | list << QString::number( x ); | 2813 | list << QString::number( x ); |
2814 | list << QString::number( y ); | 2814 | list << QString::number( y ); |
2815 | list << QString::number( w ); | 2815 | list << QString::number( w ); |
2816 | list << QString::number( h ); | 2816 | list << QString::number( h ); |
2817 | config->writeEntry("EditEventLayout",list ); | 2817 | config->writeEntry("EditEventLayout",list ); |
2818 | 2818 | ||
2819 | wid = mTodoEditor; | 2819 | wid = mTodoEditor; |
2820 | x = wid->geometry().x(); | 2820 | x = wid->geometry().x(); |
2821 | y = wid->geometry().y(); | 2821 | y = wid->geometry().y(); |
2822 | w = wid->width(); | 2822 | w = wid->width(); |
2823 | h = wid->height(); | 2823 | h = wid->height(); |
2824 | list.clear(); | 2824 | list.clear(); |
2825 | list << QString::number( x ); | 2825 | list << QString::number( x ); |
2826 | list << QString::number( y ); | 2826 | list << QString::number( y ); |
2827 | list << QString::number( w ); | 2827 | list << QString::number( w ); |
2828 | list << QString::number( h ); | 2828 | list << QString::number( h ); |
2829 | config->writeEntry("EditTodoLayout",list ); | 2829 | config->writeEntry("EditTodoLayout",list ); |
2830 | wid = getEventViewerDialog(); | 2830 | wid = getEventViewerDialog(); |
2831 | x = wid->geometry().x(); | 2831 | x = wid->geometry().x(); |
2832 | y = wid->geometry().y(); | 2832 | y = wid->geometry().y(); |
2833 | w = wid->width(); | 2833 | w = wid->width(); |
2834 | h = wid->height(); | 2834 | h = wid->height(); |
2835 | list.clear(); | 2835 | list.clear(); |
2836 | list << QString::number( x ); | 2836 | list << QString::number( x ); |
2837 | list << QString::number( y ); | 2837 | list << QString::number( y ); |
2838 | list << QString::number( w ); | 2838 | list << QString::number( w ); |
2839 | list << QString::number( h ); | 2839 | list << QString::number( h ); |
2840 | config->writeEntry("ViewerLayout",list ); | 2840 | config->writeEntry("ViewerLayout",list ); |
2841 | wid = mDialogManager->getSearchDialog(); | 2841 | wid = mDialogManager->getSearchDialog(); |
2842 | if ( wid ) { | 2842 | if ( wid ) { |
2843 | x = wid->geometry().x(); | 2843 | x = wid->geometry().x(); |
2844 | y = wid->geometry().y(); | 2844 | y = wid->geometry().y(); |
2845 | w = wid->width(); | 2845 | w = wid->width(); |
2846 | h = wid->height(); | 2846 | h = wid->height(); |
2847 | list.clear(); | 2847 | list.clear(); |
2848 | list << QString::number( x ); | 2848 | list << QString::number( x ); |
2849 | list << QString::number( y ); | 2849 | list << QString::number( y ); |
2850 | list << QString::number( w ); | 2850 | list << QString::number( w ); |
2851 | list << QString::number( h ); | 2851 | list << QString::number( h ); |
2852 | config->writeEntry("SearchLayout",list ); | 2852 | config->writeEntry("SearchLayout",list ); |
2853 | } | 2853 | } |
2854 | #endif | 2854 | #endif |
2855 | 2855 | ||
2856 | 2856 | ||
2857 | config->sync(); | 2857 | config->sync(); |
2858 | } | 2858 | } |
2859 | 2859 | ||
2860 | void CalendarView::readFilterSettings(KConfig *config) | 2860 | void CalendarView::readFilterSettings(KConfig *config) |
2861 | { | 2861 | { |
2862 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2862 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2863 | 2863 | ||
2864 | mFilters.clear(); | 2864 | mFilters.clear(); |
2865 | 2865 | ||
2866 | config->setGroup("General"); | 2866 | config->setGroup("General"); |
2867 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2867 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2868 | 2868 | ||
2869 | QStringList::ConstIterator it = filterList.begin(); | 2869 | QStringList::ConstIterator it = filterList.begin(); |
2870 | QStringList::ConstIterator end = filterList.end(); | 2870 | QStringList::ConstIterator end = filterList.end(); |
2871 | while(it != end) { | 2871 | while(it != end) { |
2872 | // kdDebug() << " filter: " << (*it) << endl; | 2872 | // kdDebug() << " filter: " << (*it) << endl; |
2873 | 2873 | ||
2874 | CalFilter *filter; | 2874 | CalFilter *filter; |
2875 | filter = new CalFilter(*it); | 2875 | filter = new CalFilter(*it); |
2876 | config->setGroup("Filter_" + (*it).utf8()); | 2876 | config->setGroup("Filter_" + (*it).utf8()); |
2877 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2877 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2878 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2878 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2879 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2879 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2880 | mFilters.append(filter); | 2880 | mFilters.append(filter); |
2881 | 2881 | ||
2882 | ++it; | 2882 | ++it; |
2883 | } | 2883 | } |
2884 | 2884 | ||
2885 | if (mFilters.count() == 0) { | 2885 | if (mFilters.count() == 0) { |
2886 | CalFilter *filter = new CalFilter(i18n("Default")); | 2886 | CalFilter *filter = new CalFilter(i18n("Default")); |
2887 | mFilters.append(filter); | 2887 | mFilters.append(filter); |
2888 | } | 2888 | } |
2889 | mFilterView->updateFilters(); | 2889 | mFilterView->updateFilters(); |
2890 | config->setGroup("FilterView"); | 2890 | config->setGroup("FilterView"); |
2891 | 2891 | ||
2892 | mFilterView->blockSignals(true); | 2892 | mFilterView->blockSignals(true); |
2893 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2893 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2894 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2894 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2895 | mFilterView->blockSignals(false); | 2895 | mFilterView->blockSignals(false); |
2896 | // We do it manually to avoid it being done twice by the above calls | 2896 | // We do it manually to avoid it being done twice by the above calls |
2897 | updateFilter(); | 2897 | updateFilter(); |
2898 | } | 2898 | } |
2899 | 2899 | ||
2900 | void CalendarView::writeFilterSettings(KConfig *config) | 2900 | void CalendarView::writeFilterSettings(KConfig *config) |
2901 | { | 2901 | { |
2902 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2902 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2903 | 2903 | ||
2904 | QStringList filterList; | 2904 | QStringList filterList; |
2905 | 2905 | ||
2906 | CalFilter *filter = mFilters.first(); | 2906 | CalFilter *filter = mFilters.first(); |
2907 | while(filter) { | 2907 | while(filter) { |
2908 | // kdDebug() << " fn: " << filter->name() << endl; | 2908 | // kdDebug() << " fn: " << filter->name() << endl; |
2909 | filterList << filter->name(); | 2909 | filterList << filter->name(); |
2910 | config->setGroup("Filter_" + filter->name().utf8()); | 2910 | config->setGroup("Filter_" + filter->name().utf8()); |
2911 | config->writeEntry("Criteria",filter->criteria()); | 2911 | config->writeEntry("Criteria",filter->criteria()); |
2912 | config->writeEntry("CategoryList",filter->categoryList()); | 2912 | config->writeEntry("CategoryList",filter->categoryList()); |
2913 | filter = mFilters.next(); | 2913 | filter = mFilters.next(); |
2914 | } | 2914 | } |
2915 | config->setGroup("General"); | 2915 | config->setGroup("General"); |
2916 | config->writeEntry("CalendarFilters",filterList); | 2916 | config->writeEntry("CalendarFilters",filterList); |
2917 | 2917 | ||
2918 | config->setGroup("FilterView"); | 2918 | config->setGroup("FilterView"); |
2919 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2919 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2920 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2920 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2921 | } | 2921 | } |
2922 | 2922 | ||
2923 | 2923 | ||
2924 | void CalendarView::goToday() | 2924 | void CalendarView::goToday() |
2925 | { | 2925 | { |
2926 | if ( mViewManager->currentView()->isMonthView() ) | 2926 | if ( mViewManager->currentView()->isMonthView() ) |
2927 | mNavigator->selectTodayMonth(); | 2927 | mNavigator->selectTodayMonth(); |
2928 | else | 2928 | else |
2929 | mNavigator->selectToday(); | 2929 | mNavigator->selectToday(); |
2930 | } | 2930 | } |
2931 | 2931 | ||
2932 | void CalendarView::goNext() | 2932 | void CalendarView::goNext() |
2933 | { | 2933 | { |
2934 | mNavigator->selectNext(); | 2934 | mNavigator->selectNext(); |
2935 | } | 2935 | } |
2936 | 2936 | ||
2937 | void CalendarView::goPrevious() | 2937 | void CalendarView::goPrevious() |
2938 | { | 2938 | { |
2939 | mNavigator->selectPrevious(); | 2939 | mNavigator->selectPrevious(); |
2940 | } | 2940 | } |
2941 | void CalendarView::goNextMonth() | 2941 | void CalendarView::goNextMonth() |
2942 | { | 2942 | { |
2943 | mNavigator->selectNextMonth(); | 2943 | mNavigator->selectNextMonth(); |
2944 | } | 2944 | } |
2945 | 2945 | ||
2946 | void CalendarView::goPreviousMonth() | 2946 | void CalendarView::goPreviousMonth() |
2947 | { | 2947 | { |
2948 | mNavigator->selectPreviousMonth(); | 2948 | mNavigator->selectPreviousMonth(); |
2949 | } | 2949 | } |
2950 | 2950 | ||
2951 | void CalendarView::updateConfig() | 2951 | void CalendarView::updateConfig() |
2952 | { | 2952 | { |
2953 | if ( KOPrefs::instance()->mUseAppColors ) | 2953 | if ( KOPrefs::instance()->mUseAppColors ) |
2954 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2954 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2955 | emit configChanged(); | 2955 | emit configChanged(); |
2956 | mTodoList->updateConfig(); | 2956 | mTodoList->updateConfig(); |
2957 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2957 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2958 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2958 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2959 | // To make the "fill window" configurations work | 2959 | // To make the "fill window" configurations work |
2960 | //mViewManager->raiseCurrentView(); | 2960 | //mViewManager->raiseCurrentView(); |
2961 | } | 2961 | } |
2962 | 2962 | ||
2963 | 2963 | ||
2964 | void CalendarView::eventChanged(Event *event) | 2964 | void CalendarView::eventChanged(Event *event) |
2965 | { | 2965 | { |
2966 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2966 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2967 | //updateUnmanagedViews(); | 2967 | //updateUnmanagedViews(); |
2968 | } | 2968 | } |
2969 | 2969 | ||
2970 | void CalendarView::eventAdded(Event *event) | 2970 | void CalendarView::eventAdded(Event *event) |
2971 | { | 2971 | { |
2972 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2972 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2973 | } | 2973 | } |
2974 | 2974 | ||
2975 | void CalendarView::eventToBeDeleted(Event *) | 2975 | void CalendarView::eventToBeDeleted(Event *) |
2976 | { | 2976 | { |
2977 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2977 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2978 | } | 2978 | } |
2979 | 2979 | ||
2980 | void CalendarView::eventDeleted() | 2980 | void CalendarView::eventDeleted() |
2981 | { | 2981 | { |
2982 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2982 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2983 | } | 2983 | } |
2984 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2984 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2985 | { | 2985 | { |
2986 | changeIncidenceDisplay((Incidence *)which, action); | 2986 | changeIncidenceDisplay((Incidence *)which, action); |
2987 | mDateNavigator->updateView(); //LR | 2987 | mDateNavigator->updateView(); //LR |
2988 | //mDialogManager->updateSearchDialog(); | 2988 | //mDialogManager->updateSearchDialog(); |
2989 | 2989 | ||
2990 | if (which) { | 2990 | if (which) { |
2991 | mViewManager->updateWNview(); | 2991 | mViewManager->updateWNview(); |
2992 | //mTodoList->updateView(); | 2992 | //mTodoList->updateView(); |
2993 | } | 2993 | } |
2994 | 2994 | ||
2995 | } | 2995 | } |
2996 | 2996 | ||
2997 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2997 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2998 | { | 2998 | { |
2999 | updateUnmanagedViews(); | 2999 | updateUnmanagedViews(); |
3000 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 3000 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
3001 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 3001 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
3002 | mCalendar->checkAlarmForIncidence( 0, true ); | 3002 | mCalendar->checkAlarmForIncidence( 0, true ); |
3003 | if ( mEventViewerDialog ) | 3003 | if ( mEventViewerDialog ) |
3004 | mEventViewerDialog->hide(); | 3004 | mEventViewerDialog->hide(); |
3005 | } | 3005 | } |
3006 | else | 3006 | else |
3007 | mCalendar->checkAlarmForIncidence( which , false ); | 3007 | mCalendar->checkAlarmForIncidence( which , false ); |
3008 | } | 3008 | } |
3009 | 3009 | ||
3010 | // most of the changeEventDisplays() right now just call the view's | 3010 | // most of the changeEventDisplays() right now just call the view's |
3011 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 3011 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
3012 | void CalendarView::changeEventDisplay(Event *which, int action) | 3012 | void CalendarView::changeEventDisplay(Event *which, int action) |
3013 | { | 3013 | { |
3014 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 3014 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
3015 | changeIncidenceDisplay((Incidence *)which, action); | 3015 | changeIncidenceDisplay((Incidence *)which, action); |
3016 | static bool clearallviews = false; | 3016 | static bool clearallviews = false; |
3017 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 3017 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
3018 | if ( clearallviews ) { | 3018 | if ( clearallviews ) { |
3019 | clearAllViews(); | 3019 | clearAllViews(); |
3020 | clearallviews = false; | 3020 | clearallviews = false; |
3021 | } | 3021 | } |
3022 | return; | 3022 | return; |
3023 | } | 3023 | } |
3024 | clearallviews = true; | 3024 | clearallviews = true; |
3025 | mDateNavigator->updateView(); | 3025 | mDateNavigator->updateView(); |
3026 | //mDialogManager->updateSearchDialog(); | 3026 | //mDialogManager->updateSearchDialog(); |
3027 | if (which) { | 3027 | if (which) { |
3028 | // If there is an event view visible update the display | 3028 | // If there is an event view visible update the display |
3029 | mViewManager->currentView()->changeEventDisplay(which,action); | 3029 | mViewManager->currentView()->changeEventDisplay(which,action); |
3030 | // TODO: check, if update needed | 3030 | // TODO: check, if update needed |
3031 | // if (which->getTodoStatus()) { | 3031 | // if (which->getTodoStatus()) { |
3032 | mTodoList->updateView(); | 3032 | mTodoList->updateView(); |
3033 | if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { | 3033 | if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { |
3034 | mConflictingEvent = which ; | 3034 | mConflictingEvent = which ; |
3035 | int time = 1000; | 3035 | int time = 1000; |
3036 | #ifdef DESKTOP_VERSION | 3036 | #ifdef DESKTOP_VERSION |
3037 | time = 500; | 3037 | time = 500; |
3038 | #endif | 3038 | #endif |
3039 | bool checkC = false; | 3039 | bool checkC = false; |
3040 | if ( mConflictingEvent->doesFloat() ) { | 3040 | if ( mConflictingEvent->doesFloat() ) { |
3041 | checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay | 3041 | checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay |
3042 | || KOPrefs::instance()->mCheckConflictsAllDayNonAD; | 3042 | || KOPrefs::instance()->mCheckConflictsAllDayNonAD; |
3043 | } else { | 3043 | } else { |
3044 | checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay | 3044 | checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay |
3045 | || KOPrefs::instance()->mCheckConflictsNonADNonAD; | 3045 | || KOPrefs::instance()->mCheckConflictsNonADNonAD; |
3046 | } | 3046 | } |
3047 | if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) | ||
3048 | checkC = false; | ||
3047 | if ( checkC ) | 3049 | if ( checkC ) |
3048 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); | 3050 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); |
3049 | } | 3051 | } |
3050 | // } | 3052 | // } |
3051 | } else { | 3053 | } else { |
3052 | mViewManager->currentView()->updateView(); | 3054 | mViewManager->currentView()->updateView(); |
3053 | } | 3055 | } |
3054 | } | 3056 | } |
3055 | void CalendarView::checkConflictForEvent() | 3057 | void CalendarView::checkConflictForEvent() |
3056 | { | 3058 | { |
3057 | 3059 | ||
3058 | if (!KOPrefs::instance()->mConfirm) | 3060 | if (!KOPrefs::instance()->mConfirm) |
3059 | return; | 3061 | return; |
3060 | if ( ! mConflictingEvent ) return; | 3062 | if ( ! mConflictingEvent ) return; |
3061 | Event * conflictingEvent = mConflictingEvent; | 3063 | Event * conflictingEvent = mConflictingEvent; |
3062 | mConflictingEvent = 0; | 3064 | mConflictingEvent = 0; |
3063 | QDateTime current = QDateTime::currentDateTime(); | 3065 | QDateTime current = QDateTime::currentDateTime(); |
3064 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { | 3066 | if ( ! conflictingEvent->matchTime( ¤t, 0 ) ) { |
3065 | return; | 3067 | return; |
3066 | } | 3068 | } |
3067 | CalFilter *filterIN = 0; | 3069 | CalFilter *filterIN = 0; |
3068 | CalFilter *filterALL = 0; | 3070 | CalFilter *filterALL = 0; |
3069 | CalFilter *filter = mFilters.first(); | 3071 | CalFilter *filter = mFilters.first(); |
3070 | while(filter) { | 3072 | while(filter) { |
3071 | if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) | 3073 | if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) |
3072 | filterIN = filter; | 3074 | filterIN = filter; |
3073 | if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) | 3075 | if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) |
3074 | filterALL = filter; | 3076 | filterALL = filter; |
3075 | filter = mFilters.next(); | 3077 | filter = mFilters.next(); |
3076 | } | 3078 | } |
3077 | if ( filterIN ) { | 3079 | if ( filterIN ) { |
3078 | if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { | 3080 | if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { |
3079 | return; | 3081 | return; |
3080 | } | 3082 | } |
3081 | } | 3083 | } |
3082 | QPtrList<Event> testlist = mCalendar->events(); | 3084 | QPtrList<Event> testlist = mCalendar->events(); |
3083 | Event * test = testlist.first(); | 3085 | Event * test = testlist.first(); |
3084 | QDateTime conflict; | 3086 | QDateTime conflict; |
3085 | QDateTime retVal; | 3087 | QDateTime retVal; |
3086 | bool found = false; | 3088 | bool found = false; |
3087 | Event * cE = 0; | 3089 | Event * cE = 0; |
3088 | bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; | 3090 | bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; |
3089 | bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; | 3091 | bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; |
3090 | if ( !conflictingEvent->doesFloat() ) { | 3092 | if ( !conflictingEvent->doesFloat() ) { |
3091 | chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; | 3093 | chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; |
3092 | chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; | 3094 | chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; |
3093 | } | 3095 | } |
3094 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 3096 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
3095 | while ( test ) { | 3097 | while ( test ) { |
3096 | qApp->processEvents(); | 3098 | qApp->processEvents(); |
3097 | bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); | 3099 | bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); |
3100 | |||
3101 | if ( !skip ) { | ||
3102 | if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) | ||
3103 | skip = true; | ||
3104 | } | ||
3098 | if ( !skip ) { | 3105 | if ( !skip ) { |
3099 | if ( filterALL ) { | 3106 | if ( filterALL ) { |
3100 | if ( !filterALL->filterCalendarItem( test ) ) { | 3107 | if ( !filterALL->filterCalendarItem( test ) ) { |
3101 | skip = true; | 3108 | skip = true; |
3102 | } | 3109 | } |
3103 | } | 3110 | } |
3104 | if ( !skip ) { | 3111 | if ( !skip ) { |
3105 | if ( found ) | 3112 | if ( found ) |
3106 | skip = !test->matchTime( ¤t, &conflict ); | 3113 | skip = !test->matchTime( ¤t, &conflict ); |
3107 | else | 3114 | else |
3108 | skip = !test->matchTime( ¤t, 0 ); | 3115 | skip = !test->matchTime( ¤t, 0 ); |
3109 | if ( !skip ) { | 3116 | if ( !skip ) { |
3110 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 3117 | if ( conflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
3111 | if ( ! found ) { | 3118 | if ( ! found ) { |
3112 | conflict = retVal; | 3119 | conflict = retVal; |
3113 | cE = test; | 3120 | cE = test; |
3114 | } else { | 3121 | } else { |
3115 | if ( retVal < conflict ) { | 3122 | if ( retVal < conflict ) { |
3116 | conflict = retVal; | 3123 | conflict = retVal; |
3117 | cE = test; | 3124 | cE = test; |
3118 | } | 3125 | } |
3119 | } | 3126 | } |
3120 | found = true; | 3127 | found = true; |
3121 | } | 3128 | } |
3122 | } | 3129 | } |
3123 | } | 3130 | } |
3124 | } | 3131 | } |
3125 | test = testlist.next(); | 3132 | test = testlist.next(); |
3126 | } | 3133 | } |
3127 | topLevelWidget()->setCaption( i18n("KO/Pi") ); | 3134 | topLevelWidget()->setCaption( i18n("KO/Pi") ); |
3128 | if ( found ) { | 3135 | if ( found ) { |
3129 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 3136 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
3130 | qApp->processEvents(); | 3137 | qApp->processEvents(); |
3131 | int km = KMessageBox::warningContinueCancel(this,mess, | 3138 | int km = KMessageBox::warningContinueCancel(this,mess, |
3132 | i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); | 3139 | i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); |
3133 | if ( km != KMessageBox::Continue ) { | 3140 | if ( km != KMessageBox::Continue ) { |
3134 | return; | 3141 | return; |
3135 | } | 3142 | } |
3136 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 3143 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
3137 | mViewManager->showDayView(); | 3144 | mViewManager->showDayView(); |
3138 | mNavigator->slotDaySelect( conflict.date() ); | 3145 | mNavigator->slotDaySelect( conflict.date() ); |
3139 | int hour = conflict.time().hour(); | 3146 | int hour = conflict.time().hour(); |
3140 | mViewManager->agendaView()->setStartHour( hour ); | 3147 | mViewManager->agendaView()->setStartHour( hour ); |
3141 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 3148 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
3142 | } else | 3149 | } else |
3143 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 3150 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
3144 | return; | 3151 | return; |
3145 | 3152 | ||
3146 | } | 3153 | } |
3147 | 3154 | ||
3148 | void CalendarView::updateTodoViews() | 3155 | void CalendarView::updateTodoViews() |
3149 | { | 3156 | { |
3150 | mTodoList->updateView(); | 3157 | mTodoList->updateView(); |
3151 | mViewManager->currentView()->updateView(); | 3158 | mViewManager->currentView()->updateView(); |
3152 | 3159 | ||
3153 | } | 3160 | } |
3154 | 3161 | ||
3155 | 3162 | ||
3156 | 3163 | ||
3157 | void CalendarView::clearAllViews() | 3164 | void CalendarView::clearAllViews() |
3158 | { | 3165 | { |
3159 | mTodoList->clearList(); | 3166 | mTodoList->clearList(); |
3160 | mViewManager->clearAllViews(); | 3167 | mViewManager->clearAllViews(); |
3161 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 3168 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
3162 | if ( sd ) { | 3169 | if ( sd ) { |
3163 | KOListView* kol = sd->listview(); | 3170 | KOListView* kol = sd->listview(); |
3164 | if ( kol ) | 3171 | if ( kol ) |
3165 | kol->clearList(); | 3172 | kol->clearList(); |
3166 | } | 3173 | } |
3167 | } | 3174 | } |
3168 | void CalendarView::updateView() | 3175 | void CalendarView::updateView() |
3169 | { | 3176 | { |
3170 | static bool clearallviews = false; | 3177 | static bool clearallviews = false; |
3171 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 3178 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
3172 | if ( clearallviews ) { | 3179 | if ( clearallviews ) { |
3173 | clearAllViews(); | 3180 | clearAllViews(); |
3174 | clearallviews = false; | 3181 | clearallviews = false; |
3175 | } | 3182 | } |
3176 | return; | 3183 | return; |
3177 | } | 3184 | } |
3178 | clearallviews = true; | 3185 | clearallviews = true; |
3179 | DateList tmpList = mNavigator->selectedDates(); | 3186 | DateList tmpList = mNavigator->selectedDates(); |
3180 | 3187 | ||
3181 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 3188 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
3182 | mTodoList->updateView(); | 3189 | mTodoList->updateView(); |
3183 | // We assume that the navigator only selects consecutive days. | 3190 | // We assume that the navigator only selects consecutive days. |
3184 | updateView( tmpList.first(), tmpList.last() ); | 3191 | updateView( tmpList.first(), tmpList.last() ); |
3185 | } | 3192 | } |
3186 | 3193 | ||
3187 | void CalendarView::updateUnmanagedViews() | 3194 | void CalendarView::updateUnmanagedViews() |
3188 | { | 3195 | { |
3189 | mDateNavigator->updateDayMatrix(); | 3196 | mDateNavigator->updateDayMatrix(); |
3190 | } | 3197 | } |
3191 | 3198 | ||
3192 | int CalendarView::msgItemDelete(const QString name) | 3199 | int CalendarView::msgItemDelete(const QString name) |
3193 | { | 3200 | { |
3194 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 3201 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
3195 | i18n("This item will be\npermanently deleted."), | 3202 | i18n("This item will be\npermanently deleted."), |
3196 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 3203 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
3197 | } | 3204 | } |
3198 | 3205 | ||
3199 | 3206 | ||
3200 | void CalendarView::edit_cut() | 3207 | void CalendarView::edit_cut() |
3201 | { | 3208 | { |
3202 | Event *anEvent=0; | 3209 | Event *anEvent=0; |
3203 | 3210 | ||
3204 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3211 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3205 | 3212 | ||
3206 | if (mViewManager->currentView()->isEventView()) { | 3213 | if (mViewManager->currentView()->isEventView()) { |
3207 | if ( incidence && incidence->typeID() == eventID ) { | 3214 | if ( incidence && incidence->typeID() == eventID ) { |
3208 | anEvent = static_cast<Event *>(incidence); | 3215 | anEvent = static_cast<Event *>(incidence); |
3209 | } | 3216 | } |
3210 | } | 3217 | } |
3211 | 3218 | ||
3212 | if (!anEvent) { | 3219 | if (!anEvent) { |
3213 | KNotifyClient::beep(); | 3220 | KNotifyClient::beep(); |
3214 | return; | 3221 | return; |
3215 | } | 3222 | } |
3216 | DndFactory factory( mCalendar ); | 3223 | DndFactory factory( mCalendar ); |
3217 | factory.cutIncidence(anEvent); | 3224 | factory.cutIncidence(anEvent); |
3218 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3225 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3219 | } | 3226 | } |
3220 | 3227 | ||
3221 | void CalendarView::edit_copy() | 3228 | void CalendarView::edit_copy() |
3222 | { | 3229 | { |
3223 | Event *anEvent=0; | 3230 | Event *anEvent=0; |
3224 | 3231 | ||
3225 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3232 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3226 | 3233 | ||
3227 | if (mViewManager->currentView()->isEventView()) { | 3234 | if (mViewManager->currentView()->isEventView()) { |
3228 | if ( incidence && incidence->typeID() == eventID ) { | 3235 | if ( incidence && incidence->typeID() == eventID ) { |
3229 | anEvent = static_cast<Event *>(incidence); | 3236 | anEvent = static_cast<Event *>(incidence); |
3230 | } | 3237 | } |
3231 | } | 3238 | } |
3232 | 3239 | ||
3233 | if (!anEvent) { | 3240 | if (!anEvent) { |
3234 | KNotifyClient::beep(); | 3241 | KNotifyClient::beep(); |
3235 | return; | 3242 | return; |
3236 | } | 3243 | } |
3237 | DndFactory factory( mCalendar ); | 3244 | DndFactory factory( mCalendar ); |
3238 | factory.copyIncidence(anEvent); | 3245 | factory.copyIncidence(anEvent); |
3239 | } | 3246 | } |
3240 | 3247 | ||
3241 | void CalendarView::edit_paste() | 3248 | void CalendarView::edit_paste() |
3242 | { | 3249 | { |
3243 | QDate date = mNavigator->selectedDates().first(); | 3250 | QDate date = mNavigator->selectedDates().first(); |
3244 | 3251 | ||
3245 | DndFactory factory( mCalendar ); | 3252 | DndFactory factory( mCalendar ); |
3246 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 3253 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
3247 | 3254 | ||
3248 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 3255 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
3249 | } | 3256 | } |
3250 | void CalendarView::edit_global_options() | 3257 | void CalendarView::edit_global_options() |
3251 | { | 3258 | { |
3252 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 3259 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
3253 | emit save(); | 3260 | emit save(); |
3254 | emit saveStopTimer(); | 3261 | emit saveStopTimer(); |
3255 | mDialogManager->showGlobalOptionsDialog(); | 3262 | mDialogManager->showGlobalOptionsDialog(); |
3256 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 3263 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
3257 | emit saveStopTimer(); | 3264 | emit saveStopTimer(); |
3258 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 3265 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
3259 | i18n("Timezone settings"),i18n("Reload"))) { | 3266 | i18n("Timezone settings"),i18n("Reload"))) { |
3260 | qDebug("KO: TZ reload cancelled "); | 3267 | qDebug("KO: TZ reload cancelled "); |
3261 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3268 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3262 | return; | 3269 | return; |
3263 | } | 3270 | } |
3264 | qDebug("KO: Timezone change "); | 3271 | qDebug("KO: Timezone change "); |
3265 | loadCalendars(); | 3272 | loadCalendars(); |
3266 | setModified(true); | 3273 | setModified(true); |
3267 | } | 3274 | } |
3268 | else | 3275 | else |
3269 | qDebug("KO: No tz change "); | 3276 | qDebug("KO: No tz change "); |
3270 | } | 3277 | } |
3271 | void CalendarView::edit_options() | 3278 | void CalendarView::edit_options() |
3272 | { | 3279 | { |
3273 | mDialogManager->showOptionsDialog(); | 3280 | mDialogManager->showOptionsDialog(); |
3274 | } | 3281 | } |
3275 | 3282 | ||
3276 | 3283 | ||
3277 | void CalendarView::slotSelectPickerDate( QDate d) | 3284 | void CalendarView::slotSelectPickerDate( QDate d) |
3278 | { | 3285 | { |
3279 | mDateFrame->hide(); | 3286 | mDateFrame->hide(); |
3280 | if ( mDatePickerMode == 1 ) { | 3287 | if ( mDatePickerMode == 1 ) { |
3281 | mNavigator->slotDaySelect( d ); | 3288 | mNavigator->slotDaySelect( d ); |
3282 | } else if ( mDatePickerMode == 2 ) { | 3289 | } else if ( mDatePickerMode == 2 ) { |
3283 | if ( mMoveIncidence->typeID() == todoID ) { | 3290 | if ( mMoveIncidence->typeID() == todoID ) { |
3284 | Todo * to = (Todo *) mMoveIncidence; | 3291 | Todo * to = (Todo *) mMoveIncidence; |
3285 | QTime tim; | 3292 | QTime tim; |
3286 | int len = 0; | 3293 | int len = 0; |
3287 | if ( to->hasStartDate() && to->hasDueDate() ) | 3294 | if ( to->hasStartDate() && to->hasDueDate() ) |
3288 | len = to->dtStart().secsTo( to->dtDue()); | 3295 | len = to->dtStart().secsTo( to->dtDue()); |
3289 | if ( to->hasDueDate() ) | 3296 | if ( to->hasDueDate() ) |
3290 | tim = to->dtDue().time(); | 3297 | tim = to->dtDue().time(); |
3291 | else { | 3298 | else { |
3292 | tim = QTime ( 0,0,0 ); | 3299 | tim = QTime ( 0,0,0 ); |
3293 | to->setFloats( true ); | 3300 | to->setFloats( true ); |
3294 | to->setHasDueDate( true ); | 3301 | to->setHasDueDate( true ); |
3295 | } | 3302 | } |
3296 | QDateTime dt ( d,tim ); | 3303 | QDateTime dt ( d,tim ); |
3297 | to->setDtDue( dt ); | 3304 | to->setDtDue( dt ); |
3298 | 3305 | ||
3299 | if ( to->hasStartDate() ) { | 3306 | if ( to->hasStartDate() ) { |
3300 | if ( len>0 ) | 3307 | if ( len>0 ) |
3301 | to->setDtStart(to->dtDue().addSecs( -len )); | 3308 | to->setDtStart(to->dtDue().addSecs( -len )); |
3302 | else | 3309 | else |
3303 | if (to->dtStart() > to->dtDue() ) | 3310 | if (to->dtStart() > to->dtDue() ) |
3304 | to->setDtStart(to->dtDue().addDays( -3 )); | 3311 | to->setDtStart(to->dtDue().addDays( -3 )); |
3305 | } | 3312 | } |
3306 | 3313 | ||
3307 | todoChanged( to ); | 3314 | todoChanged( to ); |
3308 | } else if ( mMoveIncidence->typeID() == eventID ) { | 3315 | } else if ( mMoveIncidence->typeID() == eventID ) { |
3309 | if ( mMoveIncidence->doesRecur() ) { | 3316 | if ( mMoveIncidence->doesRecur() ) { |
3310 | #if 0 | 3317 | #if 0 |
3311 | // PENDING implement this | 3318 | // PENDING implement this |
3312 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 3319 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3313 | mCalendar()->addIncidence( newInc ); | 3320 | mCalendar()->addIncidence( newInc ); |
3314 | if ( mMoveIncidence->typeID() == todoID ) | 3321 | if ( mMoveIncidence->typeID() == todoID ) |
3315 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 3322 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3316 | else | 3323 | else |
3317 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 3324 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3318 | mMoveIncidence = newInc; | 3325 | mMoveIncidence = newInc; |
3319 | 3326 | ||
3320 | #endif | 3327 | #endif |
3321 | } | 3328 | } |
3322 | QTime tim = mMoveIncidence->dtStart().time(); | 3329 | QTime tim = mMoveIncidence->dtStart().time(); |
3323 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 3330 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3324 | QDateTime dt ( d,tim ); | 3331 | QDateTime dt ( d,tim ); |
3325 | mMoveIncidence->setDtStart( dt ); | 3332 | mMoveIncidence->setDtStart( dt ); |
3326 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 3333 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3327 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 3334 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3328 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3335 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3329 | QTime tim = mMoveIncidence->dtStart().time(); | 3336 | QTime tim = mMoveIncidence->dtStart().time(); |
3330 | QDateTime dt ( d,tim ); | 3337 | QDateTime dt ( d,tim ); |
3331 | mMoveIncidence->setDtStart( dt ); | 3338 | mMoveIncidence->setDtStart( dt ); |
3332 | updateView(); | 3339 | updateView(); |
3333 | } | 3340 | } |
3334 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3341 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3335 | } | 3342 | } |
3336 | } | 3343 | } |
3337 | 3344 | ||
3338 | void CalendarView::removeCategories() | 3345 | void CalendarView::removeCategories() |
3339 | { | 3346 | { |
3340 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3347 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3341 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3348 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3342 | QStringList catIncList; | 3349 | QStringList catIncList; |
3343 | QStringList newCatList; | 3350 | QStringList newCatList; |
3344 | Incidence* inc = incList.first(); | 3351 | Incidence* inc = incList.first(); |
3345 | uint i; | 3352 | uint i; |
3346 | while ( inc ) { | 3353 | while ( inc ) { |
3347 | newCatList.clear(); | 3354 | newCatList.clear(); |
3348 | catIncList = inc->categories() ; | 3355 | catIncList = inc->categories() ; |
3349 | for( i = 0; i< catIncList.count(); ++i ) { | 3356 | for( i = 0; i< catIncList.count(); ++i ) { |
3350 | if ( catList.contains (catIncList[i])) | 3357 | if ( catList.contains (catIncList[i])) |
3351 | newCatList.append( catIncList[i] ); | 3358 | newCatList.append( catIncList[i] ); |
3352 | } | 3359 | } |
3353 | newCatList.sort(); | 3360 | newCatList.sort(); |
3354 | inc->setCategories( newCatList.join(",") ); | 3361 | inc->setCategories( newCatList.join(",") ); |
3355 | inc = incList.next(); | 3362 | inc = incList.next(); |
3356 | } | 3363 | } |
3357 | } | 3364 | } |
3358 | 3365 | ||
3359 | int CalendarView::addCategories() | 3366 | int CalendarView::addCategories() |
3360 | { | 3367 | { |
3361 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3368 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3362 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3369 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3363 | QStringList catIncList; | 3370 | QStringList catIncList; |
3364 | Incidence* inc = incList.first(); | 3371 | Incidence* inc = incList.first(); |
3365 | uint i; | 3372 | uint i; |
3366 | int count = 0; | 3373 | int count = 0; |
3367 | while ( inc ) { | 3374 | while ( inc ) { |
3368 | catIncList = inc->categories() ; | 3375 | catIncList = inc->categories() ; |
3369 | for( i = 0; i< catIncList.count(); ++i ) { | 3376 | for( i = 0; i< catIncList.count(); ++i ) { |
3370 | if ( !catList.contains (catIncList[i])) { | 3377 | if ( !catList.contains (catIncList[i])) { |
3371 | catList.append( catIncList[i] ); | 3378 | catList.append( catIncList[i] ); |
3372 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3379 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3373 | ++count; | 3380 | ++count; |
3374 | } | 3381 | } |
3375 | } | 3382 | } |
3376 | inc = incList.next(); | 3383 | inc = incList.next(); |
3377 | } | 3384 | } |
3378 | catList.sort(); | 3385 | catList.sort(); |
3379 | KOPrefs::instance()->mCustomCategories = catList; | 3386 | KOPrefs::instance()->mCustomCategories = catList; |
3380 | return count; | 3387 | return count; |
3381 | } | 3388 | } |
3382 | 3389 | ||
3383 | void CalendarView::editCategories() | 3390 | void CalendarView::editCategories() |
3384 | { | 3391 | { |
3385 | qDebug("CalendarView::editCategories() "); | 3392 | qDebug("CalendarView::editCategories() "); |
3386 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3393 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3387 | ced.exec(); | 3394 | ced.exec(); |
3388 | } | 3395 | } |
3389 | void CalendarView::manageCategories() | 3396 | void CalendarView::manageCategories() |
3390 | { | 3397 | { |
3391 | KOCatPrefs* cp = new KOCatPrefs(); | 3398 | KOCatPrefs* cp = new KOCatPrefs(); |
3392 | cp->show(); | 3399 | cp->show(); |
3393 | int w =cp->sizeHint().width() ; | 3400 | int w =cp->sizeHint().width() ; |
3394 | int h = cp->sizeHint().height() ; | 3401 | int h = cp->sizeHint().height() ; |
3395 | int dw = QApplication::desktop()->width(); | 3402 | int dw = QApplication::desktop()->width(); |
3396 | int dh = QApplication::desktop()->height(); | 3403 | int dh = QApplication::desktop()->height(); |
3397 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3404 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3398 | if ( !cp->exec() ) { | 3405 | if ( !cp->exec() ) { |
3399 | delete cp; | 3406 | delete cp; |
3400 | return; | 3407 | return; |
3401 | } | 3408 | } |
3402 | int count = 0; | 3409 | int count = 0; |
3403 | if ( cp->addCat() ) { | 3410 | if ( cp->addCat() ) { |
3404 | count = addCategories(); | 3411 | count = addCategories(); |
3405 | if ( count ) { | 3412 | if ( count ) { |
3406 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3413 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3407 | writeSettings(); | 3414 | writeSettings(); |
3408 | } else | 3415 | } else |
3409 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3416 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3410 | } else { | 3417 | } else { |
3411 | removeCategories(); | 3418 | removeCategories(); |
3412 | updateView(); | 3419 | updateView(); |
3413 | } | 3420 | } |
3414 | delete cp; | 3421 | delete cp; |
3415 | } | 3422 | } |
3416 | 3423 | ||
3417 | void CalendarView::beamIncidence(Incidence * Inc) | 3424 | void CalendarView::beamIncidence(Incidence * Inc) |
3418 | { | 3425 | { |
3419 | QPtrList<Incidence> delSel ; | 3426 | QPtrList<Incidence> delSel ; |
3420 | delSel.append(Inc); | 3427 | delSel.append(Inc); |
3421 | beamIncidenceList( delSel ); | 3428 | beamIncidenceList( delSel ); |
3422 | } | 3429 | } |
3423 | void CalendarView::beamCalendar() | 3430 | void CalendarView::beamCalendar() |
3424 | { | 3431 | { |
3425 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3432 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3426 | //qDebug("beamCalendar() "); | 3433 | //qDebug("beamCalendar() "); |
3427 | beamIncidenceList( delSel ); | 3434 | beamIncidenceList( delSel ); |
3428 | } | 3435 | } |
3429 | void CalendarView::beamFilteredCalendar() | 3436 | void CalendarView::beamFilteredCalendar() |
3430 | { | 3437 | { |
3431 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3438 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3432 | //qDebug("beamFilteredCalendar() "); | 3439 | //qDebug("beamFilteredCalendar() "); |
3433 | beamIncidenceList( delSel ); | 3440 | beamIncidenceList( delSel ); |
3434 | } | 3441 | } |
3435 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3442 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3436 | { | 3443 | { |
3437 | 3444 | ||
3438 | KOBeamPrefs beamDialog; | 3445 | KOBeamPrefs beamDialog; |
3439 | if ( beamDialog.exec () == QDialog::Rejected ) | 3446 | if ( beamDialog.exec () == QDialog::Rejected ) |
3440 | return; | 3447 | return; |
3441 | #ifdef DESKTOP_VERSION | 3448 | #ifdef DESKTOP_VERSION |
3442 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3449 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3443 | #else | 3450 | #else |
3444 | QString fn = "/tmp/kopibeamfile"; | 3451 | QString fn = "/tmp/kopibeamfile"; |
3445 | #endif | 3452 | #endif |
3446 | QString mes; | 3453 | QString mes; |
3447 | bool createbup = true; | 3454 | bool createbup = true; |
3448 | if ( createbup ) { | 3455 | if ( createbup ) { |
3449 | QString description = "\n"; | 3456 | QString description = "\n"; |
3450 | CalendarLocal* cal = new CalendarLocal(); | 3457 | CalendarLocal* cal = new CalendarLocal(); |
3451 | if ( beamDialog.beamLocal() ) | 3458 | if ( beamDialog.beamLocal() ) |
3452 | cal->setLocalTime(); | 3459 | cal->setLocalTime(); |
3453 | else | 3460 | else |
3454 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3461 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3455 | Incidence *incidence = delSel.first(); | 3462 | Incidence *incidence = delSel.first(); |
3456 | bool addText = false; | 3463 | bool addText = false; |
3457 | if ( delSel.count() < 10 ) | 3464 | if ( delSel.count() < 10 ) |
3458 | addText = true; | 3465 | addText = true; |
3459 | else { | 3466 | else { |
3460 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3467 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3461 | } | 3468 | } |
3462 | while ( incidence ) { | 3469 | while ( incidence ) { |
3463 | Incidence *in = incidence->clone(); | 3470 | Incidence *in = incidence->clone(); |
3464 | if ( ! in->summary().isEmpty() ) { | 3471 | if ( ! in->summary().isEmpty() ) { |
3465 | in->setDescription(""); | 3472 | in->setDescription(""); |
3466 | } else { | 3473 | } else { |
3467 | in->setSummary( in->description().left(20)); | 3474 | in->setSummary( in->description().left(20)); |
3468 | in->setDescription(""); | 3475 | in->setDescription(""); |
3469 | } | 3476 | } |
3470 | if ( addText ) | 3477 | if ( addText ) |
3471 | description += in->summary() + "\n"; | 3478 | description += in->summary() + "\n"; |
3472 | cal->addIncidence( in ); | 3479 | cal->addIncidence( in ); |
3473 | incidence = delSel.next(); | 3480 | incidence = delSel.next(); |
3474 | } | 3481 | } |
3475 | if ( beamDialog.beamVcal() ) { | 3482 | if ( beamDialog.beamVcal() ) { |
3476 | fn += ".vcs"; | 3483 | fn += ".vcs"; |
3477 | FileStorage storage( cal, fn, new VCalFormat ); | 3484 | FileStorage storage( cal, fn, new VCalFormat ); |
3478 | storage.save(); | 3485 | storage.save(); |
3479 | } else { | 3486 | } else { |
3480 | fn += ".ics"; | 3487 | fn += ".ics"; |
3481 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3488 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3482 | storage.save(); | 3489 | storage.save(); |
3483 | } | 3490 | } |
3484 | delete cal; | 3491 | delete cal; |
3485 | mes = i18n("KO/Pi: Ready for beaming"); | 3492 | mes = i18n("KO/Pi: Ready for beaming"); |
3486 | topLevelWidget()->setCaption(mes); | 3493 | topLevelWidget()->setCaption(mes); |
3487 | KApplication::convert2latin1( fn ); | 3494 | KApplication::convert2latin1( fn ); |
3488 | #ifndef DESKTOP_VERSION | 3495 | #ifndef DESKTOP_VERSION |
3489 | Ir *ir = new Ir( this ); | 3496 | Ir *ir = new Ir( this ); |
3490 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3497 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3491 | ir->send( fn, description, "text/x-vCalendar" ); | 3498 | ir->send( fn, description, "text/x-vCalendar" ); |
3492 | #endif | 3499 | #endif |
3493 | } | 3500 | } |
3494 | } | 3501 | } |
3495 | 3502 | ||
3496 | #ifndef DESKTOP_VERSION | 3503 | #ifndef DESKTOP_VERSION |
3497 | void CalendarView::beamDone( Ir *ir ) | 3504 | void CalendarView::beamDone( Ir *ir ) |
3498 | { | 3505 | { |
3499 | delete ir; | 3506 | delete ir; |
3500 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3507 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3501 | topLevelWidget()->raise(); | 3508 | topLevelWidget()->raise(); |
3502 | } | 3509 | } |
3503 | #else | 3510 | #else |
3504 | void CalendarView::beamDone( Ir *){;} | 3511 | void CalendarView::beamDone( Ir *){;} |
3505 | #endif | 3512 | #endif |
3506 | void CalendarView::moveIncidence(Incidence * inc ) | 3513 | void CalendarView::moveIncidence(Incidence * inc ) |
3507 | { | 3514 | { |
3508 | if ( !inc ) return; | 3515 | if ( !inc ) return; |
3509 | showDatePickerPopup(); | 3516 | showDatePickerPopup(); |
3510 | mDatePickerMode = 2; | 3517 | mDatePickerMode = 2; |
3511 | mMoveIncidence = inc ; | 3518 | mMoveIncidence = inc ; |
3512 | QDate da; | 3519 | QDate da; |
3513 | if ( mMoveIncidence->typeID() == todoID ) { | 3520 | if ( mMoveIncidence->typeID() == todoID ) { |
3514 | Todo * to = (Todo *) mMoveIncidence; | 3521 | Todo * to = (Todo *) mMoveIncidence; |
3515 | if ( to->hasDueDate() ) | 3522 | if ( to->hasDueDate() ) |
3516 | da = to->dtDue().date(); | 3523 | da = to->dtDue().date(); |
3517 | else | 3524 | else |
3518 | da = QDate::currentDate(); | 3525 | da = QDate::currentDate(); |
3519 | } else { | 3526 | } else { |
3520 | da = mMoveIncidence->dtStart().date(); | 3527 | da = mMoveIncidence->dtStart().date(); |
3521 | } | 3528 | } |
3522 | //PENDING set date for recurring incidence to date of recurrence | 3529 | //PENDING set date for recurring incidence to date of recurrence |
3523 | //mMoveIncidenceOldDate; | 3530 | //mMoveIncidenceOldDate; |
3524 | mDatePicker->setDate( da ); | 3531 | mDatePicker->setDate( da ); |
3525 | } | 3532 | } |
3526 | void CalendarView::showDatePickerPopup() | 3533 | void CalendarView::showDatePickerPopup() |
3527 | { | 3534 | { |
3528 | if ( mDateFrame->isVisible() ) | 3535 | if ( mDateFrame->isVisible() ) |
3529 | mDateFrame->hide(); | 3536 | mDateFrame->hide(); |
3530 | else { | 3537 | else { |
3531 | int offX = 0, offY = 0; | 3538 | int offX = 0, offY = 0; |
3532 | #ifdef DESKTOP_VERSION | 3539 | #ifdef DESKTOP_VERSION |
3533 | int w =mDatePicker->sizeHint().width() ; | 3540 | int w =mDatePicker->sizeHint().width() ; |
3534 | int h = mDatePicker->sizeHint().height() ; | 3541 | int h = mDatePicker->sizeHint().height() ; |
3535 | int dw = topLevelWidget()->width(); | 3542 | int dw = topLevelWidget()->width(); |
3536 | int dh = topLevelWidget()->height(); | 3543 | int dh = topLevelWidget()->height(); |
3537 | offX = topLevelWidget()->x(); | 3544 | offX = topLevelWidget()->x(); |
3538 | offY = topLevelWidget()->y(); | 3545 | offY = topLevelWidget()->y(); |
3539 | #else | 3546 | #else |
3540 | int w =mDatePicker->sizeHint().width() ; | 3547 | int w =mDatePicker->sizeHint().width() ; |
3541 | int h = mDatePicker->sizeHint().height() ; | 3548 | int h = mDatePicker->sizeHint().height() ; |
3542 | int dw = QApplication::desktop()->width(); | 3549 | int dw = QApplication::desktop()->width(); |
3543 | int dh = QApplication::desktop()->height(); | 3550 | int dh = QApplication::desktop()->height(); |
3544 | #endif | 3551 | #endif |
3545 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3552 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3546 | mDateFrame->show(); | 3553 | mDateFrame->show(); |
3547 | } | 3554 | } |
3548 | } | 3555 | } |
3549 | void CalendarView::showDatePicker( ) | 3556 | void CalendarView::showDatePicker( ) |
3550 | { | 3557 | { |
3551 | showDatePickerPopup(); | 3558 | showDatePickerPopup(); |
3552 | mDatePickerMode = 1; | 3559 | mDatePickerMode = 1; |
3553 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3560 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3554 | } | 3561 | } |
3555 | 3562 | ||
3556 | void CalendarView::showEventEditor() | 3563 | void CalendarView::showEventEditor() |
3557 | { | 3564 | { |
3558 | #ifdef DESKTOP_VERSION | 3565 | #ifdef DESKTOP_VERSION |
3559 | int x,y,w,h; | 3566 | int x,y,w,h; |
3560 | x = mEventEditor->geometry().x(); | 3567 | x = mEventEditor->geometry().x(); |
3561 | y = mEventEditor->geometry().y(); | 3568 | y = mEventEditor->geometry().y(); |
3562 | w = mEventEditor->width(); | 3569 | w = mEventEditor->width(); |
3563 | h = mEventEditor->height(); | 3570 | h = mEventEditor->height(); |
3564 | mEventEditor->show(); | 3571 | mEventEditor->show(); |
3565 | mEventEditor->setGeometry(x,y,w,h); | 3572 | mEventEditor->setGeometry(x,y,w,h); |
3566 | #else | 3573 | #else |
3567 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3574 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3568 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3575 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3569 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3576 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3570 | qApp->processEvents(); | 3577 | qApp->processEvents(); |
3571 | delete mEventEditor; | 3578 | delete mEventEditor; |
3572 | mEventEditor = mDialogManager->getEventEditor(); | 3579 | mEventEditor = mDialogManager->getEventEditor(); |
3573 | topLevelWidget()->setCaption( i18n("") ); | 3580 | topLevelWidget()->setCaption( i18n("") ); |
3574 | } | 3581 | } |
3575 | mEventEditor->showMaximized(); | 3582 | mEventEditor->showMaximized(); |
3576 | #endif | 3583 | #endif |
3577 | } | 3584 | } |
3578 | void CalendarView::showTodoEditor() | 3585 | void CalendarView::showTodoEditor() |
3579 | { | 3586 | { |
3580 | #ifdef DESKTOP_VERSION | 3587 | #ifdef DESKTOP_VERSION |
3581 | int x,y,w,h; | 3588 | int x,y,w,h; |
3582 | x = mTodoEditor->geometry().x(); | 3589 | x = mTodoEditor->geometry().x(); |
3583 | y = mTodoEditor->geometry().y(); | 3590 | y = mTodoEditor->geometry().y(); |
3584 | w = mTodoEditor->width(); | 3591 | w = mTodoEditor->width(); |
3585 | h = mTodoEditor->height(); | 3592 | h = mTodoEditor->height(); |
3586 | mTodoEditor->show(); | 3593 | mTodoEditor->show(); |
3587 | mTodoEditor->setGeometry(x,y,w,h); | 3594 | mTodoEditor->setGeometry(x,y,w,h); |
3588 | #else | 3595 | #else |
3589 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3596 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3590 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3597 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3591 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3598 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3592 | qApp->processEvents(); | 3599 | qApp->processEvents(); |
3593 | delete mTodoEditor; | 3600 | delete mTodoEditor; |
3594 | mTodoEditor = mDialogManager->getTodoEditor(); | 3601 | mTodoEditor = mDialogManager->getTodoEditor(); |
3595 | topLevelWidget()->setCaption( i18n("") ); | 3602 | topLevelWidget()->setCaption( i18n("") ); |
3596 | } | 3603 | } |
3597 | mTodoEditor->showMaximized(); | 3604 | mTodoEditor->showMaximized(); |
3598 | #endif | 3605 | #endif |
3599 | } | 3606 | } |
3600 | 3607 | ||
3601 | void CalendarView::cloneIncidence() | 3608 | void CalendarView::cloneIncidence() |
3602 | { | 3609 | { |
3603 | Incidence *incidence = currentSelection(); | 3610 | Incidence *incidence = currentSelection(); |
3604 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3611 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3605 | if ( incidence ) { | 3612 | if ( incidence ) { |
3606 | cloneIncidence(incidence); | 3613 | cloneIncidence(incidence); |
3607 | } | 3614 | } |
3608 | } | 3615 | } |
3609 | void CalendarView::moveIncidence() | 3616 | void CalendarView::moveIncidence() |
3610 | { | 3617 | { |
3611 | Incidence *incidence = currentSelection(); | 3618 | Incidence *incidence = currentSelection(); |
3612 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3619 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3613 | if ( incidence ) { | 3620 | if ( incidence ) { |
3614 | moveIncidence(incidence); | 3621 | moveIncidence(incidence); |
3615 | } | 3622 | } |
3616 | } | 3623 | } |
3617 | void CalendarView::beamIncidence() | 3624 | void CalendarView::beamIncidence() |
3618 | { | 3625 | { |
3619 | Incidence *incidence = currentSelection(); | 3626 | Incidence *incidence = currentSelection(); |
3620 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3627 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3621 | if ( incidence ) { | 3628 | if ( incidence ) { |
3622 | beamIncidence(incidence); | 3629 | beamIncidence(incidence); |
3623 | } | 3630 | } |
3624 | } | 3631 | } |
3625 | void CalendarView::toggleCancelIncidence() | 3632 | void CalendarView::toggleCancelIncidence() |
3626 | { | 3633 | { |
3627 | Incidence *incidence = currentSelection(); | 3634 | Incidence *incidence = currentSelection(); |
3628 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3635 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3629 | if ( incidence ) { | 3636 | if ( incidence ) { |
3630 | cancelIncidence(incidence); | 3637 | cancelIncidence(incidence); |
3631 | } | 3638 | } |
3632 | } | 3639 | } |
3633 | 3640 | ||
3634 | 3641 | ||
3635 | void CalendarView::cancelIncidence(Incidence * inc ) | 3642 | void CalendarView::cancelIncidence(Incidence * inc ) |
3636 | { | 3643 | { |
3637 | inc->setCancelled( ! inc->cancelled() ); | 3644 | inc->setCancelled( ! inc->cancelled() ); |
3638 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3645 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3639 | updateView(); | 3646 | updateView(); |
3640 | } | 3647 | } |
3641 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3648 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3642 | { | 3649 | { |
3643 | Incidence * newInc = orgInc->clone(); | 3650 | Incidence * newInc = orgInc->clone(); |
3644 | newInc->recreate(); | 3651 | newInc->recreate(); |
3645 | 3652 | ||
3646 | if ( newInc->typeID() == todoID ) { | 3653 | if ( newInc->typeID() == todoID ) { |
3647 | Todo* t = (Todo*) newInc; | 3654 | Todo* t = (Todo*) newInc; |
3648 | bool cloneSub = false; | 3655 | bool cloneSub = false; |
3649 | if ( orgInc->relations().count() ) { | 3656 | if ( orgInc->relations().count() ) { |
3650 | int result = KMessageBox::warningYesNoCancel(this, | 3657 | int result = KMessageBox::warningYesNoCancel(this, |
3651 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), | 3658 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), |
3652 | i18n("Todo has subtodos"), | 3659 | i18n("Todo has subtodos"), |
3653 | i18n("Yes"), | 3660 | i18n("Yes"), |
3654 | i18n("No")); | 3661 | i18n("No")); |
3655 | 3662 | ||
3656 | if ( result == KMessageBox::Cancel ) { | 3663 | if ( result == KMessageBox::Cancel ) { |
3657 | delete t; | 3664 | delete t; |
3658 | return; | 3665 | return; |
3659 | } | 3666 | } |
3660 | if (result == KMessageBox::Yes) cloneSub = true; | 3667 | if (result == KMessageBox::Yes) cloneSub = true; |
3661 | } | 3668 | } |
3662 | showTodoEditor(); | 3669 | showTodoEditor(); |
3663 | mTodoEditor->editTodo( t ); | 3670 | mTodoEditor->editTodo( t ); |
3664 | if ( mTodoEditor->exec() ) { | 3671 | if ( mTodoEditor->exec() ) { |
3665 | if ( cloneSub ) { | 3672 | if ( cloneSub ) { |
3666 | orgInc->cloneRelations( t ); | 3673 | orgInc->cloneRelations( t ); |
3667 | mCalendar->addIncidenceBranch( t ); | 3674 | mCalendar->addIncidenceBranch( t ); |
3668 | updateView(); | 3675 | updateView(); |
3669 | 3676 | ||
3670 | } else { | 3677 | } else { |
3671 | mCalendar->addTodo( t ); | 3678 | mCalendar->addTodo( t ); |
3672 | updateView(); | 3679 | updateView(); |
3673 | } | 3680 | } |
3674 | } else { | 3681 | } else { |
3675 | delete t; | 3682 | delete t; |
3676 | } | 3683 | } |
3677 | } | 3684 | } |
3678 | else if ( newInc->typeID() == eventID ) { | 3685 | else if ( newInc->typeID() == eventID ) { |
3679 | Event* e = (Event*) newInc; | 3686 | Event* e = (Event*) newInc; |
3680 | showEventEditor(); | 3687 | showEventEditor(); |
3681 | mEventEditor->editEvent( e ); | 3688 | mEventEditor->editEvent( e ); |
3682 | if ( mEventEditor->exec() ) { | 3689 | if ( mEventEditor->exec() ) { |
3683 | mCalendar->addEvent( e ); | 3690 | mCalendar->addEvent( e ); |
3684 | updateView(); | 3691 | updateView(); |
3685 | } else { | 3692 | } else { |
3686 | delete e; | 3693 | delete e; |
3687 | } | 3694 | } |
3688 | } else if ( newInc->typeID() == journalID ) { | 3695 | } else if ( newInc->typeID() == journalID ) { |
3689 | mCalendar->addJournal( (Journal*) newInc ); | 3696 | mCalendar->addJournal( (Journal*) newInc ); |
3690 | editJournal( (Journal*) newInc ); | 3697 | editJournal( (Journal*) newInc ); |
3691 | } | 3698 | } |
3692 | setActiveWindow(); | 3699 | setActiveWindow(); |
3693 | } | 3700 | } |
3694 | 3701 | ||
3695 | void CalendarView::newEvent() | 3702 | void CalendarView::newEvent() |
3696 | { | 3703 | { |
3697 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3704 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3698 | KOAgendaView *aView = mViewManager->agendaView(); | 3705 | KOAgendaView *aView = mViewManager->agendaView(); |
3699 | if (aView) { | 3706 | if (aView) { |
3700 | if (aView->selectionStart().isValid()) { | 3707 | if (aView->selectionStart().isValid()) { |
3701 | if (aView->selectedIsAllDay()) { | 3708 | if (aView->selectedIsAllDay()) { |
3702 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3709 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3703 | } else { | 3710 | } else { |
3704 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3711 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3705 | } | 3712 | } |
3706 | return; | 3713 | return; |
3707 | } | 3714 | } |
3708 | } | 3715 | } |
3709 | 3716 | ||
3710 | QDate date = mNavigator->selectedDates().first(); | 3717 | QDate date = mNavigator->selectedDates().first(); |
3711 | #if 0 | 3718 | #if 0 |
3712 | QDateTime current = QDateTime::currentDateTime(); | 3719 | QDateTime current = QDateTime::currentDateTime(); |
3713 | if ( date <= current.date() ) { | 3720 | if ( date <= current.date() ) { |
3714 | int hour = current.time().hour() +1; | 3721 | int hour = current.time().hour() +1; |
3715 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3722 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3716 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3723 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3717 | } else | 3724 | } else |
3718 | #endif | 3725 | #endif |
3719 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3726 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3720 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3727 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3721 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3728 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3722 | } | 3729 | } |
3723 | 3730 | ||
3724 | void CalendarView::newEvent(QDateTime fh) | 3731 | void CalendarView::newEvent(QDateTime fh) |
3725 | { | 3732 | { |
3726 | newEvent(fh, | 3733 | newEvent(fh, |
3727 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3734 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3728 | } | 3735 | } |
3729 | 3736 | ||
3730 | void CalendarView::newEvent(QDate dt) | 3737 | void CalendarView::newEvent(QDate dt) |
3731 | { | 3738 | { |
3732 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3739 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3733 | QDateTime(dt, QTime(0,0,0)), true); | 3740 | QDateTime(dt, QTime(0,0,0)), true); |
3734 | } | 3741 | } |
3735 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3742 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3736 | { | 3743 | { |
3737 | newEvent(fromHint, toHint, false); | 3744 | newEvent(fromHint, toHint, false); |
3738 | } | 3745 | } |
3739 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3746 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3740 | { | 3747 | { |
3741 | 3748 | ||
3742 | showEventEditor(); | 3749 | showEventEditor(); |
3743 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3750 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3744 | if ( mFilterView->filtersEnabled() ) { | 3751 | if ( mFilterView->filtersEnabled() ) { |
3745 | CalFilter *filter = mFilterView->selectedFilter(); | 3752 | CalFilter *filter = mFilterView->selectedFilter(); |
3746 | if (filter && filter->showCategories()) { | 3753 | if (filter && filter->showCategories()) { |
3747 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3754 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3748 | } | 3755 | } |
3749 | if ( filter ) | 3756 | if ( filter ) |
3750 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3757 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3751 | } | 3758 | } |
3752 | mEventEditor->exec(); | 3759 | mEventEditor->exec(); |
3753 | setActiveWindow(); | 3760 | setActiveWindow(); |
3754 | } | 3761 | } |
3755 | void CalendarView::todoAdded(Todo * t) | 3762 | void CalendarView::todoAdded(Todo * t) |
3756 | { | 3763 | { |
3757 | 3764 | ||
3758 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3765 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3759 | updateTodoViews(); | 3766 | updateTodoViews(); |
3760 | } | 3767 | } |
3761 | void CalendarView::todoChanged(Todo * t) | 3768 | void CalendarView::todoChanged(Todo * t) |
3762 | { | 3769 | { |
3763 | emit todoModified( t, 4 ); | 3770 | emit todoModified( t, 4 ); |
3764 | // updateTodoViews(); | 3771 | // updateTodoViews(); |
3765 | } | 3772 | } |
3766 | void CalendarView::todoToBeDeleted(Todo *) | 3773 | void CalendarView::todoToBeDeleted(Todo *) |
3767 | { | 3774 | { |
3768 | //qDebug("todoToBeDeleted(Todo *) "); | 3775 | //qDebug("todoToBeDeleted(Todo *) "); |
3769 | updateTodoViews(); | 3776 | updateTodoViews(); |
3770 | } | 3777 | } |
3771 | void CalendarView::todoDeleted() | 3778 | void CalendarView::todoDeleted() |
3772 | { | 3779 | { |
3773 | //qDebug(" todoDeleted()"); | 3780 | //qDebug(" todoDeleted()"); |
3774 | updateTodoViews(); | 3781 | updateTodoViews(); |
3775 | } | 3782 | } |
3776 | 3783 | ||
3777 | 3784 | ||
3778 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3785 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3779 | { | 3786 | { |
3780 | showTodoEditor(); | 3787 | showTodoEditor(); |
3781 | mTodoEditor->newTodo(dt,0,allday); | 3788 | mTodoEditor->newTodo(dt,0,allday); |
3782 | if ( mFilterView->filtersEnabled() ) { | 3789 | if ( mFilterView->filtersEnabled() ) { |
3783 | CalFilter *filter = mFilterView->selectedFilter(); | 3790 | CalFilter *filter = mFilterView->selectedFilter(); |
3784 | if (filter && filter->showCategories()) { | 3791 | if (filter && filter->showCategories()) { |
3785 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3792 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3786 | } | 3793 | } |
3787 | if ( filter ) | 3794 | if ( filter ) |
3788 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3795 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3789 | } | 3796 | } |
3790 | mTodoEditor->exec(); | 3797 | mTodoEditor->exec(); |
3791 | setActiveWindow(); | 3798 | setActiveWindow(); |
3792 | } | 3799 | } |
3793 | 3800 | ||
3794 | void CalendarView::newTodo() | 3801 | void CalendarView::newTodo() |
3795 | { | 3802 | { |
3796 | newTodoDateTime( QDateTime(),true ); | 3803 | newTodoDateTime( QDateTime(),true ); |
3797 | } | 3804 | } |
3798 | 3805 | ||
3799 | void CalendarView::newSubTodo() | 3806 | void CalendarView::newSubTodo() |
3800 | { | 3807 | { |
3801 | Todo *todo = selectedTodo(); | 3808 | Todo *todo = selectedTodo(); |
3802 | if ( todo ) newSubTodo( todo ); | 3809 | if ( todo ) newSubTodo( todo ); |
3803 | } | 3810 | } |
3804 | 3811 | ||
3805 | void CalendarView::newSubTodo(Todo *parentEvent) | 3812 | void CalendarView::newSubTodo(Todo *parentEvent) |
3806 | { | 3813 | { |
3807 | 3814 | ||
3808 | showTodoEditor(); | 3815 | showTodoEditor(); |
3809 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3816 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3810 | mTodoEditor->exec(); | 3817 | mTodoEditor->exec(); |
3811 | setActiveWindow(); | 3818 | setActiveWindow(); |
3812 | } | 3819 | } |
3813 | 3820 | ||
3814 | void CalendarView::newFloatingEvent() | 3821 | void CalendarView::newFloatingEvent() |
3815 | { | 3822 | { |
3816 | DateList tmpList = mNavigator->selectedDates(); | 3823 | DateList tmpList = mNavigator->selectedDates(); |
3817 | QDate date = tmpList.first(); | 3824 | QDate date = tmpList.first(); |
3818 | 3825 | ||
3819 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3826 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3820 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3827 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3821 | } | 3828 | } |
3822 | 3829 | ||
3823 | 3830 | ||
3824 | void CalendarView::editEvent( Event *event ) | 3831 | void CalendarView::editEvent( Event *event ) |
3825 | { | 3832 | { |
3826 | 3833 | ||
3827 | if ( !event ) return; | 3834 | if ( !event ) return; |
3828 | if ( event->isReadOnly() ) { | 3835 | if ( event->isReadOnly() ) { |
3829 | showEvent( event ); | 3836 | showEvent( event ); |
3830 | return; | 3837 | return; |
3831 | } | 3838 | } |
3832 | showEventEditor(); | 3839 | showEventEditor(); |
3833 | mEventEditor->editEvent( event , mFlagEditDescription); | 3840 | mEventEditor->editEvent( event , mFlagEditDescription); |
3834 | mEventEditor->exec(); | 3841 | mEventEditor->exec(); |
3835 | setActiveWindow(); | 3842 | setActiveWindow(); |
3836 | 3843 | ||
3837 | } | 3844 | } |
3838 | void CalendarView::editJournal( Journal *jour ) | 3845 | void CalendarView::editJournal( Journal *jour ) |
3839 | { | 3846 | { |
3840 | if ( !jour ) return; | 3847 | if ( !jour ) return; |
3841 | mDialogManager->hideSearchDialog(); | 3848 | mDialogManager->hideSearchDialog(); |
3842 | mViewManager->showJournalView(); | 3849 | mViewManager->showJournalView(); |
3843 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3850 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3844 | } | 3851 | } |
3845 | void CalendarView::editTodo( Todo *todo ) | 3852 | void CalendarView::editTodo( Todo *todo ) |
3846 | { | 3853 | { |
3847 | if ( !todo ) return; | 3854 | if ( !todo ) return; |
3848 | 3855 | ||
3849 | if ( todo->isReadOnly() ) { | 3856 | if ( todo->isReadOnly() ) { |
3850 | showTodo( todo ); | 3857 | showTodo( todo ); |
3851 | return; | 3858 | return; |
3852 | } | 3859 | } |
3853 | showTodoEditor(); | 3860 | showTodoEditor(); |
3854 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3861 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3855 | mTodoEditor->exec(); | 3862 | mTodoEditor->exec(); |
3856 | setActiveWindow(); | 3863 | setActiveWindow(); |
3857 | 3864 | ||
3858 | } | 3865 | } |
3859 | 3866 | ||
3860 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3867 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3861 | { | 3868 | { |
3862 | if ( !mEventViewerDialog ) { | 3869 | if ( !mEventViewerDialog ) { |
3863 | mEventViewerDialog = new KOEventViewerDialog(0); | 3870 | mEventViewerDialog = new KOEventViewerDialog(0); |
3864 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3871 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3865 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3872 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3866 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3873 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3867 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3874 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3868 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3875 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3869 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3876 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3870 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3877 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3871 | this, SLOT( slotViewerClosed() ) ); | 3878 | this, SLOT( slotViewerClosed() ) ); |
3872 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3879 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3873 | this, SLOT( todoChanged(Todo *) ) ); | 3880 | this, SLOT( todoChanged(Todo *) ) ); |
3874 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3881 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3875 | mEventViewerDialog->resize( 640, 480 ); | 3882 | mEventViewerDialog->resize( 640, 480 ); |
3876 | 3883 | ||
3877 | } | 3884 | } |
3878 | return mEventViewerDialog; | 3885 | return mEventViewerDialog; |
3879 | } | 3886 | } |
3880 | void CalendarView::showEvent(Event *event) | 3887 | void CalendarView::showEvent(Event *event) |
3881 | { | 3888 | { |
3882 | getEventViewerDialog()->setEvent(event); | 3889 | getEventViewerDialog()->setEvent(event); |
3883 | getEventViewerDialog()->showMe(); | 3890 | getEventViewerDialog()->showMe(); |
3884 | } | 3891 | } |
3885 | 3892 | ||
3886 | void CalendarView::showTodo(Todo *event) | 3893 | void CalendarView::showTodo(Todo *event) |
3887 | { | 3894 | { |
3888 | getEventViewerDialog()->setTodo(event); | 3895 | getEventViewerDialog()->setTodo(event); |
3889 | getEventViewerDialog()->showMe(); | 3896 | getEventViewerDialog()->showMe(); |
3890 | } | 3897 | } |
3891 | void CalendarView::showJournal( Journal *jour ) | 3898 | void CalendarView::showJournal( Journal *jour ) |
3892 | { | 3899 | { |
3893 | getEventViewerDialog()->setJournal(jour); | 3900 | getEventViewerDialog()->setJournal(jour); |
3894 | getEventViewerDialog()->showMe(); | 3901 | getEventViewerDialog()->showMe(); |
3895 | 3902 | ||
3896 | } | 3903 | } |
3897 | // void CalendarView::todoModified (Todo *event, int changed) | 3904 | // void CalendarView::todoModified (Todo *event, int changed) |
3898 | // { | 3905 | // { |
3899 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3906 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3900 | // // kdDebug() << "Todo modified and open" << endl; | 3907 | // // kdDebug() << "Todo modified and open" << endl; |
3901 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3908 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3902 | // // temp->modified (changed); | 3909 | // // temp->modified (changed); |
3903 | 3910 | ||
3904 | // // } | 3911 | // // } |
3905 | 3912 | ||
3906 | // mViewManager->updateView(); | 3913 | // mViewManager->updateView(); |
3907 | // } | 3914 | // } |
3908 | 3915 | ||
3909 | void CalendarView::appointment_show() | 3916 | void CalendarView::appointment_show() |
3910 | { | 3917 | { |
3911 | Event *anEvent = 0; | 3918 | Event *anEvent = 0; |
3912 | 3919 | ||
3913 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3920 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3914 | 3921 | ||
3915 | if (mViewManager->currentView()->isEventView()) { | 3922 | if (mViewManager->currentView()->isEventView()) { |
3916 | if ( incidence && incidence->typeID() == eventID ) { | 3923 | if ( incidence && incidence->typeID() == eventID ) { |
3917 | anEvent = static_cast<Event *>(incidence); | 3924 | anEvent = static_cast<Event *>(incidence); |
3918 | } | 3925 | } |
3919 | } | 3926 | } |
3920 | 3927 | ||
3921 | if (!anEvent) { | 3928 | if (!anEvent) { |
3922 | KNotifyClient::beep(); | 3929 | KNotifyClient::beep(); |
3923 | return; | 3930 | return; |
3924 | } | 3931 | } |
3925 | 3932 | ||
3926 | showEvent(anEvent); | 3933 | showEvent(anEvent); |
3927 | } | 3934 | } |
3928 | 3935 | ||
3929 | void CalendarView::appointment_edit() | 3936 | void CalendarView::appointment_edit() |
3930 | { | 3937 | { |
3931 | Event *anEvent = 0; | 3938 | Event *anEvent = 0; |
3932 | 3939 | ||
3933 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3940 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3934 | 3941 | ||
3935 | if (mViewManager->currentView()->isEventView()) { | 3942 | if (mViewManager->currentView()->isEventView()) { |
3936 | if ( incidence && incidence->typeID() == eventID ) { | 3943 | if ( incidence && incidence->typeID() == eventID ) { |
3937 | anEvent = static_cast<Event *>(incidence); | 3944 | anEvent = static_cast<Event *>(incidence); |
3938 | } | 3945 | } |
3939 | } | 3946 | } |
3940 | 3947 | ||
3941 | if (!anEvent) { | 3948 | if (!anEvent) { |
3942 | KNotifyClient::beep(); | 3949 | KNotifyClient::beep(); |
3943 | return; | 3950 | return; |
3944 | } | 3951 | } |
3945 | 3952 | ||
3946 | editEvent(anEvent); | 3953 | editEvent(anEvent); |
3947 | } | 3954 | } |
3948 | 3955 | ||
3949 | void CalendarView::appointment_delete() | 3956 | void CalendarView::appointment_delete() |
3950 | { | 3957 | { |
3951 | Event *anEvent = 0; | 3958 | Event *anEvent = 0; |
3952 | 3959 | ||
3953 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3960 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3954 | 3961 | ||
3955 | if (mViewManager->currentView()->isEventView()) { | 3962 | if (mViewManager->currentView()->isEventView()) { |
3956 | if ( incidence && incidence->typeID() == eventID ) { | 3963 | if ( incidence && incidence->typeID() == eventID ) { |
3957 | anEvent = static_cast<Event *>(incidence); | 3964 | anEvent = static_cast<Event *>(incidence); |
3958 | } | 3965 | } |
3959 | } | 3966 | } |
3960 | 3967 | ||
3961 | if (!anEvent) { | 3968 | if (!anEvent) { |
3962 | KNotifyClient::beep(); | 3969 | KNotifyClient::beep(); |
3963 | return; | 3970 | return; |
3964 | } | 3971 | } |
3965 | 3972 | ||
3966 | deleteEvent(anEvent); | 3973 | deleteEvent(anEvent); |
3967 | } | 3974 | } |
3968 | 3975 | ||
3969 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3976 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3970 | { | 3977 | { |
3971 | if (!sub) return; | 3978 | if (!sub) return; |
3972 | if ( sub->relatedTo() == parent ) | 3979 | if ( sub->relatedTo() == parent ) |
3973 | return; | 3980 | return; |
3974 | sub->setRelatedTo(parent); | 3981 | sub->setRelatedTo(parent); |
3975 | sub->updated(); | 3982 | sub->updated(); |
3976 | setModified(true); | 3983 | setModified(true); |
3977 | updateView(); | 3984 | updateView(); |
3978 | } | 3985 | } |
3979 | void CalendarView::todo_unsub(Todo *anTodo ) | 3986 | void CalendarView::todo_unsub(Todo *anTodo ) |
3980 | { | 3987 | { |
3981 | todo_resub( 0, anTodo ); | 3988 | todo_resub( 0, anTodo ); |
3982 | } | 3989 | } |
3983 | 3990 | ||
3984 | void CalendarView::deleteTodo(Todo *todo) | 3991 | void CalendarView::deleteTodo(Todo *todo) |
3985 | { | 3992 | { |
3986 | if (!todo) { | 3993 | if (!todo) { |
3987 | KNotifyClient::beep(); | 3994 | KNotifyClient::beep(); |
3988 | return; | 3995 | return; |
3989 | } | 3996 | } |
3990 | if (KOPrefs::instance()->mConfirm) { | 3997 | if (KOPrefs::instance()->mConfirm) { |
3991 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3998 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3992 | if (!todo->relations().isEmpty()) { | 3999 | if (!todo->relations().isEmpty()) { |
3993 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 4000 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3994 | 4001 | ||
3995 | } | 4002 | } |
3996 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 4003 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3997 | case KMessageBox::Continue: // OK | 4004 | case KMessageBox::Continue: // OK |
3998 | bool deleteT = false; | 4005 | bool deleteT = false; |
3999 | if (!todo->relations().isEmpty()) { | 4006 | if (!todo->relations().isEmpty()) { |
4000 | deleteT = removeCompletedSubTodos( todo ); | 4007 | deleteT = removeCompletedSubTodos( todo ); |
4001 | } | 4008 | } |
4002 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 4009 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
4003 | if ( !deleteT ) { | 4010 | if ( !deleteT ) { |
4004 | checkExternalId( todo ); | 4011 | checkExternalId( todo ); |
4005 | calendar()->deleteTodo(todo); | 4012 | calendar()->deleteTodo(todo); |
4006 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4013 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4007 | updateView(); | 4014 | updateView(); |
4008 | } | 4015 | } |
4009 | break; | 4016 | break; |
4010 | } // switch | 4017 | } // switch |
4011 | } else { | 4018 | } else { |
4012 | checkExternalId( todo ); | 4019 | checkExternalId( todo ); |
4013 | mCalendar->deleteTodo(todo); | 4020 | mCalendar->deleteTodo(todo); |
4014 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 4021 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
4015 | updateView(); | 4022 | updateView(); |
4016 | } | 4023 | } |
4017 | 4024 | ||
4018 | emit updateSearchDialog(); | 4025 | emit updateSearchDialog(); |
4019 | } | 4026 | } |
4020 | void CalendarView::deleteJournal(Journal *jour) | 4027 | void CalendarView::deleteJournal(Journal *jour) |
4021 | { | 4028 | { |
4022 | if (!jour) { | 4029 | if (!jour) { |
4023 | KNotifyClient::beep(); | 4030 | KNotifyClient::beep(); |
4024 | return; | 4031 | return; |
4025 | } | 4032 | } |
4026 | if (KOPrefs::instance()->mConfirm) { | 4033 | if (KOPrefs::instance()->mConfirm) { |
4027 | 4034 | ||
4028 | QString des; | 4035 | QString des; |
4029 | if ( !jour->summary().isEmpty() ) { | 4036 | if ( !jour->summary().isEmpty() ) { |
4030 | des = jour->summary(); | 4037 | des = jour->summary(); |
4031 | } else { | 4038 | } else { |
4032 | des = jour->description().left(30); | 4039 | des = jour->description().left(30); |
4033 | des = des.simplifyWhiteSpace (); | 4040 | des = des.simplifyWhiteSpace (); |
4034 | des.replace (QRegExp ("\\n"),"" ); | 4041 | des.replace (QRegExp ("\\n"),"" ); |
4035 | des.replace (QRegExp ("\\r"),"" ); | 4042 | des.replace (QRegExp ("\\r"),"" ); |
4036 | } | 4043 | } |
4037 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 4044 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
4038 | case KMessageBox::Continue: // OK | 4045 | case KMessageBox::Continue: // OK |
4039 | calendar()->deleteJournal(jour); | 4046 | calendar()->deleteJournal(jour); |
4040 | updateView(); | 4047 | updateView(); |
4041 | break; | 4048 | break; |
4042 | } // switch | 4049 | } // switch |
4043 | } else { | 4050 | } else { |
4044 | calendar()->deleteJournal(jour);; | 4051 | calendar()->deleteJournal(jour);; |
4045 | updateView(); | 4052 | updateView(); |
4046 | } | 4053 | } |
4047 | emit updateSearchDialog(); | 4054 | emit updateSearchDialog(); |
4048 | } | 4055 | } |
4049 | 4056 | ||
4050 | void CalendarView::deleteEvent(Event *anEvent) | 4057 | void CalendarView::deleteEvent(Event *anEvent) |
4051 | { | 4058 | { |
4052 | if (!anEvent) { | 4059 | if (!anEvent) { |
4053 | KNotifyClient::beep(); | 4060 | KNotifyClient::beep(); |
4054 | return; | 4061 | return; |
4055 | } | 4062 | } |
4056 | 4063 | ||
4057 | if (anEvent->doesRecur()) { | 4064 | if (anEvent->doesRecur()) { |
4058 | QDate itemDate = mViewManager->currentSelectionDate(); | 4065 | QDate itemDate = mViewManager->currentSelectionDate(); |
4059 | int km; | 4066 | int km; |
4060 | if (!itemDate.isValid()) { | 4067 | if (!itemDate.isValid()) { |
4061 | //kdDebug() << "Date Not Valid" << endl; | 4068 | //kdDebug() << "Date Not Valid" << endl; |
4062 | if (KOPrefs::instance()->mConfirm) { | 4069 | if (KOPrefs::instance()->mConfirm) { |
4063 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4070 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4064 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 4071 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
4065 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 4072 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
4066 | if ( km == KMessageBox::Continue ) | 4073 | if ( km == KMessageBox::Continue ) |
4067 | km = KMessageBox::No; // No = all below | 4074 | km = KMessageBox::No; // No = all below |
4068 | } else | 4075 | } else |
4069 | km = KMessageBox::No; | 4076 | km = KMessageBox::No; |
4070 | } else { | 4077 | } else { |
4071 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4078 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4072 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 4079 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
4073 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 4080 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
4074 | i18n("KO/Pi Confirmation"),i18n("Current"), | 4081 | i18n("KO/Pi Confirmation"),i18n("Current"), |
4075 | i18n("All")); | 4082 | i18n("All")); |
4076 | } | 4083 | } |
4077 | switch(km) { | 4084 | switch(km) { |
4078 | 4085 | ||
4079 | case KMessageBox::No: // Continue // all | 4086 | case KMessageBox::No: // Continue // all |
4080 | //qDebug("KMessageBox::No "); | 4087 | //qDebug("KMessageBox::No "); |
4081 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4088 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4082 | schedule(Scheduler::Cancel,anEvent); | 4089 | schedule(Scheduler::Cancel,anEvent); |
4083 | 4090 | ||
4084 | checkExternalId( anEvent); | 4091 | checkExternalId( anEvent); |
4085 | mCalendar->deleteEvent(anEvent); | 4092 | mCalendar->deleteEvent(anEvent); |
4086 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 4093 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
4087 | break; | 4094 | break; |
4088 | 4095 | ||
4089 | // Disabled because it does not work | 4096 | // Disabled because it does not work |
4090 | //#if 0 | 4097 | //#if 0 |
4091 | case KMessageBox::Yes: // just this one | 4098 | case KMessageBox::Yes: // just this one |
4092 | //QDate qd = mNavigator->selectedDates().first(); | 4099 | //QDate qd = mNavigator->selectedDates().first(); |
4093 | //if (!qd.isValid()) { | 4100 | //if (!qd.isValid()) { |
4094 | // kdDebug() << "no date selected, or invalid date" << endl; | 4101 | // kdDebug() << "no date selected, or invalid date" << endl; |
4095 | // KNotifyClient::beep(); | 4102 | // KNotifyClient::beep(); |
4096 | // return; | 4103 | // return; |
4097 | //} | 4104 | //} |
4098 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 4105 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
4099 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 4106 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
4100 | anEvent->addExDate(itemDate); | 4107 | anEvent->addExDate(itemDate); |
4101 | int duration = anEvent->recurrence()->duration(); | 4108 | int duration = anEvent->recurrence()->duration(); |
4102 | if ( duration > 0 ) { | 4109 | if ( duration > 0 ) { |
4103 | anEvent->recurrence()->setDuration( duration - 1 ); | 4110 | anEvent->recurrence()->setDuration( duration - 1 ); |
4104 | } | 4111 | } |
4105 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 4112 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
4106 | } | 4113 | } |
4107 | break; | 4114 | break; |
4108 | //#endif | 4115 | //#endif |
4109 | } // switch | 4116 | } // switch |
4110 | } else { | 4117 | } else { |
4111 | if (KOPrefs::instance()->mConfirm) { | 4118 | if (KOPrefs::instance()->mConfirm) { |
4112 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 4119 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
4113 | i18n("\nAre you sure you want\nto delete this event?"), | 4120 | i18n("\nAre you sure you want\nto delete this event?"), |
4114 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 4121 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
4115 | case KMessageBox::Continue: // OK | 4122 | case KMessageBox::Continue: // OK |
4116 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4123 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4117 | schedule(Scheduler::Cancel,anEvent); | 4124 | schedule(Scheduler::Cancel,anEvent); |
4118 | checkExternalId( anEvent); | 4125 | checkExternalId( anEvent); |
4119 | mCalendar->deleteEvent(anEvent); | 4126 | mCalendar->deleteEvent(anEvent); |
4120 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4127 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4121 | break; | 4128 | break; |
4122 | } // switch | 4129 | } // switch |
4123 | } else { | 4130 | } else { |
4124 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 4131 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
4125 | schedule(Scheduler::Cancel,anEvent); | 4132 | schedule(Scheduler::Cancel,anEvent); |
4126 | checkExternalId( anEvent); | 4133 | checkExternalId( anEvent); |
4127 | mCalendar->deleteEvent(anEvent); | 4134 | mCalendar->deleteEvent(anEvent); |
4128 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 4135 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
4129 | } | 4136 | } |
4130 | } // if-else | 4137 | } // if-else |
4131 | emit updateSearchDialog(); | 4138 | emit updateSearchDialog(); |
4132 | } | 4139 | } |
4133 | 4140 | ||
4134 | bool CalendarView::deleteEvent(const QString &uid) | 4141 | bool CalendarView::deleteEvent(const QString &uid) |
4135 | { | 4142 | { |
4136 | Event *ev = mCalendar->event(uid); | 4143 | Event *ev = mCalendar->event(uid); |
4137 | if (ev) { | 4144 | if (ev) { |
4138 | deleteEvent(ev); | 4145 | deleteEvent(ev); |
4139 | return true; | 4146 | return true; |
4140 | } else { | 4147 | } else { |
4141 | return false; | 4148 | return false; |
4142 | } | 4149 | } |
4143 | } | 4150 | } |
4144 | 4151 | ||
4145 | /*****************************************************************************/ | 4152 | /*****************************************************************************/ |
4146 | 4153 | ||
4147 | void CalendarView::action_mail() | 4154 | void CalendarView::action_mail() |
4148 | { | 4155 | { |
4149 | #ifndef KORG_NOMAIL | 4156 | #ifndef KORG_NOMAIL |
4150 | KOMailClient mailClient; | 4157 | KOMailClient mailClient; |
4151 | 4158 | ||
4152 | Incidence *incidence = currentSelection(); | 4159 | Incidence *incidence = currentSelection(); |
4153 | 4160 | ||
4154 | if (!incidence) { | 4161 | if (!incidence) { |
4155 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4162 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4156 | return; | 4163 | return; |
4157 | } | 4164 | } |
4158 | if(incidence->attendeeCount() == 0 ) { | 4165 | if(incidence->attendeeCount() == 0 ) { |
4159 | KMessageBox::sorry(this, | 4166 | KMessageBox::sorry(this, |
4160 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4167 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4161 | return; | 4168 | return; |
4162 | } | 4169 | } |
4163 | 4170 | ||
4164 | CalendarLocal cal_tmp; | 4171 | CalendarLocal cal_tmp; |
4165 | Event *event = 0; | 4172 | Event *event = 0; |
4166 | Event *ev = 0; | 4173 | Event *ev = 0; |
4167 | if ( incidence && incidence->typeID() == eventID ) { | 4174 | if ( incidence && incidence->typeID() == eventID ) { |
4168 | event = static_cast<Event *>(incidence); | 4175 | event = static_cast<Event *>(incidence); |
4169 | ev = new Event(*event); | 4176 | ev = new Event(*event); |
4170 | cal_tmp.addEvent(ev); | 4177 | cal_tmp.addEvent(ev); |
4171 | } | 4178 | } |
4172 | ICalFormat mForm(); | 4179 | ICalFormat mForm(); |
4173 | QString attachment = mForm.toString( &cal_tmp ); | 4180 | QString attachment = mForm.toString( &cal_tmp ); |
4174 | if (ev) delete(ev); | 4181 | if (ev) delete(ev); |
4175 | 4182 | ||
4176 | mailClient.mailAttendees(currentSelection(), attachment); | 4183 | mailClient.mailAttendees(currentSelection(), attachment); |
4177 | 4184 | ||
4178 | #endif | 4185 | #endif |
4179 | 4186 | ||
4180 | #if 0 | 4187 | #if 0 |
4181 | Event *anEvent = 0; | 4188 | Event *anEvent = 0; |
4182 | if (mViewManager->currentView()->isEventView()) { | 4189 | if (mViewManager->currentView()->isEventView()) { |
4183 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 4190 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
4184 | } | 4191 | } |
4185 | 4192 | ||
4186 | if (!anEvent) { | 4193 | if (!anEvent) { |
4187 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 4194 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
4188 | return; | 4195 | return; |
4189 | } | 4196 | } |
4190 | if(anEvent->attendeeCount() == 0 ) { | 4197 | if(anEvent->attendeeCount() == 0 ) { |
4191 | KMessageBox::sorry(this, | 4198 | KMessageBox::sorry(this, |
4192 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 4199 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
4193 | return; | 4200 | return; |
4194 | } | 4201 | } |
4195 | 4202 | ||
4196 | mailobject.emailEvent(anEvent); | 4203 | mailobject.emailEvent(anEvent); |
4197 | #endif | 4204 | #endif |
4198 | } | 4205 | } |
4199 | 4206 | ||
4200 | 4207 | ||
4201 | void CalendarView::schedule_publish(Incidence *incidence) | 4208 | void CalendarView::schedule_publish(Incidence *incidence) |
4202 | { | 4209 | { |
4203 | Event *event = 0; | 4210 | Event *event = 0; |
4204 | Todo *todo = 0; | 4211 | Todo *todo = 0; |
4205 | 4212 | ||
4206 | if (incidence == 0) { | 4213 | if (incidence == 0) { |
4207 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4214 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4208 | if (incidence == 0) { | 4215 | if (incidence == 0) { |
4209 | incidence = mTodoList->selectedIncidences().first(); | 4216 | incidence = mTodoList->selectedIncidences().first(); |
4210 | } | 4217 | } |
4211 | } | 4218 | } |
4212 | if ( incidence && incidence->typeID() == eventID ) { | 4219 | if ( incidence && incidence->typeID() == eventID ) { |
4213 | event = static_cast<Event *>(incidence); | 4220 | event = static_cast<Event *>(incidence); |
4214 | } else { | 4221 | } else { |
4215 | if ( incidence && incidence->typeID() == todoID ) { | 4222 | if ( incidence && incidence->typeID() == todoID ) { |
4216 | todo = static_cast<Todo *>(incidence); | 4223 | todo = static_cast<Todo *>(incidence); |
4217 | } | 4224 | } |
4218 | } | 4225 | } |
4219 | 4226 | ||
4220 | if (!event && !todo) { | 4227 | if (!event && !todo) { |
4221 | KMessageBox::sorry(this,i18n("No event selected.")); | 4228 | KMessageBox::sorry(this,i18n("No event selected.")); |
4222 | return; | 4229 | return; |
4223 | } | 4230 | } |
4224 | 4231 | ||
4225 | PublishDialog *publishdlg = new PublishDialog(); | 4232 | PublishDialog *publishdlg = new PublishDialog(); |
4226 | if (incidence->attendeeCount()>0) { | 4233 | if (incidence->attendeeCount()>0) { |
4227 | QPtrList<Attendee> attendees = incidence->attendees(); | 4234 | QPtrList<Attendee> attendees = incidence->attendees(); |
4228 | attendees.first(); | 4235 | attendees.first(); |
4229 | while ( attendees.current()!=0 ) { | 4236 | while ( attendees.current()!=0 ) { |
4230 | publishdlg->addAttendee(attendees.current()); | 4237 | publishdlg->addAttendee(attendees.current()); |
4231 | attendees.next(); | 4238 | attendees.next(); |
4232 | } | 4239 | } |
4233 | } | 4240 | } |
4234 | bool send = true; | 4241 | bool send = true; |
4235 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 4242 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
4236 | if ( publishdlg->exec() != QDialog::Accepted ) | 4243 | if ( publishdlg->exec() != QDialog::Accepted ) |
4237 | send = false; | 4244 | send = false; |
4238 | } | 4245 | } |
4239 | if ( send ) { | 4246 | if ( send ) { |
4240 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4247 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4241 | if ( event ) { | 4248 | if ( event ) { |
4242 | Event *ev = new Event(*event); | 4249 | Event *ev = new Event(*event); |
4243 | ev->registerObserver(0); | 4250 | ev->registerObserver(0); |
4244 | ev->clearAttendees(); | 4251 | ev->clearAttendees(); |
4245 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4252 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4246 | delete(ev); | 4253 | delete(ev); |
4247 | } | 4254 | } |
4248 | } else { | 4255 | } else { |
4249 | if ( todo ) { | 4256 | if ( todo ) { |
4250 | Todo *ev = new Todo(*todo); | 4257 | Todo *ev = new Todo(*todo); |
4251 | ev->registerObserver(0); | 4258 | ev->registerObserver(0); |
4252 | ev->clearAttendees(); | 4259 | ev->clearAttendees(); |
4253 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 4260 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
4254 | delete(ev); | 4261 | delete(ev); |
4255 | } | 4262 | } |
4256 | } | 4263 | } |
4257 | } | 4264 | } |
4258 | } | 4265 | } |
4259 | delete publishdlg; | 4266 | delete publishdlg; |
4260 | } | 4267 | } |
4261 | 4268 | ||
4262 | void CalendarView::schedule_request(Incidence *incidence) | 4269 | void CalendarView::schedule_request(Incidence *incidence) |
4263 | { | 4270 | { |
4264 | schedule(Scheduler::Request,incidence); | 4271 | schedule(Scheduler::Request,incidence); |
4265 | } | 4272 | } |
4266 | 4273 | ||
4267 | void CalendarView::schedule_refresh(Incidence *incidence) | 4274 | void CalendarView::schedule_refresh(Incidence *incidence) |
4268 | { | 4275 | { |
4269 | schedule(Scheduler::Refresh,incidence); | 4276 | schedule(Scheduler::Refresh,incidence); |
4270 | } | 4277 | } |
4271 | 4278 | ||
4272 | void CalendarView::schedule_cancel(Incidence *incidence) | 4279 | void CalendarView::schedule_cancel(Incidence *incidence) |
4273 | { | 4280 | { |
4274 | schedule(Scheduler::Cancel,incidence); | 4281 | schedule(Scheduler::Cancel,incidence); |
4275 | } | 4282 | } |
4276 | 4283 | ||
4277 | void CalendarView::schedule_add(Incidence *incidence) | 4284 | void CalendarView::schedule_add(Incidence *incidence) |
4278 | { | 4285 | { |
4279 | schedule(Scheduler::Add,incidence); | 4286 | schedule(Scheduler::Add,incidence); |
4280 | } | 4287 | } |
4281 | 4288 | ||
4282 | void CalendarView::schedule_reply(Incidence *incidence) | 4289 | void CalendarView::schedule_reply(Incidence *incidence) |
4283 | { | 4290 | { |
4284 | schedule(Scheduler::Reply,incidence); | 4291 | schedule(Scheduler::Reply,incidence); |
4285 | } | 4292 | } |
4286 | 4293 | ||
4287 | void CalendarView::schedule_counter(Incidence *incidence) | 4294 | void CalendarView::schedule_counter(Incidence *incidence) |
4288 | { | 4295 | { |
4289 | schedule(Scheduler::Counter,incidence); | 4296 | schedule(Scheduler::Counter,incidence); |
4290 | } | 4297 | } |
4291 | 4298 | ||
4292 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 4299 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
4293 | { | 4300 | { |
4294 | schedule(Scheduler::Declinecounter,incidence); | 4301 | schedule(Scheduler::Declinecounter,incidence); |
4295 | } | 4302 | } |
4296 | 4303 | ||
4297 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 4304 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
4298 | { | 4305 | { |
4299 | QDateTime start = QDateTime::currentDateTime(); | 4306 | QDateTime start = QDateTime::currentDateTime(); |
4300 | QDateTime end = start.addDays(daysToPublish); | 4307 | QDateTime end = start.addDays(daysToPublish); |
4301 | 4308 | ||
4302 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4309 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
4303 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4310 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
4304 | 4311 | ||
4305 | 4312 | ||
4306 | PublishDialog *publishdlg = new PublishDialog(); | 4313 | PublishDialog *publishdlg = new PublishDialog(); |
4307 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4314 | if ( publishdlg->exec() == QDialog::Accepted ) { |
4308 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4315 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4309 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4316 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
4310 | delete(freebusy); | 4317 | delete(freebusy); |
4311 | } | 4318 | } |
4312 | } | 4319 | } |
4313 | delete publishdlg; | 4320 | delete publishdlg; |
4314 | } | 4321 | } |
4315 | 4322 | ||
4316 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4323 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4317 | { | 4324 | { |
4318 | Event *event = 0; | 4325 | Event *event = 0; |
4319 | Todo *todo = 0; | 4326 | Todo *todo = 0; |
4320 | 4327 | ||
4321 | if (incidence == 0) { | 4328 | if (incidence == 0) { |
4322 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4329 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4323 | if (incidence == 0) { | 4330 | if (incidence == 0) { |
4324 | incidence = mTodoList->selectedIncidences().first(); | 4331 | incidence = mTodoList->selectedIncidences().first(); |
4325 | } | 4332 | } |
4326 | } | 4333 | } |
4327 | if ( incidence && incidence->typeID() == eventID ) { | 4334 | if ( incidence && incidence->typeID() == eventID ) { |
4328 | event = static_cast<Event *>(incidence); | 4335 | event = static_cast<Event *>(incidence); |
4329 | } | 4336 | } |
4330 | if ( incidence && incidence->typeID() == todoID ) { | 4337 | if ( incidence && incidence->typeID() == todoID ) { |
4331 | todo = static_cast<Todo *>(incidence); | 4338 | todo = static_cast<Todo *>(incidence); |
4332 | } | 4339 | } |
4333 | 4340 | ||
4334 | if (!event && !todo) { | 4341 | if (!event && !todo) { |
4335 | KMessageBox::sorry(this,i18n("No event selected.")); | 4342 | KMessageBox::sorry(this,i18n("No event selected.")); |
4336 | return; | 4343 | return; |
4337 | } | 4344 | } |
4338 | 4345 | ||
4339 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4346 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4340 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4347 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4341 | return; | 4348 | return; |
4342 | } | 4349 | } |
4343 | 4350 | ||
4344 | Event *ev = 0; | 4351 | Event *ev = 0; |
4345 | if (event) ev = new Event(*event); | 4352 | if (event) ev = new Event(*event); |
4346 | Todo *to = 0; | 4353 | Todo *to = 0; |
4347 | if (todo) to = new Todo(*todo); | 4354 | if (todo) to = new Todo(*todo); |
4348 | 4355 | ||
4349 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4356 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4350 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4357 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4351 | if (!me) { | 4358 | if (!me) { |
4352 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4359 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4353 | return; | 4360 | return; |
4354 | } | 4361 | } |
4355 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4362 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4356 | StatusDialog *statdlg = new StatusDialog(this); | 4363 | StatusDialog *statdlg = new StatusDialog(this); |
4357 | if (!statdlg->exec()==QDialog::Accepted) return; | 4364 | if (!statdlg->exec()==QDialog::Accepted) return; |
4358 | me->setStatus( statdlg->status() ); | 4365 | me->setStatus( statdlg->status() ); |
4359 | delete(statdlg); | 4366 | delete(statdlg); |
4360 | } | 4367 | } |
4361 | Attendee *menew = new Attendee(*me); | 4368 | Attendee *menew = new Attendee(*me); |
4362 | if (ev) { | 4369 | if (ev) { |
4363 | ev->clearAttendees(); | 4370 | ev->clearAttendees(); |
4364 | ev->addAttendee(menew,false); | 4371 | ev->addAttendee(menew,false); |
4365 | } else { | 4372 | } else { |
4366 | if (to) { | 4373 | if (to) { |
4367 | todo->clearAttendees(); | 4374 | todo->clearAttendees(); |
4368 | todo->addAttendee(menew,false); | 4375 | todo->addAttendee(menew,false); |
4369 | } | 4376 | } |
4370 | } | 4377 | } |
4371 | } | 4378 | } |
4372 | 4379 | ||
4373 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4380 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4374 | if (ev) { | 4381 | if (ev) { |
4375 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4382 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4376 | } else { | 4383 | } else { |
4377 | if (to) { | 4384 | if (to) { |
4378 | if ( !dlg->addMessage(to,method) ) delete(to); | 4385 | if ( !dlg->addMessage(to,method) ) delete(to); |
4379 | } | 4386 | } |
4380 | } | 4387 | } |
4381 | } | 4388 | } |
4382 | 4389 | ||
4383 | void CalendarView::openAddressbook() | 4390 | void CalendarView::openAddressbook() |
4384 | { | 4391 | { |
4385 | KRun::runCommand("kaddressbook"); | 4392 | KRun::runCommand("kaddressbook"); |
4386 | } | 4393 | } |
4387 | 4394 | ||
4388 | void CalendarView::setModified(bool modified) | 4395 | void CalendarView::setModified(bool modified) |
4389 | { | 4396 | { |
4390 | //qDebug("CalendarView::setModified %d ", modified); | 4397 | //qDebug("CalendarView::setModified %d ", modified); |
4391 | if ( modified ) | 4398 | if ( modified ) |
4392 | emit signalmodified(); | 4399 | emit signalmodified(); |
4393 | mModified = modified; | 4400 | mModified = modified; |
4394 | if ( mModified ) | 4401 | if ( mModified ) |
4395 | emit modifiedChanged(mModified); | 4402 | emit modifiedChanged(mModified); |
4396 | 4403 | ||
4397 | } | 4404 | } |
4398 | 4405 | ||
4399 | bool CalendarView::isReadOnly() | 4406 | bool CalendarView::isReadOnly() |
4400 | { | 4407 | { |
4401 | return mReadOnly; | 4408 | return mReadOnly; |
4402 | } | 4409 | } |
4403 | 4410 | ||
4404 | void CalendarView::setReadOnly(bool readOnly) | 4411 | void CalendarView::setReadOnly(bool readOnly) |
4405 | { | 4412 | { |
4406 | if (mReadOnly != readOnly) { | 4413 | if (mReadOnly != readOnly) { |
4407 | mReadOnly = readOnly; | 4414 | mReadOnly = readOnly; |
4408 | emit readOnlyChanged(mReadOnly); | 4415 | emit readOnlyChanged(mReadOnly); |
4409 | } | 4416 | } |
4410 | } | 4417 | } |
4411 | 4418 | ||
4412 | bool CalendarView::isModified() | 4419 | bool CalendarView::isModified() |
4413 | { | 4420 | { |
4414 | return mModified; | 4421 | return mModified; |
4415 | } | 4422 | } |
4416 | void CalendarView::slotprintSelInc() | 4423 | void CalendarView::slotprintSelInc() |
4417 | { | 4424 | { |
4418 | if ( currentSelection() == 0 ) { | 4425 | if ( currentSelection() == 0 ) { |
4419 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4426 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4420 | return; | 4427 | return; |
4421 | } | 4428 | } |
4422 | showIncidence(); | 4429 | showIncidence(); |
4423 | getEventViewerDialog()->print(); | 4430 | getEventViewerDialog()->print(); |
4424 | 4431 | ||
4425 | } | 4432 | } |
4426 | void CalendarView::printSetup() | 4433 | void CalendarView::printSetup() |
4427 | { | 4434 | { |
4428 | #ifndef KORG_NOPRINTER | 4435 | #ifndef KORG_NOPRINTER |
4429 | createPrinter(); | 4436 | createPrinter(); |
4430 | 4437 | ||
4431 | mCalPrinter->setupPrinter(); | 4438 | mCalPrinter->setupPrinter(); |
4432 | #endif | 4439 | #endif |
4433 | } | 4440 | } |
4434 | 4441 | ||
4435 | void CalendarView::print() | 4442 | void CalendarView::print() |
4436 | { | 4443 | { |
4437 | #ifndef KORG_NOPRINTER | 4444 | #ifndef KORG_NOPRINTER |
4438 | createPrinter(); | 4445 | createPrinter(); |
4439 | 4446 | ||
4440 | DateList tmpDateList = mNavigator->selectedDates(); | 4447 | DateList tmpDateList = mNavigator->selectedDates(); |
4441 | mCalPrinter->print(CalPrinter::Month, | 4448 | mCalPrinter->print(CalPrinter::Month, |
4442 | tmpDateList.first(), tmpDateList.last()); | 4449 | tmpDateList.first(), tmpDateList.last()); |
4443 | #endif | 4450 | #endif |
4444 | } | 4451 | } |
4445 | 4452 | ||
4446 | void CalendarView::printPreview() | 4453 | void CalendarView::printPreview() |
4447 | { | 4454 | { |
4448 | #ifndef KORG_NOPRINTER | 4455 | #ifndef KORG_NOPRINTER |
4449 | kdDebug() << "CalendarView::printPreview()" << endl; | 4456 | kdDebug() << "CalendarView::printPreview()" << endl; |
4450 | 4457 | ||
4451 | createPrinter(); | 4458 | createPrinter(); |
4452 | 4459 | ||
4453 | DateList tmpDateList = mNavigator->selectedDates(); | 4460 | DateList tmpDateList = mNavigator->selectedDates(); |
4454 | 4461 | ||
4455 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4462 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4456 | tmpDateList.last()); | 4463 | tmpDateList.last()); |
4457 | #endif | 4464 | #endif |
4458 | } | 4465 | } |
4459 | 4466 | ||
4460 | void CalendarView::exportICalendar() | 4467 | void CalendarView::exportICalendar() |
4461 | { | 4468 | { |
4462 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 4469 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
4463 | 4470 | ||
4464 | // Force correct extension | 4471 | // Force correct extension |
4465 | if (filename.right(4) != ".ics") filename += ".ics"; | 4472 | if (filename.right(4) != ".ics") filename += ".ics"; |
4466 | 4473 | ||
4467 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4474 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4468 | storage.save(); | 4475 | storage.save(); |
4469 | } | 4476 | } |
4470 | 4477 | ||
4471 | bool CalendarView::exportVCalendar( QString filename ) | 4478 | bool CalendarView::exportVCalendar( QString filename ) |
4472 | { | 4479 | { |
4473 | if (mCalendar->journals().count() > 0) { | 4480 | if (mCalendar->journals().count() > 0) { |
4474 | int result = KMessageBox::warningContinueCancel(this, | 4481 | int result = KMessageBox::warningContinueCancel(this, |
4475 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4482 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4476 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4483 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4477 | true); | 4484 | true); |
4478 | if (result != KMessageBox::Continue) return false; | 4485 | if (result != KMessageBox::Continue) return false; |
4479 | } | 4486 | } |
4480 | 4487 | ||
4481 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4488 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4482 | 4489 | ||
4483 | // Force correct extension | 4490 | // Force correct extension |
4484 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4491 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4485 | 4492 | ||
4486 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4493 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4487 | return storage.save(); | 4494 | return storage.save(); |
4488 | 4495 | ||
4489 | } | 4496 | } |
4490 | 4497 | ||
4491 | void CalendarView::eventUpdated(Incidence *) | 4498 | void CalendarView::eventUpdated(Incidence *) |
4492 | { | 4499 | { |
4493 | setModified(); | 4500 | setModified(); |
4494 | // Don't call updateView here. The code, which has caused the update of the | 4501 | // Don't call updateView here. The code, which has caused the update of the |
4495 | // event is responsible for updating the view. | 4502 | // event is responsible for updating the view. |
4496 | // updateView(); | 4503 | // updateView(); |
4497 | } | 4504 | } |
4498 | 4505 | ||
4499 | void CalendarView::adaptNavigationUnits() | 4506 | void CalendarView::adaptNavigationUnits() |
4500 | { | 4507 | { |
4501 | if (mViewManager->currentView()->isEventView()) { | 4508 | if (mViewManager->currentView()->isEventView()) { |
4502 | int days = mViewManager->currentView()->currentDateCount(); | 4509 | int days = mViewManager->currentView()->currentDateCount(); |
4503 | if (days == 1) { | 4510 | if (days == 1) { |
4504 | emit changeNavStringPrev(i18n("&Previous Day")); | 4511 | emit changeNavStringPrev(i18n("&Previous Day")); |
4505 | emit changeNavStringNext(i18n("&Next Day")); | 4512 | emit changeNavStringNext(i18n("&Next Day")); |
4506 | } else { | 4513 | } else { |
4507 | emit changeNavStringPrev(i18n("&Previous Week")); | 4514 | emit changeNavStringPrev(i18n("&Previous Week")); |
4508 | emit changeNavStringNext(i18n("&Next Week")); | 4515 | emit changeNavStringNext(i18n("&Next Week")); |
4509 | } | 4516 | } |
4510 | } | 4517 | } |
4511 | } | 4518 | } |
4512 | 4519 | ||
4513 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4520 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4514 | { | 4521 | { |
4515 | if ( incidence ) mTodoList->clearSelection(); | 4522 | if ( incidence ) mTodoList->clearSelection(); |
4516 | processIncidenceSelection( incidence ); | 4523 | processIncidenceSelection( incidence ); |
4517 | } | 4524 | } |
4518 | 4525 | ||
4519 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4526 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4520 | { | 4527 | { |
4521 | if ( incidence && mViewManager->currentView() ) { | 4528 | if ( incidence && mViewManager->currentView() ) { |
4522 | mViewManager->currentView()->clearSelection(); | 4529 | mViewManager->currentView()->clearSelection(); |
4523 | } | 4530 | } |
4524 | processIncidenceSelection( incidence ); | 4531 | processIncidenceSelection( incidence ); |
4525 | } | 4532 | } |
4526 | 4533 | ||
4527 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4534 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4528 | { | 4535 | { |
4529 | emit incidenceSelected( incidence ); | 4536 | emit incidenceSelected( incidence ); |
4530 | if ( incidence == mSelectedIncidence ) return; | 4537 | if ( incidence == mSelectedIncidence ) return; |
4531 | mSelectedIncidence = incidence; | 4538 | mSelectedIncidence = incidence; |
4532 | 4539 | ||
4533 | if ( incidence && incidence->typeID() == eventID ) { | 4540 | if ( incidence && incidence->typeID() == eventID ) { |
4534 | Event *event = static_cast<Event *>( incidence ); | 4541 | Event *event = static_cast<Event *>( incidence ); |
4535 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4542 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4536 | emit organizerEventsSelected( true ); | 4543 | emit organizerEventsSelected( true ); |
4537 | } else { | 4544 | } else { |
4538 | emit organizerEventsSelected(false); | 4545 | emit organizerEventsSelected(false); |
4539 | } | 4546 | } |
4540 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4547 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4541 | KOPrefs::instance()->email() ) ) { | 4548 | KOPrefs::instance()->email() ) ) { |
4542 | emit groupEventsSelected( true ); | 4549 | emit groupEventsSelected( true ); |
4543 | } else { | 4550 | } else { |
4544 | emit groupEventsSelected(false); | 4551 | emit groupEventsSelected(false); |
4545 | } | 4552 | } |
4546 | return; | 4553 | return; |
4547 | } else { | 4554 | } else { |
4548 | if ( incidence && incidence->typeID() == todoID ) { | 4555 | if ( incidence && incidence->typeID() == todoID ) { |
4549 | emit todoSelected( true ); | 4556 | emit todoSelected( true ); |
4550 | Todo *event = static_cast<Todo *>( incidence ); | 4557 | Todo *event = static_cast<Todo *>( incidence ); |
4551 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4558 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4552 | emit organizerEventsSelected( true ); | 4559 | emit organizerEventsSelected( true ); |
4553 | } else { | 4560 | } else { |
4554 | emit organizerEventsSelected(false); | 4561 | emit organizerEventsSelected(false); |
4555 | } | 4562 | } |
4556 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4563 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4557 | KOPrefs::instance()->email() ) ) { | 4564 | KOPrefs::instance()->email() ) ) { |
4558 | emit groupEventsSelected( true ); | 4565 | emit groupEventsSelected( true ); |
4559 | } else { | 4566 | } else { |
4560 | emit groupEventsSelected(false); | 4567 | emit groupEventsSelected(false); |
4561 | } | 4568 | } |
4562 | return; | 4569 | return; |
4563 | } else { | 4570 | } else { |
4564 | emit todoSelected( false ); | 4571 | emit todoSelected( false ); |
4565 | emit organizerEventsSelected(false); | 4572 | emit organizerEventsSelected(false); |
4566 | emit groupEventsSelected(false); | 4573 | emit groupEventsSelected(false); |
4567 | } | 4574 | } |
4568 | return; | 4575 | return; |
4569 | } | 4576 | } |
4570 | 4577 | ||
4571 | /* if ( incidence && incidence->typeID() == todoID ) { | 4578 | /* if ( incidence && incidence->typeID() == todoID ) { |
4572 | emit todoSelected( true ); | 4579 | emit todoSelected( true ); |
4573 | } else { | 4580 | } else { |
4574 | emit todoSelected( false ); | 4581 | emit todoSelected( false ); |
4575 | }*/ | 4582 | }*/ |
4576 | } | 4583 | } |
4577 | 4584 | ||
4578 | 4585 | ||
4579 | void CalendarView::checkClipboard() | 4586 | void CalendarView::checkClipboard() |
4580 | { | 4587 | { |
4581 | #ifndef KORG_NODND | 4588 | #ifndef KORG_NODND |
4582 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4589 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4583 | emit pasteEnabled(true); | 4590 | emit pasteEnabled(true); |
4584 | } else { | 4591 | } else { |
4585 | emit pasteEnabled(false); | 4592 | emit pasteEnabled(false); |
4586 | } | 4593 | } |
4587 | #endif | 4594 | #endif |
4588 | } | 4595 | } |
4589 | 4596 | ||
4590 | void CalendarView::showDates(const DateList &selectedDates) | 4597 | void CalendarView::showDates(const DateList &selectedDates) |
4591 | { | 4598 | { |
4592 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4599 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4593 | 4600 | ||
4594 | 4601 | ||
4595 | if ( !mBlockShowDates ) { | 4602 | if ( !mBlockShowDates ) { |
4596 | if ( mViewManager->currentView() ) { | 4603 | if ( mViewManager->currentView() ) { |
4597 | updateView( selectedDates.first(), selectedDates.last() ); | 4604 | updateView( selectedDates.first(), selectedDates.last() ); |
4598 | } else { | 4605 | } else { |
4599 | mViewManager->showAgendaView(); | 4606 | mViewManager->showAgendaView(); |
4600 | } | 4607 | } |
4601 | } | 4608 | } |
4602 | 4609 | ||
4603 | QDate date = selectedDates.first(); | 4610 | QDate date = selectedDates.first(); |
4604 | if ( ! date.isValid() ) { | 4611 | if ( ! date.isValid() ) { |
4605 | topLevelWidget()->setCaption(""); | 4612 | topLevelWidget()->setCaption(""); |
4606 | return; | 4613 | return; |
4607 | } | 4614 | } |
4608 | 4615 | ||
4609 | QString selDates; | 4616 | QString selDates; |
4610 | selDates = KGlobal::locale()->formatDate( date, true); | 4617 | selDates = KGlobal::locale()->formatDate( date, true); |
4611 | if (selectedDates.first() < selectedDates.last() ) | 4618 | if (selectedDates.first() < selectedDates.last() ) |
4612 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4619 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4613 | else { | 4620 | else { |
4614 | QString addString; | 4621 | QString addString; |
4615 | if ( date == QDateTime::currentDateTime().date() ) | 4622 | if ( date == QDateTime::currentDateTime().date() ) |
4616 | addString = i18n("Today"); | 4623 | addString = i18n("Today"); |
4617 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4624 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4618 | addString = i18n("Tomorrow"); | 4625 | addString = i18n("Tomorrow"); |
4619 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4626 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4620 | addString = i18n("Yesterday"); | 4627 | addString = i18n("Yesterday"); |
4621 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4628 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4622 | addString = i18n("Day before yesterday"); | 4629 | addString = i18n("Day before yesterday"); |
4623 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4630 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4624 | addString = i18n("Day after tomorrow"); | 4631 | addString = i18n("Day after tomorrow"); |
4625 | if ( !addString.isEmpty() ) { | 4632 | if ( !addString.isEmpty() ) { |
4626 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4633 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4627 | return; | 4634 | return; |
4628 | } | 4635 | } |
4629 | } | 4636 | } |
4630 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4637 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4631 | 4638 | ||
4632 | } | 4639 | } |
4633 | 4640 | ||
4634 | QPtrList<CalFilter> CalendarView::filters() | 4641 | QPtrList<CalFilter> CalendarView::filters() |
4635 | { | 4642 | { |
4636 | return mFilters; | 4643 | return mFilters; |
4637 | 4644 | ||
4638 | } | 4645 | } |
4639 | void CalendarView::editFilters() | 4646 | void CalendarView::editFilters() |
4640 | { | 4647 | { |
4641 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4648 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4642 | 4649 | ||
4643 | CalFilter *filter = mFilters.first(); | 4650 | CalFilter *filter = mFilters.first(); |
4644 | while(filter) { | 4651 | while(filter) { |
4645 | filter = mFilters.next(); | 4652 | filter = mFilters.next(); |
4646 | } | 4653 | } |
4647 | 4654 | ||
4648 | mDialogManager->showFilterEditDialog(&mFilters); | 4655 | mDialogManager->showFilterEditDialog(&mFilters); |
4649 | updateFilter(); | 4656 | updateFilter(); |
4650 | } | 4657 | } |
4651 | void CalendarView::toggleFilter() | 4658 | void CalendarView::toggleFilter() |
4652 | { | 4659 | { |
4653 | if ( mLeftFrame->isHidden() ) { | 4660 | if ( mLeftFrame->isHidden() ) { |
4654 | toggleExpand(); | 4661 | toggleExpand(); |
4655 | showFilter( true ); | 4662 | showFilter( true ); |
4656 | } else | 4663 | } else |
4657 | showFilter(! mCalEditView->isVisible()); | 4664 | showFilter(! mCalEditView->isVisible()); |
4658 | } | 4665 | } |
4659 | 4666 | ||
4660 | KOFilterView *CalendarView::filterView() | 4667 | KOFilterView *CalendarView::filterView() |
4661 | { | 4668 | { |
4662 | return mFilterView; | 4669 | return mFilterView; |
4663 | } | 4670 | } |
4664 | void CalendarView::selectFilter( int fil ) | 4671 | void CalendarView::selectFilter( int fil ) |
4665 | { | 4672 | { |
4666 | mFilterView->setSelectedFilter( fil ); | 4673 | mFilterView->setSelectedFilter( fil ); |
4667 | updateUnmanagedViews(); | 4674 | updateUnmanagedViews(); |
4668 | } | 4675 | } |
4669 | void CalendarView::showFilter(bool visible) | 4676 | void CalendarView::showFilter(bool visible) |
4670 | { | 4677 | { |
4671 | #if 1 | 4678 | #if 1 |
4672 | if (visible) { | 4679 | if (visible) { |
4673 | mCalEditView->readConfig(); | 4680 | mCalEditView->readConfig(); |
4674 | mCalEditView->show(); | 4681 | mCalEditView->show(); |
4675 | QValueList<int> sizes; | 4682 | QValueList<int> sizes; |
4676 | sizes = mLeftFrame->sizes(); | 4683 | sizes = mLeftFrame->sizes(); |
4677 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4684 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4678 | sizes.clear(); | 4685 | sizes.clear(); |
4679 | sizes << 100; | 4686 | sizes << 100; |
4680 | sizes << 0; | 4687 | sizes << 0; |
4681 | sizes << 0; | 4688 | sizes << 0; |
4682 | sizes << 100; | 4689 | sizes << 100; |
4683 | mLeftFrame->setSizes(sizes); | 4690 | mLeftFrame->setSizes(sizes); |
4684 | } | 4691 | } |
4685 | #if 0 | 4692 | #if 0 |
4686 | sizes = mLeftFrame->sizes(); | 4693 | sizes = mLeftFrame->sizes(); |
4687 | int ccc = 0; | 4694 | int ccc = 0; |
4688 | while ( ccc < sizes.count()) { | 4695 | while ( ccc < sizes.count()) { |
4689 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4696 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4690 | ++ccc; | 4697 | ++ccc; |
4691 | } | 4698 | } |
4692 | #endif | 4699 | #endif |
4693 | 4700 | ||
4694 | } | 4701 | } |
4695 | else { | 4702 | else { |
4696 | mCalEditView->hide(); | 4703 | mCalEditView->hide(); |
4697 | } | 4704 | } |
4698 | #else | 4705 | #else |
4699 | if (visible) mFilterView->show(); | 4706 | if (visible) mFilterView->show(); |
4700 | else mFilterView->hide(); | 4707 | else mFilterView->hide(); |
4701 | #endif | 4708 | #endif |
4702 | } | 4709 | } |
4703 | void CalendarView::toggleFilerEnabled( ) | 4710 | void CalendarView::toggleFilerEnabled( ) |
4704 | { | 4711 | { |
4705 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4712 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4706 | if ( !mFilterView->filtersEnabled() ) | 4713 | if ( !mFilterView->filtersEnabled() ) |
4707 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4714 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4708 | updateUnmanagedViews(); | 4715 | updateUnmanagedViews(); |
4709 | 4716 | ||
4710 | } | 4717 | } |
4711 | void CalendarView::updateFilter() | 4718 | void CalendarView::updateFilter() |
4712 | { | 4719 | { |
4713 | CalFilter *filter = mFilterView->selectedFilter(); | 4720 | CalFilter *filter = mFilterView->selectedFilter(); |
4714 | if (filter) { | 4721 | if (filter) { |
4715 | QString mess; | 4722 | QString mess; |
4716 | if (mFilterView->filtersEnabled()) { | 4723 | if (mFilterView->filtersEnabled()) { |
4717 | mess = i18n("Filter selected: ")+filter->name(); | 4724 | mess = i18n("Filter selected: ")+filter->name(); |
4718 | filter->setEnabled(true); | 4725 | filter->setEnabled(true); |
4719 | } | 4726 | } |
4720 | else filter->setEnabled(false); | 4727 | else filter->setEnabled(false); |
4721 | mCalendar->setFilter(filter); | 4728 | mCalendar->setFilter(filter); |
4722 | updateView(); | 4729 | updateView(); |
4723 | if ( !mess.isEmpty() ) | 4730 | if ( !mess.isEmpty() ) |
4724 | topLevelWidget()->setCaption( mess ); | 4731 | topLevelWidget()->setCaption( mess ); |
4725 | 4732 | ||
4726 | } | 4733 | } |
4727 | emit filtersUpdated(); | 4734 | emit filtersUpdated(); |
4728 | } | 4735 | } |
4729 | 4736 | ||
4730 | void CalendarView::filterEdited() | 4737 | void CalendarView::filterEdited() |
4731 | { | 4738 | { |
4732 | mFilterView->updateFilters(); | 4739 | mFilterView->updateFilters(); |
4733 | updateFilter(); | 4740 | updateFilter(); |
4734 | writeSettings(); | 4741 | writeSettings(); |
4735 | } | 4742 | } |
4736 | 4743 | ||
4737 | 4744 | ||
4738 | void CalendarView::takeOverEvent() | 4745 | void CalendarView::takeOverEvent() |
4739 | { | 4746 | { |
4740 | Incidence *incidence = currentSelection(); | 4747 | Incidence *incidence = currentSelection(); |
4741 | 4748 | ||
4742 | if (!incidence) return; | 4749 | if (!incidence) return; |
4743 | 4750 | ||
4744 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4751 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4745 | incidence->recreate(); | 4752 | incidence->recreate(); |
4746 | incidence->setReadOnly(false); | 4753 | incidence->setReadOnly(false); |
4747 | 4754 | ||
4748 | updateView(); | 4755 | updateView(); |
4749 | } | 4756 | } |
4750 | 4757 | ||
4751 | void CalendarView::takeOverCalendar() | 4758 | void CalendarView::takeOverCalendar() |
4752 | { | 4759 | { |
4753 | // TODO: Create Calendar::allIncidences() function and use it here | 4760 | // TODO: Create Calendar::allIncidences() function and use it here |
4754 | 4761 | ||
4755 | clearAllViews(); | 4762 | clearAllViews(); |
4756 | QPtrList<Event> events = mCalendar->events(); | 4763 | QPtrList<Event> events = mCalendar->events(); |
4757 | for(uint i=0; i<events.count(); ++i) { | 4764 | for(uint i=0; i<events.count(); ++i) { |
4758 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4765 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4759 | events.at(i)->recreate(); | 4766 | events.at(i)->recreate(); |
4760 | events.at(i)->setReadOnly(false); | 4767 | events.at(i)->setReadOnly(false); |
4761 | } | 4768 | } |
4762 | 4769 | ||
4763 | QPtrList<Todo> todos = mCalendar->todos(); | 4770 | QPtrList<Todo> todos = mCalendar->todos(); |
4764 | for(uint i=0; i<todos.count(); ++i) { | 4771 | for(uint i=0; i<todos.count(); ++i) { |
4765 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4772 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4766 | todos.at(i)->recreate(); | 4773 | todos.at(i)->recreate(); |
4767 | todos.at(i)->setReadOnly(false); | 4774 | todos.at(i)->setReadOnly(false); |
4768 | } | 4775 | } |
4769 | 4776 | ||
4770 | QPtrList<Journal> journals = mCalendar->journals(); | 4777 | QPtrList<Journal> journals = mCalendar->journals(); |
4771 | for(uint i=0; i<journals.count(); ++i) { | 4778 | for(uint i=0; i<journals.count(); ++i) { |
4772 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4779 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4773 | journals.at(i)->recreate(); | 4780 | journals.at(i)->recreate(); |
4774 | journals.at(i)->setReadOnly(false); | 4781 | journals.at(i)->setReadOnly(false); |
4775 | } | 4782 | } |
4776 | 4783 | ||
4777 | updateView(); | 4784 | updateView(); |
4778 | } | 4785 | } |
4779 | 4786 | ||
4780 | void CalendarView::showIntro() | 4787 | void CalendarView::showIntro() |
4781 | { | 4788 | { |
4782 | kdDebug() << "To be implemented." << endl; | 4789 | kdDebug() << "To be implemented." << endl; |
4783 | } | 4790 | } |
4784 | 4791 | ||
4785 | QWidgetStack *CalendarView::viewStack() | 4792 | QWidgetStack *CalendarView::viewStack() |
4786 | { | 4793 | { |
4787 | return mRightFrame; | 4794 | return mRightFrame; |
4788 | } | 4795 | } |
4789 | 4796 | ||
4790 | QWidget *CalendarView::leftFrame() | 4797 | QWidget *CalendarView::leftFrame() |
4791 | { | 4798 | { |
4792 | return ( QWidget *)mLeftFrame; | 4799 | return ( QWidget *)mLeftFrame; |
4793 | } | 4800 | } |
4794 | 4801 | ||
4795 | DateNavigator *CalendarView::dateNavigator() | 4802 | DateNavigator *CalendarView::dateNavigator() |
4796 | { | 4803 | { |
4797 | return mNavigator; | 4804 | return mNavigator; |
4798 | } | 4805 | } |
4799 | 4806 | ||
4800 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4807 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4801 | { | 4808 | { |
4802 | return mDateNavigator->navigatorView(); | 4809 | return mDateNavigator->navigatorView(); |
4803 | } | 4810 | } |
4804 | void CalendarView::toggleDateNavigatorWidget() | 4811 | void CalendarView::toggleDateNavigatorWidget() |
4805 | { | 4812 | { |
4806 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4813 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4807 | 4814 | ||
4808 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4815 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4809 | mDateNavigator->hide(); | 4816 | mDateNavigator->hide(); |
4810 | else | 4817 | else |
4811 | mDateNavigator->show(); | 4818 | mDateNavigator->show(); |
4812 | } | 4819 | } |
4813 | void CalendarView::addView(KOrg::BaseView *view) | 4820 | void CalendarView::addView(KOrg::BaseView *view) |
4814 | { | 4821 | { |
4815 | mViewManager->addView(view); | 4822 | mViewManager->addView(view); |
4816 | } | 4823 | } |
4817 | 4824 | ||
4818 | void CalendarView::showView(KOrg::BaseView *view) | 4825 | void CalendarView::showView(KOrg::BaseView *view) |
4819 | { | 4826 | { |
4820 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4827 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4821 | } | 4828 | } |
4822 | 4829 | ||
4823 | Incidence *CalendarView::currentSelection() | 4830 | Incidence *CalendarView::currentSelection() |
4824 | { | 4831 | { |
4825 | return mViewManager->currentSelection(); | 4832 | return mViewManager->currentSelection(); |
4826 | } | 4833 | } |
4827 | void CalendarView::toggleAllDaySize() | 4834 | void CalendarView::toggleAllDaySize() |
4828 | { | 4835 | { |
4829 | /* | 4836 | /* |
4830 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4837 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4831 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4838 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4832 | else | 4839 | else |
4833 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4840 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4834 | */ | 4841 | */ |
4835 | viewManager()->agendaView()->toggleAllDay(); | 4842 | viewManager()->agendaView()->toggleAllDay(); |
4836 | } | 4843 | } |
4837 | void CalendarView::toggleExpand() | 4844 | void CalendarView::toggleExpand() |
4838 | { | 4845 | { |
4839 | // if ( mLeftFrame->isHidden() ) { | 4846 | // if ( mLeftFrame->isHidden() ) { |
4840 | // mLeftFrame->show(); | 4847 | // mLeftFrame->show(); |
4841 | // emit calendarViewExpanded( false ); | 4848 | // emit calendarViewExpanded( false ); |
4842 | // } else { | 4849 | // } else { |
4843 | // mLeftFrame->hide(); | 4850 | // mLeftFrame->hide(); |
4844 | // emit calendarViewExpanded( true ); | 4851 | // emit calendarViewExpanded( true ); |
4845 | // } | 4852 | // } |
4846 | //qDebug(" CalendarView::toggleExpand()"); | 4853 | //qDebug(" CalendarView::toggleExpand()"); |
4847 | globalFlagBlockAgenda = 1; | 4854 | globalFlagBlockAgenda = 1; |
4848 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4855 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4849 | globalFlagBlockAgenda = 5; | 4856 | globalFlagBlockAgenda = 5; |
4850 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4857 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4851 | //mViewManager->showView( 0, true ); | 4858 | //mViewManager->showView( 0, true ); |
4852 | } | 4859 | } |
4853 | 4860 | ||
4854 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4861 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4855 | { | 4862 | { |
4856 | setModified( modified ); | 4863 | setModified( modified ); |
4857 | } | 4864 | } |
4858 | 4865 | ||
4859 | Todo *CalendarView::selectedTodo() | 4866 | Todo *CalendarView::selectedTodo() |
4860 | { | 4867 | { |
4861 | Incidence *incidence = currentSelection(); | 4868 | Incidence *incidence = currentSelection(); |
4862 | if ( incidence && incidence->typeID() == todoID ) { | 4869 | if ( incidence && incidence->typeID() == todoID ) { |
4863 | return static_cast<Todo *>( incidence ); | 4870 | return static_cast<Todo *>( incidence ); |
4864 | } | 4871 | } |
4865 | 4872 | ||
4866 | incidence = mTodoList->selectedIncidences().first(); | 4873 | incidence = mTodoList->selectedIncidences().first(); |
4867 | if ( incidence && incidence->typeID() == todoID ) { | 4874 | if ( incidence && incidence->typeID() == todoID ) { |
4868 | return static_cast<Todo *>( incidence ); | 4875 | return static_cast<Todo *>( incidence ); |
4869 | } | 4876 | } |
4870 | 4877 | ||
4871 | return 0; | 4878 | return 0; |
4872 | } | 4879 | } |
4873 | 4880 | ||
4874 | void CalendarView::showIncidence() | 4881 | void CalendarView::showIncidence() |
4875 | { | 4882 | { |
4876 | mViewerCallerIsSearchDialog = false; | 4883 | mViewerCallerIsSearchDialog = false; |
4877 | Incidence *incidence = currentSelection(); | 4884 | Incidence *incidence = currentSelection(); |
4878 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4885 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4879 | if ( incidence ) { | 4886 | if ( incidence ) { |
4880 | ShowIncidenceVisitor v; | 4887 | ShowIncidenceVisitor v; |
4881 | v.act( incidence, this ); | 4888 | v.act( incidence, this ); |
4882 | } | 4889 | } |
4883 | } | 4890 | } |
4884 | void CalendarView::editIncidenceDescription() | 4891 | void CalendarView::editIncidenceDescription() |
4885 | { | 4892 | { |
4886 | mFlagEditDescription = true; | 4893 | mFlagEditDescription = true; |
4887 | editIncidence(); | 4894 | editIncidence(); |
4888 | mFlagEditDescription = false; | 4895 | mFlagEditDescription = false; |
4889 | } | 4896 | } |
4890 | void CalendarView::editIncidence() | 4897 | void CalendarView::editIncidence() |
4891 | { | 4898 | { |
4892 | // qDebug("editIncidence() "); | 4899 | // qDebug("editIncidence() "); |
4893 | Incidence *incidence = currentSelection(); | 4900 | Incidence *incidence = currentSelection(); |
4894 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4901 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4895 | if ( incidence ) { | 4902 | if ( incidence ) { |
4896 | EditIncidenceVisitor v; | 4903 | EditIncidenceVisitor v; |
4897 | v.act( incidence, this ); | 4904 | v.act( incidence, this ); |
4898 | } | 4905 | } |
4899 | } | 4906 | } |
4900 | 4907 | ||
4901 | void CalendarView::deleteIncidence() | 4908 | void CalendarView::deleteIncidence() |
4902 | { | 4909 | { |
4903 | Incidence *incidence = currentSelection(); | 4910 | Incidence *incidence = currentSelection(); |
4904 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4911 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4905 | if ( incidence ) { | 4912 | if ( incidence ) { |
4906 | deleteIncidence(incidence); | 4913 | deleteIncidence(incidence); |
4907 | } | 4914 | } |
4908 | } | 4915 | } |
4909 | void CalendarView::showIncidence(QString uid) | 4916 | void CalendarView::showIncidence(QString uid) |
4910 | { | 4917 | { |
4911 | Incidence *inc = mCalendar->incidence( uid ); | 4918 | Incidence *inc = mCalendar->incidence( uid ); |
4912 | if ( inc ) | 4919 | if ( inc ) |
4913 | showIncidence( inc ); | 4920 | showIncidence( inc ); |
4914 | } | 4921 | } |
4915 | void CalendarView::showIncidence(Incidence *incidence) | 4922 | void CalendarView::showIncidence(Incidence *incidence) |
4916 | { | 4923 | { |
4917 | mViewerCallerIsSearchDialog = false; | 4924 | mViewerCallerIsSearchDialog = false; |
4918 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4925 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4919 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4926 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4920 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4927 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4921 | mViewerCallerIsSearchDialog = true; | 4928 | mViewerCallerIsSearchDialog = true; |
4922 | } | 4929 | } |
4923 | } | 4930 | } |
4924 | if ( incidence ) { | 4931 | if ( incidence ) { |
4925 | ShowIncidenceVisitor v; | 4932 | ShowIncidenceVisitor v; |
4926 | v.act( incidence, this ); | 4933 | v.act( incidence, this ); |
4927 | } | 4934 | } |
4928 | } | 4935 | } |
4929 | 4936 | ||
4930 | void CalendarView::editIncidence(Incidence *incidence) | 4937 | void CalendarView::editIncidence(Incidence *incidence) |
4931 | { | 4938 | { |
4932 | if ( incidence ) { | 4939 | if ( incidence ) { |
4933 | 4940 | ||
4934 | EditIncidenceVisitor v; | 4941 | EditIncidenceVisitor v; |
4935 | v.act( incidence, this ); | 4942 | v.act( incidence, this ); |
4936 | 4943 | ||
4937 | } | 4944 | } |
4938 | } | 4945 | } |
4939 | 4946 | ||
4940 | void CalendarView::deleteIncidence(Incidence *incidence) | 4947 | void CalendarView::deleteIncidence(Incidence *incidence) |
4941 | { | 4948 | { |
4942 | //qDebug(" CalendarView::deleteIncidence "); | 4949 | //qDebug(" CalendarView::deleteIncidence "); |
4943 | if ( incidence == 0 ) { | 4950 | if ( incidence == 0 ) { |
4944 | updateView(); | 4951 | updateView(); |
4945 | emit updateSearchDialog(); | 4952 | emit updateSearchDialog(); |
4946 | return; | 4953 | return; |
4947 | } | 4954 | } |
4948 | if ( incidence ) { | 4955 | if ( incidence ) { |
4949 | DeleteIncidenceVisitor v; | 4956 | DeleteIncidenceVisitor v; |
4950 | v.act( incidence, this ); | 4957 | v.act( incidence, this ); |
4951 | } | 4958 | } |
4952 | } | 4959 | } |
4953 | 4960 | ||
4954 | 4961 | ||
4955 | void CalendarView::lookForOutgoingMessages() | 4962 | void CalendarView::lookForOutgoingMessages() |
4956 | { | 4963 | { |
4957 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4964 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4958 | ogd->loadMessages(); | 4965 | ogd->loadMessages(); |
4959 | } | 4966 | } |
4960 | 4967 | ||
4961 | void CalendarView::lookForIncomingMessages() | 4968 | void CalendarView::lookForIncomingMessages() |
4962 | { | 4969 | { |
4963 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4970 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4964 | icd->retrieve(); | 4971 | icd->retrieve(); |
4965 | } | 4972 | } |
4966 | 4973 | ||
4967 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4974 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4968 | { | 4975 | { |
4969 | bool deleteTodo = true; | 4976 | bool deleteTodo = true; |
4970 | QPtrList<Incidence> subTodos; | 4977 | QPtrList<Incidence> subTodos; |
4971 | Incidence *aTodo; | 4978 | Incidence *aTodo; |
4972 | subTodos = t->relations(); | 4979 | subTodos = t->relations(); |
4973 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4980 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4974 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4981 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4975 | deleteTodo = false; | 4982 | deleteTodo = false; |
4976 | } | 4983 | } |
4977 | if ( deleteTodo ) { | 4984 | if ( deleteTodo ) { |
4978 | if ( t->isCompleted() && !t->doesRecur()) { | 4985 | if ( t->isCompleted() && !t->doesRecur()) { |
4979 | checkExternalId( t ); | 4986 | checkExternalId( t ); |
4980 | mCalendar->deleteTodo( t ); | 4987 | mCalendar->deleteTodo( t ); |
4981 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4988 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4982 | } | 4989 | } |
4983 | else | 4990 | else |
4984 | deleteTodo = false; | 4991 | deleteTodo = false; |
4985 | } | 4992 | } |
4986 | return deleteTodo; | 4993 | return deleteTodo; |
4987 | 4994 | ||
4988 | } | 4995 | } |
4989 | void CalendarView::purgeCompleted() | 4996 | void CalendarView::purgeCompleted() |
4990 | { | 4997 | { |
4991 | int result = KMessageBox::warningContinueCancel(this, | 4998 | int result = KMessageBox::warningContinueCancel(this, |
4992 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4999 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4993 | 5000 | ||
4994 | if (result == KMessageBox::Continue) { | 5001 | if (result == KMessageBox::Continue) { |
4995 | 5002 | ||
4996 | QPtrList<Todo> todoCal; | 5003 | QPtrList<Todo> todoCal; |
4997 | QPtrList<Todo> rootTodos; | 5004 | QPtrList<Todo> rootTodos; |
4998 | //QPtrList<Incidence> rel; | 5005 | //QPtrList<Incidence> rel; |
4999 | Todo *aTodo; | 5006 | Todo *aTodo; |
5000 | todoCal = calendar()->todos(); | 5007 | todoCal = calendar()->todos(); |
5001 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 5008 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
5002 | if ( !aTodo->relatedTo() ) | 5009 | if ( !aTodo->relatedTo() ) |
5003 | rootTodos.append( aTodo ); | 5010 | rootTodos.append( aTodo ); |
5004 | } | 5011 | } |
5005 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 5012 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
5006 | removeCompletedSubTodos( aTodo ); | 5013 | removeCompletedSubTodos( aTodo ); |
5007 | } | 5014 | } |
5008 | 5015 | ||
5009 | updateView(); | 5016 | updateView(); |
5010 | } | 5017 | } |
5011 | } | 5018 | } |
5012 | 5019 | ||
5013 | void CalendarView::slotCalendarChanged() | 5020 | void CalendarView::slotCalendarChanged() |
5014 | { | 5021 | { |
5015 | ; | 5022 | ; |
5016 | } | 5023 | } |
5017 | 5024 | ||
5018 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 5025 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
5019 | { | 5026 | { |
5020 | //qDebug("CalendarView::keyPressEvent "); | 5027 | //qDebug("CalendarView::keyPressEvent "); |
5021 | e->ignore(); | 5028 | e->ignore(); |
5022 | } | 5029 | } |
5023 | 5030 | ||
5024 | 5031 | ||
5025 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 5032 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
5026 | { | 5033 | { |
5027 | 5034 | ||
5028 | if ( manager != mSyncManager) | 5035 | if ( manager != mSyncManager) |
5029 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 5036 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
5030 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 5037 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
5031 | qDebug("KO: SyncKDE request detected!"); | 5038 | qDebug("KO: SyncKDE request detected!"); |
5032 | } | 5039 | } |
5033 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5040 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5034 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5041 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5035 | return syncCalendar( filename, mode ); | 5042 | return syncCalendar( filename, mode ); |
5036 | } | 5043 | } |
5037 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 5044 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
5038 | { | 5045 | { |
5039 | //mSyncManager = manager; | 5046 | //mSyncManager = manager; |
5040 | if ( manager != mSyncManager) | 5047 | if ( manager != mSyncManager) |
5041 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 5048 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
5042 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5049 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5043 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5050 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5044 | if ( resource == "sharp" ) | 5051 | if ( resource == "sharp" ) |
5045 | syncExternal( 0 ); | 5052 | syncExternal( 0 ); |
5046 | if ( resource == "phone" ) | 5053 | if ( resource == "phone" ) |
5047 | syncExternal( 1 ); | 5054 | syncExternal( 1 ); |
5048 | // pending setmodified | 5055 | // pending setmodified |
5049 | return true; | 5056 | return true; |
5050 | } | 5057 | } |
5051 | void CalendarView::setSyncManager(KSyncManager* manager) | 5058 | void CalendarView::setSyncManager(KSyncManager* manager) |
5052 | { | 5059 | { |
5053 | mSyncManager = manager; | 5060 | mSyncManager = manager; |
5054 | } | 5061 | } |
5055 | 5062 | ||
5056 | void CalendarView::removeSyncInfo( QString syncProfile) | 5063 | void CalendarView::removeSyncInfo( QString syncProfile) |
5057 | { | 5064 | { |
5058 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 5065 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
5059 | mCalendar->removeSyncInfo( syncProfile ); | 5066 | mCalendar->removeSyncInfo( syncProfile ); |
5060 | 5067 | ||
5061 | } | 5068 | } |
5062 | 5069 | ||
5063 | void CalendarView::undo_delete() | 5070 | void CalendarView::undo_delete() |
5064 | { | 5071 | { |
5065 | //qDebug("undo_delete() "); | 5072 | //qDebug("undo_delete() "); |
5066 | Incidence* undo = mCalendar->undoIncidence(); | 5073 | Incidence* undo = mCalendar->undoIncidence(); |
5067 | if ( !undo ) { | 5074 | if ( !undo ) { |
5068 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 5075 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
5069 | i18n("KO/Pi")); | 5076 | i18n("KO/Pi")); |
5070 | return; | 5077 | return; |
5071 | } | 5078 | } |
5072 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 5079 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
5073 | i18n("\nAre you sure you want\nto restore this?"), | 5080 | i18n("\nAre you sure you want\nto restore this?"), |
5074 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 5081 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
5075 | mCalendar->undoDeleteIncidence(); | 5082 | mCalendar->undoDeleteIncidence(); |
5076 | updateView(); | 5083 | updateView(); |
5077 | } | 5084 | } |
5078 | } | 5085 | } |
5079 | 5086 | ||
5080 | void CalendarView::slotViewerClosed() | 5087 | void CalendarView::slotViewerClosed() |
5081 | { | 5088 | { |
5082 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 5089 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
5083 | } | 5090 | } |
5084 | 5091 | ||
5085 | void CalendarView::resetFocus() | 5092 | void CalendarView::resetFocus() |
5086 | { | 5093 | { |
5087 | if ( mViewerCallerIsSearchDialog ) { | 5094 | if ( mViewerCallerIsSearchDialog ) { |
5088 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 5095 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
5089 | mDialogManager->getSearchDialog()->raise(); | 5096 | mDialogManager->getSearchDialog()->raise(); |
5090 | mDialogManager->getSearchDialog()->setActiveWindow(); | 5097 | mDialogManager->getSearchDialog()->setActiveWindow(); |
5091 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 5098 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
5092 | } else | 5099 | } else |
5093 | mViewerCallerIsSearchDialog = false; | 5100 | mViewerCallerIsSearchDialog = false; |
5094 | } | 5101 | } |
5095 | if ( !mViewerCallerIsSearchDialog ) { | 5102 | if ( !mViewerCallerIsSearchDialog ) { |
5096 | //mViewManager->currentView()->setFocus(); | 5103 | //mViewManager->currentView()->setFocus(); |
5097 | //qDebug("sssssssssssssssset focus "); | 5104 | //qDebug("sssssssssssssssset focus "); |
5098 | topLevelWidget()->raise(); | 5105 | topLevelWidget()->raise(); |
5099 | setActiveWindow(); | 5106 | setActiveWindow(); |
5100 | //setFocus(); | 5107 | //setFocus(); |
5101 | } | 5108 | } |
5102 | mViewerCallerIsSearchDialog = false; | 5109 | mViewerCallerIsSearchDialog = false; |
5103 | } | 5110 | } |
5104 | 5111 | ||
5105 | void CalendarView::showNextAlarms() | 5112 | void CalendarView::showNextAlarms() |
5106 | { | 5113 | { |
5107 | QString message; | 5114 | QString message; |
5108 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 5115 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
5109 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 5116 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
5110 | QString sum = mCalendar->nextSummary(); | 5117 | QString sum = mCalendar->nextSummary(); |
5111 | QDateTime nextA = mNextAlarmDateTime; | 5118 | QDateTime nextA = mNextAlarmDateTime; |
5112 | QDateTime cur = QDateTime::currentDateTime(); | 5119 | QDateTime cur = QDateTime::currentDateTime(); |
5113 | int secs = cur.secsTo( nextA ); | 5120 | int secs = cur.secsTo( nextA ); |
5114 | int min = secs /60; | 5121 | int min = secs /60; |
5115 | int hours = min /60; | 5122 | int hours = min /60; |
5116 | min = min % 60; | 5123 | min = min % 60; |
5117 | int days = hours /24; | 5124 | int days = hours /24; |
5118 | hours = hours % 24; | 5125 | hours = hours % 24; |
5119 | 5126 | ||
5120 | //message = i18n("The next alarm is in:\n"); | 5127 | //message = i18n("The next alarm is in:\n"); |
5121 | if ( days > 1 ) | 5128 | if ( days > 1 ) |
5122 | message += i18n("%1 days\n").arg( days ); | 5129 | message += i18n("%1 days\n").arg( days ); |
5123 | else if ( days == 1 ) | 5130 | else if ( days == 1 ) |
5124 | message += i18n("1 day\n"); | 5131 | message += i18n("1 day\n"); |
5125 | if ( hours > 1 ) | 5132 | if ( hours > 1 ) |
5126 | message += i18n("%1 hours\n").arg( hours ); | 5133 | message += i18n("%1 hours\n").arg( hours ); |
5127 | else if ( hours == 1 ) | 5134 | else if ( hours == 1 ) |
5128 | message += i18n("1 hour\n"); | 5135 | message += i18n("1 hour\n"); |
5129 | if ( min > 1 ) | 5136 | if ( min > 1 ) |
5130 | message += i18n("%1 minutes\n").arg( min ); | 5137 | message += i18n("%1 minutes\n").arg( min ); |
5131 | else if ( min == 1 ) | 5138 | else if ( min == 1 ) |
5132 | message += i18n("1 minute\n"); | 5139 | message += i18n("1 minute\n"); |
5133 | if ( message.isEmpty() ) | 5140 | if ( message.isEmpty() ) |
5134 | message = i18n("The next alarm is in\nless than one minute!"); | 5141 | message = i18n("The next alarm is in\nless than one minute!"); |
5135 | else | 5142 | else |
5136 | message = i18n("The next alarm is in:\n") + message; | 5143 | message = i18n("The next alarm is in:\n") + message; |
5137 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 5144 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
5138 | } else { | 5145 | } else { |
5139 | message = i18n("There is no next alarm."); | 5146 | message = i18n("There is no next alarm."); |
5140 | 5147 | ||
5141 | } | 5148 | } |
5142 | #ifdef DESKTOP_VERSION | 5149 | #ifdef DESKTOP_VERSION |
5143 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 5150 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
5144 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 5151 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
5145 | message += i18n("Enable it in the settings menu, TAB alarm."); | 5152 | message += i18n("Enable it in the settings menu, TAB alarm."); |
5146 | } | 5153 | } |
5147 | 5154 | ||
5148 | #endif | 5155 | #endif |
5149 | KMessageBox::information( this, message); | 5156 | KMessageBox::information( this, message); |
5150 | } | 5157 | } |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 057df0d..7076e05 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,1217 +1,1223 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #include <libkcal/vcaldrag.h> | 35 | #include <libkcal/vcaldrag.h> |
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/dndfactory.h> | 37 | #include <libkcal/dndfactory.h> |
38 | #include <libkcal/calendarresources.h> | 38 | #include <libkcal/calendarresources.h> |
39 | #include <libkcal/resourcecalendar.h> | 39 | #include <libkcal/resourcecalendar.h> |
40 | #include <kresources/resourceselectdialog.h> | 40 | #include <kresources/resourceselectdialog.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPLUGINS | 44 | #ifndef KORG_NOPLUGINS |
45 | #include "kocore.h" | 45 | #include "kocore.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "koglobals.h" | 48 | #include "koglobals.h" |
49 | 49 | ||
50 | #include "kodaymatrix.h" | 50 | #include "kodaymatrix.h" |
51 | 51 | ||
52 | // ============================================================================ | 52 | // ============================================================================ |
53 | // D Y N A M I C T I P | 53 | // D Y N A M I C T I P |
54 | // ============================================================================ | 54 | // ============================================================================ |
55 | 55 | ||
56 | DynamicTip::DynamicTip( QWidget * parent ) | 56 | DynamicTip::DynamicTip( QWidget * parent ) |
57 | : QToolTip( parent ) | 57 | : QToolTip( parent ) |
58 | { | 58 | { |
59 | matrix = (KODayMatrix*)parent; | 59 | matrix = (KODayMatrix*)parent; |
60 | } | 60 | } |
61 | 61 | ||
62 | class KODaymatrixWhatsThis :public QWhatsThis | 62 | class KODaymatrixWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; | 65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; |
66 | ~KODaymatrixWhatsThis() { ; }; | 66 | ~KODaymatrixWhatsThis() { ; }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p ) | 69 | virtual QString text( const QPoint& p ) |
70 | { | 70 | { |
71 | return _view->getWhatsThisText( p ) ; | 71 | return _view->getWhatsThisText( p ) ; |
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | KODayMatrix * _view; | 74 | KODayMatrix * _view; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | void DynamicTip::maybeTip( const QPoint &pos ) | 77 | void DynamicTip::maybeTip( const QPoint &pos ) |
78 | { | 78 | { |
79 | //calculate which cell of the matrix the mouse is in | 79 | //calculate which cell of the matrix the mouse is in |
80 | QRect sz = matrix->frameRect(); | 80 | QRect sz = matrix->frameRect(); |
81 | int dheight = sz.height()*7 / 42; | 81 | int dheight = sz.height()*7 / 42; |
82 | int dwidth = sz.width() / 7; | 82 | int dwidth = sz.width() / 7; |
83 | int row = pos.y()/dheight; | 83 | int row = pos.y()/dheight; |
84 | int col = pos.x()/dwidth; | 84 | int col = pos.x()/dwidth; |
85 | 85 | ||
86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
87 | 87 | ||
88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
89 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 89 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
90 | 90 | ||
91 | //show holiday names only | 91 | //show holiday names only |
92 | QString str = matrix->getHolidayLabel(col+row*7); | 92 | QString str = matrix->getHolidayLabel(col+row*7); |
93 | if (str.isEmpty()) return; | 93 | if (str.isEmpty()) return; |
94 | tip(rct, str); | 94 | tip(rct, str); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | // ============================================================================ | 98 | // ============================================================================ |
99 | // K O D A Y M A T R I X | 99 | // K O D A Y M A T R I X |
100 | // ============================================================================ | 100 | // ============================================================================ |
101 | 101 | ||
102 | const int KODayMatrix::NOSELECTION = -1000; | 102 | const int KODayMatrix::NOSELECTION = -1000; |
103 | const int KODayMatrix::NUMDAYS = 42; | 103 | const int KODayMatrix::NUMDAYS = 42; |
104 | 104 | ||
105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
106 | : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) | 106 | : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) |
107 | 107 | ||
108 | 108 | ||
109 | { | 109 | { |
110 | mLastView = -1; | 110 | mLastView = -1; |
111 | oldW = 0; | 111 | oldW = 0; |
112 | oldH = 0; | 112 | oldH = 0; |
113 | myPix.resize( 150, 120 ); | 113 | myPix.resize( 150, 120 ); |
114 | mRedrawNeeded = true; | 114 | mRedrawNeeded = true; |
115 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); | 115 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); |
116 | mPendingUpdateBeforeRepaint = false; | 116 | mPendingUpdateBeforeRepaint = false; |
117 | mouseDown = false; | 117 | mouseDown = false; |
118 | // initialize dynamic arrays | 118 | // initialize dynamic arrays |
119 | bDays.resize ( NUMDAYS ); | 119 | bDays.resize ( NUMDAYS ); |
120 | pDays.resize ( NUMDAYS ); | 120 | pDays.resize ( NUMDAYS ); |
121 | hDays.resize ( NUMDAYS ); | 121 | hDays.resize ( NUMDAYS ); |
122 | eDays.resize ( NUMDAYS ); | 122 | eDays.resize ( NUMDAYS ); |
123 | days = new QDate[NUMDAYS]; | 123 | days = new QDate[NUMDAYS]; |
124 | daylbls = new QString[NUMDAYS]; | 124 | daylbls = new QString[NUMDAYS]; |
125 | //events = new int[NUMDAYS]; | 125 | //events = new int[NUMDAYS]; |
126 | mToolTip = new DynamicTip(this); | 126 | mToolTip = new DynamicTip(this); |
127 | 127 | ||
128 | // set default values used for drawing the matrix | 128 | // set default values used for drawing the matrix |
129 | mDefaultBackColor = palette().active().base(); | 129 | mDefaultBackColor = palette().active().base(); |
130 | mDefaultTextColor = palette().active().foreground(); | 130 | mDefaultTextColor = palette().active().foreground(); |
131 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 131 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
132 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 132 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
133 | mSelectedDaysColor = QColor("white"); | 133 | mSelectedDaysColor = QColor("white"); |
134 | mTodayMarginWidth = 2; | 134 | mTodayMarginWidth = 2; |
135 | mSelEnd = mSelStart = NOSELECTION; | 135 | mSelEnd = mSelStart = NOSELECTION; |
136 | 136 | ||
137 | setAcceptDrops(true); | 137 | setAcceptDrops(true); |
138 | //setFont( QFont("Arial", 10) ); | 138 | //setFont( QFont("Arial", 10) ); |
139 | 139 | ||
140 | mUpdateTimer = new QTimer( this ); | 140 | mUpdateTimer = new QTimer( this ); |
141 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 141 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
142 | mRepaintTimer = new QTimer( this ); | 142 | mRepaintTimer = new QTimer( this ); |
143 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 143 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
144 | mDayChanged = false; | 144 | mDayChanged = false; |
145 | updateView(); | 145 | updateView(); |
146 | } | 146 | } |
147 | QString KODayMatrix::getWhatsThisText( QPoint p ) | 147 | QString KODayMatrix::getWhatsThisText( QPoint p ) |
148 | { | 148 | { |
149 | 149 | ||
150 | int tmp = getDayIndexFrom(p.x(), p.y()); | 150 | int tmp = getDayIndexFrom(p.x(), p.y()); |
151 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) | 151 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) |
152 | return QString(); | 152 | return QString(); |
153 | QDate mDate = days[tmp]; | 153 | QDate mDate = days[tmp]; |
154 | QPtrList<Event> eventlist = mCalendar->events(mDate); | 154 | QPtrList<Event> eventlist = mCalendar->events(mDate); |
155 | Event *event; | 155 | Event *event; |
156 | QStringList mToolTip; | 156 | QStringList mToolTip; |
157 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 157 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
158 | QString mToolTipText; | 158 | QString mToolTipText; |
159 | QString text; | 159 | QString text; |
160 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 160 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
161 | if (event->isMultiDay()) { | 161 | if (event->isMultiDay()) { |
162 | QString prefix = "<->";multiday = 2; | 162 | QString prefix = "<->";multiday = 2; |
163 | QString time; | 163 | QString time; |
164 | if ( event->doesRecur() ) { | 164 | if ( event->doesRecur() ) { |
165 | if ( event->recursOn( mDate) ) { | 165 | if ( event->recursOn( mDate) ) { |
166 | prefix ="->" ;multiday = 1; | 166 | prefix ="->" ;multiday = 1; |
167 | } | 167 | } |
168 | else { | 168 | else { |
169 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 169 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
170 | if ( event->recursOn( mDate.addDays( -days)) ) { | 170 | if ( event->recursOn( mDate.addDays( -days)) ) { |
171 | prefix ="<-" ;multiday = 3; | 171 | prefix ="<-" ;multiday = 3; |
172 | } | 172 | } |
173 | } | 173 | } |
174 | } else { | 174 | } else { |
175 | if (mDate == event->dtStart().date()) { | 175 | if (mDate == event->dtStart().date()) { |
176 | prefix ="->" ;multiday = 1; | 176 | prefix ="->" ;multiday = 1; |
177 | } else if (mDate == event->dtEnd().date()) { | 177 | } else if (mDate == event->dtEnd().date()) { |
178 | prefix ="<-" ;multiday = 3; | 178 | prefix ="<-" ;multiday = 3; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | if ( !event->doesFloat() ) { | 181 | if ( !event->doesFloat() ) { |
182 | if ( mDate == event->dtStart().date () ) | 182 | if ( mDate == event->dtStart().date () ) |
183 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 183 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
184 | else if ( mDate == event->dtEnd().date () ) | 184 | else if ( mDate == event->dtEnd().date () ) |
185 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 185 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
186 | 186 | ||
187 | } | 187 | } |
188 | text = time + event->summary(); | 188 | text = time + event->summary(); |
189 | mToolTipText += prefix + text; | 189 | mToolTipText += prefix + text; |
190 | } else { | 190 | } else { |
191 | if (event->doesFloat()) { | 191 | if (event->doesFloat()) { |
192 | text = event->summary(); | 192 | text = event->summary(); |
193 | mToolTipText += text; | 193 | mToolTipText += text; |
194 | } | 194 | } |
195 | else { | 195 | else { |
196 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 196 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
197 | text += " " + event->summary(); | 197 | text += " " + event->summary(); |
198 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 198 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | if ( !event->location().isEmpty() ) | 201 | if ( !event->location().isEmpty() ) |
202 | mToolTipText += " (" + event->location() + ")"; | 202 | mToolTipText += " (" + event->location() + ")"; |
203 | //qDebug("TTT: %s ", mToolTipText.latin1()); | 203 | //qDebug("TTT: %s ", mToolTipText.latin1()); |
204 | mToolTip.append( deTag( mToolTipText ) ); | 204 | mToolTip.append( deTag( mToolTipText ) ); |
205 | } | 205 | } |
206 | mToolTip.sort(); | 206 | mToolTip.sort(); |
207 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | 207 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { |
208 | QPtrList<Todo> todolist = mCalendar->todos(mDate); | 208 | QPtrList<Todo> todolist = mCalendar->todos(mDate); |
209 | Todo *todo; | 209 | Todo *todo; |
210 | for(todo=todolist.first();todo != 0;todo=todolist.next()) { | 210 | for(todo=todolist.first();todo != 0;todo=todolist.next()) { |
211 | QString mToolTipText; | 211 | QString mToolTipText; |
212 | if ( !todo->doesFloat() ) | 212 | if ( !todo->doesFloat() ) |
213 | mToolTipText += KGlobal::locale()->formatTime(todo->dtDue().time())+" "; | 213 | mToolTipText += KGlobal::locale()->formatTime(todo->dtDue().time())+" "; |
214 | mToolTipText += todo->summary(); | 214 | mToolTipText += todo->summary(); |
215 | if ( !todo->location().isEmpty() ) | 215 | if ( !todo->location().isEmpty() ) |
216 | mToolTipText += " (" + todo->location() + ")"; | 216 | mToolTipText += " (" + todo->location() + ")"; |
217 | mToolTipText = deTag( mToolTipText); | 217 | mToolTipText = deTag( mToolTipText); |
218 | mToolTipText = "<b>" + i18n("Todo: ") + "</b>"+ mToolTipText; | 218 | mToolTipText = "<b>" + i18n("Todo: ") + "</b>"+ mToolTipText; |
219 | mToolTip.append( mToolTipText ); | 219 | mToolTip.append( mToolTipText ); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | if (KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 222 | if (KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
223 | QPtrList<Journal> j_list = mCalendar->journals4Date( mDate ); | 223 | QPtrList<Journal> j_list = mCalendar->journals4Date( mDate ); |
224 | Journal *j = j_list.first(); | 224 | Journal *j = j_list.first(); |
225 | while ( j ) { | 225 | while ( j ) { |
226 | QString mToolTipText; | 226 | QString mToolTipText; |
227 | if ( !j->summary().isEmpty() ) { | 227 | if ( !j->summary().isEmpty() ) { |
228 | mToolTipText = j->summary().left(30); | 228 | mToolTipText = j->summary().left(30); |
229 | if ( j->summary().length() > 30 ) | 229 | if ( j->summary().length() > 30 ) |
230 | mToolTipText += " ..."; | 230 | mToolTipText += " ..."; |
231 | } else { | 231 | } else { |
232 | mToolTipText = j->description().left(25); | 232 | mToolTipText = j->description().left(25); |
233 | if ( j->description().length() > 25 ) | 233 | if ( j->description().length() > 25 ) |
234 | mToolTipText += " ..."; | 234 | mToolTipText += " ..."; |
235 | mToolTipText = deTag( mToolTipText); | 235 | mToolTipText = deTag( mToolTipText); |
236 | } | 236 | } |
237 | mToolTipText = "<b>" + i18n("Journal: ") + "</b>"+ mToolTipText; | 237 | mToolTipText = "<b>" + i18n("Journal: ") + "</b>"+ mToolTipText; |
238 | mToolTip.append( mToolTipText ); | 238 | mToolTip.append( mToolTipText ); |
239 | j = j_list.next(); | 239 | j = j_list.next(); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 242 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
243 | } | 243 | } |
244 | 244 | ||
245 | 245 | ||
246 | QString KODayMatrix::deTag( QString mToolTipText ) | 246 | QString KODayMatrix::deTag( QString mToolTipText ) |
247 | { | 247 | { |
248 | 248 | ||
249 | #if QT_VERSION >= 0x030000 | 249 | #if QT_VERSION >= 0x030000 |
250 | mToolTipText.replace( '<' , "<" ); | 250 | mToolTipText.replace( '<' , "<" ); |
251 | mToolTipText.replace( '>' , ">" ); | 251 | mToolTipText.replace( '>' , ">" ); |
252 | #else | 252 | #else |
253 | if ( mToolTipText.find ('<') >= 0 ) { | 253 | if ( mToolTipText.find ('<') >= 0 ) { |
254 | mToolTipText.replace( QRegExp("<") , "<" ); | 254 | mToolTipText.replace( QRegExp("<") , "<" ); |
255 | } | 255 | } |
256 | if ( mToolTipText.find ('>') >= 0 ) { | 256 | if ( mToolTipText.find ('>') >= 0 ) { |
257 | mToolTipText.replace( QRegExp(">") , ">" ); | 257 | mToolTipText.replace( QRegExp(">") , ">" ); |
258 | } | 258 | } |
259 | #endif | 259 | #endif |
260 | return mToolTipText; | 260 | return mToolTipText; |
261 | } | 261 | } |
262 | void KODayMatrix::setCalendar( Calendar *cal ) | 262 | void KODayMatrix::setCalendar( Calendar *cal ) |
263 | { | 263 | { |
264 | mCalendar = cal; | 264 | mCalendar = cal; |
265 | 265 | ||
266 | setAcceptDrops( mCalendar ); | 266 | setAcceptDrops( mCalendar ); |
267 | 267 | ||
268 | updateEvents(); | 268 | updateEvents(); |
269 | } | 269 | } |
270 | 270 | ||
271 | QColor KODayMatrix::getShadedColor(QColor color) | 271 | QColor KODayMatrix::getShadedColor(QColor color) |
272 | { | 272 | { |
273 | QColor shaded; | 273 | QColor shaded; |
274 | int h=0; | 274 | int h=0; |
275 | int s=0; | 275 | int s=0; |
276 | int v=0; | 276 | int v=0; |
277 | color.hsv(&h,&s,&v); | 277 | color.hsv(&h,&s,&v); |
278 | s = s/4; | 278 | s = s/4; |
279 | v = 192+v/4; | 279 | v = 192+v/4; |
280 | shaded.setHsv(h,s,v); | 280 | shaded.setHsv(h,s,v); |
281 | 281 | ||
282 | return shaded; | 282 | return shaded; |
283 | } | 283 | } |
284 | 284 | ||
285 | KODayMatrix::~KODayMatrix() | 285 | KODayMatrix::~KODayMatrix() |
286 | { | 286 | { |
287 | #if QT_VERSION >= 0x030000 | 287 | #if QT_VERSION >= 0x030000 |
288 | 288 | ||
289 | #else | 289 | #else |
290 | delete mKODaymatrixWhatsThis; | 290 | delete mKODaymatrixWhatsThis; |
291 | #endif | 291 | #endif |
292 | 292 | ||
293 | // delete mKODaymatrixWhatsThis; | 293 | // delete mKODaymatrixWhatsThis; |
294 | delete [] days; | 294 | delete [] days; |
295 | delete [] daylbls; | 295 | delete [] daylbls; |
296 | //delete [] events; | 296 | //delete [] events; |
297 | delete mToolTip; | 297 | delete mToolTip; |
298 | } | 298 | } |
299 | 299 | ||
300 | /* | 300 | /* |
301 | void KODayMatrix::setStartDate(QDate start) | 301 | void KODayMatrix::setStartDate(QDate start) |
302 | { | 302 | { |
303 | updateView(start); | 303 | updateView(start); |
304 | } | 304 | } |
305 | */ | 305 | */ |
306 | 306 | ||
307 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 307 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
308 | { | 308 | { |
309 | 309 | ||
310 | if (mSelStart == NOSELECTION) { | 310 | if (mSelStart == NOSELECTION) { |
311 | return; | 311 | return; |
312 | } | 312 | } |
313 | 313 | ||
314 | //cope with selection being out of matrix limits at top (< 0) | 314 | //cope with selection being out of matrix limits at top (< 0) |
315 | int i0 = mSelStart; | 315 | int i0 = mSelStart; |
316 | if (i0 < 0) { | 316 | if (i0 < 0) { |
317 | for (int i = i0; i < 0; i++) { | 317 | for (int i = i0; i < 0; i++) { |
318 | selDays.append(days[0].addDays(i)); | 318 | selDays.append(days[0].addDays(i)); |
319 | } | 319 | } |
320 | i0 = 0; | 320 | i0 = 0; |
321 | } | 321 | } |
322 | 322 | ||
323 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 323 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
324 | if (mSelEnd > NUMDAYS-1) { | 324 | if (mSelEnd > NUMDAYS-1) { |
325 | for (int i = i0; i <= NUMDAYS-1; i++) { | 325 | for (int i = i0; i <= NUMDAYS-1; i++) { |
326 | selDays.append(days[i]); | 326 | selDays.append(days[i]); |
327 | } | 327 | } |
328 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 328 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
329 | selDays.append(days[0].addDays(i)); | 329 | selDays.append(days[0].addDays(i)); |
330 | } | 330 | } |
331 | 331 | ||
332 | // apply normal routine to selection being entirely within matrix limits | 332 | // apply normal routine to selection being entirely within matrix limits |
333 | } else { | 333 | } else { |
334 | for (int i = i0; i <= mSelEnd; i++) { | 334 | for (int i = i0; i <= mSelEnd; i++) { |
335 | selDays.append(days[i]); | 335 | selDays.append(days[i]); |
336 | } | 336 | } |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 340 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
341 | { | 341 | { |
342 | mRedrawNeeded = true; | 342 | mRedrawNeeded = true; |
343 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); | 343 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); |
344 | mSelStart = startdate.daysTo(start); | 344 | mSelStart = startdate.daysTo(start); |
345 | if ( mSelStart < 0 ) | 345 | if ( mSelStart < 0 ) |
346 | mSelStart = 0; | 346 | mSelStart = 0; |
347 | mSelEnd = startdate.daysTo(end); | 347 | mSelEnd = startdate.daysTo(end); |
348 | if ( mSelEnd > NUMDAYS-1 ) | 348 | if ( mSelEnd > NUMDAYS-1 ) |
349 | mSelEnd = NUMDAYS-1; | 349 | mSelEnd = NUMDAYS-1; |
350 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { | 350 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { |
351 | clearSelection(); | 351 | clearSelection(); |
352 | if ( noSel ) | 352 | if ( noSel ) |
353 | return false; | 353 | return false; |
354 | } | 354 | } |
355 | 355 | ||
356 | return true; | 356 | return true; |
357 | } | 357 | } |
358 | void KODayMatrix::clearSelection() | 358 | void KODayMatrix::clearSelection() |
359 | { | 359 | { |
360 | mSelEnd = mSelStart = NOSELECTION; | 360 | mSelEnd = mSelStart = NOSELECTION; |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | void KODayMatrix::recalculateToday() | 364 | void KODayMatrix::recalculateToday() |
365 | { | 365 | { |
366 | today = -1; | 366 | today = -1; |
367 | for (int i=0; i<NUMDAYS; i++) { | 367 | for (int i=0; i<NUMDAYS; i++) { |
368 | //events[i] = 0; | 368 | //events[i] = 0; |
369 | days[i] = startdate.addDays(i); | 369 | days[i] = startdate.addDays(i); |
370 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 370 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
371 | 371 | ||
372 | // if today is in the currently displayed month, hilight today | 372 | // if today is in the currently displayed month, hilight today |
373 | if (days[i].year() == QDate::currentDate().year() && | 373 | if (days[i].year() == QDate::currentDate().year() && |
374 | days[i].month() == QDate::currentDate().month() && | 374 | days[i].month() == QDate::currentDate().month() && |
375 | days[i].day() == QDate::currentDate().day()) { | 375 | days[i].day() == QDate::currentDate().day()) { |
376 | today = i; | 376 | today = i; |
377 | } | 377 | } |
378 | } | 378 | } |
379 | // qDebug(QString("Today is visible at %1.").arg(today)); | 379 | // qDebug(QString("Today is visible at %1.").arg(today)); |
380 | } | 380 | } |
381 | 381 | ||
382 | void KODayMatrix::updateView() | 382 | void KODayMatrix::updateView() |
383 | { | 383 | { |
384 | updateView(startdate); | 384 | updateView(startdate); |
385 | } | 385 | } |
386 | void KODayMatrix::repaintViewTimed() | 386 | void KODayMatrix::repaintViewTimed() |
387 | { | 387 | { |
388 | mRedrawNeeded = true; | 388 | mRedrawNeeded = true; |
389 | // bDays.fill( false); | 389 | // bDays.fill( false); |
390 | //pDays.fill( false); | 390 | //pDays.fill( false); |
391 | //hDays.fill( false); | 391 | //hDays.fill( false); |
392 | //eDays.fill( false); | 392 | //eDays.fill( false); |
393 | mRepaintTimer->stop(); | 393 | mRepaintTimer->stop(); |
394 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday | 394 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday |
395 | int i; | 395 | int i; |
396 | for(i = 0; i < NUMDAYS; i++) { | 396 | for(i = 0; i < NUMDAYS; i++) { |
397 | if ( ( (i+startDay) % 7 == 0 ) ) { | 397 | if ( ( (i+startDay) % 7 == 0 ) ) { |
398 | pDays.setBit(i); | 398 | pDays.setBit(i); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | repaint(false); | 401 | repaint(false); |
402 | } | 402 | } |
403 | void KODayMatrix::computeEvent(Event *event, int i ) | 403 | void KODayMatrix::computeEvent(Event *event, int i ) |
404 | { | 404 | { |
405 | QString holiStr = mHolidays[i]; | 405 | QString holiStr = mHolidays[i]; |
406 | if ( event->isHoliday()) { | 406 | if ( event->isHoliday()) { |
407 | pDays.setBit(i); | 407 | pDays.setBit(i); |
408 | hDays.setBit(i); | 408 | hDays.setBit(i); |
409 | if ( !holiStr.isEmpty() ) | 409 | if ( !holiStr.isEmpty() ) |
410 | holiStr += "\n"; | 410 | holiStr += "\n"; |
411 | holiStr += event->summary(); | 411 | holiStr += event->summary(); |
412 | if ( !event->location().isEmpty() ) | 412 | if ( !event->location().isEmpty() ) |
413 | holiStr += " (" + event->location() + ")"; | 413 | holiStr += " (" + event->location() + ")"; |
414 | mHolidays[i] =holiStr ; | 414 | mHolidays[i] =holiStr ; |
415 | eDays.setBit(i); | 415 | eDays.setBit(i); |
416 | } | 416 | } |
417 | if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_T_VIEW && KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) { | 417 | if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_T_VIEW && KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) { |
418 | if ( event->isBirthday()) { | 418 | if ( event->isBirthday()) { |
419 | pDays.setBit(i); | 419 | pDays.setBit(i); |
420 | if ( !holiStr.isEmpty() ) | 420 | if ( !holiStr.isEmpty() ) |
421 | holiStr += "\n"; | 421 | holiStr += "\n"; |
422 | holiStr += i18n("Birthday") + ": "+event->summary(); | 422 | holiStr += i18n("Birthday") + ": "+event->summary(); |
423 | if ( !event->location().isEmpty() ) | 423 | if ( !event->location().isEmpty() ) |
424 | holiStr += " (" + event->location() + ")"; | 424 | holiStr += " (" + event->location() + ")"; |
425 | bDays.setBit(i); | 425 | bDays.setBit(i); |
426 | mHolidays[i] =holiStr ; | 426 | mHolidays[i] =holiStr ; |
427 | } | 427 | } |
428 | } | 428 | } |
429 | if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) | 429 | if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) |
430 | eDays.setBit(i); | 430 | eDays.setBit(i); |
431 | } | 431 | } |
432 | void KODayMatrix::updateViewTimed() | 432 | void KODayMatrix::updateViewTimed() |
433 | { | 433 | { |
434 | mUpdateTimer->stop(); | 434 | mUpdateTimer->stop(); |
435 | if ( !mCalendar ) { | 435 | if ( !mCalendar ) { |
436 | qDebug("NOT CAL "); | 436 | qDebug("NOT CAL "); |
437 | return; | 437 | return; |
438 | } | 438 | } |
439 | #if 1 | 439 | #if 1 |
440 | 440 | ||
441 | 441 | ||
442 | int i; | 442 | int i; |
443 | int timeSpan = NUMDAYS-1; | 443 | int timeSpan = NUMDAYS-1; |
444 | QPtrList<Event> events = mCalendar->events(); | 444 | QPtrList<Event> events = mCalendar->events(); |
445 | Event *event; | 445 | Event *event; |
446 | QDateTime dt; | 446 | QDateTime dt; |
447 | bool ok; | 447 | bool ok; |
448 | bDays.fill( false); | 448 | bDays.fill( false); |
449 | pDays.fill( false); | 449 | pDays.fill( false); |
450 | hDays.fill( false); | 450 | hDays.fill( false); |
451 | eDays.fill( false); | 451 | eDays.fill( false); |
452 | mHolidays.clear(); | 452 | mHolidays.clear(); |
453 | QDate mStartDate = days[0]; | 453 | QDate mStartDate = days[0]; |
454 | QDate endDate = mStartDate.addDays( timeSpan ); | 454 | QDate endDate = mStartDate.addDays( timeSpan ); |
455 | for( event = events.first(); event; event = events.next() ) { // for event | 455 | for( event = events.first(); event; event = events.next() ) { // for event |
456 | ushort recurType = event->doesRecur(); | 456 | ushort recurType = event->doesRecur(); |
457 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 457 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
458 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 458 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
459 | continue; | 459 | continue; |
460 | } | 460 | } |
461 | if ( !KOPrefs::instance()->mLongAllday && event->doesFloat()&& event->isMultiDay() ) { | ||
462 | continue; | ||
463 | } | ||
461 | if ( event->doesRecur() ) { | 464 | if ( event->doesRecur() ) { |
462 | bool last; | 465 | bool last; |
463 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 466 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
464 | QDateTime incidenceEnd; | 467 | QDateTime incidenceEnd; |
465 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 468 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
466 | bool invalid = false; | 469 | bool invalid = false; |
467 | while( true ) { | 470 | while( true ) { |
468 | if ( incidenceStart.isValid() ) { | 471 | if ( incidenceStart.isValid() ) { |
469 | incidenceEnd = incidenceStart.addDays( eventlen ); | 472 | incidenceEnd = incidenceStart.addDays( eventlen ); |
470 | int st = incidenceStart.date().daysTo( endDate ); | 473 | int st = incidenceStart.date().daysTo( endDate ); |
471 | if ( st >= 0 ) { // start before timeend | 474 | if ( st >= 0 ) { // start before timeend |
472 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 475 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
473 | if ( end >= 0 ) { // end after timestart --- got one! | 476 | if ( end >= 0 ) { // end after timestart --- got one! |
474 | //normalize | 477 | //normalize |
475 | st = timeSpan - st; | 478 | st = timeSpan - st; |
476 | if ( st < 0 ) st = 0; | 479 | if ( st < 0 ) st = 0; |
477 | if ( end > timeSpan ) end = timeSpan; | 480 | if ( end > timeSpan ) end = timeSpan; |
478 | int iii; | 481 | int iii; |
479 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 482 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
480 | for ( iii = st;iii<= end;++iii) { | 483 | for ( iii = st;iii<= end;++iii) { |
481 | computeEvent( event, iii ); | 484 | computeEvent( event, iii ); |
482 | } | 485 | } |
483 | } | 486 | } |
484 | } | 487 | } |
485 | } else { | 488 | } else { |
486 | if ( invalid ) | 489 | if ( invalid ) |
487 | break; | 490 | break; |
488 | invalid = true; | 491 | invalid = true; |
489 | //qDebug("invalid %s", event->summary().latin1()); | 492 | //qDebug("invalid %s", event->summary().latin1()); |
490 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 493 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
491 | } | 494 | } |
492 | if ( last ) | 495 | if ( last ) |
493 | break; | 496 | break; |
494 | bool ok; | 497 | bool ok; |
495 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 498 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
496 | if ( ! ok ) | 499 | if ( ! ok ) |
497 | break; | 500 | break; |
498 | if ( incidenceStart.date() > endDate ) | 501 | if ( incidenceStart.date() > endDate ) |
499 | break; | 502 | break; |
500 | } | 503 | } |
501 | } else { // no recur | 504 | } else { // no recur |
502 | int st = event->dtStart().date().daysTo( endDate ); | 505 | int st = event->dtStart().date().daysTo( endDate ); |
503 | if ( st >= 0 ) { // start before timeend | 506 | if ( st >= 0 ) { // start before timeend |
504 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 507 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
505 | if ( end >= 0 ) { // end after timestart --- got one! | 508 | if ( end >= 0 ) { // end after timestart --- got one! |
506 | //normalize | 509 | //normalize |
507 | st = timeSpan - st; | 510 | st = timeSpan - st; |
508 | if ( st < 0 ) st = 0; | 511 | if ( st < 0 ) st = 0; |
509 | if ( end > timeSpan ) end = timeSpan; | 512 | if ( end > timeSpan ) end = timeSpan; |
510 | int iii; | 513 | int iii; |
511 | for ( iii = st;iii<= end;++iii) | 514 | for ( iii = st;iii<= end;++iii) |
512 | computeEvent( event, iii ); | 515 | computeEvent( event, iii ); |
513 | } | 516 | } |
514 | } | 517 | } |
515 | } | 518 | } |
516 | } | 519 | } |
517 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday | 520 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday |
518 | for(i = 0; i < NUMDAYS; i++) { | 521 | for(i = 0; i < NUMDAYS; i++) { |
519 | if ( ( (i+startDay) % 7 == 0 ) ) { | 522 | if ( ( (i+startDay) % 7 == 0 ) ) { |
520 | pDays.setBit(i); | 523 | pDays.setBit(i); |
521 | } | 524 | } |
522 | } | 525 | } |
523 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | 526 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { |
524 | bDays.fill( false); | 527 | bDays.fill( false); |
525 | // insert due todos | 528 | // insert due todos |
526 | QPtrList<Todo> todos = mCalendar->todos( ); | 529 | QPtrList<Todo> todos = mCalendar->todos( ); |
527 | Todo *todo; | 530 | Todo *todo; |
528 | for(todo = todos.first(); todo; todo = todos.next()) { | 531 | for(todo = todos.first(); todo; todo = todos.next()) { |
529 | //insertTodo( todo ); | 532 | //insertTodo( todo ); |
530 | if ( todo->hasDueDate() ) { | 533 | if ( todo->hasDueDate() ) { |
531 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 534 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
532 | if ( day >= 0 && day < timeSpan + 1) { | 535 | if ( day >= 0 && day < timeSpan + 1) { |
533 | int i = day; | 536 | int i = day; |
534 | QString holiStr = mHolidays[i]; | 537 | QString holiStr = mHolidays[i]; |
535 | pDays.setBit(i); | 538 | pDays.setBit(i); |
536 | if ( !holiStr.isEmpty() ) | 539 | if ( !holiStr.isEmpty() ) |
537 | holiStr += "\n"; | 540 | holiStr += "\n"; |
538 | holiStr += i18n("Todo") + ": "+todo->summary(); | 541 | holiStr += i18n("Todo") + ": "+todo->summary(); |
539 | if ( !todo->location().isEmpty() ) | 542 | if ( !todo->location().isEmpty() ) |
540 | holiStr += " (" + todo->location() + ")"; | 543 | holiStr += " (" + todo->location() + ")"; |
541 | bDays.setBit(i); | 544 | bDays.setBit(i); |
542 | mHolidays[i] =holiStr ; | 545 | mHolidays[i] =holiStr ; |
543 | eDays.setBit(i); | 546 | eDays.setBit(i); |
544 | } | 547 | } |
545 | } | 548 | } |
546 | } | 549 | } |
547 | } | 550 | } |
548 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 551 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
549 | bDays.fill( false); | 552 | bDays.fill( false); |
550 | // insert due todos | 553 | // insert due todos |
551 | QPtrList<Journal> todos = mCalendar->journals( ); | 554 | QPtrList<Journal> todos = mCalendar->journals( ); |
552 | Journal *todo; | 555 | Journal *todo; |
553 | for(todo = todos.first(); todo; todo = todos.next()) { | 556 | for(todo = todos.first(); todo; todo = todos.next()) { |
554 | int day = mStartDate.daysTo( todo->dtStart().date() ); | 557 | int day = mStartDate.daysTo( todo->dtStart().date() ); |
555 | if ( day >= 0 && day < timeSpan + 1) { | 558 | if ( day >= 0 && day < timeSpan + 1) { |
556 | int i = day; | 559 | int i = day; |
557 | QString holiStr = mHolidays[i]; | 560 | QString holiStr = mHolidays[i]; |
558 | pDays.setBit(i); | 561 | pDays.setBit(i); |
559 | if ( !holiStr.isEmpty() ) | 562 | if ( !holiStr.isEmpty() ) |
560 | holiStr += "\n"; | 563 | holiStr += "\n"; |
561 | holiStr += i18n("Journal: ")+todo->summary().left(25); | 564 | holiStr += i18n("Journal: ")+todo->summary().left(25); |
562 | if ( todo->summary().length() > 25 ) | 565 | if ( todo->summary().length() > 25 ) |
563 | holiStr +="..."; | 566 | holiStr +="..."; |
564 | bDays.setBit(i); | 567 | bDays.setBit(i); |
565 | mHolidays[i] =holiStr ; | 568 | mHolidays[i] =holiStr ; |
566 | eDays.setBit(i); | 569 | eDays.setBit(i); |
567 | 570 | ||
568 | } | 571 | } |
569 | } | 572 | } |
570 | } | 573 | } |
571 | #else | 574 | #else |
572 | //qDebug("KODayMatrix::updateViewTimed "); | 575 | //qDebug("KODayMatrix::updateViewTimed "); |
573 | for(int i = 0; i < NUMDAYS; i++) { | 576 | for(int i = 0; i < NUMDAYS; i++) { |
574 | // if events are set for the day then remember to draw it bold | 577 | // if events are set for the day then remember to draw it bold |
575 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 578 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
576 | Event *event; | 579 | Event *event; |
577 | int numEvents = eventlist.count(); | 580 | int numEvents = eventlist.count(); |
578 | QString holiStr = ""; | 581 | QString holiStr = ""; |
579 | bDays.clearBit(i); | 582 | bDays.clearBit(i); |
580 | hDays.clearBit(i); | 583 | hDays.clearBit(i); |
581 | eDays.clearBit(i); | 584 | eDays.clearBit(i); |
582 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 585 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
583 | ushort recurType = event->recurrence()->doesRecur(); | 586 | ushort recurType = event->recurrence()->doesRecur(); |
584 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 587 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
585 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 588 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
586 | numEvents--; | 589 | numEvents--; |
587 | } | 590 | } |
588 | if ( event->isHoliday()) { | 591 | if ( event->isHoliday()) { |
589 | hDays.setBit(i); | 592 | hDays.setBit(i); |
590 | if ( !holiStr.isEmpty() ) | 593 | if ( !holiStr.isEmpty() ) |
591 | holiStr += "\n"; | 594 | holiStr += "\n"; |
592 | holiStr += event->summary(); | 595 | holiStr += event->summary(); |
593 | if ( !event->location().isEmpty() ) | 596 | if ( !event->location().isEmpty() ) |
594 | holiStr += " (" + event->location() + ")"; | 597 | holiStr += " (" + event->location() + ")"; |
595 | } | 598 | } |
596 | if ( event->isBirthday()) { | 599 | if ( event->isBirthday()) { |
597 | if ( !holiStr.isEmpty() ) | 600 | if ( !holiStr.isEmpty() ) |
598 | holiStr += "\n"; | 601 | holiStr += "\n"; |
599 | holiStr += i18n("Birthday") + ": "+event->summary(); | 602 | holiStr += i18n("Birthday") + ": "+event->summary(); |
600 | if ( !event->location().isEmpty() ) | 603 | if ( !event->location().isEmpty() ) |
601 | holiStr += " (" + event->location() + ")"; | 604 | holiStr += " (" + event->location() + ")"; |
602 | bDays.setBit(i); | 605 | bDays.setBit(i); |
603 | } | 606 | } |
604 | } | 607 | } |
605 | if ( numEvents ) | 608 | if ( numEvents ) |
606 | eDays.setBit(i); | 609 | eDays.setBit(i); |
607 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 610 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
608 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 611 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
609 | !holiStr.isEmpty()) { | 612 | !holiStr.isEmpty()) { |
610 | mHolidays[i] = holiStr; | 613 | mHolidays[i] = holiStr; |
611 | } else { | 614 | } else { |
612 | mHolidays[i] = QString::null; | 615 | mHolidays[i] = QString::null; |
613 | } | 616 | } |
614 | } | 617 | } |
615 | #endif | 618 | #endif |
616 | mRedrawNeeded = true; | 619 | mRedrawNeeded = true; |
617 | if ( ! mPendingUpdateBeforeRepaint ) | 620 | if ( ! mPendingUpdateBeforeRepaint ) |
618 | repaint(false); | 621 | repaint(false); |
619 | } | 622 | } |
620 | void KODayMatrix::updateView(QDate actdate) | 623 | void KODayMatrix::updateView(QDate actdate) |
621 | { | 624 | { |
622 | if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView ) | 625 | if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView ) |
623 | mRedrawNeeded = true; | 626 | mRedrawNeeded = true; |
624 | mLastView = KOPrefs::instance()->mCurrentDisplayedView; | 627 | mLastView = KOPrefs::instance()->mCurrentDisplayedView; |
625 | if ( ! actdate.isValid() ) { | 628 | if ( ! actdate.isValid() ) { |
626 | //qDebug("date not valid "); | 629 | //qDebug("date not valid "); |
627 | return; | 630 | return; |
628 | } | 631 | } |
629 | mDayChanged = false; | 632 | mDayChanged = false; |
630 | //flag to indicate if the starting day of the matrix has changed by this call | 633 | //flag to indicate if the starting day of the matrix has changed by this call |
631 | //mDayChanged = false; | 634 | //mDayChanged = false; |
632 | // if a new startdate is to be set then apply Cornelius's calculation | 635 | // if a new startdate is to be set then apply Cornelius's calculation |
633 | // of the first day to be shown | 636 | // of the first day to be shown |
634 | if (actdate != startdate) { | 637 | if (actdate != startdate) { |
635 | // reset index of selection according to shift of starting date from startdate to actdate | 638 | // reset index of selection according to shift of starting date from startdate to actdate |
636 | if (mSelStart != NOSELECTION) { | 639 | if (mSelStart != NOSELECTION) { |
637 | int tmp = actdate.daysTo(startdate); | 640 | int tmp = actdate.daysTo(startdate); |
638 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 641 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
639 | // shift selection if new one would be visible at least partly ! | 642 | // shift selection if new one would be visible at least partly ! |
640 | 643 | ||
641 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 644 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
642 | // nested if is required for next X display pushed from a different month - correction required | 645 | // nested if is required for next X display pushed from a different month - correction required |
643 | // otherwise, for month forward and backward, it must be avoided | 646 | // otherwise, for month forward and backward, it must be avoided |
644 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 647 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
645 | mSelStart = mSelStart + tmp; | 648 | mSelStart = mSelStart + tmp; |
646 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 649 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
647 | mSelEnd = mSelEnd + tmp; | 650 | mSelEnd = mSelEnd + tmp; |
648 | } | 651 | } |
649 | } | 652 | } |
650 | startdate = actdate; | 653 | startdate = actdate; |
651 | mDayChanged = true; | 654 | mDayChanged = true; |
652 | recalculateToday(); | 655 | recalculateToday(); |
653 | mRedrawNeeded = true; | 656 | mRedrawNeeded = true; |
654 | } | 657 | } |
655 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 658 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
656 | if ( !isVisible() ) { | 659 | if ( !isVisible() ) { |
657 | mPendingUpdateBeforeRepaint = true; | 660 | mPendingUpdateBeforeRepaint = true; |
658 | } else { | 661 | } else { |
659 | #ifdef DESKTOP_VERSION | 662 | #ifdef DESKTOP_VERSION |
660 | //mRepaintTimer->start( 100 ); | 663 | //mRepaintTimer->start( 100 ); |
661 | //updateViewTimed(); | 664 | //updateViewTimed(); |
662 | mUpdateTimer->start( 50 ); | 665 | mUpdateTimer->start( 50 ); |
663 | #else | 666 | #else |
664 | mRepaintTimer->start( 350 ); | 667 | mRepaintTimer->start( 350 ); |
665 | mUpdateTimer->start( 800 ); | 668 | mUpdateTimer->start( 800 ); |
666 | #endif | 669 | #endif |
667 | } | 670 | } |
668 | } | 671 | } |
669 | void KODayMatrix::updateEvents() | 672 | void KODayMatrix::updateEvents() |
670 | { | 673 | { |
671 | if ( !mCalendar ) return; | 674 | if ( !mCalendar ) return; |
672 | 675 | ||
673 | for( int i = 0; i < NUMDAYS; i++ ) { | 676 | for( int i = 0; i < NUMDAYS; i++ ) { |
674 | // if events are set for the day then remember to draw it bold | 677 | // if events are set for the day then remember to draw it bold |
675 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 678 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
676 | int numEvents = eventlist.count(); | 679 | int numEvents = eventlist.count(); |
677 | Event *event; | 680 | Event *event; |
678 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 681 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
679 | ushort recurType = event->doesRecur(); | 682 | ushort recurType = event->doesRecur(); |
680 | 683 | ||
681 | if ( ( recurType == Recurrence::rDaily && | 684 | if ( ( recurType == Recurrence::rDaily && |
682 | !KOPrefs::instance()->mDailyRecur ) || | 685 | !KOPrefs::instance()->mDailyRecur ) || |
683 | ( recurType == Recurrence::rWeekly && | 686 | ( recurType == Recurrence::rWeekly && |
684 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 687 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
685 | numEvents--; | 688 | numEvents--; |
686 | } | 689 | } |
690 | if ( !KOPrefs::instance()->mLongAllday && event->doesFloat()&& event->isMultiDay() ) { | ||
691 | numEvents--; | ||
692 | } | ||
687 | } | 693 | } |
688 | if ( numEvents ) | 694 | if ( numEvents ) |
689 | eDays.setBit(i); | 695 | eDays.setBit(i); |
690 | else | 696 | else |
691 | eDays.clearBit(i); | 697 | eDays.clearBit(i); |
692 | } | 698 | } |
693 | } | 699 | } |
694 | 700 | ||
695 | const QDate& KODayMatrix::getDate(int offset) | 701 | const QDate& KODayMatrix::getDate(int offset) |
696 | { | 702 | { |
697 | if (offset < 0 || offset > NUMDAYS-1) { | 703 | if (offset < 0 || offset > NUMDAYS-1) { |
698 | qDebug("Wrong offset2 %d", offset); | 704 | qDebug("Wrong offset2 %d", offset); |
699 | return days[0]; | 705 | return days[0]; |
700 | } | 706 | } |
701 | return days[offset]; | 707 | return days[offset]; |
702 | } | 708 | } |
703 | 709 | ||
704 | QString KODayMatrix::getHolidayLabel(int offset) | 710 | QString KODayMatrix::getHolidayLabel(int offset) |
705 | { | 711 | { |
706 | if (offset < 0 || offset > NUMDAYS-1) { | 712 | if (offset < 0 || offset > NUMDAYS-1) { |
707 | qDebug("Wrong offset1 %d", offset); | 713 | qDebug("Wrong offset1 %d", offset); |
708 | return QString(); | 714 | return QString(); |
709 | } | 715 | } |
710 | return mHolidays[offset]; | 716 | return mHolidays[offset]; |
711 | } | 717 | } |
712 | 718 | ||
713 | int KODayMatrix::getDayIndexFrom(int x, int y) | 719 | int KODayMatrix::getDayIndexFrom(int x, int y) |
714 | { | 720 | { |
715 | int colModulo = (width()-2) % 7; | 721 | int colModulo = (width()-2) % 7; |
716 | int rowModulo = (height()-2) % 6; | 722 | int rowModulo = (height()-2) % 6; |
717 | #if 0 | 723 | #if 0 |
718 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 724 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
719 | 6 - x/daysize.width() : x/daysize.width()); | 725 | 6 - x/daysize.width() : x/daysize.width()); |
720 | #endif | 726 | #endif |
721 | int xVal = (x-colModulo/2-2)/daysize.width(); | 727 | int xVal = (x-colModulo/2-2)/daysize.width(); |
722 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 728 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
723 | 729 | ||
724 | 730 | ||
725 | return 7*(yVal) + xVal; | 731 | return 7*(yVal) + xVal; |
726 | 732 | ||
727 | } | 733 | } |
728 | 734 | ||
729 | // ---------------------------------------------------------------------------- | 735 | // ---------------------------------------------------------------------------- |
730 | // M O U S E E V E N T H A N D L I N G | 736 | // M O U S E E V E N T H A N D L I N G |
731 | // ---------------------------------------------------------------------------- | 737 | // ---------------------------------------------------------------------------- |
732 | 738 | ||
733 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 739 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
734 | { | 740 | { |
735 | 741 | ||
736 | if ( e->button() == LeftButton ) | 742 | if ( e->button() == LeftButton ) |
737 | mouseDown = true; | 743 | mouseDown = true; |
738 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 744 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
739 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 745 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
740 | mSelInit = mSelStart; | 746 | mSelInit = mSelStart; |
741 | mSelEnd = mSelStart; | 747 | mSelEnd = mSelStart; |
742 | mRedrawNeeded = true; | 748 | mRedrawNeeded = true; |
743 | repaint(false); | 749 | repaint(false); |
744 | } | 750 | } |
745 | 751 | ||
746 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 752 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
747 | { | 753 | { |
748 | mRedrawNeeded = true; | 754 | mRedrawNeeded = true; |
749 | if ( e->button() == LeftButton ) | 755 | if ( e->button() == LeftButton ) |
750 | if ( ! mouseDown ) { | 756 | if ( ! mouseDown ) { |
751 | return; | 757 | return; |
752 | } | 758 | } |
753 | else | 759 | else |
754 | mouseDown = false; | 760 | mouseDown = false; |
755 | int tmp = getDayIndexFrom(e->x(), e->y()); | 761 | int tmp = getDayIndexFrom(e->x(), e->y()); |
756 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 762 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
757 | 763 | ||
758 | if (mSelInit > tmp) { | 764 | if (mSelInit > tmp) { |
759 | mSelEnd = mSelInit; | 765 | mSelEnd = mSelInit; |
760 | if (tmp != mSelStart) { | 766 | if (tmp != mSelStart) { |
761 | mSelStart = tmp; | 767 | mSelStart = tmp; |
762 | repaint(false); | 768 | repaint(false); |
763 | } | 769 | } |
764 | } else { | 770 | } else { |
765 | mSelStart = mSelInit; | 771 | mSelStart = mSelInit; |
766 | 772 | ||
767 | //repaint only if selection has changed | 773 | //repaint only if selection has changed |
768 | if (tmp != mSelEnd) { | 774 | if (tmp != mSelEnd) { |
769 | mSelEnd = tmp; | 775 | mSelEnd = tmp; |
770 | repaint(false); | 776 | repaint(false); |
771 | } | 777 | } |
772 | } | 778 | } |
773 | 779 | ||
774 | DateList daylist; | 780 | DateList daylist; |
775 | if ( mSelStart < 0 ) | 781 | if ( mSelStart < 0 ) |
776 | mSelStart = 0; | 782 | mSelStart = 0; |
777 | for (int i = mSelStart; i <= mSelEnd; i++) { | 783 | for (int i = mSelStart; i <= mSelEnd; i++) { |
778 | daylist.append(days[i]); | 784 | daylist.append(days[i]); |
779 | } | 785 | } |
780 | emit selected((const DateList)daylist); | 786 | emit selected((const DateList)daylist); |
781 | 787 | ||
782 | } | 788 | } |
783 | 789 | ||
784 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 790 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
785 | { | 791 | { |
786 | if ( ! mouseDown ) { | 792 | if ( ! mouseDown ) { |
787 | return; | 793 | return; |
788 | } | 794 | } |
789 | mRedrawNeeded = true; | 795 | mRedrawNeeded = true; |
790 | int tmp = getDayIndexFrom(e->x(), e->y()); | 796 | int tmp = getDayIndexFrom(e->x(), e->y()); |
791 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 797 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
792 | 798 | ||
793 | if (mSelInit > tmp) { | 799 | if (mSelInit > tmp) { |
794 | mSelEnd = mSelInit; | 800 | mSelEnd = mSelInit; |
795 | if (tmp != mSelStart) { | 801 | if (tmp != mSelStart) { |
796 | mSelStart = tmp; | 802 | mSelStart = tmp; |
797 | repaint(false); | 803 | repaint(false); |
798 | } | 804 | } |
799 | } else { | 805 | } else { |
800 | mSelStart = mSelInit; | 806 | mSelStart = mSelInit; |
801 | 807 | ||
802 | //repaint only if selection has changed | 808 | //repaint only if selection has changed |
803 | if (tmp != mSelEnd) { | 809 | if (tmp != mSelEnd) { |
804 | mSelEnd = tmp; | 810 | mSelEnd = tmp; |
805 | repaint(false); | 811 | repaint(false); |
806 | } | 812 | } |
807 | } | 813 | } |
808 | } | 814 | } |
809 | 815 | ||
810 | // ---------------------------------------------------------------------------- | 816 | // ---------------------------------------------------------------------------- |
811 | // D R A G ' N D R O P H A N D L I N G | 817 | // D R A G ' N D R O P H A N D L I N G |
812 | // ---------------------------------------------------------------------------- | 818 | // ---------------------------------------------------------------------------- |
813 | 819 | ||
814 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 820 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
815 | { | 821 | { |
816 | #ifndef KORG_NODND | 822 | #ifndef KORG_NODND |
817 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 823 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
818 | e->ignore(); | 824 | e->ignore(); |
819 | return; | 825 | return; |
820 | } | 826 | } |
821 | 827 | ||
822 | // some visual feedback | 828 | // some visual feedback |
823 | // oldPalette = palette(); | 829 | // oldPalette = palette(); |
824 | // setPalette(my_HilitePalette); | 830 | // setPalette(my_HilitePalette); |
825 | // update(); | 831 | // update(); |
826 | #endif | 832 | #endif |
827 | } | 833 | } |
828 | 834 | ||
829 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 835 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
830 | { | 836 | { |
831 | #ifndef KORG_NODND | 837 | #ifndef KORG_NODND |
832 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 838 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
833 | e->ignore(); | 839 | e->ignore(); |
834 | return; | 840 | return; |
835 | } | 841 | } |
836 | 842 | ||
837 | e->accept(); | 843 | e->accept(); |
838 | #endif | 844 | #endif |
839 | } | 845 | } |
840 | 846 | ||
841 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 847 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
842 | { | 848 | { |
843 | #ifndef KORG_NODND | 849 | #ifndef KORG_NODND |
844 | // setPalette(oldPalette); | 850 | // setPalette(oldPalette); |
845 | // update(); | 851 | // update(); |
846 | #endif | 852 | #endif |
847 | } | 853 | } |
848 | 854 | ||
849 | void KODayMatrix::dropEvent(QDropEvent *e) | 855 | void KODayMatrix::dropEvent(QDropEvent *e) |
850 | { | 856 | { |
851 | #ifndef KORG_NODND | 857 | #ifndef KORG_NODND |
852 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 858 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
853 | 859 | ||
854 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 860 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
855 | e->ignore(); | 861 | e->ignore(); |
856 | return; | 862 | return; |
857 | } | 863 | } |
858 | 864 | ||
859 | DndFactory factory( mCalendar ); | 865 | DndFactory factory( mCalendar ); |
860 | Event *event = factory.createDrop(e); | 866 | Event *event = factory.createDrop(e); |
861 | 867 | ||
862 | if (event) { | 868 | if (event) { |
863 | e->acceptAction(); | 869 | e->acceptAction(); |
864 | 870 | ||
865 | Event *existingEvent = mCalendar->event(event->uid()); | 871 | Event *existingEvent = mCalendar->event(event->uid()); |
866 | 872 | ||
867 | if(existingEvent) { | 873 | if(existingEvent) { |
868 | // uniquify event | 874 | // uniquify event |
869 | event->recreate(); | 875 | event->recreate(); |
870 | /* | 876 | /* |
871 | KMessageBox::sorry(this, | 877 | KMessageBox::sorry(this, |
872 | i18n("Event already exists in this calendar."), | 878 | i18n("Event already exists in this calendar."), |
873 | i18n("Drop Event")); | 879 | i18n("Drop Event")); |
874 | delete event; | 880 | delete event; |
875 | return; | 881 | return; |
876 | */ | 882 | */ |
877 | } | 883 | } |
878 | // kdDebug() << "Drop new Event" << endl; | 884 | // kdDebug() << "Drop new Event" << endl; |
879 | // Adjust date | 885 | // Adjust date |
880 | QDateTime start = event->dtStart(); | 886 | QDateTime start = event->dtStart(); |
881 | QDateTime end = event->dtEnd(); | 887 | QDateTime end = event->dtEnd(); |
882 | int duration = start.daysTo(end); | 888 | int duration = start.daysTo(end); |
883 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 889 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
884 | 890 | ||
885 | start.setDate(days[idx]); | 891 | start.setDate(days[idx]); |
886 | end.setDate(days[idx].addDays(duration)); | 892 | end.setDate(days[idx].addDays(duration)); |
887 | 893 | ||
888 | event->setDtStart(start); | 894 | event->setDtStart(start); |
889 | event->setDtEnd(end); | 895 | event->setDtEnd(end); |
890 | mCalendar->addEvent(event); | 896 | mCalendar->addEvent(event); |
891 | 897 | ||
892 | emit eventDropped(event); | 898 | emit eventDropped(event); |
893 | } else { | 899 | } else { |
894 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 900 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
895 | e->ignore(); | 901 | e->ignore(); |
896 | } | 902 | } |
897 | #endif | 903 | #endif |
898 | } | 904 | } |
899 | 905 | ||
900 | // ---------------------------------------------------------------------------- | 906 | // ---------------------------------------------------------------------------- |
901 | // P A I N T E V E N T H A N D L I N G | 907 | // P A I N T E V E N T H A N D L I N G |
902 | // ---------------------------------------------------------------------------- | 908 | // ---------------------------------------------------------------------------- |
903 | 909 | ||
904 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 910 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
905 | { | 911 | { |
906 | 912 | ||
907 | if ( width() <= 0 || height() <= 0 ) | 913 | if ( width() <= 0 || height() <= 0 ) |
908 | return; | 914 | return; |
909 | if ( mPendingUpdateBeforeRepaint ) { | 915 | if ( mPendingUpdateBeforeRepaint ) { |
910 | updateViewTimed(); | 916 | updateViewTimed(); |
911 | mPendingUpdateBeforeRepaint = false; | 917 | mPendingUpdateBeforeRepaint = false; |
912 | } | 918 | } |
913 | #if 0 | 919 | #if 0 |
914 | if ( myPix.width() != width() || myPix.height()!=height() ) { | 920 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
915 | myPix.resize(size() ); | 921 | myPix.resize(size() ); |
916 | mRedrawNeeded = true; | 922 | mRedrawNeeded = true; |
917 | } | 923 | } |
918 | #endif | 924 | #endif |
919 | if ( oldW != width() || oldH !=height() ) | 925 | if ( oldW != width() || oldH !=height() ) |
920 | mRedrawNeeded = true; | 926 | mRedrawNeeded = true; |
921 | 927 | ||
922 | oldH = height() ; | 928 | oldH = height() ; |
923 | oldW = width(); | 929 | oldW = width(); |
924 | if ( myPix.width() < width() || myPix.height() < height() ) { | 930 | if ( myPix.width() < width() || myPix.height() < height() ) { |
925 | myPix.resize(size() ); | 931 | myPix.resize(size() ); |
926 | mRedrawNeeded = true; | 932 | mRedrawNeeded = true; |
927 | 933 | ||
928 | } | 934 | } |
929 | 935 | ||
930 | if ( mRedrawNeeded ) { | 936 | if ( mRedrawNeeded ) { |
931 | //qDebug("REDRAW "); | 937 | //qDebug("REDRAW "); |
932 | QPainter p(&myPix); | 938 | QPainter p(&myPix); |
933 | p.setFont(font()); | 939 | p.setFont(font()); |
934 | 940 | ||
935 | 941 | ||
936 | int dheight = daysize.height(); | 942 | int dheight = daysize.height(); |
937 | int dwidth = daysize.width(); | 943 | int dwidth = daysize.width(); |
938 | int row,col; | 944 | int row,col; |
939 | int selw, selh; | 945 | int selw, selh; |
940 | int xyOff = frameWidth(); | 946 | int xyOff = frameWidth(); |
941 | int colModulo = (width()-2) % 7; | 947 | int colModulo = (width()-2) % 7; |
942 | int rowModulo = (height()-2) % 6; | 948 | int rowModulo = (height()-2) % 6; |
943 | //qDebug("col %d row %d ",colModulo,rowModulo ); | 949 | //qDebug("col %d row %d ",colModulo,rowModulo ); |
944 | 950 | ||
945 | bool isRTL = KOGlobals::self()->reverseLayout(); | 951 | bool isRTL = KOGlobals::self()->reverseLayout(); |
946 | 952 | ||
947 | // draw background and topleft frame | 953 | // draw background and topleft frame |
948 | p.fillRect(0,0,width(),height(), mDefaultBackColor); | 954 | p.fillRect(0,0,width(),height(), mDefaultBackColor); |
949 | //p.setPen(mDefaultTextColor); | 955 | //p.setPen(mDefaultTextColor); |
950 | //p.drawRect(0, 0, width(), height()); | 956 | //p.drawRect(0, 0, width(), height()); |
951 | int mSelStartT = mSelStart; | 957 | int mSelStartT = mSelStart; |
952 | int mSelEndT = mSelEnd; | 958 | int mSelEndT = mSelEnd; |
953 | if ( mSelEndT >= NUMDAYS ) | 959 | if ( mSelEndT >= NUMDAYS ) |
954 | mSelEndT = NUMDAYS-1; | 960 | mSelEndT = NUMDAYS-1; |
955 | // draw selected days with highlighted background color | 961 | // draw selected days with highlighted background color |
956 | if (mSelStart != NOSELECTION) { | 962 | if (mSelStart != NOSELECTION) { |
957 | bool skip = false; | 963 | bool skip = false; |
958 | if ( ! mouseDown ) { | 964 | if ( ! mouseDown ) { |
959 | int mo = days[20].month(); | 965 | int mo = days[20].month(); |
960 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); | 966 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); |
961 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); | 967 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); |
962 | int startMo = days[mSelStartT].month(); | 968 | int startMo = days[mSelStartT].month(); |
963 | int endMo = days[mSelEndT].month(); | 969 | int endMo = days[mSelEndT].month(); |
964 | if ( startMo == 12 && mo == 1 && endMo <= 2 ) | 970 | if ( startMo == 12 && mo == 1 && endMo <= 2 ) |
965 | startMo = 1; | 971 | startMo = 1; |
966 | if ( endMo == 1 && mo == 12 ) | 972 | if ( endMo == 1 && mo == 12 ) |
967 | endMo = 12; | 973 | endMo = 12; |
968 | if ( mo == 12 && startMo == 1 ) | 974 | if ( mo == 12 && startMo == 1 ) |
969 | startMo = 13; | 975 | startMo = 13; |
970 | if ( (startMo > mo || endMo < mo) ) { | 976 | if ( (startMo > mo || endMo < mo) ) { |
971 | skip = true; | 977 | skip = true; |
972 | } else { | 978 | } else { |
973 | if ( days[mSelStartT].month() != mo ) { | 979 | if ( days[mSelStartT].month() != mo ) { |
974 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); | 980 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); |
975 | mSelStartT += add +1; | 981 | mSelStartT += add +1; |
976 | } | 982 | } |
977 | if ( days[mSelEndT].month() != mo ) { | 983 | if ( days[mSelEndT].month() != mo ) { |
978 | int sub = days[mSelEndT].day(); | 984 | int sub = days[mSelEndT].day(); |
979 | mSelEndT -= sub ; | 985 | mSelEndT -= sub ; |
980 | } | 986 | } |
981 | } | 987 | } |
982 | } | 988 | } |
983 | //qDebug("SKIP %d ", skip); | 989 | //qDebug("SKIP %d ", skip); |
984 | if ( ! skip ) { | 990 | if ( ! skip ) { |
985 | row = mSelStartT/7; | 991 | row = mSelStartT/7; |
986 | col = mSelStartT -row*7; | 992 | col = mSelStartT -row*7; |
987 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 993 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
988 | int addCol = 0; | 994 | int addCol = 0; |
989 | int addRow = 0; | 995 | int addRow = 0; |
990 | int addRow2 = 0; | 996 | int addRow2 = 0; |
991 | int addCol2 = 0; | 997 | int addCol2 = 0; |
992 | if (row == mSelEndT/7) { | 998 | if (row == mSelEndT/7) { |
993 | if ( rowModulo ) { | 999 | if ( rowModulo ) { |
994 | if ( row >= 6 - rowModulo ) | 1000 | if ( row >= 6 - rowModulo ) |
995 | addRow = row - 5 + rowModulo; | 1001 | addRow = row - 5 + rowModulo; |
996 | } | 1002 | } |
997 | if ( colModulo ) { | 1003 | if ( colModulo ) { |
998 | int colt1 = mSelEndT%7; | 1004 | int colt1 = mSelEndT%7; |
999 | //qDebug("colt1 %d ", colt1 ); | 1005 | //qDebug("colt1 %d ", colt1 ); |
1000 | if ( colt1 >= 7 - colModulo ) | 1006 | if ( colt1 >= 7 - colModulo ) |
1001 | addCol = colt1 - 7 + colModulo+1; | 1007 | addCol = colt1 - 7 + colModulo+1; |
1002 | int colt = mSelStartT%7; | 1008 | int colt = mSelStartT%7; |
1003 | if ( colt >= 7 - colModulo ) | 1009 | if ( colt >= 7 - colModulo ) |
1004 | addCol2 = colt - 7 + colModulo; | 1010 | addCol2 = colt - 7 + colModulo; |
1005 | addCol -= addCol2; | 1011 | addCol -= addCol2; |
1006 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); | 1012 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); |
1007 | } | 1013 | } |
1008 | // Single row selection | 1014 | // Single row selection |
1009 | //if ( row == 0) | 1015 | //if ( row == 0) |
1010 | // addRow = 1; | 1016 | // addRow = 1; |
1011 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, | 1017 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, |
1012 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); | 1018 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); |
1013 | } else { | 1019 | } else { |
1014 | // draw first row to the right | 1020 | // draw first row to the right |
1015 | if ( colModulo ) { | 1021 | if ( colModulo ) { |
1016 | if ( col >= 7 - colModulo ) | 1022 | if ( col >= 7 - colModulo ) |
1017 | addCol2 = col - 7 + colModulo; | 1023 | addCol2 = col - 7 + colModulo; |
1018 | } | 1024 | } |
1019 | if ( rowModulo ) { | 1025 | if ( rowModulo ) { |
1020 | if ( row >= 6 - rowModulo ) | 1026 | if ( row >= 6 - rowModulo ) |
1021 | addRow = row - 5 + rowModulo; | 1027 | addRow = row - 5 + rowModulo; |
1022 | } | 1028 | } |
1023 | //if ( row == 0) | 1029 | //if ( row == 0) |
1024 | // addRow = 1; | 1030 | // addRow = 1; |
1025 | int drawWid = width()-(col*dwidth+1+addCol2)-1; | 1031 | int drawWid = width()-(col*dwidth+1+addCol2)-1; |
1026 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, | 1032 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, |
1027 | dheight+1, selcol); | 1033 | dheight+1, selcol); |
1028 | // draw full block till last line | 1034 | // draw full block till last line |
1029 | selh = mSelEndT/7-row; | 1035 | selh = mSelEndT/7-row; |
1030 | addRow = 0; | 1036 | addRow = 0; |
1031 | if ( rowModulo ) { | 1037 | if ( rowModulo ) { |
1032 | if ( mSelEndT/7 >= 6 - rowModulo ) | 1038 | if ( mSelEndT/7 >= 6 - rowModulo ) |
1033 | addRow = mSelEndT/7 - 5 + rowModulo; | 1039 | addRow = mSelEndT/7 - 5 + rowModulo; |
1034 | } | 1040 | } |
1035 | //qDebug("%d %d %d ",selh, row, addRow ); | 1041 | //qDebug("%d %d %d ",selh, row, addRow ); |
1036 | int addrow2 = addRow-selh+1; | 1042 | int addrow2 = addRow-selh+1; |
1037 | if ( addrow2 < 0 ) | 1043 | if ( addrow2 < 0 ) |
1038 | addrow2 = 0; | 1044 | addrow2 = 0; |
1039 | if (selh > 1) { | 1045 | if (selh > 1) { |
1040 | p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); | 1046 | p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); |
1041 | } | 1047 | } |
1042 | // draw last block from left to mSelEndT | 1048 | // draw last block from left to mSelEndT |
1043 | selw = mSelEndT-7*(mSelEndT/7)+1; | 1049 | selw = mSelEndT-7*(mSelEndT/7)+1; |
1044 | //qDebug("esl %d ",selw ); | 1050 | //qDebug("esl %d ",selw ); |
1045 | int add = 0; | 1051 | int add = 0; |
1046 | if ( colModulo ) { | 1052 | if ( colModulo ) { |
1047 | add = 7 - colModulo; | 1053 | add = 7 - colModulo; |
1048 | if ( selw > add ) | 1054 | if ( selw > add ) |
1049 | add = selw - add; | 1055 | add = selw - add; |
1050 | else | 1056 | else |
1051 | add = 0; | 1057 | add = 0; |
1052 | } | 1058 | } |
1053 | //qDebug("add %d ", add); | 1059 | //qDebug("add %d ", add); |
1054 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, | 1060 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, |
1055 | selw*dwidth+add, dheight+1, selcol); | 1061 | selw*dwidth+add, dheight+1, selcol); |
1056 | } | 1062 | } |
1057 | } | 1063 | } |
1058 | } | 1064 | } |
1059 | 1065 | ||
1060 | // iterate over all days in the matrix and draw the day label in appropriate colors | 1066 | // iterate over all days in the matrix and draw the day label in appropriate colors |
1061 | QColor actcol = mDefaultTextColorShaded; | 1067 | QColor actcol = mDefaultTextColorShaded; |
1062 | p.setPen(actcol); | 1068 | p.setPen(actcol); |
1063 | QPen tmppen; | 1069 | QPen tmppen; |
1064 | for(int i = 0; i < NUMDAYS; i++) { | 1070 | for(int i = 0; i < NUMDAYS; i++) { |
1065 | row = i/7; | 1071 | row = i/7; |
1066 | col = isRTL ? 6-(i-row*7) : i-row*7; | 1072 | col = isRTL ? 6-(i-row*7) : i-row*7; |
1067 | 1073 | ||
1068 | // if it is the first day of a month switch color from normal to shaded and vice versa | 1074 | // if it is the first day of a month switch color from normal to shaded and vice versa |
1069 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 1075 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
1070 | if (actcol == mDefaultTextColorShaded) { | 1076 | if (actcol == mDefaultTextColorShaded) { |
1071 | actcol = mDefaultTextColor; | 1077 | actcol = mDefaultTextColor; |
1072 | } else { | 1078 | } else { |
1073 | actcol = mDefaultTextColorShaded; | 1079 | actcol = mDefaultTextColorShaded; |
1074 | } | 1080 | } |
1075 | p.setPen(actcol); | 1081 | p.setPen(actcol); |
1076 | } | 1082 | } |
1077 | if (actcol == mDefaultTextColorShaded) { | 1083 | if (actcol == mDefaultTextColorShaded) { |
1078 | if ( ! mouseDown ) { | 1084 | if ( ! mouseDown ) { |
1079 | continue; | 1085 | continue; |
1080 | } | 1086 | } |
1081 | } | 1087 | } |
1082 | //Reset pen color after selected days block | 1088 | //Reset pen color after selected days block |
1083 | if (i == mSelEndT+1) { | 1089 | if (i == mSelEndT+1) { |
1084 | p.setPen(actcol); | 1090 | p.setPen(actcol); |
1085 | } | 1091 | } |
1086 | 1092 | ||
1087 | // if today then draw rectangle around day | 1093 | // if today then draw rectangle around day |
1088 | if (today == i) { | 1094 | if (today == i) { |
1089 | tmppen = p.pen(); | 1095 | tmppen = p.pen(); |
1090 | QPen mTodayPen(p.pen()); | 1096 | QPen mTodayPen(p.pen()); |
1091 | if ( daysize.width() < 20 ) | 1097 | if ( daysize.width() < 20 ) |
1092 | mTodayPen.setWidth(1); | 1098 | mTodayPen.setWidth(1); |
1093 | else | 1099 | else |
1094 | mTodayPen.setWidth(mTodayMarginWidth); | 1100 | mTodayPen.setWidth(mTodayMarginWidth); |
1095 | //draw red rectangle for holidays | 1101 | //draw red rectangle for holidays |
1096 | if (pDays.testBit(i)) { | 1102 | if (pDays.testBit(i)) { |
1097 | if (actcol == mDefaultTextColor) { | 1103 | if (actcol == mDefaultTextColor) { |
1098 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 1104 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
1099 | } else { | 1105 | } else { |
1100 | mTodayPen.setColor(mHolidayColorShaded); | 1106 | mTodayPen.setColor(mHolidayColorShaded); |
1101 | } | 1107 | } |
1102 | } | 1108 | } |
1103 | //draw gray rectangle for today if in selection | 1109 | //draw gray rectangle for today if in selection |
1104 | if (i >= mSelStartT && i <= mSelEndT) { | 1110 | if (i >= mSelStartT && i <= mSelEndT) { |
1105 | QColor grey("grey"); | 1111 | QColor grey("grey"); |
1106 | mTodayPen.setColor(grey); | 1112 | mTodayPen.setColor(grey); |
1107 | } | 1113 | } |
1108 | p.setPen(mTodayPen); | 1114 | p.setPen(mTodayPen); |
1109 | 1115 | ||
1110 | 1116 | ||
1111 | int addCol = 0; | 1117 | int addCol = 0; |
1112 | int addRow = 0; | 1118 | int addRow = 0; |
1113 | if (rowModulo) { | 1119 | if (rowModulo) { |
1114 | if ( row >= 6 - rowModulo ) | 1120 | if ( row >= 6 - rowModulo ) |
1115 | addRow = row - 5 + rowModulo; | 1121 | addRow = row - 5 + rowModulo; |
1116 | } | 1122 | } |
1117 | if ( colModulo ) { | 1123 | if ( colModulo ) { |
1118 | if ( col >= 7 - colModulo ) | 1124 | if ( col >= 7 - colModulo ) |
1119 | addCol = col - 6 + colModulo-1; | 1125 | addCol = col - 6 + colModulo-1; |
1120 | } | 1126 | } |
1121 | 1127 | ||
1122 | addCol += 1; | 1128 | addCol += 1; |
1123 | if ( row == 0 ) | 1129 | if ( row == 0 ) |
1124 | addRow = 1; | 1130 | addRow = 1; |
1125 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); | 1131 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); |
1126 | p.setPen(tmppen); | 1132 | p.setPen(tmppen); |
1127 | } | 1133 | } |
1128 | 1134 | ||
1129 | // if any events are on that day then draw it using a bold font | 1135 | // if any events are on that day then draw it using a bold font |
1130 | if ( eDays.testBit(i) ) { | 1136 | if ( eDays.testBit(i) ) { |
1131 | QFont myFont = font(); | 1137 | QFont myFont = font(); |
1132 | myFont.setBold(true); | 1138 | myFont.setBold(true); |
1133 | p.setFont(myFont); | 1139 | p.setFont(myFont); |
1134 | } | 1140 | } |
1135 | 1141 | ||
1136 | // if it is a holiday then use the default holiday color | 1142 | // if it is a holiday then use the default holiday color |
1137 | if ( pDays.testBit(i)) { | 1143 | if ( pDays.testBit(i)) { |
1138 | if ( bDays.testBit(i) ) { | 1144 | if ( bDays.testBit(i) ) { |
1139 | if ( hDays.testBit(i) ) | 1145 | if ( hDays.testBit(i) ) |
1140 | p.setPen(QColor(0,200,0)); | 1146 | p.setPen(QColor(0,200,0)); |
1141 | else | 1147 | else |
1142 | p.setPen(QColor(Qt::blue)); | 1148 | p.setPen(QColor(Qt::blue)); |
1143 | } else { | 1149 | } else { |
1144 | if (actcol == mDefaultTextColor ) { | 1150 | if (actcol == mDefaultTextColor ) { |
1145 | p.setPen(KOPrefs::instance()->mHolidayColor); | 1151 | p.setPen(KOPrefs::instance()->mHolidayColor); |
1146 | } else { | 1152 | } else { |
1147 | p.setPen(mHolidayColorShaded); | 1153 | p.setPen(mHolidayColorShaded); |
1148 | } | 1154 | } |
1149 | } | 1155 | } |
1150 | } | 1156 | } |
1151 | 1157 | ||
1152 | // draw selected days with special color | 1158 | // draw selected days with special color |
1153 | // DO NOT specially highlight holidays in selection ! | 1159 | // DO NOT specially highlight holidays in selection ! |
1154 | if (i >= mSelStartT && i <= mSelEndT) { | 1160 | if (i >= mSelStartT && i <= mSelEndT) { |
1155 | ;//p.setPen(mSelectedDaysColor); | 1161 | ;//p.setPen(mSelectedDaysColor); |
1156 | } | 1162 | } |
1157 | 1163 | ||
1158 | int addCol = 0; | 1164 | int addCol = 0; |
1159 | int addRow = 0; | 1165 | int addRow = 0; |
1160 | if ( colModulo ) { | 1166 | if ( colModulo ) { |
1161 | if ( col >= 7 - colModulo ) | 1167 | if ( col >= 7 - colModulo ) |
1162 | addCol = col - 7 + colModulo; | 1168 | addCol = col - 7 + colModulo; |
1163 | } | 1169 | } |
1164 | if ( rowModulo ) { | 1170 | if ( rowModulo ) { |
1165 | if ( row >= 6 - rowModulo ) | 1171 | if ( row >= 6 - rowModulo ) |
1166 | addRow = row - 5 + rowModulo; | 1172 | addRow = row - 5 + rowModulo; |
1167 | } | 1173 | } |
1168 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); | 1174 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); |
1169 | ++addCol;//++addCol; | 1175 | ++addCol;//++addCol; |
1170 | if ( row == 0) | 1176 | if ( row == 0) |
1171 | addRow = 1; | 1177 | addRow = 1; |
1172 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, | 1178 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, |
1173 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 1179 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
1174 | 1180 | ||
1175 | // reset color to actual color | 1181 | // reset color to actual color |
1176 | if (pDays.testBit(i)) { | 1182 | if (pDays.testBit(i)) { |
1177 | p.setPen(actcol); | 1183 | p.setPen(actcol); |
1178 | } | 1184 | } |
1179 | // reset bold font to plain font | 1185 | // reset bold font to plain font |
1180 | if ( eDays.testBit(i)) { | 1186 | if ( eDays.testBit(i)) { |
1181 | QFont myFont = font(); | 1187 | QFont myFont = font(); |
1182 | myFont.setBold(false); | 1188 | myFont.setBold(false); |
1183 | p.setFont(myFont); | 1189 | p.setFont(myFont); |
1184 | } | 1190 | } |
1185 | } | 1191 | } |
1186 | p.setPen(mDefaultTextColor); | 1192 | p.setPen(mDefaultTextColor); |
1187 | p.drawRect(0, 0, width(), height()); | 1193 | p.drawRect(0, 0, width(), height()); |
1188 | } else { | 1194 | } else { |
1189 | //qDebug("NO redraw "); | 1195 | //qDebug("NO redraw "); |
1190 | } | 1196 | } |
1191 | 1197 | ||
1192 | bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP); | 1198 | bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP); |
1193 | mRedrawNeeded = false; | 1199 | mRedrawNeeded = false; |
1194 | } | 1200 | } |
1195 | 1201 | ||
1196 | // ---------------------------------------------------------------------------- | 1202 | // ---------------------------------------------------------------------------- |
1197 | // R E SI Z E E V E N T H A N D L I N G | 1203 | // R E SI Z E E V E N T H A N D L I N G |
1198 | // ---------------------------------------------------------------------------- | 1204 | // ---------------------------------------------------------------------------- |
1199 | 1205 | ||
1200 | void KODayMatrix::resizeEvent(QResizeEvent * e) | 1206 | void KODayMatrix::resizeEvent(QResizeEvent * e) |
1201 | { | 1207 | { |
1202 | QRect sz = frameRect(); | 1208 | QRect sz = frameRect(); |
1203 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 1209 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
1204 | daysize.setWidth(sz.width() / 7); | 1210 | daysize.setWidth(sz.width() / 7); |
1205 | QFrame::resizeEvent( e ); | 1211 | QFrame::resizeEvent( e ); |
1206 | } | 1212 | } |
1207 | 1213 | ||
1208 | QSize KODayMatrix::sizeHint() const | 1214 | QSize KODayMatrix::sizeHint() const |
1209 | { | 1215 | { |
1210 | 1216 | ||
1211 | QFontMetrics fm ( font() ); | 1217 | QFontMetrics fm ( font() ); |
1212 | int wid = fm.width( "30") *7+3; | 1218 | int wid = fm.width( "30") *7+3; |
1213 | int hei = fm.height() * 6+3; | 1219 | int hei = fm.height() * 6+3; |
1214 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); | 1220 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); |
1215 | return QSize ( wid, hei ); | 1221 | return QSize ( wid, hei ); |
1216 | 1222 | ||
1217 | } | 1223 | } |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 571ca11..1b0e5f4 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,634 +1,636 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kglobalsettings.h> | 39 | #include <kglobalsettings.h> |
40 | #include <kconfig.h> | 40 | #include <kconfig.h> |
41 | #include <klocale.h> | 41 | #include <klocale.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kemailsettings.h> | 43 | #include <kemailsettings.h> |
44 | #include <kstaticdeleter.h> | 44 | #include <kstaticdeleter.h> |
45 | #include <libkdepim/kpimglobalprefs.h> | 45 | #include <libkdepim/kpimglobalprefs.h> |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "mainwindow.h" | 48 | #include "mainwindow.h" |
49 | 49 | ||
50 | KOPrefs *KOPrefs::mInstance = 0; | 50 | KOPrefs *KOPrefs::mInstance = 0; |
51 | static KStaticDeleter<KOPrefs> insd; | 51 | static KStaticDeleter<KOPrefs> insd; |
52 | 52 | ||
53 | KOPrefs::KOPrefs() : | 53 | KOPrefs::KOPrefs() : |
54 | KPimPrefs("korganizerrc") | 54 | KPimPrefs("korganizerrc") |
55 | { | 55 | { |
56 | mGlobalUpdateDisabled = false; | 56 | mGlobalUpdateDisabled = false; |
57 | mCategoryColors.setAutoDelete(true); | 57 | mCategoryColors.setAutoDelete(true); |
58 | fillMailDefaults(); | 58 | fillMailDefaults(); |
59 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 59 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
60 | QColor defaultHolidayColor = QColor(255,0,0); | 60 | QColor defaultHolidayColor = QColor(255,0,0); |
61 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 61 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
62 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 62 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
63 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 63 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
64 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 64 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
65 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 65 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
66 | QColor defaultTodoRunColor = QColor(99,194,30); | 66 | QColor defaultTodoRunColor = QColor(99,194,30); |
67 | KPrefs::setCurrentGroup("General"); | 67 | KPrefs::setCurrentGroup("General"); |
68 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 68 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
69 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 69 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
70 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 70 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
71 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 71 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
72 | addItemBool("ShowIconList",&mShowIconList,true); | 72 | addItemBool("ShowIconList",&mShowIconList,true); |
73 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 73 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
74 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 74 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
75 | addItemBool("ShowIconDay6",&mShowIconDay6,true); | 75 | addItemBool("ShowIconDay6",&mShowIconDay6,true); |
76 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 76 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
77 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 77 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
78 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 78 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
79 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 79 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
80 | addItemBool("ShowIconBack",&mShowIconBack,true); | 80 | addItemBool("ShowIconBack",&mShowIconBack,true); |
81 | addItemBool("ShowIconToday",&mShowIconToday,true); | 81 | addItemBool("ShowIconToday",&mShowIconToday,true); |
82 | addItemBool("ShowIconForward",&mShowIconForward,true); | 82 | addItemBool("ShowIconForward",&mShowIconForward,true); |
83 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 83 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
84 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); | 84 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); |
85 | addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); | 85 | addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); |
86 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 86 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
87 | addItemBool("ShowIconNext",&mShowIconNext,true); | 87 | addItemBool("ShowIconNext",&mShowIconNext,true); |
88 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 88 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
89 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 89 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
90 | addItemBool("ShowIconFilter",&mShowIconFilter,false); | 90 | addItemBool("ShowIconFilter",&mShowIconFilter,false); |
91 | addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); | 91 | addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); |
92 | 92 | ||
93 | bool addIcons = false; | 93 | bool addIcons = false; |
94 | #ifdef DESKTOP_VERSION | 94 | #ifdef DESKTOP_VERSION |
95 | addIcons = true; | 95 | addIcons = true; |
96 | #endif | 96 | #endif |
97 | addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); | 97 | addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); |
98 | addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); | 98 | addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); |
99 | addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); | 99 | addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); |
100 | addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); | 100 | addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); |
101 | 101 | ||
102 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); | 102 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); |
103 | 103 | ||
104 | addItemBool("AskForQuit",&mAskForQuit,false); | 104 | addItemBool("AskForQuit",&mAskForQuit,false); |
105 | 105 | ||
106 | #ifndef DESKTOP_VERSION | 106 | #ifndef DESKTOP_VERSION |
107 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 107 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
108 | #else | 108 | #else |
109 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 109 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
110 | #endif | 110 | #endif |
111 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 111 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
112 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 112 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
113 | addItemBool("ToolBarHorV",&mToolBarHorV, true ); | 113 | addItemBool("ToolBarHorV",&mToolBarHorV, true ); |
114 | addItemBool("ToolBarUpV",&mToolBarUpV, false ); | 114 | addItemBool("ToolBarUpV",&mToolBarUpV, false ); |
115 | addItemBool("ToolBarHorN",&mToolBarHorN, true ); | 115 | addItemBool("ToolBarHorN",&mToolBarHorN, true ); |
116 | addItemBool("ToolBarUpN",&mToolBarUpN, false ); | 116 | addItemBool("ToolBarUpN",&mToolBarUpN, false ); |
117 | addItemBool("ToolBarHorF",&mToolBarHorF, true ); | 117 | addItemBool("ToolBarHorF",&mToolBarHorF, true ); |
118 | addItemBool("ToolBarUpF",&mToolBarUpF, false ); | 118 | addItemBool("ToolBarUpF",&mToolBarUpF, false ); |
119 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 119 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
120 | addItemBool("WhatsNextTime2Lines",&mWhatsNextTime2Lines, false ); | 120 | addItemBool("WhatsNextTime2Lines",&mWhatsNextTime2Lines, false ); |
121 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 121 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
122 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 122 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
123 | 123 | ||
124 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 124 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
125 | addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); | 125 | addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); |
126 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); | 126 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); |
127 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); | 127 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); |
128 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 128 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
129 | addItemInt("AllDay Size",&mAllDaySize,28); | 129 | addItemInt("AllDay Size",&mAllDaySize,28); |
130 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 130 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
131 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 131 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
132 | 132 | ||
133 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 133 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
134 | addItemStringList("EventSummary User",&mEventSummaryUser); | 134 | addItemStringList("EventSummary User",&mEventSummaryUser); |
135 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 135 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
136 | addItemStringList("JournalSummary User",&mJournalSummaryUser); | 136 | addItemStringList("JournalSummary User",&mJournalSummaryUser); |
137 | 137 | ||
138 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 138 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
139 | addItemBool("Enable Project View",&mEnableProjectView,false); | 139 | addItemBool("Enable Project View",&mEnableProjectView,false); |
140 | addItemBool("Auto Save",&mAutoSave,false); | 140 | addItemBool("Auto Save",&mAutoSave,false); |
141 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 141 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
142 | addItemBool("Confirm Deletes",&mConfirm,true); | 142 | addItemBool("Confirm Deletes",&mConfirm,true); |
143 | addItemString("Archive File",&mArchiveFile); | 143 | addItemString("Archive File",&mArchiveFile); |
144 | addItemString("Html Export File",&mHtmlExportFile, | 144 | addItemString("Html Export File",&mHtmlExportFile, |
145 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 145 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
146 | addItemBool("Html With Save",&mHtmlWithSave,false); | 146 | addItemBool("Html With Save",&mHtmlWithSave,false); |
147 | 147 | ||
148 | KPrefs::setCurrentGroup("Personal Settings"); | 148 | KPrefs::setCurrentGroup("Personal Settings"); |
149 | 149 | ||
150 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 150 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
151 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 151 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
152 | addItemBool("Bcc",&mBcc,false); | 152 | addItemBool("Bcc",&mBcc,false); |
153 | 153 | ||
154 | KPrefs::setCurrentGroup("Time & Date"); | 154 | KPrefs::setCurrentGroup("Time & Date"); |
155 | 155 | ||
156 | 156 | ||
157 | addItemInt("Default Start Time",&mStartTime,10); | 157 | addItemInt("Default Start Time",&mStartTime,10); |
158 | addItemInt("Default Duration",&mDefaultDuration,2); | 158 | addItemInt("Default Duration",&mDefaultDuration,2); |
159 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 159 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
160 | KPrefs::setCurrentGroup("AlarmSettings"); | 160 | KPrefs::setCurrentGroup("AlarmSettings"); |
161 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 161 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
162 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 162 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
163 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 163 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
164 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 164 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
165 | 165 | ||
166 | 166 | ||
167 | KPrefs::setCurrentGroup("Calendar"); | 167 | KPrefs::setCurrentGroup("Calendar"); |
168 | 168 | ||
169 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 169 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
170 | 170 | ||
171 | KPrefs::setCurrentGroup("Fonts"); | 171 | KPrefs::setCurrentGroup("Fonts"); |
172 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 172 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
173 | QFont fon = KGlobalSettings::generalFont(); | 173 | QFont fon = KGlobalSettings::generalFont(); |
174 | addItemFont("TimeBar Font",&mTimeBarFont,fon ); | 174 | addItemFont("TimeBar Font",&mTimeBarFont,fon ); |
175 | addItemFont("MonthView Font",&mMonthViewFont,fon); | 175 | addItemFont("MonthView Font",&mMonthViewFont,fon); |
176 | addItemFont("AgendaView Font",&mAgendaViewFont,fon); | 176 | addItemFont("AgendaView Font",&mAgendaViewFont,fon); |
177 | addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); | 177 | addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); |
178 | addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); | 178 | addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); |
179 | addItemFont("TodoView Font",&mTodoViewFont,fon); | 179 | addItemFont("TodoView Font",&mTodoViewFont,fon); |
180 | addItemFont("ListView Font",&mListViewFont,fon); | 180 | addItemFont("ListView Font",&mListViewFont,fon); |
181 | addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); | 181 | addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); |
182 | addItemFont("EditBox Font",&mEditBoxFont,fon); | 182 | addItemFont("EditBox Font",&mEditBoxFont,fon); |
183 | addItemFont("JournalView Font",&mJornalViewFont,fon); | 183 | addItemFont("JournalView Font",&mJornalViewFont,fon); |
184 | addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); | 184 | addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); |
185 | addItemFont("EventView Font",&mEventViewFont,fon); | 185 | addItemFont("EventView Font",&mEventViewFont,fon); |
186 | 186 | ||
187 | KPrefs::setCurrentGroup("RemoteSyncing"); | 187 | KPrefs::setCurrentGroup("RemoteSyncing"); |
188 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 188 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
189 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 189 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
190 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 190 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
191 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 191 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
192 | 192 | ||
193 | #ifdef _WIN32_ | 193 | #ifdef _WIN32_ |
194 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 194 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
195 | #else | 195 | #else |
196 | QString hdp= locateLocal("data","korganizer")+"/"; | 196 | QString hdp= locateLocal("data","korganizer")+"/"; |
197 | #endif | 197 | #endif |
198 | 198 | ||
199 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 199 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
200 | 200 | ||
201 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 201 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
202 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 202 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
203 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 203 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
204 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 204 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
205 | 205 | ||
206 | 206 | ||
207 | KPrefs::setCurrentGroup("Locale"); | 207 | KPrefs::setCurrentGroup("Locale"); |
208 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 208 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
209 | 209 | ||
210 | 210 | ||
211 | KPrefs::setCurrentGroup("Colors"); | 211 | KPrefs::setCurrentGroup("Colors"); |
212 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 212 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
213 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 213 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
214 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 214 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
215 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); | 215 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); |
216 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 216 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
217 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 217 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
218 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 218 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
219 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 219 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
220 | addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); | 220 | addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); |
221 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 221 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
222 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 222 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
223 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 223 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
224 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 224 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
225 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 225 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
226 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); | 226 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); |
227 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 227 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
228 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 228 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
229 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 229 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
230 | addItemBool("UseAppColors",&mUseAppColors,false); | 230 | addItemBool("UseAppColors",&mUseAppColors,false); |
231 | 231 | ||
232 | 232 | ||
233 | KPrefs::setCurrentGroup("Conflicts"); | 233 | KPrefs::setCurrentGroup("Conflicts"); |
234 | addItemBool("EnableAutoDetect",&mDetectConflicts,true); | 234 | addItemBool("EnableAutoDetect",&mDetectConflicts,true); |
235 | addItemBool("CheckConflictsFree",&mIncludeFree,true); | ||
235 | addItemBool("CheckConflictsAllDayAllDay",&mCheckConflictsAllDayAllDay,false); | 236 | addItemBool("CheckConflictsAllDayAllDay",&mCheckConflictsAllDayAllDay,false); |
236 | addItemBool("CheckConflictsAllDayNonAD",&mCheckConflictsAllDayNonAD,false); | 237 | addItemBool("CheckConflictsAllDayNonAD",&mCheckConflictsAllDayNonAD,false); |
237 | addItemBool("CheckConflictsNonADAllDay",&mCheckConflictsNonADAllDay,false); | 238 | addItemBool("CheckConflictsNonADAllDay",&mCheckConflictsNonADAllDay,false); |
238 | addItemBool("CheckConflictsNonADNonAD",&mCheckConflictsNonADNonAD,true); | 239 | addItemBool("CheckConflictsNonADNonAD",&mCheckConflictsNonADNonAD,true); |
239 | addItemString("FilterConflictEditItem", &mFilterConflictEditItem ,"nofilter" ); | 240 | addItemString("FilterConflictEditItem", &mFilterConflictEditItem ,"nofilter" ); |
240 | addItemString("FilterConflictAllItem", &mFilterConflictAllItem ,"nofilter" ); | 241 | addItemString("FilterConflictAllItem", &mFilterConflictAllItem ,"nofilter" ); |
241 | 242 | ||
242 | KPrefs::setCurrentGroup("Views"); | 243 | KPrefs::setCurrentGroup("Views"); |
243 | addItemBool("Block Popup Menu",&mBlockPopupMenu,false); | 244 | addItemBool("Block Popup Menu",&mBlockPopupMenu,false); |
244 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); | 245 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); |
245 | addItemInt("Hour Size",&mHourSize,8); | 246 | addItemInt("Hour Size",&mHourSize,8); |
246 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 247 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
248 | addItemBool("ShowLongAllday",&mLongAllday,true); | ||
247 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 249 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
248 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 250 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
249 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 251 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
250 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 252 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
251 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 253 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
252 | addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); | 254 | addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); |
253 | #ifdef DESKTOP_VERION | 255 | #ifdef DESKTOP_VERION |
254 | addItemBool("Enable ToolTips",&mEnableToolTips,true); | 256 | addItemBool("Enable ToolTips",&mEnableToolTips,true); |
255 | #else | 257 | #else |
256 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 258 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
257 | #endif | 259 | #endif |
258 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 260 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
259 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 261 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
260 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 262 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
261 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 263 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
262 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); | 264 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); |
263 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 265 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
264 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 266 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
265 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 267 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
266 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 268 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
267 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; | 269 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; |
268 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); | 270 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); |
269 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 271 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
270 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 272 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
271 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 273 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
272 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 274 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
273 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 275 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
274 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); | 276 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); |
275 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); | 277 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); |
276 | addItemBool("MonthViewWeekRowlayout",&mMonthViewWeekRowlayout,false); | 278 | addItemBool("MonthViewWeekRowlayout",&mMonthViewWeekRowlayout,false); |
277 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 279 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
278 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 280 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
279 | #ifdef DESKTOP_VERSION | 281 | #ifdef DESKTOP_VERSION |
280 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 282 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
281 | #else | 283 | #else |
282 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 284 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
283 | #endif | 285 | #endif |
284 | addItemInt("Day Begins",&mDayBegins,7); | 286 | addItemInt("Day Begins",&mDayBegins,7); |
285 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 287 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
286 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 288 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
287 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 289 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
288 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 290 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
289 | 291 | ||
290 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 292 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
291 | addItemBool("Full View Month",&mFullViewMonth,true); | 293 | addItemBool("Full View Month",&mFullViewMonth,true); |
292 | addItemBool("Full View Todo",&mFullViewTodo,true); | 294 | addItemBool("Full View Todo",&mFullViewTodo,true); |
293 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 295 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
294 | 296 | ||
295 | addItemInt("Next X Days",&mNextXDays,3); | 297 | addItemInt("Next X Days",&mNextXDays,3); |
296 | 298 | ||
297 | KPrefs::setCurrentGroup("Printer"); | 299 | KPrefs::setCurrentGroup("Printer"); |
298 | 300 | ||
299 | KPrefs::setCurrentGroup("Layout"); | 301 | KPrefs::setCurrentGroup("Layout"); |
300 | 302 | ||
301 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 303 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
302 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 304 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
303 | 305 | ||
304 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 306 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
305 | 307 | ||
306 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 308 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
307 | 309 | ||
308 | KPrefs::setCurrentGroup("Group Scheduling"); | 310 | KPrefs::setCurrentGroup("Group Scheduling"); |
309 | 311 | ||
310 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 312 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
311 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 313 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
312 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 314 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
313 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 315 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
314 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 316 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
315 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 317 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
316 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 318 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
317 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 319 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
318 | 320 | ||
319 | KPrefs::setCurrentGroup( "Editors" ); | 321 | KPrefs::setCurrentGroup( "Editors" ); |
320 | 322 | ||
321 | addItemStringList( "EventTemplates", &mEventTemplates ); | 323 | addItemStringList( "EventTemplates", &mEventTemplates ); |
322 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 324 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
323 | 325 | ||
324 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 326 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
325 | 327 | ||
326 | KPrefs::setCurrentGroup( "ViewOptions" ); | 328 | KPrefs::setCurrentGroup( "ViewOptions" ); |
327 | addItemBool("EVshowDetails",&mEVshowDetails,true); | 329 | addItemBool("EVshowDetails",&mEVshowDetails,true); |
328 | addItemBool("EVshowCreated",&mEVshowCreated,true); | 330 | addItemBool("EVshowCreated",&mEVshowCreated,true); |
329 | addItemBool("EVshowChanged",&mEVshowChanged,true); | 331 | addItemBool("EVshowChanged",&mEVshowChanged,true); |
330 | addItemBool("WTshowDetails",&mWTshowDetails,false); | 332 | addItemBool("WTshowDetails",&mWTshowDetails,false); |
331 | addItemBool("WTshowCreated",&mWTshowCreated,false); | 333 | addItemBool("WTshowCreated",&mWTshowCreated,false); |
332 | addItemBool("WTshowChanged",&mWTshowChanged,false); | 334 | addItemBool("WTshowChanged",&mWTshowChanged,false); |
333 | mCalendars.setAutoDelete( true ); | 335 | mCalendars.setAutoDelete( true ); |
334 | } | 336 | } |
335 | 337 | ||
336 | 338 | ||
337 | KOPrefs::~KOPrefs() | 339 | KOPrefs::~KOPrefs() |
338 | { | 340 | { |
339 | if (mInstance == this) | 341 | if (mInstance == this) |
340 | mInstance = insd.setObject(0); | 342 | mInstance = insd.setObject(0); |
341 | mCalendars.setAutoDelete( true ); | 343 | mCalendars.setAutoDelete( true ); |
342 | mCalendars.clear(); | 344 | mCalendars.clear(); |
343 | //qDebug("KOPrefs::~KOPrefs() "); | 345 | //qDebug("KOPrefs::~KOPrefs() "); |
344 | } | 346 | } |
345 | 347 | ||
346 | 348 | ||
347 | KOPrefs *KOPrefs::instance() | 349 | KOPrefs *KOPrefs::instance() |
348 | { | 350 | { |
349 | if (!mInstance) { | 351 | if (!mInstance) { |
350 | mInstance = insd.setObject(new KOPrefs()); | 352 | mInstance = insd.setObject(new KOPrefs()); |
351 | mInstance->readConfig(); | 353 | mInstance->readConfig(); |
352 | } | 354 | } |
353 | 355 | ||
354 | return mInstance; | 356 | return mInstance; |
355 | } | 357 | } |
356 | 358 | ||
357 | void KOPrefs::usrSetDefaults() | 359 | void KOPrefs::usrSetDefaults() |
358 | { | 360 | { |
359 | 361 | ||
360 | } | 362 | } |
361 | 363 | ||
362 | void KOPrefs::fillMailDefaults() | 364 | void KOPrefs::fillMailDefaults() |
363 | { | 365 | { |
364 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 366 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
365 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 367 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
366 | } | 368 | } |
367 | 369 | ||
368 | void KOPrefs::setTimeZoneIdDefault() | 370 | void KOPrefs::setTimeZoneIdDefault() |
369 | { | 371 | { |
370 | ; | 372 | ; |
371 | } | 373 | } |
372 | 374 | ||
373 | void KOPrefs::setAllDefaults() | 375 | void KOPrefs::setAllDefaults() |
374 | { | 376 | { |
375 | setCategoryDefaults(); | 377 | setCategoryDefaults(); |
376 | mEventSummaryUser = getDefaultList() ; | 378 | mEventSummaryUser = getDefaultList() ; |
377 | mTodoSummaryUser = getDefaultList() ; | 379 | mTodoSummaryUser = getDefaultList() ; |
378 | mJournalSummaryUser = getDefaultList() ; | 380 | mJournalSummaryUser = getDefaultList() ; |
379 | mLocationDefaults = getLocationDefaultList(); | 381 | mLocationDefaults = getLocationDefaultList(); |
380 | } | 382 | } |
381 | 383 | ||
382 | void KOPrefs::setCategoryDefaults() | 384 | void KOPrefs::setCategoryDefaults() |
383 | { | 385 | { |
384 | mCustomCategories.clear(); | 386 | mCustomCategories.clear(); |
385 | mCustomCategories = getDefaultList(); | 387 | mCustomCategories = getDefaultList(); |
386 | 388 | ||
387 | QStringList::Iterator it; | 389 | QStringList::Iterator it; |
388 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 390 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
389 | setCategoryColor(*it,mDefaultCategoryColor); | 391 | setCategoryColor(*it,mDefaultCategoryColor); |
390 | } | 392 | } |
391 | } | 393 | } |
392 | QStringList KOPrefs::getLocationDefaultList() | 394 | QStringList KOPrefs::getLocationDefaultList() |
393 | { | 395 | { |
394 | QStringList retval ; | 396 | QStringList retval ; |
395 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 397 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
396 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") | 398 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") |
397 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 399 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
398 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 400 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
399 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 401 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
400 | 402 | ||
401 | retval.sort(); | 403 | retval.sort(); |
402 | return retval; | 404 | return retval; |
403 | } | 405 | } |
404 | QStringList KOPrefs::getDefaultList() | 406 | QStringList KOPrefs::getDefaultList() |
405 | { | 407 | { |
406 | QStringList retval ; | 408 | QStringList retval ; |
407 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") | 409 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") |
408 | << i18n("Break") | 410 | << i18n("Break") |
409 | << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") | 411 | << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") |
410 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") | 412 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") |
411 | << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") | 413 | << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") |
412 | << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") | 414 | << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") |
413 | << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") | 415 | << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") |
414 | << i18n("Vacation") ; | 416 | << i18n("Vacation") ; |
415 | retval.sort(); | 417 | retval.sort(); |
416 | //qDebug("cat %s ", retval.join("-").latin1()); | 418 | //qDebug("cat %s ", retval.join("-").latin1()); |
417 | return retval; | 419 | return retval; |
418 | } | 420 | } |
419 | // << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") | 421 | // << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") |
420 | void KOPrefs::usrReadConfig() | 422 | void KOPrefs::usrReadConfig() |
421 | { | 423 | { |
422 | config()->setGroup("General"); | 424 | config()->setGroup("General"); |
423 | 425 | ||
424 | //qDebug("KOPrefs::usrReadConfig() "); | 426 | //qDebug("KOPrefs::usrReadConfig() "); |
425 | mCustomCategories = config()->readListEntry("Custom Categories"); | 427 | mCustomCategories = config()->readListEntry("Custom Categories"); |
426 | mOldLoadedLanguage = mOldLanguage ; | 428 | mOldLoadedLanguage = mOldLanguage ; |
427 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 429 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
428 | if (mLocationDefaults.isEmpty()) { | 430 | if (mLocationDefaults.isEmpty()) { |
429 | mLocationDefaults = getLocationDefaultList(); | 431 | mLocationDefaults = getLocationDefaultList(); |
430 | } | 432 | } |
431 | 433 | ||
432 | if (mEventSummaryUser.isEmpty()) { | 434 | if (mEventSummaryUser.isEmpty()) { |
433 | mEventSummaryUser = getDefaultList() ; | 435 | mEventSummaryUser = getDefaultList() ; |
434 | } | 436 | } |
435 | if (mTodoSummaryUser.isEmpty()) { | 437 | if (mTodoSummaryUser.isEmpty()) { |
436 | mTodoSummaryUser = getDefaultList() ; | 438 | mTodoSummaryUser = getDefaultList() ; |
437 | } | 439 | } |
438 | 440 | ||
439 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 441 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
440 | 442 | ||
441 | config()->setGroup("Personal Settings"); | 443 | config()->setGroup("Personal Settings"); |
442 | mName = config()->readEntry("user_name",""); | 444 | mName = config()->readEntry("user_name",""); |
443 | mEmail = config()->readEntry("user_email",""); | 445 | mEmail = config()->readEntry("user_email",""); |
444 | fillMailDefaults(); | 446 | fillMailDefaults(); |
445 | 447 | ||
446 | config()->setGroup("Category Colors"); | 448 | config()->setGroup("Category Colors"); |
447 | QStringList::Iterator it; | 449 | QStringList::Iterator it; |
448 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 450 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
449 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 451 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
450 | 452 | ||
451 | } | 453 | } |
452 | KConfig fc (locateLocal("config","kopicalendarrc")); | 454 | KConfig fc (locateLocal("config","kopicalendarrc")); |
453 | fc.setGroup("CC"); | 455 | fc.setGroup("CC"); |
454 | int numCals = fc.readNumEntry("NumberCalendars",0 ); | 456 | int numCals = fc.readNumEntry("NumberCalendars",0 ); |
455 | mNextAvailableCalendar = 1; | 457 | mNextAvailableCalendar = 1; |
456 | if ( numCals == 0 ) { | 458 | if ( numCals == 0 ) { |
457 | KopiCalendarFile *kkf = getNewCalendar(); | 459 | KopiCalendarFile *kkf = getNewCalendar(); |
458 | kkf->isStandard = true; | 460 | kkf->isStandard = true; |
459 | kkf->mName = i18n("Standard"); | 461 | kkf->mName = i18n("Standard"); |
460 | kkf->mFileName = QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); | 462 | kkf->mFileName = QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); |
461 | } | 463 | } |
462 | while ( mNextAvailableCalendar <= numCals ) { | 464 | while ( mNextAvailableCalendar <= numCals ) { |
463 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); | 465 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); |
464 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); | 466 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); |
465 | KopiCalendarFile *kkf = getNewCalendar(); | 467 | KopiCalendarFile *kkf = getNewCalendar(); |
466 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); | 468 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); |
467 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); | 469 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); |
468 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); | 470 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); |
469 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); | 471 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); |
470 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); | 472 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); |
471 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); | 473 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); |
472 | kkf->mFileName = QDir::convertSeparators( fc.readEntry( prefix+"_FileName", kkf->mFileName) ); | 474 | kkf->mFileName = QDir::convertSeparators( fc.readEntry( prefix+"_FileName", kkf->mFileName) ); |
473 | kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) ); | 475 | kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) ); |
474 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); | 476 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); |
475 | if ( kkf->mCalNumber == 1 ) { | 477 | if ( kkf->mCalNumber == 1 ) { |
476 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | 478 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); |
477 | } | 479 | } |
478 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); | 480 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); |
479 | if ( kkf->mName == i18n("Birthdays") ) { | 481 | if ( kkf->mName == i18n("Birthdays") ) { |
480 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); | 482 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); |
481 | } | 483 | } |
482 | if ( kkf->isRelative ) | 484 | if ( kkf->isRelative ) |
483 | kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); | 485 | kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); |
484 | } | 486 | } |
485 | 487 | ||
486 | KPimPrefs::usrReadConfig(); | 488 | KPimPrefs::usrReadConfig(); |
487 | } | 489 | } |
488 | 490 | ||
489 | KopiCalendarFile * KOPrefs::getCalendar( int num ) | 491 | KopiCalendarFile * KOPrefs::getCalendar( int num ) |
490 | { | 492 | { |
491 | return mDefCalColors[num-1]; | 493 | return mDefCalColors[num-1]; |
492 | } | 494 | } |
493 | 495 | ||
494 | KopiCalendarFile * KOPrefs::getNewCalendar() | 496 | KopiCalendarFile * KOPrefs::getNewCalendar() |
495 | { | 497 | { |
496 | KopiCalendarFile * kkf = new KopiCalendarFile(); | 498 | KopiCalendarFile * kkf = new KopiCalendarFile(); |
497 | kkf->mCalNumber = mNextAvailableCalendar; | 499 | kkf->mCalNumber = mNextAvailableCalendar; |
498 | mDefCalColors.resize( mNextAvailableCalendar ); | 500 | mDefCalColors.resize( mNextAvailableCalendar ); |
499 | mDefCalColors[mNextAvailableCalendar-1] = kkf; | 501 | mDefCalColors[mNextAvailableCalendar-1] = kkf; |
500 | ++mNextAvailableCalendar; | 502 | ++mNextAvailableCalendar; |
501 | kkf->mDefaultColor = mEventColor; | 503 | kkf->mDefaultColor = mEventColor; |
502 | kkf->mName = i18n("New Calendar"); | 504 | kkf->mName = i18n("New Calendar"); |
503 | mCalendars.append( kkf ); | 505 | mCalendars.append( kkf ); |
504 | return kkf; | 506 | return kkf; |
505 | } | 507 | } |
506 | void KOPrefs::deleteCalendar( int num ) | 508 | void KOPrefs::deleteCalendar( int num ) |
507 | { | 509 | { |
508 | KopiCalendarFile * kkf = mCalendars.first(); | 510 | KopiCalendarFile * kkf = mCalendars.first(); |
509 | while ( kkf ) { | 511 | while ( kkf ) { |
510 | if ( kkf->mCalNumber == num ) { | 512 | if ( kkf->mCalNumber == num ) { |
511 | qDebug("KOPrefs::deleteCalendar %d ", num ); | 513 | qDebug("KOPrefs::deleteCalendar %d ", num ); |
512 | mCalendars.remove( kkf ); | 514 | mCalendars.remove( kkf ); |
513 | delete kkf; | 515 | delete kkf; |
514 | return; | 516 | return; |
515 | } | 517 | } |
516 | kkf = mCalendars.next(); | 518 | kkf = mCalendars.next(); |
517 | } | 519 | } |
518 | } | 520 | } |
519 | int KOPrefs::getCalendarID( const QString & name ) | 521 | int KOPrefs::getCalendarID( const QString & name ) |
520 | { | 522 | { |
521 | KopiCalendarFile * kkf = mCalendars.first(); | 523 | KopiCalendarFile * kkf = mCalendars.first(); |
522 | while ( kkf ) { | 524 | while ( kkf ) { |
523 | if ( name == kkf->mName) | 525 | if ( name == kkf->mName) |
524 | return kkf->mCalNumber; | 526 | return kkf->mCalNumber; |
525 | kkf = mCalendars.next(); | 527 | kkf = mCalendars.next(); |
526 | } | 528 | } |
527 | return 1; | 529 | return 1; |
528 | } | 530 | } |
529 | QString KOPrefs::calName( int calNum) const | 531 | QString KOPrefs::calName( int calNum) const |
530 | { | 532 | { |
531 | return (mDefCalColors[calNum-1])->mName; | 533 | return (mDefCalColors[calNum-1])->mName; |
532 | } | 534 | } |
533 | QColor KOPrefs::defaultColor( int calNum ) const | 535 | QColor KOPrefs::defaultColor( int calNum ) const |
534 | { | 536 | { |
535 | if ( calNum == 1 ) return mEventColor; | 537 | if ( calNum == 1 ) return mEventColor; |
536 | return (mDefCalColors[calNum-1])->mDefaultColor; | 538 | return (mDefCalColors[calNum-1])->mDefaultColor; |
537 | } | 539 | } |
538 | void KOPrefs::usrWriteConfig() | 540 | void KOPrefs::usrWriteConfig() |
539 | { | 541 | { |
540 | config()->setGroup("General"); | 542 | config()->setGroup("General"); |
541 | config()->writeEntry("Custom Categories",mCustomCategories); | 543 | config()->writeEntry("Custom Categories",mCustomCategories); |
542 | 544 | ||
543 | config()->setGroup("Personal Settings"); | 545 | config()->setGroup("Personal Settings"); |
544 | config()->writeEntry("user_name",mName); | 546 | config()->writeEntry("user_name",mName); |
545 | config()->writeEntry("user_email",mEmail); | 547 | config()->writeEntry("user_email",mEmail); |
546 | 548 | ||
547 | config()->setGroup("Category Colors"); | 549 | config()->setGroup("Category Colors"); |
548 | QDictIterator<QColor> it(mCategoryColors); | 550 | QDictIterator<QColor> it(mCategoryColors); |
549 | while (it.current()) { | 551 | while (it.current()) { |
550 | config()->writeEntry(it.currentKey(),*(it.current())); | 552 | config()->writeEntry(it.currentKey(),*(it.current())); |
551 | ++it; | 553 | ++it; |
552 | } | 554 | } |
553 | KConfig fc (locateLocal("config","kopicalendarrc")); | 555 | KConfig fc (locateLocal("config","kopicalendarrc")); |
554 | fc.setGroup("CC"); | 556 | fc.setGroup("CC"); |
555 | fc.deleteGroup( "CC"); | 557 | fc.deleteGroup( "CC"); |
556 | fc.setGroup("CC"); | 558 | fc.setGroup("CC"); |
557 | fc.writeEntry("NumberCalendars",mCalendars.count()); | 559 | fc.writeEntry("NumberCalendars",mCalendars.count()); |
558 | int numCal = 1; | 560 | int numCal = 1; |
559 | int writeCal = 0; | 561 | int writeCal = 0; |
560 | while ( numCal < mNextAvailableCalendar ) { | 562 | while ( numCal < mNextAvailableCalendar ) { |
561 | KopiCalendarFile * kkf = mCalendars.first(); | 563 | KopiCalendarFile * kkf = mCalendars.first(); |
562 | while ( kkf ) { | 564 | while ( kkf ) { |
563 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); | 565 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); |
564 | if ( kkf->mCalNumber == numCal ) { | 566 | if ( kkf->mCalNumber == numCal ) { |
565 | ++writeCal; | 567 | ++writeCal; |
566 | //qDebug("Write calendar %d %d ", numCal , writeCal); | 568 | //qDebug("Write calendar %d %d ", numCal , writeCal); |
567 | QString prefix = "Cal_" + QString::number( writeCal ); | 569 | QString prefix = "Cal_" + QString::number( writeCal ); |
568 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); | 570 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); |
569 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); | 571 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); |
570 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); | 572 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); |
571 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); | 573 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); |
572 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); | 574 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); |
573 | fc.writeEntry( prefix+"_Name", kkf->mName); | 575 | fc.writeEntry( prefix+"_Name", kkf->mName); |
574 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); | 576 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); |
575 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); | 577 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); |
576 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); | 578 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); |
577 | } | 579 | } |
578 | kkf = mCalendars.next(); | 580 | kkf = mCalendars.next(); |
579 | } | 581 | } |
580 | ++numCal; | 582 | ++numCal; |
581 | } | 583 | } |
582 | fc.sync(); | 584 | fc.sync(); |
583 | KPimPrefs::usrWriteConfig(); | 585 | KPimPrefs::usrWriteConfig(); |
584 | } | 586 | } |
585 | 587 | ||
586 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 588 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
587 | { | 589 | { |
588 | mCategoryColors.replace(cat,new QColor(color)); | 590 | mCategoryColors.replace(cat,new QColor(color)); |
589 | } | 591 | } |
590 | 592 | ||
591 | QColor *KOPrefs::categoryColor(QString cat) | 593 | QColor *KOPrefs::categoryColor(QString cat) |
592 | { | 594 | { |
593 | QColor *color = 0; | 595 | QColor *color = 0; |
594 | 596 | ||
595 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 597 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
596 | 598 | ||
597 | if (color) return color; | 599 | if (color) return color; |
598 | else return &mDefaultCategoryColor; | 600 | else return &mDefaultCategoryColor; |
599 | } | 601 | } |
600 | 602 | ||
601 | void KOPrefs::setFullName(const QString &name) | 603 | void KOPrefs::setFullName(const QString &name) |
602 | { | 604 | { |
603 | mName = name; | 605 | mName = name; |
604 | } | 606 | } |
605 | 607 | ||
606 | void KOPrefs::setEmail(const QString &email) | 608 | void KOPrefs::setEmail(const QString &email) |
607 | { | 609 | { |
608 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 610 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
609 | mEmail = email; | 611 | mEmail = email; |
610 | } | 612 | } |
611 | 613 | ||
612 | QString KOPrefs::fullName() | 614 | QString KOPrefs::fullName() |
613 | { | 615 | { |
614 | if (mEmailControlCenter) { | 616 | if (mEmailControlCenter) { |
615 | KEMailSettings settings; | 617 | KEMailSettings settings; |
616 | return settings.getSetting(KEMailSettings::RealName); | 618 | return settings.getSetting(KEMailSettings::RealName); |
617 | } else { | 619 | } else { |
618 | return mName; | 620 | return mName; |
619 | } | 621 | } |
620 | } | 622 | } |
621 | 623 | ||
622 | QString KOPrefs::email() | 624 | QString KOPrefs::email() |
623 | { | 625 | { |
624 | if (mEmailControlCenter) { | 626 | if (mEmailControlCenter) { |
625 | KEMailSettings settings; | 627 | KEMailSettings settings; |
626 | return settings.getSetting(KEMailSettings::EmailAddress); | 628 | return settings.getSetting(KEMailSettings::EmailAddress); |
627 | } else { | 629 | } else { |
628 | return mEmail; | 630 | return mEmail; |
629 | } | 631 | } |
630 | } | 632 | } |
631 | KConfig* KOPrefs::getConfig() | 633 | KConfig* KOPrefs::getConfig() |
632 | { | 634 | { |
633 | return config(); | 635 | return config(); |
634 | } | 636 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 576edf9..bac8010 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -1,374 +1,376 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | 26 | ||
27 | #include <libkdepim/kpimprefs.h> | 27 | #include <libkdepim/kpimprefs.h> |
28 | #include <qdict.h> | 28 | #include <qdict.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qobject.h> | 30 | #include <qobject.h> |
31 | 31 | ||
32 | class KConfig; | 32 | class KConfig; |
33 | class QFont; | 33 | class QFont; |
34 | class QColor; | 34 | class QColor; |
35 | class QStringList; | 35 | class QStringList; |
36 | 36 | ||
37 | #define VIEW_WN_VIEW 1 | 37 | #define VIEW_WN_VIEW 1 |
38 | #define VIEW_NX_VIEW 2 | 38 | #define VIEW_NX_VIEW 2 |
39 | #define VIEW_J_VIEW 3 | 39 | #define VIEW_J_VIEW 3 |
40 | #define VIEW_A_VIEW 4 | 40 | #define VIEW_A_VIEW 4 |
41 | #define VIEW_ML_VIEW 5 | 41 | #define VIEW_ML_VIEW 5 |
42 | #define VIEW_M_VIEW 6 | 42 | #define VIEW_M_VIEW 6 |
43 | #define VIEW_L_VIEW 7 | 43 | #define VIEW_L_VIEW 7 |
44 | #define VIEW_T_VIEW 8 | 44 | #define VIEW_T_VIEW 8 |
45 | 45 | ||
46 | class KopiCalendarFile : public QObject | 46 | class KopiCalendarFile : public QObject |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | KopiCalendarFile( ) : QObject( ) | 49 | KopiCalendarFile( ) : QObject( ) |
50 | { | 50 | { |
51 | isStandard = false; | 51 | isStandard = false; |
52 | isEnabled = true; | 52 | isEnabled = true; |
53 | isAlarmEnabled = true; | 53 | isAlarmEnabled = true; |
54 | isReadOnly = false; | 54 | isReadOnly = false; |
55 | mName = "Calendar"; | 55 | mName = "Calendar"; |
56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; | 56 | mFileName = QDir::homeDirPath() + "/icalfile.ics"; |
57 | mSavedFileName = "icalfile.ics"; | 57 | mSavedFileName = "icalfile.ics"; |
58 | mCalNumber = 0; | 58 | mCalNumber = 0; |
59 | mDefaultColor = Qt::red; | 59 | mDefaultColor = Qt::red; |
60 | mErrorOnLoad = false; | 60 | mErrorOnLoad = false; |
61 | isRelative = false; | 61 | isRelative = false; |
62 | } | 62 | } |
63 | bool isStandard; | 63 | bool isStandard; |
64 | bool isEnabled; | 64 | bool isEnabled; |
65 | bool isAlarmEnabled; | 65 | bool isAlarmEnabled; |
66 | bool isReadOnly; | 66 | bool isReadOnly; |
67 | bool mErrorOnLoad; | 67 | bool mErrorOnLoad; |
68 | QString mName; | 68 | QString mName; |
69 | QString mFileName; | 69 | QString mFileName; |
70 | QString mSavedFileName; | 70 | QString mSavedFileName; |
71 | bool isRelative; | 71 | bool isRelative; |
72 | int mCalNumber; | 72 | int mCalNumber; |
73 | QColor mDefaultColor; | 73 | QColor mDefaultColor; |
74 | QDateTime mLoadDt; | 74 | QDateTime mLoadDt; |
75 | }; | 75 | }; |
76 | class KOPrefs : public KPimPrefs | 76 | class KOPrefs : public KPimPrefs |
77 | { | 77 | { |
78 | public: | 78 | public: |
79 | enum { FormatVCalendar, FormatICalendar }; | 79 | enum { FormatVCalendar, FormatICalendar }; |
80 | enum { MailClientKMail, MailClientSendmail }; | 80 | enum { MailClientKMail, MailClientSendmail }; |
81 | enum { IMIPDummy, IMIPKMail }; | 81 | enum { IMIPDummy, IMIPKMail }; |
82 | enum { IMIPOutbox, IMIPdirectsend }; | 82 | enum { IMIPOutbox, IMIPdirectsend }; |
83 | enum { neverAuto, addressbookAuto, selectedAuto }; | 83 | enum { neverAuto, addressbookAuto, selectedAuto }; |
84 | enum { standardDestination, askDestination }; | 84 | enum { standardDestination, askDestination }; |
85 | 85 | ||
86 | virtual ~KOPrefs(); | 86 | virtual ~KOPrefs(); |
87 | 87 | ||
88 | /** Get instance of KOPrefs. It is made sure that there is only one | 88 | /** Get instance of KOPrefs. It is made sure that there is only one |
89 | instance. */ | 89 | instance. */ |
90 | static KOPrefs *instance(); | 90 | static KOPrefs *instance(); |
91 | 91 | ||
92 | /** Set preferences to default values */ | 92 | /** Set preferences to default values */ |
93 | void usrSetDefaults(); | 93 | void usrSetDefaults(); |
94 | 94 | ||
95 | /** Read preferences from config file */ | 95 | /** Read preferences from config file */ |
96 | void usrReadConfig(); | 96 | void usrReadConfig(); |
97 | 97 | ||
98 | /** Write preferences to config file */ | 98 | /** Write preferences to config file */ |
99 | void usrWriteConfig(); | 99 | void usrWriteConfig(); |
100 | void setCategoryDefaults(); | 100 | void setCategoryDefaults(); |
101 | void setAllDefaults(); | 101 | void setAllDefaults(); |
102 | KopiCalendarFile * getNewCalendar(); | 102 | KopiCalendarFile * getNewCalendar(); |
103 | KopiCalendarFile * getCalendar( int ); | 103 | KopiCalendarFile * getCalendar( int ); |
104 | void deleteCalendar( int ); | 104 | void deleteCalendar( int ); |
105 | QColor defaultColor( int ) const; | 105 | QColor defaultColor( int ) const; |
106 | QString calName( int ) const; | 106 | QString calName( int ) const; |
107 | int getCalendarID( const QString & name ); | 107 | int getCalendarID( const QString & name ); |
108 | protected: | 108 | protected: |
109 | void setTimeZoneIdDefault(); | 109 | void setTimeZoneIdDefault(); |
110 | 110 | ||
111 | /** Fill empty mail fields with default values. */ | 111 | /** Fill empty mail fields with default values. */ |
112 | void fillMailDefaults(); | 112 | void fillMailDefaults(); |
113 | 113 | ||
114 | private: | 114 | private: |
115 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 115 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
116 | object. */ | 116 | object. */ |
117 | KOPrefs(); | 117 | KOPrefs(); |
118 | 118 | ||
119 | static KOPrefs *mInstance; | 119 | static KOPrefs *mInstance; |
120 | QStringList getDefaultList(); | 120 | QStringList getDefaultList(); |
121 | QStringList getLocationDefaultList(); | 121 | QStringList getLocationDefaultList(); |
122 | public: | 122 | public: |
123 | // preferences data | 123 | // preferences data |
124 | KConfig* getConfig(); | 124 | KConfig* getConfig(); |
125 | void setFullName(const QString &); | 125 | void setFullName(const QString &); |
126 | QString fullName(); | 126 | QString fullName(); |
127 | void setEmail(const QString &); | 127 | void setEmail(const QString &); |
128 | QString email(); | 128 | QString email(); |
129 | 129 | ||
130 | QString mAdditional; | 130 | QString mAdditional; |
131 | 131 | ||
132 | bool mEmailControlCenter; | 132 | bool mEmailControlCenter; |
133 | 133 | ||
134 | bool mBcc; | 134 | bool mBcc; |
135 | bool mAutoSave; | 135 | bool mAutoSave; |
136 | int mAutoSaveInterval; | 136 | int mAutoSaveInterval; |
137 | bool mConfirm; | 137 | bool mConfirm; |
138 | 138 | ||
139 | bool mEnableGroupScheduling; | 139 | bool mEnableGroupScheduling; |
140 | bool mEnableProjectView; | 140 | bool mEnableProjectView; |
141 | 141 | ||
142 | int mDefaultFormat; | 142 | int mDefaultFormat; |
143 | int mMailClient; | 143 | int mMailClient; |
144 | 144 | ||
145 | int mStartTime; | 145 | int mStartTime; |
146 | int mDefaultDuration; | 146 | int mDefaultDuration; |
147 | int mAlarmTime; | 147 | int mAlarmTime; |
148 | 148 | ||
149 | int mWorkingHoursStart; | 149 | int mWorkingHoursStart; |
150 | int mWorkingHoursEnd; | 150 | int mWorkingHoursEnd; |
151 | bool mExcludeHolidays; | 151 | bool mExcludeHolidays; |
152 | bool mExcludeSaturdays; | 152 | bool mExcludeSaturdays; |
153 | bool mMarcusBainsShowSeconds; | 153 | bool mMarcusBainsShowSeconds; |
154 | 154 | ||
155 | QFont mTimeBarFont; | 155 | QFont mTimeBarFont; |
156 | QFont mMonthViewFont; | 156 | QFont mMonthViewFont; |
157 | QFont mAgendaViewFont; | 157 | QFont mAgendaViewFont; |
158 | QFont mMarcusBainsFont; | 158 | QFont mMarcusBainsFont; |
159 | QFont mTimeLabelsFont; | 159 | QFont mTimeLabelsFont; |
160 | QFont mTodoViewFont; | 160 | QFont mTodoViewFont; |
161 | QFont mListViewFont; | 161 | QFont mListViewFont; |
162 | QFont mDateNavigatorFont; | 162 | QFont mDateNavigatorFont; |
163 | QFont mEditBoxFont; | 163 | QFont mEditBoxFont; |
164 | QFont mJornalViewFont; | 164 | QFont mJornalViewFont; |
165 | QFont mWhatsNextFont; | 165 | QFont mWhatsNextFont; |
166 | QFont mEventViewFont; | 166 | QFont mEventViewFont; |
167 | 167 | ||
168 | 168 | ||
169 | 169 | ||
170 | 170 | ||
171 | QColor mHolidayColor; | 171 | QColor mHolidayColor; |
172 | QColor mHighlightColor; | 172 | QColor mHighlightColor; |
173 | QColor mEventColor; | 173 | QColor mEventColor; |
174 | QColor mTodoDoneColor; | 174 | QColor mTodoDoneColor; |
175 | QColor mAgendaBgColor; | 175 | QColor mAgendaBgColor; |
176 | QColor mWorkingHoursColor; | 176 | QColor mWorkingHoursColor; |
177 | QColor mTodoDueTodayColor; | 177 | QColor mTodoDueTodayColor; |
178 | QColor mTodoOverdueColor; | 178 | QColor mTodoOverdueColor; |
179 | QColor mTodoRunColor; | 179 | QColor mTodoRunColor; |
180 | QColor mMonthViewEvenColor; | 180 | QColor mMonthViewEvenColor; |
181 | QColor mMonthViewOddColor; | 181 | QColor mMonthViewOddColor; |
182 | QColor mMonthViewHolidayColor; | 182 | QColor mMonthViewHolidayColor; |
183 | bool mMonthViewUsesDayColors; | 183 | bool mMonthViewUsesDayColors; |
184 | bool mMonthViewSatSunTog; | 184 | bool mMonthViewSatSunTog; |
185 | bool mMonthViewWeek; | 185 | bool mMonthViewWeek; |
186 | bool mMonthViewWeekRowlayout; | 186 | bool mMonthViewWeekRowlayout; |
187 | QColor mAppColor1; | 187 | QColor mAppColor1; |
188 | QColor mAppColor2; | 188 | QColor mAppColor2; |
189 | bool mUseAppColors; | 189 | bool mUseAppColors; |
190 | 190 | ||
191 | int mDayBegins; | 191 | int mDayBegins; |
192 | int mHourSize; | 192 | int mHourSize; |
193 | int mAllDaySize; | 193 | int mAllDaySize; |
194 | bool mShowFullMenu; | 194 | bool mShowFullMenu; |
195 | bool mDailyRecur; | 195 | bool mDailyRecur; |
196 | bool mWeeklyRecur; | 196 | bool mWeeklyRecur; |
197 | bool mLongAllday; | ||
197 | bool mMonthDailyRecur; | 198 | bool mMonthDailyRecur; |
198 | bool mMonthWeeklyRecur; | 199 | bool mMonthWeeklyRecur; |
199 | bool mMonthShowIcons; | 200 | bool mMonthShowIcons; |
200 | bool mMonthShowTimes; | 201 | bool mMonthShowTimes; |
201 | bool mMonthShowShort; | 202 | bool mMonthShowShort; |
202 | bool mEnableToolTips; | 203 | bool mEnableToolTips; |
203 | bool mEnableMonthScroll; | 204 | bool mEnableMonthScroll; |
204 | bool mFullViewMonth; | 205 | bool mFullViewMonth; |
205 | bool mMonthViewUsesCategoryColor; | 206 | bool mMonthViewUsesCategoryColor; |
206 | bool mFullViewTodo; | 207 | bool mFullViewTodo; |
207 | bool mShowCompletedTodo; | 208 | bool mShowCompletedTodo; |
208 | bool mMarcusBainsEnabled; | 209 | bool mMarcusBainsEnabled; |
209 | int mNextXDays; | 210 | int mNextXDays; |
210 | int mWhatsNextDays; | 211 | int mWhatsNextDays; |
211 | bool mWhatsNextTime2Lines; | 212 | bool mWhatsNextTime2Lines; |
212 | int mWhatsNextPrios; | 213 | int mWhatsNextPrios; |
213 | bool mEnableQuickTodo; | 214 | bool mEnableQuickTodo; |
214 | 215 | ||
215 | bool mCompactDialogs; | 216 | bool mCompactDialogs; |
216 | bool mVerticalScreen; | 217 | bool mVerticalScreen; |
217 | 218 | ||
218 | bool mShowIconNewTodo; | 219 | bool mShowIconNewTodo; |
219 | bool mShowIconNewEvent; | 220 | bool mShowIconNewEvent; |
220 | bool mShowIconSearch; | 221 | bool mShowIconSearch; |
221 | bool mShowIconList; | 222 | bool mShowIconList; |
222 | bool mShowIconDay1; | 223 | bool mShowIconDay1; |
223 | bool mShowIconDay5; | 224 | bool mShowIconDay5; |
224 | bool mShowIconDay6; | 225 | bool mShowIconDay6; |
225 | bool mShowIconDay7; | 226 | bool mShowIconDay7; |
226 | bool mShowIconMonth; | 227 | bool mShowIconMonth; |
227 | bool mShowIconTodoview; | 228 | bool mShowIconTodoview; |
228 | bool mShowIconBackFast; | 229 | bool mShowIconBackFast; |
229 | bool mShowIconBack; | 230 | bool mShowIconBack; |
230 | bool mShowIconToday; | 231 | bool mShowIconToday; |
231 | bool mShowIconForward; | 232 | bool mShowIconForward; |
232 | bool mShowIconForwardFast; | 233 | bool mShowIconForwardFast; |
233 | bool mShowIconWhatsThis; | 234 | bool mShowIconWhatsThis; |
234 | bool mShowIconWeekNum; | 235 | bool mShowIconWeekNum; |
235 | bool mShowIconNextDays; | 236 | bool mShowIconNextDays; |
236 | bool mShowIconNext; | 237 | bool mShowIconNext; |
237 | bool mShowIconJournal; | 238 | bool mShowIconJournal; |
238 | bool mShowIconFilter; | 239 | bool mShowIconFilter; |
239 | bool mShowIconOnetoolbar; | 240 | bool mShowIconOnetoolbar; |
240 | bool mShowIconNavigator; | 241 | bool mShowIconNavigator; |
241 | bool mShowIconAllday; | 242 | bool mShowIconAllday; |
242 | bool mShowIconFilterview; | 243 | bool mShowIconFilterview; |
243 | bool mShowIconToggleFull; | 244 | bool mShowIconToggleFull; |
244 | 245 | ||
245 | bool mShowIconStretch; | 246 | bool mShowIconStretch; |
246 | 247 | ||
247 | bool mToolBarHor; | 248 | bool mToolBarHor; |
248 | bool mToolBarUp; | 249 | bool mToolBarUp; |
249 | bool mToolBarHorV; | 250 | bool mToolBarHorV; |
250 | bool mToolBarUpV; | 251 | bool mToolBarUpV; |
251 | bool mToolBarHorN; | 252 | bool mToolBarHorN; |
252 | bool mToolBarUpN; | 253 | bool mToolBarUpN; |
253 | bool mToolBarHorF; | 254 | bool mToolBarHorF; |
254 | bool mToolBarUpF; | 255 | bool mToolBarUpF; |
255 | bool mToolBarMiniIcons; | 256 | bool mToolBarMiniIcons; |
256 | 257 | ||
257 | bool mAskForQuit; | 258 | bool mAskForQuit; |
258 | bool mUsePassWd; | 259 | bool mUsePassWd; |
259 | bool mShowSyncEvents; | 260 | bool mShowSyncEvents; |
260 | bool mShowTodoInAgenda; | 261 | bool mShowTodoInAgenda; |
261 | bool mShowCompletedTodoInAgenda; | 262 | bool mShowCompletedTodoInAgenda; |
262 | bool mShowTimeInAgenda; | 263 | bool mShowTimeInAgenda; |
263 | bool mHideNonStartedTodos; | 264 | bool mHideNonStartedTodos; |
264 | 265 | ||
265 | bool mBlockPopupMenu; | 266 | bool mBlockPopupMenu; |
266 | 267 | ||
267 | int mLastSyncTime; | 268 | int mLastSyncTime; |
268 | void setCategoryColor(QString cat,const QColor & color); | 269 | void setCategoryColor(QString cat,const QColor & color); |
269 | QColor *categoryColor(QString cat); | 270 | QColor *categoryColor(QString cat); |
270 | 271 | ||
271 | QString mArchiveFile; | 272 | QString mArchiveFile; |
272 | QString mHtmlExportFile; | 273 | QString mHtmlExportFile; |
273 | bool mHtmlWithSave; | 274 | bool mHtmlWithSave; |
274 | 275 | ||
275 | QStringList mSelectedPlugins; | 276 | QStringList mSelectedPlugins; |
276 | 277 | ||
277 | QString mLastImportFile; | 278 | QString mLastImportFile; |
278 | QString mLastVcalFile; | 279 | QString mLastVcalFile; |
279 | QString mLastSaveFile; | 280 | QString mLastSaveFile; |
280 | QString mLastLoadFile; | 281 | QString mLastLoadFile; |
281 | 282 | ||
282 | 283 | ||
283 | QString mDefaultAlarmFile; | 284 | QString mDefaultAlarmFile; |
284 | int mIMIPScheduler; | 285 | int mIMIPScheduler; |
285 | int mIMIPSend; | 286 | int mIMIPSend; |
286 | QStringList mAdditionalMails; | 287 | QStringList mAdditionalMails; |
287 | int mIMIPAutoRefresh; | 288 | int mIMIPAutoRefresh; |
288 | int mIMIPAutoInsertReply; | 289 | int mIMIPAutoInsertReply; |
289 | int mIMIPAutoInsertRequest; | 290 | int mIMIPAutoInsertRequest; |
290 | int mIMIPAutoFreeBusy; | 291 | int mIMIPAutoFreeBusy; |
291 | int mIMIPAutoFreeBusyReply; | 292 | int mIMIPAutoFreeBusyReply; |
292 | 293 | ||
293 | QStringList mTodoTemplates; | 294 | QStringList mTodoTemplates; |
294 | QStringList mEventTemplates; | 295 | QStringList mEventTemplates; |
295 | 296 | ||
296 | int mDestination; | 297 | int mDestination; |
297 | 298 | ||
298 | 299 | ||
299 | bool mEditOnDoubleClick; | 300 | bool mEditOnDoubleClick; |
300 | bool mViewChangeHoldFullscreen; | 301 | bool mViewChangeHoldFullscreen; |
301 | bool mViewChangeHoldNonFullscreen; | 302 | bool mViewChangeHoldNonFullscreen; |
302 | bool mCenterOnCurrentTime; | 303 | bool mCenterOnCurrentTime; |
303 | bool mSetTimeToDayStartAt; | 304 | bool mSetTimeToDayStartAt; |
304 | bool mHighlightCurrentDay; | 305 | bool mHighlightCurrentDay; |
305 | bool mUseHighlightLightColor; | 306 | bool mUseHighlightLightColor; |
306 | bool mListViewMonthTimespan; | 307 | bool mListViewMonthTimespan; |
307 | bool mWNViewShowsParents; | 308 | bool mWNViewShowsParents; |
308 | bool mWNViewShowsPast; | 309 | bool mWNViewShowsPast; |
309 | bool mWNViewShowLocation; | 310 | bool mWNViewShowLocation; |
310 | bool mTodoViewShowsPercentage; | 311 | bool mTodoViewShowsPercentage; |
311 | bool mTodoViewUsesCatColors; | 312 | bool mTodoViewUsesCatColors; |
312 | bool mMonthViewUsesBigFont; | 313 | bool mMonthViewUsesBigFont; |
313 | bool mTodoViewUsesSmallFont; | 314 | bool mTodoViewUsesSmallFont; |
314 | bool mTodoViewUsesForegroundColor; | 315 | bool mTodoViewUsesForegroundColor; |
315 | bool mMonthViewUsesForegroundColor; | 316 | bool mMonthViewUsesForegroundColor; |
316 | 317 | ||
317 | bool mHightlightDateTimeEdit; | 318 | bool mHightlightDateTimeEdit; |
318 | bool mShortDateInViewer; | 319 | bool mShortDateInViewer; |
319 | 320 | ||
320 | bool mShowDateNavigator; | 321 | bool mShowDateNavigator; |
321 | 322 | ||
322 | QStringList mLocationDefaults; | 323 | QStringList mLocationDefaults; |
323 | QStringList mEventSummaryUser; | 324 | QStringList mEventSummaryUser; |
324 | QStringList mTodoSummaryUser; | 325 | QStringList mTodoSummaryUser; |
325 | QStringList mJournalSummaryUser; | 326 | QStringList mJournalSummaryUser; |
326 | 327 | ||
327 | bool mUseInternalAlarmNotification; | 328 | bool mUseInternalAlarmNotification; |
328 | int mAlarmPlayBeeps; | 329 | int mAlarmPlayBeeps; |
329 | int mAlarmSuspendTime; | 330 | int mAlarmSuspendTime; |
330 | int mAlarmSuspendCount; | 331 | int mAlarmSuspendCount; |
331 | int mAlarmBeepInterval; | 332 | int mAlarmBeepInterval; |
332 | int mOldLanguage; | 333 | int mOldLanguage; |
333 | int mOldLoadedLanguage; | 334 | int mOldLoadedLanguage; |
334 | 335 | ||
335 | 336 | ||
336 | QString mActiveSyncPort; | 337 | QString mActiveSyncPort; |
337 | QString mActiveSyncIP; | 338 | QString mActiveSyncIP; |
338 | 339 | ||
339 | // settings for eventviewer | 340 | // settings for eventviewer |
340 | bool mEVshowDetails; | 341 | bool mEVshowDetails; |
341 | bool mEVshowCreated; | 342 | bool mEVshowCreated; |
342 | bool mEVshowChanged; | 343 | bool mEVshowChanged; |
343 | bool mWTshowDetails; | 344 | bool mWTshowDetails; |
344 | bool mWTshowCreated; | 345 | bool mWTshowCreated; |
345 | bool mWTshowChanged; | 346 | bool mWTshowChanged; |
346 | 347 | ||
347 | int mCurrentDisplayedView; | 348 | int mCurrentDisplayedView; |
348 | QPtrList<KopiCalendarFile> mCalendars; | 349 | QPtrList<KopiCalendarFile> mCalendars; |
349 | int mNextAvailableCalendar; | 350 | int mNextAvailableCalendar; |
350 | bool mGlobalUpdateDisabled; | 351 | bool mGlobalUpdateDisabled; |
351 | 352 | ||
352 | 353 | ||
353 | bool mDetectConflicts; | 354 | bool mDetectConflicts; |
355 | bool mIncludeFree; | ||
354 | bool mCheckConflictsAllDayAllDay; | 356 | bool mCheckConflictsAllDayAllDay; |
355 | bool mCheckConflictsAllDayNonAD; | 357 | bool mCheckConflictsAllDayNonAD; |
356 | bool mCheckConflictsNonADAllDay; | 358 | bool mCheckConflictsNonADAllDay; |
357 | bool mCheckConflictsNonADNonAD; | 359 | bool mCheckConflictsNonADNonAD; |
358 | QString mFilterConflictEditItem; | 360 | QString mFilterConflictEditItem; |
359 | QString mFilterConflictAllItem; | 361 | QString mFilterConflictAllItem; |
360 | 362 | ||
361 | private: | 363 | private: |
362 | QDict<QColor> mCategoryColors; | 364 | QDict<QColor> mCategoryColors; |
363 | QArray<KopiCalendarFile*> mDefCalColors; | 365 | QArray<KopiCalendarFile*> mDefCalColors; |
364 | QColor mDefaultCategoryColor; | 366 | QColor mDefaultCategoryColor; |
365 | 367 | ||
366 | QFont mDefaultTimeBarFont; | 368 | QFont mDefaultTimeBarFont; |
367 | QFont mDefaultViewFont; | 369 | QFont mDefaultViewFont; |
368 | QFont mDefaultMonthViewFont; | 370 | QFont mDefaultMonthViewFont; |
369 | 371 | ||
370 | QString mName; | 372 | QString mName; |
371 | QString mEmail; | 373 | QString mEmail; |
372 | }; | 374 | }; |
373 | 375 | ||
374 | #endif | 376 | #endif |
diff --git a/korganizer/koprefsdialog.cpp b/korganizer/koprefsdialog.cpp index bbdf508..f1a6c3d 100644 --- a/korganizer/koprefsdialog.cpp +++ b/korganizer/koprefsdialog.cpp | |||
@@ -1,1604 +1,1613 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qgroupbox.h> | 26 | #include <qgroupbox.h> |
27 | #include <qbuttongroup.h> | 27 | #include <qbuttongroup.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qfont.h> | 29 | #include <qfont.h> |
30 | #include <qslider.h> | 30 | #include <qslider.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | #include <qhbox.h> | 35 | #include <qhbox.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qstrlist.h> | 42 | #include <qstrlist.h> |
43 | #include <qapplication.h> | 43 | #include <qapplication.h> |
44 | 44 | ||
45 | #include <kcolorbutton.h> | 45 | #include <kcolorbutton.h> |
46 | #include <kdebug.h> | 46 | #include <kdebug.h> |
47 | #include <klocale.h> | 47 | #include <klocale.h> |
48 | #include <kglobal.h> | 48 | #include <kglobal.h> |
49 | #include <kfontdialog.h> | 49 | #include <kfontdialog.h> |
50 | #include <kfiledialog.h> | 50 | #include <kfiledialog.h> |
51 | #include <kmessagebox.h> | 51 | #include <kmessagebox.h> |
52 | #include <kcolordialog.h> | 52 | #include <kcolordialog.h> |
53 | #include <kiconloader.h> | 53 | #include <kiconloader.h> |
54 | #include <kemailsettings.h> | 54 | #include <kemailsettings.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kglobalsettings.h> | 56 | #include <kglobalsettings.h> |
57 | 57 | ||
58 | #include <kurlrequester.h> | 58 | #include <kurlrequester.h> |
59 | #include <klineedit.h> | 59 | #include <klineedit.h> |
60 | 60 | ||
61 | #if defined(USE_SOLARIS) | 61 | #if defined(USE_SOLARIS) |
62 | #include <sys/param.h> | 62 | #include <sys/param.h> |
63 | 63 | ||
64 | #define ZONEINFODIR "/usr/share/lib/zoneinfo" | 64 | #define ZONEINFODIR "/usr/share/lib/zoneinfo" |
65 | #define INITFILE "/etc/default/init" | 65 | #define INITFILE "/etc/default/init" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #include "koprefs.h" | 68 | #include "koprefs.h" |
69 | 69 | ||
70 | #include "koprefsdialog.h" | 70 | #include "koprefsdialog.h" |
71 | #include "kpimglobalprefs.h" | 71 | #include "kpimglobalprefs.h" |
72 | 72 | ||
73 | 73 | ||
74 | KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : | 74 | KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : |
75 | KPrefsDialog(KOPrefs::instance(),parent,name,true) | 75 | KPrefsDialog(KOPrefs::instance(),parent,name,true) |
76 | { | 76 | { |
77 | 77 | ||
78 | setFont( KGlobalSettings::generalMaxFont() ); | 78 | setFont( KGlobalSettings::generalMaxFont() ); |
79 | setCaption( i18n("Preferences - some settings need a restart (nr)")); | 79 | setCaption( i18n("Preferences - some settings need a restart (nr)")); |
80 | mCategoryDict.setAutoDelete(true); | 80 | mCategoryDict.setAutoDelete(true); |
81 | 81 | ||
82 | KGlobal::locale()->insertCatalogue("timezones"); | 82 | KGlobal::locale()->insertCatalogue("timezones"); |
83 | mSpacingHint = spacingHintSmall(); | 83 | mSpacingHint = spacingHintSmall(); |
84 | mMarginHint = marginHintSmall(); | 84 | mMarginHint = marginHintSmall(); |
85 | #ifndef DESKTOP_VERSION | 85 | #ifndef DESKTOP_VERSION |
86 | if ( QApplication::desktop()->height() == 480 ) | 86 | if ( QApplication::desktop()->height() == 480 ) |
87 | hideButtons(); | 87 | hideButtons(); |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | setupMainTab(); | 90 | setupMainTab(); |
91 | // setupLocaleTab(); | 91 | // setupLocaleTab(); |
92 | //setupTimeZoneTab(); | 92 | //setupTimeZoneTab(); |
93 | setupTimeTab(); | 93 | setupTimeTab(); |
94 | //setupLocaleDateTab(); | 94 | //setupLocaleDateTab(); |
95 | setupFontsTab(); | 95 | setupFontsTab(); |
96 | setupColorsTab(); | 96 | setupColorsTab(); |
97 | setupViewsTab(); | 97 | setupViewsTab(); |
98 | //setupSyncTab(); | 98 | //setupSyncTab(); |
99 | //setupSyncAlgTab(); | 99 | //setupSyncAlgTab(); |
100 | //setupPrinterTab(); | 100 | //setupPrinterTab(); |
101 | //setupGroupSchedulingTab(); | 101 | //setupGroupSchedulingTab(); |
102 | //setupGroupAutomationTab(); | 102 | //setupGroupAutomationTab(); |
103 | 103 | ||
104 | 104 | ||
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | KOPrefsDialog::~KOPrefsDialog() | 108 | KOPrefsDialog::~KOPrefsDialog() |
109 | { | 109 | { |
110 | } | 110 | } |
111 | void KOPrefsDialog::setupGlobalTab() | 111 | void KOPrefsDialog::setupGlobalTab() |
112 | { | 112 | { |
113 | 113 | ||
114 | 114 | ||
115 | } | 115 | } |
116 | void KOPrefsDialog::setupLocaleDateTab() | 116 | void KOPrefsDialog::setupLocaleDateTab() |
117 | { | 117 | { |
118 | #if 0 | 118 | #if 0 |
119 | QFrame *topFrame = addPage(i18n("Date Format"),0,0); | 119 | QFrame *topFrame = addPage(i18n("Date Format"),0,0); |
120 | QGridLayout *topLayout = new QGridLayout(topFrame,3,2); | 120 | QGridLayout *topLayout = new QGridLayout(topFrame,3,2); |
121 | topLayout->setSpacing(mSpacingHint); | 121 | topLayout->setSpacing(mSpacingHint); |
122 | topLayout->setMargin(mMarginHint); | 122 | topLayout->setMargin(mMarginHint); |
123 | int iii = 0; | 123 | int iii = 0; |
124 | 124 | ||
125 | 125 | ||
126 | KPrefsDialogWidRadios *syncPrefsGroup = | 126 | KPrefsDialogWidRadios *syncPrefsGroup = |
127 | addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); | 127 | addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); |
128 | QString format; | 128 | QString format; |
129 | if ( QApplication::desktop()->width() < 480 ) | 129 | if ( QApplication::desktop()->width() < 480 ) |
130 | format = "(%d.%m.%Y)"; | 130 | format = "(%d.%m.%Y)"; |
131 | else | 131 | else |
132 | format = "(%d.%m.%Y|%A %d %B %Y)"; | 132 | format = "(%d.%m.%Y|%A %d %B %Y)"; |
133 | syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); | 133 | syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); |
134 | if ( QApplication::desktop()->width() < 480 ) | 134 | if ( QApplication::desktop()->width() < 480 ) |
135 | format = "(%m.%d.%Y)"; | 135 | format = "(%m.%d.%Y)"; |
136 | else | 136 | else |
137 | format = "(%m.%d.%Y|%A %B %d %Y)"; | 137 | format = "(%m.%d.%Y|%A %B %d %Y)"; |
138 | syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); | 138 | syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); |
139 | if ( QApplication::desktop()->width() < 480 ) | 139 | if ( QApplication::desktop()->width() < 480 ) |
140 | format = "(%Y-%m-%d)"; | 140 | format = "(%Y-%m-%d)"; |
141 | else | 141 | else |
142 | format = "(%Y-%m-%d|%A %Y %B %d)"; | 142 | format = "(%Y-%m-%d|%A %Y %B %d)"; |
143 | syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); | 143 | syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); |
144 | syncPrefsGroup->addRadio(i18n("User defined")); | 144 | syncPrefsGroup->addRadio(i18n("User defined")); |
145 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); | 145 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); |
146 | ++iii; | 146 | ++iii; |
147 | ++iii; | 147 | ++iii; |
148 | QLabel * lab; | 148 | QLabel * lab; |
149 | mUserDateFormatLong = new QLineEdit(topFrame); | 149 | mUserDateFormatLong = new QLineEdit(topFrame); |
150 | lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); | 150 | lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); |
151 | topLayout->addWidget(lab ,iii,0); | 151 | topLayout->addWidget(lab ,iii,0); |
152 | topLayout->addWidget(mUserDateFormatLong,iii,1); | 152 | topLayout->addWidget(mUserDateFormatLong,iii,1); |
153 | ++iii; | 153 | ++iii; |
154 | mUserDateFormatShort = new QLineEdit(topFrame); | 154 | mUserDateFormatShort = new QLineEdit(topFrame); |
155 | lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); | 155 | lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); |
156 | topLayout->addWidget(lab ,iii,0); | 156 | topLayout->addWidget(lab ,iii,0); |
157 | topLayout->addWidget(mUserDateFormatShort,iii,1); | 157 | topLayout->addWidget(mUserDateFormatShort,iii,1); |
158 | ++iii; | 158 | ++iii; |
159 | lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); | 159 | lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); |
160 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); | 160 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); |
161 | ++iii; | 161 | ++iii; |
162 | lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); | 162 | lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); |
163 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); | 163 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); |
164 | ++iii; | 164 | ++iii; |
165 | lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); | 165 | lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); |
166 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); | 166 | topLayout->addMultiCellWidget(lab ,iii,iii,0,1); |
167 | ++iii; | 167 | ++iii; |
168 | #endif | 168 | #endif |
169 | 169 | ||
170 | } | 170 | } |
171 | 171 | ||
172 | void KOPrefsDialog::setupLocaleTab() | 172 | void KOPrefsDialog::setupLocaleTab() |
173 | { | 173 | { |
174 | #if 0 | 174 | #if 0 |
175 | QFrame *topFrame = addPage(i18n("Locale"),0,0); | 175 | QFrame *topFrame = addPage(i18n("Locale"),0,0); |
176 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); | 176 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); |
177 | topLayout->setSpacing(mSpacingHint); | 177 | topLayout->setSpacing(mSpacingHint); |
178 | topLayout->setMargin(mMarginHint); | 178 | topLayout->setMargin(mMarginHint); |
179 | int iii = 0; | 179 | int iii = 0; |
180 | KPrefsDialogWidRadios *syncPrefsGroup = | 180 | KPrefsDialogWidRadios *syncPrefsGroup = |
181 | addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame); | 181 | addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame); |
182 | syncPrefsGroup->addRadio(i18n("English")); | 182 | syncPrefsGroup->addRadio(i18n("English")); |
183 | syncPrefsGroup->addRadio(i18n("German")); | 183 | syncPrefsGroup->addRadio(i18n("German")); |
184 | syncPrefsGroup->addRadio(i18n("French")); | 184 | syncPrefsGroup->addRadio(i18n("French")); |
185 | syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); | 185 | syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); |
186 | if ( QApplication::desktop()->width() < 300 ) | 186 | if ( QApplication::desktop()->width() < 300 ) |
187 | ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); | 187 | ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); |
188 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); | 188 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); |
189 | ++iii; | 189 | ++iii; |
190 | 190 | ||
191 | syncPrefsGroup = | 191 | syncPrefsGroup = |
192 | addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame); | 192 | addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame); |
193 | if ( QApplication::desktop()->width() > 300 ) | 193 | if ( QApplication::desktop()->width() > 300 ) |
194 | syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); | 194 | syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); |
195 | syncPrefsGroup->addRadio(i18n("24:00")); | 195 | syncPrefsGroup->addRadio(i18n("24:00")); |
196 | syncPrefsGroup->addRadio(i18n("12:00am")); | 196 | syncPrefsGroup->addRadio(i18n("12:00am")); |
197 | syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); | 197 | syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); |
198 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); | 198 | topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); |
199 | ++iii; | 199 | ++iii; |
200 | KPrefsDialogWidBool *sb; | 200 | KPrefsDialogWidBool *sb; |
201 | if ( QApplication::desktop()->width() < 300 ) { | 201 | if ( QApplication::desktop()->width() < 300 ) { |
202 | sb = | 202 | sb = |
203 | addWidBool(i18n("Week starts on Sunday"), | 203 | addWidBool(i18n("Week starts on Sunday"), |
204 | &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame); | 204 | &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame); |
205 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 205 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
206 | ++iii; | 206 | ++iii; |
207 | sb = | 207 | sb = |
208 | addWidBool(i18n("Use short date in (WN/E) view"), | 208 | addWidBool(i18n("Use short date in (WN/E) view"), |
209 | &(KOPrefs::instance()->mShortDateInViewer),topFrame); | 209 | &(KOPrefs::instance()->mShortDateInViewer),topFrame); |
210 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 210 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
211 | } | 211 | } |
212 | else { | 212 | else { |
213 | QWidget * hb = new QWidget( topFrame ); | 213 | QWidget * hb = new QWidget( topFrame ); |
214 | QHBoxLayout *hbLayout = new QHBoxLayout(hb); | 214 | QHBoxLayout *hbLayout = new QHBoxLayout(hb); |
215 | sb = | 215 | sb = |
216 | addWidBool(i18n("Week starts on Sunday"), | 216 | addWidBool(i18n("Week starts on Sunday"), |
217 | &(KOPrefs::instance()->mWeekStartsOnSunday),hb); | 217 | &(KOPrefs::instance()->mWeekStartsOnSunday),hb); |
218 | hbLayout->addWidget(sb->checkBox() ); | 218 | hbLayout->addWidget(sb->checkBox() ); |
219 | sb = | 219 | sb = |
220 | addWidBool(i18n("Use short date in (WN/E) view"), | 220 | addWidBool(i18n("Use short date in (WN/E) view"), |
221 | &(KOPrefs::instance()->mShortDateInViewer),hb); | 221 | &(KOPrefs::instance()->mShortDateInViewer),hb); |
222 | hbLayout->addWidget(sb->checkBox() ); | 222 | hbLayout->addWidget(sb->checkBox() ); |
223 | topLayout->addMultiCellWidget(hb, iii,iii,0,1); | 223 | topLayout->addMultiCellWidget(hb, iii,iii,0,1); |
224 | 224 | ||
225 | } | 225 | } |
226 | // KPrefsDialogWidBool *sb; //#ifndef DESKTOP_VERSION | 226 | // KPrefsDialogWidBool *sb; //#ifndef DESKTOP_VERSION |
227 | #if 0 | 227 | #if 0 |
228 | ++iii; | 228 | ++iii; |
229 | sb = | 229 | sb = |
230 | addWidBool(i18n("Quick load/save (w/o Unicode)"), | 230 | addWidBool(i18n("Quick load/save (w/o Unicode)"), |
231 | &(KOPrefs::instance()->mUseQuicksave),topFrame); | 231 | &(KOPrefs::instance()->mUseQuicksave),topFrame); |
232 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); | 232 | topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); |
233 | #endif | 233 | #endif |
234 | #endif | 234 | #endif |
235 | } | 235 | } |
236 | 236 | ||
237 | void KOPrefsDialog::setupMainTab() | 237 | void KOPrefsDialog::setupMainTab() |
238 | { | 238 | { |
239 | QFrame *topFrame = addPage(i18n("General"),0,0); | 239 | QFrame *topFrame = addPage(i18n("General"),0,0); |
240 | // DesktopIcon("identity",KIcon::SizeMedium)); | 240 | // DesktopIcon("identity",KIcon::SizeMedium)); |
241 | 241 | ||
242 | QGridLayout *topLayout = new QGridLayout(topFrame,5,2); | 242 | QGridLayout *topLayout = new QGridLayout(topFrame,5,2); |
243 | topLayout->setSpacing(mSpacingHint); | 243 | topLayout->setSpacing(mSpacingHint); |
244 | topLayout->setMargin(mMarginHint); | 244 | topLayout->setMargin(mMarginHint); |
245 | 245 | ||
246 | // KPrefsDialogWidBool *emailControlCenter = | 246 | // KPrefsDialogWidBool *emailControlCenter = |
247 | // addWidBool(i18n("&Use email settings from Control Center"), | 247 | // addWidBool(i18n("&Use email settings from Control Center"), |
248 | // &(KOPrefs::instance()->mEmailControlCenter),topFrame); | 248 | // &(KOPrefs::instance()->mEmailControlCenter),topFrame); |
249 | // topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1); | 249 | // topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1); |
250 | // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)), | 250 | // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)), |
251 | // SLOT(toggleEmailSettings(bool))); | 251 | // SLOT(toggleEmailSettings(bool))); |
252 | 252 | ||
253 | mNameEdit = new QLineEdit(topFrame); | 253 | mNameEdit = new QLineEdit(topFrame); |
254 | mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); | 254 | mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); |
255 | topLayout->addWidget(mNameLabel,0,0); | 255 | topLayout->addWidget(mNameLabel,0,0); |
256 | topLayout->addWidget(mNameEdit,0,1); | 256 | topLayout->addWidget(mNameEdit,0,1); |
257 | 257 | ||
258 | mEmailEdit = new QLineEdit(topFrame); | 258 | mEmailEdit = new QLineEdit(topFrame); |
259 | mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); | 259 | mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); |
260 | topLayout->addWidget(mEmailLabel,1,0); | 260 | topLayout->addWidget(mEmailLabel,1,0); |
261 | topLayout->addWidget(mEmailEdit,1,1); | 261 | topLayout->addWidget(mEmailEdit,1,1); |
262 | KPrefsDialogWidBool *wb; | 262 | KPrefsDialogWidBool *wb; |
263 | 263 | ||
264 | 264 | ||
265 | 265 | ||
266 | KPrefsDialogWidBool *widbool = addWidBool(i18n("Full menu bar(nr)"), | 266 | KPrefsDialogWidBool *widbool = addWidBool(i18n("Full menu bar(nr)"), |
267 | &(KOPrefs::instance()->mShowFullMenu),topFrame); | 267 | &(KOPrefs::instance()->mShowFullMenu),topFrame); |
268 | topLayout->addMultiCellWidget( widbool->checkBox(), 2,2,0,1); | 268 | topLayout->addMultiCellWidget( widbool->checkBox(), 2,2,0,1); |
269 | 269 | ||
270 | 270 | ||
271 | widbool = addWidBool(i18n("Mini icons in toolbar(nr)"), | 271 | widbool = addWidBool(i18n("Mini icons in toolbar(nr)"), |
272 | &(KOPrefs::instance()->mToolBarMiniIcons),topFrame); | 272 | &(KOPrefs::instance()->mToolBarMiniIcons),topFrame); |
273 | topLayout->addMultiCellWidget( widbool->checkBox(), 3,3,0,1); | 273 | topLayout->addMultiCellWidget( widbool->checkBox(), 3,3,0,1); |
274 | 274 | ||
275 | 275 | ||
276 | KPrefsDialogWidBool *verticalScreen = | 276 | KPrefsDialogWidBool *verticalScreen = |
277 | addWidBool(i18n("Vertical screen layout(Needs restart)"), | 277 | addWidBool(i18n("Vertical screen layout(Needs restart)"), |
278 | &(KOPrefs::instance()->mVerticalScreen),topFrame); | 278 | &(KOPrefs::instance()->mVerticalScreen),topFrame); |
279 | //topLayout->addWidget(verticalScreen->checkBox(),ii++,0); | 279 | //topLayout->addWidget(verticalScreen->checkBox(),ii++,0); |
280 | topLayout->addMultiCellWidget(verticalScreen->checkBox(),4,4,0,1); | 280 | topLayout->addMultiCellWidget(verticalScreen->checkBox(),4,4,0,1); |
281 | 281 | ||
282 | 282 | ||
283 | int iii = 5; | 283 | int iii = 5; |
284 | widbool = addWidBool(i18n("Block popup until mouse button release"), | 284 | widbool = addWidBool(i18n("Block popup until mouse button release"), |
285 | &(KOPrefs::instance()->mBlockPopupMenu),topFrame); | 285 | &(KOPrefs::instance()->mBlockPopupMenu),topFrame); |
286 | topLayout->addMultiCellWidget( widbool->checkBox(), iii,iii,0,1); | 286 | topLayout->addMultiCellWidget( widbool->checkBox(), iii,iii,0,1); |
287 | ++iii; | 287 | ++iii; |
288 | if ( QApplication::desktop()->height() <= 240 ) { | 288 | if ( QApplication::desktop()->height() <= 240 ) { |
289 | topFrame = addPage(i18n("General") +" 2",0,0); | 289 | topFrame = addPage(i18n("General") +" 2",0,0); |
290 | topLayout = new QGridLayout(topFrame,4,2); | 290 | topLayout = new QGridLayout(topFrame,4,2); |
291 | topLayout->setSpacing(2); | 291 | topLayout->setSpacing(2); |
292 | topLayout->setMargin(3); | 292 | topLayout->setMargin(3); |
293 | iii = 0; | 293 | iii = 0; |
294 | } | 294 | } |
295 | QHBox *dummy = new QHBox(topFrame); | 295 | QHBox *dummy = new QHBox(topFrame); |
296 | new QLabel(i18n("Days in Next-X-Days:"),dummy); | 296 | new QLabel(i18n("Days in Next-X-Days:"),dummy); |
297 | mNextXDaysSpin = new QSpinBox(2,14,1,dummy); | 297 | mNextXDaysSpin = new QSpinBox(2,14,1,dummy); |
298 | 298 | ||
299 | topLayout->addMultiCellWidget(dummy,iii,iii,0,1); | 299 | topLayout->addMultiCellWidget(dummy,iii,iii,0,1); |
300 | 300 | ||
301 | ++iii; | 301 | ++iii; |
302 | 302 | ||
303 | 303 | ||
304 | // KPrefsDialogWidBool *bcc = | 304 | // KPrefsDialogWidBool *bcc = |
305 | // addWidBool(i18n("Send copy to owner when mailing events"), | 305 | // addWidBool(i18n("Send copy to owner when mailing events"), |
306 | // &(KOPrefs::instance()->mBcc),topFrame); | 306 | // &(KOPrefs::instance()->mBcc),topFrame); |
307 | // topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1); | 307 | // topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1); |
308 | 308 | ||
309 | 309 | ||
310 | // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame); | 310 | // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame); |
311 | //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1); | 311 | //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1); |
312 | 312 | ||
313 | // addWidBool(i18n("Enable automatic saving of calendar"), | 313 | // addWidBool(i18n("Enable automatic saving of calendar"), |
314 | // &(KOPrefs::instance()->mAutoSave),autoSaveGroup); | 314 | // &(KOPrefs::instance()->mAutoSave),autoSaveGroup); |
315 | 315 | ||
316 | QHBox *intervalBox = new QHBox(topFrame); | 316 | QHBox *intervalBox = new QHBox(topFrame); |
317 | // intervalBox->setSpacing(mSpacingHint); | 317 | // intervalBox->setSpacing(mSpacingHint); |
318 | topLayout->addMultiCellWidget(intervalBox,iii,iii,0,1); | 318 | topLayout->addMultiCellWidget(intervalBox,iii,iii,0,1); |
319 | ++iii; | 319 | ++iii; |
320 | QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox); | 320 | QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox); |
321 | mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox); | 321 | mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox); |
322 | autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin); | 322 | autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin); |
323 | /* | 323 | /* |
324 | QHBox * agendasize = new QHBox ( topFrame ); | 324 | QHBox * agendasize = new QHBox ( topFrame ); |
325 | 325 | ||
326 | new QLabel (i18n("AllDayAgenda Height:"), agendasize ); | 326 | new QLabel (i18n("AllDayAgenda Height:"), agendasize ); |
327 | 327 | ||
328 | 328 | ||
329 | mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize); | 329 | mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize); |
330 | topLayout->addMultiCellWidget(agendasize,7,7,0,1); | 330 | topLayout->addMultiCellWidget(agendasize,7,7,0,1); |
331 | */ | 331 | */ |
332 | 332 | ||
333 | 333 | ||
334 | KPrefsDialogWidBool *ask = | 334 | KPrefsDialogWidBool *ask = |
335 | addWidBool(i18n("Ask for quit when closing KO/Pi"), | 335 | addWidBool(i18n("Ask for quit when closing KO/Pi"), |
336 | &(KOPrefs::instance()->mAskForQuit),topFrame); | 336 | &(KOPrefs::instance()->mAskForQuit),topFrame); |
337 | topLayout->addMultiCellWidget(ask->checkBox(),iii,iii,0,1); | 337 | topLayout->addMultiCellWidget(ask->checkBox(),iii,iii,0,1); |
338 | ++iii; | 338 | ++iii; |
339 | 339 | ||
340 | 340 | ||
341 | /* | 341 | /* |
342 | KPrefsDialogWidBool *confirmCheck = | 342 | KPrefsDialogWidBool *confirmCheck = |
343 | addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm), | 343 | addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm), |
344 | topFrame); | 344 | topFrame); |
345 | topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1); | 345 | topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1); |
346 | 346 | ||
347 | 347 | ||
348 | mEnableGroupScheduling = | 348 | mEnableGroupScheduling = |
349 | addWidBool(i18n("Enable group scheduling"), | 349 | addWidBool(i18n("Enable group scheduling"), |
350 | &(KOPrefs::instance()->mEnableGroupScheduling),topFrame); | 350 | &(KOPrefs::instance()->mEnableGroupScheduling),topFrame); |
351 | topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0); | 351 | topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0); |
352 | connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()), | 352 | connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()), |
353 | SLOT(warningGroupScheduling())); | 353 | SLOT(warningGroupScheduling())); |
354 | 354 | ||
355 | mEnableProjectView = | 355 | mEnableProjectView = |
356 | addWidBool(i18n("Enable project view"), | 356 | addWidBool(i18n("Enable project view"), |
357 | &(KOPrefs::instance()->mEnableProjectView),topFrame); | 357 | &(KOPrefs::instance()->mEnableProjectView),topFrame); |
358 | topLayout->addWidget(mEnableProjectView->checkBox(),9,0); | 358 | topLayout->addWidget(mEnableProjectView->checkBox(),9,0); |
359 | connect(mEnableProjectView->checkBox(),SIGNAL(clicked()), | 359 | connect(mEnableProjectView->checkBox(),SIGNAL(clicked()), |
360 | SLOT(warningProjectView())); | 360 | SLOT(warningProjectView())); |
361 | 361 | ||
362 | // Can't be disabled anymore | 362 | // Can't be disabled anymore |
363 | mEnableGroupScheduling->checkBox()->hide(); | 363 | mEnableGroupScheduling->checkBox()->hide(); |
364 | 364 | ||
365 | // Disable setting, because this feature now becomes stable | 365 | // Disable setting, because this feature now becomes stable |
366 | mEnableProjectView->checkBox()->hide(); | 366 | mEnableProjectView->checkBox()->hide(); |
367 | 367 | ||
368 | KPrefsDialogWidRadios *defaultFormatGroup = | 368 | KPrefsDialogWidRadios *defaultFormatGroup = |
369 | addWidRadios(i18n("Default Calendar Format"), | 369 | addWidRadios(i18n("Default Calendar Format"), |
370 | &(KOPrefs::instance()->mDefaultFormat),topFrame); | 370 | &(KOPrefs::instance()->mDefaultFormat),topFrame); |
371 | defaultFormatGroup->addRadio(i18n("vCalendar")); | 371 | defaultFormatGroup->addRadio(i18n("vCalendar")); |
372 | defaultFormatGroup->addRadio(i18n("iCalendar")); | 372 | defaultFormatGroup->addRadio(i18n("iCalendar")); |
373 | 373 | ||
374 | topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1); | 374 | topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1); |
375 | 375 | ||
376 | // Default format unconditionally is iCalendar | 376 | // Default format unconditionally is iCalendar |
377 | defaultFormatGroup->groupBox()->hide(); | 377 | defaultFormatGroup->groupBox()->hide(); |
378 | 378 | ||
379 | KPrefsDialogWidRadios *mailClientGroup = | 379 | KPrefsDialogWidRadios *mailClientGroup = |
380 | addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient), | 380 | addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient), |
381 | topFrame); | 381 | topFrame); |
382 | mailClientGroup->addRadio(i18n("KMail")); | 382 | mailClientGroup->addRadio(i18n("KMail")); |
383 | mailClientGroup->addRadio(i18n("Sendmail")); | 383 | mailClientGroup->addRadio(i18n("Sendmail")); |
384 | topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1); | 384 | topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1); |
385 | 385 | ||
386 | KPrefsDialogWidBool *htmlsave = | 386 | KPrefsDialogWidBool *htmlsave = |
387 | addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave), | 387 | addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave), |
388 | topFrame); | 388 | topFrame); |
389 | topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1); | 389 | topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1); |
390 | 390 | ||
391 | KPrefsDialogWidRadios *destinationGroup = | 391 | KPrefsDialogWidRadios *destinationGroup = |
392 | addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination), | 392 | addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination), |
393 | topFrame); | 393 | topFrame); |
394 | destinationGroup->addRadio(i18n("be added to the standard resource")); | 394 | destinationGroup->addRadio(i18n("be added to the standard resource")); |
395 | destinationGroup->addRadio(i18n("be asked which resource to use")); | 395 | destinationGroup->addRadio(i18n("be asked which resource to use")); |
396 | topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1); | 396 | topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1); |
397 | 397 | ||
398 | topLayout->setRowStretch(14,1); | 398 | topLayout->setRowStretch(14,1); |
399 | */ | 399 | */ |
400 | } | 400 | } |
401 | 401 | ||
402 | 402 | ||
403 | void KOPrefsDialog::setupTimeTab() | 403 | void KOPrefsDialog::setupTimeTab() |
404 | { | 404 | { |
405 | QFrame *topFrame = addPage(i18n("Time"),0,0); | 405 | QFrame *topFrame = addPage(i18n("Time"),0,0); |
406 | // DesktopIcon("clock",KIcon::SizeMedium)); | 406 | // DesktopIcon("clock",KIcon::SizeMedium)); |
407 | 407 | ||
408 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); | 408 | QGridLayout *topLayout = new QGridLayout(topFrame,4,2); |
409 | topLayout->setSpacing(mSpacingHint); | 409 | topLayout->setSpacing(mSpacingHint); |
410 | topLayout->setMargin(mMarginHint); | 410 | topLayout->setMargin(mMarginHint); |
411 | 411 | ||
412 | QHBox *dummy = new QHBox(topFrame); | 412 | QHBox *dummy = new QHBox(topFrame); |
413 | KPrefsDialogWidTime *dayBegins = | 413 | KPrefsDialogWidTime *dayBegins = |
414 | addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), | 414 | addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), |
415 | dummy); | 415 | dummy); |
416 | //topLayout->addWidget(dayBegins->label(),2,0); | 416 | //topLayout->addWidget(dayBegins->label(),2,0); |
417 | 417 | ||
418 | //topLayout->addWidget(dayBegins->spinBox(),2,1); | 418 | //topLayout->addWidget(dayBegins->spinBox(),2,1); |
419 | topLayout->addMultiCellWidget(dummy,0,0,0,1); | 419 | topLayout->addMultiCellWidget(dummy,0,0,0,1); |
420 | 420 | ||
421 | topLayout->addWidget(new QLabel(i18n("Default appointment time:"), | 421 | topLayout->addWidget(new QLabel(i18n("Default appointment time:"), |
422 | topFrame),1,0); | 422 | topFrame),1,0); |
423 | mStartTimeSpin = new QSpinBox(0,23,1,topFrame); | 423 | mStartTimeSpin = new QSpinBox(0,23,1,topFrame); |
424 | mStartTimeSpin->setSuffix(":00"); | 424 | mStartTimeSpin->setSuffix(":00"); |
425 | topLayout->addWidget(mStartTimeSpin,1,1); | 425 | topLayout->addWidget(mStartTimeSpin,1,1); |
426 | 426 | ||
427 | topLayout->addWidget(new QLabel(i18n("Def. duration of new app.:"), | 427 | topLayout->addWidget(new QLabel(i18n("Def. duration of new app.:"), |
428 | topFrame),2,0); | 428 | topFrame),2,0); |
429 | mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame); | 429 | mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame); |
430 | mDefaultDurationSpin->setSuffix(":00"); | 430 | mDefaultDurationSpin->setSuffix(":00"); |
431 | topLayout->addWidget(mDefaultDurationSpin,2,1); | 431 | topLayout->addWidget(mDefaultDurationSpin,2,1); |
432 | 432 | ||
433 | QStringList alarmList; | 433 | QStringList alarmList; |
434 | alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes") | 434 | alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes") |
435 | << i18n("15 minutes") << i18n("30 minutes")<< i18n("1 hour")<< i18n("3 hours") << i18n("24 hours") ; | 435 | << i18n("15 minutes") << i18n("30 minutes")<< i18n("1 hour")<< i18n("3 hours") << i18n("24 hours") ; |
436 | topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame), | 436 | topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame), |
437 | 3,0); | 437 | 3,0); |
438 | mAlarmTimeCombo = new QComboBox(topFrame); | 438 | mAlarmTimeCombo = new QComboBox(topFrame); |
439 | mAlarmTimeCombo->insertStringList(alarmList); | 439 | mAlarmTimeCombo->insertStringList(alarmList); |
440 | topLayout->addWidget(mAlarmTimeCombo,3,1); | 440 | topLayout->addWidget(mAlarmTimeCombo,3,1); |
441 | int iii = 4; | 441 | int iii = 4; |
442 | if ( QApplication::desktop()->height() <= 240 ) { | 442 | if ( QApplication::desktop()->height() <= 240 ) { |
443 | topFrame = addPage(i18n("Time") +" 2",0,0); | 443 | topFrame = addPage(i18n("Time") +" 2",0,0); |
444 | topLayout = new QGridLayout(topFrame,1,2); | 444 | topLayout = new QGridLayout(topFrame,1,2); |
445 | topLayout->setSpacing(2); | 445 | topLayout->setSpacing(2); |
446 | topLayout->setMargin(3); | 446 | topLayout->setMargin(3); |
447 | iii = 0; | 447 | iii = 0; |
448 | } | 448 | } |
449 | 449 | ||
450 | QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal, | 450 | QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal, |
451 | i18n("Working Hours"), | 451 | i18n("Working Hours"), |
452 | topFrame); | 452 | topFrame); |
453 | topLayout->addMultiCellWidget(workingHoursGroup,iii,iii,0,1); | 453 | topLayout->addMultiCellWidget(workingHoursGroup,iii,iii,0,1); |
454 | workingHoursGroup->layout()->setSpacing( 0 ); | 454 | workingHoursGroup->layout()->setSpacing( 0 ); |
455 | workingHoursGroup->layout()->setMargin( 4 ); | 455 | workingHoursGroup->layout()->setMargin( 4 ); |
456 | QHBox *workStartBox = new QHBox(workingHoursGroup); | 456 | QHBox *workStartBox = new QHBox(workingHoursGroup); |
457 | // workStartBox->setMargin( 0 ); | 457 | // workStartBox->setMargin( 0 ); |
458 | addWidTime(i18n("Daily starting hour:"), | 458 | addWidTime(i18n("Daily starting hour:"), |
459 | &(KOPrefs::instance()->mWorkingHoursStart),workStartBox); | 459 | &(KOPrefs::instance()->mWorkingHoursStart),workStartBox); |
460 | 460 | ||
461 | QHBox *workEndBox = new QHBox(workingHoursGroup); | 461 | QHBox *workEndBox = new QHBox(workingHoursGroup); |
462 | //workEndBox->setMargin( 0 ); | 462 | //workEndBox->setMargin( 0 ); |
463 | addWidTime(i18n("Daily ending hour:"), | 463 | addWidTime(i18n("Daily ending hour:"), |
464 | &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox); | 464 | &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox); |
465 | QVBox *excludeBox = new QVBox(workingHoursGroup); | 465 | QVBox *excludeBox = new QVBox(workingHoursGroup); |
466 | //excludeBox->setMargin( 0 ); | 466 | //excludeBox->setMargin( 0 ); |
467 | addWidBool(i18n("Exclude holidays"), | 467 | addWidBool(i18n("Exclude holidays"), |
468 | &(KOPrefs::instance()->mExcludeHolidays),excludeBox); | 468 | &(KOPrefs::instance()->mExcludeHolidays),excludeBox); |
469 | 469 | ||
470 | addWidBool(i18n("Exclude Saturdays"), | 470 | addWidBool(i18n("Exclude Saturdays"), |
471 | &(KOPrefs::instance()->mExcludeSaturdays),excludeBox); | 471 | &(KOPrefs::instance()->mExcludeSaturdays),excludeBox); |
472 | 472 | ||
473 | // KPrefsDialogWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"), | 473 | // KPrefsDialogWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"), |
474 | // &(KOPrefs::instance()->mMarcusBainsShowSeconds), | 474 | // &(KOPrefs::instance()->mMarcusBainsShowSeconds), |
475 | // topFrame); | 475 | // topFrame); |
476 | // topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0); | 476 | // topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0); |
477 | 477 | ||
478 | // topLayout->setRowStretch(6,1); | 478 | // topLayout->setRowStretch(6,1); |
479 | } | 479 | } |
480 | 480 | ||
481 | 481 | ||
482 | void KOPrefsDialog::setupViewsTab() | 482 | void KOPrefsDialog::setupViewsTab() |
483 | { | 483 | { |
484 | 484 | ||
485 | QFrame *topFrame = addPage(i18n("Views"),0,0); | 485 | QFrame *topFrame = addPage(i18n("Views"),0,0); |
486 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 486 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
487 | 487 | ||
488 | QGridLayout *topLayout = new QGridLayout(topFrame,6,1); | 488 | QGridLayout *topLayout = new QGridLayout(topFrame,6,1); |
489 | topLayout->setSpacing(mSpacingHint); | 489 | topLayout->setSpacing(mSpacingHint); |
490 | topLayout->setMargin(mMarginHint); | 490 | topLayout->setMargin(mMarginHint); |
491 | 491 | ||
492 | // QBoxLayout *dayBeginsLayout = new QHBoxLayout; | 492 | // QBoxLayout *dayBeginsLayout = new QHBoxLayout; |
493 | // topLayout->addLayout(dayBeginsLayout,0,0); | 493 | // topLayout->addLayout(dayBeginsLayout,0,0); |
494 | 494 | ||
495 | // KPrefsDialogWidTime *dayBegins = | 495 | // KPrefsDialogWidTime *dayBegins = |
496 | // addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), | 496 | // addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), |
497 | // topFrame); | 497 | // topFrame); |
498 | // dayBeginsLayout->addWidget(dayBegins->label()); | 498 | // dayBeginsLayout->addWidget(dayBegins->label()); |
499 | // dayBeginsLayout->addStretch(1); | 499 | // dayBeginsLayout->addStretch(1); |
500 | // dayBeginsLayout->addWidget(dayBegins->spinBox()); | 500 | // dayBeginsLayout->addWidget(dayBegins->spinBox()); |
501 | 501 | ||
502 | // QBoxLayout *nextDaysLayout = new QHBoxLayout; | 502 | // QBoxLayout *nextDaysLayout = new QHBoxLayout; |
503 | // topLayout->addLayout(nextDaysLayout,1,0); | 503 | // topLayout->addLayout(nextDaysLayout,1,0); |
504 | // nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame)); | 504 | // nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame)); |
505 | // mNextXDaysSpin = new QSpinBox(2,14,1,topFrame); | 505 | // mNextXDaysSpin = new QSpinBox(2,14,1,topFrame); |
506 | // nextDaysLayout->addStretch(1); | 506 | // nextDaysLayout->addStretch(1); |
507 | // nextDaysLayout->addWidget(mNextXDaysSpin); | 507 | // nextDaysLayout->addWidget(mNextXDaysSpin); |
508 | 508 | ||
509 | 509 | ||
510 | int ii = 0; | 510 | int ii = 0; |
511 | KPrefsDialogWidBool *dummy = | 511 | KPrefsDialogWidBool *dummy = |
512 | addWidBool(i18n("Edit item on doubleclick (if not, show)"), | 512 | addWidBool(i18n("Edit item on doubleclick (if not, show)"), |
513 | &(KOPrefs::instance()->mEditOnDoubleClick),topFrame); | 513 | &(KOPrefs::instance()->mEditOnDoubleClick),topFrame); |
514 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 514 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
515 | 515 | ||
516 | 516 | ||
517 | 517 | ||
518 | 518 | ||
519 | 519 | ||
520 | 520 | ||
521 | // topLayout->addWidget(hourSizeGroup,ii++,0); | 521 | // topLayout->addWidget(hourSizeGroup,ii++,0); |
522 | // topLayout->addMultiCellWidget(hourSizeGroup,ii,ii,0,0); | 522 | // topLayout->addMultiCellWidget(hourSizeGroup,ii,ii,0,0); |
523 | //topLayout->setRowStretch(11,1); | 523 | //topLayout->setRowStretch(11,1); |
524 | 524 | ||
525 | 525 | ||
526 | 526 | ||
527 | 527 | ||
528 | #if 0 | 528 | #if 0 |
529 | 529 | ||
530 | topFrame = addPage(i18n("ViewChange"),0,0); | 530 | topFrame = addPage(i18n("ViewChange"),0,0); |
531 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 531 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
532 | 532 | ||
533 | topLayout = new QGridLayout(topFrame,6,1); | 533 | topLayout = new QGridLayout(topFrame,6,1); |
534 | topLayout->setSpacing(mSpacingHint); | 534 | topLayout->setSpacing(mSpacingHint); |
535 | topLayout->setMargin(mMarginHint); | 535 | topLayout->setMargin(mMarginHint); |
536 | ii = 0; | 536 | ii = 0; |
537 | 537 | ||
538 | #endif | 538 | #endif |
539 | 539 | ||
540 | dummy = | 540 | dummy = |
541 | addWidBool(i18n("Hold fullscreen on view change"), | 541 | addWidBool(i18n("Hold fullscreen on view change"), |
542 | &(KOPrefs::instance()->mViewChangeHoldFullscreen),topFrame); | 542 | &(KOPrefs::instance()->mViewChangeHoldFullscreen),topFrame); |
543 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 543 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
544 | 544 | ||
545 | dummy = | 545 | dummy = |
546 | addWidBool(i18n("Hold non-fullscreen on view change"), | 546 | addWidBool(i18n("Hold non-fullscreen on view change"), |
547 | &(KOPrefs::instance()->mViewChangeHoldNonFullscreen),topFrame); | 547 | &(KOPrefs::instance()->mViewChangeHoldNonFullscreen),topFrame); |
548 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 548 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
549 | 549 | ||
550 | 550 | ||
551 | 551 | ||
552 | KPrefsDialogWidBool *fullViewMonth = | 552 | KPrefsDialogWidBool *fullViewMonth = |
553 | addWidBool(i18n("Next days view uses full window"), | 553 | addWidBool(i18n("Next days view uses full window"), |
554 | &(KOPrefs::instance()->mFullViewMonth),topFrame); | 554 | &(KOPrefs::instance()->mFullViewMonth),topFrame); |
555 | topLayout->addWidget(fullViewMonth->checkBox(),ii++,0); | 555 | topLayout->addWidget(fullViewMonth->checkBox(),ii++,0); |
556 | 556 | ||
557 | 557 | ||
558 | KPrefsDialogWidBool *fullViewTodo = | 558 | KPrefsDialogWidBool *fullViewTodo = |
559 | addWidBool(i18n("Event list view uses full window"), | 559 | addWidBool(i18n("Event list view uses full window"), |
560 | &(KOPrefs::instance()->mFullViewTodo),topFrame); | 560 | &(KOPrefs::instance()->mFullViewTodo),topFrame); |
561 | topLayout->addWidget(fullViewTodo->checkBox(),ii++,0); | 561 | topLayout->addWidget(fullViewTodo->checkBox(),ii++,0); |
562 | dummy = | 562 | dummy = |
563 | addWidBool(i18n("Listview uses monthly timespan"), | 563 | addWidBool(i18n("Listview uses monthly timespan"), |
564 | &(KOPrefs::instance()->mListViewMonthTimespan),topFrame); | 564 | &(KOPrefs::instance()->mListViewMonthTimespan),topFrame); |
565 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 565 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
566 | dummy = | 566 | dummy = |
567 | addWidBool(i18n("Highlight selection in Time Edit"), | 567 | addWidBool(i18n("Highlight selection in Time Edit"), |
568 | &(KOPrefs::instance()->mHightlightDateTimeEdit),topFrame); | 568 | &(KOPrefs::instance()->mHightlightDateTimeEdit),topFrame); |
569 | topLayout->addWidget( dummy->checkBox(), ii++,0); | 569 | topLayout->addWidget( dummy->checkBox(), ii++,0); |
570 | 570 | ||
571 | KPrefsDialogWidBool *dailyRecur = | 571 | KPrefsDialogWidBool *dailyRecur = |
572 | addWidBool(i18n("Show events that recur daily in date nav."), | 572 | addWidBool(i18n("Show events that recur daily in date nav."), |
573 | &(KOPrefs::instance()->mDailyRecur),topFrame); | 573 | &(KOPrefs::instance()->mDailyRecur),topFrame); |
574 | topLayout->addWidget(dailyRecur->checkBox(),ii++,0); | 574 | topLayout->addWidget(dailyRecur->checkBox(),ii++,0); |
575 | 575 | ||
576 | KPrefsDialogWidBool *weeklyRecur = | 576 | KPrefsDialogWidBool *weeklyRecur = |
577 | addWidBool(i18n("Show ev. that recur weekly in date nav."), | 577 | addWidBool(i18n("Show ev. that recur weekly in date nav."), |
578 | &(KOPrefs::instance()->mWeeklyRecur),topFrame); | 578 | &(KOPrefs::instance()->mWeeklyRecur),topFrame); |
579 | topLayout->addWidget(weeklyRecur->checkBox(),ii++,0); | 579 | topLayout->addWidget(weeklyRecur->checkBox(),ii++,0); |
580 | 580 | ||
581 | weeklyRecur = | ||
582 | addWidBool(i18n("Show multiday allday ev. in date nav."), | ||
583 | &(KOPrefs::instance()->mLongAllday),topFrame); | ||
584 | topLayout->addWidget(weeklyRecur->checkBox(),ii++,0); | ||
585 | |||
581 | #ifdef DESKTOP_VERSION | 586 | #ifdef DESKTOP_VERSION |
582 | KPrefsDialogWidBool *enableToolTips = | 587 | KPrefsDialogWidBool *enableToolTips = |
583 | addWidBool(i18n("Enable tooltips displaying summary of ev."), | 588 | addWidBool(i18n("Enable tooltips displaying summary of ev."), |
584 | &(KOPrefs::instance()->mEnableToolTips),topFrame); | 589 | &(KOPrefs::instance()->mEnableToolTips),topFrame); |
585 | topLayout->addWidget(enableToolTips->checkBox(),ii++,0); | 590 | topLayout->addWidget(enableToolTips->checkBox(),ii++,0); |
586 | #endif | 591 | #endif |
587 | // ********************************************************* | 592 | // ********************************************************* |
588 | 593 | ||
589 | topFrame = addPage(i18n("Agenda View"),0,0); | 594 | topFrame = addPage(i18n("Agenda View"),0,0); |
590 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 595 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
591 | 596 | ||
592 | topLayout = new QGridLayout(topFrame,5,1); | 597 | topLayout = new QGridLayout(topFrame,5,1); |
593 | topLayout->setSpacing(mSpacingHint); | 598 | topLayout->setSpacing(mSpacingHint); |
594 | topLayout->setMargin(mMarginHint); | 599 | topLayout->setMargin(mMarginHint); |
595 | ii = 0; | 600 | ii = 0; |
596 | 601 | ||
597 | 602 | ||
598 | dummy = | 603 | dummy = |
599 | addWidBool(i18n("Show time in agenda items"), | 604 | addWidBool(i18n("Show time in agenda items"), |
600 | &(KOPrefs::instance()->mShowTimeInAgenda),topFrame); | 605 | &(KOPrefs::instance()->mShowTimeInAgenda),topFrame); |
601 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 606 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
602 | 607 | ||
603 | dummy = | 608 | dummy = |
604 | addWidBool(i18n("Highlight current day in agenda"), | 609 | addWidBool(i18n("Highlight current day in agenda"), |
605 | &(KOPrefs::instance()->mHighlightCurrentDay),topFrame); | 610 | &(KOPrefs::instance()->mHighlightCurrentDay),topFrame); |
606 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 611 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
607 | 612 | ||
608 | dummy = | 613 | dummy = |
609 | addWidBool(i18n("Use light color for highlight current day"), | 614 | addWidBool(i18n("Use light color for highlight current day"), |
610 | &(KOPrefs::instance()->mUseHighlightLightColor),topFrame); | 615 | &(KOPrefs::instance()->mUseHighlightLightColor),topFrame); |
611 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 616 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
612 | 617 | ||
613 | 618 | ||
614 | KPrefsDialogWidBool *marcusBainsEnabled = | 619 | KPrefsDialogWidBool *marcusBainsEnabled = |
615 | addWidBool(i18n("Show current time"), | 620 | addWidBool(i18n("Show current time"), |
616 | &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame); | 621 | &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame); |
617 | topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0); | 622 | topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0); |
618 | 623 | ||
619 | 624 | ||
620 | dummy = | 625 | dummy = |
621 | addWidBool(i18n("Set agenda to DayBeginsAt on change"), | 626 | addWidBool(i18n("Set agenda to DayBeginsAt on change"), |
622 | &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame); | 627 | &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame); |
623 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 628 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
624 | 629 | ||
625 | dummy = | 630 | dummy = |
626 | addWidBool(i18n("Set agenda to current time on change"), | 631 | addWidBool(i18n("Set agenda to current time on change"), |
627 | &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame); | 632 | &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame); |
628 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 633 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
629 | 634 | ||
630 | 635 | ||
631 | dummy = | 636 | dummy = |
632 | addWidBool(i18n("Allday Agenda view shows todos"), | 637 | addWidBool(i18n("Allday Agenda view shows todos"), |
633 | &(KOPrefs::instance()->mShowTodoInAgenda),topFrame); | 638 | &(KOPrefs::instance()->mShowTodoInAgenda),topFrame); |
634 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 639 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
635 | 640 | ||
636 | 641 | ||
637 | 642 | ||
638 | dummy = | 643 | dummy = |
639 | addWidBool(i18n("Agenda view shows completed todos"), | 644 | addWidBool(i18n("Agenda view shows completed todos"), |
640 | &(KOPrefs::instance()->mShowCompletedTodoInAgenda),topFrame); | 645 | &(KOPrefs::instance()->mShowCompletedTodoInAgenda),topFrame); |
641 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 646 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
642 | 647 | ||
643 | 648 | ||
644 | 649 | ||
645 | 650 | ||
646 | 651 | ||
647 | topFrame = addPage(i18n("Month View"),0,0); | 652 | topFrame = addPage(i18n("Month View"),0,0); |
648 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 653 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
649 | 654 | ||
650 | topLayout = new QGridLayout(topFrame,5,1); | 655 | topLayout = new QGridLayout(topFrame,5,1); |
651 | topLayout->setSpacing(mSpacingHint); | 656 | topLayout->setSpacing(mSpacingHint); |
652 | topLayout->setMargin(mMarginHint); | 657 | topLayout->setMargin(mMarginHint); |
653 | ii = 0; | 658 | ii = 0; |
654 | QLabel *lab; | 659 | QLabel *lab; |
655 | QHBox *habo = new QHBox( topFrame ); | 660 | QHBox *habo = new QHBox( topFrame ); |
656 | if ( QApplication::desktop()->width() <= 480 ) { | 661 | if ( QApplication::desktop()->width() <= 480 ) { |
657 | lab = new QLabel ( i18n("Show events that recur "), topFrame ); | 662 | lab = new QLabel ( i18n("Show events that recur "), topFrame ); |
658 | topLayout->addMultiCellWidget(lab,ii, ii,0,1); | 663 | topLayout->addMultiCellWidget(lab,ii, ii,0,1); |
659 | ii++; | 664 | ii++; |
660 | } else { | 665 | } else { |
661 | new QLabel ( i18n("Show events that recur "), habo ); | 666 | new QLabel ( i18n("Show events that recur "), habo ); |
662 | } | 667 | } |
663 | dailyRecur = | 668 | dailyRecur = |
664 | addWidBool(i18n("daily"), | 669 | addWidBool(i18n("daily"), |
665 | &(KOPrefs::instance()->mMonthDailyRecur),habo); | 670 | &(KOPrefs::instance()->mMonthDailyRecur),habo); |
666 | // topLayout->addWidget(dailyRecur->checkBox(),ii++,0); | 671 | // topLayout->addWidget(dailyRecur->checkBox(),ii++,0); |
667 | 672 | ||
668 | weeklyRecur = | 673 | weeklyRecur = |
669 | addWidBool(i18n("weekly"), | 674 | addWidBool(i18n("weekly"), |
670 | &(KOPrefs::instance()->mMonthWeeklyRecur),habo); | 675 | &(KOPrefs::instance()->mMonthWeeklyRecur),habo); |
671 | topLayout->addMultiCellWidget(habo,ii, ii,0,1); | 676 | topLayout->addMultiCellWidget(habo,ii, ii,0,1); |
672 | ii++; | 677 | ii++; |
673 | 678 | ||
674 | 679 | ||
675 | habo = new QHBox( topFrame ); | 680 | habo = new QHBox( topFrame ); |
676 | if ( QApplication::desktop()->width() <= 480 ) { | 681 | if ( QApplication::desktop()->width() <= 480 ) { |
677 | lab = new QLabel (i18n("Show in every cell ") , topFrame ); | 682 | lab = new QLabel (i18n("Show in every cell ") , topFrame ); |
678 | topLayout->addMultiCellWidget(lab,ii, ii,0,1); | 683 | topLayout->addMultiCellWidget(lab,ii, ii,0,1); |
679 | ii++; | 684 | ii++; |
680 | 685 | ||
681 | } else { | 686 | } else { |
682 | new QLabel ( i18n("Show in every cell "), habo ); | 687 | new QLabel ( i18n("Show in every cell "), habo ); |
683 | } | 688 | } |
684 | weeklyRecur = | 689 | weeklyRecur = |
685 | addWidBool(i18n("short month"), | 690 | addWidBool(i18n("short month"), |
686 | &(KOPrefs::instance()->mMonthShowShort),habo); | 691 | &(KOPrefs::instance()->mMonthShowShort),habo); |
687 | weeklyRecur = | 692 | weeklyRecur = |
688 | addWidBool(i18n("icons"), | 693 | addWidBool(i18n("icons"), |
689 | &(KOPrefs::instance()->mMonthShowIcons),habo); | 694 | &(KOPrefs::instance()->mMonthShowIcons),habo); |
690 | weeklyRecur = | 695 | weeklyRecur = |
691 | addWidBool(i18n("times"), | 696 | addWidBool(i18n("times"), |
692 | &(KOPrefs::instance()->mMonthShowTimes),habo); | 697 | &(KOPrefs::instance()->mMonthShowTimes),habo); |
693 | topLayout->addMultiCellWidget(habo,ii, ii,0,1); | 698 | topLayout->addMultiCellWidget(habo,ii, ii,0,1); |
694 | ii++; | 699 | ii++; |
695 | #ifdef DESKTOP_VERSION | 700 | #ifdef DESKTOP_VERSION |
696 | KPrefsDialogWidBool *enableMonthScroll = | 701 | KPrefsDialogWidBool *enableMonthScroll = |
697 | addWidBool(i18n("Enable scrollbars in month view cells"), | 702 | addWidBool(i18n("Enable scrollbars in month view cells"), |
698 | &(KOPrefs::instance()->mEnableMonthScroll),topFrame); | 703 | &(KOPrefs::instance()->mEnableMonthScroll),topFrame); |
699 | topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0); | 704 | topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0); |
700 | #endif | 705 | #endif |
701 | dummy = | 706 | dummy = |
702 | addWidBool(i18n("Week view mode uses bigger font"), | 707 | addWidBool(i18n("Week view mode uses bigger font"), |
703 | &(KOPrefs::instance()->mMonthViewUsesBigFont),topFrame); | 708 | &(KOPrefs::instance()->mMonthViewUsesBigFont),topFrame); |
704 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 709 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
705 | dummy = | 710 | dummy = |
706 | addWidBool(i18n("Week view mode uses row layout"), | 711 | addWidBool(i18n("Week view mode uses row layout"), |
707 | &(KOPrefs::instance()->mMonthViewWeekRowlayout),topFrame); | 712 | &(KOPrefs::instance()->mMonthViewWeekRowlayout),topFrame); |
708 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 713 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
709 | dummy = | 714 | dummy = |
710 | addWidBool(i18n("Show Sat/Sun together"), | 715 | addWidBool(i18n("Show Sat/Sun together"), |
711 | &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame); | 716 | &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame); |
712 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 717 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
713 | 718 | ||
714 | KPrefsDialogWidBool *coloredCategoriesInMonthView = | 719 | KPrefsDialogWidBool *coloredCategoriesInMonthView = |
715 | addWidBool(i18n("Month view uses category colors"), | 720 | addWidBool(i18n("Month view uses category colors"), |
716 | &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame); | 721 | &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame); |
717 | topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); | 722 | topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); |
718 | 723 | ||
719 | dummy = | 724 | dummy = |
720 | addWidBool(i18n("Category colors are applied to text"), | 725 | addWidBool(i18n("Category colors are applied to text"), |
721 | &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame); | 726 | &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame); |
722 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 727 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
723 | 728 | ||
724 | 729 | ||
725 | 730 | ||
726 | if ( QApplication::desktop()->height() <= 240 ) { | 731 | if ( QApplication::desktop()->height() <= 240 ) { |
727 | topFrame = addPage(i18n("Month View") +" 2",0,0); | 732 | topFrame = addPage(i18n("Month View") +" 2",0,0); |
728 | topLayout = new QGridLayout(topFrame,4,1); | 733 | topLayout = new QGridLayout(topFrame,4,1); |
729 | topLayout->setSpacing(2); | 734 | topLayout->setSpacing(2); |
730 | topLayout->setMargin(1); | 735 | topLayout->setMargin(1); |
731 | ii = 0; | 736 | ii = 0; |
732 | } | 737 | } |
733 | 738 | ||
734 | 739 | ||
735 | coloredCategoriesInMonthView = | 740 | coloredCategoriesInMonthView = |
736 | addWidBool(i18n("Month view uses day colors"), | 741 | addWidBool(i18n("Month view uses day colors"), |
737 | &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame); | 742 | &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame); |
738 | topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); | 743 | topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); |
739 | 744 | ||
740 | KPrefsDialogWidColor *holidayColor = | 745 | KPrefsDialogWidColor *holidayColor = |
741 | addWidColor(i18n("Day color odd months"), | 746 | addWidColor(i18n("Day color odd months"), |
742 | &(KOPrefs::instance()->mMonthViewOddColor),topFrame); | 747 | &(KOPrefs::instance()->mMonthViewOddColor),topFrame); |
743 | topLayout->addWidget(holidayColor->label(),ii,0); | 748 | topLayout->addWidget(holidayColor->label(),ii,0); |
744 | topLayout->addWidget(holidayColor->button(),ii++,1); | 749 | topLayout->addWidget(holidayColor->button(),ii++,1); |
745 | 750 | ||
746 | holidayColor = | 751 | holidayColor = |
747 | addWidColor(i18n("Day color even months"), | 752 | addWidColor(i18n("Day color even months"), |
748 | &(KOPrefs::instance()->mMonthViewEvenColor),topFrame); | 753 | &(KOPrefs::instance()->mMonthViewEvenColor),topFrame); |
749 | topLayout->addWidget(holidayColor->label(),ii,0); | 754 | topLayout->addWidget(holidayColor->label(),ii,0); |
750 | topLayout->addWidget(holidayColor->button(),ii++,1); | 755 | topLayout->addWidget(holidayColor->button(),ii++,1); |
751 | 756 | ||
752 | 757 | ||
753 | holidayColor = | 758 | holidayColor = |
754 | addWidColor(i18n("Color for Sundays + category \"Holiday\""), | 759 | addWidColor(i18n("Color for Sundays + category \"Holiday\""), |
755 | &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame); | 760 | &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame); |
756 | topLayout->addWidget(holidayColor->label(),ii,0); | 761 | topLayout->addWidget(holidayColor->label(),ii,0); |
757 | topLayout->addWidget(holidayColor->button(),ii++,1); | 762 | topLayout->addWidget(holidayColor->button(),ii++,1); |
758 | // *********************** What'sNext View | 763 | // *********************** What'sNext View |
759 | topFrame = addPage(i18n("What's Next View"),0,0); | 764 | topFrame = addPage(i18n("What's Next View"),0,0); |
760 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 765 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
761 | 766 | ||
762 | topLayout = new QGridLayout(topFrame,4,1); | 767 | topLayout = new QGridLayout(topFrame,4,1); |
763 | topLayout->setSpacing(mSpacingHint); | 768 | topLayout->setSpacing(mSpacingHint); |
764 | topLayout->setMargin(mMarginHint); | 769 | topLayout->setMargin(mMarginHint); |
765 | ii = 0; | 770 | ii = 0; |
766 | 771 | ||
767 | 772 | ||
768 | QHBox* hdummy = new QHBox(topFrame); | 773 | QHBox* hdummy = new QHBox(topFrame); |
769 | new QLabel(i18n("Days in What's Next:"),hdummy); | 774 | new QLabel(i18n("Days in What's Next:"),hdummy); |
770 | mWhatsNextSpin = new QSpinBox(1,14,1,hdummy); | 775 | mWhatsNextSpin = new QSpinBox(1,14,1,hdummy); |
771 | 776 | ||
772 | topLayout->addWidget(hdummy,ii++,0); | 777 | topLayout->addWidget(hdummy,ii++,0); |
773 | 778 | ||
774 | QHBox *prioBox = new QHBox(topFrame); | 779 | QHBox *prioBox = new QHBox(topFrame); |
775 | // intervalBox->setSpacing(mSpacingHint); | 780 | // intervalBox->setSpacing(mSpacingHint); |
776 | topLayout->addWidget(prioBox,ii++,0); | 781 | topLayout->addWidget(prioBox,ii++,0); |
777 | 782 | ||
778 | QLabel *prioLabel = new QLabel(i18n("Number of max.displayed todo prios:"), prioBox); | 783 | QLabel *prioLabel = new QLabel(i18n("Number of max.displayed todo prios:"), prioBox); |
779 | mPrioSpin = new QSpinBox(0,5,1,prioBox); | 784 | mPrioSpin = new QSpinBox(0,5,1,prioBox); |
780 | if ( QApplication::desktop()->width() < 300 ) | 785 | if ( QApplication::desktop()->width() < 300 ) |
781 | mPrioSpin->setFixedWidth( 40 ); | 786 | mPrioSpin->setFixedWidth( 40 ); |
782 | KPrefsDialogWidBool *passwdk = | 787 | KPrefsDialogWidBool *passwdk = |
783 | 788 | ||
784 | addWidBool(i18n("Show times on two lines"), | 789 | addWidBool(i18n("Show times on two lines"), |
785 | &(KOPrefs::instance()->mWhatsNextTime2Lines),topFrame); | 790 | &(KOPrefs::instance()->mWhatsNextTime2Lines),topFrame); |
786 | topLayout->addWidget(passwdk->checkBox(), ii++,0); | 791 | topLayout->addWidget(passwdk->checkBox(), ii++,0); |
787 | passwdk = | 792 | passwdk = |
788 | 793 | ||
789 | addWidBool(i18n("Show events that are done"), | 794 | addWidBool(i18n("Show events that are done"), |
790 | &(KOPrefs::instance()->mWNViewShowsPast),topFrame); | 795 | &(KOPrefs::instance()->mWNViewShowsPast),topFrame); |
791 | topLayout->addWidget(passwdk->checkBox(), ii++,0); | 796 | topLayout->addWidget(passwdk->checkBox(), ii++,0); |
792 | passwdk = | 797 | passwdk = |
793 | addWidBool(i18n("Show parent To-Do's"), | 798 | addWidBool(i18n("Show parent To-Do's"), |
794 | &(KOPrefs::instance()->mWNViewShowsParents),topFrame); | 799 | &(KOPrefs::instance()->mWNViewShowsParents),topFrame); |
795 | topLayout->addWidget(passwdk->checkBox(), ii++,0); | 800 | topLayout->addWidget(passwdk->checkBox(), ii++,0); |
796 | 801 | ||
797 | passwdk = | 802 | passwdk = |
798 | addWidBool(i18n("Show location"), | 803 | addWidBool(i18n("Show location"), |
799 | &(KOPrefs::instance()->mWNViewShowLocation),topFrame); | 804 | &(KOPrefs::instance()->mWNViewShowLocation),topFrame); |
800 | topLayout->addWidget(passwdk->checkBox(), ii++,0); | 805 | topLayout->addWidget(passwdk->checkBox(), ii++,0); |
801 | 806 | ||
802 | 807 | ||
803 | passwdk = | 808 | passwdk = |
804 | addWidBool(i18n("Use short date in WN+Event view"), | 809 | addWidBool(i18n("Use short date in WN+Event view"), |
805 | &(KOPrefs::instance()->mShortDateInViewer),topFrame); | 810 | &(KOPrefs::instance()->mShortDateInViewer),topFrame); |
806 | topLayout->addWidget(passwdk->checkBox(), ii++,0); | 811 | topLayout->addWidget(passwdk->checkBox(), ii++,0); |
807 | 812 | ||
808 | 813 | ||
809 | 814 | ||
810 | 815 | ||
811 | // *********************** Todo View | 816 | // *********************** Todo View |
812 | 817 | ||
813 | topFrame = addPage(i18n("Todo View"),0,0); | 818 | topFrame = addPage(i18n("Todo View"),0,0); |
814 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 819 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
815 | 820 | ||
816 | topLayout = new QGridLayout(topFrame,4,1); | 821 | topLayout = new QGridLayout(topFrame,4,1); |
817 | topLayout->setSpacing(mSpacingHint); | 822 | topLayout->setSpacing(mSpacingHint); |
818 | topLayout->setMargin(mMarginHint); | 823 | topLayout->setMargin(mMarginHint); |
819 | ii = 0; | 824 | ii = 0; |
820 | dummy = | 825 | dummy = |
821 | addWidBool(i18n("Hide not running Todos in To-do view"), | 826 | addWidBool(i18n("Hide not running Todos in To-do view"), |
822 | &(KOPrefs::instance()->mHideNonStartedTodos),topFrame); | 827 | &(KOPrefs::instance()->mHideNonStartedTodos),topFrame); |
823 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 828 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
824 | 829 | ||
825 | 830 | ||
826 | KPrefsDialogWidBool *showCompletedTodo = | 831 | KPrefsDialogWidBool *showCompletedTodo = |
827 | addWidBool(i18n("To-do view shows completed Todos"), | 832 | addWidBool(i18n("To-do view shows completed Todos"), |
828 | &(KOPrefs::instance()->mShowCompletedTodo),topFrame); | 833 | &(KOPrefs::instance()->mShowCompletedTodo),topFrame); |
829 | topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0); | 834 | topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0); |
830 | dummy = | 835 | dummy = |
831 | addWidBool(i18n("To-do view shows complete as 'xx %'"), | 836 | addWidBool(i18n("To-do view shows complete as 'xx %'"), |
832 | &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame); | 837 | &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame); |
833 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 838 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
834 | 839 | ||
835 | dummy = | 840 | dummy = |
836 | addWidBool(i18n("Small To-do view uses smaller font"), | 841 | addWidBool(i18n("Small To-do view uses smaller font"), |
837 | &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame); | 842 | &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame); |
838 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 843 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
839 | 844 | ||
840 | 845 | ||
841 | 846 | ||
842 | dummy = | 847 | dummy = |
843 | addWidBool(i18n("Todo view uses category colors"), | 848 | addWidBool(i18n("Todo view uses category colors"), |
844 | &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame); | 849 | &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame); |
845 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 850 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
846 | 851 | ||
847 | 852 | ||
848 | QWidget* wid = new QWidget( topFrame ); | 853 | QWidget* wid = new QWidget( topFrame ); |
849 | // Todo run today color | 854 | // Todo run today color |
850 | KPrefsDialogWidColor *todoRunColor = | 855 | KPrefsDialogWidColor *todoRunColor = |
851 | addWidColor(i18n("Color for running todos:"), | 856 | addWidColor(i18n("Color for running todos:"), |
852 | &(KOPrefs::instance()->mTodoRunColor),wid); | 857 | &(KOPrefs::instance()->mTodoRunColor),wid); |
853 | QHBoxLayout *widLayout = new QHBoxLayout(wid); | 858 | QHBoxLayout *widLayout = new QHBoxLayout(wid); |
854 | widLayout->addWidget( todoRunColor->label() ); | 859 | widLayout->addWidget( todoRunColor->label() ); |
855 | widLayout->addWidget( todoRunColor->button() ); | 860 | widLayout->addWidget( todoRunColor->button() ); |
856 | topLayout->addWidget(wid,ii++,0); | 861 | topLayout->addWidget(wid,ii++,0); |
857 | 862 | ||
858 | wid = new QWidget( topFrame ); | 863 | wid = new QWidget( topFrame ); |
859 | // Todo due today color | 864 | // Todo due today color |
860 | KPrefsDialogWidColor *todoDueTodayColor = | 865 | KPrefsDialogWidColor *todoDueTodayColor = |
861 | addWidColor(i18n("Todo due today color:"), | 866 | addWidColor(i18n("Todo due today color:"), |
862 | &(KOPrefs::instance()->mTodoDueTodayColor),wid); | 867 | &(KOPrefs::instance()->mTodoDueTodayColor),wid); |
863 | widLayout = new QHBoxLayout(wid); | 868 | widLayout = new QHBoxLayout(wid); |
864 | widLayout->addWidget( todoDueTodayColor->label() ); | 869 | widLayout->addWidget( todoDueTodayColor->label() ); |
865 | widLayout->addWidget( todoDueTodayColor->button() ); | 870 | widLayout->addWidget( todoDueTodayColor->button() ); |
866 | topLayout->addWidget(wid,ii++,0); | 871 | topLayout->addWidget(wid,ii++,0); |
867 | //topLayout->addWidget(todoDueTodayColor->button(),ii++,1); | 872 | //topLayout->addWidget(todoDueTodayColor->button(),ii++,1); |
868 | 873 | ||
869 | // Todo overdue color | 874 | // Todo overdue color |
870 | wid = new QWidget( topFrame ); | 875 | wid = new QWidget( topFrame ); |
871 | widLayout = new QHBoxLayout(wid); | 876 | widLayout = new QHBoxLayout(wid); |
872 | KPrefsDialogWidColor *todoOverdueColor = | 877 | KPrefsDialogWidColor *todoOverdueColor = |
873 | addWidColor(i18n("Todo overdue color:"), | 878 | addWidColor(i18n("Todo overdue color:"), |
874 | &(KOPrefs::instance()->mTodoOverdueColor),wid); | 879 | &(KOPrefs::instance()->mTodoOverdueColor),wid); |
875 | widLayout->addWidget(todoOverdueColor->label()); | 880 | widLayout->addWidget(todoOverdueColor->label()); |
876 | widLayout->addWidget(todoOverdueColor->button()); | 881 | widLayout->addWidget(todoOverdueColor->button()); |
877 | topLayout->addWidget(wid,ii++,0); | 882 | topLayout->addWidget(wid,ii++,0); |
878 | 883 | ||
879 | dummy = | 884 | dummy = |
880 | addWidBool(i18n("Colors are applied to text"), | 885 | addWidBool(i18n("Colors are applied to text"), |
881 | &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame); | 886 | &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame); |
882 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 887 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
883 | 888 | ||
884 | 889 | ||
885 | 890 | ||
886 | topFrame = addPage(i18n("View Options"),0,0); | 891 | topFrame = addPage(i18n("View Options"),0,0); |
887 | 892 | ||
888 | topLayout = new QGridLayout(topFrame,4,1); | 893 | topLayout = new QGridLayout(topFrame,4,1); |
889 | topLayout->setSpacing(mSpacingHint); | 894 | topLayout->setSpacing(mSpacingHint); |
890 | topLayout->setMargin(mMarginHint); | 895 | topLayout->setMargin(mMarginHint); |
891 | ii = 0; | 896 | ii = 0; |
892 | 897 | ||
893 | dummy = | 898 | dummy = |
894 | addWidBool(i18n("Show Sync Events"), | 899 | addWidBool(i18n("Show Sync Events"), |
895 | &(KOPrefs::instance()->mShowSyncEvents),topFrame); | 900 | &(KOPrefs::instance()->mShowSyncEvents),topFrame); |
896 | topLayout->addWidget(dummy->checkBox(), ii++,0); | 901 | topLayout->addWidget(dummy->checkBox(), ii++,0); |
897 | 902 | ||
898 | lab = new QLabel( i18n("Show in todo/event viewer:"), topFrame); | 903 | lab = new QLabel( i18n("Show in todo/event viewer:"), topFrame); |
899 | topLayout->addWidget(lab ,ii++,0); | 904 | topLayout->addWidget(lab ,ii++,0); |
900 | 905 | ||
901 | dummy = addWidBool(i18n("Details"), | 906 | dummy = addWidBool(i18n("Details"), |
902 | &(KOPrefs::instance()->mEVshowDetails),topFrame); | 907 | &(KOPrefs::instance()->mEVshowDetails),topFrame); |
903 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 908 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
904 | dummy = addWidBool(i18n("Created time"), | 909 | dummy = addWidBool(i18n("Created time"), |
905 | &(KOPrefs::instance()->mEVshowCreated),topFrame); | 910 | &(KOPrefs::instance()->mEVshowCreated),topFrame); |
906 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 911 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
907 | dummy = addWidBool(i18n("Last modified time"), | 912 | dummy = addWidBool(i18n("Last modified time"), |
908 | &(KOPrefs::instance()->mEVshowChanged),topFrame); | 913 | &(KOPrefs::instance()->mEVshowChanged),topFrame); |
909 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 914 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
910 | 915 | ||
911 | 916 | ||
912 | lab = new QLabel( i18n("Show in What'sThis quick overview:"), topFrame); | 917 | lab = new QLabel( i18n("Show in What'sThis quick overview:"), topFrame); |
913 | topLayout->addWidget(lab ,ii++,0); | 918 | topLayout->addWidget(lab ,ii++,0); |
914 | 919 | ||
915 | dummy = addWidBool(i18n("Details"), | 920 | dummy = addWidBool(i18n("Details"), |
916 | &(KOPrefs::instance()->mWTshowDetails),topFrame); | 921 | &(KOPrefs::instance()->mWTshowDetails),topFrame); |
917 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 922 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
918 | dummy = addWidBool(i18n("Created time"), | 923 | dummy = addWidBool(i18n("Created time"), |
919 | &(KOPrefs::instance()->mWTshowCreated),topFrame); | 924 | &(KOPrefs::instance()->mWTshowCreated),topFrame); |
920 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 925 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
921 | dummy = addWidBool(i18n("Last modified time"), | 926 | dummy = addWidBool(i18n("Last modified time"), |
922 | &(KOPrefs::instance()->mWTshowChanged),topFrame); | 927 | &(KOPrefs::instance()->mWTshowChanged),topFrame); |
923 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 928 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
924 | 929 | ||
925 | topFrame = addPage(i18n("Conflict detection"),0,0); | 930 | topFrame = addPage(i18n("Conflict detection"),0,0); |
926 | 931 | ||
927 | topLayout = new QGridLayout(topFrame,2,1); | 932 | topLayout = new QGridLayout(topFrame,2,1); |
928 | topLayout->setSpacing(mSpacingHint); | 933 | topLayout->setSpacing(mSpacingHint); |
929 | topLayout->setMargin(mMarginHint); | 934 | topLayout->setMargin(mMarginHint); |
930 | ii = 0; | 935 | ii = 0; |
931 | dummy = addWidBool(i18n("Enable conflict detection"), | 936 | dummy = addWidBool(i18n("Enable conflict detection"), |
932 | &(KOPrefs::instance()->mDetectConflicts),topFrame); | 937 | &(KOPrefs::instance()->mDetectConflicts),topFrame); |
933 | topLayout->addWidget(dummy->checkBox(), ii++,0); | 938 | topLayout->addWidget(dummy->checkBox(), ii++,0); |
934 | topFrame = new QFrame( topFrame ); | 939 | topFrame = new QFrame( topFrame ); |
935 | topLayout->addWidget(topFrame ,ii++,0); | 940 | topLayout->addWidget(topFrame ,ii++,0); |
936 | topLayout = new QGridLayout(topFrame,4,1); | 941 | topLayout = new QGridLayout(topFrame,4,1); |
937 | connect ( dummy->checkBox(), SIGNAL( toggled( bool ) ), topFrame, SLOT ( setEnabled( bool ) ) ); | 942 | connect ( dummy->checkBox(), SIGNAL( toggled( bool ) ), topFrame, SLOT ( setEnabled( bool ) ) ); |
938 | topLayout->addWidget( new QLabel ( i18n("Conflict detection checks an <b>edited event</b> with other <b>existing events</b> for overlapping. You can define which events are checked:"), topFrame ) , ii++,0); | 943 | dummy = addWidBool(i18n("Include events which \"show as free\""), |
944 | &(KOPrefs::instance()->mIncludeFree),topFrame); | ||
945 | topLayout->addWidget(dummy->checkBox(), ii++,0); | ||
946 | topLayout->addWidget( new QLabel ( i18n("Conflict detection checks an <b>edited event</b> with <b>other events</b> for overlapping."), topFrame ) , ii++,0); | ||
947 | |||
939 | topLayout->addWidget( new QLabel ( i18n("Filter for the edited event"), topFrame ) , ii++,0); | 948 | topLayout->addWidget( new QLabel ( i18n("Filter for the edited event"), topFrame ) , ii++,0); |
940 | mFilterEditItem = new QComboBox( topFrame ); | 949 | mFilterEditItem = new QComboBox( topFrame ); |
941 | topLayout->addWidget(mFilterEditItem,ii++,0); | 950 | topLayout->addWidget(mFilterEditItem,ii++,0); |
942 | topLayout->addWidget( new QLabel ( i18n("Filter for other existing events"), topFrame ) , ii++,0); | 951 | topLayout->addWidget( new QLabel ( i18n("Filter for other events"), topFrame ) , ii++,0); |
943 | mFilterAllItem = new QComboBox( topFrame ); | 952 | mFilterAllItem = new QComboBox( topFrame ); |
944 | topLayout->addWidget(mFilterAllItem,ii++,0); | 953 | topLayout->addWidget(mFilterAllItem,ii++,0); |
945 | dummy = addWidBool(i18n("Check Allday with Allday"), | 954 | dummy = addWidBool(i18n("Check Allday with Allday"), |
946 | &(KOPrefs::instance()->mCheckConflictsAllDayAllDay),topFrame); | 955 | &(KOPrefs::instance()->mCheckConflictsAllDayAllDay),topFrame); |
947 | topLayout->addWidget(dummy->checkBox(), ii++,0); | 956 | topLayout->addWidget(dummy->checkBox(), ii++,0); |
948 | dummy = addWidBool(i18n("Check Allday with NonAllday"), | 957 | dummy = addWidBool(i18n("Check Allday with NonAllday"), |
949 | &(KOPrefs::instance()->mCheckConflictsAllDayNonAD),topFrame); | 958 | &(KOPrefs::instance()->mCheckConflictsAllDayNonAD),topFrame); |
950 | topLayout->addWidget(dummy->checkBox(), ii++,0); | 959 | topLayout->addWidget(dummy->checkBox(), ii++,0); |
951 | dummy = addWidBool(i18n("Check NonAllday with Allday"), | 960 | dummy = addWidBool(i18n("Check NonAllday with Allday"), |
952 | &(KOPrefs::instance()->mCheckConflictsNonADAllDay),topFrame); | 961 | &(KOPrefs::instance()->mCheckConflictsNonADAllDay),topFrame); |
953 | topLayout->addWidget(dummy->checkBox(), ii++,0); | 962 | topLayout->addWidget(dummy->checkBox(), ii++,0); |
954 | dummy = addWidBool(i18n("Check NonAllday with NonAllday"), | 963 | dummy = addWidBool(i18n("Check NonAllday with NonAllday"), |
955 | &(KOPrefs::instance()->mCheckConflictsNonADNonAD),topFrame); | 964 | &(KOPrefs::instance()->mCheckConflictsNonADNonAD),topFrame); |
956 | topLayout->addWidget(dummy->checkBox(), ii++,0); | 965 | topLayout->addWidget(dummy->checkBox(), ii++,0); |
957 | 966 | ||
958 | 967 | ||
959 | 968 | ||
960 | 969 | ||
961 | topFrame = addPage(i18n("Alarm"),0,0); | 970 | topFrame = addPage(i18n("Alarm"),0,0); |
962 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 971 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
963 | 972 | ||
964 | topLayout = new QGridLayout(topFrame,2,1); | 973 | topLayout = new QGridLayout(topFrame,2,1); |
965 | topLayout->setSpacing(mSpacingHint); | 974 | topLayout->setSpacing(mSpacingHint); |
966 | topLayout->setMargin(mMarginHint); | 975 | topLayout->setMargin(mMarginHint); |
967 | int iii = 0; | 976 | int iii = 0; |
968 | 977 | ||
969 | dummy = | 978 | dummy = |
970 | addWidBool(i18n("Use internal alarm notification"), | 979 | addWidBool(i18n("Use internal alarm notification"), |
971 | &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame); | 980 | &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame); |
972 | topLayout->addWidget(dummy->checkBox(),iii++,0); | 981 | topLayout->addWidget(dummy->checkBox(),iii++,0); |
973 | 982 | ||
974 | if ( QApplication::desktop()->height() > 240 ) { | 983 | if ( QApplication::desktop()->height() > 240 ) { |
975 | 984 | ||
976 | lab = new QLabel( i18n("Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n"), topFrame); | 985 | lab = new QLabel( i18n("Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n"), topFrame); |
977 | 986 | ||
978 | topLayout->addWidget(lab ,iii++,0); | 987 | topLayout->addWidget(lab ,iii++,0); |
979 | } | 988 | } |
980 | #ifndef DESKTOP_VERSION | 989 | #ifndef DESKTOP_VERSION |
981 | lab->setAlignment( AlignLeft|WordBreak|AlignTop); | 990 | lab->setAlignment( AlignLeft|WordBreak|AlignTop); |
982 | #else | 991 | #else |
983 | lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 992 | lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
984 | lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); | 993 | lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); |
985 | #endif | 994 | #endif |
986 | 995 | ||
987 | QHBox* dummyBox = new QHBox(topFrame); | 996 | QHBox* dummyBox = new QHBox(topFrame); |
988 | new QLabel(i18n("Play beeps count:"),dummyBox); | 997 | new QLabel(i18n("Play beeps count:"),dummyBox); |
989 | mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox); | 998 | mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox); |
990 | topLayout->addWidget(dummyBox,iii++,0); | 999 | topLayout->addWidget(dummyBox,iii++,0); |
991 | 1000 | ||
992 | dummyBox = new QHBox(topFrame); | 1001 | dummyBox = new QHBox(topFrame); |
993 | new QLabel(i18n("Beeps interval in sec:"),dummyBox); | 1002 | new QLabel(i18n("Beeps interval in sec:"),dummyBox); |
994 | mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox); | 1003 | mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox); |
995 | topLayout->addWidget(dummyBox,iii++,0); | 1004 | topLayout->addWidget(dummyBox,iii++,0); |
996 | 1005 | ||
997 | dummyBox = new QHBox(topFrame); | 1006 | dummyBox = new QHBox(topFrame); |
998 | new QLabel(i18n("Default suspend time in min:"),dummyBox); | 1007 | new QLabel(i18n("Default suspend time in min:"),dummyBox); |
999 | mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox); | 1008 | mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox); |
1000 | topLayout->addWidget(dummyBox,iii++,0); | 1009 | topLayout->addWidget(dummyBox,iii++,0); |
1001 | 1010 | ||
1002 | dummyBox = new QHBox(topFrame); | 1011 | dummyBox = new QHBox(topFrame); |
1003 | new QLabel(i18n("Auto suspend count:"),dummyBox); | 1012 | new QLabel(i18n("Auto suspend count:"),dummyBox); |
1004 | mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox); | 1013 | mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox); |
1005 | topLayout->addWidget(dummyBox,iii++,0); | 1014 | topLayout->addWidget(dummyBox,iii++,0); |
1006 | 1015 | ||
1007 | 1016 | ||
1008 | 1017 | ||
1009 | QHBox* hbo = new QHBox ( topFrame ); | 1018 | QHBox* hbo = new QHBox ( topFrame ); |
1010 | mDefaultAlarmFile = new QLineEdit(hbo); | 1019 | mDefaultAlarmFile = new QLineEdit(hbo); |
1011 | QPushButton * loadTemplate = new QPushButton(hbo); | 1020 | QPushButton * loadTemplate = new QPushButton(hbo); |
1012 | QPixmap icon; | 1021 | QPixmap icon; |
1013 | if ( QApplication::desktop()->width() < 321 ) | 1022 | if ( QApplication::desktop()->width() < 321 ) |
1014 | icon = SmallIcon("fileimport16"); | 1023 | icon = SmallIcon("fileimport16"); |
1015 | else | 1024 | else |
1016 | icon = SmallIcon("fileimport"); | 1025 | icon = SmallIcon("fileimport"); |
1017 | loadTemplate->setIconSet (icon ) ; | 1026 | loadTemplate->setIconSet (icon ) ; |
1018 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) ); | 1027 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) ); |
1019 | int size = loadTemplate->sizeHint().height(); | 1028 | int size = loadTemplate->sizeHint().height(); |
1020 | loadTemplate->setFixedSize( size, size ); | 1029 | loadTemplate->setFixedSize( size, size ); |
1021 | //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame); | 1030 | //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame); |
1022 | // topLayout->addWidget(lab ,iii++,0); | 1031 | // topLayout->addWidget(lab ,iii++,0); |
1023 | lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame); | 1032 | lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame); |
1024 | topLayout->addWidget(lab ,iii++,0); | 1033 | topLayout->addWidget(lab ,iii++,0); |
1025 | topLayout->addWidget(hbo,iii++,0); | 1034 | topLayout->addWidget(hbo,iii++,0); |
1026 | // lab = new QLabel( i18n("Note: This does not mean, that for every alarm this file is replayed. This file here is associated with a newly created alarm."), topFrame); | 1035 | // lab = new QLabel( i18n("Note: This does not mean, that for every alarm this file is replayed. This file here is associated with a newly created alarm."), topFrame); |
1027 | 1036 | ||
1028 | // topLayout->addWidget(lab ,iii++,0); | 1037 | // topLayout->addWidget(lab ,iii++,0); |
1029 | // #ifndef DESKTOP_VERSION | 1038 | // #ifndef DESKTOP_VERSION |
1030 | // lab->setAlignment( AlignLeft|WordBreak|AlignTop); | 1039 | // lab->setAlignment( AlignLeft|WordBreak|AlignTop); |
1031 | // #else | 1040 | // #else |
1032 | // lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 1041 | // lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
1033 | // lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); | 1042 | // lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); |
1034 | // #endif | 1043 | // #endif |
1035 | 1044 | ||
1036 | 1045 | ||
1037 | } | 1046 | } |
1038 | 1047 | ||
1039 | void KOPrefsDialog::selectSoundFile() | 1048 | void KOPrefsDialog::selectSoundFile() |
1040 | { | 1049 | { |
1041 | QString fileName = mDefaultAlarmFile->text(); | 1050 | QString fileName = mDefaultAlarmFile->text(); |
1042 | fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this ); | 1051 | fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this ); |
1043 | if ( fileName.length() > 0 ) | 1052 | if ( fileName.length() > 0 ) |
1044 | mDefaultAlarmFile->setText( fileName ); | 1053 | mDefaultAlarmFile->setText( fileName ); |
1045 | } | 1054 | } |
1046 | void KOPrefsDialog::setupFontsTab() | 1055 | void KOPrefsDialog::setupFontsTab() |
1047 | { | 1056 | { |
1048 | 1057 | ||
1049 | QFrame *topFrame = addPage(i18n("Fonts"),0,0); | 1058 | QFrame *topFrame = addPage(i18n("Fonts"),0,0); |
1050 | // DesktopIcon("fonts",KIcon::SizeMedium)); | 1059 | // DesktopIcon("fonts",KIcon::SizeMedium)); |
1051 | 1060 | ||
1052 | QGridLayout *topLayout = new QGridLayout(topFrame,7,3); | 1061 | QGridLayout *topLayout = new QGridLayout(topFrame,7,3); |
1053 | topLayout->setSpacing(1); | 1062 | topLayout->setSpacing(1); |
1054 | topLayout->setMargin(3); | 1063 | topLayout->setMargin(3); |
1055 | KPrefsDialogWidFont * tVFont; | 1064 | KPrefsDialogWidFont * tVFont; |
1056 | int i = 0; | 1065 | int i = 0; |
1057 | KPrefsDialogWidFont *timeLabelsFont = | 1066 | KPrefsDialogWidFont *timeLabelsFont = |
1058 | addWidFont(i18n("23"),i18n("DateNavigator:(nr)"), | 1067 | addWidFont(i18n("23"),i18n("DateNavigator:(nr)"), |
1059 | &(KOPrefs::instance()->mDateNavigatorFont),topFrame); | 1068 | &(KOPrefs::instance()->mDateNavigatorFont),topFrame); |
1060 | topLayout->addWidget(timeLabelsFont->label(),i,0); | 1069 | topLayout->addWidget(timeLabelsFont->label(),i,0); |
1061 | topLayout->addWidget(timeLabelsFont->preview(),i,1); | 1070 | topLayout->addWidget(timeLabelsFont->preview(),i,1); |
1062 | topLayout->addWidget(timeLabelsFont->button(),i,2); | 1071 | topLayout->addWidget(timeLabelsFont->button(),i,2); |
1063 | ++i; | 1072 | ++i; |
1064 | 1073 | ||
1065 | 1074 | ||
1066 | timeLabelsFont = | 1075 | timeLabelsFont = |
1067 | addWidFont(i18n("Mon 15"),i18n("Date Labels:"), | 1076 | addWidFont(i18n("Mon 15"),i18n("Date Labels:"), |
1068 | &(KOPrefs::instance()->mTimeLabelsFont),topFrame); | 1077 | &(KOPrefs::instance()->mTimeLabelsFont),topFrame); |
1069 | topLayout->addWidget(timeLabelsFont->label(),i,0); | 1078 | topLayout->addWidget(timeLabelsFont->label(),i,0); |
1070 | topLayout->addWidget(timeLabelsFont->preview(),i,1); | 1079 | topLayout->addWidget(timeLabelsFont->preview(),i,1); |
1071 | topLayout->addWidget(timeLabelsFont->button(),i,2); | 1080 | topLayout->addWidget(timeLabelsFont->button(),i,2); |
1072 | ++i; | 1081 | ++i; |
1073 | 1082 | ||
1074 | KPrefsDialogWidFont *timeBarFont = | 1083 | KPrefsDialogWidFont *timeBarFont = |
1075 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"), | 1084 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"), |
1076 | &(KOPrefs::instance()->mTimeBarFont),topFrame); | 1085 | &(KOPrefs::instance()->mTimeBarFont),topFrame); |
1077 | topLayout->addWidget(timeBarFont->label(),i,0); | 1086 | topLayout->addWidget(timeBarFont->label(),i,0); |
1078 | topLayout->addWidget(timeBarFont->preview(),i,1); | 1087 | topLayout->addWidget(timeBarFont->preview(),i,1); |
1079 | topLayout->addWidget(timeBarFont->button(),i,2); | 1088 | topLayout->addWidget(timeBarFont->button(),i,2); |
1080 | ++i; | 1089 | ++i; |
1081 | 1090 | ||
1082 | 1091 | ||
1083 | KPrefsDialogWidFont *marcusBainsFont = | 1092 | KPrefsDialogWidFont *marcusBainsFont = |
1084 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"), | 1093 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"), |
1085 | &(KOPrefs::instance()->mMarcusBainsFont),topFrame); | 1094 | &(KOPrefs::instance()->mMarcusBainsFont),topFrame); |
1086 | topLayout->addWidget(marcusBainsFont->label(),i,0); | 1095 | topLayout->addWidget(marcusBainsFont->label(),i,0); |
1087 | topLayout->addWidget(marcusBainsFont->preview(),i,1); | 1096 | topLayout->addWidget(marcusBainsFont->preview(),i,1); |
1088 | topLayout->addWidget(marcusBainsFont->button(),i,2); | 1097 | topLayout->addWidget(marcusBainsFont->button(),i,2); |
1089 | ++i; | 1098 | ++i; |
1090 | 1099 | ||
1091 | tVFont = | 1100 | tVFont = |
1092 | addWidFont(i18n("Summary"),i18n("Event Viewer:"), | 1101 | addWidFont(i18n("Summary"),i18n("Event Viewer:"), |
1093 | &(KOPrefs::instance()->mEventViewFont),topFrame); | 1102 | &(KOPrefs::instance()->mEventViewFont),topFrame); |
1094 | topLayout->addWidget(tVFont->label(),i,0); | 1103 | topLayout->addWidget(tVFont->label(),i,0); |
1095 | topLayout->addWidget(tVFont->preview(),i,1); | 1104 | topLayout->addWidget(tVFont->preview(),i,1); |
1096 | topLayout->addWidget(tVFont->button(),i,2); | 1105 | topLayout->addWidget(tVFont->button(),i,2); |
1097 | ++i; | 1106 | ++i; |
1098 | 1107 | ||
1099 | 1108 | ||
1100 | 1109 | ||
1101 | tVFont = | 1110 | tVFont = |
1102 | addWidFont(i18n("Details"),i18n("EditorBox:"), | 1111 | addWidFont(i18n("Details"),i18n("EditorBox:"), |
1103 | &(KOPrefs::instance()->mEditBoxFont),topFrame); | 1112 | &(KOPrefs::instance()->mEditBoxFont),topFrame); |
1104 | topLayout->addWidget(tVFont->label(),i,0); | 1113 | topLayout->addWidget(tVFont->label(),i,0); |
1105 | topLayout->addWidget(tVFont->preview(),i,1); | 1114 | topLayout->addWidget(tVFont->preview(),i,1); |
1106 | topLayout->addWidget(tVFont->button(),i,2); | 1115 | topLayout->addWidget(tVFont->button(),i,2); |
1107 | ++i; | 1116 | ++i; |
1108 | 1117 | ||
1109 | 1118 | ||
1110 | 1119 | ||
1111 | topLayout->setColStretch(1,1); | 1120 | topLayout->setColStretch(1,1); |
1112 | topLayout->setRowStretch(4,1); | 1121 | topLayout->setRowStretch(4,1); |
1113 | 1122 | ||
1114 | 1123 | ||
1115 | i = 0; | 1124 | i = 0; |
1116 | topFrame = addPage(i18n("View Fonts"),0, | 1125 | topFrame = addPage(i18n("View Fonts"),0, |
1117 | DesktopIcon("fonts",KIcon::SizeMedium)); | 1126 | DesktopIcon("fonts",KIcon::SizeMedium)); |
1118 | 1127 | ||
1119 | topLayout = new QGridLayout(topFrame,7,3); | 1128 | topLayout = new QGridLayout(topFrame,7,3); |
1120 | topLayout->setSpacing(1); | 1129 | topLayout->setSpacing(1); |
1121 | topLayout->setMargin(3); | 1130 | topLayout->setMargin(3); |
1122 | 1131 | ||
1123 | tVFont = | 1132 | tVFont = |
1124 | addWidFont(i18n("Configure KO"),i18n("What's Next View:"), | 1133 | addWidFont(i18n("Configure KO"),i18n("What's Next View:"), |
1125 | &(KOPrefs::instance()->mWhatsNextFont),topFrame); | 1134 | &(KOPrefs::instance()->mWhatsNextFont),topFrame); |
1126 | topLayout->addWidget(tVFont->label(),i,0); | 1135 | topLayout->addWidget(tVFont->label(),i,0); |
1127 | topLayout->addWidget(tVFont->preview(),i,1); | 1136 | topLayout->addWidget(tVFont->preview(),i,1); |
1128 | topLayout->addWidget(tVFont->button(),i,2); | 1137 | topLayout->addWidget(tVFont->button(),i,2); |
1129 | ++i; | 1138 | ++i; |
1130 | KPrefsDialogWidFont *agendaViewFont = | 1139 | KPrefsDialogWidFont *agendaViewFont = |
1131 | addWidFont(i18n("Event text"),i18n("Agenda view:"), | 1140 | addWidFont(i18n("Event text"),i18n("Agenda view:"), |
1132 | &(KOPrefs::instance()->mAgendaViewFont),topFrame); | 1141 | &(KOPrefs::instance()->mAgendaViewFont),topFrame); |
1133 | topLayout->addWidget(agendaViewFont->label(),i,0); | 1142 | topLayout->addWidget(agendaViewFont->label(),i,0); |
1134 | topLayout->addWidget(agendaViewFont->preview(),i,1); | 1143 | topLayout->addWidget(agendaViewFont->preview(),i,1); |
1135 | topLayout->addWidget(agendaViewFont->button(),i,2); | 1144 | topLayout->addWidget(agendaViewFont->button(),i,2); |
1136 | ++i; | 1145 | ++i; |
1137 | 1146 | ||
1138 | 1147 | ||
1139 | KPrefsDialogWidFont *monthViewFont = | 1148 | KPrefsDialogWidFont *monthViewFont = |
1140 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"), | 1149 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"), |
1141 | i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame); | 1150 | i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame); |
1142 | topLayout->addWidget(monthViewFont->label(),i,0); | 1151 | topLayout->addWidget(monthViewFont->label(),i,0); |
1143 | topLayout->addWidget(monthViewFont->preview(),i,1); | 1152 | topLayout->addWidget(monthViewFont->preview(),i,1); |
1144 | topLayout->addWidget(monthViewFont->button(),i,2); | 1153 | topLayout->addWidget(monthViewFont->button(),i,2); |
1145 | ++i; | 1154 | ++i; |
1146 | 1155 | ||
1147 | 1156 | ||
1148 | KPrefsDialogWidFont *lVFont = | 1157 | KPrefsDialogWidFont *lVFont = |
1149 | addWidFont(i18n("Event"),i18n("List View:"), | 1158 | addWidFont(i18n("Event"),i18n("List View:"), |
1150 | &(KOPrefs::instance()->mListViewFont),topFrame); | 1159 | &(KOPrefs::instance()->mListViewFont),topFrame); |
1151 | topLayout->addWidget(lVFont->label(),i,0); | 1160 | topLayout->addWidget(lVFont->label(),i,0); |
1152 | topLayout->addWidget(lVFont->preview(),i,1); | 1161 | topLayout->addWidget(lVFont->preview(),i,1); |
1153 | topLayout->addWidget(lVFont->button(),i,2); | 1162 | topLayout->addWidget(lVFont->button(),i,2); |
1154 | ++i; | 1163 | ++i; |
1155 | 1164 | ||
1156 | 1165 | ||
1157 | tVFont = | 1166 | tVFont = |
1158 | addWidFont(i18n("ToDo"),i18n("ToDoView:"), | 1167 | addWidFont(i18n("ToDo"),i18n("ToDoView:"), |
1159 | &(KOPrefs::instance()->mTodoViewFont),topFrame); | 1168 | &(KOPrefs::instance()->mTodoViewFont),topFrame); |
1160 | topLayout->addWidget(tVFont->label(),i,0); | 1169 | topLayout->addWidget(tVFont->label(),i,0); |
1161 | topLayout->addWidget(tVFont->preview(),i,1); | 1170 | topLayout->addWidget(tVFont->preview(),i,1); |
1162 | topLayout->addWidget(tVFont->button(),i,2); | 1171 | topLayout->addWidget(tVFont->button(),i,2); |
1163 | ++i; | 1172 | ++i; |
1164 | 1173 | ||
1165 | 1174 | ||
1166 | tVFont = | 1175 | tVFont = |
1167 | addWidFont(i18n("Today"),i18n("JournalView:"), | 1176 | addWidFont(i18n("Today"),i18n("JournalView:"), |
1168 | &(KOPrefs::instance()->mJornalViewFont),topFrame); | 1177 | &(KOPrefs::instance()->mJornalViewFont),topFrame); |
1169 | topLayout->addWidget(tVFont->label(),i,0); | 1178 | topLayout->addWidget(tVFont->label(),i,0); |
1170 | topLayout->addWidget(tVFont->preview(),i,1); | 1179 | topLayout->addWidget(tVFont->preview(),i,1); |
1171 | topLayout->addWidget(tVFont->button(),i,2); | 1180 | topLayout->addWidget(tVFont->button(),i,2); |
1172 | ++i; | 1181 | ++i; |
1173 | 1182 | ||
1174 | 1183 | ||
1175 | 1184 | ||
1176 | 1185 | ||
1177 | topLayout->setColStretch(1,1); | 1186 | topLayout->setColStretch(1,1); |
1178 | topLayout->setRowStretch(4,1); | 1187 | topLayout->setRowStretch(4,1); |
1179 | 1188 | ||
1180 | 1189 | ||
1181 | 1190 | ||
1182 | 1191 | ||
1183 | } | 1192 | } |
1184 | 1193 | ||
1185 | void KOPrefsDialog::setupColorsTab() | 1194 | void KOPrefsDialog::setupColorsTab() |
1186 | { | 1195 | { |
1187 | QFrame *topFrame = addPage(i18n("Colors"),0,0); | 1196 | QFrame *topFrame = addPage(i18n("Colors"),0,0); |
1188 | // DesktopIcon("colorize",KIcon::SizeMedium)); | 1197 | // DesktopIcon("colorize",KIcon::SizeMedium)); |
1189 | 1198 | ||
1190 | QGridLayout *topLayout = new QGridLayout(topFrame,5,2); | 1199 | QGridLayout *topLayout = new QGridLayout(topFrame,5,2); |
1191 | // topLayout->setSpacing(mSpacingHint); | 1200 | // topLayout->setSpacing(mSpacingHint); |
1192 | // topLayout->setMargin(mMarginHint); | 1201 | // topLayout->setMargin(mMarginHint); |
1193 | 1202 | ||
1194 | topLayout->setSpacing(2); | 1203 | topLayout->setSpacing(2); |
1195 | topLayout->setMargin(3); | 1204 | topLayout->setMargin(3); |
1196 | 1205 | ||
1197 | int ii = 1; | 1206 | int ii = 1; |
1198 | QGroupBox *categoryGroup ; | 1207 | QGroupBox *categoryGroup ; |
1199 | 1208 | ||
1200 | categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"), | 1209 | categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"), |
1201 | topFrame); | 1210 | topFrame); |
1202 | topLayout->addMultiCellWidget(categoryGroup,0,0,0,1); | 1211 | topLayout->addMultiCellWidget(categoryGroup,0,0,0,1); |
1203 | 1212 | ||
1204 | mCategoryCombo = new QComboBox(categoryGroup); | 1213 | mCategoryCombo = new QComboBox(categoryGroup); |
1205 | mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); | 1214 | mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); |
1206 | connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); | 1215 | connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); |
1207 | 1216 | ||
1208 | mCategoryButton = new KColorButton(categoryGroup); | 1217 | mCategoryButton = new KColorButton(categoryGroup); |
1209 | connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor())); | 1218 | connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor())); |
1210 | updateCategoryColor(); | 1219 | updateCategoryColor(); |
1211 | 1220 | ||
1212 | 1221 | ||
1213 | // Holiday Color | 1222 | // Holiday Color |
1214 | 1223 | ||
1215 | KPrefsDialogWidColor *holidayColor = | 1224 | KPrefsDialogWidColor *holidayColor = |
1216 | addWidColor(i18n("Holiday color:"), | 1225 | addWidColor(i18n("Holiday color:"), |
1217 | &(KOPrefs::instance()->mHolidayColor),topFrame); | 1226 | &(KOPrefs::instance()->mHolidayColor),topFrame); |
1218 | topLayout->addWidget(holidayColor->label(),ii,0); | 1227 | topLayout->addWidget(holidayColor->label(),ii,0); |
1219 | topLayout->addWidget(holidayColor->button(),ii++,1); | 1228 | topLayout->addWidget(holidayColor->button(),ii++,1); |
1220 | 1229 | ||
1221 | // Highlight Color | 1230 | // Highlight Color |
1222 | KPrefsDialogWidColor *highlightColor = | 1231 | KPrefsDialogWidColor *highlightColor = |
1223 | addWidColor(i18n("Highlight color:"), | 1232 | addWidColor(i18n("Highlight color:"), |
1224 | &(KOPrefs::instance()->mHighlightColor),topFrame); | 1233 | &(KOPrefs::instance()->mHighlightColor),topFrame); |
1225 | topLayout->addWidget(highlightColor->label(),ii,0); | 1234 | topLayout->addWidget(highlightColor->label(),ii,0); |
1226 | topLayout->addWidget(highlightColor->button(),ii++,1); | 1235 | topLayout->addWidget(highlightColor->button(),ii++,1); |
1227 | 1236 | ||
1228 | // Event color | 1237 | // Event color |
1229 | KPrefsDialogWidColor *eventColor = | 1238 | KPrefsDialogWidColor *eventColor = |
1230 | addWidColor(i18n("Default event color:"), | 1239 | addWidColor(i18n("Default event color:"), |
1231 | &(KOPrefs::instance()->mEventColor),topFrame); | 1240 | &(KOPrefs::instance()->mEventColor),topFrame); |
1232 | topLayout->addWidget(eventColor->label(),ii,0); | 1241 | topLayout->addWidget(eventColor->label(),ii,0); |
1233 | topLayout->addWidget(eventColor->button(),ii++,1); | 1242 | topLayout->addWidget(eventColor->button(),ii++,1); |
1234 | eventColor = | 1243 | eventColor = |
1235 | addWidColor(i18n("Default todo done color:"), | 1244 | addWidColor(i18n("Default todo done color:"), |
1236 | &(KOPrefs::instance()->mTodoDoneColor),topFrame); | 1245 | &(KOPrefs::instance()->mTodoDoneColor),topFrame); |
1237 | topLayout->addWidget(eventColor->label(),ii,0); | 1246 | topLayout->addWidget(eventColor->label(),ii,0); |
1238 | topLayout->addWidget(eventColor->button(),ii++,1); | 1247 | topLayout->addWidget(eventColor->button(),ii++,1); |
1239 | 1248 | ||
1240 | if ( QApplication::desktop()->height() <= 240 ) { | 1249 | if ( QApplication::desktop()->height() <= 240 ) { |
1241 | topFrame = addPage(i18n("Colors") +" 2",0,0); | 1250 | topFrame = addPage(i18n("Colors") +" 2",0,0); |
1242 | // DesktopIcon("colorize",KIcon::SizeMedium)); | 1251 | // DesktopIcon("colorize",KIcon::SizeMedium)); |
1243 | 1252 | ||
1244 | topLayout = new QGridLayout(topFrame,5,2); | 1253 | topLayout = new QGridLayout(topFrame,5,2); |
1245 | // topLayout->setSpacing(mSpacingHint); | 1254 | // topLayout->setSpacing(mSpacingHint); |
1246 | // topLayout->setMargin(mMarginHint); | 1255 | // topLayout->setMargin(mMarginHint); |
1247 | 1256 | ||
1248 | topLayout->setSpacing(2); | 1257 | topLayout->setSpacing(2); |
1249 | topLayout->setMargin(3); | 1258 | topLayout->setMargin(3); |
1250 | } | 1259 | } |
1251 | 1260 | ||
1252 | 1261 | ||
1253 | // agenda view background color | 1262 | // agenda view background color |
1254 | KPrefsDialogWidColor *agendaBgColor = | 1263 | KPrefsDialogWidColor *agendaBgColor = |
1255 | addWidColor(i18n("Agenda view background color:"), | 1264 | addWidColor(i18n("Agenda view background color:"), |
1256 | &(KOPrefs::instance()->mAgendaBgColor),topFrame); | 1265 | &(KOPrefs::instance()->mAgendaBgColor),topFrame); |
1257 | topLayout->addWidget(agendaBgColor->label(),ii,0); | 1266 | topLayout->addWidget(agendaBgColor->label(),ii,0); |
1258 | topLayout->addWidget(agendaBgColor->button(),ii++,1); | 1267 | topLayout->addWidget(agendaBgColor->button(),ii++,1); |
1259 | 1268 | ||
1260 | // working hours color | 1269 | // working hours color |
1261 | KPrefsDialogWidColor *workingHoursColor = | 1270 | KPrefsDialogWidColor *workingHoursColor = |
1262 | addWidColor(i18n("Working hours color:"), | 1271 | addWidColor(i18n("Working hours color:"), |
1263 | &(KOPrefs::instance()->mWorkingHoursColor),topFrame); | 1272 | &(KOPrefs::instance()->mWorkingHoursColor),topFrame); |
1264 | topLayout->addWidget(workingHoursColor->label(),ii,0); | 1273 | topLayout->addWidget(workingHoursColor->label(),ii,0); |
1265 | topLayout->addWidget(workingHoursColor->button(),ii++,1); | 1274 | topLayout->addWidget(workingHoursColor->button(),ii++,1); |
1266 | 1275 | ||
1267 | KPrefsDialogWidBool *sb = | 1276 | KPrefsDialogWidBool *sb = |
1268 | addWidBool(i18n("Use colors for application:"), | 1277 | addWidBool(i18n("Use colors for application:"), |
1269 | &(KOPrefs::instance()->mUseAppColors),topFrame); | 1278 | &(KOPrefs::instance()->mUseAppColors),topFrame); |
1270 | topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 ); | 1279 | topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 ); |
1271 | 1280 | ||
1272 | ii++; | 1281 | ii++; |
1273 | KPrefsDialogWidColor * workingHoursColor1 = | 1282 | KPrefsDialogWidColor * workingHoursColor1 = |
1274 | addWidColor(i18n("Buttons, menus, etc.:"), | 1283 | addWidColor(i18n("Buttons, menus, etc.:"), |
1275 | &(KOPrefs::instance()->mAppColor1),topFrame); | 1284 | &(KOPrefs::instance()->mAppColor1),topFrame); |
1276 | topLayout->addWidget(workingHoursColor1->label(),ii,0); | 1285 | topLayout->addWidget(workingHoursColor1->label(),ii,0); |
1277 | topLayout->addWidget(workingHoursColor1->button(),ii++,1); | 1286 | topLayout->addWidget(workingHoursColor1->button(),ii++,1); |
1278 | 1287 | ||
1279 | KPrefsDialogWidColor * workingHoursColor2 = | 1288 | KPrefsDialogWidColor * workingHoursColor2 = |
1280 | addWidColor(i18n("Frames, labels, etc.:"), | 1289 | addWidColor(i18n("Frames, labels, etc.:"), |
1281 | &(KOPrefs::instance()->mAppColor2),topFrame); | 1290 | &(KOPrefs::instance()->mAppColor2),topFrame); |
1282 | topLayout->addWidget(workingHoursColor2->label(),ii,0); | 1291 | topLayout->addWidget(workingHoursColor2->label(),ii,0); |
1283 | topLayout->addWidget(workingHoursColor2->button(),ii++,1); | 1292 | topLayout->addWidget(workingHoursColor2->button(),ii++,1); |
1284 | 1293 | ||
1285 | 1294 | ||
1286 | 1295 | ||
1287 | } | 1296 | } |
1288 | 1297 | ||
1289 | void KOPrefsDialog::setCategoryColor() | 1298 | void KOPrefsDialog::setCategoryColor() |
1290 | { | 1299 | { |
1291 | mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color())); | 1300 | mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color())); |
1292 | } | 1301 | } |
1293 | 1302 | ||
1294 | void KOPrefsDialog::updateCategoryColor() | 1303 | void KOPrefsDialog::updateCategoryColor() |
1295 | { | 1304 | { |
1296 | QString cat = mCategoryCombo->currentText(); | 1305 | QString cat = mCategoryCombo->currentText(); |
1297 | QColor *color = mCategoryDict.find(cat); | 1306 | QColor *color = mCategoryDict.find(cat); |
1298 | if (!color) { | 1307 | if (!color) { |
1299 | color = KOPrefs::instance()->categoryColor(cat); | 1308 | color = KOPrefs::instance()->categoryColor(cat); |
1300 | } | 1309 | } |
1301 | if (color) { | 1310 | if (color) { |
1302 | mCategoryButton->setColor(*color); | 1311 | mCategoryButton->setColor(*color); |
1303 | } | 1312 | } |
1304 | } | 1313 | } |
1305 | 1314 | ||
1306 | void KOPrefsDialog::setupPrinterTab() | 1315 | void KOPrefsDialog::setupPrinterTab() |
1307 | { | 1316 | { |
1308 | mPrinterTab = addPage(i18n("Printing"),0, | 1317 | mPrinterTab = addPage(i18n("Printing"),0, |
1309 | DesktopIcon("fileprint",KIcon::SizeMedium)); | 1318 | DesktopIcon("fileprint",KIcon::SizeMedium)); |
1310 | 1319 | ||
1311 | QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2); | 1320 | QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2); |
1312 | topLayout->setSpacing(mSpacingHint); | 1321 | topLayout->setSpacing(mSpacingHint); |
1313 | topLayout->setMargin(mMarginHint); | 1322 | topLayout->setMargin(mMarginHint); |
1314 | 1323 | ||
1315 | topLayout->setRowStretch(4,1); | 1324 | topLayout->setRowStretch(4,1); |
1316 | } | 1325 | } |
1317 | 1326 | ||
1318 | void KOPrefsDialog::setupGroupSchedulingTab() | 1327 | void KOPrefsDialog::setupGroupSchedulingTab() |
1319 | { | 1328 | { |
1320 | #if 0 | 1329 | #if 0 |
1321 | QFrame *topFrame = addPage(i18n("Group Scheduling"),0, | 1330 | QFrame *topFrame = addPage(i18n("Group Scheduling"),0, |
1322 | DesktopIcon("personal",KIcon::SizeMedium)); | 1331 | DesktopIcon("personal",KIcon::SizeMedium)); |
1323 | 1332 | ||
1324 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 1333 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
1325 | topLayout->setSpacing(mSpacingHint); | 1334 | topLayout->setSpacing(mSpacingHint); |
1326 | topLayout->setMargin(mMarginHint); | 1335 | topLayout->setMargin(mMarginHint); |
1327 | 1336 | ||
1328 | #if 0 | 1337 | #if 0 |
1329 | KPrefsDialogWidRadios *schedulerGroup = | 1338 | KPrefsDialogWidRadios *schedulerGroup = |
1330 | addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler), | 1339 | addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler), |
1331 | topFrame); | 1340 | topFrame); |
1332 | schedulerGroup->addRadio("Dummy"); // Only for debugging | 1341 | schedulerGroup->addRadio("Dummy"); // Only for debugging |
1333 | schedulerGroup->addRadio(i18n("Mail client")); | 1342 | schedulerGroup->addRadio(i18n("Mail client")); |
1334 | 1343 | ||
1335 | topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); | 1344 | topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); |
1336 | #endif | 1345 | #endif |
1337 | 1346 | ||
1338 | KPrefsDialogWidRadios *sendGroup = | 1347 | KPrefsDialogWidRadios *sendGroup = |
1339 | addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend), | 1348 | addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend), |
1340 | topFrame); | 1349 | topFrame); |
1341 | sendGroup->addRadio(i18n("Send to outbox")); | 1350 | sendGroup->addRadio(i18n("Send to outbox")); |
1342 | sendGroup->addRadio(i18n("Send directly")); | 1351 | sendGroup->addRadio(i18n("Send directly")); |
1343 | 1352 | ||
1344 | topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); | 1353 | topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); |
1345 | 1354 | ||
1346 | topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1); | 1355 | topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1); |
1347 | mAMails = new QListView(topFrame); | 1356 | mAMails = new QListView(topFrame); |
1348 | mAMails->addColumn(i18n("Email"),300); | 1357 | mAMails->addColumn(i18n("Email"),300); |
1349 | topLayout->addMultiCellWidget(mAMails,3,3,0,1); | 1358 | topLayout->addMultiCellWidget(mAMails,3,3,0,1); |
1350 | 1359 | ||
1351 | topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0); | 1360 | topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0); |
1352 | aEmailsEdit = new QLineEdit(topFrame); | 1361 | aEmailsEdit = new QLineEdit(topFrame); |
1353 | aEmailsEdit->setEnabled(false); | 1362 | aEmailsEdit->setEnabled(false); |
1354 | topLayout->addWidget(aEmailsEdit,4,1); | 1363 | topLayout->addWidget(aEmailsEdit,4,1); |
1355 | 1364 | ||
1356 | QPushButton *add = new QPushButton(i18n("New"),topFrame,"new"); | 1365 | QPushButton *add = new QPushButton(i18n("New"),topFrame,"new"); |
1357 | topLayout->addWidget(add,5,0); | 1366 | topLayout->addWidget(add,5,0); |
1358 | QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove"); | 1367 | QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove"); |
1359 | topLayout->addWidget(del,5,1); | 1368 | topLayout->addWidget(del,5,1); |
1360 | 1369 | ||
1361 | //topLayout->setRowStretch(2,1); | 1370 | //topLayout->setRowStretch(2,1); |
1362 | connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) ); | 1371 | connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) ); |
1363 | connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) ); | 1372 | connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) ); |
1364 | connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem())); | 1373 | connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem())); |
1365 | connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput())); | 1374 | connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput())); |
1366 | #endif | 1375 | #endif |
1367 | } | 1376 | } |
1368 | 1377 | ||
1369 | void KOPrefsDialog::setupGroupAutomationTab() | 1378 | void KOPrefsDialog::setupGroupAutomationTab() |
1370 | { | 1379 | { |
1371 | return; | 1380 | return; |
1372 | QFrame *topFrame = addPage(i18n("Group Automation"),0, | 1381 | QFrame *topFrame = addPage(i18n("Group Automation"),0, |
1373 | DesktopIcon("personal",KIcon::SizeMedium)); | 1382 | DesktopIcon("personal",KIcon::SizeMedium)); |
1374 | 1383 | ||
1375 | QGridLayout *topLayout = new QGridLayout(topFrame,5,1); | 1384 | QGridLayout *topLayout = new QGridLayout(topFrame,5,1); |
1376 | topLayout->setSpacing(mSpacingHint); | 1385 | topLayout->setSpacing(mSpacingHint); |
1377 | topLayout->setMargin(mMarginHint); | 1386 | topLayout->setMargin(mMarginHint); |
1378 | 1387 | ||
1379 | KPrefsDialogWidRadios *autoRefreshGroup = | 1388 | KPrefsDialogWidRadios *autoRefreshGroup = |
1380 | addWidRadios(i18n("Auto Send Refresh"), | 1389 | addWidRadios(i18n("Auto Send Refresh"), |
1381 | &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame); | 1390 | &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame); |
1382 | autoRefreshGroup->addRadio(i18n("Never")); | 1391 | autoRefreshGroup->addRadio(i18n("Never")); |
1383 | autoRefreshGroup->addRadio(i18n("If attendee is in addressbook")); | 1392 | autoRefreshGroup->addRadio(i18n("If attendee is in addressbook")); |
1384 | //autoRefreshGroup->addRadio(i18n("selected emails")); | 1393 | //autoRefreshGroup->addRadio(i18n("selected emails")); |
1385 | topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0); | 1394 | topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0); |
1386 | 1395 | ||
1387 | KPrefsDialogWidRadios *autoInsertGroup = | 1396 | KPrefsDialogWidRadios *autoInsertGroup = |
1388 | addWidRadios(i18n("Auto Insert IMIP Replies"), | 1397 | addWidRadios(i18n("Auto Insert IMIP Replies"), |
1389 | &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame); | 1398 | &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame); |
1390 | autoInsertGroup->addRadio(i18n("Never")); | 1399 | autoInsertGroup->addRadio(i18n("Never")); |
1391 | autoInsertGroup->addRadio(i18n("If attendee is in addressbook")); | 1400 | autoInsertGroup->addRadio(i18n("If attendee is in addressbook")); |
1392 | //autoInsertGroup->addRadio(i18n("selected emails")); | 1401 | //autoInsertGroup->addRadio(i18n("selected emails")); |
1393 | topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0); | 1402 | topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0); |
1394 | 1403 | ||
1395 | KPrefsDialogWidRadios *autoRequestGroup = | 1404 | KPrefsDialogWidRadios *autoRequestGroup = |
1396 | addWidRadios(i18n("Auto Insert IMIP Requests"), | 1405 | addWidRadios(i18n("Auto Insert IMIP Requests"), |
1397 | &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame); | 1406 | &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame); |
1398 | autoRequestGroup->addRadio(i18n("Never")); | 1407 | autoRequestGroup->addRadio(i18n("Never")); |
1399 | autoRequestGroup->addRadio(i18n("If organizer is in addressbook")); | 1408 | autoRequestGroup->addRadio(i18n("If organizer is in addressbook")); |
1400 | //autoInsertGroup->addRadio(i18n("selected emails")); | 1409 | //autoInsertGroup->addRadio(i18n("selected emails")); |
1401 | topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0); | 1410 | topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0); |
1402 | 1411 | ||
1403 | KPrefsDialogWidRadios *autoFreeBusyGroup = | 1412 | KPrefsDialogWidRadios *autoFreeBusyGroup = |
1404 | addWidRadios(i18n("Auto Send FreeBusy Information"), | 1413 | addWidRadios(i18n("Auto Send FreeBusy Information"), |
1405 | &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame); | 1414 | &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame); |
1406 | autoFreeBusyGroup->addRadio(i18n("Never")); | 1415 | autoFreeBusyGroup->addRadio(i18n("Never")); |
1407 | autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook")); | 1416 | autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook")); |
1408 | //autoFreeBusyGroup->addRadio(i18n("selected emails")); | 1417 | //autoFreeBusyGroup->addRadio(i18n("selected emails")); |
1409 | topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0); | 1418 | topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0); |
1410 | 1419 | ||
1411 | KPrefsDialogWidRadios *autoFreeBusyReplyGroup = | 1420 | KPrefsDialogWidRadios *autoFreeBusyReplyGroup = |
1412 | addWidRadios(i18n("Auto Save FreeBusy Replies"), | 1421 | addWidRadios(i18n("Auto Save FreeBusy Replies"), |
1413 | &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame); | 1422 | &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame); |
1414 | autoFreeBusyReplyGroup->addRadio(i18n("Never")); | 1423 | autoFreeBusyReplyGroup->addRadio(i18n("Never")); |
1415 | autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook")); | 1424 | autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook")); |
1416 | //autoFreeBusyGroup->addRadio(i18n("selected emails")); | 1425 | //autoFreeBusyGroup->addRadio(i18n("selected emails")); |
1417 | topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0); | 1426 | topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0); |
1418 | } | 1427 | } |
1419 | 1428 | ||
1420 | void KOPrefsDialog::showPrinterTab() | 1429 | void KOPrefsDialog::showPrinterTab() |
1421 | { | 1430 | { |
1422 | showPage(pageIndex(mPrinterTab)); | 1431 | showPage(pageIndex(mPrinterTab)); |
1423 | } | 1432 | } |
1424 | 1433 | ||
1425 | 1434 | ||
1426 | void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text, | 1435 | void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text, |
1427 | const QStringList *tags) | 1436 | const QStringList *tags) |
1428 | { | 1437 | { |
1429 | if (tags) { | 1438 | if (tags) { |
1430 | int i = tags->findIndex(text); | 1439 | int i = tags->findIndex(text); |
1431 | if (i > 0) combo->setCurrentItem(i); | 1440 | if (i > 0) combo->setCurrentItem(i); |
1432 | } else { | 1441 | } else { |
1433 | for(int i=0;i<combo->count();++i) { | 1442 | for(int i=0;i<combo->count();++i) { |
1434 | if (combo->text(i) == text) { | 1443 | if (combo->text(i) == text) { |
1435 | combo->setCurrentItem(i); | 1444 | combo->setCurrentItem(i); |
1436 | break; | 1445 | break; |
1437 | } | 1446 | } |
1438 | } | 1447 | } |
1439 | } | 1448 | } |
1440 | } | 1449 | } |
1441 | 1450 | ||
1442 | void KOPrefsDialog::usrReadConfig() | 1451 | void KOPrefsDialog::usrReadConfig() |
1443 | { | 1452 | { |
1444 | 1453 | ||
1445 | mNameEdit->setText(KOPrefs::instance()->fullName()); | 1454 | mNameEdit->setText(KOPrefs::instance()->fullName()); |
1446 | mEmailEdit->setText(KOPrefs::instance()->email()); | 1455 | mEmailEdit->setText(KOPrefs::instance()->email()); |
1447 | 1456 | ||
1448 | mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval); | 1457 | mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval); |
1449 | 1458 | ||
1450 | mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime); | 1459 | mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime); |
1451 | mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration); | 1460 | mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration); |
1452 | mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); | 1461 | mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); |
1453 | 1462 | ||
1454 | mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays); | 1463 | mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays); |
1455 | mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays); | 1464 | mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays); |
1456 | mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios); | 1465 | mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios); |
1457 | // mAMails->clear(); | 1466 | // mAMails->clear(); |
1458 | // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin(); | 1467 | // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin(); |
1459 | // it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) { | 1468 | // it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) { |
1460 | // QListViewItem *item = new QListViewItem(mAMails); | 1469 | // QListViewItem *item = new QListViewItem(mAMails); |
1461 | // item->setText(0,*it); | 1470 | // item->setText(0,*it); |
1462 | // mAMails->insertItem(item); | 1471 | // mAMails->insertItem(item); |
1463 | // } | 1472 | // } |
1464 | 1473 | ||
1465 | //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile); | 1474 | //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile); |
1466 | mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile); | 1475 | mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile); |
1467 | updateCategories(); | 1476 | updateCategories(); |
1468 | mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps ); | 1477 | mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps ); |
1469 | mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime ); | 1478 | mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime ); |
1470 | mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount ); | 1479 | mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount ); |
1471 | mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval ); | 1480 | mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval ); |
1472 | mCatDefaultColor = KOPrefs::instance()->mEventColor; | 1481 | mCatDefaultColor = KOPrefs::instance()->mEventColor; |
1473 | 1482 | ||
1474 | 1483 | ||
1475 | KConfig cfgko(locateLocal("config","korganizerrc")); | 1484 | KConfig cfgko(locateLocal("config","korganizerrc")); |
1476 | cfgko.setGroup("General"); | 1485 | cfgko.setGroup("General"); |
1477 | QStringList temp = cfgko.readListEntry("CalendarFilters"); | 1486 | QStringList temp = cfgko.readListEntry("CalendarFilters"); |
1478 | temp.prepend(i18n("No Filter") ); | 1487 | temp.prepend(i18n("No Filter") ); |
1479 | mFilterEditItem->insertStringList( temp ); | 1488 | mFilterEditItem->insertStringList( temp ); |
1480 | mFilterAllItem->insertStringList( temp ); | 1489 | mFilterAllItem->insertStringList( temp ); |
1481 | int index = temp.findIndex( KOPrefs::instance()->mFilterConflictEditItem ); | 1490 | int index = temp.findIndex( KOPrefs::instance()->mFilterConflictEditItem ); |
1482 | if ( index >= 0 ) | 1491 | if ( index >= 0 ) |
1483 | mFilterEditItem->setCurrentItem( index ); | 1492 | mFilterEditItem->setCurrentItem( index ); |
1484 | index = temp.findIndex( KOPrefs::instance()->mFilterConflictAllItem ); | 1493 | index = temp.findIndex( KOPrefs::instance()->mFilterConflictAllItem ); |
1485 | if ( index >= 0 ) | 1494 | if ( index >= 0 ) |
1486 | mFilterAllItem->setCurrentItem( index ); | 1495 | mFilterAllItem->setCurrentItem( index ); |
1487 | } | 1496 | } |
1488 | 1497 | ||
1489 | 1498 | ||
1490 | void KOPrefsDialog::usrWriteConfig() | 1499 | void KOPrefsDialog::usrWriteConfig() |
1491 | { | 1500 | { |
1492 | KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text(); | 1501 | KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text(); |
1493 | KOPrefs::instance()->setFullName(mNameEdit->text()); | 1502 | KOPrefs::instance()->setFullName(mNameEdit->text()); |
1494 | KOPrefs::instance()->setEmail(mEmailEdit->text()); | 1503 | KOPrefs::instance()->setEmail(mEmailEdit->text()); |
1495 | 1504 | ||
1496 | KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value(); | 1505 | KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value(); |
1497 | KOPrefs::instance()->mStartTime = mStartTimeSpin->value(); | 1506 | KOPrefs::instance()->mStartTime = mStartTimeSpin->value(); |
1498 | KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value(); | 1507 | KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value(); |
1499 | KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); | 1508 | KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); |
1500 | if ( mCatDefaultColor != KOPrefs::instance()->mEventColor ) { | 1509 | if ( mCatDefaultColor != KOPrefs::instance()->mEventColor ) { |
1501 | QStringList cat = KOPrefs::instance()->mCustomCategories; | 1510 | QStringList cat = KOPrefs::instance()->mCustomCategories; |
1502 | int iii = 0; | 1511 | int iii = 0; |
1503 | while ( iii < cat.count() ) { | 1512 | while ( iii < cat.count() ) { |
1504 | if ( *KOPrefs::instance()->categoryColor( cat[ iii ] ) == mCatDefaultColor ) | 1513 | if ( *KOPrefs::instance()->categoryColor( cat[ iii ] ) == mCatDefaultColor ) |
1505 | KOPrefs::instance()->setCategoryColor( cat[ iii ], KOPrefs::instance()->mEventColor ); | 1514 | KOPrefs::instance()->setCategoryColor( cat[ iii ], KOPrefs::instance()->mEventColor ); |
1506 | ++iii; | 1515 | ++iii; |
1507 | } | 1516 | } |
1508 | } | 1517 | } |
1509 | QDictIterator<QColor> it(mCategoryDict); | 1518 | QDictIterator<QColor> it(mCategoryDict); |
1510 | while (it.current()) { | 1519 | while (it.current()) { |
1511 | KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); | 1520 | KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); |
1512 | ++it; | 1521 | ++it; |
1513 | } | 1522 | } |
1514 | 1523 | ||
1515 | KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value(); | 1524 | KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value(); |
1516 | KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value(); | 1525 | KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value(); |
1517 | KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value(); | 1526 | KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value(); |
1518 | 1527 | ||
1519 | KOPrefs::instance()->mAdditionalMails.clear(); | 1528 | KOPrefs::instance()->mAdditionalMails.clear(); |
1520 | // QListViewItem *item; | 1529 | // QListViewItem *item; |
1521 | // item = mAMails->firstChild(); | 1530 | // item = mAMails->firstChild(); |
1522 | // while (item) | 1531 | // while (item) |
1523 | // { | 1532 | // { |
1524 | // KOPrefs::instance()->mAdditionalMails.append( item->text(0) ); | 1533 | // KOPrefs::instance()->mAdditionalMails.append( item->text(0) ); |
1525 | // item = item->nextSibling(); | 1534 | // item = item->nextSibling(); |
1526 | // } | 1535 | // } |
1527 | KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value(); | 1536 | KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value(); |
1528 | KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ; | 1537 | KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ; |
1529 | KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ; | 1538 | KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ; |
1530 | KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ; | 1539 | KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ; |
1531 | 1540 | ||
1532 | KOPrefs::instance()->mFilterConflictEditItem = mFilterEditItem->currentText(); | 1541 | KOPrefs::instance()->mFilterConflictEditItem = mFilterEditItem->currentText(); |
1533 | KOPrefs::instance()->mFilterConflictAllItem = mFilterAllItem->currentText(); | 1542 | KOPrefs::instance()->mFilterConflictAllItem = mFilterAllItem->currentText(); |
1534 | } | 1543 | } |
1535 | 1544 | ||
1536 | void KOPrefsDialog::updateCategories() | 1545 | void KOPrefsDialog::updateCategories() |
1537 | { | 1546 | { |
1538 | mCategoryCombo->clear(); | 1547 | mCategoryCombo->clear(); |
1539 | mCategoryDict.clear(); | 1548 | mCategoryDict.clear(); |
1540 | mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); | 1549 | mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); |
1541 | updateCategoryColor(); | 1550 | updateCategoryColor(); |
1542 | } | 1551 | } |
1543 | 1552 | ||
1544 | void KOPrefsDialog::toggleEmailSettings(bool on) | 1553 | void KOPrefsDialog::toggleEmailSettings(bool on) |
1545 | { | 1554 | { |
1546 | if (on) { | 1555 | if (on) { |
1547 | mEmailEdit->setEnabled(false); | 1556 | mEmailEdit->setEnabled(false); |
1548 | mNameEdit->setEnabled(false); | 1557 | mNameEdit->setEnabled(false); |
1549 | mEmailLabel->setEnabled(false); | 1558 | mEmailLabel->setEnabled(false); |
1550 | mNameLabel->setEnabled(false); | 1559 | mNameLabel->setEnabled(false); |
1551 | 1560 | ||
1552 | KEMailSettings settings; | 1561 | KEMailSettings settings; |
1553 | mNameEdit->setText(settings.getSetting(KEMailSettings::RealName)); | 1562 | mNameEdit->setText(settings.getSetting(KEMailSettings::RealName)); |
1554 | mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress)); | 1563 | mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress)); |
1555 | } else { | 1564 | } else { |
1556 | mEmailEdit->setEnabled(true); | 1565 | mEmailEdit->setEnabled(true); |
1557 | mNameEdit->setEnabled(true); | 1566 | mNameEdit->setEnabled(true); |
1558 | mEmailLabel->setEnabled(true); | 1567 | mEmailLabel->setEnabled(true); |
1559 | mNameLabel->setEnabled(true); | 1568 | mNameLabel->setEnabled(true); |
1560 | } | 1569 | } |
1561 | } | 1570 | } |
1562 | 1571 | ||
1563 | void KOPrefsDialog::addItem() | 1572 | void KOPrefsDialog::addItem() |
1564 | { | 1573 | { |
1565 | // aEmailsEdit->setEnabled(true); | 1574 | // aEmailsEdit->setEnabled(true); |
1566 | // QListViewItem *item = new QListViewItem(mAMails); | 1575 | // QListViewItem *item = new QListViewItem(mAMails); |
1567 | // mAMails->insertItem(item); | 1576 | // mAMails->insertItem(item); |
1568 | // mAMails->setSelected(item,true); | 1577 | // mAMails->setSelected(item,true); |
1569 | // aEmailsEdit->setText(i18n("(EmptyEmail)")); | 1578 | // aEmailsEdit->setText(i18n("(EmptyEmail)")); |
1570 | } | 1579 | } |
1571 | 1580 | ||
1572 | void KOPrefsDialog::removeItem() | 1581 | void KOPrefsDialog::removeItem() |
1573 | { | 1582 | { |
1574 | // QListViewItem *item; | 1583 | // QListViewItem *item; |
1575 | // item = mAMails->selectedItem(); | 1584 | // item = mAMails->selectedItem(); |
1576 | // if (!item) return; | 1585 | // if (!item) return; |
1577 | // mAMails->takeItem(item); | 1586 | // mAMails->takeItem(item); |
1578 | // item = mAMails->selectedItem(); | 1587 | // item = mAMails->selectedItem(); |
1579 | // if (!item) { | 1588 | // if (!item) { |
1580 | // aEmailsEdit->setText(""); | 1589 | // aEmailsEdit->setText(""); |
1581 | // aEmailsEdit->setEnabled(false); | 1590 | // aEmailsEdit->setEnabled(false); |
1582 | // } | 1591 | // } |
1583 | // if (mAMails->childCount() == 0) { | 1592 | // if (mAMails->childCount() == 0) { |
1584 | // aEmailsEdit->setEnabled(false); | 1593 | // aEmailsEdit->setEnabled(false); |
1585 | // } | 1594 | // } |
1586 | } | 1595 | } |
1587 | 1596 | ||
1588 | void KOPrefsDialog::updateItem() | 1597 | void KOPrefsDialog::updateItem() |
1589 | { | 1598 | { |
1590 | // QListViewItem *item; | 1599 | // QListViewItem *item; |
1591 | // item = mAMails->selectedItem(); | 1600 | // item = mAMails->selectedItem(); |
1592 | // if (!item) return; | 1601 | // if (!item) return; |
1593 | // item->setText(0,aEmailsEdit->text()); | 1602 | // item->setText(0,aEmailsEdit->text()); |
1594 | } | 1603 | } |
1595 | 1604 | ||
1596 | void KOPrefsDialog::updateInput() | 1605 | void KOPrefsDialog::updateInput() |
1597 | { | 1606 | { |
1598 | // QListViewItem *item; | 1607 | // QListViewItem *item; |
1599 | // item = mAMails->selectedItem(); | 1608 | // item = mAMails->selectedItem(); |
1600 | // if (!item) return; | 1609 | // if (!item) return; |
1601 | // aEmailsEdit->setEnabled(true); | 1610 | // aEmailsEdit->setEnabled(true); |
1602 | // aEmailsEdit->setText(item->text(0)); | 1611 | // aEmailsEdit->setText(item->text(0)); |
1603 | } | 1612 | } |
1604 | 1613 | ||