author | zautrix <zautrix> | 2005-07-07 12:30:17 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-07 12:30:17 (UTC) |
commit | 766b53919de14b8faec22db32b6a750acde0b760 (patch) (unidiff) | |
tree | bb07c0af89b0dddf4257a61e9f5b1cf23c4a282a | |
parent | b4d85da57e2d558ec088af6f3b2a34b1854462c0 (diff) | |
download | kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.zip kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.tar.gz kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.tar.bz2 |
fixesss
-rw-r--r-- | korganizer/calendarview.cpp | 70 | ||||
-rw-r--r-- | korganizer/calendarview.h | 2 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 39 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 124 | ||||
-rw-r--r-- | korganizer/komonthview.h | 2 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 1 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | korganizer/koprefsdialog.cpp | 4 |
8 files changed, 192 insertions, 51 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 9a114d0..e766b8f 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4727 +1,4797 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | #include "categoryeditdialog.h" | 119 | #include "categoryeditdialog.h" |
120 | 120 | ||
121 | #include "calendarview.h" | 121 | #include "calendarview.h" |
122 | #ifndef DESKTOP_VERSION | 122 | #ifndef DESKTOP_VERSION |
123 | #include <qtopia/alarmserver.h> | 123 | #include <qtopia/alarmserver.h> |
124 | #endif | 124 | #endif |
125 | #ifndef _WIN32_ | 125 | #ifndef _WIN32_ |
126 | #include <stdlib.h> | 126 | #include <stdlib.h> |
127 | #include <stdio.h> | 127 | #include <stdio.h> |
128 | #include <unistd.h> | 128 | #include <unistd.h> |
129 | #else | 129 | #else |
130 | #include <qprocess.h> | 130 | #include <qprocess.h> |
131 | #endif | 131 | #endif |
132 | 132 | ||
133 | #ifdef DESKTOP_VERSION | 133 | #ifdef DESKTOP_VERSION |
134 | #include <kabc/stdaddressbook.h> | 134 | #include <kabc/stdaddressbook.h> |
135 | #endif | 135 | #endif |
136 | using namespace KOrg; | 136 | using namespace KOrg; |
137 | using namespace KCal; | 137 | using namespace KCal; |
138 | extern int globalFlagBlockAgenda; | 138 | extern int globalFlagBlockAgenda; |
139 | extern int globalFlagBlockStartup; | 139 | extern int globalFlagBlockStartup; |
140 | 140 | ||
141 | 141 | ||
142 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 142 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
143 | 143 | ||
144 | { | 144 | { |
145 | mAlarms = alarms; | 145 | mAlarms = alarms; |
146 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 146 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
147 | QString mText = "<table width=\"100%\">\n"; | 147 | QString mText = "<table width=\"100%\">\n"; |
148 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 148 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
149 | #ifdef DESKTOP_VERSION | 149 | #ifdef DESKTOP_VERSION |
150 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 150 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
151 | #else | 151 | #else |
152 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 152 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
153 | #endif | 153 | #endif |
154 | // mText += "<img src=\""; | 154 | // mText += "<img src=\""; |
155 | // mText += ipath; | 155 | // mText += ipath; |
156 | // mText += "\">"; | 156 | // mText += "\">"; |
157 | //mEventDate = QDate::currentDate(); | 157 | //mEventDate = QDate::currentDate(); |
158 | #ifdef DESKTOP_VERSION | 158 | #ifdef DESKTOP_VERSION |
159 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 159 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
160 | #else | 160 | #else |
161 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 161 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
162 | #endif | 162 | #endif |
163 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 163 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
164 | 164 | ||
165 | Incidence * inc = getNextInc( start ); | 165 | Incidence * inc = getNextInc( start ); |
166 | int time = 0; | 166 | int time = 0; |
167 | //mText += "<table>"; | 167 | //mText += "<table>"; |
168 | while ( inc ) { | 168 | while ( inc ) { |
169 | QDateTime dt ; | 169 | QDateTime dt ; |
170 | QString tempText = "<a "; | 170 | QString tempText = "<a "; |
171 | bool ok; | 171 | bool ok; |
172 | dt = inc->getNextOccurence( start, &ok ); | 172 | dt = inc->getNextOccurence( start, &ok ); |
173 | if ( !ok ) continue; | 173 | if ( !ok ) continue; |
174 | if ( inc->typeID() == eventID ) { | 174 | if ( inc->typeID() == eventID ) { |
175 | tempText += "href=\"event:"; | 175 | tempText += "href=\"event:"; |
176 | } else if ( inc->typeID() == todoID ) { | 176 | } else if ( inc->typeID() == todoID ) { |
177 | tempText += "href=\"todo:"; | 177 | tempText += "href=\"todo:"; |
178 | } | 178 | } |
179 | tempText += inc->uid() + "\">"; | 179 | tempText += inc->uid() + "\">"; |
180 | if ( inc->typeID() == todoID ) | 180 | if ( inc->typeID() == todoID ) |
181 | tempText += i18n("Todo: "); | 181 | tempText += i18n("Todo: "); |
182 | if ( inc->summary().length() > 0 ) | 182 | if ( inc->summary().length() > 0 ) |
183 | tempText += inc->summary(); | 183 | tempText += inc->summary(); |
184 | else | 184 | else |
185 | tempText += i18n("-no summary-"); | 185 | tempText += i18n("-no summary-"); |
186 | QString timestr; | 186 | QString timestr; |
187 | if (!inc->doesFloat()) | 187 | if (!inc->doesFloat()) |
188 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 188 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
189 | else | 189 | else |
190 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 190 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
191 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 191 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
192 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 192 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
193 | mText += "<table>"; | 193 | mText += "<table>"; |
194 | time = 1; | 194 | time = 1; |
195 | } | 195 | } |
196 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 196 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
197 | if ( time > 0 ) | 197 | if ( time > 0 ) |
198 | mText +="</table>"; | 198 | mText +="</table>"; |
199 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 199 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
200 | mText += "<table>"; | 200 | mText += "<table>"; |
201 | time = 2; | 201 | time = 2; |
202 | 202 | ||
203 | } | 203 | } |
204 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 204 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
205 | if ( time > 0 ) | 205 | if ( time > 0 ) |
206 | mText +="</table>"; | 206 | mText +="</table>"; |
207 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 207 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
208 | mText += "<table>"; | 208 | mText += "<table>"; |
209 | time = 3; | 209 | time = 3; |
210 | } | 210 | } |
211 | mText +="<tr><td><b>"; | 211 | mText +="<tr><td><b>"; |
212 | mText += timestr; | 212 | mText += timestr; |
213 | mText += "</b></td><td>"; | 213 | mText += "</b></td><td>"; |
214 | mText += tempText; | 214 | mText += tempText; |
215 | mText += "</td></tr>\n"; | 215 | mText += "</td></tr>\n"; |
216 | inc = getNextInc( start ); | 216 | inc = getNextInc( start ); |
217 | } | 217 | } |
218 | mText +="</table>"; | 218 | mText +="</table>"; |
219 | setText( mText ); | 219 | setText( mText ); |
220 | } | 220 | } |
221 | 221 | ||
222 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 222 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
223 | { | 223 | { |
224 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 224 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
225 | } | 225 | } |
226 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 226 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
227 | { | 227 | { |
228 | QDateTime dt ; | 228 | QDateTime dt ; |
229 | Incidence * retInc; | 229 | Incidence * retInc; |
230 | Incidence * inc = mAlarms.first(); | 230 | Incidence * inc = mAlarms.first(); |
231 | if ( inc == 0 ) | 231 | if ( inc == 0 ) |
232 | return 0; | 232 | return 0; |
233 | bool ok; | 233 | bool ok; |
234 | dt = inc->getNextOccurence( start, &ok ); | 234 | dt = inc->getNextOccurence( start, &ok ); |
235 | if ( ! ok ) return 0; | 235 | if ( ! ok ) return 0; |
236 | QDateTime dtn ; | 236 | QDateTime dtn ; |
237 | retInc = inc; | 237 | retInc = inc; |
238 | inc = mAlarms.next(); | 238 | inc = mAlarms.next(); |
239 | while ( inc ) { | 239 | while ( inc ) { |
240 | dtn = inc->getNextOccurence( start, &ok ); | 240 | dtn = inc->getNextOccurence( start, &ok ); |
241 | if ( ! ok ) return 0; | 241 | if ( ! ok ) return 0; |
242 | if ( dtn < dt ) { | 242 | if ( dtn < dt ) { |
243 | dt = dtn; | 243 | dt = dtn; |
244 | retInc = inc; | 244 | retInc = inc; |
245 | } | 245 | } |
246 | inc = mAlarms.next(); | 246 | inc = mAlarms.next(); |
247 | } | 247 | } |
248 | mAlarms.remove( retInc ); | 248 | mAlarms.remove( retInc ); |
249 | return retInc; | 249 | return retInc; |
250 | 250 | ||
251 | } | 251 | } |
252 | void MissedAlarmTextBrowser::setSource(const QString & n) | 252 | void MissedAlarmTextBrowser::setSource(const QString & n) |
253 | { | 253 | { |
254 | if (n.startsWith("event:")) { | 254 | if (n.startsWith("event:")) { |
255 | #ifdef DESKTOP_VERSION | 255 | #ifdef DESKTOP_VERSION |
256 | emit showIncidence(n.mid(8)); | 256 | emit showIncidence(n.mid(8)); |
257 | #else | 257 | #else |
258 | emit showIncidence(n.mid(6)); | 258 | emit showIncidence(n.mid(6)); |
259 | #endif | 259 | #endif |
260 | return; | 260 | return; |
261 | } else if (n.startsWith("todo:")) { | 261 | } else if (n.startsWith("todo:")) { |
262 | #ifdef DESKTOP_VERSION | 262 | #ifdef DESKTOP_VERSION |
263 | emit showIncidence(n.mid(7)); | 263 | emit showIncidence(n.mid(7)); |
264 | #else | 264 | #else |
265 | emit showIncidence(n.mid(5)); | 265 | emit showIncidence(n.mid(5)); |
266 | #endif | 266 | #endif |
267 | return; | 267 | return; |
268 | } | 268 | } |
269 | } | 269 | } |
270 | 270 | ||
271 | 271 | ||
272 | class KOBeamPrefs : public QDialog | 272 | class KOBeamPrefs : public QDialog |
273 | { | 273 | { |
274 | public: | 274 | public: |
275 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 275 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
276 | QDialog( parent, name, true ) | 276 | QDialog( parent, name, true ) |
277 | { | 277 | { |
278 | setCaption( i18n("Beam Options") ); | 278 | setCaption( i18n("Beam Options") ); |
279 | QVBoxLayout* lay = new QVBoxLayout( this ); | 279 | QVBoxLayout* lay = new QVBoxLayout( this ); |
280 | lay->setSpacing( 3 ); | 280 | lay->setSpacing( 3 ); |
281 | lay->setMargin( 3 ); | 281 | lay->setMargin( 3 ); |
282 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 282 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
283 | lay->addWidget( format ); | 283 | lay->addWidget( format ); |
284 | format->setExclusive ( true ) ; | 284 | format->setExclusive ( true ) ; |
285 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 285 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
286 | lay->addWidget( time ); time->setExclusive ( true ) ; | 286 | lay->addWidget( time ); time->setExclusive ( true ) ; |
287 | vcal = new QRadioButton(" vCalendar ", format ); | 287 | vcal = new QRadioButton(" vCalendar ", format ); |
288 | ical = new QRadioButton(" iCalendar ", format ); | 288 | ical = new QRadioButton(" iCalendar ", format ); |
289 | vcal->setChecked( true ); | 289 | vcal->setChecked( true ); |
290 | tz = new QRadioButton(i18n(" With timezone "), time ); | 290 | tz = new QRadioButton(i18n(" With timezone "), time ); |
291 | local = new QRadioButton(i18n(" Local time "), time ); | 291 | local = new QRadioButton(i18n(" Local time "), time ); |
292 | tz->setChecked( true ); | 292 | tz->setChecked( true ); |
293 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 293 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
294 | lay->addWidget( ok ); | 294 | lay->addWidget( ok ); |
295 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 295 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
296 | lay->addWidget( cancel ); | 296 | lay->addWidget( cancel ); |
297 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 297 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
298 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 298 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
299 | resize( 200, 200 ); | 299 | resize( 200, 200 ); |
300 | } | 300 | } |
301 | 301 | ||
302 | bool beamVcal() { return vcal->isChecked(); } | 302 | bool beamVcal() { return vcal->isChecked(); } |
303 | bool beamLocal() { return local->isChecked(); } | 303 | bool beamLocal() { return local->isChecked(); } |
304 | private: | 304 | private: |
305 | QRadioButton* vcal, *ical, *local, *tz; | 305 | QRadioButton* vcal, *ical, *local, *tz; |
306 | }; | 306 | }; |
307 | class KOCatPrefs : public QDialog | 307 | class KOCatPrefs : public QDialog |
308 | { | 308 | { |
309 | public: | 309 | public: |
310 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 310 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
311 | QDialog( parent, name, true ) | 311 | QDialog( parent, name, true ) |
312 | { | 312 | { |
313 | setCaption( i18n("Manage new Categories") ); | 313 | setCaption( i18n("Manage new Categories") ); |
314 | QVBoxLayout* lay = new QVBoxLayout( this ); | 314 | QVBoxLayout* lay = new QVBoxLayout( this ); |
315 | lay->setSpacing( 3 ); | 315 | lay->setSpacing( 3 ); |
316 | lay->setMargin( 3 ); | 316 | lay->setMargin( 3 ); |
317 | 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 ); | 317 | 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 | lay->addWidget( lab ); | 318 | lay->addWidget( lab ); |
319 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 319 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
320 | lay->addWidget( format ); | 320 | lay->addWidget( format ); |
321 | format->setExclusive ( true ) ; | 321 | format->setExclusive ( true ) ; |
322 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 322 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
323 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 323 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
324 | addCatBut->setChecked( true ); | 324 | addCatBut->setChecked( true ); |
325 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 325 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
326 | lay->addWidget( ok ); | 326 | lay->addWidget( ok ); |
327 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 327 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
328 | lay->addWidget( cancel ); | 328 | lay->addWidget( cancel ); |
329 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 329 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
330 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 330 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
331 | resize( 200, 200 ); | 331 | resize( 200, 200 ); |
332 | } | 332 | } |
333 | 333 | ||
334 | bool addCat() { return addCatBut->isChecked(); } | 334 | bool addCat() { return addCatBut->isChecked(); } |
335 | private: | 335 | private: |
336 | QRadioButton* addCatBut; | 336 | QRadioButton* addCatBut; |
337 | }; | 337 | }; |
338 | 338 | ||
339 | 339 | ||
340 | 340 | ||
341 | CalendarView::CalendarView( CalendarResources *calendar, | 341 | CalendarView::CalendarView( CalendarResources *calendar, |
342 | QWidget *parent, const char *name ) | 342 | QWidget *parent, const char *name ) |
343 | : CalendarViewBase( parent, name ), | 343 | : CalendarViewBase( parent, name ), |
344 | mCalendar( calendar ), | 344 | mCalendar( calendar ), |
345 | mResourceManager( calendar->resourceManager() ) | 345 | mResourceManager( calendar->resourceManager() ) |
346 | { | 346 | { |
347 | 347 | ||
348 | mEventEditor = 0; | 348 | mEventEditor = 0; |
349 | mTodoEditor = 0; | 349 | mTodoEditor = 0; |
350 | 350 | ||
351 | init(); | 351 | init(); |
352 | } | 352 | } |
353 | 353 | ||
354 | CalendarView::CalendarView( Calendar *calendar, | 354 | CalendarView::CalendarView( Calendar *calendar, |
355 | QWidget *parent, const char *name ) | 355 | QWidget *parent, const char *name ) |
356 | : CalendarViewBase( parent, name ), | 356 | : CalendarViewBase( parent, name ), |
357 | mCalendar( calendar ), | 357 | mCalendar( calendar ), |
358 | mResourceManager( 0 ) | 358 | mResourceManager( 0 ) |
359 | { | 359 | { |
360 | 360 | ||
361 | mEventEditor = 0; | 361 | mEventEditor = 0; |
362 | mTodoEditor = 0; | 362 | mTodoEditor = 0; |
363 | init(); | 363 | init(); |
364 | } | 364 | } |
365 | 365 | ||
366 | void CalendarView::init() | 366 | void CalendarView::init() |
367 | { | 367 | { |
368 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 368 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
369 | setFocusPolicy ( NoFocus ); | 369 | setFocusPolicy ( NoFocus ); |
370 | mViewerCallerIsSearchDialog = false; | 370 | mViewerCallerIsSearchDialog = false; |
371 | mBlockShowDates = false; | 371 | mBlockShowDates = false; |
372 | 372 | ||
373 | mDatePickerMode = 0; | 373 | mDatePickerMode = 0; |
374 | mCurrentSyncDevice = ""; | 374 | mCurrentSyncDevice = ""; |
375 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
378 | mModified = false; | 378 | mModified = false; |
379 | mReadOnly = false; | 379 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
383 | 383 | ||
384 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 386 | ||
387 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 389 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 392 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
395 | 395 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 399 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
402 | 402 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 407 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 409 | mResourceView = 0; |
410 | #else | 410 | #else |
411 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
416 | } else { | 416 | } else { |
417 | mResourceView = 0; | 417 | mResourceView = 0; |
418 | } | 418 | } |
419 | #endif | 419 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 422 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 425 | ||
426 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
427 | #else | 427 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 438 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 445 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
449 | #ifdef DESKTOP_VERSION | 449 | #ifdef DESKTOP_VERSION |
450 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); | 450 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); |
451 | topLayout->addWidget( mDateScrollBar ); | 451 | topLayout->addWidget( mDateScrollBar ); |
452 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 452 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
453 | if ( QApplication::desktop()->width() < 800 ) | 453 | if ( QApplication::desktop()->width() < 800 ) |
454 | mDateScrollBar->hide(); | 454 | mDateScrollBar->hide(); |
455 | #endif | 455 | #endif |
456 | //mainBoxLayout->addWidget (mLeftFrame); | 456 | //mainBoxLayout->addWidget (mLeftFrame); |
457 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 457 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
458 | "CalendarView::DateNavigator" ); | 458 | "CalendarView::DateNavigator" ); |
459 | #if 0 | 459 | #if 0 |
460 | // FIXME | 460 | // FIXME |
461 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 461 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
462 | "CalendarView::DateNavigator", QDate::currentDate()); | 462 | "CalendarView::DateNavigator", QDate::currentDate()); |
463 | #endif | 463 | #endif |
464 | // mDateNavigator->blockSignals( true ); | 464 | // mDateNavigator->blockSignals( true ); |
465 | //leftFrameLayout->addWidget( mDateNavigator ); | 465 | //leftFrameLayout->addWidget( mDateNavigator ); |
466 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 466 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
467 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 467 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
468 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 468 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
469 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 469 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
470 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 472 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 474 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
475 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 475 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
476 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 476 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
477 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 477 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
478 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 478 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
479 | 479 | ||
480 | mTodoList->setNavigator( mNavigator ); | 480 | mTodoList->setNavigator( mNavigator ); |
481 | #if 0 | 481 | #if 0 |
482 | if ( QApplication::desktop()->width() < 480 ) { | 482 | if ( QApplication::desktop()->width() < 480 ) { |
483 | leftFrameLayout->addWidget(mFilterView); | 483 | leftFrameLayout->addWidget(mFilterView); |
484 | leftFrameLayout->addWidget(mTodoList, 2 ); | 484 | leftFrameLayout->addWidget(mTodoList, 2 ); |
485 | 485 | ||
486 | } else { | 486 | } else { |
487 | leftFrameLayout->addWidget(mTodoList,2 ); | 487 | leftFrameLayout->addWidget(mTodoList,2 ); |
488 | leftFrameLayout->addWidget(mFilterView ); | 488 | leftFrameLayout->addWidget(mFilterView ); |
489 | } | 489 | } |
490 | #endif | 490 | #endif |
491 | mFilterView->hide(); | 491 | mFilterView->hide(); |
492 | mCalEditView->hide(); | 492 | mCalEditView->hide(); |
493 | QWidget *rightBox = new QWidget( mMainFrame ); | 493 | QWidget *rightBox = new QWidget( mMainFrame ); |
494 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 494 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
495 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 495 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
496 | mRightFrame = new QWidgetStack( rightBox ); | 496 | mRightFrame = new QWidgetStack( rightBox ); |
497 | rightLayout->addWidget( mRightFrame, 10 ); | 497 | rightLayout->addWidget( mRightFrame, 10 ); |
498 | 498 | ||
499 | //mLeftFrame = (QWidget *)leftFrame; | 499 | //mLeftFrame = (QWidget *)leftFrame; |
500 | if ( KOPrefs::instance()->mVerticalScreen ) { | 500 | if ( KOPrefs::instance()->mVerticalScreen ) { |
501 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 501 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
502 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 502 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
503 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 503 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
504 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | } else { | 505 | } else { |
506 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 506 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
507 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | } | 509 | } |
510 | if ( !KOPrefs::instance()->mShowDateNavigator) | 510 | if ( !KOPrefs::instance()->mShowDateNavigator) |
511 | mDateNavigator->hide(); | 511 | mDateNavigator->hide(); |
512 | //qDebug("Calendarview Size %d %d ", width(), height()); | 512 | //qDebug("Calendarview Size %d %d ", width(), height()); |
513 | #endif | 513 | #endif |
514 | 514 | ||
515 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 515 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
516 | SLOT( showDates( const KCal::DateList & ) ) ); | 516 | SLOT( showDates( const KCal::DateList & ) ) ); |
517 | 517 | ||
518 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 518 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
519 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 519 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
520 | 520 | ||
521 | 521 | ||
522 | 522 | ||
523 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 523 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
524 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 524 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
525 | 525 | ||
526 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 526 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
527 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 527 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
528 | 528 | ||
529 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 529 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
530 | mNavigator, SLOT( selectPreviousYear() ) ); | 530 | mNavigator, SLOT( selectPreviousYear() ) ); |
531 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 531 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
532 | mNavigator, SLOT( selectNextYear() ) ); | 532 | mNavigator, SLOT( selectNextYear() ) ); |
533 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 533 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
534 | mNavigator, SLOT( selectPreviousMonth() ) ); | 534 | mNavigator, SLOT( selectPreviousMonth() ) ); |
535 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 535 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
536 | mNavigator, SLOT( selectNextMonth() ) ); | 536 | mNavigator, SLOT( selectNextMonth() ) ); |
537 | 537 | ||
538 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 538 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
539 | mNavigator, SLOT( selectPrevious() ) ); | 539 | mNavigator, SLOT( selectPrevious() ) ); |
540 | connect( mDateNavigator, SIGNAL( goNext() ), | 540 | connect( mDateNavigator, SIGNAL( goNext() ), |
541 | mNavigator, SLOT( selectNext() ) ); | 541 | mNavigator, SLOT( selectNext() ) ); |
542 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 542 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
543 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 543 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
544 | 544 | ||
545 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 545 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
546 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 546 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
547 | #if 0 | 547 | #if 0 |
548 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 548 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
549 | SLOT( incidenceAdded( Incidence *) ) ); | 549 | SLOT( incidenceAdded( Incidence *) ) ); |
550 | #endif | 550 | #endif |
551 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 551 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
552 | 552 | ||
553 | connect( this, SIGNAL( configChanged() ), | 553 | connect( this, SIGNAL( configChanged() ), |
554 | mDateNavigator, SLOT( updateConfig() ) ); | 554 | mDateNavigator, SLOT( updateConfig() ) ); |
555 | 555 | ||
556 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 556 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
557 | SLOT( newTodo() ) ); | 557 | SLOT( newTodo() ) ); |
558 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 558 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
559 | SLOT( newSubTodo( Todo * ) ) ); | 559 | SLOT( newSubTodo( Todo * ) ) ); |
560 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 560 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
561 | SLOT( editTodo( Todo * ) ) ); | 561 | SLOT( editTodo( Todo * ) ) ); |
562 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 562 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
563 | SLOT( showTodo( Todo *) ) ); | 563 | SLOT( showTodo( Todo *) ) ); |
564 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 564 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
565 | SLOT( deleteTodo( Todo *) ) ); | 565 | SLOT( deleteTodo( Todo *) ) ); |
566 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 566 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
567 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 567 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
568 | SLOT( purgeCompleted() ) ); | 568 | SLOT( purgeCompleted() ) ); |
569 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 569 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
570 | SIGNAL( todoModified( Todo *, int ) ) ); | 570 | SIGNAL( todoModified( Todo *, int ) ) ); |
571 | 571 | ||
572 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 572 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
573 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 573 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
574 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 574 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
575 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 575 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
576 | 576 | ||
577 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 577 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
578 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 578 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
579 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 579 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
580 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 580 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
581 | 581 | ||
582 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 582 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
583 | this, SLOT ( todo_unsub( Todo * ) ) ); | 583 | this, SLOT ( todo_unsub( Todo * ) ) ); |
584 | 584 | ||
585 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 585 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
586 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 586 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
587 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 587 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
588 | SLOT( updateTodo( Todo *, int ) ) ); | 588 | SLOT( updateTodo( Todo *, int ) ) ); |
589 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 589 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
590 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 590 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
591 | 591 | ||
592 | 592 | ||
593 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 593 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
594 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 594 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
595 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 595 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
596 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
597 | 597 | ||
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 602 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
603 | SLOT(checkClipboard())); | 603 | SLOT(checkClipboard())); |
604 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 604 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
605 | SLOT( processTodoListSelection( Incidence * ) ) ); | 605 | SLOT( processTodoListSelection( Incidence * ) ) ); |
606 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 606 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
607 | 607 | ||
608 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 608 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
609 | 609 | ||
610 | mDateFrame = new QVBox(0,0,WType_Popup); | 610 | mDateFrame = new QVBox(0,0,WType_Popup); |
611 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 611 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
612 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 612 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
613 | mDateFrame->setLineWidth(3); | 613 | mDateFrame->setLineWidth(3); |
614 | mDateFrame->hide(); | 614 | mDateFrame->hide(); |
615 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 615 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
616 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 616 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
617 | 617 | ||
618 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 618 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
619 | 619 | ||
620 | mEventEditor = mDialogManager->getEventEditor(); | 620 | mEventEditor = mDialogManager->getEventEditor(); |
621 | mTodoEditor = mDialogManager->getTodoEditor(); | 621 | mTodoEditor = mDialogManager->getTodoEditor(); |
622 | 622 | ||
623 | mFlagEditDescription = false; | 623 | mFlagEditDescription = false; |
624 | 624 | ||
625 | mSuspendTimer = new QTimer( this ); | 625 | mSuspendTimer = new QTimer( this ); |
626 | mAlarmTimer = new QTimer( this ); | 626 | mAlarmTimer = new QTimer( this ); |
627 | mRecheckAlarmTimer = new QTimer( this ); | 627 | mRecheckAlarmTimer = new QTimer( this ); |
628 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 628 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
629 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 629 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
630 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 630 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
631 | mAlarmDialog = new AlarmDialog( this ); | 631 | mAlarmDialog = new AlarmDialog( this ); |
632 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 632 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
633 | mAlarmDialog->setServerNotification( false ); | 633 | mAlarmDialog->setServerNotification( false ); |
634 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 634 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
635 | 635 | ||
636 | 636 | ||
637 | #ifndef DESKTOP_VERSION | 637 | #ifndef DESKTOP_VERSION |
638 | //US listen for arriving address resultsets | 638 | //US listen for arriving address resultsets |
639 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 639 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
640 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 640 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
641 | #endif | 641 | #endif |
642 | mDateNavigator->setCalendar( mCalendar ); | 642 | mDateNavigator->setCalendar( mCalendar ); |
643 | } | 643 | } |
644 | 644 | ||
645 | 645 | ||
646 | CalendarView::~CalendarView() | 646 | CalendarView::~CalendarView() |
647 | { | 647 | { |
648 | // kdDebug() << "~CalendarView()" << endl; | 648 | // kdDebug() << "~CalendarView()" << endl; |
649 | //qDebug("CalendarView::~CalendarView() "); | 649 | //qDebug("CalendarView::~CalendarView() "); |
650 | delete mDialogManager; | 650 | delete mDialogManager; |
651 | delete mViewManager; | 651 | delete mViewManager; |
652 | delete mStorage; | 652 | delete mStorage; |
653 | delete mDateFrame ; | 653 | delete mDateFrame ; |
654 | delete mEventViewerDialog; | 654 | delete mEventViewerDialog; |
655 | //kdDebug() << "~CalendarView() done" << endl; | 655 | //kdDebug() << "~CalendarView() done" << endl; |
656 | } | 656 | } |
657 | void CalendarView::nextConflict( bool all, bool allday ) | 657 | void CalendarView::nextConflict( bool all, bool allday ) |
658 | { | 658 | { |
659 | QDate start = mNavigator->selectedDates().first().addDays(1); | 659 | QDate start = mNavigator->selectedDates().first().addDays(1); |
660 | QDate end = start.addDays( 365*2); | 660 | QDate end = start.addDays( 365*2); |
661 | while ( start < end ) { | 661 | while ( start < end ) { |
662 | QPtrList<Event> eventList = calendar()->events( start ); | 662 | QPtrList<Event> eventList = calendar()->events( start ); |
663 | Event * ev = eventList.first(); | 663 | Event * ev = eventList.first(); |
664 | QPtrList<Event> test = eventList; | 664 | QPtrList<Event> test = eventList; |
665 | while ( ev ) { | 665 | while ( ev ) { |
666 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); | 666 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); |
667 | Event * t_ev = test.first(); | 667 | Event * t_ev = test.first(); |
668 | QDateTime es = ev->dtStart(); | 668 | QDateTime es = ev->dtStart(); |
669 | QDateTime ee = ev->dtEnd(); | 669 | QDateTime ee = ev->dtEnd(); |
670 | if ( ev->doesFloat() ) | 670 | if ( ev->doesFloat() ) |
671 | ee = ee.addDays( 1 ); | 671 | ee = ee.addDays( 1 ); |
672 | if ( ! all ) { | 672 | if ( ! all ) { |
673 | if ( ev->doesFloat() != allday ) | 673 | if ( ev->doesFloat() != allday ) |
674 | t_ev = 0; | 674 | t_ev = 0; |
675 | } | 675 | } |
676 | while ( t_ev ) { | 676 | while ( t_ev ) { |
677 | bool skip = false; | 677 | bool skip = false; |
678 | if ( ! all ) { | 678 | if ( ! all ) { |
679 | if ( t_ev->doesFloat() != allday ) | 679 | if ( t_ev->doesFloat() != allday ) |
680 | skip = true; | 680 | skip = true; |
681 | } | 681 | } |
682 | if ( !skip && ev != t_ev ) { | 682 | if ( !skip && ev != t_ev ) { |
683 | QDateTime ets = t_ev->dtStart(); | 683 | QDateTime ets = t_ev->dtStart(); |
684 | QDateTime ete = t_ev->dtEnd(); | 684 | QDateTime ete = t_ev->dtEnd(); |
685 | if ( t_ev->doesFloat() ) | 685 | if ( t_ev->doesFloat() ) |
686 | ete = ete.addDays( 1 ); | 686 | ete = ete.addDays( 1 ); |
687 | //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); | 687 | //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); |
688 | if ( es < ete && ets < ee ) { | 688 | if ( es < ete && ets < ee ) { |
689 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 689 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
690 | mViewManager->showDayView(); | 690 | mViewManager->showDayView(); |
691 | mNavigator->slotDaySelect( start ); | 691 | mNavigator->slotDaySelect( start ); |
692 | int hour = es.time().hour(); | 692 | int hour = es.time().hour(); |
693 | if ( ets > es ) | 693 | if ( ets > es ) |
694 | hour = ets.time().hour(); | 694 | hour = ets.time().hour(); |
695 | mViewManager->agendaView()->setStartHour( hour ); | 695 | mViewManager->agendaView()->setStartHour( hour ); |
696 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); | 696 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); |
697 | return; | 697 | return; |
698 | } | 698 | } |
699 | } | 699 | } |
700 | t_ev = test.next(); | 700 | t_ev = test.next(); |
701 | } | 701 | } |
702 | ev = eventList.next(); | 702 | ev = eventList.next(); |
703 | } | 703 | } |
704 | start = start.addDays( 1 ); | 704 | start = start.addDays( 1 ); |
705 | } | 705 | } |
706 | topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); | 706 | topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); |
707 | qDebug("No conflict found "); | 707 | qDebug("No conflict found "); |
708 | } | 708 | } |
709 | 709 | ||
710 | void CalendarView::conflictAll() | 710 | void CalendarView::conflictAll() |
711 | { | 711 | { |
712 | nextConflict ( true, true ); | 712 | nextConflict ( true, true ); |
713 | } | 713 | } |
714 | void CalendarView::conflictAllday() | 714 | void CalendarView::conflictAllday() |
715 | { | 715 | { |
716 | nextConflict ( false, true ); | 716 | nextConflict ( false, true ); |
717 | } | 717 | } |
718 | void CalendarView::conflictNotAll() | 718 | void CalendarView::conflictNotAll() |
719 | { | 719 | { |
720 | nextConflict ( false, false ); | 720 | nextConflict ( false, false ); |
721 | } | 721 | } |
722 | 722 | ||
723 | void CalendarView::setCalReadOnly( int id, bool readO ) | 723 | void CalendarView::setCalReadOnly( int id, bool readO ) |
724 | { | 724 | { |
725 | if ( readO ) { | 725 | if ( readO ) { |
726 | emit save(); | 726 | emit save(); |
727 | } | 727 | } |
728 | mCalendar->setReadOnly( id, readO ); | 728 | mCalendar->setReadOnly( id, readO ); |
729 | } | 729 | } |
730 | void CalendarView::setScrollBarStep(int val ) | 730 | void CalendarView::setScrollBarStep(int val ) |
731 | { | 731 | { |
732 | #ifdef DESKTOP_VERSION | 732 | #ifdef DESKTOP_VERSION |
733 | mDateScrollBar->setLineStep ( val ); | 733 | mDateScrollBar->setLineStep ( val ); |
734 | #endif | 734 | #endif |
735 | } | 735 | } |
736 | void CalendarView::scrollBarValue(int val ) | 736 | void CalendarView::scrollBarValue(int val ) |
737 | { | 737 | { |
738 | #ifdef DESKTOP_VERSION | 738 | #ifdef DESKTOP_VERSION |
739 | if ( QApplication::desktop()->width() < 800 ) return; | 739 | if ( QApplication::desktop()->width() < 800 ) return; |
740 | static bool block = false; | 740 | static bool block = false; |
741 | if ( block ) return; | 741 | if ( block ) return; |
742 | block = true; | 742 | block = true; |
743 | int count = mNavigator->selectedDates().count(); | 743 | int count = mNavigator->selectedDates().count(); |
744 | int day = mNavigator->selectedDates().first().dayOfYear(); | 744 | int day = mNavigator->selectedDates().first().dayOfYear(); |
745 | int stepdays = val; | 745 | int stepdays = val; |
746 | if ( mDateScrollBar->lineStep () <= count ) { | 746 | if ( mDateScrollBar->lineStep () <= count ) { |
747 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 747 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
748 | //qDebug("VAL %d ",val ); | 748 | //qDebug("VAL %d ",val ); |
749 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 749 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
750 | stepdays = day+stepdays; | 750 | stepdays = day+stepdays; |
751 | if ( stepdays < 0 ) stepdays = 0; | 751 | if ( stepdays < 0 ) stepdays = 0; |
752 | } | 752 | } |
753 | if ( stepdays == day ) { | 753 | if ( stepdays == day ) { |
754 | block = false; | 754 | block = false; |
755 | return; | 755 | return; |
756 | } | 756 | } |
757 | int year = mNavigator->selectedDates().first().year(); | 757 | int year = mNavigator->selectedDates().first().year(); |
758 | QDate d ( year,1,1 ); | 758 | QDate d ( year,1,1 ); |
759 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 759 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
760 | block = false; | 760 | block = false; |
761 | #endif | 761 | #endif |
762 | 762 | ||
763 | } | 763 | } |
764 | void CalendarView::updateView(const QDate &start, const QDate &end) | 764 | void CalendarView::updateView(const QDate &start, const QDate &end) |
765 | { | 765 | { |
766 | #ifdef DESKTOP_VERSION | 766 | #ifdef DESKTOP_VERSION |
767 | if ( ! mDateScrollBar->draggingSlider () ) { | 767 | if ( ! mDateScrollBar->draggingSlider () ) { |
768 | int dof = start.dayOfYear(); | 768 | int dof = start.dayOfYear(); |
769 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 769 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
770 | if ( dof != mDateScrollBar->value() ) { | 770 | if ( dof != mDateScrollBar->value() ) { |
771 | mDateScrollBar->blockSignals( true ); | 771 | mDateScrollBar->blockSignals( true ); |
772 | mDateScrollBar->setValue( start.dayOfYear()); | 772 | mDateScrollBar->setValue( start.dayOfYear()); |
773 | mDateScrollBar->blockSignals( false ); | 773 | mDateScrollBar->blockSignals( false ); |
774 | } | 774 | } |
775 | } | 775 | } |
776 | #endif | 776 | #endif |
777 | mTodoList->updateView(); | 777 | mTodoList->updateView(); |
778 | mViewManager->updateView(start, end); | 778 | mViewManager->updateView(start, end); |
779 | //mDateNavigator->updateView(); | 779 | //mDateNavigator->updateView(); |
780 | } | 780 | } |
781 | 781 | ||
782 | 782 | ||
783 | 783 | ||
784 | void CalendarView::checkFiles() | 784 | void CalendarView::checkFiles() |
785 | { | 785 | { |
786 | QString message; | 786 | QString message; |
787 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 787 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
788 | KopiCalendarFile * cal = calendars.first(); | 788 | KopiCalendarFile * cal = calendars.first(); |
789 | while ( cal ) { | 789 | while ( cal ) { |
790 | if ( cal->mErrorOnLoad ) { | 790 | if ( cal->mErrorOnLoad ) { |
791 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 791 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
792 | } | 792 | } |
793 | cal = calendars.next(); | 793 | cal = calendars.next(); |
794 | } | 794 | } |
795 | if ( !message.isEmpty() ) { | 795 | if ( !message.isEmpty() ) { |
796 | 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); | 796 | 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); |
797 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 797 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
798 | } | 798 | } |
799 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 799 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
800 | } | 800 | } |
801 | void CalendarView::checkAlarms() | 801 | void CalendarView::checkAlarms() |
802 | { | 802 | { |
803 | 803 | ||
804 | 804 | ||
805 | KConfig *config = KOGlobals::config(); | 805 | KConfig *config = KOGlobals::config(); |
806 | config->setGroup( "AppRun" ); | 806 | config->setGroup( "AppRun" ); |
807 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 807 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
808 | int daysto = dt.daysTo( QDate::currentDate() ); | 808 | int daysto = dt.daysTo( QDate::currentDate() ); |
809 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 809 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
810 | dt = dt.addDays( days ); | 810 | dt = dt.addDays( days ); |
811 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 811 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
812 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 812 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
813 | //qDebug("KO: Reading program stop %d ", secs); | 813 | //qDebug("KO: Reading program stop %d ", secs); |
814 | //secs -= ( 3600 * 24*3 ); // debug only | 814 | //secs -= ( 3600 * 24*3 ); // debug only |
815 | QDateTime latest = dt.addSecs ( secs ); | 815 | QDateTime latest = dt.addSecs ( secs ); |
816 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 816 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
817 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 817 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
818 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 818 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
819 | QPtrList<Incidence> al; | 819 | QPtrList<Incidence> al; |
820 | Incidence* inL = el.first(); | 820 | Incidence* inL = el.first(); |
821 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 821 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
822 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 822 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
823 | while ( inL ) { | 823 | while ( inL ) { |
824 | bool ok = false; | 824 | bool ok = false; |
825 | int offset = 0; | 825 | int offset = 0; |
826 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 826 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
827 | if ( ok ) { | 827 | if ( ok ) { |
828 | //qDebug("OK %s",next.toString().latin1()); | 828 | //qDebug("OK %s",next.toString().latin1()); |
829 | if ( next < cur ) { | 829 | if ( next < cur ) { |
830 | al.append( inL ); | 830 | al.append( inL ); |
831 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 831 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
832 | } | 832 | } |
833 | } | 833 | } |
834 | inL = el.next(); | 834 | inL = el.next(); |
835 | } | 835 | } |
836 | if ( al.count() ) { | 836 | if ( al.count() ) { |
837 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 837 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
838 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 838 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
839 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 839 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
840 | lay->setSpacing( 0 ); | 840 | lay->setSpacing( 0 ); |
841 | lay->setMargin( 0 ); | 841 | lay->setMargin( 0 ); |
842 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 842 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
843 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 843 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
844 | lay->addWidget( matb ); | 844 | lay->addWidget( matb ); |
845 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 845 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
846 | int wid = 210; | 846 | int wid = 210; |
847 | int x = QApplication::desktop()->width() - wid - 7; | 847 | int x = QApplication::desktop()->width() - wid - 7; |
848 | int y = QApplication::desktop()->height() - wid - 70; | 848 | int y = QApplication::desktop()->height() - wid - 70; |
849 | dia->setGeometry ( x,y,wid,wid); | 849 | dia->setGeometry ( x,y,wid,wid); |
850 | } else { | 850 | } else { |
851 | int si = 220; | 851 | int si = 220; |
852 | if ( QApplication::desktop()->width() > 470 ) | 852 | if ( QApplication::desktop()->width() > 470 ) |
853 | si = 400; | 853 | si = 400; |
854 | dia->resize(si,si/2); | 854 | dia->resize(si,si/2); |
855 | } | 855 | } |
856 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 856 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
857 | dia->show(); | 857 | dia->show(); |
858 | 858 | ||
859 | } | 859 | } |
860 | } | 860 | } |
861 | void CalendarView::showDay( QDate d ) | 861 | void CalendarView::showDay( QDate d ) |
862 | { | 862 | { |
863 | dateNavigator()->blockSignals( true ); | 863 | dateNavigator()->blockSignals( true ); |
864 | dateNavigator()->selectDate( d ); | 864 | dateNavigator()->selectDate( d ); |
865 | dateNavigator()->blockSignals( false ); | 865 | dateNavigator()->blockSignals( false ); |
866 | mViewManager->showDayView(); | 866 | mViewManager->showDayView(); |
867 | //dateNavigator()->selectDate( d ); | 867 | //dateNavigator()->selectDate( d ); |
868 | } | 868 | } |
869 | void CalendarView::timerAlarm() | 869 | void CalendarView::timerAlarm() |
870 | { | 870 | { |
871 | //qDebug("CalendarView::timerAlarm() "); | 871 | //qDebug("CalendarView::timerAlarm() "); |
872 | computeAlarm(mAlarmNotification ); | 872 | computeAlarm(mAlarmNotification ); |
873 | } | 873 | } |
874 | 874 | ||
875 | void CalendarView::suspendAlarm() | 875 | void CalendarView::suspendAlarm() |
876 | { | 876 | { |
877 | //qDebug(" CalendarView::suspendAlarm() "); | 877 | //qDebug(" CalendarView::suspendAlarm() "); |
878 | computeAlarm(mSuspendAlarmNotification ); | 878 | computeAlarm(mSuspendAlarmNotification ); |
879 | 879 | ||
880 | } | 880 | } |
881 | 881 | ||
882 | void CalendarView::startAlarm( QString mess , QString filename) | 882 | void CalendarView::startAlarm( QString mess , QString filename) |
883 | { | 883 | { |
884 | 884 | ||
885 | topLevelWidget()->showNormal(); | 885 | topLevelWidget()->showNormal(); |
886 | topLevelWidget()->setActiveWindow(); | 886 | topLevelWidget()->setActiveWindow(); |
887 | topLevelWidget()->raise(); | 887 | topLevelWidget()->raise(); |
888 | 888 | ||
889 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 889 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
890 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 890 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
891 | 891 | ||
892 | } | 892 | } |
893 | 893 | ||
894 | void CalendarView::checkNextTimerAlarm() | 894 | void CalendarView::checkNextTimerAlarm() |
895 | { | 895 | { |
896 | mCalendar->checkAlarmForIncidence( 0, true ); | 896 | mCalendar->checkAlarmForIncidence( 0, true ); |
897 | } | 897 | } |
898 | 898 | ||
899 | void CalendarView::computeAlarm( QString msg ) | 899 | void CalendarView::computeAlarm( QString msg ) |
900 | { | 900 | { |
901 | 901 | ||
902 | QString mess = msg; | 902 | QString mess = msg; |
903 | QString mAlarmMessage = mess.mid( 9 ); | 903 | QString mAlarmMessage = mess.mid( 9 ); |
904 | QString filename = MainWindow::resourcePath(); | 904 | QString filename = MainWindow::resourcePath(); |
905 | filename += "koalarm.wav"; | 905 | filename += "koalarm.wav"; |
906 | QString tempfilename; | 906 | QString tempfilename; |
907 | if ( mess.left( 13 ) == "suspend_alarm") { | 907 | if ( mess.left( 13 ) == "suspend_alarm") { |
908 | bool error = false; | 908 | bool error = false; |
909 | int len = mess.mid( 13 ).find("+++"); | 909 | int len = mess.mid( 13 ).find("+++"); |
910 | if ( len < 2 ) | 910 | if ( len < 2 ) |
911 | error = true; | 911 | error = true; |
912 | else { | 912 | else { |
913 | tempfilename = mess.mid( 13, len ); | 913 | tempfilename = mess.mid( 13, len ); |
914 | if ( !QFile::exists( tempfilename ) ) | 914 | if ( !QFile::exists( tempfilename ) ) |
915 | error = true; | 915 | error = true; |
916 | } | 916 | } |
917 | if ( ! error ) { | 917 | if ( ! error ) { |
918 | filename = tempfilename; | 918 | filename = tempfilename; |
919 | } | 919 | } |
920 | mAlarmMessage = mess.mid( 13+len+3 ); | 920 | mAlarmMessage = mess.mid( 13+len+3 ); |
921 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 921 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
922 | startAlarm( mAlarmMessage, filename); | 922 | startAlarm( mAlarmMessage, filename); |
923 | return; | 923 | return; |
924 | } | 924 | } |
925 | if ( mess.left( 11 ) == "timer_alarm") { | 925 | if ( mess.left( 11 ) == "timer_alarm") { |
926 | //mTimerTime = 0; | 926 | //mTimerTime = 0; |
927 | startAlarm( mess.mid( 11 ), filename ); | 927 | startAlarm( mess.mid( 11 ), filename ); |
928 | return; | 928 | return; |
929 | } | 929 | } |
930 | if ( mess.left( 10 ) == "proc_alarm") { | 930 | if ( mess.left( 10 ) == "proc_alarm") { |
931 | bool error = false; | 931 | bool error = false; |
932 | int len = mess.mid( 10 ).find("+++"); | 932 | int len = mess.mid( 10 ).find("+++"); |
933 | if ( len < 2 ) | 933 | if ( len < 2 ) |
934 | error = true; | 934 | error = true; |
935 | else { | 935 | else { |
936 | tempfilename = mess.mid( 10, len ); | 936 | tempfilename = mess.mid( 10, len ); |
937 | if ( !QFile::exists( tempfilename ) ) | 937 | if ( !QFile::exists( tempfilename ) ) |
938 | error = true; | 938 | error = true; |
939 | } | 939 | } |
940 | if ( error ) { | 940 | if ( error ) { |
941 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 941 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
942 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 942 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
943 | } else { | 943 | } else { |
944 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 944 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
945 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 945 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
946 | #ifndef _WIN32_ | 946 | #ifndef _WIN32_ |
947 | if ( vfork () == 0 ) { | 947 | if ( vfork () == 0 ) { |
948 | execl ( tempfilename.latin1(), 0 ); | 948 | execl ( tempfilename.latin1(), 0 ); |
949 | return; | 949 | return; |
950 | } | 950 | } |
951 | #else | 951 | #else |
952 | QProcess* p = new QProcess(); | 952 | QProcess* p = new QProcess(); |
953 | p->addArgument( tempfilename.latin1() ); | 953 | p->addArgument( tempfilename.latin1() ); |
954 | p->start(); | 954 | p->start(); |
955 | return; | 955 | return; |
956 | #endif | 956 | #endif |
957 | 957 | ||
958 | return; | 958 | return; |
959 | } | 959 | } |
960 | 960 | ||
961 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 961 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
962 | } | 962 | } |
963 | if ( mess.left( 11 ) == "audio_alarm") { | 963 | if ( mess.left( 11 ) == "audio_alarm") { |
964 | bool error = false; | 964 | bool error = false; |
965 | int len = mess.mid( 11 ).find("+++"); | 965 | int len = mess.mid( 11 ).find("+++"); |
966 | if ( len < 2 ) | 966 | if ( len < 2 ) |
967 | error = true; | 967 | error = true; |
968 | else { | 968 | else { |
969 | tempfilename = mess.mid( 11, len ); | 969 | tempfilename = mess.mid( 11, len ); |
970 | if ( !QFile::exists( tempfilename ) ) | 970 | if ( !QFile::exists( tempfilename ) ) |
971 | error = true; | 971 | error = true; |
972 | } | 972 | } |
973 | if ( ! error ) { | 973 | if ( ! error ) { |
974 | filename = tempfilename; | 974 | filename = tempfilename; |
975 | } | 975 | } |
976 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 976 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
977 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 977 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
978 | } | 978 | } |
979 | if ( mess.left( 9 ) == "cal_alarm") { | 979 | if ( mess.left( 9 ) == "cal_alarm") { |
980 | mAlarmMessage = mess.mid( 9 ) ; | 980 | mAlarmMessage = mess.mid( 9 ) ; |
981 | } | 981 | } |
982 | 982 | ||
983 | startAlarm( mAlarmMessage, filename ); | 983 | startAlarm( mAlarmMessage, filename ); |
984 | 984 | ||
985 | 985 | ||
986 | } | 986 | } |
987 | 987 | ||
988 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 988 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
989 | { | 989 | { |
990 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 990 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
991 | 991 | ||
992 | mSuspendAlarmNotification = noti; | 992 | mSuspendAlarmNotification = noti; |
993 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 993 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
994 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 994 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
995 | mSuspendTimer->start( ms , true ); | 995 | mSuspendTimer->start( ms , true ); |
996 | 996 | ||
997 | } | 997 | } |
998 | 998 | ||
999 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 999 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1000 | { | 1000 | { |
1001 | mNextAlarmDateTime = qdt; | 1001 | mNextAlarmDateTime = qdt; |
1002 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1002 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1003 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1003 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1004 | #ifndef DESKTOP_VERSION | 1004 | #ifndef DESKTOP_VERSION |
1005 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1005 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1006 | #endif | 1006 | #endif |
1007 | return; | 1007 | return; |
1008 | } | 1008 | } |
1009 | int maxSec; | 1009 | int maxSec; |
1010 | //maxSec = 5; //testing only | 1010 | //maxSec = 5; //testing only |
1011 | maxSec = 86400+3600; // one day+1hour | 1011 | maxSec = 86400+3600; // one day+1hour |
1012 | mAlarmNotification = noti; | 1012 | mAlarmNotification = noti; |
1013 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1013 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1014 | if ( sec > maxSec ) { | 1014 | if ( sec > maxSec ) { |
1015 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1015 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1016 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1016 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1017 | return; | 1017 | return; |
1018 | } else { | 1018 | } else { |
1019 | mRecheckAlarmTimer->stop(); | 1019 | mRecheckAlarmTimer->stop(); |
1020 | } | 1020 | } |
1021 | //qDebug("Alarm timer started with secs: %d ", sec); | 1021 | //qDebug("Alarm timer started with secs: %d ", sec); |
1022 | mAlarmTimer->start( sec *1000 , true ); | 1022 | mAlarmTimer->start( sec *1000 , true ); |
1023 | 1023 | ||
1024 | } | 1024 | } |
1025 | // called by mRecheckAlarmTimer to get next alarm | 1025 | // called by mRecheckAlarmTimer to get next alarm |
1026 | // we need this, because a QTimer has only a max range of 25 days | 1026 | // we need this, because a QTimer has only a max range of 25 days |
1027 | void CalendarView::recheckTimerAlarm() | 1027 | void CalendarView::recheckTimerAlarm() |
1028 | { | 1028 | { |
1029 | mAlarmTimer->stop(); | 1029 | mAlarmTimer->stop(); |
1030 | mRecheckAlarmTimer->stop(); | 1030 | mRecheckAlarmTimer->stop(); |
1031 | mCalendar->checkAlarmForIncidence( 0, true ); | 1031 | mCalendar->checkAlarmForIncidence( 0, true ); |
1032 | } | 1032 | } |
1033 | #ifndef DESKTOP_VERSION | 1033 | #ifndef DESKTOP_VERSION |
1034 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1034 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1035 | #else | 1035 | #else |
1036 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1036 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1037 | #endif | 1037 | #endif |
1038 | { | 1038 | { |
1039 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1039 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1040 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1040 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1041 | #ifndef DESKTOP_VERSION | 1041 | #ifndef DESKTOP_VERSION |
1042 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1042 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1043 | #endif | 1043 | #endif |
1044 | return; | 1044 | return; |
1045 | } | 1045 | } |
1046 | mAlarmTimer->stop(); | 1046 | mAlarmTimer->stop(); |
1047 | } | 1047 | } |
1048 | void CalendarView::selectWeekNum ( int num ) | 1048 | void CalendarView::selectWeekNum ( int num ) |
1049 | { | 1049 | { |
1050 | dateNavigator()->blockSignals( true ); | 1050 | dateNavigator()->blockSignals( true ); |
1051 | dateNavigator()->selectWeek( num ); | 1051 | dateNavigator()->selectWeek( num ); |
1052 | dateNavigator()->blockSignals( false ); | 1052 | dateNavigator()->blockSignals( false ); |
1053 | mViewManager->showWeekView(); | 1053 | mViewManager->showWeekView(); |
1054 | } | 1054 | } |
1055 | KOViewManager *CalendarView::viewManager() | 1055 | KOViewManager *CalendarView::viewManager() |
1056 | { | 1056 | { |
1057 | return mViewManager; | 1057 | return mViewManager; |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | KODialogManager *CalendarView::dialogManager() | 1060 | KODialogManager *CalendarView::dialogManager() |
1061 | { | 1061 | { |
1062 | return mDialogManager; | 1062 | return mDialogManager; |
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | QDate CalendarView::startDate() | 1065 | QDate CalendarView::startDate() |
1066 | { | 1066 | { |
1067 | DateList dates = mNavigator->selectedDates(); | 1067 | DateList dates = mNavigator->selectedDates(); |
1068 | 1068 | ||
1069 | return dates.first(); | 1069 | return dates.first(); |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | QDate CalendarView::endDate() | 1072 | QDate CalendarView::endDate() |
1073 | { | 1073 | { |
1074 | DateList dates = mNavigator->selectedDates(); | 1074 | DateList dates = mNavigator->selectedDates(); |
1075 | 1075 | ||
1076 | return dates.last(); | 1076 | return dates.last(); |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | 1079 | ||
1080 | void CalendarView::createPrinter() | 1080 | void CalendarView::createPrinter() |
1081 | { | 1081 | { |
1082 | #ifndef KORG_NOPRINTER | 1082 | #ifndef KORG_NOPRINTER |
1083 | if (!mCalPrinter) { | 1083 | if (!mCalPrinter) { |
1084 | mCalPrinter = new CalPrinter(this, mCalendar); | 1084 | mCalPrinter = new CalPrinter(this, mCalendar); |
1085 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1085 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1086 | } | 1086 | } |
1087 | #endif | 1087 | #endif |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | 1090 | ||
1091 | //KOPrefs::instance()->mWriteBackFile | 1091 | //KOPrefs::instance()->mWriteBackFile |
1092 | //KOPrefs::instance()->mWriteBackExistingOnly | 1092 | //KOPrefs::instance()->mWriteBackExistingOnly |
1093 | 1093 | ||
1094 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1094 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1095 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1095 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1096 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1096 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1097 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1097 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1098 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1098 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1099 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1099 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1100 | 1100 | ||
1101 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1101 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1102 | { | 1102 | { |
1103 | 1103 | ||
1104 | // 0 equal | 1104 | // 0 equal |
1105 | // 1 take local | 1105 | // 1 take local |
1106 | // 2 take remote | 1106 | // 2 take remote |
1107 | // 3 cancel | 1107 | // 3 cancel |
1108 | QDateTime lastSync = mLastCalendarSync; | 1108 | QDateTime lastSync = mLastCalendarSync; |
1109 | QDateTime localMod = local->lastModified(); | 1109 | QDateTime localMod = local->lastModified(); |
1110 | QDateTime remoteMod = remote->lastModified(); | 1110 | QDateTime remoteMod = remote->lastModified(); |
1111 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1111 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1112 | bool remCh, locCh; | 1112 | bool remCh, locCh; |
1113 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1113 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1114 | //if ( remCh ) | 1114 | //if ( remCh ) |
1115 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1115 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1116 | locCh = ( localMod > mLastCalendarSync ); | 1116 | locCh = ( localMod > mLastCalendarSync ); |
1117 | if ( !remCh && ! locCh ) { | 1117 | if ( !remCh && ! locCh ) { |
1118 | //qDebug("both not changed "); | 1118 | //qDebug("both not changed "); |
1119 | lastSync = localMod.addDays(1); | 1119 | lastSync = localMod.addDays(1); |
1120 | if ( mode <= SYNC_PREF_ASK ) | 1120 | if ( mode <= SYNC_PREF_ASK ) |
1121 | return 0; | 1121 | return 0; |
1122 | } else { | 1122 | } else { |
1123 | if ( locCh ) { | 1123 | if ( locCh ) { |
1124 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1124 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1125 | lastSync = localMod.addDays( -1 ); | 1125 | lastSync = localMod.addDays( -1 ); |
1126 | if ( !remCh ) | 1126 | if ( !remCh ) |
1127 | remoteMod = ( lastSync.addDays( -1 ) ); | 1127 | remoteMod = ( lastSync.addDays( -1 ) ); |
1128 | } else { | 1128 | } else { |
1129 | //qDebug(" not loc changed "); | 1129 | //qDebug(" not loc changed "); |
1130 | lastSync = localMod.addDays( 1 ); | 1130 | lastSync = localMod.addDays( 1 ); |
1131 | if ( remCh ) | 1131 | if ( remCh ) |
1132 | remoteMod =( lastSync.addDays( 1 ) ); | 1132 | remoteMod =( lastSync.addDays( 1 ) ); |
1133 | 1133 | ||
1134 | } | 1134 | } |
1135 | } | 1135 | } |
1136 | full = true; | 1136 | full = true; |
1137 | if ( mode < SYNC_PREF_ASK ) | 1137 | if ( mode < SYNC_PREF_ASK ) |
1138 | mode = SYNC_PREF_ASK; | 1138 | mode = SYNC_PREF_ASK; |
1139 | } else { | 1139 | } else { |
1140 | if ( localMod == remoteMod ) | 1140 | if ( localMod == remoteMod ) |
1141 | // if ( local->revision() == remote->revision() ) | 1141 | // if ( local->revision() == remote->revision() ) |
1142 | return 0; | 1142 | return 0; |
1143 | 1143 | ||
1144 | } | 1144 | } |
1145 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1145 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1146 | 1146 | ||
1147 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1147 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1148 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1148 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1149 | //full = true; //debug only | 1149 | //full = true; //debug only |
1150 | if ( full ) { | 1150 | if ( full ) { |
1151 | bool equ = false; | 1151 | bool equ = false; |
1152 | if ( local->typeID() == eventID ) { | 1152 | if ( local->typeID() == eventID ) { |
1153 | equ = (*((Event*) local) == *((Event*) remote)); | 1153 | equ = (*((Event*) local) == *((Event*) remote)); |
1154 | } | 1154 | } |
1155 | else if ( local->typeID() == todoID ) | 1155 | else if ( local->typeID() == todoID ) |
1156 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1156 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1157 | else if ( local->typeID() == journalID ) | 1157 | else if ( local->typeID() == journalID ) |
1158 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1158 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1159 | if ( equ ) { | 1159 | if ( equ ) { |
1160 | //qDebug("equal "); | 1160 | //qDebug("equal "); |
1161 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1161 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1162 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1162 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1163 | } | 1163 | } |
1164 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1164 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1165 | return 0; | 1165 | return 0; |
1166 | 1166 | ||
1167 | }//else //debug only | 1167 | }//else //debug only |
1168 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1168 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1169 | } | 1169 | } |
1170 | int result; | 1170 | int result; |
1171 | bool localIsNew; | 1171 | bool localIsNew; |
1172 | //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() ); | 1172 | //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() ); |
1173 | 1173 | ||
1174 | 1174 | ||
1175 | // ************************************************ | 1175 | // ************************************************ |
1176 | // ************************************************ | 1176 | // ************************************************ |
1177 | // ************************************************ | 1177 | // ************************************************ |
1178 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1178 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1179 | // BUT remoteMod != localMod | 1179 | // BUT remoteMod != localMod |
1180 | 1180 | ||
1181 | 1181 | ||
1182 | if ( full && mode < SYNC_PREF_NEWEST ) | 1182 | if ( full && mode < SYNC_PREF_NEWEST ) |
1183 | mode = SYNC_PREF_ASK; | 1183 | mode = SYNC_PREF_ASK; |
1184 | 1184 | ||
1185 | switch( mode ) { | 1185 | switch( mode ) { |
1186 | case SYNC_PREF_LOCAL: | 1186 | case SYNC_PREF_LOCAL: |
1187 | if ( lastSync > remoteMod ) | 1187 | if ( lastSync > remoteMod ) |
1188 | return 1; | 1188 | return 1; |
1189 | if ( lastSync > localMod ) | 1189 | if ( lastSync > localMod ) |
1190 | return 2; | 1190 | return 2; |
1191 | return 1; | 1191 | return 1; |
1192 | break; | 1192 | break; |
1193 | case SYNC_PREF_REMOTE: | 1193 | case SYNC_PREF_REMOTE: |
1194 | if ( lastSync > localMod ) | 1194 | if ( lastSync > localMod ) |
1195 | return 2; | 1195 | return 2; |
1196 | if ( lastSync > remoteMod ) | 1196 | if ( lastSync > remoteMod ) |
1197 | return 1; | 1197 | return 1; |
1198 | return 2; | 1198 | return 2; |
1199 | break; | 1199 | break; |
1200 | case SYNC_PREF_NEWEST: | 1200 | case SYNC_PREF_NEWEST: |
1201 | if ( localMod >= remoteMod ) | 1201 | if ( localMod >= remoteMod ) |
1202 | return 1; | 1202 | return 1; |
1203 | else | 1203 | else |
1204 | return 2; | 1204 | return 2; |
1205 | break; | 1205 | break; |
1206 | case SYNC_PREF_ASK: | 1206 | case SYNC_PREF_ASK: |
1207 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1207 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1208 | if ( lastSync > remoteMod && lastSync > localMod) | 1208 | if ( lastSync > remoteMod && lastSync > localMod) |
1209 | return 0; | 1209 | return 0; |
1210 | if ( lastSync > remoteMod ) | 1210 | if ( lastSync > remoteMod ) |
1211 | return 1; | 1211 | return 1; |
1212 | if ( lastSync > localMod ) | 1212 | if ( lastSync > localMod ) |
1213 | return 2; | 1213 | return 2; |
1214 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1214 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1215 | localIsNew = localMod >= remoteMod; | 1215 | localIsNew = localMod >= remoteMod; |
1216 | if ( localIsNew ) | 1216 | if ( localIsNew ) |
1217 | getEventViewerDialog()->setColorMode( 1 ); | 1217 | getEventViewerDialog()->setColorMode( 1 ); |
1218 | else | 1218 | else |
1219 | getEventViewerDialog()->setColorMode( 2 ); | 1219 | getEventViewerDialog()->setColorMode( 2 ); |
1220 | getEventViewerDialog()->setIncidence(local); | 1220 | getEventViewerDialog()->setIncidence(local); |
1221 | if ( localIsNew ) | 1221 | if ( localIsNew ) |
1222 | getEventViewerDialog()->setColorMode( 2 ); | 1222 | getEventViewerDialog()->setColorMode( 2 ); |
1223 | else | 1223 | else |
1224 | getEventViewerDialog()->setColorMode( 1 ); | 1224 | getEventViewerDialog()->setColorMode( 1 ); |
1225 | getEventViewerDialog()->addIncidence(remote); | 1225 | getEventViewerDialog()->addIncidence(remote); |
1226 | getEventViewerDialog()->setColorMode( 0 ); | 1226 | getEventViewerDialog()->setColorMode( 0 ); |
1227 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1227 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1228 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1228 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1229 | getEventViewerDialog()->showMe(); | 1229 | getEventViewerDialog()->showMe(); |
1230 | result = getEventViewerDialog()->executeS( localIsNew ); | 1230 | result = getEventViewerDialog()->executeS( localIsNew ); |
1231 | return result; | 1231 | return result; |
1232 | 1232 | ||
1233 | break; | 1233 | break; |
1234 | case SYNC_PREF_FORCE_LOCAL: | 1234 | case SYNC_PREF_FORCE_LOCAL: |
1235 | return 1; | 1235 | return 1; |
1236 | break; | 1236 | break; |
1237 | case SYNC_PREF_FORCE_REMOTE: | 1237 | case SYNC_PREF_FORCE_REMOTE: |
1238 | return 2; | 1238 | return 2; |
1239 | break; | 1239 | break; |
1240 | 1240 | ||
1241 | default: | 1241 | default: |
1242 | // SYNC_PREF_TAKE_BOTH not implemented | 1242 | // SYNC_PREF_TAKE_BOTH not implemented |
1243 | break; | 1243 | break; |
1244 | } | 1244 | } |
1245 | return 0; | 1245 | return 0; |
1246 | } | 1246 | } |
1247 | Event* CalendarView::getLastSyncEvent() | 1247 | Event* CalendarView::getLastSyncEvent() |
1248 | { | 1248 | { |
1249 | Event* lse; | 1249 | Event* lse; |
1250 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1250 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1251 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1251 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1252 | if (!lse) { | 1252 | if (!lse) { |
1253 | lse = new Event(); | 1253 | lse = new Event(); |
1254 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1254 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1255 | QString sum = ""; | 1255 | QString sum = ""; |
1256 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1256 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1257 | sum = "E: "; | 1257 | sum = "E: "; |
1258 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1258 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1259 | lse->setDtStart( mLastCalendarSync ); | 1259 | lse->setDtStart( mLastCalendarSync ); |
1260 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1260 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1261 | lse->setCategories( i18n("SyncEvent") ); | 1261 | lse->setCategories( i18n("SyncEvent") ); |
1262 | lse->setReadOnly( true ); | 1262 | lse->setReadOnly( true ); |
1263 | mCalendar->addEvent( lse ); | 1263 | mCalendar->addEvent( lse ); |
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | return lse; | 1266 | return lse; |
1267 | 1267 | ||
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | // we check, if the to delete event has a id for a profile | 1270 | // we check, if the to delete event has a id for a profile |
1271 | // if yes, we set this id in the profile to delete | 1271 | // if yes, we set this id in the profile to delete |
1272 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1272 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1273 | { | 1273 | { |
1274 | if ( lastSync.count() == 0 ) { | 1274 | if ( lastSync.count() == 0 ) { |
1275 | //qDebug(" lastSync.count() == 0"); | 1275 | //qDebug(" lastSync.count() == 0"); |
1276 | return; | 1276 | return; |
1277 | } | 1277 | } |
1278 | if ( toDelete->typeID() == journalID ) | 1278 | if ( toDelete->typeID() == journalID ) |
1279 | return; | 1279 | return; |
1280 | 1280 | ||
1281 | Event* eve = lastSync.first(); | 1281 | Event* eve = lastSync.first(); |
1282 | 1282 | ||
1283 | while ( eve ) { | 1283 | while ( eve ) { |
1284 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1284 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1285 | if ( !id.isEmpty() ) { | 1285 | if ( !id.isEmpty() ) { |
1286 | QString des = eve->description(); | 1286 | QString des = eve->description(); |
1287 | QString pref = "e"; | 1287 | QString pref = "e"; |
1288 | if ( toDelete->typeID() == todoID ) | 1288 | if ( toDelete->typeID() == todoID ) |
1289 | pref = "t"; | 1289 | pref = "t"; |
1290 | des += pref+ id + ","; | 1290 | des += pref+ id + ","; |
1291 | eve->setReadOnly( false ); | 1291 | eve->setReadOnly( false ); |
1292 | eve->setDescription( des ); | 1292 | eve->setDescription( des ); |
1293 | //qDebug("setdes %s ", des.latin1()); | 1293 | //qDebug("setdes %s ", des.latin1()); |
1294 | eve->setReadOnly( true ); | 1294 | eve->setReadOnly( true ); |
1295 | } | 1295 | } |
1296 | eve = lastSync.next(); | 1296 | eve = lastSync.next(); |
1297 | } | 1297 | } |
1298 | 1298 | ||
1299 | } | 1299 | } |
1300 | void CalendarView::checkExternalId( Incidence * inc ) | 1300 | void CalendarView::checkExternalId( Incidence * inc ) |
1301 | { | 1301 | { |
1302 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1302 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1303 | checkExternSyncEvent( lastSync, inc ); | 1303 | checkExternSyncEvent( lastSync, inc ); |
1304 | 1304 | ||
1305 | } | 1305 | } |
1306 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1306 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1307 | { | 1307 | { |
1308 | bool syncOK = true; | 1308 | bool syncOK = true; |
1309 | int addedEvent = 0; | 1309 | int addedEvent = 0; |
1310 | int addedEventR = 0; | 1310 | int addedEventR = 0; |
1311 | int deletedEventR = 0; | 1311 | int deletedEventR = 0; |
1312 | int deletedEventL = 0; | 1312 | int deletedEventL = 0; |
1313 | int changedLocal = 0; | 1313 | int changedLocal = 0; |
1314 | int changedRemote = 0; | 1314 | int changedRemote = 0; |
1315 | int filteredIN = 0; | 1315 | int filteredIN = 0; |
1316 | int filteredOUT = 0; | 1316 | int filteredOUT = 0; |
1317 | //QPtrList<Event> el = local->rawEvents(); | 1317 | //QPtrList<Event> el = local->rawEvents(); |
1318 | Event* eventR; | 1318 | Event* eventR; |
1319 | QString uid; | 1319 | QString uid; |
1320 | int take; | 1320 | int take; |
1321 | Event* eventRSync; | 1321 | Event* eventRSync; |
1322 | Event* eventLSync; | 1322 | Event* eventLSync; |
1323 | clearAllViews(); | 1323 | clearAllViews(); |
1324 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1324 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1325 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1325 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1326 | bool fullDateRange = false; | 1326 | bool fullDateRange = false; |
1327 | local->resetTempSyncStat(); | 1327 | local->resetTempSyncStat(); |
1328 | mLastCalendarSync = QDateTime::currentDateTime(); | 1328 | mLastCalendarSync = QDateTime::currentDateTime(); |
1329 | if ( mSyncManager->syncWithDesktop() ) { | 1329 | if ( mSyncManager->syncWithDesktop() ) { |
1330 | remote->resetPilotStat(1); | 1330 | remote->resetPilotStat(1); |
1331 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1331 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1332 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1332 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1333 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1333 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1334 | } else { | 1334 | } else { |
1335 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1335 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1336 | } | 1336 | } |
1337 | } | 1337 | } |
1338 | QDateTime modifiedCalendar = mLastCalendarSync; | 1338 | QDateTime modifiedCalendar = mLastCalendarSync; |
1339 | eventLSync = getLastSyncEvent(); | 1339 | eventLSync = getLastSyncEvent(); |
1340 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1340 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1341 | if ( eventR ) { | 1341 | if ( eventR ) { |
1342 | eventRSync = (Event*) eventR->clone(); | 1342 | eventRSync = (Event*) eventR->clone(); |
1343 | remote->deleteEvent(eventR ); | 1343 | remote->deleteEvent(eventR ); |
1344 | 1344 | ||
1345 | } else { | 1345 | } else { |
1346 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1346 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1347 | eventRSync = (Event*)eventLSync->clone(); | 1347 | eventRSync = (Event*)eventLSync->clone(); |
1348 | } else { | 1348 | } else { |
1349 | fullDateRange = true; | 1349 | fullDateRange = true; |
1350 | eventRSync = new Event(); | 1350 | eventRSync = new Event(); |
1351 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1351 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1352 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1352 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1353 | eventRSync->setDtStart( mLastCalendarSync ); | 1353 | eventRSync->setDtStart( mLastCalendarSync ); |
1354 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1354 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1355 | eventRSync->setCategories( i18n("SyncEvent") ); | 1355 | eventRSync->setCategories( i18n("SyncEvent") ); |
1356 | } | 1356 | } |
1357 | } | 1357 | } |
1358 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1358 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1359 | fullDateRange = true; | 1359 | fullDateRange = true; |
1360 | 1360 | ||
1361 | if ( ! fullDateRange ) { | 1361 | if ( ! fullDateRange ) { |
1362 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1362 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1363 | 1363 | ||
1364 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1364 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1365 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1365 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1366 | fullDateRange = true; | 1366 | fullDateRange = true; |
1367 | } | 1367 | } |
1368 | } | 1368 | } |
1369 | if ( mSyncManager->syncWithDesktop() ) { | 1369 | if ( mSyncManager->syncWithDesktop() ) { |
1370 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1370 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1371 | } | 1371 | } |
1372 | if ( fullDateRange ) | 1372 | if ( fullDateRange ) |
1373 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1373 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1374 | else | 1374 | else |
1375 | mLastCalendarSync = eventLSync->dtStart(); | 1375 | mLastCalendarSync = eventLSync->dtStart(); |
1376 | // for resyncing if own file has changed | 1376 | // for resyncing if own file has changed |
1377 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1377 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1378 | mLastCalendarSync = loadedFileVersion; | 1378 | mLastCalendarSync = loadedFileVersion; |
1379 | //qDebug("setting mLastCalendarSync "); | 1379 | //qDebug("setting mLastCalendarSync "); |
1380 | } | 1380 | } |
1381 | //qDebug("*************************** "); | 1381 | //qDebug("*************************** "); |
1382 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1382 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1383 | QPtrList<Incidence> er = remote->rawIncidences(); | 1383 | QPtrList<Incidence> er = remote->rawIncidences(); |
1384 | Incidence* inR = er.first(); | 1384 | Incidence* inR = er.first(); |
1385 | Incidence* inL; | 1385 | Incidence* inL; |
1386 | QProgressBar bar( er.count(),0 ); | 1386 | QProgressBar bar( er.count(),0 ); |
1387 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1387 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1388 | 1388 | ||
1389 | // ************** setting up filter ************* | 1389 | // ************** setting up filter ************* |
1390 | CalFilter *filterIN = 0; | 1390 | CalFilter *filterIN = 0; |
1391 | CalFilter *filterOUT = 0; | 1391 | CalFilter *filterOUT = 0; |
1392 | CalFilter *filter = mFilters.first(); | 1392 | CalFilter *filter = mFilters.first(); |
1393 | while(filter) { | 1393 | while(filter) { |
1394 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1394 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1395 | filterIN = filter; | 1395 | filterIN = filter; |
1396 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1396 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1397 | filterOUT = filter; | 1397 | filterOUT = filter; |
1398 | filter = mFilters.next(); | 1398 | filter = mFilters.next(); |
1399 | } | 1399 | } |
1400 | int w = 300; | 1400 | int w = 300; |
1401 | if ( QApplication::desktop()->width() < 320 ) | 1401 | if ( QApplication::desktop()->width() < 320 ) |
1402 | w = 220; | 1402 | w = 220; |
1403 | int h = bar.sizeHint().height() ; | 1403 | int h = bar.sizeHint().height() ; |
1404 | int dw = QApplication::desktop()->width(); | 1404 | int dw = QApplication::desktop()->width(); |
1405 | int dh = QApplication::desktop()->height(); | 1405 | int dh = QApplication::desktop()->height(); |
1406 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1406 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1407 | bar.show(); | 1407 | bar.show(); |
1408 | int modulo = (er.count()/10)+1; | 1408 | int modulo = (er.count()/10)+1; |
1409 | int incCounter = 0; | 1409 | int incCounter = 0; |
1410 | while ( inR ) { | 1410 | while ( inR ) { |
1411 | if ( ! bar.isVisible() ) | 1411 | if ( ! bar.isVisible() ) |
1412 | return false; | 1412 | return false; |
1413 | if ( incCounter % modulo == 0 ) | 1413 | if ( incCounter % modulo == 0 ) |
1414 | bar.setProgress( incCounter ); | 1414 | bar.setProgress( incCounter ); |
1415 | ++incCounter; | 1415 | ++incCounter; |
1416 | uid = inR->uid(); | 1416 | uid = inR->uid(); |
1417 | bool skipIncidence = false; | 1417 | bool skipIncidence = false; |
1418 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1418 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1419 | skipIncidence = true; | 1419 | skipIncidence = true; |
1420 | QString idS; | 1420 | QString idS; |
1421 | qApp->processEvents(); | 1421 | qApp->processEvents(); |
1422 | if ( !skipIncidence ) { | 1422 | if ( !skipIncidence ) { |
1423 | inL = local->incidence( uid ); | 1423 | inL = local->incidence( uid ); |
1424 | if ( inL ) { // maybe conflict - same uid in both calendars | 1424 | if ( inL ) { // maybe conflict - same uid in both calendars |
1425 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1425 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1426 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1426 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1427 | if ( take == 3 ) | 1427 | if ( take == 3 ) |
1428 | return false; | 1428 | return false; |
1429 | if ( take == 1 ) {// take local ********************** | 1429 | if ( take == 1 ) {// take local ********************** |
1430 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1430 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1431 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1431 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1432 | else | 1432 | else |
1433 | idS = inR->IDStr(); | 1433 | idS = inR->IDStr(); |
1434 | remote->deleteIncidence( inR ); | 1434 | remote->deleteIncidence( inR ); |
1435 | inR = inL->clone(); | 1435 | inR = inL->clone(); |
1436 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1436 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1437 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1437 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1438 | inR->setIDStr( idS ); | 1438 | inR->setIDStr( idS ); |
1439 | remote->addIncidence( inR ); | 1439 | remote->addIncidence( inR ); |
1440 | if ( mSyncManager->syncWithDesktop() ) | 1440 | if ( mSyncManager->syncWithDesktop() ) |
1441 | inR->setPilotId( 2 ); | 1441 | inR->setPilotId( 2 ); |
1442 | ++changedRemote; | 1442 | ++changedRemote; |
1443 | } else {// take remote ********************** | 1443 | } else {// take remote ********************** |
1444 | idS = inL->IDStr(); | 1444 | idS = inL->IDStr(); |
1445 | int pid = inL->pilotId(); | 1445 | int pid = inL->pilotId(); |
1446 | local->deleteIncidence( inL ); | 1446 | local->deleteIncidence( inL ); |
1447 | inL = inR->clone(); | 1447 | inL = inR->clone(); |
1448 | if ( mSyncManager->syncWithDesktop() ) | 1448 | if ( mSyncManager->syncWithDesktop() ) |
1449 | inL->setPilotId( pid ); | 1449 | inL->setPilotId( pid ); |
1450 | inL->setIDStr( idS ); | 1450 | inL->setIDStr( idS ); |
1451 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1451 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1452 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1452 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1453 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1453 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1454 | } | 1454 | } |
1455 | local->addIncidence( inL ); | 1455 | local->addIncidence( inL ); |
1456 | ++changedLocal; | 1456 | ++changedLocal; |
1457 | } | 1457 | } |
1458 | } | 1458 | } |
1459 | } else { // no conflict ********** add or delete remote | 1459 | } else { // no conflict ********** add or delete remote |
1460 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1460 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1461 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1461 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1462 | QString des = eventLSync->description(); | 1462 | QString des = eventLSync->description(); |
1463 | QString pref = "e"; | 1463 | QString pref = "e"; |
1464 | if ( inR->typeID() == todoID ) | 1464 | if ( inR->typeID() == todoID ) |
1465 | pref = "t"; | 1465 | pref = "t"; |
1466 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1466 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1467 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1467 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1468 | //remote->deleteIncidence( inR ); | 1468 | //remote->deleteIncidence( inR ); |
1469 | ++deletedEventR; | 1469 | ++deletedEventR; |
1470 | } else { | 1470 | } else { |
1471 | inR->setLastModified( modifiedCalendar ); | 1471 | inR->setLastModified( modifiedCalendar ); |
1472 | inL = inR->clone(); | 1472 | inL = inR->clone(); |
1473 | inL->setIDStr( ":" ); | 1473 | inL->setIDStr( ":" ); |
1474 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1474 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1475 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1475 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1476 | local->addIncidence( inL ); | 1476 | local->addIncidence( inL ); |
1477 | ++addedEvent; | 1477 | ++addedEvent; |
1478 | 1478 | ||
1479 | } | 1479 | } |
1480 | } else { | 1480 | } else { |
1481 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1481 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1482 | inR->setLastModified( modifiedCalendar ); | 1482 | inR->setLastModified( modifiedCalendar ); |
1483 | inL = inR->clone(); | 1483 | inL = inR->clone(); |
1484 | inL->setIDStr( ":" ); | 1484 | inL->setIDStr( ":" ); |
1485 | local->addIncidence( inL ); | 1485 | local->addIncidence( inL ); |
1486 | ++addedEvent; | 1486 | ++addedEvent; |
1487 | 1487 | ||
1488 | } else { | 1488 | } else { |
1489 | checkExternSyncEvent(eventRSyncSharp, inR); | 1489 | checkExternSyncEvent(eventRSyncSharp, inR); |
1490 | remote->deleteIncidence( inR ); | 1490 | remote->deleteIncidence( inR ); |
1491 | ++deletedEventR; | 1491 | ++deletedEventR; |
1492 | } | 1492 | } |
1493 | } | 1493 | } |
1494 | } else { | 1494 | } else { |
1495 | ++filteredIN; | 1495 | ++filteredIN; |
1496 | } | 1496 | } |
1497 | } | 1497 | } |
1498 | } | 1498 | } |
1499 | inR = er.next(); | 1499 | inR = er.next(); |
1500 | } | 1500 | } |
1501 | QPtrList<Incidence> el = local->rawIncidences(); | 1501 | QPtrList<Incidence> el = local->rawIncidences(); |
1502 | inL = el.first(); | 1502 | inL = el.first(); |
1503 | modulo = (el.count()/10)+1; | 1503 | modulo = (el.count()/10)+1; |
1504 | bar.setCaption (i18n("Add / remove events") ); | 1504 | bar.setCaption (i18n("Add / remove events") ); |
1505 | bar.setTotalSteps ( el.count() ) ; | 1505 | bar.setTotalSteps ( el.count() ) ; |
1506 | bar.show(); | 1506 | bar.show(); |
1507 | incCounter = 0; | 1507 | incCounter = 0; |
1508 | 1508 | ||
1509 | while ( inL ) { | 1509 | while ( inL ) { |
1510 | 1510 | ||
1511 | qApp->processEvents(); | 1511 | qApp->processEvents(); |
1512 | if ( ! bar.isVisible() ) | 1512 | if ( ! bar.isVisible() ) |
1513 | return false; | 1513 | return false; |
1514 | if ( incCounter % modulo == 0 ) | 1514 | if ( incCounter % modulo == 0 ) |
1515 | bar.setProgress( incCounter ); | 1515 | bar.setProgress( incCounter ); |
1516 | ++incCounter; | 1516 | ++incCounter; |
1517 | uid = inL->uid(); | 1517 | uid = inL->uid(); |
1518 | bool skipIncidence = false; | 1518 | bool skipIncidence = false; |
1519 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1519 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1520 | skipIncidence = true; | 1520 | skipIncidence = true; |
1521 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1521 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1522 | skipIncidence = true; | 1522 | skipIncidence = true; |
1523 | if ( !skipIncidence ) { | 1523 | if ( !skipIncidence ) { |
1524 | inR = remote->incidence( uid ); | 1524 | inR = remote->incidence( uid ); |
1525 | if ( ! inR ) { | 1525 | if ( ! inR ) { |
1526 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1526 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1527 | // no conflict ********** add or delete local | 1527 | // no conflict ********** add or delete local |
1528 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1528 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1529 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1529 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1530 | checkExternSyncEvent(eventLSyncSharp, inL); | 1530 | checkExternSyncEvent(eventLSyncSharp, inL); |
1531 | local->deleteIncidence( inL ); | 1531 | local->deleteIncidence( inL ); |
1532 | ++deletedEventL; | 1532 | ++deletedEventL; |
1533 | } else { | 1533 | } else { |
1534 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1534 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1535 | inL->removeID(mCurrentSyncDevice ); | 1535 | inL->removeID(mCurrentSyncDevice ); |
1536 | ++addedEventR; | 1536 | ++addedEventR; |
1537 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1537 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1538 | inL->setLastModified( modifiedCalendar ); | 1538 | inL->setLastModified( modifiedCalendar ); |
1539 | inR = inL->clone(); | 1539 | inR = inL->clone(); |
1540 | inR->setIDStr( ":" ); | 1540 | inR->setIDStr( ":" ); |
1541 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1541 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1542 | remote->addIncidence( inR ); | 1542 | remote->addIncidence( inR ); |
1543 | } | 1543 | } |
1544 | } | 1544 | } |
1545 | } else { | 1545 | } else { |
1546 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1546 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1547 | checkExternSyncEvent(eventLSyncSharp, inL); | 1547 | checkExternSyncEvent(eventLSyncSharp, inL); |
1548 | local->deleteIncidence( inL ); | 1548 | local->deleteIncidence( inL ); |
1549 | ++deletedEventL; | 1549 | ++deletedEventL; |
1550 | } else { | 1550 | } else { |
1551 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1551 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1552 | ++addedEventR; | 1552 | ++addedEventR; |
1553 | inL->setLastModified( modifiedCalendar ); | 1553 | inL->setLastModified( modifiedCalendar ); |
1554 | inR = inL->clone(); | 1554 | inR = inL->clone(); |
1555 | inR->setIDStr( ":" ); | 1555 | inR->setIDStr( ":" ); |
1556 | remote->addIncidence( inR ); | 1556 | remote->addIncidence( inR ); |
1557 | } | 1557 | } |
1558 | } | 1558 | } |
1559 | } | 1559 | } |
1560 | } else { | 1560 | } else { |
1561 | ++filteredOUT; | 1561 | ++filteredOUT; |
1562 | } | 1562 | } |
1563 | } | 1563 | } |
1564 | } | 1564 | } |
1565 | inL = el.next(); | 1565 | inL = el.next(); |
1566 | } | 1566 | } |
1567 | int delFut = 0; | 1567 | int delFut = 0; |
1568 | int remRem = 0; | 1568 | int remRem = 0; |
1569 | if ( mSyncManager->mWriteBackInFuture ) { | 1569 | if ( mSyncManager->mWriteBackInFuture ) { |
1570 | er = remote->rawIncidences(); | 1570 | er = remote->rawIncidences(); |
1571 | remRem = er.count(); | 1571 | remRem = er.count(); |
1572 | inR = er.first(); | 1572 | inR = er.first(); |
1573 | QDateTime dt; | 1573 | QDateTime dt; |
1574 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1574 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1575 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1575 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1576 | while ( inR ) { | 1576 | while ( inR ) { |
1577 | if ( inR->typeID() == todoID ) { | 1577 | if ( inR->typeID() == todoID ) { |
1578 | Todo * t = (Todo*)inR; | 1578 | Todo * t = (Todo*)inR; |
1579 | if ( t->hasDueDate() ) | 1579 | if ( t->hasDueDate() ) |
1580 | dt = t->dtDue(); | 1580 | dt = t->dtDue(); |
1581 | else | 1581 | else |
1582 | dt = cur.addSecs( 62 ); | 1582 | dt = cur.addSecs( 62 ); |
1583 | } | 1583 | } |
1584 | else if (inR->typeID() == eventID ) { | 1584 | else if (inR->typeID() == eventID ) { |
1585 | bool ok; | 1585 | bool ok; |
1586 | dt = inR->getNextOccurence( cur, &ok ); | 1586 | dt = inR->getNextOccurence( cur, &ok ); |
1587 | if ( !ok ) | 1587 | if ( !ok ) |
1588 | dt = cur.addSecs( -62 ); | 1588 | dt = cur.addSecs( -62 ); |
1589 | } | 1589 | } |
1590 | else | 1590 | else |
1591 | dt = inR->dtStart(); | 1591 | dt = inR->dtStart(); |
1592 | if ( dt < cur || dt > end ) { | 1592 | if ( dt < cur || dt > end ) { |
1593 | remote->deleteIncidence( inR ); | 1593 | remote->deleteIncidence( inR ); |
1594 | ++delFut; | 1594 | ++delFut; |
1595 | } | 1595 | } |
1596 | inR = er.next(); | 1596 | inR = er.next(); |
1597 | } | 1597 | } |
1598 | } | 1598 | } |
1599 | bar.hide(); | 1599 | bar.hide(); |
1600 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1600 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1601 | eventLSync->setReadOnly( false ); | 1601 | eventLSync->setReadOnly( false ); |
1602 | eventLSync->setDtStart( mLastCalendarSync ); | 1602 | eventLSync->setDtStart( mLastCalendarSync ); |
1603 | eventRSync->setDtStart( mLastCalendarSync ); | 1603 | eventRSync->setDtStart( mLastCalendarSync ); |
1604 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1604 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1605 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1605 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1606 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1606 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1607 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1607 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1608 | eventLSync->setReadOnly( true ); | 1608 | eventLSync->setReadOnly( true ); |
1609 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1609 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1610 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1610 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1611 | remote->addEvent( eventRSync ); | 1611 | remote->addEvent( eventRSync ); |
1612 | else | 1612 | else |
1613 | delete eventRSync; | 1613 | delete eventRSync; |
1614 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1614 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1615 | QString mes; | 1615 | QString mes; |
1616 | 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 ); | 1616 | 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 ); |
1617 | QString delmess; | 1617 | QString delmess; |
1618 | if ( delFut ) { | 1618 | if ( delFut ) { |
1619 | 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); | 1619 | 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); |
1620 | mes += delmess; | 1620 | mes += delmess; |
1621 | } | 1621 | } |
1622 | mes = i18n("Local calendar changed!\n") +mes; | 1622 | mes = i18n("Local calendar changed!\n") +mes; |
1623 | mCalendar->checkAlarmForIncidence( 0, true ); | 1623 | mCalendar->checkAlarmForIncidence( 0, true ); |
1624 | qDebug( mes ); | 1624 | qDebug( mes ); |
1625 | if ( mSyncManager->mShowSyncSummary ) { | 1625 | if ( mSyncManager->mShowSyncSummary ) { |
1626 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1626 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1627 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1627 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1628 | qDebug("KO: WB cancelled "); | 1628 | qDebug("KO: WB cancelled "); |
1629 | mSyncManager->mWriteBackFile = false; | 1629 | mSyncManager->mWriteBackFile = false; |
1630 | return syncOK; | 1630 | return syncOK; |
1631 | } | 1631 | } |
1632 | } | 1632 | } |
1633 | return syncOK; | 1633 | return syncOK; |
1634 | } | 1634 | } |
1635 | 1635 | ||
1636 | void CalendarView::setSyncDevice( QString s ) | 1636 | void CalendarView::setSyncDevice( QString s ) |
1637 | { | 1637 | { |
1638 | mCurrentSyncDevice= s; | 1638 | mCurrentSyncDevice= s; |
1639 | } | 1639 | } |
1640 | void CalendarView::setSyncName( QString s ) | 1640 | void CalendarView::setSyncName( QString s ) |
1641 | { | 1641 | { |
1642 | mCurrentSyncName= s; | 1642 | mCurrentSyncName= s; |
1643 | } | 1643 | } |
1644 | bool CalendarView::syncCalendar(QString filename, int mode) | 1644 | bool CalendarView::syncCalendar(QString filename, int mode) |
1645 | { | 1645 | { |
1646 | //qDebug("syncCalendar %s ", filename.latin1()); | 1646 | //qDebug("syncCalendar %s ", filename.latin1()); |
1647 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1647 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1648 | CalendarLocal* calendar = new CalendarLocal(); | 1648 | CalendarLocal* calendar = new CalendarLocal(); |
1649 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1649 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1650 | FileStorage* storage = new FileStorage( calendar ); | 1650 | FileStorage* storage = new FileStorage( calendar ); |
1651 | bool syncOK = false; | 1651 | bool syncOK = false; |
1652 | storage->setFileName( filename ); | 1652 | storage->setFileName( filename ); |
1653 | // qDebug("loading ... "); | 1653 | // qDebug("loading ... "); |
1654 | if ( storage->load() ) { | 1654 | if ( storage->load() ) { |
1655 | getEventViewerDialog()->setSyncMode( true ); | 1655 | getEventViewerDialog()->setSyncMode( true ); |
1656 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1656 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1657 | getEventViewerDialog()->setSyncMode( false ); | 1657 | getEventViewerDialog()->setSyncMode( false ); |
1658 | if ( syncOK ) { | 1658 | if ( syncOK ) { |
1659 | if ( mSyncManager->mWriteBackFile ) | 1659 | if ( mSyncManager->mWriteBackFile ) |
1660 | { | 1660 | { |
1661 | storage->setSaveFormat( new ICalFormat() ); | 1661 | storage->setSaveFormat( new ICalFormat() ); |
1662 | storage->save(); | 1662 | storage->save(); |
1663 | } | 1663 | } |
1664 | } | 1664 | } |
1665 | setModified( true ); | 1665 | setModified( true ); |
1666 | } | 1666 | } |
1667 | delete storage; | 1667 | delete storage; |
1668 | delete calendar; | 1668 | delete calendar; |
1669 | if ( syncOK ) | 1669 | if ( syncOK ) |
1670 | updateView(); | 1670 | updateView(); |
1671 | return syncOK; | 1671 | return syncOK; |
1672 | } | 1672 | } |
1673 | 1673 | ||
1674 | void CalendarView::syncExternal( int mode ) | 1674 | void CalendarView::syncExternal( int mode ) |
1675 | { | 1675 | { |
1676 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1676 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1677 | 1677 | ||
1678 | qApp->processEvents(); | 1678 | qApp->processEvents(); |
1679 | CalendarLocal* calendar = new CalendarLocal(); | 1679 | CalendarLocal* calendar = new CalendarLocal(); |
1680 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1680 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1681 | bool syncOK = false; | 1681 | bool syncOK = false; |
1682 | bool loadSuccess = false; | 1682 | bool loadSuccess = false; |
1683 | PhoneFormat* phoneFormat = 0; | 1683 | PhoneFormat* phoneFormat = 0; |
1684 | emit tempDisableBR(true); | 1684 | emit tempDisableBR(true); |
1685 | #ifndef DESKTOP_VERSION | 1685 | #ifndef DESKTOP_VERSION |
1686 | SharpFormat* sharpFormat = 0; | 1686 | SharpFormat* sharpFormat = 0; |
1687 | if ( mode == 0 ) { // sharp | 1687 | if ( mode == 0 ) { // sharp |
1688 | sharpFormat = new SharpFormat () ; | 1688 | sharpFormat = new SharpFormat () ; |
1689 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1689 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1690 | 1690 | ||
1691 | } else | 1691 | } else |
1692 | #endif | 1692 | #endif |
1693 | if ( mode == 1 ) { // phone | 1693 | if ( mode == 1 ) { // phone |
1694 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1694 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1695 | mSyncManager->mPhoneDevice, | 1695 | mSyncManager->mPhoneDevice, |
1696 | mSyncManager->mPhoneConnection, | 1696 | mSyncManager->mPhoneConnection, |
1697 | mSyncManager->mPhoneModel); | 1697 | mSyncManager->mPhoneModel); |
1698 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1698 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1699 | 1699 | ||
1700 | } else { | 1700 | } else { |
1701 | emit tempDisableBR(false); | 1701 | emit tempDisableBR(false); |
1702 | return; | 1702 | return; |
1703 | } | 1703 | } |
1704 | if ( loadSuccess ) { | 1704 | if ( loadSuccess ) { |
1705 | getEventViewerDialog()->setSyncMode( true ); | 1705 | getEventViewerDialog()->setSyncMode( true ); |
1706 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1706 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1707 | getEventViewerDialog()->setSyncMode( false ); | 1707 | getEventViewerDialog()->setSyncMode( false ); |
1708 | qApp->processEvents(); | 1708 | qApp->processEvents(); |
1709 | if ( syncOK ) { | 1709 | if ( syncOK ) { |
1710 | if ( mSyncManager->mWriteBackFile ) | 1710 | if ( mSyncManager->mWriteBackFile ) |
1711 | { | 1711 | { |
1712 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1712 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1713 | Incidence* inc = iL.first(); | 1713 | Incidence* inc = iL.first(); |
1714 | if ( phoneFormat ) { | 1714 | if ( phoneFormat ) { |
1715 | while ( inc ) { | 1715 | while ( inc ) { |
1716 | inc->removeID(mCurrentSyncDevice); | 1716 | inc->removeID(mCurrentSyncDevice); |
1717 | inc = iL.next(); | 1717 | inc = iL.next(); |
1718 | } | 1718 | } |
1719 | } | 1719 | } |
1720 | #ifndef DESKTOP_VERSION | 1720 | #ifndef DESKTOP_VERSION |
1721 | if ( sharpFormat ) | 1721 | if ( sharpFormat ) |
1722 | sharpFormat->save(calendar); | 1722 | sharpFormat->save(calendar); |
1723 | #endif | 1723 | #endif |
1724 | if ( phoneFormat ) | 1724 | if ( phoneFormat ) |
1725 | phoneFormat->save(calendar); | 1725 | phoneFormat->save(calendar); |
1726 | iL = calendar->rawIncidences(); | 1726 | iL = calendar->rawIncidences(); |
1727 | inc = iL.first(); | 1727 | inc = iL.first(); |
1728 | Incidence* loc; | 1728 | Incidence* loc; |
1729 | while ( inc ) { | 1729 | while ( inc ) { |
1730 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1730 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1731 | loc = mCalendar->incidence(inc->uid() ); | 1731 | loc = mCalendar->incidence(inc->uid() ); |
1732 | if ( loc ) { | 1732 | if ( loc ) { |
1733 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1733 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1734 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1734 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1735 | } | 1735 | } |
1736 | } | 1736 | } |
1737 | inc = iL.next(); | 1737 | inc = iL.next(); |
1738 | } | 1738 | } |
1739 | Incidence* lse = getLastSyncEvent(); | 1739 | Incidence* lse = getLastSyncEvent(); |
1740 | if ( lse ) { | 1740 | if ( lse ) { |
1741 | lse->setReadOnly( false ); | 1741 | lse->setReadOnly( false ); |
1742 | lse->setDescription( "" ); | 1742 | lse->setDescription( "" ); |
1743 | lse->setReadOnly( true ); | 1743 | lse->setReadOnly( true ); |
1744 | } | 1744 | } |
1745 | } | 1745 | } |
1746 | } else { | 1746 | } else { |
1747 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1747 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1748 | } | 1748 | } |
1749 | setModified( true ); | 1749 | setModified( true ); |
1750 | } else { | 1750 | } else { |
1751 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1751 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1752 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1752 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1753 | question, i18n("Ok")) ; | 1753 | question, i18n("Ok")) ; |
1754 | 1754 | ||
1755 | } | 1755 | } |
1756 | delete calendar; | 1756 | delete calendar; |
1757 | updateView(); | 1757 | updateView(); |
1758 | emit tempDisableBR(false); | 1758 | emit tempDisableBR(false); |
1759 | return ;//syncOK; | 1759 | return ;//syncOK; |
1760 | 1760 | ||
1761 | } | 1761 | } |
1762 | 1762 | ||
1763 | bool CalendarView::importBday() | 1763 | bool CalendarView::importBday() |
1764 | { | 1764 | { |
1765 | #ifndef KORG_NOKABC | 1765 | #ifndef KORG_NOKABC |
1766 | 1766 | ||
1767 | #ifdef DESKTOP_VERSION | 1767 | #ifdef DESKTOP_VERSION |
1768 | int curCal = mCalendar->defaultCalendar(); | 1768 | int curCal = mCalendar->defaultCalendar(); |
1769 | int bd = mCalEditView->getBirtdayID(); | 1769 | int bd = mCalEditView->getBirtdayID(); |
1770 | if ( bd == 0 ) | 1770 | if ( bd == 0 ) |
1771 | return false; | 1771 | return false; |
1772 | mCalendar->setDefaultCalendar( bd ); | 1772 | mCalendar->setDefaultCalendar( bd ); |
1773 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1773 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1774 | KABC::AddressBook::Iterator it; | 1774 | KABC::AddressBook::Iterator it; |
1775 | int count = 0; | 1775 | int count = 0; |
1776 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1776 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1777 | ++count; | 1777 | ++count; |
1778 | } | 1778 | } |
1779 | QProgressBar bar(count,0 ); | 1779 | QProgressBar bar(count,0 ); |
1780 | int w = 300; | 1780 | int w = 300; |
1781 | if ( QApplication::desktop()->width() < 320 ) | 1781 | if ( QApplication::desktop()->width() < 320 ) |
1782 | w = 220; | 1782 | w = 220; |
1783 | int h = bar.sizeHint().height() ; | 1783 | int h = bar.sizeHint().height() ; |
1784 | int dw = QApplication::desktop()->width(); | 1784 | int dw = QApplication::desktop()->width(); |
1785 | int dh = QApplication::desktop()->height(); | 1785 | int dh = QApplication::desktop()->height(); |
1786 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1786 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1787 | bar.show(); | 1787 | bar.show(); |
1788 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1788 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1789 | qApp->processEvents(); | 1789 | qApp->processEvents(); |
1790 | count = 0; | 1790 | count = 0; |
1791 | int addCount = 0; | 1791 | int addCount = 0; |
1792 | KCal::Attendee* a = 0; | 1792 | KCal::Attendee* a = 0; |
1793 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1793 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1794 | if ( ! bar.isVisible() ) | 1794 | if ( ! bar.isVisible() ) |
1795 | return false; | 1795 | return false; |
1796 | bar.setProgress( count++ ); | 1796 | bar.setProgress( count++ ); |
1797 | qApp->processEvents(); | 1797 | qApp->processEvents(); |
1798 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1798 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1799 | if ( (*it).birthday().date().isValid() ){ | 1799 | if ( (*it).birthday().date().isValid() ){ |
1800 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1800 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1801 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1801 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1802 | ++addCount; | 1802 | ++addCount; |
1803 | } | 1803 | } |
1804 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1804 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1805 | if ( anni.isValid() ){ | 1805 | if ( anni.isValid() ){ |
1806 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1806 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1807 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1807 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1808 | ++addCount; | 1808 | ++addCount; |
1809 | } | 1809 | } |
1810 | } | 1810 | } |
1811 | mCalendar->setDefaultCalendar( curCal ); | 1811 | mCalendar->setDefaultCalendar( curCal ); |
1812 | updateView(); | 1812 | updateView(); |
1813 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1813 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1814 | #else //DESKTOP_VERSION | 1814 | #else //DESKTOP_VERSION |
1815 | 1815 | ||
1816 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1816 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1817 | // the result should now arrive through method insertBirthdays | 1817 | // the result should now arrive through method insertBirthdays |
1818 | 1818 | ||
1819 | #endif //DESKTOP_VERSION | 1819 | #endif //DESKTOP_VERSION |
1820 | 1820 | ||
1821 | #endif //KORG_NOKABC | 1821 | #endif //KORG_NOKABC |
1822 | 1822 | ||
1823 | 1823 | ||
1824 | return true; | 1824 | return true; |
1825 | } | 1825 | } |
1826 | 1826 | ||
1827 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1827 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1828 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1828 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1829 | const QStringList& anniversaryList, const QStringList& realNameList, | 1829 | const QStringList& anniversaryList, const QStringList& realNameList, |
1830 | const QStringList& emailList, const QStringList& assembledNameList, | 1830 | const QStringList& emailList, const QStringList& assembledNameList, |
1831 | const QStringList& uidList) | 1831 | const QStringList& uidList) |
1832 | { | 1832 | { |
1833 | 1833 | ||
1834 | //qDebug("KO::CalendarView::insertBirthdays"); | 1834 | //qDebug("KO::CalendarView::insertBirthdays"); |
1835 | if (uid == this->name()) | 1835 | if (uid == this->name()) |
1836 | { | 1836 | { |
1837 | int curCal = mCalendar->defaultCalendar(); | 1837 | int curCal = mCalendar->defaultCalendar(); |
1838 | int bd = mCalEditView->getBirtdayID(); | 1838 | int bd = mCalEditView->getBirtdayID(); |
1839 | if ( bd == 0 ) | 1839 | if ( bd == 0 ) |
1840 | return; | 1840 | return; |
1841 | mCalendar->setDefaultCalendar( bd ); | 1841 | mCalendar->setDefaultCalendar( bd ); |
1842 | 1842 | ||
1843 | 1843 | ||
1844 | int count = birthdayList.count(); | 1844 | int count = birthdayList.count(); |
1845 | int addCount = 0; | 1845 | int addCount = 0; |
1846 | KCal::Attendee* a = 0; | 1846 | KCal::Attendee* a = 0; |
1847 | 1847 | ||
1848 | //qDebug("CalView 1 %i", count); | 1848 | //qDebug("CalView 1 %i", count); |
1849 | 1849 | ||
1850 | QProgressBar bar(count,0 ); | 1850 | QProgressBar bar(count,0 ); |
1851 | int w = 300; | 1851 | int w = 300; |
1852 | if ( QApplication::desktop()->width() < 320 ) | 1852 | if ( QApplication::desktop()->width() < 320 ) |
1853 | w = 220; | 1853 | w = 220; |
1854 | int h = bar.sizeHint().height() ; | 1854 | int h = bar.sizeHint().height() ; |
1855 | int dw = QApplication::desktop()->width(); | 1855 | int dw = QApplication::desktop()->width(); |
1856 | int dh = QApplication::desktop()->height(); | 1856 | int dh = QApplication::desktop()->height(); |
1857 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1857 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1858 | bar.show(); | 1858 | bar.show(); |
1859 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1859 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1860 | qApp->processEvents(); | 1860 | qApp->processEvents(); |
1861 | 1861 | ||
1862 | QDate birthday; | 1862 | QDate birthday; |
1863 | QDate anniversary; | 1863 | QDate anniversary; |
1864 | QString realName; | 1864 | QString realName; |
1865 | QString email; | 1865 | QString email; |
1866 | QString assembledName; | 1866 | QString assembledName; |
1867 | QString uid; | 1867 | QString uid; |
1868 | bool ok = true; | 1868 | bool ok = true; |
1869 | for ( int i = 0; i < count; i++) | 1869 | for ( int i = 0; i < count; i++) |
1870 | { | 1870 | { |
1871 | if ( ! bar.isVisible() ) | 1871 | if ( ! bar.isVisible() ) |
1872 | return; | 1872 | return; |
1873 | bar.setProgress( i ); | 1873 | bar.setProgress( i ); |
1874 | qApp->processEvents(); | 1874 | qApp->processEvents(); |
1875 | 1875 | ||
1876 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1876 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1877 | if (!ok) { | 1877 | if (!ok) { |
1878 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1878 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1879 | } | 1879 | } |
1880 | 1880 | ||
1881 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1881 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1882 | if (!ok) { | 1882 | if (!ok) { |
1883 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1883 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1884 | } | 1884 | } |
1885 | realName = realNameList[i]; | 1885 | realName = realNameList[i]; |
1886 | email = emailList[i]; | 1886 | email = emailList[i]; |
1887 | assembledName = assembledNameList[i]; | 1887 | assembledName = assembledNameList[i]; |
1888 | uid = uidList[i]; | 1888 | uid = uidList[i]; |
1889 | //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() ); | 1889 | //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() ); |
1890 | 1890 | ||
1891 | if ( birthday.isValid() ){ | 1891 | if ( birthday.isValid() ){ |
1892 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1892 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1893 | KCal::Attendee::ReqParticipant,uid) ; | 1893 | KCal::Attendee::ReqParticipant,uid) ; |
1894 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1894 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1895 | ++addCount; | 1895 | ++addCount; |
1896 | } | 1896 | } |
1897 | 1897 | ||
1898 | if ( anniversary.isValid() ){ | 1898 | if ( anniversary.isValid() ){ |
1899 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1899 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1900 | KCal::Attendee::ReqParticipant,uid) ; | 1900 | KCal::Attendee::ReqParticipant,uid) ; |
1901 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1901 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1902 | ++addCount; | 1902 | ++addCount; |
1903 | } | 1903 | } |
1904 | } | 1904 | } |
1905 | 1905 | ||
1906 | mCalendar->setDefaultCalendar( curCal ); | 1906 | mCalendar->setDefaultCalendar( curCal ); |
1907 | updateView(); | 1907 | updateView(); |
1908 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1908 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1909 | 1909 | ||
1910 | } | 1910 | } |
1911 | 1911 | ||
1912 | } | 1912 | } |
1913 | 1913 | ||
1914 | 1914 | ||
1915 | 1915 | ||
1916 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1916 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1917 | { | 1917 | { |
1918 | //qDebug("addAnni "); | 1918 | //qDebug("addAnni "); |
1919 | Event * ev = new Event(); | 1919 | Event * ev = new Event(); |
1920 | ev->setOrganizer(KOPrefs::instance()->email()); | 1920 | ev->setOrganizer(KOPrefs::instance()->email()); |
1921 | if ( a ) { | 1921 | if ( a ) { |
1922 | ev->addAttendee( a ); | 1922 | ev->addAttendee( a ); |
1923 | } | 1923 | } |
1924 | QString kind; | 1924 | QString kind; |
1925 | if ( birthday ) { | 1925 | if ( birthday ) { |
1926 | kind = i18n( "Birthday" ); | 1926 | kind = i18n( "Birthday" ); |
1927 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1927 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1928 | } | 1928 | } |
1929 | else { | 1929 | else { |
1930 | kind = i18n( "Anniversary" ); | 1930 | kind = i18n( "Anniversary" ); |
1931 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1931 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1932 | } | 1932 | } |
1933 | ev->setCategories( kind ); | 1933 | ev->setCategories( kind ); |
1934 | ev->setDtStart( QDateTime(date) ); | 1934 | ev->setDtStart( QDateTime(date) ); |
1935 | ev->setDtEnd( QDateTime(date) ); | 1935 | ev->setDtEnd( QDateTime(date) ); |
1936 | ev->setFloats( true ); | 1936 | ev->setFloats( true ); |
1937 | Recurrence * rec = ev->recurrence(); | 1937 | Recurrence * rec = ev->recurrence(); |
1938 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1938 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1939 | rec->addYearlyNum( date.month() ); | 1939 | rec->addYearlyNum( date.month() ); |
1940 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1940 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1941 | delete ev; | 1941 | delete ev; |
1942 | return false; | 1942 | return false; |
1943 | } | 1943 | } |
1944 | return true; | 1944 | return true; |
1945 | 1945 | ||
1946 | } | 1946 | } |
1947 | bool CalendarView::importQtopia( const QString &categories, | 1947 | bool CalendarView::importQtopia( const QString &categories, |
1948 | const QString &datebook, | 1948 | const QString &datebook, |
1949 | const QString &todolist ) | 1949 | const QString &todolist ) |
1950 | { | 1950 | { |
1951 | 1951 | ||
1952 | QtopiaFormat qtopiaFormat; | 1952 | QtopiaFormat qtopiaFormat; |
1953 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1953 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1954 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1954 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1955 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1955 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1956 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1956 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1957 | 1957 | ||
1958 | updateView(); | 1958 | updateView(); |
1959 | return true; | 1959 | return true; |
1960 | 1960 | ||
1961 | #if 0 | 1961 | #if 0 |
1962 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1962 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1963 | mCurrentSyncDevice = "qtopia-XML"; | 1963 | mCurrentSyncDevice = "qtopia-XML"; |
1964 | if ( mSyncManager->mAskForPreferences ) | 1964 | if ( mSyncManager->mAskForPreferences ) |
1965 | edit_sync_options(); | 1965 | edit_sync_options(); |
1966 | qApp->processEvents(); | 1966 | qApp->processEvents(); |
1967 | CalendarLocal* calendar = new CalendarLocal(); | 1967 | CalendarLocal* calendar = new CalendarLocal(); |
1968 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1968 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1969 | bool syncOK = false; | 1969 | bool syncOK = false; |
1970 | QtopiaFormat qtopiaFormat; | 1970 | QtopiaFormat qtopiaFormat; |
1971 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1971 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1972 | bool loadOk = true; | 1972 | bool loadOk = true; |
1973 | if ( !categories.isEmpty() ) | 1973 | if ( !categories.isEmpty() ) |
1974 | loadOk = qtopiaFormat.load( calendar, categories ); | 1974 | loadOk = qtopiaFormat.load( calendar, categories ); |
1975 | if ( loadOk && !datebook.isEmpty() ) | 1975 | if ( loadOk && !datebook.isEmpty() ) |
1976 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1976 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1977 | if ( loadOk && !todolist.isEmpty() ) | 1977 | if ( loadOk && !todolist.isEmpty() ) |
1978 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1978 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1979 | 1979 | ||
1980 | if ( loadOk ) { | 1980 | if ( loadOk ) { |
1981 | getEventViewerDialog()->setSyncMode( true ); | 1981 | getEventViewerDialog()->setSyncMode( true ); |
1982 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1982 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1983 | getEventViewerDialog()->setSyncMode( false ); | 1983 | getEventViewerDialog()->setSyncMode( false ); |
1984 | qApp->processEvents(); | 1984 | qApp->processEvents(); |
1985 | if ( syncOK ) { | 1985 | if ( syncOK ) { |
1986 | if ( mSyncManager->mWriteBackFile ) | 1986 | if ( mSyncManager->mWriteBackFile ) |
1987 | { | 1987 | { |
1988 | // write back XML file | 1988 | // write back XML file |
1989 | 1989 | ||
1990 | } | 1990 | } |
1991 | setModified( true ); | 1991 | setModified( true ); |
1992 | } | 1992 | } |
1993 | } else { | 1993 | } else { |
1994 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1994 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1995 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1995 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1996 | question, i18n("Ok")) ; | 1996 | question, i18n("Ok")) ; |
1997 | } | 1997 | } |
1998 | delete calendar; | 1998 | delete calendar; |
1999 | updateView(); | 1999 | updateView(); |
2000 | return syncOK; | 2000 | return syncOK; |
2001 | 2001 | ||
2002 | 2002 | ||
2003 | #endif | 2003 | #endif |
2004 | 2004 | ||
2005 | } | 2005 | } |
2006 | 2006 | ||
2007 | void CalendarView::setSyncEventsReadOnly() | 2007 | void CalendarView::setSyncEventsReadOnly() |
2008 | { | 2008 | { |
2009 | mCalendar->setSyncEventsReadOnly(); | 2009 | mCalendar->setSyncEventsReadOnly(); |
2010 | } | 2010 | } |
2011 | 2011 | ||
2012 | bool CalendarView::loadCalendars() | 2012 | bool CalendarView::loadCalendars() |
2013 | { | 2013 | { |
2014 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2014 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2015 | KopiCalendarFile * cal = calendars.first(); | 2015 | KopiCalendarFile * cal = calendars.first(); |
2016 | mCalendar->setDefaultCalendar( 1 ); | 2016 | mCalendar->setDefaultCalendar( 1 ); |
2017 | openCalendar( MainWindow::defaultFileName(), false ); | 2017 | openCalendar( MainWindow::defaultFileName(), false ); |
2018 | cal = calendars.next(); | 2018 | cal = calendars.next(); |
2019 | while ( cal ) { | 2019 | while ( cal ) { |
2020 | addCalendar( cal ); | 2020 | addCalendar( cal ); |
2021 | cal = calendars.next(); | 2021 | cal = calendars.next(); |
2022 | } | 2022 | } |
2023 | restoreCalendarSettings(); | 2023 | restoreCalendarSettings(); |
2024 | return true; | 2024 | return true; |
2025 | } | 2025 | } |
2026 | bool CalendarView::restoreCalendarSettings() | 2026 | bool CalendarView::restoreCalendarSettings() |
2027 | { | 2027 | { |
2028 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2028 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2029 | KopiCalendarFile * cal = calendars.first(); | 2029 | KopiCalendarFile * cal = calendars.first(); |
2030 | while ( cal ) { | 2030 | while ( cal ) { |
2031 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2031 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2032 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2032 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2033 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2033 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2034 | if ( cal->isStandard ) | 2034 | if ( cal->isStandard ) |
2035 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2035 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2036 | cal = calendars.next(); | 2036 | cal = calendars.next(); |
2037 | } | 2037 | } |
2038 | setSyncEventsReadOnly(); | 2038 | setSyncEventsReadOnly(); |
2039 | mCalendar->reInitAlarmSettings(); | 2039 | mCalendar->reInitAlarmSettings(); |
2040 | updateUnmanagedViews(); | 2040 | updateUnmanagedViews(); |
2041 | updateView(); | 2041 | updateView(); |
2042 | return true; | 2042 | return true; |
2043 | } | 2043 | } |
2044 | void CalendarView::addCalendarId( int id ) | 2044 | void CalendarView::addCalendarId( int id ) |
2045 | { | 2045 | { |
2046 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2046 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2047 | if ( cal ) | 2047 | if ( cal ) |
2048 | addCalendar( cal ); | 2048 | addCalendar( cal ); |
2049 | } | 2049 | } |
2050 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2050 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2051 | { | 2051 | { |
2052 | cal->mErrorOnLoad = false; | 2052 | cal->mErrorOnLoad = false; |
2053 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2053 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2054 | cal->mLoadDt = QDateTime::currentDateTime(); | 2054 | cal->mLoadDt = QDateTime::currentDateTime(); |
2055 | return true; | 2055 | return true; |
2056 | } | 2056 | } |
2057 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2057 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2058 | cal->mErrorOnLoad = true; | 2058 | cal->mErrorOnLoad = true; |
2059 | return false; | 2059 | return false; |
2060 | } | 2060 | } |
2061 | bool CalendarView::openCalendar(QString filename, bool merge) | 2061 | bool CalendarView::openCalendar(QString filename, bool merge) |
2062 | { | 2062 | { |
2063 | 2063 | ||
2064 | if (filename.isEmpty()) { | 2064 | if (filename.isEmpty()) { |
2065 | return false; | 2065 | return false; |
2066 | } | 2066 | } |
2067 | 2067 | ||
2068 | if (!QFile::exists(filename)) { | 2068 | if (!QFile::exists(filename)) { |
2069 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2069 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2070 | return false; | 2070 | return false; |
2071 | } | 2071 | } |
2072 | 2072 | ||
2073 | globalFlagBlockAgenda = 1; | 2073 | globalFlagBlockAgenda = 1; |
2074 | clearAllViews(); | 2074 | clearAllViews(); |
2075 | if (!merge) { | 2075 | if (!merge) { |
2076 | mViewManager->setDocumentId( filename ); | 2076 | mViewManager->setDocumentId( filename ); |
2077 | mCalendar->close(); | 2077 | mCalendar->close(); |
2078 | } | 2078 | } |
2079 | mStorage->setFileName( filename ); | 2079 | mStorage->setFileName( filename ); |
2080 | 2080 | ||
2081 | if ( mStorage->load() ) { | 2081 | if ( mStorage->load() ) { |
2082 | if ( merge ) ;//setModified( true ); | 2082 | if ( merge ) ;//setModified( true ); |
2083 | else { | 2083 | else { |
2084 | //setModified( true ); | 2084 | //setModified( true ); |
2085 | mViewManager->setDocumentId( filename ); | 2085 | mViewManager->setDocumentId( filename ); |
2086 | mDialogManager->setDocumentId( filename ); | 2086 | mDialogManager->setDocumentId( filename ); |
2087 | mTodoList->setDocumentId( filename ); | 2087 | mTodoList->setDocumentId( filename ); |
2088 | } | 2088 | } |
2089 | globalFlagBlockAgenda = 2; | 2089 | globalFlagBlockAgenda = 2; |
2090 | // if ( getLastSyncEvent() ) | 2090 | // if ( getLastSyncEvent() ) |
2091 | // getLastSyncEvent()->setReadOnly( true ); | 2091 | // getLastSyncEvent()->setReadOnly( true ); |
2092 | mCalendar->reInitAlarmSettings(); | 2092 | mCalendar->reInitAlarmSettings(); |
2093 | setSyncEventsReadOnly(); | 2093 | setSyncEventsReadOnly(); |
2094 | updateUnmanagedViews(); | 2094 | updateUnmanagedViews(); |
2095 | updateView(); | 2095 | updateView(); |
2096 | if ( filename != MainWindow::defaultFileName() ) { | 2096 | if ( filename != MainWindow::defaultFileName() ) { |
2097 | saveCalendar( MainWindow::defaultFileName() ); | 2097 | saveCalendar( MainWindow::defaultFileName() ); |
2098 | } else { | 2098 | } else { |
2099 | QFileInfo finf ( MainWindow::defaultFileName()); | 2099 | QFileInfo finf ( MainWindow::defaultFileName()); |
2100 | if ( finf.exists() ) { | 2100 | if ( finf.exists() ) { |
2101 | setLoadedFileVersion( finf.lastModified () ); | 2101 | setLoadedFileVersion( finf.lastModified () ); |
2102 | } | 2102 | } |
2103 | } | 2103 | } |
2104 | return true; | 2104 | return true; |
2105 | } else { | 2105 | } else { |
2106 | // while failing to load, the calendar object could | 2106 | // while failing to load, the calendar object could |
2107 | // have become partially populated. Clear it out. | 2107 | // have become partially populated. Clear it out. |
2108 | if ( !merge ) { | 2108 | if ( !merge ) { |
2109 | mCalendar->close(); | 2109 | mCalendar->close(); |
2110 | mViewManager->setDocumentId( filename ); | 2110 | mViewManager->setDocumentId( filename ); |
2111 | mDialogManager->setDocumentId( filename ); | 2111 | mDialogManager->setDocumentId( filename ); |
2112 | mTodoList->setDocumentId( filename ); | 2112 | mTodoList->setDocumentId( filename ); |
2113 | } | 2113 | } |
2114 | 2114 | ||
2115 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2115 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2116 | 2116 | ||
2117 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2117 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2118 | globalFlagBlockAgenda = 2; | 2118 | globalFlagBlockAgenda = 2; |
2119 | mCalendar->reInitAlarmSettings(); | 2119 | mCalendar->reInitAlarmSettings(); |
2120 | setSyncEventsReadOnly(); | 2120 | setSyncEventsReadOnly(); |
2121 | updateUnmanagedViews(); | 2121 | updateUnmanagedViews(); |
2122 | updateView(); | 2122 | updateView(); |
2123 | } | 2123 | } |
2124 | return false; | 2124 | return false; |
2125 | } | 2125 | } |
2126 | void CalendarView::showOpenError() | 2126 | void CalendarView::showOpenError() |
2127 | { | 2127 | { |
2128 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2128 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2129 | } | 2129 | } |
2130 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2130 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2131 | { | 2131 | { |
2132 | loadedFileVersion = dt; | 2132 | loadedFileVersion = dt; |
2133 | } | 2133 | } |
2134 | bool CalendarView::checkFileChanged(QString fn) | 2134 | bool CalendarView::checkFileChanged(QString fn) |
2135 | { | 2135 | { |
2136 | QFileInfo finf ( fn ); | 2136 | QFileInfo finf ( fn ); |
2137 | if ( !finf.exists() ) | 2137 | if ( !finf.exists() ) |
2138 | return true; | 2138 | return true; |
2139 | QDateTime dt = finf.lastModified (); | 2139 | QDateTime dt = finf.lastModified (); |
2140 | if ( dt <= loadedFileVersion ) | 2140 | if ( dt <= loadedFileVersion ) |
2141 | return false; | 2141 | return false; |
2142 | return true; | 2142 | return true; |
2143 | 2143 | ||
2144 | } | 2144 | } |
2145 | void CalendarView::watchSavedFile() | 2145 | void CalendarView::watchSavedFile() |
2146 | { | 2146 | { |
2147 | QFileInfo finf ( MainWindow::defaultFileName()); | 2147 | QFileInfo finf ( MainWindow::defaultFileName()); |
2148 | if ( !finf.exists() ) | 2148 | if ( !finf.exists() ) |
2149 | return; | 2149 | return; |
2150 | QDateTime dt = finf.lastModified (); | 2150 | QDateTime dt = finf.lastModified (); |
2151 | if ( dt < loadedFileVersion ) { | 2151 | if ( dt < loadedFileVersion ) { |
2152 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2152 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2153 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2153 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2154 | return; | 2154 | return; |
2155 | } | 2155 | } |
2156 | loadedFileVersion = dt; | 2156 | loadedFileVersion = dt; |
2157 | } | 2157 | } |
2158 | bool CalendarView::checkAllFileVersions() | 2158 | bool CalendarView::checkAllFileVersions() |
2159 | { | 2159 | { |
2160 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2160 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2161 | KopiCalendarFile * cal = calendars.first(); | 2161 | KopiCalendarFile * cal = calendars.first(); |
2162 | mCalendar->setDefaultCalendar( 1 ); | 2162 | mCalendar->setDefaultCalendar( 1 ); |
2163 | mCalendar->setDefaultCalendarEnabledOnly(); | 2163 | mCalendar->setDefaultCalendarEnabledOnly(); |
2164 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2164 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2165 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2165 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2166 | restoreCalendarSettings(); | 2166 | restoreCalendarSettings(); |
2167 | return false; | 2167 | return false; |
2168 | } | 2168 | } |
2169 | } | 2169 | } |
2170 | cal = calendars.next(); | 2170 | cal = calendars.next(); |
2171 | QDateTime storeTemp = loadedFileVersion; | 2171 | QDateTime storeTemp = loadedFileVersion; |
2172 | while ( cal ) { | 2172 | while ( cal ) { |
2173 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2173 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2174 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2174 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2175 | mCalendar->setDefaultCalendarEnabledOnly(); | 2175 | mCalendar->setDefaultCalendarEnabledOnly(); |
2176 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2176 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2177 | if ( !checkFileVersion(cal->mFileName )) { | 2177 | if ( !checkFileVersion(cal->mFileName )) { |
2178 | loadedFileVersion = storeTemp; | 2178 | loadedFileVersion = storeTemp; |
2179 | restoreCalendarSettings(); | 2179 | restoreCalendarSettings(); |
2180 | return false; | 2180 | return false; |
2181 | } | 2181 | } |
2182 | } | 2182 | } |
2183 | cal = calendars.next(); | 2183 | cal = calendars.next(); |
2184 | } | 2184 | } |
2185 | loadedFileVersion = storeTemp; | 2185 | loadedFileVersion = storeTemp; |
2186 | return true; | 2186 | return true; |
2187 | } | 2187 | } |
2188 | bool CalendarView::checkFileVersion(QString fn) | 2188 | bool CalendarView::checkFileVersion(QString fn) |
2189 | { | 2189 | { |
2190 | QFileInfo finf ( fn ); | 2190 | QFileInfo finf ( fn ); |
2191 | if ( !finf.exists() ) | 2191 | if ( !finf.exists() ) |
2192 | return true; | 2192 | return true; |
2193 | QDateTime dt = finf.lastModified (); | 2193 | QDateTime dt = finf.lastModified (); |
2194 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2194 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2195 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2195 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2196 | if ( dt <= loadedFileVersion ) | 2196 | if ( dt <= loadedFileVersion ) |
2197 | return true; | 2197 | return true; |
2198 | 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)) , | 2198 | 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)) , |
2199 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2199 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2200 | i18n("Sync+save")); | 2200 | i18n("Sync+save")); |
2201 | 2201 | ||
2202 | if ( km == KMessageBox::Cancel ) | 2202 | if ( km == KMessageBox::Cancel ) |
2203 | return false; | 2203 | return false; |
2204 | if ( km == KMessageBox::Yes ) | 2204 | if ( km == KMessageBox::Yes ) |
2205 | return true; | 2205 | return true; |
2206 | 2206 | ||
2207 | setSyncDevice("deleteaftersync" ); | 2207 | setSyncDevice("deleteaftersync" ); |
2208 | mSyncManager->mAskForPreferences = true; | 2208 | mSyncManager->mAskForPreferences = true; |
2209 | mSyncManager->mSyncAlgoPrefs = 3; | 2209 | mSyncManager->mSyncAlgoPrefs = 3; |
2210 | mSyncManager->mWriteBackFile = false; | 2210 | mSyncManager->mWriteBackFile = false; |
2211 | mSyncManager->mWriteBackExistingOnly = false; | 2211 | mSyncManager->mWriteBackExistingOnly = false; |
2212 | mSyncManager->mShowSyncSummary = false; | 2212 | mSyncManager->mShowSyncSummary = false; |
2213 | syncCalendar( fn, 3 ); | 2213 | syncCalendar( fn, 3 ); |
2214 | Event * e = getLastSyncEvent(); | 2214 | Event * e = getLastSyncEvent(); |
2215 | if ( e ) | 2215 | if ( e ) |
2216 | mCalendar->deleteEvent( e ); | 2216 | mCalendar->deleteEvent( e ); |
2217 | return true; | 2217 | return true; |
2218 | } | 2218 | } |
2219 | bool CalendarView::saveCalendars() | 2219 | bool CalendarView::saveCalendars() |
2220 | { | 2220 | { |
2221 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2221 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2222 | KopiCalendarFile * cal = calendars.first(); | 2222 | KopiCalendarFile * cal = calendars.first(); |
2223 | mCalendar->setDefaultCalendar( 1 ); | 2223 | mCalendar->setDefaultCalendar( 1 ); |
2224 | mCalendar->setDefaultCalendarEnabledOnly(); | 2224 | mCalendar->setDefaultCalendarEnabledOnly(); |
2225 | saveCalendar( MainWindow::defaultFileName() ); | 2225 | saveCalendar( MainWindow::defaultFileName() ); |
2226 | cal = calendars.next(); | 2226 | cal = calendars.next(); |
2227 | while ( cal ) { | 2227 | while ( cal ) { |
2228 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2228 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2229 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2229 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2230 | mCalendar->setDefaultCalendarEnabledOnly(); | 2230 | mCalendar->setDefaultCalendarEnabledOnly(); |
2231 | if ( saveCalendar( cal->mFileName ) ) | 2231 | if ( saveCalendar( cal->mFileName ) ) |
2232 | cal->mLoadDt = QDateTime::currentDateTime(); | 2232 | cal->mLoadDt = QDateTime::currentDateTime(); |
2233 | } | 2233 | } |
2234 | cal = calendars.next(); | 2234 | cal = calendars.next(); |
2235 | } | 2235 | } |
2236 | restoreCalendarSettings(); | 2236 | restoreCalendarSettings(); |
2237 | return true; | 2237 | return true; |
2238 | } | 2238 | } |
2239 | bool CalendarView::saveCalendar( QString filename ) | 2239 | bool CalendarView::saveCalendar( QString filename ) |
2240 | { | 2240 | { |
2241 | 2241 | ||
2242 | // Store back all unsaved data into calendar object | 2242 | // Store back all unsaved data into calendar object |
2243 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2243 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2244 | if ( mViewManager->currentView() ) | 2244 | if ( mViewManager->currentView() ) |
2245 | mViewManager->currentView()->flushView(); | 2245 | mViewManager->currentView()->flushView(); |
2246 | 2246 | ||
2247 | 2247 | ||
2248 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2248 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2249 | mStorage->setSaveFormat( new ICalFormat() ); | 2249 | mStorage->setSaveFormat( new ICalFormat() ); |
2250 | mStorage->setFileName( filename ); | 2250 | mStorage->setFileName( filename ); |
2251 | bool success; | 2251 | bool success; |
2252 | success = mStorage->save(); | 2252 | success = mStorage->save(); |
2253 | if ( !success ) { | 2253 | if ( !success ) { |
2254 | return false; | 2254 | return false; |
2255 | } | 2255 | } |
2256 | if ( filename == MainWindow::defaultFileName() ) { | 2256 | if ( filename == MainWindow::defaultFileName() ) { |
2257 | setLoadedFileVersion( lfv ); | 2257 | setLoadedFileVersion( lfv ); |
2258 | watchSavedFile(); | 2258 | watchSavedFile(); |
2259 | } | 2259 | } |
2260 | return true; | 2260 | return true; |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | void CalendarView::closeCalendar() | 2263 | void CalendarView::closeCalendar() |
2264 | { | 2264 | { |
2265 | 2265 | ||
2266 | // child windows no longer valid | 2266 | // child windows no longer valid |
2267 | clearAllViews(); | 2267 | clearAllViews(); |
2268 | emit closingDown(); | 2268 | emit closingDown(); |
2269 | 2269 | ||
2270 | mCalendar->close(); | 2270 | mCalendar->close(); |
2271 | setModified(false); | 2271 | setModified(false); |
2272 | updateView(); | 2272 | updateView(); |
2273 | } | 2273 | } |
2274 | 2274 | ||
2275 | void CalendarView::archiveCalendar() | 2275 | void CalendarView::archiveCalendar() |
2276 | { | 2276 | { |
2277 | mDialogManager->showArchiveDialog(); | 2277 | mDialogManager->showArchiveDialog(); |
2278 | } | 2278 | } |
2279 | 2279 | ||
2280 | 2280 | ||
2281 | void CalendarView::readSettings() | 2281 | void CalendarView::readSettings() |
2282 | { | 2282 | { |
2283 | 2283 | ||
2284 | 2284 | ||
2285 | // mViewManager->showAgendaView(); | 2285 | // mViewManager->showAgendaView(); |
2286 | QString str; | 2286 | QString str; |
2287 | //qDebug("CalendarView::readSettings() "); | 2287 | //qDebug("CalendarView::readSettings() "); |
2288 | // read settings from the KConfig, supplying reasonable | 2288 | // read settings from the KConfig, supplying reasonable |
2289 | // defaults where none are to be found | 2289 | // defaults where none are to be found |
2290 | KConfig *config = KOGlobals::config(); | 2290 | KConfig *config = KOGlobals::config(); |
2291 | #ifndef KORG_NOSPLITTER | 2291 | #ifndef KORG_NOSPLITTER |
2292 | config->setGroup("KOrganizer Geometry"); | 2292 | config->setGroup("KOrganizer Geometry"); |
2293 | 2293 | ||
2294 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2294 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2295 | if (sizes.count() != 2) { | 2295 | if (sizes.count() != 2) { |
2296 | sizes << mDateNavigator->minimumSizeHint().width(); | 2296 | sizes << mDateNavigator->minimumSizeHint().width(); |
2297 | sizes << 300; | 2297 | sizes << 300; |
2298 | } | 2298 | } |
2299 | mPanner->setSizes(sizes); | 2299 | mPanner->setSizes(sizes); |
2300 | 2300 | ||
2301 | sizes = config->readIntListEntry("Separator2"); | 2301 | sizes = config->readIntListEntry("Separator2"); |
2302 | if ( ( mResourceView && sizes.count() == 4 ) || | 2302 | if ( ( mResourceView && sizes.count() == 4 ) || |
2303 | ( !mResourceView && sizes.count() == 3 ) ) { | 2303 | ( !mResourceView && sizes.count() == 3 ) ) { |
2304 | mLeftSplitter->setSizes(sizes); | 2304 | mLeftSplitter->setSizes(sizes); |
2305 | } | 2305 | } |
2306 | #endif | 2306 | #endif |
2307 | globalFlagBlockAgenda = 1; | 2307 | globalFlagBlockAgenda = 1; |
2308 | mViewManager->showAgendaView(); | 2308 | mViewManager->showAgendaView(); |
2309 | //mViewManager->readSettings( config ); | 2309 | //mViewManager->readSettings( config ); |
2310 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2310 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2311 | readFilterSettings(config); | 2311 | readFilterSettings(config); |
2312 | 2312 | ||
2313 | #ifdef DESKTOP_VERSION | 2313 | #ifdef DESKTOP_VERSION |
2314 | config->setGroup("WidgetLayout"); | 2314 | config->setGroup("WidgetLayout"); |
2315 | QStringList list; | 2315 | QStringList list; |
2316 | list = config->readListEntry("MainLayout"); | 2316 | list = config->readListEntry("MainLayout"); |
2317 | int x,y,w,h; | 2317 | int x,y,w,h; |
2318 | if ( ! list.isEmpty() ) { | 2318 | if ( ! list.isEmpty() ) { |
2319 | x = list[0].toInt(); | 2319 | x = list[0].toInt(); |
2320 | y = list[1].toInt(); | 2320 | y = list[1].toInt(); |
2321 | w = list[2].toInt(); | 2321 | w = list[2].toInt(); |
2322 | h = list[3].toInt(); | 2322 | h = list[3].toInt(); |
2323 | KApplication::testCoords( &x,&y,&w,&h ); | 2323 | KApplication::testCoords( &x,&y,&w,&h ); |
2324 | topLevelWidget()->setGeometry(x,y,w,h); | 2324 | topLevelWidget()->setGeometry(x,y,w,h); |
2325 | 2325 | ||
2326 | } else { | 2326 | } else { |
2327 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2327 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2328 | } | 2328 | } |
2329 | list = config->readListEntry("EditEventLayout"); | 2329 | list = config->readListEntry("EditEventLayout"); |
2330 | if ( ! list.isEmpty() ) { | 2330 | if ( ! list.isEmpty() ) { |
2331 | x = list[0].toInt(); | 2331 | x = list[0].toInt(); |
2332 | y = list[1].toInt(); | 2332 | y = list[1].toInt(); |
2333 | w = list[2].toInt(); | 2333 | w = list[2].toInt(); |
2334 | h = list[3].toInt(); | 2334 | h = list[3].toInt(); |
2335 | KApplication::testCoords( &x,&y,&w,&h ); | 2335 | KApplication::testCoords( &x,&y,&w,&h ); |
2336 | mEventEditor->setGeometry(x,y,w,h); | 2336 | mEventEditor->setGeometry(x,y,w,h); |
2337 | 2337 | ||
2338 | } | 2338 | } |
2339 | list = config->readListEntry("EditTodoLayout"); | 2339 | list = config->readListEntry("EditTodoLayout"); |
2340 | if ( ! list.isEmpty() ) { | 2340 | if ( ! list.isEmpty() ) { |
2341 | x = list[0].toInt(); | 2341 | x = list[0].toInt(); |
2342 | y = list[1].toInt(); | 2342 | y = list[1].toInt(); |
2343 | w = list[2].toInt(); | 2343 | w = list[2].toInt(); |
2344 | h = list[3].toInt(); | 2344 | h = list[3].toInt(); |
2345 | KApplication::testCoords( &x,&y,&w,&h ); | 2345 | KApplication::testCoords( &x,&y,&w,&h ); |
2346 | mTodoEditor->setGeometry(x,y,w,h); | 2346 | mTodoEditor->setGeometry(x,y,w,h); |
2347 | 2347 | ||
2348 | } | 2348 | } |
2349 | list = config->readListEntry("ViewerLayout"); | 2349 | list = config->readListEntry("ViewerLayout"); |
2350 | if ( ! list.isEmpty() ) { | 2350 | if ( ! list.isEmpty() ) { |
2351 | x = list[0].toInt(); | 2351 | x = list[0].toInt(); |
2352 | y = list[1].toInt(); | 2352 | y = list[1].toInt(); |
2353 | w = list[2].toInt(); | 2353 | w = list[2].toInt(); |
2354 | h = list[3].toInt(); | 2354 | h = list[3].toInt(); |
2355 | KApplication::testCoords( &x,&y,&w,&h ); | 2355 | KApplication::testCoords( &x,&y,&w,&h ); |
2356 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2356 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2357 | } | 2357 | } |
2358 | #endif | 2358 | #endif |
2359 | config->setGroup( "Views" ); | 2359 | config->setGroup( "Views" ); |
2360 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2360 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2361 | 2361 | ||
2362 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2362 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2363 | 2363 | ||
2364 | int resetval = 0; | 2364 | int resetval = 0; |
2365 | int maxVal = 0; | 2365 | int maxVal = 0; |
2366 | if (sizes.count() != 3) { | 2366 | if (sizes.count() != 3) { |
2367 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2367 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2368 | resetval = mDateNavigator->sizeHint().width()+2; | 2368 | resetval = mDateNavigator->sizeHint().width()+2; |
2369 | } else { | 2369 | } else { |
2370 | resetval = mDateNavigator->sizeHint().height()+2; | 2370 | resetval = mDateNavigator->sizeHint().height()+2; |
2371 | } | 2371 | } |
2372 | } | 2372 | } |
2373 | if ( resetval ) { | 2373 | if ( resetval ) { |
2374 | sizes.clear(); | 2374 | sizes.clear(); |
2375 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2375 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2376 | maxVal = QApplication::desktop()->width() -10; | 2376 | maxVal = QApplication::desktop()->width() -10; |
2377 | } else { | 2377 | } else { |
2378 | maxVal = QApplication::desktop()->height()-10; | 2378 | maxVal = QApplication::desktop()->height()-10; |
2379 | } | 2379 | } |
2380 | sizes << resetval; | 2380 | sizes << resetval; |
2381 | if ( maxVal < resetval + resetval) | 2381 | if ( maxVal < resetval + resetval) |
2382 | resetval = maxVal - resetval; | 2382 | resetval = maxVal - resetval; |
2383 | sizes << resetval; | 2383 | sizes << resetval; |
2384 | sizes << 100; | 2384 | sizes << 100; |
2385 | } | 2385 | } |
2386 | mLeftFrame->setSizes(sizes); | 2386 | mLeftFrame->setSizes(sizes); |
2387 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2387 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2388 | resetval = 0; | 2388 | resetval = 0; |
2389 | maxVal = 0; | 2389 | maxVal = 0; |
2390 | if (sizes.count() != 2) { | 2390 | if (sizes.count() != 2) { |
2391 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2391 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2392 | resetval = mDateNavigator->sizeHint().width()+2; | 2392 | resetval = mDateNavigator->sizeHint().width()+2; |
2393 | } else { | 2393 | } else { |
2394 | resetval = mDateNavigator->sizeHint().height()+2; | 2394 | resetval = mDateNavigator->sizeHint().height()+2; |
2395 | } | 2395 | } |
2396 | } | 2396 | } |
2397 | if ( resetval ) { | 2397 | if ( resetval ) { |
2398 | sizes.clear(); | 2398 | sizes.clear(); |
2399 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2399 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2400 | maxVal = QApplication::desktop()->width() -10; | 2400 | maxVal = QApplication::desktop()->width() -10; |
2401 | } else { | 2401 | } else { |
2402 | maxVal = QApplication::desktop()->height()-10; | 2402 | maxVal = QApplication::desktop()->height()-10; |
2403 | } | 2403 | } |
2404 | sizes << resetval; | 2404 | sizes << resetval; |
2405 | if ( maxVal < resetval + resetval) | 2405 | if ( maxVal < resetval + resetval) |
2406 | resetval = maxVal - resetval; | 2406 | resetval = maxVal - resetval; |
2407 | sizes << resetval; | 2407 | sizes << resetval; |
2408 | } | 2408 | } |
2409 | mMainFrame->setSizes(sizes); | 2409 | mMainFrame->setSizes(sizes); |
2410 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2410 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2411 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2411 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2412 | else mNavigator->selectDates( dateCount ); | 2412 | else mNavigator->selectDates( dateCount ); |
2413 | // mViewManager->readSettings( config ); | 2413 | // mViewManager->readSettings( config ); |
2414 | updateConfig(); | 2414 | updateConfig(); |
2415 | globalFlagBlockAgenda = 2; | 2415 | globalFlagBlockAgenda = 2; |
2416 | mViewManager->readSettings( config ); | 2416 | mViewManager->readSettings( config ); |
2417 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2417 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2418 | } | 2418 | } |
2419 | 2419 | ||
2420 | void CalendarView::checkSuspendAlarm() | 2420 | void CalendarView::checkSuspendAlarm() |
2421 | { | 2421 | { |
2422 | if ( mSuspendTimer->isActive() ) { | 2422 | if ( mSuspendTimer->isActive() ) { |
2423 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2423 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2424 | } | 2424 | } |
2425 | } | 2425 | } |
2426 | void CalendarView::writeSettings() | 2426 | void CalendarView::writeSettings() |
2427 | { | 2427 | { |
2428 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2428 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2429 | 2429 | ||
2430 | KConfig *config = KOGlobals::config(); | 2430 | KConfig *config = KOGlobals::config(); |
2431 | 2431 | ||
2432 | mViewManager->writeSettings( config ); | 2432 | mViewManager->writeSettings( config ); |
2433 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2433 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2434 | mDialogManager->writeSettings( config ); | 2434 | mDialogManager->writeSettings( config ); |
2435 | //KOPrefs::instance()->usrWriteConfig(); | 2435 | //KOPrefs::instance()->usrWriteConfig(); |
2436 | KOPrefs::instance()->writeConfig(); | 2436 | KOPrefs::instance()->writeConfig(); |
2437 | 2437 | ||
2438 | writeFilterSettings(config); | 2438 | writeFilterSettings(config); |
2439 | config->setGroup( "AppRun" ); | 2439 | config->setGroup( "AppRun" ); |
2440 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2440 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2441 | int days = dt.daysTo( QDate::currentDate() ); | 2441 | int days = dt.daysTo( QDate::currentDate() ); |
2442 | dt = dt.addDays( days ); | 2442 | dt = dt.addDays( days ); |
2443 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2443 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2444 | config->writeEntry( "LatestProgramStopDays", days ); | 2444 | config->writeEntry( "LatestProgramStopDays", days ); |
2445 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2445 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2446 | //qDebug("KO: Writing stop time: %d ", secs); | 2446 | //qDebug("KO: Writing stop time: %d ", secs); |
2447 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2447 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2448 | //QDateTime latest = dt.addSecs ( secs ); | 2448 | //QDateTime latest = dt.addSecs ( secs ); |
2449 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2449 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2450 | config->setGroup( "Views" ); | 2450 | config->setGroup( "Views" ); |
2451 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2451 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2452 | 2452 | ||
2453 | #if 0 | 2453 | #if 0 |
2454 | qDebug("********************* "); | 2454 | qDebug("********************* "); |
2455 | qDebug("Testcode secsto "); | 2455 | qDebug("Testcode secsto "); |
2456 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2456 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2457 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2457 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2458 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2458 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2459 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2459 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2460 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2460 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2461 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2461 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2462 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2462 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2463 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2463 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2464 | qDebug("********************* testcode end"); | 2464 | qDebug("********************* testcode end"); |
2465 | 2465 | ||
2466 | #endif | 2466 | #endif |
2467 | 2467 | ||
2468 | QValueList<int> listINT = mLeftFrame->sizes(); | 2468 | QValueList<int> listINT = mLeftFrame->sizes(); |
2469 | config->writeEntry("Left Splitter Frame",listINT); | 2469 | config->writeEntry("Left Splitter Frame",listINT); |
2470 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2470 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2471 | config->writeEntry("Main Splitter Frame",listINT2); | 2471 | config->writeEntry("Main Splitter Frame",listINT2); |
2472 | #ifdef DESKTOP_VERSION | 2472 | #ifdef DESKTOP_VERSION |
2473 | config->setGroup("WidgetLayout"); | 2473 | config->setGroup("WidgetLayout"); |
2474 | QStringList list ;//= config->readListEntry("MainLayout"); | 2474 | QStringList list ;//= config->readListEntry("MainLayout"); |
2475 | int x,y,w,h; | 2475 | int x,y,w,h; |
2476 | QWidget* wid; | 2476 | QWidget* wid; |
2477 | wid = topLevelWidget(); | 2477 | wid = topLevelWidget(); |
2478 | x = wid->geometry().x(); | 2478 | x = wid->geometry().x(); |
2479 | y = wid->geometry().y(); | 2479 | y = wid->geometry().y(); |
2480 | w = wid->width(); | 2480 | w = wid->width(); |
2481 | h = wid->height(); | 2481 | h = wid->height(); |
2482 | list.clear(); | 2482 | list.clear(); |
2483 | list << QString::number( x ); | 2483 | list << QString::number( x ); |
2484 | list << QString::number( y ); | 2484 | list << QString::number( y ); |
2485 | list << QString::number( w ); | 2485 | list << QString::number( w ); |
2486 | list << QString::number( h ); | 2486 | list << QString::number( h ); |
2487 | config->writeEntry("MainLayout",list ); | 2487 | config->writeEntry("MainLayout",list ); |
2488 | 2488 | ||
2489 | wid = mEventEditor; | 2489 | wid = mEventEditor; |
2490 | x = wid->geometry().x(); | 2490 | x = wid->geometry().x(); |
2491 | y = wid->geometry().y(); | 2491 | y = wid->geometry().y(); |
2492 | w = wid->width(); | 2492 | w = wid->width(); |
2493 | h = wid->height(); | 2493 | h = wid->height(); |
2494 | list.clear(); | 2494 | list.clear(); |
2495 | list << QString::number( x ); | 2495 | list << QString::number( x ); |
2496 | list << QString::number( y ); | 2496 | list << QString::number( y ); |
2497 | list << QString::number( w ); | 2497 | list << QString::number( w ); |
2498 | list << QString::number( h ); | 2498 | list << QString::number( h ); |
2499 | config->writeEntry("EditEventLayout",list ); | 2499 | config->writeEntry("EditEventLayout",list ); |
2500 | 2500 | ||
2501 | wid = mTodoEditor; | 2501 | wid = mTodoEditor; |
2502 | x = wid->geometry().x(); | 2502 | x = wid->geometry().x(); |
2503 | y = wid->geometry().y(); | 2503 | y = wid->geometry().y(); |
2504 | w = wid->width(); | 2504 | w = wid->width(); |
2505 | h = wid->height(); | 2505 | h = wid->height(); |
2506 | list.clear(); | 2506 | list.clear(); |
2507 | list << QString::number( x ); | 2507 | list << QString::number( x ); |
2508 | list << QString::number( y ); | 2508 | list << QString::number( y ); |
2509 | list << QString::number( w ); | 2509 | list << QString::number( w ); |
2510 | list << QString::number( h ); | 2510 | list << QString::number( h ); |
2511 | config->writeEntry("EditTodoLayout",list ); | 2511 | config->writeEntry("EditTodoLayout",list ); |
2512 | wid = getEventViewerDialog(); | 2512 | wid = getEventViewerDialog(); |
2513 | x = wid->geometry().x(); | 2513 | x = wid->geometry().x(); |
2514 | y = wid->geometry().y(); | 2514 | y = wid->geometry().y(); |
2515 | w = wid->width(); | 2515 | w = wid->width(); |
2516 | h = wid->height(); | 2516 | h = wid->height(); |
2517 | list.clear(); | 2517 | list.clear(); |
2518 | list << QString::number( x ); | 2518 | list << QString::number( x ); |
2519 | list << QString::number( y ); | 2519 | list << QString::number( y ); |
2520 | list << QString::number( w ); | 2520 | list << QString::number( w ); |
2521 | list << QString::number( h ); | 2521 | list << QString::number( h ); |
2522 | config->writeEntry("ViewerLayout",list ); | 2522 | config->writeEntry("ViewerLayout",list ); |
2523 | wid = mDialogManager->getSearchDialog(); | 2523 | wid = mDialogManager->getSearchDialog(); |
2524 | if ( wid ) { | 2524 | if ( wid ) { |
2525 | x = wid->geometry().x(); | 2525 | x = wid->geometry().x(); |
2526 | y = wid->geometry().y(); | 2526 | y = wid->geometry().y(); |
2527 | w = wid->width(); | 2527 | w = wid->width(); |
2528 | h = wid->height(); | 2528 | h = wid->height(); |
2529 | list.clear(); | 2529 | list.clear(); |
2530 | list << QString::number( x ); | 2530 | list << QString::number( x ); |
2531 | list << QString::number( y ); | 2531 | list << QString::number( y ); |
2532 | list << QString::number( w ); | 2532 | list << QString::number( w ); |
2533 | list << QString::number( h ); | 2533 | list << QString::number( h ); |
2534 | config->writeEntry("SearchLayout",list ); | 2534 | config->writeEntry("SearchLayout",list ); |
2535 | } | 2535 | } |
2536 | #endif | 2536 | #endif |
2537 | 2537 | ||
2538 | 2538 | ||
2539 | config->sync(); | 2539 | config->sync(); |
2540 | } | 2540 | } |
2541 | 2541 | ||
2542 | void CalendarView::readFilterSettings(KConfig *config) | 2542 | void CalendarView::readFilterSettings(KConfig *config) |
2543 | { | 2543 | { |
2544 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2544 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2545 | 2545 | ||
2546 | mFilters.clear(); | 2546 | mFilters.clear(); |
2547 | 2547 | ||
2548 | config->setGroup("General"); | 2548 | config->setGroup("General"); |
2549 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2549 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2550 | 2550 | ||
2551 | QStringList::ConstIterator it = filterList.begin(); | 2551 | QStringList::ConstIterator it = filterList.begin(); |
2552 | QStringList::ConstIterator end = filterList.end(); | 2552 | QStringList::ConstIterator end = filterList.end(); |
2553 | while(it != end) { | 2553 | while(it != end) { |
2554 | // kdDebug() << " filter: " << (*it) << endl; | 2554 | // kdDebug() << " filter: " << (*it) << endl; |
2555 | 2555 | ||
2556 | CalFilter *filter; | 2556 | CalFilter *filter; |
2557 | filter = new CalFilter(*it); | 2557 | filter = new CalFilter(*it); |
2558 | config->setGroup("Filter_" + (*it).utf8()); | 2558 | config->setGroup("Filter_" + (*it).utf8()); |
2559 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2559 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2560 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2560 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2561 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2561 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2562 | mFilters.append(filter); | 2562 | mFilters.append(filter); |
2563 | 2563 | ||
2564 | ++it; | 2564 | ++it; |
2565 | } | 2565 | } |
2566 | 2566 | ||
2567 | if (mFilters.count() == 0) { | 2567 | if (mFilters.count() == 0) { |
2568 | CalFilter *filter = new CalFilter(i18n("Default")); | 2568 | CalFilter *filter = new CalFilter(i18n("Default")); |
2569 | mFilters.append(filter); | 2569 | mFilters.append(filter); |
2570 | } | 2570 | } |
2571 | mFilterView->updateFilters(); | 2571 | mFilterView->updateFilters(); |
2572 | config->setGroup("FilterView"); | 2572 | config->setGroup("FilterView"); |
2573 | 2573 | ||
2574 | mFilterView->blockSignals(true); | 2574 | mFilterView->blockSignals(true); |
2575 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2575 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2576 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2576 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2577 | mFilterView->blockSignals(false); | 2577 | mFilterView->blockSignals(false); |
2578 | // We do it manually to avoid it being done twice by the above calls | 2578 | // We do it manually to avoid it being done twice by the above calls |
2579 | updateFilter(); | 2579 | updateFilter(); |
2580 | } | 2580 | } |
2581 | 2581 | ||
2582 | void CalendarView::writeFilterSettings(KConfig *config) | 2582 | void CalendarView::writeFilterSettings(KConfig *config) |
2583 | { | 2583 | { |
2584 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2584 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2585 | 2585 | ||
2586 | QStringList filterList; | 2586 | QStringList filterList; |
2587 | 2587 | ||
2588 | CalFilter *filter = mFilters.first(); | 2588 | CalFilter *filter = mFilters.first(); |
2589 | while(filter) { | 2589 | while(filter) { |
2590 | // kdDebug() << " fn: " << filter->name() << endl; | 2590 | // kdDebug() << " fn: " << filter->name() << endl; |
2591 | filterList << filter->name(); | 2591 | filterList << filter->name(); |
2592 | config->setGroup("Filter_" + filter->name().utf8()); | 2592 | config->setGroup("Filter_" + filter->name().utf8()); |
2593 | config->writeEntry("Criteria",filter->criteria()); | 2593 | config->writeEntry("Criteria",filter->criteria()); |
2594 | config->writeEntry("CategoryList",filter->categoryList()); | 2594 | config->writeEntry("CategoryList",filter->categoryList()); |
2595 | filter = mFilters.next(); | 2595 | filter = mFilters.next(); |
2596 | } | 2596 | } |
2597 | config->setGroup("General"); | 2597 | config->setGroup("General"); |
2598 | config->writeEntry("CalendarFilters",filterList); | 2598 | config->writeEntry("CalendarFilters",filterList); |
2599 | 2599 | ||
2600 | config->setGroup("FilterView"); | 2600 | config->setGroup("FilterView"); |
2601 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2601 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2602 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2602 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2603 | } | 2603 | } |
2604 | 2604 | ||
2605 | 2605 | ||
2606 | void CalendarView::goToday() | 2606 | void CalendarView::goToday() |
2607 | { | 2607 | { |
2608 | if ( mViewManager->currentView()->isMonthView() ) | 2608 | if ( mViewManager->currentView()->isMonthView() ) |
2609 | mNavigator->selectTodayMonth(); | 2609 | mNavigator->selectTodayMonth(); |
2610 | else | 2610 | else |
2611 | mNavigator->selectToday(); | 2611 | mNavigator->selectToday(); |
2612 | } | 2612 | } |
2613 | 2613 | ||
2614 | void CalendarView::goNext() | 2614 | void CalendarView::goNext() |
2615 | { | 2615 | { |
2616 | mNavigator->selectNext(); | 2616 | mNavigator->selectNext(); |
2617 | } | 2617 | } |
2618 | 2618 | ||
2619 | void CalendarView::goPrevious() | 2619 | void CalendarView::goPrevious() |
2620 | { | 2620 | { |
2621 | mNavigator->selectPrevious(); | 2621 | mNavigator->selectPrevious(); |
2622 | } | 2622 | } |
2623 | void CalendarView::goNextMonth() | 2623 | void CalendarView::goNextMonth() |
2624 | { | 2624 | { |
2625 | mNavigator->selectNextMonth(); | 2625 | mNavigator->selectNextMonth(); |
2626 | } | 2626 | } |
2627 | 2627 | ||
2628 | void CalendarView::goPreviousMonth() | 2628 | void CalendarView::goPreviousMonth() |
2629 | { | 2629 | { |
2630 | mNavigator->selectPreviousMonth(); | 2630 | mNavigator->selectPreviousMonth(); |
2631 | } | 2631 | } |
2632 | 2632 | ||
2633 | void CalendarView::updateConfig() | 2633 | void CalendarView::updateConfig() |
2634 | { | 2634 | { |
2635 | if ( KOPrefs::instance()->mUseAppColors ) | 2635 | if ( KOPrefs::instance()->mUseAppColors ) |
2636 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2636 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2637 | emit configChanged(); | 2637 | emit configChanged(); |
2638 | mTodoList->updateConfig(); | 2638 | mTodoList->updateConfig(); |
2639 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2639 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2640 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2640 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2641 | // To make the "fill window" configurations work | 2641 | // To make the "fill window" configurations work |
2642 | //mViewManager->raiseCurrentView(); | 2642 | //mViewManager->raiseCurrentView(); |
2643 | } | 2643 | } |
2644 | 2644 | ||
2645 | 2645 | ||
2646 | void CalendarView::eventChanged(Event *event) | 2646 | void CalendarView::eventChanged(Event *event) |
2647 | { | 2647 | { |
2648 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2648 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2649 | //updateUnmanagedViews(); | 2649 | //updateUnmanagedViews(); |
2650 | } | 2650 | } |
2651 | 2651 | ||
2652 | void CalendarView::eventAdded(Event *event) | 2652 | void CalendarView::eventAdded(Event *event) |
2653 | { | 2653 | { |
2654 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2654 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2655 | } | 2655 | } |
2656 | 2656 | ||
2657 | void CalendarView::eventToBeDeleted(Event *) | 2657 | void CalendarView::eventToBeDeleted(Event *) |
2658 | { | 2658 | { |
2659 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2659 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2660 | } | 2660 | } |
2661 | 2661 | ||
2662 | void CalendarView::eventDeleted() | 2662 | void CalendarView::eventDeleted() |
2663 | { | 2663 | { |
2664 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2664 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2665 | } | 2665 | } |
2666 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2666 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2667 | { | 2667 | { |
2668 | changeIncidenceDisplay((Incidence *)which, action); | 2668 | changeIncidenceDisplay((Incidence *)which, action); |
2669 | mDateNavigator->updateView(); //LR | 2669 | mDateNavigator->updateView(); //LR |
2670 | //mDialogManager->updateSearchDialog(); | 2670 | //mDialogManager->updateSearchDialog(); |
2671 | 2671 | ||
2672 | if (which) { | 2672 | if (which) { |
2673 | mViewManager->updateWNview(); | 2673 | mViewManager->updateWNview(); |
2674 | //mTodoList->updateView(); | 2674 | //mTodoList->updateView(); |
2675 | } | 2675 | } |
2676 | 2676 | ||
2677 | } | 2677 | } |
2678 | 2678 | ||
2679 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2679 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2680 | { | 2680 | { |
2681 | updateUnmanagedViews(); | 2681 | updateUnmanagedViews(); |
2682 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2682 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2683 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2683 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2684 | mCalendar->checkAlarmForIncidence( 0, true ); | 2684 | mCalendar->checkAlarmForIncidence( 0, true ); |
2685 | if ( mEventViewerDialog ) | 2685 | if ( mEventViewerDialog ) |
2686 | mEventViewerDialog->hide(); | 2686 | mEventViewerDialog->hide(); |
2687 | } | 2687 | } |
2688 | else | 2688 | else |
2689 | mCalendar->checkAlarmForIncidence( which , false ); | 2689 | mCalendar->checkAlarmForIncidence( which , false ); |
2690 | } | 2690 | } |
2691 | 2691 | ||
2692 | // most of the changeEventDisplays() right now just call the view's | 2692 | // most of the changeEventDisplays() right now just call the view's |
2693 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2693 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2694 | void CalendarView::changeEventDisplay(Event *which, int action) | 2694 | void CalendarView::changeEventDisplay(Event *which, int action) |
2695 | { | 2695 | { |
2696 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2696 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2697 | changeIncidenceDisplay((Incidence *)which, action); | 2697 | changeIncidenceDisplay((Incidence *)which, action); |
2698 | 2698 | ||
2699 | 2699 | ||
2700 | static bool clearallviews = false; | 2700 | static bool clearallviews = false; |
2701 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2701 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2702 | if ( clearallviews ) { | 2702 | if ( clearallviews ) { |
2703 | clearAllViews(); | 2703 | clearAllViews(); |
2704 | clearallviews = false; | 2704 | clearallviews = false; |
2705 | } | 2705 | } |
2706 | return; | 2706 | return; |
2707 | } | 2707 | } |
2708 | clearallviews = true; | 2708 | clearallviews = true; |
2709 | 2709 | ||
2710 | 2710 | ||
2711 | 2711 | ||
2712 | mDateNavigator->updateView(); | 2712 | mDateNavigator->updateView(); |
2713 | //mDialogManager->updateSearchDialog(); | 2713 | //mDialogManager->updateSearchDialog(); |
2714 | 2714 | ||
2715 | if (which) { | 2715 | if (which) { |
2716 | // If there is an event view visible update the display | 2716 | // If there is an event view visible update the display |
2717 | mViewManager->currentView()->changeEventDisplay(which,action); | 2717 | mViewManager->currentView()->changeEventDisplay(which,action); |
2718 | // TODO: check, if update needed | 2718 | // TODO: check, if update needed |
2719 | // if (which->getTodoStatus()) { | 2719 | // if (which->getTodoStatus()) { |
2720 | mTodoList->updateView(); | 2720 | mTodoList->updateView(); |
2721 | if ( action != KOGlobals::EVENTDELETED ) { | ||
2722 | mConflictingEvent = which ; | ||
2723 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); | ||
2724 | } | ||
2721 | // } | 2725 | // } |
2722 | } else { | 2726 | } else { |
2723 | mViewManager->currentView()->updateView(); | 2727 | mViewManager->currentView()->updateView(); |
2724 | } | 2728 | } |
2725 | } | 2729 | } |
2730 | void CalendarView::checkConflictForEvent() | ||
2731 | { | ||
2732 | |||
2733 | if (!KOPrefs::instance()->mConfirm) | ||
2734 | return; | ||
2735 | if ( ! mConflictingEvent ) return; | ||
2736 | if ( mConflictingEvent->doesFloat() ) { | ||
2737 | mConflictingEvent = 0; | ||
2738 | return; | ||
2739 | } | ||
2740 | bool all = false; | ||
2741 | bool allday = false; | ||
2742 | Event * ev = mConflictingEvent; | ||
2743 | mConflictingEvent = 0; | ||
2744 | QDate start = ev->dtStart().date(); | ||
2745 | QDate end = ev->dtEnd().date().addDays(1); | ||
2746 | while ( start < end ) { | ||
2747 | QPtrList<Event> test = calendar()->events( start ); | ||
2748 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); | ||
2749 | Event * t_ev = test.first(); | ||
2750 | QDateTime es = ev->dtStart(); | ||
2751 | QDateTime ee = ev->dtEnd(); | ||
2752 | if ( ev->doesFloat() ) | ||
2753 | ee = ee.addDays( 1 ); | ||
2754 | if ( ! all ) { | ||
2755 | if ( ev->doesFloat() != allday ) | ||
2756 | t_ev = 0; | ||
2757 | } | ||
2758 | while ( t_ev ) { | ||
2759 | bool skip = false; | ||
2760 | if ( ! all ) { | ||
2761 | if ( t_ev->doesFloat() != allday ) | ||
2762 | skip = true; | ||
2763 | } | ||
2764 | if ( !skip && ev != t_ev ) { | ||
2765 | QDateTime ets = t_ev->dtStart(); | ||
2766 | QDateTime ete = t_ev->dtEnd(); | ||
2767 | if ( t_ev->doesFloat() ) | ||
2768 | ete = ete.addDays( 1 ); | ||
2769 | //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); | ||
2770 | if ( es < ete && ets < ee ) { | ||
2771 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( ev->summary(),0 ) ).arg( KGlobal::formatMessage ( t_ev->summary(),0 )).arg(KGlobal::locale()->formatDate(start) ) ; | ||
2772 | qApp->processEvents(); | ||
2773 | int km = KMessageBox::warningContinueCancel(this,mess, | ||
2774 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | ||
2775 | if ( km != KMessageBox::Continue ) | ||
2776 | return; | ||
2777 | |||
2778 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | ||
2779 | mViewManager->showDayView(); | ||
2780 | mNavigator->slotDaySelect( start ); | ||
2781 | int hour = es.time().hour(); | ||
2782 | if ( ets > es ) | ||
2783 | hour = ets.time().hour(); | ||
2784 | mViewManager->agendaView()->setStartHour( hour ); | ||
2785 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); | ||
2786 | return; | ||
2787 | } | ||
2788 | } | ||
2789 | t_ev = test.next(); | ||
2790 | } | ||
2791 | start = start.addDays( 1 ); | ||
2792 | } | ||
2793 | qDebug("No conflict found "); | ||
2794 | |||
2726 | 2795 | ||
2796 | } | ||
2727 | 2797 | ||
2728 | void CalendarView::updateTodoViews() | 2798 | void CalendarView::updateTodoViews() |
2729 | { | 2799 | { |
2730 | mTodoList->updateView(); | 2800 | mTodoList->updateView(); |
2731 | mViewManager->currentView()->updateView(); | 2801 | mViewManager->currentView()->updateView(); |
2732 | 2802 | ||
2733 | } | 2803 | } |
2734 | 2804 | ||
2735 | 2805 | ||
2736 | 2806 | ||
2737 | void CalendarView::clearAllViews() | 2807 | void CalendarView::clearAllViews() |
2738 | { | 2808 | { |
2739 | mTodoList->clearList(); | 2809 | mTodoList->clearList(); |
2740 | mViewManager->clearAllViews(); | 2810 | mViewManager->clearAllViews(); |
2741 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2811 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2742 | if ( sd ) { | 2812 | if ( sd ) { |
2743 | KOListView* kol = sd->listview(); | 2813 | KOListView* kol = sd->listview(); |
2744 | if ( kol ) | 2814 | if ( kol ) |
2745 | kol->clearList(); | 2815 | kol->clearList(); |
2746 | } | 2816 | } |
2747 | } | 2817 | } |
2748 | void CalendarView::updateView() | 2818 | void CalendarView::updateView() |
2749 | { | 2819 | { |
2750 | static bool clearallviews = false; | 2820 | static bool clearallviews = false; |
2751 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2821 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2752 | if ( clearallviews ) { | 2822 | if ( clearallviews ) { |
2753 | clearAllViews(); | 2823 | clearAllViews(); |
2754 | clearallviews = false; | 2824 | clearallviews = false; |
2755 | } | 2825 | } |
2756 | return; | 2826 | return; |
2757 | } | 2827 | } |
2758 | clearallviews = true; | 2828 | clearallviews = true; |
2759 | DateList tmpList = mNavigator->selectedDates(); | 2829 | DateList tmpList = mNavigator->selectedDates(); |
2760 | 2830 | ||
2761 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2831 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2762 | mTodoList->updateView(); | 2832 | mTodoList->updateView(); |
2763 | // We assume that the navigator only selects consecutive days. | 2833 | // We assume that the navigator only selects consecutive days. |
2764 | updateView( tmpList.first(), tmpList.last() ); | 2834 | updateView( tmpList.first(), tmpList.last() ); |
2765 | } | 2835 | } |
2766 | 2836 | ||
2767 | void CalendarView::updateUnmanagedViews() | 2837 | void CalendarView::updateUnmanagedViews() |
2768 | { | 2838 | { |
2769 | mDateNavigator->updateDayMatrix(); | 2839 | mDateNavigator->updateDayMatrix(); |
2770 | } | 2840 | } |
2771 | 2841 | ||
2772 | int CalendarView::msgItemDelete(const QString name) | 2842 | int CalendarView::msgItemDelete(const QString name) |
2773 | { | 2843 | { |
2774 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2844 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2775 | i18n("This item will be\npermanently deleted."), | 2845 | i18n("This item will be\npermanently deleted."), |
2776 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2846 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2777 | } | 2847 | } |
2778 | 2848 | ||
2779 | 2849 | ||
2780 | void CalendarView::edit_cut() | 2850 | void CalendarView::edit_cut() |
2781 | { | 2851 | { |
2782 | Event *anEvent=0; | 2852 | Event *anEvent=0; |
2783 | 2853 | ||
2784 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2854 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2785 | 2855 | ||
2786 | if (mViewManager->currentView()->isEventView()) { | 2856 | if (mViewManager->currentView()->isEventView()) { |
2787 | if ( incidence && incidence->typeID() == eventID ) { | 2857 | if ( incidence && incidence->typeID() == eventID ) { |
2788 | anEvent = static_cast<Event *>(incidence); | 2858 | anEvent = static_cast<Event *>(incidence); |
2789 | } | 2859 | } |
2790 | } | 2860 | } |
2791 | 2861 | ||
2792 | if (!anEvent) { | 2862 | if (!anEvent) { |
2793 | KNotifyClient::beep(); | 2863 | KNotifyClient::beep(); |
2794 | return; | 2864 | return; |
2795 | } | 2865 | } |
2796 | DndFactory factory( mCalendar ); | 2866 | DndFactory factory( mCalendar ); |
2797 | factory.cutIncidence(anEvent); | 2867 | factory.cutIncidence(anEvent); |
2798 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2868 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2799 | } | 2869 | } |
2800 | 2870 | ||
2801 | void CalendarView::edit_copy() | 2871 | void CalendarView::edit_copy() |
2802 | { | 2872 | { |
2803 | Event *anEvent=0; | 2873 | Event *anEvent=0; |
2804 | 2874 | ||
2805 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2875 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2806 | 2876 | ||
2807 | if (mViewManager->currentView()->isEventView()) { | 2877 | if (mViewManager->currentView()->isEventView()) { |
2808 | if ( incidence && incidence->typeID() == eventID ) { | 2878 | if ( incidence && incidence->typeID() == eventID ) { |
2809 | anEvent = static_cast<Event *>(incidence); | 2879 | anEvent = static_cast<Event *>(incidence); |
2810 | } | 2880 | } |
2811 | } | 2881 | } |
2812 | 2882 | ||
2813 | if (!anEvent) { | 2883 | if (!anEvent) { |
2814 | KNotifyClient::beep(); | 2884 | KNotifyClient::beep(); |
2815 | return; | 2885 | return; |
2816 | } | 2886 | } |
2817 | DndFactory factory( mCalendar ); | 2887 | DndFactory factory( mCalendar ); |
2818 | factory.copyIncidence(anEvent); | 2888 | factory.copyIncidence(anEvent); |
2819 | } | 2889 | } |
2820 | 2890 | ||
2821 | void CalendarView::edit_paste() | 2891 | void CalendarView::edit_paste() |
2822 | { | 2892 | { |
2823 | QDate date = mNavigator->selectedDates().first(); | 2893 | QDate date = mNavigator->selectedDates().first(); |
2824 | 2894 | ||
2825 | DndFactory factory( mCalendar ); | 2895 | DndFactory factory( mCalendar ); |
2826 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2896 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2827 | 2897 | ||
2828 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2898 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2829 | } | 2899 | } |
2830 | void CalendarView::edit_global_options() | 2900 | void CalendarView::edit_global_options() |
2831 | { | 2901 | { |
2832 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2902 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2833 | emit save(); | 2903 | emit save(); |
2834 | emit saveStopTimer(); | 2904 | emit saveStopTimer(); |
2835 | mDialogManager->showGlobalOptionsDialog(); | 2905 | mDialogManager->showGlobalOptionsDialog(); |
2836 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2906 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2837 | emit saveStopTimer(); | 2907 | emit saveStopTimer(); |
2838 | 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!"), | 2908 | 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!"), |
2839 | i18n("Timezone settings"),i18n("Reload"))) { | 2909 | i18n("Timezone settings"),i18n("Reload"))) { |
2840 | qDebug("KO: TZ reload cancelled "); | 2910 | qDebug("KO: TZ reload cancelled "); |
2841 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2911 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2842 | return; | 2912 | return; |
2843 | } | 2913 | } |
2844 | qDebug("KO: Timezone change "); | 2914 | qDebug("KO: Timezone change "); |
2845 | loadCalendars(); | 2915 | loadCalendars(); |
2846 | setModified(true); | 2916 | setModified(true); |
2847 | } | 2917 | } |
2848 | else | 2918 | else |
2849 | qDebug("KO: No tz change "); | 2919 | qDebug("KO: No tz change "); |
2850 | } | 2920 | } |
2851 | void CalendarView::edit_options() | 2921 | void CalendarView::edit_options() |
2852 | { | 2922 | { |
2853 | mDialogManager->showOptionsDialog(); | 2923 | mDialogManager->showOptionsDialog(); |
2854 | } | 2924 | } |
2855 | 2925 | ||
2856 | 2926 | ||
2857 | void CalendarView::slotSelectPickerDate( QDate d) | 2927 | void CalendarView::slotSelectPickerDate( QDate d) |
2858 | { | 2928 | { |
2859 | mDateFrame->hide(); | 2929 | mDateFrame->hide(); |
2860 | if ( mDatePickerMode == 1 ) { | 2930 | if ( mDatePickerMode == 1 ) { |
2861 | mNavigator->slotDaySelect( d ); | 2931 | mNavigator->slotDaySelect( d ); |
2862 | } else if ( mDatePickerMode == 2 ) { | 2932 | } else if ( mDatePickerMode == 2 ) { |
2863 | if ( mMoveIncidence->typeID() == todoID ) { | 2933 | if ( mMoveIncidence->typeID() == todoID ) { |
2864 | Todo * to = (Todo *) mMoveIncidence; | 2934 | Todo * to = (Todo *) mMoveIncidence; |
2865 | QTime tim; | 2935 | QTime tim; |
2866 | int len = 0; | 2936 | int len = 0; |
2867 | if ( to->hasStartDate() && to->hasDueDate() ) | 2937 | if ( to->hasStartDate() && to->hasDueDate() ) |
2868 | len = to->dtStart().secsTo( to->dtDue()); | 2938 | len = to->dtStart().secsTo( to->dtDue()); |
2869 | if ( to->hasDueDate() ) | 2939 | if ( to->hasDueDate() ) |
2870 | tim = to->dtDue().time(); | 2940 | tim = to->dtDue().time(); |
2871 | else { | 2941 | else { |
2872 | tim = QTime ( 0,0,0 ); | 2942 | tim = QTime ( 0,0,0 ); |
2873 | to->setFloats( true ); | 2943 | to->setFloats( true ); |
2874 | to->setHasDueDate( true ); | 2944 | to->setHasDueDate( true ); |
2875 | } | 2945 | } |
2876 | QDateTime dt ( d,tim ); | 2946 | QDateTime dt ( d,tim ); |
2877 | to->setDtDue( dt ); | 2947 | to->setDtDue( dt ); |
2878 | 2948 | ||
2879 | if ( to->hasStartDate() ) { | 2949 | if ( to->hasStartDate() ) { |
2880 | if ( len>0 ) | 2950 | if ( len>0 ) |
2881 | to->setDtStart(to->dtDue().addSecs( -len )); | 2951 | to->setDtStart(to->dtDue().addSecs( -len )); |
2882 | else | 2952 | else |
2883 | if (to->dtStart() > to->dtDue() ) | 2953 | if (to->dtStart() > to->dtDue() ) |
2884 | to->setDtStart(to->dtDue().addDays( -3 )); | 2954 | to->setDtStart(to->dtDue().addDays( -3 )); |
2885 | } | 2955 | } |
2886 | 2956 | ||
2887 | todoChanged( to ); | 2957 | todoChanged( to ); |
2888 | } else if ( mMoveIncidence->typeID() == eventID ) { | 2958 | } else if ( mMoveIncidence->typeID() == eventID ) { |
2889 | if ( mMoveIncidence->doesRecur() ) { | 2959 | if ( mMoveIncidence->doesRecur() ) { |
2890 | #if 0 | 2960 | #if 0 |
2891 | // PENDING implement this | 2961 | // PENDING implement this |
2892 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2962 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2893 | mCalendar()->addIncidence( newInc ); | 2963 | mCalendar()->addIncidence( newInc ); |
2894 | if ( mMoveIncidence->typeID() == todoID ) | 2964 | if ( mMoveIncidence->typeID() == todoID ) |
2895 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2965 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2896 | else | 2966 | else |
2897 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2967 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2898 | mMoveIncidence = newInc; | 2968 | mMoveIncidence = newInc; |
2899 | 2969 | ||
2900 | #endif | 2970 | #endif |
2901 | } | 2971 | } |
2902 | QTime tim = mMoveIncidence->dtStart().time(); | 2972 | QTime tim = mMoveIncidence->dtStart().time(); |
2903 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2973 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2904 | QDateTime dt ( d,tim ); | 2974 | QDateTime dt ( d,tim ); |
2905 | mMoveIncidence->setDtStart( dt ); | 2975 | mMoveIncidence->setDtStart( dt ); |
2906 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2976 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2907 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2977 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2908 | } else if ( mMoveIncidence->typeID() == journalID ) { | 2978 | } else if ( mMoveIncidence->typeID() == journalID ) { |
2909 | QTime tim = mMoveIncidence->dtStart().time(); | 2979 | QTime tim = mMoveIncidence->dtStart().time(); |
2910 | QDateTime dt ( d,tim ); | 2980 | QDateTime dt ( d,tim ); |
2911 | mMoveIncidence->setDtStart( dt ); | 2981 | mMoveIncidence->setDtStart( dt ); |
2912 | updateView(); | 2982 | updateView(); |
2913 | } | 2983 | } |
2914 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2984 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2915 | } | 2985 | } |
2916 | } | 2986 | } |
2917 | 2987 | ||
2918 | void CalendarView::removeCategories() | 2988 | void CalendarView::removeCategories() |
2919 | { | 2989 | { |
2920 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2990 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2921 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2991 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2922 | QStringList catIncList; | 2992 | QStringList catIncList; |
2923 | QStringList newCatList; | 2993 | QStringList newCatList; |
2924 | Incidence* inc = incList.first(); | 2994 | Incidence* inc = incList.first(); |
2925 | uint i; | 2995 | uint i; |
2926 | while ( inc ) { | 2996 | while ( inc ) { |
2927 | newCatList.clear(); | 2997 | newCatList.clear(); |
2928 | catIncList = inc->categories() ; | 2998 | catIncList = inc->categories() ; |
2929 | for( i = 0; i< catIncList.count(); ++i ) { | 2999 | for( i = 0; i< catIncList.count(); ++i ) { |
2930 | if ( catList.contains (catIncList[i])) | 3000 | if ( catList.contains (catIncList[i])) |
2931 | newCatList.append( catIncList[i] ); | 3001 | newCatList.append( catIncList[i] ); |
2932 | } | 3002 | } |
2933 | newCatList.sort(); | 3003 | newCatList.sort(); |
2934 | inc->setCategories( newCatList.join(",") ); | 3004 | inc->setCategories( newCatList.join(",") ); |
2935 | inc = incList.next(); | 3005 | inc = incList.next(); |
2936 | } | 3006 | } |
2937 | } | 3007 | } |
2938 | 3008 | ||
2939 | int CalendarView::addCategories() | 3009 | int CalendarView::addCategories() |
2940 | { | 3010 | { |
2941 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3011 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2942 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3012 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2943 | QStringList catIncList; | 3013 | QStringList catIncList; |
2944 | Incidence* inc = incList.first(); | 3014 | Incidence* inc = incList.first(); |
2945 | uint i; | 3015 | uint i; |
2946 | int count = 0; | 3016 | int count = 0; |
2947 | while ( inc ) { | 3017 | while ( inc ) { |
2948 | catIncList = inc->categories() ; | 3018 | catIncList = inc->categories() ; |
2949 | for( i = 0; i< catIncList.count(); ++i ) { | 3019 | for( i = 0; i< catIncList.count(); ++i ) { |
2950 | if ( !catList.contains (catIncList[i])) { | 3020 | if ( !catList.contains (catIncList[i])) { |
2951 | catList.append( catIncList[i] ); | 3021 | catList.append( catIncList[i] ); |
2952 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3022 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2953 | ++count; | 3023 | ++count; |
2954 | } | 3024 | } |
2955 | } | 3025 | } |
2956 | inc = incList.next(); | 3026 | inc = incList.next(); |
2957 | } | 3027 | } |
2958 | catList.sort(); | 3028 | catList.sort(); |
2959 | KOPrefs::instance()->mCustomCategories = catList; | 3029 | KOPrefs::instance()->mCustomCategories = catList; |
2960 | return count; | 3030 | return count; |
2961 | } | 3031 | } |
2962 | 3032 | ||
2963 | void CalendarView::editCategories() | 3033 | void CalendarView::editCategories() |
2964 | { | 3034 | { |
2965 | qDebug("CalendarView::editCategories() "); | 3035 | qDebug("CalendarView::editCategories() "); |
2966 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3036 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
2967 | ced.exec(); | 3037 | ced.exec(); |
2968 | } | 3038 | } |
2969 | void CalendarView::manageCategories() | 3039 | void CalendarView::manageCategories() |
2970 | { | 3040 | { |
2971 | KOCatPrefs* cp = new KOCatPrefs(); | 3041 | KOCatPrefs* cp = new KOCatPrefs(); |
2972 | cp->show(); | 3042 | cp->show(); |
2973 | int w =cp->sizeHint().width() ; | 3043 | int w =cp->sizeHint().width() ; |
2974 | int h = cp->sizeHint().height() ; | 3044 | int h = cp->sizeHint().height() ; |
2975 | int dw = QApplication::desktop()->width(); | 3045 | int dw = QApplication::desktop()->width(); |
2976 | int dh = QApplication::desktop()->height(); | 3046 | int dh = QApplication::desktop()->height(); |
2977 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3047 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2978 | if ( !cp->exec() ) { | 3048 | if ( !cp->exec() ) { |
2979 | delete cp; | 3049 | delete cp; |
2980 | return; | 3050 | return; |
2981 | } | 3051 | } |
2982 | int count = 0; | 3052 | int count = 0; |
2983 | if ( cp->addCat() ) { | 3053 | if ( cp->addCat() ) { |
2984 | count = addCategories(); | 3054 | count = addCategories(); |
2985 | if ( count ) { | 3055 | if ( count ) { |
2986 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3056 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2987 | writeSettings(); | 3057 | writeSettings(); |
2988 | } else | 3058 | } else |
2989 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3059 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2990 | } else { | 3060 | } else { |
2991 | removeCategories(); | 3061 | removeCategories(); |
2992 | updateView(); | 3062 | updateView(); |
2993 | } | 3063 | } |
2994 | delete cp; | 3064 | delete cp; |
2995 | } | 3065 | } |
2996 | 3066 | ||
2997 | void CalendarView::beamIncidence(Incidence * Inc) | 3067 | void CalendarView::beamIncidence(Incidence * Inc) |
2998 | { | 3068 | { |
2999 | QPtrList<Incidence> delSel ; | 3069 | QPtrList<Incidence> delSel ; |
3000 | delSel.append(Inc); | 3070 | delSel.append(Inc); |
3001 | beamIncidenceList( delSel ); | 3071 | beamIncidenceList( delSel ); |
3002 | } | 3072 | } |
3003 | void CalendarView::beamCalendar() | 3073 | void CalendarView::beamCalendar() |
3004 | { | 3074 | { |
3005 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3075 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3006 | //qDebug("beamCalendar() "); | 3076 | //qDebug("beamCalendar() "); |
3007 | beamIncidenceList( delSel ); | 3077 | beamIncidenceList( delSel ); |
3008 | } | 3078 | } |
3009 | void CalendarView::beamFilteredCalendar() | 3079 | void CalendarView::beamFilteredCalendar() |
3010 | { | 3080 | { |
3011 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3081 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3012 | //qDebug("beamFilteredCalendar() "); | 3082 | //qDebug("beamFilteredCalendar() "); |
3013 | beamIncidenceList( delSel ); | 3083 | beamIncidenceList( delSel ); |
3014 | } | 3084 | } |
3015 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3085 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3016 | { | 3086 | { |
3017 | 3087 | ||
3018 | KOBeamPrefs beamDialog; | 3088 | KOBeamPrefs beamDialog; |
3019 | if ( beamDialog.exec () == QDialog::Rejected ) | 3089 | if ( beamDialog.exec () == QDialog::Rejected ) |
3020 | return; | 3090 | return; |
3021 | #ifdef DESKTOP_VERSION | 3091 | #ifdef DESKTOP_VERSION |
3022 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3092 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3023 | #else | 3093 | #else |
3024 | QString fn = "/tmp/kopibeamfile"; | 3094 | QString fn = "/tmp/kopibeamfile"; |
3025 | #endif | 3095 | #endif |
3026 | QString mes; | 3096 | QString mes; |
3027 | bool createbup = true; | 3097 | bool createbup = true; |
3028 | if ( createbup ) { | 3098 | if ( createbup ) { |
3029 | QString description = "\n"; | 3099 | QString description = "\n"; |
3030 | CalendarLocal* cal = new CalendarLocal(); | 3100 | CalendarLocal* cal = new CalendarLocal(); |
3031 | if ( beamDialog.beamLocal() ) | 3101 | if ( beamDialog.beamLocal() ) |
3032 | cal->setLocalTime(); | 3102 | cal->setLocalTime(); |
3033 | else | 3103 | else |
3034 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3104 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3035 | Incidence *incidence = delSel.first(); | 3105 | Incidence *incidence = delSel.first(); |
3036 | bool addText = false; | 3106 | bool addText = false; |
3037 | if ( delSel.count() < 10 ) | 3107 | if ( delSel.count() < 10 ) |
3038 | addText = true; | 3108 | addText = true; |
3039 | else { | 3109 | else { |
3040 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3110 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3041 | } | 3111 | } |
3042 | while ( incidence ) { | 3112 | while ( incidence ) { |
3043 | Incidence *in = incidence->clone(); | 3113 | Incidence *in = incidence->clone(); |
3044 | if ( ! in->summary().isEmpty() ) { | 3114 | if ( ! in->summary().isEmpty() ) { |
3045 | in->setDescription(""); | 3115 | in->setDescription(""); |
3046 | } else { | 3116 | } else { |
3047 | in->setSummary( in->description().left(20)); | 3117 | in->setSummary( in->description().left(20)); |
3048 | in->setDescription(""); | 3118 | in->setDescription(""); |
3049 | } | 3119 | } |
3050 | if ( addText ) | 3120 | if ( addText ) |
3051 | description += in->summary() + "\n"; | 3121 | description += in->summary() + "\n"; |
3052 | cal->addIncidence( in ); | 3122 | cal->addIncidence( in ); |
3053 | incidence = delSel.next(); | 3123 | incidence = delSel.next(); |
3054 | } | 3124 | } |
3055 | if ( beamDialog.beamVcal() ) { | 3125 | if ( beamDialog.beamVcal() ) { |
3056 | fn += ".vcs"; | 3126 | fn += ".vcs"; |
3057 | FileStorage storage( cal, fn, new VCalFormat ); | 3127 | FileStorage storage( cal, fn, new VCalFormat ); |
3058 | storage.save(); | 3128 | storage.save(); |
3059 | } else { | 3129 | } else { |
3060 | fn += ".ics"; | 3130 | fn += ".ics"; |
3061 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3131 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3062 | storage.save(); | 3132 | storage.save(); |
3063 | } | 3133 | } |
3064 | delete cal; | 3134 | delete cal; |
3065 | mes = i18n("KO/Pi: Ready for beaming"); | 3135 | mes = i18n("KO/Pi: Ready for beaming"); |
3066 | topLevelWidget()->setCaption(mes); | 3136 | topLevelWidget()->setCaption(mes); |
3067 | KApplication::convert2latin1( fn ); | 3137 | KApplication::convert2latin1( fn ); |
3068 | #ifndef DESKTOP_VERSION | 3138 | #ifndef DESKTOP_VERSION |
3069 | Ir *ir = new Ir( this ); | 3139 | Ir *ir = new Ir( this ); |
3070 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3140 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3071 | ir->send( fn, description, "text/x-vCalendar" ); | 3141 | ir->send( fn, description, "text/x-vCalendar" ); |
3072 | #endif | 3142 | #endif |
3073 | } | 3143 | } |
3074 | } | 3144 | } |
3075 | 3145 | ||
3076 | #ifndef DESKTOP_VERSION | 3146 | #ifndef DESKTOP_VERSION |
3077 | void CalendarView::beamDone( Ir *ir ) | 3147 | void CalendarView::beamDone( Ir *ir ) |
3078 | { | 3148 | { |
3079 | delete ir; | 3149 | delete ir; |
3080 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3150 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3081 | topLevelWidget()->raise(); | 3151 | topLevelWidget()->raise(); |
3082 | } | 3152 | } |
3083 | #else | 3153 | #else |
3084 | void CalendarView::beamDone( Ir *){;} | 3154 | void CalendarView::beamDone( Ir *){;} |
3085 | #endif | 3155 | #endif |
3086 | void CalendarView::moveIncidence(Incidence * inc ) | 3156 | void CalendarView::moveIncidence(Incidence * inc ) |
3087 | { | 3157 | { |
3088 | if ( !inc ) return; | 3158 | if ( !inc ) return; |
3089 | showDatePickerPopup(); | 3159 | showDatePickerPopup(); |
3090 | mDatePickerMode = 2; | 3160 | mDatePickerMode = 2; |
3091 | mMoveIncidence = inc ; | 3161 | mMoveIncidence = inc ; |
3092 | QDate da; | 3162 | QDate da; |
3093 | if ( mMoveIncidence->typeID() == todoID ) { | 3163 | if ( mMoveIncidence->typeID() == todoID ) { |
3094 | Todo * to = (Todo *) mMoveIncidence; | 3164 | Todo * to = (Todo *) mMoveIncidence; |
3095 | if ( to->hasDueDate() ) | 3165 | if ( to->hasDueDate() ) |
3096 | da = to->dtDue().date(); | 3166 | da = to->dtDue().date(); |
3097 | else | 3167 | else |
3098 | da = QDate::currentDate(); | 3168 | da = QDate::currentDate(); |
3099 | } else { | 3169 | } else { |
3100 | da = mMoveIncidence->dtStart().date(); | 3170 | da = mMoveIncidence->dtStart().date(); |
3101 | } | 3171 | } |
3102 | //PENDING set date for recurring incidence to date of recurrence | 3172 | //PENDING set date for recurring incidence to date of recurrence |
3103 | //mMoveIncidenceOldDate; | 3173 | //mMoveIncidenceOldDate; |
3104 | mDatePicker->setDate( da ); | 3174 | mDatePicker->setDate( da ); |
3105 | } | 3175 | } |
3106 | void CalendarView::showDatePickerPopup() | 3176 | void CalendarView::showDatePickerPopup() |
3107 | { | 3177 | { |
3108 | if ( mDateFrame->isVisible() ) | 3178 | if ( mDateFrame->isVisible() ) |
3109 | mDateFrame->hide(); | 3179 | mDateFrame->hide(); |
3110 | else { | 3180 | else { |
3111 | int offX = 0, offY = 0; | 3181 | int offX = 0, offY = 0; |
3112 | #ifdef DESKTOP_VERSION | 3182 | #ifdef DESKTOP_VERSION |
3113 | int w =mDatePicker->sizeHint().width() ; | 3183 | int w =mDatePicker->sizeHint().width() ; |
3114 | int h = mDatePicker->sizeHint().height() ; | 3184 | int h = mDatePicker->sizeHint().height() ; |
3115 | int dw = topLevelWidget()->width(); | 3185 | int dw = topLevelWidget()->width(); |
3116 | int dh = topLevelWidget()->height(); | 3186 | int dh = topLevelWidget()->height(); |
3117 | offX = topLevelWidget()->x(); | 3187 | offX = topLevelWidget()->x(); |
3118 | offY = topLevelWidget()->y(); | 3188 | offY = topLevelWidget()->y(); |
3119 | #else | 3189 | #else |
3120 | int w =mDatePicker->sizeHint().width() ; | 3190 | int w =mDatePicker->sizeHint().width() ; |
3121 | int h = mDatePicker->sizeHint().height() ; | 3191 | int h = mDatePicker->sizeHint().height() ; |
3122 | int dw = QApplication::desktop()->width(); | 3192 | int dw = QApplication::desktop()->width(); |
3123 | int dh = QApplication::desktop()->height(); | 3193 | int dh = QApplication::desktop()->height(); |
3124 | #endif | 3194 | #endif |
3125 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3195 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3126 | mDateFrame->show(); | 3196 | mDateFrame->show(); |
3127 | } | 3197 | } |
3128 | } | 3198 | } |
3129 | void CalendarView::showDatePicker( ) | 3199 | void CalendarView::showDatePicker( ) |
3130 | { | 3200 | { |
3131 | showDatePickerPopup(); | 3201 | showDatePickerPopup(); |
3132 | mDatePickerMode = 1; | 3202 | mDatePickerMode = 1; |
3133 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3203 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3134 | } | 3204 | } |
3135 | 3205 | ||
3136 | void CalendarView::showEventEditor() | 3206 | void CalendarView::showEventEditor() |
3137 | { | 3207 | { |
3138 | #ifdef DESKTOP_VERSION | 3208 | #ifdef DESKTOP_VERSION |
3139 | int x,y,w,h; | 3209 | int x,y,w,h; |
3140 | x = mEventEditor->geometry().x(); | 3210 | x = mEventEditor->geometry().x(); |
3141 | y = mEventEditor->geometry().y(); | 3211 | y = mEventEditor->geometry().y(); |
3142 | w = mEventEditor->width(); | 3212 | w = mEventEditor->width(); |
3143 | h = mEventEditor->height(); | 3213 | h = mEventEditor->height(); |
3144 | mEventEditor->show(); | 3214 | mEventEditor->show(); |
3145 | mEventEditor->setGeometry(x,y,w,h); | 3215 | mEventEditor->setGeometry(x,y,w,h); |
3146 | #else | 3216 | #else |
3147 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3217 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3148 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3218 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3149 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3219 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3150 | qApp->processEvents(); | 3220 | qApp->processEvents(); |
3151 | delete mEventEditor; | 3221 | delete mEventEditor; |
3152 | mEventEditor = mDialogManager->getEventEditor(); | 3222 | mEventEditor = mDialogManager->getEventEditor(); |
3153 | topLevelWidget()->setCaption( i18n("") ); | 3223 | topLevelWidget()->setCaption( i18n("") ); |
3154 | } | 3224 | } |
3155 | mEventEditor->showMaximized(); | 3225 | mEventEditor->showMaximized(); |
3156 | #endif | 3226 | #endif |
3157 | } | 3227 | } |
3158 | void CalendarView::showTodoEditor() | 3228 | void CalendarView::showTodoEditor() |
3159 | { | 3229 | { |
3160 | #ifdef DESKTOP_VERSION | 3230 | #ifdef DESKTOP_VERSION |
3161 | int x,y,w,h; | 3231 | int x,y,w,h; |
3162 | x = mTodoEditor->geometry().x(); | 3232 | x = mTodoEditor->geometry().x(); |
3163 | y = mTodoEditor->geometry().y(); | 3233 | y = mTodoEditor->geometry().y(); |
3164 | w = mTodoEditor->width(); | 3234 | w = mTodoEditor->width(); |
3165 | h = mTodoEditor->height(); | 3235 | h = mTodoEditor->height(); |
3166 | mTodoEditor->show(); | 3236 | mTodoEditor->show(); |
3167 | mTodoEditor->setGeometry(x,y,w,h); | 3237 | mTodoEditor->setGeometry(x,y,w,h); |
3168 | #else | 3238 | #else |
3169 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3239 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3170 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3240 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3171 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3241 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3172 | qApp->processEvents(); | 3242 | qApp->processEvents(); |
3173 | delete mTodoEditor; | 3243 | delete mTodoEditor; |
3174 | mTodoEditor = mDialogManager->getTodoEditor(); | 3244 | mTodoEditor = mDialogManager->getTodoEditor(); |
3175 | topLevelWidget()->setCaption( i18n("") ); | 3245 | topLevelWidget()->setCaption( i18n("") ); |
3176 | } | 3246 | } |
3177 | mTodoEditor->showMaximized(); | 3247 | mTodoEditor->showMaximized(); |
3178 | #endif | 3248 | #endif |
3179 | } | 3249 | } |
3180 | 3250 | ||
3181 | void CalendarView::cloneIncidence() | 3251 | void CalendarView::cloneIncidence() |
3182 | { | 3252 | { |
3183 | Incidence *incidence = currentSelection(); | 3253 | Incidence *incidence = currentSelection(); |
3184 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3254 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3185 | if ( incidence ) { | 3255 | if ( incidence ) { |
3186 | cloneIncidence(incidence); | 3256 | cloneIncidence(incidence); |
3187 | } | 3257 | } |
3188 | } | 3258 | } |
3189 | void CalendarView::moveIncidence() | 3259 | void CalendarView::moveIncidence() |
3190 | { | 3260 | { |
3191 | Incidence *incidence = currentSelection(); | 3261 | Incidence *incidence = currentSelection(); |
3192 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3262 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3193 | if ( incidence ) { | 3263 | if ( incidence ) { |
3194 | moveIncidence(incidence); | 3264 | moveIncidence(incidence); |
3195 | } | 3265 | } |
3196 | } | 3266 | } |
3197 | void CalendarView::beamIncidence() | 3267 | void CalendarView::beamIncidence() |
3198 | { | 3268 | { |
3199 | Incidence *incidence = currentSelection(); | 3269 | Incidence *incidence = currentSelection(); |
3200 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3270 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3201 | if ( incidence ) { | 3271 | if ( incidence ) { |
3202 | beamIncidence(incidence); | 3272 | beamIncidence(incidence); |
3203 | } | 3273 | } |
3204 | } | 3274 | } |
3205 | void CalendarView::toggleCancelIncidence() | 3275 | void CalendarView::toggleCancelIncidence() |
3206 | { | 3276 | { |
3207 | Incidence *incidence = currentSelection(); | 3277 | Incidence *incidence = currentSelection(); |
3208 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3278 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3209 | if ( incidence ) { | 3279 | if ( incidence ) { |
3210 | cancelIncidence(incidence); | 3280 | cancelIncidence(incidence); |
3211 | } | 3281 | } |
3212 | } | 3282 | } |
3213 | 3283 | ||
3214 | 3284 | ||
3215 | void CalendarView::cancelIncidence(Incidence * inc ) | 3285 | void CalendarView::cancelIncidence(Incidence * inc ) |
3216 | { | 3286 | { |
3217 | inc->setCancelled( ! inc->cancelled() ); | 3287 | inc->setCancelled( ! inc->cancelled() ); |
3218 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3288 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3219 | updateView(); | 3289 | updateView(); |
3220 | } | 3290 | } |
3221 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3291 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3222 | { | 3292 | { |
3223 | Incidence * newInc = orgInc->clone(); | 3293 | Incidence * newInc = orgInc->clone(); |
3224 | newInc->recreate(); | 3294 | newInc->recreate(); |
3225 | 3295 | ||
3226 | if ( newInc->typeID() == todoID ) { | 3296 | if ( newInc->typeID() == todoID ) { |
3227 | Todo* t = (Todo*) newInc; | 3297 | Todo* t = (Todo*) newInc; |
3228 | bool cloneSub = false; | 3298 | bool cloneSub = false; |
3229 | if ( orgInc->relations().count() ) { | 3299 | if ( orgInc->relations().count() ) { |
3230 | int result = KMessageBox::warningYesNoCancel(this, | 3300 | int result = KMessageBox::warningYesNoCancel(this, |
3231 | 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 ) ), | 3301 | 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 ) ), |
3232 | i18n("Todo has subtodos"), | 3302 | i18n("Todo has subtodos"), |
3233 | i18n("Yes"), | 3303 | i18n("Yes"), |
3234 | i18n("No")); | 3304 | i18n("No")); |
3235 | 3305 | ||
3236 | if ( result == KMessageBox::Cancel ) { | 3306 | if ( result == KMessageBox::Cancel ) { |
3237 | delete t; | 3307 | delete t; |
3238 | return; | 3308 | return; |
3239 | } | 3309 | } |
3240 | if (result == KMessageBox::Yes) cloneSub = true; | 3310 | if (result == KMessageBox::Yes) cloneSub = true; |
3241 | } | 3311 | } |
3242 | showTodoEditor(); | 3312 | showTodoEditor(); |
3243 | mTodoEditor->editTodo( t ); | 3313 | mTodoEditor->editTodo( t ); |
3244 | if ( mTodoEditor->exec() ) { | 3314 | if ( mTodoEditor->exec() ) { |
3245 | if ( cloneSub ) { | 3315 | if ( cloneSub ) { |
3246 | orgInc->cloneRelations( t ); | 3316 | orgInc->cloneRelations( t ); |
3247 | mCalendar->addIncidenceBranch( t ); | 3317 | mCalendar->addIncidenceBranch( t ); |
3248 | updateView(); | 3318 | updateView(); |
3249 | 3319 | ||
3250 | } else { | 3320 | } else { |
3251 | mCalendar->addTodo( t ); | 3321 | mCalendar->addTodo( t ); |
3252 | updateView(); | 3322 | updateView(); |
3253 | } | 3323 | } |
3254 | } else { | 3324 | } else { |
3255 | delete t; | 3325 | delete t; |
3256 | } | 3326 | } |
3257 | } | 3327 | } |
3258 | else if ( newInc->typeID() == eventID ) { | 3328 | else if ( newInc->typeID() == eventID ) { |
3259 | Event* e = (Event*) newInc; | 3329 | Event* e = (Event*) newInc; |
3260 | showEventEditor(); | 3330 | showEventEditor(); |
3261 | mEventEditor->editEvent( e ); | 3331 | mEventEditor->editEvent( e ); |
3262 | if ( mEventEditor->exec() ) { | 3332 | if ( mEventEditor->exec() ) { |
3263 | mCalendar->addEvent( e ); | 3333 | mCalendar->addEvent( e ); |
3264 | updateView(); | 3334 | updateView(); |
3265 | } else { | 3335 | } else { |
3266 | delete e; | 3336 | delete e; |
3267 | } | 3337 | } |
3268 | } if ( newInc->typeID() == journalID ) { | 3338 | } if ( newInc->typeID() == journalID ) { |
3269 | mCalendar->addJournal( (Journal*) newInc ); | 3339 | mCalendar->addJournal( (Journal*) newInc ); |
3270 | editJournal( (Journal*) newInc ); | 3340 | editJournal( (Journal*) newInc ); |
3271 | } | 3341 | } |
3272 | setActiveWindow(); | 3342 | setActiveWindow(); |
3273 | } | 3343 | } |
3274 | 3344 | ||
3275 | void CalendarView::newEvent() | 3345 | void CalendarView::newEvent() |
3276 | { | 3346 | { |
3277 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3347 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3278 | KOAgendaView *aView = mViewManager->agendaView(); | 3348 | KOAgendaView *aView = mViewManager->agendaView(); |
3279 | if (aView) { | 3349 | if (aView) { |
3280 | if (aView->selectionStart().isValid()) { | 3350 | if (aView->selectionStart().isValid()) { |
3281 | if (aView->selectedIsAllDay()) { | 3351 | if (aView->selectedIsAllDay()) { |
3282 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3352 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3283 | } else { | 3353 | } else { |
3284 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3354 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3285 | } | 3355 | } |
3286 | return; | 3356 | return; |
3287 | } | 3357 | } |
3288 | } | 3358 | } |
3289 | 3359 | ||
3290 | QDate date = mNavigator->selectedDates().first(); | 3360 | QDate date = mNavigator->selectedDates().first(); |
3291 | QDateTime current = QDateTime::currentDateTime(); | 3361 | QDateTime current = QDateTime::currentDateTime(); |
3292 | if ( date <= current.date() ) { | 3362 | if ( date <= current.date() ) { |
3293 | int hour = current.time().hour() +1; | 3363 | int hour = current.time().hour() +1; |
3294 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3364 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3295 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3365 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3296 | } else | 3366 | } else |
3297 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3367 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3298 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3368 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3299 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3369 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3300 | } | 3370 | } |
3301 | 3371 | ||
3302 | void CalendarView::newEvent(QDateTime fh) | 3372 | void CalendarView::newEvent(QDateTime fh) |
3303 | { | 3373 | { |
3304 | newEvent(fh, | 3374 | newEvent(fh, |
3305 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3375 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3306 | } | 3376 | } |
3307 | 3377 | ||
3308 | void CalendarView::newEvent(QDate dt) | 3378 | void CalendarView::newEvent(QDate dt) |
3309 | { | 3379 | { |
3310 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3380 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3311 | QDateTime(dt, QTime(0,0,0)), true); | 3381 | QDateTime(dt, QTime(0,0,0)), true); |
3312 | } | 3382 | } |
3313 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3383 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3314 | { | 3384 | { |
3315 | newEvent(fromHint, toHint, false); | 3385 | newEvent(fromHint, toHint, false); |
3316 | } | 3386 | } |
3317 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3387 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3318 | { | 3388 | { |
3319 | 3389 | ||
3320 | showEventEditor(); | 3390 | showEventEditor(); |
3321 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3391 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3322 | if ( mFilterView->filtersEnabled() ) { | 3392 | if ( mFilterView->filtersEnabled() ) { |
3323 | CalFilter *filter = mFilterView->selectedFilter(); | 3393 | CalFilter *filter = mFilterView->selectedFilter(); |
3324 | if (filter && filter->showCategories()) { | 3394 | if (filter && filter->showCategories()) { |
3325 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3395 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3326 | } | 3396 | } |
3327 | if ( filter ) | 3397 | if ( filter ) |
3328 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3398 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3329 | } | 3399 | } |
3330 | mEventEditor->exec(); | 3400 | mEventEditor->exec(); |
3331 | setActiveWindow(); | 3401 | setActiveWindow(); |
3332 | } | 3402 | } |
3333 | void CalendarView::todoAdded(Todo * t) | 3403 | void CalendarView::todoAdded(Todo * t) |
3334 | { | 3404 | { |
3335 | 3405 | ||
3336 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3406 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3337 | updateTodoViews(); | 3407 | updateTodoViews(); |
3338 | } | 3408 | } |
3339 | void CalendarView::todoChanged(Todo * t) | 3409 | void CalendarView::todoChanged(Todo * t) |
3340 | { | 3410 | { |
3341 | emit todoModified( t, 4 ); | 3411 | emit todoModified( t, 4 ); |
3342 | // updateTodoViews(); | 3412 | // updateTodoViews(); |
3343 | } | 3413 | } |
3344 | void CalendarView::todoToBeDeleted(Todo *) | 3414 | void CalendarView::todoToBeDeleted(Todo *) |
3345 | { | 3415 | { |
3346 | //qDebug("todoToBeDeleted(Todo *) "); | 3416 | //qDebug("todoToBeDeleted(Todo *) "); |
3347 | updateTodoViews(); | 3417 | updateTodoViews(); |
3348 | } | 3418 | } |
3349 | void CalendarView::todoDeleted() | 3419 | void CalendarView::todoDeleted() |
3350 | { | 3420 | { |
3351 | //qDebug(" todoDeleted()"); | 3421 | //qDebug(" todoDeleted()"); |
3352 | updateTodoViews(); | 3422 | updateTodoViews(); |
3353 | } | 3423 | } |
3354 | 3424 | ||
3355 | 3425 | ||
3356 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3426 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3357 | { | 3427 | { |
3358 | showTodoEditor(); | 3428 | showTodoEditor(); |
3359 | mTodoEditor->newTodo(dt,0,allday); | 3429 | mTodoEditor->newTodo(dt,0,allday); |
3360 | if ( mFilterView->filtersEnabled() ) { | 3430 | if ( mFilterView->filtersEnabled() ) { |
3361 | CalFilter *filter = mFilterView->selectedFilter(); | 3431 | CalFilter *filter = mFilterView->selectedFilter(); |
3362 | if (filter && filter->showCategories()) { | 3432 | if (filter && filter->showCategories()) { |
3363 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3433 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3364 | } | 3434 | } |
3365 | if ( filter ) | 3435 | if ( filter ) |
3366 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3436 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3367 | } | 3437 | } |
3368 | mTodoEditor->exec(); | 3438 | mTodoEditor->exec(); |
3369 | setActiveWindow(); | 3439 | setActiveWindow(); |
3370 | } | 3440 | } |
3371 | 3441 | ||
3372 | void CalendarView::newTodo() | 3442 | void CalendarView::newTodo() |
3373 | { | 3443 | { |
3374 | newTodoDateTime( QDateTime(),true ); | 3444 | newTodoDateTime( QDateTime(),true ); |
3375 | } | 3445 | } |
3376 | 3446 | ||
3377 | void CalendarView::newSubTodo() | 3447 | void CalendarView::newSubTodo() |
3378 | { | 3448 | { |
3379 | Todo *todo = selectedTodo(); | 3449 | Todo *todo = selectedTodo(); |
3380 | if ( todo ) newSubTodo( todo ); | 3450 | if ( todo ) newSubTodo( todo ); |
3381 | } | 3451 | } |
3382 | 3452 | ||
3383 | void CalendarView::newSubTodo(Todo *parentEvent) | 3453 | void CalendarView::newSubTodo(Todo *parentEvent) |
3384 | { | 3454 | { |
3385 | 3455 | ||
3386 | showTodoEditor(); | 3456 | showTodoEditor(); |
3387 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3457 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3388 | mTodoEditor->exec(); | 3458 | mTodoEditor->exec(); |
3389 | setActiveWindow(); | 3459 | setActiveWindow(); |
3390 | } | 3460 | } |
3391 | 3461 | ||
3392 | void CalendarView::newFloatingEvent() | 3462 | void CalendarView::newFloatingEvent() |
3393 | { | 3463 | { |
3394 | DateList tmpList = mNavigator->selectedDates(); | 3464 | DateList tmpList = mNavigator->selectedDates(); |
3395 | QDate date = tmpList.first(); | 3465 | QDate date = tmpList.first(); |
3396 | 3466 | ||
3397 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3467 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3398 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3468 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3399 | } | 3469 | } |
3400 | 3470 | ||
3401 | 3471 | ||
3402 | void CalendarView::editEvent( Event *event ) | 3472 | void CalendarView::editEvent( Event *event ) |
3403 | { | 3473 | { |
3404 | 3474 | ||
3405 | if ( !event ) return; | 3475 | if ( !event ) return; |
3406 | if ( event->isReadOnly() ) { | 3476 | if ( event->isReadOnly() ) { |
3407 | showEvent( event ); | 3477 | showEvent( event ); |
3408 | return; | 3478 | return; |
3409 | } | 3479 | } |
3410 | showEventEditor(); | 3480 | showEventEditor(); |
3411 | mEventEditor->editEvent( event , mFlagEditDescription); | 3481 | mEventEditor->editEvent( event , mFlagEditDescription); |
3412 | mEventEditor->exec(); | 3482 | mEventEditor->exec(); |
3413 | setActiveWindow(); | 3483 | setActiveWindow(); |
3414 | 3484 | ||
3415 | } | 3485 | } |
3416 | void CalendarView::editJournal( Journal *jour ) | 3486 | void CalendarView::editJournal( Journal *jour ) |
3417 | { | 3487 | { |
3418 | if ( !jour ) return; | 3488 | if ( !jour ) return; |
3419 | mDialogManager->hideSearchDialog(); | 3489 | mDialogManager->hideSearchDialog(); |
3420 | mViewManager->showJournalView(); | 3490 | mViewManager->showJournalView(); |
3421 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3491 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3422 | } | 3492 | } |
3423 | void CalendarView::editTodo( Todo *todo ) | 3493 | void CalendarView::editTodo( Todo *todo ) |
3424 | { | 3494 | { |
3425 | if ( !todo ) return; | 3495 | if ( !todo ) return; |
3426 | 3496 | ||
3427 | if ( todo->isReadOnly() ) { | 3497 | if ( todo->isReadOnly() ) { |
3428 | showTodo( todo ); | 3498 | showTodo( todo ); |
3429 | return; | 3499 | return; |
3430 | } | 3500 | } |
3431 | showTodoEditor(); | 3501 | showTodoEditor(); |
3432 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3502 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3433 | mTodoEditor->exec(); | 3503 | mTodoEditor->exec(); |
3434 | setActiveWindow(); | 3504 | setActiveWindow(); |
3435 | 3505 | ||
3436 | } | 3506 | } |
3437 | 3507 | ||
3438 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3508 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3439 | { | 3509 | { |
3440 | if ( !mEventViewerDialog ) { | 3510 | if ( !mEventViewerDialog ) { |
3441 | mEventViewerDialog = new KOEventViewerDialog(0); | 3511 | mEventViewerDialog = new KOEventViewerDialog(0); |
3442 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3512 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3443 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3513 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3444 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3514 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3445 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3515 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3446 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3516 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3447 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3517 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3448 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3518 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3449 | this, SLOT( slotViewerClosed() ) ); | 3519 | this, SLOT( slotViewerClosed() ) ); |
3450 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3520 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3451 | this, SLOT( todoChanged(Todo *) ) ); | 3521 | this, SLOT( todoChanged(Todo *) ) ); |
3452 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3522 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3453 | mEventViewerDialog->resize( 640, 480 ); | 3523 | mEventViewerDialog->resize( 640, 480 ); |
3454 | 3524 | ||
3455 | } | 3525 | } |
3456 | return mEventViewerDialog; | 3526 | return mEventViewerDialog; |
3457 | } | 3527 | } |
3458 | void CalendarView::showEvent(Event *event) | 3528 | void CalendarView::showEvent(Event *event) |
3459 | { | 3529 | { |
3460 | getEventViewerDialog()->setEvent(event); | 3530 | getEventViewerDialog()->setEvent(event); |
3461 | getEventViewerDialog()->showMe(); | 3531 | getEventViewerDialog()->showMe(); |
3462 | } | 3532 | } |
3463 | 3533 | ||
3464 | void CalendarView::showTodo(Todo *event) | 3534 | void CalendarView::showTodo(Todo *event) |
3465 | { | 3535 | { |
3466 | getEventViewerDialog()->setTodo(event); | 3536 | getEventViewerDialog()->setTodo(event); |
3467 | getEventViewerDialog()->showMe(); | 3537 | getEventViewerDialog()->showMe(); |
3468 | } | 3538 | } |
3469 | void CalendarView::showJournal( Journal *jour ) | 3539 | void CalendarView::showJournal( Journal *jour ) |
3470 | { | 3540 | { |
3471 | getEventViewerDialog()->setJournal(jour); | 3541 | getEventViewerDialog()->setJournal(jour); |
3472 | getEventViewerDialog()->showMe(); | 3542 | getEventViewerDialog()->showMe(); |
3473 | 3543 | ||
3474 | } | 3544 | } |
3475 | // void CalendarView::todoModified (Todo *event, int changed) | 3545 | // void CalendarView::todoModified (Todo *event, int changed) |
3476 | // { | 3546 | // { |
3477 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3547 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3478 | // // kdDebug() << "Todo modified and open" << endl; | 3548 | // // kdDebug() << "Todo modified and open" << endl; |
3479 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3549 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3480 | // // temp->modified (changed); | 3550 | // // temp->modified (changed); |
3481 | 3551 | ||
3482 | // // } | 3552 | // // } |
3483 | 3553 | ||
3484 | // mViewManager->updateView(); | 3554 | // mViewManager->updateView(); |
3485 | // } | 3555 | // } |
3486 | 3556 | ||
3487 | void CalendarView::appointment_show() | 3557 | void CalendarView::appointment_show() |
3488 | { | 3558 | { |
3489 | Event *anEvent = 0; | 3559 | Event *anEvent = 0; |
3490 | 3560 | ||
3491 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3561 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3492 | 3562 | ||
3493 | if (mViewManager->currentView()->isEventView()) { | 3563 | if (mViewManager->currentView()->isEventView()) { |
3494 | if ( incidence && incidence->typeID() == eventID ) { | 3564 | if ( incidence && incidence->typeID() == eventID ) { |
3495 | anEvent = static_cast<Event *>(incidence); | 3565 | anEvent = static_cast<Event *>(incidence); |
3496 | } | 3566 | } |
3497 | } | 3567 | } |
3498 | 3568 | ||
3499 | if (!anEvent) { | 3569 | if (!anEvent) { |
3500 | KNotifyClient::beep(); | 3570 | KNotifyClient::beep(); |
3501 | return; | 3571 | return; |
3502 | } | 3572 | } |
3503 | 3573 | ||
3504 | showEvent(anEvent); | 3574 | showEvent(anEvent); |
3505 | } | 3575 | } |
3506 | 3576 | ||
3507 | void CalendarView::appointment_edit() | 3577 | void CalendarView::appointment_edit() |
3508 | { | 3578 | { |
3509 | Event *anEvent = 0; | 3579 | Event *anEvent = 0; |
3510 | 3580 | ||
3511 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3581 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3512 | 3582 | ||
3513 | if (mViewManager->currentView()->isEventView()) { | 3583 | if (mViewManager->currentView()->isEventView()) { |
3514 | if ( incidence && incidence->typeID() == eventID ) { | 3584 | if ( incidence && incidence->typeID() == eventID ) { |
3515 | anEvent = static_cast<Event *>(incidence); | 3585 | anEvent = static_cast<Event *>(incidence); |
3516 | } | 3586 | } |
3517 | } | 3587 | } |
3518 | 3588 | ||
3519 | if (!anEvent) { | 3589 | if (!anEvent) { |
3520 | KNotifyClient::beep(); | 3590 | KNotifyClient::beep(); |
3521 | return; | 3591 | return; |
3522 | } | 3592 | } |
3523 | 3593 | ||
3524 | editEvent(anEvent); | 3594 | editEvent(anEvent); |
3525 | } | 3595 | } |
3526 | 3596 | ||
3527 | void CalendarView::appointment_delete() | 3597 | void CalendarView::appointment_delete() |
3528 | { | 3598 | { |
3529 | Event *anEvent = 0; | 3599 | Event *anEvent = 0; |
3530 | 3600 | ||
3531 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3601 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3532 | 3602 | ||
3533 | if (mViewManager->currentView()->isEventView()) { | 3603 | if (mViewManager->currentView()->isEventView()) { |
3534 | if ( incidence && incidence->typeID() == eventID ) { | 3604 | if ( incidence && incidence->typeID() == eventID ) { |
3535 | anEvent = static_cast<Event *>(incidence); | 3605 | anEvent = static_cast<Event *>(incidence); |
3536 | } | 3606 | } |
3537 | } | 3607 | } |
3538 | 3608 | ||
3539 | if (!anEvent) { | 3609 | if (!anEvent) { |
3540 | KNotifyClient::beep(); | 3610 | KNotifyClient::beep(); |
3541 | return; | 3611 | return; |
3542 | } | 3612 | } |
3543 | 3613 | ||
3544 | deleteEvent(anEvent); | 3614 | deleteEvent(anEvent); |
3545 | } | 3615 | } |
3546 | 3616 | ||
3547 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3617 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3548 | { | 3618 | { |
3549 | if (!sub) return; | 3619 | if (!sub) return; |
3550 | if ( sub->relatedTo() == parent ) | 3620 | if ( sub->relatedTo() == parent ) |
3551 | return; | 3621 | return; |
3552 | sub->setRelatedTo(parent); | 3622 | sub->setRelatedTo(parent); |
3553 | sub->updated(); | 3623 | sub->updated(); |
3554 | setModified(true); | 3624 | setModified(true); |
3555 | updateView(); | 3625 | updateView(); |
3556 | } | 3626 | } |
3557 | void CalendarView::todo_unsub(Todo *anTodo ) | 3627 | void CalendarView::todo_unsub(Todo *anTodo ) |
3558 | { | 3628 | { |
3559 | todo_resub( 0, anTodo ); | 3629 | todo_resub( 0, anTodo ); |
3560 | } | 3630 | } |
3561 | 3631 | ||
3562 | void CalendarView::deleteTodo(Todo *todo) | 3632 | void CalendarView::deleteTodo(Todo *todo) |
3563 | { | 3633 | { |
3564 | if (!todo) { | 3634 | if (!todo) { |
3565 | KNotifyClient::beep(); | 3635 | KNotifyClient::beep(); |
3566 | return; | 3636 | return; |
3567 | } | 3637 | } |
3568 | if (KOPrefs::instance()->mConfirm) { | 3638 | if (KOPrefs::instance()->mConfirm) { |
3569 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3639 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3570 | if (!todo->relations().isEmpty()) { | 3640 | if (!todo->relations().isEmpty()) { |
3571 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3641 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3572 | 3642 | ||
3573 | } | 3643 | } |
3574 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3644 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3575 | case KMessageBox::Continue: // OK | 3645 | case KMessageBox::Continue: // OK |
3576 | bool deleteT = false; | 3646 | bool deleteT = false; |
3577 | if (!todo->relations().isEmpty()) { | 3647 | if (!todo->relations().isEmpty()) { |
3578 | deleteT = removeCompletedSubTodos( todo ); | 3648 | deleteT = removeCompletedSubTodos( todo ); |
3579 | } | 3649 | } |
3580 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3650 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3581 | if ( !deleteT ) { | 3651 | if ( !deleteT ) { |
3582 | checkExternalId( todo ); | 3652 | checkExternalId( todo ); |
3583 | calendar()->deleteTodo(todo); | 3653 | calendar()->deleteTodo(todo); |
3584 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3654 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3585 | updateView(); | 3655 | updateView(); |
3586 | } | 3656 | } |
3587 | break; | 3657 | break; |
3588 | } // switch | 3658 | } // switch |
3589 | } else { | 3659 | } else { |
3590 | checkExternalId( todo ); | 3660 | checkExternalId( todo ); |
3591 | mCalendar->deleteTodo(todo); | 3661 | mCalendar->deleteTodo(todo); |
3592 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3662 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3593 | updateView(); | 3663 | updateView(); |
3594 | } | 3664 | } |
3595 | 3665 | ||
3596 | emit updateSearchDialog(); | 3666 | emit updateSearchDialog(); |
3597 | } | 3667 | } |
3598 | void CalendarView::deleteJournal(Journal *jour) | 3668 | void CalendarView::deleteJournal(Journal *jour) |
3599 | { | 3669 | { |
3600 | if (!jour) { | 3670 | if (!jour) { |
3601 | KNotifyClient::beep(); | 3671 | KNotifyClient::beep(); |
3602 | return; | 3672 | return; |
3603 | } | 3673 | } |
3604 | if (KOPrefs::instance()->mConfirm) { | 3674 | if (KOPrefs::instance()->mConfirm) { |
3605 | 3675 | ||
3606 | QString des; | 3676 | QString des; |
3607 | if ( !jour->summary().isEmpty() ) { | 3677 | if ( !jour->summary().isEmpty() ) { |
3608 | des = jour->summary(); | 3678 | des = jour->summary(); |
3609 | } else { | 3679 | } else { |
3610 | des = jour->description().left(30); | 3680 | des = jour->description().left(30); |
3611 | des = des.simplifyWhiteSpace (); | 3681 | des = des.simplifyWhiteSpace (); |
3612 | des.replace (QRegExp ("\\n"),"" ); | 3682 | des.replace (QRegExp ("\\n"),"" ); |
3613 | des.replace (QRegExp ("\\r"),"" ); | 3683 | des.replace (QRegExp ("\\r"),"" ); |
3614 | } | 3684 | } |
3615 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 3685 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3616 | case KMessageBox::Continue: // OK | 3686 | case KMessageBox::Continue: // OK |
3617 | calendar()->deleteJournal(jour); | 3687 | calendar()->deleteJournal(jour); |
3618 | updateView(); | 3688 | updateView(); |
3619 | break; | 3689 | break; |
3620 | } // switch | 3690 | } // switch |
3621 | } else { | 3691 | } else { |
3622 | calendar()->deleteJournal(jour);; | 3692 | calendar()->deleteJournal(jour);; |
3623 | updateView(); | 3693 | updateView(); |
3624 | } | 3694 | } |
3625 | emit updateSearchDialog(); | 3695 | emit updateSearchDialog(); |
3626 | } | 3696 | } |
3627 | 3697 | ||
3628 | void CalendarView::deleteEvent(Event *anEvent) | 3698 | void CalendarView::deleteEvent(Event *anEvent) |
3629 | { | 3699 | { |
3630 | if (!anEvent) { | 3700 | if (!anEvent) { |
3631 | KNotifyClient::beep(); | 3701 | KNotifyClient::beep(); |
3632 | return; | 3702 | return; |
3633 | } | 3703 | } |
3634 | 3704 | ||
3635 | if (anEvent->recurrence()->doesRecur()) { | 3705 | if (anEvent->recurrence()->doesRecur()) { |
3636 | QDate itemDate = mViewManager->currentSelectionDate(); | 3706 | QDate itemDate = mViewManager->currentSelectionDate(); |
3637 | int km; | 3707 | int km; |
3638 | if (!itemDate.isValid()) { | 3708 | if (!itemDate.isValid()) { |
3639 | //kdDebug() << "Date Not Valid" << endl; | 3709 | //kdDebug() << "Date Not Valid" << endl; |
3640 | if (KOPrefs::instance()->mConfirm) { | 3710 | if (KOPrefs::instance()->mConfirm) { |
3641 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3711 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3642 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3712 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3643 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3713 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3644 | if ( km == KMessageBox::Continue ) | 3714 | if ( km == KMessageBox::Continue ) |
3645 | km = KMessageBox::No; // No = all below | 3715 | km = KMessageBox::No; // No = all below |
3646 | } else | 3716 | } else |
3647 | km = KMessageBox::No; | 3717 | km = KMessageBox::No; |
3648 | } else { | 3718 | } else { |
3649 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3719 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3650 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3720 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3651 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3721 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3652 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3722 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3653 | i18n("All")); | 3723 | i18n("All")); |
3654 | } | 3724 | } |
3655 | switch(km) { | 3725 | switch(km) { |
3656 | 3726 | ||
3657 | case KMessageBox::No: // Continue // all | 3727 | case KMessageBox::No: // Continue // all |
3658 | //qDebug("KMessageBox::No "); | 3728 | //qDebug("KMessageBox::No "); |
3659 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3729 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3660 | schedule(Scheduler::Cancel,anEvent); | 3730 | schedule(Scheduler::Cancel,anEvent); |
3661 | 3731 | ||
3662 | checkExternalId( anEvent); | 3732 | checkExternalId( anEvent); |
3663 | mCalendar->deleteEvent(anEvent); | 3733 | mCalendar->deleteEvent(anEvent); |
3664 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3734 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3665 | break; | 3735 | break; |
3666 | 3736 | ||
3667 | // Disabled because it does not work | 3737 | // Disabled because it does not work |
3668 | //#if 0 | 3738 | //#if 0 |
3669 | case KMessageBox::Yes: // just this one | 3739 | case KMessageBox::Yes: // just this one |
3670 | //QDate qd = mNavigator->selectedDates().first(); | 3740 | //QDate qd = mNavigator->selectedDates().first(); |
3671 | //if (!qd.isValid()) { | 3741 | //if (!qd.isValid()) { |
3672 | // kdDebug() << "no date selected, or invalid date" << endl; | 3742 | // kdDebug() << "no date selected, or invalid date" << endl; |
3673 | // KNotifyClient::beep(); | 3743 | // KNotifyClient::beep(); |
3674 | // return; | 3744 | // return; |
3675 | //} | 3745 | //} |
3676 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3746 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3677 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3747 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3678 | anEvent->addExDate(itemDate); | 3748 | anEvent->addExDate(itemDate); |
3679 | int duration = anEvent->recurrence()->duration(); | 3749 | int duration = anEvent->recurrence()->duration(); |
3680 | if ( duration > 0 ) { | 3750 | if ( duration > 0 ) { |
3681 | anEvent->recurrence()->setDuration( duration - 1 ); | 3751 | anEvent->recurrence()->setDuration( duration - 1 ); |
3682 | } | 3752 | } |
3683 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3753 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3684 | } | 3754 | } |
3685 | break; | 3755 | break; |
3686 | //#endif | 3756 | //#endif |
3687 | } // switch | 3757 | } // switch |
3688 | } else { | 3758 | } else { |
3689 | if (KOPrefs::instance()->mConfirm) { | 3759 | if (KOPrefs::instance()->mConfirm) { |
3690 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3760 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3691 | i18n("\nAre you sure you want\nto delete this event?"), | 3761 | i18n("\nAre you sure you want\nto delete this event?"), |
3692 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3762 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3693 | case KMessageBox::Continue: // OK | 3763 | case KMessageBox::Continue: // OK |
3694 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3764 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3695 | schedule(Scheduler::Cancel,anEvent); | 3765 | schedule(Scheduler::Cancel,anEvent); |
3696 | checkExternalId( anEvent); | 3766 | checkExternalId( anEvent); |
3697 | mCalendar->deleteEvent(anEvent); | 3767 | mCalendar->deleteEvent(anEvent); |
3698 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3768 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3699 | break; | 3769 | break; |
3700 | } // switch | 3770 | } // switch |
3701 | } else { | 3771 | } else { |
3702 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3772 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3703 | schedule(Scheduler::Cancel,anEvent); | 3773 | schedule(Scheduler::Cancel,anEvent); |
3704 | checkExternalId( anEvent); | 3774 | checkExternalId( anEvent); |
3705 | mCalendar->deleteEvent(anEvent); | 3775 | mCalendar->deleteEvent(anEvent); |
3706 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3776 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3707 | } | 3777 | } |
3708 | } // if-else | 3778 | } // if-else |
3709 | emit updateSearchDialog(); | 3779 | emit updateSearchDialog(); |
3710 | } | 3780 | } |
3711 | 3781 | ||
3712 | bool CalendarView::deleteEvent(const QString &uid) | 3782 | bool CalendarView::deleteEvent(const QString &uid) |
3713 | { | 3783 | { |
3714 | Event *ev = mCalendar->event(uid); | 3784 | Event *ev = mCalendar->event(uid); |
3715 | if (ev) { | 3785 | if (ev) { |
3716 | deleteEvent(ev); | 3786 | deleteEvent(ev); |
3717 | return true; | 3787 | return true; |
3718 | } else { | 3788 | } else { |
3719 | return false; | 3789 | return false; |
3720 | } | 3790 | } |
3721 | } | 3791 | } |
3722 | 3792 | ||
3723 | /*****************************************************************************/ | 3793 | /*****************************************************************************/ |
3724 | 3794 | ||
3725 | void CalendarView::action_mail() | 3795 | void CalendarView::action_mail() |
3726 | { | 3796 | { |
3727 | #ifndef KORG_NOMAIL | 3797 | #ifndef KORG_NOMAIL |
3728 | KOMailClient mailClient; | 3798 | KOMailClient mailClient; |
3729 | 3799 | ||
3730 | Incidence *incidence = currentSelection(); | 3800 | Incidence *incidence = currentSelection(); |
3731 | 3801 | ||
3732 | if (!incidence) { | 3802 | if (!incidence) { |
3733 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3803 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3734 | return; | 3804 | return; |
3735 | } | 3805 | } |
3736 | if(incidence->attendeeCount() == 0 ) { | 3806 | if(incidence->attendeeCount() == 0 ) { |
3737 | KMessageBox::sorry(this, | 3807 | KMessageBox::sorry(this, |
3738 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3808 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3739 | return; | 3809 | return; |
3740 | } | 3810 | } |
3741 | 3811 | ||
3742 | CalendarLocal cal_tmp; | 3812 | CalendarLocal cal_tmp; |
3743 | Event *event = 0; | 3813 | Event *event = 0; |
3744 | Event *ev = 0; | 3814 | Event *ev = 0; |
3745 | if ( incidence && incidence->typeID() == eventID ) { | 3815 | if ( incidence && incidence->typeID() == eventID ) { |
3746 | event = static_cast<Event *>(incidence); | 3816 | event = static_cast<Event *>(incidence); |
3747 | ev = new Event(*event); | 3817 | ev = new Event(*event); |
3748 | cal_tmp.addEvent(ev); | 3818 | cal_tmp.addEvent(ev); |
3749 | } | 3819 | } |
3750 | ICalFormat mForm(); | 3820 | ICalFormat mForm(); |
3751 | QString attachment = mForm.toString( &cal_tmp ); | 3821 | QString attachment = mForm.toString( &cal_tmp ); |
3752 | if (ev) delete(ev); | 3822 | if (ev) delete(ev); |
3753 | 3823 | ||
3754 | mailClient.mailAttendees(currentSelection(), attachment); | 3824 | mailClient.mailAttendees(currentSelection(), attachment); |
3755 | 3825 | ||
3756 | #endif | 3826 | #endif |
3757 | 3827 | ||
3758 | #if 0 | 3828 | #if 0 |
3759 | Event *anEvent = 0; | 3829 | Event *anEvent = 0; |
3760 | if (mViewManager->currentView()->isEventView()) { | 3830 | if (mViewManager->currentView()->isEventView()) { |
3761 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3831 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3762 | } | 3832 | } |
3763 | 3833 | ||
3764 | if (!anEvent) { | 3834 | if (!anEvent) { |
3765 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3835 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3766 | return; | 3836 | return; |
3767 | } | 3837 | } |
3768 | if(anEvent->attendeeCount() == 0 ) { | 3838 | if(anEvent->attendeeCount() == 0 ) { |
3769 | KMessageBox::sorry(this, | 3839 | KMessageBox::sorry(this, |
3770 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3840 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3771 | return; | 3841 | return; |
3772 | } | 3842 | } |
3773 | 3843 | ||
3774 | mailobject.emailEvent(anEvent); | 3844 | mailobject.emailEvent(anEvent); |
3775 | #endif | 3845 | #endif |
3776 | } | 3846 | } |
3777 | 3847 | ||
3778 | 3848 | ||
3779 | void CalendarView::schedule_publish(Incidence *incidence) | 3849 | void CalendarView::schedule_publish(Incidence *incidence) |
3780 | { | 3850 | { |
3781 | Event *event = 0; | 3851 | Event *event = 0; |
3782 | Todo *todo = 0; | 3852 | Todo *todo = 0; |
3783 | 3853 | ||
3784 | if (incidence == 0) { | 3854 | if (incidence == 0) { |
3785 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3855 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3786 | if (incidence == 0) { | 3856 | if (incidence == 0) { |
3787 | incidence = mTodoList->selectedIncidences().first(); | 3857 | incidence = mTodoList->selectedIncidences().first(); |
3788 | } | 3858 | } |
3789 | } | 3859 | } |
3790 | if ( incidence && incidence->typeID() == eventID ) { | 3860 | if ( incidence && incidence->typeID() == eventID ) { |
3791 | event = static_cast<Event *>(incidence); | 3861 | event = static_cast<Event *>(incidence); |
3792 | } else { | 3862 | } else { |
3793 | if ( incidence && incidence->typeID() == todoID ) { | 3863 | if ( incidence && incidence->typeID() == todoID ) { |
3794 | todo = static_cast<Todo *>(incidence); | 3864 | todo = static_cast<Todo *>(incidence); |
3795 | } | 3865 | } |
3796 | } | 3866 | } |
3797 | 3867 | ||
3798 | if (!event && !todo) { | 3868 | if (!event && !todo) { |
3799 | KMessageBox::sorry(this,i18n("No event selected.")); | 3869 | KMessageBox::sorry(this,i18n("No event selected.")); |
3800 | return; | 3870 | return; |
3801 | } | 3871 | } |
3802 | 3872 | ||
3803 | PublishDialog *publishdlg = new PublishDialog(); | 3873 | PublishDialog *publishdlg = new PublishDialog(); |
3804 | if (incidence->attendeeCount()>0) { | 3874 | if (incidence->attendeeCount()>0) { |
3805 | QPtrList<Attendee> attendees = incidence->attendees(); | 3875 | QPtrList<Attendee> attendees = incidence->attendees(); |
3806 | attendees.first(); | 3876 | attendees.first(); |
3807 | while ( attendees.current()!=0 ) { | 3877 | while ( attendees.current()!=0 ) { |
3808 | publishdlg->addAttendee(attendees.current()); | 3878 | publishdlg->addAttendee(attendees.current()); |
3809 | attendees.next(); | 3879 | attendees.next(); |
3810 | } | 3880 | } |
3811 | } | 3881 | } |
3812 | bool send = true; | 3882 | bool send = true; |
3813 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3883 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3814 | if ( publishdlg->exec() != QDialog::Accepted ) | 3884 | if ( publishdlg->exec() != QDialog::Accepted ) |
3815 | send = false; | 3885 | send = false; |
3816 | } | 3886 | } |
3817 | if ( send ) { | 3887 | if ( send ) { |
3818 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3888 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3819 | if ( event ) { | 3889 | if ( event ) { |
3820 | Event *ev = new Event(*event); | 3890 | Event *ev = new Event(*event); |
3821 | ev->registerObserver(0); | 3891 | ev->registerObserver(0); |
3822 | ev->clearAttendees(); | 3892 | ev->clearAttendees(); |
3823 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3893 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3824 | delete(ev); | 3894 | delete(ev); |
3825 | } | 3895 | } |
3826 | } else { | 3896 | } else { |
3827 | if ( todo ) { | 3897 | if ( todo ) { |
3828 | Todo *ev = new Todo(*todo); | 3898 | Todo *ev = new Todo(*todo); |
3829 | ev->registerObserver(0); | 3899 | ev->registerObserver(0); |
3830 | ev->clearAttendees(); | 3900 | ev->clearAttendees(); |
3831 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3901 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3832 | delete(ev); | 3902 | delete(ev); |
3833 | } | 3903 | } |
3834 | } | 3904 | } |
3835 | } | 3905 | } |
3836 | } | 3906 | } |
3837 | delete publishdlg; | 3907 | delete publishdlg; |
3838 | } | 3908 | } |
3839 | 3909 | ||
3840 | void CalendarView::schedule_request(Incidence *incidence) | 3910 | void CalendarView::schedule_request(Incidence *incidence) |
3841 | { | 3911 | { |
3842 | schedule(Scheduler::Request,incidence); | 3912 | schedule(Scheduler::Request,incidence); |
3843 | } | 3913 | } |
3844 | 3914 | ||
3845 | void CalendarView::schedule_refresh(Incidence *incidence) | 3915 | void CalendarView::schedule_refresh(Incidence *incidence) |
3846 | { | 3916 | { |
3847 | schedule(Scheduler::Refresh,incidence); | 3917 | schedule(Scheduler::Refresh,incidence); |
3848 | } | 3918 | } |
3849 | 3919 | ||
3850 | void CalendarView::schedule_cancel(Incidence *incidence) | 3920 | void CalendarView::schedule_cancel(Incidence *incidence) |
3851 | { | 3921 | { |
3852 | schedule(Scheduler::Cancel,incidence); | 3922 | schedule(Scheduler::Cancel,incidence); |
3853 | } | 3923 | } |
3854 | 3924 | ||
3855 | void CalendarView::schedule_add(Incidence *incidence) | 3925 | void CalendarView::schedule_add(Incidence *incidence) |
3856 | { | 3926 | { |
3857 | schedule(Scheduler::Add,incidence); | 3927 | schedule(Scheduler::Add,incidence); |
3858 | } | 3928 | } |
3859 | 3929 | ||
3860 | void CalendarView::schedule_reply(Incidence *incidence) | 3930 | void CalendarView::schedule_reply(Incidence *incidence) |
3861 | { | 3931 | { |
3862 | schedule(Scheduler::Reply,incidence); | 3932 | schedule(Scheduler::Reply,incidence); |
3863 | } | 3933 | } |
3864 | 3934 | ||
3865 | void CalendarView::schedule_counter(Incidence *incidence) | 3935 | void CalendarView::schedule_counter(Incidence *incidence) |
3866 | { | 3936 | { |
3867 | schedule(Scheduler::Counter,incidence); | 3937 | schedule(Scheduler::Counter,incidence); |
3868 | } | 3938 | } |
3869 | 3939 | ||
3870 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3940 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3871 | { | 3941 | { |
3872 | schedule(Scheduler::Declinecounter,incidence); | 3942 | schedule(Scheduler::Declinecounter,incidence); |
3873 | } | 3943 | } |
3874 | 3944 | ||
3875 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3945 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3876 | { | 3946 | { |
3877 | QDateTime start = QDateTime::currentDateTime(); | 3947 | QDateTime start = QDateTime::currentDateTime(); |
3878 | QDateTime end = start.addDays(daysToPublish); | 3948 | QDateTime end = start.addDays(daysToPublish); |
3879 | 3949 | ||
3880 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3950 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3881 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3951 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3882 | 3952 | ||
3883 | 3953 | ||
3884 | PublishDialog *publishdlg = new PublishDialog(); | 3954 | PublishDialog *publishdlg = new PublishDialog(); |
3885 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3955 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3886 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3956 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3887 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3957 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3888 | delete(freebusy); | 3958 | delete(freebusy); |
3889 | } | 3959 | } |
3890 | } | 3960 | } |
3891 | delete publishdlg; | 3961 | delete publishdlg; |
3892 | } | 3962 | } |
3893 | 3963 | ||
3894 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3964 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3895 | { | 3965 | { |
3896 | Event *event = 0; | 3966 | Event *event = 0; |
3897 | Todo *todo = 0; | 3967 | Todo *todo = 0; |
3898 | 3968 | ||
3899 | if (incidence == 0) { | 3969 | if (incidence == 0) { |
3900 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3970 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3901 | if (incidence == 0) { | 3971 | if (incidence == 0) { |
3902 | incidence = mTodoList->selectedIncidences().first(); | 3972 | incidence = mTodoList->selectedIncidences().first(); |
3903 | } | 3973 | } |
3904 | } | 3974 | } |
3905 | if ( incidence && incidence->typeID() == eventID ) { | 3975 | if ( incidence && incidence->typeID() == eventID ) { |
3906 | event = static_cast<Event *>(incidence); | 3976 | event = static_cast<Event *>(incidence); |
3907 | } | 3977 | } |
3908 | if ( incidence && incidence->typeID() == todoID ) { | 3978 | if ( incidence && incidence->typeID() == todoID ) { |
3909 | todo = static_cast<Todo *>(incidence); | 3979 | todo = static_cast<Todo *>(incidence); |
3910 | } | 3980 | } |
3911 | 3981 | ||
3912 | if (!event && !todo) { | 3982 | if (!event && !todo) { |
3913 | KMessageBox::sorry(this,i18n("No event selected.")); | 3983 | KMessageBox::sorry(this,i18n("No event selected.")); |
3914 | return; | 3984 | return; |
3915 | } | 3985 | } |
3916 | 3986 | ||
3917 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3987 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3918 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3988 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3919 | return; | 3989 | return; |
3920 | } | 3990 | } |
3921 | 3991 | ||
3922 | Event *ev = 0; | 3992 | Event *ev = 0; |
3923 | if (event) ev = new Event(*event); | 3993 | if (event) ev = new Event(*event); |
3924 | Todo *to = 0; | 3994 | Todo *to = 0; |
3925 | if (todo) to = new Todo(*todo); | 3995 | if (todo) to = new Todo(*todo); |
3926 | 3996 | ||
3927 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3997 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3928 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3998 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3929 | if (!me) { | 3999 | if (!me) { |
3930 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4000 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3931 | return; | 4001 | return; |
3932 | } | 4002 | } |
3933 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4003 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3934 | StatusDialog *statdlg = new StatusDialog(this); | 4004 | StatusDialog *statdlg = new StatusDialog(this); |
3935 | if (!statdlg->exec()==QDialog::Accepted) return; | 4005 | if (!statdlg->exec()==QDialog::Accepted) return; |
3936 | me->setStatus( statdlg->status() ); | 4006 | me->setStatus( statdlg->status() ); |
3937 | delete(statdlg); | 4007 | delete(statdlg); |
3938 | } | 4008 | } |
3939 | Attendee *menew = new Attendee(*me); | 4009 | Attendee *menew = new Attendee(*me); |
3940 | if (ev) { | 4010 | if (ev) { |
3941 | ev->clearAttendees(); | 4011 | ev->clearAttendees(); |
3942 | ev->addAttendee(menew,false); | 4012 | ev->addAttendee(menew,false); |
3943 | } else { | 4013 | } else { |
3944 | if (to) { | 4014 | if (to) { |
3945 | todo->clearAttendees(); | 4015 | todo->clearAttendees(); |
3946 | todo->addAttendee(menew,false); | 4016 | todo->addAttendee(menew,false); |
3947 | } | 4017 | } |
3948 | } | 4018 | } |
3949 | } | 4019 | } |
3950 | 4020 | ||
3951 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4021 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3952 | if (ev) { | 4022 | if (ev) { |
3953 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4023 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3954 | } else { | 4024 | } else { |
3955 | if (to) { | 4025 | if (to) { |
3956 | if ( !dlg->addMessage(to,method) ) delete(to); | 4026 | if ( !dlg->addMessage(to,method) ) delete(to); |
3957 | } | 4027 | } |
3958 | } | 4028 | } |
3959 | } | 4029 | } |
3960 | 4030 | ||
3961 | void CalendarView::openAddressbook() | 4031 | void CalendarView::openAddressbook() |
3962 | { | 4032 | { |
3963 | KRun::runCommand("kaddressbook"); | 4033 | KRun::runCommand("kaddressbook"); |
3964 | } | 4034 | } |
3965 | 4035 | ||
3966 | void CalendarView::setModified(bool modified) | 4036 | void CalendarView::setModified(bool modified) |
3967 | { | 4037 | { |
3968 | if ( modified ) | 4038 | if ( modified ) |
3969 | emit signalmodified(); | 4039 | emit signalmodified(); |
3970 | if (mModified != modified) { | 4040 | if (mModified != modified) { |
3971 | mModified = modified; | 4041 | mModified = modified; |
3972 | emit modifiedChanged(mModified); | 4042 | emit modifiedChanged(mModified); |
3973 | } | 4043 | } |
3974 | } | 4044 | } |
3975 | 4045 | ||
3976 | bool CalendarView::isReadOnly() | 4046 | bool CalendarView::isReadOnly() |
3977 | { | 4047 | { |
3978 | return mReadOnly; | 4048 | return mReadOnly; |
3979 | } | 4049 | } |
3980 | 4050 | ||
3981 | void CalendarView::setReadOnly(bool readOnly) | 4051 | void CalendarView::setReadOnly(bool readOnly) |
3982 | { | 4052 | { |
3983 | if (mReadOnly != readOnly) { | 4053 | if (mReadOnly != readOnly) { |
3984 | mReadOnly = readOnly; | 4054 | mReadOnly = readOnly; |
3985 | emit readOnlyChanged(mReadOnly); | 4055 | emit readOnlyChanged(mReadOnly); |
3986 | } | 4056 | } |
3987 | } | 4057 | } |
3988 | 4058 | ||
3989 | bool CalendarView::isModified() | 4059 | bool CalendarView::isModified() |
3990 | { | 4060 | { |
3991 | return mModified; | 4061 | return mModified; |
3992 | } | 4062 | } |
3993 | void CalendarView::slotprintSelInc() | 4063 | void CalendarView::slotprintSelInc() |
3994 | { | 4064 | { |
3995 | if ( currentSelection() == 0 ) { | 4065 | if ( currentSelection() == 0 ) { |
3996 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4066 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
3997 | return; | 4067 | return; |
3998 | } | 4068 | } |
3999 | showIncidence(); | 4069 | showIncidence(); |
4000 | getEventViewerDialog()->print(); | 4070 | getEventViewerDialog()->print(); |
4001 | 4071 | ||
4002 | } | 4072 | } |
4003 | void CalendarView::printSetup() | 4073 | void CalendarView::printSetup() |
4004 | { | 4074 | { |
4005 | #ifndef KORG_NOPRINTER | 4075 | #ifndef KORG_NOPRINTER |
4006 | createPrinter(); | 4076 | createPrinter(); |
4007 | 4077 | ||
4008 | mCalPrinter->setupPrinter(); | 4078 | mCalPrinter->setupPrinter(); |
4009 | #endif | 4079 | #endif |
4010 | } | 4080 | } |
4011 | 4081 | ||
4012 | void CalendarView::print() | 4082 | void CalendarView::print() |
4013 | { | 4083 | { |
4014 | #ifndef KORG_NOPRINTER | 4084 | #ifndef KORG_NOPRINTER |
4015 | createPrinter(); | 4085 | createPrinter(); |
4016 | 4086 | ||
4017 | DateList tmpDateList = mNavigator->selectedDates(); | 4087 | DateList tmpDateList = mNavigator->selectedDates(); |
4018 | mCalPrinter->print(CalPrinter::Month, | 4088 | mCalPrinter->print(CalPrinter::Month, |
4019 | tmpDateList.first(), tmpDateList.last()); | 4089 | tmpDateList.first(), tmpDateList.last()); |
4020 | #endif | 4090 | #endif |
4021 | } | 4091 | } |
4022 | 4092 | ||
4023 | void CalendarView::printPreview() | 4093 | void CalendarView::printPreview() |
4024 | { | 4094 | { |
4025 | #ifndef KORG_NOPRINTER | 4095 | #ifndef KORG_NOPRINTER |
4026 | kdDebug() << "CalendarView::printPreview()" << endl; | 4096 | kdDebug() << "CalendarView::printPreview()" << endl; |
4027 | 4097 | ||
4028 | createPrinter(); | 4098 | createPrinter(); |
4029 | 4099 | ||
4030 | DateList tmpDateList = mNavigator->selectedDates(); | 4100 | DateList tmpDateList = mNavigator->selectedDates(); |
4031 | 4101 | ||
4032 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 4102 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
4033 | tmpDateList.last()); | 4103 | tmpDateList.last()); |
4034 | #endif | 4104 | #endif |
4035 | } | 4105 | } |
4036 | 4106 | ||
4037 | void CalendarView::exportICalendar() | 4107 | void CalendarView::exportICalendar() |
4038 | { | 4108 | { |
4039 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 4109 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
4040 | 4110 | ||
4041 | // Force correct extension | 4111 | // Force correct extension |
4042 | if (filename.right(4) != ".ics") filename += ".ics"; | 4112 | if (filename.right(4) != ".ics") filename += ".ics"; |
4043 | 4113 | ||
4044 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 4114 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
4045 | storage.save(); | 4115 | storage.save(); |
4046 | } | 4116 | } |
4047 | 4117 | ||
4048 | bool CalendarView::exportVCalendar( QString filename ) | 4118 | bool CalendarView::exportVCalendar( QString filename ) |
4049 | { | 4119 | { |
4050 | if (mCalendar->journals().count() > 0) { | 4120 | if (mCalendar->journals().count() > 0) { |
4051 | int result = KMessageBox::warningContinueCancel(this, | 4121 | int result = KMessageBox::warningContinueCancel(this, |
4052 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 4122 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
4053 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 4123 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
4054 | true); | 4124 | true); |
4055 | if (result != KMessageBox::Continue) return false; | 4125 | if (result != KMessageBox::Continue) return false; |
4056 | } | 4126 | } |
4057 | 4127 | ||
4058 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 4128 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
4059 | 4129 | ||
4060 | // Force correct extension | 4130 | // Force correct extension |
4061 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 4131 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
4062 | 4132 | ||
4063 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 4133 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
4064 | return storage.save(); | 4134 | return storage.save(); |
4065 | 4135 | ||
4066 | } | 4136 | } |
4067 | 4137 | ||
4068 | void CalendarView::eventUpdated(Incidence *) | 4138 | void CalendarView::eventUpdated(Incidence *) |
4069 | { | 4139 | { |
4070 | setModified(); | 4140 | setModified(); |
4071 | // Don't call updateView here. The code, which has caused the update of the | 4141 | // Don't call updateView here. The code, which has caused the update of the |
4072 | // event is responsible for updating the view. | 4142 | // event is responsible for updating the view. |
4073 | // updateView(); | 4143 | // updateView(); |
4074 | } | 4144 | } |
4075 | 4145 | ||
4076 | void CalendarView::adaptNavigationUnits() | 4146 | void CalendarView::adaptNavigationUnits() |
4077 | { | 4147 | { |
4078 | if (mViewManager->currentView()->isEventView()) { | 4148 | if (mViewManager->currentView()->isEventView()) { |
4079 | int days = mViewManager->currentView()->currentDateCount(); | 4149 | int days = mViewManager->currentView()->currentDateCount(); |
4080 | if (days == 1) { | 4150 | if (days == 1) { |
4081 | emit changeNavStringPrev(i18n("&Previous Day")); | 4151 | emit changeNavStringPrev(i18n("&Previous Day")); |
4082 | emit changeNavStringNext(i18n("&Next Day")); | 4152 | emit changeNavStringNext(i18n("&Next Day")); |
4083 | } else { | 4153 | } else { |
4084 | emit changeNavStringPrev(i18n("&Previous Week")); | 4154 | emit changeNavStringPrev(i18n("&Previous Week")); |
4085 | emit changeNavStringNext(i18n("&Next Week")); | 4155 | emit changeNavStringNext(i18n("&Next Week")); |
4086 | } | 4156 | } |
4087 | } | 4157 | } |
4088 | } | 4158 | } |
4089 | 4159 | ||
4090 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 4160 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
4091 | { | 4161 | { |
4092 | if ( incidence ) mTodoList->clearSelection(); | 4162 | if ( incidence ) mTodoList->clearSelection(); |
4093 | processIncidenceSelection( incidence ); | 4163 | processIncidenceSelection( incidence ); |
4094 | } | 4164 | } |
4095 | 4165 | ||
4096 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 4166 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
4097 | { | 4167 | { |
4098 | if ( incidence && mViewManager->currentView() ) { | 4168 | if ( incidence && mViewManager->currentView() ) { |
4099 | mViewManager->currentView()->clearSelection(); | 4169 | mViewManager->currentView()->clearSelection(); |
4100 | } | 4170 | } |
4101 | processIncidenceSelection( incidence ); | 4171 | processIncidenceSelection( incidence ); |
4102 | } | 4172 | } |
4103 | 4173 | ||
4104 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 4174 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
4105 | { | 4175 | { |
4106 | emit incidenceSelected( incidence ); | 4176 | emit incidenceSelected( incidence ); |
4107 | if ( incidence == mSelectedIncidence ) return; | 4177 | if ( incidence == mSelectedIncidence ) return; |
4108 | mSelectedIncidence = incidence; | 4178 | mSelectedIncidence = incidence; |
4109 | 4179 | ||
4110 | if ( incidence && incidence->typeID() == eventID ) { | 4180 | if ( incidence && incidence->typeID() == eventID ) { |
4111 | Event *event = static_cast<Event *>( incidence ); | 4181 | Event *event = static_cast<Event *>( incidence ); |
4112 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4182 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4113 | emit organizerEventsSelected( true ); | 4183 | emit organizerEventsSelected( true ); |
4114 | } else { | 4184 | } else { |
4115 | emit organizerEventsSelected(false); | 4185 | emit organizerEventsSelected(false); |
4116 | } | 4186 | } |
4117 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4187 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4118 | KOPrefs::instance()->email() ) ) { | 4188 | KOPrefs::instance()->email() ) ) { |
4119 | emit groupEventsSelected( true ); | 4189 | emit groupEventsSelected( true ); |
4120 | } else { | 4190 | } else { |
4121 | emit groupEventsSelected(false); | 4191 | emit groupEventsSelected(false); |
4122 | } | 4192 | } |
4123 | return; | 4193 | return; |
4124 | } else { | 4194 | } else { |
4125 | if ( incidence && incidence->typeID() == todoID ) { | 4195 | if ( incidence && incidence->typeID() == todoID ) { |
4126 | emit todoSelected( true ); | 4196 | emit todoSelected( true ); |
4127 | Todo *event = static_cast<Todo *>( incidence ); | 4197 | Todo *event = static_cast<Todo *>( incidence ); |
4128 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 4198 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
4129 | emit organizerEventsSelected( true ); | 4199 | emit organizerEventsSelected( true ); |
4130 | } else { | 4200 | } else { |
4131 | emit organizerEventsSelected(false); | 4201 | emit organizerEventsSelected(false); |
4132 | } | 4202 | } |
4133 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 4203 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
4134 | KOPrefs::instance()->email() ) ) { | 4204 | KOPrefs::instance()->email() ) ) { |
4135 | emit groupEventsSelected( true ); | 4205 | emit groupEventsSelected( true ); |
4136 | } else { | 4206 | } else { |
4137 | emit groupEventsSelected(false); | 4207 | emit groupEventsSelected(false); |
4138 | } | 4208 | } |
4139 | return; | 4209 | return; |
4140 | } else { | 4210 | } else { |
4141 | emit todoSelected( false ); | 4211 | emit todoSelected( false ); |
4142 | emit organizerEventsSelected(false); | 4212 | emit organizerEventsSelected(false); |
4143 | emit groupEventsSelected(false); | 4213 | emit groupEventsSelected(false); |
4144 | } | 4214 | } |
4145 | return; | 4215 | return; |
4146 | } | 4216 | } |
4147 | 4217 | ||
4148 | /* if ( incidence && incidence->typeID() == todoID ) { | 4218 | /* if ( incidence && incidence->typeID() == todoID ) { |
4149 | emit todoSelected( true ); | 4219 | emit todoSelected( true ); |
4150 | } else { | 4220 | } else { |
4151 | emit todoSelected( false ); | 4221 | emit todoSelected( false ); |
4152 | }*/ | 4222 | }*/ |
4153 | } | 4223 | } |
4154 | 4224 | ||
4155 | 4225 | ||
4156 | void CalendarView::checkClipboard() | 4226 | void CalendarView::checkClipboard() |
4157 | { | 4227 | { |
4158 | #ifndef KORG_NODND | 4228 | #ifndef KORG_NODND |
4159 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 4229 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
4160 | emit pasteEnabled(true); | 4230 | emit pasteEnabled(true); |
4161 | } else { | 4231 | } else { |
4162 | emit pasteEnabled(false); | 4232 | emit pasteEnabled(false); |
4163 | } | 4233 | } |
4164 | #endif | 4234 | #endif |
4165 | } | 4235 | } |
4166 | 4236 | ||
4167 | void CalendarView::showDates(const DateList &selectedDates) | 4237 | void CalendarView::showDates(const DateList &selectedDates) |
4168 | { | 4238 | { |
4169 | // kdDebug() << "CalendarView::selectDates()" << endl; | 4239 | // kdDebug() << "CalendarView::selectDates()" << endl; |
4170 | 4240 | ||
4171 | 4241 | ||
4172 | if ( !mBlockShowDates ) { | 4242 | if ( !mBlockShowDates ) { |
4173 | if ( mViewManager->currentView() ) { | 4243 | if ( mViewManager->currentView() ) { |
4174 | updateView( selectedDates.first(), selectedDates.last() ); | 4244 | updateView( selectedDates.first(), selectedDates.last() ); |
4175 | } else { | 4245 | } else { |
4176 | mViewManager->showAgendaView(); | 4246 | mViewManager->showAgendaView(); |
4177 | } | 4247 | } |
4178 | } | 4248 | } |
4179 | 4249 | ||
4180 | QDate date = selectedDates.first(); | 4250 | QDate date = selectedDates.first(); |
4181 | if ( ! date.isValid() ) { | 4251 | if ( ! date.isValid() ) { |
4182 | topLevelWidget()->setCaption(""); | 4252 | topLevelWidget()->setCaption(""); |
4183 | return; | 4253 | return; |
4184 | } | 4254 | } |
4185 | 4255 | ||
4186 | QString selDates; | 4256 | QString selDates; |
4187 | selDates = KGlobal::locale()->formatDate( date, true); | 4257 | selDates = KGlobal::locale()->formatDate( date, true); |
4188 | if (selectedDates.first() < selectedDates.last() ) | 4258 | if (selectedDates.first() < selectedDates.last() ) |
4189 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 4259 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
4190 | else { | 4260 | else { |
4191 | QString addString; | 4261 | QString addString; |
4192 | if ( date == QDateTime::currentDateTime().date() ) | 4262 | if ( date == QDateTime::currentDateTime().date() ) |
4193 | addString = i18n("Today"); | 4263 | addString = i18n("Today"); |
4194 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) | 4264 | else if ( date == QDateTime::currentDateTime().date().addDays(1) ) |
4195 | addString = i18n("Tomorrow"); | 4265 | addString = i18n("Tomorrow"); |
4196 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) | 4266 | else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) |
4197 | addString = i18n("Yesterday"); | 4267 | addString = i18n("Yesterday"); |
4198 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) | 4268 | else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) |
4199 | addString = i18n("Day before yesterday"); | 4269 | addString = i18n("Day before yesterday"); |
4200 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) | 4270 | else if ( date == QDateTime::currentDateTime().date().addDays(2) ) |
4201 | addString = i18n("Day after tomorrow"); | 4271 | addString = i18n("Day after tomorrow"); |
4202 | if ( !addString.isEmpty() ) { | 4272 | if ( !addString.isEmpty() ) { |
4203 | topLevelWidget()->setCaption( addString+", " + selDates ); | 4273 | topLevelWidget()->setCaption( addString+", " + selDates ); |
4204 | return; | 4274 | return; |
4205 | } | 4275 | } |
4206 | } | 4276 | } |
4207 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 4277 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
4208 | 4278 | ||
4209 | } | 4279 | } |
4210 | 4280 | ||
4211 | QPtrList<CalFilter> CalendarView::filters() | 4281 | QPtrList<CalFilter> CalendarView::filters() |
4212 | { | 4282 | { |
4213 | return mFilters; | 4283 | return mFilters; |
4214 | 4284 | ||
4215 | } | 4285 | } |
4216 | void CalendarView::editFilters() | 4286 | void CalendarView::editFilters() |
4217 | { | 4287 | { |
4218 | // kdDebug() << "CalendarView::editFilters()" << endl; | 4288 | // kdDebug() << "CalendarView::editFilters()" << endl; |
4219 | 4289 | ||
4220 | CalFilter *filter = mFilters.first(); | 4290 | CalFilter *filter = mFilters.first(); |
4221 | while(filter) { | 4291 | while(filter) { |
4222 | filter = mFilters.next(); | 4292 | filter = mFilters.next(); |
4223 | } | 4293 | } |
4224 | 4294 | ||
4225 | mDialogManager->showFilterEditDialog(&mFilters); | 4295 | mDialogManager->showFilterEditDialog(&mFilters); |
4226 | updateFilter(); | 4296 | updateFilter(); |
4227 | } | 4297 | } |
4228 | void CalendarView::toggleFilter() | 4298 | void CalendarView::toggleFilter() |
4229 | { | 4299 | { |
4230 | if ( mLeftFrame->isHidden() ) { | 4300 | if ( mLeftFrame->isHidden() ) { |
4231 | toggleExpand(); | 4301 | toggleExpand(); |
4232 | showFilter( true ); | 4302 | showFilter( true ); |
4233 | } else | 4303 | } else |
4234 | showFilter(! mCalEditView->isVisible()); | 4304 | showFilter(! mCalEditView->isVisible()); |
4235 | } | 4305 | } |
4236 | 4306 | ||
4237 | KOFilterView *CalendarView::filterView() | 4307 | KOFilterView *CalendarView::filterView() |
4238 | { | 4308 | { |
4239 | return mFilterView; | 4309 | return mFilterView; |
4240 | } | 4310 | } |
4241 | void CalendarView::selectFilter( int fil ) | 4311 | void CalendarView::selectFilter( int fil ) |
4242 | { | 4312 | { |
4243 | mFilterView->setSelectedFilter( fil ); | 4313 | mFilterView->setSelectedFilter( fil ); |
4244 | updateUnmanagedViews(); | 4314 | updateUnmanagedViews(); |
4245 | } | 4315 | } |
4246 | void CalendarView::showFilter(bool visible) | 4316 | void CalendarView::showFilter(bool visible) |
4247 | { | 4317 | { |
4248 | #if 1 | 4318 | #if 1 |
4249 | if (visible) { | 4319 | if (visible) { |
4250 | mCalEditView->readConfig(); | 4320 | mCalEditView->readConfig(); |
4251 | mCalEditView->show(); | 4321 | mCalEditView->show(); |
4252 | QValueList<int> sizes; | 4322 | QValueList<int> sizes; |
4253 | sizes = mLeftFrame->sizes(); | 4323 | sizes = mLeftFrame->sizes(); |
4254 | if ( sizes.count() == 4 && sizes[3] < 20 ) { | 4324 | if ( sizes.count() == 4 && sizes[3] < 20 ) { |
4255 | sizes.clear(); | 4325 | sizes.clear(); |
4256 | sizes << 100; | 4326 | sizes << 100; |
4257 | sizes << 0; | 4327 | sizes << 0; |
4258 | sizes << 0; | 4328 | sizes << 0; |
4259 | sizes << 100; | 4329 | sizes << 100; |
4260 | mLeftFrame->setSizes(sizes); | 4330 | mLeftFrame->setSizes(sizes); |
4261 | } | 4331 | } |
4262 | #if 0 | 4332 | #if 0 |
4263 | sizes = mLeftFrame->sizes(); | 4333 | sizes = mLeftFrame->sizes(); |
4264 | int ccc = 0; | 4334 | int ccc = 0; |
4265 | while ( ccc < sizes.count()) { | 4335 | while ( ccc < sizes.count()) { |
4266 | qDebug("size %d %d ", ccc, sizes[ccc]); | 4336 | qDebug("size %d %d ", ccc, sizes[ccc]); |
4267 | ++ccc; | 4337 | ++ccc; |
4268 | } | 4338 | } |
4269 | #endif | 4339 | #endif |
4270 | 4340 | ||
4271 | } | 4341 | } |
4272 | else { | 4342 | else { |
4273 | mCalEditView->hide(); | 4343 | mCalEditView->hide(); |
4274 | } | 4344 | } |
4275 | #else | 4345 | #else |
4276 | if (visible) mFilterView->show(); | 4346 | if (visible) mFilterView->show(); |
4277 | else mFilterView->hide(); | 4347 | else mFilterView->hide(); |
4278 | #endif | 4348 | #endif |
4279 | } | 4349 | } |
4280 | void CalendarView::toggleFilerEnabled( ) | 4350 | void CalendarView::toggleFilerEnabled( ) |
4281 | { | 4351 | { |
4282 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 4352 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
4283 | if ( !mFilterView->filtersEnabled() ) | 4353 | if ( !mFilterView->filtersEnabled() ) |
4284 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 4354 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
4285 | updateUnmanagedViews(); | 4355 | updateUnmanagedViews(); |
4286 | 4356 | ||
4287 | } | 4357 | } |
4288 | void CalendarView::updateFilter() | 4358 | void CalendarView::updateFilter() |
4289 | { | 4359 | { |
4290 | CalFilter *filter = mFilterView->selectedFilter(); | 4360 | CalFilter *filter = mFilterView->selectedFilter(); |
4291 | if (filter) { | 4361 | if (filter) { |
4292 | QString mess; | 4362 | QString mess; |
4293 | if (mFilterView->filtersEnabled()) { | 4363 | if (mFilterView->filtersEnabled()) { |
4294 | mess = i18n("Filter selected: ")+filter->name(); | 4364 | mess = i18n("Filter selected: ")+filter->name(); |
4295 | filter->setEnabled(true); | 4365 | filter->setEnabled(true); |
4296 | } | 4366 | } |
4297 | else filter->setEnabled(false); | 4367 | else filter->setEnabled(false); |
4298 | mCalendar->setFilter(filter); | 4368 | mCalendar->setFilter(filter); |
4299 | updateView(); | 4369 | updateView(); |
4300 | if ( !mess.isEmpty() ) | 4370 | if ( !mess.isEmpty() ) |
4301 | topLevelWidget()->setCaption( mess ); | 4371 | topLevelWidget()->setCaption( mess ); |
4302 | 4372 | ||
4303 | } | 4373 | } |
4304 | emit filtersUpdated(); | 4374 | emit filtersUpdated(); |
4305 | } | 4375 | } |
4306 | 4376 | ||
4307 | void CalendarView::filterEdited() | 4377 | void CalendarView::filterEdited() |
4308 | { | 4378 | { |
4309 | mFilterView->updateFilters(); | 4379 | mFilterView->updateFilters(); |
4310 | updateFilter(); | 4380 | updateFilter(); |
4311 | writeSettings(); | 4381 | writeSettings(); |
4312 | } | 4382 | } |
4313 | 4383 | ||
4314 | 4384 | ||
4315 | void CalendarView::takeOverEvent() | 4385 | void CalendarView::takeOverEvent() |
4316 | { | 4386 | { |
4317 | Incidence *incidence = currentSelection(); | 4387 | Incidence *incidence = currentSelection(); |
4318 | 4388 | ||
4319 | if (!incidence) return; | 4389 | if (!incidence) return; |
4320 | 4390 | ||
4321 | incidence->setOrganizer(KOPrefs::instance()->email()); | 4391 | incidence->setOrganizer(KOPrefs::instance()->email()); |
4322 | incidence->recreate(); | 4392 | incidence->recreate(); |
4323 | incidence->setReadOnly(false); | 4393 | incidence->setReadOnly(false); |
4324 | 4394 | ||
4325 | updateView(); | 4395 | updateView(); |
4326 | } | 4396 | } |
4327 | 4397 | ||
4328 | void CalendarView::takeOverCalendar() | 4398 | void CalendarView::takeOverCalendar() |
4329 | { | 4399 | { |
4330 | // TODO: Create Calendar::allIncidences() function and use it here | 4400 | // TODO: Create Calendar::allIncidences() function and use it here |
4331 | 4401 | ||
4332 | clearAllViews(); | 4402 | clearAllViews(); |
4333 | QPtrList<Event> events = mCalendar->events(); | 4403 | QPtrList<Event> events = mCalendar->events(); |
4334 | for(uint i=0; i<events.count(); ++i) { | 4404 | for(uint i=0; i<events.count(); ++i) { |
4335 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4405 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4336 | events.at(i)->recreate(); | 4406 | events.at(i)->recreate(); |
4337 | events.at(i)->setReadOnly(false); | 4407 | events.at(i)->setReadOnly(false); |
4338 | } | 4408 | } |
4339 | 4409 | ||
4340 | QPtrList<Todo> todos = mCalendar->todos(); | 4410 | QPtrList<Todo> todos = mCalendar->todos(); |
4341 | for(uint i=0; i<todos.count(); ++i) { | 4411 | for(uint i=0; i<todos.count(); ++i) { |
4342 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4412 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4343 | todos.at(i)->recreate(); | 4413 | todos.at(i)->recreate(); |
4344 | todos.at(i)->setReadOnly(false); | 4414 | todos.at(i)->setReadOnly(false); |
4345 | } | 4415 | } |
4346 | 4416 | ||
4347 | QPtrList<Journal> journals = mCalendar->journals(); | 4417 | QPtrList<Journal> journals = mCalendar->journals(); |
4348 | for(uint i=0; i<journals.count(); ++i) { | 4418 | for(uint i=0; i<journals.count(); ++i) { |
4349 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 4419 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
4350 | journals.at(i)->recreate(); | 4420 | journals.at(i)->recreate(); |
4351 | journals.at(i)->setReadOnly(false); | 4421 | journals.at(i)->setReadOnly(false); |
4352 | } | 4422 | } |
4353 | 4423 | ||
4354 | updateView(); | 4424 | updateView(); |
4355 | } | 4425 | } |
4356 | 4426 | ||
4357 | void CalendarView::showIntro() | 4427 | void CalendarView::showIntro() |
4358 | { | 4428 | { |
4359 | kdDebug() << "To be implemented." << endl; | 4429 | kdDebug() << "To be implemented." << endl; |
4360 | } | 4430 | } |
4361 | 4431 | ||
4362 | QWidgetStack *CalendarView::viewStack() | 4432 | QWidgetStack *CalendarView::viewStack() |
4363 | { | 4433 | { |
4364 | return mRightFrame; | 4434 | return mRightFrame; |
4365 | } | 4435 | } |
4366 | 4436 | ||
4367 | QWidget *CalendarView::leftFrame() | 4437 | QWidget *CalendarView::leftFrame() |
4368 | { | 4438 | { |
4369 | return ( QWidget *)mLeftFrame; | 4439 | return ( QWidget *)mLeftFrame; |
4370 | } | 4440 | } |
4371 | 4441 | ||
4372 | DateNavigator *CalendarView::dateNavigator() | 4442 | DateNavigator *CalendarView::dateNavigator() |
4373 | { | 4443 | { |
4374 | return mNavigator; | 4444 | return mNavigator; |
4375 | } | 4445 | } |
4376 | 4446 | ||
4377 | KDateNavigator* CalendarView::dateNavigatorWidget() | 4447 | KDateNavigator* CalendarView::dateNavigatorWidget() |
4378 | { | 4448 | { |
4379 | return mDateNavigator->navigatorView(); | 4449 | return mDateNavigator->navigatorView(); |
4380 | } | 4450 | } |
4381 | void CalendarView::toggleDateNavigatorWidget() | 4451 | void CalendarView::toggleDateNavigatorWidget() |
4382 | { | 4452 | { |
4383 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 4453 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
4384 | 4454 | ||
4385 | if (!KOPrefs::instance()->mShowDateNavigator ) | 4455 | if (!KOPrefs::instance()->mShowDateNavigator ) |
4386 | mDateNavigator->hide(); | 4456 | mDateNavigator->hide(); |
4387 | else | 4457 | else |
4388 | mDateNavigator->show(); | 4458 | mDateNavigator->show(); |
4389 | } | 4459 | } |
4390 | void CalendarView::addView(KOrg::BaseView *view) | 4460 | void CalendarView::addView(KOrg::BaseView *view) |
4391 | { | 4461 | { |
4392 | mViewManager->addView(view); | 4462 | mViewManager->addView(view); |
4393 | } | 4463 | } |
4394 | 4464 | ||
4395 | void CalendarView::showView(KOrg::BaseView *view) | 4465 | void CalendarView::showView(KOrg::BaseView *view) |
4396 | { | 4466 | { |
4397 | mViewManager->showView(view, mLeftFrame->isVisible()); | 4467 | mViewManager->showView(view, mLeftFrame->isVisible()); |
4398 | } | 4468 | } |
4399 | 4469 | ||
4400 | Incidence *CalendarView::currentSelection() | 4470 | Incidence *CalendarView::currentSelection() |
4401 | { | 4471 | { |
4402 | return mViewManager->currentSelection(); | 4472 | return mViewManager->currentSelection(); |
4403 | } | 4473 | } |
4404 | void CalendarView::toggleAllDaySize() | 4474 | void CalendarView::toggleAllDaySize() |
4405 | { | 4475 | { |
4406 | /* | 4476 | /* |
4407 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 4477 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
4408 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 4478 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
4409 | else | 4479 | else |
4410 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 4480 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
4411 | */ | 4481 | */ |
4412 | viewManager()->agendaView()->toggleAllDay(); | 4482 | viewManager()->agendaView()->toggleAllDay(); |
4413 | } | 4483 | } |
4414 | void CalendarView::toggleExpand() | 4484 | void CalendarView::toggleExpand() |
4415 | { | 4485 | { |
4416 | // if ( mLeftFrame->isHidden() ) { | 4486 | // if ( mLeftFrame->isHidden() ) { |
4417 | // mLeftFrame->show(); | 4487 | // mLeftFrame->show(); |
4418 | // emit calendarViewExpanded( false ); | 4488 | // emit calendarViewExpanded( false ); |
4419 | // } else { | 4489 | // } else { |
4420 | // mLeftFrame->hide(); | 4490 | // mLeftFrame->hide(); |
4421 | // emit calendarViewExpanded( true ); | 4491 | // emit calendarViewExpanded( true ); |
4422 | // } | 4492 | // } |
4423 | //qDebug(" CalendarView::toggleExpand()"); | 4493 | //qDebug(" CalendarView::toggleExpand()"); |
4424 | globalFlagBlockAgenda = 1; | 4494 | globalFlagBlockAgenda = 1; |
4425 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 4495 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
4426 | globalFlagBlockAgenda = 5; | 4496 | globalFlagBlockAgenda = 5; |
4427 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 4497 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
4428 | //mViewManager->showView( 0, true ); | 4498 | //mViewManager->showView( 0, true ); |
4429 | } | 4499 | } |
4430 | 4500 | ||
4431 | void CalendarView::calendarModified( bool modified, Calendar * ) | 4501 | void CalendarView::calendarModified( bool modified, Calendar * ) |
4432 | { | 4502 | { |
4433 | setModified( modified ); | 4503 | setModified( modified ); |
4434 | } | 4504 | } |
4435 | 4505 | ||
4436 | Todo *CalendarView::selectedTodo() | 4506 | Todo *CalendarView::selectedTodo() |
4437 | { | 4507 | { |
4438 | Incidence *incidence = currentSelection(); | 4508 | Incidence *incidence = currentSelection(); |
4439 | if ( incidence && incidence->typeID() == todoID ) { | 4509 | if ( incidence && incidence->typeID() == todoID ) { |
4440 | return static_cast<Todo *>( incidence ); | 4510 | return static_cast<Todo *>( incidence ); |
4441 | } | 4511 | } |
4442 | 4512 | ||
4443 | incidence = mTodoList->selectedIncidences().first(); | 4513 | incidence = mTodoList->selectedIncidences().first(); |
4444 | if ( incidence && incidence->typeID() == todoID ) { | 4514 | if ( incidence && incidence->typeID() == todoID ) { |
4445 | return static_cast<Todo *>( incidence ); | 4515 | return static_cast<Todo *>( incidence ); |
4446 | } | 4516 | } |
4447 | 4517 | ||
4448 | return 0; | 4518 | return 0; |
4449 | } | 4519 | } |
4450 | 4520 | ||
4451 | void CalendarView::showIncidence() | 4521 | void CalendarView::showIncidence() |
4452 | { | 4522 | { |
4453 | mViewerCallerIsSearchDialog = false; | 4523 | mViewerCallerIsSearchDialog = false; |
4454 | Incidence *incidence = currentSelection(); | 4524 | Incidence *incidence = currentSelection(); |
4455 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4525 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4456 | if ( incidence ) { | 4526 | if ( incidence ) { |
4457 | ShowIncidenceVisitor v; | 4527 | ShowIncidenceVisitor v; |
4458 | v.act( incidence, this ); | 4528 | v.act( incidence, this ); |
4459 | } | 4529 | } |
4460 | } | 4530 | } |
4461 | void CalendarView::editIncidenceDescription() | 4531 | void CalendarView::editIncidenceDescription() |
4462 | { | 4532 | { |
4463 | mFlagEditDescription = true; | 4533 | mFlagEditDescription = true; |
4464 | editIncidence(); | 4534 | editIncidence(); |
4465 | mFlagEditDescription = false; | 4535 | mFlagEditDescription = false; |
4466 | } | 4536 | } |
4467 | void CalendarView::editIncidence() | 4537 | void CalendarView::editIncidence() |
4468 | { | 4538 | { |
4469 | // qDebug("editIncidence() "); | 4539 | // qDebug("editIncidence() "); |
4470 | Incidence *incidence = currentSelection(); | 4540 | Incidence *incidence = currentSelection(); |
4471 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4541 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4472 | if ( incidence ) { | 4542 | if ( incidence ) { |
4473 | EditIncidenceVisitor v; | 4543 | EditIncidenceVisitor v; |
4474 | v.act( incidence, this ); | 4544 | v.act( incidence, this ); |
4475 | } | 4545 | } |
4476 | } | 4546 | } |
4477 | 4547 | ||
4478 | void CalendarView::deleteIncidence() | 4548 | void CalendarView::deleteIncidence() |
4479 | { | 4549 | { |
4480 | Incidence *incidence = currentSelection(); | 4550 | Incidence *incidence = currentSelection(); |
4481 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 4551 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
4482 | if ( incidence ) { | 4552 | if ( incidence ) { |
4483 | deleteIncidence(incidence); | 4553 | deleteIncidence(incidence); |
4484 | } | 4554 | } |
4485 | } | 4555 | } |
4486 | void CalendarView::showIncidence(QString uid) | 4556 | void CalendarView::showIncidence(QString uid) |
4487 | { | 4557 | { |
4488 | Incidence *inc = mCalendar->incidence( uid ); | 4558 | Incidence *inc = mCalendar->incidence( uid ); |
4489 | if ( inc ) | 4559 | if ( inc ) |
4490 | showIncidence( inc ); | 4560 | showIncidence( inc ); |
4491 | } | 4561 | } |
4492 | void CalendarView::showIncidence(Incidence *incidence) | 4562 | void CalendarView::showIncidence(Incidence *incidence) |
4493 | { | 4563 | { |
4494 | mViewerCallerIsSearchDialog = false; | 4564 | mViewerCallerIsSearchDialog = false; |
4495 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 4565 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
4496 | if ( sender() && mDialogManager->getSearchDialog() ) { | 4566 | if ( sender() && mDialogManager->getSearchDialog() ) { |
4497 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 4567 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
4498 | mViewerCallerIsSearchDialog = true; | 4568 | mViewerCallerIsSearchDialog = true; |
4499 | } | 4569 | } |
4500 | } | 4570 | } |
4501 | if ( incidence ) { | 4571 | if ( incidence ) { |
4502 | ShowIncidenceVisitor v; | 4572 | ShowIncidenceVisitor v; |
4503 | v.act( incidence, this ); | 4573 | v.act( incidence, this ); |
4504 | } | 4574 | } |
4505 | } | 4575 | } |
4506 | 4576 | ||
4507 | void CalendarView::editIncidence(Incidence *incidence) | 4577 | void CalendarView::editIncidence(Incidence *incidence) |
4508 | { | 4578 | { |
4509 | if ( incidence ) { | 4579 | if ( incidence ) { |
4510 | 4580 | ||
4511 | EditIncidenceVisitor v; | 4581 | EditIncidenceVisitor v; |
4512 | v.act( incidence, this ); | 4582 | v.act( incidence, this ); |
4513 | 4583 | ||
4514 | } | 4584 | } |
4515 | } | 4585 | } |
4516 | 4586 | ||
4517 | void CalendarView::deleteIncidence(Incidence *incidence) | 4587 | void CalendarView::deleteIncidence(Incidence *incidence) |
4518 | { | 4588 | { |
4519 | //qDebug(" CalendarView::deleteIncidence "); | 4589 | //qDebug(" CalendarView::deleteIncidence "); |
4520 | if ( incidence == 0 ) { | 4590 | if ( incidence == 0 ) { |
4521 | updateView(); | 4591 | updateView(); |
4522 | emit updateSearchDialog(); | 4592 | emit updateSearchDialog(); |
4523 | return; | 4593 | return; |
4524 | } | 4594 | } |
4525 | if ( incidence ) { | 4595 | if ( incidence ) { |
4526 | DeleteIncidenceVisitor v; | 4596 | DeleteIncidenceVisitor v; |
4527 | v.act( incidence, this ); | 4597 | v.act( incidence, this ); |
4528 | } | 4598 | } |
4529 | } | 4599 | } |
4530 | 4600 | ||
4531 | 4601 | ||
4532 | void CalendarView::lookForOutgoingMessages() | 4602 | void CalendarView::lookForOutgoingMessages() |
4533 | { | 4603 | { |
4534 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 4604 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
4535 | ogd->loadMessages(); | 4605 | ogd->loadMessages(); |
4536 | } | 4606 | } |
4537 | 4607 | ||
4538 | void CalendarView::lookForIncomingMessages() | 4608 | void CalendarView::lookForIncomingMessages() |
4539 | { | 4609 | { |
4540 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 4610 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
4541 | icd->retrieve(); | 4611 | icd->retrieve(); |
4542 | } | 4612 | } |
4543 | 4613 | ||
4544 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 4614 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
4545 | { | 4615 | { |
4546 | bool deleteTodo = true; | 4616 | bool deleteTodo = true; |
4547 | QPtrList<Incidence> subTodos; | 4617 | QPtrList<Incidence> subTodos; |
4548 | Incidence *aTodo; | 4618 | Incidence *aTodo; |
4549 | subTodos = t->relations(); | 4619 | subTodos = t->relations(); |
4550 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 4620 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
4551 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 4621 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
4552 | deleteTodo = false; | 4622 | deleteTodo = false; |
4553 | } | 4623 | } |
4554 | if ( deleteTodo ) { | 4624 | if ( deleteTodo ) { |
4555 | if ( t->isCompleted() && !t->doesRecur()) { | 4625 | if ( t->isCompleted() && !t->doesRecur()) { |
4556 | checkExternalId( t ); | 4626 | checkExternalId( t ); |
4557 | mCalendar->deleteTodo( t ); | 4627 | mCalendar->deleteTodo( t ); |
4558 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4628 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4559 | } | 4629 | } |
4560 | else | 4630 | else |
4561 | deleteTodo = false; | 4631 | deleteTodo = false; |
4562 | } | 4632 | } |
4563 | return deleteTodo; | 4633 | return deleteTodo; |
4564 | 4634 | ||
4565 | } | 4635 | } |
4566 | void CalendarView::purgeCompleted() | 4636 | void CalendarView::purgeCompleted() |
4567 | { | 4637 | { |
4568 | int result = KMessageBox::warningContinueCancel(this, | 4638 | int result = KMessageBox::warningContinueCancel(this, |
4569 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4639 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4570 | 4640 | ||
4571 | if (result == KMessageBox::Continue) { | 4641 | if (result == KMessageBox::Continue) { |
4572 | 4642 | ||
4573 | QPtrList<Todo> todoCal; | 4643 | QPtrList<Todo> todoCal; |
4574 | QPtrList<Todo> rootTodos; | 4644 | QPtrList<Todo> rootTodos; |
4575 | //QPtrList<Incidence> rel; | 4645 | //QPtrList<Incidence> rel; |
4576 | Todo *aTodo; | 4646 | Todo *aTodo; |
4577 | todoCal = calendar()->todos(); | 4647 | todoCal = calendar()->todos(); |
4578 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4648 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4579 | if ( !aTodo->relatedTo() ) | 4649 | if ( !aTodo->relatedTo() ) |
4580 | rootTodos.append( aTodo ); | 4650 | rootTodos.append( aTodo ); |
4581 | } | 4651 | } |
4582 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4652 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4583 | removeCompletedSubTodos( aTodo ); | 4653 | removeCompletedSubTodos( aTodo ); |
4584 | } | 4654 | } |
4585 | 4655 | ||
4586 | updateView(); | 4656 | updateView(); |
4587 | } | 4657 | } |
4588 | } | 4658 | } |
4589 | 4659 | ||
4590 | void CalendarView::slotCalendarChanged() | 4660 | void CalendarView::slotCalendarChanged() |
4591 | { | 4661 | { |
4592 | ; | 4662 | ; |
4593 | } | 4663 | } |
4594 | 4664 | ||
4595 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4665 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4596 | { | 4666 | { |
4597 | //qDebug(" alendarView::keyPressEvent "); | 4667 | //qDebug(" alendarView::keyPressEvent "); |
4598 | e->ignore(); | 4668 | e->ignore(); |
4599 | } | 4669 | } |
4600 | 4670 | ||
4601 | 4671 | ||
4602 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4672 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4603 | { | 4673 | { |
4604 | 4674 | ||
4605 | if ( manager != mSyncManager) | 4675 | if ( manager != mSyncManager) |
4606 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 4676 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
4607 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4677 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4608 | qDebug("KO: SyncKDE request detected!"); | 4678 | qDebug("KO: SyncKDE request detected!"); |
4609 | } | 4679 | } |
4610 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4680 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4611 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4681 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4612 | return syncCalendar( filename, mode ); | 4682 | return syncCalendar( filename, mode ); |
4613 | } | 4683 | } |
4614 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4684 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4615 | { | 4685 | { |
4616 | //mSyncManager = manager; | 4686 | //mSyncManager = manager; |
4617 | if ( manager != mSyncManager) | 4687 | if ( manager != mSyncManager) |
4618 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 4688 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
4619 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4689 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4620 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4690 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4621 | if ( resource == "sharp" ) | 4691 | if ( resource == "sharp" ) |
4622 | syncExternal( 0 ); | 4692 | syncExternal( 0 ); |
4623 | if ( resource == "phone" ) | 4693 | if ( resource == "phone" ) |
4624 | syncExternal( 1 ); | 4694 | syncExternal( 1 ); |
4625 | // pending setmodified | 4695 | // pending setmodified |
4626 | return true; | 4696 | return true; |
4627 | } | 4697 | } |
4628 | void CalendarView::setSyncManager(KSyncManager* manager) | 4698 | void CalendarView::setSyncManager(KSyncManager* manager) |
4629 | { | 4699 | { |
4630 | mSyncManager = manager; | 4700 | mSyncManager = manager; |
4631 | } | 4701 | } |
4632 | 4702 | ||
4633 | void CalendarView::removeSyncInfo( QString syncProfile) | 4703 | void CalendarView::removeSyncInfo( QString syncProfile) |
4634 | { | 4704 | { |
4635 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4705 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4636 | mCalendar->removeSyncInfo( syncProfile ); | 4706 | mCalendar->removeSyncInfo( syncProfile ); |
4637 | 4707 | ||
4638 | } | 4708 | } |
4639 | 4709 | ||
4640 | void CalendarView::undo_delete() | 4710 | void CalendarView::undo_delete() |
4641 | { | 4711 | { |
4642 | //qDebug("undo_delete() "); | 4712 | //qDebug("undo_delete() "); |
4643 | Incidence* undo = mCalendar->undoIncidence(); | 4713 | Incidence* undo = mCalendar->undoIncidence(); |
4644 | if ( !undo ) { | 4714 | if ( !undo ) { |
4645 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4715 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4646 | i18n("KO/Pi")); | 4716 | i18n("KO/Pi")); |
4647 | return; | 4717 | return; |
4648 | } | 4718 | } |
4649 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + | 4719 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
4650 | i18n("\nAre you sure you want\nto restore this?"), | 4720 | i18n("\nAre you sure you want\nto restore this?"), |
4651 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4721 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4652 | mCalendar->undoDeleteIncidence(); | 4722 | mCalendar->undoDeleteIncidence(); |
4653 | updateView(); | 4723 | updateView(); |
4654 | } | 4724 | } |
4655 | } | 4725 | } |
4656 | 4726 | ||
4657 | void CalendarView::slotViewerClosed() | 4727 | void CalendarView::slotViewerClosed() |
4658 | { | 4728 | { |
4659 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4729 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4660 | } | 4730 | } |
4661 | 4731 | ||
4662 | void CalendarView::resetFocus() | 4732 | void CalendarView::resetFocus() |
4663 | { | 4733 | { |
4664 | if ( mViewerCallerIsSearchDialog ) { | 4734 | if ( mViewerCallerIsSearchDialog ) { |
4665 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4735 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4666 | mDialogManager->getSearchDialog()->raise(); | 4736 | mDialogManager->getSearchDialog()->raise(); |
4667 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4737 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4668 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4738 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4669 | } else | 4739 | } else |
4670 | mViewerCallerIsSearchDialog = false; | 4740 | mViewerCallerIsSearchDialog = false; |
4671 | } | 4741 | } |
4672 | if ( !mViewerCallerIsSearchDialog ) { | 4742 | if ( !mViewerCallerIsSearchDialog ) { |
4673 | //mViewManager->currentView()->setFocus(); | 4743 | //mViewManager->currentView()->setFocus(); |
4674 | //qDebug("sssssssssssssssset focus "); | 4744 | //qDebug("sssssssssssssssset focus "); |
4675 | topLevelWidget()->raise(); | 4745 | topLevelWidget()->raise(); |
4676 | setActiveWindow(); | 4746 | setActiveWindow(); |
4677 | //setFocus(); | 4747 | //setFocus(); |
4678 | } | 4748 | } |
4679 | mViewerCallerIsSearchDialog = false; | 4749 | mViewerCallerIsSearchDialog = false; |
4680 | } | 4750 | } |
4681 | 4751 | ||
4682 | void CalendarView::showNextAlarms() | 4752 | void CalendarView::showNextAlarms() |
4683 | { | 4753 | { |
4684 | QString message; | 4754 | QString message; |
4685 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4755 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4686 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4756 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4687 | QString sum = mCalendar->nextSummary(); | 4757 | QString sum = mCalendar->nextSummary(); |
4688 | QDateTime nextA = mNextAlarmDateTime; | 4758 | QDateTime nextA = mNextAlarmDateTime; |
4689 | QDateTime cur = QDateTime::currentDateTime(); | 4759 | QDateTime cur = QDateTime::currentDateTime(); |
4690 | int secs = cur.secsTo( nextA ); | 4760 | int secs = cur.secsTo( nextA ); |
4691 | int min = secs /60; | 4761 | int min = secs /60; |
4692 | int hours = min /60; | 4762 | int hours = min /60; |
4693 | min = min % 60; | 4763 | min = min % 60; |
4694 | int days = hours /24; | 4764 | int days = hours /24; |
4695 | hours = hours % 24; | 4765 | hours = hours % 24; |
4696 | 4766 | ||
4697 | //message = i18n("The next alarm is in:\n"); | 4767 | //message = i18n("The next alarm is in:\n"); |
4698 | if ( days > 1 ) | 4768 | if ( days > 1 ) |
4699 | message += i18n("%1 days\n").arg( days ); | 4769 | message += i18n("%1 days\n").arg( days ); |
4700 | else if ( days == 1 ) | 4770 | else if ( days == 1 ) |
4701 | message += i18n("1 day\n"); | 4771 | message += i18n("1 day\n"); |
4702 | if ( hours > 1 ) | 4772 | if ( hours > 1 ) |
4703 | message += i18n("%1 hours\n").arg( hours ); | 4773 | message += i18n("%1 hours\n").arg( hours ); |
4704 | else if ( hours == 1 ) | 4774 | else if ( hours == 1 ) |
4705 | message += i18n("1 hour\n"); | 4775 | message += i18n("1 hour\n"); |
4706 | if ( min > 1 ) | 4776 | if ( min > 1 ) |
4707 | message += i18n("%1 minutes\n").arg( min ); | 4777 | message += i18n("%1 minutes\n").arg( min ); |
4708 | else if ( min == 1 ) | 4778 | else if ( min == 1 ) |
4709 | message += i18n("1 minute\n"); | 4779 | message += i18n("1 minute\n"); |
4710 | if ( message.isEmpty() ) | 4780 | if ( message.isEmpty() ) |
4711 | message = i18n("The next alarm is in\nless than one minute!"); | 4781 | message = i18n("The next alarm is in\nless than one minute!"); |
4712 | else | 4782 | else |
4713 | message = i18n("The next alarm is in:\n") + message; | 4783 | message = i18n("The next alarm is in:\n") + message; |
4714 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4784 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4715 | } else { | 4785 | } else { |
4716 | message = i18n("There is no next alarm."); | 4786 | message = i18n("There is no next alarm."); |
4717 | 4787 | ||
4718 | } | 4788 | } |
4719 | #ifdef DESKTOP_VERSION | 4789 | #ifdef DESKTOP_VERSION |
4720 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4790 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4721 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4791 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4722 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4792 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4723 | } | 4793 | } |
4724 | 4794 | ||
4725 | #endif | 4795 | #endif |
4726 | KMessageBox::information( this, message); | 4796 | KMessageBox::information( this, message); |
4727 | } | 4797 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 51eb1d4..706d05d 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,664 +1,666 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #include <qscrollbar.h> | 33 | #include <qscrollbar.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qtopia/ir.h> | 35 | #include <qtopia/ir.h> |
36 | #else | 36 | #else |
37 | #define Ir char | 37 | #define Ir char |
38 | #endif | 38 | #endif |
39 | #include <libkcal/calendar.h> | 39 | #include <libkcal/calendar.h> |
40 | #include <libkcal/scheduler.h> | 40 | #include <libkcal/scheduler.h> |
41 | #include <libkcal/calendarresources.h> | 41 | #include <libkcal/calendarresources.h> |
42 | #include <libkcal/resourcecalendar.h> | 42 | #include <libkcal/resourcecalendar.h> |
43 | #include <KDGanttMinimizeSplitter.h> | 43 | #include <KDGanttMinimizeSplitter.h> |
44 | 44 | ||
45 | #include <korganizer/calendarviewbase.h> | 45 | #include <korganizer/calendarviewbase.h> |
46 | 46 | ||
47 | #include <ksyncmanager.h> | 47 | #include <ksyncmanager.h> |
48 | //#include <koprefs.h> | 48 | //#include <koprefs.h> |
49 | 49 | ||
50 | class QWidgetStack; | 50 | class QWidgetStack; |
51 | class QSplitter; | 51 | class QSplitter; |
52 | class KopiCalendarFile; | 52 | class KopiCalendarFile; |
53 | class CalPrinter; | 53 | class CalPrinter; |
54 | class KOFilterView; | 54 | class KOFilterView; |
55 | class KOCalEditView; | 55 | class KOCalEditView; |
56 | class KOViewManager; | 56 | class KOViewManager; |
57 | class KODialogManager; | 57 | class KODialogManager; |
58 | class KOTodoView; | 58 | class KOTodoView; |
59 | class KDateNavigator; | 59 | class KDateNavigator; |
60 | class DateNavigatorContainer; | 60 | class DateNavigatorContainer; |
61 | class DateNavigator; | 61 | class DateNavigator; |
62 | class KOIncidenceEditor; | 62 | class KOIncidenceEditor; |
63 | class KDatePicker; | 63 | class KDatePicker; |
64 | class ResourceView; | 64 | class ResourceView; |
65 | class KOEventEditor; | 65 | class KOEventEditor; |
66 | class KOTodoEditor ; | 66 | class KOTodoEditor ; |
67 | class KOEventViewerDialog; | 67 | class KOEventViewerDialog; |
68 | class KOBeamPrefs; | 68 | class KOBeamPrefs; |
69 | class KSyncProfile; | 69 | class KSyncProfile; |
70 | class AlarmDialog; | 70 | class AlarmDialog; |
71 | class KCal::Attendee; | 71 | class KCal::Attendee; |
72 | 72 | ||
73 | namespace KCal { class FileStorage; } | 73 | namespace KCal { class FileStorage; } |
74 | 74 | ||
75 | using namespace KCal; | 75 | using namespace KCal; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | This is the main calendar widget. It provides the different vies on t he | 78 | This is the main calendar widget. It provides the different vies on t he |
79 | calendar data as well as the date navigator. It also handles synchronisation | 79 | calendar data as well as the date navigator. It also handles synchronisation |
80 | of the different views and controls the different dialogs like preferences, | 80 | of the different views and controls the different dialogs like preferences, |
81 | event editor, search dialog etc. | 81 | event editor, search dialog etc. |
82 | 82 | ||
83 | @short main calendar view widget | 83 | @short main calendar view widget |
84 | @author Cornelius Schumacher | 84 | @author Cornelius Schumacher |
85 | */ | 85 | */ |
86 | 86 | ||
87 | #include <qtextbrowser.h> | 87 | #include <qtextbrowser.h> |
88 | #include <qtextcodec.h> | 88 | #include <qtextcodec.h> |
89 | 89 | ||
90 | class MissedAlarmTextBrowser : public QTextBrowser { | 90 | class MissedAlarmTextBrowser : public QTextBrowser { |
91 | Q_OBJECT | 91 | Q_OBJECT |
92 | public: | 92 | public: |
93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); | 93 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); |
94 | ~MissedAlarmTextBrowser(); | 94 | ~MissedAlarmTextBrowser(); |
95 | void setSource(const QString & n); | 95 | void setSource(const QString & n); |
96 | 96 | ||
97 | private: | 97 | private: |
98 | Incidence * getNextInc(QDateTime start ); | 98 | Incidence * getNextInc(QDateTime start ); |
99 | QPtrList<Incidence> mAlarms; | 99 | QPtrList<Incidence> mAlarms; |
100 | signals: | 100 | signals: |
101 | void showIncidence( QString uid); | 101 | void showIncidence( QString uid); |
102 | }; | 102 | }; |
103 | 103 | ||
104 | 104 | ||
105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
106 | { | 106 | { |
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | public: | 108 | public: |
109 | /** | 109 | /** |
110 | Constructs a new calendar view widget. | 110 | Constructs a new calendar view widget. |
111 | 111 | ||
112 | @param calendar calendar document | 112 | @param calendar calendar document |
113 | @param parent parent window | 113 | @param parent parent window |
114 | @param name Qt internal widget object name | 114 | @param name Qt internal widget object name |
115 | */ | 115 | */ |
116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
117 | const char *name = 0 ); | 117 | const char *name = 0 ); |
118 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 118 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
119 | const char *name = 0 ); | 119 | const char *name = 0 ); |
120 | virtual ~CalendarView(); | 120 | virtual ~CalendarView(); |
121 | 121 | ||
122 | Calendar *calendar() { return mCalendar; } | 122 | Calendar *calendar() { return mCalendar; } |
123 | 123 | ||
124 | KOViewManager *viewManager(); | 124 | KOViewManager *viewManager(); |
125 | KODialogManager *dialogManager(); | 125 | KODialogManager *dialogManager(); |
126 | 126 | ||
127 | QDate startDate(); | 127 | QDate startDate(); |
128 | QDate endDate(); | 128 | QDate endDate(); |
129 | 129 | ||
130 | QWidgetStack *viewStack(); | 130 | QWidgetStack *viewStack(); |
131 | QWidget *leftFrame(); | 131 | QWidget *leftFrame(); |
132 | 132 | ||
133 | DateNavigator *dateNavigator(); | 133 | DateNavigator *dateNavigator(); |
134 | KDateNavigator *dateNavigatorWidget(); | 134 | KDateNavigator *dateNavigatorWidget(); |
135 | 135 | ||
136 | void addView(KOrg::BaseView *); | 136 | void addView(KOrg::BaseView *); |
137 | void showView(KOrg::BaseView *); | 137 | void showView(KOrg::BaseView *); |
138 | KOEventViewerDialog* getEventViewerDialog(); | 138 | KOEventViewerDialog* getEventViewerDialog(); |
139 | Incidence *currentSelection(); | 139 | Incidence *currentSelection(); |
140 | void checkSuspendAlarm(); | 140 | void checkSuspendAlarm(); |
141 | 141 | ||
142 | signals: | 142 | signals: |
143 | void save (); | 143 | void save (); |
144 | void saveStopTimer (); | 144 | void saveStopTimer (); |
145 | void tempDisableBR(bool); | 145 | void tempDisableBR(bool); |
146 | /** This todo has been modified */ | 146 | /** This todo has been modified */ |
147 | void todoModified(Todo *, int); | 147 | void todoModified(Todo *, int); |
148 | 148 | ||
149 | /** when change is made to options dialog, the topwidget will catch this | 149 | /** when change is made to options dialog, the topwidget will catch this |
150 | * and emit this signal which notifies all widgets which have registered | 150 | * and emit this signal which notifies all widgets which have registered |
151 | * for notification to update their settings. */ | 151 | * for notification to update their settings. */ |
152 | void configChanged(); | 152 | void configChanged(); |
153 | /** emitted when the topwidget is closing down, so that any attached | 153 | /** emitted when the topwidget is closing down, so that any attached |
154 | child windows can also close. */ | 154 | child windows can also close. */ |
155 | void closingDown(); | 155 | void closingDown(); |
156 | /** emitted right before we die */ | 156 | /** emitted right before we die */ |
157 | void closed(QWidget *); | 157 | void closed(QWidget *); |
158 | 158 | ||
159 | /** Emitted when state of modified flag changes */ | 159 | /** Emitted when state of modified flag changes */ |
160 | void modifiedChanged(bool); | 160 | void modifiedChanged(bool); |
161 | void signalmodified(); | 161 | void signalmodified(); |
162 | 162 | ||
163 | /** Emitted when state of read-only flag changes */ | 163 | /** Emitted when state of read-only flag changes */ |
164 | void readOnlyChanged(bool); | 164 | void readOnlyChanged(bool); |
165 | 165 | ||
166 | /** Emitted when the unit of navigation changes */ | 166 | /** Emitted when the unit of navigation changes */ |
167 | void changeNavStringPrev(const QString &); | 167 | void changeNavStringPrev(const QString &); |
168 | void changeNavStringNext(const QString &); | 168 | void changeNavStringNext(const QString &); |
169 | 169 | ||
170 | /** Emitted when state of events selection has changed and user is organizer*/ | 170 | /** Emitted when state of events selection has changed and user is organizer*/ |
171 | void organizerEventsSelected(bool); | 171 | void organizerEventsSelected(bool); |
172 | /** Emitted when state of events selection has changed and user is attendee*/ | 172 | /** Emitted when state of events selection has changed and user is attendee*/ |
173 | void groupEventsSelected(bool); | 173 | void groupEventsSelected(bool); |
174 | /** | 174 | /** |
175 | Emitted when an incidence gets selected. If the selection is cleared the | 175 | Emitted when an incidence gets selected. If the selection is cleared the |
176 | signal is emitted with 0 as argument. | 176 | signal is emitted with 0 as argument. |
177 | */ | 177 | */ |
178 | void incidenceSelected( Incidence * ); | 178 | void incidenceSelected( Incidence * ); |
179 | /** Emitted, when a todoitem is selected or deselected. */ | 179 | /** Emitted, when a todoitem is selected or deselected. */ |
180 | void todoSelected( bool ); | 180 | void todoSelected( bool ); |
181 | 181 | ||
182 | /** | 182 | /** |
183 | Emitted, when clipboard content changes. Parameter indicates if paste | 183 | Emitted, when clipboard content changes. Parameter indicates if paste |
184 | is possible or not. | 184 | is possible or not. |
185 | */ | 185 | */ |
186 | void pasteEnabled(bool); | 186 | void pasteEnabled(bool); |
187 | 187 | ||
188 | /** Emitted, when the number of incoming messages has changed. */ | 188 | /** Emitted, when the number of incoming messages has changed. */ |
189 | void numIncomingChanged(int); | 189 | void numIncomingChanged(int); |
190 | 190 | ||
191 | /** Emitted, when the number of outgoing messages has changed. */ | 191 | /** Emitted, when the number of outgoing messages has changed. */ |
192 | void numOutgoingChanged(int); | 192 | void numOutgoingChanged(int); |
193 | 193 | ||
194 | /** Send status message, which can e.g. be displayed in the status bar. */ | 194 | /** Send status message, which can e.g. be displayed in the status bar. */ |
195 | void statusMessage(const QString &); | 195 | void statusMessage(const QString &); |
196 | 196 | ||
197 | void calendarViewExpanded( bool ); | 197 | void calendarViewExpanded( bool ); |
198 | void updateSearchDialog(); | 198 | void updateSearchDialog(); |
199 | void filtersUpdated(); | 199 | void filtersUpdated(); |
200 | 200 | ||
201 | 201 | ||
202 | public slots: | 202 | public slots: |
203 | void nextConflict( bool all, bool allday ); | 203 | void nextConflict( bool all, bool allday ); |
204 | void conflictAll(); | 204 | void conflictAll(); |
205 | void conflictAllday(); | 205 | void conflictAllday(); |
206 | void conflictNotAll(); | 206 | void conflictNotAll(); |
207 | void setCalReadOnly( int id, bool readO ); | 207 | void setCalReadOnly( int id, bool readO ); |
208 | void checkAlarms(); | 208 | void checkAlarms(); |
209 | void checkFiles(); | 209 | void checkFiles(); |
210 | void slotprintSelInc(); | 210 | void slotprintSelInc(); |
211 | void showNextAlarms(); | 211 | void showNextAlarms(); |
212 | void showOpenError(); | 212 | void showOpenError(); |
213 | void watchSavedFile(); | 213 | void watchSavedFile(); |
214 | void recheckTimerAlarm(); | 214 | void recheckTimerAlarm(); |
215 | void checkNextTimerAlarm(); | 215 | void checkNextTimerAlarm(); |
216 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 216 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
217 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 217 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
218 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 218 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
219 | 219 | ||
220 | /** options dialog made a changed to the configuration. we catch this | 220 | /** options dialog made a changed to the configuration. we catch this |
221 | * and notify all widgets which need to update their configuration. */ | 221 | * and notify all widgets which need to update their configuration. */ |
222 | void updateConfig(); | 222 | void updateConfig(); |
223 | 223 | ||
224 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 224 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
225 | const QStringList& anniversaryList, const QStringList& realNameList, | 225 | const QStringList& anniversaryList, const QStringList& realNameList, |
226 | const QStringList& emailList, const QStringList& assembledNameList, | 226 | const QStringList& emailList, const QStringList& assembledNameList, |
227 | const QStringList& uidList); | 227 | const QStringList& uidList); |
228 | 228 | ||
229 | /** | 229 | /** |
230 | Load calendar from file \a filename. If \a merge is true, load | 230 | Load calendar from file \a filename. If \a merge is true, load |
231 | calendar into existing one, if it is false, clear calendar, before | 231 | calendar into existing one, if it is false, clear calendar, before |
232 | loading. Return true, if calendar could be successfully loaded. | 232 | loading. Return true, if calendar could be successfully loaded. |
233 | */ | 233 | */ |
234 | bool openCalendar(QString filename, bool merge=false); | 234 | bool openCalendar(QString filename, bool merge=false); |
235 | bool loadCalendars(); | 235 | bool loadCalendars(); |
236 | bool saveCalendars(); | 236 | bool saveCalendars(); |
237 | bool restoreCalendarSettings(); | 237 | bool restoreCalendarSettings(); |
238 | bool addCalendar( KopiCalendarFile * ); | 238 | bool addCalendar( KopiCalendarFile * ); |
239 | void addCalendarId( int id ); | 239 | void addCalendarId( int id ); |
240 | bool syncCalendar(QString filename,int mode = 0 ); | 240 | bool syncCalendar(QString filename,int mode = 0 ); |
241 | 241 | ||
242 | /** | 242 | /** |
243 | Save calendar data to file. Return true if calendar could be | 243 | Save calendar data to file. Return true if calendar could be |
244 | successfully saved. | 244 | successfully saved. |
245 | */ | 245 | */ |
246 | bool saveCalendar(QString filename); | 246 | bool saveCalendar(QString filename); |
247 | 247 | ||
248 | /** | 248 | /** |
249 | Close calendar. Clear calendar data and reset views to display an empty | 249 | Close calendar. Clear calendar data and reset views to display an empty |
250 | calendar. | 250 | calendar. |
251 | */ | 251 | */ |
252 | void closeCalendar(); | 252 | void closeCalendar(); |
253 | 253 | ||
254 | /** Archive old events of calendar */ | 254 | /** Archive old events of calendar */ |
255 | void archiveCalendar(); | 255 | void archiveCalendar(); |
256 | 256 | ||
257 | void showIncidence(); | 257 | void showIncidence(); |
258 | void editIncidence(); | 258 | void editIncidence(); |
259 | void editIncidenceDescription(); | 259 | void editIncidenceDescription(); |
260 | void deleteIncidence(); | 260 | void deleteIncidence(); |
261 | void cloneIncidence(); | 261 | void cloneIncidence(); |
262 | void moveIncidence(); | 262 | void moveIncidence(); |
263 | void beamIncidence(); | 263 | void beamIncidence(); |
264 | void toggleCancelIncidence(); | 264 | void toggleCancelIncidence(); |
265 | 265 | ||
266 | /** create an editeventwin with supplied date/time, and if bool is true, | 266 | /** create an editeventwin with supplied date/time, and if bool is true, |
267 | * make the event take all day. */ | 267 | * make the event take all day. */ |
268 | void newEvent(QDateTime, QDateTime, bool allDay ); | 268 | void newEvent(QDateTime, QDateTime, bool allDay ); |
269 | void newEvent(QDateTime, QDateTime); | 269 | void newEvent(QDateTime, QDateTime); |
270 | void newEvent(QDateTime fh); | 270 | void newEvent(QDateTime fh); |
271 | void newEvent(QDate dt); | 271 | void newEvent(QDate dt); |
272 | /** create new event without having a date hint. Takes current date as | 272 | /** create new event without having a date hint. Takes current date as |
273 | default hint. */ | 273 | default hint. */ |
274 | void newEvent(); | 274 | void newEvent(); |
275 | void newFloatingEvent(); | 275 | void newFloatingEvent(); |
276 | 276 | ||
277 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 277 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
278 | void showIncidence(Incidence *); | 278 | void showIncidence(Incidence *); |
279 | void showIncidence(QString uid); | 279 | void showIncidence(QString uid); |
280 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 280 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
281 | void editIncidence(Incidence *); | 281 | void editIncidence(Incidence *); |
282 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 282 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
283 | void deleteIncidence(Incidence *); | 283 | void deleteIncidence(Incidence *); |
284 | void cloneIncidence(Incidence *); | 284 | void cloneIncidence(Incidence *); |
285 | void cancelIncidence(Incidence *); | 285 | void cancelIncidence(Incidence *); |
286 | /** Create an editor for the supplied event. */ | 286 | /** Create an editor for the supplied event. */ |
287 | void editEvent(Event *); | 287 | void editEvent(Event *); |
288 | /** Delete the supplied event. */ | 288 | /** Delete the supplied event. */ |
289 | void deleteEvent(Event *); | 289 | void deleteEvent(Event *); |
290 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 290 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
291 | found. */ | 291 | found. */ |
292 | bool deleteEvent(const QString &uid); | 292 | bool deleteEvent(const QString &uid); |
293 | /** Create a read-only viewer dialog for the supplied event. */ | 293 | /** Create a read-only viewer dialog for the supplied event. */ |
294 | void showEvent(Event *); | 294 | void showEvent(Event *); |
295 | 295 | ||
296 | void editJournal(Journal *); | 296 | void editJournal(Journal *); |
297 | void showJournal(Journal *); | 297 | void showJournal(Journal *); |
298 | void deleteJournal(Journal *); | 298 | void deleteJournal(Journal *); |
299 | /** Create an editor dialog for a todo */ | 299 | /** Create an editor dialog for a todo */ |
300 | void editTodo(Todo *); | 300 | void editTodo(Todo *); |
301 | /** Create a read-only viewer dialog for the supplied todo */ | 301 | /** Create a read-only viewer dialog for the supplied todo */ |
302 | void showTodo(Todo *); | 302 | void showTodo(Todo *); |
303 | /** create new todo */ | 303 | /** create new todo */ |
304 | void newTodo(); | 304 | void newTodo(); |
305 | void newTodoDateTime(QDateTime, bool allday); | 305 | void newTodoDateTime(QDateTime, bool allday); |
306 | /** create new todo with a parent todo */ | 306 | /** create new todo with a parent todo */ |
307 | void newSubTodo(); | 307 | void newSubTodo(); |
308 | /** create new todo with a parent todo */ | 308 | /** create new todo with a parent todo */ |
309 | void newSubTodo(Todo *); | 309 | void newSubTodo(Todo *); |
310 | /** Delete todo */ | 310 | /** Delete todo */ |
311 | void deleteTodo(Todo *); | 311 | void deleteTodo(Todo *); |
312 | 312 | ||
313 | 313 | ||
314 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 314 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
315 | * emitted as result. */ | 315 | * emitted as result. */ |
316 | void checkClipboard(); | 316 | void checkClipboard(); |
317 | 317 | ||
318 | /** using the KConfig associated with the kapp variable, read in the | 318 | /** using the KConfig associated with the kapp variable, read in the |
319 | * settings from the config file. | 319 | * settings from the config file. |
320 | */ | 320 | */ |
321 | void readSettings(); | 321 | void readSettings(); |
322 | 322 | ||
323 | /** write current state to config file. */ | 323 | /** write current state to config file. */ |
324 | void writeSettings(); | 324 | void writeSettings(); |
325 | 325 | ||
326 | /** read settings for calendar filters */ | 326 | /** read settings for calendar filters */ |
327 | void readFilterSettings(KConfig *config); | 327 | void readFilterSettings(KConfig *config); |
328 | 328 | ||
329 | /** write settings for calendar filters */ | 329 | /** write settings for calendar filters */ |
330 | void writeFilterSettings(KConfig *config); | 330 | void writeFilterSettings(KConfig *config); |
331 | 331 | ||
332 | /** passes on the message that an event has changed to the currently | 332 | /** passes on the message that an event has changed to the currently |
333 | * activated view so that it can make appropriate display changes. */ | 333 | * activated view so that it can make appropriate display changes. */ |
334 | void changeEventDisplay(Event *, int); | 334 | void changeEventDisplay(Event *, int); |
335 | void changeIncidenceDisplay(Incidence *, int); | 335 | void changeIncidenceDisplay(Incidence *, int); |
336 | void changeTodoDisplay(Todo *, int); | 336 | void changeTodoDisplay(Todo *, int); |
337 | 337 | ||
338 | void eventAdded(Event *); | 338 | void eventAdded(Event *); |
339 | void eventChanged(Event *); | 339 | void eventChanged(Event *); |
340 | void eventToBeDeleted(Event *); | 340 | void eventToBeDeleted(Event *); |
341 | void eventDeleted(); | 341 | void eventDeleted(); |
342 | 342 | ||
343 | void todoAdded(Todo *); | 343 | void todoAdded(Todo *); |
344 | void todoChanged(Todo *); | 344 | void todoChanged(Todo *); |
345 | void todoToBeDeleted(Todo *); | 345 | void todoToBeDeleted(Todo *); |
346 | void todoDeleted(); | 346 | void todoDeleted(); |
347 | 347 | ||
348 | void updateView(const QDate &start, const QDate &end); | 348 | void updateView(const QDate &start, const QDate &end); |
349 | void updateView(); | 349 | void updateView(); |
350 | void clearAllViews(); | 350 | void clearAllViews(); |
351 | 351 | ||
352 | /** Full update of visible todo views */ | 352 | /** Full update of visible todo views */ |
353 | void updateTodoViews(); | 353 | void updateTodoViews(); |
354 | 354 | ||
355 | void updateUnmanagedViews(); | 355 | void updateUnmanagedViews(); |
356 | 356 | ||
357 | /** cut the current appointment to the clipboard */ | 357 | /** cut the current appointment to the clipboard */ |
358 | void edit_cut(); | 358 | void edit_cut(); |
359 | 359 | ||
360 | /** copy the current appointment(s) to the clipboard */ | 360 | /** copy the current appointment(s) to the clipboard */ |
361 | void edit_copy(); | 361 | void edit_copy(); |
362 | 362 | ||
363 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 363 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
364 | void edit_paste(); | 364 | void edit_paste(); |
365 | 365 | ||
366 | /** edit viewing and configuration options. */ | 366 | /** edit viewing and configuration options. */ |
367 | void edit_options(); | 367 | void edit_options(); |
368 | void edit_global_options(); | 368 | void edit_global_options(); |
369 | /** | 369 | /** |
370 | Functions for printing, previewing a print, and setting up printing | 370 | Functions for printing, previewing a print, and setting up printing |
371 | parameters. | 371 | parameters. |
372 | */ | 372 | */ |
373 | void print(); | 373 | void print(); |
374 | void printSetup(); | 374 | void printSetup(); |
375 | void printPreview(); | 375 | void printPreview(); |
376 | 376 | ||
377 | /** Export as iCalendar file */ | 377 | /** Export as iCalendar file */ |
378 | void exportICalendar(); | 378 | void exportICalendar(); |
379 | 379 | ||
380 | /** Export as vCalendar file */ | 380 | /** Export as vCalendar file */ |
381 | bool exportVCalendar( QString fn); | 381 | bool exportVCalendar( QString fn); |
382 | 382 | ||
383 | /** pop up a dialog to show an existing appointment. */ | 383 | /** pop up a dialog to show an existing appointment. */ |
384 | void appointment_show(); | 384 | void appointment_show(); |
385 | /** | 385 | /** |
386 | * pop up an Appointment Dialog to edit an existing appointment.Get | 386 | * pop up an Appointment Dialog to edit an existing appointment.Get |
387 | * information on the appointment from the list of unique IDs that is | 387 | * information on the appointment from the list of unique IDs that is |
388 | * currently in the View, called currIds. | 388 | * currently in the View, called currIds. |
389 | */ | 389 | */ |
390 | void appointment_edit(); | 390 | void appointment_edit(); |
391 | /** | 391 | /** |
392 | * pop up dialog confirming deletion of currently selected event in the | 392 | * pop up dialog confirming deletion of currently selected event in the |
393 | * View. | 393 | * View. |
394 | */ | 394 | */ |
395 | void appointment_delete(); | 395 | void appointment_delete(); |
396 | 396 | ||
397 | /** mails the currently selected event to a particular user as a vCalendar | 397 | /** mails the currently selected event to a particular user as a vCalendar |
398 | attachment. */ | 398 | attachment. */ |
399 | void action_mail(); | 399 | void action_mail(); |
400 | 400 | ||
401 | /* frees a subtodo from it's relation */ | 401 | /* frees a subtodo from it's relation */ |
402 | void todo_unsub( Todo * ); | 402 | void todo_unsub( Todo * ); |
403 | void todo_resub( Todo * parent, Todo * sub ); | 403 | void todo_resub( Todo * parent, Todo * sub ); |
404 | 404 | ||
405 | /** Take ownership of selected event. */ | 405 | /** Take ownership of selected event. */ |
406 | void takeOverEvent(); | 406 | void takeOverEvent(); |
407 | 407 | ||
408 | /** Take ownership of all events in calendar. */ | 408 | /** Take ownership of all events in calendar. */ |
409 | void takeOverCalendar(); | 409 | void takeOverCalendar(); |
410 | 410 | ||
411 | /** query whether or not the calendar is "dirty". */ | 411 | /** query whether or not the calendar is "dirty". */ |
412 | bool isModified(); | 412 | bool isModified(); |
413 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 413 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
414 | void setModified(bool modified=true); | 414 | void setModified(bool modified=true); |
415 | 415 | ||
416 | /** query if the calendar is read-only. */ | 416 | /** query if the calendar is read-only. */ |
417 | bool isReadOnly(); | 417 | bool isReadOnly(); |
418 | /** set state of calendar to read-only */ | 418 | /** set state of calendar to read-only */ |
419 | void setReadOnly(bool readOnly=true); | 419 | void setReadOnly(bool readOnly=true); |
420 | 420 | ||
421 | void eventUpdated(Incidence *); | 421 | void eventUpdated(Incidence *); |
422 | 422 | ||
423 | /* iTIP scheduling actions */ | 423 | /* iTIP scheduling actions */ |
424 | void schedule_publish(Incidence *incidence = 0); | 424 | void schedule_publish(Incidence *incidence = 0); |
425 | void schedule_request(Incidence *incidence = 0); | 425 | void schedule_request(Incidence *incidence = 0); |
426 | void schedule_refresh(Incidence *incidence = 0); | 426 | void schedule_refresh(Incidence *incidence = 0); |
427 | void schedule_cancel(Incidence *incidence = 0); | 427 | void schedule_cancel(Incidence *incidence = 0); |
428 | void schedule_add(Incidence *incidence = 0); | 428 | void schedule_add(Incidence *incidence = 0); |
429 | void schedule_reply(Incidence *incidence = 0); | 429 | void schedule_reply(Incidence *incidence = 0); |
430 | void schedule_counter(Incidence *incidence = 0); | 430 | void schedule_counter(Incidence *incidence = 0); |
431 | void schedule_declinecounter(Incidence *incidence = 0); | 431 | void schedule_declinecounter(Incidence *incidence = 0); |
432 | void schedule_publish_freebusy(int daysToPublish = 30); | 432 | void schedule_publish_freebusy(int daysToPublish = 30); |
433 | 433 | ||
434 | void openAddressbook(); | 434 | void openAddressbook(); |
435 | 435 | ||
436 | void editFilters(); | 436 | void editFilters(); |
437 | void toggleFilerEnabled(); | 437 | void toggleFilerEnabled(); |
438 | QPtrList<CalFilter> filters(); | 438 | QPtrList<CalFilter> filters(); |
439 | void toggleFilter(); | 439 | void toggleFilter(); |
440 | void showFilter(bool visible); | 440 | void showFilter(bool visible); |
441 | void updateFilter(); | 441 | void updateFilter(); |
442 | void filterEdited(); | 442 | void filterEdited(); |
443 | void selectFilter( int ); | 443 | void selectFilter( int ); |
444 | KOFilterView *filterView(); | 444 | KOFilterView *filterView(); |
445 | 445 | ||
446 | void showIntro(); | 446 | void showIntro(); |
447 | 447 | ||
448 | /** Move the curdatepient view date to today */ | 448 | /** Move the curdatepient view date to today */ |
449 | void goToday(); | 449 | void goToday(); |
450 | 450 | ||
451 | /** Move to the next date(s) in the current view */ | 451 | /** Move to the next date(s) in the current view */ |
452 | void goNext(); | 452 | void goNext(); |
453 | 453 | ||
454 | /** Move to the previous date(s) in the current view */ | 454 | /** Move to the previous date(s) in the current view */ |
455 | void goPrevious(); | 455 | void goPrevious(); |
456 | /** Move to the next date(s) in the current view */ | 456 | /** Move to the next date(s) in the current view */ |
457 | void goNextMonth(); | 457 | void goNextMonth(); |
458 | 458 | ||
459 | /** Move to the previous date(s) in the current view */ | 459 | /** Move to the previous date(s) in the current view */ |
460 | void goPreviousMonth(); | 460 | void goPreviousMonth(); |
461 | 461 | ||
462 | void toggleExpand(); | 462 | void toggleExpand(); |
463 | void toggleDateNavigatorWidget(); | 463 | void toggleDateNavigatorWidget(); |
464 | void toggleAllDaySize(); | 464 | void toggleAllDaySize(); |
465 | 465 | ||
466 | /** Look for new messages in the inbox */ | 466 | /** Look for new messages in the inbox */ |
467 | void lookForIncomingMessages(); | 467 | void lookForIncomingMessages(); |
468 | /** Look for new messages in the outbox */ | 468 | /** Look for new messages in the outbox */ |
469 | void lookForOutgoingMessages(); | 469 | void lookForOutgoingMessages(); |
470 | 470 | ||
471 | void processMainViewSelection( Incidence * ); | 471 | void processMainViewSelection( Incidence * ); |
472 | void processTodoListSelection( Incidence * ); | 472 | void processTodoListSelection( Incidence * ); |
473 | 473 | ||
474 | void processIncidenceSelection( Incidence * ); | 474 | void processIncidenceSelection( Incidence * ); |
475 | 475 | ||
476 | void purgeCompleted(); | 476 | void purgeCompleted(); |
477 | bool removeCompletedSubTodos( Todo* ); | 477 | bool removeCompletedSubTodos( Todo* ); |
478 | void slotCalendarChanged(); | 478 | void slotCalendarChanged(); |
479 | bool importBday(); | 479 | bool importBday(); |
480 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 480 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
481 | bool importQtopia( const QString &categoriesFile, | 481 | bool importQtopia( const QString &categoriesFile, |
482 | const QString &datebookFile, | 482 | const QString &datebookFile, |
483 | const QString &tasklistFile ); | 483 | const QString &tasklistFile ); |
484 | void syncExternal( int mode ); | 484 | void syncExternal( int mode ); |
485 | void slotSelectPickerDate( QDate ) ; | 485 | void slotSelectPickerDate( QDate ) ; |
486 | void showDatePicker() ; | 486 | void showDatePicker() ; |
487 | void showDatePickerPopup() ; | 487 | void showDatePickerPopup() ; |
488 | void moveIncidence(Incidence *) ; | 488 | void moveIncidence(Incidence *) ; |
489 | void beamIncidence(Incidence *) ; | 489 | void beamIncidence(Incidence *) ; |
490 | void beamCalendar() ; | 490 | void beamCalendar() ; |
491 | void beamFilteredCalendar() ; | 491 | void beamFilteredCalendar() ; |
492 | void beamIncidenceList(QPtrList<Incidence>) ; | 492 | void beamIncidenceList(QPtrList<Incidence>) ; |
493 | void manageCategories(); | 493 | void manageCategories(); |
494 | void editCategories(); | 494 | void editCategories(); |
495 | int addCategories(); | 495 | int addCategories(); |
496 | void removeCategories(); | 496 | void removeCategories(); |
497 | void setSyncDevice( QString ); | 497 | void setSyncDevice( QString ); |
498 | void setSyncName( QString ); | 498 | void setSyncName( QString ); |
499 | void showDay( QDate ); | 499 | void showDay( QDate ); |
500 | void undo_delete(); | 500 | void undo_delete(); |
501 | protected slots: | 501 | protected slots: |
502 | void resetFocus(); | 502 | void resetFocus(); |
503 | void scrollBarValue(int); | 503 | void scrollBarValue(int); |
504 | void slotViewerClosed(); | 504 | void slotViewerClosed(); |
505 | void timerAlarm(); | 505 | void timerAlarm(); |
506 | void suspendAlarm(); | 506 | void suspendAlarm(); |
507 | void beamDone( Ir *ir ); | 507 | void beamDone( Ir *ir ); |
508 | /** Select a view or adapt the current view to display the specified dates. */ | 508 | /** Select a view or adapt the current view to display the specified dates. */ |
509 | void showDates( const KCal::DateList & ); | 509 | void showDates( const KCal::DateList & ); |
510 | void selectWeekNum ( int ); | 510 | void selectWeekNum ( int ); |
511 | void checkConflictForEvent(); | ||
511 | 512 | ||
512 | public: | 513 | public: |
513 | // show a standard warning | 514 | // show a standard warning |
514 | // returns KMsgBox::yesNoCancel() | 515 | // returns KMsgBox::yesNoCancel() |
515 | int msgCalModified(); | 516 | int msgCalModified(); |
516 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 517 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
517 | 518 | ||
518 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 519 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
519 | virtual void removeSyncInfo( QString syncProfile); | 520 | virtual void removeSyncInfo( QString syncProfile); |
520 | void setSyncManager(KSyncManager* manager); | 521 | void setSyncManager(KSyncManager* manager); |
521 | void setLoadedFileVersion(QDateTime); | 522 | void setLoadedFileVersion(QDateTime); |
522 | bool checkFileVersion(QString fn); | 523 | bool checkFileVersion(QString fn); |
523 | bool checkAllFileVersions(); | 524 | bool checkAllFileVersions(); |
524 | bool checkFileChanged(QString fn); | 525 | bool checkFileChanged(QString fn); |
525 | Event* getLastSyncEvent(); | 526 | Event* getLastSyncEvent(); |
526 | /** Adapt navigation units correpsonding to step size of navigation of the | 527 | /** Adapt navigation units correpsonding to step size of navigation of the |
527 | * current view. | 528 | * current view. |
528 | */ | 529 | */ |
529 | void adaptNavigationUnits(); | 530 | void adaptNavigationUnits(); |
530 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 531 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
531 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 532 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
532 | //Attendee* getYourAttendee(Event *event); | 533 | //Attendee* getYourAttendee(Event *event); |
533 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 534 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
534 | void setScrollBarStep(int val ); | 535 | void setScrollBarStep(int val ); |
535 | 536 | ||
536 | protected: | 537 | protected: |
538 | Event *mConflictingEvent; | ||
537 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 539 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
538 | 540 | ||
539 | // returns KMsgBox::OKCandel() | 541 | // returns KMsgBox::OKCandel() |
540 | int msgItemDelete(const QString name); | 542 | int msgItemDelete(const QString name); |
541 | void showEventEditor(); | 543 | void showEventEditor(); |
542 | void showTodoEditor(); | 544 | void showTodoEditor(); |
543 | Todo *selectedTodo(); | 545 | Todo *selectedTodo(); |
544 | private: | 546 | private: |
545 | #ifdef DESKTOP_VERSION | 547 | #ifdef DESKTOP_VERSION |
546 | QScrollBar * mDateScrollBar; | 548 | QScrollBar * mDateScrollBar; |
547 | #endif | 549 | #endif |
548 | QDateTime mNextAlarmDateTime; | 550 | QDateTime mNextAlarmDateTime; |
549 | bool mViewerCallerIsSearchDialog; | 551 | bool mViewerCallerIsSearchDialog; |
550 | bool mBlockShowDates; | 552 | bool mBlockShowDates; |
551 | KSyncManager* mSyncManager; | 553 | KSyncManager* mSyncManager; |
552 | AlarmDialog * mAlarmDialog; | 554 | AlarmDialog * mAlarmDialog; |
553 | QString mAlarmNotification; | 555 | QString mAlarmNotification; |
554 | QString mSuspendAlarmNotification; | 556 | QString mSuspendAlarmNotification; |
555 | QTimer* mSuspendTimer; | 557 | QTimer* mSuspendTimer; |
556 | QTimer* mAlarmTimer; | 558 | QTimer* mAlarmTimer; |
557 | QTimer* mRecheckAlarmTimer; | 559 | QTimer* mRecheckAlarmTimer; |
558 | void computeAlarm( QString ); | 560 | void computeAlarm( QString ); |
559 | void startAlarm( QString, QString ); | 561 | void startAlarm( QString, QString ); |
560 | void setSyncEventsReadOnly(); | 562 | void setSyncEventsReadOnly(); |
561 | 563 | ||
562 | QDateTime loadedFileVersion; | 564 | QDateTime loadedFileVersion; |
563 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 565 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
564 | void checkExternalId( Incidence * inc ); | 566 | void checkExternalId( Incidence * inc ); |
565 | int mGlobalSyncMode; | 567 | int mGlobalSyncMode; |
566 | QString mCurrentSyncDevice; | 568 | QString mCurrentSyncDevice; |
567 | QString mCurrentSyncName; | 569 | QString mCurrentSyncName; |
568 | void init(); | 570 | void init(); |
569 | int mDatePickerMode; | 571 | int mDatePickerMode; |
570 | bool mFlagEditDescription; | 572 | bool mFlagEditDescription; |
571 | QDateTime mLastCalendarSync; | 573 | QDateTime mLastCalendarSync; |
572 | void createPrinter(); | 574 | void createPrinter(); |
573 | 575 | ||
574 | void calendarModified( bool, Calendar * ); | 576 | void calendarModified( bool, Calendar * ); |
575 | 577 | ||
576 | CalPrinter *mCalPrinter; | 578 | CalPrinter *mCalPrinter; |
577 | 579 | ||
578 | QSplitter *mPanner; | 580 | QSplitter *mPanner; |
579 | QSplitter *mLeftSplitter; | 581 | QSplitter *mLeftSplitter; |
580 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; | 582 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; |
581 | QWidgetStack *mRightFrame; | 583 | QWidgetStack *mRightFrame; |
582 | 584 | ||
583 | KDatePicker* mDatePicker; | 585 | KDatePicker* mDatePicker; |
584 | QVBox* mDateFrame; | 586 | QVBox* mDateFrame; |
585 | 587 | ||
586 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. | 588 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. |
587 | 589 | ||
588 | KOFilterView *mFilterView; | 590 | KOFilterView *mFilterView; |
589 | KOCalEditView *mCalEditView; | 591 | KOCalEditView *mCalEditView; |
590 | 592 | ||
591 | ResourceView *mResourceView; | 593 | ResourceView *mResourceView; |
592 | 594 | ||
593 | // calendar object for this viewing instance | 595 | // calendar object for this viewing instance |
594 | Calendar *mCalendar; | 596 | Calendar *mCalendar; |
595 | 597 | ||
596 | CalendarResourceManager *mResourceManager; | 598 | CalendarResourceManager *mResourceManager; |
597 | 599 | ||
598 | FileStorage *mStorage; | 600 | FileStorage *mStorage; |
599 | 601 | ||
600 | DateNavigator *mNavigator; | 602 | DateNavigator *mNavigator; |
601 | 603 | ||
602 | KOViewManager *mViewManager; | 604 | KOViewManager *mViewManager; |
603 | KODialogManager *mDialogManager; | 605 | KODialogManager *mDialogManager; |
604 | 606 | ||
605 | // Calendar filters | 607 | // Calendar filters |
606 | QPtrList<CalFilter> mFilters; | 608 | QPtrList<CalFilter> mFilters; |
607 | 609 | ||
608 | // various housekeeping variables. | 610 | // various housekeeping variables. |
609 | bool mModified; // flag indicating if calendar is modified | 611 | bool mModified; // flag indicating if calendar is modified |
610 | bool mReadOnly; // flag indicating if calendar is read-only | 612 | bool mReadOnly; // flag indicating if calendar is read-only |
611 | QDate mSaveSingleDate; | 613 | QDate mSaveSingleDate; |
612 | 614 | ||
613 | Incidence *mSelectedIncidence; | 615 | Incidence *mSelectedIncidence; |
614 | Incidence *mMoveIncidence; | 616 | Incidence *mMoveIncidence; |
615 | QDate mMoveIncidenceOldDate; | 617 | QDate mMoveIncidenceOldDate; |
616 | KOTodoView *mTodoList; | 618 | KOTodoView *mTodoList; |
617 | KOEventEditor * mEventEditor; | 619 | KOEventEditor * mEventEditor; |
618 | KOTodoEditor * mTodoEditor; | 620 | KOTodoEditor * mTodoEditor; |
619 | KOEventViewerDialog * mEventViewerDialog; | 621 | KOEventViewerDialog * mEventViewerDialog; |
620 | void keyPressEvent ( QKeyEvent *e) ; | 622 | void keyPressEvent ( QKeyEvent *e) ; |
621 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 623 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
622 | }; | 624 | }; |
623 | 625 | ||
624 | 626 | ||
625 | class CalendarViewVisitor : public Incidence::Visitor | 627 | class CalendarViewVisitor : public Incidence::Visitor |
626 | { | 628 | { |
627 | public: | 629 | public: |
628 | CalendarViewVisitor() : mView( 0 ) {} | 630 | CalendarViewVisitor() : mView( 0 ) {} |
629 | 631 | ||
630 | bool act( Incidence *incidence, CalendarView *view ) | 632 | bool act( Incidence *incidence, CalendarView *view ) |
631 | { | 633 | { |
632 | mView = view; | 634 | mView = view; |
633 | return incidence->accept( *this ); | 635 | return incidence->accept( *this ); |
634 | } | 636 | } |
635 | 637 | ||
636 | protected: | 638 | protected: |
637 | CalendarView *mView; | 639 | CalendarView *mView; |
638 | }; | 640 | }; |
639 | 641 | ||
640 | class ShowIncidenceVisitor : public CalendarViewVisitor | 642 | class ShowIncidenceVisitor : public CalendarViewVisitor |
641 | { | 643 | { |
642 | protected: | 644 | protected: |
643 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 645 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
644 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 646 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
645 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 647 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
646 | }; | 648 | }; |
647 | 649 | ||
648 | class EditIncidenceVisitor : public CalendarViewVisitor | 650 | class EditIncidenceVisitor : public CalendarViewVisitor |
649 | { | 651 | { |
650 | protected: | 652 | protected: |
651 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 653 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
652 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 654 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
653 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 655 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
654 | }; | 656 | }; |
655 | 657 | ||
656 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 658 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
657 | { | 659 | { |
658 | protected: | 660 | protected: |
659 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 661 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
660 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 662 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
661 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 663 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
662 | }; | 664 | }; |
663 | 665 | ||
664 | #endif | 666 | #endif |
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 7783dd4..d25f671 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,1452 +1,1447 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1999 Preston Brown | 3 | Copyright (c) 1999 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qprogressbar.h> | 29 | #include <qprogressbar.h> |
30 | #include <qfileinfo.h> | 30 | #include <qfileinfo.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qwhatsthis.h> | 35 | #include <qwhatsthis.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | #include <qpaintdevicemetrics.h> | 38 | #include <qpaintdevicemetrics.h> |
39 | 39 | ||
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | #include <kglobal.h> | 43 | #include <kglobal.h> |
44 | 44 | ||
45 | #include <libkdepim/kpimglobalprefs.h> | 45 | #include <libkdepim/kpimglobalprefs.h> |
46 | #include <libkcal/calendar.h> | 46 | #include <libkcal/calendar.h> |
47 | #include <libkcal/calendarlocal.h> | 47 | #include <libkcal/calendarlocal.h> |
48 | #include <libkcal/icalformat.h> | 48 | #include <libkcal/icalformat.h> |
49 | #include <libkcal/vcalformat.h> | 49 | #include <libkcal/vcalformat.h> |
50 | #include <libkcal/recurrence.h> | 50 | #include <libkcal/recurrence.h> |
51 | #include <libkcal/filestorage.h> | 51 | #include <libkcal/filestorage.h> |
52 | #include <libkdepim/categoryselectdialog.h> | 52 | #include <libkdepim/categoryselectdialog.h> |
53 | #include <libkcal/kincidenceformatter.h> | 53 | #include <libkcal/kincidenceformatter.h> |
54 | #ifndef DESKTOP_VERSION | 54 | #ifndef DESKTOP_VERSION |
55 | #include <qpe/qpeapplication.h> | 55 | #include <qpe/qpeapplication.h> |
56 | #else | 56 | #else |
57 | #include <qapplication.h> | 57 | #include <qapplication.h> |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #ifndef KORG_NOPRINTER | 60 | #ifndef KORG_NOPRINTER |
61 | #include "calprinter.h" | 61 | #include "calprinter.h" |
62 | #endif | 62 | #endif |
63 | #include "koglobals.h" | 63 | #include "koglobals.h" |
64 | #include "koprefs.h" | 64 | #include "koprefs.h" |
65 | #include "kfiledialog.h" | 65 | #include "kfiledialog.h" |
66 | 66 | ||
67 | #include "kolistview.h" | 67 | #include "kolistview.h" |
68 | #include "koeventviewer.h" | 68 | #include "koeventviewer.h" |
69 | 69 | ||
70 | extern QPixmap* sgListViewCompletedPix[6]; | 70 | extern QPixmap* sgListViewCompletedPix[6]; |
71 | extern QPixmap* sgListViewJournalPix; | 71 | extern QPixmap* sgListViewJournalPix; |
72 | 72 | ||
73 | class KOListViewWhatsThis :public QWhatsThis | 73 | class KOListViewWhatsThis :public QWhatsThis |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 76 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
77 | 77 | ||
78 | protected: | 78 | protected: |
79 | virtual QString text( const QPoint& p) | 79 | virtual QString text( const QPoint& p) |
80 | { | 80 | { |
81 | return _view->getWhatsThisText(p) ; | 81 | return _view->getWhatsThisText(p) ; |
82 | } | 82 | } |
83 | private: | 83 | private: |
84 | QWidget* _wid; | 84 | QWidget* _wid; |
85 | KOListView * _view; | 85 | KOListView * _view; |
86 | }; | 86 | }; |
87 | 87 | ||
88 | 88 | ||
89 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 89 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
90 | { | 90 | { |
91 | mItem = item; | 91 | mItem = item; |
92 | mDate = date; | 92 | mDate = date; |
93 | } | 93 | } |
94 | 94 | ||
95 | ListItemVisitor::~ListItemVisitor() | 95 | ListItemVisitor::~ListItemVisitor() |
96 | { | 96 | { |
97 | } | 97 | } |
98 | 98 | ||
99 | bool ListItemVisitor::visit(Event *e) | 99 | bool ListItemVisitor::visit(Event *e) |
100 | { | 100 | { |
101 | bool ok = false; | 101 | bool ok = false; |
102 | QString start, end; | 102 | QString start, end; |
103 | QDate ds, de; | 103 | QDate ds, de; |
104 | if ( e->doesRecur() ) { | 104 | if ( e->doesRecur() ) { |
105 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 105 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
106 | if ( ok ) { | 106 | if ( ok ) { |
107 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 107 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
108 | start = KGlobal::locale()->formatDate(ds,true); | 108 | start = KGlobal::locale()->formatDate(ds,true); |
109 | de = ds.addDays( days); | 109 | de = ds.addDays( days); |
110 | end = KGlobal::locale()->formatDate(de,true); | 110 | end = KGlobal::locale()->formatDate(de,true); |
111 | } | 111 | } |
112 | 112 | ||
113 | } | 113 | } |
114 | if ( ! ok ) { | 114 | if ( ! ok ) { |
115 | start =e->dtStartDateStr(); | 115 | start =e->dtStartDateStr(); |
116 | end = e->dtEndDateStr(); | 116 | end = e->dtEndDateStr(); |
117 | ds = e->dtStart().date(); | 117 | ds = e->dtStart().date(); |
118 | de = e->dtEnd().date(); | 118 | de = e->dtEnd().date(); |
119 | } | 119 | } |
120 | mItem->setText(0,e->summary()); | 120 | mItem->setText(0,e->summary()); |
121 | mItem->setText(1,start); | 121 | mItem->setText(1,start); |
122 | if ( e->doesFloat() ) | 122 | if ( e->doesFloat() ) |
123 | mItem->setText(2,"---"); | 123 | mItem->setText(2,"---"); |
124 | else | 124 | else |
125 | mItem->setText(2,e->dtStartTimeStr()); | 125 | mItem->setText(2,e->dtStartTimeStr()); |
126 | mItem->setText(3,end); | 126 | mItem->setText(3,end); |
127 | if ( e->doesFloat() ) | 127 | if ( e->doesFloat() ) |
128 | mItem->setText(4,"---"); | 128 | mItem->setText(4,"---"); |
129 | else | 129 | else |
130 | mItem->setText(4,e->dtEndTimeStr()); | 130 | mItem->setText(4,e->dtEndTimeStr()); |
131 | if ( e->isAlarmEnabled() ) { | 131 | if ( e->isAlarmEnabled() ) { |
132 | mItem->setText(5,e->alarms().first()->offsetText() ); | 132 | mItem->setText(5,e->alarms().first()->offsetText() ); |
133 | } else { | 133 | } else { |
134 | mItem->setText(5, i18n("No")); | 134 | mItem->setText(5, i18n("No")); |
135 | } | 135 | } |
136 | mItem->setText(6, e->recurrence()->recurrenceText()); | 136 | mItem->setText(6, e->recurrence()->recurrenceText()); |
137 | if( ! e->doesRecur() ) | 137 | if( ! e->doesRecur() ) |
138 | mItem->setSortKey( 6, "-" ); | 138 | mItem->setSortKey( 6, "-" ); |
139 | mItem->setText(7,"---"); | 139 | mItem->setText(7,"---"); |
140 | mItem->setText(8,"---"); | 140 | mItem->setText(8,"---"); |
141 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 141 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
142 | mItem->setText(10,e->categoriesStr()); | 142 | mItem->setText(10,e->categoriesStr()); |
143 | mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); | 143 | mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); |
144 | mItem->setText(12, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); | 144 | mItem->setText(12, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); |
145 | 145 | ||
146 | QString key; | 146 | QString key; |
147 | QDate d = e->lastModified().date(); | 147 | QDate d = e->lastModified().date(); |
148 | QTime t = e->lastModified().time(); | 148 | QTime t = e->lastModified().time(); |
149 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); | 149 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); |
150 | mItem->setSortKey(12,key); | 150 | mItem->setSortKey(12,key); |
151 | t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 151 | t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
152 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); | 152 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); |
153 | mItem->setSortKey(1,key); | 153 | mItem->setSortKey(1,key); |
154 | 154 | ||
155 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 155 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
156 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); | 156 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); |
157 | mItem->setSortKey(3,key); | 157 | mItem->setSortKey(3,key); |
158 | return true; | 158 | return true; |
159 | } | 159 | } |
160 | 160 | ||
161 | bool ListItemVisitor::visit(Todo *t) | 161 | bool ListItemVisitor::visit(Todo *t) |
162 | { | 162 | { |
163 | mItem->setText(0,t->summary()); | 163 | mItem->setText(0,t->summary()); |
164 | if ( t->isCompleted() ) { | 164 | if ( t->isCompleted() ) { |
165 | mItem->setSortKey(0,"99"+ t->summary().left(10)); | 165 | mItem->setSortKey(0,"99"+ t->summary().left(10)); |
166 | } else | 166 | } else |
167 | mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10)); | 167 | mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10)); |
168 | mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); | 168 | mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); |
169 | if (t->hasStartDate()) { | 169 | if (t->hasStartDate()) { |
170 | mItem->setText(1,t->dtStartDateStr()); | 170 | mItem->setText(1,t->dtStartDateStr()); |
171 | if (t->doesFloat()) { | 171 | if (t->doesFloat()) { |
172 | mItem->setText(2,"---"); | 172 | mItem->setText(2,"---"); |
173 | } else { | 173 | } else { |
174 | mItem->setText(2,t->dtStartTimeStr()); | 174 | mItem->setText(2,t->dtStartTimeStr()); |
175 | } | 175 | } |
176 | } else { | 176 | } else { |
177 | mItem->setText(1,"---"); | 177 | mItem->setText(1,"---"); |
178 | mItem->setText(2,"---"); | 178 | mItem->setText(2,"---"); |
179 | } | 179 | } |
180 | mItem->setText(3,"---"); | 180 | mItem->setText(3,"---"); |
181 | mItem->setText(4,"---"); | 181 | mItem->setText(4,"---"); |
182 | if ( t->isAlarmEnabled() ) { | 182 | if ( t->isAlarmEnabled() ) { |
183 | mItem->setText(5,t->alarms().first()->offsetText() ); | 183 | mItem->setText(5,t->alarms().first()->offsetText() ); |
184 | } else { | 184 | } else { |
185 | mItem->setText(5, i18n("No")); | 185 | mItem->setText(5, i18n("No")); |
186 | } | 186 | } |
187 | mItem->setText(6, t->recurrence()->recurrenceText()); | 187 | mItem->setText(6, t->recurrence()->recurrenceText()); |
188 | if( ! t->doesRecur() ) | 188 | if( ! t->doesRecur() ) |
189 | mItem->setSortKey( 6, "-" ); | 189 | mItem->setSortKey( 6, "-" ); |
190 | if (t->hasDueDate()) { | 190 | if (t->hasDueDate()) { |
191 | mItem->setText(7,t->dtDueDateStr()); | 191 | mItem->setText(7,t->dtDueDateStr()); |
192 | if (t->doesFloat()) { | 192 | if (t->doesFloat()) { |
193 | mItem->setText(8,"---"); | 193 | mItem->setText(8,"---"); |
194 | } else { | 194 | } else { |
195 | mItem->setText(8,t->dtDueTimeStr()); | 195 | mItem->setText(8,t->dtDueTimeStr()); |
196 | } | 196 | } |
197 | } else { | 197 | } else { |
198 | mItem->setText(7,"---"); | 198 | mItem->setText(7,"---"); |
199 | mItem->setText(8,"---"); | 199 | mItem->setText(8,"---"); |
200 | } | 200 | } |
201 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 201 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
202 | mItem->setText(10,t->categoriesStr()); | 202 | mItem->setText(10,t->categoriesStr()); |
203 | mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); | 203 | mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); |
204 | mItem->setText(12, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); | 204 | mItem->setText(12, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); |
205 | QString key; | 205 | QString key; |
206 | QDate d = t->lastModified().date(); | 206 | QDate d = t->lastModified().date(); |
207 | QTime tm = t->lastModified().time(); | 207 | QTime tm = t->lastModified().time(); |
208 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); | 208 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); |
209 | mItem->setSortKey(12,key); | 209 | mItem->setSortKey(12,key); |
210 | if (t->hasDueDate()) { | 210 | if (t->hasDueDate()) { |
211 | d = t->dtDue().date(); | 211 | d = t->dtDue().date(); |
212 | tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 212 | tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
213 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 213 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
214 | mItem->setSortKey(7,key); | 214 | mItem->setSortKey(7,key); |
215 | } | 215 | } |
216 | if ( t->hasStartDate() ) { | 216 | if ( t->hasStartDate() ) { |
217 | d = t->dtStart().date(); | 217 | d = t->dtStart().date(); |
218 | tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 218 | tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
219 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 219 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
220 | mItem->setSortKey(1,key); | 220 | mItem->setSortKey(1,key); |
221 | } | 221 | } |
222 | return true; | 222 | return true; |
223 | } | 223 | } |
224 | 224 | ||
225 | bool ListItemVisitor::visit(Journal * j) | 225 | bool ListItemVisitor::visit(Journal * j) |
226 | { | 226 | { |
227 | 227 | ||
228 | QString des; | 228 | QString des; |
229 | mItem->setPixmap( 0, *sgListViewJournalPix); | 229 | mItem->setPixmap( 0, *sgListViewJournalPix); |
230 | if ( !j->summary().isEmpty() ) { | 230 | if ( !j->summary().isEmpty() ) { |
231 | des = j->summary(); | 231 | des = j->summary(); |
232 | } else { | 232 | } else { |
233 | des = j->description().left(30); | 233 | des = j->description().left(30); |
234 | des = des.simplifyWhiteSpace (); | 234 | des = des.simplifyWhiteSpace (); |
235 | des.replace (QRegExp ("\\n"),"" ); | 235 | des.replace (QRegExp ("\\n"),"" ); |
236 | des.replace (QRegExp ("\\r"),"" ); | 236 | des.replace (QRegExp ("\\r"),"" ); |
237 | } | 237 | } |
238 | mItem->setText(0,des.left(25)); | 238 | mItem->setText(0,des.left(25)); |
239 | mItem->setSortKey(0,"0"+ des.left(25)); | 239 | mItem->setSortKey(0,"0"+ des.left(25)); |
240 | mItem->setText(1,j->dtStartDateStr()); | 240 | mItem->setText(1,j->dtStartDateStr()); |
241 | mItem->setText(2,"---"); | 241 | mItem->setText(2,"---"); |
242 | mItem->setText(3,"---"); | 242 | mItem->setText(3,"---"); |
243 | mItem->setText(4,"---"); | 243 | mItem->setText(4,"---"); |
244 | mItem->setText(5,"---"); | 244 | mItem->setText(5,"---"); |
245 | mItem->setText(6,"---"); | 245 | mItem->setText(6,"---"); |
246 | mItem->setText(7,j->dtStartDateStr()); | 246 | mItem->setText(7,j->dtStartDateStr()); |
247 | mItem->setText(8,"---"); | 247 | mItem->setText(8,"---"); |
248 | mItem->setText(9,"---"); | 248 | mItem->setText(9,"---"); |
249 | mItem->setText(10,j->categoriesStr()); | 249 | mItem->setText(10,j->categoriesStr()); |
250 | mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); | 250 | mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); |
251 | mItem->setText(12, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); | 251 | mItem->setText(12, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); |
252 | 252 | ||
253 | QString key; | 253 | QString key; |
254 | QDate d = j->lastModified().date(); | 254 | QDate d = j->lastModified().date(); |
255 | QTime tm = j->lastModified().time(); | 255 | QTime tm = j->lastModified().time(); |
256 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); | 256 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); |
257 | mItem->setSortKey(12,key); | 257 | mItem->setSortKey(12,key); |
258 | d = j->dtStart().date(); | 258 | d = j->dtStart().date(); |
259 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 259 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
260 | mItem->setSortKey(1,key); | 260 | mItem->setSortKey(1,key); |
261 | mItem->setSortKey(7,key); | 261 | mItem->setSortKey(7,key); |
262 | 262 | ||
263 | return true; | 263 | return true; |
264 | } | 264 | } |
265 | 265 | ||
266 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 266 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
267 | const char *name) | 267 | const char *name) |
268 | : KOEventView(calendar, parent, name) | 268 | : KOEventView(calendar, parent, name) |
269 | { | 269 | { |
270 | 270 | ||
271 | mActiveItem = 0; | 271 | mActiveItem = 0; |
272 | mForceShowCompletedTodos = false; | 272 | mForceShowCompletedTodos = false; |
273 | mListView = new KOListViewListView(this); | 273 | mListView = new KOListViewListView(this); |
274 | mListView->addColumn(i18n("Summary")); | 274 | mListView->addColumn(i18n("Summary")); |
275 | mListView->addColumn(i18n("Start Date")); | 275 | mListView->addColumn(i18n("Start Date")); |
276 | mListView->addColumn(i18n("Start Time")); | 276 | mListView->addColumn(i18n("Start Time")); |
277 | mListView->addColumn(i18n("End Date")); | 277 | mListView->addColumn(i18n("End Date")); |
278 | mListView->addColumn(i18n("End Time")); | 278 | mListView->addColumn(i18n("End Time")); |
279 | mListView->addColumn(i18n("Alarm")); // alarm set? | 279 | mListView->addColumn(i18n("Alarm")); // alarm set? |
280 | mListView->addColumn(i18n("Recurs")); // recurs? | 280 | mListView->addColumn(i18n("Recurs")); // recurs? |
281 | mListView->addColumn(i18n("Due Date")); | 281 | mListView->addColumn(i18n("Due Date")); |
282 | mListView->addColumn(i18n("Due Time")); | 282 | mListView->addColumn(i18n("Due Time")); |
283 | mListView->addColumn(i18n("Cancelled")); | 283 | mListView->addColumn(i18n("Cancelled")); |
284 | mListView->addColumn(i18n("Categories")); | 284 | mListView->addColumn(i18n("Categories")); |
285 | mListView->addColumn(i18n("Calendar")); | 285 | mListView->addColumn(i18n("Calendar")); |
286 | mListView->addColumn(i18n("Last Modified")); | 286 | mListView->addColumn(i18n("Last Modified")); |
287 | 287 | ||
288 | mListView->setColumnAlignment(0,AlignLeft); | 288 | mListView->setColumnAlignment(0,AlignLeft); |
289 | mListView->setColumnAlignment(1,AlignLeft); | 289 | mListView->setColumnAlignment(1,AlignLeft); |
290 | mListView->setColumnAlignment(2,AlignHCenter); | 290 | mListView->setColumnAlignment(2,AlignHCenter); |
291 | mListView->setColumnAlignment(3,AlignLeft); | 291 | mListView->setColumnAlignment(3,AlignLeft); |
292 | mListView->setColumnAlignment(4,AlignHCenter); | 292 | mListView->setColumnAlignment(4,AlignHCenter); |
293 | mListView->setColumnAlignment(5,AlignLeft); | 293 | mListView->setColumnAlignment(5,AlignLeft); |
294 | mListView->setColumnAlignment(6,AlignLeft); | 294 | mListView->setColumnAlignment(6,AlignLeft); |
295 | mListView->setColumnAlignment(7,AlignLeft); | 295 | mListView->setColumnAlignment(7,AlignLeft); |
296 | mListView->setColumnAlignment(8,AlignLeft); | 296 | mListView->setColumnAlignment(8,AlignLeft); |
297 | mListView->setColumnAlignment(9,AlignLeft); | 297 | mListView->setColumnAlignment(9,AlignLeft); |
298 | mListView->setColumnAlignment(10,AlignLeft); | 298 | mListView->setColumnAlignment(10,AlignLeft); |
299 | mListView->setColumnAlignment(11,AlignLeft); | 299 | mListView->setColumnAlignment(11,AlignLeft); |
300 | mListView->setColumnAlignment(12,AlignLeft); | 300 | mListView->setColumnAlignment(12,AlignLeft); |
301 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); | 301 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); |
302 | 302 | ||
303 | int iii = 0; | 303 | int iii = 0; |
304 | for ( iii = 0; iii< 13 ; ++iii ) | 304 | for ( iii = 0; iii< 13 ; ++iii ) |
305 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 305 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
306 | 306 | ||
307 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 307 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
308 | layoutTop->addWidget(mListView); | 308 | layoutTop->addWidget(mListView); |
309 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 309 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
310 | mPopupMenu = eventPopup(); | 310 | mPopupMenu = eventPopup(); |
311 | QPopupMenu* selPopup = new QPopupMenu ( this ); | 311 | QPopupMenu* selPopup = new QPopupMenu ( this ); |
312 | mPopupMenu->insertSeparator(); | 312 | mPopupMenu->insertSeparator(); |
313 | 313 | ||
314 | selPopup->insertItem(i18n("All"),this, | 314 | selPopup->insertItem(i18n("All"),this, |
315 | SLOT(allSelection())); | 315 | SLOT(allSelection())); |
316 | selPopup->insertItem(i18n("None"),this, | 316 | selPopup->insertItem(i18n("None"),this, |
317 | SLOT(clearSelection())); | 317 | SLOT(clearSelection())); |
318 | selPopup->insertItem(i18n("Delete selected..."),this, | 318 | selPopup->insertItem(i18n("Delete selected..."),this, |
319 | SLOT(deleteAll())); | 319 | SLOT(deleteAll())); |
320 | mPopupMenu->insertItem(i18n("Selection"), selPopup ); | 320 | mPopupMenu->insertItem(i18n("Selection"), selPopup ); |
321 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 321 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
322 | i18n("Hide all selected"),this, | 322 | i18n("Hide all selected"),this, |
323 | SLOT(hideAll()),true); | 323 | SLOT(hideAll()),true); |
324 | 324 | ||
325 | selPopup->insertSeparator(); | 325 | selPopup->insertSeparator(); |
326 | QPopupMenu * exportPO = new QPopupMenu ( this ); | 326 | QPopupMenu * exportPO = new QPopupMenu ( this ); |
327 | selPopup->insertItem( i18n("Export"), exportPO ); | 327 | selPopup->insertItem( i18n("Export"), exportPO ); |
328 | #ifdef DESKTOP_VERSION | 328 | #ifdef DESKTOP_VERSION |
329 | mPopupMenu->insertSeparator(); | 329 | mPopupMenu->insertSeparator(); |
330 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 330 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
331 | i18n("Print complete list..."),this, | 331 | i18n("Print complete list..."),this, |
332 | SLOT(printList()),true); | 332 | SLOT(printList()),true); |
333 | #endif | 333 | #endif |
334 | mCalPopup = new QPopupMenu ( this ); | 334 | mCalPopup = new QPopupMenu ( this ); |
335 | selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); | 335 | selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); |
336 | 336 | ||
337 | selPopup->insertItem(i18n("Set categories")+"...",this, | 337 | selPopup->insertItem(i18n("Set categories")+"...",this, |
338 | SLOT(setCat()) ); | 338 | SLOT(setCat()) ); |
339 | selPopup->insertItem( i18n("Set alarm..."),this, | 339 | selPopup->insertItem( i18n("Set alarm..."),this, |
340 | SLOT(setAlarm())); | 340 | SLOT(setAlarm())); |
341 | #if 0 | 341 | #if 0 |
342 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 342 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
343 | i18n("Set categories")+"...",this, | 343 | i18n("Set categories")+"...",this, |
344 | SLOT(setCat()),true); | 344 | SLOT(setCat()),true); |
345 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 345 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
346 | i18n("Set alarm..."),this, | 346 | i18n("Set alarm..."),this, |
347 | SLOT(setAlarm()),true); | 347 | SLOT(setAlarm()),true); |
348 | #endif | 348 | #endif |
349 | QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, | 349 | QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, |
350 | SLOT( populateCalPopup() )); | 350 | SLOT( populateCalPopup() )); |
351 | QObject::connect(mCalPopup,SIGNAL(activated( int )),this, | 351 | QObject::connect(mCalPopup,SIGNAL(activated( int )),this, |
352 | SLOT( setCalendar( int ) )); | 352 | SLOT( setCalendar( int ) )); |
353 | QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, | 353 | QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, |
354 | SLOT( catChanged( Incidence * ) )); | 354 | SLOT( catChanged( Incidence * ) )); |
355 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, | 355 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, |
356 | SLOT(saveToFile())); | 356 | SLOT(saveToFile())); |
357 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, | 357 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, |
358 | SLOT(saveToFileVCS())); | 358 | SLOT(saveToFileVCS())); |
359 | exportPO->insertItem( i18n("Journal/Details..."),this, | 359 | exportPO->insertItem( i18n("Journal/Details..."),this, |
360 | SLOT(saveDescriptionToFile())); | 360 | SLOT(saveDescriptionToFile())); |
361 | // mPopupMenu->insertSeparator(); | 361 | // mPopupMenu->insertSeparator(); |
362 | // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 362 | // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
363 | // i18n("Add Categ. to selected..."),this, | 363 | // i18n("Add Categ. to selected..."),this, |
364 | // SLOT(addCat()),true); | 364 | // SLOT(addCat()),true); |
365 | //mPopupMenu->insertSeparator(); | 365 | //mPopupMenu->insertSeparator(); |
366 | #ifndef DESKTOP_VERSION | 366 | #ifndef DESKTOP_VERSION |
367 | selPopup->insertSeparator(); | 367 | selPopup->insertSeparator(); |
368 | selPopup->insertItem( i18n("Beam via IR..."),this, | 368 | selPopup->insertItem( i18n("Beam via IR..."),this, |
369 | SLOT(beamSelected())); | 369 | SLOT(beamSelected())); |
370 | #if 0 | 370 | #if 0 |
371 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 371 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
372 | i18n("Beam via IR"),this, | 372 | i18n("Beam via IR"),this, |
373 | SLOT(beamSelected()),true); | 373 | SLOT(beamSelected()),true); |
374 | #endif | 374 | #endif |
375 | #endif | 375 | #endif |
376 | /* | 376 | /* |
377 | mPopupMenu = new QPopupMenu; | 377 | mPopupMenu = new QPopupMenu; |
378 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 378 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
379 | SLOT (editEvent())); | 379 | SLOT (editEvent())); |
380 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 380 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
381 | SLOT (deleteEvent())); | 381 | SLOT (deleteEvent())); |
382 | mPopupMenu->insertSeparator(); | 382 | mPopupMenu->insertSeparator(); |
383 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 383 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
384 | SLOT(showDates())); | 384 | SLOT(showDates())); |
385 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 385 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
386 | SLOT(hideDates())); | 386 | SLOT(hideDates())); |
387 | */ | 387 | */ |
388 | QObject::connect(mListView,SIGNAL( newEvent()), | 388 | QObject::connect(mListView,SIGNAL( newEvent()), |
389 | this,SIGNAL(signalNewEvent())); | 389 | this,SIGNAL(signalNewEvent())); |
390 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 390 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
391 | this,SLOT(defaultItemAction(QListViewItem *))); | 391 | this,SLOT(defaultItemAction(QListViewItem *))); |
392 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, | 392 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, |
393 | const QPoint &, int )), | 393 | const QPoint &, int )), |
394 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 394 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
395 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 395 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
396 | SLOT(processSelectionChange(QListViewItem *))); | 396 | SLOT(processSelectionChange(QListViewItem *))); |
397 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 397 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
398 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 398 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
399 | 399 | ||
400 | readSettings(KOGlobals::config(),"KOListView Layout"); | 400 | readSettings(KOGlobals::config(),"KOListView Layout"); |
401 | } | 401 | } |
402 | 402 | ||
403 | KOListView::~KOListView() | 403 | KOListView::~KOListView() |
404 | { | 404 | { |
405 | delete mPopupMenu; | 405 | delete mPopupMenu; |
406 | #if QT_VERSION >= 0x030000 | 406 | #if QT_VERSION >= 0x030000 |
407 | 407 | ||
408 | #else | 408 | #else |
409 | delete mKOListViewWhatsThis; | 409 | delete mKOListViewWhatsThis; |
410 | #endif | 410 | #endif |
411 | } | 411 | } |
412 | 412 | ||
413 | void KOListView::catChanged( Incidence* inc) | 413 | void KOListView::catChanged( Incidence* inc) |
414 | { | 414 | { |
415 | KOListViewItem* item = getItemForEvent(inc); | 415 | KOListViewItem* item = getItemForEvent(inc); |
416 | if (item) { | 416 | if (item) { |
417 | ListItemVisitor v(item, mStartDate ); | 417 | ListItemVisitor v(item, mStartDate ); |
418 | inc->accept(v); | 418 | inc->accept(v); |
419 | } | 419 | } |
420 | } | 420 | } |
421 | QString KOListView::getWhatsThisText(QPoint p) | 421 | QString KOListView::getWhatsThisText(QPoint p) |
422 | { | 422 | { |
423 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 423 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
424 | if ( item ) | 424 | if ( item ) |
425 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 425 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
426 | KOPrefs::instance()->mWTshowDetails, | 426 | KOPrefs::instance()->mWTshowDetails, |
427 | KOPrefs::instance()->mWTshowCreated, | 427 | KOPrefs::instance()->mWTshowCreated, |
428 | KOPrefs::instance()->mWTshowChanged); | 428 | KOPrefs::instance()->mWTshowChanged); |
429 | return i18n("That is the list view" ); | 429 | return i18n("That is the list view" ); |
430 | 430 | ||
431 | } | 431 | } |
432 | 432 | ||
433 | void KOListView::setCalendar( int c ) | 433 | void KOListView::setCalendar( int c ) |
434 | { | 434 | { |
435 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 435 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
436 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), | 436 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), |
437 | i18n("Continue"), i18n("Cancel"), 0, | 437 | i18n("Continue"), i18n("Cancel"), 0, |
438 | 0, 1 ); | 438 | 0, 1 ); |
439 | if ( result != 0 ) { | 439 | if ( result != 0 ) { |
440 | return; | 440 | return; |
441 | } | 441 | } |
442 | 442 | ||
443 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 443 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
444 | int icount = delSel.count(); | 444 | int icount = delSel.count(); |
445 | if ( icount ) { | 445 | if ( icount ) { |
446 | Incidence *incidence = delSel.first(); | 446 | Incidence *incidence = delSel.first(); |
447 | while ( incidence ) { | 447 | while ( incidence ) { |
448 | incidence->setCalID( c ); | 448 | incidence->setCalID( c ); |
449 | KOListViewItem * item = getItemForEvent( incidence ); | 449 | KOListViewItem * item = getItemForEvent( incidence ); |
450 | if ( item ) { | 450 | if ( item ) { |
451 | ListItemVisitor v(item, mStartDate ); | 451 | ListItemVisitor v(item, mStartDate ); |
452 | incidence->accept(v); | 452 | incidence->accept(v); |
453 | } | 453 | } |
454 | incidence = delSel.next(); | 454 | incidence = delSel.next(); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 457 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
458 | KopiCalendarFile * cal = calendars.first(); | 458 | KopiCalendarFile * cal = calendars.first(); |
459 | while ( cal ) { | 459 | while ( cal ) { |
460 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 460 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
461 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 461 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
462 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 462 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
463 | if ( cal->isStandard ) | 463 | if ( cal->isStandard ) |
464 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 464 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
465 | cal = calendars.next(); | 465 | cal = calendars.next(); |
466 | } | 466 | } |
467 | mCalendar->setSyncEventsReadOnly(); | 467 | mCalendar->setSyncEventsReadOnly(); |
468 | mCalendar->reInitAlarmSettings(); | 468 | mCalendar->reInitAlarmSettings(); |
469 | 469 | ||
470 | } | 470 | } |
471 | void KOListView::populateCalPopup() | 471 | void KOListView::populateCalPopup() |
472 | { | 472 | { |
473 | mCalPopup->clear(); | 473 | mCalPopup->clear(); |
474 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 474 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
475 | while ( kkf ) { | 475 | while ( kkf ) { |
476 | int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); | 476 | int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); |
477 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) | 477 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) |
478 | mCalPopup->setItemEnabled( index, false ); | 478 | mCalPopup->setItemEnabled( index, false ); |
479 | kkf = KOPrefs::instance()->mCalendars.next(); | 479 | kkf = KOPrefs::instance()->mCalendars.next(); |
480 | } | 480 | } |
481 | } | 481 | } |
482 | void KOListView::updateList() | 482 | void KOListView::updateList() |
483 | { | 483 | { |
484 | // qDebug(" KOListView::updateList() "); | 484 | // qDebug(" KOListView::updateList() "); |
485 | 485 | ||
486 | } | 486 | } |
487 | 487 | ||
488 | void KOListView::clearList() | 488 | void KOListView::clearList() |
489 | { | 489 | { |
490 | clear (); | 490 | clear (); |
491 | } | 491 | } |
492 | 492 | ||
493 | void KOListView::setCat() | 493 | void KOListView::setCat() |
494 | { | 494 | { |
495 | 495 | ||
496 | bool set = true; | 496 | bool set = true; |
497 | int result = KMessageBox::warningYesNoCancel(this, | 497 | int result = KMessageBox::warningYesNoCancel(this, |
498 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), | 498 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), |
499 | i18n("Set categories"), | 499 | i18n("Set categories"), |
500 | i18n("Add"), | 500 | i18n("Add"), |
501 | i18n("Reset")); | 501 | i18n("Reset")); |
502 | if (result == KMessageBox::Cancel) return; | 502 | if (result == KMessageBox::Cancel) return; |
503 | if (result == KMessageBox::Yes) set = false; | 503 | if (result == KMessageBox::Yes) set = false; |
504 | setCategories( set ); | 504 | setCategories( set ); |
505 | } | 505 | } |
506 | 506 | ||
507 | void KOListView::setAlarm() | 507 | void KOListView::setAlarm() |
508 | { | 508 | { |
509 | KOAlarmPrefs kap( this); | 509 | KOAlarmPrefs kap( this); |
510 | if ( !kap.exec() ) | 510 | if ( !kap.exec() ) |
511 | return; | 511 | return; |
512 | QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos | 512 | QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos |
513 | Incidence* inc = delSel.first(); | 513 | Incidence* inc = delSel.first(); |
514 | int count = 0; | 514 | int count = 0; |
515 | while ( inc ) { | 515 | while ( inc ) { |
516 | ++count; | 516 | ++count; |
517 | if (kap.mAlarmButton->isChecked()) { | 517 | if (kap.mAlarmButton->isChecked()) { |
518 | if (inc->alarms().count() == 0) | 518 | if (inc->alarms().count() == 0) |
519 | inc->newAlarm(); | 519 | inc->newAlarm(); |
520 | Alarm *alarm = inc->alarms().first(); | ||
521 | alarm->setEnabled(true); | ||
522 | int j = kap.mAlarmTimeEdit->value()* -60; | ||
523 | if (kap.mAlarmIncrCombo->currentItem() == 1) | ||
524 | j = j * 60; | ||
525 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | ||
526 | j = j * (60 * 24); | ||
527 | alarm->setStartOffset( j ); | ||
528 | |||
529 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | ||
530 | alarm->setProcedureAlarm(kap.mAlarmProgram); | ||
531 | } | ||
532 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | ||
533 | alarm->setAudioAlarm(kap.mAlarmSound); | ||
534 | else | ||
535 | alarm->setType(Alarm::Invalid); | ||
536 | } else { | ||
520 | QPtrList<Alarm> alarms = inc->alarms(); | 537 | QPtrList<Alarm> alarms = inc->alarms(); |
521 | Alarm *alarm; | 538 | Alarm *alarm; |
522 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 539 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
523 | alarm->setEnabled(true); | ||
524 | int j = kap.mAlarmTimeEdit->value()* -60; | ||
525 | if (kap.mAlarmIncrCombo->currentItem() == 1) | ||
526 | j = j * 60; | ||
527 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | ||
528 | j = j * (60 * 24); | ||
529 | alarm->setStartOffset( j ); | ||
530 | |||
531 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | ||
532 | alarm->setProcedureAlarm(kap.mAlarmProgram); | ||
533 | } | ||
534 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | ||
535 | alarm->setAudioAlarm(kap.mAlarmSound); | ||
536 | else | ||
537 | alarm->setType(Alarm::Invalid); | ||
538 | //alarm->setAudioAlarm("default"); | ||
539 | // TODO: Deal with multiple alarms | ||
540 | break; // For now, stop after the first alarm | ||
541 | } | ||
542 | } else { | ||
543 | Alarm* alarm = inc->alarms().first(); | ||
544 | if ( alarm ) { | ||
545 | alarm->setEnabled(false); | 540 | alarm->setEnabled(false); |
546 | alarm->setType(Alarm::Invalid); | 541 | alarm->setType(Alarm::Invalid); |
547 | } | 542 | } |
548 | } | 543 | } |
549 | KOListViewItem* item = getItemForEvent(inc); | 544 | KOListViewItem* item = getItemForEvent(inc); |
550 | if (item) { | 545 | if (item) { |
551 | ListItemVisitor v(item, mStartDate ); | 546 | ListItemVisitor v(item, mStartDate ); |
552 | inc->accept(v); | 547 | inc->accept(v); |
553 | } | 548 | } |
554 | inc = delSel.next(); | 549 | inc = delSel.next(); |
555 | } | 550 | } |
556 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); | 551 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); |
557 | qDebug("KO: Set alarm for %d items", count); | 552 | qDebug("KO: Set alarm for %d items", count); |
558 | calendar()->reInitAlarmSettings(); | 553 | calendar()->reInitAlarmSettings(); |
559 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 554 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
560 | } | 555 | } |
561 | void KOListView::setCategories( bool removeOld ) | 556 | void KOListView::setCategories( bool removeOld ) |
562 | { | 557 | { |
563 | 558 | ||
564 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 559 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
565 | csd->setColorEnabled(); | 560 | csd->setColorEnabled(); |
566 | if (! csd->exec()) { | 561 | if (! csd->exec()) { |
567 | delete csd; | 562 | delete csd; |
568 | return; | 563 | return; |
569 | } | 564 | } |
570 | QStringList catList = csd->selectedCategories(); | 565 | QStringList catList = csd->selectedCategories(); |
571 | delete csd; | 566 | delete csd; |
572 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 567 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
573 | Incidence* inc = delSel.first(); | 568 | Incidence* inc = delSel.first(); |
574 | while ( inc ) { | 569 | while ( inc ) { |
575 | if ( removeOld ) { | 570 | if ( removeOld ) { |
576 | inc->setCategories( catList, false ); | 571 | inc->setCategories( catList, false ); |
577 | } else { | 572 | } else { |
578 | inc->addCategories( catList, false ); | 573 | inc->addCategories( catList, false ); |
579 | } | 574 | } |
580 | KOListViewItem* item = getItemForEvent(inc); | 575 | KOListViewItem* item = getItemForEvent(inc); |
581 | if (item) { | 576 | if (item) { |
582 | ListItemVisitor v(item, mStartDate ); | 577 | ListItemVisitor v(item, mStartDate ); |
583 | inc->accept(v); | 578 | inc->accept(v); |
584 | } | 579 | } |
585 | inc = delSel.next(); | 580 | inc = delSel.next(); |
586 | } | 581 | } |
587 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 582 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
588 | } | 583 | } |
589 | 584 | ||
590 | void KOListView::beamSelected() | 585 | void KOListView::beamSelected() |
591 | { | 586 | { |
592 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 587 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
593 | if ( delSel.count() ) | 588 | if ( delSel.count() ) |
594 | emit beamIncidenceList( delSel ); | 589 | emit beamIncidenceList( delSel ); |
595 | } | 590 | } |
596 | 591 | ||
597 | void KOListView::saveDescriptionToFile() | 592 | void KOListView::saveDescriptionToFile() |
598 | { | 593 | { |
599 | 594 | ||
600 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 595 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
601 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 596 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
602 | i18n("Continue"), i18n("Cancel"), 0, | 597 | i18n("Continue"), i18n("Cancel"), 0, |
603 | 0, 1 ); | 598 | 0, 1 ); |
604 | if ( result != 0 ) { | 599 | if ( result != 0 ) { |
605 | return; | 600 | return; |
606 | } | 601 | } |
607 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 602 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
608 | int icount = delSel.count(); | 603 | int icount = delSel.count(); |
609 | if ( icount ) { | 604 | if ( icount ) { |
610 | QString fn = KOPrefs::instance()->mLastSaveFile; | 605 | QString fn = KOPrefs::instance()->mLastSaveFile; |
611 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 606 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
612 | 607 | ||
613 | if ( fn == "" ) | 608 | if ( fn == "" ) |
614 | return; | 609 | return; |
615 | QFileInfo info; | 610 | QFileInfo info; |
616 | info.setFile( fn ); | 611 | info.setFile( fn ); |
617 | QString mes; | 612 | QString mes; |
618 | bool createbup = true; | 613 | bool createbup = true; |
619 | if ( info. exists() ) { | 614 | if ( info. exists() ) { |
620 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 615 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
621 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 616 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
622 | i18n("Overwrite!"), i18n("Cancel"), 0, | 617 | i18n("Overwrite!"), i18n("Cancel"), 0, |
623 | 0, 1 ); | 618 | 0, 1 ); |
624 | if ( result != 0 ) { | 619 | if ( result != 0 ) { |
625 | createbup = false; | 620 | createbup = false; |
626 | } | 621 | } |
627 | } | 622 | } |
628 | if ( createbup ) { | 623 | if ( createbup ) { |
629 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 624 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
630 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 625 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
631 | Incidence *incidence = delSel.first(); | 626 | Incidence *incidence = delSel.first(); |
632 | icount = 0; | 627 | icount = 0; |
633 | while ( incidence ) { | 628 | while ( incidence ) { |
634 | if ( incidence->typeID() == journalID ) { | 629 | if ( incidence->typeID() == journalID ) { |
635 | text += "\n************************************\n"; | 630 | text += "\n************************************\n"; |
636 | if ( !incidence->summary().isEmpty() ) | 631 | if ( !incidence->summary().isEmpty() ) |
637 | text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); | 632 | text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); |
638 | else | 633 | else |
639 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 634 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
640 | if ( !incidence->location().isEmpty() ) | 635 | if ( !incidence->location().isEmpty() ) |
641 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; | 636 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; |
642 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 637 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
643 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 638 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
644 | ++icount; | 639 | ++icount; |
645 | 640 | ||
646 | } else { | 641 | } else { |
647 | if ( !incidence->description().isEmpty() ) { | 642 | if ( !incidence->description().isEmpty() ) { |
648 | text += "\n************************************\n"; | 643 | text += "\n************************************\n"; |
649 | if ( incidence->typeID() == todoID ) | 644 | if ( incidence->typeID() == todoID ) |
650 | text += i18n("To-Do: "); | 645 | text += i18n("To-Do: "); |
651 | text += incidence->summary(); | 646 | text += incidence->summary(); |
652 | if ( !incidence->location().isEmpty() ) | 647 | if ( !incidence->location().isEmpty() ) |
653 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; | 648 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; |
654 | if ( incidence->hasStartDate() ) | 649 | if ( incidence->hasStartDate() ) |
655 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 650 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
656 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 651 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
657 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 652 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
658 | ++icount; | 653 | ++icount; |
659 | 654 | ||
660 | } | 655 | } |
661 | } | 656 | } |
662 | incidence = delSel.next(); | 657 | incidence = delSel.next(); |
663 | } | 658 | } |
664 | QFile file( fn ); | 659 | QFile file( fn ); |
665 | if (!file.open( IO_WriteOnly ) ) { | 660 | if (!file.open( IO_WriteOnly ) ) { |
666 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 661 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
667 | return; | 662 | return; |
668 | } | 663 | } |
669 | QTextStream ts( &file ); | 664 | QTextStream ts( &file ); |
670 | ts << text; | 665 | ts << text; |
671 | file.close(); | 666 | file.close(); |
672 | //qDebug("%s ", text.latin1()); | 667 | //qDebug("%s ", text.latin1()); |
673 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 668 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
674 | KOPrefs::instance()->mLastSaveFile = fn; | 669 | KOPrefs::instance()->mLastSaveFile = fn; |
675 | topLevelWidget()->setCaption(mes); | 670 | topLevelWidget()->setCaption(mes); |
676 | } | 671 | } |
677 | } | 672 | } |
678 | } | 673 | } |
679 | void KOListView::saveToFileVCS() | 674 | void KOListView::saveToFileVCS() |
680 | { | 675 | { |
681 | writeToFile( false ); | 676 | writeToFile( false ); |
682 | } | 677 | } |
683 | void KOListView::saveToFile() | 678 | void KOListView::saveToFile() |
684 | { | 679 | { |
685 | writeToFile( true ); | 680 | writeToFile( true ); |
686 | } | 681 | } |
687 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) | 682 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) |
688 | { | 683 | { |
689 | QPtrList<Incidence> delSel ; | 684 | QPtrList<Incidence> delSel ; |
690 | bool addSubTodos = false; | 685 | bool addSubTodos = false; |
691 | bool askSubTodos = true; | 686 | bool askSubTodos = true; |
692 | QListViewItem *item = mListView->firstChild (); | 687 | QListViewItem *item = mListView->firstChild (); |
693 | while ( item ) { | 688 | while ( item ) { |
694 | if ( item->isSelected() ) { | 689 | if ( item->isSelected() ) { |
695 | Incidence* inc = ((KOListViewItem *)item)->data(); | 690 | Incidence* inc = ((KOListViewItem *)item)->data(); |
696 | if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { | 691 | if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { |
697 | if ( (inc->typeID() == todoID && includeTodos) || | 692 | if ( (inc->typeID() == todoID && includeTodos) || |
698 | (inc->typeID() == eventID && includeEvents) || | 693 | (inc->typeID() == eventID && includeEvents) || |
699 | (inc->typeID() == journalID && includeJournals) ) { | 694 | (inc->typeID() == journalID && includeJournals) ) { |
700 | if ( inc->typeID() == todoID && onlyDueTodos ) { | 695 | if ( inc->typeID() == todoID && onlyDueTodos ) { |
701 | if ( ((Todo*)inc)->hasDueDate() ) | 696 | if ( ((Todo*)inc)->hasDueDate() ) |
702 | delSel.append( inc ); | 697 | delSel.append( inc ); |
703 | } else | 698 | } else |
704 | delSel.append( inc ); | 699 | delSel.append( inc ); |
705 | 700 | ||
706 | } | 701 | } |
707 | } | 702 | } |
708 | if ( inc->typeID() == todoID ) { | 703 | if ( inc->typeID() == todoID ) { |
709 | Todo * todo = (Todo*) inc; | 704 | Todo * todo = (Todo*) inc; |
710 | if ( todo->relations().count() ) { | 705 | if ( todo->relations().count() ) { |
711 | if ( askSubTodos ) { | 706 | if ( askSubTodos ) { |
712 | int result = KMessageBox::warningYesNoCancel(this, | 707 | int result = KMessageBox::warningYesNoCancel(this, |
713 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), | 708 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), |
714 | i18n("Todo has subtodos"), | 709 | i18n("Todo has subtodos"), |
715 | i18n("Yes"), | 710 | i18n("Yes"), |
716 | i18n("No")); | 711 | i18n("No")); |
717 | if ( result == KMessageBox::Cancel ) { | 712 | if ( result == KMessageBox::Cancel ) { |
718 | delSel.clear(); | 713 | delSel.clear(); |
719 | return delSel; | 714 | return delSel; |
720 | } | 715 | } |
721 | if (result == KMessageBox::Yes) | 716 | if (result == KMessageBox::Yes) |
722 | addSubTodos = true; | 717 | addSubTodos = true; |
723 | askSubTodos = false; | 718 | askSubTodos = false; |
724 | } | 719 | } |
725 | if ( addSubTodos ) { | 720 | if ( addSubTodos ) { |
726 | QPtrList<Incidence> tempSel ; | 721 | QPtrList<Incidence> tempSel ; |
727 | inc->addRelationsToList( &tempSel ); | 722 | inc->addRelationsToList( &tempSel ); |
728 | Incidence* tempinc = tempSel.first(); | 723 | Incidence* tempinc = tempSel.first(); |
729 | while ( tempinc ) { | 724 | while ( tempinc ) { |
730 | if ( delSel.findRef( tempinc ) == -1 ) { | 725 | if ( delSel.findRef( tempinc ) == -1 ) { |
731 | if ( tempinc->typeID() == todoID && onlyDueTodos ) { | 726 | if ( tempinc->typeID() == todoID && onlyDueTodos ) { |
732 | if ( ((Todo*)tempinc)->hasDueDate() ) | 727 | if ( ((Todo*)tempinc)->hasDueDate() ) |
733 | delSel.append( tempinc ); | 728 | delSel.append( tempinc ); |
734 | } else | 729 | } else |
735 | delSel.append( tempinc ); | 730 | delSel.append( tempinc ); |
736 | } | 731 | } |
737 | tempinc = tempSel.next(); | 732 | tempinc = tempSel.next(); |
738 | } | 733 | } |
739 | } | 734 | } |
740 | } | 735 | } |
741 | } | 736 | } |
742 | } | 737 | } |
743 | item = item->nextSibling(); | 738 | item = item->nextSibling(); |
744 | } | 739 | } |
745 | return delSel; | 740 | return delSel; |
746 | } | 741 | } |
747 | 742 | ||
748 | void KOListView::writeToFile( bool iCal ) | 743 | void KOListView::writeToFile( bool iCal ) |
749 | { | 744 | { |
750 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 745 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
751 | if ( !iCal ) { | 746 | if ( !iCal ) { |
752 | bool journal = false; | 747 | bool journal = false; |
753 | Incidence *incidence = delSel.first(); | 748 | Incidence *incidence = delSel.first(); |
754 | while ( incidence ) { | 749 | while ( incidence ) { |
755 | if ( incidence->typeID() == journalID ) { | 750 | if ( incidence->typeID() == journalID ) { |
756 | journal = true; | 751 | journal = true; |
757 | break; | 752 | break; |
758 | } | 753 | } |
759 | incidence = delSel.next(); | 754 | incidence = delSel.next(); |
760 | } | 755 | } |
761 | if ( journal ) { | 756 | if ( journal ) { |
762 | int result = KMessageBox::warningContinueCancel(this, | 757 | int result = KMessageBox::warningContinueCancel(this, |
763 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 758 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
764 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 759 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
765 | true); | 760 | true); |
766 | if (result != KMessageBox::Continue) return; | 761 | if (result != KMessageBox::Continue) return; |
767 | } | 762 | } |
768 | } | 763 | } |
769 | if ( delSel.count() ) { | 764 | if ( delSel.count() ) { |
770 | QString fn = KOPrefs::instance()->mLastSaveFile; | 765 | QString fn = KOPrefs::instance()->mLastSaveFile; |
771 | QString extension; | 766 | QString extension; |
772 | if ( iCal ) { | 767 | if ( iCal ) { |
773 | if ( fn.right( 4 ).lower() == ".vcs" ) { | 768 | if ( fn.right( 4 ).lower() == ".vcs" ) { |
774 | fn = fn.left( fn.length() -3) + "ics"; | 769 | fn = fn.left( fn.length() -3) + "ics"; |
775 | } | 770 | } |
776 | } else { | 771 | } else { |
777 | if ( fn.right( 4 ).lower() == ".ics" ) { | 772 | if ( fn.right( 4 ).lower() == ".ics" ) { |
778 | fn = fn.left( fn.length() -3) + "vcs"; | 773 | fn = fn.left( fn.length() -3) + "vcs"; |
779 | } | 774 | } |
780 | } | 775 | } |
781 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 776 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
782 | 777 | ||
783 | if ( fn == "" ) | 778 | if ( fn == "" ) |
784 | return; | 779 | return; |
785 | QFileInfo info; | 780 | QFileInfo info; |
786 | info.setFile( fn ); | 781 | info.setFile( fn ); |
787 | QString mes; | 782 | QString mes; |
788 | bool createbup = true; | 783 | bool createbup = true; |
789 | if ( info. exists() ) { | 784 | if ( info. exists() ) { |
790 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 785 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
791 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 786 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
792 | i18n("Overwrite!"), i18n("Cancel"), 0, | 787 | i18n("Overwrite!"), i18n("Cancel"), 0, |
793 | 0, 1 ); | 788 | 0, 1 ); |
794 | if ( result != 0 ) { | 789 | if ( result != 0 ) { |
795 | createbup = false; | 790 | createbup = false; |
796 | } | 791 | } |
797 | } | 792 | } |
798 | if ( createbup ) { | 793 | if ( createbup ) { |
799 | CalendarLocal cal; | 794 | CalendarLocal cal; |
800 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 795 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
801 | Incidence *incidence = delSel.first(); | 796 | Incidence *incidence = delSel.first(); |
802 | while ( incidence ) { | 797 | while ( incidence ) { |
803 | cal.addIncidence( incidence->clone() ); | 798 | cal.addIncidence( incidence->clone() ); |
804 | incidence = delSel.next(); | 799 | incidence = delSel.next(); |
805 | } | 800 | } |
806 | if ( iCal ) { | 801 | if ( iCal ) { |
807 | ICalFormat format; | 802 | ICalFormat format; |
808 | format.save( &cal, fn ); | 803 | format.save( &cal, fn ); |
809 | } else { | 804 | } else { |
810 | 805 | ||
811 | VCalFormat format; | 806 | VCalFormat format; |
812 | format.save( &cal, fn ); | 807 | format.save( &cal, fn ); |
813 | } | 808 | } |
814 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 809 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
815 | KOPrefs::instance()->mLastSaveFile = fn; | 810 | KOPrefs::instance()->mLastSaveFile = fn; |
816 | topLevelWidget()->setCaption(mes); | 811 | topLevelWidget()->setCaption(mes); |
817 | } | 812 | } |
818 | } | 813 | } |
819 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 814 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
820 | } | 815 | } |
821 | void KOListView::hideAll() | 816 | void KOListView::hideAll() |
822 | { | 817 | { |
823 | QPtrList<QListViewItem> delSel ; | 818 | QPtrList<QListViewItem> delSel ; |
824 | QListViewItem *item = mListView->firstChild (); | 819 | QListViewItem *item = mListView->firstChild (); |
825 | while ( item ) { | 820 | while ( item ) { |
826 | if ( item->isSelected() ) { | 821 | if ( item->isSelected() ) { |
827 | delSel.append(item); | 822 | delSel.append(item); |
828 | } | 823 | } |
829 | item = item->nextSibling(); | 824 | item = item->nextSibling(); |
830 | } | 825 | } |
831 | item = delSel.first() ; | 826 | item = delSel.first() ; |
832 | while ( item ) { | 827 | while ( item ) { |
833 | QListViewItem * del = item; | 828 | QListViewItem * del = item; |
834 | item = delSel.next(); | 829 | item = delSel.next(); |
835 | delete del; | 830 | delete del; |
836 | } | 831 | } |
837 | } | 832 | } |
838 | void KOListView::printList() | 833 | void KOListView::printList() |
839 | { | 834 | { |
840 | mListView->printList(); | 835 | mListView->printList(); |
841 | } | 836 | } |
842 | void KOListView::deleteAll() | 837 | void KOListView::deleteAll() |
843 | { | 838 | { |
844 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; | 839 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; |
845 | if ( delSel.count() ) { | 840 | if ( delSel.count() ) { |
846 | int icount = delSel.count(); | 841 | int icount = delSel.count(); |
847 | Incidence *incidence = delSel.first(); | 842 | Incidence *incidence = delSel.first(); |
848 | Incidence *toDelete; | 843 | Incidence *toDelete; |
849 | KOPrefs *p = KOPrefs::instance(); | 844 | KOPrefs *p = KOPrefs::instance(); |
850 | bool confirm = p->mConfirm; | 845 | bool confirm = p->mConfirm; |
851 | QString mess; | 846 | QString mess; |
852 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); | 847 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); |
853 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { | 848 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { |
854 | p->mConfirm = false; | 849 | p->mConfirm = false; |
855 | int delCounter = 0; | 850 | int delCounter = 0; |
856 | QDialog dia ( this, "p-dialog", true ); | 851 | QDialog dia ( this, "p-dialog", true ); |
857 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); | 852 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); |
858 | QVBoxLayout lay( &dia ); | 853 | QVBoxLayout lay( &dia ); |
859 | lay.setMargin(7); | 854 | lay.setMargin(7); |
860 | lay.setSpacing(7); | 855 | lay.setSpacing(7); |
861 | lay.addWidget( &lab); | 856 | lay.addWidget( &lab); |
862 | QProgressBar bar( icount, &dia ); | 857 | QProgressBar bar( icount, &dia ); |
863 | lay.addWidget( &bar); | 858 | lay.addWidget( &bar); |
864 | int w = 220; | 859 | int w = 220; |
865 | int h = 50; | 860 | int h = 50; |
866 | int dw = QApplication::desktop()->width(); | 861 | int dw = QApplication::desktop()->width(); |
867 | int dh = QApplication::desktop()->height(); | 862 | int dh = QApplication::desktop()->height(); |
868 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 863 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
869 | //dia.resize( 240,50 ); | 864 | //dia.resize( 240,50 ); |
870 | dia.show(); | 865 | dia.show(); |
871 | KOPrefs::instance()->mGlobalUpdateDisabled = true; | 866 | KOPrefs::instance()->mGlobalUpdateDisabled = true; |
872 | while ( incidence ) { | 867 | while ( incidence ) { |
873 | bar.setProgress( delCounter ); | 868 | bar.setProgress( delCounter ); |
874 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); | 869 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); |
875 | dia.setCaption( mess ); | 870 | dia.setCaption( mess ); |
876 | qApp->processEvents(); | 871 | qApp->processEvents(); |
877 | toDelete = (incidence); | 872 | toDelete = (incidence); |
878 | incidence = delSel.next(); | 873 | incidence = delSel.next(); |
879 | emit deleteIncidenceSignal(toDelete ); | 874 | emit deleteIncidenceSignal(toDelete ); |
880 | if ( dia.result() != 0 ) | 875 | if ( dia.result() != 0 ) |
881 | break; | 876 | break; |
882 | 877 | ||
883 | } | 878 | } |
884 | KOPrefs::instance()->mGlobalUpdateDisabled = false; | 879 | KOPrefs::instance()->mGlobalUpdateDisabled = false; |
885 | emit deleteIncidenceSignal( 0 ); | 880 | emit deleteIncidenceSignal( 0 ); |
886 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); | 881 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); |
887 | topLevelWidget ()->setCaption( mess ); | 882 | topLevelWidget ()->setCaption( mess ); |
888 | p->mConfirm = confirm; | 883 | p->mConfirm = confirm; |
889 | } | 884 | } |
890 | } | 885 | } |
891 | 886 | ||
892 | 887 | ||
893 | } | 888 | } |
894 | int KOListView::maxDatesHint() | 889 | int KOListView::maxDatesHint() |
895 | { | 890 | { |
896 | return 0; | 891 | return 0; |
897 | } | 892 | } |
898 | 893 | ||
899 | int KOListView::currentDateCount() | 894 | int KOListView::currentDateCount() |
900 | { | 895 | { |
901 | return 0; | 896 | return 0; |
902 | } | 897 | } |
903 | 898 | ||
904 | QPtrList<Incidence> KOListView::selectedIncidences() | 899 | QPtrList<Incidence> KOListView::selectedIncidences() |
905 | { | 900 | { |
906 | QPtrList<Incidence> eventList; | 901 | QPtrList<Incidence> eventList; |
907 | QListViewItem *item = mListView->firstChild (); | 902 | QListViewItem *item = mListView->firstChild (); |
908 | while ( item ) { | 903 | while ( item ) { |
909 | if ( item->isSelected() ) { | 904 | if ( item->isSelected() ) { |
910 | eventList.append(((KOListViewItem *)item)->data()); | 905 | eventList.append(((KOListViewItem *)item)->data()); |
911 | } | 906 | } |
912 | 907 | ||
913 | item = item->nextSibling(); | 908 | item = item->nextSibling(); |
914 | } | 909 | } |
915 | 910 | ||
916 | // // QListViewItem *item = mListView->selectedItem(); | 911 | // // QListViewItem *item = mListView->selectedItem(); |
917 | //if (item) eventList.append(((KOListViewItem *)item)->data()); | 912 | //if (item) eventList.append(((KOListViewItem *)item)->data()); |
918 | 913 | ||
919 | return eventList; | 914 | return eventList; |
920 | } | 915 | } |
921 | 916 | ||
922 | DateList KOListView::selectedDates() | 917 | DateList KOListView::selectedDates() |
923 | { | 918 | { |
924 | DateList eventList; | 919 | DateList eventList; |
925 | return eventList; | 920 | return eventList; |
926 | } | 921 | } |
927 | 922 | ||
928 | void KOListView::showDates(bool show) | 923 | void KOListView::showDates(bool show) |
929 | { | 924 | { |
930 | // Shouldn't we set it to a value greater 0? When showDates is called with | 925 | // Shouldn't we set it to a value greater 0? When showDates is called with |
931 | // show == true at first, then the columnwidths are set to zero. | 926 | // show == true at first, then the columnwidths are set to zero. |
932 | static int oldColWidth1 = 0; | 927 | static int oldColWidth1 = 0; |
933 | static int oldColWidth3 = 0; | 928 | static int oldColWidth3 = 0; |
934 | 929 | ||
935 | if (!show) { | 930 | if (!show) { |
936 | oldColWidth1 = mListView->columnWidth(1); | 931 | oldColWidth1 = mListView->columnWidth(1); |
937 | oldColWidth3 = mListView->columnWidth(3); | 932 | oldColWidth3 = mListView->columnWidth(3); |
938 | mListView->setColumnWidth(1, 0); | 933 | mListView->setColumnWidth(1, 0); |
939 | mListView->setColumnWidth(3, 0); | 934 | mListView->setColumnWidth(3, 0); |
940 | } else { | 935 | } else { |
941 | mListView->setColumnWidth(1, oldColWidth1); | 936 | mListView->setColumnWidth(1, oldColWidth1); |
942 | mListView->setColumnWidth(3, oldColWidth3); | 937 | mListView->setColumnWidth(3, oldColWidth3); |
943 | } | 938 | } |
944 | mListView->repaint(); | 939 | mListView->repaint(); |
945 | } | 940 | } |
946 | 941 | ||
947 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 942 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
948 | const QDate &td) | 943 | const QDate &td) |
949 | { | 944 | { |
950 | #ifndef KORG_NOPRINTER | 945 | #ifndef KORG_NOPRINTER |
951 | calPrinter->preview(CalPrinter::Day, fd, td); | 946 | calPrinter->preview(CalPrinter::Day, fd, td); |
952 | #endif | 947 | #endif |
953 | } | 948 | } |
954 | 949 | ||
955 | void KOListView::showDates() | 950 | void KOListView::showDates() |
956 | { | 951 | { |
957 | showDates(true); | 952 | showDates(true); |
958 | } | 953 | } |
959 | 954 | ||
960 | void KOListView::hideDates() | 955 | void KOListView::hideDates() |
961 | { | 956 | { |
962 | showDates(false); | 957 | showDates(false); |
963 | } | 958 | } |
964 | 959 | ||
965 | void KOListView::resetFocus() | 960 | void KOListView::resetFocus() |
966 | { | 961 | { |
967 | topLevelWidget()->setActiveWindow(); | 962 | topLevelWidget()->setActiveWindow(); |
968 | topLevelWidget()->raise(); | 963 | topLevelWidget()->raise(); |
969 | mListView->setFocus(); | 964 | mListView->setFocus(); |
970 | } | 965 | } |
971 | void KOListView::updateView() | 966 | void KOListView::updateView() |
972 | { | 967 | { |
973 | mListView->setFocus(); | 968 | mListView->setFocus(); |
974 | if ( mListView->firstChild () ) { | 969 | if ( mListView->firstChild () ) { |
975 | mListView->setCurrentItem( mListView->firstChild () ); | 970 | mListView->setCurrentItem( mListView->firstChild () ); |
976 | } | 971 | } |
977 | processSelectionChange( mListView->firstChild () ); | 972 | processSelectionChange( mListView->firstChild () ); |
978 | } | 973 | } |
979 | void KOListView::updateConfig() | 974 | void KOListView::updateConfig() |
980 | { | 975 | { |
981 | 976 | ||
982 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 977 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
983 | updateView(); | 978 | updateView(); |
984 | 979 | ||
985 | } | 980 | } |
986 | void KOListView::setStartDate(const QDate &start) | 981 | void KOListView::setStartDate(const QDate &start) |
987 | { | 982 | { |
988 | mStartDate = start; | 983 | mStartDate = start; |
989 | } | 984 | } |
990 | 985 | ||
991 | void KOListView::showDates(const QDate &start, const QDate &end) | 986 | void KOListView::showDates(const QDate &start, const QDate &end) |
992 | { | 987 | { |
993 | clear(); | 988 | clear(); |
994 | mStartDate = start; | 989 | mStartDate = start; |
995 | QDate date = start; | 990 | QDate date = start; |
996 | while( date <= end ) { | 991 | while( date <= end ) { |
997 | addEvents(calendar()->events(date)); | 992 | addEvents(calendar()->events(date)); |
998 | addTodos(calendar()->todos(date)); | 993 | addTodos(calendar()->todos(date)); |
999 | addJournals( calendar()->journals4Date(date) ); | 994 | addJournals( calendar()->journals4Date(date) ); |
1000 | date = date.addDays( 1 ); | 995 | date = date.addDays( 1 ); |
1001 | } | 996 | } |
1002 | //emit incidenceSelected( 0 ); | 997 | //emit incidenceSelected( 0 ); |
1003 | updateView(); | 998 | updateView(); |
1004 | 999 | ||
1005 | } | 1000 | } |
1006 | 1001 | ||
1007 | void KOListView::addEvents(QPtrList<Event> eventList) | 1002 | void KOListView::addEvents(QPtrList<Event> eventList) |
1008 | { | 1003 | { |
1009 | 1004 | ||
1010 | Event *ev; | 1005 | Event *ev; |
1011 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 1006 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
1012 | addIncidence(ev); | 1007 | addIncidence(ev); |
1013 | } | 1008 | } |
1014 | if ( !mListView->currentItem() ){ | 1009 | if ( !mListView->currentItem() ){ |
1015 | updateView(); | 1010 | updateView(); |
1016 | } | 1011 | } |
1017 | } | 1012 | } |
1018 | 1013 | ||
1019 | void KOListView::addTodos(QPtrList<Todo> eventList) | 1014 | void KOListView::addTodos(QPtrList<Todo> eventList) |
1020 | { | 1015 | { |
1021 | Todo *ev; | 1016 | Todo *ev; |
1022 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 1017 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
1023 | addIncidence(ev); | 1018 | addIncidence(ev); |
1024 | } | 1019 | } |
1025 | if ( !mListView->currentItem() ){ | 1020 | if ( !mListView->currentItem() ){ |
1026 | updateView(); | 1021 | updateView(); |
1027 | } | 1022 | } |
1028 | } | 1023 | } |
1029 | void KOListView::addJournals(QPtrList<Journal> eventList) | 1024 | void KOListView::addJournals(QPtrList<Journal> eventList) |
1030 | { | 1025 | { |
1031 | Journal *ev; | 1026 | Journal *ev; |
1032 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 1027 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
1033 | addIncidence(ev); | 1028 | addIncidence(ev); |
1034 | } | 1029 | } |
1035 | if ( !mListView->currentItem() ){ | 1030 | if ( !mListView->currentItem() ){ |
1036 | updateView(); | 1031 | updateView(); |
1037 | } | 1032 | } |
1038 | } | 1033 | } |
1039 | 1034 | ||
1040 | void KOListView::showCompletedTodos() | 1035 | void KOListView::showCompletedTodos() |
1041 | { | 1036 | { |
1042 | mForceShowCompletedTodos = true; | 1037 | mForceShowCompletedTodos = true; |
1043 | } | 1038 | } |
1044 | void KOListView::addIncidence(Incidence *incidence) | 1039 | void KOListView::addIncidence(Incidence *incidence) |
1045 | { | 1040 | { |
1046 | if ( mUidDict.find( incidence->uid() ) ) return; | 1041 | if ( mUidDict.find( incidence->uid() ) ) return; |
1047 | 1042 | ||
1048 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 1043 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
1049 | if ( incidence->typeID() == todoID ) { | 1044 | if ( incidence->typeID() == todoID ) { |
1050 | if ( ! mForceShowCompletedTodos ) { | 1045 | if ( ! mForceShowCompletedTodos ) { |
1051 | if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) | 1046 | if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) |
1052 | return; | 1047 | return; |
1053 | } | 1048 | } |
1054 | } | 1049 | } |
1055 | mUidDict.insert( incidence->uid(), incidence ); | 1050 | mUidDict.insert( incidence->uid(), incidence ); |
1056 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); | 1051 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); |
1057 | ListItemVisitor v(item, mStartDate ); | 1052 | ListItemVisitor v(item, mStartDate ); |
1058 | if (incidence->accept(v)) { | 1053 | if (incidence->accept(v)) { |
1059 | return; | 1054 | return; |
1060 | } | 1055 | } |
1061 | else delete item; | 1056 | else delete item; |
1062 | } | 1057 | } |
1063 | 1058 | ||
1064 | void KOListView::showEvents(QPtrList<Event> eventList) | 1059 | void KOListView::showEvents(QPtrList<Event> eventList) |
1065 | { | 1060 | { |
1066 | clear(); | 1061 | clear(); |
1067 | 1062 | ||
1068 | addEvents(eventList); | 1063 | addEvents(eventList); |
1069 | 1064 | ||
1070 | // After new creation of list view no events are selected. | 1065 | // After new creation of list view no events are selected. |
1071 | emit incidenceSelected( 0 ); | 1066 | emit incidenceSelected( 0 ); |
1072 | } | 1067 | } |
1073 | int KOListView::count() | 1068 | int KOListView::count() |
1074 | { | 1069 | { |
1075 | return mListView->childCount(); | 1070 | return mListView->childCount(); |
1076 | } | 1071 | } |
1077 | 1072 | ||
1078 | void KOListView::changeEventDisplay(Event *event, int action) | 1073 | void KOListView::changeEventDisplay(Event *event, int action) |
1079 | { | 1074 | { |
1080 | KOListViewItem *item; | 1075 | KOListViewItem *item; |
1081 | 1076 | ||
1082 | switch(action) { | 1077 | switch(action) { |
1083 | case KOGlobals::EVENTADDED: | 1078 | case KOGlobals::EVENTADDED: |
1084 | addIncidence( event ); | 1079 | addIncidence( event ); |
1085 | break; | 1080 | break; |
1086 | case KOGlobals::EVENTEDITED: | 1081 | case KOGlobals::EVENTEDITED: |
1087 | item = getItemForEvent(event); | 1082 | item = getItemForEvent(event); |
1088 | if (item) { | 1083 | if (item) { |
1089 | ListItemVisitor v(item, mStartDate ); | 1084 | ListItemVisitor v(item, mStartDate ); |
1090 | ((Incidence*)event)->accept(v); | 1085 | ((Incidence*)event)->accept(v); |
1091 | } | 1086 | } |
1092 | break; | 1087 | break; |
1093 | case KOGlobals::EVENTDELETED: | 1088 | case KOGlobals::EVENTDELETED: |
1094 | item = getItemForEvent(event); | 1089 | item = getItemForEvent(event); |
1095 | if (item) { | 1090 | if (item) { |
1096 | mUidDict.remove( event->uid() ); | 1091 | mUidDict.remove( event->uid() ); |
1097 | delete item; | 1092 | delete item; |
1098 | } | 1093 | } |
1099 | break; | 1094 | break; |
1100 | default: | 1095 | default: |
1101 | ; | 1096 | ; |
1102 | } | 1097 | } |
1103 | } | 1098 | } |
1104 | 1099 | ||
1105 | KOListViewItem *KOListView::getItemForEvent(Incidence *event) | 1100 | KOListViewItem *KOListView::getItemForEvent(Incidence *event) |
1106 | { | 1101 | { |
1107 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 1102 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |
1108 | while (item) { | 1103 | while (item) { |
1109 | if (item->data() == event) return item; | 1104 | if (item->data() == event) return item; |
1110 | item = (KOListViewItem *)item->nextSibling(); | 1105 | item = (KOListViewItem *)item->nextSibling(); |
1111 | } | 1106 | } |
1112 | return 0; | 1107 | return 0; |
1113 | } | 1108 | } |
1114 | 1109 | ||
1115 | void KOListView::defaultItemAction(QListViewItem *i) | 1110 | void KOListView::defaultItemAction(QListViewItem *i) |
1116 | { | 1111 | { |
1117 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); | 1112 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); |
1118 | if ( item ) defaultAction( item->data() ); | 1113 | if ( item ) defaultAction( item->data() ); |
1119 | 1114 | ||
1120 | } | 1115 | } |
1121 | 1116 | ||
1122 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 1117 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) |
1123 | { | 1118 | { |
1124 | mActiveItem = (KOListViewItem *)item; | 1119 | mActiveItem = (KOListViewItem *)item; |
1125 | if (mActiveItem) { | 1120 | if (mActiveItem) { |
1126 | Incidence *incidence = mActiveItem->data(); | 1121 | Incidence *incidence = mActiveItem->data(); |
1127 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); | 1122 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); |
1128 | mPopupMenu->showIncidencePopup(incidence); | 1123 | mPopupMenu->showIncidencePopup(incidence); |
1129 | 1124 | ||
1130 | /* | 1125 | /* |
1131 | if ( incidence && incidence->type() == "Event" ) { | 1126 | if ( incidence && incidence->type() == "Event" ) { |
1132 | Event *event = static_cast<Event *>( incidence ); | 1127 | Event *event = static_cast<Event *>( incidence ); |
1133 | mPopupMenu->showEventPopup(event); | 1128 | mPopupMenu->showEventPopup(event); |
1134 | } | 1129 | } |
1135 | */ | 1130 | */ |
1136 | } | 1131 | } |
1137 | } | 1132 | } |
1138 | 1133 | ||
1139 | void KOListView::readSettings(KConfig *config, QString setting) | 1134 | void KOListView::readSettings(KConfig *config, QString setting) |
1140 | { | 1135 | { |
1141 | // qDebug("KOListView::readSettings "); | 1136 | // qDebug("KOListView::readSettings "); |
1142 | mListView->restoreLayout(config,setting); | 1137 | mListView->restoreLayout(config,setting); |
1143 | } | 1138 | } |
1144 | 1139 | ||
1145 | void KOListView::writeSettings(KConfig *config, QString setting) | 1140 | void KOListView::writeSettings(KConfig *config, QString setting) |
1146 | { | 1141 | { |
1147 | // qDebug("KOListView::writeSettings "); | 1142 | // qDebug("KOListView::writeSettings "); |
1148 | mListView->saveLayout(config, setting); | 1143 | mListView->saveLayout(config, setting); |
1149 | } | 1144 | } |
1150 | 1145 | ||
1151 | void KOListView::processSelectionChange(QListViewItem *) | 1146 | void KOListView::processSelectionChange(QListViewItem *) |
1152 | { | 1147 | { |
1153 | 1148 | ||
1154 | KOListViewItem *item = | 1149 | KOListViewItem *item = |
1155 | static_cast<KOListViewItem *>( mListView->currentItem() ); | 1150 | static_cast<KOListViewItem *>( mListView->currentItem() ); |
1156 | 1151 | ||
1157 | if ( !item ) { | 1152 | if ( !item ) { |
1158 | emit incidenceSelected( 0 ); | 1153 | emit incidenceSelected( 0 ); |
1159 | } else { | 1154 | } else { |
1160 | emit incidenceSelected( item->data() ); | 1155 | emit incidenceSelected( item->data() ); |
1161 | } | 1156 | } |
1162 | } | 1157 | } |
1163 | 1158 | ||
1164 | void KOListView::clearSelection() | 1159 | void KOListView::clearSelection() |
1165 | { | 1160 | { |
1166 | mListView->selectAll( false ); | 1161 | mListView->selectAll( false ); |
1167 | } | 1162 | } |
1168 | void KOListView::allSelection() | 1163 | void KOListView::allSelection() |
1169 | { | 1164 | { |
1170 | mListView->selectAll( true ); | 1165 | mListView->selectAll( true ); |
1171 | } | 1166 | } |
1172 | 1167 | ||
1173 | void KOListView::clear() | 1168 | void KOListView::clear() |
1174 | { | 1169 | { |
1175 | mListView->clear(); | 1170 | mListView->clear(); |
1176 | mUidDict.clear(); | 1171 | mUidDict.clear(); |
1177 | } | 1172 | } |
1178 | 1173 | ||
1179 | Incidence* KOListView::currentItem() | 1174 | Incidence* KOListView::currentItem() |
1180 | { | 1175 | { |
1181 | if ( mListView->currentItem() ) | 1176 | if ( mListView->currentItem() ) |
1182 | return ((KOListViewItem*) mListView->currentItem())->data(); | 1177 | return ((KOListViewItem*) mListView->currentItem())->data(); |
1183 | return 0; | 1178 | return 0; |
1184 | } | 1179 | } |
1185 | void KOListView::keyPressEvent ( QKeyEvent *e) | 1180 | void KOListView::keyPressEvent ( QKeyEvent *e) |
1186 | { | 1181 | { |
1187 | 1182 | ||
1188 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { | 1183 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { |
1189 | deleteAll(); | 1184 | deleteAll(); |
1190 | return; | 1185 | return; |
1191 | } | 1186 | } |
1192 | 1187 | ||
1193 | e->ignore(); | 1188 | e->ignore(); |
1194 | } | 1189 | } |
1195 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) | 1190 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) |
1196 | { | 1191 | { |
1197 | 1192 | ||
1198 | switch ( e->key() ) { | 1193 | switch ( e->key() ) { |
1199 | case Qt::Key_Down: | 1194 | case Qt::Key_Down: |
1200 | if ( e->state() == ShiftButton ) { | 1195 | if ( e->state() == ShiftButton ) { |
1201 | QListViewItem* cn = currentItem(); | 1196 | QListViewItem* cn = currentItem(); |
1202 | if ( !cn ) | 1197 | if ( !cn ) |
1203 | cn = firstChild(); | 1198 | cn = firstChild(); |
1204 | if ( !cn ) | 1199 | if ( !cn ) |
1205 | return; | 1200 | return; |
1206 | while ( cn->nextSibling() ) | 1201 | while ( cn->nextSibling() ) |
1207 | cn = cn->nextSibling(); | 1202 | cn = cn->nextSibling(); |
1208 | setCurrentItem ( cn ); | 1203 | setCurrentItem ( cn ); |
1209 | ensureItemVisible ( cn ); | 1204 | ensureItemVisible ( cn ); |
1210 | 1205 | ||
1211 | e->accept(); | 1206 | e->accept(); |
1212 | return; | 1207 | return; |
1213 | } | 1208 | } |
1214 | if ( e->state() == ControlButton ) { | 1209 | if ( e->state() == ControlButton ) { |
1215 | int count = childCount (); | 1210 | int count = childCount (); |
1216 | int jump = count / 5; | 1211 | int jump = count / 5; |
1217 | QListViewItem* cn; | 1212 | QListViewItem* cn; |
1218 | cn = currentItem(); | 1213 | cn = currentItem(); |
1219 | if ( ! cn ) | 1214 | if ( ! cn ) |
1220 | return; | 1215 | return; |
1221 | if ( jump == 0 ) | 1216 | if ( jump == 0 ) |
1222 | jump = 1; | 1217 | jump = 1; |
1223 | while ( jump && cn->nextSibling() ) { | 1218 | while ( jump && cn->nextSibling() ) { |
1224 | cn = cn->nextSibling(); | 1219 | cn = cn->nextSibling(); |
1225 | --jump; | 1220 | --jump; |
1226 | } | 1221 | } |
1227 | setCurrentItem ( cn ); | 1222 | setCurrentItem ( cn ); |
1228 | ensureItemVisible ( cn ); | 1223 | ensureItemVisible ( cn ); |
1229 | 1224 | ||
1230 | } else | 1225 | } else |
1231 | QListView::keyPressEvent ( e ) ; | 1226 | QListView::keyPressEvent ( e ) ; |
1232 | e->accept(); | 1227 | e->accept(); |
1233 | break; | 1228 | break; |
1234 | 1229 | ||
1235 | case Qt::Key_Up: | 1230 | case Qt::Key_Up: |
1236 | if ( e->state() == ShiftButton ) { | 1231 | if ( e->state() == ShiftButton ) { |
1237 | QListViewItem* cn = firstChild(); | 1232 | QListViewItem* cn = firstChild(); |
1238 | if ( cn ) { | 1233 | if ( cn ) { |
1239 | setCurrentItem ( cn ); | 1234 | setCurrentItem ( cn ); |
1240 | ensureItemVisible ( cn ); | 1235 | ensureItemVisible ( cn ); |
1241 | } | 1236 | } |
1242 | e->accept(); | 1237 | e->accept(); |
1243 | return; | 1238 | return; |
1244 | } | 1239 | } |
1245 | if ( e->state() == ControlButton ) { | 1240 | if ( e->state() == ControlButton ) { |
1246 | int count = childCount (); | 1241 | int count = childCount (); |
1247 | int jump = count / 5; | 1242 | int jump = count / 5; |
1248 | QListViewItem* cn; | 1243 | QListViewItem* cn; |
1249 | cn = currentItem(); | 1244 | cn = currentItem(); |
1250 | if ( ! cn ) | 1245 | if ( ! cn ) |
1251 | return; | 1246 | return; |
1252 | if ( jump == 0 ) | 1247 | if ( jump == 0 ) |
1253 | jump = 1; | 1248 | jump = 1; |
1254 | while ( jump && cn->itemAbove ()) { | 1249 | while ( jump && cn->itemAbove ()) { |
1255 | cn = cn->itemAbove (); | 1250 | cn = cn->itemAbove (); |
1256 | --jump; | 1251 | --jump; |
1257 | } | 1252 | } |
1258 | setCurrentItem ( cn ); | 1253 | setCurrentItem ( cn ); |
1259 | ensureItemVisible ( cn ); | 1254 | ensureItemVisible ( cn ); |
1260 | } else | 1255 | } else |
1261 | QListView::keyPressEvent ( e ) ; | 1256 | QListView::keyPressEvent ( e ) ; |
1262 | e->accept(); | 1257 | e->accept(); |
1263 | break; | 1258 | break; |
1264 | case Qt::Key_I: { | 1259 | case Qt::Key_I: { |
1265 | QListViewItem* cn; | 1260 | QListViewItem* cn; |
1266 | cn = currentItem(); | 1261 | cn = currentItem(); |
1267 | if ( cn ) { | 1262 | if ( cn ) { |
1268 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1263 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1269 | if ( ci ){ | 1264 | if ( ci ){ |
1270 | //emit showIncidence( ci->data()); | 1265 | //emit showIncidence( ci->data()); |
1271 | cn = cn->nextSibling(); | 1266 | cn = cn->nextSibling(); |
1272 | if ( cn ) { | 1267 | if ( cn ) { |
1273 | setCurrentItem ( cn ); | 1268 | setCurrentItem ( cn ); |
1274 | ensureItemVisible ( cn ); | 1269 | ensureItemVisible ( cn ); |
1275 | } | 1270 | } |
1276 | emit showIncidence( ci->data()); | 1271 | emit showIncidence( ci->data()); |
1277 | } | 1272 | } |
1278 | } | 1273 | } |
1279 | e->accept(); | 1274 | e->accept(); |
1280 | } | 1275 | } |
1281 | break; | 1276 | break; |
1282 | case Qt::Key_Return: | 1277 | case Qt::Key_Return: |
1283 | case Qt::Key_Enter: | 1278 | case Qt::Key_Enter: |
1284 | { | 1279 | { |
1285 | QListViewItem* cn; | 1280 | QListViewItem* cn; |
1286 | cn = currentItem(); | 1281 | cn = currentItem(); |
1287 | if ( cn ) { | 1282 | if ( cn ) { |
1288 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1283 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1289 | if ( ci ){ | 1284 | if ( ci ){ |
1290 | if ( e->state() == ShiftButton ) | 1285 | if ( e->state() == ShiftButton ) |
1291 | ci->setSelected( false ); | 1286 | ci->setSelected( false ); |
1292 | else | 1287 | else |
1293 | ci->setSelected( true ); | 1288 | ci->setSelected( true ); |
1294 | cn = cn->nextSibling(); | 1289 | cn = cn->nextSibling(); |
1295 | if ( cn ) { | 1290 | if ( cn ) { |
1296 | setCurrentItem ( cn ); | 1291 | setCurrentItem ( cn ); |
1297 | ensureItemVisible ( cn ); | 1292 | ensureItemVisible ( cn ); |
1298 | } | 1293 | } |
1299 | } | 1294 | } |
1300 | } | 1295 | } |
1301 | e->accept(); | 1296 | e->accept(); |
1302 | } | 1297 | } |
1303 | break; | 1298 | break; |
1304 | default: | 1299 | default: |
1305 | e->ignore(); | 1300 | e->ignore(); |
1306 | } | 1301 | } |
1307 | } | 1302 | } |
1308 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1303 | KOListViewListView::KOListViewListView(KOListView * lv ) |
1309 | : KListView( lv, "kolistlistview", false ) | 1304 | : KListView( lv, "kolistlistview", false ) |
1310 | { | 1305 | { |
1311 | mYMousePos = 0; | 1306 | mYMousePos = 0; |
1312 | mPopupTimer = new QTimer(this); | 1307 | mPopupTimer = new QTimer(this); |
1313 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 1308 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
1314 | #ifndef DESKTOP_VERSION | 1309 | #ifndef DESKTOP_VERSION |
1315 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 1310 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
1316 | #endif | 1311 | #endif |
1317 | setSelectionMode( QListView::Multi ); | 1312 | setSelectionMode( QListView::Multi ); |
1318 | setMultiSelection( true); | 1313 | setMultiSelection( true); |
1319 | } | 1314 | } |
1320 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) | 1315 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) |
1321 | { | 1316 | { |
1322 | QListViewItem *qitem = firstChild (); | 1317 | QListViewItem *qitem = firstChild (); |
1323 | while ( qitem ) { | 1318 | while ( qitem ) { |
1324 | if ( qitem->isSelected() && item != qitem ) | 1319 | if ( qitem->isSelected() && item != qitem ) |
1325 | return true; | 1320 | return true; |
1326 | qitem = qitem->nextSibling(); | 1321 | qitem = qitem->nextSibling(); |
1327 | } | 1322 | } |
1328 | return false; | 1323 | return false; |
1329 | } | 1324 | } |
1330 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1325 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1331 | { | 1326 | { |
1332 | if (!e) return; | 1327 | if (!e) return; |
1333 | QPoint vp = contentsToViewport(e->pos()); | 1328 | QPoint vp = contentsToViewport(e->pos()); |
1334 | QListViewItem *item = itemAt(vp); | 1329 | QListViewItem *item = itemAt(vp); |
1335 | if (!item) { | 1330 | if (!item) { |
1336 | emit newEvent(); | 1331 | emit newEvent(); |
1337 | return; | 1332 | return; |
1338 | } | 1333 | } |
1339 | KListView::contentsMouseDoubleClickEvent(e); | 1334 | KListView::contentsMouseDoubleClickEvent(e); |
1340 | } | 1335 | } |
1341 | #if 0 | 1336 | #if 0 |
1342 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1337 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1343 | { | 1338 | { |
1344 | //qDebug("contentsMousePressEvent++++ "); | 1339 | //qDebug("contentsMousePressEvent++++ "); |
1345 | KListView::contentsMousePressEvent( e ); | 1340 | KListView::contentsMousePressEvent( e ); |
1346 | if ( e->button() == RightButton ) { | 1341 | if ( e->button() == RightButton ) { |
1347 | QListViewItem* ci = currentItem(); | 1342 | QListViewItem* ci = currentItem(); |
1348 | clearSelection () ; | 1343 | clearSelection () ; |
1349 | if ( ci ) | 1344 | if ( ci ) |
1350 | ci->setSelected( true ); | 1345 | ci->setSelected( true ); |
1351 | } | 1346 | } |
1352 | } | 1347 | } |
1353 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1348 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1354 | { | 1349 | { |
1355 | KListView::contentsMouseReleaseEvent(e); | 1350 | KListView::contentsMouseReleaseEvent(e); |
1356 | } | 1351 | } |
1357 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1352 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1358 | { | 1353 | { |
1359 | KListView::contentsMouseMoveEvent(e); | 1354 | KListView::contentsMouseMoveEvent(e); |
1360 | } | 1355 | } |
1361 | #endif | 1356 | #endif |
1362 | void KOListViewListView::popupMenu() | 1357 | void KOListViewListView::popupMenu() |
1363 | { | 1358 | { |
1364 | mPopupTimer->stop(); | 1359 | mPopupTimer->stop(); |
1365 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); | 1360 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); |
1366 | QApplication::postEvent( this->viewport(), e ); | 1361 | QApplication::postEvent( this->viewport(), e ); |
1367 | 1362 | ||
1368 | } | 1363 | } |
1369 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1364 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1370 | { | 1365 | { |
1371 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); | 1366 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); |
1372 | mYMousePos = mapToGlobal( (e->pos())).y(); | 1367 | mYMousePos = mapToGlobal( (e->pos())).y(); |
1373 | if ( e->button() == LeftButton ) { | 1368 | if ( e->button() == LeftButton ) { |
1374 | mPopupTimer->start( 600 ); | 1369 | mPopupTimer->start( 600 ); |
1375 | mEventPos = contentsToViewport(e->pos()); | 1370 | mEventPos = contentsToViewport(e->pos()); |
1376 | mEventGlobalPos = e->globalPos(); | 1371 | mEventGlobalPos = e->globalPos(); |
1377 | } | 1372 | } |
1378 | KListView::contentsMousePressEvent( e ); | 1373 | KListView::contentsMousePressEvent( e ); |
1379 | if ( e->button() == RightButton ) { | 1374 | if ( e->button() == RightButton ) { |
1380 | QListViewItem* ci = currentItem(); | 1375 | QListViewItem* ci = currentItem(); |
1381 | //clearSelection(); | 1376 | //clearSelection(); |
1382 | if ( ci ) | 1377 | if ( ci ) |
1383 | ci->setSelected( true ); | 1378 | ci->setSelected( true ); |
1384 | } | 1379 | } |
1385 | } | 1380 | } |
1386 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1381 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1387 | { | 1382 | { |
1388 | mPopupTimer->stop(); | 1383 | mPopupTimer->stop(); |
1389 | KListView::contentsMouseReleaseEvent(e); | 1384 | KListView::contentsMouseReleaseEvent(e); |
1390 | } | 1385 | } |
1391 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1386 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1392 | { | 1387 | { |
1393 | // qDebug("contentsMouseMoveEv....... "); | 1388 | // qDebug("contentsMouseMoveEv....... "); |
1394 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); | 1389 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); |
1395 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); | 1390 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); |
1396 | if ( diff < 0 ) diff = -diff; | 1391 | if ( diff < 0 ) diff = -diff; |
1397 | if ( diff > 15 ) | 1392 | if ( diff > 15 ) |
1398 | mPopupTimer->stop(); | 1393 | mPopupTimer->stop(); |
1399 | else { | 1394 | else { |
1400 | mEventPos = contentsToViewport(e->pos()); | 1395 | mEventPos = contentsToViewport(e->pos()); |
1401 | mEventGlobalPos = e->globalPos(); | 1396 | mEventGlobalPos = e->globalPos(); |
1402 | } | 1397 | } |
1403 | KListView::contentsMouseMoveEvent(e); | 1398 | KListView::contentsMouseMoveEvent(e); |
1404 | } | 1399 | } |
1405 | 1400 | ||
1406 | #define protected public | 1401 | #define protected public |
1407 | #include <qheader.h> | 1402 | #include <qheader.h> |
1408 | #undef protected | 1403 | #undef protected |
1409 | void KOListViewListView::printList() | 1404 | void KOListViewListView::printList() |
1410 | { | 1405 | { |
1411 | #ifdef DESKTOP_VERSION | 1406 | #ifdef DESKTOP_VERSION |
1412 | KOPrintPrefs pp ( this ); | 1407 | KOPrintPrefs pp ( this ); |
1413 | if (!pp.exec() ) | 1408 | if (!pp.exec() ) |
1414 | return; | 1409 | return; |
1415 | int scaleval = pp.printMode() ; | 1410 | int scaleval = pp.printMode() ; |
1416 | 1411 | ||
1417 | QPrinter printer; | 1412 | QPrinter printer; |
1418 | if (!printer.setup() ) | 1413 | if (!printer.setup() ) |
1419 | return; | 1414 | return; |
1420 | clearSelection (); | 1415 | clearSelection (); |
1421 | QPainter p; | 1416 | QPainter p; |
1422 | p.begin ( &printer ); | 1417 | p.begin ( &printer ); |
1423 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 1418 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
1424 | float dx, dy; | 1419 | float dx, dy; |
1425 | int wid = (m.width() * 9)/10; | 1420 | int wid = (m.width() * 9)/10; |
1426 | dx = (float) wid/(float)contentsWidth (); | 1421 | dx = (float) wid/(float)contentsWidth (); |
1427 | dy = (float)(m.height()) / (float)contentsHeight (); | 1422 | dy = (float)(m.height()) / (float)contentsHeight (); |
1428 | float scale; | 1423 | float scale; |
1429 | // scale to fit the width or height of the paper | 1424 | // scale to fit the width or height of the paper |
1430 | if ( dx < dy ) | 1425 | if ( dx < dy ) |
1431 | scale = dx; | 1426 | scale = dx; |
1432 | else | 1427 | else |
1433 | scale = dy; | 1428 | scale = dy; |
1434 | 1429 | ||
1435 | p.translate( m.width()/10,m.width()/10 ); | 1430 | p.translate( m.width()/10,m.width()/10 ); |
1436 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 1431 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
1437 | p.scale( scale, scale ); | 1432 | p.scale( scale, scale ); |
1438 | } | 1433 | } |
1439 | 1434 | ||
1440 | int cou = header()->count(); | 1435 | int cou = header()->count(); |
1441 | int iii; | 1436 | int iii; |
1442 | QRect rect ( 0,0,0, header()->height()); | 1437 | QRect rect ( 0,0,0, header()->height()); |
1443 | for ( iii = 0; iii < cou; ++iii ) { | 1438 | for ( iii = 0; iii < cou; ++iii ) { |
1444 | rect.setLeft ( header()->sectionPos( iii ) ); | 1439 | rect.setLeft ( header()->sectionPos( iii ) ); |
1445 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); | 1440 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); |
1446 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); | 1441 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); |
1447 | } | 1442 | } |
1448 | p.translate( 0, header()->height()); | 1443 | p.translate( 0, header()->height()); |
1449 | drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); | 1444 | drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); |
1450 | p.end(); | 1445 | p.end(); |
1451 | #endif | 1446 | #endif |
1452 | } | 1447 | } |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 2289977..53bbe28 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,2255 +1,2321 @@ | |||
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 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #else | 34 | #else |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | #include <kconfig.h> | 41 | #include <kconfig.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | 43 | ||
44 | #include <kcalendarsystem.h> | 44 | #include <kcalendarsystem.h> |
45 | 45 | ||
46 | #ifndef KORG_NOPRINTER | 46 | #ifndef KORG_NOPRINTER |
47 | #include "calprinter.h" | 47 | #include "calprinter.h" |
48 | #endif | 48 | #endif |
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #ifndef KORG_NOPLUGINS | 50 | #ifndef KORG_NOPLUGINS |
51 | #include "kocore.h" | 51 | #include "kocore.h" |
52 | #endif | 52 | #endif |
53 | #include "koglobals.h" | 53 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
55 | 55 | ||
56 | #include "komonthview.h" | 56 | #include "komonthview.h" |
57 | 57 | ||
58 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 61 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
70 | { | 70 | { |
71 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
72 | }; | 72 | }; |
73 | private: | 73 | private: |
74 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
81 | { | 81 | { |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 84 | #endif |
85 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
86 | resetOnFocusIn = true; | 86 | resetOnFocusIn = true; |
87 | setVScrollBarMode(QScrollView::AlwaysOff); | 87 | setVScrollBarMode(QScrollView::AlwaysOff); |
88 | setHScrollBarMode(QScrollView::AlwaysOff); | 88 | setHScrollBarMode(QScrollView::AlwaysOff); |
89 | } | 89 | } |
90 | KNoScrollListBox::~KNoScrollListBox() | 90 | KNoScrollListBox::~KNoScrollListBox() |
91 | { | 91 | { |
92 | #if QT_VERSION >= 0x030000 | 92 | #if QT_VERSION >= 0x030000 |
93 | 93 | ||
94 | #else | 94 | #else |
95 | delete mWT; | 95 | delete mWT; |
96 | #endif | 96 | #endif |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | 100 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) |
101 | { | 101 | { |
102 | QListBox::focusInEvent ( e ); | 102 | QListBox::focusInEvent ( e ); |
103 | if ( count() ){ | 103 | if ( count() ){ |
104 | int ci = currentItem(); | 104 | int ci = currentItem(); |
105 | if ( ci < 0 ) ci = 0; | 105 | if ( ci < 0 ) ci = 0; |
106 | 106 | ||
107 | setCurrentItem( ci ); | 107 | setCurrentItem( ci ); |
108 | setSelected ( ci, true ); | 108 | setSelected ( ci, true ); |
109 | emit highlighted( item ( ci ) ); | 109 | emit highlighted( item ( ci ) ); |
110 | 110 | ||
111 | resetOnFocusIn = true; | 111 | resetOnFocusIn = true; |
112 | 112 | ||
113 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 113 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
114 | QListBoxItem *fi = firstItem (); | 114 | QListBoxItem *fi = firstItem (); |
115 | if (fi ) { | 115 | if (fi ) { |
116 | int ihei = fi->height( this ); | 116 | int ihei = fi->height( this ); |
117 | int hei = numRows () * ihei; | 117 | int hei = numRows () * ihei; |
118 | if ( hei < height() - horizontalScrollBar()->height () ) { | 118 | if ( hei < height() - horizontalScrollBar()->height () ) { |
119 | setVScrollBarMode(QScrollView::AlwaysOff); | 119 | setVScrollBarMode(QScrollView::AlwaysOff); |
120 | } | 120 | } |
121 | else | 121 | else |
122 | setVScrollBarMode(QScrollView::Auto); | 122 | setVScrollBarMode(QScrollView::Auto); |
123 | if ( ihei *3 > height() ) { | 123 | if ( ihei *3 > height() ) { |
124 | setHScrollBarMode(QScrollView::AlwaysOff); | 124 | setHScrollBarMode(QScrollView::AlwaysOff); |
125 | } | 125 | } |
126 | else { | 126 | else { |
127 | setHScrollBarMode(QScrollView::Auto); | 127 | setHScrollBarMode(QScrollView::Auto); |
128 | } | 128 | } |
129 | } else { | 129 | } else { |
130 | setVScrollBarMode(QScrollView::Auto); | 130 | setVScrollBarMode(QScrollView::Auto); |
131 | setHScrollBarMode(QScrollView::Auto); | 131 | setHScrollBarMode(QScrollView::Auto); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | 136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) |
137 | { | 137 | { |
138 | int i = currentItem (); | 138 | int i = currentItem (); |
139 | if ( i >= 0 ) { | 139 | if ( i >= 0 ) { |
140 | setSelected ( i, false ); | 140 | setSelected ( i, false ); |
141 | } | 141 | } |
142 | QListBox::focusOutEvent ( e ); | 142 | QListBox::focusOutEvent ( e ); |
143 | setVScrollBarMode(QScrollView::AlwaysOff); | 143 | setVScrollBarMode(QScrollView::AlwaysOff); |
144 | setHScrollBarMode(QScrollView::AlwaysOff); | 144 | setHScrollBarMode(QScrollView::AlwaysOff); |
145 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); | 145 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); |
146 | } | 146 | } |
147 | 147 | ||
148 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 148 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
149 | { | 149 | { |
150 | QListBoxItem* item = itemAt ( p ); | 150 | QListBoxItem* item = itemAt ( p ); |
151 | if ( ! item ) { | 151 | if ( ! item ) { |
152 | return i18n("Click in the cell\nto add an event!"); | 152 | return i18n("Click in the cell\nto add an event!"); |
153 | } | 153 | } |
154 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 154 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
155 | KOPrefs::instance()->mWTshowDetails, | 155 | KOPrefs::instance()->mWTshowDetails, |
156 | KOPrefs::instance()->mWTshowCreated, | 156 | KOPrefs::instance()->mWTshowCreated, |
157 | KOPrefs::instance()->mWTshowChanged); | 157 | KOPrefs::instance()->mWTshowChanged); |
158 | } | 158 | } |
159 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 159 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
160 | { | 160 | { |
161 | //qDebug("KNoScrollListBox::keyPressEvent "); | 161 | //qDebug("KNoScrollListBox::keyPressEvent "); |
162 | switch(e->key()) { | 162 | switch(e->key()) { |
163 | case Key_Right: | 163 | case Key_Right: |
164 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 164 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
165 | { | 165 | { |
166 | e->ignore(); | 166 | e->ignore(); |
167 | return; | 167 | return; |
168 | } | 168 | } |
169 | scrollBy(10,0); | 169 | scrollBy(10,0); |
170 | break; | 170 | break; |
171 | case Key_Left: | 171 | case Key_Left: |
172 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 172 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
173 | { | 173 | { |
174 | e->ignore(); | 174 | e->ignore(); |
175 | return; | 175 | return; |
176 | } | 176 | } |
177 | scrollBy(-10,0); | 177 | scrollBy(-10,0); |
178 | break; | 178 | break; |
179 | case Key_Up: | 179 | case Key_Up: |
180 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 180 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
181 | e->ignore(); | 181 | e->ignore(); |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | if ( count() ) { | 184 | if ( count() ) { |
185 | if ( currentItem() == 0 ) { | 185 | if ( currentItem() == 0 ) { |
186 | emit prevCell(); | 186 | emit prevCell(); |
187 | } else { | 187 | } else { |
188 | setCurrentItem((currentItem()+count()-1)%count()); | 188 | setCurrentItem((currentItem()+count()-1)%count()); |
189 | if(!itemVisible(currentItem())) { | 189 | if(!itemVisible(currentItem())) { |
190 | if((unsigned int) currentItem() == (count()-1)) { | 190 | if((unsigned int) currentItem() == (count()-1)) { |
191 | setTopItem(currentItem()-numItemsVisible()+1); | 191 | setTopItem(currentItem()-numItemsVisible()+1); |
192 | } else { | 192 | } else { |
193 | setTopItem(topItem()-1); | 193 | setTopItem(topItem()-1); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | } | 196 | } |
197 | } | 197 | } |
198 | break; | 198 | break; |
199 | case Key_Down: | 199 | case Key_Down: |
200 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 200 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
201 | e->ignore(); | 201 | e->ignore(); |
202 | break; | 202 | break; |
203 | } | 203 | } |
204 | if ( count () ) { | 204 | if ( count () ) { |
205 | if ( ((uint)currentItem()+1) == count () ) { | 205 | if ( ((uint)currentItem()+1) == count () ) { |
206 | emit nextCell(); | 206 | emit nextCell(); |
207 | } else { | 207 | } else { |
208 | setCurrentItem((currentItem()+1)%count()); | 208 | setCurrentItem((currentItem()+1)%count()); |
209 | if(!itemVisible(currentItem())) { | 209 | if(!itemVisible(currentItem())) { |
210 | if(currentItem() == 0) { | 210 | if(currentItem() == 0) { |
211 | setTopItem(0); | 211 | setTopItem(0); |
212 | } else { | 212 | } else { |
213 | setTopItem(topItem()+1); | 213 | setTopItem(topItem()+1); |
214 | } | 214 | } |
215 | } | 215 | } |
216 | } | 216 | } |
217 | } | 217 | } |
218 | break; | 218 | break; |
219 | case Key_I: | 219 | case Key_I: |
220 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); | 220 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
221 | e->ignore(); | 221 | e->ignore(); |
222 | break; | 222 | break; |
223 | case Key_Return: | 223 | case Key_Return: |
224 | case Key_Enter: | 224 | case Key_Enter: |
225 | { | 225 | { |
226 | if ( currentItem() >= 0 ) { | 226 | if ( currentItem() >= 0 ) { |
227 | emit doubleClicked( item( currentItem() ) ); | 227 | emit doubleClicked( item( currentItem() ) ); |
228 | e->accept(); | 228 | e->accept(); |
229 | } else { | 229 | } else { |
230 | e->ignore(); | 230 | e->ignore(); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | break; | 233 | break; |
234 | case Key_Shift: | 234 | case Key_Shift: |
235 | emit shiftDown(); | 235 | emit shiftDown(); |
236 | break; | 236 | break; |
237 | default: | 237 | default: |
238 | e->ignore(); | 238 | e->ignore(); |
239 | break; | 239 | break; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | void KNoScrollListBox::oneDown() | 243 | void KNoScrollListBox::oneDown() |
244 | { | 244 | { |
245 | if ( count () ) { | 245 | if ( count () ) { |
246 | if ( ((uint)currentItem()+1) == count () ) { | 246 | if ( ((uint)currentItem()+1) == count () ) { |
247 | emit nextCell(); | 247 | emit nextCell(); |
248 | } else { | 248 | } else { |
249 | resetOnFocusIn = false; | 249 | resetOnFocusIn = false; |
250 | setCurrentItem((currentItem()+1)%count()); | 250 | setCurrentItem((currentItem()+1)%count()); |
251 | if(!itemVisible(currentItem())) { | 251 | if(!itemVisible(currentItem())) { |
252 | if(currentItem() == 0) { | 252 | if(currentItem() == 0) { |
253 | setTopItem(0); | 253 | setTopItem(0); |
254 | } else { | 254 | } else { |
255 | setTopItem(topItem()+1); | 255 | setTopItem(topItem()+1); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | } | 259 | } |
260 | } | 260 | } |
261 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 261 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
262 | { | 262 | { |
263 | switch(e->key()) { | 263 | switch(e->key()) { |
264 | case Key_Shift: | 264 | case Key_Shift: |
265 | emit shiftUp(); | 265 | emit shiftUp(); |
266 | break; | 266 | break; |
267 | default: | 267 | default: |
268 | break; | 268 | break; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 272 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
273 | { | 273 | { |
274 | QListBox::mousePressEvent(e); | 274 | QListBox::mousePressEvent(e); |
275 | 275 | ||
276 | if(e->button() == RightButton) { | 276 | if(e->button() == RightButton) { |
277 | emit rightClick(); | 277 | emit rightClick(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) | 281 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) |
282 | : QListBoxItem() | 282 | : QListBoxItem() |
283 | { | 283 | { |
284 | mblockRepaint = true; | 284 | mblockRepaint = true; |
285 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 285 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
286 | recycle( incidence, s ); | 286 | recycle( incidence, s ); |
287 | } | 287 | } |
288 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) | 288 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) |
289 | { | 289 | { |
290 | mDisplayHighlighted = false; | 290 | mDisplayHighlighted = false; |
291 | setText( s ); | 291 | setText( s ); |
292 | mMultiday = 0; | 292 | mMultiday = 0; |
293 | mIncidence = incidence; | 293 | mIncidence = incidence; |
294 | mRecur = false; | 294 | mRecur = false; |
295 | mAlarm = false; | 295 | mAlarm = false; |
296 | mReply = false; | 296 | mReply = false; |
297 | mInfo = false; | 297 | mInfo = false; |
298 | mdayPos = 0; | 298 | mdayPos = 0; |
299 | } | 299 | } |
300 | 300 | ||
301 | bool MonthViewItem::setHighlightedFalse() | 301 | bool MonthViewItem::setHighlightedFalse() |
302 | { | 302 | { |
303 | if ( !mDisplayHighlighted ) | 303 | if ( !mDisplayHighlighted ) |
304 | return false; | 304 | return false; |
305 | mDisplayHighlighted = false; | 305 | mDisplayHighlighted = false; |
306 | return true; | 306 | return true; |
307 | } | 307 | } |
308 | 308 | ||
309 | bool MonthViewItem::setHighlighted( Incidence * inc ) | 309 | bool MonthViewItem::setHighlighted( Incidence * inc ) |
310 | { | 310 | { |
311 | if ( inc == mIncidence ) { | 311 | if ( inc == mIncidence ) { |
312 | if ( mDisplayHighlighted ) | 312 | if ( mDisplayHighlighted ) |
313 | return false; | 313 | return false; |
314 | mDisplayHighlighted = true; | 314 | mDisplayHighlighted = true; |
315 | return true; | 315 | return true; |
316 | } else { | 316 | } else { |
317 | if ( !mDisplayHighlighted ) | 317 | if ( !mDisplayHighlighted ) |
318 | return false; | 318 | return false; |
319 | mDisplayHighlighted = false; | 319 | mDisplayHighlighted = false; |
320 | return true; | 320 | return true; |
321 | } | 321 | } |
322 | return false; | 322 | return false; |
323 | } | 323 | } |
324 | void MonthViewItem::paint(QPainter *p) | 324 | void MonthViewItem::paint(QPainter *p) |
325 | { | 325 | { |
326 | if ( mblockRepaint || !mIncidence ) { | 326 | if ( mblockRepaint || !mIncidence ) { |
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | #if QT_VERSION >= 0x030000 | 329 | #if QT_VERSION >= 0x030000 |
330 | bool sel = isSelected(); | 330 | bool sel = isSelected(); |
331 | #else | 331 | #else |
332 | bool sel = selected(); | 332 | bool sel = selected(); |
333 | #endif | 333 | #endif |
334 | int heihei = height( listBox () ); | 334 | int heihei = height( listBox () ); |
335 | int x = 1; | 335 | int x = 1; |
336 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) | 336 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) |
337 | { | 337 | { |
338 | 338 | ||
339 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 339 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
340 | sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); | 340 | sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); |
341 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); | 341 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); |
342 | } | 342 | } |
343 | 343 | ||
344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
345 | int size = PIXMAP_SIZE; | 345 | int size = PIXMAP_SIZE; |
346 | if ( QApplication::desktop()->width() < 300 ) | 346 | if ( QApplication::desktop()->width() < 300 ) |
347 | size = 3; | 347 | size = 3; |
348 | int y = (heihei - size -1 ) /2; | 348 | int y = (heihei - size -1 ) /2; |
349 | 349 | ||
350 | if ( mIncidence->calID() > 1 ) { | 350 | if ( mIncidence->calID() > 1 ) { |
351 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); | 351 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); |
352 | p->drawRect ( x, y-2,size,size+4); | 352 | p->drawRect ( x, y-2,size,size+4); |
353 | x += size + 1; | 353 | x += size + 1; |
354 | } | 354 | } |
355 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 355 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
356 | if ( mInfo ) { | 356 | if ( mInfo ) { |
357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
358 | x += size + 1; | 358 | x += size + 1; |
359 | } | 359 | } |
360 | if ( mRecur ) { | 360 | if ( mRecur ) { |
361 | p->fillRect ( x, y,size,size, Qt::blue ); | 361 | p->fillRect ( x, y,size,size, Qt::blue ); |
362 | x += size + 1; | 362 | x += size + 1; |
363 | } | 363 | } |
364 | if ( mAlarm ) { | 364 | if ( mAlarm ) { |
365 | p->fillRect ( x, y,size,size, Qt::red ); | 365 | p->fillRect ( x, y,size,size, Qt::red ); |
366 | x += size + 1; | 366 | x += size + 1; |
367 | } | 367 | } |
368 | if ( mReply ) { | 368 | if ( mReply ) { |
369 | p->fillRect ( x, y,size,size, Qt::yellow ); | 369 | p->fillRect ( x, y,size,size, Qt::yellow ); |
370 | x += size + 1; | 370 | x += size + 1; |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | 375 | ||
376 | 376 | ||
377 | if ( sel ) p->setPen( Qt::white ); | 377 | if ( sel ) p->setPen( Qt::white ); |
378 | else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); | 378 | else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); |
379 | 379 | ||
380 | #if 0 | 380 | #if 0 |
381 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 381 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
382 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 382 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
383 | #endif | 383 | #endif |
384 | QColor textColor = p->pen().color(); | 384 | QColor textColor = p->pen().color(); |
385 | 385 | ||
386 | 386 | ||
387 | if ( mMultiday ) { | 387 | if ( mMultiday ) { |
388 | int yyy = y+(size/2); | 388 | int yyy = y+(size/2); |
389 | int sizeM = size+2; | 389 | int sizeM = size+2; |
390 | p->setBrush( QBrush( textColor ) ); | 390 | p->setBrush( QBrush( textColor ) ); |
391 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 391 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
392 | if ( mMultiday == 2 || mMultiday == 3 ) { | 392 | if ( mMultiday == 2 || mMultiday == 3 ) { |
393 | QPointArray pa ( 3 ); | 393 | QPointArray pa ( 3 ); |
394 | pa.setPoint (0, x, yyy ); | 394 | pa.setPoint (0, x, yyy ); |
395 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 395 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
396 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 396 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
397 | p->drawPolygon( pa ); | 397 | p->drawPolygon( pa ); |
398 | } | 398 | } |
399 | if ( mMultiday == 2 || mMultiday == 1 ) { | 399 | if ( mMultiday == 2 || mMultiday == 1 ) { |
400 | QPointArray pa ( 3 ); | 400 | QPointArray pa ( 3 ); |
401 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 401 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
402 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 402 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
403 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 403 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
404 | p->drawPolygon( pa ); | 404 | p->drawPolygon( pa ); |
405 | } | 405 | } |
406 | if ( mMultiday == 1 ) { | 406 | if ( mMultiday == 1 ) { |
407 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 407 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
408 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 408 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
409 | } | 409 | } |
410 | if ( mMultiday == 3 ) { | 410 | if ( mMultiday == 3 ) { |
411 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 411 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
412 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 412 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
413 | 413 | ||
414 | } | 414 | } |
415 | x += sizeM/2 + 1; | 415 | x += sizeM/2 + 1; |
416 | x += sizeM + 1; | 416 | x += sizeM + 1; |
417 | } | 417 | } |
418 | 418 | ||
419 | if ( mIncidence->typeID() == todoID ){ | 419 | if ( mIncidence->typeID() == todoID ){ |
420 | Todo* td = ( Todo* ) mIncidence; | 420 | Todo* td = ( Todo* ) mIncidence; |
421 | if ( td->isCompleted() ) { | 421 | if ( td->isCompleted() ) { |
422 | int half = size/2; | 422 | int half = size/2; |
423 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 423 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
424 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 424 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
425 | x += half+half + 4; | 425 | x += half+half + 4; |
426 | 426 | ||
427 | } else { | 427 | } else { |
428 | int val = td->percentComplete()/20; | 428 | int val = td->percentComplete()/20; |
429 | p->fillRect ( x+1, y-2, val ,size+4,textColor ); | 429 | p->fillRect ( x+1, y-2, val ,size+4,textColor ); |
430 | p->drawRect ( x, y-2,7,size+4); | 430 | p->drawRect ( x, y-2,7,size+4); |
431 | x += size + 3; | 431 | x += size + 3; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | QFontMetrics fm = p->fontMetrics(); | 434 | QFontMetrics fm = p->fontMetrics(); |
435 | int yPos; | 435 | int yPos; |
436 | int pmheight = size; | 436 | int pmheight = size; |
437 | if( pmheight < fm.height() ) | 437 | if( pmheight < fm.height() ) |
438 | yPos = fm.ascent() + fm.leading()/2; | 438 | yPos = fm.ascent() + fm.leading()/2; |
439 | else | 439 | else |
440 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 440 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
441 | 441 | ||
442 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { | 442 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { |
443 | p->drawText( x, yPos, text() ); | 443 | p->drawText( x, yPos, text() ); |
444 | if ( mIncidence->cancelled() ) { | 444 | if ( mIncidence->cancelled() ) { |
445 | int wid = fm.width( text() ); | 445 | int wid = fm.width( text() ); |
446 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 446 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
447 | } | 447 | } |
448 | } else { | 448 | } else { |
449 | QString pText = text(); | 449 | QString pText = text(); |
450 | if( pText.mid(2,1) == ":" ) | 450 | if( pText.mid(2,1) == ":" ) |
451 | pText = pText.mid( 6 ); | 451 | pText = pText.mid( 6 ); |
452 | p->drawText( x, yPos, pText ); | 452 | p->drawText( x, yPos, pText ); |
453 | if ( mIncidence->cancelled() ) { | 453 | if ( mIncidence->cancelled() ) { |
454 | int wid = fm.width( pText ); | 454 | int wid = fm.width( pText ); |
455 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 455 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | int MonthViewItem::height(const QListBox *lb) const | 460 | int MonthViewItem::height(const QListBox *lb) const |
461 | { | 461 | { |
462 | int ret = 10; | 462 | int ret = 10; |
463 | if ( lb ) | 463 | if ( lb ) |
464 | ret = lb->fontMetrics().lineSpacing()+1; | 464 | ret = lb->fontMetrics().lineSpacing()+1; |
465 | return ret; | 465 | return ret; |
466 | } | 466 | } |
467 | 467 | ||
468 | int MonthViewItem::width(const QListBox *lb) const | 468 | int MonthViewItem::width(const QListBox *lb) const |
469 | { | 469 | { |
470 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 470 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
471 | int size = PIXMAP_SIZE; | 471 | int size = PIXMAP_SIZE; |
472 | if ( QApplication::desktop()->width() < 300 ) | 472 | if ( QApplication::desktop()->width() < 300 ) |
473 | size = 3; | 473 | size = 3; |
474 | int x = 1; | 474 | int x = 1; |
475 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 475 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
476 | if ( mInfo ) { | 476 | if ( mInfo ) { |
477 | x += size + 1; | 477 | x += size + 1; |
478 | } | 478 | } |
479 | if( mRecur ) { | 479 | if( mRecur ) { |
480 | x += size+1; | 480 | x += size+1; |
481 | } | 481 | } |
482 | if( mAlarm ) { | 482 | if( mAlarm ) { |
483 | x += size+1; | 483 | x += size+1; |
484 | } | 484 | } |
485 | if( mReply ) { | 485 | if( mReply ) { |
486 | x += size+1; | 486 | x += size+1; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | if( mMultiday ) { | 489 | if( mMultiday ) { |
490 | x += size+1+2+size/2; | 490 | x += size+1+2+size/2; |
491 | } | 491 | } |
492 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 492 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
493 | } | 493 | } |
494 | if ( ! lb ) | 494 | if ( ! lb ) |
495 | return 10; | 495 | return 10; |
496 | return lb->width(); | 496 | return lb->width(); |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 500 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
501 | : KNoScrollListBox( par ), | 501 | : KNoScrollListBox( par ), |
502 | mMonthView( parent ) | 502 | mMonthView( parent ) |
503 | { | 503 | { |
504 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 504 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
505 | currentPalette = 0; | 505 | currentPalette = 0; |
506 | // mLabel = new QLabel( this );QPushButton | 506 | // mLabel = new QLabel( this );QPushButton |
507 | mLabel = new QPushButton( this ); | 507 | mLabel = new QPushButton( this ); |
508 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 508 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
509 | //mLabel->setLineWidth( 1 ); | 509 | //mLabel->setLineWidth( 1 ); |
510 | //mLabel->setAlignment( AlignCenter ); | 510 | //mLabel->setAlignment( AlignCenter ); |
511 | mLabel->setFlat( true ); | 511 | mLabel->setFlat( true ); |
512 | mLabel->setFocusPolicy(NoFocus); | 512 | mLabel->setFocusPolicy(NoFocus); |
513 | //mItemList = new KNoScrollListBox( this ); | 513 | //mItemList = new KNoScrollListBox( this ); |
514 | setMinimumSize( 10, 10 ); | 514 | setMinimumSize( 10, 10 ); |
515 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 515 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
516 | setLineWidth( 1 ); | 516 | setLineWidth( 1 ); |
517 | //topLayout->addWidget( mItemList ); | 517 | //topLayout->addWidget( mItemList ); |
518 | mLabel->raise(); | 518 | mLabel->raise(); |
519 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 519 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
520 | mStandardPalette = palette(); | 520 | mStandardPalette = palette(); |
521 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 521 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
522 | 522 | ||
523 | enableScrollBars( false ); | 523 | enableScrollBars( false ); |
524 | updateConfig(); | 524 | updateConfig(); |
525 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 525 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
526 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 526 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
527 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 527 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
528 | SLOT( defaultAction( QListBoxItem * ) ) ); | 528 | SLOT( defaultAction( QListBoxItem * ) ) ); |
529 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 529 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
530 | const QPoint &) ), | 530 | const QPoint &) ), |
531 | SLOT( contextMenu( QListBoxItem * ) ) ); | 531 | SLOT( contextMenu( QListBoxItem * ) ) ); |
532 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 532 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
533 | SLOT( selection( QListBoxItem * ) ) ); | 533 | SLOT( selection( QListBoxItem * ) ) ); |
534 | 534 | ||
535 | /* | 535 | /* |
536 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 536 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
537 | SLOT( selection( QListBoxItem * ) ) ); | 537 | SLOT( selection( QListBoxItem * ) ) ); |
538 | */ | 538 | */ |
539 | } | 539 | } |
540 | #ifdef DESKTOP_VERSION | 540 | #ifdef DESKTOP_VERSION |
541 | QToolTipGroup *MonthViewCell::toolTipGroup() | 541 | QToolTipGroup *MonthViewCell::toolTipGroup() |
542 | { | 542 | { |
543 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 543 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
544 | return mToolTipGroup; | 544 | return mToolTipGroup; |
545 | } | 545 | } |
546 | #endif | 546 | #endif |
547 | 547 | ||
548 | void MonthViewCell::setDate( const QDate &date ) | 548 | void MonthViewCell::setDate( const QDate &date ) |
549 | { | 549 | { |
550 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 550 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
551 | mDate = date; | 551 | mDate = date; |
552 | 552 | ||
553 | 553 | ||
554 | 554 | ||
555 | //resizeEvent( 0 ); | 555 | //resizeEvent( 0 ); |
556 | } | 556 | } |
557 | 557 | ||
558 | QDate MonthViewCell::date() const | 558 | QDate MonthViewCell::date() const |
559 | { | 559 | { |
560 | return mDate; | 560 | return mDate; |
561 | } | 561 | } |
562 | 562 | ||
563 | void MonthViewCell::setPrimary( bool primary ) | 563 | void MonthViewCell::setPrimary( bool primary ) |
564 | { | 564 | { |
565 | mPrimary = primary; | 565 | mPrimary = primary; |
566 | //setMyPalette(); | 566 | //setMyPalette(); |
567 | } | 567 | } |
568 | void MonthViewCell::setMyPalette() | 568 | void MonthViewCell::setMyPalette() |
569 | { | 569 | { |
570 | 570 | ||
571 | if ( mHoliday) { | 571 | if ( mHoliday) { |
572 | if ( currentPalette == 1 ) return; | 572 | if ( currentPalette == 1 ) return; |
573 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 573 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
574 | setPalette( mHolidayPalette ); | 574 | setPalette( mHolidayPalette ); |
575 | //mLabel->setPalette( mHolidayPalette ); | 575 | //mLabel->setPalette( mHolidayPalette ); |
576 | currentPalette = 1; | 576 | currentPalette = 1; |
577 | 577 | ||
578 | } else { | 578 | } else { |
579 | if ( mPrimary ) { | 579 | if ( mPrimary ) { |
580 | if ( currentPalette == 2 ) return; | 580 | if ( currentPalette == 2 ) return; |
581 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 581 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
582 | //mLabel->setPalette( mPrimaryPalette ); | 582 | //mLabel->setPalette( mPrimaryPalette ); |
583 | setPalette( mPrimaryPalette ); | 583 | setPalette( mPrimaryPalette ); |
584 | currentPalette = 2; | 584 | currentPalette = 2; |
585 | 585 | ||
586 | } else { | 586 | } else { |
587 | if ( currentPalette == 3 ) return; | 587 | if ( currentPalette == 3 ) return; |
588 | setPalette( mNonPrimaryPalette ); | 588 | setPalette( mNonPrimaryPalette ); |
589 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 589 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
590 | //mLabel->setPalette( mNonPrimaryPalette );; | 590 | //mLabel->setPalette( mNonPrimaryPalette );; |
591 | currentPalette = 3; | 591 | currentPalette = 3; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | //QPalette pal = palette(); | 594 | //QPalette pal = palette(); |
595 | 595 | ||
596 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 596 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
597 | } | 597 | } |
598 | QPalette MonthViewCell::getPalette () | 598 | QPalette MonthViewCell::getPalette () |
599 | { | 599 | { |
600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
601 | return mStandardPalette; | 601 | return mStandardPalette; |
602 | if ( mHoliday) { | 602 | if ( mHoliday) { |
603 | return mHolidayPalette ; | 603 | return mHolidayPalette ; |
604 | } else { | 604 | } else { |
605 | if ( mPrimary ) { | 605 | if ( mPrimary ) { |
606 | return mPrimaryPalette ; | 606 | return mPrimaryPalette ; |
607 | } | 607 | } |
608 | } | 608 | } |
609 | return mNonPrimaryPalette; | 609 | return mNonPrimaryPalette; |
610 | } | 610 | } |
611 | bool MonthViewCell::isPrimary() const | 611 | bool MonthViewCell::isPrimary() const |
612 | { | 612 | { |
613 | return mPrimary; | 613 | return mPrimary; |
614 | } | 614 | } |
615 | 615 | ||
616 | void MonthViewCell::setHoliday( bool holiday ) | 616 | void MonthViewCell::setHoliday( bool holiday ) |
617 | { | 617 | { |
618 | mHoliday = holiday; | 618 | mHoliday = holiday; |
619 | //setMyPalette(); | 619 | //setMyPalette(); |
620 | } | 620 | } |
621 | 621 | ||
622 | void MonthViewCell::setHoliday( const QString &holiday ) | 622 | void MonthViewCell::setHoliday( const QString &holiday ) |
623 | { | 623 | { |
624 | mHolidayString = holiday; | 624 | mHolidayString = holiday; |
625 | 625 | ||
626 | if ( !holiday.isEmpty() ) { | 626 | if ( !holiday.isEmpty() ) { |
627 | setHoliday( true ); | 627 | setHoliday( true ); |
628 | } | 628 | } |
629 | } | 629 | } |
630 | 630 | ||
631 | void MonthViewCell::startUpdateCell() | 631 | void MonthViewCell::startUpdateCell() |
632 | { | 632 | { |
633 | blockSignals( true ); | 633 | blockSignals( true ); |
634 | mdayCount = 0; | 634 | mdayCount = 0; |
635 | setFocusPolicy(NoFocus); | 635 | setFocusPolicy(NoFocus); |
636 | if ( !mMonthView->isUpdatePossible() ) | 636 | if ( !mMonthView->isUpdatePossible() ) |
637 | return; | 637 | return; |
638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
639 | while ( mitem ) { | 639 | while ( mitem ) { |
640 | mitem->setBlockRepaint( true ); | 640 | mitem->setBlockRepaint( true ); |
641 | mitem = (MonthViewItem *)mitem->next(); | 641 | mitem = (MonthViewItem *)mitem->next(); |
642 | } | 642 | } |
643 | if ( mAvailItemList.count() > 20 ) { | 643 | if ( mAvailItemList.count() > 20 ) { |
644 | mAvailItemList.setAutoDelete( true ); | 644 | mAvailItemList.setAutoDelete( true ); |
645 | mAvailItemList.clear(); | 645 | mAvailItemList.clear(); |
646 | mAvailItemList.setAutoDelete( false ); | 646 | mAvailItemList.setAutoDelete( false ); |
647 | clear(); | 647 | clear(); |
648 | } | 648 | } |
649 | 649 | ||
650 | setPrimary( mDate.month()%2 ); | 650 | setPrimary( mDate.month()%2 ); |
651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
652 | if ( mDate == QDate::currentDate() ) { | 652 | if ( mDate == QDate::currentDate() ) { |
653 | setLineWidth( 3 ); | 653 | setLineWidth( 3 ); |
654 | } else { | 654 | } else { |
655 | setLineWidth( 1 ); | 655 | setLineWidth( 1 ); |
656 | } | 656 | } |
657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
658 | //clear(); | 658 | //clear(); |
659 | while ( CurrentAvailItem ) { | 659 | while ( CurrentAvailItem ) { |
660 | MonthViewItem *item = CurrentAvailItem; | 660 | MonthViewItem *item = CurrentAvailItem; |
661 | //item->setHighlightedFalse(); | 661 | //item->setHighlightedFalse(); |
662 | item->recycle( 0, ""); | 662 | item->recycle( 0, ""); |
663 | CurrentAvailItem = (MonthViewItem *)item->next(); | 663 | CurrentAvailItem = (MonthViewItem *)item->next(); |
664 | mAvailItemList.append( item ); | 664 | mAvailItemList.append( item ); |
665 | takeItem ( item ); | 665 | takeItem ( item ); |
666 | } | 666 | } |
667 | 667 | ||
668 | #ifdef DESKTOP_VERSION | 668 | #ifdef DESKTOP_VERSION |
669 | QToolTip::remove(this); | 669 | QToolTip::remove(this); |
670 | #endif | 670 | #endif |
671 | mToolTip.clear(); | 671 | mToolTip.clear(); |
672 | //qApp->processEvents(); | 672 | //qApp->processEvents(); |
673 | #if 0 | 673 | #if 0 |
674 | if ( !mHolidayString.isEmpty() ) { | 674 | if ( !mHolidayString.isEmpty() ) { |
675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
676 | item->setPalette( mHolidayPalette ); | 676 | item->setPalette( mHolidayPalette ); |
677 | insertItem( item ); | 677 | insertItem( item ); |
678 | mToolTip.append ( mHolidayString ); | 678 | mToolTip.append ( mHolidayString ); |
679 | } | 679 | } |
680 | #endif | 680 | #endif |
681 | } | 681 | } |
682 | 682 | ||
683 | int MonthViewCell::insertEvent(Event *event) | 683 | int MonthViewCell::insertEvent(Event *event) |
684 | { | 684 | { |
685 | bool useToolTips = true; | 685 | bool useToolTips = true; |
686 | #ifndef DESKTOP_VERSION | 686 | #ifndef DESKTOP_VERSION |
687 | useToolTips = false; | 687 | useToolTips = false; |
688 | #endif | 688 | #endif |
689 | QString mToolTipText; | 689 | QString mToolTipText; |
690 | setFocusPolicy(WheelFocus); | 690 | setFocusPolicy(WheelFocus); |
691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
693 | return mdayCount; | 693 | return mdayCount; |
694 | else | 694 | else |
695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
696 | return mdayCount; | 696 | return mdayCount; |
697 | } | 697 | } |
698 | 698 | ||
699 | if ( event->isHoliday()) { | 699 | if ( event->isHoliday()) { |
700 | setHoliday( true ); | 700 | setHoliday( true ); |
701 | if ( mDate.dayOfWeek() == 7 ) | 701 | if ( mDate.dayOfWeek() == 7 ) |
702 | setLineWidth( 3 ); | 702 | setLineWidth( 3 ); |
703 | } | 703 | } |
704 | QString text; | 704 | QString text; |
705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
706 | if (event->isMultiDay()) { | 706 | if (event->isMultiDay()) { |
707 | QString prefix = "<->";multiday = 2; | 707 | QString prefix = "<->";multiday = 2; |
708 | QString time; | 708 | QString time; |
709 | if ( event->doesRecur() ) { | 709 | if ( event->doesRecur() ) { |
710 | if ( event->recursOn( mDate) ) { | 710 | if ( event->recursOn( mDate) ) { |
711 | prefix ="->" ;multiday = 1; | 711 | prefix ="->" ;multiday = 1; |
712 | } | 712 | } |
713 | else { | 713 | else { |
714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
715 | if ( event->recursOn( mDate.addDays( -days)) ) { | 715 | if ( event->recursOn( mDate.addDays( -days)) ) { |
716 | prefix ="<-" ;multiday = 3; | 716 | prefix ="<-" ;multiday = 3; |
717 | } | 717 | } |
718 | } | 718 | } |
719 | 719 | ||
720 | } else { | 720 | } else { |
721 | if (mDate == event->dtStart().date()) { | 721 | if (mDate == event->dtStart().date()) { |
722 | prefix ="->" ;multiday = 1; | 722 | prefix ="->" ;multiday = 1; |
723 | } else if (mDate == event->dtEnd().date()) { | 723 | } else if (mDate == event->dtEnd().date()) { |
724 | prefix ="<-" ;multiday = 3; | 724 | prefix ="<-" ;multiday = 3; |
725 | } | 725 | } |
726 | } | 726 | } |
727 | if ( !event->doesFloat() ) { | 727 | if ( !event->doesFloat() ) { |
728 | if ( mDate == event->dtStart().date () ) | 728 | if ( mDate == event->dtStart().date () ) |
729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
730 | else if ( mDate == event->dtEnd().date () ) | 730 | else if ( mDate == event->dtEnd().date () ) |
731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
732 | 732 | ||
733 | } | 733 | } |
734 | text = time + event->summary(); | 734 | text = time + event->summary(); |
735 | if ( useToolTips ) | 735 | if ( useToolTips ) |
736 | mToolTipText += prefix + text; | 736 | mToolTipText += prefix + text; |
737 | } else { | 737 | } else { |
738 | if (event->doesFloat()) { | 738 | if (event->doesFloat()) { |
739 | text = event->summary(); | 739 | text = event->summary(); |
740 | if ( useToolTips ) | 740 | if ( useToolTips ) |
741 | mToolTipText += text; | 741 | mToolTipText += text; |
742 | } | 742 | } |
743 | else { | 743 | else { |
744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
745 | text += " " + event->summary(); | 745 | text += " " + event->summary(); |
746 | if ( useToolTips ) | 746 | if ( useToolTips ) |
747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
748 | } | 748 | } |
749 | } | 749 | } |
750 | if ( useToolTips && ! event->location().isEmpty() ) { | 750 | if ( useToolTips && ! event->location().isEmpty() ) { |
751 | mToolTipText += " (" + event->location() +")"; | 751 | mToolTipText += " (" + event->location() +")"; |
752 | } | 752 | } |
753 | MonthViewItem *item ; | 753 | MonthViewItem *item ; |
754 | 754 | ||
755 | if ( mAvailItemList.count() ) { | 755 | if ( mAvailItemList.count() ) { |
756 | item = mAvailItemList.first(); | 756 | item = mAvailItemList.first(); |
757 | mAvailItemList.remove( item ); | 757 | mAvailItemList.remove( item ); |
758 | item->recycle( event, text ); | 758 | item->recycle( event, text ); |
759 | } else { | 759 | } else { |
760 | item = new MonthViewItem( event, text ); | 760 | item = new MonthViewItem( event, text ); |
761 | } | 761 | } |
762 | 762 | ||
763 | QPalette pal; | 763 | QPalette pal; |
764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
765 | QStringList categories = event->categories(); | 765 | QStringList categories = event->categories(); |
766 | QString cat = categories.first(); | 766 | QString cat = categories.first(); |
767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
768 | pal = getPalette(); | 768 | pal = getPalette(); |
769 | if (cat.isEmpty()) { | 769 | if (cat.isEmpty()) { |
770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); | 771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); |
772 | } else { | 772 | } else { |
773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
774 | } | 774 | } |
775 | 775 | ||
776 | } else { | 776 | } else { |
777 | if (cat.isEmpty()) { | 777 | if (cat.isEmpty()) { |
778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); | 779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); |
780 | } else { | 780 | } else { |
781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
782 | } | 782 | } |
783 | } | 783 | } |
784 | 784 | ||
785 | } else { | 785 | } else { |
786 | pal = mStandardPalette ; | 786 | pal = mStandardPalette ; |
787 | } | 787 | } |
788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
789 | item->setPalette( pal ); | 789 | item->setPalette( pal ); |
790 | item->setRecur( event->recurrence()->doesRecur() ); | 790 | item->setRecur( event->recurrence()->doesRecur() ); |
791 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); | 791 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); |
792 | item->setMoreInfo( event->description().length() > 0 ); | 792 | item->setMoreInfo( event->description().length() > 0 ); |
793 | #ifdef DESKTOP_VERSION | 793 | #ifdef DESKTOP_VERSION |
794 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 794 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
795 | KOPrefs::instance()->email()); | 795 | KOPrefs::instance()->email()); |
796 | if ( me != 0 ) { | 796 | if ( me != 0 ) { |
797 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 797 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
798 | item->setReply(true && multiday < 2); | 798 | item->setReply(true && multiday < 2); |
799 | else | 799 | else |
800 | item->setReply(false); | 800 | item->setReply(false); |
801 | } else | 801 | } else |
802 | item->setReply(false); | 802 | item->setReply(false); |
803 | #endif | 803 | #endif |
804 | 804 | ||
805 | item->setMultiDay( multiday ); | 805 | item->setMultiDay( multiday ); |
806 | if ( multiday ) { | 806 | if ( multiday ) { |
807 | insertItem( item ,mdayCount); | 807 | insertItem( item ,mdayCount); |
808 | ++mdayCount; | 808 | ++mdayCount; |
809 | } else { | 809 | } else { |
810 | uint i = mdayCount; | 810 | uint i = mdayCount; |
811 | uint pos = mdayCount; | 811 | uint pos = mdayCount; |
812 | uint itcount = count(); | 812 | uint itcount = count(); |
813 | if ( itcount > 1000 ) { | 813 | if ( itcount > 1000 ) { |
814 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); | 814 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); |
815 | itcount = 0; | 815 | itcount = 0; |
816 | } | 816 | } |
817 | for ( i = pos; i < itcount;++i ) { | 817 | for ( i = pos; i < itcount;++i ) { |
818 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); | 818 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); |
819 | QListBoxItem* it = this->item ( i ); | 819 | QListBoxItem* it = this->item ( i ); |
820 | if ( it && text < it->text() ) { | 820 | if ( it && text < it->text() ) { |
821 | pos = i; | 821 | pos = i; |
822 | break; | 822 | break; |
823 | } | 823 | } |
824 | ++pos; | 824 | ++pos; |
825 | } | 825 | } |
826 | insertItem( item ,pos); | 826 | insertItem( item ,pos); |
827 | } | 827 | } |
828 | if ( useToolTips ) { | 828 | if ( useToolTips ) { |
829 | mToolTip.append( mToolTipText ); | 829 | mToolTip.append( mToolTipText ); |
830 | } | 830 | } |
831 | return mdayCount; | 831 | return mdayCount; |
832 | } | 832 | } |
833 | void MonthViewCell::insertTodo(Todo *todo) | 833 | void MonthViewCell::insertTodo(Todo *todo) |
834 | { | 834 | { |
835 | setFocusPolicy(WheelFocus); | 835 | setFocusPolicy(WheelFocus); |
836 | QString text; | 836 | QString text; |
837 | if (todo->hasDueDate()) { | 837 | if (todo->hasDueDate()) { |
838 | if (!todo->doesFloat()) { | 838 | if (!todo->doesFloat()) { |
839 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 839 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
840 | text += " "; | 840 | text += " "; |
841 | } | 841 | } |
842 | } | 842 | } |
843 | text += todo->summary(); | 843 | text += todo->summary(); |
844 | MonthViewItem *item ; | 844 | MonthViewItem *item ; |
845 | if ( mAvailItemList.count() ) { | 845 | if ( mAvailItemList.count() ) { |
846 | item = mAvailItemList.first(); | 846 | item = mAvailItemList.first(); |
847 | mAvailItemList.remove( item ); | 847 | mAvailItemList.remove( item ); |
848 | item->recycle( todo, text ); | 848 | item->recycle( todo, text ); |
849 | } else { | 849 | } else { |
850 | item = new MonthViewItem( todo, text ); | 850 | item = new MonthViewItem( todo, text ); |
851 | } | 851 | } |
852 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 852 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
853 | //item->setPalette( mStandardPalette ); | 853 | //item->setPalette( mStandardPalette ); |
854 | QPalette pal; | 854 | QPalette pal; |
855 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 855 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
856 | QStringList categories = todo->categories(); | 856 | QStringList categories = todo->categories(); |
857 | QString cat = categories.first(); | 857 | QString cat = categories.first(); |
858 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 858 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
859 | pal = getPalette(); | 859 | pal = getPalette(); |
860 | if (cat.isEmpty()) { | 860 | if (cat.isEmpty()) { |
861 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 861 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
862 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); | 862 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); |
863 | } else { | 863 | } else { |
864 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 864 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
865 | } | 865 | } |
866 | 866 | ||
867 | } else { | 867 | } else { |
868 | if (cat.isEmpty()) { | 868 | if (cat.isEmpty()) { |
869 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 869 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
870 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); | 870 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); |
871 | } else { | 871 | } else { |
872 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 872 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | 875 | ||
876 | } else { | 876 | } else { |
877 | pal = mStandardPalette ; | 877 | pal = mStandardPalette ; |
878 | } | 878 | } |
879 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 879 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
880 | item->setPalette( pal ); | 880 | item->setPalette( pal ); |
881 | item->setRecur( todo->recurrence()->doesRecur() ); | 881 | item->setRecur( todo->recurrence()->doesRecur() ); |
882 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); | 882 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); |
883 | item->setMoreInfo( todo->description().length() > 0 ); | 883 | item->setMoreInfo( todo->description().length() > 0 ); |
884 | insertItem( item , count()); | 884 | insertItem( item , count()); |
885 | #ifdef DESKTOP_VERSION | 885 | #ifdef DESKTOP_VERSION |
886 | mToolTip.append( text ); | 886 | mToolTip.append( text ); |
887 | #endif | 887 | #endif |
888 | } | 888 | } |
889 | void MonthViewCell::repaintfinishUpdateCell() | 889 | void MonthViewCell::repaintfinishUpdateCell() |
890 | { | 890 | { |
891 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 891 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
892 | while ( mitem ) { | 892 | while ( mitem ) { |
893 | mitem->setBlockRepaint( false ); | 893 | mitem->setBlockRepaint( false ); |
894 | updateItem ( mitem ); | 894 | updateItem ( mitem ); |
895 | mitem = (MonthViewItem *)mitem->next(); | 895 | mitem = (MonthViewItem *)mitem->next(); |
896 | } | 896 | } |
897 | blockSignals( false ); | 897 | blockSignals( false ); |
898 | } | 898 | } |
899 | void MonthViewCell::finishUpdateCell() | 899 | void MonthViewCell::finishUpdateCell() |
900 | { | 900 | { |
901 | 901 | ||
902 | 902 | ||
903 | 903 | ||
904 | #ifdef DESKTOP_VERSION | 904 | #ifdef DESKTOP_VERSION |
905 | if (mToolTip.count() > 0 ) { | 905 | if (mToolTip.count() > 0 ) { |
906 | mToolTip.sort(); | 906 | mToolTip.sort(); |
907 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 907 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
908 | } | 908 | } |
909 | #endif | 909 | #endif |
910 | //sort(); | 910 | //sort(); |
911 | //setMyPalette(); | 911 | //setMyPalette(); |
912 | setMyPalette(); | 912 | setMyPalette(); |
913 | 913 | ||
914 | resizeEvent( 0 ); | 914 | resizeEvent( 0 ); |
915 | 915 | ||
916 | } | 916 | } |
917 | void MonthViewCell::updateCell() | 917 | void MonthViewCell::updateCell() |
918 | { | 918 | { |
919 | if ( !mMonthView->isUpdatePossible() ) | 919 | if ( !mMonthView->isUpdatePossible() ) |
920 | return; | 920 | return; |
921 | startUpdateCell(); | 921 | startUpdateCell(); |
922 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 922 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
923 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 923 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
924 | Event *event; | 924 | Event *event; |
925 | for( event = events.first(); event; event = events.next() ) { // for event | 925 | for( event = events.first(); event; event = events.next() ) { // for event |
926 | insertEvent(event); | 926 | insertEvent(event); |
927 | } | 927 | } |
928 | // insert due todos | 928 | // insert due todos |
929 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 929 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
930 | Todo *todo; | 930 | Todo *todo; |
931 | for(todo = todos.first(); todo; todo = todos.next()) { | 931 | for(todo = todos.first(); todo; todo = todos.next()) { |
932 | insertTodo( todo ); | 932 | insertTodo( todo ); |
933 | } | 933 | } |
934 | finishUpdateCell(); | 934 | finishUpdateCell(); |
935 | // if ( isVisible()) | 935 | // if ( isVisible()) |
936 | //qApp->processEvents(); | 936 | //qApp->processEvents(); |
937 | } | 937 | } |
938 | 938 | ||
939 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 939 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
940 | { | 940 | { |
941 | 941 | ||
942 | if ( bigFont ) { | 942 | if ( bigFont ) { |
943 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 943 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
944 | int ps = fo.pointSize() + 2; | 944 | int ps = fo.pointSize() + 2; |
945 | if ( ps < 18 ) | 945 | if ( ps < 18 ) |
946 | ps += 2; | 946 | ps += 2; |
947 | fo.setPointSize( ps ); | 947 | fo.setPointSize( ps ); |
948 | setFont( fo ); | 948 | setFont( fo ); |
949 | } else | 949 | } else |
950 | setFont( KOPrefs::instance()->mMonthViewFont ); | 950 | setFont( KOPrefs::instance()->mMonthViewFont ); |
951 | 951 | ||
952 | QFontMetrics fm( font() ); | 952 | QFontMetrics fm( font() ); |
953 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 953 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
954 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 954 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
955 | mHolidayPalette = mStandardPalette; | 955 | mHolidayPalette = mStandardPalette; |
956 | mPrimaryPalette = mStandardPalette; | 956 | mPrimaryPalette = mStandardPalette; |
957 | mNonPrimaryPalette = mStandardPalette; | 957 | mNonPrimaryPalette = mStandardPalette; |
958 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 958 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
959 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 959 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
960 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 960 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
961 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 961 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
962 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 962 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
963 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 963 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
964 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 964 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
965 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 965 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
966 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 966 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
967 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 967 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
968 | } | 968 | } |
969 | //updateCell(); | 969 | //updateCell(); |
970 | } | 970 | } |
971 | 971 | ||
972 | void MonthViewCell::enableScrollBars( bool enabled ) | 972 | void MonthViewCell::enableScrollBars( bool enabled ) |
973 | { | 973 | { |
974 | 974 | ||
975 | return; | 975 | return; |
976 | if ( enabled ) { | 976 | if ( enabled ) { |
977 | QListBoxItem *fi = firstItem (); | 977 | QListBoxItem *fi = firstItem (); |
978 | if (fi ) { | 978 | if (fi ) { |
979 | int ihei = fi->height( this ); | 979 | int ihei = fi->height( this ); |
980 | int hei = numRows () * ihei; | 980 | int hei = numRows () * ihei; |
981 | if ( hei < height() - horizontalScrollBar()->height () ) { | 981 | if ( hei < height() - horizontalScrollBar()->height () ) { |
982 | setVScrollBarMode(QScrollView::AlwaysOff); | 982 | setVScrollBarMode(QScrollView::AlwaysOff); |
983 | } | 983 | } |
984 | else | 984 | else |
985 | setVScrollBarMode(QScrollView::Auto); | 985 | setVScrollBarMode(QScrollView::Auto); |
986 | if ( ihei *3 > height() ) { | 986 | if ( ihei *3 > height() ) { |
987 | setHScrollBarMode(QScrollView::AlwaysOff); | 987 | setHScrollBarMode(QScrollView::AlwaysOff); |
988 | } | 988 | } |
989 | else { | 989 | else { |
990 | setHScrollBarMode(QScrollView::Auto); | 990 | setHScrollBarMode(QScrollView::Auto); |
991 | } | 991 | } |
992 | } else { | 992 | } else { |
993 | setVScrollBarMode(QScrollView::Auto); | 993 | setVScrollBarMode(QScrollView::Auto); |
994 | setHScrollBarMode(QScrollView::Auto); | 994 | setHScrollBarMode(QScrollView::Auto); |
995 | } | 995 | } |
996 | } else { | 996 | } else { |
997 | setVScrollBarMode(QScrollView::AlwaysOff); | 997 | setVScrollBarMode(QScrollView::AlwaysOff); |
998 | setHScrollBarMode(QScrollView::AlwaysOff); | 998 | setHScrollBarMode(QScrollView::AlwaysOff); |
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | Incidence *MonthViewCell::selectedIncidence() | 1002 | Incidence *MonthViewCell::selectedIncidence() |
1003 | { | 1003 | { |
1004 | int index = currentItem(); | 1004 | int index = currentItem(); |
1005 | if ( index < 0 ) return 0; | 1005 | if ( index < 0 ) return 0; |
1006 | 1006 | ||
1007 | MonthViewItem *mitem = | 1007 | MonthViewItem *mitem = |
1008 | static_cast<MonthViewItem *>( item( index ) ); | 1008 | static_cast<MonthViewItem *>( item( index ) ); |
1009 | 1009 | ||
1010 | if ( !mitem ) return 0; | 1010 | if ( !mitem ) return 0; |
1011 | 1011 | ||
1012 | return mitem->incidence(); | 1012 | return mitem->incidence(); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | QDate MonthViewCell::selectedIncidenceDate() | 1015 | QDate MonthViewCell::selectedIncidenceDate() |
1016 | { | 1016 | { |
1017 | QDate qd; | 1017 | QDate qd; |
1018 | int index = currentItem(); | 1018 | int index = currentItem(); |
1019 | if ( index < 0 ) return qd; | 1019 | if ( index < 0 ) return qd; |
1020 | return mDate; | 1020 | return mDate; |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | void MonthViewCell::deselect() | 1023 | void MonthViewCell::deselect() |
1024 | { | 1024 | { |
1025 | clearSelection(); | 1025 | clearSelection(); |
1026 | enableScrollBars( false ); | 1026 | enableScrollBars( false ); |
1027 | // updateCell(); | 1027 | // updateCell(); |
1028 | } | 1028 | } |
1029 | void MonthViewCell::select() | 1029 | void MonthViewCell::select() |
1030 | { | 1030 | { |
1031 | ;// updateCell(); | 1031 | ;// updateCell(); |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 1034 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
1035 | { | 1035 | { |
1036 | if ( !mMonthView->isUpdatePossible() ) | 1036 | if ( !mMonthView->isUpdatePossible() ) |
1037 | return; | 1037 | return; |
1038 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 1038 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
1039 | deselect(); | 1039 | deselect(); |
1040 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 1040 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
1041 | 1041 | ||
1042 | QString text; | 1042 | QString text; |
1043 | //mLabel->setText( text ); | 1043 | //mLabel->setText( text ); |
1044 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 1044 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
1045 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 1045 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
1046 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); | 1046 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); |
1047 | mLabel->resize( mLabelBigSize ); | 1047 | mLabel->resize( mLabelBigSize ); |
1048 | } else { | 1048 | } else { |
1049 | mLabel->resize( mLabelSize ); | 1049 | mLabel->resize( mLabelSize ); |
1050 | text = QString::number( mDate.day() ); | 1050 | text = QString::number( mDate.day() ); |
1051 | } | 1051 | } |
1052 | mLabel->setText( text ); | 1052 | mLabel->setText( text ); |
1053 | 1053 | ||
1054 | int size = height() - mLabel->height() - lineWidth()-1; | 1054 | int size = height() - mLabel->height() - lineWidth()-1; |
1055 | //qDebug("LW %d ", lineWidth()); | 1055 | //qDebug("LW %d ", lineWidth()); |
1056 | if ( size > 0 ) | 1056 | if ( size > 0 ) |
1057 | verticalScrollBar()->setMaximumHeight( size ); | 1057 | verticalScrollBar()->setMaximumHeight( size ); |
1058 | size = width() - mLabel->width() -lineWidth()-1; | 1058 | size = width() - mLabel->width() -lineWidth()-1; |
1059 | if ( size > 0 ) | 1059 | if ( size > 0 ) |
1060 | horizontalScrollBar()->setMaximumWidth( size ); | 1060 | horizontalScrollBar()->setMaximumWidth( size ); |
1061 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1061 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1062 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1062 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1063 | // mItemList->resize ( width(), height () ); | 1063 | // mItemList->resize ( width(), height () ); |
1064 | if ( e ) | 1064 | if ( e ) |
1065 | KNoScrollListBox::resizeEvent ( e ); | 1065 | KNoScrollListBox::resizeEvent ( e ); |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1068 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
1069 | { | 1069 | { |
1070 | 1070 | ||
1071 | if ( !item ) { | 1071 | if ( !item ) { |
1072 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1072 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1073 | emit newEventSignal( dt ); | 1073 | emit newEventSignal( dt ); |
1074 | return; | 1074 | return; |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1077 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1078 | Incidence *incidence = eventItem->incidence(); | 1078 | Incidence *incidence = eventItem->incidence(); |
1079 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1079 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1080 | } | 1080 | } |
1081 | void MonthViewCell::showDay() | 1081 | void MonthViewCell::showDay() |
1082 | { | 1082 | { |
1083 | emit showDaySignal( date() ); | 1083 | emit showDaySignal( date() ); |
1084 | } | 1084 | } |
1085 | void MonthViewCell::newEvent() | 1085 | void MonthViewCell::newEvent() |
1086 | { | 1086 | { |
1087 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1087 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1088 | emit newEventSignal( dt ); | 1088 | emit newEventSignal( dt ); |
1089 | } | 1089 | } |
1090 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1090 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
1091 | { | 1091 | { |
1092 | mMonthView->setSelectedCell( this ); | 1092 | mMonthView->setSelectedCell( this ); |
1093 | if ( item == 0 ) { | 1093 | if ( item == 0 ) { |
1094 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1094 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1095 | emit newEventSignal( dt ); | 1095 | emit newEventSignal( dt ); |
1096 | return; | 1096 | return; |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1101 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1102 | { | 1102 | { |
1103 | mMonthView->setPopupCell( this ); | 1103 | mMonthView->setPopupCell( this ); |
1104 | if ( !item ) { | 1104 | if ( !item ) { |
1105 | mMonthView->showContextMenu( 0 ); | 1105 | mMonthView->showContextMenu( 0 ); |
1106 | return; | 1106 | return; |
1107 | } | 1107 | } |
1108 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1108 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1109 | Incidence *incidence = eventItem->incidence(); | 1109 | Incidence *incidence = eventItem->incidence(); |
1110 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1110 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | void MonthViewCell::selection( QListBoxItem *item ) | 1113 | void MonthViewCell::selection( QListBoxItem *item ) |
1114 | { | 1114 | { |
1115 | if ( !item ) { | 1115 | if ( !item ) { |
1116 | emit highlightIncidence( 0 , this, 0 ); | 1116 | emit highlightIncidence( 0 , this, 0 ); |
1117 | return; | 1117 | return; |
1118 | } | 1118 | } |
1119 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); | 1119 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); |
1120 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); | 1120 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); |
1121 | mMonthView->setSelectedCell( this ); | 1121 | mMonthView->setSelectedCell( this ); |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | void MonthViewCell::deHighLight() | 1124 | void MonthViewCell::deHighLight() |
1125 | { | 1125 | { |
1126 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1126 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1127 | while ( mitem ) { | 1127 | while ( mitem ) { |
1128 | if ( mitem->setHighlightedFalse() ) | 1128 | if ( mitem->setHighlightedFalse() ) |
1129 | updateItem ( mitem ); | 1129 | updateItem ( mitem ); |
1130 | mitem = (MonthViewItem *)mitem->next(); | 1130 | mitem = (MonthViewItem *)mitem->next(); |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | // returns true if no inc found | 1133 | // returns true if no inc found |
1134 | bool MonthViewCell::doHighLight( Incidence * inc ) | 1134 | bool MonthViewCell::doHighLight( Incidence * inc ) |
1135 | { | 1135 | { |
1136 | 1136 | ||
1137 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1137 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1138 | while ( mitem ) { | 1138 | while ( mitem ) { |
1139 | if ( mitem->incidence() == inc ) { | 1139 | if ( mitem->incidence() == inc ) { |
1140 | if ( mitem->setHighlighted( inc ) ) | 1140 | if ( mitem->setHighlighted( inc ) ) |
1141 | updateItem ( mitem ); | 1141 | updateItem ( mitem ); |
1142 | return false; | 1142 | return false; |
1143 | } | 1143 | } |
1144 | mitem = (MonthViewItem *)mitem->next(); | 1144 | mitem = (MonthViewItem *)mitem->next(); |
1145 | } | 1145 | } |
1146 | return true; | 1146 | return true; |
1147 | } | 1147 | } |
1148 | // ******************************************************************************* | 1148 | // ******************************************************************************* |
1149 | // ******************************************************************************* | 1149 | // ******************************************************************************* |
1150 | // ******************************************************************************* | 1150 | // ******************************************************************************* |
1151 | 1151 | ||
1152 | 1152 | ||
1153 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1153 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1154 | : KOEventView( calendar, parent, name ), | 1154 | : KOEventView( calendar, parent, name ), |
1155 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1155 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1156 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1156 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1157 | { | 1157 | { |
1158 | mFlagKeyPressed = false; | 1158 | mFlagKeyPressed = false; |
1159 | mShortDayLabelsM = false; | 1159 | mShortDayLabelsM = false; |
1160 | mShortDayLabelsW = false; | 1160 | mShortDayLabelsW = false; |
1161 | skipResize = false; | 1161 | skipResize = false; |
1162 | clPending = true; | 1162 | clPending = true; |
1163 | mPopupCell = 0; | 1163 | mPopupCell = 0; |
1164 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1164 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1165 | mWidStack = new QWidgetStack( this ); | 1165 | mWidStack = new QWidgetStack( this ); |
1166 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1166 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1167 | mMonthView = new QWidget( mWidStack ); | 1167 | mMonthView = new QWidget( mWidStack ); |
1168 | mWeekView = new QWidget( mWidStack ); | 1168 | mWeekView = new QWidget( mWidStack ); |
1169 | #if QT_VERSION >= 0x030000 | 1169 | #if QT_VERSION >= 0x030000 |
1170 | mWidStack->addWidget(mMonthView ); | 1170 | mWidStack->addWidget(mMonthView ); |
1171 | mWidStack->addWidget(mWeekView ); | 1171 | mWidStack->addWidget(mWeekView ); |
1172 | #else | 1172 | #else |
1173 | mWidStack->addWidget( mMonthView, 1 ); | 1173 | mWidStack->addWidget( mMonthView, 1 ); |
1174 | mWidStack->addWidget( mWeekView , 1 ); | 1174 | mWidStack->addWidget( mWeekView , 1 ); |
1175 | #endif | 1175 | #endif |
1176 | hb->addWidget( mNavigatorBar ); | 1176 | hb->addWidget( mNavigatorBar ); |
1177 | hb->addWidget( mWidStack ); | 1177 | hb->addWidget( mWidStack ); |
1178 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1178 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1179 | updatePossible = false; | 1179 | updatePossible = false; |
1180 | //updatePossible = true; | 1180 | //updatePossible = true; |
1181 | mCells.setAutoDelete( true ); | 1181 | mCells.setAutoDelete( true ); |
1182 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1182 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1183 | mDayLabels.resize( mDaysPerWeek ); | 1183 | mDayLabels.resize( mDaysPerWeek ); |
1184 | mDayLabelsW.resize( mDaysPerWeek ); | 1184 | mDayLabelsW.resize( mDaysPerWeek ); |
1185 | QFont bfont = font(); | 1185 | QFont bfont = font(); |
1186 | if ( QApplication::desktop()->width() < 650 ) { | 1186 | if ( QApplication::desktop()->width() < 650 ) { |
1187 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1187 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1188 | } | 1188 | } |
1189 | bfont.setBold( true ); | 1189 | bfont.setBold( true ); |
1190 | int i; | 1190 | int i; |
1191 | 1191 | ||
1192 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1192 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1193 | QLabel *label = new QLabel( mMonthView ); | 1193 | QLabel *label = new QLabel( mMonthView ); |
1194 | label->setFont(bfont); | 1194 | label->setFont(bfont); |
1195 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1195 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1196 | label->setLineWidth(1); | 1196 | label->setLineWidth(1); |
1197 | label->setAlignment(AlignCenter); | 1197 | label->setAlignment(AlignCenter); |
1198 | mDayLabels.insert( i, label ); | 1198 | mDayLabels.insert( i, label ); |
1199 | label = new QLabel( mWeekView ); | 1199 | label = new QLabel( mWeekView ); |
1200 | label->setFont(bfont); | 1200 | label->setFont(bfont); |
1201 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1201 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1202 | label->setLineWidth(1); | 1202 | label->setLineWidth(1); |
1203 | label->setAlignment(AlignCenter); | 1203 | label->setAlignment(AlignCenter); |
1204 | mDayLabelsW.insert( i, label ); | 1204 | mDayLabelsW.insert( i, label ); |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | bfont.setBold( false ); | 1207 | bfont.setBold( false ); |
1208 | mWeekLabels.resize( mNumWeeks+1 ); | 1208 | mWeekLabels.resize( mNumWeeks+1 ); |
1209 | mWeekLabelsW.resize( 2 ); | 1209 | mWeekLabelsW.resize( 2 ); |
1210 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1210 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1211 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1211 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1212 | label->setFocusPolicy(NoFocus); | 1212 | label->setFocusPolicy(NoFocus); |
1213 | label->setFont(bfont); | 1213 | label->setFont(bfont); |
1214 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1214 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1215 | label->setFlat(true); | 1215 | label->setFlat(true); |
1216 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1216 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1217 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1217 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1218 | //label->setLineWidth(1); | 1218 | //label->setLineWidth(1); |
1219 | //label->setAlignment(AlignCenter); | 1219 | //label->setAlignment(AlignCenter); |
1220 | mWeekLabels.insert( i, label ); | 1220 | mWeekLabels.insert( i, label ); |
1221 | } | 1221 | } |
1222 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1222 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1223 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1223 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); |
1224 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1224 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1225 | 1225 | ||
1226 | for( i = 0; i < 1+1; i++ ) { | 1226 | for( i = 0; i < 1+1; i++ ) { |
1227 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1227 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1228 | label->setFocusPolicy(NoFocus); | 1228 | label->setFocusPolicy(NoFocus); |
1229 | label->setFont(bfont); | 1229 | label->setFont(bfont); |
1230 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1230 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1231 | label->setFlat(true); | 1231 | label->setFlat(true); |
1232 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1232 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1233 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1233 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1234 | //label->setLineWidth(1); | 1234 | //label->setLineWidth(1); |
1235 | //label->setAlignment(AlignCenter); | 1235 | //label->setAlignment(AlignCenter); |
1236 | mWeekLabelsW.insert( i, label ); | 1236 | mWeekLabelsW.insert( i, label ); |
1237 | } | 1237 | } |
1238 | mWeekLabelsW[1]->setText( i18n("W")); | 1238 | mWeekLabelsW[1]->setText( i18n("W")); |
1239 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1239 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); |
1240 | 1240 | ||
1241 | 1241 | ||
1242 | int row, col; | 1242 | int row, col; |
1243 | mCells.resize( mNumCells ); | 1243 | mCells.resize( mNumCells ); |
1244 | for( row = 0; row < mNumWeeks; ++row ) { | 1244 | for( row = 0; row < mNumWeeks; ++row ) { |
1245 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1245 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1246 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1246 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1247 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1247 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1248 | 1248 | ||
1249 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1249 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1250 | SLOT( defaultAction( Incidence * ) ) ); | 1250 | SLOT( defaultAction( Incidence * ) ) ); |
1251 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1251 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1252 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1252 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1253 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1253 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1254 | SIGNAL( showDaySignal( QDate ) ) ); | 1254 | SIGNAL( showDaySignal( QDate ) ) ); |
1255 | connect( cell, SIGNAL( nextCell() ), | 1255 | connect( cell, SIGNAL( nextCell() ), |
1256 | SLOT( nextCell() ) ); | 1256 | SLOT( nextCell() ) ); |
1257 | connect( cell, SIGNAL( prevCell() ), | 1257 | connect( cell, SIGNAL( prevCell() ), |
1258 | SLOT( prevCell() ) ); | 1258 | SLOT( prevCell() ) ); |
1259 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1259 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1260 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1260 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1261 | } | 1261 | } |
1262 | } | 1262 | } |
1263 | mCellsW.resize( mDaysPerWeek ); | 1263 | mCellsW.resize( mDaysPerWeek ); |
1264 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1264 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1265 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1265 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1266 | mCellsW.insert( col, cell ); | 1266 | mCellsW.insert( col, cell ); |
1267 | 1267 | ||
1268 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1268 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1269 | SLOT( defaultAction( Incidence * ) ) ); | 1269 | SLOT( defaultAction( Incidence * ) ) ); |
1270 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1270 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1271 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1271 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1272 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1272 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1273 | SIGNAL( showDaySignal( QDate ) ) ); | 1273 | SIGNAL( showDaySignal( QDate ) ) ); |
1274 | connect( cell, SIGNAL( nextCell() ), | 1274 | connect( cell, SIGNAL( nextCell() ), |
1275 | SLOT( nextCell() ) ); | 1275 | SLOT( nextCell() ) ); |
1276 | connect( cell, SIGNAL( prevCell() ), | 1276 | connect( cell, SIGNAL( prevCell() ), |
1277 | SLOT( prevCell() ) ); | 1277 | SLOT( prevCell() ) ); |
1278 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1278 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1279 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1279 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1280 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1280 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1281 | } | 1281 | } |
1282 | 1282 | ||
1283 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1283 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1284 | mContextMenu = eventPopup(); | 1284 | mContextMenu = eventPopup(); |
1285 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1285 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1286 | i18n("New Event..."),this, | 1286 | i18n("New Event..."),this, |
1287 | SLOT(slotNewEvent()),false); | 1287 | SLOT(slotNewEvent()),false); |
1288 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1288 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1289 | i18n("New Todo..."),this, | 1289 | i18n("New Todo..."),this, |
1290 | SLOT(slotNewTodo()),false); | 1290 | SLOT(slotNewTodo()),false); |
1291 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1291 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1292 | i18n("Journal"),this, | 1292 | i18n("Journal"),this, |
1293 | SLOT(slotEditJournal()),false); | 1293 | SLOT(slotEditJournal()),false); |
1294 | 1294 | ||
1295 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, | 1295 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, |
1296 | SLOT( catChanged( Incidence * ) )); | 1296 | SLOT( catChanged( Incidence * ) )); |
1297 | 1297 | ||
1298 | 1298 | ||
1299 | QString pathString = ""; | 1299 | QString pathString = ""; |
1300 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 1300 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
1301 | if ( QApplication::desktop()->width() < 480 ) | 1301 | if ( QApplication::desktop()->width() < 480 ) |
1302 | pathString += "icons16/"; | 1302 | pathString += "icons16/"; |
1303 | } else | 1303 | } else |
1304 | pathString += "iconsmini/"; | 1304 | pathString += "iconsmini/"; |
1305 | mNewItemMenu = new QPopupMenu( this ); | 1305 | mNewItemMenu = new QPopupMenu( this ); |
1306 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); | 1306 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); |
1307 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); | 1307 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); |
1308 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); | 1308 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); |
1309 | 1309 | ||
1310 | // updateConfig(); //useless here... | 1310 | // updateConfig(); //useless here... |
1311 | // ... but we need mWidthLongDayLabel computed | 1311 | // ... but we need mWidthLongDayLabel computed |
1312 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1312 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1313 | mWidthLongDayLabel = 0; | 1313 | mWidthLongDayLabel = 0; |
1314 | for (int i = 0; i < 7; i++) { | 1314 | for (int i = 0; i < 7; i++) { |
1315 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1315 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1316 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1316 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1319 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1320 | 1320 | ||
1321 | #if 0 | 1321 | #if 0 |
1322 | if ( mShowWeekView ) | 1322 | if ( mShowWeekView ) |
1323 | mWidStack->raiseWidget( mWeekView ); | 1323 | mWidStack->raiseWidget( mWeekView ); |
1324 | else | 1324 | else |
1325 | mWidStack->raiseWidget( mMonthView ); | 1325 | mWidStack->raiseWidget( mMonthView ); |
1326 | #endif | 1326 | #endif |
1327 | 1327 | ||
1328 | emit incidenceSelected( 0 ); | 1328 | emit incidenceSelected( 0 ); |
1329 | 1329 | ||
1330 | mComputeLayoutTimer = new QTimer( this ); | 1330 | mComputeLayoutTimer = new QTimer( this ); |
1331 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1331 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1332 | 1332 | ||
1333 | 1333 | ||
1334 | #ifndef DESKTOP_VERSION | 1334 | #ifndef DESKTOP_VERSION |
1335 | resize( QApplication::desktop()->size() ); | 1335 | resize( QApplication::desktop()->size() ); |
1336 | #else | 1336 | #else |
1337 | resize(640, 480 ); | 1337 | resize(640, 480 ); |
1338 | updatePossible = true; | 1338 | updatePossible = true; |
1339 | #endif | 1339 | #endif |
1340 | computeLayout(); | 1340 | computeLayout(); |
1341 | 1341 | ||
1342 | if ( mShowWeekView ) | 1342 | if ( mShowWeekView ) |
1343 | mWidStack->raiseWidget( mWeekView ); | 1343 | mWidStack->raiseWidget( mWeekView ); |
1344 | else | 1344 | else |
1345 | mWidStack->raiseWidget( mMonthView ); | 1345 | mWidStack->raiseWidget( mMonthView ); |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | KOMonthView::~KOMonthView() | 1348 | KOMonthView::~KOMonthView() |
1349 | { | 1349 | { |
1350 | delete mContextMenu; | 1350 | delete mContextMenu; |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | void KOMonthView::catChanged( Incidence * ) | 1353 | void KOMonthView::catChanged( Incidence * ) |
1354 | { | 1354 | { |
1355 | updateView(); | 1355 | updateView(); |
1356 | } | 1356 | } |
1357 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) | 1357 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) |
1358 | { | 1358 | { |
1359 | static Incidence * lastInc = 0; | 1359 | static Incidence * lastInc = 0; |
1360 | static MonthViewCell * lastCell = 0; | 1360 | static MonthViewCell * lastCell = 0; |
1361 | 1361 | ||
1362 | if ( lastInc == inc && lastCell == mc ) | 1362 | if ( lastInc == inc && lastCell == mc ) |
1363 | return; | 1363 | return; |
1364 | lastInc = inc; | 1364 | lastInc = inc; |
1365 | lastCell = mc; | 1365 | lastCell = mc; |
1366 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | 1366 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); |
1367 | 1367 | ||
1368 | bool weekview = false; | 1368 | bool weekview = false; |
1369 | uint index = 0; | 1369 | uint index = 0; |
1370 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1370 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1371 | if ( mCellsW[i] == mc ) { | 1371 | if ( mCellsW[i] == mc ) { |
1372 | weekview = true; | 1372 | weekview = true; |
1373 | index = i; | 1373 | index = i; |
1374 | break; | 1374 | break; |
1375 | } | 1375 | } |
1376 | } | 1376 | } |
1377 | QPtrVector<MonthViewCell> *cells; | 1377 | QPtrVector<MonthViewCell> *cells; |
1378 | if ( weekview ) | 1378 | if ( weekview ) |
1379 | cells = &mCellsW; | 1379 | cells = &mCellsW; |
1380 | else { | 1380 | else { |
1381 | for (uint i = 0; i < mCells.count(); ++i) { | 1381 | for (uint i = 0; i < mCells.count(); ++i) { |
1382 | if ( mCells[i] == mc ) { | 1382 | if ( mCells[i] == mc ) { |
1383 | index = i; | 1383 | index = i; |
1384 | break; | 1384 | break; |
1385 | } | 1385 | } |
1386 | } | 1386 | } |
1387 | cells = &mCells; | 1387 | cells = &mCells; |
1388 | } | 1388 | } |
1389 | for (uint i = 0; i < (*cells).count(); ++i) { | 1389 | for (uint i = 0; i < (*cells).count(); ++i) { |
1390 | (*cells)[i]->deHighLight(); | 1390 | (*cells)[i]->deHighLight(); |
1391 | } | 1391 | } |
1392 | if ( ! inc ) | 1392 | if ( ! inc ) |
1393 | return; | 1393 | return; |
1394 | 1394 | ||
1395 | uint count = (*cells).count(); | 1395 | uint count = (*cells).count(); |
1396 | bool goLeft = (mday > 1 && index > 0); | 1396 | bool goLeft = (mday > 1 && index > 0); |
1397 | bool goRight = (mday < 3 && mday > 0 && index < count -1); | 1397 | bool goRight = (mday < 3 && mday > 0 && index < count -1); |
1398 | for (uint iii = 1; iii < count; ++iii) { | 1398 | for (uint iii = 1; iii < count; ++iii) { |
1399 | if ( goLeft ) { | 1399 | if ( goLeft ) { |
1400 | int left = index - iii; | 1400 | int left = index - iii; |
1401 | if ( left >= 0 ) { | 1401 | if ( left >= 0 ) { |
1402 | if ( (*cells)[(uint)left]->doHighLight(inc) ) | 1402 | if ( (*cells)[(uint)left]->doHighLight(inc) ) |
1403 | goLeft = false; | 1403 | goLeft = false; |
1404 | } else | 1404 | } else |
1405 | goLeft = false; | 1405 | goLeft = false; |
1406 | } | 1406 | } |
1407 | if ( goRight ) { | 1407 | if ( goRight ) { |
1408 | uint right = index + iii; | 1408 | uint right = index + iii; |
1409 | if ( right < count ) { | 1409 | if ( right < count ) { |
1410 | if ( (*cells)[right]->doHighLight(inc) ) | 1410 | if ( (*cells)[right]->doHighLight(inc) ) |
1411 | goRight = false; | 1411 | goRight = false; |
1412 | 1412 | ||
1413 | } else | 1413 | } else |
1414 | goRight = false; | 1414 | goRight = false; |
1415 | } | 1415 | } |
1416 | 1416 | ||
1417 | } | 1417 | } |
1418 | #if 0 | 1418 | #if 0 |
1419 | if ( mday > 1 && index > 0 ) | 1419 | if ( mday > 1 && index > 0 ) |
1420 | for (int i = index-1; i >= 0; --i) { | 1420 | for (int i = index-1; i >= 0; --i) { |
1421 | //qDebug("index %d iii %d ", index, i); | 1421 | //qDebug("index %d iii %d ", index, i); |
1422 | if ( (*cells)[(uint)i]->doHighLight(inc) ) | 1422 | if ( (*cells)[(uint)i]->doHighLight(inc) ) |
1423 | break; | 1423 | break; |
1424 | } | 1424 | } |
1425 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) | 1425 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) |
1426 | for (uint i = index+1; i < (*cells).count(); ++i) { | 1426 | for (uint i = index+1; i < (*cells).count(); ++i) { |
1427 | if ( (*cells)[i]->doHighLight(inc) ) | 1427 | if ( (*cells)[i]->doHighLight(inc) ) |
1428 | break; | 1428 | break; |
1429 | } | 1429 | } |
1430 | #endif | 1430 | #endif |
1431 | 1431 | ||
1432 | } | 1432 | } |
1433 | void KOMonthView::selectInternalWeekNum ( int n ) | 1433 | void KOMonthView::selectInternalWeekNum ( int n ) |
1434 | { | 1434 | { |
1435 | switchView(); | 1435 | switchView(); |
1436 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1436 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1437 | emit selectMonth (); | 1437 | emit selectMonth (); |
1438 | else | 1438 | else |
1439 | emit selectWeekNum ( n ); | 1439 | emit selectWeekNum ( n ); |
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | int KOMonthView::currentWeek() | 1442 | int KOMonthView::currentWeek() |
1443 | { | 1443 | { |
1444 | if ( mShowWeekView ) | 1444 | if ( mShowWeekView ) |
1445 | return mWeekLabelsW[0]->getWeekNum(); | 1445 | return mWeekLabelsW[0]->getWeekNum(); |
1446 | return mWeekLabels[0]->getWeekNum(); | 1446 | return mWeekLabels[0]->getWeekNum(); |
1447 | } | 1447 | } |
1448 | void KOMonthView::switchView() | 1448 | void KOMonthView::switchView() |
1449 | { | 1449 | { |
1450 | if ( selectedCell( ) ) | 1450 | if ( selectedCell( ) ) |
1451 | selectedCell()->deselect(); | 1451 | selectedCell()->deselect(); |
1452 | mShowWeekView = !mShowWeekView; | 1452 | mShowWeekView = !mShowWeekView; |
1453 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1453 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1454 | if ( clPending ) { | 1454 | if ( clPending ) { |
1455 | computeLayout(); | 1455 | computeLayout(); |
1456 | updateConfig(); | 1456 | updateConfig(); |
1457 | } | 1457 | } |
1458 | if ( mShowWeekView ) | 1458 | if ( mShowWeekView ) |
1459 | mWidStack->raiseWidget( mWeekView ); | 1459 | mWidStack->raiseWidget( mWeekView ); |
1460 | else | 1460 | else |
1461 | mWidStack->raiseWidget( mMonthView ); | 1461 | mWidStack->raiseWidget( mMonthView ); |
1462 | clPending = false; | 1462 | clPending = false; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | int KOMonthView::maxDatesHint() | 1465 | int KOMonthView::maxDatesHint() |
1466 | { | 1466 | { |
1467 | return mNumCells; | 1467 | return mNumCells; |
1468 | } | 1468 | } |
1469 | 1469 | ||
1470 | int KOMonthView::currentDateCount() | 1470 | int KOMonthView::currentDateCount() |
1471 | { | 1471 | { |
1472 | return mNumCells; | 1472 | return mNumCells; |
1473 | } | 1473 | } |
1474 | 1474 | ||
1475 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1475 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1476 | { | 1476 | { |
1477 | QPtrList<Incidence> selected; | 1477 | QPtrList<Incidence> selected; |
1478 | 1478 | ||
1479 | if ( mSelectedCell ) { | 1479 | if ( mSelectedCell ) { |
1480 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1480 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1481 | if ( incidence ) selected.append( incidence ); | 1481 | if ( incidence ) selected.append( incidence ); |
1482 | } | 1482 | } |
1483 | 1483 | ||
1484 | return selected; | 1484 | return selected; |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | DateList KOMonthView::selectedDates() | 1487 | DateList KOMonthView::selectedDates() |
1488 | { | 1488 | { |
1489 | DateList selected; | 1489 | DateList selected; |
1490 | 1490 | ||
1491 | if ( mSelectedCell ) { | 1491 | if ( mSelectedCell ) { |
1492 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1492 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1493 | if ( qd.isValid() ) selected.append( qd ); | 1493 | if ( qd.isValid() ) selected.append( qd ); |
1494 | } | 1494 | } |
1495 | 1495 | ||
1496 | return selected; | 1496 | return selected; |
1497 | } | 1497 | } |
1498 | #if 0 | 1498 | #if 0 |
1499 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1499 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1500 | const QDate &td) | 1500 | const QDate &td) |
1501 | { | 1501 | { |
1502 | #ifndef KORG_NOPRINTER | 1502 | #ifndef KORG_NOPRINTER |
1503 | calPrinter->preview(CalPrinter::Month, fd, td); | 1503 | calPrinter->preview(CalPrinter::Month, fd, td); |
1504 | #endif | 1504 | #endif |
1505 | } | 1505 | } |
1506 | #endif | 1506 | #endif |
1507 | void KOMonthView::updateConfig() | 1507 | void KOMonthView::updateConfig() |
1508 | { | 1508 | { |
1509 | 1509 | ||
1510 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1510 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1511 | 1511 | ||
1512 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1512 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1513 | mWeekStartsMonday = true; | 1513 | mWeekStartsMonday = true; |
1514 | } | 1514 | } |
1515 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1515 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1516 | mWidthLongDayLabel = 0; | 1516 | mWidthLongDayLabel = 0; |
1517 | 1517 | ||
1518 | for (int i = 0; i < 7; i++) { | 1518 | for (int i = 0; i < 7; i++) { |
1519 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1519 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1520 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1520 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1521 | } | 1521 | } |
1522 | bool temp = mShowSatSunComp ; | 1522 | bool temp = mShowSatSunComp ; |
1523 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1523 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1524 | if ( ! mShowWeekView ) { | 1524 | if ( ! mShowWeekView ) { |
1525 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1525 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1526 | computeLayout(); | 1526 | computeLayout(); |
1527 | } | 1527 | } else |
1528 | doComputeLayoutWeek(); | ||
1528 | updateDayLabels(); | 1529 | updateDayLabels(); |
1529 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1530 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1530 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1531 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1531 | //resizeEvent( 0 ); | 1532 | //resizeEvent( 0 ); |
1532 | for (uint i = 0; i < mCells.count(); ++i) { | 1533 | for (uint i = 0; i < mCells.count(); ++i) { |
1533 | mCells[i]->updateConfig(); | 1534 | mCells[i]->updateConfig(); |
1534 | } | 1535 | } |
1535 | 1536 | ||
1536 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1537 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1537 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1538 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1538 | } | 1539 | } |
1539 | #ifdef DESKTOP_VERSION | 1540 | #ifdef DESKTOP_VERSION |
1540 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1541 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1541 | #endif | 1542 | #endif |
1542 | updateView(); | 1543 | updateView(); |
1543 | } | 1544 | } |
1544 | 1545 | ||
1545 | void KOMonthView::updateDayLabels() | 1546 | void KOMonthView::updateDayLabels() |
1546 | { | 1547 | { |
1547 | 1548 | ||
1548 | QPtrVector<QLabel> *mDayLabelsT; | 1549 | QPtrVector<QLabel> *mDayLabelsT; |
1549 | 1550 | ||
1550 | mDayLabelsT = &mDayLabelsW; | 1551 | mDayLabelsT = &mDayLabelsW; |
1551 | for (int i = 0; i < 7; i++) { | 1552 | for (int i = 0; i < 7; i++) { |
1552 | { | 1553 | { |
1553 | bool show = mShortDayLabelsW; | 1554 | bool show = mShortDayLabelsW; |
1554 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1555 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1555 | show = true; | 1556 | show = true; |
1556 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1557 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1557 | } | 1558 | } |
1558 | } | 1559 | } |
1559 | mDayLabelsT = &mDayLabels; | 1560 | mDayLabelsT = &mDayLabels; |
1560 | for (int i = 0; i < 7; i++) { | 1561 | for (int i = 0; i < 7; i++) { |
1561 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1562 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1562 | bool show = mShortDayLabelsM; | 1563 | bool show = mShortDayLabelsM; |
1563 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1564 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1564 | show = true; | 1565 | show = true; |
1565 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1566 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1566 | } else { | 1567 | } else { |
1567 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1568 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1568 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1569 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1569 | 1570 | ||
1570 | } | 1571 | } |
1571 | } | 1572 | } |
1572 | 1573 | ||
1573 | } | 1574 | } |
1574 | 1575 | ||
1575 | void KOMonthView::clearList() | 1576 | void KOMonthView::clearList() |
1576 | { | 1577 | { |
1577 | unsigned int i; | 1578 | unsigned int i; |
1578 | for( i = 0; i < mCells.size(); ++i ) { | 1579 | for( i = 0; i < mCells.size(); ++i ) { |
1579 | mCells[i]->clear(); | 1580 | mCells[i]->clear(); |
1580 | } | 1581 | } |
1581 | for( i = 0; i < mCellsW.size(); ++i ) { | 1582 | for( i = 0; i < mCellsW.size(); ++i ) { |
1582 | mCellsW[i]->clear(); | 1583 | mCellsW[i]->clear(); |
1583 | } | 1584 | } |
1584 | } | 1585 | } |
1585 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1586 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1586 | { | 1587 | { |
1587 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1588 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1588 | 1589 | ||
1589 | QPtrVector<MonthViewCell> *cells; | 1590 | QPtrVector<MonthViewCell> *cells; |
1590 | QPtrVector<QLabel> *dayLabels; | 1591 | QPtrVector<QLabel> *dayLabels; |
1591 | QPtrVector<KOWeekButton> *weekLabels; | 1592 | QPtrVector<KOWeekButton> *weekLabels; |
1592 | uint weekNum = 6; | 1593 | uint weekNum = 6; |
1593 | mStartDate = start; | 1594 | mStartDate = start; |
1594 | if ( mShowWeekView ) { | 1595 | if ( mShowWeekView ) { |
1595 | weekNum = 1; | 1596 | weekNum = 1; |
1596 | cells = &mCellsW; | 1597 | cells = &mCellsW; |
1597 | dayLabels = &mDayLabelsW; | 1598 | dayLabels = &mDayLabelsW; |
1598 | weekLabels = &mWeekLabelsW; | 1599 | weekLabels = &mWeekLabelsW; |
1599 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1600 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1600 | mStartDate = mStartDate.addDays( 1 ); | 1601 | mStartDate = mStartDate.addDays( 1 ); |
1601 | } | 1602 | } |
1602 | } else { | 1603 | } else { |
1603 | cells = &mCells; | 1604 | cells = &mCells; |
1604 | dayLabels = &mDayLabels; | 1605 | dayLabels = &mDayLabels; |
1605 | weekLabels = &mWeekLabels; | 1606 | weekLabels = &mWeekLabels; |
1606 | } | 1607 | } |
1607 | 1608 | ||
1608 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1609 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1609 | 1610 | ||
1610 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1611 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1611 | mWeekStartsMonday = true; | 1612 | mWeekStartsMonday = true; |
1612 | } | 1613 | } |
1613 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1614 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1614 | 1615 | ||
1615 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1616 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1616 | mStartDate = mStartDate.addDays( -1 ); | 1617 | mStartDate = mStartDate.addDays( -1 ); |
1617 | } | 1618 | } |
1618 | uint i; | 1619 | uint i; |
1619 | for( i = 0; i < (*cells).size(); ++i ) { | 1620 | for( i = 0; i < (*cells).size(); ++i ) { |
1620 | QDate date = mStartDate.addDays( i ); | 1621 | QDate date = mStartDate.addDays( i ); |
1621 | (*cells)[i]->setDate( date ); | 1622 | (*cells)[i]->setDate( date ); |
1622 | 1623 | ||
1623 | #ifndef KORG_NOPLUGINS | 1624 | #ifndef KORG_NOPLUGINS |
1624 | // add holiday, if present | 1625 | // add holiday, if present |
1625 | QString hstring(KOCore::self()->holiday(date)); | 1626 | QString hstring(KOCore::self()->holiday(date)); |
1626 | (*cells)[i]->setHoliday( hstring ); | 1627 | (*cells)[i]->setHoliday( hstring ); |
1627 | #endif | 1628 | #endif |
1628 | 1629 | ||
1629 | } | 1630 | } |
1630 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1631 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1631 | for( i = 0; i < weekNum; ++i ) { | 1632 | for( i = 0; i < weekNum; ++i ) { |
1632 | int wno; | 1633 | int wno; |
1633 | // remember, according to ISO 8601, the first week of the year is the | 1634 | // remember, according to ISO 8601, the first week of the year is the |
1634 | // first week that contains a thursday. Thus we must subtract off 4, | 1635 | // first week that contains a thursday. Thus we must subtract off 4, |
1635 | // not just 1. | 1636 | // not just 1. |
1636 | int dayOfYear = date.dayOfYear(); | 1637 | int dayOfYear = date.dayOfYear(); |
1637 | if (dayOfYear % 7 != 0) | 1638 | if (dayOfYear % 7 != 0) |
1638 | wno = dayOfYear / 7 + 1; | 1639 | wno = dayOfYear / 7 + 1; |
1639 | else | 1640 | else |
1640 | wno =dayOfYear / 7; | 1641 | wno =dayOfYear / 7; |
1641 | (*weekLabels)[i]->setWeekNum( wno ); | 1642 | (*weekLabels)[i]->setWeekNum( wno ); |
1642 | date = date.addDays( 7 ); | 1643 | date = date.addDays( 7 ); |
1643 | } | 1644 | } |
1644 | updateView(); | 1645 | updateView(); |
1645 | } | 1646 | } |
1646 | 1647 | ||
1647 | void KOMonthView::showEvents(QPtrList<Event>) | 1648 | void KOMonthView::showEvents(QPtrList<Event>) |
1648 | { | 1649 | { |
1649 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1650 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1650 | } | 1651 | } |
1651 | 1652 | ||
1652 | void KOMonthView::changeEventDisplay(Event *, int) | 1653 | void KOMonthView::changeEventDisplay(Event *, int) |
1653 | { | 1654 | { |
1654 | // this should be re-written to be much more efficient, but this | 1655 | // this should be re-written to be much more efficient, but this |
1655 | // quick-and-dirty-hack gets the job done for right now. | 1656 | // quick-and-dirty-hack gets the job done for right now. |
1656 | //qDebug("KOMonthView::changeEventDisplay "); | 1657 | //qDebug("KOMonthView::changeEventDisplay "); |
1657 | updateView(); | 1658 | updateView(); |
1658 | } | 1659 | } |
1659 | 1660 | ||
1660 | void KOMonthView::updateView() | 1661 | void KOMonthView::updateView() |
1661 | { | 1662 | { |
1662 | 1663 | ||
1663 | if ( !updatePossible ) | 1664 | if ( !updatePossible ) |
1664 | return; | 1665 | return; |
1665 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1666 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1666 | //QTime ti; | 1667 | //QTime ti; |
1667 | //ti.start(); | 1668 | //ti.start(); |
1668 | clearSelection(); | 1669 | clearSelection(); |
1669 | QPtrVector<MonthViewCell> *cells; | 1670 | QPtrVector<MonthViewCell> *cells; |
1670 | if ( mShowWeekView ) { | 1671 | if ( mShowWeekView ) { |
1671 | cells = &mCellsW; | 1672 | cells = &mCellsW; |
1672 | } else { | 1673 | } else { |
1673 | cells = &mCells; | 1674 | cells = &mCells; |
1674 | } | 1675 | } |
1675 | #if 1 | 1676 | #if 1 |
1676 | int i; | 1677 | int i; |
1677 | int timeSpan = (*cells).size()-1; | 1678 | int timeSpan = (*cells).size()-1; |
1678 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1679 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1679 | timeSpan = 6; | 1680 | timeSpan = 6; |
1680 | for( i = 0; i < timeSpan + 1; ++i ) { | 1681 | for( i = 0; i < timeSpan + 1; ++i ) { |
1681 | (*cells)[i]->startUpdateCell(); | 1682 | (*cells)[i]->startUpdateCell(); |
1682 | } | 1683 | } |
1683 | 1684 | ||
1684 | QPtrList<Event> events = calendar()->events(); | 1685 | QPtrList<Event> events = calendar()->events(); |
1685 | Event *event; | 1686 | Event *event; |
1686 | QDateTime dt; | 1687 | QDateTime dt; |
1687 | QDate endDate = mStartDate.addDays( timeSpan ); | 1688 | QDate endDate = mStartDate.addDays( timeSpan ); |
1688 | for( event = events.first(); event; event = events.next() ) { // for event | 1689 | for( event = events.first(); event; event = events.next() ) { // for event |
1689 | if ( event->doesRecur() ) { | 1690 | if ( event->doesRecur() ) { |
1690 | bool last; | 1691 | bool last; |
1691 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1692 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1692 | QDateTime incidenceEnd; | 1693 | QDateTime incidenceEnd; |
1693 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1694 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1694 | bool invalid = false; | 1695 | bool invalid = false; |
1695 | while( true ) { | 1696 | while( true ) { |
1696 | if ( incidenceStart.isValid() ) { | 1697 | if ( incidenceStart.isValid() ) { |
1697 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1698 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1698 | int st = incidenceStart.date().daysTo( endDate ); | 1699 | int st = incidenceStart.date().daysTo( endDate ); |
1699 | if ( st >= 0 ) { // start before timeend | 1700 | if ( st >= 0 ) { // start before timeend |
1700 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1701 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1701 | if ( end >= 0 ) { // end after timestart --- got one! | 1702 | if ( end >= 0 ) { // end after timestart --- got one! |
1702 | //normalize | 1703 | //normalize |
1703 | st = timeSpan - st; | 1704 | st = timeSpan - st; |
1704 | if ( st < 0 ) st = 0; | 1705 | if ( st < 0 ) st = 0; |
1705 | if ( end > timeSpan ) end = timeSpan; | 1706 | if ( end > timeSpan ) end = timeSpan; |
1706 | int iii; | 1707 | int iii; |
1707 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1708 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1708 | for ( iii = st;iii<= end;++iii) | 1709 | for ( iii = st;iii<= end;++iii) |
1709 | (*cells)[iii]->insertEvent( event ); | 1710 | (*cells)[iii]->insertEvent( event ); |
1710 | } | 1711 | } |
1711 | } | 1712 | } |
1712 | } else { | 1713 | } else { |
1713 | if ( invalid ) | 1714 | if ( invalid ) |
1714 | break; | 1715 | break; |
1715 | invalid = true; | 1716 | invalid = true; |
1716 | //qDebug("invalid %s", event->summary().latin1()); | 1717 | //qDebug("invalid %s", event->summary().latin1()); |
1717 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1718 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1718 | } | 1719 | } |
1719 | if ( last ) | 1720 | if ( last ) |
1720 | break; | 1721 | break; |
1721 | bool ok; | 1722 | bool ok; |
1722 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1723 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1723 | if ( ! ok ) | 1724 | if ( ! ok ) |
1724 | break; | 1725 | break; |
1725 | if ( incidenceStart.date() > endDate ) | 1726 | if ( incidenceStart.date() > endDate ) |
1726 | break; | 1727 | break; |
1727 | } | 1728 | } |
1728 | } else { // no recur | 1729 | } else { // no recur |
1729 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1730 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1730 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1731 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1731 | continue; | 1732 | continue; |
1732 | int st = event->dtStart().date().daysTo( endDate ); | 1733 | int st = event->dtStart().date().daysTo( endDate ); |
1733 | if ( st >= 0 ) { // start before timeend | 1734 | if ( st >= 0 ) { // start before timeend |
1734 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1735 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1735 | if ( end >= 0 ) { // end after timestart --- got one! | 1736 | if ( end >= 0 ) { // end after timestart --- got one! |
1736 | //normalize | 1737 | //normalize |
1737 | st = timeSpan - st; | 1738 | st = timeSpan - st; |
1738 | if ( st < 0 ) st = 0; | 1739 | if ( st < 0 ) st = 0; |
1739 | if ( end > timeSpan ) end = timeSpan; | 1740 | if ( end > timeSpan ) end = timeSpan; |
1740 | int iii; | 1741 | int iii; |
1741 | for ( iii = st;iii<= end;++iii) | 1742 | for ( iii = st;iii<= end;++iii) |
1742 | (*cells)[iii]->insertEvent( event ); | 1743 | (*cells)[iii]->insertEvent( event ); |
1743 | } | 1744 | } |
1744 | } | 1745 | } |
1745 | } | 1746 | } |
1746 | } | 1747 | } |
1747 | // insert due todos | 1748 | // insert due todos |
1748 | QPtrList<Todo> todos = calendar()->todos( ); | 1749 | QPtrList<Todo> todos = calendar()->todos( ); |
1749 | Todo *todo; | 1750 | Todo *todo; |
1750 | for(todo = todos.first(); todo; todo = todos.next()) { | 1751 | for(todo = todos.first(); todo; todo = todos.next()) { |
1751 | //insertTodo( todo ); | 1752 | //insertTodo( todo ); |
1752 | if ( todo->hasDueDate() ) { | 1753 | if ( todo->hasDueDate() ) { |
1753 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1754 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1754 | if ( day >= 0 && day < timeSpan + 1) { | 1755 | if ( day >= 0 && day < timeSpan + 1) { |
1755 | (*cells)[day]->insertTodo( todo ); | 1756 | (*cells)[day]->insertTodo( todo ); |
1756 | } | 1757 | } |
1757 | } | 1758 | } |
1758 | } | 1759 | } |
1759 | 1760 | ||
1760 | for( i = 0; i < timeSpan+1; ++i ) { | 1761 | for( i = 0; i < timeSpan+1; ++i ) { |
1761 | (*cells)[i]->finishUpdateCell(); | 1762 | (*cells)[i]->finishUpdateCell(); |
1762 | } | 1763 | } |
1763 | processSelectionChange(); | 1764 | processSelectionChange(); |
1764 | //qApp->processEvents(); | 1765 | //qApp->processEvents(); |
1765 | for( i = 0; i < timeSpan+1; ++i ) { | 1766 | for( i = 0; i < timeSpan+1; ++i ) { |
1766 | //(*cells)[i]->repaintfinishUpdateCell(); | 1767 | //(*cells)[i]->repaintfinishUpdateCell(); |
1767 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); | 1768 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); |
1768 | } | 1769 | } |
1769 | setKeyBFocus(); | 1770 | setKeyBFocus(); |
1770 | #else | 1771 | #else |
1771 | // old code | 1772 | // old code |
1772 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1773 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1773 | int i; | 1774 | int i; |
1774 | for( i = 0; i < (*cells).count(); ++i ) { | 1775 | for( i = 0; i < (*cells).count(); ++i ) { |
1775 | (*cells)[i]->updateCell(); | 1776 | (*cells)[i]->updateCell(); |
1776 | } | 1777 | } |
1777 | 1778 | ||
1778 | //qDebug("KOMonthView::updateView() "); | 1779 | //qDebug("KOMonthView::updateView() "); |
1779 | processSelectionChange(); | 1780 | processSelectionChange(); |
1780 | // qDebug("---------------------------------------------------------------------+ "); | 1781 | // qDebug("---------------------------------------------------------------------+ "); |
1781 | (*cells)[0]->setFocus(); | 1782 | (*cells)[0]->setFocus(); |
1782 | #endif | 1783 | #endif |
1783 | 1784 | ||
1784 | //qDebug("update time %d ", ti.elapsed()); | 1785 | //qDebug("update time %d ", ti.elapsed()); |
1785 | } | 1786 | } |
1786 | 1787 | ||
1787 | void KOMonthView::setKeyBoardFocus() | 1788 | void KOMonthView::setKeyBoardFocus() |
1788 | { | 1789 | { |
1789 | //qDebug("KOMonthView::setKeyBoardFocus() "); | 1790 | //qDebug("KOMonthView::setKeyBoardFocus() "); |
1790 | bool shootAgain = false; | 1791 | bool shootAgain = false; |
1791 | if ( mShowWeekView ) { | 1792 | if ( mShowWeekView ) { |
1792 | shootAgain = !mWeekLabelsW[1]->hasFocus(); | 1793 | shootAgain = !mWeekLabelsW[1]->hasFocus(); |
1793 | mWeekLabelsW[1]->setFocus(); | 1794 | mWeekLabelsW[1]->setFocus(); |
1794 | } | 1795 | } |
1795 | else { | 1796 | else { |
1796 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); | 1797 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); |
1797 | mWeekLabels[mNumWeeks]->setFocus(); | 1798 | mWeekLabels[mNumWeeks]->setFocus(); |
1798 | } | 1799 | } |
1799 | --mKBFcounter; | 1800 | --mKBFcounter; |
1800 | if ( shootAgain && mKBFcounter > 0 ) { | 1801 | if ( shootAgain && mKBFcounter > 0 ) { |
1801 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); | 1802 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); |
1802 | } | 1803 | } |
1803 | } | 1804 | } |
1804 | void KOMonthView::setKeyBFocus() | 1805 | void KOMonthView::setKeyBFocus() |
1805 | { | 1806 | { |
1806 | //qDebug("KOMonthView::setKeyBFocus() "); | 1807 | //qDebug("KOMonthView::setKeyBFocus() "); |
1807 | mKBFcounter = 10; | 1808 | mKBFcounter = 10; |
1808 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); | 1809 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); |
1809 | } | 1810 | } |
1810 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1811 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1811 | { | 1812 | { |
1812 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1813 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1813 | if ( isVisible() ) { | 1814 | if ( isVisible() ) { |
1814 | //qDebug("KOMonthView::isVisible "); | 1815 | //qDebug("KOMonthView::isVisible "); |
1815 | slotComputeLayout(); | 1816 | slotComputeLayout(); |
1816 | } else | 1817 | } else |
1817 | mComputeLayoutTimer->start( 100 ); | 1818 | mComputeLayoutTimer->start( 100 ); |
1818 | KOEventView::resizeEvent( e ); | 1819 | if ( e ) |
1820 | KOEventView::resizeEvent( e ); | ||
1819 | } | 1821 | } |
1820 | 1822 | ||
1821 | void KOMonthView::slotComputeLayout() | 1823 | void KOMonthView::slotComputeLayout() |
1822 | { | 1824 | { |
1823 | mComputeLayoutTimer->stop(); | 1825 | mComputeLayoutTimer->stop(); |
1824 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | 1826 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); |
1825 | computeLayout(); | 1827 | computeLayout(); |
1826 | clPending = true; | 1828 | clPending = true; |
1827 | setKeyBFocus(); | 1829 | setKeyBFocus(); |
1828 | } | 1830 | } |
1829 | void KOMonthView::computeLayoutWeek() | 1831 | |
1832 | void KOMonthView::doComputeLayoutWeek() | ||
1830 | { | 1833 | { |
1831 | static int lastWid = 0; | 1834 | |
1832 | static int lastHei = 0; | ||
1833 | int daysToShow; | 1835 | int daysToShow; |
1834 | bool combinedSatSun = false; | 1836 | bool combinedSatSun = false; |
1835 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1837 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1836 | daysToShow = 6; | 1838 | daysToShow = 6; |
1837 | combinedSatSun = true; | 1839 | combinedSatSun = true; |
1838 | } | 1840 | } |
1839 | int tWid = topLevelWidget()->size().width(); | ||
1840 | int tHei = topLevelWidget()->size().height(); | ||
1841 | |||
1842 | int wid = width();//e | 1841 | int wid = width();//e |
1843 | int hei = height()-1-mNavigatorBar->height(); | 1842 | int hei = height()-1-mNavigatorBar->height(); |
1844 | 1843 | if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { | |
1845 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | ||
1846 | return; | ||
1847 | |||
1848 | if ( lastWid == width() && lastHei == height() ) { | ||
1849 | //qDebug("KOListWeekView::No compute layout needed "); | ||
1850 | return; | ||
1851 | } | ||
1852 | lastWid = width(); | ||
1853 | lastHei = height(); | ||
1854 | |||
1855 | |||
1856 | if ( wid < hei ) | ||
1857 | daysToShow = 2; | 1844 | daysToShow = 2; |
1858 | else | 1845 | } else { |
1859 | daysToShow = 3; | 1846 | if ( wid < hei ) |
1847 | daysToShow = 2; | ||
1848 | else | ||
1849 | daysToShow = 3; | ||
1850 | } | ||
1851 | bool landscape = (daysToShow == 3); | ||
1860 | mShowSatSunComp = true; | 1852 | mShowSatSunComp = true; |
1861 | combinedSatSun = true; | 1853 | combinedSatSun = true; |
1862 | 1854 | ||
1863 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1855 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1864 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1856 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1865 | int weeklabelwid = fm.width( "888" ); | 1857 | int weeklabelwid = fm.width( "888" ); |
1866 | wid -= weeklabelwid; | 1858 | wid -= weeklabelwid; |
1867 | 1859 | ||
1868 | int colWid = wid / daysToShow; | 1860 | int colWid = wid / daysToShow; |
1869 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1861 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1870 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1862 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1871 | int colModulo = wid % daysToShow; | 1863 | int colModulo = wid % daysToShow; |
1872 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1864 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1873 | //qDebug("rowmod %d ", rowModulo); | 1865 | //qDebug("rowmod %d ", rowModulo); |
1874 | int i; | 1866 | int i; |
1875 | int x,y,w,h; | 1867 | int x,y,w,h; |
1876 | x= 0; | 1868 | x= 0; |
1877 | y= 0; | 1869 | y= 0; |
1878 | w = colWid; | 1870 | w = colWid; |
1879 | h = dayLabelHei ; | 1871 | h = dayLabelHei ; |
1880 | for ( i = 0; i < 7; i++) { | 1872 | for ( i = 0; i < 7; i++) { |
1881 | if ( i && !( i % daysToShow) && i < 6) { | 1873 | if ( i && !( i % daysToShow) && i < 6) { |
1882 | y += hei/(5-daysToShow); | 1874 | y += hei/(5-daysToShow); |
1883 | x = 0; | 1875 | x = 0; |
1884 | w = colWid; | 1876 | w = colWid; |
1885 | } | 1877 | } |
1886 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1878 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1887 | ++w; | 1879 | ++w; |
1888 | } | 1880 | } |
1881 | int xC,yC,wC,hC; | ||
1889 | if ( i >= 5 ) { | 1882 | if ( i >= 5 ) { |
1890 | int wi = width() - x - weeklabelwid; | 1883 | int wi = width() - x - weeklabelwid; |
1891 | if ( i == 5 ) { | 1884 | if ( i == 5 ) { |
1892 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); | 1885 | xC = x+weeklabelwid; |
1886 | yC = y; | ||
1887 | wC = wi/2+wi%2; | ||
1888 | hC = h; | ||
1893 | } else { | 1889 | } else { |
1894 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); | 1890 | xC = x+weeklabelwid; |
1891 | yC = y; | ||
1892 | wC = wi; | ||
1893 | hC = h; | ||
1895 | } | 1894 | } |
1896 | x = x - w + wi - (wi/2 ); | 1895 | x = x - w + wi - (wi/2 ); |
1897 | } | 1896 | } |
1898 | else { | 1897 | else { |
1899 | int wi = w; | 1898 | int wi = w; |
1900 | if ( !(( i+1) % daysToShow)) { | 1899 | if ( !(( i+1) % daysToShow)) { |
1901 | wi = width() - x - weeklabelwid; | 1900 | wi = width() - x - weeklabelwid; |
1902 | } | 1901 | } |
1903 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); | 1902 | xC = x+weeklabelwid; |
1903 | yC = y; | ||
1904 | wC = wi; | ||
1905 | hC = h; | ||
1904 | } | 1906 | } |
1907 | mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); | ||
1908 | |||
1909 | |||
1905 | x += w; | 1910 | x += w; |
1906 | } | 1911 | } |
1907 | x= 0; | 1912 | x= 0; |
1908 | y= dayLabelHei; | 1913 | y= dayLabelHei; |
1909 | w = colWid; | 1914 | w = colWid; |
1910 | h = cellHei; | 1915 | h = cellHei; |
1911 | int max = 0; | 1916 | int max = 0; |
1912 | int w_count = mCellsW.count(); | 1917 | int w_count = mCellsW.count(); |
1913 | for ( i = 0; i < w_count; ++i) { | 1918 | for ( i = 0; i < w_count; ++i) { |
1914 | if ( i > 6 ) { | 1919 | if ( i > 6 ) { |
1915 | mCellsW[i]->hide(); | 1920 | mCellsW[i]->hide(); |
1916 | continue; | 1921 | continue; |
1917 | } | 1922 | } |
1918 | 1923 | ||
1919 | w = colWid; | 1924 | w = colWid; |
1920 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1925 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1921 | ++w; | 1926 | ++w; |
1922 | } | 1927 | } |
1923 | if ( i == (daysToShow-1-rowModulo)*7) | 1928 | if ( i == (daysToShow-1-rowModulo)*7) |
1924 | ++h; | 1929 | ++h; |
1925 | 1930 | ||
1931 | int xC,yC,wC,hC; | ||
1926 | if ( i >= 5 ) { | 1932 | if ( i >= 5 ) { |
1927 | if ( i ==5 ) { | 1933 | if ( i ==5 ) { |
1928 | max = h/2; | 1934 | max = h/2; |
1929 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1935 | xC = x+weeklabelwid; |
1936 | yC = y; | ||
1937 | wC = w; | ||
1938 | hC = max; | ||
1930 | x -= w ;y += h/2; | 1939 | x -= w ;y += h/2; |
1931 | } else { | 1940 | } else { |
1932 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1941 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1933 | ++w; | 1942 | ++w; |
1934 | } | 1943 | } |
1935 | max = h-h/2; | 1944 | max = h-h/2; |
1936 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1945 | xC = x+weeklabelwid; |
1946 | yC = y; | ||
1947 | wC = w; | ||
1948 | hC = max; | ||
1937 | y -= h/2; | 1949 | y -= h/2; |
1938 | } | 1950 | } |
1939 | } else { | 1951 | } else { |
1940 | max = h; | 1952 | max = h; |
1941 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1953 | xC = x+weeklabelwid; |
1954 | yC = y; | ||
1955 | wC = w; | ||
1956 | hC = h; | ||
1942 | } | 1957 | } |
1958 | mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); | ||
1943 | 1959 | ||
1944 | 1960 | ||
1945 | x += w; | 1961 | x += w; |
1946 | if ( x + w/2 > wid ) { | 1962 | if ( x + w/2 > wid ) { |
1947 | x = 0; | 1963 | x = 0; |
1948 | y += h+dayLabelHei ; | 1964 | y += h+dayLabelHei ; |
1949 | } | 1965 | } |
1950 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); | 1966 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); |
1951 | } | 1967 | } |
1952 | y= dayLabelHei; | 1968 | y= dayLabelHei; |
1953 | h = cellHei ; | 1969 | h = cellHei ; |
1954 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1970 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1955 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1971 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1956 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1972 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1957 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1973 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1958 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1974 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1959 | updateDayLabels(); | 1975 | updateDayLabels(); |
1960 | //bool forceUpdate = !updatePossible; | 1976 | //bool forceUpdate = !updatePossible; |
1961 | updatePossible = true; | 1977 | updatePossible = true; |
1962 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1978 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1963 | //if ( forceUpdate ) | 1979 | //if ( forceUpdate ) |
1964 | // updateView(); | 1980 | // updateView(); |
1965 | } | 1981 | } |
1982 | void KOMonthView::computeLayoutWeek() | ||
1983 | { | ||
1984 | static int lastWid = 0; | ||
1985 | static int lastHei = 0; | ||
1986 | int tWid = topLevelWidget()->size().width(); | ||
1987 | int tHei = topLevelWidget()->size().height(); | ||
1988 | int wid = width();//e | ||
1989 | int hei = height()-1-mNavigatorBar->height(); | ||
1990 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | ||
1991 | return; | ||
1992 | |||
1993 | if ( lastWid == width() && lastHei == height() ) { | ||
1994 | //qDebug("KOListWeekView::No compute layout needed "); | ||
1995 | return; | ||
1996 | } | ||
1997 | lastWid = width(); | ||
1998 | lastHei = height(); | ||
1999 | doComputeLayoutWeek(); | ||
2000 | } | ||
2001 | int KOMonthView::mapWeekLayout( int index, bool landscape ) | ||
2002 | { | ||
2003 | if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) | ||
2004 | return index; | ||
2005 | int diff = 0; | ||
2006 | if ( !landscape ) diff = 1; | ||
2007 | switch( index ) { | ||
2008 | case 0: | ||
2009 | case 5: | ||
2010 | case 6: | ||
2011 | return index; | ||
2012 | break; | ||
2013 | case 1: | ||
2014 | return 2+diff; | ||
2015 | break; | ||
2016 | case 2: | ||
2017 | return 4-(3*diff); | ||
2018 | break; | ||
2019 | case 3: | ||
2020 | return 1+(3*diff); | ||
2021 | break; | ||
2022 | case 4: | ||
2023 | return 3-diff; | ||
2024 | break; | ||
2025 | default: | ||
2026 | qDebug("KO: Error in mapping week layout "); | ||
2027 | return index; | ||
2028 | break; | ||
2029 | } | ||
2030 | return index; | ||
2031 | } | ||
1966 | void KOMonthView::computeLayout() | 2032 | void KOMonthView::computeLayout() |
1967 | { | 2033 | { |
1968 | 2034 | ||
1969 | 2035 | ||
1970 | static int lastWid = 0; | 2036 | static int lastWid = 0; |
1971 | static int lastHei = 0; | 2037 | static int lastHei = 0; |
1972 | 2038 | ||
1973 | if ( mShowWeekView ){ | 2039 | if ( mShowWeekView ){ |
1974 | computeLayoutWeek(); | 2040 | computeLayoutWeek(); |
1975 | return; | 2041 | return; |
1976 | } | 2042 | } |
1977 | int daysToShow = 7; | 2043 | int daysToShow = 7; |
1978 | bool combinedSatSun = false; | 2044 | bool combinedSatSun = false; |
1979 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 2045 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1980 | daysToShow = 6; | 2046 | daysToShow = 6; |
1981 | combinedSatSun = true; | 2047 | combinedSatSun = true; |
1982 | } | 2048 | } |
1983 | int tWid = topLevelWidget()->size().width(); | 2049 | int tWid = topLevelWidget()->size().width(); |
1984 | int tHei = topLevelWidget()->size().height(); | 2050 | int tHei = topLevelWidget()->size().height(); |
1985 | 2051 | ||
1986 | int wid = width();//e | 2052 | int wid = width();//e |
1987 | int hei = height()-1-mNavigatorBar->height(); | 2053 | int hei = height()-1-mNavigatorBar->height(); |
1988 | 2054 | ||
1989 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 2055 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1990 | return; | 2056 | return; |
1991 | } | 2057 | } |
1992 | if ( lastWid == width() && lastHei == height() ){ | 2058 | if ( lastWid == width() && lastHei == height() ){ |
1993 | //qDebug("KOMonthview::No compute layout needed "); | 2059 | //qDebug("KOMonthview::No compute layout needed "); |
1994 | return; | 2060 | return; |
1995 | } | 2061 | } |
1996 | 2062 | ||
1997 | lastWid = width(); | 2063 | lastWid = width(); |
1998 | lastHei = height(); | 2064 | lastHei = height(); |
1999 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); | 2065 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); |
2000 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 2066 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
2001 | int weeklabelwid = fm.width( "888" ); | 2067 | int weeklabelwid = fm.width( "888" ); |
2002 | wid -= weeklabelwid; | 2068 | wid -= weeklabelwid; |
2003 | 2069 | ||
2004 | int colWid = wid / daysToShow; | 2070 | int colWid = wid / daysToShow; |
2005 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 2071 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
2006 | int cellHei = (hei - dayLabelHei) /6; | 2072 | int cellHei = (hei - dayLabelHei) /6; |
2007 | int colModulo = wid % daysToShow; | 2073 | int colModulo = wid % daysToShow; |
2008 | int rowModulo = (hei- dayLabelHei) % 6; | 2074 | int rowModulo = (hei- dayLabelHei) % 6; |
2009 | //qDebug("rowmod %d ", rowModulo); | 2075 | //qDebug("rowmod %d ", rowModulo); |
2010 | int i; | 2076 | int i; |
2011 | int x,y,w,h; | 2077 | int x,y,w,h; |
2012 | x= 0; | 2078 | x= 0; |
2013 | y= 0; | 2079 | y= 0; |
2014 | w = colWid; | 2080 | w = colWid; |
2015 | h = dayLabelHei ; | 2081 | h = dayLabelHei ; |
2016 | for ( i = 0; i < 7; i++) { | 2082 | for ( i = 0; i < 7; i++) { |
2017 | if ( i == daysToShow-colModulo ) | 2083 | if ( i == daysToShow-colModulo ) |
2018 | ++w; | 2084 | ++w; |
2019 | if ( combinedSatSun ) { | 2085 | if ( combinedSatSun ) { |
2020 | if ( i >= daysToShow-1 ) { | 2086 | if ( i >= daysToShow-1 ) { |
2021 | 2087 | ||
2022 | if ( i == 6 ) | 2088 | if ( i == 6 ) |
2023 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); | 2089 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); |
2024 | else | 2090 | else |
2025 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 2091 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
2026 | x -= w/2 ; | 2092 | x -= w/2 ; |
2027 | } | 2093 | } |
2028 | else | 2094 | else |
2029 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 2095 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
2030 | } else | 2096 | } else |
2031 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 2097 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
2032 | x += w; | 2098 | x += w; |
2033 | } | 2099 | } |
2034 | x= 0; | 2100 | x= 0; |
2035 | y= dayLabelHei; | 2101 | y= dayLabelHei; |
2036 | w = colWid; | 2102 | w = colWid; |
2037 | h = cellHei ; | 2103 | h = cellHei ; |
2038 | int max = 0; | 2104 | int max = 0; |
2039 | int mc_count = mCells.count(); | 2105 | int mc_count = mCells.count(); |
2040 | for ( i = 0; i < mc_count; ++i) { | 2106 | for ( i = 0; i < mc_count; ++i) { |
2041 | //qDebug("iii %d ", i); | 2107 | //qDebug("iii %d ", i); |
2042 | w = colWid; | 2108 | w = colWid; |
2043 | if ( ((i) % 7) >= 7-colModulo ) { | 2109 | if ( ((i) % 7) >= 7-colModulo ) { |
2044 | ++w; | 2110 | ++w; |
2045 | } | 2111 | } |
2046 | if ( i == (6-rowModulo)*7) | 2112 | if ( i == (6-rowModulo)*7) |
2047 | ++h; | 2113 | ++h; |
2048 | if ( combinedSatSun ) { | 2114 | if ( combinedSatSun ) { |
2049 | if ( (i)%7 >= daysToShow-1 ) { | 2115 | if ( (i)%7 >= daysToShow-1 ) { |
2050 | if ( (i)%7 == daysToShow-1 ) { | 2116 | if ( (i)%7 == daysToShow-1 ) { |
2051 | w = width()-x-weeklabelwid; | 2117 | w = width()-x-weeklabelwid; |
2052 | max = h/2; | 2118 | max = h/2; |
2053 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 2119 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
2054 | x -= w ;y += h/2; | 2120 | x -= w ;y += h/2; |
2055 | } else { | 2121 | } else { |
2056 | w = width()-x-weeklabelwid; | 2122 | w = width()-x-weeklabelwid; |
2057 | max = h-h/2; | 2123 | max = h-h/2; |
2058 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 2124 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
2059 | y -= h/2; | 2125 | y -= h/2; |
2060 | } | 2126 | } |
2061 | } else { | 2127 | } else { |
2062 | max = h; | 2128 | max = h; |
2063 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 2129 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
2064 | } | 2130 | } |
2065 | 2131 | ||
2066 | } | 2132 | } |
2067 | else { | 2133 | else { |
2068 | max = h; | 2134 | max = h; |
2069 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 2135 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
2070 | } | 2136 | } |
2071 | x += w; | 2137 | x += w; |
2072 | if ( x + w/2 > wid ) { | 2138 | if ( x + w/2 > wid ) { |
2073 | x = 0; | 2139 | x = 0; |
2074 | y += h; | 2140 | y += h; |
2075 | } | 2141 | } |
2076 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); | 2142 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); |
2077 | } | 2143 | } |
2078 | y= dayLabelHei; | 2144 | y= dayLabelHei; |
2079 | h = cellHei ; | 2145 | h = cellHei ; |
2080 | for ( i = 0; i < 6; i++) { | 2146 | for ( i = 0; i < 6; i++) { |
2081 | if ( i == (6-rowModulo)) | 2147 | if ( i == (6-rowModulo)) |
2082 | ++h; | 2148 | ++h; |
2083 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 2149 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
2084 | y += h; | 2150 | y += h; |
2085 | } | 2151 | } |
2086 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 2152 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
2087 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 2153 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
2088 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 2154 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
2089 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 2155 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
2090 | updateDayLabels(); | 2156 | updateDayLabels(); |
2091 | //bool forceUpdate = !updatePossible; | 2157 | //bool forceUpdate = !updatePossible; |
2092 | updatePossible = true; | 2158 | updatePossible = true; |
2093 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 2159 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
2094 | } | 2160 | } |
2095 | 2161 | ||
2096 | void KOMonthView::showContextMenu( Incidence *incidence ) | 2162 | void KOMonthView::showContextMenu( Incidence *incidence ) |
2097 | { | 2163 | { |
2098 | if( incidence ) | 2164 | if( incidence ) |
2099 | mContextMenu->showIncidencePopup(incidence); | 2165 | mContextMenu->showIncidencePopup(incidence); |
2100 | else { | 2166 | else { |
2101 | //qDebug("KOMonthView::showContextMenu "); | 2167 | //qDebug("KOMonthView::showContextMenu "); |
2102 | mNewItemMenu->popup(QCursor::pos()); | 2168 | mNewItemMenu->popup(QCursor::pos()); |
2103 | } | 2169 | } |
2104 | /* | 2170 | /* |
2105 | if( incidence && incidence->typeID() == eventID ) { | 2171 | if( incidence && incidence->typeID() == eventID ) { |
2106 | Event *event = static_cast<Event *>(incidence); | 2172 | Event *event = static_cast<Event *>(incidence); |
2107 | mContextMenu->showEventPopup(event); | 2173 | mContextMenu->showEventPopup(event); |
2108 | } else { | 2174 | } else { |
2109 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 2175 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
2110 | } | 2176 | } |
2111 | */ | 2177 | */ |
2112 | } | 2178 | } |
2113 | MonthViewCell * KOMonthView::selectedCell( ) | 2179 | MonthViewCell * KOMonthView::selectedCell( ) |
2114 | { | 2180 | { |
2115 | return mSelectedCell; | 2181 | return mSelectedCell; |
2116 | } | 2182 | } |
2117 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 2183 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
2118 | { | 2184 | { |
2119 | //qDebug("KOMonthView::setSelectedCell %d", cell); | 2185 | //qDebug("KOMonthView::setSelectedCell %d", cell); |
2120 | if ( mSelectedCell && mSelectedCell != cell ) { | 2186 | if ( mSelectedCell && mSelectedCell != cell ) { |
2121 | MonthViewCell * mvc = mSelectedCell; | 2187 | MonthViewCell * mvc = mSelectedCell; |
2122 | mSelectedCell = cell; | 2188 | mSelectedCell = cell; |
2123 | mvc->deselect(); | 2189 | mvc->deselect(); |
2124 | } else | 2190 | } else |
2125 | mSelectedCell = cell; | 2191 | mSelectedCell = cell; |
2126 | // if ( mSelectedCell ) | 2192 | // if ( mSelectedCell ) |
2127 | // mSelectedCell->select(); | 2193 | // mSelectedCell->select(); |
2128 | if ( !mSelectedCell ) | 2194 | if ( !mSelectedCell ) |
2129 | emit incidenceSelected( 0 ); | 2195 | emit incidenceSelected( 0 ); |
2130 | else | 2196 | else |
2131 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 2197 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
2132 | } | 2198 | } |
2133 | 2199 | ||
2134 | void KOMonthView::processSelectionChange() | 2200 | void KOMonthView::processSelectionChange() |
2135 | { | 2201 | { |
2136 | QPtrList<Incidence> incidences = selectedIncidences(); | 2202 | QPtrList<Incidence> incidences = selectedIncidences(); |
2137 | if (incidences.count() > 0) { | 2203 | if (incidences.count() > 0) { |
2138 | emit incidenceSelected( incidences.first() ); | 2204 | emit incidenceSelected( incidences.first() ); |
2139 | } else { | 2205 | } else { |
2140 | emit incidenceSelected( 0 ); | 2206 | emit incidenceSelected( 0 ); |
2141 | clearSelection(); | 2207 | clearSelection(); |
2142 | } | 2208 | } |
2143 | } | 2209 | } |
2144 | 2210 | ||
2145 | void KOMonthView::clearSelection() | 2211 | void KOMonthView::clearSelection() |
2146 | { | 2212 | { |
2147 | if ( mSelectedCell ) { | 2213 | if ( mSelectedCell ) { |
2148 | mSelectedCell->deselect(); | 2214 | mSelectedCell->deselect(); |
2149 | mSelectedCell = 0; | 2215 | mSelectedCell = 0; |
2150 | } | 2216 | } |
2151 | } | 2217 | } |
2152 | 2218 | ||
2153 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) | 2219 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) |
2154 | { | 2220 | { |
2155 | if ( !e->isAutoRepeat() ) { | 2221 | if ( !e->isAutoRepeat() ) { |
2156 | mFlagKeyPressed = false; | 2222 | mFlagKeyPressed = false; |
2157 | } | 2223 | } |
2158 | } | 2224 | } |
2159 | 2225 | ||
2160 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 2226 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
2161 | { | 2227 | { |
2162 | 2228 | ||
2163 | qApp->processEvents(); | 2229 | qApp->processEvents(); |
2164 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2230 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2165 | //e->ignore(); | 2231 | //e->ignore(); |
2166 | e->accept(); | 2232 | e->accept(); |
2167 | return; | 2233 | return; |
2168 | } | 2234 | } |
2169 | if (! e->isAutoRepeat() ) | 2235 | if (! e->isAutoRepeat() ) |
2170 | mFlagKeyPressed = true; | 2236 | mFlagKeyPressed = true; |
2171 | switch(e->key()) { | 2237 | switch(e->key()) { |
2172 | case Key_Up: | 2238 | case Key_Up: |
2173 | { | 2239 | { |
2174 | if ( mShowWeekView ) { | 2240 | if ( mShowWeekView ) { |
2175 | emit selectWeekNum ( currentWeek() - 1 ); | 2241 | emit selectWeekNum ( currentWeek() - 1 ); |
2176 | } | 2242 | } |
2177 | else { | 2243 | else { |
2178 | emit prevMonth(); | 2244 | emit prevMonth(); |
2179 | } | 2245 | } |
2180 | } | 2246 | } |
2181 | e->accept(); | 2247 | e->accept(); |
2182 | break; | 2248 | break; |
2183 | case Key_Down: | 2249 | case Key_Down: |
2184 | { | 2250 | { |
2185 | if ( mShowWeekView ) { | 2251 | if ( mShowWeekView ) { |
2186 | emit selectWeekNum ( currentWeek() +1); | 2252 | emit selectWeekNum ( currentWeek() +1); |
2187 | } | 2253 | } |
2188 | else { | 2254 | else { |
2189 | emit nextMonth(); | 2255 | emit nextMonth(); |
2190 | } | 2256 | } |
2191 | 2257 | ||
2192 | } | 2258 | } |
2193 | e->accept(); | 2259 | e->accept(); |
2194 | break; | 2260 | break; |
2195 | case Key_Return: | 2261 | case Key_Return: |
2196 | case Key_Enter: | 2262 | case Key_Enter: |
2197 | { | 2263 | { |
2198 | selectInternalWeekNum ( currentWeek() ); | 2264 | selectInternalWeekNum ( currentWeek() ); |
2199 | } | 2265 | } |
2200 | e->accept(); | 2266 | e->accept(); |
2201 | break; | 2267 | break; |
2202 | case Key_D: | 2268 | case Key_D: |
2203 | if ( mSelectedCell ) { | 2269 | if ( mSelectedCell ) { |
2204 | mSelectedCell->showDay(); | 2270 | mSelectedCell->showDay(); |
2205 | e->accept(); | 2271 | e->accept(); |
2206 | } else { | 2272 | } else { |
2207 | e->ignore(); | 2273 | e->ignore(); |
2208 | } | 2274 | } |
2209 | break; | 2275 | break; |
2210 | default: | 2276 | default: |
2211 | e->ignore(); | 2277 | e->ignore(); |
2212 | break; | 2278 | break; |
2213 | } | 2279 | } |
2214 | } | 2280 | } |
2215 | 2281 | ||
2216 | void KOMonthView::nextCell() | 2282 | void KOMonthView::nextCell() |
2217 | { | 2283 | { |
2218 | focusNextPrevChild ( true ); | 2284 | focusNextPrevChild ( true ); |
2219 | } | 2285 | } |
2220 | void KOMonthView::prevCell() | 2286 | void KOMonthView::prevCell() |
2221 | { | 2287 | { |
2222 | focusNextPrevChild ( false ); | 2288 | focusNextPrevChild ( false ); |
2223 | } | 2289 | } |
2224 | 2290 | ||
2225 | void KOMonthView::slotNewTodo() | 2291 | void KOMonthView::slotNewTodo() |
2226 | { | 2292 | { |
2227 | //qDebug("KOMonthView::slotNewTodo() "); | 2293 | //qDebug("KOMonthView::slotNewTodo() "); |
2228 | if ( mPopupCell ){ | 2294 | if ( mPopupCell ){ |
2229 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2295 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2230 | emit newTodoSignal(dt,true); | 2296 | emit newTodoSignal(dt,true); |
2231 | } | 2297 | } |
2232 | mPopupCell = 0; | 2298 | mPopupCell = 0; |
2233 | } | 2299 | } |
2234 | void KOMonthView::slotNewEvent() | 2300 | void KOMonthView::slotNewEvent() |
2235 | { | 2301 | { |
2236 | if ( mPopupCell ) { | 2302 | if ( mPopupCell ) { |
2237 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2303 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2238 | emit newEventSignal( dt ); | 2304 | emit newEventSignal( dt ); |
2239 | } | 2305 | } |
2240 | //qDebug("KOMonthView::slotNewEvent() "); | 2306 | //qDebug("KOMonthView::slotNewEvent() "); |
2241 | mPopupCell = 0; | 2307 | mPopupCell = 0; |
2242 | } | 2308 | } |
2243 | 2309 | ||
2244 | void KOMonthView::slotEditJournal() | 2310 | void KOMonthView::slotEditJournal() |
2245 | { | 2311 | { |
2246 | if ( mPopupCell ) | 2312 | if ( mPopupCell ) |
2247 | emit showJournalSignal( 7, mPopupCell->date() ); | 2313 | emit showJournalSignal( 7, mPopupCell->date() ); |
2248 | //qDebug("KOMonthView::slotEditJournal() "); | 2314 | //qDebug("KOMonthView::slotEditJournal() "); |
2249 | mPopupCell = 0; | 2315 | mPopupCell = 0; |
2250 | } | 2316 | } |
2251 | 2317 | ||
2252 | void KOMonthView::setPopupCell( MonthViewCell * c) | 2318 | void KOMonthView::setPopupCell( MonthViewCell * c) |
2253 | { | 2319 | { |
2254 | mPopupCell = c; | 2320 | mPopupCell = c; |
2255 | } | 2321 | } |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 4d62e9b..61a141a 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -1,348 +1,350 @@ | |||
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 | 19 | ||
20 | #ifndef _KOMONTHVIEW_H | 20 | #ifndef _KOMONTHVIEW_H |
21 | #define _KOMONTHVIEW_H | 21 | #define _KOMONTHVIEW_H |
22 | 22 | ||
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qframe.h> | 24 | #include <qframe.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qpoint.h> | 27 | #include <qpoint.h> |
28 | #include <qwidgetstack.h> | 28 | #include <qwidgetstack.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qintdict.h> | 31 | #include <qintdict.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qvaluelist.h> | 33 | #include <qvaluelist.h> |
34 | #include <qptrvector.h> | 34 | #include <qptrvector.h> |
35 | 35 | ||
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | #include <libkcal/event.h> | 37 | #include <libkcal/event.h> |
38 | 38 | ||
39 | #include "koeventview.h" | 39 | #include "koeventview.h" |
40 | #include "navigatorbar.h" | 40 | #include "navigatorbar.h" |
41 | 41 | ||
42 | #ifdef DESKTOP_VERSION | 42 | #ifdef DESKTOP_VERSION |
43 | class QToolTipGroup; | 43 | class QToolTipGroup; |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | class KNOWhatsThis; | 46 | class KNOWhatsThis; |
47 | class MonthViewCell; | 47 | class MonthViewCell; |
48 | class KOWeekButton : public QPushButton | 48 | class KOWeekButton : public QPushButton |
49 | { | 49 | { |
50 | Q_OBJECT | 50 | Q_OBJECT |
51 | public: | 51 | public: |
52 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : | 52 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : |
53 | QPushButton( parent, name) | 53 | QPushButton( parent, name) |
54 | { | 54 | { |
55 | connect( this, SIGNAL( clicked() ), | 55 | connect( this, SIGNAL( clicked() ), |
56 | SLOT( bottonClicked() )); | 56 | SLOT( bottonClicked() )); |
57 | mNumber = -1; | 57 | mNumber = -1; |
58 | } | 58 | } |
59 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} | 59 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} |
60 | int getWeekNum() { return mNumber;} | 60 | int getWeekNum() { return mNumber;} |
61 | signals: | 61 | signals: |
62 | void selectWeekNum ( int ); | 62 | void selectWeekNum ( int ); |
63 | private: | 63 | private: |
64 | void focusInEvent ( QFocusEvent * ){;} | 64 | void focusInEvent ( QFocusEvent * ){;} |
65 | int mNumber; | 65 | int mNumber; |
66 | void keyPressEvent ( QKeyEvent * e ) | 66 | void keyPressEvent ( QKeyEvent * e ) |
67 | { | 67 | { |
68 | e->ignore(); | 68 | e->ignore(); |
69 | } | 69 | } |
70 | 70 | ||
71 | private slots : | 71 | private slots : |
72 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } | 72 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } |
73 | }; | 73 | }; |
74 | 74 | ||
75 | class KNoScrollListBox: public QListBox | 75 | class KNoScrollListBox: public QListBox |
76 | { | 76 | { |
77 | Q_OBJECT | 77 | Q_OBJECT |
78 | public: | 78 | public: |
79 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 79 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
80 | ~KNoScrollListBox(); | 80 | ~KNoScrollListBox(); |
81 | QString getWhatsThisText(QPoint p) ; | 81 | QString getWhatsThisText(QPoint p) ; |
82 | 82 | ||
83 | signals: | 83 | signals: |
84 | void shiftDown(); | 84 | void shiftDown(); |
85 | void shiftUp(); | 85 | void shiftUp(); |
86 | void rightClick(); | 86 | void rightClick(); |
87 | void nextCell(); | 87 | void nextCell(); |
88 | void prevCell(); | 88 | void prevCell(); |
89 | void highlightIncidence( Incidence * , MonthViewCell*, int ); | 89 | void highlightIncidence( Incidence * , MonthViewCell*, int ); |
90 | 90 | ||
91 | protected slots: | 91 | protected slots: |
92 | void oneDown(); | 92 | void oneDown(); |
93 | void keyPressEvent(QKeyEvent *); | 93 | void keyPressEvent(QKeyEvent *); |
94 | void keyReleaseEvent(QKeyEvent *); | 94 | void keyReleaseEvent(QKeyEvent *); |
95 | void mousePressEvent(QMouseEvent *); | 95 | void mousePressEvent(QMouseEvent *); |
96 | void focusInEvent ( QFocusEvent * ); | 96 | void focusInEvent ( QFocusEvent * ); |
97 | void focusOutEvent ( QFocusEvent * ); | 97 | void focusOutEvent ( QFocusEvent * ); |
98 | 98 | ||
99 | private: | 99 | private: |
100 | bool resetOnFocusIn; | 100 | bool resetOnFocusIn; |
101 | KNOWhatsThis * mWT; | 101 | KNOWhatsThis * mWT; |
102 | }; | 102 | }; |
103 | 103 | ||
104 | 104 | ||
105 | class MonthViewItem: public QListBoxItem | 105 | class MonthViewItem: public QListBoxItem |
106 | { | 106 | { |
107 | public: | 107 | public: |
108 | MonthViewItem( Incidence *,const QString & title ); | 108 | MonthViewItem( Incidence *,const QString & title ); |
109 | void recycle( Incidence *incidence, const QString & s); | 109 | void recycle( Incidence *incidence, const QString & s); |
110 | void setRecur(bool on) { mRecur = on; } | 110 | void setRecur(bool on) { mRecur = on; } |
111 | void setAlarm(bool on) { mAlarm = on; } | 111 | void setAlarm(bool on) { mAlarm = on; } |
112 | void setReply(bool on) { mReply = on; } | 112 | void setReply(bool on) { mReply = on; } |
113 | void setMoreInfo(bool on) { mInfo = on; } | 113 | void setMoreInfo(bool on) { mInfo = on; } |
114 | void setMultiDay(int type) { mMultiday = type; } | 114 | void setMultiDay(int type) { mMultiday = type; } |
115 | int multiDay() { return mMultiday; } | 115 | int multiDay() { return mMultiday; } |
116 | void setMultiDayPos(int type) { mdayPos = type; } | 116 | void setMultiDayPos(int type) { mdayPos = type; } |
117 | int gettMultiDayPos() { return mdayPos; } | 117 | int gettMultiDayPos() { return mdayPos; } |
118 | void setBlockRepaint(bool on) { mblockRepaint = on; } | 118 | void setBlockRepaint(bool on) { mblockRepaint = on; } |
119 | bool setHighlighted( Incidence * ); | 119 | bool setHighlighted( Incidence * ); |
120 | 120 | ||
121 | void setPalette(const QPalette &p) { mPalette = p; } | 121 | void setPalette(const QPalette &p) { mPalette = p; } |
122 | QPalette palette() const { return mPalette; } | 122 | QPalette palette() const { return mPalette; } |
123 | bool setHighlightedFalse(); | 123 | bool setHighlightedFalse(); |
124 | Incidence *incidence() const { return mIncidence; } | 124 | Incidence *incidence() const { return mIncidence; } |
125 | 125 | ||
126 | protected: | 126 | protected: |
127 | virtual void paint(QPainter *); | 127 | virtual void paint(QPainter *); |
128 | virtual int height(const QListBox *) const; | 128 | virtual int height(const QListBox *) const; |
129 | virtual int width(const QListBox *) const; | 129 | virtual int width(const QListBox *) const; |
130 | 130 | ||
131 | private: | 131 | private: |
132 | int mdayPos; | 132 | int mdayPos; |
133 | bool isWeekItem; | 133 | bool isWeekItem; |
134 | bool mblockRepaint; | 134 | bool mblockRepaint; |
135 | int mMultiday; | 135 | int mMultiday; |
136 | bool mRecur; | 136 | bool mRecur; |
137 | bool mAlarm; | 137 | bool mAlarm; |
138 | bool mReply; | 138 | bool mReply; |
139 | bool mInfo; | 139 | bool mInfo; |
140 | bool mDisplayHighlighted; | 140 | bool mDisplayHighlighted; |
141 | 141 | ||
142 | QPalette mPalette; | 142 | QPalette mPalette; |
143 | QDate mDate; | 143 | QDate mDate; |
144 | 144 | ||
145 | Incidence *mIncidence; | 145 | Incidence *mIncidence; |
146 | }; | 146 | }; |
147 | 147 | ||
148 | 148 | ||
149 | class KOMonthView; | 149 | class KOMonthView; |
150 | 150 | ||
151 | class MonthViewCell : public KNoScrollListBox | 151 | class MonthViewCell : public KNoScrollListBox |
152 | { | 152 | { |
153 | Q_OBJECT | 153 | Q_OBJECT |
154 | public: | 154 | public: |
155 | MonthViewCell(KOMonthView *,QWidget* ); | 155 | MonthViewCell(KOMonthView *,QWidget* ); |
156 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} | 156 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} |
157 | 157 | ||
158 | void setDate( const QDate & ); | 158 | void setDate( const QDate & ); |
159 | QDate date() const; | 159 | QDate date() const; |
160 | 160 | ||
161 | void setPrimary( bool ); | 161 | void setPrimary( bool ); |
162 | bool isPrimary() const; | 162 | bool isPrimary() const; |
163 | 163 | ||
164 | void setHoliday( bool ); | 164 | void setHoliday( bool ); |
165 | void setHoliday( const QString & ); | 165 | void setHoliday( const QString & ); |
166 | 166 | ||
167 | void updateCell(); | 167 | void updateCell(); |
168 | void startUpdateCell(); | 168 | void startUpdateCell(); |
169 | void finishUpdateCell(); | 169 | void finishUpdateCell(); |
170 | int insertEvent(Event *); | 170 | int insertEvent(Event *); |
171 | void insertTodo(Todo *); | 171 | void insertTodo(Todo *); |
172 | 172 | ||
173 | void updateConfig( bool bigFont = false ); | 173 | void updateConfig( bool bigFont = false ); |
174 | 174 | ||
175 | void enableScrollBars( bool ); | 175 | void enableScrollBars( bool ); |
176 | 176 | ||
177 | Incidence *selectedIncidence(); | 177 | Incidence *selectedIncidence(); |
178 | QDate selectedIncidenceDate(); | 178 | QDate selectedIncidenceDate(); |
179 | QPushButton * dateLabel() { return mLabel; } | 179 | QPushButton * dateLabel() { return mLabel; } |
180 | bool doHighLight( Incidence *); | 180 | bool doHighLight( Incidence *); |
181 | void deselect(); | 181 | void deselect(); |
182 | void select(); | 182 | void select(); |
183 | #ifdef DESKTOP_VERSION | 183 | #ifdef DESKTOP_VERSION |
184 | static QToolTipGroup *toolTipGroup(); | 184 | static QToolTipGroup *toolTipGroup(); |
185 | #endif | 185 | #endif |
186 | signals: | 186 | signals: |
187 | void defaultAction( Incidence * ); | 187 | void defaultAction( Incidence * ); |
188 | void newEventSignal( QDateTime ); | 188 | void newEventSignal( QDateTime ); |
189 | void showDaySignal( QDate ); | 189 | void showDaySignal( QDate ); |
190 | 190 | ||
191 | protected: | 191 | protected: |
192 | QStringList mToolTip; | 192 | QStringList mToolTip; |
193 | void resizeEvent( QResizeEvent * ); | 193 | void resizeEvent( QResizeEvent * ); |
194 | 194 | ||
195 | public slots: | 195 | public slots: |
196 | void showDay(); | 196 | void showDay(); |
197 | void deHighLight(); | 197 | void deHighLight(); |
198 | void repaintfinishUpdateCell(); | 198 | void repaintfinishUpdateCell(); |
199 | protected slots: | 199 | protected slots: |
200 | void defaultAction( QListBoxItem * ); | 200 | void defaultAction( QListBoxItem * ); |
201 | void contextMenu( QListBoxItem * ); | 201 | void contextMenu( QListBoxItem * ); |
202 | void selection( QListBoxItem * ); | 202 | void selection( QListBoxItem * ); |
203 | void cellClicked( QListBoxItem * ); | 203 | void cellClicked( QListBoxItem * ); |
204 | void newEvent(); | 204 | void newEvent(); |
205 | 205 | ||
206 | private: | 206 | private: |
207 | int mdayCount; | 207 | int mdayCount; |
208 | QPtrList <MonthViewItem> mAvailItemList; | 208 | QPtrList <MonthViewItem> mAvailItemList; |
209 | KOMonthView *mMonthView; | 209 | KOMonthView *mMonthView; |
210 | int currentPalette; | 210 | int currentPalette; |
211 | 211 | ||
212 | QDate mDate; | 212 | QDate mDate; |
213 | bool mPrimary; | 213 | bool mPrimary; |
214 | bool mHoliday; | 214 | bool mHoliday; |
215 | QString mHolidayString; | 215 | QString mHolidayString; |
216 | 216 | ||
217 | //QLabel *mLabel; | 217 | //QLabel *mLabel; |
218 | QPushButton *mLabel; | 218 | QPushButton *mLabel; |
219 | //QListBox *mItemList; | 219 | //QListBox *mItemList; |
220 | #ifdef DESKTOP_VERSION | 220 | #ifdef DESKTOP_VERSION |
221 | static QToolTipGroup *mToolTipGroup; | 221 | static QToolTipGroup *mToolTipGroup; |
222 | #endif | 222 | #endif |
223 | QSize mLabelSize; | 223 | QSize mLabelSize; |
224 | QSize mLabelBigSize; | 224 | QSize mLabelBigSize; |
225 | QPalette mHolidayPalette; | 225 | QPalette mHolidayPalette; |
226 | QPalette mStandardPalette; | 226 | QPalette mStandardPalette; |
227 | QPalette mPrimaryPalette; | 227 | QPalette mPrimaryPalette; |
228 | QPalette mNonPrimaryPalette; | 228 | QPalette mNonPrimaryPalette; |
229 | void setMyPalette(); | 229 | void setMyPalette(); |
230 | QPalette getPalette (); | 230 | QPalette getPalette (); |
231 | 231 | ||
232 | }; | 232 | }; |
233 | 233 | ||
234 | 234 | ||
235 | class KOMonthView: public KOEventView | 235 | class KOMonthView: public KOEventView |
236 | { | 236 | { |
237 | Q_OBJECT | 237 | Q_OBJECT |
238 | public: | 238 | public: |
239 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); | 239 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); |
240 | ~KOMonthView(); | 240 | ~KOMonthView(); |
241 | 241 | ||
242 | /** Returns maximum number of days supported by the komonthview */ | 242 | /** Returns maximum number of days supported by the komonthview */ |
243 | virtual int maxDatesHint(); | 243 | virtual int maxDatesHint(); |
244 | 244 | ||
245 | /** Returns number of currently shown dates. */ | 245 | /** Returns number of currently shown dates. */ |
246 | virtual int currentDateCount(); | 246 | virtual int currentDateCount(); |
247 | 247 | ||
248 | /** returns the currently selected events */ | 248 | /** returns the currently selected events */ |
249 | virtual QPtrList<Incidence> selectedIncidences(); | 249 | virtual QPtrList<Incidence> selectedIncidences(); |
250 | 250 | ||
251 | /** returns dates of the currently selected events */ | 251 | /** returns dates of the currently selected events */ |
252 | virtual DateList selectedDates(); | 252 | virtual DateList selectedDates(); |
253 | #if 0 | 253 | #if 0 |
254 | virtual void printPreview(CalPrinter *calPrinter, | 254 | virtual void printPreview(CalPrinter *calPrinter, |
255 | const QDate &, const QDate &); | 255 | const QDate &, const QDate &); |
256 | #endif | 256 | #endif |
257 | bool isMonthView() { return !mShowWeekView; } | 257 | bool isMonthView() { return !mShowWeekView; } |
258 | bool isUpdatePossible() { return updatePossible; } | 258 | bool isUpdatePossible() { return updatePossible; } |
259 | 259 | ||
260 | MonthViewCell * selectedCell(); | 260 | MonthViewCell * selectedCell(); |
261 | bool skipResize; | 261 | bool skipResize; |
262 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} | 262 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} |
263 | void clearList(); | 263 | void clearList(); |
264 | public slots: | 264 | public slots: |
265 | void incidenceHighlighted( Incidence *, MonthViewCell*, int ); | 265 | void incidenceHighlighted( Incidence *, MonthViewCell*, int ); |
266 | void nextCell(); | 266 | void nextCell(); |
267 | void prevCell(); | 267 | void prevCell(); |
268 | virtual void updateView(); | 268 | virtual void updateView(); |
269 | virtual void updateConfig(); | 269 | virtual void updateConfig(); |
270 | virtual void showDates(const QDate &start, const QDate &end); | 270 | virtual void showDates(const QDate &start, const QDate &end); |
271 | virtual void showEvents(QPtrList<Event> eventList); | 271 | virtual void showEvents(QPtrList<Event> eventList); |
272 | 272 | ||
273 | void changeEventDisplay(Event *, int); | 273 | void changeEventDisplay(Event *, int); |
274 | 274 | ||
275 | void clearSelection(); | 275 | void clearSelection(); |
276 | 276 | ||
277 | void showContextMenu( Incidence * ); | 277 | void showContextMenu( Incidence * ); |
278 | 278 | ||
279 | void setSelectedCell( MonthViewCell * ); | 279 | void setSelectedCell( MonthViewCell * ); |
280 | void setPopupCell( MonthViewCell * ); | 280 | void setPopupCell( MonthViewCell * ); |
281 | void switchView(); | 281 | void switchView(); |
282 | void setKeyBFocus(); | 282 | void setKeyBFocus(); |
283 | 283 | ||
284 | protected slots: | 284 | protected slots: |
285 | void catChanged( Incidence * ); | 285 | void catChanged( Incidence * ); |
286 | void setKeyBoardFocus(); | 286 | void setKeyBoardFocus(); |
287 | void slotNewTodo(); | 287 | void slotNewTodo(); |
288 | void slotNewEvent(); | 288 | void slotNewEvent(); |
289 | void slotEditJournal(); | 289 | void slotEditJournal(); |
290 | void slotComputeLayout(); | 290 | void slotComputeLayout(); |
291 | void selectInternalWeekNum ( int ); | 291 | void selectInternalWeekNum ( int ); |
292 | void processSelectionChange(); | 292 | void processSelectionChange(); |
293 | signals: | 293 | signals: |
294 | void nextMonth(); | 294 | void nextMonth(); |
295 | void prevMonth(); | 295 | void prevMonth(); |
296 | void selectWeekNum ( int ); | 296 | void selectWeekNum ( int ); |
297 | void selectMonth (); | 297 | void selectMonth (); |
298 | void showDaySignal( QDate ); | 298 | void showDaySignal( QDate ); |
299 | void newTodoSignal( QDateTime, bool ); | 299 | void newTodoSignal( QDateTime, bool ); |
300 | void showJournalSignal( int,QDate ); | 300 | void showJournalSignal( int,QDate ); |
301 | protected: | 301 | protected: |
302 | void resizeEvent(QResizeEvent *); | 302 | void resizeEvent(QResizeEvent *); |
303 | void viewChanged(); | 303 | void viewChanged(); |
304 | void updateDayLabels(); | 304 | void updateDayLabels(); |
305 | int mapWeekLayout( int, bool ); | ||
305 | 306 | ||
306 | private: | 307 | private: |
307 | int mKBFcounter; | 308 | int mKBFcounter; |
308 | QTimer* mComputeLayoutTimer; | 309 | QTimer* mComputeLayoutTimer; |
309 | NavigatorBar* mNavigatorBar; | 310 | NavigatorBar* mNavigatorBar; |
310 | int currentWeek(); | 311 | int currentWeek(); |
311 | bool clPending; | 312 | bool clPending; |
312 | QWidgetStack * mWidStack; | 313 | QWidgetStack * mWidStack; |
313 | QWidget* mMonthView; | 314 | QWidget* mMonthView; |
314 | QWidget* mWeekView; | 315 | QWidget* mWeekView; |
315 | bool mShowWeekView; | 316 | bool mShowWeekView; |
316 | bool updatePossible; | 317 | bool updatePossible; |
317 | int mDaysPerWeek; | 318 | int mDaysPerWeek; |
318 | int mNumWeeks; | 319 | int mNumWeeks; |
319 | int mNumCells; | 320 | int mNumCells; |
320 | //bool mWeekStartsMonday; | 321 | //bool mWeekStartsMonday; |
321 | bool mShowSatSunComp; | 322 | bool mShowSatSunComp; |
322 | void computeLayout(); | 323 | void computeLayout(); |
323 | void computeLayoutWeek(); | 324 | void computeLayoutWeek(); |
325 | void doComputeLayoutWeek(); | ||
324 | 326 | ||
325 | QPtrVector<MonthViewCell> mCells; | 327 | QPtrVector<MonthViewCell> mCells; |
326 | QPtrVector<QLabel> mDayLabels; | 328 | QPtrVector<QLabel> mDayLabels; |
327 | QPtrVector<KOWeekButton> mWeekLabels; | 329 | QPtrVector<KOWeekButton> mWeekLabels; |
328 | QPtrVector<MonthViewCell> mCellsW; | 330 | QPtrVector<MonthViewCell> mCellsW; |
329 | QPtrVector<QLabel> mDayLabelsW; | 331 | QPtrVector<QLabel> mDayLabelsW; |
330 | QPtrVector<KOWeekButton> mWeekLabelsW; | 332 | QPtrVector<KOWeekButton> mWeekLabelsW; |
331 | 333 | ||
332 | bool mShortDayLabelsM; | 334 | bool mShortDayLabelsM; |
333 | bool mShortDayLabelsW; | 335 | bool mShortDayLabelsW; |
334 | int mWidthLongDayLabel; | 336 | int mWidthLongDayLabel; |
335 | 337 | ||
336 | QDate mStartDate; | 338 | QDate mStartDate; |
337 | 339 | ||
338 | MonthViewCell *mSelectedCell; | 340 | MonthViewCell *mSelectedCell; |
339 | MonthViewCell *mPopupCell; | 341 | MonthViewCell *mPopupCell; |
340 | bool mFlagKeyPressed; | 342 | bool mFlagKeyPressed; |
341 | KOEventPopupMenu *mContextMenu; | 343 | KOEventPopupMenu *mContextMenu; |
342 | QPopupMenu *mNewItemMenu; | 344 | QPopupMenu *mNewItemMenu; |
343 | void keyPressEvent ( QKeyEvent * ) ; | 345 | void keyPressEvent ( QKeyEvent * ) ; |
344 | void keyReleaseEvent ( QKeyEvent * ) ; | 346 | void keyReleaseEvent ( QKeyEvent * ) ; |
345 | 347 | ||
346 | }; | 348 | }; |
347 | 349 | ||
348 | #endif | 350 | #endif |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index a63297e..9e7f18c 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,624 +1,625 @@ | |||
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 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 120 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
121 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 121 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
122 | 122 | ||
123 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 123 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
124 | addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); | 124 | addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); |
125 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); | 125 | addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); |
126 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); | 126 | addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); |
127 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 127 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
128 | addItemInt("AllDay Size",&mAllDaySize,28); | 128 | addItemInt("AllDay Size",&mAllDaySize,28); |
129 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 129 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
130 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 130 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
131 | 131 | ||
132 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 132 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
133 | addItemStringList("EventSummary User",&mEventSummaryUser); | 133 | addItemStringList("EventSummary User",&mEventSummaryUser); |
134 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 134 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
135 | addItemStringList("JournalSummary User",&mJournalSummaryUser); | 135 | addItemStringList("JournalSummary User",&mJournalSummaryUser); |
136 | 136 | ||
137 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 137 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
138 | addItemBool("Enable Project View",&mEnableProjectView,false); | 138 | addItemBool("Enable Project View",&mEnableProjectView,false); |
139 | addItemBool("Auto Save",&mAutoSave,false); | 139 | addItemBool("Auto Save",&mAutoSave,false); |
140 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 140 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
141 | addItemBool("Confirm Deletes",&mConfirm,true); | 141 | addItemBool("Confirm Deletes",&mConfirm,true); |
142 | addItemString("Archive File",&mArchiveFile); | 142 | addItemString("Archive File",&mArchiveFile); |
143 | addItemString("Html Export File",&mHtmlExportFile, | 143 | addItemString("Html Export File",&mHtmlExportFile, |
144 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 144 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
145 | addItemBool("Html With Save",&mHtmlWithSave,false); | 145 | addItemBool("Html With Save",&mHtmlWithSave,false); |
146 | 146 | ||
147 | KPrefs::setCurrentGroup("Personal Settings"); | 147 | KPrefs::setCurrentGroup("Personal Settings"); |
148 | 148 | ||
149 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 149 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
150 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 150 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
151 | addItemBool("Bcc",&mBcc,false); | 151 | addItemBool("Bcc",&mBcc,false); |
152 | 152 | ||
153 | KPrefs::setCurrentGroup("Time & Date"); | 153 | KPrefs::setCurrentGroup("Time & Date"); |
154 | 154 | ||
155 | 155 | ||
156 | addItemInt("Default Start Time",&mStartTime,10); | 156 | addItemInt("Default Start Time",&mStartTime,10); |
157 | addItemInt("Default Duration",&mDefaultDuration,2); | 157 | addItemInt("Default Duration",&mDefaultDuration,2); |
158 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 158 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
159 | KPrefs::setCurrentGroup("AlarmSettings"); | 159 | KPrefs::setCurrentGroup("AlarmSettings"); |
160 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 160 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
161 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 161 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
162 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 162 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
163 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 163 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
164 | 164 | ||
165 | 165 | ||
166 | KPrefs::setCurrentGroup("Calendar"); | 166 | KPrefs::setCurrentGroup("Calendar"); |
167 | 167 | ||
168 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 168 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
169 | 169 | ||
170 | KPrefs::setCurrentGroup("Fonts"); | 170 | KPrefs::setCurrentGroup("Fonts"); |
171 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 171 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
172 | QFont fon = KGlobalSettings::generalFont(); | 172 | QFont fon = KGlobalSettings::generalFont(); |
173 | addItemFont("TimeBar Font",&mTimeBarFont,fon ); | 173 | addItemFont("TimeBar Font",&mTimeBarFont,fon ); |
174 | addItemFont("MonthView Font",&mMonthViewFont,fon); | 174 | addItemFont("MonthView Font",&mMonthViewFont,fon); |
175 | addItemFont("AgendaView Font",&mAgendaViewFont,fon); | 175 | addItemFont("AgendaView Font",&mAgendaViewFont,fon); |
176 | addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); | 176 | addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); |
177 | addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); | 177 | addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); |
178 | addItemFont("TodoView Font",&mTodoViewFont,fon); | 178 | addItemFont("TodoView Font",&mTodoViewFont,fon); |
179 | addItemFont("ListView Font",&mListViewFont,fon); | 179 | addItemFont("ListView Font",&mListViewFont,fon); |
180 | addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); | 180 | addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); |
181 | addItemFont("EditBox Font",&mEditBoxFont,fon); | 181 | addItemFont("EditBox Font",&mEditBoxFont,fon); |
182 | addItemFont("JournalView Font",&mJornalViewFont,fon); | 182 | addItemFont("JournalView Font",&mJornalViewFont,fon); |
183 | addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); | 183 | addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); |
184 | addItemFont("EventView Font",&mEventViewFont,fon); | 184 | addItemFont("EventView Font",&mEventViewFont,fon); |
185 | 185 | ||
186 | KPrefs::setCurrentGroup("RemoteSyncing"); | 186 | KPrefs::setCurrentGroup("RemoteSyncing"); |
187 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 187 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
188 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 188 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
189 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 189 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
190 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 190 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
191 | 191 | ||
192 | #ifdef _WIN32_ | 192 | #ifdef _WIN32_ |
193 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 193 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
194 | #else | 194 | #else |
195 | QString hdp= locateLocal("data","korganizer")+"/"; | 195 | QString hdp= locateLocal("data","korganizer")+"/"; |
196 | #endif | 196 | #endif |
197 | 197 | ||
198 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 198 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
199 | 199 | ||
200 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 200 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
201 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 201 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
202 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 202 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
203 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 203 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
204 | 204 | ||
205 | 205 | ||
206 | KPrefs::setCurrentGroup("Locale"); | 206 | KPrefs::setCurrentGroup("Locale"); |
207 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 207 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
208 | 208 | ||
209 | 209 | ||
210 | KPrefs::setCurrentGroup("Colors"); | 210 | KPrefs::setCurrentGroup("Colors"); |
211 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 211 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
212 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 212 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
213 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 213 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
214 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); | 214 | addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); |
215 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 215 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
216 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 216 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
217 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 217 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
218 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 218 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
219 | addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); | 219 | addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); |
220 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 220 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
221 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 221 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
222 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 222 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
223 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 223 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
224 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 224 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
225 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); | 225 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); |
226 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 226 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
227 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 227 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
228 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 228 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
229 | addItemBool("UseAppColors",&mUseAppColors,false); | 229 | addItemBool("UseAppColors",&mUseAppColors,false); |
230 | 230 | ||
231 | 231 | ||
232 | 232 | ||
233 | KPrefs::setCurrentGroup("Views"); | 233 | KPrefs::setCurrentGroup("Views"); |
234 | addItemBool("Block Popup Menu",&mBlockPopupMenu,false); | 234 | addItemBool("Block Popup Menu",&mBlockPopupMenu,false); |
235 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); | 235 | addItemBool("Show Date Navigator",&mShowDateNavigator,true); |
236 | addItemInt("Hour Size",&mHourSize,8); | 236 | addItemInt("Hour Size",&mHourSize,8); |
237 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 237 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
238 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 238 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
239 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 239 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
240 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 240 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
241 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 241 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
242 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 242 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
243 | addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); | 243 | addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); |
244 | #ifdef DESKTOP_VERION | 244 | #ifdef DESKTOP_VERION |
245 | addItemBool("Enable ToolTips",&mEnableToolTips,true); | 245 | addItemBool("Enable ToolTips",&mEnableToolTips,true); |
246 | #else | 246 | #else |
247 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 247 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
248 | #endif | 248 | #endif |
249 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 249 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
250 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 250 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
251 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 251 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
252 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 252 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
253 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); | 253 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); |
254 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 254 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
255 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 255 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
256 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 256 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
257 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 257 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
258 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; | 258 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; |
259 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); | 259 | addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); |
260 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 260 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
261 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 261 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
262 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 262 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
263 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 263 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
264 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 264 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
265 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); | 265 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); |
266 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); | 266 | addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); |
267 | addItemBool("MonthViewWeekRowlayout",&mMonthViewWeekRowlayout,true); | ||
267 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 268 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
268 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 269 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
269 | #ifdef DESKTOP_VERSION | 270 | #ifdef DESKTOP_VERSION |
270 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 271 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
271 | #else | 272 | #else |
272 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 273 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
273 | #endif | 274 | #endif |
274 | addItemInt("Day Begins",&mDayBegins,7); | 275 | addItemInt("Day Begins",&mDayBegins,7); |
275 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 276 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
276 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 277 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
277 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 278 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
278 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 279 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
279 | 280 | ||
280 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 281 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
281 | addItemBool("Full View Month",&mFullViewMonth,true); | 282 | addItemBool("Full View Month",&mFullViewMonth,true); |
282 | addItemBool("Full View Todo",&mFullViewTodo,true); | 283 | addItemBool("Full View Todo",&mFullViewTodo,true); |
283 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 284 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
284 | 285 | ||
285 | addItemInt("Next X Days",&mNextXDays,3); | 286 | addItemInt("Next X Days",&mNextXDays,3); |
286 | 287 | ||
287 | KPrefs::setCurrentGroup("Printer"); | 288 | KPrefs::setCurrentGroup("Printer"); |
288 | 289 | ||
289 | KPrefs::setCurrentGroup("Layout"); | 290 | KPrefs::setCurrentGroup("Layout"); |
290 | 291 | ||
291 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 292 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
292 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 293 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
293 | 294 | ||
294 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 295 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
295 | 296 | ||
296 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 297 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
297 | 298 | ||
298 | KPrefs::setCurrentGroup("Group Scheduling"); | 299 | KPrefs::setCurrentGroup("Group Scheduling"); |
299 | 300 | ||
300 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 301 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
301 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 302 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
302 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 303 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
303 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 304 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
304 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 305 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
305 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 306 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
306 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 307 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
307 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 308 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
308 | 309 | ||
309 | KPrefs::setCurrentGroup( "Editors" ); | 310 | KPrefs::setCurrentGroup( "Editors" ); |
310 | 311 | ||
311 | addItemStringList( "EventTemplates", &mEventTemplates ); | 312 | addItemStringList( "EventTemplates", &mEventTemplates ); |
312 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 313 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
313 | 314 | ||
314 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 315 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
315 | 316 | ||
316 | KPrefs::setCurrentGroup( "ViewOptions" ); | 317 | KPrefs::setCurrentGroup( "ViewOptions" ); |
317 | addItemBool("EVshowDetails",&mEVshowDetails,true); | 318 | addItemBool("EVshowDetails",&mEVshowDetails,true); |
318 | addItemBool("EVshowCreated",&mEVshowCreated,true); | 319 | addItemBool("EVshowCreated",&mEVshowCreated,true); |
319 | addItemBool("EVshowChanged",&mEVshowChanged,true); | 320 | addItemBool("EVshowChanged",&mEVshowChanged,true); |
320 | addItemBool("WTshowDetails",&mWTshowDetails,false); | 321 | addItemBool("WTshowDetails",&mWTshowDetails,false); |
321 | addItemBool("WTshowCreated",&mWTshowCreated,false); | 322 | addItemBool("WTshowCreated",&mWTshowCreated,false); |
322 | addItemBool("WTshowChanged",&mWTshowChanged,false); | 323 | addItemBool("WTshowChanged",&mWTshowChanged,false); |
323 | mCalendars.setAutoDelete( true ); | 324 | mCalendars.setAutoDelete( true ); |
324 | } | 325 | } |
325 | 326 | ||
326 | 327 | ||
327 | KOPrefs::~KOPrefs() | 328 | KOPrefs::~KOPrefs() |
328 | { | 329 | { |
329 | if (mInstance == this) | 330 | if (mInstance == this) |
330 | mInstance = insd.setObject(0); | 331 | mInstance = insd.setObject(0); |
331 | mCalendars.setAutoDelete( true ); | 332 | mCalendars.setAutoDelete( true ); |
332 | mCalendars.clear(); | 333 | mCalendars.clear(); |
333 | //qDebug("KOPrefs::~KOPrefs() "); | 334 | //qDebug("KOPrefs::~KOPrefs() "); |
334 | } | 335 | } |
335 | 336 | ||
336 | 337 | ||
337 | KOPrefs *KOPrefs::instance() | 338 | KOPrefs *KOPrefs::instance() |
338 | { | 339 | { |
339 | if (!mInstance) { | 340 | if (!mInstance) { |
340 | mInstance = insd.setObject(new KOPrefs()); | 341 | mInstance = insd.setObject(new KOPrefs()); |
341 | mInstance->readConfig(); | 342 | mInstance->readConfig(); |
342 | } | 343 | } |
343 | 344 | ||
344 | return mInstance; | 345 | return mInstance; |
345 | } | 346 | } |
346 | 347 | ||
347 | void KOPrefs::usrSetDefaults() | 348 | void KOPrefs::usrSetDefaults() |
348 | { | 349 | { |
349 | 350 | ||
350 | } | 351 | } |
351 | 352 | ||
352 | void KOPrefs::fillMailDefaults() | 353 | void KOPrefs::fillMailDefaults() |
353 | { | 354 | { |
354 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 355 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
355 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 356 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
356 | } | 357 | } |
357 | 358 | ||
358 | void KOPrefs::setTimeZoneIdDefault() | 359 | void KOPrefs::setTimeZoneIdDefault() |
359 | { | 360 | { |
360 | ; | 361 | ; |
361 | } | 362 | } |
362 | 363 | ||
363 | void KOPrefs::setAllDefaults() | 364 | void KOPrefs::setAllDefaults() |
364 | { | 365 | { |
365 | setCategoryDefaults(); | 366 | setCategoryDefaults(); |
366 | mEventSummaryUser = getDefaultList() ; | 367 | mEventSummaryUser = getDefaultList() ; |
367 | mTodoSummaryUser = getDefaultList() ; | 368 | mTodoSummaryUser = getDefaultList() ; |
368 | mJournalSummaryUser = getDefaultList() ; | 369 | mJournalSummaryUser = getDefaultList() ; |
369 | mLocationDefaults = getLocationDefaultList(); | 370 | mLocationDefaults = getLocationDefaultList(); |
370 | } | 371 | } |
371 | 372 | ||
372 | void KOPrefs::setCategoryDefaults() | 373 | void KOPrefs::setCategoryDefaults() |
373 | { | 374 | { |
374 | mCustomCategories.clear(); | 375 | mCustomCategories.clear(); |
375 | mCustomCategories = getDefaultList(); | 376 | mCustomCategories = getDefaultList(); |
376 | 377 | ||
377 | QStringList::Iterator it; | 378 | QStringList::Iterator it; |
378 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 379 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
379 | setCategoryColor(*it,mDefaultCategoryColor); | 380 | setCategoryColor(*it,mDefaultCategoryColor); |
380 | } | 381 | } |
381 | } | 382 | } |
382 | QStringList KOPrefs::getLocationDefaultList() | 383 | QStringList KOPrefs::getLocationDefaultList() |
383 | { | 384 | { |
384 | QStringList retval ; | 385 | QStringList retval ; |
385 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 386 | retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
386 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") | 387 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") |
387 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 388 | << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
388 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 389 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
389 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 390 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
390 | 391 | ||
391 | retval.sort(); | 392 | retval.sort(); |
392 | return retval; | 393 | return retval; |
393 | } | 394 | } |
394 | QStringList KOPrefs::getDefaultList() | 395 | QStringList KOPrefs::getDefaultList() |
395 | { | 396 | { |
396 | QStringList retval ; | 397 | QStringList retval ; |
397 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") | 398 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") |
398 | << i18n("Break") | 399 | << i18n("Break") |
399 | << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") | 400 | << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") |
400 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") | 401 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") |
401 | << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") | 402 | << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") |
402 | << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") | 403 | << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") |
403 | << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") | 404 | << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") |
404 | << i18n("Vacation") ; | 405 | << i18n("Vacation") ; |
405 | retval.sort(); | 406 | retval.sort(); |
406 | //qDebug("cat %s ", retval.join("-").latin1()); | 407 | //qDebug("cat %s ", retval.join("-").latin1()); |
407 | return retval; | 408 | return retval; |
408 | } | 409 | } |
409 | // << 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") | 410 | // << 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") |
410 | void KOPrefs::usrReadConfig() | 411 | void KOPrefs::usrReadConfig() |
411 | { | 412 | { |
412 | config()->setGroup("General"); | 413 | config()->setGroup("General"); |
413 | 414 | ||
414 | //qDebug("KOPrefs::usrReadConfig() "); | 415 | //qDebug("KOPrefs::usrReadConfig() "); |
415 | mCustomCategories = config()->readListEntry("Custom Categories"); | 416 | mCustomCategories = config()->readListEntry("Custom Categories"); |
416 | mOldLoadedLanguage = mOldLanguage ; | 417 | mOldLoadedLanguage = mOldLanguage ; |
417 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 418 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
418 | if (mLocationDefaults.isEmpty()) { | 419 | if (mLocationDefaults.isEmpty()) { |
419 | mLocationDefaults = getLocationDefaultList(); | 420 | mLocationDefaults = getLocationDefaultList(); |
420 | } | 421 | } |
421 | 422 | ||
422 | if (mEventSummaryUser.isEmpty()) { | 423 | if (mEventSummaryUser.isEmpty()) { |
423 | mEventSummaryUser = getDefaultList() ; | 424 | mEventSummaryUser = getDefaultList() ; |
424 | } | 425 | } |
425 | if (mTodoSummaryUser.isEmpty()) { | 426 | if (mTodoSummaryUser.isEmpty()) { |
426 | mTodoSummaryUser = getDefaultList() ; | 427 | mTodoSummaryUser = getDefaultList() ; |
427 | } | 428 | } |
428 | 429 | ||
429 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 430 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
430 | 431 | ||
431 | config()->setGroup("Personal Settings"); | 432 | config()->setGroup("Personal Settings"); |
432 | mName = config()->readEntry("user_name",""); | 433 | mName = config()->readEntry("user_name",""); |
433 | mEmail = config()->readEntry("user_email",""); | 434 | mEmail = config()->readEntry("user_email",""); |
434 | fillMailDefaults(); | 435 | fillMailDefaults(); |
435 | 436 | ||
436 | config()->setGroup("Category Colors"); | 437 | config()->setGroup("Category Colors"); |
437 | QStringList::Iterator it; | 438 | QStringList::Iterator it; |
438 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 439 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
439 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 440 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
440 | 441 | ||
441 | } | 442 | } |
442 | KConfig fc (locateLocal("config","kopicalendarrc")); | 443 | KConfig fc (locateLocal("config","kopicalendarrc")); |
443 | fc.setGroup("CC"); | 444 | fc.setGroup("CC"); |
444 | int numCals = fc.readNumEntry("NumberCalendars",0 ); | 445 | int numCals = fc.readNumEntry("NumberCalendars",0 ); |
445 | mNextAvailableCalendar = 1; | 446 | mNextAvailableCalendar = 1; |
446 | if ( numCals == 0 ) { | 447 | if ( numCals == 0 ) { |
447 | KopiCalendarFile *kkf = getNewCalendar(); | 448 | KopiCalendarFile *kkf = getNewCalendar(); |
448 | kkf->isStandard = true; | 449 | kkf->isStandard = true; |
449 | kkf->mName = i18n("Standard"); | 450 | kkf->mName = i18n("Standard"); |
450 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | 451 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); |
451 | } | 452 | } |
452 | while ( mNextAvailableCalendar <= numCals ) { | 453 | while ( mNextAvailableCalendar <= numCals ) { |
453 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); | 454 | //qDebug("Read cal #%d ", mNextAvailableCalendar ); |
454 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); | 455 | QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); |
455 | KopiCalendarFile *kkf = getNewCalendar(); | 456 | KopiCalendarFile *kkf = getNewCalendar(); |
456 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); | 457 | kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); |
457 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); | 458 | kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); |
458 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); | 459 | kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); |
459 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); | 460 | kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); |
460 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); | 461 | kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); |
461 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); | 462 | kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); |
462 | kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); | 463 | kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); |
463 | kkf->mSavedFileName = fc.readEntry( prefix+"_SavedFileName", kkf->mFileName); | 464 | kkf->mSavedFileName = fc.readEntry( prefix+"_SavedFileName", kkf->mFileName); |
464 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); | 465 | kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); |
465 | if ( kkf->mCalNumber == 1 ) { | 466 | if ( kkf->mCalNumber == 1 ) { |
466 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); | 467 | kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); |
467 | } | 468 | } |
468 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); | 469 | //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); |
469 | if ( kkf->mName == i18n("Birthdays") ) { | 470 | if ( kkf->mName == i18n("Birthdays") ) { |
470 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); | 471 | kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); |
471 | } | 472 | } |
472 | if ( kkf->isRelative ) | 473 | if ( kkf->isRelative ) |
473 | kkf->mFileName = KGlobalSettings::calendarDir() + kkf->mSavedFileName; | 474 | kkf->mFileName = KGlobalSettings::calendarDir() + kkf->mSavedFileName; |
474 | } | 475 | } |
475 | 476 | ||
476 | KPimPrefs::usrReadConfig(); | 477 | KPimPrefs::usrReadConfig(); |
477 | } | 478 | } |
478 | 479 | ||
479 | KopiCalendarFile * KOPrefs::getCalendar( int num ) | 480 | KopiCalendarFile * KOPrefs::getCalendar( int num ) |
480 | { | 481 | { |
481 | return mDefCalColors[num-1]; | 482 | return mDefCalColors[num-1]; |
482 | } | 483 | } |
483 | 484 | ||
484 | KopiCalendarFile * KOPrefs::getNewCalendar() | 485 | KopiCalendarFile * KOPrefs::getNewCalendar() |
485 | { | 486 | { |
486 | KopiCalendarFile * kkf = new KopiCalendarFile(); | 487 | KopiCalendarFile * kkf = new KopiCalendarFile(); |
487 | kkf->mCalNumber = mNextAvailableCalendar; | 488 | kkf->mCalNumber = mNextAvailableCalendar; |
488 | mDefCalColors.resize( mNextAvailableCalendar ); | 489 | mDefCalColors.resize( mNextAvailableCalendar ); |
489 | mDefCalColors[mNextAvailableCalendar-1] = kkf; | 490 | mDefCalColors[mNextAvailableCalendar-1] = kkf; |
490 | ++mNextAvailableCalendar; | 491 | ++mNextAvailableCalendar; |
491 | kkf->mDefaultColor = mEventColor; | 492 | kkf->mDefaultColor = mEventColor; |
492 | kkf->mName = i18n("New Calendar"); | 493 | kkf->mName = i18n("New Calendar"); |
493 | mCalendars.append( kkf ); | 494 | mCalendars.append( kkf ); |
494 | return kkf; | 495 | return kkf; |
495 | } | 496 | } |
496 | void KOPrefs::deleteCalendar( int num ) | 497 | void KOPrefs::deleteCalendar( int num ) |
497 | { | 498 | { |
498 | KopiCalendarFile * kkf = mCalendars.first(); | 499 | KopiCalendarFile * kkf = mCalendars.first(); |
499 | while ( kkf ) { | 500 | while ( kkf ) { |
500 | if ( kkf->mCalNumber == num ) { | 501 | if ( kkf->mCalNumber == num ) { |
501 | qDebug("KOPrefs::deleteCalendar %d ", num ); | 502 | qDebug("KOPrefs::deleteCalendar %d ", num ); |
502 | mCalendars.remove( kkf ); | 503 | mCalendars.remove( kkf ); |
503 | delete kkf; | 504 | delete kkf; |
504 | return; | 505 | return; |
505 | } | 506 | } |
506 | kkf = mCalendars.next(); | 507 | kkf = mCalendars.next(); |
507 | } | 508 | } |
508 | } | 509 | } |
509 | int KOPrefs::getCalendarID( const QString & name ) | 510 | int KOPrefs::getCalendarID( const QString & name ) |
510 | { | 511 | { |
511 | KopiCalendarFile * kkf = mCalendars.first(); | 512 | KopiCalendarFile * kkf = mCalendars.first(); |
512 | while ( kkf ) { | 513 | while ( kkf ) { |
513 | if ( name == kkf->mName) | 514 | if ( name == kkf->mName) |
514 | return kkf->mCalNumber; | 515 | return kkf->mCalNumber; |
515 | kkf = mCalendars.next(); | 516 | kkf = mCalendars.next(); |
516 | } | 517 | } |
517 | return 1; | 518 | return 1; |
518 | } | 519 | } |
519 | QString KOPrefs::calName( int calNum) const | 520 | QString KOPrefs::calName( int calNum) const |
520 | { | 521 | { |
521 | return (mDefCalColors[calNum-1])->mName; | 522 | return (mDefCalColors[calNum-1])->mName; |
522 | } | 523 | } |
523 | QColor KOPrefs::defaultColor( int calNum ) const | 524 | QColor KOPrefs::defaultColor( int calNum ) const |
524 | { | 525 | { |
525 | if ( calNum == 1 ) return mEventColor; | 526 | if ( calNum == 1 ) return mEventColor; |
526 | return (mDefCalColors[calNum-1])->mDefaultColor; | 527 | return (mDefCalColors[calNum-1])->mDefaultColor; |
527 | } | 528 | } |
528 | void KOPrefs::usrWriteConfig() | 529 | void KOPrefs::usrWriteConfig() |
529 | { | 530 | { |
530 | config()->setGroup("General"); | 531 | config()->setGroup("General"); |
531 | config()->writeEntry("Custom Categories",mCustomCategories); | 532 | config()->writeEntry("Custom Categories",mCustomCategories); |
532 | 533 | ||
533 | config()->setGroup("Personal Settings"); | 534 | config()->setGroup("Personal Settings"); |
534 | config()->writeEntry("user_name",mName); | 535 | config()->writeEntry("user_name",mName); |
535 | config()->writeEntry("user_email",mEmail); | 536 | config()->writeEntry("user_email",mEmail); |
536 | 537 | ||
537 | config()->setGroup("Category Colors"); | 538 | config()->setGroup("Category Colors"); |
538 | QDictIterator<QColor> it(mCategoryColors); | 539 | QDictIterator<QColor> it(mCategoryColors); |
539 | while (it.current()) { | 540 | while (it.current()) { |
540 | config()->writeEntry(it.currentKey(),*(it.current())); | 541 | config()->writeEntry(it.currentKey(),*(it.current())); |
541 | ++it; | 542 | ++it; |
542 | } | 543 | } |
543 | KConfig fc (locateLocal("config","kopicalendarrc")); | 544 | KConfig fc (locateLocal("config","kopicalendarrc")); |
544 | fc.setGroup("CC"); | 545 | fc.setGroup("CC"); |
545 | fc.deleteGroup( "CC"); | 546 | fc.deleteGroup( "CC"); |
546 | fc.setGroup("CC"); | 547 | fc.setGroup("CC"); |
547 | fc.writeEntry("NumberCalendars",mCalendars.count()); | 548 | fc.writeEntry("NumberCalendars",mCalendars.count()); |
548 | int numCal = 1; | 549 | int numCal = 1; |
549 | int writeCal = 0; | 550 | int writeCal = 0; |
550 | while ( numCal < mNextAvailableCalendar ) { | 551 | while ( numCal < mNextAvailableCalendar ) { |
551 | KopiCalendarFile * kkf = mCalendars.first(); | 552 | KopiCalendarFile * kkf = mCalendars.first(); |
552 | while ( kkf ) { | 553 | while ( kkf ) { |
553 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); | 554 | //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); |
554 | if ( kkf->mCalNumber == numCal ) { | 555 | if ( kkf->mCalNumber == numCal ) { |
555 | ++writeCal; | 556 | ++writeCal; |
556 | //qDebug("Write calendar %d %d ", numCal , writeCal); | 557 | //qDebug("Write calendar %d %d ", numCal , writeCal); |
557 | QString prefix = "Cal_" + QString::number( writeCal ); | 558 | QString prefix = "Cal_" + QString::number( writeCal ); |
558 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); | 559 | fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); |
559 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); | 560 | fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); |
560 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); | 561 | fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); |
561 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); | 562 | fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); |
562 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); | 563 | fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); |
563 | fc.writeEntry( prefix+"_Name", kkf->mName); | 564 | fc.writeEntry( prefix+"_Name", kkf->mName); |
564 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); | 565 | fc.writeEntry( prefix+"_FileName", kkf->mFileName); |
565 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); | 566 | fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); |
566 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); | 567 | fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); |
567 | } | 568 | } |
568 | kkf = mCalendars.next(); | 569 | kkf = mCalendars.next(); |
569 | } | 570 | } |
570 | ++numCal; | 571 | ++numCal; |
571 | } | 572 | } |
572 | fc.sync(); | 573 | fc.sync(); |
573 | KPimPrefs::usrWriteConfig(); | 574 | KPimPrefs::usrWriteConfig(); |
574 | } | 575 | } |
575 | 576 | ||
576 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 577 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
577 | { | 578 | { |
578 | mCategoryColors.replace(cat,new QColor(color)); | 579 | mCategoryColors.replace(cat,new QColor(color)); |
579 | } | 580 | } |
580 | 581 | ||
581 | QColor *KOPrefs::categoryColor(QString cat) | 582 | QColor *KOPrefs::categoryColor(QString cat) |
582 | { | 583 | { |
583 | QColor *color = 0; | 584 | QColor *color = 0; |
584 | 585 | ||
585 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 586 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
586 | 587 | ||
587 | if (color) return color; | 588 | if (color) return color; |
588 | else return &mDefaultCategoryColor; | 589 | else return &mDefaultCategoryColor; |
589 | } | 590 | } |
590 | 591 | ||
591 | void KOPrefs::setFullName(const QString &name) | 592 | void KOPrefs::setFullName(const QString &name) |
592 | { | 593 | { |
593 | mName = name; | 594 | mName = name; |
594 | } | 595 | } |
595 | 596 | ||
596 | void KOPrefs::setEmail(const QString &email) | 597 | void KOPrefs::setEmail(const QString &email) |
597 | { | 598 | { |
598 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 599 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
599 | mEmail = email; | 600 | mEmail = email; |
600 | } | 601 | } |
601 | 602 | ||
602 | QString KOPrefs::fullName() | 603 | QString KOPrefs::fullName() |
603 | { | 604 | { |
604 | if (mEmailControlCenter) { | 605 | if (mEmailControlCenter) { |
605 | KEMailSettings settings; | 606 | KEMailSettings settings; |
606 | return settings.getSetting(KEMailSettings::RealName); | 607 | return settings.getSetting(KEMailSettings::RealName); |
607 | } else { | 608 | } else { |
608 | return mName; | 609 | return mName; |
609 | } | 610 | } |
610 | } | 611 | } |
611 | 612 | ||
612 | QString KOPrefs::email() | 613 | QString KOPrefs::email() |
613 | { | 614 | { |
614 | if (mEmailControlCenter) { | 615 | if (mEmailControlCenter) { |
615 | KEMailSettings settings; | 616 | KEMailSettings settings; |
616 | return settings.getSetting(KEMailSettings::EmailAddress); | 617 | return settings.getSetting(KEMailSettings::EmailAddress); |
617 | } else { | 618 | } else { |
618 | return mEmail; | 619 | return mEmail; |
619 | } | 620 | } |
620 | } | 621 | } |
621 | KConfig* KOPrefs::getConfig() | 622 | KConfig* KOPrefs::getConfig() |
622 | { | 623 | { |
623 | return config(); | 624 | return config(); |
624 | } | 625 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 392360d..2ff03fa 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -1,363 +1,364 @@ | |||
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 | QColor mAppColor1; | 187 | QColor mAppColor1; |
187 | QColor mAppColor2; | 188 | QColor mAppColor2; |
188 | bool mUseAppColors; | 189 | bool mUseAppColors; |
189 | 190 | ||
190 | int mDayBegins; | 191 | int mDayBegins; |
191 | int mHourSize; | 192 | int mHourSize; |
192 | int mAllDaySize; | 193 | int mAllDaySize; |
193 | bool mShowFullMenu; | 194 | bool mShowFullMenu; |
194 | bool mDailyRecur; | 195 | bool mDailyRecur; |
195 | bool mWeeklyRecur; | 196 | bool mWeeklyRecur; |
196 | bool mMonthDailyRecur; | 197 | bool mMonthDailyRecur; |
197 | bool mMonthWeeklyRecur; | 198 | bool mMonthWeeklyRecur; |
198 | bool mMonthShowIcons; | 199 | bool mMonthShowIcons; |
199 | bool mMonthShowTimes; | 200 | bool mMonthShowTimes; |
200 | bool mMonthShowShort; | 201 | bool mMonthShowShort; |
201 | bool mEnableToolTips; | 202 | bool mEnableToolTips; |
202 | bool mEnableMonthScroll; | 203 | bool mEnableMonthScroll; |
203 | bool mFullViewMonth; | 204 | bool mFullViewMonth; |
204 | bool mMonthViewUsesCategoryColor; | 205 | bool mMonthViewUsesCategoryColor; |
205 | bool mFullViewTodo; | 206 | bool mFullViewTodo; |
206 | bool mShowCompletedTodo; | 207 | bool mShowCompletedTodo; |
207 | bool mMarcusBainsEnabled; | 208 | bool mMarcusBainsEnabled; |
208 | int mNextXDays; | 209 | int mNextXDays; |
209 | int mWhatsNextDays; | 210 | int mWhatsNextDays; |
210 | int mWhatsNextPrios; | 211 | int mWhatsNextPrios; |
211 | bool mEnableQuickTodo; | 212 | bool mEnableQuickTodo; |
212 | 213 | ||
213 | bool mCompactDialogs; | 214 | bool mCompactDialogs; |
214 | bool mVerticalScreen; | 215 | bool mVerticalScreen; |
215 | 216 | ||
216 | bool mShowIconNewTodo; | 217 | bool mShowIconNewTodo; |
217 | bool mShowIconNewEvent; | 218 | bool mShowIconNewEvent; |
218 | bool mShowIconSearch; | 219 | bool mShowIconSearch; |
219 | bool mShowIconList; | 220 | bool mShowIconList; |
220 | bool mShowIconDay1; | 221 | bool mShowIconDay1; |
221 | bool mShowIconDay5; | 222 | bool mShowIconDay5; |
222 | bool mShowIconDay6; | 223 | bool mShowIconDay6; |
223 | bool mShowIconDay7; | 224 | bool mShowIconDay7; |
224 | bool mShowIconMonth; | 225 | bool mShowIconMonth; |
225 | bool mShowIconTodoview; | 226 | bool mShowIconTodoview; |
226 | bool mShowIconBackFast; | 227 | bool mShowIconBackFast; |
227 | bool mShowIconBack; | 228 | bool mShowIconBack; |
228 | bool mShowIconToday; | 229 | bool mShowIconToday; |
229 | bool mShowIconForward; | 230 | bool mShowIconForward; |
230 | bool mShowIconForwardFast; | 231 | bool mShowIconForwardFast; |
231 | bool mShowIconWhatsThis; | 232 | bool mShowIconWhatsThis; |
232 | bool mShowIconWeekNum; | 233 | bool mShowIconWeekNum; |
233 | bool mShowIconNextDays; | 234 | bool mShowIconNextDays; |
234 | bool mShowIconNext; | 235 | bool mShowIconNext; |
235 | bool mShowIconJournal; | 236 | bool mShowIconJournal; |
236 | bool mShowIconFilter; | 237 | bool mShowIconFilter; |
237 | bool mShowIconOnetoolbar; | 238 | bool mShowIconOnetoolbar; |
238 | bool mShowIconNavigator; | 239 | bool mShowIconNavigator; |
239 | bool mShowIconAllday; | 240 | bool mShowIconAllday; |
240 | bool mShowIconFilterview; | 241 | bool mShowIconFilterview; |
241 | bool mShowIconToggleFull; | 242 | bool mShowIconToggleFull; |
242 | 243 | ||
243 | bool mShowIconStretch; | 244 | bool mShowIconStretch; |
244 | 245 | ||
245 | bool mToolBarHor; | 246 | bool mToolBarHor; |
246 | bool mToolBarUp; | 247 | bool mToolBarUp; |
247 | bool mToolBarHorV; | 248 | bool mToolBarHorV; |
248 | bool mToolBarUpV; | 249 | bool mToolBarUpV; |
249 | bool mToolBarHorN; | 250 | bool mToolBarHorN; |
250 | bool mToolBarUpN; | 251 | bool mToolBarUpN; |
251 | bool mToolBarHorF; | 252 | bool mToolBarHorF; |
252 | bool mToolBarUpF; | 253 | bool mToolBarUpF; |
253 | bool mToolBarMiniIcons; | 254 | bool mToolBarMiniIcons; |
254 | 255 | ||
255 | bool mAskForQuit; | 256 | bool mAskForQuit; |
256 | bool mUsePassWd; | 257 | bool mUsePassWd; |
257 | bool mShowSyncEvents; | 258 | bool mShowSyncEvents; |
258 | bool mShowTodoInAgenda; | 259 | bool mShowTodoInAgenda; |
259 | bool mShowCompletedTodoInAgenda; | 260 | bool mShowCompletedTodoInAgenda; |
260 | bool mShowTimeInAgenda; | 261 | bool mShowTimeInAgenda; |
261 | bool mHideNonStartedTodos; | 262 | bool mHideNonStartedTodos; |
262 | 263 | ||
263 | bool mBlockPopupMenu; | 264 | bool mBlockPopupMenu; |
264 | 265 | ||
265 | int mLastSyncTime; | 266 | int mLastSyncTime; |
266 | void setCategoryColor(QString cat,const QColor & color); | 267 | void setCategoryColor(QString cat,const QColor & color); |
267 | QColor *categoryColor(QString cat); | 268 | QColor *categoryColor(QString cat); |
268 | 269 | ||
269 | QString mArchiveFile; | 270 | QString mArchiveFile; |
270 | QString mHtmlExportFile; | 271 | QString mHtmlExportFile; |
271 | bool mHtmlWithSave; | 272 | bool mHtmlWithSave; |
272 | 273 | ||
273 | QStringList mSelectedPlugins; | 274 | QStringList mSelectedPlugins; |
274 | 275 | ||
275 | QString mLastImportFile; | 276 | QString mLastImportFile; |
276 | QString mLastVcalFile; | 277 | QString mLastVcalFile; |
277 | QString mLastSaveFile; | 278 | QString mLastSaveFile; |
278 | QString mLastLoadFile; | 279 | QString mLastLoadFile; |
279 | 280 | ||
280 | 281 | ||
281 | QString mDefaultAlarmFile; | 282 | QString mDefaultAlarmFile; |
282 | int mIMIPScheduler; | 283 | int mIMIPScheduler; |
283 | int mIMIPSend; | 284 | int mIMIPSend; |
284 | QStringList mAdditionalMails; | 285 | QStringList mAdditionalMails; |
285 | int mIMIPAutoRefresh; | 286 | int mIMIPAutoRefresh; |
286 | int mIMIPAutoInsertReply; | 287 | int mIMIPAutoInsertReply; |
287 | int mIMIPAutoInsertRequest; | 288 | int mIMIPAutoInsertRequest; |
288 | int mIMIPAutoFreeBusy; | 289 | int mIMIPAutoFreeBusy; |
289 | int mIMIPAutoFreeBusyReply; | 290 | int mIMIPAutoFreeBusyReply; |
290 | 291 | ||
291 | QStringList mTodoTemplates; | 292 | QStringList mTodoTemplates; |
292 | QStringList mEventTemplates; | 293 | QStringList mEventTemplates; |
293 | 294 | ||
294 | int mDestination; | 295 | int mDestination; |
295 | 296 | ||
296 | 297 | ||
297 | bool mEditOnDoubleClick; | 298 | bool mEditOnDoubleClick; |
298 | bool mViewChangeHoldFullscreen; | 299 | bool mViewChangeHoldFullscreen; |
299 | bool mViewChangeHoldNonFullscreen; | 300 | bool mViewChangeHoldNonFullscreen; |
300 | bool mCenterOnCurrentTime; | 301 | bool mCenterOnCurrentTime; |
301 | bool mSetTimeToDayStartAt; | 302 | bool mSetTimeToDayStartAt; |
302 | bool mHighlightCurrentDay; | 303 | bool mHighlightCurrentDay; |
303 | bool mUseHighlightLightColor; | 304 | bool mUseHighlightLightColor; |
304 | bool mListViewMonthTimespan; | 305 | bool mListViewMonthTimespan; |
305 | bool mWNViewShowsParents; | 306 | bool mWNViewShowsParents; |
306 | bool mWNViewShowsPast; | 307 | bool mWNViewShowsPast; |
307 | bool mWNViewShowLocation; | 308 | bool mWNViewShowLocation; |
308 | bool mTodoViewShowsPercentage; | 309 | bool mTodoViewShowsPercentage; |
309 | bool mTodoViewUsesCatColors; | 310 | bool mTodoViewUsesCatColors; |
310 | bool mMonthViewUsesBigFont; | 311 | bool mMonthViewUsesBigFont; |
311 | bool mTodoViewUsesSmallFont; | 312 | bool mTodoViewUsesSmallFont; |
312 | bool mTodoViewUsesForegroundColor; | 313 | bool mTodoViewUsesForegroundColor; |
313 | bool mMonthViewUsesForegroundColor; | 314 | bool mMonthViewUsesForegroundColor; |
314 | 315 | ||
315 | bool mHightlightDateTimeEdit; | 316 | bool mHightlightDateTimeEdit; |
316 | bool mShortDateInViewer; | 317 | bool mShortDateInViewer; |
317 | 318 | ||
318 | bool mShowDateNavigator; | 319 | bool mShowDateNavigator; |
319 | 320 | ||
320 | QStringList mLocationDefaults; | 321 | QStringList mLocationDefaults; |
321 | QStringList mEventSummaryUser; | 322 | QStringList mEventSummaryUser; |
322 | QStringList mTodoSummaryUser; | 323 | QStringList mTodoSummaryUser; |
323 | QStringList mJournalSummaryUser; | 324 | QStringList mJournalSummaryUser; |
324 | 325 | ||
325 | bool mUseInternalAlarmNotification; | 326 | bool mUseInternalAlarmNotification; |
326 | int mAlarmPlayBeeps; | 327 | int mAlarmPlayBeeps; |
327 | int mAlarmSuspendTime; | 328 | int mAlarmSuspendTime; |
328 | int mAlarmSuspendCount; | 329 | int mAlarmSuspendCount; |
329 | int mAlarmBeepInterval; | 330 | int mAlarmBeepInterval; |
330 | int mOldLanguage; | 331 | int mOldLanguage; |
331 | int mOldLoadedLanguage; | 332 | int mOldLoadedLanguage; |
332 | 333 | ||
333 | 334 | ||
334 | QString mActiveSyncPort; | 335 | QString mActiveSyncPort; |
335 | QString mActiveSyncIP; | 336 | QString mActiveSyncIP; |
336 | 337 | ||
337 | // settings for eventviewer | 338 | // settings for eventviewer |
338 | bool mEVshowDetails; | 339 | bool mEVshowDetails; |
339 | bool mEVshowCreated; | 340 | bool mEVshowCreated; |
340 | bool mEVshowChanged; | 341 | bool mEVshowChanged; |
341 | bool mWTshowDetails; | 342 | bool mWTshowDetails; |
342 | bool mWTshowCreated; | 343 | bool mWTshowCreated; |
343 | bool mWTshowChanged; | 344 | bool mWTshowChanged; |
344 | 345 | ||
345 | int mCurrentDisplayedView; | 346 | int mCurrentDisplayedView; |
346 | QPtrList<KopiCalendarFile> mCalendars; | 347 | QPtrList<KopiCalendarFile> mCalendars; |
347 | int mNextAvailableCalendar; | 348 | int mNextAvailableCalendar; |
348 | bool mGlobalUpdateDisabled; | 349 | bool mGlobalUpdateDisabled; |
349 | 350 | ||
350 | private: | 351 | private: |
351 | QDict<QColor> mCategoryColors; | 352 | QDict<QColor> mCategoryColors; |
352 | QArray<KopiCalendarFile*> mDefCalColors; | 353 | QArray<KopiCalendarFile*> mDefCalColors; |
353 | QColor mDefaultCategoryColor; | 354 | QColor mDefaultCategoryColor; |
354 | 355 | ||
355 | QFont mDefaultTimeBarFont; | 356 | QFont mDefaultTimeBarFont; |
356 | QFont mDefaultViewFont; | 357 | QFont mDefaultViewFont; |
357 | QFont mDefaultMonthViewFont; | 358 | QFont mDefaultMonthViewFont; |
358 | 359 | ||
359 | QString mName; | 360 | QString mName; |
360 | QString mEmail; | 361 | QString mEmail; |
361 | }; | 362 | }; |
362 | 363 | ||
363 | #endif | 364 | #endif |
diff --git a/korganizer/koprefsdialog.cpp b/korganizer/koprefsdialog.cpp index ebcff33..05bd73f 100644 --- a/korganizer/koprefsdialog.cpp +++ b/korganizer/koprefsdialog.cpp | |||
@@ -1,1544 +1,1548 @@ | |||
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 | #ifdef DESKTOP_VERSION | 581 | #ifdef DESKTOP_VERSION |
582 | KPrefsDialogWidBool *enableToolTips = | 582 | KPrefsDialogWidBool *enableToolTips = |
583 | addWidBool(i18n("Enable tooltips displaying summary of ev."), | 583 | addWidBool(i18n("Enable tooltips displaying summary of ev."), |
584 | &(KOPrefs::instance()->mEnableToolTips),topFrame); | 584 | &(KOPrefs::instance()->mEnableToolTips),topFrame); |
585 | topLayout->addWidget(enableToolTips->checkBox(),ii++,0); | 585 | topLayout->addWidget(enableToolTips->checkBox(),ii++,0); |
586 | #endif | 586 | #endif |
587 | // ********************************************************* | 587 | // ********************************************************* |
588 | 588 | ||
589 | topFrame = addPage(i18n("Agenda View"),0,0); | 589 | topFrame = addPage(i18n("Agenda View"),0,0); |
590 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 590 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
591 | 591 | ||
592 | topLayout = new QGridLayout(topFrame,5,1); | 592 | topLayout = new QGridLayout(topFrame,5,1); |
593 | topLayout->setSpacing(mSpacingHint); | 593 | topLayout->setSpacing(mSpacingHint); |
594 | topLayout->setMargin(mMarginHint); | 594 | topLayout->setMargin(mMarginHint); |
595 | ii = 0; | 595 | ii = 0; |
596 | 596 | ||
597 | 597 | ||
598 | dummy = | 598 | dummy = |
599 | addWidBool(i18n("Show time in agenda items"), | 599 | addWidBool(i18n("Show time in agenda items"), |
600 | &(KOPrefs::instance()->mShowTimeInAgenda),topFrame); | 600 | &(KOPrefs::instance()->mShowTimeInAgenda),topFrame); |
601 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 601 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
602 | 602 | ||
603 | dummy = | 603 | dummy = |
604 | addWidBool(i18n("Highlight current day in agenda"), | 604 | addWidBool(i18n("Highlight current day in agenda"), |
605 | &(KOPrefs::instance()->mHighlightCurrentDay),topFrame); | 605 | &(KOPrefs::instance()->mHighlightCurrentDay),topFrame); |
606 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 606 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
607 | 607 | ||
608 | dummy = | 608 | dummy = |
609 | addWidBool(i18n("Use light color for highlight current day"), | 609 | addWidBool(i18n("Use light color for highlight current day"), |
610 | &(KOPrefs::instance()->mUseHighlightLightColor),topFrame); | 610 | &(KOPrefs::instance()->mUseHighlightLightColor),topFrame); |
611 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 611 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
612 | 612 | ||
613 | 613 | ||
614 | KPrefsDialogWidBool *marcusBainsEnabled = | 614 | KPrefsDialogWidBool *marcusBainsEnabled = |
615 | addWidBool(i18n("Show current time"), | 615 | addWidBool(i18n("Show current time"), |
616 | &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame); | 616 | &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame); |
617 | topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0); | 617 | topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0); |
618 | 618 | ||
619 | 619 | ||
620 | dummy = | 620 | dummy = |
621 | addWidBool(i18n("Set agenda to DayBeginsAt on change"), | 621 | addWidBool(i18n("Set agenda to DayBeginsAt on change"), |
622 | &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame); | 622 | &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame); |
623 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 623 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
624 | 624 | ||
625 | dummy = | 625 | dummy = |
626 | addWidBool(i18n("Set agenda to current time on change"), | 626 | addWidBool(i18n("Set agenda to current time on change"), |
627 | &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame); | 627 | &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame); |
628 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 628 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
629 | 629 | ||
630 | 630 | ||
631 | dummy = | 631 | dummy = |
632 | addWidBool(i18n("Allday Agenda view shows todos"), | 632 | addWidBool(i18n("Allday Agenda view shows todos"), |
633 | &(KOPrefs::instance()->mShowTodoInAgenda),topFrame); | 633 | &(KOPrefs::instance()->mShowTodoInAgenda),topFrame); |
634 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 634 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
635 | 635 | ||
636 | 636 | ||
637 | 637 | ||
638 | dummy = | 638 | dummy = |
639 | addWidBool(i18n("Agenda view shows completed todos"), | 639 | addWidBool(i18n("Agenda view shows completed todos"), |
640 | &(KOPrefs::instance()->mShowCompletedTodoInAgenda),topFrame); | 640 | &(KOPrefs::instance()->mShowCompletedTodoInAgenda),topFrame); |
641 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 641 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
642 | 642 | ||
643 | 643 | ||
644 | 644 | ||
645 | 645 | ||
646 | 646 | ||
647 | topFrame = addPage(i18n("Month View"),0,0); | 647 | topFrame = addPage(i18n("Month View"),0,0); |
648 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 648 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
649 | 649 | ||
650 | topLayout = new QGridLayout(topFrame,5,1); | 650 | topLayout = new QGridLayout(topFrame,5,1); |
651 | topLayout->setSpacing(mSpacingHint); | 651 | topLayout->setSpacing(mSpacingHint); |
652 | topLayout->setMargin(mMarginHint); | 652 | topLayout->setMargin(mMarginHint); |
653 | ii = 0; | 653 | ii = 0; |
654 | QLabel *lab; | 654 | QLabel *lab; |
655 | QHBox *habo = new QHBox( topFrame ); | 655 | QHBox *habo = new QHBox( topFrame ); |
656 | if ( QApplication::desktop()->width() <= 480 ) { | 656 | if ( QApplication::desktop()->width() <= 480 ) { |
657 | lab = new QLabel ( i18n("Show events that recur "), topFrame ); | 657 | lab = new QLabel ( i18n("Show events that recur "), topFrame ); |
658 | topLayout->addMultiCellWidget(lab,ii, ii,0,1); | 658 | topLayout->addMultiCellWidget(lab,ii, ii,0,1); |
659 | ii++; | 659 | ii++; |
660 | } else { | 660 | } else { |
661 | new QLabel ( i18n("Show events that recur "), habo ); | 661 | new QLabel ( i18n("Show events that recur "), habo ); |
662 | } | 662 | } |
663 | dailyRecur = | 663 | dailyRecur = |
664 | addWidBool(i18n("daily"), | 664 | addWidBool(i18n("daily"), |
665 | &(KOPrefs::instance()->mMonthDailyRecur),habo); | 665 | &(KOPrefs::instance()->mMonthDailyRecur),habo); |
666 | // topLayout->addWidget(dailyRecur->checkBox(),ii++,0); | 666 | // topLayout->addWidget(dailyRecur->checkBox(),ii++,0); |
667 | 667 | ||
668 | weeklyRecur = | 668 | weeklyRecur = |
669 | addWidBool(i18n("weekly"), | 669 | addWidBool(i18n("weekly"), |
670 | &(KOPrefs::instance()->mMonthWeeklyRecur),habo); | 670 | &(KOPrefs::instance()->mMonthWeeklyRecur),habo); |
671 | topLayout->addMultiCellWidget(habo,ii, ii,0,1); | 671 | topLayout->addMultiCellWidget(habo,ii, ii,0,1); |
672 | ii++; | 672 | ii++; |
673 | 673 | ||
674 | 674 | ||
675 | habo = new QHBox( topFrame ); | 675 | habo = new QHBox( topFrame ); |
676 | if ( QApplication::desktop()->width() <= 480 ) { | 676 | if ( QApplication::desktop()->width() <= 480 ) { |
677 | lab = new QLabel (i18n("Show in every cell ") , topFrame ); | 677 | lab = new QLabel (i18n("Show in every cell ") , topFrame ); |
678 | topLayout->addMultiCellWidget(lab,ii, ii,0,1); | 678 | topLayout->addMultiCellWidget(lab,ii, ii,0,1); |
679 | ii++; | 679 | ii++; |
680 | 680 | ||
681 | } else { | 681 | } else { |
682 | new QLabel ( i18n("Show in every cell "), habo ); | 682 | new QLabel ( i18n("Show in every cell "), habo ); |
683 | } | 683 | } |
684 | weeklyRecur = | 684 | weeklyRecur = |
685 | addWidBool(i18n("short month"), | 685 | addWidBool(i18n("short month"), |
686 | &(KOPrefs::instance()->mMonthShowShort),habo); | 686 | &(KOPrefs::instance()->mMonthShowShort),habo); |
687 | weeklyRecur = | 687 | weeklyRecur = |
688 | addWidBool(i18n("icons"), | 688 | addWidBool(i18n("icons"), |
689 | &(KOPrefs::instance()->mMonthShowIcons),habo); | 689 | &(KOPrefs::instance()->mMonthShowIcons),habo); |
690 | weeklyRecur = | 690 | weeklyRecur = |
691 | addWidBool(i18n("times"), | 691 | addWidBool(i18n("times"), |
692 | &(KOPrefs::instance()->mMonthShowTimes),habo); | 692 | &(KOPrefs::instance()->mMonthShowTimes),habo); |
693 | topLayout->addMultiCellWidget(habo,ii, ii,0,1); | 693 | topLayout->addMultiCellWidget(habo,ii, ii,0,1); |
694 | ii++; | 694 | ii++; |
695 | #ifdef DESKTOP_VERSION | 695 | #ifdef DESKTOP_VERSION |
696 | KPrefsDialogWidBool *enableMonthScroll = | 696 | KPrefsDialogWidBool *enableMonthScroll = |
697 | addWidBool(i18n("Enable scrollbars in month view cells"), | 697 | addWidBool(i18n("Enable scrollbars in month view cells"), |
698 | &(KOPrefs::instance()->mEnableMonthScroll),topFrame); | 698 | &(KOPrefs::instance()->mEnableMonthScroll),topFrame); |
699 | topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0); | 699 | topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0); |
700 | #endif | 700 | #endif |
701 | dummy = | 701 | dummy = |
702 | addWidBool(i18n("Week view mode uses bigger font"), | 702 | addWidBool(i18n("Week view mode uses bigger font"), |
703 | &(KOPrefs::instance()->mMonthViewUsesBigFont),topFrame); | 703 | &(KOPrefs::instance()->mMonthViewUsesBigFont),topFrame); |
704 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 704 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
705 | dummy = | 705 | dummy = |
706 | addWidBool(i18n("Week view mode uses row layout"), | ||
707 | &(KOPrefs::instance()->mMonthViewWeekRowlayout),topFrame); | ||
708 | topLayout->addWidget(dummy->checkBox(),ii++,0); | ||
709 | dummy = | ||
706 | addWidBool(i18n("Show Sat/Sun together"), | 710 | addWidBool(i18n("Show Sat/Sun together"), |
707 | &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame); | 711 | &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame); |
708 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 712 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
709 | 713 | ||
710 | KPrefsDialogWidBool *coloredCategoriesInMonthView = | 714 | KPrefsDialogWidBool *coloredCategoriesInMonthView = |
711 | addWidBool(i18n("Month view uses category colors"), | 715 | addWidBool(i18n("Month view uses category colors"), |
712 | &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame); | 716 | &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame); |
713 | topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); | 717 | topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); |
714 | 718 | ||
715 | dummy = | 719 | dummy = |
716 | addWidBool(i18n("Category colors are applied to text"), | 720 | addWidBool(i18n("Category colors are applied to text"), |
717 | &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame); | 721 | &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame); |
718 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 722 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
719 | 723 | ||
720 | 724 | ||
721 | 725 | ||
722 | if ( QApplication::desktop()->height() <= 240 ) { | 726 | if ( QApplication::desktop()->height() <= 240 ) { |
723 | topFrame = addPage(i18n("Month View") +" 2",0,0); | 727 | topFrame = addPage(i18n("Month View") +" 2",0,0); |
724 | topLayout = new QGridLayout(topFrame,4,1); | 728 | topLayout = new QGridLayout(topFrame,4,1); |
725 | topLayout->setSpacing(2); | 729 | topLayout->setSpacing(2); |
726 | topLayout->setMargin(1); | 730 | topLayout->setMargin(1); |
727 | ii = 0; | 731 | ii = 0; |
728 | } | 732 | } |
729 | 733 | ||
730 | 734 | ||
731 | coloredCategoriesInMonthView = | 735 | coloredCategoriesInMonthView = |
732 | addWidBool(i18n("Month view uses day colors"), | 736 | addWidBool(i18n("Month view uses day colors"), |
733 | &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame); | 737 | &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame); |
734 | topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); | 738 | topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); |
735 | 739 | ||
736 | KPrefsDialogWidColor *holidayColor = | 740 | KPrefsDialogWidColor *holidayColor = |
737 | addWidColor(i18n("Day color odd months"), | 741 | addWidColor(i18n("Day color odd months"), |
738 | &(KOPrefs::instance()->mMonthViewOddColor),topFrame); | 742 | &(KOPrefs::instance()->mMonthViewOddColor),topFrame); |
739 | topLayout->addWidget(holidayColor->label(),ii,0); | 743 | topLayout->addWidget(holidayColor->label(),ii,0); |
740 | topLayout->addWidget(holidayColor->button(),ii++,1); | 744 | topLayout->addWidget(holidayColor->button(),ii++,1); |
741 | 745 | ||
742 | holidayColor = | 746 | holidayColor = |
743 | addWidColor(i18n("Day color even months"), | 747 | addWidColor(i18n("Day color even months"), |
744 | &(KOPrefs::instance()->mMonthViewEvenColor),topFrame); | 748 | &(KOPrefs::instance()->mMonthViewEvenColor),topFrame); |
745 | topLayout->addWidget(holidayColor->label(),ii,0); | 749 | topLayout->addWidget(holidayColor->label(),ii,0); |
746 | topLayout->addWidget(holidayColor->button(),ii++,1); | 750 | topLayout->addWidget(holidayColor->button(),ii++,1); |
747 | 751 | ||
748 | 752 | ||
749 | holidayColor = | 753 | holidayColor = |
750 | addWidColor(i18n("Color for Sundays + category \"Holiday\""), | 754 | addWidColor(i18n("Color for Sundays + category \"Holiday\""), |
751 | &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame); | 755 | &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame); |
752 | topLayout->addWidget(holidayColor->label(),ii,0); | 756 | topLayout->addWidget(holidayColor->label(),ii,0); |
753 | topLayout->addWidget(holidayColor->button(),ii++,1); | 757 | topLayout->addWidget(holidayColor->button(),ii++,1); |
754 | // *********************** What'sNext View | 758 | // *********************** What'sNext View |
755 | topFrame = addPage(i18n("What's Next View"),0,0); | 759 | topFrame = addPage(i18n("What's Next View"),0,0); |
756 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 760 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
757 | 761 | ||
758 | topLayout = new QGridLayout(topFrame,4,1); | 762 | topLayout = new QGridLayout(topFrame,4,1); |
759 | topLayout->setSpacing(mSpacingHint); | 763 | topLayout->setSpacing(mSpacingHint); |
760 | topLayout->setMargin(mMarginHint); | 764 | topLayout->setMargin(mMarginHint); |
761 | ii = 0; | 765 | ii = 0; |
762 | 766 | ||
763 | 767 | ||
764 | QHBox* hdummy = new QHBox(topFrame); | 768 | QHBox* hdummy = new QHBox(topFrame); |
765 | new QLabel(i18n("Days in What's Next:"),hdummy); | 769 | new QLabel(i18n("Days in What's Next:"),hdummy); |
766 | mWhatsNextSpin = new QSpinBox(1,14,1,hdummy); | 770 | mWhatsNextSpin = new QSpinBox(1,14,1,hdummy); |
767 | 771 | ||
768 | topLayout->addWidget(hdummy,ii++,0); | 772 | topLayout->addWidget(hdummy,ii++,0); |
769 | 773 | ||
770 | QHBox *prioBox = new QHBox(topFrame); | 774 | QHBox *prioBox = new QHBox(topFrame); |
771 | // intervalBox->setSpacing(mSpacingHint); | 775 | // intervalBox->setSpacing(mSpacingHint); |
772 | topLayout->addWidget(prioBox,ii++,0); | 776 | topLayout->addWidget(prioBox,ii++,0); |
773 | 777 | ||
774 | QLabel *prioLabel = new QLabel(i18n("Number of max.displayed todo prios:"), prioBox); | 778 | QLabel *prioLabel = new QLabel(i18n("Number of max.displayed todo prios:"), prioBox); |
775 | mPrioSpin = new QSpinBox(0,5,1,prioBox); | 779 | mPrioSpin = new QSpinBox(0,5,1,prioBox); |
776 | if ( QApplication::desktop()->width() < 300 ) | 780 | if ( QApplication::desktop()->width() < 300 ) |
777 | mPrioSpin->setFixedWidth( 40 ); | 781 | mPrioSpin->setFixedWidth( 40 ); |
778 | 782 | ||
779 | KPrefsDialogWidBool *passwdk = | 783 | KPrefsDialogWidBool *passwdk = |
780 | 784 | ||
781 | addWidBool(i18n("Show events that are done"), | 785 | addWidBool(i18n("Show events that are done"), |
782 | &(KOPrefs::instance()->mWNViewShowsPast),topFrame); | 786 | &(KOPrefs::instance()->mWNViewShowsPast),topFrame); |
783 | topLayout->addWidget(passwdk->checkBox(), ii++,0); | 787 | topLayout->addWidget(passwdk->checkBox(), ii++,0); |
784 | passwdk = | 788 | passwdk = |
785 | addWidBool(i18n("Show parent To-Do's"), | 789 | addWidBool(i18n("Show parent To-Do's"), |
786 | &(KOPrefs::instance()->mWNViewShowsParents),topFrame); | 790 | &(KOPrefs::instance()->mWNViewShowsParents),topFrame); |
787 | topLayout->addWidget(passwdk->checkBox(), ii++,0); | 791 | topLayout->addWidget(passwdk->checkBox(), ii++,0); |
788 | 792 | ||
789 | passwdk = | 793 | passwdk = |
790 | addWidBool(i18n("Show location"), | 794 | addWidBool(i18n("Show location"), |
791 | &(KOPrefs::instance()->mWNViewShowLocation),topFrame); | 795 | &(KOPrefs::instance()->mWNViewShowLocation),topFrame); |
792 | topLayout->addWidget(passwdk->checkBox(), ii++,0); | 796 | topLayout->addWidget(passwdk->checkBox(), ii++,0); |
793 | 797 | ||
794 | 798 | ||
795 | passwdk = | 799 | passwdk = |
796 | addWidBool(i18n("Use short date in WN+Event view"), | 800 | addWidBool(i18n("Use short date in WN+Event view"), |
797 | &(KOPrefs::instance()->mShortDateInViewer),topFrame); | 801 | &(KOPrefs::instance()->mShortDateInViewer),topFrame); |
798 | topLayout->addWidget(passwdk->checkBox(), ii++,0); | 802 | topLayout->addWidget(passwdk->checkBox(), ii++,0); |
799 | 803 | ||
800 | 804 | ||
801 | 805 | ||
802 | 806 | ||
803 | // *********************** Todo View | 807 | // *********************** Todo View |
804 | 808 | ||
805 | topFrame = addPage(i18n("Todo View"),0,0); | 809 | topFrame = addPage(i18n("Todo View"),0,0); |
806 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 810 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
807 | 811 | ||
808 | topLayout = new QGridLayout(topFrame,4,1); | 812 | topLayout = new QGridLayout(topFrame,4,1); |
809 | topLayout->setSpacing(mSpacingHint); | 813 | topLayout->setSpacing(mSpacingHint); |
810 | topLayout->setMargin(mMarginHint); | 814 | topLayout->setMargin(mMarginHint); |
811 | ii = 0; | 815 | ii = 0; |
812 | dummy = | 816 | dummy = |
813 | addWidBool(i18n("Hide not running Todos in To-do view"), | 817 | addWidBool(i18n("Hide not running Todos in To-do view"), |
814 | &(KOPrefs::instance()->mHideNonStartedTodos),topFrame); | 818 | &(KOPrefs::instance()->mHideNonStartedTodos),topFrame); |
815 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 819 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
816 | 820 | ||
817 | 821 | ||
818 | KPrefsDialogWidBool *showCompletedTodo = | 822 | KPrefsDialogWidBool *showCompletedTodo = |
819 | addWidBool(i18n("To-do view shows completed Todos"), | 823 | addWidBool(i18n("To-do view shows completed Todos"), |
820 | &(KOPrefs::instance()->mShowCompletedTodo),topFrame); | 824 | &(KOPrefs::instance()->mShowCompletedTodo),topFrame); |
821 | topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0); | 825 | topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0); |
822 | dummy = | 826 | dummy = |
823 | addWidBool(i18n("To-do view shows complete as 'xx %'"), | 827 | addWidBool(i18n("To-do view shows complete as 'xx %'"), |
824 | &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame); | 828 | &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame); |
825 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 829 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
826 | 830 | ||
827 | dummy = | 831 | dummy = |
828 | addWidBool(i18n("Small To-do view uses smaller font"), | 832 | addWidBool(i18n("Small To-do view uses smaller font"), |
829 | &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame); | 833 | &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame); |
830 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 834 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
831 | 835 | ||
832 | 836 | ||
833 | 837 | ||
834 | dummy = | 838 | dummy = |
835 | addWidBool(i18n("Todo view uses category colors"), | 839 | addWidBool(i18n("Todo view uses category colors"), |
836 | &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame); | 840 | &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame); |
837 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 841 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
838 | 842 | ||
839 | 843 | ||
840 | QWidget* wid = new QWidget( topFrame ); | 844 | QWidget* wid = new QWidget( topFrame ); |
841 | // Todo run today color | 845 | // Todo run today color |
842 | KPrefsDialogWidColor *todoRunColor = | 846 | KPrefsDialogWidColor *todoRunColor = |
843 | addWidColor(i18n("Color for running todos:"), | 847 | addWidColor(i18n("Color for running todos:"), |
844 | &(KOPrefs::instance()->mTodoRunColor),wid); | 848 | &(KOPrefs::instance()->mTodoRunColor),wid); |
845 | QHBoxLayout *widLayout = new QHBoxLayout(wid); | 849 | QHBoxLayout *widLayout = new QHBoxLayout(wid); |
846 | widLayout->addWidget( todoRunColor->label() ); | 850 | widLayout->addWidget( todoRunColor->label() ); |
847 | widLayout->addWidget( todoRunColor->button() ); | 851 | widLayout->addWidget( todoRunColor->button() ); |
848 | topLayout->addWidget(wid,ii++,0); | 852 | topLayout->addWidget(wid,ii++,0); |
849 | 853 | ||
850 | wid = new QWidget( topFrame ); | 854 | wid = new QWidget( topFrame ); |
851 | // Todo due today color | 855 | // Todo due today color |
852 | KPrefsDialogWidColor *todoDueTodayColor = | 856 | KPrefsDialogWidColor *todoDueTodayColor = |
853 | addWidColor(i18n("Todo due today color:"), | 857 | addWidColor(i18n("Todo due today color:"), |
854 | &(KOPrefs::instance()->mTodoDueTodayColor),wid); | 858 | &(KOPrefs::instance()->mTodoDueTodayColor),wid); |
855 | widLayout = new QHBoxLayout(wid); | 859 | widLayout = new QHBoxLayout(wid); |
856 | widLayout->addWidget( todoDueTodayColor->label() ); | 860 | widLayout->addWidget( todoDueTodayColor->label() ); |
857 | widLayout->addWidget( todoDueTodayColor->button() ); | 861 | widLayout->addWidget( todoDueTodayColor->button() ); |
858 | topLayout->addWidget(wid,ii++,0); | 862 | topLayout->addWidget(wid,ii++,0); |
859 | //topLayout->addWidget(todoDueTodayColor->button(),ii++,1); | 863 | //topLayout->addWidget(todoDueTodayColor->button(),ii++,1); |
860 | 864 | ||
861 | // Todo overdue color | 865 | // Todo overdue color |
862 | wid = new QWidget( topFrame ); | 866 | wid = new QWidget( topFrame ); |
863 | widLayout = new QHBoxLayout(wid); | 867 | widLayout = new QHBoxLayout(wid); |
864 | KPrefsDialogWidColor *todoOverdueColor = | 868 | KPrefsDialogWidColor *todoOverdueColor = |
865 | addWidColor(i18n("Todo overdue color:"), | 869 | addWidColor(i18n("Todo overdue color:"), |
866 | &(KOPrefs::instance()->mTodoOverdueColor),wid); | 870 | &(KOPrefs::instance()->mTodoOverdueColor),wid); |
867 | widLayout->addWidget(todoOverdueColor->label()); | 871 | widLayout->addWidget(todoOverdueColor->label()); |
868 | widLayout->addWidget(todoOverdueColor->button()); | 872 | widLayout->addWidget(todoOverdueColor->button()); |
869 | topLayout->addWidget(wid,ii++,0); | 873 | topLayout->addWidget(wid,ii++,0); |
870 | 874 | ||
871 | dummy = | 875 | dummy = |
872 | addWidBool(i18n("Colors are applied to text"), | 876 | addWidBool(i18n("Colors are applied to text"), |
873 | &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame); | 877 | &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame); |
874 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 878 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
875 | 879 | ||
876 | 880 | ||
877 | 881 | ||
878 | topFrame = addPage(i18n("View Options"),0,0); | 882 | topFrame = addPage(i18n("View Options"),0,0); |
879 | 883 | ||
880 | topLayout = new QGridLayout(topFrame,4,1); | 884 | topLayout = new QGridLayout(topFrame,4,1); |
881 | topLayout->setSpacing(mSpacingHint); | 885 | topLayout->setSpacing(mSpacingHint); |
882 | topLayout->setMargin(mMarginHint); | 886 | topLayout->setMargin(mMarginHint); |
883 | ii = 0; | 887 | ii = 0; |
884 | 888 | ||
885 | dummy = | 889 | dummy = |
886 | addWidBool(i18n("Show Sync Events"), | 890 | addWidBool(i18n("Show Sync Events"), |
887 | &(KOPrefs::instance()->mShowSyncEvents),topFrame); | 891 | &(KOPrefs::instance()->mShowSyncEvents),topFrame); |
888 | topLayout->addWidget(dummy->checkBox(), ii++,0); | 892 | topLayout->addWidget(dummy->checkBox(), ii++,0); |
889 | 893 | ||
890 | lab = new QLabel( i18n("Show in todo/event viewer:"), topFrame); | 894 | lab = new QLabel( i18n("Show in todo/event viewer:"), topFrame); |
891 | topLayout->addWidget(lab ,ii++,0); | 895 | topLayout->addWidget(lab ,ii++,0); |
892 | 896 | ||
893 | dummy = addWidBool(i18n("Details"), | 897 | dummy = addWidBool(i18n("Details"), |
894 | &(KOPrefs::instance()->mEVshowDetails),topFrame); | 898 | &(KOPrefs::instance()->mEVshowDetails),topFrame); |
895 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 899 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
896 | dummy = addWidBool(i18n("Created time"), | 900 | dummy = addWidBool(i18n("Created time"), |
897 | &(KOPrefs::instance()->mEVshowCreated),topFrame); | 901 | &(KOPrefs::instance()->mEVshowCreated),topFrame); |
898 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 902 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
899 | dummy = addWidBool(i18n("Last modified time"), | 903 | dummy = addWidBool(i18n("Last modified time"), |
900 | &(KOPrefs::instance()->mEVshowChanged),topFrame); | 904 | &(KOPrefs::instance()->mEVshowChanged),topFrame); |
901 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 905 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
902 | 906 | ||
903 | 907 | ||
904 | lab = new QLabel( i18n("Show in What'sThis quick overview:"), topFrame); | 908 | lab = new QLabel( i18n("Show in What'sThis quick overview:"), topFrame); |
905 | topLayout->addWidget(lab ,ii++,0); | 909 | topLayout->addWidget(lab ,ii++,0); |
906 | 910 | ||
907 | dummy = addWidBool(i18n("Details"), | 911 | dummy = addWidBool(i18n("Details"), |
908 | &(KOPrefs::instance()->mWTshowDetails),topFrame); | 912 | &(KOPrefs::instance()->mWTshowDetails),topFrame); |
909 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 913 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
910 | dummy = addWidBool(i18n("Created time"), | 914 | dummy = addWidBool(i18n("Created time"), |
911 | &(KOPrefs::instance()->mWTshowCreated),topFrame); | 915 | &(KOPrefs::instance()->mWTshowCreated),topFrame); |
912 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 916 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
913 | dummy = addWidBool(i18n("Last modified time"), | 917 | dummy = addWidBool(i18n("Last modified time"), |
914 | &(KOPrefs::instance()->mWTshowChanged),topFrame); | 918 | &(KOPrefs::instance()->mWTshowChanged),topFrame); |
915 | topLayout->addWidget(dummy->checkBox(),ii++,0); | 919 | topLayout->addWidget(dummy->checkBox(),ii++,0); |
916 | 920 | ||
917 | 921 | ||
918 | topFrame = addPage(i18n("Alarm"),0,0); | 922 | topFrame = addPage(i18n("Alarm"),0,0); |
919 | // DesktopIcon("viewmag",KIcon::SizeMedium)); | 923 | // DesktopIcon("viewmag",KIcon::SizeMedium)); |
920 | 924 | ||
921 | topLayout = new QGridLayout(topFrame,2,1); | 925 | topLayout = new QGridLayout(topFrame,2,1); |
922 | topLayout->setSpacing(mSpacingHint); | 926 | topLayout->setSpacing(mSpacingHint); |
923 | topLayout->setMargin(mMarginHint); | 927 | topLayout->setMargin(mMarginHint); |
924 | int iii = 0; | 928 | int iii = 0; |
925 | 929 | ||
926 | dummy = | 930 | dummy = |
927 | addWidBool(i18n("Use internal alarm notification"), | 931 | addWidBool(i18n("Use internal alarm notification"), |
928 | &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame); | 932 | &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame); |
929 | topLayout->addWidget(dummy->checkBox(),iii++,0); | 933 | topLayout->addWidget(dummy->checkBox(),iii++,0); |
930 | 934 | ||
931 | if ( QApplication::desktop()->height() > 240 ) { | 935 | if ( QApplication::desktop()->height() > 240 ) { |
932 | 936 | ||
933 | 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); | 937 | 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); |
934 | 938 | ||
935 | topLayout->addWidget(lab ,iii++,0); | 939 | topLayout->addWidget(lab ,iii++,0); |
936 | } | 940 | } |
937 | #ifndef DESKTOP_VERSION | 941 | #ifndef DESKTOP_VERSION |
938 | lab->setAlignment( AlignLeft|WordBreak|AlignTop); | 942 | lab->setAlignment( AlignLeft|WordBreak|AlignTop); |
939 | #else | 943 | #else |
940 | lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 944 | lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
941 | lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); | 945 | lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); |
942 | #endif | 946 | #endif |
943 | 947 | ||
944 | QHBox* dummyBox = new QHBox(topFrame); | 948 | QHBox* dummyBox = new QHBox(topFrame); |
945 | new QLabel(i18n("Play beeps count:"),dummyBox); | 949 | new QLabel(i18n("Play beeps count:"),dummyBox); |
946 | mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox); | 950 | mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox); |
947 | topLayout->addWidget(dummyBox,iii++,0); | 951 | topLayout->addWidget(dummyBox,iii++,0); |
948 | 952 | ||
949 | dummyBox = new QHBox(topFrame); | 953 | dummyBox = new QHBox(topFrame); |
950 | new QLabel(i18n("Beeps interval in sec:"),dummyBox); | 954 | new QLabel(i18n("Beeps interval in sec:"),dummyBox); |
951 | mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox); | 955 | mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox); |
952 | topLayout->addWidget(dummyBox,iii++,0); | 956 | topLayout->addWidget(dummyBox,iii++,0); |
953 | 957 | ||
954 | dummyBox = new QHBox(topFrame); | 958 | dummyBox = new QHBox(topFrame); |
955 | new QLabel(i18n("Default suspend time in min:"),dummyBox); | 959 | new QLabel(i18n("Default suspend time in min:"),dummyBox); |
956 | mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox); | 960 | mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox); |
957 | topLayout->addWidget(dummyBox,iii++,0); | 961 | topLayout->addWidget(dummyBox,iii++,0); |
958 | 962 | ||
959 | dummyBox = new QHBox(topFrame); | 963 | dummyBox = new QHBox(topFrame); |
960 | new QLabel(i18n("Auto suspend count:"),dummyBox); | 964 | new QLabel(i18n("Auto suspend count:"),dummyBox); |
961 | mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox); | 965 | mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox); |
962 | topLayout->addWidget(dummyBox,iii++,0); | 966 | topLayout->addWidget(dummyBox,iii++,0); |
963 | 967 | ||
964 | 968 | ||
965 | 969 | ||
966 | QHBox* hbo = new QHBox ( topFrame ); | 970 | QHBox* hbo = new QHBox ( topFrame ); |
967 | mDefaultAlarmFile = new QLineEdit(hbo); | 971 | mDefaultAlarmFile = new QLineEdit(hbo); |
968 | QPushButton * loadTemplate = new QPushButton(hbo); | 972 | QPushButton * loadTemplate = new QPushButton(hbo); |
969 | QPixmap icon; | 973 | QPixmap icon; |
970 | if ( QApplication::desktop()->width() < 321 ) | 974 | if ( QApplication::desktop()->width() < 321 ) |
971 | icon = SmallIcon("fileimport16"); | 975 | icon = SmallIcon("fileimport16"); |
972 | else | 976 | else |
973 | icon = SmallIcon("fileimport"); | 977 | icon = SmallIcon("fileimport"); |
974 | loadTemplate->setIconSet (icon ) ; | 978 | loadTemplate->setIconSet (icon ) ; |
975 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) ); | 979 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) ); |
976 | int size = loadTemplate->sizeHint().height(); | 980 | int size = loadTemplate->sizeHint().height(); |
977 | loadTemplate->setFixedSize( size, size ); | 981 | loadTemplate->setFixedSize( size, size ); |
978 | //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame); | 982 | //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame); |
979 | // topLayout->addWidget(lab ,iii++,0); | 983 | // topLayout->addWidget(lab ,iii++,0); |
980 | lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame); | 984 | lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame); |
981 | topLayout->addWidget(lab ,iii++,0); | 985 | topLayout->addWidget(lab ,iii++,0); |
982 | topLayout->addWidget(hbo,iii++,0); | 986 | topLayout->addWidget(hbo,iii++,0); |
983 | // 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); | 987 | // 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); |
984 | 988 | ||
985 | // topLayout->addWidget(lab ,iii++,0); | 989 | // topLayout->addWidget(lab ,iii++,0); |
986 | // #ifndef DESKTOP_VERSION | 990 | // #ifndef DESKTOP_VERSION |
987 | // lab->setAlignment( AlignLeft|WordBreak|AlignTop); | 991 | // lab->setAlignment( AlignLeft|WordBreak|AlignTop); |
988 | // #else | 992 | // #else |
989 | // lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 993 | // lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
990 | // lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); | 994 | // lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); |
991 | // #endif | 995 | // #endif |
992 | 996 | ||
993 | 997 | ||
994 | } | 998 | } |
995 | 999 | ||
996 | void KOPrefsDialog::selectSoundFile() | 1000 | void KOPrefsDialog::selectSoundFile() |
997 | { | 1001 | { |
998 | QString fileName = mDefaultAlarmFile->text(); | 1002 | QString fileName = mDefaultAlarmFile->text(); |
999 | fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this ); | 1003 | fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this ); |
1000 | if ( fileName.length() > 0 ) | 1004 | if ( fileName.length() > 0 ) |
1001 | mDefaultAlarmFile->setText( fileName ); | 1005 | mDefaultAlarmFile->setText( fileName ); |
1002 | } | 1006 | } |
1003 | void KOPrefsDialog::setupFontsTab() | 1007 | void KOPrefsDialog::setupFontsTab() |
1004 | { | 1008 | { |
1005 | 1009 | ||
1006 | QFrame *topFrame = addPage(i18n("Fonts"),0,0); | 1010 | QFrame *topFrame = addPage(i18n("Fonts"),0,0); |
1007 | // DesktopIcon("fonts",KIcon::SizeMedium)); | 1011 | // DesktopIcon("fonts",KIcon::SizeMedium)); |
1008 | 1012 | ||
1009 | QGridLayout *topLayout = new QGridLayout(topFrame,7,3); | 1013 | QGridLayout *topLayout = new QGridLayout(topFrame,7,3); |
1010 | topLayout->setSpacing(1); | 1014 | topLayout->setSpacing(1); |
1011 | topLayout->setMargin(3); | 1015 | topLayout->setMargin(3); |
1012 | KPrefsDialogWidFont * tVFont; | 1016 | KPrefsDialogWidFont * tVFont; |
1013 | int i = 0; | 1017 | int i = 0; |
1014 | KPrefsDialogWidFont *timeLabelsFont = | 1018 | KPrefsDialogWidFont *timeLabelsFont = |
1015 | addWidFont(i18n("23"),i18n("DateNavigator:(nr)"), | 1019 | addWidFont(i18n("23"),i18n("DateNavigator:(nr)"), |
1016 | &(KOPrefs::instance()->mDateNavigatorFont),topFrame); | 1020 | &(KOPrefs::instance()->mDateNavigatorFont),topFrame); |
1017 | topLayout->addWidget(timeLabelsFont->label(),i,0); | 1021 | topLayout->addWidget(timeLabelsFont->label(),i,0); |
1018 | topLayout->addWidget(timeLabelsFont->preview(),i,1); | 1022 | topLayout->addWidget(timeLabelsFont->preview(),i,1); |
1019 | topLayout->addWidget(timeLabelsFont->button(),i,2); | 1023 | topLayout->addWidget(timeLabelsFont->button(),i,2); |
1020 | ++i; | 1024 | ++i; |
1021 | 1025 | ||
1022 | 1026 | ||
1023 | timeLabelsFont = | 1027 | timeLabelsFont = |
1024 | addWidFont(i18n("Mon 15"),i18n("Date Labels:"), | 1028 | addWidFont(i18n("Mon 15"),i18n("Date Labels:"), |
1025 | &(KOPrefs::instance()->mTimeLabelsFont),topFrame); | 1029 | &(KOPrefs::instance()->mTimeLabelsFont),topFrame); |
1026 | topLayout->addWidget(timeLabelsFont->label(),i,0); | 1030 | topLayout->addWidget(timeLabelsFont->label(),i,0); |
1027 | topLayout->addWidget(timeLabelsFont->preview(),i,1); | 1031 | topLayout->addWidget(timeLabelsFont->preview(),i,1); |
1028 | topLayout->addWidget(timeLabelsFont->button(),i,2); | 1032 | topLayout->addWidget(timeLabelsFont->button(),i,2); |
1029 | ++i; | 1033 | ++i; |
1030 | 1034 | ||
1031 | KPrefsDialogWidFont *timeBarFont = | 1035 | KPrefsDialogWidFont *timeBarFont = |
1032 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"), | 1036 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"), |
1033 | &(KOPrefs::instance()->mTimeBarFont),topFrame); | 1037 | &(KOPrefs::instance()->mTimeBarFont),topFrame); |
1034 | topLayout->addWidget(timeBarFont->label(),i,0); | 1038 | topLayout->addWidget(timeBarFont->label(),i,0); |
1035 | topLayout->addWidget(timeBarFont->preview(),i,1); | 1039 | topLayout->addWidget(timeBarFont->preview(),i,1); |
1036 | topLayout->addWidget(timeBarFont->button(),i,2); | 1040 | topLayout->addWidget(timeBarFont->button(),i,2); |
1037 | ++i; | 1041 | ++i; |
1038 | 1042 | ||
1039 | 1043 | ||
1040 | KPrefsDialogWidFont *marcusBainsFont = | 1044 | KPrefsDialogWidFont *marcusBainsFont = |
1041 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"), | 1045 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"), |
1042 | &(KOPrefs::instance()->mMarcusBainsFont),topFrame); | 1046 | &(KOPrefs::instance()->mMarcusBainsFont),topFrame); |
1043 | topLayout->addWidget(marcusBainsFont->label(),i,0); | 1047 | topLayout->addWidget(marcusBainsFont->label(),i,0); |
1044 | topLayout->addWidget(marcusBainsFont->preview(),i,1); | 1048 | topLayout->addWidget(marcusBainsFont->preview(),i,1); |
1045 | topLayout->addWidget(marcusBainsFont->button(),i,2); | 1049 | topLayout->addWidget(marcusBainsFont->button(),i,2); |
1046 | ++i; | 1050 | ++i; |
1047 | 1051 | ||
1048 | tVFont = | 1052 | tVFont = |
1049 | addWidFont(i18n("Summary"),i18n("Event Viewer:"), | 1053 | addWidFont(i18n("Summary"),i18n("Event Viewer:"), |
1050 | &(KOPrefs::instance()->mEventViewFont),topFrame); | 1054 | &(KOPrefs::instance()->mEventViewFont),topFrame); |
1051 | topLayout->addWidget(tVFont->label(),i,0); | 1055 | topLayout->addWidget(tVFont->label(),i,0); |
1052 | topLayout->addWidget(tVFont->preview(),i,1); | 1056 | topLayout->addWidget(tVFont->preview(),i,1); |
1053 | topLayout->addWidget(tVFont->button(),i,2); | 1057 | topLayout->addWidget(tVFont->button(),i,2); |
1054 | ++i; | 1058 | ++i; |
1055 | 1059 | ||
1056 | 1060 | ||
1057 | 1061 | ||
1058 | tVFont = | 1062 | tVFont = |
1059 | addWidFont(i18n("Details"),i18n("EditorBox:"), | 1063 | addWidFont(i18n("Details"),i18n("EditorBox:"), |
1060 | &(KOPrefs::instance()->mEditBoxFont),topFrame); | 1064 | &(KOPrefs::instance()->mEditBoxFont),topFrame); |
1061 | topLayout->addWidget(tVFont->label(),i,0); | 1065 | topLayout->addWidget(tVFont->label(),i,0); |
1062 | topLayout->addWidget(tVFont->preview(),i,1); | 1066 | topLayout->addWidget(tVFont->preview(),i,1); |
1063 | topLayout->addWidget(tVFont->button(),i,2); | 1067 | topLayout->addWidget(tVFont->button(),i,2); |
1064 | ++i; | 1068 | ++i; |
1065 | 1069 | ||
1066 | 1070 | ||
1067 | 1071 | ||
1068 | topLayout->setColStretch(1,1); | 1072 | topLayout->setColStretch(1,1); |
1069 | topLayout->setRowStretch(4,1); | 1073 | topLayout->setRowStretch(4,1); |
1070 | 1074 | ||
1071 | 1075 | ||
1072 | i = 0; | 1076 | i = 0; |
1073 | topFrame = addPage(i18n("View Fonts"),0, | 1077 | topFrame = addPage(i18n("View Fonts"),0, |
1074 | DesktopIcon("fonts",KIcon::SizeMedium)); | 1078 | DesktopIcon("fonts",KIcon::SizeMedium)); |
1075 | 1079 | ||
1076 | topLayout = new QGridLayout(topFrame,7,3); | 1080 | topLayout = new QGridLayout(topFrame,7,3); |
1077 | topLayout->setSpacing(1); | 1081 | topLayout->setSpacing(1); |
1078 | topLayout->setMargin(3); | 1082 | topLayout->setMargin(3); |
1079 | 1083 | ||
1080 | tVFont = | 1084 | tVFont = |
1081 | addWidFont(i18n("Configure KO"),i18n("What's Next View:"), | 1085 | addWidFont(i18n("Configure KO"),i18n("What's Next View:"), |
1082 | &(KOPrefs::instance()->mWhatsNextFont),topFrame); | 1086 | &(KOPrefs::instance()->mWhatsNextFont),topFrame); |
1083 | topLayout->addWidget(tVFont->label(),i,0); | 1087 | topLayout->addWidget(tVFont->label(),i,0); |
1084 | topLayout->addWidget(tVFont->preview(),i,1); | 1088 | topLayout->addWidget(tVFont->preview(),i,1); |
1085 | topLayout->addWidget(tVFont->button(),i,2); | 1089 | topLayout->addWidget(tVFont->button(),i,2); |
1086 | ++i; | 1090 | ++i; |
1087 | KPrefsDialogWidFont *agendaViewFont = | 1091 | KPrefsDialogWidFont *agendaViewFont = |
1088 | addWidFont(i18n("Event text"),i18n("Agenda view:"), | 1092 | addWidFont(i18n("Event text"),i18n("Agenda view:"), |
1089 | &(KOPrefs::instance()->mAgendaViewFont),topFrame); | 1093 | &(KOPrefs::instance()->mAgendaViewFont),topFrame); |
1090 | topLayout->addWidget(agendaViewFont->label(),i,0); | 1094 | topLayout->addWidget(agendaViewFont->label(),i,0); |
1091 | topLayout->addWidget(agendaViewFont->preview(),i,1); | 1095 | topLayout->addWidget(agendaViewFont->preview(),i,1); |
1092 | topLayout->addWidget(agendaViewFont->button(),i,2); | 1096 | topLayout->addWidget(agendaViewFont->button(),i,2); |
1093 | ++i; | 1097 | ++i; |
1094 | 1098 | ||
1095 | 1099 | ||
1096 | KPrefsDialogWidFont *monthViewFont = | 1100 | KPrefsDialogWidFont *monthViewFont = |
1097 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"), | 1101 | addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"), |
1098 | i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame); | 1102 | i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame); |
1099 | topLayout->addWidget(monthViewFont->label(),i,0); | 1103 | topLayout->addWidget(monthViewFont->label(),i,0); |
1100 | topLayout->addWidget(monthViewFont->preview(),i,1); | 1104 | topLayout->addWidget(monthViewFont->preview(),i,1); |
1101 | topLayout->addWidget(monthViewFont->button(),i,2); | 1105 | topLayout->addWidget(monthViewFont->button(),i,2); |
1102 | ++i; | 1106 | ++i; |
1103 | 1107 | ||
1104 | 1108 | ||
1105 | KPrefsDialogWidFont *lVFont = | 1109 | KPrefsDialogWidFont *lVFont = |
1106 | addWidFont(i18n("Event"),i18n("List View:"), | 1110 | addWidFont(i18n("Event"),i18n("List View:"), |
1107 | &(KOPrefs::instance()->mListViewFont),topFrame); | 1111 | &(KOPrefs::instance()->mListViewFont),topFrame); |
1108 | topLayout->addWidget(lVFont->label(),i,0); | 1112 | topLayout->addWidget(lVFont->label(),i,0); |
1109 | topLayout->addWidget(lVFont->preview(),i,1); | 1113 | topLayout->addWidget(lVFont->preview(),i,1); |
1110 | topLayout->addWidget(lVFont->button(),i,2); | 1114 | topLayout->addWidget(lVFont->button(),i,2); |
1111 | ++i; | 1115 | ++i; |
1112 | 1116 | ||
1113 | 1117 | ||
1114 | tVFont = | 1118 | tVFont = |
1115 | addWidFont(i18n("ToDo"),i18n("ToDoView:"), | 1119 | addWidFont(i18n("ToDo"),i18n("ToDoView:"), |
1116 | &(KOPrefs::instance()->mTodoViewFont),topFrame); | 1120 | &(KOPrefs::instance()->mTodoViewFont),topFrame); |
1117 | topLayout->addWidget(tVFont->label(),i,0); | 1121 | topLayout->addWidget(tVFont->label(),i,0); |
1118 | topLayout->addWidget(tVFont->preview(),i,1); | 1122 | topLayout->addWidget(tVFont->preview(),i,1); |
1119 | topLayout->addWidget(tVFont->button(),i,2); | 1123 | topLayout->addWidget(tVFont->button(),i,2); |
1120 | ++i; | 1124 | ++i; |
1121 | 1125 | ||
1122 | 1126 | ||
1123 | tVFont = | 1127 | tVFont = |
1124 | addWidFont(i18n("Today"),i18n("JournalView:"), | 1128 | addWidFont(i18n("Today"),i18n("JournalView:"), |
1125 | &(KOPrefs::instance()->mJornalViewFont),topFrame); | 1129 | &(KOPrefs::instance()->mJornalViewFont),topFrame); |
1126 | topLayout->addWidget(tVFont->label(),i,0); | 1130 | topLayout->addWidget(tVFont->label(),i,0); |
1127 | topLayout->addWidget(tVFont->preview(),i,1); | 1131 | topLayout->addWidget(tVFont->preview(),i,1); |
1128 | topLayout->addWidget(tVFont->button(),i,2); | 1132 | topLayout->addWidget(tVFont->button(),i,2); |
1129 | ++i; | 1133 | ++i; |
1130 | 1134 | ||
1131 | 1135 | ||
1132 | 1136 | ||
1133 | 1137 | ||
1134 | topLayout->setColStretch(1,1); | 1138 | topLayout->setColStretch(1,1); |
1135 | topLayout->setRowStretch(4,1); | 1139 | topLayout->setRowStretch(4,1); |
1136 | 1140 | ||
1137 | 1141 | ||
1138 | 1142 | ||
1139 | 1143 | ||
1140 | } | 1144 | } |
1141 | 1145 | ||
1142 | void KOPrefsDialog::setupColorsTab() | 1146 | void KOPrefsDialog::setupColorsTab() |
1143 | { | 1147 | { |
1144 | QFrame *topFrame = addPage(i18n("Colors"),0,0); | 1148 | QFrame *topFrame = addPage(i18n("Colors"),0,0); |
1145 | // DesktopIcon("colorize",KIcon::SizeMedium)); | 1149 | // DesktopIcon("colorize",KIcon::SizeMedium)); |
1146 | 1150 | ||
1147 | QGridLayout *topLayout = new QGridLayout(topFrame,5,2); | 1151 | QGridLayout *topLayout = new QGridLayout(topFrame,5,2); |
1148 | // topLayout->setSpacing(mSpacingHint); | 1152 | // topLayout->setSpacing(mSpacingHint); |
1149 | // topLayout->setMargin(mMarginHint); | 1153 | // topLayout->setMargin(mMarginHint); |
1150 | 1154 | ||
1151 | topLayout->setSpacing(2); | 1155 | topLayout->setSpacing(2); |
1152 | topLayout->setMargin(3); | 1156 | topLayout->setMargin(3); |
1153 | 1157 | ||
1154 | int ii = 1; | 1158 | int ii = 1; |
1155 | QGroupBox *categoryGroup ; | 1159 | QGroupBox *categoryGroup ; |
1156 | 1160 | ||
1157 | categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"), | 1161 | categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"), |
1158 | topFrame); | 1162 | topFrame); |
1159 | topLayout->addMultiCellWidget(categoryGroup,0,0,0,1); | 1163 | topLayout->addMultiCellWidget(categoryGroup,0,0,0,1); |
1160 | 1164 | ||
1161 | mCategoryCombo = new QComboBox(categoryGroup); | 1165 | mCategoryCombo = new QComboBox(categoryGroup); |
1162 | mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); | 1166 | mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); |
1163 | connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); | 1167 | connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); |
1164 | 1168 | ||
1165 | mCategoryButton = new KColorButton(categoryGroup); | 1169 | mCategoryButton = new KColorButton(categoryGroup); |
1166 | connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor())); | 1170 | connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor())); |
1167 | updateCategoryColor(); | 1171 | updateCategoryColor(); |
1168 | 1172 | ||
1169 | 1173 | ||
1170 | // Holiday Color | 1174 | // Holiday Color |
1171 | 1175 | ||
1172 | KPrefsDialogWidColor *holidayColor = | 1176 | KPrefsDialogWidColor *holidayColor = |
1173 | addWidColor(i18n("Holiday color:"), | 1177 | addWidColor(i18n("Holiday color:"), |
1174 | &(KOPrefs::instance()->mHolidayColor),topFrame); | 1178 | &(KOPrefs::instance()->mHolidayColor),topFrame); |
1175 | topLayout->addWidget(holidayColor->label(),ii,0); | 1179 | topLayout->addWidget(holidayColor->label(),ii,0); |
1176 | topLayout->addWidget(holidayColor->button(),ii++,1); | 1180 | topLayout->addWidget(holidayColor->button(),ii++,1); |
1177 | 1181 | ||
1178 | // Highlight Color | 1182 | // Highlight Color |
1179 | KPrefsDialogWidColor *highlightColor = | 1183 | KPrefsDialogWidColor *highlightColor = |
1180 | addWidColor(i18n("Highlight color:"), | 1184 | addWidColor(i18n("Highlight color:"), |
1181 | &(KOPrefs::instance()->mHighlightColor),topFrame); | 1185 | &(KOPrefs::instance()->mHighlightColor),topFrame); |
1182 | topLayout->addWidget(highlightColor->label(),ii,0); | 1186 | topLayout->addWidget(highlightColor->label(),ii,0); |
1183 | topLayout->addWidget(highlightColor->button(),ii++,1); | 1187 | topLayout->addWidget(highlightColor->button(),ii++,1); |
1184 | 1188 | ||
1185 | // Event color | 1189 | // Event color |
1186 | KPrefsDialogWidColor *eventColor = | 1190 | KPrefsDialogWidColor *eventColor = |
1187 | addWidColor(i18n("Default event color:"), | 1191 | addWidColor(i18n("Default event color:"), |
1188 | &(KOPrefs::instance()->mEventColor),topFrame); | 1192 | &(KOPrefs::instance()->mEventColor),topFrame); |
1189 | topLayout->addWidget(eventColor->label(),ii,0); | 1193 | topLayout->addWidget(eventColor->label(),ii,0); |
1190 | topLayout->addWidget(eventColor->button(),ii++,1); | 1194 | topLayout->addWidget(eventColor->button(),ii++,1); |
1191 | eventColor = | 1195 | eventColor = |
1192 | addWidColor(i18n("Default todo done color:"), | 1196 | addWidColor(i18n("Default todo done color:"), |
1193 | &(KOPrefs::instance()->mTodoDoneColor),topFrame); | 1197 | &(KOPrefs::instance()->mTodoDoneColor),topFrame); |
1194 | topLayout->addWidget(eventColor->label(),ii,0); | 1198 | topLayout->addWidget(eventColor->label(),ii,0); |
1195 | topLayout->addWidget(eventColor->button(),ii++,1); | 1199 | topLayout->addWidget(eventColor->button(),ii++,1); |
1196 | 1200 | ||
1197 | if ( QApplication::desktop()->height() <= 240 ) { | 1201 | if ( QApplication::desktop()->height() <= 240 ) { |
1198 | topFrame = addPage(i18n("Colors") +" 2",0,0); | 1202 | topFrame = addPage(i18n("Colors") +" 2",0,0); |
1199 | // DesktopIcon("colorize",KIcon::SizeMedium)); | 1203 | // DesktopIcon("colorize",KIcon::SizeMedium)); |
1200 | 1204 | ||
1201 | topLayout = new QGridLayout(topFrame,5,2); | 1205 | topLayout = new QGridLayout(topFrame,5,2); |
1202 | // topLayout->setSpacing(mSpacingHint); | 1206 | // topLayout->setSpacing(mSpacingHint); |
1203 | // topLayout->setMargin(mMarginHint); | 1207 | // topLayout->setMargin(mMarginHint); |
1204 | 1208 | ||
1205 | topLayout->setSpacing(2); | 1209 | topLayout->setSpacing(2); |
1206 | topLayout->setMargin(3); | 1210 | topLayout->setMargin(3); |
1207 | } | 1211 | } |
1208 | 1212 | ||
1209 | 1213 | ||
1210 | // agenda view background color | 1214 | // agenda view background color |
1211 | KPrefsDialogWidColor *agendaBgColor = | 1215 | KPrefsDialogWidColor *agendaBgColor = |
1212 | addWidColor(i18n("Agenda view background color:"), | 1216 | addWidColor(i18n("Agenda view background color:"), |
1213 | &(KOPrefs::instance()->mAgendaBgColor),topFrame); | 1217 | &(KOPrefs::instance()->mAgendaBgColor),topFrame); |
1214 | topLayout->addWidget(agendaBgColor->label(),ii,0); | 1218 | topLayout->addWidget(agendaBgColor->label(),ii,0); |
1215 | topLayout->addWidget(agendaBgColor->button(),ii++,1); | 1219 | topLayout->addWidget(agendaBgColor->button(),ii++,1); |
1216 | 1220 | ||
1217 | // working hours color | 1221 | // working hours color |
1218 | KPrefsDialogWidColor *workingHoursColor = | 1222 | KPrefsDialogWidColor *workingHoursColor = |
1219 | addWidColor(i18n("Working hours color:"), | 1223 | addWidColor(i18n("Working hours color:"), |
1220 | &(KOPrefs::instance()->mWorkingHoursColor),topFrame); | 1224 | &(KOPrefs::instance()->mWorkingHoursColor),topFrame); |
1221 | topLayout->addWidget(workingHoursColor->label(),ii,0); | 1225 | topLayout->addWidget(workingHoursColor->label(),ii,0); |
1222 | topLayout->addWidget(workingHoursColor->button(),ii++,1); | 1226 | topLayout->addWidget(workingHoursColor->button(),ii++,1); |
1223 | 1227 | ||
1224 | KPrefsDialogWidBool *sb = | 1228 | KPrefsDialogWidBool *sb = |
1225 | addWidBool(i18n("Use colors for application:"), | 1229 | addWidBool(i18n("Use colors for application:"), |
1226 | &(KOPrefs::instance()->mUseAppColors),topFrame); | 1230 | &(KOPrefs::instance()->mUseAppColors),topFrame); |
1227 | topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 ); | 1231 | topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 ); |
1228 | 1232 | ||
1229 | ii++; | 1233 | ii++; |
1230 | KPrefsDialogWidColor * workingHoursColor1 = | 1234 | KPrefsDialogWidColor * workingHoursColor1 = |
1231 | addWidColor(i18n("Buttons, menus, etc.:"), | 1235 | addWidColor(i18n("Buttons, menus, etc.:"), |
1232 | &(KOPrefs::instance()->mAppColor1),topFrame); | 1236 | &(KOPrefs::instance()->mAppColor1),topFrame); |
1233 | topLayout->addWidget(workingHoursColor1->label(),ii,0); | 1237 | topLayout->addWidget(workingHoursColor1->label(),ii,0); |
1234 | topLayout->addWidget(workingHoursColor1->button(),ii++,1); | 1238 | topLayout->addWidget(workingHoursColor1->button(),ii++,1); |
1235 | 1239 | ||
1236 | KPrefsDialogWidColor * workingHoursColor2 = | 1240 | KPrefsDialogWidColor * workingHoursColor2 = |
1237 | addWidColor(i18n("Frames, labels, etc.:"), | 1241 | addWidColor(i18n("Frames, labels, etc.:"), |
1238 | &(KOPrefs::instance()->mAppColor2),topFrame); | 1242 | &(KOPrefs::instance()->mAppColor2),topFrame); |
1239 | topLayout->addWidget(workingHoursColor2->label(),ii,0); | 1243 | topLayout->addWidget(workingHoursColor2->label(),ii,0); |
1240 | topLayout->addWidget(workingHoursColor2->button(),ii++,1); | 1244 | topLayout->addWidget(workingHoursColor2->button(),ii++,1); |
1241 | 1245 | ||
1242 | 1246 | ||
1243 | 1247 | ||
1244 | } | 1248 | } |
1245 | 1249 | ||
1246 | void KOPrefsDialog::setCategoryColor() | 1250 | void KOPrefsDialog::setCategoryColor() |
1247 | { | 1251 | { |
1248 | mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color())); | 1252 | mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color())); |
1249 | } | 1253 | } |
1250 | 1254 | ||
1251 | void KOPrefsDialog::updateCategoryColor() | 1255 | void KOPrefsDialog::updateCategoryColor() |
1252 | { | 1256 | { |
1253 | QString cat = mCategoryCombo->currentText(); | 1257 | QString cat = mCategoryCombo->currentText(); |
1254 | QColor *color = mCategoryDict.find(cat); | 1258 | QColor *color = mCategoryDict.find(cat); |
1255 | if (!color) { | 1259 | if (!color) { |
1256 | color = KOPrefs::instance()->categoryColor(cat); | 1260 | color = KOPrefs::instance()->categoryColor(cat); |
1257 | } | 1261 | } |
1258 | if (color) { | 1262 | if (color) { |
1259 | mCategoryButton->setColor(*color); | 1263 | mCategoryButton->setColor(*color); |
1260 | } | 1264 | } |
1261 | } | 1265 | } |
1262 | 1266 | ||
1263 | void KOPrefsDialog::setupPrinterTab() | 1267 | void KOPrefsDialog::setupPrinterTab() |
1264 | { | 1268 | { |
1265 | mPrinterTab = addPage(i18n("Printing"),0, | 1269 | mPrinterTab = addPage(i18n("Printing"),0, |
1266 | DesktopIcon("fileprint",KIcon::SizeMedium)); | 1270 | DesktopIcon("fileprint",KIcon::SizeMedium)); |
1267 | 1271 | ||
1268 | QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2); | 1272 | QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2); |
1269 | topLayout->setSpacing(mSpacingHint); | 1273 | topLayout->setSpacing(mSpacingHint); |
1270 | topLayout->setMargin(mMarginHint); | 1274 | topLayout->setMargin(mMarginHint); |
1271 | 1275 | ||
1272 | topLayout->setRowStretch(4,1); | 1276 | topLayout->setRowStretch(4,1); |
1273 | } | 1277 | } |
1274 | 1278 | ||
1275 | void KOPrefsDialog::setupGroupSchedulingTab() | 1279 | void KOPrefsDialog::setupGroupSchedulingTab() |
1276 | { | 1280 | { |
1277 | #if 0 | 1281 | #if 0 |
1278 | QFrame *topFrame = addPage(i18n("Group Scheduling"),0, | 1282 | QFrame *topFrame = addPage(i18n("Group Scheduling"),0, |
1279 | DesktopIcon("personal",KIcon::SizeMedium)); | 1283 | DesktopIcon("personal",KIcon::SizeMedium)); |
1280 | 1284 | ||
1281 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 1285 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
1282 | topLayout->setSpacing(mSpacingHint); | 1286 | topLayout->setSpacing(mSpacingHint); |
1283 | topLayout->setMargin(mMarginHint); | 1287 | topLayout->setMargin(mMarginHint); |
1284 | 1288 | ||
1285 | #if 0 | 1289 | #if 0 |
1286 | KPrefsDialogWidRadios *schedulerGroup = | 1290 | KPrefsDialogWidRadios *schedulerGroup = |
1287 | addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler), | 1291 | addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler), |
1288 | topFrame); | 1292 | topFrame); |
1289 | schedulerGroup->addRadio("Dummy"); // Only for debugging | 1293 | schedulerGroup->addRadio("Dummy"); // Only for debugging |
1290 | schedulerGroup->addRadio(i18n("Mail client")); | 1294 | schedulerGroup->addRadio(i18n("Mail client")); |
1291 | 1295 | ||
1292 | topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); | 1296 | topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); |
1293 | #endif | 1297 | #endif |
1294 | 1298 | ||
1295 | KPrefsDialogWidRadios *sendGroup = | 1299 | KPrefsDialogWidRadios *sendGroup = |
1296 | addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend), | 1300 | addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend), |
1297 | topFrame); | 1301 | topFrame); |
1298 | sendGroup->addRadio(i18n("Send to outbox")); | 1302 | sendGroup->addRadio(i18n("Send to outbox")); |
1299 | sendGroup->addRadio(i18n("Send directly")); | 1303 | sendGroup->addRadio(i18n("Send directly")); |
1300 | 1304 | ||
1301 | topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); | 1305 | topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); |
1302 | 1306 | ||
1303 | topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1); | 1307 | topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1); |
1304 | mAMails = new QListView(topFrame); | 1308 | mAMails = new QListView(topFrame); |
1305 | mAMails->addColumn(i18n("Email"),300); | 1309 | mAMails->addColumn(i18n("Email"),300); |
1306 | topLayout->addMultiCellWidget(mAMails,3,3,0,1); | 1310 | topLayout->addMultiCellWidget(mAMails,3,3,0,1); |
1307 | 1311 | ||
1308 | topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0); | 1312 | topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0); |
1309 | aEmailsEdit = new QLineEdit(topFrame); | 1313 | aEmailsEdit = new QLineEdit(topFrame); |
1310 | aEmailsEdit->setEnabled(false); | 1314 | aEmailsEdit->setEnabled(false); |
1311 | topLayout->addWidget(aEmailsEdit,4,1); | 1315 | topLayout->addWidget(aEmailsEdit,4,1); |
1312 | 1316 | ||
1313 | QPushButton *add = new QPushButton(i18n("New"),topFrame,"new"); | 1317 | QPushButton *add = new QPushButton(i18n("New"),topFrame,"new"); |
1314 | topLayout->addWidget(add,5,0); | 1318 | topLayout->addWidget(add,5,0); |
1315 | QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove"); | 1319 | QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove"); |
1316 | topLayout->addWidget(del,5,1); | 1320 | topLayout->addWidget(del,5,1); |
1317 | 1321 | ||
1318 | //topLayout->setRowStretch(2,1); | 1322 | //topLayout->setRowStretch(2,1); |
1319 | connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) ); | 1323 | connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) ); |
1320 | connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) ); | 1324 | connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) ); |
1321 | connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem())); | 1325 | connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem())); |
1322 | connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput())); | 1326 | connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput())); |
1323 | #endif | 1327 | #endif |
1324 | } | 1328 | } |
1325 | 1329 | ||
1326 | void KOPrefsDialog::setupGroupAutomationTab() | 1330 | void KOPrefsDialog::setupGroupAutomationTab() |
1327 | { | 1331 | { |
1328 | return; | 1332 | return; |
1329 | QFrame *topFrame = addPage(i18n("Group Automation"),0, | 1333 | QFrame *topFrame = addPage(i18n("Group Automation"),0, |
1330 | DesktopIcon("personal",KIcon::SizeMedium)); | 1334 | DesktopIcon("personal",KIcon::SizeMedium)); |
1331 | 1335 | ||
1332 | QGridLayout *topLayout = new QGridLayout(topFrame,5,1); | 1336 | QGridLayout *topLayout = new QGridLayout(topFrame,5,1); |
1333 | topLayout->setSpacing(mSpacingHint); | 1337 | topLayout->setSpacing(mSpacingHint); |
1334 | topLayout->setMargin(mMarginHint); | 1338 | topLayout->setMargin(mMarginHint); |
1335 | 1339 | ||
1336 | KPrefsDialogWidRadios *autoRefreshGroup = | 1340 | KPrefsDialogWidRadios *autoRefreshGroup = |
1337 | addWidRadios(i18n("Auto Send Refresh"), | 1341 | addWidRadios(i18n("Auto Send Refresh"), |
1338 | &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame); | 1342 | &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame); |
1339 | autoRefreshGroup->addRadio(i18n("Never")); | 1343 | autoRefreshGroup->addRadio(i18n("Never")); |
1340 | autoRefreshGroup->addRadio(i18n("If attendee is in addressbook")); | 1344 | autoRefreshGroup->addRadio(i18n("If attendee is in addressbook")); |
1341 | //autoRefreshGroup->addRadio(i18n("selected emails")); | 1345 | //autoRefreshGroup->addRadio(i18n("selected emails")); |
1342 | topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0); | 1346 | topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0); |
1343 | 1347 | ||
1344 | KPrefsDialogWidRadios *autoInsertGroup = | 1348 | KPrefsDialogWidRadios *autoInsertGroup = |
1345 | addWidRadios(i18n("Auto Insert IMIP Replies"), | 1349 | addWidRadios(i18n("Auto Insert IMIP Replies"), |
1346 | &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame); | 1350 | &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame); |
1347 | autoInsertGroup->addRadio(i18n("Never")); | 1351 | autoInsertGroup->addRadio(i18n("Never")); |
1348 | autoInsertGroup->addRadio(i18n("If attendee is in addressbook")); | 1352 | autoInsertGroup->addRadio(i18n("If attendee is in addressbook")); |
1349 | //autoInsertGroup->addRadio(i18n("selected emails")); | 1353 | //autoInsertGroup->addRadio(i18n("selected emails")); |
1350 | topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0); | 1354 | topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0); |
1351 | 1355 | ||
1352 | KPrefsDialogWidRadios *autoRequestGroup = | 1356 | KPrefsDialogWidRadios *autoRequestGroup = |
1353 | addWidRadios(i18n("Auto Insert IMIP Requests"), | 1357 | addWidRadios(i18n("Auto Insert IMIP Requests"), |
1354 | &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame); | 1358 | &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame); |
1355 | autoRequestGroup->addRadio(i18n("Never")); | 1359 | autoRequestGroup->addRadio(i18n("Never")); |
1356 | autoRequestGroup->addRadio(i18n("If organizer is in addressbook")); | 1360 | autoRequestGroup->addRadio(i18n("If organizer is in addressbook")); |
1357 | //autoInsertGroup->addRadio(i18n("selected emails")); | 1361 | //autoInsertGroup->addRadio(i18n("selected emails")); |
1358 | topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0); | 1362 | topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0); |
1359 | 1363 | ||
1360 | KPrefsDialogWidRadios *autoFreeBusyGroup = | 1364 | KPrefsDialogWidRadios *autoFreeBusyGroup = |
1361 | addWidRadios(i18n("Auto Send FreeBusy Information"), | 1365 | addWidRadios(i18n("Auto Send FreeBusy Information"), |
1362 | &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame); | 1366 | &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame); |
1363 | autoFreeBusyGroup->addRadio(i18n("Never")); | 1367 | autoFreeBusyGroup->addRadio(i18n("Never")); |
1364 | autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook")); | 1368 | autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook")); |
1365 | //autoFreeBusyGroup->addRadio(i18n("selected emails")); | 1369 | //autoFreeBusyGroup->addRadio(i18n("selected emails")); |
1366 | topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0); | 1370 | topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0); |
1367 | 1371 | ||
1368 | KPrefsDialogWidRadios *autoFreeBusyReplyGroup = | 1372 | KPrefsDialogWidRadios *autoFreeBusyReplyGroup = |
1369 | addWidRadios(i18n("Auto Save FreeBusy Replies"), | 1373 | addWidRadios(i18n("Auto Save FreeBusy Replies"), |
1370 | &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame); | 1374 | &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame); |
1371 | autoFreeBusyReplyGroup->addRadio(i18n("Never")); | 1375 | autoFreeBusyReplyGroup->addRadio(i18n("Never")); |
1372 | autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook")); | 1376 | autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook")); |
1373 | //autoFreeBusyGroup->addRadio(i18n("selected emails")); | 1377 | //autoFreeBusyGroup->addRadio(i18n("selected emails")); |
1374 | topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0); | 1378 | topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0); |
1375 | } | 1379 | } |
1376 | 1380 | ||
1377 | void KOPrefsDialog::showPrinterTab() | 1381 | void KOPrefsDialog::showPrinterTab() |
1378 | { | 1382 | { |
1379 | showPage(pageIndex(mPrinterTab)); | 1383 | showPage(pageIndex(mPrinterTab)); |
1380 | } | 1384 | } |
1381 | 1385 | ||
1382 | 1386 | ||
1383 | void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text, | 1387 | void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text, |
1384 | const QStringList *tags) | 1388 | const QStringList *tags) |
1385 | { | 1389 | { |
1386 | if (tags) { | 1390 | if (tags) { |
1387 | int i = tags->findIndex(text); | 1391 | int i = tags->findIndex(text); |
1388 | if (i > 0) combo->setCurrentItem(i); | 1392 | if (i > 0) combo->setCurrentItem(i); |
1389 | } else { | 1393 | } else { |
1390 | for(int i=0;i<combo->count();++i) { | 1394 | for(int i=0;i<combo->count();++i) { |
1391 | if (combo->text(i) == text) { | 1395 | if (combo->text(i) == text) { |
1392 | combo->setCurrentItem(i); | 1396 | combo->setCurrentItem(i); |
1393 | break; | 1397 | break; |
1394 | } | 1398 | } |
1395 | } | 1399 | } |
1396 | } | 1400 | } |
1397 | } | 1401 | } |
1398 | 1402 | ||
1399 | void KOPrefsDialog::usrReadConfig() | 1403 | void KOPrefsDialog::usrReadConfig() |
1400 | { | 1404 | { |
1401 | 1405 | ||
1402 | mNameEdit->setText(KOPrefs::instance()->fullName()); | 1406 | mNameEdit->setText(KOPrefs::instance()->fullName()); |
1403 | mEmailEdit->setText(KOPrefs::instance()->email()); | 1407 | mEmailEdit->setText(KOPrefs::instance()->email()); |
1404 | 1408 | ||
1405 | mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval); | 1409 | mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval); |
1406 | 1410 | ||
1407 | mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime); | 1411 | mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime); |
1408 | mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration); | 1412 | mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration); |
1409 | mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); | 1413 | mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); |
1410 | 1414 | ||
1411 | mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays); | 1415 | mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays); |
1412 | mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays); | 1416 | mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays); |
1413 | mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios); | 1417 | mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios); |
1414 | // mAMails->clear(); | 1418 | // mAMails->clear(); |
1415 | // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin(); | 1419 | // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin(); |
1416 | // it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) { | 1420 | // it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) { |
1417 | // QListViewItem *item = new QListViewItem(mAMails); | 1421 | // QListViewItem *item = new QListViewItem(mAMails); |
1418 | // item->setText(0,*it); | 1422 | // item->setText(0,*it); |
1419 | // mAMails->insertItem(item); | 1423 | // mAMails->insertItem(item); |
1420 | // } | 1424 | // } |
1421 | 1425 | ||
1422 | //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile); | 1426 | //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile); |
1423 | mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile); | 1427 | mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile); |
1424 | updateCategories(); | 1428 | updateCategories(); |
1425 | mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps ); | 1429 | mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps ); |
1426 | mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime ); | 1430 | mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime ); |
1427 | mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount ); | 1431 | mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount ); |
1428 | mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval ); | 1432 | mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval ); |
1429 | mCatDefaultColor = KOPrefs::instance()->mEventColor; | 1433 | mCatDefaultColor = KOPrefs::instance()->mEventColor; |
1430 | } | 1434 | } |
1431 | 1435 | ||
1432 | 1436 | ||
1433 | void KOPrefsDialog::usrWriteConfig() | 1437 | void KOPrefsDialog::usrWriteConfig() |
1434 | { | 1438 | { |
1435 | KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text(); | 1439 | KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text(); |
1436 | KOPrefs::instance()->setFullName(mNameEdit->text()); | 1440 | KOPrefs::instance()->setFullName(mNameEdit->text()); |
1437 | KOPrefs::instance()->setEmail(mEmailEdit->text()); | 1441 | KOPrefs::instance()->setEmail(mEmailEdit->text()); |
1438 | 1442 | ||
1439 | KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value(); | 1443 | KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value(); |
1440 | KOPrefs::instance()->mStartTime = mStartTimeSpin->value(); | 1444 | KOPrefs::instance()->mStartTime = mStartTimeSpin->value(); |
1441 | KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value(); | 1445 | KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value(); |
1442 | KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); | 1446 | KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); |
1443 | if ( mCatDefaultColor != KOPrefs::instance()->mEventColor ) { | 1447 | if ( mCatDefaultColor != KOPrefs::instance()->mEventColor ) { |
1444 | QStringList cat = KOPrefs::instance()->mCustomCategories; | 1448 | QStringList cat = KOPrefs::instance()->mCustomCategories; |
1445 | int iii = 0; | 1449 | int iii = 0; |
1446 | while ( iii < cat.count() ) { | 1450 | while ( iii < cat.count() ) { |
1447 | if ( *KOPrefs::instance()->categoryColor( cat[ iii ] ) == mCatDefaultColor ) | 1451 | if ( *KOPrefs::instance()->categoryColor( cat[ iii ] ) == mCatDefaultColor ) |
1448 | KOPrefs::instance()->setCategoryColor( cat[ iii ], KOPrefs::instance()->mEventColor ); | 1452 | KOPrefs::instance()->setCategoryColor( cat[ iii ], KOPrefs::instance()->mEventColor ); |
1449 | ++iii; | 1453 | ++iii; |
1450 | } | 1454 | } |
1451 | } | 1455 | } |
1452 | QDictIterator<QColor> it(mCategoryDict); | 1456 | QDictIterator<QColor> it(mCategoryDict); |
1453 | while (it.current()) { | 1457 | while (it.current()) { |
1454 | KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); | 1458 | KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); |
1455 | ++it; | 1459 | ++it; |
1456 | } | 1460 | } |
1457 | 1461 | ||
1458 | KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value(); | 1462 | KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value(); |
1459 | KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value(); | 1463 | KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value(); |
1460 | KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value(); | 1464 | KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value(); |
1461 | 1465 | ||
1462 | KOPrefs::instance()->mAdditionalMails.clear(); | 1466 | KOPrefs::instance()->mAdditionalMails.clear(); |
1463 | // QListViewItem *item; | 1467 | // QListViewItem *item; |
1464 | // item = mAMails->firstChild(); | 1468 | // item = mAMails->firstChild(); |
1465 | // while (item) | 1469 | // while (item) |
1466 | // { | 1470 | // { |
1467 | // KOPrefs::instance()->mAdditionalMails.append( item->text(0) ); | 1471 | // KOPrefs::instance()->mAdditionalMails.append( item->text(0) ); |
1468 | // item = item->nextSibling(); | 1472 | // item = item->nextSibling(); |
1469 | // } | 1473 | // } |
1470 | KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value(); | 1474 | KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value(); |
1471 | KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ; | 1475 | KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ; |
1472 | KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ; | 1476 | KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ; |
1473 | KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ; | 1477 | KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ; |
1474 | } | 1478 | } |
1475 | 1479 | ||
1476 | void KOPrefsDialog::updateCategories() | 1480 | void KOPrefsDialog::updateCategories() |
1477 | { | 1481 | { |
1478 | mCategoryCombo->clear(); | 1482 | mCategoryCombo->clear(); |
1479 | mCategoryDict.clear(); | 1483 | mCategoryDict.clear(); |
1480 | mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); | 1484 | mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); |
1481 | updateCategoryColor(); | 1485 | updateCategoryColor(); |
1482 | } | 1486 | } |
1483 | 1487 | ||
1484 | void KOPrefsDialog::toggleEmailSettings(bool on) | 1488 | void KOPrefsDialog::toggleEmailSettings(bool on) |
1485 | { | 1489 | { |
1486 | if (on) { | 1490 | if (on) { |
1487 | mEmailEdit->setEnabled(false); | 1491 | mEmailEdit->setEnabled(false); |
1488 | mNameEdit->setEnabled(false); | 1492 | mNameEdit->setEnabled(false); |
1489 | mEmailLabel->setEnabled(false); | 1493 | mEmailLabel->setEnabled(false); |
1490 | mNameLabel->setEnabled(false); | 1494 | mNameLabel->setEnabled(false); |
1491 | 1495 | ||
1492 | KEMailSettings settings; | 1496 | KEMailSettings settings; |
1493 | mNameEdit->setText(settings.getSetting(KEMailSettings::RealName)); | 1497 | mNameEdit->setText(settings.getSetting(KEMailSettings::RealName)); |
1494 | mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress)); | 1498 | mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress)); |
1495 | } else { | 1499 | } else { |
1496 | mEmailEdit->setEnabled(true); | 1500 | mEmailEdit->setEnabled(true); |
1497 | mNameEdit->setEnabled(true); | 1501 | mNameEdit->setEnabled(true); |
1498 | mEmailLabel->setEnabled(true); | 1502 | mEmailLabel->setEnabled(true); |
1499 | mNameLabel->setEnabled(true); | 1503 | mNameLabel->setEnabled(true); |
1500 | } | 1504 | } |
1501 | } | 1505 | } |
1502 | 1506 | ||
1503 | void KOPrefsDialog::addItem() | 1507 | void KOPrefsDialog::addItem() |
1504 | { | 1508 | { |
1505 | // aEmailsEdit->setEnabled(true); | 1509 | // aEmailsEdit->setEnabled(true); |
1506 | // QListViewItem *item = new QListViewItem(mAMails); | 1510 | // QListViewItem *item = new QListViewItem(mAMails); |
1507 | // mAMails->insertItem(item); | 1511 | // mAMails->insertItem(item); |
1508 | // mAMails->setSelected(item,true); | 1512 | // mAMails->setSelected(item,true); |
1509 | // aEmailsEdit->setText(i18n("(EmptyEmail)")); | 1513 | // aEmailsEdit->setText(i18n("(EmptyEmail)")); |
1510 | } | 1514 | } |
1511 | 1515 | ||
1512 | void KOPrefsDialog::removeItem() | 1516 | void KOPrefsDialog::removeItem() |
1513 | { | 1517 | { |
1514 | // QListViewItem *item; | 1518 | // QListViewItem *item; |
1515 | // item = mAMails->selectedItem(); | 1519 | // item = mAMails->selectedItem(); |
1516 | // if (!item) return; | 1520 | // if (!item) return; |
1517 | // mAMails->takeItem(item); | 1521 | // mAMails->takeItem(item); |
1518 | // item = mAMails->selectedItem(); | 1522 | // item = mAMails->selectedItem(); |
1519 | // if (!item) { | 1523 | // if (!item) { |
1520 | // aEmailsEdit->setText(""); | 1524 | // aEmailsEdit->setText(""); |
1521 | // aEmailsEdit->setEnabled(false); | 1525 | // aEmailsEdit->setEnabled(false); |
1522 | // } | 1526 | // } |
1523 | // if (mAMails->childCount() == 0) { | 1527 | // if (mAMails->childCount() == 0) { |
1524 | // aEmailsEdit->setEnabled(false); | 1528 | // aEmailsEdit->setEnabled(false); |
1525 | // } | 1529 | // } |
1526 | } | 1530 | } |
1527 | 1531 | ||
1528 | void KOPrefsDialog::updateItem() | 1532 | void KOPrefsDialog::updateItem() |
1529 | { | 1533 | { |
1530 | // QListViewItem *item; | 1534 | // QListViewItem *item; |
1531 | // item = mAMails->selectedItem(); | 1535 | // item = mAMails->selectedItem(); |
1532 | // if (!item) return; | 1536 | // if (!item) return; |
1533 | // item->setText(0,aEmailsEdit->text()); | 1537 | // item->setText(0,aEmailsEdit->text()); |
1534 | } | 1538 | } |
1535 | 1539 | ||
1536 | void KOPrefsDialog::updateInput() | 1540 | void KOPrefsDialog::updateInput() |
1537 | { | 1541 | { |
1538 | // QListViewItem *item; | 1542 | // QListViewItem *item; |
1539 | // item = mAMails->selectedItem(); | 1543 | // item = mAMails->selectedItem(); |
1540 | // if (!item) return; | 1544 | // if (!item) return; |
1541 | // aEmailsEdit->setEnabled(true); | 1545 | // aEmailsEdit->setEnabled(true); |
1542 | // aEmailsEdit->setText(item->text(0)); | 1546 | // aEmailsEdit->setText(item->text(0)); |
1543 | } | 1547 | } |
1544 | 1548 | ||