author | zautrix <zautrix> | 2005-07-07 22:22:20 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-07 22:22:20 (UTC) |
commit | 876816e6582299d527610e847d259d2be6de403c (patch) (unidiff) | |
tree | 6683baf2835672d0d9b28b3cbbf90e84c398b835 /korganizer | |
parent | 3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc (diff) | |
download | kdepimpi-876816e6582299d527610e847d259d2be6de403c.zip kdepimpi-876816e6582299d527610e847d259d2be6de403c.tar.gz kdepimpi-876816e6582299d527610e847d259d2be6de403c.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/calendarview.cpp | 64 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 4 | ||||
-rw-r--r-- | korganizer/koagenda.h | 1 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 5 |
4 files changed, 15 insertions, 59 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 426e8f9..2582931 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,2315 +1,2263 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "koagenda.h" | ||
107 | #include "kodialogmanager.h" | 108 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 109 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 110 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 111 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 112 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 113 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 114 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 115 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 116 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 117 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 118 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 119 | #include "mainwindow.h" |
119 | #include "categoryeditdialog.h" | 120 | #include "categoryeditdialog.h" |
120 | 121 | ||
121 | #include "calendarview.h" | 122 | #include "calendarview.h" |
122 | #ifndef DESKTOP_VERSION | 123 | #ifndef DESKTOP_VERSION |
123 | #include <qtopia/alarmserver.h> | 124 | #include <qtopia/alarmserver.h> |
124 | #endif | 125 | #endif |
125 | #ifndef _WIN32_ | 126 | #ifndef _WIN32_ |
126 | #include <stdlib.h> | 127 | #include <stdlib.h> |
127 | #include <stdio.h> | 128 | #include <stdio.h> |
128 | #include <unistd.h> | 129 | #include <unistd.h> |
129 | #else | 130 | #else |
130 | #include <qprocess.h> | 131 | #include <qprocess.h> |
131 | #endif | 132 | #endif |
132 | 133 | ||
133 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
134 | #include <kabc/stdaddressbook.h> | 135 | #include <kabc/stdaddressbook.h> |
135 | #endif | 136 | #endif |
136 | using namespace KOrg; | 137 | using namespace KOrg; |
137 | using namespace KCal; | 138 | using namespace KCal; |
138 | extern int globalFlagBlockAgenda; | 139 | extern int globalFlagBlockAgenda; |
139 | extern int globalFlagBlockStartup; | 140 | extern int globalFlagBlockStartup; |
140 | 141 | ||
141 | 142 | ||
142 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 143 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
143 | 144 | ||
144 | { | 145 | { |
145 | mAlarms = alarms; | 146 | mAlarms = alarms; |
146 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 147 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
147 | QString mText = "<table width=\"100%\">\n"; | 148 | QString mText = "<table width=\"100%\">\n"; |
148 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 149 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
149 | #ifdef DESKTOP_VERSION | 150 | #ifdef DESKTOP_VERSION |
150 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
151 | #else | 152 | #else |
152 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 153 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
153 | #endif | 154 | #endif |
154 | // mText += "<img src=\""; | 155 | // mText += "<img src=\""; |
155 | // mText += ipath; | 156 | // mText += ipath; |
156 | // mText += "\">"; | 157 | // mText += "\">"; |
157 | //mEventDate = QDate::currentDate(); | 158 | //mEventDate = QDate::currentDate(); |
158 | #ifdef DESKTOP_VERSION | 159 | #ifdef DESKTOP_VERSION |
159 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
160 | #else | 161 | #else |
161 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 162 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
162 | #endif | 163 | #endif |
163 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 164 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
164 | 165 | ||
165 | Incidence * inc = getNextInc( start ); | 166 | Incidence * inc = getNextInc( start ); |
166 | int time = 0; | 167 | int time = 0; |
167 | //mText += "<table>"; | 168 | //mText += "<table>"; |
168 | while ( inc ) { | 169 | while ( inc ) { |
169 | QDateTime dt ; | 170 | QDateTime dt ; |
170 | QString tempText = "<a "; | 171 | QString tempText = "<a "; |
171 | bool ok; | 172 | bool ok; |
172 | dt = inc->getNextOccurence( start, &ok ); | 173 | dt = inc->getNextOccurence( start, &ok ); |
173 | if ( !ok ) continue; | 174 | if ( !ok ) continue; |
174 | if ( inc->typeID() == eventID ) { | 175 | if ( inc->typeID() == eventID ) { |
175 | tempText += "href=\"event:"; | 176 | tempText += "href=\"event:"; |
176 | } else if ( inc->typeID() == todoID ) { | 177 | } else if ( inc->typeID() == todoID ) { |
177 | tempText += "href=\"todo:"; | 178 | tempText += "href=\"todo:"; |
178 | } | 179 | } |
179 | tempText += inc->uid() + "\">"; | 180 | tempText += inc->uid() + "\">"; |
180 | if ( inc->typeID() == todoID ) | 181 | if ( inc->typeID() == todoID ) |
181 | tempText += i18n("Todo: "); | 182 | tempText += i18n("Todo: "); |
182 | if ( inc->summary().length() > 0 ) | 183 | if ( inc->summary().length() > 0 ) |
183 | tempText += inc->summary(); | 184 | tempText += inc->summary(); |
184 | else | 185 | else |
185 | tempText += i18n("-no summary-"); | 186 | tempText += i18n("-no summary-"); |
186 | QString timestr; | 187 | QString timestr; |
187 | if (!inc->doesFloat()) | 188 | if (!inc->doesFloat()) |
188 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
189 | else | 190 | else |
190 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 191 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
191 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 192 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
192 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 193 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
193 | mText += "<table>"; | 194 | mText += "<table>"; |
194 | time = 1; | 195 | time = 1; |
195 | } | 196 | } |
196 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 197 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
197 | if ( time > 0 ) | 198 | if ( time > 0 ) |
198 | mText +="</table>"; | 199 | mText +="</table>"; |
199 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 200 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
200 | mText += "<table>"; | 201 | mText += "<table>"; |
201 | time = 2; | 202 | time = 2; |
202 | 203 | ||
203 | } | 204 | } |
204 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 205 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
205 | if ( time > 0 ) | 206 | if ( time > 0 ) |
206 | mText +="</table>"; | 207 | mText +="</table>"; |
207 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 208 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
208 | mText += "<table>"; | 209 | mText += "<table>"; |
209 | time = 3; | 210 | time = 3; |
210 | } | 211 | } |
211 | mText +="<tr><td><b>"; | 212 | mText +="<tr><td><b>"; |
212 | mText += timestr; | 213 | mText += timestr; |
213 | mText += "</b></td><td>"; | 214 | mText += "</b></td><td>"; |
214 | mText += tempText; | 215 | mText += tempText; |
215 | mText += "</td></tr>\n"; | 216 | mText += "</td></tr>\n"; |
216 | inc = getNextInc( start ); | 217 | inc = getNextInc( start ); |
217 | } | 218 | } |
218 | mText +="</table>"; | 219 | mText +="</table>"; |
219 | setText( mText ); | 220 | setText( mText ); |
220 | } | 221 | } |
221 | 222 | ||
222 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
223 | { | 224 | { |
224 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
225 | } | 226 | } |
226 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
227 | { | 228 | { |
228 | QDateTime dt ; | 229 | QDateTime dt ; |
229 | Incidence * retInc; | 230 | Incidence * retInc; |
230 | Incidence * inc = mAlarms.first(); | 231 | Incidence * inc = mAlarms.first(); |
231 | if ( inc == 0 ) | 232 | if ( inc == 0 ) |
232 | return 0; | 233 | return 0; |
233 | bool ok; | 234 | bool ok; |
234 | dt = inc->getNextOccurence( start, &ok ); | 235 | dt = inc->getNextOccurence( start, &ok ); |
235 | if ( ! ok ) return 0; | 236 | if ( ! ok ) return 0; |
236 | QDateTime dtn ; | 237 | QDateTime dtn ; |
237 | retInc = inc; | 238 | retInc = inc; |
238 | inc = mAlarms.next(); | 239 | inc = mAlarms.next(); |
239 | while ( inc ) { | 240 | while ( inc ) { |
240 | dtn = inc->getNextOccurence( start, &ok ); | 241 | dtn = inc->getNextOccurence( start, &ok ); |
241 | if ( ! ok ) return 0; | 242 | if ( ! ok ) return 0; |
242 | if ( dtn < dt ) { | 243 | if ( dtn < dt ) { |
243 | dt = dtn; | 244 | dt = dtn; |
244 | retInc = inc; | 245 | retInc = inc; |
245 | } | 246 | } |
246 | inc = mAlarms.next(); | 247 | inc = mAlarms.next(); |
247 | } | 248 | } |
248 | mAlarms.remove( retInc ); | 249 | mAlarms.remove( retInc ); |
249 | return retInc; | 250 | return retInc; |
250 | 251 | ||
251 | } | 252 | } |
252 | void MissedAlarmTextBrowser::setSource(const QString & n) | 253 | void MissedAlarmTextBrowser::setSource(const QString & n) |
253 | { | 254 | { |
254 | if (n.startsWith("event:")) { | 255 | if (n.startsWith("event:")) { |
255 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
256 | emit showIncidence(n.mid(8)); | 257 | emit showIncidence(n.mid(8)); |
257 | #else | 258 | #else |
258 | emit showIncidence(n.mid(6)); | 259 | emit showIncidence(n.mid(6)); |
259 | #endif | 260 | #endif |
260 | return; | 261 | return; |
261 | } else if (n.startsWith("todo:")) { | 262 | } else if (n.startsWith("todo:")) { |
262 | #ifdef DESKTOP_VERSION | 263 | #ifdef DESKTOP_VERSION |
263 | emit showIncidence(n.mid(7)); | 264 | emit showIncidence(n.mid(7)); |
264 | #else | 265 | #else |
265 | emit showIncidence(n.mid(5)); | 266 | emit showIncidence(n.mid(5)); |
266 | #endif | 267 | #endif |
267 | return; | 268 | return; |
268 | } | 269 | } |
269 | } | 270 | } |
270 | 271 | ||
271 | 272 | ||
272 | class KOBeamPrefs : public QDialog | 273 | class KOBeamPrefs : public QDialog |
273 | { | 274 | { |
274 | public: | 275 | public: |
275 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
276 | QDialog( parent, name, true ) | 277 | QDialog( parent, name, true ) |
277 | { | 278 | { |
278 | setCaption( i18n("Beam Options") ); | 279 | setCaption( i18n("Beam Options") ); |
279 | QVBoxLayout* lay = new QVBoxLayout( this ); | 280 | QVBoxLayout* lay = new QVBoxLayout( this ); |
280 | lay->setSpacing( 3 ); | 281 | lay->setSpacing( 3 ); |
281 | lay->setMargin( 3 ); | 282 | lay->setMargin( 3 ); |
282 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
283 | lay->addWidget( format ); | 284 | lay->addWidget( format ); |
284 | format->setExclusive ( true ) ; | 285 | format->setExclusive ( true ) ; |
285 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
286 | lay->addWidget( time ); time->setExclusive ( true ) ; | 287 | lay->addWidget( time ); time->setExclusive ( true ) ; |
287 | vcal = new QRadioButton(" vCalendar ", format ); | 288 | vcal = new QRadioButton(" vCalendar ", format ); |
288 | ical = new QRadioButton(" iCalendar ", format ); | 289 | ical = new QRadioButton(" iCalendar ", format ); |
289 | vcal->setChecked( true ); | 290 | vcal->setChecked( true ); |
290 | tz = new QRadioButton(i18n(" With timezone "), time ); | 291 | tz = new QRadioButton(i18n(" With timezone "), time ); |
291 | local = new QRadioButton(i18n(" Local time "), time ); | 292 | local = new QRadioButton(i18n(" Local time "), time ); |
292 | tz->setChecked( true ); | 293 | tz->setChecked( true ); |
293 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
294 | lay->addWidget( ok ); | 295 | lay->addWidget( ok ); |
295 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
296 | lay->addWidget( cancel ); | 297 | lay->addWidget( cancel ); |
297 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
298 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
299 | resize( 200, 200 ); | 300 | resize( 200, 200 ); |
300 | } | 301 | } |
301 | 302 | ||
302 | bool beamVcal() { return vcal->isChecked(); } | 303 | bool beamVcal() { return vcal->isChecked(); } |
303 | bool beamLocal() { return local->isChecked(); } | 304 | bool beamLocal() { return local->isChecked(); } |
304 | private: | 305 | private: |
305 | QRadioButton* vcal, *ical, *local, *tz; | 306 | QRadioButton* vcal, *ical, *local, *tz; |
306 | }; | 307 | }; |
307 | class KOCatPrefs : public QDialog | 308 | class KOCatPrefs : public QDialog |
308 | { | 309 | { |
309 | public: | 310 | public: |
310 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
311 | QDialog( parent, name, true ) | 312 | QDialog( parent, name, true ) |
312 | { | 313 | { |
313 | setCaption( i18n("Manage new Categories") ); | 314 | setCaption( i18n("Manage new Categories") ); |
314 | QVBoxLayout* lay = new QVBoxLayout( this ); | 315 | QVBoxLayout* lay = new QVBoxLayout( this ); |
315 | lay->setSpacing( 3 ); | 316 | lay->setSpacing( 3 ); |
316 | lay->setMargin( 3 ); | 317 | 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 ); | 318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); |
318 | lay->addWidget( lab ); | 319 | lay->addWidget( lab ); |
319 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
320 | lay->addWidget( format ); | 321 | lay->addWidget( format ); |
321 | format->setExclusive ( true ) ; | 322 | format->setExclusive ( true ) ; |
322 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
323 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
324 | addCatBut->setChecked( true ); | 325 | addCatBut->setChecked( true ); |
325 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
326 | lay->addWidget( ok ); | 327 | lay->addWidget( ok ); |
327 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
328 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
329 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
330 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
331 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
332 | } | 333 | } |
333 | 334 | ||
334 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
335 | private: | 336 | private: |
336 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
337 | }; | 338 | }; |
338 | 339 | ||
339 | 340 | ||
340 | 341 | ||
341 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
342 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
343 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
344 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
345 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
346 | { | 347 | { |
347 | 348 | ||
348 | mEventEditor = 0; | 349 | mEventEditor = 0; |
349 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
350 | 351 | ||
351 | init(); | 352 | init(); |
352 | } | 353 | } |
353 | 354 | ||
354 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
355 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
356 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
357 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
358 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
359 | { | 360 | { |
360 | 361 | ||
361 | mEventEditor = 0; | 362 | mEventEditor = 0; |
362 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
363 | init(); | 364 | init(); |
364 | } | 365 | } |
365 | 366 | ||
366 | void CalendarView::init() | 367 | void CalendarView::init() |
367 | { | 368 | { |
368 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 369 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
369 | setFocusPolicy ( NoFocus ); | 370 | setFocusPolicy ( NoFocus ); |
370 | mViewerCallerIsSearchDialog = false; | 371 | mViewerCallerIsSearchDialog = false; |
371 | mBlockShowDates = false; | 372 | mBlockShowDates = false; |
372 | 373 | ||
373 | mDatePickerMode = 0; | 374 | mDatePickerMode = 0; |
374 | mCurrentSyncDevice = ""; | 375 | mCurrentSyncDevice = ""; |
375 | mViewManager = new KOViewManager( this ); | 376 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 377 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 378 | mEventViewerDialog = 0; |
378 | mModified = false; | 379 | mModified = false; |
379 | mReadOnly = false; | 380 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 381 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 382 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 383 | mFilters.setAutoDelete(true); |
383 | 384 | ||
384 | mCalendar->registerObserver( this ); | 385 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 386 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 387 | ||
387 | mStorage = new FileStorage( mCalendar ); | 388 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 390 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 392 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 393 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 395 | topLayout->addWidget(mPanner); |
395 | 396 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 398 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 400 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 402 | "CalendarView::DateNavigator" ); |
402 | 403 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 406 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 408 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 409 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 410 | mResourceView = 0; |
410 | #else | 411 | #else |
411 | if ( mResourceManager ) { | 412 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 414 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 415 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 416 | SLOT( updateView() ) ); |
416 | } else { | 417 | } else { |
417 | mResourceView = 0; | 418 | mResourceView = 0; |
418 | } | 419 | } |
419 | #endif | 420 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 421 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 423 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 424 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 425 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 426 | ||
426 | mLeftFrame = mLeftSplitter; | 427 | mLeftFrame = mLeftSplitter; |
427 | #else | 428 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 429 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 430 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 431 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 432 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 433 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 439 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 440 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 446 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 448 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 449 | topLayout->addWidget( mMainFrame ); |
449 | #ifdef DESKTOP_VERSION | 450 | #ifdef DESKTOP_VERSION |
450 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); |
451 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
452 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
453 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
454 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
455 | #endif | 456 | #endif |
456 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
457 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
458 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
459 | #if 0 | 460 | #if 0 |
460 | // FIXME | 461 | // FIXME |
461 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
462 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
463 | #endif | 464 | #endif |
464 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
465 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
466 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
467 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
468 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
469 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
470 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
475 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
476 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
477 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
478 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
479 | 480 | ||
480 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
481 | #if 0 | 482 | #if 0 |
482 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
483 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
484 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
485 | 486 | ||
486 | } else { | 487 | } else { |
487 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
488 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
489 | } | 490 | } |
490 | #endif | 491 | #endif |
491 | mFilterView->hide(); | 492 | mFilterView->hide(); |
492 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
493 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
494 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
495 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
496 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
497 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
498 | 499 | ||
499 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
500 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
501 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
502 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
503 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
504 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | } else { | 506 | } else { |
506 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
507 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | } | 510 | } |
510 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
511 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
512 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
513 | #endif | 514 | #endif |
514 | 515 | ||
515 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
516 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
517 | 518 | ||
518 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
519 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
520 | 521 | ||
521 | 522 | ||
522 | 523 | ||
523 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
524 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
525 | 526 | ||
526 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
527 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
528 | 529 | ||
529 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
530 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
531 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
532 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
533 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
534 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
535 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
536 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
537 | 538 | ||
538 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
539 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
540 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
541 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
542 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
543 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
544 | 545 | ||
545 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
546 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
547 | #if 0 | 548 | #if 0 |
548 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
549 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
550 | #endif | 551 | #endif |
551 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
552 | 553 | ||
553 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
554 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
555 | 556 | ||
556 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
557 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
558 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
559 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
560 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
561 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
562 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
563 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
564 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
565 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
566 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
567 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
568 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
569 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
570 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
571 | 572 | ||
572 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
573 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
574 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
575 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
576 | 577 | ||
577 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
578 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
579 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
580 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
581 | 582 | ||
582 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
583 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
584 | 585 | ||
585 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
586 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
587 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
588 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
589 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
590 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
591 | 592 | ||
592 | 593 | ||
593 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
594 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
595 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
596 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
597 | 598 | ||
598 | 599 | ||
599 | 600 | ||
600 | 601 | ||
601 | 602 | ||
602 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
603 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
604 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
605 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
606 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
607 | 608 | ||
608 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
609 | 610 | ||
610 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
611 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
612 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
613 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
614 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
615 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
616 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
617 | 618 | ||
618 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
619 | 620 | ||
620 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
621 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
622 | 623 | ||
623 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
624 | 625 | ||
625 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
626 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
627 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
628 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
629 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
630 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
631 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
632 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
633 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
634 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
635 | 636 | ||
636 | 637 | ||
637 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
638 | //US listen for arriving address resultsets | 639 | //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&)), | 640 | 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&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
641 | #endif | 642 | #endif |
642 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
643 | } | 644 | } |
644 | 645 | ||
645 | 646 | ||
646 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
647 | { | 648 | { |
648 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
649 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
650 | delete mDialogManager; | 651 | delete mDialogManager; |
651 | delete mViewManager; | 652 | delete mViewManager; |
652 | delete mStorage; | 653 | delete mStorage; |
653 | delete mDateFrame ; | 654 | delete mDateFrame ; |
654 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
655 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
656 | } | 657 | } |
657 | void CalendarView::nextConflict( bool all, bool allday ) | 658 | void CalendarView::nextConflict( bool all, bool allday ) |
658 | { | 659 | { |
659 | 660 | ||
660 | QPtrList<Event> testlist = mCalendar->events(); | 661 | QPtrList<Event> testlist = mCalendar->events(); |
661 | Event * test = testlist.first(); | 662 | Event * test = testlist.first(); |
662 | while ( test ) { | 663 | while ( test ) { |
663 | test->setTagged( false ); | 664 | test->setTagged( false ); |
664 | test = testlist.next(); | 665 | test = testlist.next(); |
665 | } | 666 | } |
666 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first().addDays(1), QTime ( 0,0,0)); | 667 | QTime st ( 0,0,0); |
668 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | ||
669 | st = mViewManager->agendaView()->agenda()->getEndTime(); | ||
670 | //qDebug("time %s ", st.toString().latin1()); | ||
671 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | ||
667 | QDateTime conflict; | 672 | QDateTime conflict; |
668 | QDateTime retVal; | 673 | QDateTime retVal; |
669 | bool found = false; | 674 | bool found = false; |
670 | Event * cE = 0; | 675 | Event * cE = 0; |
671 | Event * cE2 = 0; | 676 | Event * cE2 = 0; |
672 | QPtrList<Event> testlist2 = testlist; | 677 | QPtrList<Event> testlist2 = testlist; |
673 | test = testlist.first(); | 678 | test = testlist.first(); |
674 | bool skip = false; | 679 | bool skip = false; |
675 | while ( test ) { | 680 | while ( test ) { |
676 | skip = false; | 681 | skip = false; |
677 | if ( !all ) skip = ( allday != test->doesFloat() ); | 682 | if ( !all ) skip = ( allday != test->doesFloat() ); |
678 | if ( !skip ) { | 683 | if ( !skip ) { |
679 | Event * test2 = testlist2.first(); | 684 | Event * test2 = testlist2.first(); |
680 | while ( test2 ) { | 685 | while ( test2 ) { |
681 | skip = false; | 686 | skip = false; |
682 | if ( !all ) skip = ( allday != test2->doesFloat() ); | 687 | if ( !all ) skip = ( allday != test2->doesFloat() ); |
683 | if ( !skip ) { | 688 | if ( !skip ) { |
684 | if ( !test2->isTagged() ) { | 689 | if ( !test2->isTagged() ) { |
685 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 690 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
686 | //qDebug("overlap "); | 691 | //qDebug("overlap "); |
687 | if ( ! found ) { | 692 | if ( ! found ) { |
688 | if ( retVal >= startDT ) { | 693 | if ( retVal >= startDT ) { |
689 | conflict = retVal; | 694 | conflict = retVal; |
690 | cE = test; | 695 | cE = test; |
691 | cE2 = test2; | 696 | cE2 = test2; |
692 | found = true; | 697 | found = true; |
693 | } | 698 | } |
694 | } else { | 699 | } else { |
695 | if ( retVal >= startDT && retVal < conflict ) { | 700 | if ( retVal >= startDT && retVal < conflict ) { |
696 | conflict = retVal; | 701 | conflict = retVal; |
697 | cE = test; | 702 | cE = test; |
698 | cE2 = test2; | 703 | cE2 = test2; |
699 | } | 704 | } |
700 | } | 705 | } |
701 | } | 706 | } |
702 | } | 707 | } |
703 | } | 708 | } |
704 | test2 = testlist2.next(); | 709 | test2 = testlist2.next(); |
705 | } | 710 | } |
706 | } | 711 | } |
707 | test->setTagged( true ); | 712 | test->setTagged( true ); |
708 | test = testlist.next(); | 713 | test = testlist.next(); |
709 | } | 714 | } |
710 | if ( found ) { | 715 | if ( found ) { |
711 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 716 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
712 | mViewManager->showDayView(); | 717 | mViewManager->showDayView(); |
713 | mNavigator->slotDaySelect( conflict.date() ); | 718 | mNavigator->slotDaySelect( conflict.date() ); |
714 | int hour = conflict.time().hour(); | 719 | int hour = conflict.time().hour(); |
715 | mViewManager->agendaView()->setStartHour( hour ); | 720 | mViewManager->agendaView()->setStartHour( hour ); |
716 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 721 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
717 | return; | 722 | return; |
718 | } | 723 | } |
719 | 724 | ||
720 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 725 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
721 | qDebug("No conflict found "); | 726 | qDebug("No conflict found "); |
722 | return; | 727 | return; |
723 | |||
724 | |||
725 | |||
726 | |||
727 | |||
728 | #if 0 | ||
729 | |||
730 | |||
731 | QDate end = start.addDays( 365*2); | ||
732 | while ( start < end ) { | ||
733 | QPtrList<Event> eventList = calendar()->events( start ); | ||
734 | Event * ev = eventList.first(); | ||
735 | QPtrList<Event> test = eventList; | ||
736 | while ( ev ) { | ||
737 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); | ||
738 | Event * t_ev = test.first(); | ||
739 | QDateTime es = ev->dtStart(); | ||
740 | QDateTime ee = ev->dtEnd(); | ||
741 | if ( ev->doesFloat() ) | ||
742 | ee = ee.addDays( 1 ); | ||
743 | if ( ! all ) { | ||
744 | if ( ev->doesFloat() != allday ) | ||
745 | t_ev = 0; | ||
746 | } | ||
747 | while ( t_ev ) { | ||
748 | bool skip = false; | ||
749 | if ( ! all ) { | ||
750 | if ( t_ev->doesFloat() != allday ) | ||
751 | skip = true; | ||
752 | } | ||
753 | if ( !skip && ev != t_ev ) { | ||
754 | QDateTime ets = t_ev->dtStart(); | ||
755 | QDateTime ete = t_ev->dtEnd(); | ||
756 | if ( t_ev->doesFloat() ) | ||
757 | ete = ete.addDays( 1 ); | ||
758 | //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); | ||
759 | if ( es < ete && ets < ee ) { | ||
760 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | ||
761 | mViewManager->showDayView(); | ||
762 | mNavigator->slotDaySelect( start ); | ||
763 | int hour = es.time().hour(); | ||
764 | if ( ets > es ) | ||
765 | hour = ets.time().hour(); | ||
766 | mViewManager->agendaView()->setStartHour( hour ); | ||
767 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); | ||
768 | return; | ||
769 | } | ||
770 | } | ||
771 | t_ev = test.next(); | ||
772 | } | ||
773 | ev = eventList.next(); | ||
774 | } | ||
775 | start = start.addDays( 1 ); | ||
776 | } | ||
777 | topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); | ||
778 | qDebug("No conflict found "); | ||
779 | #endif | ||
780 | } | 728 | } |
781 | 729 | ||
782 | void CalendarView::conflictAll() | 730 | void CalendarView::conflictAll() |
783 | { | 731 | { |
784 | nextConflict ( true, true ); | 732 | nextConflict ( true, true ); |
785 | } | 733 | } |
786 | void CalendarView::conflictAllday() | 734 | void CalendarView::conflictAllday() |
787 | { | 735 | { |
788 | nextConflict ( false, true ); | 736 | nextConflict ( false, true ); |
789 | } | 737 | } |
790 | void CalendarView::conflictNotAll() | 738 | void CalendarView::conflictNotAll() |
791 | { | 739 | { |
792 | nextConflict ( false, false ); | 740 | nextConflict ( false, false ); |
793 | } | 741 | } |
794 | 742 | ||
795 | void CalendarView::setCalReadOnly( int id, bool readO ) | 743 | void CalendarView::setCalReadOnly( int id, bool readO ) |
796 | { | 744 | { |
797 | if ( readO ) { | 745 | if ( readO ) { |
798 | emit save(); | 746 | emit save(); |
799 | } | 747 | } |
800 | mCalendar->setReadOnly( id, readO ); | 748 | mCalendar->setReadOnly( id, readO ); |
801 | } | 749 | } |
802 | void CalendarView::setScrollBarStep(int val ) | 750 | void CalendarView::setScrollBarStep(int val ) |
803 | { | 751 | { |
804 | #ifdef DESKTOP_VERSION | 752 | #ifdef DESKTOP_VERSION |
805 | mDateScrollBar->setLineStep ( val ); | 753 | mDateScrollBar->setLineStep ( val ); |
806 | #endif | 754 | #endif |
807 | } | 755 | } |
808 | void CalendarView::scrollBarValue(int val ) | 756 | void CalendarView::scrollBarValue(int val ) |
809 | { | 757 | { |
810 | #ifdef DESKTOP_VERSION | 758 | #ifdef DESKTOP_VERSION |
811 | if ( QApplication::desktop()->width() < 800 ) return; | 759 | if ( QApplication::desktop()->width() < 800 ) return; |
812 | static bool block = false; | 760 | static bool block = false; |
813 | if ( block ) return; | 761 | if ( block ) return; |
814 | block = true; | 762 | block = true; |
815 | int count = mNavigator->selectedDates().count(); | 763 | int count = mNavigator->selectedDates().count(); |
816 | int day = mNavigator->selectedDates().first().dayOfYear(); | 764 | int day = mNavigator->selectedDates().first().dayOfYear(); |
817 | int stepdays = val; | 765 | int stepdays = val; |
818 | if ( mDateScrollBar->lineStep () <= count ) { | 766 | if ( mDateScrollBar->lineStep () <= count ) { |
819 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 767 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
820 | //qDebug("VAL %d ",val ); | 768 | //qDebug("VAL %d ",val ); |
821 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 769 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
822 | stepdays = day+stepdays; | 770 | stepdays = day+stepdays; |
823 | if ( stepdays < 0 ) stepdays = 0; | 771 | if ( stepdays < 0 ) stepdays = 0; |
824 | } | 772 | } |
825 | if ( stepdays == day ) { | 773 | if ( stepdays == day ) { |
826 | block = false; | 774 | block = false; |
827 | return; | 775 | return; |
828 | } | 776 | } |
829 | int year = mNavigator->selectedDates().first().year(); | 777 | int year = mNavigator->selectedDates().first().year(); |
830 | QDate d ( year,1,1 ); | 778 | QDate d ( year,1,1 ); |
831 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 779 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
832 | block = false; | 780 | block = false; |
833 | #endif | 781 | #endif |
834 | 782 | ||
835 | } | 783 | } |
836 | void CalendarView::updateView(const QDate &start, const QDate &end) | 784 | void CalendarView::updateView(const QDate &start, const QDate &end) |
837 | { | 785 | { |
838 | #ifdef DESKTOP_VERSION | 786 | #ifdef DESKTOP_VERSION |
839 | if ( ! mDateScrollBar->draggingSlider () ) { | 787 | if ( ! mDateScrollBar->draggingSlider () ) { |
840 | int dof = start.dayOfYear(); | 788 | int dof = start.dayOfYear(); |
841 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 789 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
842 | if ( dof != mDateScrollBar->value() ) { | 790 | if ( dof != mDateScrollBar->value() ) { |
843 | mDateScrollBar->blockSignals( true ); | 791 | mDateScrollBar->blockSignals( true ); |
844 | mDateScrollBar->setValue( start.dayOfYear()); | 792 | mDateScrollBar->setValue( start.dayOfYear()); |
845 | mDateScrollBar->blockSignals( false ); | 793 | mDateScrollBar->blockSignals( false ); |
846 | } | 794 | } |
847 | } | 795 | } |
848 | #endif | 796 | #endif |
849 | mTodoList->updateView(); | 797 | mTodoList->updateView(); |
850 | mViewManager->updateView(start, end); | 798 | mViewManager->updateView(start, end); |
851 | //mDateNavigator->updateView(); | 799 | //mDateNavigator->updateView(); |
852 | } | 800 | } |
853 | 801 | ||
854 | 802 | ||
855 | 803 | ||
856 | void CalendarView::checkFiles() | 804 | void CalendarView::checkFiles() |
857 | { | 805 | { |
858 | QString message; | 806 | QString message; |
859 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 807 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
860 | KopiCalendarFile * cal = calendars.first(); | 808 | KopiCalendarFile * cal = calendars.first(); |
861 | while ( cal ) { | 809 | while ( cal ) { |
862 | if ( cal->mErrorOnLoad ) { | 810 | if ( cal->mErrorOnLoad ) { |
863 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 811 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
864 | } | 812 | } |
865 | cal = calendars.next(); | 813 | cal = calendars.next(); |
866 | } | 814 | } |
867 | if ( !message.isEmpty() ) { | 815 | if ( !message.isEmpty() ) { |
868 | 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); | 816 | 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); |
869 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 817 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
870 | } | 818 | } |
871 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 819 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
872 | } | 820 | } |
873 | void CalendarView::checkAlarms() | 821 | void CalendarView::checkAlarms() |
874 | { | 822 | { |
875 | 823 | ||
876 | 824 | ||
877 | KConfig *config = KOGlobals::config(); | 825 | KConfig *config = KOGlobals::config(); |
878 | config->setGroup( "AppRun" ); | 826 | config->setGroup( "AppRun" ); |
879 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 827 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
880 | int daysto = dt.daysTo( QDate::currentDate() ); | 828 | int daysto = dt.daysTo( QDate::currentDate() ); |
881 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 829 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
882 | dt = dt.addDays( days ); | 830 | dt = dt.addDays( days ); |
883 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 831 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
884 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 832 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
885 | //qDebug("KO: Reading program stop %d ", secs); | 833 | //qDebug("KO: Reading program stop %d ", secs); |
886 | //secs -= ( 3600 * 24*3 ); // debug only | 834 | //secs -= ( 3600 * 24*3 ); // debug only |
887 | QDateTime latest = dt.addSecs ( secs ); | 835 | QDateTime latest = dt.addSecs ( secs ); |
888 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 836 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
889 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 837 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
890 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 838 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
891 | QPtrList<Incidence> al; | 839 | QPtrList<Incidence> al; |
892 | Incidence* inL = el.first(); | 840 | Incidence* inL = el.first(); |
893 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 841 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
894 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 842 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
895 | while ( inL ) { | 843 | while ( inL ) { |
896 | bool ok = false; | 844 | bool ok = false; |
897 | int offset = 0; | 845 | int offset = 0; |
898 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 846 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
899 | if ( ok ) { | 847 | if ( ok ) { |
900 | //qDebug("OK %s",next.toString().latin1()); | 848 | //qDebug("OK %s",next.toString().latin1()); |
901 | if ( next < cur ) { | 849 | if ( next < cur ) { |
902 | al.append( inL ); | 850 | al.append( inL ); |
903 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 851 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
904 | } | 852 | } |
905 | } | 853 | } |
906 | inL = el.next(); | 854 | inL = el.next(); |
907 | } | 855 | } |
908 | if ( al.count() ) { | 856 | if ( al.count() ) { |
909 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 857 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
910 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 858 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
911 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 859 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
912 | lay->setSpacing( 0 ); | 860 | lay->setSpacing( 0 ); |
913 | lay->setMargin( 0 ); | 861 | lay->setMargin( 0 ); |
914 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 862 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
915 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 863 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
916 | lay->addWidget( matb ); | 864 | lay->addWidget( matb ); |
917 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 865 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
918 | int wid = 210; | 866 | int wid = 210; |
919 | int x = QApplication::desktop()->width() - wid - 7; | 867 | int x = QApplication::desktop()->width() - wid - 7; |
920 | int y = QApplication::desktop()->height() - wid - 70; | 868 | int y = QApplication::desktop()->height() - wid - 70; |
921 | dia->setGeometry ( x,y,wid,wid); | 869 | dia->setGeometry ( x,y,wid,wid); |
922 | } else { | 870 | } else { |
923 | int si = 220; | 871 | int si = 220; |
924 | if ( QApplication::desktop()->width() > 470 ) | 872 | if ( QApplication::desktop()->width() > 470 ) |
925 | si = 400; | 873 | si = 400; |
926 | dia->resize(si,si/2); | 874 | dia->resize(si,si/2); |
927 | } | 875 | } |
928 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 876 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
929 | dia->show(); | 877 | dia->show(); |
930 | 878 | ||
931 | } | 879 | } |
932 | } | 880 | } |
933 | void CalendarView::showDay( QDate d ) | 881 | void CalendarView::showDay( QDate d ) |
934 | { | 882 | { |
935 | dateNavigator()->blockSignals( true ); | 883 | dateNavigator()->blockSignals( true ); |
936 | dateNavigator()->selectDate( d ); | 884 | dateNavigator()->selectDate( d ); |
937 | dateNavigator()->blockSignals( false ); | 885 | dateNavigator()->blockSignals( false ); |
938 | mViewManager->showDayView(); | 886 | mViewManager->showDayView(); |
939 | //dateNavigator()->selectDate( d ); | 887 | //dateNavigator()->selectDate( d ); |
940 | } | 888 | } |
941 | void CalendarView::timerAlarm() | 889 | void CalendarView::timerAlarm() |
942 | { | 890 | { |
943 | //qDebug("CalendarView::timerAlarm() "); | 891 | //qDebug("CalendarView::timerAlarm() "); |
944 | computeAlarm(mAlarmNotification ); | 892 | computeAlarm(mAlarmNotification ); |
945 | } | 893 | } |
946 | 894 | ||
947 | void CalendarView::suspendAlarm() | 895 | void CalendarView::suspendAlarm() |
948 | { | 896 | { |
949 | //qDebug(" CalendarView::suspendAlarm() "); | 897 | //qDebug(" CalendarView::suspendAlarm() "); |
950 | computeAlarm(mSuspendAlarmNotification ); | 898 | computeAlarm(mSuspendAlarmNotification ); |
951 | 899 | ||
952 | } | 900 | } |
953 | 901 | ||
954 | void CalendarView::startAlarm( QString mess , QString filename) | 902 | void CalendarView::startAlarm( QString mess , QString filename) |
955 | { | 903 | { |
956 | 904 | ||
957 | topLevelWidget()->showNormal(); | 905 | topLevelWidget()->showNormal(); |
958 | topLevelWidget()->setActiveWindow(); | 906 | topLevelWidget()->setActiveWindow(); |
959 | topLevelWidget()->raise(); | 907 | topLevelWidget()->raise(); |
960 | 908 | ||
961 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 909 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
962 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 910 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
963 | 911 | ||
964 | } | 912 | } |
965 | 913 | ||
966 | void CalendarView::checkNextTimerAlarm() | 914 | void CalendarView::checkNextTimerAlarm() |
967 | { | 915 | { |
968 | mCalendar->checkAlarmForIncidence( 0, true ); | 916 | mCalendar->checkAlarmForIncidence( 0, true ); |
969 | } | 917 | } |
970 | 918 | ||
971 | void CalendarView::computeAlarm( QString msg ) | 919 | void CalendarView::computeAlarm( QString msg ) |
972 | { | 920 | { |
973 | 921 | ||
974 | QString mess = msg; | 922 | QString mess = msg; |
975 | QString mAlarmMessage = mess.mid( 9 ); | 923 | QString mAlarmMessage = mess.mid( 9 ); |
976 | QString filename = MainWindow::resourcePath(); | 924 | QString filename = MainWindow::resourcePath(); |
977 | filename += "koalarm.wav"; | 925 | filename += "koalarm.wav"; |
978 | QString tempfilename; | 926 | QString tempfilename; |
979 | if ( mess.left( 13 ) == "suspend_alarm") { | 927 | if ( mess.left( 13 ) == "suspend_alarm") { |
980 | bool error = false; | 928 | bool error = false; |
981 | int len = mess.mid( 13 ).find("+++"); | 929 | int len = mess.mid( 13 ).find("+++"); |
982 | if ( len < 2 ) | 930 | if ( len < 2 ) |
983 | error = true; | 931 | error = true; |
984 | else { | 932 | else { |
985 | tempfilename = mess.mid( 13, len ); | 933 | tempfilename = mess.mid( 13, len ); |
986 | if ( !QFile::exists( tempfilename ) ) | 934 | if ( !QFile::exists( tempfilename ) ) |
987 | error = true; | 935 | error = true; |
988 | } | 936 | } |
989 | if ( ! error ) { | 937 | if ( ! error ) { |
990 | filename = tempfilename; | 938 | filename = tempfilename; |
991 | } | 939 | } |
992 | mAlarmMessage = mess.mid( 13+len+3 ); | 940 | mAlarmMessage = mess.mid( 13+len+3 ); |
993 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 941 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
994 | startAlarm( mAlarmMessage, filename); | 942 | startAlarm( mAlarmMessage, filename); |
995 | return; | 943 | return; |
996 | } | 944 | } |
997 | if ( mess.left( 11 ) == "timer_alarm") { | 945 | if ( mess.left( 11 ) == "timer_alarm") { |
998 | //mTimerTime = 0; | 946 | //mTimerTime = 0; |
999 | startAlarm( mess.mid( 11 ), filename ); | 947 | startAlarm( mess.mid( 11 ), filename ); |
1000 | return; | 948 | return; |
1001 | } | 949 | } |
1002 | if ( mess.left( 10 ) == "proc_alarm") { | 950 | if ( mess.left( 10 ) == "proc_alarm") { |
1003 | bool error = false; | 951 | bool error = false; |
1004 | int len = mess.mid( 10 ).find("+++"); | 952 | int len = mess.mid( 10 ).find("+++"); |
1005 | if ( len < 2 ) | 953 | if ( len < 2 ) |
1006 | error = true; | 954 | error = true; |
1007 | else { | 955 | else { |
1008 | tempfilename = mess.mid( 10, len ); | 956 | tempfilename = mess.mid( 10, len ); |
1009 | if ( !QFile::exists( tempfilename ) ) | 957 | if ( !QFile::exists( tempfilename ) ) |
1010 | error = true; | 958 | error = true; |
1011 | } | 959 | } |
1012 | if ( error ) { | 960 | if ( error ) { |
1013 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 961 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1014 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 962 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1015 | } else { | 963 | } else { |
1016 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 964 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1017 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 965 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1018 | #ifndef _WIN32_ | 966 | #ifndef _WIN32_ |
1019 | if ( vfork () == 0 ) { | 967 | if ( vfork () == 0 ) { |
1020 | execl ( tempfilename.latin1(), 0 ); | 968 | execl ( tempfilename.latin1(), 0 ); |
1021 | return; | 969 | return; |
1022 | } | 970 | } |
1023 | #else | 971 | #else |
1024 | QProcess* p = new QProcess(); | 972 | QProcess* p = new QProcess(); |
1025 | p->addArgument( tempfilename.latin1() ); | 973 | p->addArgument( tempfilename.latin1() ); |
1026 | p->start(); | 974 | p->start(); |
1027 | return; | 975 | return; |
1028 | #endif | 976 | #endif |
1029 | 977 | ||
1030 | return; | 978 | return; |
1031 | } | 979 | } |
1032 | 980 | ||
1033 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 981 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1034 | } | 982 | } |
1035 | if ( mess.left( 11 ) == "audio_alarm") { | 983 | if ( mess.left( 11 ) == "audio_alarm") { |
1036 | bool error = false; | 984 | bool error = false; |
1037 | int len = mess.mid( 11 ).find("+++"); | 985 | int len = mess.mid( 11 ).find("+++"); |
1038 | if ( len < 2 ) | 986 | if ( len < 2 ) |
1039 | error = true; | 987 | error = true; |
1040 | else { | 988 | else { |
1041 | tempfilename = mess.mid( 11, len ); | 989 | tempfilename = mess.mid( 11, len ); |
1042 | if ( !QFile::exists( tempfilename ) ) | 990 | if ( !QFile::exists( tempfilename ) ) |
1043 | error = true; | 991 | error = true; |
1044 | } | 992 | } |
1045 | if ( ! error ) { | 993 | if ( ! error ) { |
1046 | filename = tempfilename; | 994 | filename = tempfilename; |
1047 | } | 995 | } |
1048 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 996 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1049 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 997 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1050 | } | 998 | } |
1051 | if ( mess.left( 9 ) == "cal_alarm") { | 999 | if ( mess.left( 9 ) == "cal_alarm") { |
1052 | mAlarmMessage = mess.mid( 9 ) ; | 1000 | mAlarmMessage = mess.mid( 9 ) ; |
1053 | } | 1001 | } |
1054 | 1002 | ||
1055 | startAlarm( mAlarmMessage, filename ); | 1003 | startAlarm( mAlarmMessage, filename ); |
1056 | 1004 | ||
1057 | 1005 | ||
1058 | } | 1006 | } |
1059 | 1007 | ||
1060 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1008 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1061 | { | 1009 | { |
1062 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1010 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1063 | 1011 | ||
1064 | mSuspendAlarmNotification = noti; | 1012 | mSuspendAlarmNotification = noti; |
1065 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1013 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1066 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1014 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1067 | mSuspendTimer->start( ms , true ); | 1015 | mSuspendTimer->start( ms , true ); |
1068 | 1016 | ||
1069 | } | 1017 | } |
1070 | 1018 | ||
1071 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1019 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1072 | { | 1020 | { |
1073 | mNextAlarmDateTime = qdt; | 1021 | mNextAlarmDateTime = qdt; |
1074 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1022 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1075 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1023 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1076 | #ifndef DESKTOP_VERSION | 1024 | #ifndef DESKTOP_VERSION |
1077 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1025 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1078 | #endif | 1026 | #endif |
1079 | return; | 1027 | return; |
1080 | } | 1028 | } |
1081 | int maxSec; | 1029 | int maxSec; |
1082 | //maxSec = 5; //testing only | 1030 | //maxSec = 5; //testing only |
1083 | maxSec = 86400+3600; // one day+1hour | 1031 | maxSec = 86400+3600; // one day+1hour |
1084 | mAlarmNotification = noti; | 1032 | mAlarmNotification = noti; |
1085 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1033 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1086 | if ( sec > maxSec ) { | 1034 | if ( sec > maxSec ) { |
1087 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1035 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1088 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1036 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1089 | return; | 1037 | return; |
1090 | } else { | 1038 | } else { |
1091 | mRecheckAlarmTimer->stop(); | 1039 | mRecheckAlarmTimer->stop(); |
1092 | } | 1040 | } |
1093 | //qDebug("Alarm timer started with secs: %d ", sec); | 1041 | //qDebug("Alarm timer started with secs: %d ", sec); |
1094 | mAlarmTimer->start( sec *1000 , true ); | 1042 | mAlarmTimer->start( sec *1000 , true ); |
1095 | 1043 | ||
1096 | } | 1044 | } |
1097 | // called by mRecheckAlarmTimer to get next alarm | 1045 | // called by mRecheckAlarmTimer to get next alarm |
1098 | // we need this, because a QTimer has only a max range of 25 days | 1046 | // we need this, because a QTimer has only a max range of 25 days |
1099 | void CalendarView::recheckTimerAlarm() | 1047 | void CalendarView::recheckTimerAlarm() |
1100 | { | 1048 | { |
1101 | mAlarmTimer->stop(); | 1049 | mAlarmTimer->stop(); |
1102 | mRecheckAlarmTimer->stop(); | 1050 | mRecheckAlarmTimer->stop(); |
1103 | mCalendar->checkAlarmForIncidence( 0, true ); | 1051 | mCalendar->checkAlarmForIncidence( 0, true ); |
1104 | } | 1052 | } |
1105 | #ifndef DESKTOP_VERSION | 1053 | #ifndef DESKTOP_VERSION |
1106 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1054 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1107 | #else | 1055 | #else |
1108 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1056 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1109 | #endif | 1057 | #endif |
1110 | { | 1058 | { |
1111 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1059 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1112 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1060 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1113 | #ifndef DESKTOP_VERSION | 1061 | #ifndef DESKTOP_VERSION |
1114 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1062 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1115 | #endif | 1063 | #endif |
1116 | return; | 1064 | return; |
1117 | } | 1065 | } |
1118 | mAlarmTimer->stop(); | 1066 | mAlarmTimer->stop(); |
1119 | } | 1067 | } |
1120 | void CalendarView::selectWeekNum ( int num ) | 1068 | void CalendarView::selectWeekNum ( int num ) |
1121 | { | 1069 | { |
1122 | dateNavigator()->blockSignals( true ); | 1070 | dateNavigator()->blockSignals( true ); |
1123 | dateNavigator()->selectWeek( num ); | 1071 | dateNavigator()->selectWeek( num ); |
1124 | dateNavigator()->blockSignals( false ); | 1072 | dateNavigator()->blockSignals( false ); |
1125 | mViewManager->showWeekView(); | 1073 | mViewManager->showWeekView(); |
1126 | } | 1074 | } |
1127 | KOViewManager *CalendarView::viewManager() | 1075 | KOViewManager *CalendarView::viewManager() |
1128 | { | 1076 | { |
1129 | return mViewManager; | 1077 | return mViewManager; |
1130 | } | 1078 | } |
1131 | 1079 | ||
1132 | KODialogManager *CalendarView::dialogManager() | 1080 | KODialogManager *CalendarView::dialogManager() |
1133 | { | 1081 | { |
1134 | return mDialogManager; | 1082 | return mDialogManager; |
1135 | } | 1083 | } |
1136 | 1084 | ||
1137 | QDate CalendarView::startDate() | 1085 | QDate CalendarView::startDate() |
1138 | { | 1086 | { |
1139 | DateList dates = mNavigator->selectedDates(); | 1087 | DateList dates = mNavigator->selectedDates(); |
1140 | 1088 | ||
1141 | return dates.first(); | 1089 | return dates.first(); |
1142 | } | 1090 | } |
1143 | 1091 | ||
1144 | QDate CalendarView::endDate() | 1092 | QDate CalendarView::endDate() |
1145 | { | 1093 | { |
1146 | DateList dates = mNavigator->selectedDates(); | 1094 | DateList dates = mNavigator->selectedDates(); |
1147 | 1095 | ||
1148 | return dates.last(); | 1096 | return dates.last(); |
1149 | } | 1097 | } |
1150 | 1098 | ||
1151 | 1099 | ||
1152 | void CalendarView::createPrinter() | 1100 | void CalendarView::createPrinter() |
1153 | { | 1101 | { |
1154 | #ifndef KORG_NOPRINTER | 1102 | #ifndef KORG_NOPRINTER |
1155 | if (!mCalPrinter) { | 1103 | if (!mCalPrinter) { |
1156 | mCalPrinter = new CalPrinter(this, mCalendar); | 1104 | mCalPrinter = new CalPrinter(this, mCalendar); |
1157 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1105 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1158 | } | 1106 | } |
1159 | #endif | 1107 | #endif |
1160 | } | 1108 | } |
1161 | 1109 | ||
1162 | 1110 | ||
1163 | //KOPrefs::instance()->mWriteBackFile | 1111 | //KOPrefs::instance()->mWriteBackFile |
1164 | //KOPrefs::instance()->mWriteBackExistingOnly | 1112 | //KOPrefs::instance()->mWriteBackExistingOnly |
1165 | 1113 | ||
1166 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1114 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1167 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1115 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1168 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1116 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1169 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1117 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1170 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1118 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1171 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1119 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1172 | 1120 | ||
1173 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1121 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1174 | { | 1122 | { |
1175 | 1123 | ||
1176 | // 0 equal | 1124 | // 0 equal |
1177 | // 1 take local | 1125 | // 1 take local |
1178 | // 2 take remote | 1126 | // 2 take remote |
1179 | // 3 cancel | 1127 | // 3 cancel |
1180 | QDateTime lastSync = mLastCalendarSync; | 1128 | QDateTime lastSync = mLastCalendarSync; |
1181 | QDateTime localMod = local->lastModified(); | 1129 | QDateTime localMod = local->lastModified(); |
1182 | QDateTime remoteMod = remote->lastModified(); | 1130 | QDateTime remoteMod = remote->lastModified(); |
1183 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1131 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1184 | bool remCh, locCh; | 1132 | bool remCh, locCh; |
1185 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1133 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1186 | //if ( remCh ) | 1134 | //if ( remCh ) |
1187 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1135 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1188 | locCh = ( localMod > mLastCalendarSync ); | 1136 | locCh = ( localMod > mLastCalendarSync ); |
1189 | if ( !remCh && ! locCh ) { | 1137 | if ( !remCh && ! locCh ) { |
1190 | //qDebug("both not changed "); | 1138 | //qDebug("both not changed "); |
1191 | lastSync = localMod.addDays(1); | 1139 | lastSync = localMod.addDays(1); |
1192 | if ( mode <= SYNC_PREF_ASK ) | 1140 | if ( mode <= SYNC_PREF_ASK ) |
1193 | return 0; | 1141 | return 0; |
1194 | } else { | 1142 | } else { |
1195 | if ( locCh ) { | 1143 | if ( locCh ) { |
1196 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1144 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1197 | lastSync = localMod.addDays( -1 ); | 1145 | lastSync = localMod.addDays( -1 ); |
1198 | if ( !remCh ) | 1146 | if ( !remCh ) |
1199 | remoteMod = ( lastSync.addDays( -1 ) ); | 1147 | remoteMod = ( lastSync.addDays( -1 ) ); |
1200 | } else { | 1148 | } else { |
1201 | //qDebug(" not loc changed "); | 1149 | //qDebug(" not loc changed "); |
1202 | lastSync = localMod.addDays( 1 ); | 1150 | lastSync = localMod.addDays( 1 ); |
1203 | if ( remCh ) | 1151 | if ( remCh ) |
1204 | remoteMod =( lastSync.addDays( 1 ) ); | 1152 | remoteMod =( lastSync.addDays( 1 ) ); |
1205 | 1153 | ||
1206 | } | 1154 | } |
1207 | } | 1155 | } |
1208 | full = true; | 1156 | full = true; |
1209 | if ( mode < SYNC_PREF_ASK ) | 1157 | if ( mode < SYNC_PREF_ASK ) |
1210 | mode = SYNC_PREF_ASK; | 1158 | mode = SYNC_PREF_ASK; |
1211 | } else { | 1159 | } else { |
1212 | if ( localMod == remoteMod ) | 1160 | if ( localMod == remoteMod ) |
1213 | // if ( local->revision() == remote->revision() ) | 1161 | // if ( local->revision() == remote->revision() ) |
1214 | return 0; | 1162 | return 0; |
1215 | 1163 | ||
1216 | } | 1164 | } |
1217 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1165 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1218 | 1166 | ||
1219 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1167 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1220 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1168 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1221 | //full = true; //debug only | 1169 | //full = true; //debug only |
1222 | if ( full ) { | 1170 | if ( full ) { |
1223 | bool equ = false; | 1171 | bool equ = false; |
1224 | if ( local->typeID() == eventID ) { | 1172 | if ( local->typeID() == eventID ) { |
1225 | equ = (*((Event*) local) == *((Event*) remote)); | 1173 | equ = (*((Event*) local) == *((Event*) remote)); |
1226 | } | 1174 | } |
1227 | else if ( local->typeID() == todoID ) | 1175 | else if ( local->typeID() == todoID ) |
1228 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1176 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1229 | else if ( local->typeID() == journalID ) | 1177 | else if ( local->typeID() == journalID ) |
1230 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1178 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1231 | if ( equ ) { | 1179 | if ( equ ) { |
1232 | //qDebug("equal "); | 1180 | //qDebug("equal "); |
1233 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1181 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1234 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1182 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1235 | } | 1183 | } |
1236 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1184 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1237 | return 0; | 1185 | return 0; |
1238 | 1186 | ||
1239 | }//else //debug only | 1187 | }//else //debug only |
1240 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1188 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1241 | } | 1189 | } |
1242 | int result; | 1190 | int result; |
1243 | bool localIsNew; | 1191 | bool localIsNew; |
1244 | //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() ); | 1192 | //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() ); |
1245 | 1193 | ||
1246 | 1194 | ||
1247 | // ************************************************ | 1195 | // ************************************************ |
1248 | // ************************************************ | 1196 | // ************************************************ |
1249 | // ************************************************ | 1197 | // ************************************************ |
1250 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1198 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1251 | // BUT remoteMod != localMod | 1199 | // BUT remoteMod != localMod |
1252 | 1200 | ||
1253 | 1201 | ||
1254 | if ( full && mode < SYNC_PREF_NEWEST ) | 1202 | if ( full && mode < SYNC_PREF_NEWEST ) |
1255 | mode = SYNC_PREF_ASK; | 1203 | mode = SYNC_PREF_ASK; |
1256 | 1204 | ||
1257 | switch( mode ) { | 1205 | switch( mode ) { |
1258 | case SYNC_PREF_LOCAL: | 1206 | case SYNC_PREF_LOCAL: |
1259 | if ( lastSync > remoteMod ) | 1207 | if ( lastSync > remoteMod ) |
1260 | return 1; | 1208 | return 1; |
1261 | if ( lastSync > localMod ) | 1209 | if ( lastSync > localMod ) |
1262 | return 2; | 1210 | return 2; |
1263 | return 1; | 1211 | return 1; |
1264 | break; | 1212 | break; |
1265 | case SYNC_PREF_REMOTE: | 1213 | case SYNC_PREF_REMOTE: |
1266 | if ( lastSync > localMod ) | 1214 | if ( lastSync > localMod ) |
1267 | return 2; | 1215 | return 2; |
1268 | if ( lastSync > remoteMod ) | 1216 | if ( lastSync > remoteMod ) |
1269 | return 1; | 1217 | return 1; |
1270 | return 2; | 1218 | return 2; |
1271 | break; | 1219 | break; |
1272 | case SYNC_PREF_NEWEST: | 1220 | case SYNC_PREF_NEWEST: |
1273 | if ( localMod >= remoteMod ) | 1221 | if ( localMod >= remoteMod ) |
1274 | return 1; | 1222 | return 1; |
1275 | else | 1223 | else |
1276 | return 2; | 1224 | return 2; |
1277 | break; | 1225 | break; |
1278 | case SYNC_PREF_ASK: | 1226 | case SYNC_PREF_ASK: |
1279 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1227 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1280 | if ( lastSync > remoteMod && lastSync > localMod) | 1228 | if ( lastSync > remoteMod && lastSync > localMod) |
1281 | return 0; | 1229 | return 0; |
1282 | if ( lastSync > remoteMod ) | 1230 | if ( lastSync > remoteMod ) |
1283 | return 1; | 1231 | return 1; |
1284 | if ( lastSync > localMod ) | 1232 | if ( lastSync > localMod ) |
1285 | return 2; | 1233 | return 2; |
1286 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1234 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1287 | localIsNew = localMod >= remoteMod; | 1235 | localIsNew = localMod >= remoteMod; |
1288 | if ( localIsNew ) | 1236 | if ( localIsNew ) |
1289 | getEventViewerDialog()->setColorMode( 1 ); | 1237 | getEventViewerDialog()->setColorMode( 1 ); |
1290 | else | 1238 | else |
1291 | getEventViewerDialog()->setColorMode( 2 ); | 1239 | getEventViewerDialog()->setColorMode( 2 ); |
1292 | getEventViewerDialog()->setIncidence(local); | 1240 | getEventViewerDialog()->setIncidence(local); |
1293 | if ( localIsNew ) | 1241 | if ( localIsNew ) |
1294 | getEventViewerDialog()->setColorMode( 2 ); | 1242 | getEventViewerDialog()->setColorMode( 2 ); |
1295 | else | 1243 | else |
1296 | getEventViewerDialog()->setColorMode( 1 ); | 1244 | getEventViewerDialog()->setColorMode( 1 ); |
1297 | getEventViewerDialog()->addIncidence(remote); | 1245 | getEventViewerDialog()->addIncidence(remote); |
1298 | getEventViewerDialog()->setColorMode( 0 ); | 1246 | getEventViewerDialog()->setColorMode( 0 ); |
1299 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1247 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1300 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1248 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1301 | getEventViewerDialog()->showMe(); | 1249 | getEventViewerDialog()->showMe(); |
1302 | result = getEventViewerDialog()->executeS( localIsNew ); | 1250 | result = getEventViewerDialog()->executeS( localIsNew ); |
1303 | return result; | 1251 | return result; |
1304 | 1252 | ||
1305 | break; | 1253 | break; |
1306 | case SYNC_PREF_FORCE_LOCAL: | 1254 | case SYNC_PREF_FORCE_LOCAL: |
1307 | return 1; | 1255 | return 1; |
1308 | break; | 1256 | break; |
1309 | case SYNC_PREF_FORCE_REMOTE: | 1257 | case SYNC_PREF_FORCE_REMOTE: |
1310 | return 2; | 1258 | return 2; |
1311 | break; | 1259 | break; |
1312 | 1260 | ||
1313 | default: | 1261 | default: |
1314 | // SYNC_PREF_TAKE_BOTH not implemented | 1262 | // SYNC_PREF_TAKE_BOTH not implemented |
1315 | break; | 1263 | break; |
1316 | } | 1264 | } |
1317 | return 0; | 1265 | return 0; |
1318 | } | 1266 | } |
1319 | Event* CalendarView::getLastSyncEvent() | 1267 | Event* CalendarView::getLastSyncEvent() |
1320 | { | 1268 | { |
1321 | Event* lse; | 1269 | Event* lse; |
1322 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1270 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1323 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1271 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1324 | if (!lse) { | 1272 | if (!lse) { |
1325 | lse = new Event(); | 1273 | lse = new Event(); |
1326 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1274 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1327 | QString sum = ""; | 1275 | QString sum = ""; |
1328 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1276 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1329 | sum = "E: "; | 1277 | sum = "E: "; |
1330 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1278 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1331 | lse->setDtStart( mLastCalendarSync ); | 1279 | lse->setDtStart( mLastCalendarSync ); |
1332 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1280 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1333 | lse->setCategories( i18n("SyncEvent") ); | 1281 | lse->setCategories( i18n("SyncEvent") ); |
1334 | lse->setReadOnly( true ); | 1282 | lse->setReadOnly( true ); |
1335 | mCalendar->addEvent( lse ); | 1283 | mCalendar->addEvent( lse ); |
1336 | } | 1284 | } |
1337 | 1285 | ||
1338 | return lse; | 1286 | return lse; |
1339 | 1287 | ||
1340 | } | 1288 | } |
1341 | 1289 | ||
1342 | // we check, if the to delete event has a id for a profile | 1290 | // we check, if the to delete event has a id for a profile |
1343 | // if yes, we set this id in the profile to delete | 1291 | // if yes, we set this id in the profile to delete |
1344 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1292 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1345 | { | 1293 | { |
1346 | if ( lastSync.count() == 0 ) { | 1294 | if ( lastSync.count() == 0 ) { |
1347 | //qDebug(" lastSync.count() == 0"); | 1295 | //qDebug(" lastSync.count() == 0"); |
1348 | return; | 1296 | return; |
1349 | } | 1297 | } |
1350 | if ( toDelete->typeID() == journalID ) | 1298 | if ( toDelete->typeID() == journalID ) |
1351 | return; | 1299 | return; |
1352 | 1300 | ||
1353 | Event* eve = lastSync.first(); | 1301 | Event* eve = lastSync.first(); |
1354 | 1302 | ||
1355 | while ( eve ) { | 1303 | while ( eve ) { |
1356 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1304 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1357 | if ( !id.isEmpty() ) { | 1305 | if ( !id.isEmpty() ) { |
1358 | QString des = eve->description(); | 1306 | QString des = eve->description(); |
1359 | QString pref = "e"; | 1307 | QString pref = "e"; |
1360 | if ( toDelete->typeID() == todoID ) | 1308 | if ( toDelete->typeID() == todoID ) |
1361 | pref = "t"; | 1309 | pref = "t"; |
1362 | des += pref+ id + ","; | 1310 | des += pref+ id + ","; |
1363 | eve->setReadOnly( false ); | 1311 | eve->setReadOnly( false ); |
1364 | eve->setDescription( des ); | 1312 | eve->setDescription( des ); |
1365 | //qDebug("setdes %s ", des.latin1()); | 1313 | //qDebug("setdes %s ", des.latin1()); |
1366 | eve->setReadOnly( true ); | 1314 | eve->setReadOnly( true ); |
1367 | } | 1315 | } |
1368 | eve = lastSync.next(); | 1316 | eve = lastSync.next(); |
1369 | } | 1317 | } |
1370 | 1318 | ||
1371 | } | 1319 | } |
1372 | void CalendarView::checkExternalId( Incidence * inc ) | 1320 | void CalendarView::checkExternalId( Incidence * inc ) |
1373 | { | 1321 | { |
1374 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1322 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1375 | checkExternSyncEvent( lastSync, inc ); | 1323 | checkExternSyncEvent( lastSync, inc ); |
1376 | 1324 | ||
1377 | } | 1325 | } |
1378 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1326 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1379 | { | 1327 | { |
1380 | bool syncOK = true; | 1328 | bool syncOK = true; |
1381 | int addedEvent = 0; | 1329 | int addedEvent = 0; |
1382 | int addedEventR = 0; | 1330 | int addedEventR = 0; |
1383 | int deletedEventR = 0; | 1331 | int deletedEventR = 0; |
1384 | int deletedEventL = 0; | 1332 | int deletedEventL = 0; |
1385 | int changedLocal = 0; | 1333 | int changedLocal = 0; |
1386 | int changedRemote = 0; | 1334 | int changedRemote = 0; |
1387 | int filteredIN = 0; | 1335 | int filteredIN = 0; |
1388 | int filteredOUT = 0; | 1336 | int filteredOUT = 0; |
1389 | //QPtrList<Event> el = local->rawEvents(); | 1337 | //QPtrList<Event> el = local->rawEvents(); |
1390 | Event* eventR; | 1338 | Event* eventR; |
1391 | QString uid; | 1339 | QString uid; |
1392 | int take; | 1340 | int take; |
1393 | Event* eventRSync; | 1341 | Event* eventRSync; |
1394 | Event* eventLSync; | 1342 | Event* eventLSync; |
1395 | clearAllViews(); | 1343 | clearAllViews(); |
1396 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1344 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1397 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1345 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1398 | bool fullDateRange = false; | 1346 | bool fullDateRange = false; |
1399 | local->resetTempSyncStat(); | 1347 | local->resetTempSyncStat(); |
1400 | mLastCalendarSync = QDateTime::currentDateTime(); | 1348 | mLastCalendarSync = QDateTime::currentDateTime(); |
1401 | if ( mSyncManager->syncWithDesktop() ) { | 1349 | if ( mSyncManager->syncWithDesktop() ) { |
1402 | remote->resetPilotStat(1); | 1350 | remote->resetPilotStat(1); |
1403 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1351 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1404 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1352 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1405 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1353 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1406 | } else { | 1354 | } else { |
1407 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1355 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1408 | } | 1356 | } |
1409 | } | 1357 | } |
1410 | QDateTime modifiedCalendar = mLastCalendarSync; | 1358 | QDateTime modifiedCalendar = mLastCalendarSync; |
1411 | eventLSync = getLastSyncEvent(); | 1359 | eventLSync = getLastSyncEvent(); |
1412 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1413 | if ( eventR ) { | 1361 | if ( eventR ) { |
1414 | eventRSync = (Event*) eventR->clone(); | 1362 | eventRSync = (Event*) eventR->clone(); |
1415 | remote->deleteEvent(eventR ); | 1363 | remote->deleteEvent(eventR ); |
1416 | 1364 | ||
1417 | } else { | 1365 | } else { |
1418 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1366 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1419 | eventRSync = (Event*)eventLSync->clone(); | 1367 | eventRSync = (Event*)eventLSync->clone(); |
1420 | } else { | 1368 | } else { |
1421 | fullDateRange = true; | 1369 | fullDateRange = true; |
1422 | eventRSync = new Event(); | 1370 | eventRSync = new Event(); |
1423 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1371 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1424 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1372 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1425 | eventRSync->setDtStart( mLastCalendarSync ); | 1373 | eventRSync->setDtStart( mLastCalendarSync ); |
1426 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1374 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1427 | eventRSync->setCategories( i18n("SyncEvent") ); | 1375 | eventRSync->setCategories( i18n("SyncEvent") ); |
1428 | } | 1376 | } |
1429 | } | 1377 | } |
1430 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1378 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1431 | fullDateRange = true; | 1379 | fullDateRange = true; |
1432 | 1380 | ||
1433 | if ( ! fullDateRange ) { | 1381 | if ( ! fullDateRange ) { |
1434 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1382 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1435 | 1383 | ||
1436 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1384 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1437 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1385 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1438 | fullDateRange = true; | 1386 | fullDateRange = true; |
1439 | } | 1387 | } |
1440 | } | 1388 | } |
1441 | if ( mSyncManager->syncWithDesktop() ) { | 1389 | if ( mSyncManager->syncWithDesktop() ) { |
1442 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1390 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1443 | } | 1391 | } |
1444 | if ( fullDateRange ) | 1392 | if ( fullDateRange ) |
1445 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1393 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1446 | else | 1394 | else |
1447 | mLastCalendarSync = eventLSync->dtStart(); | 1395 | mLastCalendarSync = eventLSync->dtStart(); |
1448 | // for resyncing if own file has changed | 1396 | // for resyncing if own file has changed |
1449 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1397 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1450 | mLastCalendarSync = loadedFileVersion; | 1398 | mLastCalendarSync = loadedFileVersion; |
1451 | //qDebug("setting mLastCalendarSync "); | 1399 | //qDebug("setting mLastCalendarSync "); |
1452 | } | 1400 | } |
1453 | //qDebug("*************************** "); | 1401 | //qDebug("*************************** "); |
1454 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1402 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1455 | QPtrList<Incidence> er = remote->rawIncidences(); | 1403 | QPtrList<Incidence> er = remote->rawIncidences(); |
1456 | Incidence* inR = er.first(); | 1404 | Incidence* inR = er.first(); |
1457 | Incidence* inL; | 1405 | Incidence* inL; |
1458 | QProgressBar bar( er.count(),0 ); | 1406 | QProgressBar bar( er.count(),0 ); |
1459 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1407 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1460 | 1408 | ||
1461 | // ************** setting up filter ************* | 1409 | // ************** setting up filter ************* |
1462 | CalFilter *filterIN = 0; | 1410 | CalFilter *filterIN = 0; |
1463 | CalFilter *filterOUT = 0; | 1411 | CalFilter *filterOUT = 0; |
1464 | CalFilter *filter = mFilters.first(); | 1412 | CalFilter *filter = mFilters.first(); |
1465 | while(filter) { | 1413 | while(filter) { |
1466 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1414 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1467 | filterIN = filter; | 1415 | filterIN = filter; |
1468 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1416 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1469 | filterOUT = filter; | 1417 | filterOUT = filter; |
1470 | filter = mFilters.next(); | 1418 | filter = mFilters.next(); |
1471 | } | 1419 | } |
1472 | int w = 300; | 1420 | int w = 300; |
1473 | if ( QApplication::desktop()->width() < 320 ) | 1421 | if ( QApplication::desktop()->width() < 320 ) |
1474 | w = 220; | 1422 | w = 220; |
1475 | int h = bar.sizeHint().height() ; | 1423 | int h = bar.sizeHint().height() ; |
1476 | int dw = QApplication::desktop()->width(); | 1424 | int dw = QApplication::desktop()->width(); |
1477 | int dh = QApplication::desktop()->height(); | 1425 | int dh = QApplication::desktop()->height(); |
1478 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1426 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1479 | bar.show(); | 1427 | bar.show(); |
1480 | int modulo = (er.count()/10)+1; | 1428 | int modulo = (er.count()/10)+1; |
1481 | int incCounter = 0; | 1429 | int incCounter = 0; |
1482 | while ( inR ) { | 1430 | while ( inR ) { |
1483 | if ( ! bar.isVisible() ) | 1431 | if ( ! bar.isVisible() ) |
1484 | return false; | 1432 | return false; |
1485 | if ( incCounter % modulo == 0 ) | 1433 | if ( incCounter % modulo == 0 ) |
1486 | bar.setProgress( incCounter ); | 1434 | bar.setProgress( incCounter ); |
1487 | ++incCounter; | 1435 | ++incCounter; |
1488 | uid = inR->uid(); | 1436 | uid = inR->uid(); |
1489 | bool skipIncidence = false; | 1437 | bool skipIncidence = false; |
1490 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1438 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1491 | skipIncidence = true; | 1439 | skipIncidence = true; |
1492 | QString idS; | 1440 | QString idS; |
1493 | qApp->processEvents(); | 1441 | qApp->processEvents(); |
1494 | if ( !skipIncidence ) { | 1442 | if ( !skipIncidence ) { |
1495 | inL = local->incidence( uid ); | 1443 | inL = local->incidence( uid ); |
1496 | if ( inL ) { // maybe conflict - same uid in both calendars | 1444 | if ( inL ) { // maybe conflict - same uid in both calendars |
1497 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1445 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1498 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1446 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1499 | if ( take == 3 ) | 1447 | if ( take == 3 ) |
1500 | return false; | 1448 | return false; |
1501 | if ( take == 1 ) {// take local ********************** | 1449 | if ( take == 1 ) {// take local ********************** |
1502 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1450 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1503 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1451 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1504 | else | 1452 | else |
1505 | idS = inR->IDStr(); | 1453 | idS = inR->IDStr(); |
1506 | remote->deleteIncidence( inR ); | 1454 | remote->deleteIncidence( inR ); |
1507 | inR = inL->clone(); | 1455 | inR = inL->clone(); |
1508 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1456 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1509 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1457 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1510 | inR->setIDStr( idS ); | 1458 | inR->setIDStr( idS ); |
1511 | remote->addIncidence( inR ); | 1459 | remote->addIncidence( inR ); |
1512 | if ( mSyncManager->syncWithDesktop() ) | 1460 | if ( mSyncManager->syncWithDesktop() ) |
1513 | inR->setPilotId( 2 ); | 1461 | inR->setPilotId( 2 ); |
1514 | ++changedRemote; | 1462 | ++changedRemote; |
1515 | } else {// take remote ********************** | 1463 | } else {// take remote ********************** |
1516 | idS = inL->IDStr(); | 1464 | idS = inL->IDStr(); |
1517 | int pid = inL->pilotId(); | 1465 | int pid = inL->pilotId(); |
1518 | local->deleteIncidence( inL ); | 1466 | local->deleteIncidence( inL ); |
1519 | inL = inR->clone(); | 1467 | inL = inR->clone(); |
1520 | if ( mSyncManager->syncWithDesktop() ) | 1468 | if ( mSyncManager->syncWithDesktop() ) |
1521 | inL->setPilotId( pid ); | 1469 | inL->setPilotId( pid ); |
1522 | inL->setIDStr( idS ); | 1470 | inL->setIDStr( idS ); |
1523 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1471 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1524 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1472 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1525 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1473 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1526 | } | 1474 | } |
1527 | local->addIncidence( inL ); | 1475 | local->addIncidence( inL ); |
1528 | ++changedLocal; | 1476 | ++changedLocal; |
1529 | } | 1477 | } |
1530 | } | 1478 | } |
1531 | } else { // no conflict ********** add or delete remote | 1479 | } else { // no conflict ********** add or delete remote |
1532 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1480 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1533 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1481 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1534 | QString des = eventLSync->description(); | 1482 | QString des = eventLSync->description(); |
1535 | QString pref = "e"; | 1483 | QString pref = "e"; |
1536 | if ( inR->typeID() == todoID ) | 1484 | if ( inR->typeID() == todoID ) |
1537 | pref = "t"; | 1485 | pref = "t"; |
1538 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1486 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1539 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1487 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1540 | //remote->deleteIncidence( inR ); | 1488 | //remote->deleteIncidence( inR ); |
1541 | ++deletedEventR; | 1489 | ++deletedEventR; |
1542 | } else { | 1490 | } else { |
1543 | inR->setLastModified( modifiedCalendar ); | 1491 | inR->setLastModified( modifiedCalendar ); |
1544 | inL = inR->clone(); | 1492 | inL = inR->clone(); |
1545 | inL->setIDStr( ":" ); | 1493 | inL->setIDStr( ":" ); |
1546 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1494 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1547 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1495 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1548 | local->addIncidence( inL ); | 1496 | local->addIncidence( inL ); |
1549 | ++addedEvent; | 1497 | ++addedEvent; |
1550 | 1498 | ||
1551 | } | 1499 | } |
1552 | } else { | 1500 | } else { |
1553 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1501 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1554 | inR->setLastModified( modifiedCalendar ); | 1502 | inR->setLastModified( modifiedCalendar ); |
1555 | inL = inR->clone(); | 1503 | inL = inR->clone(); |
1556 | inL->setIDStr( ":" ); | 1504 | inL->setIDStr( ":" ); |
1557 | local->addIncidence( inL ); | 1505 | local->addIncidence( inL ); |
1558 | ++addedEvent; | 1506 | ++addedEvent; |
1559 | 1507 | ||
1560 | } else { | 1508 | } else { |
1561 | checkExternSyncEvent(eventRSyncSharp, inR); | 1509 | checkExternSyncEvent(eventRSyncSharp, inR); |
1562 | remote->deleteIncidence( inR ); | 1510 | remote->deleteIncidence( inR ); |
1563 | ++deletedEventR; | 1511 | ++deletedEventR; |
1564 | } | 1512 | } |
1565 | } | 1513 | } |
1566 | } else { | 1514 | } else { |
1567 | ++filteredIN; | 1515 | ++filteredIN; |
1568 | } | 1516 | } |
1569 | } | 1517 | } |
1570 | } | 1518 | } |
1571 | inR = er.next(); | 1519 | inR = er.next(); |
1572 | } | 1520 | } |
1573 | QPtrList<Incidence> el = local->rawIncidences(); | 1521 | QPtrList<Incidence> el = local->rawIncidences(); |
1574 | inL = el.first(); | 1522 | inL = el.first(); |
1575 | modulo = (el.count()/10)+1; | 1523 | modulo = (el.count()/10)+1; |
1576 | bar.setCaption (i18n("Add / remove events") ); | 1524 | bar.setCaption (i18n("Add / remove events") ); |
1577 | bar.setTotalSteps ( el.count() ) ; | 1525 | bar.setTotalSteps ( el.count() ) ; |
1578 | bar.show(); | 1526 | bar.show(); |
1579 | incCounter = 0; | 1527 | incCounter = 0; |
1580 | 1528 | ||
1581 | while ( inL ) { | 1529 | while ( inL ) { |
1582 | 1530 | ||
1583 | qApp->processEvents(); | 1531 | qApp->processEvents(); |
1584 | if ( ! bar.isVisible() ) | 1532 | if ( ! bar.isVisible() ) |
1585 | return false; | 1533 | return false; |
1586 | if ( incCounter % modulo == 0 ) | 1534 | if ( incCounter % modulo == 0 ) |
1587 | bar.setProgress( incCounter ); | 1535 | bar.setProgress( incCounter ); |
1588 | ++incCounter; | 1536 | ++incCounter; |
1589 | uid = inL->uid(); | 1537 | uid = inL->uid(); |
1590 | bool skipIncidence = false; | 1538 | bool skipIncidence = false; |
1591 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1539 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1592 | skipIncidence = true; | 1540 | skipIncidence = true; |
1593 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1541 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1594 | skipIncidence = true; | 1542 | skipIncidence = true; |
1595 | if ( !skipIncidence ) { | 1543 | if ( !skipIncidence ) { |
1596 | inR = remote->incidence( uid ); | 1544 | inR = remote->incidence( uid ); |
1597 | if ( ! inR ) { | 1545 | if ( ! inR ) { |
1598 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1546 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1599 | // no conflict ********** add or delete local | 1547 | // no conflict ********** add or delete local |
1600 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1548 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1601 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1549 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1602 | checkExternSyncEvent(eventLSyncSharp, inL); | 1550 | checkExternSyncEvent(eventLSyncSharp, inL); |
1603 | local->deleteIncidence( inL ); | 1551 | local->deleteIncidence( inL ); |
1604 | ++deletedEventL; | 1552 | ++deletedEventL; |
1605 | } else { | 1553 | } else { |
1606 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1554 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1607 | inL->removeID(mCurrentSyncDevice ); | 1555 | inL->removeID(mCurrentSyncDevice ); |
1608 | ++addedEventR; | 1556 | ++addedEventR; |
1609 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1557 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1610 | inL->setLastModified( modifiedCalendar ); | 1558 | inL->setLastModified( modifiedCalendar ); |
1611 | inR = inL->clone(); | 1559 | inR = inL->clone(); |
1612 | inR->setIDStr( ":" ); | 1560 | inR->setIDStr( ":" ); |
1613 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1561 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1614 | remote->addIncidence( inR ); | 1562 | remote->addIncidence( inR ); |
1615 | } | 1563 | } |
1616 | } | 1564 | } |
1617 | } else { | 1565 | } else { |
1618 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1566 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1619 | checkExternSyncEvent(eventLSyncSharp, inL); | 1567 | checkExternSyncEvent(eventLSyncSharp, inL); |
1620 | local->deleteIncidence( inL ); | 1568 | local->deleteIncidence( inL ); |
1621 | ++deletedEventL; | 1569 | ++deletedEventL; |
1622 | } else { | 1570 | } else { |
1623 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1571 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1624 | ++addedEventR; | 1572 | ++addedEventR; |
1625 | inL->setLastModified( modifiedCalendar ); | 1573 | inL->setLastModified( modifiedCalendar ); |
1626 | inR = inL->clone(); | 1574 | inR = inL->clone(); |
1627 | inR->setIDStr( ":" ); | 1575 | inR->setIDStr( ":" ); |
1628 | remote->addIncidence( inR ); | 1576 | remote->addIncidence( inR ); |
1629 | } | 1577 | } |
1630 | } | 1578 | } |
1631 | } | 1579 | } |
1632 | } else { | 1580 | } else { |
1633 | ++filteredOUT; | 1581 | ++filteredOUT; |
1634 | } | 1582 | } |
1635 | } | 1583 | } |
1636 | } | 1584 | } |
1637 | inL = el.next(); | 1585 | inL = el.next(); |
1638 | } | 1586 | } |
1639 | int delFut = 0; | 1587 | int delFut = 0; |
1640 | int remRem = 0; | 1588 | int remRem = 0; |
1641 | if ( mSyncManager->mWriteBackInFuture ) { | 1589 | if ( mSyncManager->mWriteBackInFuture ) { |
1642 | er = remote->rawIncidences(); | 1590 | er = remote->rawIncidences(); |
1643 | remRem = er.count(); | 1591 | remRem = er.count(); |
1644 | inR = er.first(); | 1592 | inR = er.first(); |
1645 | QDateTime dt; | 1593 | QDateTime dt; |
1646 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1594 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1647 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1595 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1648 | while ( inR ) { | 1596 | while ( inR ) { |
1649 | if ( inR->typeID() == todoID ) { | 1597 | if ( inR->typeID() == todoID ) { |
1650 | Todo * t = (Todo*)inR; | 1598 | Todo * t = (Todo*)inR; |
1651 | if ( t->hasDueDate() ) | 1599 | if ( t->hasDueDate() ) |
1652 | dt = t->dtDue(); | 1600 | dt = t->dtDue(); |
1653 | else | 1601 | else |
1654 | dt = cur.addSecs( 62 ); | 1602 | dt = cur.addSecs( 62 ); |
1655 | } | 1603 | } |
1656 | else if (inR->typeID() == eventID ) { | 1604 | else if (inR->typeID() == eventID ) { |
1657 | bool ok; | 1605 | bool ok; |
1658 | dt = inR->getNextOccurence( cur, &ok ); | 1606 | dt = inR->getNextOccurence( cur, &ok ); |
1659 | if ( !ok ) | 1607 | if ( !ok ) |
1660 | dt = cur.addSecs( -62 ); | 1608 | dt = cur.addSecs( -62 ); |
1661 | } | 1609 | } |
1662 | else | 1610 | else |
1663 | dt = inR->dtStart(); | 1611 | dt = inR->dtStart(); |
1664 | if ( dt < cur || dt > end ) { | 1612 | if ( dt < cur || dt > end ) { |
1665 | remote->deleteIncidence( inR ); | 1613 | remote->deleteIncidence( inR ); |
1666 | ++delFut; | 1614 | ++delFut; |
1667 | } | 1615 | } |
1668 | inR = er.next(); | 1616 | inR = er.next(); |
1669 | } | 1617 | } |
1670 | } | 1618 | } |
1671 | bar.hide(); | 1619 | bar.hide(); |
1672 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1620 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1673 | eventLSync->setReadOnly( false ); | 1621 | eventLSync->setReadOnly( false ); |
1674 | eventLSync->setDtStart( mLastCalendarSync ); | 1622 | eventLSync->setDtStart( mLastCalendarSync ); |
1675 | eventRSync->setDtStart( mLastCalendarSync ); | 1623 | eventRSync->setDtStart( mLastCalendarSync ); |
1676 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1624 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1677 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1625 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1678 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1626 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1679 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1627 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1680 | eventLSync->setReadOnly( true ); | 1628 | eventLSync->setReadOnly( true ); |
1681 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1629 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1682 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1630 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1683 | remote->addEvent( eventRSync ); | 1631 | remote->addEvent( eventRSync ); |
1684 | else | 1632 | else |
1685 | delete eventRSync; | 1633 | delete eventRSync; |
1686 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1634 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1687 | QString mes; | 1635 | QString mes; |
1688 | 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 ); | 1636 | 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 ); |
1689 | QString delmess; | 1637 | QString delmess; |
1690 | if ( delFut ) { | 1638 | if ( delFut ) { |
1691 | 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); | 1639 | 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); |
1692 | mes += delmess; | 1640 | mes += delmess; |
1693 | } | 1641 | } |
1694 | mes = i18n("Local calendar changed!\n") +mes; | 1642 | mes = i18n("Local calendar changed!\n") +mes; |
1695 | mCalendar->checkAlarmForIncidence( 0, true ); | 1643 | mCalendar->checkAlarmForIncidence( 0, true ); |
1696 | qDebug( mes ); | 1644 | qDebug( mes ); |
1697 | if ( mSyncManager->mShowSyncSummary ) { | 1645 | if ( mSyncManager->mShowSyncSummary ) { |
1698 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1646 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1699 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1647 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1700 | qDebug("KO: WB cancelled "); | 1648 | qDebug("KO: WB cancelled "); |
1701 | mSyncManager->mWriteBackFile = false; | 1649 | mSyncManager->mWriteBackFile = false; |
1702 | return syncOK; | 1650 | return syncOK; |
1703 | } | 1651 | } |
1704 | } | 1652 | } |
1705 | return syncOK; | 1653 | return syncOK; |
1706 | } | 1654 | } |
1707 | 1655 | ||
1708 | void CalendarView::setSyncDevice( QString s ) | 1656 | void CalendarView::setSyncDevice( QString s ) |
1709 | { | 1657 | { |
1710 | mCurrentSyncDevice= s; | 1658 | mCurrentSyncDevice= s; |
1711 | } | 1659 | } |
1712 | void CalendarView::setSyncName( QString s ) | 1660 | void CalendarView::setSyncName( QString s ) |
1713 | { | 1661 | { |
1714 | mCurrentSyncName= s; | 1662 | mCurrentSyncName= s; |
1715 | } | 1663 | } |
1716 | bool CalendarView::syncCalendar(QString filename, int mode) | 1664 | bool CalendarView::syncCalendar(QString filename, int mode) |
1717 | { | 1665 | { |
1718 | //qDebug("syncCalendar %s ", filename.latin1()); | 1666 | //qDebug("syncCalendar %s ", filename.latin1()); |
1719 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1667 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1720 | CalendarLocal* calendar = new CalendarLocal(); | 1668 | CalendarLocal* calendar = new CalendarLocal(); |
1721 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1669 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1722 | FileStorage* storage = new FileStorage( calendar ); | 1670 | FileStorage* storage = new FileStorage( calendar ); |
1723 | bool syncOK = false; | 1671 | bool syncOK = false; |
1724 | storage->setFileName( filename ); | 1672 | storage->setFileName( filename ); |
1725 | // qDebug("loading ... "); | 1673 | // qDebug("loading ... "); |
1726 | if ( storage->load() ) { | 1674 | if ( storage->load() ) { |
1727 | getEventViewerDialog()->setSyncMode( true ); | 1675 | getEventViewerDialog()->setSyncMode( true ); |
1728 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1676 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1729 | getEventViewerDialog()->setSyncMode( false ); | 1677 | getEventViewerDialog()->setSyncMode( false ); |
1730 | if ( syncOK ) { | 1678 | if ( syncOK ) { |
1731 | if ( mSyncManager->mWriteBackFile ) | 1679 | if ( mSyncManager->mWriteBackFile ) |
1732 | { | 1680 | { |
1733 | storage->setSaveFormat( new ICalFormat() ); | 1681 | storage->setSaveFormat( new ICalFormat() ); |
1734 | storage->save(); | 1682 | storage->save(); |
1735 | } | 1683 | } |
1736 | } | 1684 | } |
1737 | setModified( true ); | 1685 | setModified( true ); |
1738 | } | 1686 | } |
1739 | delete storage; | 1687 | delete storage; |
1740 | delete calendar; | 1688 | delete calendar; |
1741 | if ( syncOK ) | 1689 | if ( syncOK ) |
1742 | updateView(); | 1690 | updateView(); |
1743 | return syncOK; | 1691 | return syncOK; |
1744 | } | 1692 | } |
1745 | 1693 | ||
1746 | void CalendarView::syncExternal( int mode ) | 1694 | void CalendarView::syncExternal( int mode ) |
1747 | { | 1695 | { |
1748 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1696 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1749 | 1697 | ||
1750 | qApp->processEvents(); | 1698 | qApp->processEvents(); |
1751 | CalendarLocal* calendar = new CalendarLocal(); | 1699 | CalendarLocal* calendar = new CalendarLocal(); |
1752 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1700 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1753 | bool syncOK = false; | 1701 | bool syncOK = false; |
1754 | bool loadSuccess = false; | 1702 | bool loadSuccess = false; |
1755 | PhoneFormat* phoneFormat = 0; | 1703 | PhoneFormat* phoneFormat = 0; |
1756 | emit tempDisableBR(true); | 1704 | emit tempDisableBR(true); |
1757 | #ifndef DESKTOP_VERSION | 1705 | #ifndef DESKTOP_VERSION |
1758 | SharpFormat* sharpFormat = 0; | 1706 | SharpFormat* sharpFormat = 0; |
1759 | if ( mode == 0 ) { // sharp | 1707 | if ( mode == 0 ) { // sharp |
1760 | sharpFormat = new SharpFormat () ; | 1708 | sharpFormat = new SharpFormat () ; |
1761 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1709 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1762 | 1710 | ||
1763 | } else | 1711 | } else |
1764 | #endif | 1712 | #endif |
1765 | if ( mode == 1 ) { // phone | 1713 | if ( mode == 1 ) { // phone |
1766 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1714 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1767 | mSyncManager->mPhoneDevice, | 1715 | mSyncManager->mPhoneDevice, |
1768 | mSyncManager->mPhoneConnection, | 1716 | mSyncManager->mPhoneConnection, |
1769 | mSyncManager->mPhoneModel); | 1717 | mSyncManager->mPhoneModel); |
1770 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1718 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1771 | 1719 | ||
1772 | } else { | 1720 | } else { |
1773 | emit tempDisableBR(false); | 1721 | emit tempDisableBR(false); |
1774 | return; | 1722 | return; |
1775 | } | 1723 | } |
1776 | if ( loadSuccess ) { | 1724 | if ( loadSuccess ) { |
1777 | getEventViewerDialog()->setSyncMode( true ); | 1725 | getEventViewerDialog()->setSyncMode( true ); |
1778 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1726 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1779 | getEventViewerDialog()->setSyncMode( false ); | 1727 | getEventViewerDialog()->setSyncMode( false ); |
1780 | qApp->processEvents(); | 1728 | qApp->processEvents(); |
1781 | if ( syncOK ) { | 1729 | if ( syncOK ) { |
1782 | if ( mSyncManager->mWriteBackFile ) | 1730 | if ( mSyncManager->mWriteBackFile ) |
1783 | { | 1731 | { |
1784 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1732 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1785 | Incidence* inc = iL.first(); | 1733 | Incidence* inc = iL.first(); |
1786 | if ( phoneFormat ) { | 1734 | if ( phoneFormat ) { |
1787 | while ( inc ) { | 1735 | while ( inc ) { |
1788 | inc->removeID(mCurrentSyncDevice); | 1736 | inc->removeID(mCurrentSyncDevice); |
1789 | inc = iL.next(); | 1737 | inc = iL.next(); |
1790 | } | 1738 | } |
1791 | } | 1739 | } |
1792 | #ifndef DESKTOP_VERSION | 1740 | #ifndef DESKTOP_VERSION |
1793 | if ( sharpFormat ) | 1741 | if ( sharpFormat ) |
1794 | sharpFormat->save(calendar); | 1742 | sharpFormat->save(calendar); |
1795 | #endif | 1743 | #endif |
1796 | if ( phoneFormat ) | 1744 | if ( phoneFormat ) |
1797 | phoneFormat->save(calendar); | 1745 | phoneFormat->save(calendar); |
1798 | iL = calendar->rawIncidences(); | 1746 | iL = calendar->rawIncidences(); |
1799 | inc = iL.first(); | 1747 | inc = iL.first(); |
1800 | Incidence* loc; | 1748 | Incidence* loc; |
1801 | while ( inc ) { | 1749 | while ( inc ) { |
1802 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1750 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1803 | loc = mCalendar->incidence(inc->uid() ); | 1751 | loc = mCalendar->incidence(inc->uid() ); |
1804 | if ( loc ) { | 1752 | if ( loc ) { |
1805 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1753 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1806 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1754 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1807 | } | 1755 | } |
1808 | } | 1756 | } |
1809 | inc = iL.next(); | 1757 | inc = iL.next(); |
1810 | } | 1758 | } |
1811 | Incidence* lse = getLastSyncEvent(); | 1759 | Incidence* lse = getLastSyncEvent(); |
1812 | if ( lse ) { | 1760 | if ( lse ) { |
1813 | lse->setReadOnly( false ); | 1761 | lse->setReadOnly( false ); |
1814 | lse->setDescription( "" ); | 1762 | lse->setDescription( "" ); |
1815 | lse->setReadOnly( true ); | 1763 | lse->setReadOnly( true ); |
1816 | } | 1764 | } |
1817 | } | 1765 | } |
1818 | } else { | 1766 | } else { |
1819 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1767 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1820 | } | 1768 | } |
1821 | setModified( true ); | 1769 | setModified( true ); |
1822 | } else { | 1770 | } else { |
1823 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1771 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1824 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1772 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1825 | question, i18n("Ok")) ; | 1773 | question, i18n("Ok")) ; |
1826 | 1774 | ||
1827 | } | 1775 | } |
1828 | delete calendar; | 1776 | delete calendar; |
1829 | updateView(); | 1777 | updateView(); |
1830 | emit tempDisableBR(false); | 1778 | emit tempDisableBR(false); |
1831 | return ;//syncOK; | 1779 | return ;//syncOK; |
1832 | 1780 | ||
1833 | } | 1781 | } |
1834 | 1782 | ||
1835 | bool CalendarView::importBday() | 1783 | bool CalendarView::importBday() |
1836 | { | 1784 | { |
1837 | #ifndef KORG_NOKABC | 1785 | #ifndef KORG_NOKABC |
1838 | 1786 | ||
1839 | #ifdef DESKTOP_VERSION | 1787 | #ifdef DESKTOP_VERSION |
1840 | int curCal = mCalendar->defaultCalendar(); | 1788 | int curCal = mCalendar->defaultCalendar(); |
1841 | int bd = mCalEditView->getBirtdayID(); | 1789 | int bd = mCalEditView->getBirtdayID(); |
1842 | if ( bd == 0 ) | 1790 | if ( bd == 0 ) |
1843 | return false; | 1791 | return false; |
1844 | mCalendar->setDefaultCalendar( bd ); | 1792 | mCalendar->setDefaultCalendar( bd ); |
1845 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1793 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1846 | KABC::AddressBook::Iterator it; | 1794 | KABC::AddressBook::Iterator it; |
1847 | int count = 0; | 1795 | int count = 0; |
1848 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1796 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1849 | ++count; | 1797 | ++count; |
1850 | } | 1798 | } |
1851 | QProgressBar bar(count,0 ); | 1799 | QProgressBar bar(count,0 ); |
1852 | int w = 300; | 1800 | int w = 300; |
1853 | if ( QApplication::desktop()->width() < 320 ) | 1801 | if ( QApplication::desktop()->width() < 320 ) |
1854 | w = 220; | 1802 | w = 220; |
1855 | int h = bar.sizeHint().height() ; | 1803 | int h = bar.sizeHint().height() ; |
1856 | int dw = QApplication::desktop()->width(); | 1804 | int dw = QApplication::desktop()->width(); |
1857 | int dh = QApplication::desktop()->height(); | 1805 | int dh = QApplication::desktop()->height(); |
1858 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1806 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1859 | bar.show(); | 1807 | bar.show(); |
1860 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1808 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1861 | qApp->processEvents(); | 1809 | qApp->processEvents(); |
1862 | count = 0; | 1810 | count = 0; |
1863 | int addCount = 0; | 1811 | int addCount = 0; |
1864 | KCal::Attendee* a = 0; | 1812 | KCal::Attendee* a = 0; |
1865 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1813 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1866 | if ( ! bar.isVisible() ) | 1814 | if ( ! bar.isVisible() ) |
1867 | return false; | 1815 | return false; |
1868 | bar.setProgress( count++ ); | 1816 | bar.setProgress( count++ ); |
1869 | qApp->processEvents(); | 1817 | qApp->processEvents(); |
1870 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1818 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1871 | if ( (*it).birthday().date().isValid() ){ | 1819 | if ( (*it).birthday().date().isValid() ){ |
1872 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1820 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1873 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1821 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1874 | ++addCount; | 1822 | ++addCount; |
1875 | } | 1823 | } |
1876 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1824 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1877 | if ( anni.isValid() ){ | 1825 | if ( anni.isValid() ){ |
1878 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1826 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1879 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1827 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1880 | ++addCount; | 1828 | ++addCount; |
1881 | } | 1829 | } |
1882 | } | 1830 | } |
1883 | mCalendar->setDefaultCalendar( curCal ); | 1831 | mCalendar->setDefaultCalendar( curCal ); |
1884 | updateView(); | 1832 | updateView(); |
1885 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1833 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1886 | #else //DESKTOP_VERSION | 1834 | #else //DESKTOP_VERSION |
1887 | 1835 | ||
1888 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1836 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1889 | // the result should now arrive through method insertBirthdays | 1837 | // the result should now arrive through method insertBirthdays |
1890 | 1838 | ||
1891 | #endif //DESKTOP_VERSION | 1839 | #endif //DESKTOP_VERSION |
1892 | 1840 | ||
1893 | #endif //KORG_NOKABC | 1841 | #endif //KORG_NOKABC |
1894 | 1842 | ||
1895 | 1843 | ||
1896 | return true; | 1844 | return true; |
1897 | } | 1845 | } |
1898 | 1846 | ||
1899 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1847 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1900 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1848 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1901 | const QStringList& anniversaryList, const QStringList& realNameList, | 1849 | const QStringList& anniversaryList, const QStringList& realNameList, |
1902 | const QStringList& emailList, const QStringList& assembledNameList, | 1850 | const QStringList& emailList, const QStringList& assembledNameList, |
1903 | const QStringList& uidList) | 1851 | const QStringList& uidList) |
1904 | { | 1852 | { |
1905 | 1853 | ||
1906 | //qDebug("KO::CalendarView::insertBirthdays"); | 1854 | //qDebug("KO::CalendarView::insertBirthdays"); |
1907 | if (uid == this->name()) | 1855 | if (uid == this->name()) |
1908 | { | 1856 | { |
1909 | int curCal = mCalendar->defaultCalendar(); | 1857 | int curCal = mCalendar->defaultCalendar(); |
1910 | int bd = mCalEditView->getBirtdayID(); | 1858 | int bd = mCalEditView->getBirtdayID(); |
1911 | if ( bd == 0 ) | 1859 | if ( bd == 0 ) |
1912 | return; | 1860 | return; |
1913 | mCalendar->setDefaultCalendar( bd ); | 1861 | mCalendar->setDefaultCalendar( bd ); |
1914 | 1862 | ||
1915 | 1863 | ||
1916 | int count = birthdayList.count(); | 1864 | int count = birthdayList.count(); |
1917 | int addCount = 0; | 1865 | int addCount = 0; |
1918 | KCal::Attendee* a = 0; | 1866 | KCal::Attendee* a = 0; |
1919 | 1867 | ||
1920 | //qDebug("CalView 1 %i", count); | 1868 | //qDebug("CalView 1 %i", count); |
1921 | 1869 | ||
1922 | QProgressBar bar(count,0 ); | 1870 | QProgressBar bar(count,0 ); |
1923 | int w = 300; | 1871 | int w = 300; |
1924 | if ( QApplication::desktop()->width() < 320 ) | 1872 | if ( QApplication::desktop()->width() < 320 ) |
1925 | w = 220; | 1873 | w = 220; |
1926 | int h = bar.sizeHint().height() ; | 1874 | int h = bar.sizeHint().height() ; |
1927 | int dw = QApplication::desktop()->width(); | 1875 | int dw = QApplication::desktop()->width(); |
1928 | int dh = QApplication::desktop()->height(); | 1876 | int dh = QApplication::desktop()->height(); |
1929 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1877 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1930 | bar.show(); | 1878 | bar.show(); |
1931 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1879 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1932 | qApp->processEvents(); | 1880 | qApp->processEvents(); |
1933 | 1881 | ||
1934 | QDate birthday; | 1882 | QDate birthday; |
1935 | QDate anniversary; | 1883 | QDate anniversary; |
1936 | QString realName; | 1884 | QString realName; |
1937 | QString email; | 1885 | QString email; |
1938 | QString assembledName; | 1886 | QString assembledName; |
1939 | QString uid; | 1887 | QString uid; |
1940 | bool ok = true; | 1888 | bool ok = true; |
1941 | for ( int i = 0; i < count; i++) | 1889 | for ( int i = 0; i < count; i++) |
1942 | { | 1890 | { |
1943 | if ( ! bar.isVisible() ) | 1891 | if ( ! bar.isVisible() ) |
1944 | return; | 1892 | return; |
1945 | bar.setProgress( i ); | 1893 | bar.setProgress( i ); |
1946 | qApp->processEvents(); | 1894 | qApp->processEvents(); |
1947 | 1895 | ||
1948 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1896 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1949 | if (!ok) { | 1897 | if (!ok) { |
1950 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1898 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1951 | } | 1899 | } |
1952 | 1900 | ||
1953 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1901 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1954 | if (!ok) { | 1902 | if (!ok) { |
1955 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1903 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1956 | } | 1904 | } |
1957 | realName = realNameList[i]; | 1905 | realName = realNameList[i]; |
1958 | email = emailList[i]; | 1906 | email = emailList[i]; |
1959 | assembledName = assembledNameList[i]; | 1907 | assembledName = assembledNameList[i]; |
1960 | uid = uidList[i]; | 1908 | uid = uidList[i]; |
1961 | //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() ); | 1909 | //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() ); |
1962 | 1910 | ||
1963 | if ( birthday.isValid() ){ | 1911 | if ( birthday.isValid() ){ |
1964 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1912 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1965 | KCal::Attendee::ReqParticipant,uid) ; | 1913 | KCal::Attendee::ReqParticipant,uid) ; |
1966 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1914 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1967 | ++addCount; | 1915 | ++addCount; |
1968 | } | 1916 | } |
1969 | 1917 | ||
1970 | if ( anniversary.isValid() ){ | 1918 | if ( anniversary.isValid() ){ |
1971 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1919 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1972 | KCal::Attendee::ReqParticipant,uid) ; | 1920 | KCal::Attendee::ReqParticipant,uid) ; |
1973 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1921 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1974 | ++addCount; | 1922 | ++addCount; |
1975 | } | 1923 | } |
1976 | } | 1924 | } |
1977 | 1925 | ||
1978 | mCalendar->setDefaultCalendar( curCal ); | 1926 | mCalendar->setDefaultCalendar( curCal ); |
1979 | updateView(); | 1927 | updateView(); |
1980 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1928 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1981 | 1929 | ||
1982 | } | 1930 | } |
1983 | 1931 | ||
1984 | } | 1932 | } |
1985 | 1933 | ||
1986 | 1934 | ||
1987 | 1935 | ||
1988 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1936 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1989 | { | 1937 | { |
1990 | //qDebug("addAnni "); | 1938 | //qDebug("addAnni "); |
1991 | Event * ev = new Event(); | 1939 | Event * ev = new Event(); |
1992 | ev->setOrganizer(KOPrefs::instance()->email()); | 1940 | ev->setOrganizer(KOPrefs::instance()->email()); |
1993 | if ( a ) { | 1941 | if ( a ) { |
1994 | ev->addAttendee( a ); | 1942 | ev->addAttendee( a ); |
1995 | } | 1943 | } |
1996 | QString kind; | 1944 | QString kind; |
1997 | if ( birthday ) { | 1945 | if ( birthday ) { |
1998 | kind = i18n( "Birthday" ); | 1946 | kind = i18n( "Birthday" ); |
1999 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1947 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
2000 | } | 1948 | } |
2001 | else { | 1949 | else { |
2002 | kind = i18n( "Anniversary" ); | 1950 | kind = i18n( "Anniversary" ); |
2003 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1951 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
2004 | } | 1952 | } |
2005 | ev->setCategories( kind ); | 1953 | ev->setCategories( kind ); |
2006 | ev->setDtStart( QDateTime(date) ); | 1954 | ev->setDtStart( QDateTime(date) ); |
2007 | ev->setDtEnd( QDateTime(date) ); | 1955 | ev->setDtEnd( QDateTime(date) ); |
2008 | ev->setFloats( true ); | 1956 | ev->setFloats( true ); |
2009 | Recurrence * rec = ev->recurrence(); | 1957 | Recurrence * rec = ev->recurrence(); |
2010 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1958 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
2011 | rec->addYearlyNum( date.month() ); | 1959 | rec->addYearlyNum( date.month() ); |
2012 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1960 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
2013 | delete ev; | 1961 | delete ev; |
2014 | return false; | 1962 | return false; |
2015 | } | 1963 | } |
2016 | return true; | 1964 | return true; |
2017 | 1965 | ||
2018 | } | 1966 | } |
2019 | bool CalendarView::importQtopia( const QString &categories, | 1967 | bool CalendarView::importQtopia( const QString &categories, |
2020 | const QString &datebook, | 1968 | const QString &datebook, |
2021 | const QString &todolist ) | 1969 | const QString &todolist ) |
2022 | { | 1970 | { |
2023 | 1971 | ||
2024 | QtopiaFormat qtopiaFormat; | 1972 | QtopiaFormat qtopiaFormat; |
2025 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1973 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2026 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1974 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
2027 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1975 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
2028 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1976 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
2029 | 1977 | ||
2030 | updateView(); | 1978 | updateView(); |
2031 | return true; | 1979 | return true; |
2032 | 1980 | ||
2033 | #if 0 | 1981 | #if 0 |
2034 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1982 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
2035 | mCurrentSyncDevice = "qtopia-XML"; | 1983 | mCurrentSyncDevice = "qtopia-XML"; |
2036 | if ( mSyncManager->mAskForPreferences ) | 1984 | if ( mSyncManager->mAskForPreferences ) |
2037 | edit_sync_options(); | 1985 | edit_sync_options(); |
2038 | qApp->processEvents(); | 1986 | qApp->processEvents(); |
2039 | CalendarLocal* calendar = new CalendarLocal(); | 1987 | CalendarLocal* calendar = new CalendarLocal(); |
2040 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1988 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2041 | bool syncOK = false; | 1989 | bool syncOK = false; |
2042 | QtopiaFormat qtopiaFormat; | 1990 | QtopiaFormat qtopiaFormat; |
2043 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1991 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
2044 | bool loadOk = true; | 1992 | bool loadOk = true; |
2045 | if ( !categories.isEmpty() ) | 1993 | if ( !categories.isEmpty() ) |
2046 | loadOk = qtopiaFormat.load( calendar, categories ); | 1994 | loadOk = qtopiaFormat.load( calendar, categories ); |
2047 | if ( loadOk && !datebook.isEmpty() ) | 1995 | if ( loadOk && !datebook.isEmpty() ) |
2048 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1996 | loadOk = qtopiaFormat.load( calendar, datebook ); |
2049 | if ( loadOk && !todolist.isEmpty() ) | 1997 | if ( loadOk && !todolist.isEmpty() ) |
2050 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1998 | loadOk = qtopiaFormat.load( calendar, todolist ); |
2051 | 1999 | ||
2052 | if ( loadOk ) { | 2000 | if ( loadOk ) { |
2053 | getEventViewerDialog()->setSyncMode( true ); | 2001 | getEventViewerDialog()->setSyncMode( true ); |
2054 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 2002 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
2055 | getEventViewerDialog()->setSyncMode( false ); | 2003 | getEventViewerDialog()->setSyncMode( false ); |
2056 | qApp->processEvents(); | 2004 | qApp->processEvents(); |
2057 | if ( syncOK ) { | 2005 | if ( syncOK ) { |
2058 | if ( mSyncManager->mWriteBackFile ) | 2006 | if ( mSyncManager->mWriteBackFile ) |
2059 | { | 2007 | { |
2060 | // write back XML file | 2008 | // write back XML file |
2061 | 2009 | ||
2062 | } | 2010 | } |
2063 | setModified( true ); | 2011 | setModified( true ); |
2064 | } | 2012 | } |
2065 | } else { | 2013 | } else { |
2066 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 2014 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
2067 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 2015 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
2068 | question, i18n("Ok")) ; | 2016 | question, i18n("Ok")) ; |
2069 | } | 2017 | } |
2070 | delete calendar; | 2018 | delete calendar; |
2071 | updateView(); | 2019 | updateView(); |
2072 | return syncOK; | 2020 | return syncOK; |
2073 | 2021 | ||
2074 | 2022 | ||
2075 | #endif | 2023 | #endif |
2076 | 2024 | ||
2077 | } | 2025 | } |
2078 | 2026 | ||
2079 | void CalendarView::setSyncEventsReadOnly() | 2027 | void CalendarView::setSyncEventsReadOnly() |
2080 | { | 2028 | { |
2081 | mCalendar->setSyncEventsReadOnly(); | 2029 | mCalendar->setSyncEventsReadOnly(); |
2082 | } | 2030 | } |
2083 | 2031 | ||
2084 | bool CalendarView::loadCalendars() | 2032 | bool CalendarView::loadCalendars() |
2085 | { | 2033 | { |
2086 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2034 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2087 | KopiCalendarFile * cal = calendars.first(); | 2035 | KopiCalendarFile * cal = calendars.first(); |
2088 | mCalendar->setDefaultCalendar( 1 ); | 2036 | mCalendar->setDefaultCalendar( 1 ); |
2089 | openCalendar( MainWindow::defaultFileName(), false ); | 2037 | openCalendar( MainWindow::defaultFileName(), false ); |
2090 | cal = calendars.next(); | 2038 | cal = calendars.next(); |
2091 | while ( cal ) { | 2039 | while ( cal ) { |
2092 | addCalendar( cal ); | 2040 | addCalendar( cal ); |
2093 | cal = calendars.next(); | 2041 | cal = calendars.next(); |
2094 | } | 2042 | } |
2095 | restoreCalendarSettings(); | 2043 | restoreCalendarSettings(); |
2096 | return true; | 2044 | return true; |
2097 | } | 2045 | } |
2098 | bool CalendarView::restoreCalendarSettings() | 2046 | bool CalendarView::restoreCalendarSettings() |
2099 | { | 2047 | { |
2100 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2048 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2101 | KopiCalendarFile * cal = calendars.first(); | 2049 | KopiCalendarFile * cal = calendars.first(); |
2102 | while ( cal ) { | 2050 | while ( cal ) { |
2103 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 2051 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
2104 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 2052 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
2105 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 2053 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
2106 | if ( cal->isStandard ) | 2054 | if ( cal->isStandard ) |
2107 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2055 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2108 | cal = calendars.next(); | 2056 | cal = calendars.next(); |
2109 | } | 2057 | } |
2110 | setSyncEventsReadOnly(); | 2058 | setSyncEventsReadOnly(); |
2111 | mCalendar->reInitAlarmSettings(); | 2059 | mCalendar->reInitAlarmSettings(); |
2112 | updateUnmanagedViews(); | 2060 | updateUnmanagedViews(); |
2113 | updateView(); | 2061 | updateView(); |
2114 | return true; | 2062 | return true; |
2115 | } | 2063 | } |
2116 | void CalendarView::addCalendarId( int id ) | 2064 | void CalendarView::addCalendarId( int id ) |
2117 | { | 2065 | { |
2118 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); | 2066 | KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); |
2119 | if ( cal ) | 2067 | if ( cal ) |
2120 | addCalendar( cal ); | 2068 | addCalendar( cal ); |
2121 | } | 2069 | } |
2122 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | 2070 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) |
2123 | { | 2071 | { |
2124 | cal->mErrorOnLoad = false; | 2072 | cal->mErrorOnLoad = false; |
2125 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { | 2073 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { |
2126 | cal->mLoadDt = QDateTime::currentDateTime(); | 2074 | cal->mLoadDt = QDateTime::currentDateTime(); |
2127 | return true; | 2075 | return true; |
2128 | } | 2076 | } |
2129 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); | 2077 | qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); |
2130 | cal->mErrorOnLoad = true; | 2078 | cal->mErrorOnLoad = true; |
2131 | return false; | 2079 | return false; |
2132 | } | 2080 | } |
2133 | bool CalendarView::openCalendar(QString filename, bool merge) | 2081 | bool CalendarView::openCalendar(QString filename, bool merge) |
2134 | { | 2082 | { |
2135 | 2083 | ||
2136 | if (filename.isEmpty()) { | 2084 | if (filename.isEmpty()) { |
2137 | return false; | 2085 | return false; |
2138 | } | 2086 | } |
2139 | 2087 | ||
2140 | if (!QFile::exists(filename)) { | 2088 | if (!QFile::exists(filename)) { |
2141 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 2089 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
2142 | return false; | 2090 | return false; |
2143 | } | 2091 | } |
2144 | 2092 | ||
2145 | globalFlagBlockAgenda = 1; | 2093 | globalFlagBlockAgenda = 1; |
2146 | clearAllViews(); | 2094 | clearAllViews(); |
2147 | if (!merge) { | 2095 | if (!merge) { |
2148 | mViewManager->setDocumentId( filename ); | 2096 | mViewManager->setDocumentId( filename ); |
2149 | mCalendar->close(); | 2097 | mCalendar->close(); |
2150 | } | 2098 | } |
2151 | mStorage->setFileName( filename ); | 2099 | mStorage->setFileName( filename ); |
2152 | 2100 | ||
2153 | if ( mStorage->load() ) { | 2101 | if ( mStorage->load() ) { |
2154 | if ( merge ) ;//setModified( true ); | 2102 | if ( merge ) ;//setModified( true ); |
2155 | else { | 2103 | else { |
2156 | //setModified( true ); | 2104 | //setModified( true ); |
2157 | mViewManager->setDocumentId( filename ); | 2105 | mViewManager->setDocumentId( filename ); |
2158 | mDialogManager->setDocumentId( filename ); | 2106 | mDialogManager->setDocumentId( filename ); |
2159 | mTodoList->setDocumentId( filename ); | 2107 | mTodoList->setDocumentId( filename ); |
2160 | } | 2108 | } |
2161 | globalFlagBlockAgenda = 2; | 2109 | globalFlagBlockAgenda = 2; |
2162 | // if ( getLastSyncEvent() ) | 2110 | // if ( getLastSyncEvent() ) |
2163 | // getLastSyncEvent()->setReadOnly( true ); | 2111 | // getLastSyncEvent()->setReadOnly( true ); |
2164 | mCalendar->reInitAlarmSettings(); | 2112 | mCalendar->reInitAlarmSettings(); |
2165 | setSyncEventsReadOnly(); | 2113 | setSyncEventsReadOnly(); |
2166 | updateUnmanagedViews(); | 2114 | updateUnmanagedViews(); |
2167 | updateView(); | 2115 | updateView(); |
2168 | if ( filename != MainWindow::defaultFileName() ) { | 2116 | if ( filename != MainWindow::defaultFileName() ) { |
2169 | saveCalendar( MainWindow::defaultFileName() ); | 2117 | saveCalendar( MainWindow::defaultFileName() ); |
2170 | } else { | 2118 | } else { |
2171 | QFileInfo finf ( MainWindow::defaultFileName()); | 2119 | QFileInfo finf ( MainWindow::defaultFileName()); |
2172 | if ( finf.exists() ) { | 2120 | if ( finf.exists() ) { |
2173 | setLoadedFileVersion( finf.lastModified () ); | 2121 | setLoadedFileVersion( finf.lastModified () ); |
2174 | } | 2122 | } |
2175 | } | 2123 | } |
2176 | return true; | 2124 | return true; |
2177 | } else { | 2125 | } else { |
2178 | // while failing to load, the calendar object could | 2126 | // while failing to load, the calendar object could |
2179 | // have become partially populated. Clear it out. | 2127 | // have become partially populated. Clear it out. |
2180 | if ( !merge ) { | 2128 | if ( !merge ) { |
2181 | mCalendar->close(); | 2129 | mCalendar->close(); |
2182 | mViewManager->setDocumentId( filename ); | 2130 | mViewManager->setDocumentId( filename ); |
2183 | mDialogManager->setDocumentId( filename ); | 2131 | mDialogManager->setDocumentId( filename ); |
2184 | mTodoList->setDocumentId( filename ); | 2132 | mTodoList->setDocumentId( filename ); |
2185 | } | 2133 | } |
2186 | 2134 | ||
2187 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2135 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2188 | 2136 | ||
2189 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2137 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2190 | globalFlagBlockAgenda = 2; | 2138 | globalFlagBlockAgenda = 2; |
2191 | mCalendar->reInitAlarmSettings(); | 2139 | mCalendar->reInitAlarmSettings(); |
2192 | setSyncEventsReadOnly(); | 2140 | setSyncEventsReadOnly(); |
2193 | updateUnmanagedViews(); | 2141 | updateUnmanagedViews(); |
2194 | updateView(); | 2142 | updateView(); |
2195 | } | 2143 | } |
2196 | return false; | 2144 | return false; |
2197 | } | 2145 | } |
2198 | void CalendarView::showOpenError() | 2146 | void CalendarView::showOpenError() |
2199 | { | 2147 | { |
2200 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2148 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2201 | } | 2149 | } |
2202 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2150 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2203 | { | 2151 | { |
2204 | loadedFileVersion = dt; | 2152 | loadedFileVersion = dt; |
2205 | } | 2153 | } |
2206 | bool CalendarView::checkFileChanged(QString fn) | 2154 | bool CalendarView::checkFileChanged(QString fn) |
2207 | { | 2155 | { |
2208 | QFileInfo finf ( fn ); | 2156 | QFileInfo finf ( fn ); |
2209 | if ( !finf.exists() ) | 2157 | if ( !finf.exists() ) |
2210 | return true; | 2158 | return true; |
2211 | QDateTime dt = finf.lastModified (); | 2159 | QDateTime dt = finf.lastModified (); |
2212 | if ( dt <= loadedFileVersion ) | 2160 | if ( dt <= loadedFileVersion ) |
2213 | return false; | 2161 | return false; |
2214 | return true; | 2162 | return true; |
2215 | 2163 | ||
2216 | } | 2164 | } |
2217 | void CalendarView::watchSavedFile() | 2165 | void CalendarView::watchSavedFile() |
2218 | { | 2166 | { |
2219 | QFileInfo finf ( MainWindow::defaultFileName()); | 2167 | QFileInfo finf ( MainWindow::defaultFileName()); |
2220 | if ( !finf.exists() ) | 2168 | if ( !finf.exists() ) |
2221 | return; | 2169 | return; |
2222 | QDateTime dt = finf.lastModified (); | 2170 | QDateTime dt = finf.lastModified (); |
2223 | if ( dt < loadedFileVersion ) { | 2171 | if ( dt < loadedFileVersion ) { |
2224 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2172 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2225 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2173 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2226 | return; | 2174 | return; |
2227 | } | 2175 | } |
2228 | loadedFileVersion = dt; | 2176 | loadedFileVersion = dt; |
2229 | } | 2177 | } |
2230 | bool CalendarView::checkAllFileVersions() | 2178 | bool CalendarView::checkAllFileVersions() |
2231 | { | 2179 | { |
2232 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2180 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2233 | KopiCalendarFile * cal = calendars.first(); | 2181 | KopiCalendarFile * cal = calendars.first(); |
2234 | mCalendar->setDefaultCalendar( 1 ); | 2182 | mCalendar->setDefaultCalendar( 1 ); |
2235 | mCalendar->setDefaultCalendarEnabledOnly(); | 2183 | mCalendar->setDefaultCalendarEnabledOnly(); |
2236 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2184 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2237 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2185 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2238 | restoreCalendarSettings(); | 2186 | restoreCalendarSettings(); |
2239 | return false; | 2187 | return false; |
2240 | } | 2188 | } |
2241 | } | 2189 | } |
2242 | cal = calendars.next(); | 2190 | cal = calendars.next(); |
2243 | QDateTime storeTemp = loadedFileVersion; | 2191 | QDateTime storeTemp = loadedFileVersion; |
2244 | while ( cal ) { | 2192 | while ( cal ) { |
2245 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2193 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2246 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2194 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2247 | mCalendar->setDefaultCalendarEnabledOnly(); | 2195 | mCalendar->setDefaultCalendarEnabledOnly(); |
2248 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2196 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2249 | if ( !checkFileVersion(cal->mFileName )) { | 2197 | if ( !checkFileVersion(cal->mFileName )) { |
2250 | loadedFileVersion = storeTemp; | 2198 | loadedFileVersion = storeTemp; |
2251 | restoreCalendarSettings(); | 2199 | restoreCalendarSettings(); |
2252 | return false; | 2200 | return false; |
2253 | } | 2201 | } |
2254 | } | 2202 | } |
2255 | cal = calendars.next(); | 2203 | cal = calendars.next(); |
2256 | } | 2204 | } |
2257 | loadedFileVersion = storeTemp; | 2205 | loadedFileVersion = storeTemp; |
2258 | return true; | 2206 | return true; |
2259 | } | 2207 | } |
2260 | bool CalendarView::checkFileVersion(QString fn) | 2208 | bool CalendarView::checkFileVersion(QString fn) |
2261 | { | 2209 | { |
2262 | QFileInfo finf ( fn ); | 2210 | QFileInfo finf ( fn ); |
2263 | if ( !finf.exists() ) | 2211 | if ( !finf.exists() ) |
2264 | return true; | 2212 | return true; |
2265 | QDateTime dt = finf.lastModified (); | 2213 | QDateTime dt = finf.lastModified (); |
2266 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2214 | qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2267 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2215 | qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2268 | if ( dt <= loadedFileVersion ) | 2216 | if ( dt <= loadedFileVersion ) |
2269 | return true; | 2217 | return true; |
2270 | 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)) , | 2218 | 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)) , |
2271 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2219 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2272 | i18n("Sync+save")); | 2220 | i18n("Sync+save")); |
2273 | 2221 | ||
2274 | if ( km == KMessageBox::Cancel ) | 2222 | if ( km == KMessageBox::Cancel ) |
2275 | return false; | 2223 | return false; |
2276 | if ( km == KMessageBox::Yes ) | 2224 | if ( km == KMessageBox::Yes ) |
2277 | return true; | 2225 | return true; |
2278 | 2226 | ||
2279 | setSyncDevice("deleteaftersync" ); | 2227 | setSyncDevice("deleteaftersync" ); |
2280 | mSyncManager->mAskForPreferences = true; | 2228 | mSyncManager->mAskForPreferences = true; |
2281 | mSyncManager->mSyncAlgoPrefs = 3; | 2229 | mSyncManager->mSyncAlgoPrefs = 3; |
2282 | mSyncManager->mWriteBackFile = false; | 2230 | mSyncManager->mWriteBackFile = false; |
2283 | mSyncManager->mWriteBackExistingOnly = false; | 2231 | mSyncManager->mWriteBackExistingOnly = false; |
2284 | mSyncManager->mShowSyncSummary = false; | 2232 | mSyncManager->mShowSyncSummary = false; |
2285 | syncCalendar( fn, 3 ); | 2233 | syncCalendar( fn, 3 ); |
2286 | Event * e = getLastSyncEvent(); | 2234 | Event * e = getLastSyncEvent(); |
2287 | if ( e ) | 2235 | if ( e ) |
2288 | mCalendar->deleteEvent( e ); | 2236 | mCalendar->deleteEvent( e ); |
2289 | return true; | 2237 | return true; |
2290 | } | 2238 | } |
2291 | bool CalendarView::saveCalendars() | 2239 | bool CalendarView::saveCalendars() |
2292 | { | 2240 | { |
2293 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2241 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2294 | KopiCalendarFile * cal = calendars.first(); | 2242 | KopiCalendarFile * cal = calendars.first(); |
2295 | mCalendar->setDefaultCalendar( 1 ); | 2243 | mCalendar->setDefaultCalendar( 1 ); |
2296 | mCalendar->setDefaultCalendarEnabledOnly(); | 2244 | mCalendar->setDefaultCalendarEnabledOnly(); |
2297 | saveCalendar( MainWindow::defaultFileName() ); | 2245 | saveCalendar( MainWindow::defaultFileName() ); |
2298 | cal = calendars.next(); | 2246 | cal = calendars.next(); |
2299 | while ( cal ) { | 2247 | while ( cal ) { |
2300 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2248 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2301 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2249 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2302 | mCalendar->setDefaultCalendarEnabledOnly(); | 2250 | mCalendar->setDefaultCalendarEnabledOnly(); |
2303 | if ( saveCalendar( cal->mFileName ) ) | 2251 | if ( saveCalendar( cal->mFileName ) ) |
2304 | cal->mLoadDt = QDateTime::currentDateTime(); | 2252 | cal->mLoadDt = QDateTime::currentDateTime(); |
2305 | } | 2253 | } |
2306 | cal = calendars.next(); | 2254 | cal = calendars.next(); |
2307 | } | 2255 | } |
2308 | restoreCalendarSettings(); | 2256 | restoreCalendarSettings(); |
2309 | return true; | 2257 | return true; |
2310 | } | 2258 | } |
2311 | bool CalendarView::saveCalendar( QString filename ) | 2259 | bool CalendarView::saveCalendar( QString filename ) |
2312 | { | 2260 | { |
2313 | 2261 | ||
2314 | // Store back all unsaved data into calendar object | 2262 | // Store back all unsaved data into calendar object |
2315 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2263 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index b290020..779f12e 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -100,2162 +100,2166 @@ int MarcusBains::todayColumn() | |||
100 | return KOGlobals::self()->reverseLayout() ? | 100 | return KOGlobals::self()->reverseLayout() ? |
101 | agenda->columns() - 1 - col : col; | 101 | agenda->columns() - 1 - col : col; |
102 | ++col; | 102 | ++col; |
103 | } | 103 | } |
104 | 104 | ||
105 | return -1; | 105 | return -1; |
106 | } | 106 | } |
107 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
108 | { | 108 | { |
109 | updateLocation(); | 109 | updateLocation(); |
110 | } | 110 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 111 | void MarcusBains::updateLocation(bool recalculate) |
112 | { | 112 | { |
113 | 113 | ||
114 | QTime tim = QTime::currentTime(); | 114 | QTime tim = QTime::currentTime(); |
115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
116 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 116 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
117 | recalculate = true; | 117 | recalculate = true; |
118 | 118 | ||
119 | int mins = tim.hour()*60 + tim.minute(); | 119 | int mins = tim.hour()*60 + tim.minute(); |
120 | int minutesPerCell = 24 * 60 / agenda->rows(); | 120 | int minutesPerCell = 24 * 60 / agenda->rows(); |
121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
122 | int today = recalculate ? todayColumn() : oldToday; | 122 | int today = recalculate ? todayColumn() : oldToday; |
123 | int x = agenda->gridSpacingX()*today; | 123 | int x = agenda->gridSpacingX()*today; |
124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
125 | 125 | ||
126 | oldTime = tim; | 126 | oldTime = tim; |
127 | oldToday = today; | 127 | oldToday = today; |
128 | 128 | ||
129 | if(disabled || (today<0)) { | 129 | if(disabled || (today<0)) { |
130 | hide(); mTimeBox->hide(); | 130 | hide(); mTimeBox->hide(); |
131 | return; | 131 | return; |
132 | } else { | 132 | } else { |
133 | show(); mTimeBox->show(); | 133 | show(); mTimeBox->show(); |
134 | } | 134 | } |
135 | 135 | ||
136 | if(recalculate) | 136 | if(recalculate) |
137 | setFixedSize(agenda->gridSpacingX(),1); | 137 | setFixedSize(agenda->gridSpacingX(),1); |
138 | agenda->moveChild(this, x, y); | 138 | agenda->moveChild(this, x, y); |
139 | raise(); | 139 | raise(); |
140 | 140 | ||
141 | if(recalculate) | 141 | if(recalculate) |
142 | //mTimeBox->setFont(QFont("helvetica",10)); | 142 | //mTimeBox->setFont(QFont("helvetica",10)); |
143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
144 | 144 | ||
145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
146 | mTimeBox->adjustSize(); | 146 | mTimeBox->adjustSize(); |
147 | // the -2 below is there because there is a bug in this program | 147 | // the -2 below is there because there is a bug in this program |
148 | // somewhere, where the last column of this widget is a few pixels | 148 | // somewhere, where the last column of this widget is a few pixels |
149 | // narrower than the other columns. | 149 | // narrower than the other columns. |
150 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 150 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
151 | agenda->moveChild(mTimeBox, | 151 | agenda->moveChild(mTimeBox, |
152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
153 | y-mTimeBox->height()); | 153 | y-mTimeBox->height()); |
154 | mTimeBox->raise(); | 154 | mTimeBox->raise(); |
155 | //mTimeBox->setAutoMask(true); | 155 | //mTimeBox->setAutoMask(true); |
156 | int secs = QTime::currentTime().second(); | 156 | int secs = QTime::currentTime().second(); |
157 | minutes->start( (60 - secs +1)*1000 ,true); | 157 | minutes->start( (60 - secs +1)*1000 ,true); |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | //////////////////////////////////////////////////////////////////////////// | 161 | //////////////////////////////////////////////////////////////////////////// |
162 | 162 | ||
163 | 163 | ||
164 | /* | 164 | /* |
165 | Create an agenda widget with rows rows and columns columns. | 165 | Create an agenda widget with rows rows and columns columns. |
166 | */ | 166 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
168 | const char *name,WFlags f) : | 168 | const char *name,WFlags f) : |
169 | QScrollView(parent,name,f) | 169 | QScrollView(parent,name,f) |
170 | { | 170 | { |
171 | 171 | ||
172 | mAllAgendaPopup = 0; | 172 | mAllAgendaPopup = 0; |
173 | mColumns = columns; | 173 | mColumns = columns; |
174 | mRows = rows; | 174 | mRows = rows; |
175 | mGridSpacingY = rowSize; | 175 | mGridSpacingY = rowSize; |
176 | mAllDayMode = false; | 176 | mAllDayMode = false; |
177 | #ifndef DESKTOP_VERSION | 177 | #ifndef DESKTOP_VERSION |
178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
179 | #endif | 179 | #endif |
180 | mHolidayMask = 0; | 180 | mHolidayMask = 0; |
181 | init(); | 181 | init(); |
182 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); | 182 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); |
183 | } | 183 | } |
184 | 184 | ||
185 | /* | 185 | /* |
186 | Create an agenda widget with columns columns and one row. This is used for | 186 | Create an agenda widget with columns columns and one row. This is used for |
187 | all-day events. | 187 | all-day events. |
188 | */ | 188 | */ |
189 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 189 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
190 | QScrollView(parent,name,f) | 190 | QScrollView(parent,name,f) |
191 | { | 191 | { |
192 | mAllAgendaPopup = 0; | 192 | mAllAgendaPopup = 0; |
193 | blockResize = false; | 193 | blockResize = false; |
194 | mColumns = columns; | 194 | mColumns = columns; |
195 | mRows = 1; | 195 | mRows = 1; |
196 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 196 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
197 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 197 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
198 | mAllDayMode = true; | 198 | mAllDayMode = true; |
199 | #ifndef DESKTOP_VERSION | 199 | #ifndef DESKTOP_VERSION |
200 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 200 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
201 | #endif | 201 | #endif |
202 | mHolidayMask = 0; | 202 | mHolidayMask = 0; |
203 | init(); | 203 | init(); |
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | KOAgenda::~KOAgenda() | 207 | KOAgenda::~KOAgenda() |
208 | { | 208 | { |
209 | if(mMarcusBains) delete mMarcusBains; | 209 | if(mMarcusBains) delete mMarcusBains; |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | Incidence *KOAgenda::selectedIncidence() const | 213 | Incidence *KOAgenda::selectedIncidence() const |
214 | { | 214 | { |
215 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 215 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | QDate KOAgenda::selectedIncidenceDate() const | 219 | QDate KOAgenda::selectedIncidenceDate() const |
220 | { | 220 | { |
221 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 221 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | void KOAgenda::init() | 225 | void KOAgenda::init() |
226 | { | 226 | { |
227 | mPopupTimer = new QTimer(this); | 227 | mPopupTimer = new QTimer(this); |
228 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 228 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
229 | 229 | ||
230 | mNewItemPopup = new QPopupMenu( this ); | 230 | mNewItemPopup = new QPopupMenu( this ); |
231 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 231 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
232 | QString pathString = ""; | 232 | QString pathString = ""; |
233 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 233 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
234 | if ( QApplication::desktop()->width() < 480 ) | 234 | if ( QApplication::desktop()->width() < 480 ) |
235 | pathString += "icons16/"; | 235 | pathString += "icons16/"; |
236 | } else | 236 | } else |
237 | pathString += "iconsmini/"; | 237 | pathString += "iconsmini/"; |
238 | 238 | ||
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
241 | mNewItemPopup->insertSeparator ( ); | 241 | mNewItemPopup->insertSeparator ( ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
248 | #ifndef _WIN32_ | 248 | #ifndef _WIN32_ |
249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
250 | viewport()->setWFlags ( wflags); | 250 | viewport()->setWFlags ( wflags); |
251 | #endif | 251 | #endif |
252 | mGridSpacingX = 80; | 252 | mGridSpacingX = 80; |
253 | mResizeBorderWidth = 8; | 253 | mResizeBorderWidth = 8; |
254 | mScrollBorderWidth = 8; | 254 | mScrollBorderWidth = 8; |
255 | mScrollDelay = 30; | 255 | mScrollDelay = 30; |
256 | mScrollOffset = 10; | 256 | mScrollOffset = 10; |
257 | mPaintPixmap.resize( 20,20); | 257 | mPaintPixmap.resize( 20,20); |
258 | //enableClipper(true); | 258 | //enableClipper(true); |
259 | 259 | ||
260 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 260 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
261 | // effect. Has to be fixed. | 261 | // effect. Has to be fixed. |
262 | setFocusPolicy(WheelFocus); | 262 | setFocusPolicy(WheelFocus); |
263 | 263 | ||
264 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 264 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
265 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 265 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
266 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 266 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
267 | 267 | ||
268 | mStartCellX = 0; | 268 | mStartCellX = 0; |
269 | mStartCellY = 0; | 269 | mStartCellY = 0; |
270 | mCurrentCellX = 0; | 270 | mCurrentCellX = 0; |
271 | mCurrentCellY = 0; | 271 | mCurrentCellY = 0; |
272 | 272 | ||
273 | mSelectionCellX = 0; | 273 | mSelectionCellX = 0; |
274 | mSelectionYTop = 0; | 274 | mSelectionYTop = 0; |
275 | mSelectionHeight = 0; | 275 | mSelectionHeight = 0; |
276 | 276 | ||
277 | mOldLowerScrollValue = -1; | 277 | mOldLowerScrollValue = -1; |
278 | mOldUpperScrollValue = -1; | 278 | mOldUpperScrollValue = -1; |
279 | 279 | ||
280 | mClickedItem = 0; | 280 | mClickedItem = 0; |
281 | 281 | ||
282 | mActionItem = 0; | 282 | mActionItem = 0; |
283 | mActionType = NOP; | 283 | mActionType = NOP; |
284 | mItemMoved = false; | 284 | mItemMoved = false; |
285 | 285 | ||
286 | mSelectedItem = 0; | 286 | mSelectedItem = 0; |
287 | 287 | ||
288 | // mItems.setAutoDelete(true); | 288 | // mItems.setAutoDelete(true); |
289 | 289 | ||
290 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 290 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
291 | 291 | ||
292 | viewport()->update(); | 292 | viewport()->update(); |
293 | 293 | ||
294 | setMinimumSize(30, 1); | 294 | setMinimumSize(30, 1); |
295 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 295 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
296 | 296 | ||
297 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 297 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
298 | // controlled in a way that the contents horizontally always fits. Then it is | 298 | // controlled in a way that the contents horizontally always fits. Then it is |
299 | // not necessary to turn off the scrollbar. | 299 | // not necessary to turn off the scrollbar. |
300 | setHScrollBarMode(AlwaysOff); | 300 | setHScrollBarMode(AlwaysOff); |
301 | if ( ! mAllDayMode ) | 301 | if ( ! mAllDayMode ) |
302 | setVScrollBarMode(AlwaysOn); | 302 | setVScrollBarMode(AlwaysOn); |
303 | else | 303 | else |
304 | setVScrollBarMode(AlwaysOff); | 304 | setVScrollBarMode(AlwaysOff); |
305 | 305 | ||
306 | setStartHour(KOPrefs::instance()->mDayBegins); | 306 | setStartHour(KOPrefs::instance()->mDayBegins); |
307 | 307 | ||
308 | calculateWorkingHours(); | 308 | calculateWorkingHours(); |
309 | 309 | ||
310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
311 | SLOT(checkScrollBoundaries(int))); | 311 | SLOT(checkScrollBoundaries(int))); |
312 | 312 | ||
313 | // Create the Marcus Bains line. | 313 | // Create the Marcus Bains line. |
314 | if(mAllDayMode) | 314 | if(mAllDayMode) |
315 | mMarcusBains = 0; | 315 | mMarcusBains = 0; |
316 | else { | 316 | else { |
317 | mMarcusBains = new MarcusBains(this); | 317 | mMarcusBains = new MarcusBains(this); |
318 | addChild(mMarcusBains); | 318 | addChild(mMarcusBains); |
319 | } | 319 | } |
320 | mPopupKind = 0; | 320 | mPopupKind = 0; |
321 | mPopupItem = 0; | 321 | mPopupItem = 0; |
322 | mInvalidPixmap = false; | 322 | mInvalidPixmap = false; |
323 | 323 | ||
324 | } | 324 | } |
325 | 325 | ||
326 | void KOAgenda::shrinkPixmap() | 326 | void KOAgenda::shrinkPixmap() |
327 | { | 327 | { |
328 | mPaintPixmap.resize( 20,20); | 328 | mPaintPixmap.resize( 20,20); |
329 | mInvalidPixmap = true; | 329 | mInvalidPixmap = true; |
330 | } | 330 | } |
331 | void KOAgenda::slotContentMove(int,int) | 331 | void KOAgenda::slotContentMove(int,int) |
332 | { | 332 | { |
333 | emit sendPing(); | 333 | emit sendPing(); |
334 | if ( mActionType == NOP ) | 334 | if ( mActionType == NOP ) |
335 | slotClearSelection(); | 335 | slotClearSelection(); |
336 | if ( mSelectedItem && !mActionItem ) { | 336 | if ( mSelectedItem && !mActionItem ) { |
337 | deselectItem(); | 337 | deselectItem(); |
338 | emit incidenceSelected( 0 ); | 338 | emit incidenceSelected( 0 ); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | void KOAgenda::clear() | 341 | void KOAgenda::clear() |
342 | { | 342 | { |
343 | KOAgendaItem *item; | 343 | KOAgendaItem *item; |
344 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 344 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
345 | mUnusedItems.append( item ); | 345 | mUnusedItems.append( item ); |
346 | //item->hide(); | 346 | //item->hide(); |
347 | } | 347 | } |
348 | mItems.clear(); | 348 | mItems.clear(); |
349 | mSelectedItem = 0; | 349 | mSelectedItem = 0; |
350 | clearSelection(); | 350 | clearSelection(); |
351 | } | 351 | } |
352 | 352 | ||
353 | void KOAgenda::clearSelection() | 353 | void KOAgenda::clearSelection() |
354 | { | 354 | { |
355 | mSelectionCellX = 0; | 355 | mSelectionCellX = 0; |
356 | mSelectionYTop = 0; | 356 | mSelectionYTop = 0; |
357 | mSelectionHeight = 0; | 357 | mSelectionHeight = 0; |
358 | } | 358 | } |
359 | 359 | ||
360 | void KOAgenda::marcus_bains() | 360 | void KOAgenda::marcus_bains() |
361 | { | 361 | { |
362 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 362 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | void KOAgenda::changeColumns(int columns) | 366 | void KOAgenda::changeColumns(int columns) |
367 | { | 367 | { |
368 | if (columns == 0) { | 368 | if (columns == 0) { |
369 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 369 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
370 | return; | 370 | return; |
371 | } | 371 | } |
372 | clear(); | 372 | clear(); |
373 | mColumns = columns; | 373 | mColumns = columns; |
374 | computeSizes(); | 374 | computeSizes(); |
375 | } | 375 | } |
376 | 376 | ||
377 | /* | 377 | /* |
378 | This is the eventFilter function, which gets all events from the KOAgendaItems | 378 | This is the eventFilter function, which gets all events from the KOAgendaItems |
379 | contained in the agenda. It has to handle moving and resizing for all items. | 379 | contained in the agenda. It has to handle moving and resizing for all items. |
380 | */ | 380 | */ |
381 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 381 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
382 | { | 382 | { |
383 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 383 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
384 | switch(event->type()) { | 384 | switch(event->type()) { |
385 | case QEvent::MouseButtonPress: | 385 | case QEvent::MouseButtonPress: |
386 | case QEvent::MouseButtonDblClick: | 386 | case QEvent::MouseButtonDblClick: |
387 | case QEvent::MouseButtonRelease: | 387 | case QEvent::MouseButtonRelease: |
388 | case QEvent::MouseMove: | 388 | case QEvent::MouseMove: |
389 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 389 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
390 | 390 | ||
391 | case (QEvent::Leave): | 391 | case (QEvent::Leave): |
392 | if (!mActionItem) | 392 | if (!mActionItem) |
393 | setCursor(arrowCursor); | 393 | setCursor(arrowCursor); |
394 | return true; | 394 | return true; |
395 | 395 | ||
396 | default: | 396 | default: |
397 | return QScrollView::eventFilter(object,event); | 397 | return QScrollView::eventFilter(object,event); |
398 | } | 398 | } |
399 | } | 399 | } |
400 | void KOAgenda::popupMenu() | 400 | void KOAgenda::popupMenu() |
401 | { | 401 | { |
402 | mPopupTimer->stop(); | 402 | mPopupTimer->stop(); |
403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
404 | if (mActionItem ) { | 404 | if (mActionItem ) { |
405 | endItemAction(); | 405 | endItemAction(); |
406 | } | 406 | } |
407 | mLeftMouseDown = false; // no more leftMouse computation | 407 | mLeftMouseDown = false; // no more leftMouse computation |
408 | if (mPopupItem) { | 408 | if (mPopupItem) { |
409 | //mClickedItem = mPopupItem; | 409 | //mClickedItem = mPopupItem; |
410 | selectItem(mPopupItem); | 410 | selectItem(mPopupItem); |
411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
412 | mAllAgendaPopup->installEventFilter( this ); | 412 | mAllAgendaPopup->installEventFilter( this ); |
413 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 413 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
414 | 414 | ||
415 | } | 415 | } |
416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
418 | endSelectAction( false ); // do not emit new event signal | 418 | endSelectAction( false ); // do not emit new event signal |
419 | mLeftMouseDown = false; // no more leftMouse computation | 419 | mLeftMouseDown = false; // no more leftMouse computation |
420 | } | 420 | } |
421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
422 | mNewItemPopup->installEventFilter( this ); | 422 | mNewItemPopup->installEventFilter( this ); |
423 | mNewItemPopup->popup( mPopupPos); | 423 | mNewItemPopup->popup( mPopupPos); |
424 | 424 | ||
425 | } | 425 | } |
426 | mLeftMouseDown = false; | 426 | mLeftMouseDown = false; |
427 | mPopupItem = 0; | 427 | mPopupItem = 0; |
428 | mPopupKind = 0; | 428 | mPopupKind = 0; |
429 | } | 429 | } |
430 | void KOAgenda::categoryChanged(Incidence * inc) | 430 | void KOAgenda::categoryChanged(Incidence * inc) |
431 | { | 431 | { |
432 | KOAgendaItem *item; | 432 | KOAgendaItem *item; |
433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
434 | if ( item->incidence() == inc ) { | 434 | if ( item->incidence() == inc ) { |
435 | item->initColor (); | 435 | item->initColor (); |
436 | item->updateItem(); | 436 | item->updateItem(); |
437 | } | 437 | } |
438 | } | 438 | } |
439 | } | 439 | } |
440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
441 | { | 441 | { |
442 | 442 | ||
443 | if ( mInvalidPixmap ) { | 443 | if ( mInvalidPixmap ) { |
444 | mInvalidPixmap = false; | 444 | mInvalidPixmap = false; |
445 | qDebug("KO: Upsizing Pixmaps "); | 445 | qDebug("KO: Upsizing Pixmaps "); |
446 | computeSizes(); | 446 | computeSizes(); |
447 | emit updateViewSignal(); | 447 | emit updateViewSignal(); |
448 | return true; | 448 | return true; |
449 | } | 449 | } |
450 | emit sendPing(); | 450 | emit sendPing(); |
451 | static int startX = 0; | 451 | static int startX = 0; |
452 | static int startY = 0; | 452 | static int startY = 0; |
453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
454 | static bool blockMoving = true; | 454 | static bool blockMoving = true; |
455 | 455 | ||
456 | //qDebug("KOAgenda::eventFilter_mous "); | 456 | //qDebug("KOAgenda::eventFilter_mous "); |
457 | if ( object == mNewItemPopup ) { | 457 | if ( object == mNewItemPopup ) { |
458 | //qDebug("mNewItemPopup "); | 458 | //qDebug("mNewItemPopup "); |
459 | if ( me->type() == QEvent::MouseButtonRelease ) { | 459 | if ( me->type() == QEvent::MouseButtonRelease ) { |
460 | mNewItemPopup->removeEventFilter( this ); | 460 | mNewItemPopup->removeEventFilter( this ); |
461 | int dX = me->globalPos().x() - mPopupPos.x();; | 461 | int dX = me->globalPos().x() - mPopupPos.x();; |
462 | if ( dX < 0 ) | 462 | if ( dX < 0 ) |
463 | dX = -dX; | 463 | dX = -dX; |
464 | int dY = me->globalPos().y() - mPopupPos.y(); | 464 | int dY = me->globalPos().y() - mPopupPos.y(); |
465 | if ( dY < 0 ) | 465 | if ( dY < 0 ) |
466 | dY = -dY; | 466 | dY = -dY; |
467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
468 | mNewItemPopup->hide(); | 468 | mNewItemPopup->hide(); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | return true; | 471 | return true; |
472 | } | 472 | } |
473 | if ( object == mAllAgendaPopup ) { | 473 | if ( object == mAllAgendaPopup ) { |
474 | //qDebug(" mAllAgendaPopup "); | 474 | //qDebug(" mAllAgendaPopup "); |
475 | if ( me->type() == QEvent::MouseButtonRelease ) { | 475 | if ( me->type() == QEvent::MouseButtonRelease ) { |
476 | mAllAgendaPopup->removeEventFilter( this ); | 476 | mAllAgendaPopup->removeEventFilter( this ); |
477 | int dX = me->globalPos().x() - mPopupPos.x();; | 477 | int dX = me->globalPos().x() - mPopupPos.x();; |
478 | if ( dX < 0 ) | 478 | if ( dX < 0 ) |
479 | dX = -dX; | 479 | dX = -dX; |
480 | int dY = me->globalPos().y() - mPopupPos.y(); | 480 | int dY = me->globalPos().y() - mPopupPos.y(); |
481 | if ( dY < 0 ) | 481 | if ( dY < 0 ) |
482 | dY = -dY; | 482 | dY = -dY; |
483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
484 | mAllAgendaPopup->hide(); | 484 | mAllAgendaPopup->hide(); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | return true; | 487 | return true; |
488 | } | 488 | } |
489 | QPoint viewportPos; | 489 | QPoint viewportPos; |
490 | if (object != viewport()) { | 490 | if (object != viewport()) { |
491 | blockmoveDist = blockmoveDist*2; | 491 | blockmoveDist = blockmoveDist*2; |
492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
493 | } else { | 493 | } else { |
494 | viewportPos = me->pos(); | 494 | viewportPos = me->pos(); |
495 | } | 495 | } |
496 | bool objIsNotViewport = (object != viewport()); | 496 | bool objIsNotViewport = (object != viewport()); |
497 | bool leftButt = false; | 497 | bool leftButt = false; |
498 | #ifdef DESKTOP_VERSION | 498 | #ifdef DESKTOP_VERSION |
499 | leftButt = (me->button() == LeftButton); | 499 | leftButt = (me->button() == LeftButton); |
500 | #endif | 500 | #endif |
501 | switch (me->type()) { | 501 | switch (me->type()) { |
502 | case QEvent::MouseButtonPress: | 502 | case QEvent::MouseButtonPress: |
503 | if (me->button() == LeftButton) { | 503 | if (me->button() == LeftButton) { |
504 | mPopupTimer->start( 600 ); | 504 | mPopupTimer->start( 600 ); |
505 | mLeftMouseDown = true; | 505 | mLeftMouseDown = true; |
506 | } | 506 | } |
507 | blockMoving = true; | 507 | blockMoving = true; |
508 | startX = viewportPos.x(); | 508 | startX = viewportPos.x(); |
509 | startY = viewportPos.y(); | 509 | startY = viewportPos.y(); |
510 | mPopupPos = me->globalPos(); | 510 | mPopupPos = me->globalPos(); |
511 | if ( objIsNotViewport && !leftButt ) { | 511 | if ( objIsNotViewport && !leftButt ) { |
512 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 512 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
513 | if (mAllDayMode) { | 513 | if (mAllDayMode) { |
514 | if ( tempItem->height() > 10 ) { | 514 | if ( tempItem->height() > 10 ) { |
515 | int minV = tempItem->height()/4; | 515 | int minV = tempItem->height()/4; |
516 | if ( minV > (blockmoveDist/2)-2 ) { | 516 | if ( minV > (blockmoveDist/2)-2 ) { |
517 | if ( minV > blockmoveDist ) | 517 | if ( minV > blockmoveDist ) |
518 | minV = blockmoveDist; | 518 | minV = blockmoveDist; |
519 | else | 519 | else |
520 | minV = (blockmoveDist/2); | 520 | minV = (blockmoveDist/2); |
521 | } | 521 | } |
522 | bool border = false; | 522 | bool border = false; |
523 | int diff = tempItem->y() - viewportPos.y(); | 523 | int diff = tempItem->y() - viewportPos.y(); |
524 | if ( diff < 0 ) | 524 | if ( diff < 0 ) |
525 | diff *= -1; | 525 | diff *= -1; |
526 | if ( diff < minV ) { | 526 | if ( diff < minV ) { |
527 | border = true; | 527 | border = true; |
528 | objIsNotViewport = false; | 528 | objIsNotViewport = false; |
529 | } | 529 | } |
530 | if ( ! border ) { | 530 | if ( ! border ) { |
531 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 531 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
532 | if ( diff < 0 ) | 532 | if ( diff < 0 ) |
533 | diff *= -1; | 533 | diff *= -1; |
534 | if ( diff < minV ) { | 534 | if ( diff < minV ) { |
535 | border = true; | 535 | border = true; |
536 | objIsNotViewport = false; | 536 | objIsNotViewport = false; |
537 | } | 537 | } |
538 | } | 538 | } |
539 | } | 539 | } |
540 | } else { // not allday | 540 | } else { // not allday |
541 | if ( tempItem->width() > 10 ) { | 541 | if ( tempItem->width() > 10 ) { |
542 | int minH = tempItem->width()/4; | 542 | int minH = tempItem->width()/4; |
543 | if ( minH > (blockmoveDist/2)-2 ) { | 543 | if ( minH > (blockmoveDist/2)-2 ) { |
544 | if ( minH > blockmoveDist ) | 544 | if ( minH > blockmoveDist ) |
545 | minH = blockmoveDist; | 545 | minH = blockmoveDist; |
546 | else | 546 | else |
547 | minH = (blockmoveDist/2); | 547 | minH = (blockmoveDist/2); |
548 | } | 548 | } |
549 | bool border = false; | 549 | bool border = false; |
550 | int diff = tempItem->x() - viewportPos.x(); | 550 | int diff = tempItem->x() - viewportPos.x(); |
551 | if ( diff < 0 ) | 551 | if ( diff < 0 ) |
552 | diff *= -1; | 552 | diff *= -1; |
553 | if ( diff < minH ) { | 553 | if ( diff < minH ) { |
554 | border = true; | 554 | border = true; |
555 | objIsNotViewport = false; | 555 | objIsNotViewport = false; |
556 | } | 556 | } |
557 | if ( ! border ) { | 557 | if ( ! border ) { |
558 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); | 558 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); |
559 | if ( diff < 0 ) | 559 | if ( diff < 0 ) |
560 | diff *= -1; | 560 | diff *= -1; |
561 | if ( diff < minH ) { | 561 | if ( diff < minH ) { |
562 | border = true; | 562 | border = true; |
563 | objIsNotViewport = false; | 563 | objIsNotViewport = false; |
564 | } | 564 | } |
565 | } | 565 | } |
566 | } | 566 | } |
567 | } | 567 | } |
568 | } | 568 | } |
569 | if ( objIsNotViewport ) { | 569 | if ( objIsNotViewport ) { |
570 | mPopupItem = (KOAgendaItem *)object; | 570 | mPopupItem = (KOAgendaItem *)object; |
571 | mPopupKind = 1; | 571 | mPopupKind = 1; |
572 | if (me->button() == RightButton) { | 572 | if (me->button() == RightButton) { |
573 | mPopupKind = 3; | 573 | mPopupKind = 3; |
574 | popupMenu(); | 574 | popupMenu(); |
575 | } else if (me->button() == LeftButton) { | 575 | } else if (me->button() == LeftButton) { |
576 | mActionItem = (KOAgendaItem *)object; | 576 | mActionItem = (KOAgendaItem *)object; |
577 | if (mActionItem) { | 577 | if (mActionItem) { |
578 | emit signalClearSelection(); | 578 | emit signalClearSelection(); |
579 | slotClearSelection(); | 579 | slotClearSelection(); |
580 | selectItem(mActionItem); | 580 | selectItem(mActionItem); |
581 | Incidence *incidence = mActionItem->incidence(); | 581 | Incidence *incidence = mActionItem->incidence(); |
582 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 582 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
583 | mActionItem = 0; | 583 | mActionItem = 0; |
584 | } else { | 584 | } else { |
585 | startItemAction(viewportPos); | 585 | startItemAction(viewportPos); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | } | 588 | } |
589 | } else { // ---------- viewport() | 589 | } else { // ---------- viewport() |
590 | mPopupItem = 0; | 590 | mPopupItem = 0; |
591 | mPopupKind = 2; | 591 | mPopupKind = 2; |
592 | selectItem(0); | 592 | selectItem(0); |
593 | mActionItem = 0; | 593 | mActionItem = 0; |
594 | if (me->button() == RightButton) { | 594 | if (me->button() == RightButton) { |
595 | int x,y; | 595 | int x,y; |
596 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 596 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
597 | int gx,gy; | 597 | int gx,gy; |
598 | contentsToGrid(x,y,gx,gy); | 598 | contentsToGrid(x,y,gx,gy); |
599 | mCurrentCellX = gx; | 599 | mCurrentCellX = gx; |
600 | mCurrentCellY = gy; | 600 | mCurrentCellY = gy; |
601 | mStartCellX = gx; | 601 | mStartCellX = gx; |
602 | mStartCellY = gy; | 602 | mStartCellY = gy; |
603 | mPopupKind = 4; | 603 | mPopupKind = 4; |
604 | popupMenu(); | 604 | popupMenu(); |
605 | } else if (me->button() == LeftButton) { | 605 | } else if (me->button() == LeftButton) { |
606 | setCursor(arrowCursor); | 606 | setCursor(arrowCursor); |
607 | startSelectAction(viewportPos); | 607 | startSelectAction(viewportPos); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | break; | 610 | break; |
611 | 611 | ||
612 | case QEvent::MouseButtonRelease: | 612 | case QEvent::MouseButtonRelease: |
613 | if (me->button() == LeftButton ) { | 613 | if (me->button() == LeftButton ) { |
614 | mPopupTimer->stop(); | 614 | mPopupTimer->stop(); |
615 | } | 615 | } |
616 | if (object != viewport()) { | 616 | if (object != viewport()) { |
617 | if (me->button() == LeftButton && mLeftMouseDown) { | 617 | if (me->button() == LeftButton && mLeftMouseDown) { |
618 | if (mActionItem) { | 618 | if (mActionItem) { |
619 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 619 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
620 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 620 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
621 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 621 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
622 | mScrollUpTimer.stop(); | 622 | mScrollUpTimer.stop(); |
623 | mScrollDownTimer.stop(); | 623 | mScrollDownTimer.stop(); |
624 | mActionItem->resetMove(); | 624 | mActionItem->resetMove(); |
625 | placeSubCells( mActionItem ); | 625 | placeSubCells( mActionItem ); |
626 | // emit startDragSignal( mActionItem->incidence() ); | 626 | // emit startDragSignal( mActionItem->incidence() ); |
627 | setCursor( arrowCursor ); | 627 | setCursor( arrowCursor ); |
628 | mActionItem = 0; | 628 | mActionItem = 0; |
629 | mActionType = NOP; | 629 | mActionType = NOP; |
630 | mItemMoved = 0; | 630 | mItemMoved = 0; |
631 | mLeftMouseDown = false; | 631 | mLeftMouseDown = false; |
632 | return true; | 632 | return true; |
633 | } | 633 | } |
634 | endItemAction(); | 634 | endItemAction(); |
635 | } | 635 | } |
636 | } | 636 | } |
637 | 637 | ||
638 | } else { // ---------- viewport() | 638 | } else { // ---------- viewport() |
639 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 639 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
640 | endSelectAction( true ); // emit new event signal | 640 | endSelectAction( true ); // emit new event signal |
641 | } | 641 | } |
642 | } | 642 | } |
643 | if (me->button() == LeftButton) | 643 | if (me->button() == LeftButton) |
644 | mLeftMouseDown = false; | 644 | mLeftMouseDown = false; |
645 | 645 | ||
646 | break; | 646 | break; |
647 | 647 | ||
648 | case QEvent::MouseMove: | 648 | case QEvent::MouseMove: |
649 | //qDebug("mm "); | 649 | //qDebug("mm "); |
650 | if ( !mLeftMouseDown ) | 650 | if ( !mLeftMouseDown ) |
651 | return false; | 651 | return false; |
652 | if ( blockMoving ) { | 652 | if ( blockMoving ) { |
653 | int dX, dY; | 653 | int dX, dY; |
654 | dX = startX - viewportPos.x(); | 654 | dX = startX - viewportPos.x(); |
655 | if ( dX < 0 ) | 655 | if ( dX < 0 ) |
656 | dX = -dX; | 656 | dX = -dX; |
657 | dY = viewportPos.y() - startY; | 657 | dY = viewportPos.y() - startY; |
658 | if ( dY < 0 ) | 658 | if ( dY < 0 ) |
659 | dY = -dY; | 659 | dY = -dY; |
660 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 660 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
661 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 661 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
662 | blockMoving = false; | 662 | blockMoving = false; |
663 | } | 663 | } |
664 | } | 664 | } |
665 | if ( ! blockMoving ) | 665 | if ( ! blockMoving ) |
666 | mPopupTimer->stop(); | 666 | mPopupTimer->stop(); |
667 | if (object != viewport()) { | 667 | if (object != viewport()) { |
668 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 668 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
669 | if (!moveItem->incidence()->isReadOnly() ) { | 669 | if (!moveItem->incidence()->isReadOnly() ) { |
670 | if (!mActionItem) | 670 | if (!mActionItem) |
671 | setNoActionCursor(moveItem,viewportPos); | 671 | setNoActionCursor(moveItem,viewportPos); |
672 | else { | 672 | else { |
673 | if ( !blockMoving ) | 673 | if ( !blockMoving ) |
674 | performItemAction(viewportPos); | 674 | performItemAction(viewportPos); |
675 | } | 675 | } |
676 | } | 676 | } |
677 | } else { // ---------- viewport() | 677 | } else { // ---------- viewport() |
678 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 678 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
679 | if ( mActionType == SELECT ) { | 679 | if ( mActionType == SELECT ) { |
680 | performSelectAction( viewportPos ); | 680 | performSelectAction( viewportPos ); |
681 | } | 681 | } |
682 | } | 682 | } |
683 | break; | 683 | break; |
684 | 684 | ||
685 | case QEvent::MouseButtonDblClick: | 685 | case QEvent::MouseButtonDblClick: |
686 | mPopupTimer->stop(); | 686 | mPopupTimer->stop(); |
687 | if (object == viewport()) { | 687 | if (object == viewport()) { |
688 | selectItem(0); | 688 | selectItem(0); |
689 | int x,y; | 689 | int x,y; |
690 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 690 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
691 | int gx,gy; | 691 | int gx,gy; |
692 | contentsToGrid(x,y,gx,gy); | 692 | contentsToGrid(x,y,gx,gy); |
693 | emit newEventSignal(gx,gy); | 693 | emit newEventSignal(gx,gy); |
694 | } else { | 694 | } else { |
695 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 695 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
696 | selectItem(doubleClickedItem); | 696 | selectItem(doubleClickedItem); |
697 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 697 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
698 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 698 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
699 | else | 699 | else |
700 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 700 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
701 | } | 701 | } |
702 | break; | 702 | break; |
703 | 703 | ||
704 | default: | 704 | default: |
705 | break; | 705 | break; |
706 | } | 706 | } |
707 | return true; | 707 | return true; |
708 | 708 | ||
709 | } | 709 | } |
710 | 710 | ||
711 | void KOAgenda::newItem( int item ) | 711 | void KOAgenda::newItem( int item ) |
712 | { | 712 | { |
713 | if ( item == 1 ) { //new event | 713 | if ( item == 1 ) { //new event |
714 | newEventSignal(mStartCellX ,mStartCellY ); | 714 | newEventSignal(mStartCellX ,mStartCellY ); |
715 | } else | 715 | } else |
716 | if ( item == 2 ) { //new event | 716 | if ( item == 2 ) { //new event |
717 | newTodoSignal(mStartCellX ,mStartCellY ); | 717 | newTodoSignal(mStartCellX ,mStartCellY ); |
718 | } else | 718 | } else |
719 | { | 719 | { |
720 | emit showDateView( item, mStartCellX ); | 720 | emit showDateView( item, mStartCellX ); |
721 | // 3Day view | 721 | // 3Day view |
722 | // 4Week view | 722 | // 4Week view |
723 | // 5Month view | 723 | // 5Month view |
724 | // 6Journal view | 724 | // 6Journal view |
725 | } | 725 | } |
726 | } | 726 | } |
727 | void KOAgenda::slotClearSelection() | 727 | void KOAgenda::slotClearSelection() |
728 | { | 728 | { |
729 | if (mSelectionHeight) { | 729 | if (mSelectionHeight) { |
730 | int selectionX = mSelectionCellX * mGridSpacingX; | 730 | int selectionX = mSelectionCellX * mGridSpacingX; |
731 | int top = mSelectionYTop - 2 *mGridSpacingY; | 731 | int top = mSelectionYTop - 2 *mGridSpacingY; |
732 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 732 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
733 | clearSelection(); | 733 | clearSelection(); |
734 | repaintContents( selectionX, top, | 734 | repaintContents( selectionX, top, |
735 | mGridSpacingX, hei ,false ); | 735 | mGridSpacingX, hei ,false ); |
736 | } | 736 | } |
737 | 737 | ||
738 | } | 738 | } |
739 | void KOAgenda::startSelectAction(QPoint viewportPos) | 739 | void KOAgenda::startSelectAction(QPoint viewportPos) |
740 | { | 740 | { |
741 | 741 | ||
742 | emit signalClearSelection(); | 742 | emit signalClearSelection(); |
743 | slotClearSelection(); | 743 | slotClearSelection(); |
744 | 744 | ||
745 | mActionType = SELECT; | 745 | mActionType = SELECT; |
746 | 746 | ||
747 | int x,y; | 747 | int x,y; |
748 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 748 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
749 | int gx,gy; | 749 | int gx,gy; |
750 | contentsToGrid(x,y,gx,gy); | 750 | contentsToGrid(x,y,gx,gy); |
751 | 751 | ||
752 | mStartCellX = gx; | 752 | mStartCellX = gx; |
753 | mStartCellY = gy; | 753 | mStartCellY = gy; |
754 | mCurrentCellX = gx; | 754 | mCurrentCellX = gx; |
755 | mCurrentCellY = gy; | 755 | mCurrentCellY = gy; |
756 | 756 | ||
757 | // Store new selection | 757 | // Store new selection |
758 | mSelectionCellX = gx; | 758 | mSelectionCellX = gx; |
759 | mSelectionYTop = gy * mGridSpacingY; | 759 | mSelectionYTop = gy * mGridSpacingY; |
760 | mSelectionHeight = mGridSpacingY; | 760 | mSelectionHeight = mGridSpacingY; |
761 | 761 | ||
762 | // Paint new selection | 762 | // Paint new selection |
763 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, | 763 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, |
764 | mGridSpacingX-1, mSelectionHeight ); | 764 | mGridSpacingX-1, mSelectionHeight ); |
765 | } | 765 | } |
766 | 766 | ||
767 | void KOAgenda::performSelectAction(QPoint viewportPos) | 767 | void KOAgenda::performSelectAction(QPoint viewportPos) |
768 | { | 768 | { |
769 | int x,y; | 769 | int x,y; |
770 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 770 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
771 | int gx,gy; | 771 | int gx,gy; |
772 | contentsToGrid(x,y,gx,gy); | 772 | contentsToGrid(x,y,gx,gy); |
773 | 773 | ||
774 | QPoint clipperPos = clipper()-> | 774 | QPoint clipperPos = clipper()-> |
775 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 775 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
776 | 776 | ||
777 | // Scroll if cursor was moved to upper or lower end of agenda. | 777 | // Scroll if cursor was moved to upper or lower end of agenda. |
778 | if (clipperPos.y() < mScrollBorderWidth) { | 778 | if (clipperPos.y() < mScrollBorderWidth) { |
779 | mScrollUpTimer.start(mScrollDelay); | 779 | mScrollUpTimer.start(mScrollDelay); |
780 | } else if (visibleHeight() - clipperPos.y() < | 780 | } else if (visibleHeight() - clipperPos.y() < |
781 | mScrollBorderWidth) { | 781 | mScrollBorderWidth) { |
782 | mScrollDownTimer.start(mScrollDelay); | 782 | mScrollDownTimer.start(mScrollDelay); |
783 | } else { | 783 | } else { |
784 | mScrollUpTimer.stop(); | 784 | mScrollUpTimer.stop(); |
785 | mScrollDownTimer.stop(); | 785 | mScrollDownTimer.stop(); |
786 | } | 786 | } |
787 | 787 | ||
788 | if ( gy > mCurrentCellY ) { | 788 | if ( gy > mCurrentCellY ) { |
789 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 789 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
790 | 790 | ||
791 | 791 | ||
792 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 792 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
793 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 793 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
794 | mGridSpacingX, mSelectionYTop, | 794 | mGridSpacingX, mSelectionYTop, |
795 | mGridSpacingX, mSelectionHeight , false); | 795 | mGridSpacingX, mSelectionHeight , false); |
796 | 796 | ||
797 | mCurrentCellY = gy; | 797 | mCurrentCellY = gy; |
798 | } else if ( gy < mCurrentCellY ) { | 798 | } else if ( gy < mCurrentCellY ) { |
799 | if ( gy >= mStartCellY ) { | 799 | if ( gy >= mStartCellY ) { |
800 | int selectionHeight = mSelectionHeight; | 800 | int selectionHeight = mSelectionHeight; |
801 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 801 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
802 | 802 | ||
803 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 803 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
804 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 804 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
805 | mGridSpacingX, mSelectionYTop, | 805 | mGridSpacingX, mSelectionYTop, |
806 | mGridSpacingX, selectionHeight,false ); | 806 | mGridSpacingX, selectionHeight,false ); |
807 | 807 | ||
808 | mCurrentCellY = gy; | 808 | mCurrentCellY = gy; |
809 | } else { | 809 | } else { |
810 | } | 810 | } |
811 | } | 811 | } |
812 | } | 812 | } |
813 | 813 | ||
814 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 814 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
815 | { | 815 | { |
816 | mActionType = NOP; | 816 | mActionType = NOP; |
817 | mScrollUpTimer.stop(); | 817 | mScrollUpTimer.stop(); |
818 | mScrollDownTimer.stop(); | 818 | mScrollDownTimer.stop(); |
819 | 819 | ||
820 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 820 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
821 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 821 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
822 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 822 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
823 | } | 823 | } |
824 | } | 824 | } |
825 | 825 | ||
826 | void KOAgenda::startItemAction(QPoint viewportPos) | 826 | void KOAgenda::startItemAction(QPoint viewportPos) |
827 | { | 827 | { |
828 | int x,y; | 828 | int x,y; |
829 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 829 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
830 | int gx,gy; | 830 | int gx,gy; |
831 | contentsToGrid(x,y,gx,gy); | 831 | contentsToGrid(x,y,gx,gy); |
832 | 832 | ||
833 | mStartCellX = gx; | 833 | mStartCellX = gx; |
834 | mStartCellY = gy; | 834 | mStartCellY = gy; |
835 | mCurrentCellX = gx; | 835 | mCurrentCellX = gx; |
836 | mCurrentCellY = gy; | 836 | mCurrentCellY = gy; |
837 | 837 | ||
838 | if (mAllDayMode) { | 838 | if (mAllDayMode) { |
839 | int gridDistanceX = (x - gx * mGridSpacingX); | 839 | int gridDistanceX = (x - gx * mGridSpacingX); |
840 | if (gridDistanceX < mResizeBorderWidth && | 840 | if (gridDistanceX < mResizeBorderWidth && |
841 | mActionItem->cellX() == mCurrentCellX) { | 841 | mActionItem->cellX() == mCurrentCellX) { |
842 | mActionType = RESIZELEFT; | 842 | mActionType = RESIZELEFT; |
843 | setCursor(sizeHorCursor); | 843 | setCursor(sizeHorCursor); |
844 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 844 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
845 | mActionItem->cellXWidth() == mCurrentCellX) { | 845 | mActionItem->cellXWidth() == mCurrentCellX) { |
846 | mActionType = RESIZERIGHT; | 846 | mActionType = RESIZERIGHT; |
847 | setCursor(sizeHorCursor); | 847 | setCursor(sizeHorCursor); |
848 | } else { | 848 | } else { |
849 | mActionType = MOVE; | 849 | mActionType = MOVE; |
850 | mActionItem->startMove(); | 850 | mActionItem->startMove(); |
851 | setCursor(sizeAllCursor); | 851 | setCursor(sizeAllCursor); |
852 | } | 852 | } |
853 | } else { | 853 | } else { |
854 | int gridDistanceY = (y - gy * mGridSpacingY); | 854 | int gridDistanceY = (y - gy * mGridSpacingY); |
855 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); | 855 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); |
856 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 856 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
857 | mActionItem->cellYTop() == mCurrentCellY && | 857 | mActionItem->cellYTop() == mCurrentCellY && |
858 | !mActionItem->firstMultiItem()) { | 858 | !mActionItem->firstMultiItem()) { |
859 | mActionType = RESIZETOP; | 859 | mActionType = RESIZETOP; |
860 | setCursor(sizeVerCursor); | 860 | setCursor(sizeVerCursor); |
861 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 861 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
862 | mActionItem->cellYBottom() == mCurrentCellY && | 862 | mActionItem->cellYBottom() == mCurrentCellY && |
863 | !mActionItem->lastMultiItem()) { | 863 | !mActionItem->lastMultiItem()) { |
864 | mActionType = RESIZEBOTTOM; | 864 | mActionType = RESIZEBOTTOM; |
865 | setCursor(sizeVerCursor); | 865 | setCursor(sizeVerCursor); |
866 | } else { | 866 | } else { |
867 | mActionType = MOVE; | 867 | mActionType = MOVE; |
868 | mActionItem->startMove(); | 868 | mActionItem->startMove(); |
869 | setCursor(sizeAllCursor); | 869 | setCursor(sizeAllCursor); |
870 | } | 870 | } |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | void KOAgenda::performItemAction(QPoint viewportPos) | 874 | void KOAgenda::performItemAction(QPoint viewportPos) |
875 | { | 875 | { |
876 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 876 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
877 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 877 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
878 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 878 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
879 | // point = clipper()->mapFromGlobal(point); | 879 | // point = clipper()->mapFromGlobal(point); |
880 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 880 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
881 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 881 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
882 | int x,y; | 882 | int x,y; |
883 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 883 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
884 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 884 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
885 | int gx,gy; | 885 | int gx,gy; |
886 | contentsToGrid(x,y,gx,gy); | 886 | contentsToGrid(x,y,gx,gy); |
887 | QPoint clipperPos = clipper()-> | 887 | QPoint clipperPos = clipper()-> |
888 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 888 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
889 | 889 | ||
890 | // Cursor left active agenda area. | 890 | // Cursor left active agenda area. |
891 | // This starts a drag. | 891 | // This starts a drag. |
892 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 892 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
893 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 893 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
894 | if ( mActionType == MOVE ) { | 894 | if ( mActionType == MOVE ) { |
895 | mScrollUpTimer.stop(); | 895 | mScrollUpTimer.stop(); |
896 | mScrollDownTimer.stop(); | 896 | mScrollDownTimer.stop(); |
897 | mActionItem->resetMove(); | 897 | mActionItem->resetMove(); |
898 | placeSubCells( mActionItem ); | 898 | placeSubCells( mActionItem ); |
899 | // emit startDragSignal( mActionItem->incidence() ); | 899 | // emit startDragSignal( mActionItem->incidence() ); |
900 | setCursor( arrowCursor ); | 900 | setCursor( arrowCursor ); |
901 | mActionItem = 0; | 901 | mActionItem = 0; |
902 | mActionType = NOP; | 902 | mActionType = NOP; |
903 | mItemMoved = 0; | 903 | mItemMoved = 0; |
904 | return; | 904 | return; |
905 | } | 905 | } |
906 | } else { | 906 | } else { |
907 | switch ( mActionType ) { | 907 | switch ( mActionType ) { |
908 | case MOVE: | 908 | case MOVE: |
909 | setCursor( sizeAllCursor ); | 909 | setCursor( sizeAllCursor ); |
910 | break; | 910 | break; |
911 | case RESIZETOP: | 911 | case RESIZETOP: |
912 | case RESIZEBOTTOM: | 912 | case RESIZEBOTTOM: |
913 | setCursor( sizeVerCursor ); | 913 | setCursor( sizeVerCursor ); |
914 | break; | 914 | break; |
915 | case RESIZELEFT: | 915 | case RESIZELEFT: |
916 | case RESIZERIGHT: | 916 | case RESIZERIGHT: |
917 | setCursor( sizeHorCursor ); | 917 | setCursor( sizeHorCursor ); |
918 | break; | 918 | break; |
919 | default: | 919 | default: |
920 | setCursor( arrowCursor ); | 920 | setCursor( arrowCursor ); |
921 | } | 921 | } |
922 | } | 922 | } |
923 | 923 | ||
924 | // Scroll if item was moved to upper or lower end of agenda. | 924 | // Scroll if item was moved to upper or lower end of agenda. |
925 | if (clipperPos.y() < mScrollBorderWidth) { | 925 | if (clipperPos.y() < mScrollBorderWidth) { |
926 | mScrollUpTimer.start(mScrollDelay); | 926 | mScrollUpTimer.start(mScrollDelay); |
927 | } else if (visibleHeight() - clipperPos.y() < | 927 | } else if (visibleHeight() - clipperPos.y() < |
928 | mScrollBorderWidth) { | 928 | mScrollBorderWidth) { |
929 | mScrollDownTimer.start(mScrollDelay); | 929 | mScrollDownTimer.start(mScrollDelay); |
930 | } else { | 930 | } else { |
931 | mScrollUpTimer.stop(); | 931 | mScrollUpTimer.stop(); |
932 | mScrollDownTimer.stop(); | 932 | mScrollDownTimer.stop(); |
933 | } | 933 | } |
934 | 934 | ||
935 | // Move or resize item if necessary | 935 | // Move or resize item if necessary |
936 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 936 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
937 | mItemMoved = true; | 937 | mItemMoved = true; |
938 | mActionItem->raise(); | 938 | mActionItem->raise(); |
939 | if (mActionType == MOVE) { | 939 | if (mActionType == MOVE) { |
940 | // Move all items belonging to a multi item | 940 | // Move all items belonging to a multi item |
941 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 941 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
942 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 942 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
943 | if (!moveItem) moveItem = mActionItem; | 943 | if (!moveItem) moveItem = mActionItem; |
944 | while (moveItem) { | 944 | while (moveItem) { |
945 | int dy; | 945 | int dy; |
946 | if (isMultiItem) dy = 0; | 946 | if (isMultiItem) dy = 0; |
947 | else dy = gy - mCurrentCellY; | 947 | else dy = gy - mCurrentCellY; |
948 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 948 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
949 | int x,y; | 949 | int x,y; |
950 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 950 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
951 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 951 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
952 | mGridSpacingY * moveItem->cellHeight()); | 952 | mGridSpacingY * moveItem->cellHeight()); |
953 | moveItem->raise(); | 953 | moveItem->raise(); |
954 | moveChild(moveItem,x,y); | 954 | moveChild(moveItem,x,y); |
955 | moveItem = moveItem->nextMultiItem(); | 955 | moveItem = moveItem->nextMultiItem(); |
956 | } | 956 | } |
957 | } else if (mActionType == RESIZETOP) { | 957 | } else if (mActionType == RESIZETOP) { |
958 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 958 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
959 | mActionItem->expandTop(gy - mCurrentCellY); | 959 | mActionItem->expandTop(gy - mCurrentCellY); |
960 | mActionItem->resize(mActionItem->width(), | 960 | mActionItem->resize(mActionItem->width(), |
961 | mGridSpacingY * mActionItem->cellHeight()); | 961 | mGridSpacingY * mActionItem->cellHeight()); |
962 | int x,y; | 962 | int x,y; |
963 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 963 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
964 | //moveChild(mActionItem,childX(mActionItem),y); | 964 | //moveChild(mActionItem,childX(mActionItem),y); |
965 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 965 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
966 | } | 966 | } |
967 | } else if (mActionType == RESIZEBOTTOM) { | 967 | } else if (mActionType == RESIZEBOTTOM) { |
968 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 968 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
969 | mActionItem->expandBottom(gy - mCurrentCellY); | 969 | mActionItem->expandBottom(gy - mCurrentCellY); |
970 | mActionItem->resize(mActionItem->width(), | 970 | mActionItem->resize(mActionItem->width(), |
971 | mGridSpacingY * mActionItem->cellHeight()); | 971 | mGridSpacingY * mActionItem->cellHeight()); |
972 | } | 972 | } |
973 | } else if (mActionType == RESIZELEFT) { | 973 | } else if (mActionType == RESIZELEFT) { |
974 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 974 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
975 | mActionItem->expandLeft(gx - mCurrentCellX); | 975 | mActionItem->expandLeft(gx - mCurrentCellX); |
976 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 976 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
977 | mActionItem->height()); | 977 | mActionItem->height()); |
978 | int x,y; | 978 | int x,y; |
979 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 979 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
980 | moveChild(mActionItem,x,childY(mActionItem)); | 980 | moveChild(mActionItem,x,childY(mActionItem)); |
981 | } | 981 | } |
982 | } else if (mActionType == RESIZERIGHT) { | 982 | } else if (mActionType == RESIZERIGHT) { |
983 | if (mCurrentCellX >= mActionItem->cellX()) { | 983 | if (mCurrentCellX >= mActionItem->cellX()) { |
984 | mActionItem->expandRight(gx - mCurrentCellX); | 984 | mActionItem->expandRight(gx - mCurrentCellX); |
985 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 985 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
986 | mActionItem->height()); | 986 | mActionItem->height()); |
987 | } | 987 | } |
988 | } | 988 | } |
989 | mCurrentCellX = gx; | 989 | mCurrentCellX = gx; |
990 | mCurrentCellY = gy; | 990 | mCurrentCellY = gy; |
991 | } | 991 | } |
992 | } | 992 | } |
993 | 993 | ||
994 | void KOAgenda::endItemAction() | 994 | void KOAgenda::endItemAction() |
995 | { | 995 | { |
996 | 996 | ||
997 | if ( mItemMoved ) { | 997 | if ( mItemMoved ) { |
998 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 998 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
999 | if ( !placeItem ) { | 999 | if ( !placeItem ) { |
1000 | placeItem = mActionItem; | 1000 | placeItem = mActionItem; |
1001 | } | 1001 | } |
1002 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 1002 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
1003 | Incidence* oldInc = placeItem->incidence(); | 1003 | Incidence* oldInc = placeItem->incidence(); |
1004 | placeItem->recreateIncidence(); | 1004 | placeItem->recreateIncidence(); |
1005 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 1005 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
1006 | } | 1006 | } |
1007 | int type = mActionType; | 1007 | int type = mActionType; |
1008 | if ( mAllDayMode ) | 1008 | if ( mAllDayMode ) |
1009 | type = -1; | 1009 | type = -1; |
1010 | KOAgendaItem *modifiedItem = placeItem; | 1010 | KOAgendaItem *modifiedItem = placeItem; |
1011 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 1011 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
1012 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 1012 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
1013 | KOAgendaItem *item; | 1013 | KOAgendaItem *item; |
1014 | 1014 | ||
1015 | if ( placeItem->incidence()->typeID() == todoID ) { | 1015 | if ( placeItem->incidence()->typeID() == todoID ) { |
1016 | mSelectedItem = 0; | 1016 | mSelectedItem = 0; |
1017 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 1017 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
1018 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 1018 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
1019 | emit itemModified( modifiedItem, mActionType ); | 1019 | emit itemModified( modifiedItem, mActionType ); |
1020 | } | 1020 | } |
1021 | else { | 1021 | else { |
1022 | 1022 | ||
1023 | 1023 | ||
1024 | globalFlagBlockAgendaItemPaint = 1; | 1024 | globalFlagBlockAgendaItemPaint = 1; |
1025 | for ( item=oldconflictItems.first(); item != 0; | 1025 | for ( item=oldconflictItems.first(); item != 0; |
1026 | item=oldconflictItems.next() ) { | 1026 | item=oldconflictItems.next() ) { |
1027 | placeSubCells(item); | 1027 | placeSubCells(item); |
1028 | } | 1028 | } |
1029 | while ( placeItem ) { | 1029 | while ( placeItem ) { |
1030 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1030 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1031 | oldconflictItems = placeItem->conflictItems(); | 1031 | oldconflictItems = placeItem->conflictItems(); |
1032 | for ( item=oldconflictItems.first(); item != 0; | 1032 | for ( item=oldconflictItems.first(); item != 0; |
1033 | item=oldconflictItems.next() ) { | 1033 | item=oldconflictItems.next() ) { |
1034 | placeSubCells(item); | 1034 | placeSubCells(item); |
1035 | } | 1035 | } |
1036 | placeSubCells( placeItem ); | 1036 | placeSubCells( placeItem ); |
1037 | placeItem = placeItem->nextMultiItem(); | 1037 | placeItem = placeItem->nextMultiItem(); |
1038 | } | 1038 | } |
1039 | globalFlagBlockAgendaItemPaint = 0; | 1039 | globalFlagBlockAgendaItemPaint = 0; |
1040 | for ( item=oldconflictItems.first(); item != 0; | 1040 | for ( item=oldconflictItems.first(); item != 0; |
1041 | item=oldconflictItems.next() ) { | 1041 | item=oldconflictItems.next() ) { |
1042 | globalFlagBlockAgendaItemUpdate = 0; | 1042 | globalFlagBlockAgendaItemUpdate = 0; |
1043 | item->repaintMe(); | 1043 | item->repaintMe(); |
1044 | globalFlagBlockAgendaItemUpdate = 1; | 1044 | globalFlagBlockAgendaItemUpdate = 1; |
1045 | item->repaint( false ); | 1045 | item->repaint( false ); |
1046 | } | 1046 | } |
1047 | placeItem = modifiedItem; | 1047 | placeItem = modifiedItem; |
1048 | 1048 | ||
1049 | while ( placeItem ) { | 1049 | while ( placeItem ) { |
1050 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1050 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1051 | globalFlagBlockAgendaItemUpdate = 0; | 1051 | globalFlagBlockAgendaItemUpdate = 0; |
1052 | placeItem->repaintMe(); | 1052 | placeItem->repaintMe(); |
1053 | globalFlagBlockAgendaItemUpdate = 1; | 1053 | globalFlagBlockAgendaItemUpdate = 1; |
1054 | placeItem->repaint(false); | 1054 | placeItem->repaint(false); |
1055 | placeItem = placeItem->nextMultiItem(); | 1055 | placeItem = placeItem->nextMultiItem(); |
1056 | } | 1056 | } |
1057 | emit itemModified( modifiedItem, mActionType ); | 1057 | emit itemModified( modifiedItem, mActionType ); |
1058 | 1058 | ||
1059 | 1059 | ||
1060 | placeItem = modifiedItem; | 1060 | placeItem = modifiedItem; |
1061 | while ( placeItem ) { | 1061 | while ( placeItem ) { |
1062 | oldconflictItems = placeItem->conflictItems(); | 1062 | oldconflictItems = placeItem->conflictItems(); |
1063 | for ( item=oldconflictItems.first(); item != 0; | 1063 | for ( item=oldconflictItems.first(); item != 0; |
1064 | item=oldconflictItems.next() ) { | 1064 | item=oldconflictItems.next() ) { |
1065 | placeSubCells(item); | 1065 | placeSubCells(item); |
1066 | } | 1066 | } |
1067 | placeSubCells( placeItem ); | 1067 | placeSubCells( placeItem ); |
1068 | placeItem = placeItem->nextMultiItem(); | 1068 | placeItem = placeItem->nextMultiItem(); |
1069 | 1069 | ||
1070 | } | 1070 | } |
1071 | placeItem = modifiedItem; | 1071 | placeItem = modifiedItem; |
1072 | while ( placeItem ) { | 1072 | while ( placeItem ) { |
1073 | oldconflictItems = placeItem->conflictItems(); | 1073 | oldconflictItems = placeItem->conflictItems(); |
1074 | for ( item=oldconflictItems.first(); item != 0; | 1074 | for ( item=oldconflictItems.first(); item != 0; |
1075 | item=oldconflictItems.next() ) { | 1075 | item=oldconflictItems.next() ) { |
1076 | globalFlagBlockAgendaItemUpdate = 0; | 1076 | globalFlagBlockAgendaItemUpdate = 0; |
1077 | item->repaintMe(); | 1077 | item->repaintMe(); |
1078 | globalFlagBlockAgendaItemUpdate = 1; | 1078 | globalFlagBlockAgendaItemUpdate = 1; |
1079 | item->repaint(false); | 1079 | item->repaint(false); |
1080 | } | 1080 | } |
1081 | placeItem = placeItem->nextMultiItem(); | 1081 | placeItem = placeItem->nextMultiItem(); |
1082 | } | 1082 | } |
1083 | /* | 1083 | /* |
1084 | 1084 | ||
1085 | oldconflictItems = modifiedItem->conflictItems(); | 1085 | oldconflictItems = modifiedItem->conflictItems(); |
1086 | for ( item=oldconflictItems.first(); item != 0; | 1086 | for ( item=oldconflictItems.first(); item != 0; |
1087 | item=oldconflictItems.next() ) { | 1087 | item=oldconflictItems.next() ) { |
1088 | globalFlagBlockAgendaItemUpdate = 0; | 1088 | globalFlagBlockAgendaItemUpdate = 0; |
1089 | item->paintMe(false); | 1089 | item->paintMe(false); |
1090 | globalFlagBlockAgendaItemUpdate = 1; | 1090 | globalFlagBlockAgendaItemUpdate = 1; |
1091 | item->repaint(false); | 1091 | item->repaint(false); |
1092 | } | 1092 | } |
1093 | */ | 1093 | */ |
1094 | 1094 | ||
1095 | 1095 | ||
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | } | 1098 | } |
1099 | if ( mActionItem ) | 1099 | if ( mActionItem ) |
1100 | emit incidenceSelected( mActionItem->incidence() ); | 1100 | emit incidenceSelected( mActionItem->incidence() ); |
1101 | mScrollUpTimer.stop(); | 1101 | mScrollUpTimer.stop(); |
1102 | mScrollDownTimer.stop(); | 1102 | mScrollDownTimer.stop(); |
1103 | setCursor( arrowCursor ); | 1103 | setCursor( arrowCursor ); |
1104 | mActionItem = 0; | 1104 | mActionItem = 0; |
1105 | mActionType = NOP; | 1105 | mActionType = NOP; |
1106 | mItemMoved = 0; | 1106 | mItemMoved = 0; |
1107 | 1107 | ||
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1110 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1111 | { | 1111 | { |
1112 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1112 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1113 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1113 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1114 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1114 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1115 | // point = clipper()->mapFromGlobal(point); | 1115 | // point = clipper()->mapFromGlobal(point); |
1116 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1116 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1117 | 1117 | ||
1118 | int x,y; | 1118 | int x,y; |
1119 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1119 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1120 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1120 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1121 | int gx,gy; | 1121 | int gx,gy; |
1122 | contentsToGrid(x,y,gx,gy); | 1122 | contentsToGrid(x,y,gx,gy); |
1123 | 1123 | ||
1124 | // Change cursor to resize cursor if appropriate | 1124 | // Change cursor to resize cursor if appropriate |
1125 | if (mAllDayMode) { | 1125 | if (mAllDayMode) { |
1126 | int gridDistanceX = (x - gx * mGridSpacingX); | 1126 | int gridDistanceX = (x - gx * mGridSpacingX); |
1127 | if (gridDistanceX < mResizeBorderWidth && | 1127 | if (gridDistanceX < mResizeBorderWidth && |
1128 | moveItem->cellX() == gx) { | 1128 | moveItem->cellX() == gx) { |
1129 | setCursor(sizeHorCursor); | 1129 | setCursor(sizeHorCursor); |
1130 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1130 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1131 | moveItem->cellXWidth() == gx) { | 1131 | moveItem->cellXWidth() == gx) { |
1132 | setCursor(sizeHorCursor); | 1132 | setCursor(sizeHorCursor); |
1133 | } else { | 1133 | } else { |
1134 | setCursor(arrowCursor); | 1134 | setCursor(arrowCursor); |
1135 | } | 1135 | } |
1136 | } else { | 1136 | } else { |
1137 | int gridDistanceY = (y - gy * mGridSpacingY); | 1137 | int gridDistanceY = (y - gy * mGridSpacingY); |
1138 | if (gridDistanceY < mResizeBorderWidth && | 1138 | if (gridDistanceY < mResizeBorderWidth && |
1139 | moveItem->cellYTop() == gy && | 1139 | moveItem->cellYTop() == gy && |
1140 | !moveItem->firstMultiItem()) { | 1140 | !moveItem->firstMultiItem()) { |
1141 | setCursor(sizeVerCursor); | 1141 | setCursor(sizeVerCursor); |
1142 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1142 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1143 | moveItem->cellYBottom() == gy && | 1143 | moveItem->cellYBottom() == gy && |
1144 | !moveItem->lastMultiItem()) { | 1144 | !moveItem->lastMultiItem()) { |
1145 | setCursor(sizeVerCursor); | 1145 | setCursor(sizeVerCursor); |
1146 | } else { | 1146 | } else { |
1147 | setCursor(arrowCursor); | 1147 | setCursor(arrowCursor); |
1148 | } | 1148 | } |
1149 | } | 1149 | } |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | 1152 | ||
1153 | /* | 1153 | /* |
1154 | Place item in cell and take care that multiple items using the same cell do | 1154 | Place item in cell and take care that multiple items using the same cell do |
1155 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1155 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1156 | it can get in all cases. | 1156 | it can get in all cases. |
1157 | At the moment the method has a bug: When an item is placed only the sub cell | 1157 | At the moment the method has a bug: When an item is placed only the sub cell |
1158 | widths of the items are changed, which are within the Y region the item to | 1158 | widths of the items are changed, which are within the Y region the item to |
1159 | place spans. When the sub cell width change of one of this items affects a | 1159 | place spans. When the sub cell width change of one of this items affects a |
1160 | cell, where other items are, which do not overlap in Y with the item to place, | 1160 | cell, where other items are, which do not overlap in Y with the item to place, |
1161 | the display gets corrupted, although the corruption looks quite nice. | 1161 | the display gets corrupted, although the corruption looks quite nice. |
1162 | */ | 1162 | */ |
1163 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1163 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1164 | { | 1164 | { |
1165 | 1165 | ||
1166 | QPtrList<KOAgendaItem> conflictItems; | 1166 | QPtrList<KOAgendaItem> conflictItems; |
1167 | int maxSubCells = 0; | 1167 | int maxSubCells = 0; |
1168 | QIntDict<KOAgendaItem> subCellDict(7); | 1168 | QIntDict<KOAgendaItem> subCellDict(7); |
1169 | 1169 | ||
1170 | KOAgendaItem *item; | 1170 | KOAgendaItem *item; |
1171 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1171 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1172 | if (item != placeItem) { | 1172 | if (item != placeItem) { |
1173 | if (placeItem->cellX() <= item->cellXWidth() && | 1173 | if (placeItem->cellX() <= item->cellXWidth() && |
1174 | placeItem->cellXWidth() >= item->cellX()) { | 1174 | placeItem->cellXWidth() >= item->cellX()) { |
1175 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1175 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1176 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1176 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1177 | conflictItems.append(item); | 1177 | conflictItems.append(item); |
1178 | if (item->subCells() > maxSubCells) | 1178 | if (item->subCells() > maxSubCells) |
1179 | maxSubCells = item->subCells(); | 1179 | maxSubCells = item->subCells(); |
1180 | subCellDict.insert(item->subCell(),item); | 1180 | subCellDict.insert(item->subCell(),item); |
1181 | } | 1181 | } |
1182 | } | 1182 | } |
1183 | } | 1183 | } |
1184 | } | 1184 | } |
1185 | 1185 | ||
1186 | if (conflictItems.count() > 0) { | 1186 | if (conflictItems.count() > 0) { |
1187 | // Look for unused sub cell and insert item | 1187 | // Look for unused sub cell and insert item |
1188 | int i; | 1188 | int i; |
1189 | for(i=0;i<maxSubCells;++i) { | 1189 | for(i=0;i<maxSubCells;++i) { |
1190 | if (!subCellDict.find(i)) { | 1190 | if (!subCellDict.find(i)) { |
1191 | placeItem->setSubCell(i); | 1191 | placeItem->setSubCell(i); |
1192 | break; | 1192 | break; |
1193 | } | 1193 | } |
1194 | } | 1194 | } |
1195 | if (i == maxSubCells) { | 1195 | if (i == maxSubCells) { |
1196 | placeItem->setSubCell(maxSubCells); | 1196 | placeItem->setSubCell(maxSubCells); |
1197 | maxSubCells++; // add new item to number of sub cells | 1197 | maxSubCells++; // add new item to number of sub cells |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | // Prepare for sub cell geometry adjustment | 1200 | // Prepare for sub cell geometry adjustment |
1201 | int newSubCellWidth; | 1201 | int newSubCellWidth; |
1202 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1202 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1203 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1203 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1204 | conflictItems.append(placeItem); | 1204 | conflictItems.append(placeItem); |
1205 | 1205 | ||
1206 | 1206 | ||
1207 | // Adjust sub cell geometry of all direct conflict items | 1207 | // Adjust sub cell geometry of all direct conflict items |
1208 | for ( item=conflictItems.first(); item != 0; | 1208 | for ( item=conflictItems.first(); item != 0; |
1209 | item=conflictItems.next() ) { | 1209 | item=conflictItems.next() ) { |
1210 | item->setSubCells(maxSubCells); | 1210 | item->setSubCells(maxSubCells); |
1211 | if (mAllDayMode) { | 1211 | if (mAllDayMode) { |
1212 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1212 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1213 | } else { | 1213 | } else { |
1214 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1214 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1215 | } | 1215 | } |
1216 | int x,y; | 1216 | int x,y; |
1217 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1217 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1218 | if (mAllDayMode) { | 1218 | if (mAllDayMode) { |
1219 | y += item->subCell() * newSubCellWidth; | 1219 | y += item->subCell() * newSubCellWidth; |
1220 | } else { | 1220 | } else { |
1221 | x += item->subCell() * newSubCellWidth; | 1221 | x += item->subCell() * newSubCellWidth; |
1222 | } | 1222 | } |
1223 | moveChild(item,x,y); | 1223 | moveChild(item,x,y); |
1224 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1224 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1225 | //item->updateItem(); | 1225 | //item->updateItem(); |
1226 | } | 1226 | } |
1227 | // Adjust sub cell geometry of all conflict items of all conflict items | 1227 | // Adjust sub cell geometry of all conflict items of all conflict items |
1228 | for ( item=conflictItems.first(); item != 0; | 1228 | for ( item=conflictItems.first(); item != 0; |
1229 | item=conflictItems.next() ) { | 1229 | item=conflictItems.next() ) { |
1230 | if ( placeItem != item ) { | 1230 | if ( placeItem != item ) { |
1231 | KOAgendaItem *item2; | 1231 | KOAgendaItem *item2; |
1232 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1232 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1233 | for ( item2=conflictItems2.first(); item2 != 0; | 1233 | for ( item2=conflictItems2.first(); item2 != 0; |
1234 | item2=conflictItems2.next() ) { | 1234 | item2=conflictItems2.next() ) { |
1235 | if ( item2->subCells() != maxSubCells) { | 1235 | if ( item2->subCells() != maxSubCells) { |
1236 | item2->setSubCells(maxSubCells); | 1236 | item2->setSubCells(maxSubCells); |
1237 | if (mAllDayMode) { | 1237 | if (mAllDayMode) { |
1238 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1238 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1239 | } else { | 1239 | } else { |
1240 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1240 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1241 | } | 1241 | } |
1242 | int x,y; | 1242 | int x,y; |
1243 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1243 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1244 | if (mAllDayMode) { | 1244 | if (mAllDayMode) { |
1245 | y += item2->subCell() * newSubCellWidth; | 1245 | y += item2->subCell() * newSubCellWidth; |
1246 | } else { | 1246 | } else { |
1247 | x += item2->subCell() * newSubCellWidth; | 1247 | x += item2->subCell() * newSubCellWidth; |
1248 | } | 1248 | } |
1249 | moveChild(item2,x,y); | 1249 | moveChild(item2,x,y); |
1250 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1250 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1251 | } | 1251 | } |
1252 | } | 1252 | } |
1253 | } | 1253 | } |
1254 | } | 1254 | } |
1255 | } else { | 1255 | } else { |
1256 | placeItem->setSubCell(0); | 1256 | placeItem->setSubCell(0); |
1257 | placeItem->setSubCells(1); | 1257 | placeItem->setSubCells(1); |
1258 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1258 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1259 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1259 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1260 | int x,y; | 1260 | int x,y; |
1261 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1261 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1262 | moveChild(placeItem,x,y); | 1262 | moveChild(placeItem,x,y); |
1263 | } | 1263 | } |
1264 | placeItem->setConflictItems(conflictItems); | 1264 | placeItem->setConflictItems(conflictItems); |
1265 | // for ( item=conflictItems.first(); item != 0; | 1265 | // for ( item=conflictItems.first(); item != 0; |
1266 | // item=conflictItems.next() ) { | 1266 | // item=conflictItems.next() ) { |
1267 | // //item->updateItem(); | 1267 | // //item->updateItem(); |
1268 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1268 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1269 | // } | 1269 | // } |
1270 | // placeItem->updateItem(); | 1270 | // placeItem->updateItem(); |
1271 | } | 1271 | } |
1272 | 1272 | ||
1273 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1273 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1274 | { | 1274 | { |
1275 | if ( globalFlagBlockAgenda ) | 1275 | if ( globalFlagBlockAgenda ) |
1276 | return; | 1276 | return; |
1277 | 1277 | ||
1278 | if ( mInvalidPixmap ) { | 1278 | if ( mInvalidPixmap ) { |
1279 | mInvalidPixmap = false; | 1279 | mInvalidPixmap = false; |
1280 | qDebug("KO: Upsizing Pixmaps "); | 1280 | qDebug("KO: Upsizing Pixmaps "); |
1281 | computeSizes(); | 1281 | computeSizes(); |
1282 | emit updateViewSignal(); | 1282 | emit updateViewSignal(); |
1283 | return; | 1283 | return; |
1284 | } | 1284 | } |
1285 | if ( ! mAllDayMode ) { | 1285 | if ( ! mAllDayMode ) { |
1286 | // currently not working for | 1286 | // currently not working for |
1287 | 1287 | ||
1288 | //qDebug("KOAgenda::drawContents "); | 1288 | //qDebug("KOAgenda::drawContents "); |
1289 | #if 0 | 1289 | #if 0 |
1290 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1290 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1291 | qDebug("WAU "); | 1291 | qDebug("WAU "); |
1292 | drawContentsToPainter(); | 1292 | drawContentsToPainter(); |
1293 | } | 1293 | } |
1294 | #endif | 1294 | #endif |
1295 | QPaintDevice* pd = p->device(); | 1295 | QPaintDevice* pd = p->device(); |
1296 | p->end(); | 1296 | p->end(); |
1297 | int vx, vy; | 1297 | int vx, vy; |
1298 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1298 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1299 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1299 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1300 | mSelectionCellX * mGridSpacingX; | 1300 | mSelectionCellX * mGridSpacingX; |
1301 | contentsToViewport ( cx, cy, vx,vy); | 1301 | contentsToViewport ( cx, cy, vx,vy); |
1302 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1302 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1303 | 1303 | ||
1304 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1304 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1305 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1305 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1306 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1306 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1307 | 1307 | ||
1308 | int vxSel, vySel; | 1308 | int vxSel, vySel; |
1309 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1309 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1310 | int off = mSelectionHeight; | 1310 | int off = mSelectionHeight; |
1311 | if ( vySel < 0 ) | 1311 | if ( vySel < 0 ) |
1312 | off += vySel; | 1312 | off += vySel; |
1313 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1313 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1314 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1314 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1315 | } else { | 1315 | } else { |
1316 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1316 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1317 | } | 1317 | } |
1318 | } | 1318 | } |
1319 | if ( mSelectionHeight > 0 ) { | 1319 | if ( mSelectionHeight > 0 ) { |
1320 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1320 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1323 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1323 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1324 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1324 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1325 | int hei = mSelectionHeight; | 1325 | int hei = mSelectionHeight; |
1326 | int offset = 0; | 1326 | int offset = 0; |
1327 | while ( hei > 0 ) { | 1327 | while ( hei > 0 ) { |
1328 | int p_hei = 5; | 1328 | int p_hei = 5; |
1329 | if ( hei < 5 ) p_hei = hei; | 1329 | if ( hei < 5 ) p_hei = hei; |
1330 | hei -= 5; | 1330 | hei -= 5; |
1331 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1331 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1332 | offset += 5; | 1332 | offset += 5; |
1333 | } | 1333 | } |
1334 | } | 1334 | } |
1335 | } | 1335 | } |
1336 | p->begin( pd ); | 1336 | p->begin( pd ); |
1337 | } else { | 1337 | } else { |
1338 | #if 0 | 1338 | #if 0 |
1339 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); | 1339 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); |
1340 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1340 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1341 | qDebug("WAUWAU "); | 1341 | qDebug("WAUWAU "); |
1342 | drawContentsToPainter(); | 1342 | drawContentsToPainter(); |
1343 | } | 1343 | } |
1344 | #endif | 1344 | #endif |
1345 | QPaintDevice* pd = p->device(); | 1345 | QPaintDevice* pd = p->device(); |
1346 | p->end(); | 1346 | p->end(); |
1347 | int vx, vy; | 1347 | int vx, vy; |
1348 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1348 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1349 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1349 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1350 | mSelectionCellX * mGridSpacingX; | 1350 | mSelectionCellX * mGridSpacingX; |
1351 | contentsToViewport ( cx, cy, vx,vy); | 1351 | contentsToViewport ( cx, cy, vx,vy); |
1352 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1352 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1353 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1353 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1354 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1354 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1355 | 1355 | ||
1356 | if ( mSelectionHeight > 0 ) { | 1356 | if ( mSelectionHeight > 0 ) { |
1357 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1357 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1358 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1358 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1359 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1359 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1360 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1360 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1361 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1361 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1362 | int hei = mSelectionHeight; | 1362 | int hei = mSelectionHeight; |
1363 | int offset = 0; | 1363 | int offset = 0; |
1364 | while ( hei > 0 ) { | 1364 | while ( hei > 0 ) { |
1365 | int p_hei = 5; | 1365 | int p_hei = 5; |
1366 | if ( hei < 5 ) p_hei = hei; | 1366 | if ( hei < 5 ) p_hei = hei; |
1367 | hei -= 5; | 1367 | hei -= 5; |
1368 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1368 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1369 | offset += 5; | 1369 | offset += 5; |
1370 | } | 1370 | } |
1371 | } | 1371 | } |
1372 | } | 1372 | } |
1373 | p->begin( pd ); | 1373 | p->begin( pd ); |
1374 | } | 1374 | } |
1375 | 1375 | ||
1376 | } | 1376 | } |
1377 | 1377 | ||
1378 | void KOAgenda::finishUpdate() | 1378 | void KOAgenda::finishUpdate() |
1379 | { | 1379 | { |
1380 | 1380 | ||
1381 | KOAgendaItem *item; | 1381 | KOAgendaItem *item; |
1382 | globalFlagBlockAgendaItemPaint = 1; | 1382 | globalFlagBlockAgendaItemPaint = 1; |
1383 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1383 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1384 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1384 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1385 | if ( !item->checkLayout() ) { | 1385 | if ( !item->checkLayout() ) { |
1386 | //qDebug(" conflictitem found "); | 1386 | //qDebug(" conflictitem found "); |
1387 | int newSubCellWidth; | 1387 | int newSubCellWidth; |
1388 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1388 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1389 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1389 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1390 | 1390 | ||
1391 | if (mAllDayMode) { | 1391 | if (mAllDayMode) { |
1392 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1392 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1393 | } else { | 1393 | } else { |
1394 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1394 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1395 | } | 1395 | } |
1396 | int x,y; | 1396 | int x,y; |
1397 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1397 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1398 | if (mAllDayMode) { | 1398 | if (mAllDayMode) { |
1399 | y += item->subCell() * newSubCellWidth; | 1399 | y += item->subCell() * newSubCellWidth; |
1400 | } else { | 1400 | } else { |
1401 | x += item->subCell() * newSubCellWidth; | 1401 | x += item->subCell() * newSubCellWidth; |
1402 | } | 1402 | } |
1403 | moveChild(item,x,y); | 1403 | moveChild(item,x,y); |
1404 | } | 1404 | } |
1405 | } | 1405 | } |
1406 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1406 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1407 | if ( !item->isVisible() ) | 1407 | if ( !item->isVisible() ) |
1408 | item->show(); | 1408 | item->show(); |
1409 | 1409 | ||
1410 | } | 1410 | } |
1411 | globalFlagBlockAgendaItemUpdate = 0; | 1411 | globalFlagBlockAgendaItemUpdate = 0; |
1412 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1412 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1413 | item->repaintMe( ); | 1413 | item->repaintMe( ); |
1414 | } | 1414 | } |
1415 | globalFlagBlockAgendaItemUpdate = 1; | 1415 | globalFlagBlockAgendaItemUpdate = 1; |
1416 | qApp->processEvents(); | 1416 | qApp->processEvents(); |
1417 | globalFlagBlockAgendaItemPaint = 0; | 1417 | globalFlagBlockAgendaItemPaint = 0; |
1418 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1418 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1419 | item->repaint( false ); | 1419 | item->repaint( false ); |
1420 | } | 1420 | } |
1421 | marcus_bains(); | 1421 | marcus_bains(); |
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | /* | 1424 | /* |
1425 | Draw grid in the background of the agenda. | 1425 | Draw grid in the background of the agenda. |
1426 | */ | 1426 | */ |
1427 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1427 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1428 | { | 1428 | { |
1429 | 1429 | ||
1430 | 1430 | ||
1431 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1431 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1432 | return; | 1432 | return; |
1433 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1433 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1434 | return; | 1434 | return; |
1435 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1435 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1436 | if ( ch < 1 ) | 1436 | if ( ch < 1 ) |
1437 | ch = 1; | 1437 | ch = 1; |
1438 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1438 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1439 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1439 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1440 | } | 1440 | } |
1441 | mCurPixWid = contentsWidth(); | 1441 | mCurPixWid = contentsWidth(); |
1442 | mCurPixHei = ch; | 1442 | mCurPixHei = ch; |
1443 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { | 1443 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { |
1444 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); | 1444 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); |
1445 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1445 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1446 | } | 1446 | } |
1447 | mPixPainter.begin( &mPaintPixmap) ; | 1447 | mPixPainter.begin( &mPaintPixmap) ; |
1448 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1448 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1449 | QPainter * p ; | 1449 | QPainter * p ; |
1450 | if (paint == 0) { | 1450 | if (paint == 0) { |
1451 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1451 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1452 | p = &mPixPainter; | 1452 | p = &mPixPainter; |
1453 | } | 1453 | } |
1454 | else | 1454 | else |
1455 | p = paint ; | 1455 | p = paint ; |
1456 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1456 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1457 | 1457 | ||
1458 | //--cx;++cw; | 1458 | //--cx;++cw; |
1459 | int lGridSpacingY = mGridSpacingY*2; | 1459 | int lGridSpacingY = mGridSpacingY*2; |
1460 | int selDay; | 1460 | int selDay; |
1461 | QDate curDate = QDate::currentDate(); | 1461 | QDate curDate = QDate::currentDate(); |
1462 | if ( !backgroundOnly ) { | 1462 | if ( !backgroundOnly ) { |
1463 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1463 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1464 | { | 1464 | { |
1465 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { | 1465 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { |
1466 | int x1 = cx; | 1466 | int x1 = cx; |
1467 | int y1 = 0; | 1467 | int y1 = 0; |
1468 | if (y1 < cy) y1 = cy; | 1468 | if (y1 < cy) y1 = cy; |
1469 | int x2 = cx+cw-1; | 1469 | int x2 = cx+cw-1; |
1470 | int y2 = contentsHeight(); | 1470 | int y2 = contentsHeight(); |
1471 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1471 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1472 | if (x2 >= x1 && y2 >= y1) { | 1472 | if (x2 >= x1 && y2 >= y1) { |
1473 | int gxStart = selDay; | 1473 | int gxStart = selDay; |
1474 | int gxEnd = gxStart ; | 1474 | int gxEnd = gxStart ; |
1475 | int xStart = KOGlobals::self()->reverseLayout() ? | 1475 | int xStart = KOGlobals::self()->reverseLayout() ? |
1476 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1476 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1477 | gxStart*mGridSpacingX; | 1477 | gxStart*mGridSpacingX; |
1478 | if (xStart < x1) xStart = x1; | 1478 | if (xStart < x1) xStart = x1; |
1479 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1479 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1480 | (mColumns - gxStart)*mGridSpacingX-1 : | 1480 | (mColumns - gxStart)*mGridSpacingX-1 : |
1481 | (gxStart+1)*mGridSpacingX-1; | 1481 | (gxStart+1)*mGridSpacingX-1; |
1482 | if (xEnd > x2) xEnd = x2; | 1482 | if (xEnd > x2) xEnd = x2; |
1483 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1483 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1484 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1484 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1485 | KOPrefs::instance()->mAgendaBgColor.light()); | 1485 | KOPrefs::instance()->mAgendaBgColor.light()); |
1486 | else | 1486 | else |
1487 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1487 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1488 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1488 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1489 | 1489 | ||
1490 | } | 1490 | } |
1491 | } | 1491 | } |
1492 | } | 1492 | } |
1493 | } | 1493 | } |
1494 | // Highlight working hours | 1494 | // Highlight working hours |
1495 | 1495 | ||
1496 | if ( !backgroundOnly ) | 1496 | if ( !backgroundOnly ) |
1497 | if (mWorkingHoursEnable) { | 1497 | if (mWorkingHoursEnable) { |
1498 | int x1 = cx; | 1498 | int x1 = cx; |
1499 | int y1 = mWorkingHoursYTop; | 1499 | int y1 = mWorkingHoursYTop; |
1500 | if (y1 < cy) y1 = cy; | 1500 | if (y1 < cy) y1 = cy; |
1501 | int x2 = cx+cw-1; | 1501 | int x2 = cx+cw-1; |
1502 | // int x2 = mGridSpacingX * 5 - 1; | 1502 | // int x2 = mGridSpacingX * 5 - 1; |
1503 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1503 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1504 | int y2 = mWorkingHoursYBottom; | 1504 | int y2 = mWorkingHoursYBottom; |
1505 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1505 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1506 | 1506 | ||
1507 | if (x2 >= x1 && y2 >= y1) { | 1507 | if (x2 >= x1 && y2 >= y1) { |
1508 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1508 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1509 | int gxStart = x1/mGridSpacingX; | 1509 | int gxStart = x1/mGridSpacingX; |
1510 | int gxEnd = x2/mGridSpacingX; | 1510 | int gxEnd = x2/mGridSpacingX; |
1511 | while(gxStart <= gxEnd) { | 1511 | while(gxStart <= gxEnd) { |
1512 | if (gxStart < int(mHolidayMask->count()) && | 1512 | if (gxStart < int(mHolidayMask->count()) && |
1513 | !mHolidayMask->at(gxStart)) { | 1513 | !mHolidayMask->at(gxStart)) { |
1514 | int xStart = KOGlobals::self()->reverseLayout() ? | 1514 | int xStart = KOGlobals::self()->reverseLayout() ? |
1515 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1515 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1516 | gxStart*mGridSpacingX; | 1516 | gxStart*mGridSpacingX; |
1517 | if (xStart < x1) xStart = x1; | 1517 | if (xStart < x1) xStart = x1; |
1518 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1518 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1519 | (mColumns - gxStart)*mGridSpacingX-1 : | 1519 | (mColumns - gxStart)*mGridSpacingX-1 : |
1520 | (gxStart+1)*mGridSpacingX-1; | 1520 | (gxStart+1)*mGridSpacingX-1; |
1521 | if (xEnd > x2) xEnd = x2; | 1521 | if (xEnd > x2) xEnd = x2; |
1522 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { | 1522 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { |
1523 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1523 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1524 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1524 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1525 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1525 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1526 | else | 1526 | else |
1527 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1527 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1528 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1528 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1529 | } else { | 1529 | } else { |
1530 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1530 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1531 | KOPrefs::instance()->mWorkingHoursColor); | 1531 | KOPrefs::instance()->mWorkingHoursColor); |
1532 | } | 1532 | } |
1533 | } | 1533 | } |
1534 | ++gxStart; | 1534 | ++gxStart; |
1535 | } | 1535 | } |
1536 | } | 1536 | } |
1537 | } | 1537 | } |
1538 | /* | 1538 | /* |
1539 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1539 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1540 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1540 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1541 | mSelectionCellX * mGridSpacingX; | 1541 | mSelectionCellX * mGridSpacingX; |
1542 | 1542 | ||
1543 | // Draw selection | 1543 | // Draw selection |
1544 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1544 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1545 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1545 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1546 | // TODO: paint only part within cx,cy,cw,ch | 1546 | // TODO: paint only part within cx,cy,cw,ch |
1547 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1547 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1548 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1548 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1549 | } | 1549 | } |
1550 | */ | 1550 | */ |
1551 | // Draw vertical lines of grid | 1551 | // Draw vertical lines of grid |
1552 | 1552 | ||
1553 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1553 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1554 | if ( mGridSpacingX > 0 ) { | 1554 | if ( mGridSpacingX > 0 ) { |
1555 | while (x < cx + cw) { | 1555 | while (x < cx + cw) { |
1556 | p->drawLine(x,cy,x,cy+ch); | 1556 | p->drawLine(x,cy,x,cy+ch); |
1557 | x+=mGridSpacingX; | 1557 | x+=mGridSpacingX; |
1558 | } | 1558 | } |
1559 | } | 1559 | } |
1560 | // Draw horizontal lines of grid | 1560 | // Draw horizontal lines of grid |
1561 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1561 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1562 | if ( lGridSpacingY > 0 ) { | 1562 | if ( lGridSpacingY > 0 ) { |
1563 | while (y < cy + ch) { | 1563 | while (y < cy + ch) { |
1564 | p->setPen( SolidLine ); | 1564 | p->setPen( SolidLine ); |
1565 | p->drawLine(cx,y,cx+cw,y); | 1565 | p->drawLine(cx,y,cx+cw,y); |
1566 | y+=lGridSpacingY; | 1566 | y+=lGridSpacingY; |
1567 | p->setPen( DotLine ); | 1567 | p->setPen( DotLine ); |
1568 | p->drawLine(cx,y,cx+cw,y); | 1568 | p->drawLine(cx,y,cx+cw,y); |
1569 | y+=lGridSpacingY; | 1569 | y+=lGridSpacingY; |
1570 | } | 1570 | } |
1571 | p->setPen( SolidLine ); | 1571 | p->setPen( SolidLine ); |
1572 | } | 1572 | } |
1573 | mPixPainter.end() ; | 1573 | mPixPainter.end() ; |
1574 | } | 1574 | } |
1575 | 1575 | ||
1576 | /* | 1576 | /* |
1577 | Convert srcollview contents coordinates to agenda grid coordinates. | 1577 | Convert srcollview contents coordinates to agenda grid coordinates. |
1578 | */ | 1578 | */ |
1579 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1579 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1580 | { | 1580 | { |
1581 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1581 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1582 | x/mGridSpacingX; | 1582 | x/mGridSpacingX; |
1583 | gy = y/mGridSpacingY; | 1583 | gy = y/mGridSpacingY; |
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | /* | 1586 | /* |
1587 | Convert agenda grid coordinates to scrollview contents coordinates. | 1587 | Convert agenda grid coordinates to scrollview contents coordinates. |
1588 | */ | 1588 | */ |
1589 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1589 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1590 | { | 1590 | { |
1591 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1591 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1592 | gx*mGridSpacingX; | 1592 | gx*mGridSpacingX; |
1593 | y = gy*mGridSpacingY; | 1593 | y = gy*mGridSpacingY; |
1594 | } | 1594 | } |
1595 | 1595 | ||
1596 | 1596 | ||
1597 | /* | 1597 | /* |
1598 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1598 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1599 | the grid. | 1599 | the grid. |
1600 | */ | 1600 | */ |
1601 | int KOAgenda::timeToY(const QTime &time) | 1601 | int KOAgenda::timeToY(const QTime &time) |
1602 | { | 1602 | { |
1603 | int minutesPerCell = 24 * 60 / mRows; | 1603 | int minutesPerCell = 24 * 60 / mRows; |
1604 | int timeMinutes = time.hour() * 60 + time.minute(); | 1604 | int timeMinutes = time.hour() * 60 + time.minute(); |
1605 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1605 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1606 | return Y; | 1606 | return Y; |
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | 1609 | ||
1610 | /* | 1610 | /* |
1611 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1611 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1612 | fit into the grid. | 1612 | fit into the grid. |
1613 | */ | 1613 | */ |
1614 | QTime KOAgenda::gyToTime(int gy) | 1614 | QTime KOAgenda::gyToTime(int gy) |
1615 | { | 1615 | { |
1616 | 1616 | ||
1617 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1617 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1618 | 1618 | ||
1619 | int timeSeconds = secondsPerCell * gy; | 1619 | int timeSeconds = secondsPerCell * gy; |
1620 | 1620 | ||
1621 | QTime time( 0, 0, 0 ); | 1621 | QTime time( 0, 0, 0 ); |
1622 | if ( timeSeconds < 24 * 60 * 60 ) { | 1622 | if ( timeSeconds < 24 * 60 * 60 ) { |
1623 | time = time.addSecs(timeSeconds); | 1623 | time = time.addSecs(timeSeconds); |
1624 | } else { | 1624 | } else { |
1625 | time.setHMS( 23, 59, 59 ); | 1625 | time.setHMS( 23, 59, 59 ); |
1626 | } | 1626 | } |
1627 | 1627 | ||
1628 | return time; | 1628 | return time; |
1629 | } | 1629 | } |
1630 | 1630 | ||
1631 | void KOAgenda::setStartHour(int startHour) | 1631 | void KOAgenda::setStartHour(int startHour) |
1632 | { | 1632 | { |
1633 | int startCell = startHour * mRows / 24; | 1633 | int startCell = startHour * mRows / 24; |
1634 | setContentsPos(0,startCell * gridSpacingY()); | 1634 | setContentsPos(0,startCell * gridSpacingY()); |
1635 | } | 1635 | } |
1636 | QTime KOAgenda::getEndTime() | ||
1637 | { | ||
1638 | return QTime ( (contentsY ()+viewport()->height())*24/contentsHeight ()+1,0,0); | ||
1639 | } | ||
1636 | void KOAgenda::hideUnused() | 1640 | void KOAgenda::hideUnused() |
1637 | { | 1641 | { |
1638 | // experimental only | 1642 | // experimental only |
1639 | // return; | 1643 | // return; |
1640 | KOAgendaItem *item; | 1644 | KOAgendaItem *item; |
1641 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1645 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1642 | item->hide(); | 1646 | item->hide(); |
1643 | } | 1647 | } |
1644 | } | 1648 | } |
1645 | 1649 | ||
1646 | 1650 | ||
1647 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1651 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1648 | { | 1652 | { |
1649 | 1653 | ||
1650 | KOAgendaItem *fi; | 1654 | KOAgendaItem *fi; |
1651 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1655 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1652 | if ( fi->incidence() == event ) { | 1656 | if ( fi->incidence() == event ) { |
1653 | mUnusedItems.remove(); | 1657 | mUnusedItems.remove(); |
1654 | fi->init( event, qd ); | 1658 | fi->init( event, qd ); |
1655 | return fi; | 1659 | return fi; |
1656 | } | 1660 | } |
1657 | } | 1661 | } |
1658 | fi=mUnusedItems.first(); | 1662 | fi=mUnusedItems.first(); |
1659 | if ( fi ) { | 1663 | if ( fi ) { |
1660 | mUnusedItems.remove(); | 1664 | mUnusedItems.remove(); |
1661 | fi->init( event, qd ); | 1665 | fi->init( event, qd ); |
1662 | return fi; | 1666 | return fi; |
1663 | } | 1667 | } |
1664 | // qDebug("new KOAgendaItem "); | 1668 | // qDebug("new KOAgendaItem "); |
1665 | 1669 | ||
1666 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1670 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1667 | agendaItem->installEventFilter(this); | 1671 | agendaItem->installEventFilter(this); |
1668 | addChild(agendaItem,0,0); | 1672 | addChild(agendaItem,0,0); |
1669 | return agendaItem; | 1673 | return agendaItem; |
1670 | } | 1674 | } |
1671 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1675 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1672 | { | 1676 | { |
1673 | KOAgendaItem *item; | 1677 | KOAgendaItem *item; |
1674 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1678 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1675 | if ( item->incidence() == todo ) { | 1679 | if ( item->incidence() == todo ) { |
1676 | mItems.remove(); | 1680 | mItems.remove(); |
1677 | return item; | 1681 | return item; |
1678 | } | 1682 | } |
1679 | } | 1683 | } |
1680 | return 0; | 1684 | return 0; |
1681 | } | 1685 | } |
1682 | 1686 | ||
1683 | 1687 | ||
1684 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1688 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1685 | { | 1689 | { |
1686 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1690 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1687 | KOAgendaItem *item; | 1691 | KOAgendaItem *item; |
1688 | item = getItemForTodo ( todo ); | 1692 | item = getItemForTodo ( todo ); |
1689 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1693 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1690 | if ( item ) { | 1694 | if ( item ) { |
1691 | blockSignals( true ); | 1695 | blockSignals( true ); |
1692 | //qDebug("item found "); | 1696 | //qDebug("item found "); |
1693 | item->hide(); | 1697 | item->hide(); |
1694 | item->setCellX(-2, -1 ); | 1698 | item->setCellX(-2, -1 ); |
1695 | item->select(false); | 1699 | item->select(false); |
1696 | mUnusedItems.append( item ); | 1700 | mUnusedItems.append( item ); |
1697 | mItems.remove( item ); | 1701 | mItems.remove( item ); |
1698 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1702 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1699 | KOAgendaItem *itemit; | 1703 | KOAgendaItem *itemit; |
1700 | //globalFlagBlockAgendaItemPaint = 1; | 1704 | //globalFlagBlockAgendaItemPaint = 1; |
1701 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1705 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1702 | itemit=oldconflictItems.next() ) { | 1706 | itemit=oldconflictItems.next() ) { |
1703 | if ( itemit != item ) | 1707 | if ( itemit != item ) |
1704 | placeSubCells(itemit); | 1708 | placeSubCells(itemit); |
1705 | } | 1709 | } |
1706 | qApp->processEvents(); | 1710 | qApp->processEvents(); |
1707 | //globalFlagBlockAgendaItemPaint = 0; | 1711 | //globalFlagBlockAgendaItemPaint = 0; |
1708 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1712 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1709 | itemit=oldconflictItems.next() ) { | 1713 | itemit=oldconflictItems.next() ) { |
1710 | globalFlagBlockAgendaItemUpdate = 0; | 1714 | globalFlagBlockAgendaItemUpdate = 0; |
1711 | if ( itemit != item ) | 1715 | if ( itemit != item ) |
1712 | itemit->repaintMe(); | 1716 | itemit->repaintMe(); |
1713 | globalFlagBlockAgendaItemUpdate = 1; | 1717 | globalFlagBlockAgendaItemUpdate = 1; |
1714 | //qDebug("sigleshot "); | 1718 | //qDebug("sigleshot "); |
1715 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); | 1719 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); |
1716 | //itemit->repaint( false ); repaintItem() | 1720 | //itemit->repaint( false ); repaintItem() |
1717 | } | 1721 | } |
1718 | blockSignals( false ); | 1722 | blockSignals( false ); |
1719 | } | 1723 | } |
1720 | if ( remove ) { | 1724 | if ( remove ) { |
1721 | //qDebug("remove****************************************** "); | 1725 | //qDebug("remove****************************************** "); |
1722 | return; | 1726 | return; |
1723 | } | 1727 | } |
1724 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) | 1728 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) |
1725 | return; | 1729 | return; |
1726 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1730 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1727 | QDate currentDate = QDate::currentDate(); | 1731 | QDate currentDate = QDate::currentDate(); |
1728 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1732 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1729 | QDateTime dt; | 1733 | QDateTime dt; |
1730 | if ( todo->hasCompletedDate() ) | 1734 | if ( todo->hasCompletedDate() ) |
1731 | dt = todo->completed(); | 1735 | dt = todo->completed(); |
1732 | else | 1736 | else |
1733 | dt = todo->dtDue(); | 1737 | dt = todo->dtDue(); |
1734 | if ( overdue ) { | 1738 | if ( overdue ) { |
1735 | days += todo->dtDue().date().daysTo( currentDate ); | 1739 | days += todo->dtDue().date().daysTo( currentDate ); |
1736 | } | 1740 | } |
1737 | else | 1741 | else |
1738 | currentDate = dt.date(); | 1742 | currentDate = dt.date(); |
1739 | 1743 | ||
1740 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1744 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1741 | if ( ! mAllDayMode ) return; | 1745 | if ( ! mAllDayMode ) return; |
1742 | // aldayagenda | 1746 | // aldayagenda |
1743 | globalFlagBlockAgendaItemPaint = 1; | 1747 | globalFlagBlockAgendaItemPaint = 1; |
1744 | item = insertAllDayItem(todo, currentDate,days, days); | 1748 | item = insertAllDayItem(todo, currentDate,days, days); |
1745 | item->show(); | 1749 | item->show(); |
1746 | 1750 | ||
1747 | } | 1751 | } |
1748 | else { | 1752 | else { |
1749 | if ( mAllDayMode ) return; | 1753 | if ( mAllDayMode ) return; |
1750 | // mAgenda | 1754 | // mAgenda |
1751 | globalFlagBlockAgendaItemPaint = 1; | 1755 | globalFlagBlockAgendaItemPaint = 1; |
1752 | int endY = timeToY(dt.time()) - 1; | 1756 | int endY = timeToY(dt.time()) - 1; |
1753 | int hi = 12/KOPrefs::instance()->mHourSize; | 1757 | int hi = 12/KOPrefs::instance()->mHourSize; |
1754 | int startY = endY - 1-hi; | 1758 | int startY = endY - 1-hi; |
1755 | item = insertItem(todo,currentDate,days,startY,endY); | 1759 | item = insertItem(todo,currentDate,days,startY,endY); |
1756 | item->show(); | 1760 | item->show(); |
1757 | } | 1761 | } |
1758 | qApp->processEvents(); | 1762 | qApp->processEvents(); |
1759 | globalFlagBlockAgendaItemPaint = 0; | 1763 | globalFlagBlockAgendaItemPaint = 0; |
1760 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1764 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1761 | KOAgendaItem *itemit; | 1765 | KOAgendaItem *itemit; |
1762 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1766 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1763 | itemit=oldconflictItems.next() ) { | 1767 | itemit=oldconflictItems.next() ) { |
1764 | globalFlagBlockAgendaItemUpdate = 0; | 1768 | globalFlagBlockAgendaItemUpdate = 0; |
1765 | itemit->repaintMe(); | 1769 | itemit->repaintMe(); |
1766 | globalFlagBlockAgendaItemUpdate = 1; | 1770 | globalFlagBlockAgendaItemUpdate = 1; |
1767 | itemit->repaint(); | 1771 | itemit->repaint(); |
1768 | } | 1772 | } |
1769 | globalFlagBlockAgendaItemUpdate = 0; | 1773 | globalFlagBlockAgendaItemUpdate = 0; |
1770 | item->repaintMe(); | 1774 | item->repaintMe(); |
1771 | globalFlagBlockAgendaItemUpdate = 1; | 1775 | globalFlagBlockAgendaItemUpdate = 1; |
1772 | item->repaint(); | 1776 | item->repaint(); |
1773 | } | 1777 | } |
1774 | /* | 1778 | /* |
1775 | Insert KOAgendaItem into agenda. | 1779 | Insert KOAgendaItem into agenda. |
1776 | */ | 1780 | */ |
1777 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1781 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1778 | { | 1782 | { |
1779 | if (mAllDayMode) { | 1783 | if (mAllDayMode) { |
1780 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1784 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1781 | return 0; | 1785 | return 0; |
1782 | } | 1786 | } |
1783 | 1787 | ||
1784 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1788 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1785 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1789 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1786 | 1790 | ||
1787 | int YSize = YBottom - YTop + 1; | 1791 | int YSize = YBottom - YTop + 1; |
1788 | if (YSize < 0) { | 1792 | if (YSize < 0) { |
1789 | YSize = 1; | 1793 | YSize = 1; |
1790 | } | 1794 | } |
1791 | int iheight = mGridSpacingY * YSize; | 1795 | int iheight = mGridSpacingY * YSize; |
1792 | 1796 | ||
1793 | agendaItem->resize(mGridSpacingX,iheight ); | 1797 | agendaItem->resize(mGridSpacingX,iheight ); |
1794 | agendaItem->setCellXY(X,YTop,YBottom); | 1798 | agendaItem->setCellXY(X,YTop,YBottom); |
1795 | agendaItem->setCellXWidth(X); | 1799 | agendaItem->setCellXWidth(X); |
1796 | 1800 | ||
1797 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1801 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1798 | mItems.append(agendaItem); | 1802 | mItems.append(agendaItem); |
1799 | 1803 | ||
1800 | placeSubCells(agendaItem); | 1804 | placeSubCells(agendaItem); |
1801 | 1805 | ||
1802 | //agendaItem->show(); | 1806 | //agendaItem->show(); |
1803 | 1807 | ||
1804 | 1808 | ||
1805 | return agendaItem; | 1809 | return agendaItem; |
1806 | } | 1810 | } |
1807 | 1811 | ||
1808 | 1812 | ||
1809 | /* | 1813 | /* |
1810 | Insert all-day KOAgendaItem into agenda. | 1814 | Insert all-day KOAgendaItem into agenda. |
1811 | */ | 1815 | */ |
1812 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1816 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1813 | { | 1817 | { |
1814 | if (!mAllDayMode) { | 1818 | if (!mAllDayMode) { |
1815 | return 0; | 1819 | return 0; |
1816 | } | 1820 | } |
1817 | 1821 | ||
1818 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1822 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1819 | 1823 | ||
1820 | agendaItem->setCellXY(XBegin,0,0); | 1824 | agendaItem->setCellXY(XBegin,0,0); |
1821 | agendaItem->setCellXWidth(XEnd); | 1825 | agendaItem->setCellXWidth(XEnd); |
1822 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1826 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1823 | 1827 | ||
1824 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1828 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1825 | mItems.append(agendaItem); | 1829 | mItems.append(agendaItem); |
1826 | 1830 | ||
1827 | placeSubCells(agendaItem); | 1831 | placeSubCells(agendaItem); |
1828 | 1832 | ||
1829 | //agendaItem->show(); | 1833 | //agendaItem->show(); |
1830 | 1834 | ||
1831 | return agendaItem; | 1835 | return agendaItem; |
1832 | } | 1836 | } |
1833 | 1837 | ||
1834 | 1838 | ||
1835 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1839 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1836 | int YTop,int YBottom) | 1840 | int YTop,int YBottom) |
1837 | { | 1841 | { |
1838 | if (mAllDayMode) { | 1842 | if (mAllDayMode) { |
1839 | ; | 1843 | ; |
1840 | return; | 1844 | return; |
1841 | } | 1845 | } |
1842 | 1846 | ||
1843 | int cellX,cellYTop,cellYBottom; | 1847 | int cellX,cellYTop,cellYBottom; |
1844 | QString newtext; | 1848 | QString newtext; |
1845 | int width = XEnd - XBegin + 1; | 1849 | int width = XEnd - XBegin + 1; |
1846 | int count = 0; | 1850 | int count = 0; |
1847 | KOAgendaItem *current = 0; | 1851 | KOAgendaItem *current = 0; |
1848 | QPtrList<KOAgendaItem> multiItems; | 1852 | QPtrList<KOAgendaItem> multiItems; |
1849 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1853 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1850 | if (cellX == XBegin) cellYTop = YTop; | 1854 | if (cellX == XBegin) cellYTop = YTop; |
1851 | else cellYTop = 0; | 1855 | else cellYTop = 0; |
1852 | if (cellX == XEnd) cellYBottom = YBottom; | 1856 | if (cellX == XEnd) cellYBottom = YBottom; |
1853 | else cellYBottom = rows() - 1; | 1857 | else cellYBottom = rows() - 1; |
1854 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1858 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1855 | newtext.append(event->summary()); | 1859 | newtext.append(event->summary()); |
1856 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1860 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1857 | current->setText(newtext); | 1861 | current->setText(newtext); |
1858 | multiItems.append(current); | 1862 | multiItems.append(current); |
1859 | } | 1863 | } |
1860 | 1864 | ||
1861 | KOAgendaItem *next = 0; | 1865 | KOAgendaItem *next = 0; |
1862 | KOAgendaItem *last = multiItems.last(); | 1866 | KOAgendaItem *last = multiItems.last(); |
1863 | KOAgendaItem *first = multiItems.first(); | 1867 | KOAgendaItem *first = multiItems.first(); |
1864 | KOAgendaItem *setFirst,*setLast; | 1868 | KOAgendaItem *setFirst,*setLast; |
1865 | current = first; | 1869 | current = first; |
1866 | while (current) { | 1870 | while (current) { |
1867 | next = multiItems.next(); | 1871 | next = multiItems.next(); |
1868 | if (current == first) setFirst = 0; | 1872 | if (current == first) setFirst = 0; |
1869 | else setFirst = first; | 1873 | else setFirst = first; |
1870 | if (current == last) setLast = 0; | 1874 | if (current == last) setLast = 0; |
1871 | else setLast = last; | 1875 | else setLast = last; |
1872 | 1876 | ||
1873 | current->setMultiItem(setFirst,next,setLast); | 1877 | current->setMultiItem(setFirst,next,setLast); |
1874 | current = next; | 1878 | current = next; |
1875 | } | 1879 | } |
1876 | } | 1880 | } |
1877 | 1881 | ||
1878 | 1882 | ||
1879 | //QSizePolicy KOAgenda::sizePolicy() const | 1883 | //QSizePolicy KOAgenda::sizePolicy() const |
1880 | //{ | 1884 | //{ |
1881 | // Thought this would make the all-day event agenda minimum size and the | 1885 | // Thought this would make the all-day event agenda minimum size and the |
1882 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1886 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1883 | // don´t seem to think that an Expanding widget needs more space than a | 1887 | // don´t seem to think that an Expanding widget needs more space than a |
1884 | // Preferred one. | 1888 | // Preferred one. |
1885 | // But it doesn´t hurt, so it stays. | 1889 | // But it doesn´t hurt, so it stays. |
1886 | // if (mAllDayMode) { | 1890 | // if (mAllDayMode) { |
1887 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1891 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1888 | // } else { | 1892 | // } else { |
1889 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1893 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1890 | // } | 1894 | // } |
1891 | //} | 1895 | //} |
1892 | void KOAgenda::finishResize ( ) | 1896 | void KOAgenda::finishResize ( ) |
1893 | { | 1897 | { |
1894 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1898 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1895 | if ( globalFlagBlockAgenda == 0 ) { | 1899 | if ( globalFlagBlockAgenda == 0 ) { |
1896 | finishUpdate(); | 1900 | finishUpdate(); |
1897 | //qDebug("finishUpdate() called "); | 1901 | //qDebug("finishUpdate() called "); |
1898 | } | 1902 | } |
1899 | } | 1903 | } |
1900 | /* | 1904 | /* |
1901 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1905 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1902 | */ | 1906 | */ |
1903 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1907 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1904 | { | 1908 | { |
1905 | mSelectionHeight = 0; | 1909 | mSelectionHeight = 0; |
1906 | mResizeTimer.start( 150 , true ); | 1910 | mResizeTimer.start( 150 , true ); |
1907 | computeSizes(); | 1911 | computeSizes(); |
1908 | return; | 1912 | return; |
1909 | 1913 | ||
1910 | } | 1914 | } |
1911 | void KOAgenda::computeSizes() | 1915 | void KOAgenda::computeSizes() |
1912 | { | 1916 | { |
1913 | if ( globalFlagBlockStartup ) | 1917 | if ( globalFlagBlockStartup ) |
1914 | return; | 1918 | return; |
1915 | int frameOffset = frameWidth() * 2 +1; | 1919 | int frameOffset = frameWidth() * 2 +1; |
1916 | if (mAllDayMode) { | 1920 | if (mAllDayMode) { |
1917 | mGridSpacingX = (width()-frameOffset) / mColumns; | 1921 | mGridSpacingX = (width()-frameOffset) / mColumns; |
1918 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1922 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1919 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1923 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1920 | // mGridSpacingY = height(); | 1924 | // mGridSpacingY = height(); |
1921 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1925 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1922 | 1926 | ||
1923 | KOAgendaItem *item; | 1927 | KOAgendaItem *item; |
1924 | int subCellWidth; | 1928 | int subCellWidth; |
1925 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1929 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1926 | subCellWidth = mGridSpacingY / item->subCells(); | 1930 | subCellWidth = mGridSpacingY / item->subCells(); |
1927 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1931 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1928 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1932 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1929 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1933 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1930 | item->cellX() * mGridSpacingX, | 1934 | item->cellX() * mGridSpacingX, |
1931 | item->subCell() * subCellWidth); | 1935 | item->subCell() * subCellWidth); |
1932 | } | 1936 | } |
1933 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1937 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1934 | } else { | 1938 | } else { |
1935 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; | 1939 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1936 | if (height() > mGridSpacingY * mRows + 1 ) { | 1940 | if (height() > mGridSpacingY * mRows + 1 ) { |
1937 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1941 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1938 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1942 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1939 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1943 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1940 | emit resizedSignal(); | 1944 | emit resizedSignal(); |
1941 | } else | 1945 | } else |
1942 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1946 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1943 | KOAgendaItem *item; | 1947 | KOAgendaItem *item; |
1944 | int subCellWidth; | 1948 | int subCellWidth; |
1945 | 1949 | ||
1946 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1950 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1947 | subCellWidth = mGridSpacingX / item->subCells(); | 1951 | subCellWidth = mGridSpacingX / item->subCells(); |
1948 | item->resize(subCellWidth,item->height()); | 1952 | item->resize(subCellWidth,item->height()); |
1949 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1953 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1950 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1954 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1951 | item->cellX() * mGridSpacingX) + | 1955 | item->cellX() * mGridSpacingX) + |
1952 | item->subCell() * subCellWidth,childY(item)); | 1956 | item->subCell() * subCellWidth,childY(item)); |
1953 | } | 1957 | } |
1954 | } | 1958 | } |
1955 | int cw = contentsWidth(); | 1959 | int cw = contentsWidth(); |
1956 | int ch = contentsHeight(); | 1960 | int ch = contentsHeight(); |
1957 | if ( mAllDayMode ) { | 1961 | if ( mAllDayMode ) { |
1958 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1962 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1959 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { | 1963 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { |
1960 | //qDebug("paintPixAll->resize "); | 1964 | //qDebug("paintPixAll->resize "); |
1961 | paintPixAll->resize( cw, ch ); | 1965 | paintPixAll->resize( cw, ch ); |
1962 | } | 1966 | } |
1963 | } else { | 1967 | } else { |
1964 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1968 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1965 | if ( paintPix->width() < cw || paintPix->height() < ch ) { | 1969 | if ( paintPix->width() < cw || paintPix->height() < ch ) { |
1966 | //qDebug("paintPix->resize "); | 1970 | //qDebug("paintPix->resize "); |
1967 | paintPix->resize( cw , ch ); | 1971 | paintPix->resize( cw , ch ); |
1968 | } | 1972 | } |
1969 | } | 1973 | } |
1970 | 1974 | ||
1971 | checkScrollBoundaries(); | 1975 | checkScrollBoundaries(); |
1972 | drawContentsToPainter(); | 1976 | drawContentsToPainter(); |
1973 | viewport()->repaint(false); | 1977 | viewport()->repaint(false); |
1974 | } | 1978 | } |
1975 | 1979 | ||
1976 | void KOAgenda::scrollUp() | 1980 | void KOAgenda::scrollUp() |
1977 | { | 1981 | { |
1978 | scrollBy(0,-mScrollOffset); | 1982 | scrollBy(0,-mScrollOffset); |
1979 | } | 1983 | } |
1980 | 1984 | ||
1981 | 1985 | ||
1982 | void KOAgenda::scrollDown() | 1986 | void KOAgenda::scrollDown() |
1983 | { | 1987 | { |
1984 | scrollBy(0,mScrollOffset); | 1988 | scrollBy(0,mScrollOffset); |
1985 | } | 1989 | } |
1986 | 1990 | ||
1987 | void KOAgenda::popupAlarm() | 1991 | void KOAgenda::popupAlarm() |
1988 | { | 1992 | { |
1989 | if (!mClickedItem) { | 1993 | if (!mClickedItem) { |
1990 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1994 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1991 | return; | 1995 | return; |
1992 | } | 1996 | } |
1993 | // TODO: deal correctly with multiple alarms | 1997 | // TODO: deal correctly with multiple alarms |
1994 | Alarm* alarm; | 1998 | Alarm* alarm; |
1995 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1999 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1996 | for(alarm=list.first();alarm;alarm=list.next()) { | 2000 | for(alarm=list.first();alarm;alarm=list.next()) { |
1997 | alarm->toggleAlarm(); | 2001 | alarm->toggleAlarm(); |
1998 | } | 2002 | } |
1999 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 2003 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
2000 | mClickedItem->paintMe( true ); | 2004 | mClickedItem->paintMe( true ); |
2001 | mClickedItem->repaint( false ); | 2005 | mClickedItem->repaint( false ); |
2002 | } | 2006 | } |
2003 | 2007 | ||
2004 | /* | 2008 | /* |
2005 | Calculates the minimum width | 2009 | Calculates the minimum width |
2006 | */ | 2010 | */ |
2007 | int KOAgenda::minimumWidth() const | 2011 | int KOAgenda::minimumWidth() const |
2008 | { | 2012 | { |
2009 | // TODO:: develop a way to dynamically determine the minimum width | 2013 | // TODO:: develop a way to dynamically determine the minimum width |
2010 | int min = 100; | 2014 | int min = 100; |
2011 | 2015 | ||
2012 | return min; | 2016 | return min; |
2013 | } | 2017 | } |
2014 | 2018 | ||
2015 | void KOAgenda::updateConfig() | 2019 | void KOAgenda::updateConfig() |
2016 | { | 2020 | { |
2017 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 2021 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
2018 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 2022 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
2019 | if ( mAllDayMode ) { | 2023 | if ( mAllDayMode ) { |
2020 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 2024 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
2021 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 2025 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
2022 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 2026 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
2023 | // setMaximumHeight( mGridSpacingY+1 ); | 2027 | // setMaximumHeight( mGridSpacingY+1 ); |
2024 | viewport()->repaint( false ); | 2028 | viewport()->repaint( false ); |
2025 | //setFixedHeight( mGridSpacingY+1 ); | 2029 | //setFixedHeight( mGridSpacingY+1 ); |
2026 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 2030 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
2027 | } | 2031 | } |
2028 | else { | 2032 | else { |
2029 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 2033 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
2030 | calculateWorkingHours(); | 2034 | calculateWorkingHours(); |
2031 | } | 2035 | } |
2032 | } | 2036 | } |
2033 | 2037 | ||
2034 | void KOAgenda::checkScrollBoundaries() | 2038 | void KOAgenda::checkScrollBoundaries() |
2035 | { | 2039 | { |
2036 | // Invalidate old values to force update | 2040 | // Invalidate old values to force update |
2037 | mOldLowerScrollValue = -1; | 2041 | mOldLowerScrollValue = -1; |
2038 | mOldUpperScrollValue = -1; | 2042 | mOldUpperScrollValue = -1; |
2039 | 2043 | ||
2040 | checkScrollBoundaries(verticalScrollBar()->value()); | 2044 | checkScrollBoundaries(verticalScrollBar()->value()); |
2041 | } | 2045 | } |
2042 | 2046 | ||
2043 | void KOAgenda::checkScrollBoundaries(int v) | 2047 | void KOAgenda::checkScrollBoundaries(int v) |
2044 | { | 2048 | { |
2045 | if ( mGridSpacingY == 0 ) | 2049 | if ( mGridSpacingY == 0 ) |
2046 | return; | 2050 | return; |
2047 | int yMin = v/mGridSpacingY; | 2051 | int yMin = v/mGridSpacingY; |
2048 | int yMax = (v+visibleHeight())/mGridSpacingY; | 2052 | int yMax = (v+visibleHeight())/mGridSpacingY; |
2049 | 2053 | ||
2050 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 2054 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
2051 | 2055 | ||
2052 | if (yMin != mOldLowerScrollValue) { | 2056 | if (yMin != mOldLowerScrollValue) { |
2053 | mOldLowerScrollValue = yMin; | 2057 | mOldLowerScrollValue = yMin; |
2054 | emit lowerYChanged(yMin); | 2058 | emit lowerYChanged(yMin); |
2055 | } | 2059 | } |
2056 | if (yMax != mOldUpperScrollValue) { | 2060 | if (yMax != mOldUpperScrollValue) { |
2057 | mOldUpperScrollValue = yMax; | 2061 | mOldUpperScrollValue = yMax; |
2058 | emit upperYChanged(yMax); | 2062 | emit upperYChanged(yMax); |
2059 | } | 2063 | } |
2060 | } | 2064 | } |
2061 | 2065 | ||
2062 | void KOAgenda::deselectItem() | 2066 | void KOAgenda::deselectItem() |
2063 | { | 2067 | { |
2064 | if (mSelectedItem.isNull()) return; | 2068 | if (mSelectedItem.isNull()) return; |
2065 | mSelectedItem->select(false); | 2069 | mSelectedItem->select(false); |
2066 | mSelectedItem = 0; | 2070 | mSelectedItem = 0; |
2067 | } | 2071 | } |
2068 | 2072 | ||
2069 | void KOAgenda::selectItem(KOAgendaItem *item) | 2073 | void KOAgenda::selectItem(KOAgendaItem *item) |
2070 | { | 2074 | { |
2071 | if ((KOAgendaItem *)mSelectedItem == item) return; | 2075 | if ((KOAgendaItem *)mSelectedItem == item) return; |
2072 | deselectItem(); | 2076 | deselectItem(); |
2073 | if (item == 0) { | 2077 | if (item == 0) { |
2074 | emit incidenceSelected( 0 ); | 2078 | emit incidenceSelected( 0 ); |
2075 | return; | 2079 | return; |
2076 | } | 2080 | } |
2077 | mSelectedItem = item; | 2081 | mSelectedItem = item; |
2078 | mSelectedItem->select(); | 2082 | mSelectedItem->select(); |
2079 | emit incidenceSelected( mSelectedItem->incidence() ); | 2083 | emit incidenceSelected( mSelectedItem->incidence() ); |
2080 | } | 2084 | } |
2081 | 2085 | ||
2082 | // This function seems never be called. | 2086 | // This function seems never be called. |
2083 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 2087 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
2084 | { | 2088 | { |
2085 | switch(kev->key()) { | 2089 | switch(kev->key()) { |
2086 | case Key_PageDown: | 2090 | case Key_PageDown: |
2087 | verticalScrollBar()->addPage(); | 2091 | verticalScrollBar()->addPage(); |
2088 | break; | 2092 | break; |
2089 | case Key_PageUp: | 2093 | case Key_PageUp: |
2090 | verticalScrollBar()->subtractPage(); | 2094 | verticalScrollBar()->subtractPage(); |
2091 | break; | 2095 | break; |
2092 | case Key_Down: | 2096 | case Key_Down: |
2093 | verticalScrollBar()->addLine(); | 2097 | verticalScrollBar()->addLine(); |
2094 | break; | 2098 | break; |
2095 | case Key_Up: | 2099 | case Key_Up: |
2096 | verticalScrollBar()->subtractLine(); | 2100 | verticalScrollBar()->subtractLine(); |
2097 | break; | 2101 | break; |
2098 | default: | 2102 | default: |
2099 | ; | 2103 | ; |
2100 | } | 2104 | } |
2101 | } | 2105 | } |
2102 | 2106 | ||
2103 | void KOAgenda::calculateWorkingHours() | 2107 | void KOAgenda::calculateWorkingHours() |
2104 | { | 2108 | { |
2105 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 2109 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
2106 | mWorkingHoursEnable = !mAllDayMode; | 2110 | mWorkingHoursEnable = !mAllDayMode; |
2107 | 2111 | ||
2108 | mWorkingHoursYTop = mGridSpacingY * | 2112 | mWorkingHoursYTop = mGridSpacingY * |
2109 | KOPrefs::instance()->mWorkingHoursStart * 4; | 2113 | KOPrefs::instance()->mWorkingHoursStart * 4; |
2110 | mWorkingHoursYBottom = mGridSpacingY * | 2114 | mWorkingHoursYBottom = mGridSpacingY * |
2111 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 2115 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
2112 | } | 2116 | } |
2113 | 2117 | ||
2114 | 2118 | ||
2115 | DateList KOAgenda::dateList() const | 2119 | DateList KOAgenda::dateList() const |
2116 | { | 2120 | { |
2117 | return mSelectedDates; | 2121 | return mSelectedDates; |
2118 | } | 2122 | } |
2119 | 2123 | ||
2120 | void KOAgenda::setDateList(const DateList &selectedDates) | 2124 | void KOAgenda::setDateList(const DateList &selectedDates) |
2121 | { | 2125 | { |
2122 | mSelectedDates = selectedDates; | 2126 | mSelectedDates = selectedDates; |
2123 | } | 2127 | } |
2124 | 2128 | ||
2125 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 2129 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
2126 | { | 2130 | { |
2127 | mHolidayMask = mask; | 2131 | mHolidayMask = mask; |
2128 | 2132 | ||
2129 | /* | 2133 | /* |
2130 | kdDebug() << "HolidayMask: "; | 2134 | kdDebug() << "HolidayMask: "; |
2131 | for(uint i=0;i<mask->count();++i) { | 2135 | for(uint i=0;i<mask->count();++i) { |
2132 | kdDebug() << (mask->at(i) ? "*" : "o"); | 2136 | kdDebug() << (mask->at(i) ? "*" : "o"); |
2133 | } | 2137 | } |
2134 | kdDebug() << endl; | 2138 | kdDebug() << endl; |
2135 | */ | 2139 | */ |
2136 | } | 2140 | } |
2137 | 2141 | ||
2138 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 2142 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
2139 | { | 2143 | { |
2140 | 2144 | ||
2141 | QScrollView::contentsMousePressEvent(event); | 2145 | QScrollView::contentsMousePressEvent(event); |
2142 | } | 2146 | } |
2143 | 2147 | ||
2144 | void KOAgenda::storePosition() | 2148 | void KOAgenda::storePosition() |
2145 | { | 2149 | { |
2146 | //mContentPosition | 2150 | //mContentPosition |
2147 | int max = mGridSpacingY*4*24; | 2151 | int max = mGridSpacingY*4*24; |
2148 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 2152 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
2149 | mContentPosition = 0; | 2153 | mContentPosition = 0; |
2150 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 2154 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
2151 | mContentPosition = -1.0; | 2155 | mContentPosition = -1.0; |
2152 | else | 2156 | else |
2153 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 2157 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
2154 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 2158 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
2155 | 2159 | ||
2156 | } | 2160 | } |
2157 | void KOAgenda::restorePosition() | 2161 | void KOAgenda::restorePosition() |
2158 | { | 2162 | { |
2159 | int posY; | 2163 | int posY; |
2160 | int max = mGridSpacingY*4*24; | 2164 | int max = mGridSpacingY*4*24; |
2161 | if ( mContentPosition < 0 ) | 2165 | if ( mContentPosition < 0 ) |
2162 | posY = max-viewport()->height(); | 2166 | posY = max-viewport()->height(); |
2163 | else | 2167 | else |
2164 | if ( mContentPosition == 0 ) | 2168 | if ( mContentPosition == 0 ) |
2165 | posY = 0; | 2169 | posY = 0; |
2166 | else | 2170 | else |
2167 | posY = (max/mContentPosition)-(viewport()->height()/2); | 2171 | posY = (max/mContentPosition)-(viewport()->height()/2); |
2168 | setContentsPos (0, posY ); | 2172 | setContentsPos (0, posY ); |
2169 | //qDebug("posY %d hei %d", posY, max); | 2173 | //qDebug("posY %d hei %d", posY, max); |
2170 | 2174 | ||
2171 | } | 2175 | } |
2172 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 2176 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
2173 | { | 2177 | { |
2174 | ++x; | 2178 | ++x; |
2175 | QScrollView::moveChild( w, x , y ); | 2179 | QScrollView::moveChild( w, x , y ); |
2176 | } | 2180 | } |
2177 | #include <qmessagebox.h> | 2181 | #include <qmessagebox.h> |
2178 | #ifdef DESKTOP_VERSION | 2182 | #ifdef DESKTOP_VERSION |
2179 | #include <qprinter.h> | 2183 | #include <qprinter.h> |
2180 | #include <qpainter.h> | 2184 | #include <qpainter.h> |
2181 | #include <qpaintdevicemetrics.h> | 2185 | #include <qpaintdevicemetrics.h> |
2182 | 2186 | ||
2183 | #endif | 2187 | #endif |
2184 | void KOAgenda::printSelection() | 2188 | void KOAgenda::printSelection() |
2185 | { | 2189 | { |
2186 | #ifdef DESKTOP_VERSION | 2190 | #ifdef DESKTOP_VERSION |
2187 | if ( mStartCellY == mCurrentCellY ) { | 2191 | if ( mStartCellY == mCurrentCellY ) { |
2188 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2192 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2189 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 2193 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
2190 | i18n("OK"), 0, 0, | 2194 | i18n("OK"), 0, 0, |
2191 | 0, 1 ); | 2195 | 0, 1 ); |
2192 | return; | 2196 | return; |
2193 | } | 2197 | } |
2194 | 2198 | ||
2195 | float dx, dy; | 2199 | float dx, dy; |
2196 | int x,y,w,h; | 2200 | int x,y,w,h; |
2197 | x= 0; | 2201 | x= 0; |
2198 | w= contentsWidth()+2; | 2202 | w= contentsWidth()+2; |
2199 | // h= contentsHeight(); | 2203 | // h= contentsHeight(); |
2200 | y = mGridSpacingY*mStartCellY; | 2204 | y = mGridSpacingY*mStartCellY; |
2201 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 2205 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
2202 | 2206 | ||
2203 | //return; | 2207 | //return; |
2204 | QPrinter* printer = new QPrinter(); | 2208 | QPrinter* printer = new QPrinter(); |
2205 | if ( !printer->setup()) { | 2209 | if ( !printer->setup()) { |
2206 | delete printer; | 2210 | delete printer; |
2207 | return; | 2211 | return; |
2208 | } | 2212 | } |
2209 | QPainter p( printer ); | 2213 | QPainter p( printer ); |
2210 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 2214 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
2211 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 2215 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
2212 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 2216 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
2213 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 2217 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
2214 | // p.drawText( 0, 0, date ); | 2218 | // p.drawText( 0, 0, date ); |
2215 | int offset = m.width()/8; | 2219 | int offset = m.width()/8; |
2216 | // compute the scale | 2220 | // compute the scale |
2217 | dx = ((float) m.width()-offset) / (float)w; | 2221 | dx = ((float) m.width()-offset) / (float)w; |
2218 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 2222 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
2219 | float scale; | 2223 | float scale; |
2220 | // scale to fit the width or height of the paper | 2224 | // scale to fit the width or height of the paper |
2221 | if ( dx < dy ) | 2225 | if ( dx < dy ) |
2222 | scale = dx; | 2226 | scale = dx; |
2223 | else | 2227 | else |
2224 | scale = dy; | 2228 | scale = dy; |
2225 | // set the scale | 2229 | // set the scale |
2226 | p.drawText( offset* scale, offset* scale*3/4, date ); | 2230 | p.drawText( offset* scale, offset* scale*3/4, date ); |
2227 | 2231 | ||
2228 | int selDay; | 2232 | int selDay; |
2229 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 2233 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
2230 | float startX = 1; | 2234 | float startX = 1; |
2231 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 2235 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
2232 | { | 2236 | { |
2233 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 2237 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
2234 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 2238 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
2235 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 2239 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
2236 | startX += widOffset; | 2240 | startX += widOffset; |
2237 | 2241 | ||
2238 | } | 2242 | } |
2239 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 2243 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
2240 | p.scale( scale, scale ); | 2244 | p.scale( scale, scale ); |
2241 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 2245 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
2242 | // now printing with y offset: 2 hei | 2246 | // now printing with y offset: 2 hei |
2243 | // p.translate( 0, -y*scale); | 2247 | // p.translate( 0, -y*scale); |
2244 | 2248 | ||
2245 | drawContentsToPainter(&p, true ); | 2249 | drawContentsToPainter(&p, true ); |
2246 | globalFlagBlockAgendaItemUpdate = false; | 2250 | globalFlagBlockAgendaItemUpdate = false; |
2247 | KOAgendaItem *item; | 2251 | KOAgendaItem *item; |
2248 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 2252 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
2249 | item->select(false); | 2253 | item->select(false); |
2250 | item->paintMe( false, &p ); | 2254 | item->paintMe( false, &p ); |
2251 | } | 2255 | } |
2252 | globalFlagBlockAgendaItemUpdate = true; | 2256 | globalFlagBlockAgendaItemUpdate = true; |
2253 | p.end(); | 2257 | p.end(); |
2254 | delete printer; | 2258 | delete printer; |
2255 | #else | 2259 | #else |
2256 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2260 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2257 | i18n("Not supported \non PDA!\n"), | 2261 | i18n("Not supported \non PDA!\n"), |
2258 | i18n("OK"), 0, 0, | 2262 | i18n("OK"), 0, 0, |
2259 | 0, 1 ); | 2263 | 0, 1 ); |
2260 | #endif | 2264 | #endif |
2261 | } | 2265 | } |
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 0e3aed8..86cf2f4 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h | |||
@@ -1,306 +1,307 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOAGENDA_H | 23 | #ifndef KOAGENDA_H |
24 | #define KOAGENDA_H | 24 | #define KOAGENDA_H |
25 | 25 | ||
26 | #include <qscrollview.h> | 26 | #include <qscrollview.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qmemarray.h> | 28 | #include <qmemarray.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qpixmap.h> | 30 | #include <qpixmap.h> |
31 | #include <qguardedptr.h> | 31 | #include <qguardedptr.h> |
32 | 32 | ||
33 | #include "koagendaitem.h" | 33 | #include "koagendaitem.h" |
34 | #include "koeventview.h" | 34 | #include "koeventview.h" |
35 | 35 | ||
36 | class QPopupMenu; | 36 | class QPopupMenu; |
37 | class QTime; | 37 | class QTime; |
38 | class KConfig; | 38 | class KConfig; |
39 | class QFrame; | 39 | class QFrame; |
40 | class KOAgenda; | 40 | class KOAgenda; |
41 | class KCal::Event; | 41 | class KCal::Event; |
42 | class KCal::Todo; | 42 | class KCal::Todo; |
43 | 43 | ||
44 | using namespace KCal; | 44 | using namespace KCal; |
45 | 45 | ||
46 | class MarcusBains : public QFrame { | 46 | class MarcusBains : public QFrame { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | public: | 48 | public: |
49 | MarcusBains(KOAgenda *agenda=0,const char *name=0); | 49 | MarcusBains(KOAgenda *agenda=0,const char *name=0); |
50 | virtual ~MarcusBains(); | 50 | virtual ~MarcusBains(); |
51 | 51 | ||
52 | public slots: | 52 | public slots: |
53 | void updateLocation(bool recalculate=false); | 53 | void updateLocation(bool recalculate=false); |
54 | void updateLoc(); | 54 | void updateLoc(); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | int todayColumn(); | 57 | int todayColumn(); |
58 | QTimer *minutes; | 58 | QTimer *minutes; |
59 | QLabel *mTimeBox; | 59 | QLabel *mTimeBox; |
60 | KOAgenda *agenda; | 60 | KOAgenda *agenda; |
61 | QTime oldTime; | 61 | QTime oldTime; |
62 | int oldToday; | 62 | int oldToday; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | class KOAgenda : public QScrollView | 66 | class KOAgenda : public QScrollView |
67 | { | 67 | { |
68 | Q_OBJECT | 68 | Q_OBJECT |
69 | public: | 69 | public: |
70 | enum MouseActionType { NOP, MOVE, SELECT, | 70 | enum MouseActionType { NOP, MOVE, SELECT, |
71 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; | 71 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; |
72 | 72 | ||
73 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, | 73 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, |
74 | const char * name=0, WFlags f=0 ); | 74 | const char * name=0, WFlags f=0 ); |
75 | KOAgenda ( int columns, QWidget * parent=0, | 75 | KOAgenda ( int columns, QWidget * parent=0, |
76 | const char * name=0, WFlags f=0 ); | 76 | const char * name=0, WFlags f=0 ); |
77 | virtual ~KOAgenda(); | 77 | virtual ~KOAgenda(); |
78 | bool mInvalidPixmap; | 78 | bool mInvalidPixmap; |
79 | 79 | ||
80 | Incidence *selectedIncidence() const; | 80 | Incidence *selectedIncidence() const; |
81 | QDate selectedIncidenceDate() const; | 81 | QDate selectedIncidenceDate() const; |
82 | 82 | ||
83 | virtual bool eventFilter ( QObject *, QEvent * ); | 83 | virtual bool eventFilter ( QObject *, QEvent * ); |
84 | 84 | ||
85 | void contentsToGrid (int x, int y, int& gx, int& gy); | 85 | void contentsToGrid (int x, int y, int& gx, int& gy); |
86 | void gridToContents (int gx, int gy, int& x, int& y); | 86 | void gridToContents (int gx, int gy, int& x, int& y); |
87 | 87 | ||
88 | int timeToY (const QTime &time); | 88 | int timeToY (const QTime &time); |
89 | QTime gyToTime (int y); | 89 | QTime gyToTime (int y); |
90 | 90 | ||
91 | void setStartHour(int startHour); | 91 | void setStartHour(int startHour); |
92 | 92 | ||
93 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); | 93 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); |
94 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); | 94 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); |
95 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 95 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
96 | int YTop,int YBottom); | 96 | int YTop,int YBottom); |
97 | 97 | ||
98 | void changeColumns(int columns); | 98 | void changeColumns(int columns); |
99 | 99 | ||
100 | int columns() { return mColumns; } | 100 | int columns() { return mColumns; } |
101 | int rows() { return mRows; } | 101 | int rows() { return mRows; } |
102 | 102 | ||
103 | int gridSpacingX() const { return mGridSpacingX; } | 103 | int gridSpacingX() const { return mGridSpacingX; } |
104 | int gridSpacingY() const { return mGridSpacingY; } | 104 | int gridSpacingY() const { return mGridSpacingY; } |
105 | 105 | ||
106 | // virtual QSizePolicy sizePolicy() const; | 106 | // virtual QSizePolicy sizePolicy() const; |
107 | 107 | ||
108 | void clear(); | 108 | void clear(); |
109 | 109 | ||
110 | void clearSelection(); | 110 | void clearSelection(); |
111 | void hideUnused(); | 111 | void hideUnused(); |
112 | 112 | ||
113 | /** Calculates the minimum width */ | 113 | /** Calculates the minimum width */ |
114 | virtual int minimumWidth() const; | 114 | virtual int minimumWidth() const; |
115 | /** Update configuration from preference settings */ | 115 | /** Update configuration from preference settings */ |
116 | void updateConfig(); | 116 | void updateConfig(); |
117 | 117 | ||
118 | void checkScrollBoundaries(); | 118 | void checkScrollBoundaries(); |
119 | 119 | ||
120 | void setHolidayMask(QMemArray<bool> *); | 120 | void setHolidayMask(QMemArray<bool> *); |
121 | void setDateList(const DateList &selectedDates); | 121 | void setDateList(const DateList &selectedDates); |
122 | DateList dateList() const; | 122 | DateList dateList() const; |
123 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); | 123 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); |
124 | void finishUpdate(); | 124 | void finishUpdate(); |
125 | void printSelection(); | 125 | void printSelection(); |
126 | void storePosition(); | 126 | void storePosition(); |
127 | void restorePosition(); | 127 | void restorePosition(); |
128 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } | 128 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } |
129 | void shrinkPixmap(); | 129 | void shrinkPixmap(); |
130 | QTime getEndTime(); | ||
130 | 131 | ||
131 | public slots: | 132 | public slots: |
132 | void slotContentMove(int,int); | 133 | void slotContentMove(int,int); |
133 | void categoryChanged(Incidence * inc); | 134 | void categoryChanged(Incidence * inc); |
134 | void slotClearSelection(); | 135 | void slotClearSelection(); |
135 | void popupMenu(); | 136 | void popupMenu(); |
136 | void newItem( int ); | 137 | void newItem( int ); |
137 | void moveChild( QWidget *, int, int ); | 138 | void moveChild( QWidget *, int, int ); |
138 | void scrollUp(); | 139 | void scrollUp(); |
139 | void scrollDown(); | 140 | void scrollDown(); |
140 | void updateTodo( Todo * t, int , bool ); | 141 | void updateTodo( Todo * t, int , bool ); |
141 | void popupAlarm(); | 142 | void popupAlarm(); |
142 | 143 | ||
143 | void checkScrollBoundaries(int); | 144 | void checkScrollBoundaries(int); |
144 | 145 | ||
145 | /** Deselect selected items. This function does not emit any signals. */ | 146 | /** Deselect selected items. This function does not emit any signals. */ |
146 | void deselectItem(); | 147 | void deselectItem(); |
147 | /** Select item. If the argument is 0, the currently selected item gets | 148 | /** Select item. If the argument is 0, the currently selected item gets |
148 | deselected. This function emits the itemSelected(bool) signal to inform | 149 | deselected. This function emits the itemSelected(bool) signal to inform |
149 | about selection/deseelction of events. */ | 150 | about selection/deseelction of events. */ |
150 | void selectItem(KOAgendaItem *); | 151 | void selectItem(KOAgendaItem *); |
151 | void finishResize(); | 152 | void finishResize(); |
152 | 153 | ||
153 | signals: | 154 | signals: |
154 | void signalClearSelection(); | 155 | void signalClearSelection(); |
155 | void showDateView( int, int); | 156 | void showDateView( int, int); |
156 | void newEventSignal(); | 157 | void newEventSignal(); |
157 | void newEventSignal(int gx,int gy); | 158 | void newEventSignal(int gx,int gy); |
158 | void newTodoSignal(int gx,int gy); | 159 | void newTodoSignal(int gx,int gy); |
159 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 160 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
160 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 161 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
161 | void newStartSelectSignal(); | 162 | void newStartSelectSignal(); |
162 | void showIncidenceSignal(Incidence *); | 163 | void showIncidenceSignal(Incidence *); |
163 | void editIncidenceSignal(Incidence *); | 164 | void editIncidenceSignal(Incidence *); |
164 | void deleteIncidenceSignal(Incidence *); | 165 | void deleteIncidenceSignal(Incidence *); |
165 | void showIncidencePopupSignal(Incidence *); | 166 | void showIncidencePopupSignal(Incidence *); |
166 | 167 | ||
167 | void itemModified(KOAgendaItem *item, int ); | 168 | void itemModified(KOAgendaItem *item, int ); |
168 | void incidenceSelected(Incidence *); | 169 | void incidenceSelected(Incidence *); |
169 | 170 | ||
170 | void lowerYChanged(int); | 171 | void lowerYChanged(int); |
171 | void upperYChanged(int); | 172 | void upperYChanged(int); |
172 | 173 | ||
173 | void startDragSignal(Incidence *); | 174 | void startDragSignal(Incidence *); |
174 | void addToCalSignal(Incidence *, Incidence *); | 175 | void addToCalSignal(Incidence *, Incidence *); |
175 | void resizedSignal(); | 176 | void resizedSignal(); |
176 | void updateViewSignal(); | 177 | void updateViewSignal(); |
177 | void sendPing(); | 178 | void sendPing(); |
178 | 179 | ||
179 | protected: | 180 | protected: |
180 | KOEventPopupMenu * mAllAgendaPopup; | 181 | KOEventPopupMenu * mAllAgendaPopup; |
181 | QPainter mPixPainter; | 182 | QPainter mPixPainter; |
182 | QPixmap mPaintPixmap; | 183 | QPixmap mPaintPixmap; |
183 | QPixmap mHighlightPixmap; | 184 | QPixmap mHighlightPixmap; |
184 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); | 185 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); |
185 | virtual void resizeEvent ( QResizeEvent * ); | 186 | virtual void resizeEvent ( QResizeEvent * ); |
186 | 187 | ||
187 | /** Handles mouse events. Called from eventFilter */ | 188 | /** Handles mouse events. Called from eventFilter */ |
188 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); | 189 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); |
189 | 190 | ||
190 | /** Start selecting time span. */ | 191 | /** Start selecting time span. */ |
191 | void startSelectAction(QPoint viewportPos); | 192 | void startSelectAction(QPoint viewportPos); |
192 | 193 | ||
193 | /** Select time span. */ | 194 | /** Select time span. */ |
194 | void performSelectAction(QPoint viewportPos); | 195 | void performSelectAction(QPoint viewportPos); |
195 | 196 | ||
196 | /** Emd selecting time span. */ | 197 | /** Emd selecting time span. */ |
197 | void endSelectAction( bool emitNewEvent = false ); | 198 | void endSelectAction( bool emitNewEvent = false ); |
198 | 199 | ||
199 | /** Start moving/resizing agenda item */ | 200 | /** Start moving/resizing agenda item */ |
200 | void startItemAction(QPoint viewportPos); | 201 | void startItemAction(QPoint viewportPos); |
201 | 202 | ||
202 | /** Move/resize agenda item */ | 203 | /** Move/resize agenda item */ |
203 | void performItemAction(QPoint viewportPos); | 204 | void performItemAction(QPoint viewportPos); |
204 | 205 | ||
205 | /** End moving/resizing agenda item */ | 206 | /** End moving/resizing agenda item */ |
206 | void endItemAction(); | 207 | void endItemAction(); |
207 | 208 | ||
208 | /** Set cursor, when no item action is in progress */ | 209 | /** Set cursor, when no item action is in progress */ |
209 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); | 210 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); |
210 | 211 | ||
211 | /** Place agenda item in agenda and adjust other cells if necessary */ | 212 | /** Place agenda item in agenda and adjust other cells if necessary */ |
212 | void placeSubCells(KOAgendaItem *placeItem); | 213 | void placeSubCells(KOAgendaItem *placeItem); |
213 | 214 | ||
214 | /** Process the keyevent, including the ignored keyevents of eventwidgets. | 215 | /** Process the keyevent, including the ignored keyevents of eventwidgets. |
215 | * Implements pgup/pgdn and cursor key navigation in the view. | 216 | * Implements pgup/pgdn and cursor key navigation in the view. |
216 | */ | 217 | */ |
217 | void keyPressEvent( QKeyEvent * ); | 218 | void keyPressEvent( QKeyEvent * ); |
218 | 219 | ||
219 | void calculateWorkingHours(); | 220 | void calculateWorkingHours(); |
220 | 221 | ||
221 | virtual void contentsMousePressEvent ( QMouseEvent * ); | 222 | virtual void contentsMousePressEvent ( QMouseEvent * ); |
222 | 223 | ||
223 | private: | 224 | private: |
224 | void init(); | 225 | void init(); |
225 | void marcus_bains(); | 226 | void marcus_bains(); |
226 | bool mAllDayMode; | 227 | bool mAllDayMode; |
227 | bool blockResize; | 228 | bool blockResize; |
228 | bool mLeftMouseDown; | 229 | bool mLeftMouseDown; |
229 | KOAgendaItem *mPopupItem; | 230 | KOAgendaItem *mPopupItem; |
230 | QTimer* mPopupTimer; | 231 | QTimer* mPopupTimer; |
231 | int mPopupKind; | 232 | int mPopupKind; |
232 | QPoint mPopupPos; | 233 | QPoint mPopupPos; |
233 | QTimer mResizeTimer; | 234 | QTimer mResizeTimer; |
234 | double mContentPosition; | 235 | double mContentPosition; |
235 | 236 | ||
236 | // Width and height of agenda cells | 237 | // Width and height of agenda cells |
237 | int mGridSpacingX; | 238 | int mGridSpacingX; |
238 | int mGridSpacingY; | 239 | int mGridSpacingY; |
239 | 240 | ||
240 | // size of border, where mouse action will resize the KOAgendaItem | 241 | // size of border, where mouse action will resize the KOAgendaItem |
241 | int mResizeBorderWidth; | 242 | int mResizeBorderWidth; |
242 | 243 | ||
243 | // size of border, where mouse mve will cause a scroll of the agenda | 244 | // size of border, where mouse mve will cause a scroll of the agenda |
244 | int mScrollBorderWidth; | 245 | int mScrollBorderWidth; |
245 | int mScrollDelay; | 246 | int mScrollDelay; |
246 | int mScrollOffset; | 247 | int mScrollOffset; |
247 | 248 | ||
248 | QTimer mScrollUpTimer; | 249 | QTimer mScrollUpTimer; |
249 | QTimer mScrollDownTimer; | 250 | QTimer mScrollDownTimer; |
250 | 251 | ||
251 | // Number of Columns/Rows of agenda grid | 252 | // Number of Columns/Rows of agenda grid |
252 | int mColumns; | 253 | int mColumns; |
253 | int mRows; | 254 | int mRows; |
254 | 255 | ||
255 | // Cells to store Move and Resize coordiantes | 256 | // Cells to store Move and Resize coordiantes |
256 | int mStartCellX; | 257 | int mStartCellX; |
257 | int mStartCellY; | 258 | int mStartCellY; |
258 | int mCurrentCellX; | 259 | int mCurrentCellX; |
259 | int mCurrentCellY; | 260 | int mCurrentCellY; |
260 | 261 | ||
261 | // Working Hour coordiantes | 262 | // Working Hour coordiantes |
262 | bool mWorkingHoursEnable; | 263 | bool mWorkingHoursEnable; |
263 | int mWorkingHoursYTop; | 264 | int mWorkingHoursYTop; |
264 | int mWorkingHoursYBottom; | 265 | int mWorkingHoursYBottom; |
265 | 266 | ||
266 | // Selection | 267 | // Selection |
267 | int mSelectionCellX; | 268 | int mSelectionCellX; |
268 | int mSelectionYTop; | 269 | int mSelectionYTop; |
269 | int mSelectionHeight; | 270 | int mSelectionHeight; |
270 | 271 | ||
271 | // List of dates to be displayed | 272 | // List of dates to be displayed |
272 | DateList mSelectedDates; | 273 | DateList mSelectedDates; |
273 | 274 | ||
274 | // The KOAgendaItem, which has been right-clicked last | 275 | // The KOAgendaItem, which has been right-clicked last |
275 | KOAgendaItem *mClickedItem; | 276 | KOAgendaItem *mClickedItem; |
276 | 277 | ||
277 | // The KOAgendaItem, which is being moved/resized | 278 | // The KOAgendaItem, which is being moved/resized |
278 | QGuardedPtr<KOAgendaItem> mActionItem; | 279 | QGuardedPtr<KOAgendaItem> mActionItem; |
279 | 280 | ||
280 | // Currently selected item | 281 | // Currently selected item |
281 | QGuardedPtr<KOAgendaItem> mSelectedItem; | 282 | QGuardedPtr<KOAgendaItem> mSelectedItem; |
282 | 283 | ||
283 | // The Marcus Bains Line widget. | 284 | // The Marcus Bains Line widget. |
284 | MarcusBains *mMarcusBains; | 285 | MarcusBains *mMarcusBains; |
285 | void computeSizes(); | 286 | void computeSizes(); |
286 | 287 | ||
287 | MouseActionType mActionType; | 288 | MouseActionType mActionType; |
288 | 289 | ||
289 | bool mItemMoved; | 290 | bool mItemMoved; |
290 | 291 | ||
291 | // List of all Items contained in agenda | 292 | // List of all Items contained in agenda |
292 | QPtrList<KOAgendaItem> mItems; | 293 | QPtrList<KOAgendaItem> mItems; |
293 | QPtrList<KOAgendaItem> mUnusedItems; | 294 | QPtrList<KOAgendaItem> mUnusedItems; |
294 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); | 295 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); |
295 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems | 296 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems |
296 | QPopupMenu *mNewItemPopup; | 297 | QPopupMenu *mNewItemPopup; |
297 | 298 | ||
298 | int mOldLowerScrollValue; | 299 | int mOldLowerScrollValue; |
299 | int mOldUpperScrollValue; | 300 | int mOldUpperScrollValue; |
300 | KOAgendaItem * getItemForTodo ( Todo * todo ); | 301 | KOAgendaItem * getItemForTodo ( Todo * todo ); |
301 | QMemArray<bool> *mHolidayMask; | 302 | QMemArray<bool> *mHolidayMask; |
302 | int mCurPixWid; | 303 | int mCurPixWid; |
303 | int mCurPixHei; | 304 | int mCurPixHei; |
304 | }; | 305 | }; |
305 | 306 | ||
306 | #endif // KOAGENDA_H | 307 | #endif // KOAGENDA_H |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 53bbe28..b5a59af 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -307,2015 +307,2018 @@ bool MonthViewItem::setHighlightedFalse() | |||
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 | } else | 1527 | } else |
1528 | doComputeLayoutWeek(); | 1528 | doComputeLayoutWeek(); |
1529 | updateDayLabels(); | 1529 | updateDayLabels(); |
1530 | //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); |
1531 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1531 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1532 | //resizeEvent( 0 ); | 1532 | //resizeEvent( 0 ); |
1533 | for (uint i = 0; i < mCells.count(); ++i) { | 1533 | for (uint i = 0; i < mCells.count(); ++i) { |
1534 | mCells[i]->updateConfig(); | 1534 | mCells[i]->updateConfig(); |
1535 | } | 1535 | } |
1536 | 1536 | ||
1537 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1537 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1538 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1538 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1539 | } | 1539 | } |
1540 | #ifdef DESKTOP_VERSION | 1540 | #ifdef DESKTOP_VERSION |
1541 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1541 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1542 | #endif | 1542 | #endif |
1543 | updateView(); | 1543 | updateView(); |
1544 | } | 1544 | } |
1545 | 1545 | ||
1546 | void KOMonthView::updateDayLabels() | 1546 | void KOMonthView::updateDayLabels() |
1547 | { | 1547 | { |
1548 | 1548 | ||
1549 | QPtrVector<QLabel> *mDayLabelsT; | 1549 | QPtrVector<QLabel> *mDayLabelsT; |
1550 | 1550 | ||
1551 | mDayLabelsT = &mDayLabelsW; | 1551 | mDayLabelsT = &mDayLabelsW; |
1552 | for (int i = 0; i < 7; i++) { | 1552 | for (int i = 0; i < 7; i++) { |
1553 | { | 1553 | { |
1554 | bool show = mShortDayLabelsW; | 1554 | bool show = mShortDayLabelsW; |
1555 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1555 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1556 | show = true; | 1556 | show = true; |
1557 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1557 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1558 | } | 1558 | } |
1559 | } | 1559 | } |
1560 | mDayLabelsT = &mDayLabels; | 1560 | mDayLabelsT = &mDayLabels; |
1561 | for (int i = 0; i < 7; i++) { | 1561 | for (int i = 0; i < 7; i++) { |
1562 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1562 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1563 | bool show = mShortDayLabelsM; | 1563 | bool show = mShortDayLabelsM; |
1564 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1564 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1565 | show = true; | 1565 | show = true; |
1566 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1566 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1567 | } else { | 1567 | } else { |
1568 | 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)); |
1569 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1569 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1570 | 1570 | ||
1571 | } | 1571 | } |
1572 | } | 1572 | } |
1573 | 1573 | ||
1574 | } | 1574 | } |
1575 | 1575 | ||
1576 | void KOMonthView::clearList() | 1576 | void KOMonthView::clearList() |
1577 | { | 1577 | { |
1578 | unsigned int i; | 1578 | unsigned int i; |
1579 | for( i = 0; i < mCells.size(); ++i ) { | 1579 | for( i = 0; i < mCells.size(); ++i ) { |
1580 | mCells[i]->clear(); | 1580 | mCells[i]->clear(); |
1581 | } | 1581 | } |
1582 | for( i = 0; i < mCellsW.size(); ++i ) { | 1582 | for( i = 0; i < mCellsW.size(); ++i ) { |
1583 | mCellsW[i]->clear(); | 1583 | mCellsW[i]->clear(); |
1584 | } | 1584 | } |
1585 | } | 1585 | } |
1586 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1586 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1587 | { | 1587 | { |
1588 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1588 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1589 | 1589 | ||
1590 | QPtrVector<MonthViewCell> *cells; | 1590 | QPtrVector<MonthViewCell> *cells; |
1591 | QPtrVector<QLabel> *dayLabels; | 1591 | QPtrVector<QLabel> *dayLabels; |
1592 | QPtrVector<KOWeekButton> *weekLabels; | 1592 | QPtrVector<KOWeekButton> *weekLabels; |
1593 | uint weekNum = 6; | 1593 | uint weekNum = 6; |
1594 | mStartDate = start; | 1594 | mStartDate = start; |
1595 | if ( mShowWeekView ) { | 1595 | if ( mShowWeekView ) { |
1596 | weekNum = 1; | 1596 | weekNum = 1; |
1597 | cells = &mCellsW; | 1597 | cells = &mCellsW; |
1598 | dayLabels = &mDayLabelsW; | 1598 | dayLabels = &mDayLabelsW; |
1599 | weekLabels = &mWeekLabelsW; | 1599 | weekLabels = &mWeekLabelsW; |
1600 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1600 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1601 | mStartDate = mStartDate.addDays( 1 ); | 1601 | mStartDate = mStartDate.addDays( 1 ); |
1602 | } | 1602 | } |
1603 | } else { | 1603 | } else { |
1604 | cells = &mCells; | 1604 | cells = &mCells; |
1605 | dayLabels = &mDayLabels; | 1605 | dayLabels = &mDayLabels; |
1606 | weekLabels = &mWeekLabels; | 1606 | weekLabels = &mWeekLabels; |
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1609 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1610 | 1610 | ||
1611 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1611 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1612 | mWeekStartsMonday = true; | 1612 | mWeekStartsMonday = true; |
1613 | } | 1613 | } |
1614 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1614 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1615 | 1615 | ||
1616 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1616 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1617 | mStartDate = mStartDate.addDays( -1 ); | 1617 | mStartDate = mStartDate.addDays( -1 ); |
1618 | } | 1618 | } |
1619 | uint i; | 1619 | uint i; |
1620 | for( i = 0; i < (*cells).size(); ++i ) { | 1620 | for( i = 0; i < (*cells).size(); ++i ) { |
1621 | QDate date = mStartDate.addDays( i ); | 1621 | QDate date = mStartDate.addDays( i ); |
1622 | (*cells)[i]->setDate( date ); | 1622 | (*cells)[i]->setDate( date ); |
1623 | 1623 | ||
1624 | #ifndef KORG_NOPLUGINS | 1624 | #ifndef KORG_NOPLUGINS |
1625 | // add holiday, if present | 1625 | // add holiday, if present |
1626 | QString hstring(KOCore::self()->holiday(date)); | 1626 | QString hstring(KOCore::self()->holiday(date)); |
1627 | (*cells)[i]->setHoliday( hstring ); | 1627 | (*cells)[i]->setHoliday( hstring ); |
1628 | #endif | 1628 | #endif |
1629 | 1629 | ||
1630 | } | 1630 | } |
1631 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1631 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1632 | for( i = 0; i < weekNum; ++i ) { | 1632 | for( i = 0; i < weekNum; ++i ) { |
1633 | int wno; | 1633 | int wno; |
1634 | // 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 |
1635 | // 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, |
1636 | // not just 1. | 1636 | // not just 1. |
1637 | int dayOfYear = date.dayOfYear(); | 1637 | int dayOfYear = date.dayOfYear(); |
1638 | if (dayOfYear % 7 != 0) | 1638 | if (dayOfYear % 7 != 0) |
1639 | wno = dayOfYear / 7 + 1; | 1639 | wno = dayOfYear / 7 + 1; |
1640 | else | 1640 | else |
1641 | wno =dayOfYear / 7; | 1641 | wno =dayOfYear / 7; |
1642 | (*weekLabels)[i]->setWeekNum( wno ); | 1642 | (*weekLabels)[i]->setWeekNum( wno ); |
1643 | date = date.addDays( 7 ); | 1643 | date = date.addDays( 7 ); |
1644 | } | 1644 | } |
1645 | updateView(); | 1645 | updateView(); |
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | void KOMonthView::showEvents(QPtrList<Event>) | 1648 | void KOMonthView::showEvents(QPtrList<Event>) |
1649 | { | 1649 | { |
1650 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1650 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1651 | } | 1651 | } |
1652 | 1652 | ||
1653 | void KOMonthView::changeEventDisplay(Event *, int) | 1653 | void KOMonthView::changeEventDisplay(Event *, int) |
1654 | { | 1654 | { |
1655 | // 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 |
1656 | // quick-and-dirty-hack gets the job done for right now. | 1656 | // quick-and-dirty-hack gets the job done for right now. |
1657 | //qDebug("KOMonthView::changeEventDisplay "); | 1657 | //qDebug("KOMonthView::changeEventDisplay "); |
1658 | updateView(); | 1658 | updateView(); |
1659 | } | 1659 | } |
1660 | 1660 | ||
1661 | void KOMonthView::updateView() | 1661 | void KOMonthView::updateView() |
1662 | { | 1662 | { |
1663 | 1663 | ||
1664 | if ( !updatePossible ) | 1664 | if ( !updatePossible ) |
1665 | return; | 1665 | return; |
1666 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1666 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1667 | //QTime ti; | 1667 | //QTime ti; |
1668 | //ti.start(); | 1668 | //ti.start(); |
1669 | clearSelection(); | 1669 | clearSelection(); |
1670 | QPtrVector<MonthViewCell> *cells; | 1670 | QPtrVector<MonthViewCell> *cells; |
1671 | if ( mShowWeekView ) { | 1671 | if ( mShowWeekView ) { |
1672 | cells = &mCellsW; | 1672 | cells = &mCellsW; |
1673 | } else { | 1673 | } else { |
1674 | cells = &mCells; | 1674 | cells = &mCells; |
1675 | } | 1675 | } |
1676 | #if 1 | 1676 | #if 1 |
1677 | int i; | 1677 | int i; |
1678 | int timeSpan = (*cells).size()-1; | 1678 | int timeSpan = (*cells).size()-1; |
1679 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1679 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1680 | timeSpan = 6; | 1680 | timeSpan = 6; |
1681 | for( i = 0; i < timeSpan + 1; ++i ) { | 1681 | for( i = 0; i < timeSpan + 1; ++i ) { |
1682 | (*cells)[i]->startUpdateCell(); | 1682 | (*cells)[i]->startUpdateCell(); |
1683 | } | 1683 | } |
1684 | 1684 | ||
1685 | QPtrList<Event> events = calendar()->events(); | 1685 | QPtrList<Event> events = calendar()->events(); |
1686 | Event *event; | 1686 | Event *event; |
1687 | QDateTime dt; | 1687 | QDateTime dt; |
1688 | QDate endDate = mStartDate.addDays( timeSpan ); | 1688 | QDate endDate = mStartDate.addDays( timeSpan ); |
1689 | for( event = events.first(); event; event = events.next() ) { // for event | 1689 | for( event = events.first(); event; event = events.next() ) { // for event |
1690 | if ( event->doesRecur() ) { | 1690 | if ( event->doesRecur() ) { |
1691 | bool last; | 1691 | bool last; |
1692 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1692 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1693 | QDateTime incidenceEnd; | 1693 | QDateTime incidenceEnd; |
1694 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1694 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1695 | bool invalid = false; | 1695 | bool invalid = false; |
1696 | while( true ) { | 1696 | while( true ) { |
1697 | if ( incidenceStart.isValid() ) { | 1697 | if ( incidenceStart.isValid() ) { |
1698 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1698 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1699 | int st = incidenceStart.date().daysTo( endDate ); | 1699 | int st = incidenceStart.date().daysTo( endDate ); |
1700 | if ( st >= 0 ) { // start before timeend | 1700 | if ( st >= 0 ) { // start before timeend |
1701 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1701 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1702 | if ( end >= 0 ) { // end after timestart --- got one! | 1702 | if ( end >= 0 ) { // end after timestart --- got one! |
1703 | //normalize | 1703 | //normalize |
1704 | st = timeSpan - st; | 1704 | st = timeSpan - st; |
1705 | if ( st < 0 ) st = 0; | 1705 | if ( st < 0 ) st = 0; |
1706 | if ( end > timeSpan ) end = timeSpan; | 1706 | if ( end > timeSpan ) end = timeSpan; |
1707 | int iii; | 1707 | int iii; |
1708 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1708 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1709 | for ( iii = st;iii<= end;++iii) | 1709 | for ( iii = st;iii<= end;++iii) |
1710 | (*cells)[iii]->insertEvent( event ); | 1710 | (*cells)[iii]->insertEvent( event ); |
1711 | } | 1711 | } |
1712 | } | 1712 | } |
1713 | } else { | 1713 | } else { |
1714 | if ( invalid ) | 1714 | if ( invalid ) |
1715 | break; | 1715 | break; |
1716 | invalid = true; | 1716 | invalid = true; |
1717 | //qDebug("invalid %s", event->summary().latin1()); | 1717 | //qDebug("invalid %s", event->summary().latin1()); |
1718 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1718 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1719 | } | 1719 | } |
1720 | if ( last ) | 1720 | if ( last ) |
1721 | break; | 1721 | break; |
1722 | bool ok; | 1722 | bool ok; |
1723 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1723 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1724 | if ( ! ok ) | 1724 | if ( ! ok ) |
1725 | break; | 1725 | break; |
1726 | if ( incidenceStart.date() > endDate ) | 1726 | if ( incidenceStart.date() > endDate ) |
1727 | break; | 1727 | break; |
1728 | } | 1728 | } |
1729 | } else { // no recur | 1729 | } else { // no recur |
1730 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1730 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1731 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1731 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1732 | continue; | 1732 | continue; |
1733 | int st = event->dtStart().date().daysTo( endDate ); | 1733 | int st = event->dtStart().date().daysTo( endDate ); |
1734 | if ( st >= 0 ) { // start before timeend | 1734 | if ( st >= 0 ) { // start before timeend |
1735 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1735 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1736 | if ( end >= 0 ) { // end after timestart --- got one! | 1736 | if ( end >= 0 ) { // end after timestart --- got one! |
1737 | //normalize | 1737 | //normalize |
1738 | st = timeSpan - st; | 1738 | st = timeSpan - st; |
1739 | if ( st < 0 ) st = 0; | 1739 | if ( st < 0 ) st = 0; |
1740 | if ( end > timeSpan ) end = timeSpan; | 1740 | if ( end > timeSpan ) end = timeSpan; |
1741 | int iii; | 1741 | int iii; |
1742 | for ( iii = st;iii<= end;++iii) | 1742 | for ( iii = st;iii<= end;++iii) |
1743 | (*cells)[iii]->insertEvent( event ); | 1743 | (*cells)[iii]->insertEvent( event ); |
1744 | } | 1744 | } |
1745 | } | 1745 | } |
1746 | } | 1746 | } |
1747 | } | 1747 | } |
1748 | // insert due todos | 1748 | // insert due todos |
1749 | QPtrList<Todo> todos = calendar()->todos( ); | 1749 | QPtrList<Todo> todos = calendar()->todos( ); |
1750 | Todo *todo; | 1750 | Todo *todo; |
1751 | for(todo = todos.first(); todo; todo = todos.next()) { | 1751 | for(todo = todos.first(); todo; todo = todos.next()) { |
1752 | //insertTodo( todo ); | 1752 | //insertTodo( todo ); |
1753 | if ( todo->hasDueDate() ) { | 1753 | if ( todo->hasDueDate() ) { |
1754 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1754 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1755 | if ( day >= 0 && day < timeSpan + 1) { | 1755 | if ( day >= 0 && day < timeSpan + 1) { |
1756 | (*cells)[day]->insertTodo( todo ); | 1756 | (*cells)[day]->insertTodo( todo ); |
1757 | } | 1757 | } |
1758 | } | 1758 | } |
1759 | } | 1759 | } |
1760 | 1760 | ||
1761 | for( i = 0; i < timeSpan+1; ++i ) { | 1761 | for( i = 0; i < timeSpan+1; ++i ) { |
1762 | (*cells)[i]->finishUpdateCell(); | 1762 | (*cells)[i]->finishUpdateCell(); |
1763 | } | 1763 | } |
1764 | processSelectionChange(); | 1764 | processSelectionChange(); |
1765 | //qApp->processEvents(); | 1765 | //qApp->processEvents(); |
1766 | for( i = 0; i < timeSpan+1; ++i ) { | 1766 | for( i = 0; i < timeSpan+1; ++i ) { |
1767 | //(*cells)[i]->repaintfinishUpdateCell(); | 1767 | //(*cells)[i]->repaintfinishUpdateCell(); |
1768 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); | 1768 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); |
1769 | } | 1769 | } |
1770 | setKeyBFocus(); | 1770 | setKeyBFocus(); |
1771 | #else | 1771 | #else |
1772 | // old code | 1772 | // old code |
1773 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1773 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1774 | int i; | 1774 | int i; |
1775 | for( i = 0; i < (*cells).count(); ++i ) { | 1775 | for( i = 0; i < (*cells).count(); ++i ) { |
1776 | (*cells)[i]->updateCell(); | 1776 | (*cells)[i]->updateCell(); |
1777 | } | 1777 | } |
1778 | 1778 | ||
1779 | //qDebug("KOMonthView::updateView() "); | 1779 | //qDebug("KOMonthView::updateView() "); |
1780 | processSelectionChange(); | 1780 | processSelectionChange(); |
1781 | // qDebug("---------------------------------------------------------------------+ "); | 1781 | // qDebug("---------------------------------------------------------------------+ "); |
1782 | (*cells)[0]->setFocus(); | 1782 | (*cells)[0]->setFocus(); |
1783 | #endif | 1783 | #endif |
1784 | 1784 | ||
1785 | //qDebug("update time %d ", ti.elapsed()); | 1785 | //qDebug("update time %d ", ti.elapsed()); |
1786 | } | 1786 | } |
1787 | 1787 | ||
1788 | void KOMonthView::setKeyBoardFocus() | 1788 | void KOMonthView::setKeyBoardFocus() |
1789 | { | 1789 | { |
1790 | //qDebug("KOMonthView::setKeyBoardFocus() "); | 1790 | //qDebug("KOMonthView::setKeyBoardFocus() "); |
1791 | bool shootAgain = false; | 1791 | bool shootAgain = false; |
1792 | if ( mShowWeekView ) { | 1792 | if ( mShowWeekView ) { |
1793 | shootAgain = !mWeekLabelsW[1]->hasFocus(); | 1793 | shootAgain = !mWeekLabelsW[1]->hasFocus(); |
1794 | mWeekLabelsW[1]->setFocus(); | 1794 | mWeekLabelsW[1]->setFocus(); |
1795 | } | 1795 | } |
1796 | else { | 1796 | else { |
1797 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); | 1797 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); |
1798 | mWeekLabels[mNumWeeks]->setFocus(); | 1798 | mWeekLabels[mNumWeeks]->setFocus(); |
1799 | } | 1799 | } |
1800 | --mKBFcounter; | 1800 | --mKBFcounter; |
1801 | if ( shootAgain && mKBFcounter > 0 ) { | 1801 | if ( shootAgain && mKBFcounter > 0 ) { |
1802 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); | 1802 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); |
1803 | } | 1803 | } |
1804 | } | 1804 | } |
1805 | void KOMonthView::setKeyBFocus() | 1805 | void KOMonthView::setKeyBFocus() |
1806 | { | 1806 | { |
1807 | //qDebug("KOMonthView::setKeyBFocus() "); | 1807 | //qDebug("KOMonthView::setKeyBFocus() "); |
1808 | mKBFcounter = 10; | 1808 | mKBFcounter = 10; |
1809 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); | 1809 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); |
1810 | } | 1810 | } |
1811 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1811 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1812 | { | 1812 | { |
1813 | //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()); |
1814 | if ( isVisible() ) { | 1814 | if ( isVisible() ) { |
1815 | //qDebug("KOMonthView::isVisible "); | 1815 | //qDebug("KOMonthView::isVisible "); |
1816 | slotComputeLayout(); | 1816 | slotComputeLayout(); |
1817 | } else | 1817 | } else |
1818 | mComputeLayoutTimer->start( 100 ); | 1818 | mComputeLayoutTimer->start( 100 ); |
1819 | if ( e ) | 1819 | if ( e ) |
1820 | KOEventView::resizeEvent( e ); | 1820 | KOEventView::resizeEvent( e ); |
1821 | } | 1821 | } |
1822 | 1822 | ||
1823 | void KOMonthView::slotComputeLayout() | 1823 | void KOMonthView::slotComputeLayout() |
1824 | { | 1824 | { |
1825 | mComputeLayoutTimer->stop(); | 1825 | mComputeLayoutTimer->stop(); |
1826 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | 1826 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); |
1827 | computeLayout(); | 1827 | computeLayout(); |
1828 | clPending = true; | 1828 | clPending = true; |
1829 | setKeyBFocus(); | 1829 | setKeyBFocus(); |
1830 | } | 1830 | } |
1831 | 1831 | ||
1832 | void KOMonthView::doComputeLayoutWeek() | 1832 | void KOMonthView::doComputeLayoutWeek() |
1833 | { | 1833 | { |
1834 | 1834 | ||
1835 | int daysToShow; | 1835 | int daysToShow; |
1836 | bool combinedSatSun = false; | 1836 | bool combinedSatSun = false; |
1837 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1837 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1838 | daysToShow = 6; | 1838 | daysToShow = 6; |
1839 | combinedSatSun = true; | 1839 | combinedSatSun = true; |
1840 | } | 1840 | } |
1841 | int wid = width();//e | 1841 | int wid = width();//e |
1842 | int hei = height()-1-mNavigatorBar->height(); | 1842 | int hei = height()-1-mNavigatorBar->height(); |
1843 | #ifdef DESKTOP_VERSION | ||
1843 | if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { | 1844 | if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { |
1844 | daysToShow = 2; | 1845 | daysToShow = 2; |
1845 | } else { | 1846 | } else |
1847 | #endif | ||
1848 | { | ||
1846 | if ( wid < hei ) | 1849 | if ( wid < hei ) |
1847 | daysToShow = 2; | 1850 | daysToShow = 2; |
1848 | else | 1851 | else |
1849 | daysToShow = 3; | 1852 | daysToShow = 3; |
1850 | } | 1853 | } |
1851 | bool landscape = (daysToShow == 3); | 1854 | bool landscape = (daysToShow == 3); |
1852 | mShowSatSunComp = true; | 1855 | mShowSatSunComp = true; |
1853 | combinedSatSun = true; | 1856 | combinedSatSun = true; |
1854 | 1857 | ||
1855 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1858 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1856 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1859 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1857 | int weeklabelwid = fm.width( "888" ); | 1860 | int weeklabelwid = fm.width( "888" ); |
1858 | wid -= weeklabelwid; | 1861 | wid -= weeklabelwid; |
1859 | 1862 | ||
1860 | int colWid = wid / daysToShow; | 1863 | int colWid = wid / daysToShow; |
1861 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1864 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1862 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1865 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1863 | int colModulo = wid % daysToShow; | 1866 | int colModulo = wid % daysToShow; |
1864 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1867 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1865 | //qDebug("rowmod %d ", rowModulo); | 1868 | //qDebug("rowmod %d ", rowModulo); |
1866 | int i; | 1869 | int i; |
1867 | int x,y,w,h; | 1870 | int x,y,w,h; |
1868 | x= 0; | 1871 | x= 0; |
1869 | y= 0; | 1872 | y= 0; |
1870 | w = colWid; | 1873 | w = colWid; |
1871 | h = dayLabelHei ; | 1874 | h = dayLabelHei ; |
1872 | for ( i = 0; i < 7; i++) { | 1875 | for ( i = 0; i < 7; i++) { |
1873 | if ( i && !( i % daysToShow) && i < 6) { | 1876 | if ( i && !( i % daysToShow) && i < 6) { |
1874 | y += hei/(5-daysToShow); | 1877 | y += hei/(5-daysToShow); |
1875 | x = 0; | 1878 | x = 0; |
1876 | w = colWid; | 1879 | w = colWid; |
1877 | } | 1880 | } |
1878 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1881 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1879 | ++w; | 1882 | ++w; |
1880 | } | 1883 | } |
1881 | int xC,yC,wC,hC; | 1884 | int xC,yC,wC,hC; |
1882 | if ( i >= 5 ) { | 1885 | if ( i >= 5 ) { |
1883 | int wi = width() - x - weeklabelwid; | 1886 | int wi = width() - x - weeklabelwid; |
1884 | if ( i == 5 ) { | 1887 | if ( i == 5 ) { |
1885 | xC = x+weeklabelwid; | 1888 | xC = x+weeklabelwid; |
1886 | yC = y; | 1889 | yC = y; |
1887 | wC = wi/2+wi%2; | 1890 | wC = wi/2+wi%2; |
1888 | hC = h; | 1891 | hC = h; |
1889 | } else { | 1892 | } else { |
1890 | xC = x+weeklabelwid; | 1893 | xC = x+weeklabelwid; |
1891 | yC = y; | 1894 | yC = y; |
1892 | wC = wi; | 1895 | wC = wi; |
1893 | hC = h; | 1896 | hC = h; |
1894 | } | 1897 | } |
1895 | x = x - w + wi - (wi/2 ); | 1898 | x = x - w + wi - (wi/2 ); |
1896 | } | 1899 | } |
1897 | else { | 1900 | else { |
1898 | int wi = w; | 1901 | int wi = w; |
1899 | if ( !(( i+1) % daysToShow)) { | 1902 | if ( !(( i+1) % daysToShow)) { |
1900 | wi = width() - x - weeklabelwid; | 1903 | wi = width() - x - weeklabelwid; |
1901 | } | 1904 | } |
1902 | xC = x+weeklabelwid; | 1905 | xC = x+weeklabelwid; |
1903 | yC = y; | 1906 | yC = y; |
1904 | wC = wi; | 1907 | wC = wi; |
1905 | hC = h; | 1908 | hC = h; |
1906 | } | 1909 | } |
1907 | mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); | 1910 | mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); |
1908 | 1911 | ||
1909 | 1912 | ||
1910 | x += w; | 1913 | x += w; |
1911 | } | 1914 | } |
1912 | x= 0; | 1915 | x= 0; |
1913 | y= dayLabelHei; | 1916 | y= dayLabelHei; |
1914 | w = colWid; | 1917 | w = colWid; |
1915 | h = cellHei; | 1918 | h = cellHei; |
1916 | int max = 0; | 1919 | int max = 0; |
1917 | int w_count = mCellsW.count(); | 1920 | int w_count = mCellsW.count(); |
1918 | for ( i = 0; i < w_count; ++i) { | 1921 | for ( i = 0; i < w_count; ++i) { |
1919 | if ( i > 6 ) { | 1922 | if ( i > 6 ) { |
1920 | mCellsW[i]->hide(); | 1923 | mCellsW[i]->hide(); |
1921 | continue; | 1924 | continue; |
1922 | } | 1925 | } |
1923 | 1926 | ||
1924 | w = colWid; | 1927 | w = colWid; |
1925 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1928 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1926 | ++w; | 1929 | ++w; |
1927 | } | 1930 | } |
1928 | if ( i == (daysToShow-1-rowModulo)*7) | 1931 | if ( i == (daysToShow-1-rowModulo)*7) |
1929 | ++h; | 1932 | ++h; |
1930 | 1933 | ||
1931 | int xC,yC,wC,hC; | 1934 | int xC,yC,wC,hC; |
1932 | if ( i >= 5 ) { | 1935 | if ( i >= 5 ) { |
1933 | if ( i ==5 ) { | 1936 | if ( i ==5 ) { |
1934 | max = h/2; | 1937 | max = h/2; |
1935 | xC = x+weeklabelwid; | 1938 | xC = x+weeklabelwid; |
1936 | yC = y; | 1939 | yC = y; |
1937 | wC = w; | 1940 | wC = w; |
1938 | hC = max; | 1941 | hC = max; |
1939 | x -= w ;y += h/2; | 1942 | x -= w ;y += h/2; |
1940 | } else { | 1943 | } else { |
1941 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1944 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1942 | ++w; | 1945 | ++w; |
1943 | } | 1946 | } |
1944 | max = h-h/2; | 1947 | max = h-h/2; |
1945 | xC = x+weeklabelwid; | 1948 | xC = x+weeklabelwid; |
1946 | yC = y; | 1949 | yC = y; |
1947 | wC = w; | 1950 | wC = w; |
1948 | hC = max; | 1951 | hC = max; |
1949 | y -= h/2; | 1952 | y -= h/2; |
1950 | } | 1953 | } |
1951 | } else { | 1954 | } else { |
1952 | max = h; | 1955 | max = h; |
1953 | xC = x+weeklabelwid; | 1956 | xC = x+weeklabelwid; |
1954 | yC = y; | 1957 | yC = y; |
1955 | wC = w; | 1958 | wC = w; |
1956 | hC = h; | 1959 | hC = h; |
1957 | } | 1960 | } |
1958 | mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); | 1961 | mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); |
1959 | 1962 | ||
1960 | 1963 | ||
1961 | x += w; | 1964 | x += w; |
1962 | if ( x + w/2 > wid ) { | 1965 | if ( x + w/2 > wid ) { |
1963 | x = 0; | 1966 | x = 0; |
1964 | y += h+dayLabelHei ; | 1967 | y += h+dayLabelHei ; |
1965 | } | 1968 | } |
1966 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); | 1969 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); |
1967 | } | 1970 | } |
1968 | y= dayLabelHei; | 1971 | y= dayLabelHei; |
1969 | h = cellHei ; | 1972 | h = cellHei ; |
1970 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1973 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1971 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1974 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1972 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1975 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1973 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1976 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1974 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1977 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1975 | updateDayLabels(); | 1978 | updateDayLabels(); |
1976 | //bool forceUpdate = !updatePossible; | 1979 | //bool forceUpdate = !updatePossible; |
1977 | updatePossible = true; | 1980 | updatePossible = true; |
1978 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1981 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1979 | //if ( forceUpdate ) | 1982 | //if ( forceUpdate ) |
1980 | // updateView(); | 1983 | // updateView(); |
1981 | } | 1984 | } |
1982 | void KOMonthView::computeLayoutWeek() | 1985 | void KOMonthView::computeLayoutWeek() |
1983 | { | 1986 | { |
1984 | static int lastWid = 0; | 1987 | static int lastWid = 0; |
1985 | static int lastHei = 0; | 1988 | static int lastHei = 0; |
1986 | int tWid = topLevelWidget()->size().width(); | 1989 | int tWid = topLevelWidget()->size().width(); |
1987 | int tHei = topLevelWidget()->size().height(); | 1990 | int tHei = topLevelWidget()->size().height(); |
1988 | int wid = width();//e | 1991 | int wid = width();//e |
1989 | int hei = height()-1-mNavigatorBar->height(); | 1992 | int hei = height()-1-mNavigatorBar->height(); |
1990 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1993 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1991 | return; | 1994 | return; |
1992 | 1995 | ||
1993 | if ( lastWid == width() && lastHei == height() ) { | 1996 | if ( lastWid == width() && lastHei == height() ) { |
1994 | //qDebug("KOListWeekView::No compute layout needed "); | 1997 | //qDebug("KOListWeekView::No compute layout needed "); |
1995 | return; | 1998 | return; |
1996 | } | 1999 | } |
1997 | lastWid = width(); | 2000 | lastWid = width(); |
1998 | lastHei = height(); | 2001 | lastHei = height(); |
1999 | doComputeLayoutWeek(); | 2002 | doComputeLayoutWeek(); |
2000 | } | 2003 | } |
2001 | int KOMonthView::mapWeekLayout( int index, bool landscape ) | 2004 | int KOMonthView::mapWeekLayout( int index, bool landscape ) |
2002 | { | 2005 | { |
2003 | if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) | 2006 | if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) |
2004 | return index; | 2007 | return index; |
2005 | int diff = 0; | 2008 | int diff = 0; |
2006 | if ( !landscape ) diff = 1; | 2009 | if ( !landscape ) diff = 1; |
2007 | switch( index ) { | 2010 | switch( index ) { |
2008 | case 0: | 2011 | case 0: |
2009 | case 5: | 2012 | case 5: |
2010 | case 6: | 2013 | case 6: |
2011 | return index; | 2014 | return index; |
2012 | break; | 2015 | break; |
2013 | case 1: | 2016 | case 1: |
2014 | return 2+diff; | 2017 | return 2+diff; |
2015 | break; | 2018 | break; |
2016 | case 2: | 2019 | case 2: |
2017 | return 4-(3*diff); | 2020 | return 4-(3*diff); |
2018 | break; | 2021 | break; |
2019 | case 3: | 2022 | case 3: |
2020 | return 1+(3*diff); | 2023 | return 1+(3*diff); |
2021 | break; | 2024 | break; |
2022 | case 4: | 2025 | case 4: |
2023 | return 3-diff; | 2026 | return 3-diff; |
2024 | break; | 2027 | break; |
2025 | default: | 2028 | default: |
2026 | qDebug("KO: Error in mapping week layout "); | 2029 | qDebug("KO: Error in mapping week layout "); |
2027 | return index; | 2030 | return index; |
2028 | break; | 2031 | break; |
2029 | } | 2032 | } |
2030 | return index; | 2033 | return index; |
2031 | } | 2034 | } |
2032 | void KOMonthView::computeLayout() | 2035 | void KOMonthView::computeLayout() |
2033 | { | 2036 | { |
2034 | 2037 | ||
2035 | 2038 | ||
2036 | static int lastWid = 0; | 2039 | static int lastWid = 0; |
2037 | static int lastHei = 0; | 2040 | static int lastHei = 0; |
2038 | 2041 | ||
2039 | if ( mShowWeekView ){ | 2042 | if ( mShowWeekView ){ |
2040 | computeLayoutWeek(); | 2043 | computeLayoutWeek(); |
2041 | return; | 2044 | return; |
2042 | } | 2045 | } |
2043 | int daysToShow = 7; | 2046 | int daysToShow = 7; |
2044 | bool combinedSatSun = false; | 2047 | bool combinedSatSun = false; |
2045 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 2048 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
2046 | daysToShow = 6; | 2049 | daysToShow = 6; |
2047 | combinedSatSun = true; | 2050 | combinedSatSun = true; |
2048 | } | 2051 | } |
2049 | int tWid = topLevelWidget()->size().width(); | 2052 | int tWid = topLevelWidget()->size().width(); |
2050 | int tHei = topLevelWidget()->size().height(); | 2053 | int tHei = topLevelWidget()->size().height(); |
2051 | 2054 | ||
2052 | int wid = width();//e | 2055 | int wid = width();//e |
2053 | int hei = height()-1-mNavigatorBar->height(); | 2056 | int hei = height()-1-mNavigatorBar->height(); |
2054 | 2057 | ||
2055 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 2058 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
2056 | return; | 2059 | return; |
2057 | } | 2060 | } |
2058 | if ( lastWid == width() && lastHei == height() ){ | 2061 | if ( lastWid == width() && lastHei == height() ){ |
2059 | //qDebug("KOMonthview::No compute layout needed "); | 2062 | //qDebug("KOMonthview::No compute layout needed "); |
2060 | return; | 2063 | return; |
2061 | } | 2064 | } |
2062 | 2065 | ||
2063 | lastWid = width(); | 2066 | lastWid = width(); |
2064 | lastHei = height(); | 2067 | lastHei = height(); |
2065 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); | 2068 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); |
2066 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 2069 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
2067 | int weeklabelwid = fm.width( "888" ); | 2070 | int weeklabelwid = fm.width( "888" ); |
2068 | wid -= weeklabelwid; | 2071 | wid -= weeklabelwid; |
2069 | 2072 | ||
2070 | int colWid = wid / daysToShow; | 2073 | int colWid = wid / daysToShow; |
2071 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 2074 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
2072 | int cellHei = (hei - dayLabelHei) /6; | 2075 | int cellHei = (hei - dayLabelHei) /6; |
2073 | int colModulo = wid % daysToShow; | 2076 | int colModulo = wid % daysToShow; |
2074 | int rowModulo = (hei- dayLabelHei) % 6; | 2077 | int rowModulo = (hei- dayLabelHei) % 6; |
2075 | //qDebug("rowmod %d ", rowModulo); | 2078 | //qDebug("rowmod %d ", rowModulo); |
2076 | int i; | 2079 | int i; |
2077 | int x,y,w,h; | 2080 | int x,y,w,h; |
2078 | x= 0; | 2081 | x= 0; |
2079 | y= 0; | 2082 | y= 0; |
2080 | w = colWid; | 2083 | w = colWid; |
2081 | h = dayLabelHei ; | 2084 | h = dayLabelHei ; |
2082 | for ( i = 0; i < 7; i++) { | 2085 | for ( i = 0; i < 7; i++) { |
2083 | if ( i == daysToShow-colModulo ) | 2086 | if ( i == daysToShow-colModulo ) |
2084 | ++w; | 2087 | ++w; |
2085 | if ( combinedSatSun ) { | 2088 | if ( combinedSatSun ) { |
2086 | if ( i >= daysToShow-1 ) { | 2089 | if ( i >= daysToShow-1 ) { |
2087 | 2090 | ||
2088 | if ( i == 6 ) | 2091 | if ( i == 6 ) |
2089 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); | 2092 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); |
2090 | else | 2093 | else |
2091 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 2094 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
2092 | x -= w/2 ; | 2095 | x -= w/2 ; |
2093 | } | 2096 | } |
2094 | else | 2097 | else |
2095 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 2098 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
2096 | } else | 2099 | } else |
2097 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 2100 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
2098 | x += w; | 2101 | x += w; |
2099 | } | 2102 | } |
2100 | x= 0; | 2103 | x= 0; |
2101 | y= dayLabelHei; | 2104 | y= dayLabelHei; |
2102 | w = colWid; | 2105 | w = colWid; |
2103 | h = cellHei ; | 2106 | h = cellHei ; |
2104 | int max = 0; | 2107 | int max = 0; |
2105 | int mc_count = mCells.count(); | 2108 | int mc_count = mCells.count(); |
2106 | for ( i = 0; i < mc_count; ++i) { | 2109 | for ( i = 0; i < mc_count; ++i) { |
2107 | //qDebug("iii %d ", i); | 2110 | //qDebug("iii %d ", i); |
2108 | w = colWid; | 2111 | w = colWid; |
2109 | if ( ((i) % 7) >= 7-colModulo ) { | 2112 | if ( ((i) % 7) >= 7-colModulo ) { |
2110 | ++w; | 2113 | ++w; |
2111 | } | 2114 | } |
2112 | if ( i == (6-rowModulo)*7) | 2115 | if ( i == (6-rowModulo)*7) |
2113 | ++h; | 2116 | ++h; |
2114 | if ( combinedSatSun ) { | 2117 | if ( combinedSatSun ) { |
2115 | if ( (i)%7 >= daysToShow-1 ) { | 2118 | if ( (i)%7 >= daysToShow-1 ) { |
2116 | if ( (i)%7 == daysToShow-1 ) { | 2119 | if ( (i)%7 == daysToShow-1 ) { |
2117 | w = width()-x-weeklabelwid; | 2120 | w = width()-x-weeklabelwid; |
2118 | max = h/2; | 2121 | max = h/2; |
2119 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 2122 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
2120 | x -= w ;y += h/2; | 2123 | x -= w ;y += h/2; |
2121 | } else { | 2124 | } else { |
2122 | w = width()-x-weeklabelwid; | 2125 | w = width()-x-weeklabelwid; |
2123 | max = h-h/2; | 2126 | max = h-h/2; |
2124 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 2127 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
2125 | y -= h/2; | 2128 | y -= h/2; |
2126 | } | 2129 | } |
2127 | } else { | 2130 | } else { |
2128 | max = h; | 2131 | max = h; |
2129 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 2132 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
2130 | } | 2133 | } |
2131 | 2134 | ||
2132 | } | 2135 | } |
2133 | else { | 2136 | else { |
2134 | max = h; | 2137 | max = h; |
2135 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 2138 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
2136 | } | 2139 | } |
2137 | x += w; | 2140 | x += w; |
2138 | if ( x + w/2 > wid ) { | 2141 | if ( x + w/2 > wid ) { |
2139 | x = 0; | 2142 | x = 0; |
2140 | y += h; | 2143 | y += h; |
2141 | } | 2144 | } |
2142 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); | 2145 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); |
2143 | } | 2146 | } |
2144 | y= dayLabelHei; | 2147 | y= dayLabelHei; |
2145 | h = cellHei ; | 2148 | h = cellHei ; |
2146 | for ( i = 0; i < 6; i++) { | 2149 | for ( i = 0; i < 6; i++) { |
2147 | if ( i == (6-rowModulo)) | 2150 | if ( i == (6-rowModulo)) |
2148 | ++h; | 2151 | ++h; |
2149 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 2152 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
2150 | y += h; | 2153 | y += h; |
2151 | } | 2154 | } |
2152 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 2155 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
2153 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 2156 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
2154 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 2157 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
2155 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 2158 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
2156 | updateDayLabels(); | 2159 | updateDayLabels(); |
2157 | //bool forceUpdate = !updatePossible; | 2160 | //bool forceUpdate = !updatePossible; |
2158 | updatePossible = true; | 2161 | updatePossible = true; |
2159 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 2162 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
2160 | } | 2163 | } |
2161 | 2164 | ||
2162 | void KOMonthView::showContextMenu( Incidence *incidence ) | 2165 | void KOMonthView::showContextMenu( Incidence *incidence ) |
2163 | { | 2166 | { |
2164 | if( incidence ) | 2167 | if( incidence ) |
2165 | mContextMenu->showIncidencePopup(incidence); | 2168 | mContextMenu->showIncidencePopup(incidence); |
2166 | else { | 2169 | else { |
2167 | //qDebug("KOMonthView::showContextMenu "); | 2170 | //qDebug("KOMonthView::showContextMenu "); |
2168 | mNewItemMenu->popup(QCursor::pos()); | 2171 | mNewItemMenu->popup(QCursor::pos()); |
2169 | } | 2172 | } |
2170 | /* | 2173 | /* |
2171 | if( incidence && incidence->typeID() == eventID ) { | 2174 | if( incidence && incidence->typeID() == eventID ) { |
2172 | Event *event = static_cast<Event *>(incidence); | 2175 | Event *event = static_cast<Event *>(incidence); |
2173 | mContextMenu->showEventPopup(event); | 2176 | mContextMenu->showEventPopup(event); |
2174 | } else { | 2177 | } else { |
2175 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 2178 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
2176 | } | 2179 | } |
2177 | */ | 2180 | */ |
2178 | } | 2181 | } |
2179 | MonthViewCell * KOMonthView::selectedCell( ) | 2182 | MonthViewCell * KOMonthView::selectedCell( ) |
2180 | { | 2183 | { |
2181 | return mSelectedCell; | 2184 | return mSelectedCell; |
2182 | } | 2185 | } |
2183 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 2186 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
2184 | { | 2187 | { |
2185 | //qDebug("KOMonthView::setSelectedCell %d", cell); | 2188 | //qDebug("KOMonthView::setSelectedCell %d", cell); |
2186 | if ( mSelectedCell && mSelectedCell != cell ) { | 2189 | if ( mSelectedCell && mSelectedCell != cell ) { |
2187 | MonthViewCell * mvc = mSelectedCell; | 2190 | MonthViewCell * mvc = mSelectedCell; |
2188 | mSelectedCell = cell; | 2191 | mSelectedCell = cell; |
2189 | mvc->deselect(); | 2192 | mvc->deselect(); |
2190 | } else | 2193 | } else |
2191 | mSelectedCell = cell; | 2194 | mSelectedCell = cell; |
2192 | // if ( mSelectedCell ) | 2195 | // if ( mSelectedCell ) |
2193 | // mSelectedCell->select(); | 2196 | // mSelectedCell->select(); |
2194 | if ( !mSelectedCell ) | 2197 | if ( !mSelectedCell ) |
2195 | emit incidenceSelected( 0 ); | 2198 | emit incidenceSelected( 0 ); |
2196 | else | 2199 | else |
2197 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 2200 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
2198 | } | 2201 | } |
2199 | 2202 | ||
2200 | void KOMonthView::processSelectionChange() | 2203 | void KOMonthView::processSelectionChange() |
2201 | { | 2204 | { |
2202 | QPtrList<Incidence> incidences = selectedIncidences(); | 2205 | QPtrList<Incidence> incidences = selectedIncidences(); |
2203 | if (incidences.count() > 0) { | 2206 | if (incidences.count() > 0) { |
2204 | emit incidenceSelected( incidences.first() ); | 2207 | emit incidenceSelected( incidences.first() ); |
2205 | } else { | 2208 | } else { |
2206 | emit incidenceSelected( 0 ); | 2209 | emit incidenceSelected( 0 ); |
2207 | clearSelection(); | 2210 | clearSelection(); |
2208 | } | 2211 | } |
2209 | } | 2212 | } |
2210 | 2213 | ||
2211 | void KOMonthView::clearSelection() | 2214 | void KOMonthView::clearSelection() |
2212 | { | 2215 | { |
2213 | if ( mSelectedCell ) { | 2216 | if ( mSelectedCell ) { |
2214 | mSelectedCell->deselect(); | 2217 | mSelectedCell->deselect(); |
2215 | mSelectedCell = 0; | 2218 | mSelectedCell = 0; |
2216 | } | 2219 | } |
2217 | } | 2220 | } |
2218 | 2221 | ||
2219 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) | 2222 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) |
2220 | { | 2223 | { |
2221 | if ( !e->isAutoRepeat() ) { | 2224 | if ( !e->isAutoRepeat() ) { |
2222 | mFlagKeyPressed = false; | 2225 | mFlagKeyPressed = false; |
2223 | } | 2226 | } |
2224 | } | 2227 | } |
2225 | 2228 | ||
2226 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 2229 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
2227 | { | 2230 | { |
2228 | 2231 | ||
2229 | qApp->processEvents(); | 2232 | qApp->processEvents(); |
2230 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2233 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2231 | //e->ignore(); | 2234 | //e->ignore(); |
2232 | e->accept(); | 2235 | e->accept(); |
2233 | return; | 2236 | return; |
2234 | } | 2237 | } |
2235 | if (! e->isAutoRepeat() ) | 2238 | if (! e->isAutoRepeat() ) |
2236 | mFlagKeyPressed = true; | 2239 | mFlagKeyPressed = true; |
2237 | switch(e->key()) { | 2240 | switch(e->key()) { |
2238 | case Key_Up: | 2241 | case Key_Up: |
2239 | { | 2242 | { |
2240 | if ( mShowWeekView ) { | 2243 | if ( mShowWeekView ) { |
2241 | emit selectWeekNum ( currentWeek() - 1 ); | 2244 | emit selectWeekNum ( currentWeek() - 1 ); |
2242 | } | 2245 | } |
2243 | else { | 2246 | else { |
2244 | emit prevMonth(); | 2247 | emit prevMonth(); |
2245 | } | 2248 | } |
2246 | } | 2249 | } |
2247 | e->accept(); | 2250 | e->accept(); |
2248 | break; | 2251 | break; |
2249 | case Key_Down: | 2252 | case Key_Down: |
2250 | { | 2253 | { |
2251 | if ( mShowWeekView ) { | 2254 | if ( mShowWeekView ) { |
2252 | emit selectWeekNum ( currentWeek() +1); | 2255 | emit selectWeekNum ( currentWeek() +1); |
2253 | } | 2256 | } |
2254 | else { | 2257 | else { |
2255 | emit nextMonth(); | 2258 | emit nextMonth(); |
2256 | } | 2259 | } |
2257 | 2260 | ||
2258 | } | 2261 | } |
2259 | e->accept(); | 2262 | e->accept(); |
2260 | break; | 2263 | break; |
2261 | case Key_Return: | 2264 | case Key_Return: |
2262 | case Key_Enter: | 2265 | case Key_Enter: |
2263 | { | 2266 | { |
2264 | selectInternalWeekNum ( currentWeek() ); | 2267 | selectInternalWeekNum ( currentWeek() ); |
2265 | } | 2268 | } |
2266 | e->accept(); | 2269 | e->accept(); |
2267 | break; | 2270 | break; |
2268 | case Key_D: | 2271 | case Key_D: |
2269 | if ( mSelectedCell ) { | 2272 | if ( mSelectedCell ) { |
2270 | mSelectedCell->showDay(); | 2273 | mSelectedCell->showDay(); |
2271 | e->accept(); | 2274 | e->accept(); |
2272 | } else { | 2275 | } else { |
2273 | e->ignore(); | 2276 | e->ignore(); |
2274 | } | 2277 | } |
2275 | break; | 2278 | break; |
2276 | default: | 2279 | default: |
2277 | e->ignore(); | 2280 | e->ignore(); |
2278 | break; | 2281 | break; |
2279 | } | 2282 | } |
2280 | } | 2283 | } |
2281 | 2284 | ||
2282 | void KOMonthView::nextCell() | 2285 | void KOMonthView::nextCell() |
2283 | { | 2286 | { |
2284 | focusNextPrevChild ( true ); | 2287 | focusNextPrevChild ( true ); |
2285 | } | 2288 | } |
2286 | void KOMonthView::prevCell() | 2289 | void KOMonthView::prevCell() |
2287 | { | 2290 | { |
2288 | focusNextPrevChild ( false ); | 2291 | focusNextPrevChild ( false ); |
2289 | } | 2292 | } |
2290 | 2293 | ||
2291 | void KOMonthView::slotNewTodo() | 2294 | void KOMonthView::slotNewTodo() |
2292 | { | 2295 | { |
2293 | //qDebug("KOMonthView::slotNewTodo() "); | 2296 | //qDebug("KOMonthView::slotNewTodo() "); |
2294 | if ( mPopupCell ){ | 2297 | if ( mPopupCell ){ |
2295 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2298 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2296 | emit newTodoSignal(dt,true); | 2299 | emit newTodoSignal(dt,true); |
2297 | } | 2300 | } |
2298 | mPopupCell = 0; | 2301 | mPopupCell = 0; |
2299 | } | 2302 | } |
2300 | void KOMonthView::slotNewEvent() | 2303 | void KOMonthView::slotNewEvent() |
2301 | { | 2304 | { |
2302 | if ( mPopupCell ) { | 2305 | if ( mPopupCell ) { |
2303 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2306 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2304 | emit newEventSignal( dt ); | 2307 | emit newEventSignal( dt ); |
2305 | } | 2308 | } |
2306 | //qDebug("KOMonthView::slotNewEvent() "); | 2309 | //qDebug("KOMonthView::slotNewEvent() "); |
2307 | mPopupCell = 0; | 2310 | mPopupCell = 0; |
2308 | } | 2311 | } |
2309 | 2312 | ||
2310 | void KOMonthView::slotEditJournal() | 2313 | void KOMonthView::slotEditJournal() |
2311 | { | 2314 | { |
2312 | if ( mPopupCell ) | 2315 | if ( mPopupCell ) |
2313 | emit showJournalSignal( 7, mPopupCell->date() ); | 2316 | emit showJournalSignal( 7, mPopupCell->date() ); |
2314 | //qDebug("KOMonthView::slotEditJournal() "); | 2317 | //qDebug("KOMonthView::slotEditJournal() "); |
2315 | mPopupCell = 0; | 2318 | mPopupCell = 0; |
2316 | } | 2319 | } |
2317 | 2320 | ||
2318 | void KOMonthView::setPopupCell( MonthViewCell * c) | 2321 | void KOMonthView::setPopupCell( MonthViewCell * c) |
2319 | { | 2322 | { |
2320 | mPopupCell = c; | 2323 | mPopupCell = c; |
2321 | } | 2324 | } |