-rw-r--r-- | korganizer/komonthview.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index eea9a4d..4aeb20c 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,2326 +1,2330 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #else | 34 | #else |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | #include <kconfig.h> | 41 | #include <kconfig.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | 43 | ||
44 | #include <kcalendarsystem.h> | 44 | #include <kcalendarsystem.h> |
45 | 45 | ||
46 | #ifndef KORG_NOPRINTER | 46 | #ifndef KORG_NOPRINTER |
47 | #include "calprinter.h" | 47 | #include "calprinter.h" |
48 | #endif | 48 | #endif |
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #ifndef KORG_NOPLUGINS | 50 | #ifndef KORG_NOPLUGINS |
51 | #include "kocore.h" | 51 | #include "kocore.h" |
52 | #endif | 52 | #endif |
53 | #include "koglobals.h" | 53 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
55 | 55 | ||
56 | #include "komonthview.h" | 56 | #include "komonthview.h" |
57 | 57 | ||
58 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 61 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
70 | { | 70 | { |
71 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
72 | }; | 72 | }; |
73 | private: | 73 | private: |
74 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
81 | { | 81 | { |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 84 | #endif |
85 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
86 | resetOnFocusIn = true; | 86 | resetOnFocusIn = true; |
87 | setVScrollBarMode(QScrollView::AlwaysOff); | 87 | setVScrollBarMode(QScrollView::AlwaysOff); |
88 | setHScrollBarMode(QScrollView::AlwaysOff); | 88 | setHScrollBarMode(QScrollView::AlwaysOff); |
89 | } | 89 | } |
90 | KNoScrollListBox::~KNoScrollListBox() | 90 | KNoScrollListBox::~KNoScrollListBox() |
91 | { | 91 | { |
92 | #if QT_VERSION >= 0x030000 | 92 | #if QT_VERSION >= 0x030000 |
93 | 93 | ||
94 | #else | 94 | #else |
95 | delete mWT; | 95 | delete mWT; |
96 | #endif | 96 | #endif |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | 100 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) |
101 | { | 101 | { |
102 | QListBox::focusInEvent ( e ); | 102 | QListBox::focusInEvent ( e ); |
103 | if ( count() ){ | 103 | if ( count() ){ |
104 | int ci = currentItem(); | 104 | int ci = currentItem(); |
105 | if ( ci < 0 ) ci = 0; | 105 | if ( ci < 0 ) ci = 0; |
106 | 106 | ||
107 | setCurrentItem( ci ); | 107 | setCurrentItem( ci ); |
108 | setSelected ( ci, true ); | 108 | setSelected ( ci, true ); |
109 | emit highlighted( item ( ci ) ); | 109 | emit highlighted( item ( ci ) ); |
110 | 110 | ||
111 | resetOnFocusIn = true; | 111 | resetOnFocusIn = true; |
112 | 112 | ||
113 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 113 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
114 | QListBoxItem *fi = firstItem (); | 114 | QListBoxItem *fi = firstItem (); |
115 | if (fi ) { | 115 | if (fi ) { |
116 | int ihei = fi->height( this ); | 116 | int ihei = fi->height( this ); |
117 | int hei = numRows () * ihei; | 117 | int hei = numRows () * ihei; |
118 | if ( hei < height() - horizontalScrollBar()->height () ) { | 118 | if ( hei < height() - horizontalScrollBar()->height () ) { |
119 | setVScrollBarMode(QScrollView::AlwaysOff); | 119 | setVScrollBarMode(QScrollView::AlwaysOff); |
120 | } | 120 | } |
121 | else | 121 | else |
122 | setVScrollBarMode(QScrollView::Auto); | 122 | setVScrollBarMode(QScrollView::Auto); |
123 | if ( ihei *3 > height() ) { | 123 | if ( ihei *3 > height() ) { |
124 | setHScrollBarMode(QScrollView::AlwaysOff); | 124 | setHScrollBarMode(QScrollView::AlwaysOff); |
125 | } | 125 | } |
126 | else { | 126 | else { |
127 | setHScrollBarMode(QScrollView::Auto); | 127 | setHScrollBarMode(QScrollView::Auto); |
128 | } | 128 | } |
129 | } else { | 129 | } else { |
130 | setVScrollBarMode(QScrollView::Auto); | 130 | setVScrollBarMode(QScrollView::Auto); |
131 | setHScrollBarMode(QScrollView::Auto); | 131 | setHScrollBarMode(QScrollView::Auto); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | 136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) |
137 | { | 137 | { |
138 | int i = currentItem (); | 138 | int i = currentItem (); |
139 | if ( i >= 0 ) { | 139 | if ( i >= 0 ) { |
140 | setSelected ( i, false ); | 140 | setSelected ( i, false ); |
141 | } | 141 | } |
142 | QListBox::focusOutEvent ( e ); | 142 | QListBox::focusOutEvent ( e ); |
143 | setVScrollBarMode(QScrollView::AlwaysOff); | 143 | setVScrollBarMode(QScrollView::AlwaysOff); |
144 | setHScrollBarMode(QScrollView::AlwaysOff); | 144 | setHScrollBarMode(QScrollView::AlwaysOff); |
145 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); | 145 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); |
146 | } | 146 | } |
147 | 147 | ||
148 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 148 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
149 | { | 149 | { |
150 | QListBoxItem* item = itemAt ( p ); | 150 | QListBoxItem* item = itemAt ( p ); |
151 | if ( ! item ) { | 151 | if ( ! item ) { |
152 | return i18n("Click in the cell\nto add an event!"); | 152 | return i18n("Click in the cell\nto add an event!"); |
153 | } | 153 | } |
154 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 154 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
155 | KOPrefs::instance()->mWTshowDetails, | 155 | KOPrefs::instance()->mWTshowDetails, |
156 | KOPrefs::instance()->mWTshowCreated, | 156 | KOPrefs::instance()->mWTshowCreated, |
157 | KOPrefs::instance()->mWTshowChanged); | 157 | KOPrefs::instance()->mWTshowChanged); |
158 | } | 158 | } |
159 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 159 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
160 | { | 160 | { |
161 | //qDebug("KNoScrollListBox::keyPressEvent "); | 161 | //qDebug("KNoScrollListBox::keyPressEvent "); |
162 | switch(e->key()) { | 162 | switch(e->key()) { |
163 | case Key_Right: | 163 | case Key_Right: |
164 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 164 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
165 | { | 165 | { |
166 | e->ignore(); | 166 | e->ignore(); |
167 | return; | 167 | return; |
168 | } | 168 | } |
169 | scrollBy(10,0); | 169 | scrollBy(10,0); |
170 | break; | 170 | break; |
171 | case Key_Left: | 171 | case Key_Left: |
172 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 172 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
173 | { | 173 | { |
174 | e->ignore(); | 174 | e->ignore(); |
175 | return; | 175 | return; |
176 | } | 176 | } |
177 | scrollBy(-10,0); | 177 | scrollBy(-10,0); |
178 | break; | 178 | break; |
179 | case Key_Up: | 179 | case Key_Up: |
180 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 180 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
181 | e->ignore(); | 181 | e->ignore(); |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | if ( count() ) { | 184 | if ( count() ) { |
185 | if ( currentItem() == 0 ) { | 185 | if ( currentItem() == 0 ) { |
186 | emit prevCell(); | 186 | emit prevCell(); |
187 | } else { | 187 | } else { |
188 | setCurrentItem((currentItem()+count()-1)%count()); | 188 | setCurrentItem((currentItem()+count()-1)%count()); |
189 | if(!itemVisible(currentItem())) { | 189 | if(!itemVisible(currentItem())) { |
190 | if((unsigned int) currentItem() == (count()-1)) { | 190 | if((unsigned int) currentItem() == (count()-1)) { |
191 | setTopItem(currentItem()-numItemsVisible()+1); | 191 | setTopItem(currentItem()-numItemsVisible()+1); |
192 | } else { | 192 | } else { |
193 | setTopItem(topItem()-1); | 193 | setTopItem(topItem()-1); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | } | 196 | } |
197 | } | 197 | } |
198 | break; | 198 | break; |
199 | case Key_Down: | 199 | case Key_Down: |
200 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 200 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
201 | e->ignore(); | 201 | e->ignore(); |
202 | break; | 202 | break; |
203 | } | 203 | } |
204 | if ( count () ) { | 204 | if ( count () ) { |
205 | if ( ((uint)currentItem()+1) == count () ) { | 205 | if ( ((uint)currentItem()+1) == count () ) { |
206 | emit nextCell(); | 206 | emit nextCell(); |
207 | } else { | 207 | } else { |
208 | setCurrentItem((currentItem()+1)%count()); | 208 | setCurrentItem((currentItem()+1)%count()); |
209 | if(!itemVisible(currentItem())) { | 209 | if(!itemVisible(currentItem())) { |
210 | if(currentItem() == 0) { | 210 | if(currentItem() == 0) { |
211 | setTopItem(0); | 211 | setTopItem(0); |
212 | } else { | 212 | } else { |
213 | setTopItem(topItem()+1); | 213 | setTopItem(topItem()+1); |
214 | } | 214 | } |
215 | } | 215 | } |
216 | } | 216 | } |
217 | } | 217 | } |
218 | break; | 218 | break; |
219 | case Key_I: | 219 | case Key_I: |
220 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); | 220 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
221 | e->ignore(); | 221 | e->ignore(); |
222 | break; | 222 | break; |
223 | case Key_Return: | 223 | case Key_Return: |
224 | case Key_Enter: | 224 | case Key_Enter: |
225 | { | 225 | { |
226 | if ( currentItem() >= 0 ) { | 226 | if ( currentItem() >= 0 ) { |
227 | emit doubleClicked( item( currentItem() ) ); | 227 | emit doubleClicked( item( currentItem() ) ); |
228 | e->accept(); | 228 | e->accept(); |
229 | } else { | 229 | } else { |
230 | e->ignore(); | 230 | e->ignore(); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | break; | 233 | break; |
234 | case Key_Shift: | 234 | case Key_Shift: |
235 | emit shiftDown(); | 235 | emit shiftDown(); |
236 | break; | 236 | break; |
237 | default: | 237 | default: |
238 | e->ignore(); | 238 | e->ignore(); |
239 | break; | 239 | break; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | void KNoScrollListBox::oneDown() | 243 | void KNoScrollListBox::oneDown() |
244 | { | 244 | { |
245 | if ( count () ) { | 245 | if ( count () ) { |
246 | if ( ((uint)currentItem()+1) == count () ) { | 246 | if ( ((uint)currentItem()+1) == count () ) { |
247 | emit nextCell(); | 247 | emit nextCell(); |
248 | } else { | 248 | } else { |
249 | resetOnFocusIn = false; | 249 | resetOnFocusIn = false; |
250 | setCurrentItem((currentItem()+1)%count()); | 250 | setCurrentItem((currentItem()+1)%count()); |
251 | if(!itemVisible(currentItem())) { | 251 | if(!itemVisible(currentItem())) { |
252 | if(currentItem() == 0) { | 252 | if(currentItem() == 0) { |
253 | setTopItem(0); | 253 | setTopItem(0); |
254 | } else { | 254 | } else { |
255 | setTopItem(topItem()+1); | 255 | setTopItem(topItem()+1); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | } | 259 | } |
260 | } | 260 | } |
261 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 261 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
262 | { | 262 | { |
263 | switch(e->key()) { | 263 | switch(e->key()) { |
264 | case Key_Shift: | 264 | case Key_Shift: |
265 | emit shiftUp(); | 265 | emit shiftUp(); |
266 | break; | 266 | break; |
267 | default: | 267 | default: |
268 | break; | 268 | break; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 272 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
273 | { | 273 | { |
274 | QListBox::mousePressEvent(e); | 274 | QListBox::mousePressEvent(e); |
275 | 275 | ||
276 | if(e->button() == RightButton) { | 276 | if(e->button() == RightButton) { |
277 | emit rightClick(); | 277 | emit rightClick(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) | 281 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) |
282 | : QListBoxItem() | 282 | : QListBoxItem() |
283 | { | 283 | { |
284 | mblockRepaint = true; | 284 | mblockRepaint = true; |
285 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 285 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
286 | recycle( incidence, s ); | 286 | recycle( incidence, s ); |
287 | } | 287 | } |
288 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) | 288 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) |
289 | { | 289 | { |
290 | mDisplayHighlighted = false; | 290 | mDisplayHighlighted = false; |
291 | setText( s ); | 291 | setText( s ); |
292 | mMultiday = 0; | 292 | mMultiday = 0; |
293 | mIncidence = incidence; | 293 | mIncidence = incidence; |
294 | mRecur = false; | 294 | mRecur = false; |
295 | mAlarm = false; | 295 | mAlarm = false; |
296 | mReply = false; | 296 | mReply = false; |
297 | mInfo = false; | 297 | mInfo = false; |
298 | mdayPos = 0; | 298 | mdayPos = 0; |
299 | } | 299 | } |
300 | 300 | ||
301 | bool MonthViewItem::setHighlightedFalse() | 301 | bool MonthViewItem::setHighlightedFalse() |
302 | { | 302 | { |
303 | if ( !mDisplayHighlighted ) | 303 | if ( !mDisplayHighlighted ) |
304 | return false; | 304 | return false; |
305 | mDisplayHighlighted = false; | 305 | mDisplayHighlighted = false; |
306 | return true; | 306 | return true; |
307 | } | 307 | } |
308 | 308 | ||
309 | bool MonthViewItem::setHighlighted( Incidence * inc ) | 309 | bool MonthViewItem::setHighlighted( Incidence * inc ) |
310 | { | 310 | { |
311 | if ( inc == mIncidence ) { | 311 | if ( inc == mIncidence ) { |
312 | if ( mDisplayHighlighted ) | 312 | if ( mDisplayHighlighted ) |
313 | return false; | 313 | return false; |
314 | mDisplayHighlighted = true; | 314 | mDisplayHighlighted = true; |
315 | return true; | 315 | return true; |
316 | } else { | 316 | } else { |
317 | if ( !mDisplayHighlighted ) | 317 | if ( !mDisplayHighlighted ) |
318 | return false; | 318 | return false; |
319 | mDisplayHighlighted = false; | 319 | mDisplayHighlighted = false; |
320 | return true; | 320 | return true; |
321 | } | 321 | } |
322 | return false; | 322 | return false; |
323 | } | 323 | } |
324 | void MonthViewItem::paint(QPainter *p) | 324 | void MonthViewItem::paint(QPainter *p) |
325 | { | 325 | { |
326 | if ( mblockRepaint || !mIncidence ) { | 326 | if ( mblockRepaint || !mIncidence ) { |
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | #if QT_VERSION >= 0x030000 | 329 | #if QT_VERSION >= 0x030000 |
330 | bool sel = isSelected(); | 330 | bool sel = isSelected(); |
331 | #else | 331 | #else |
332 | bool sel = selected(); | 332 | bool sel = selected(); |
333 | #endif | 333 | #endif |
334 | int heihei = height( listBox () ); | 334 | int heihei = height( listBox () ); |
335 | int x = 1; | 335 | int x = 1; |
336 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) | 336 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) |
337 | { | 337 | { |
338 | 338 | ||
339 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 339 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
340 | sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); | 340 | sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); |
341 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); | 341 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); |
342 | } | 342 | } |
343 | 343 | ||
344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
345 | int size = PIXMAP_SIZE; | 345 | int size = PIXMAP_SIZE; |
346 | if ( QApplication::desktop()->width() < 300 ) | 346 | if ( QApplication::desktop()->width() < 300 ) |
347 | size = 3; | 347 | size = 3; |
348 | int y = (heihei - size -1 ) /2; | 348 | int y = (heihei - size -1 ) /2; |
349 | 349 | ||
350 | if ( mIncidence->calID() > 1 ) { | 350 | if ( mIncidence->calID() > 1 ) { |
351 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); | 351 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); |
352 | p->drawRect ( x, y-2,size,size+4); | 352 | p->drawRect ( x, y-2,size,size+4); |
353 | x += size + 1; | 353 | x += size + 1; |
354 | } | 354 | } |
355 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 355 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
356 | if ( mInfo ) { | 356 | if ( mInfo ) { |
357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
358 | x += size + 1; | 358 | x += size + 1; |
359 | } | 359 | } |
360 | if ( mRecur ) { | 360 | if ( mRecur ) { |
361 | p->fillRect ( x, y,size,size, Qt::blue ); | 361 | p->fillRect ( x, y,size,size, Qt::blue ); |
362 | x += size + 1; | 362 | x += size + 1; |
363 | } | 363 | } |
364 | if ( mAlarm ) { | 364 | if ( mAlarm ) { |
365 | p->fillRect ( x, y,size,size, Qt::red ); | 365 | p->fillRect ( x, y,size,size, Qt::red ); |
366 | x += size + 1; | 366 | x += size + 1; |
367 | } | 367 | } |
368 | if ( mReply ) { | 368 | if ( mReply ) { |
369 | p->fillRect ( x, y,size,size, Qt::yellow ); | 369 | p->fillRect ( x, y,size,size, Qt::yellow ); |
370 | x += size + 1; | 370 | x += size + 1; |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | 375 | ||
376 | 376 | ||
377 | if ( sel ) p->setPen( Qt::white ); | 377 | if ( sel ) p->setPen( Qt::white ); |
378 | else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); | 378 | else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); |
379 | 379 | ||
380 | #if 0 | 380 | #if 0 |
381 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 381 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
382 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 382 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
383 | #endif | 383 | #endif |
384 | QColor textColor = p->pen().color(); | 384 | QColor textColor = p->pen().color(); |
385 | 385 | ||
386 | 386 | ||
387 | if ( mMultiday ) { | 387 | if ( mMultiday ) { |
388 | int yyy = y+(size/2); | 388 | int yyy = y+(size/2); |
389 | int sizeM = size+2; | 389 | int sizeM = size+2; |
390 | p->setBrush( QBrush( textColor ) ); | 390 | p->setBrush( QBrush( textColor ) ); |
391 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 391 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
392 | if ( mMultiday == 2 || mMultiday == 3 ) { | 392 | if ( mMultiday == 2 || mMultiday == 3 ) { |
393 | QPointArray pa ( 3 ); | 393 | QPointArray pa ( 3 ); |
394 | pa.setPoint (0, x, yyy ); | 394 | pa.setPoint (0, x, yyy ); |
395 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 395 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
396 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 396 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
397 | p->drawPolygon( pa ); | 397 | p->drawPolygon( pa ); |
398 | } | 398 | } |
399 | if ( mMultiday == 2 || mMultiday == 1 ) { | 399 | if ( mMultiday == 2 || mMultiday == 1 ) { |
400 | QPointArray pa ( 3 ); | 400 | QPointArray pa ( 3 ); |
401 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 401 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
402 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 402 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
403 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 403 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
404 | p->drawPolygon( pa ); | 404 | p->drawPolygon( pa ); |
405 | } | 405 | } |
406 | if ( mMultiday == 1 ) { | 406 | if ( mMultiday == 1 ) { |
407 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 407 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
408 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 408 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
409 | } | 409 | } |
410 | if ( mMultiday == 3 ) { | 410 | if ( mMultiday == 3 ) { |
411 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 411 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
412 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 412 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
413 | 413 | ||
414 | } | 414 | } |
415 | x += sizeM/2 + 1; | 415 | x += sizeM/2 + 1; |
416 | x += sizeM + 1; | 416 | x += sizeM + 1; |
417 | } | 417 | } |
418 | 418 | ||
419 | if ( mIncidence->typeID() == todoID ){ | 419 | if ( mIncidence->typeID() == todoID ){ |
420 | Todo* td = ( Todo* ) mIncidence; | 420 | Todo* td = ( Todo* ) mIncidence; |
421 | if ( td->isCompleted() ) { | 421 | if ( td->isCompleted() ) { |
422 | int half = size/2; | 422 | int half = size/2; |
423 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 423 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
424 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 424 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
425 | x += half+half + 4; | 425 | x += half+half + 4; |
426 | 426 | ||
427 | } else { | 427 | } else { |
428 | int val = td->percentComplete()/20; | 428 | int val = td->percentComplete()/20; |
429 | p->fillRect ( x+1, y-2, val ,size+4,textColor ); | 429 | p->fillRect ( x+1, y-2, val ,size+4,textColor ); |
430 | p->drawRect ( x, y-2,7,size+4); | 430 | p->drawRect ( x, y-2,7,size+4); |
431 | x += size + 3; | 431 | x += size + 3; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | QFontMetrics fm = p->fontMetrics(); | 434 | QFontMetrics fm = p->fontMetrics(); |
435 | int yPos; | 435 | int yPos; |
436 | int pmheight = size; | 436 | int pmheight = size; |
437 | if( pmheight < fm.height() ) | 437 | if( pmheight < fm.height() ) |
438 | yPos = fm.ascent() + fm.leading()/2; | 438 | yPos = fm.ascent() + fm.leading()/2; |
439 | else | 439 | else |
440 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 440 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
441 | 441 | ||
442 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { | 442 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { |
443 | p->drawText( x, yPos, text() ); | 443 | p->drawText( x, yPos, text() ); |
444 | if ( mIncidence->cancelled() ) { | 444 | if ( mIncidence->cancelled() ) { |
445 | int wid = fm.width( text() ); | 445 | int wid = fm.width( text() ); |
446 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 446 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
447 | } | 447 | } |
448 | } else { | 448 | } else { |
449 | QString pText = text(); | 449 | QString pText = text(); |
450 | if( pText.mid(2,1) == ":" ) | 450 | if( pText.mid(2,1) == ":" ) |
451 | pText = pText.mid( 6 ); | 451 | pText = pText.mid( 6 ); |
452 | p->drawText( x, yPos, pText ); | 452 | p->drawText( x, yPos, pText ); |
453 | if ( mIncidence->cancelled() ) { | 453 | if ( mIncidence->cancelled() ) { |
454 | int wid = fm.width( pText ); | 454 | int wid = fm.width( pText ); |
455 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 455 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | int MonthViewItem::height(const QListBox *lb) const | 460 | int MonthViewItem::height(const QListBox *lb) const |
461 | { | 461 | { |
462 | int ret = 10; | 462 | int ret = 10; |
463 | if ( lb ) | 463 | if ( lb ) |
464 | ret = lb->fontMetrics().lineSpacing()+1; | 464 | ret = lb->fontMetrics().lineSpacing()+1; |
465 | return ret; | 465 | return ret; |
466 | } | 466 | } |
467 | 467 | ||
468 | int MonthViewItem::width(const QListBox *lb) const | 468 | int MonthViewItem::width(const QListBox *lb) const |
469 | { | 469 | { |
470 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 470 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
471 | int size = PIXMAP_SIZE; | 471 | int size = PIXMAP_SIZE; |
472 | if ( QApplication::desktop()->width() < 300 ) | 472 | if ( QApplication::desktop()->width() < 300 ) |
473 | size = 3; | 473 | size = 3; |
474 | int x = 1; | 474 | int x = 1; |
475 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 475 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
476 | if ( mInfo ) { | 476 | if ( mInfo ) { |
477 | x += size + 1; | 477 | x += size + 1; |
478 | } | 478 | } |
479 | if( mRecur ) { | 479 | if( mRecur ) { |
480 | x += size+1; | 480 | x += size+1; |
481 | } | 481 | } |
482 | if( mAlarm ) { | 482 | if( mAlarm ) { |
483 | x += size+1; | 483 | x += size+1; |
484 | } | 484 | } |
485 | if( mReply ) { | 485 | if( mReply ) { |
486 | x += size+1; | 486 | x += size+1; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | if( mMultiday ) { | 489 | if( mMultiday ) { |
490 | x += size+1+2+size/2; | 490 | x += size+1+2+size/2; |
491 | } | 491 | } |
492 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 492 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
493 | } | 493 | } |
494 | if ( ! lb ) | 494 | if ( ! lb ) |
495 | return 10; | 495 | return 10; |
496 | return lb->width(); | 496 | return lb->width(); |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 500 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
501 | : KNoScrollListBox( par ), | 501 | : KNoScrollListBox( par ), |
502 | mMonthView( parent ) | 502 | mMonthView( parent ) |
503 | { | 503 | { |
504 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 504 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
505 | currentPalette = 0; | 505 | currentPalette = 0; |
506 | // mLabel = new QLabel( this );QPushButton | 506 | // mLabel = new QLabel( this );QPushButton |
507 | mLabel = new QPushButton( this ); | 507 | mLabel = new QPushButton( this ); |
508 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 508 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
509 | //mLabel->setLineWidth( 1 ); | 509 | //mLabel->setLineWidth( 1 ); |
510 | //mLabel->setAlignment( AlignCenter ); | 510 | //mLabel->setAlignment( AlignCenter ); |
511 | mLabel->setFlat( true ); | 511 | mLabel->setFlat( true ); |
512 | mLabel->setFocusPolicy(NoFocus); | 512 | mLabel->setFocusPolicy(NoFocus); |
513 | //mItemList = new KNoScrollListBox( this ); | 513 | //mItemList = new KNoScrollListBox( this ); |
514 | setMinimumSize( 10, 10 ); | 514 | setMinimumSize( 10, 10 ); |
515 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 515 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
516 | setLineWidth( 1 ); | 516 | setLineWidth( 1 ); |
517 | //topLayout->addWidget( mItemList ); | 517 | //topLayout->addWidget( mItemList ); |
518 | mLabel->raise(); | 518 | mLabel->raise(); |
519 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 519 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
520 | mStandardPalette = palette(); | 520 | mStandardPalette = palette(); |
521 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 521 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
522 | 522 | ||
523 | enableScrollBars( false ); | 523 | enableScrollBars( false ); |
524 | updateConfig(); | 524 | updateConfig(); |
525 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 525 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
526 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 526 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
527 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 527 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
528 | SLOT( defaultAction( QListBoxItem * ) ) ); | 528 | SLOT( defaultAction( QListBoxItem * ) ) ); |
529 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 529 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
530 | const QPoint &) ), | 530 | const QPoint &) ), |
531 | SLOT( contextMenu( QListBoxItem * ) ) ); | 531 | SLOT( contextMenu( QListBoxItem * ) ) ); |
532 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 532 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
533 | SLOT( selection( QListBoxItem * ) ) ); | 533 | SLOT( selection( QListBoxItem * ) ) ); |
534 | 534 | ||
535 | /* | 535 | /* |
536 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 536 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
537 | SLOT( selection( QListBoxItem * ) ) ); | 537 | SLOT( selection( QListBoxItem * ) ) ); |
538 | */ | 538 | */ |
539 | } | 539 | } |
540 | #ifdef DESKTOP_VERSION | 540 | #ifdef DESKTOP_VERSION |
541 | QToolTipGroup *MonthViewCell::toolTipGroup() | 541 | QToolTipGroup *MonthViewCell::toolTipGroup() |
542 | { | 542 | { |
543 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 543 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
544 | return mToolTipGroup; | 544 | return mToolTipGroup; |
545 | } | 545 | } |
546 | #endif | 546 | #endif |
547 | 547 | ||
548 | void MonthViewCell::setDate( const QDate &date ) | 548 | void MonthViewCell::setDate( const QDate &date ) |
549 | { | 549 | { |
550 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 550 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
551 | mDate = date; | 551 | mDate = date; |
552 | 552 | ||
553 | 553 | ||
554 | 554 | ||
555 | //resizeEvent( 0 ); | 555 | //resizeEvent( 0 ); |
556 | } | 556 | } |
557 | 557 | ||
558 | QDate MonthViewCell::date() const | 558 | QDate MonthViewCell::date() const |
559 | { | 559 | { |
560 | return mDate; | 560 | return mDate; |
561 | } | 561 | } |
562 | 562 | ||
563 | void MonthViewCell::setPrimary( bool primary ) | 563 | void MonthViewCell::setPrimary( bool primary ) |
564 | { | 564 | { |
565 | mPrimary = primary; | 565 | mPrimary = primary; |
566 | //setMyPalette(); | 566 | //setMyPalette(); |
567 | } | 567 | } |
568 | void MonthViewCell::setMyPalette() | 568 | void MonthViewCell::setMyPalette() |
569 | { | 569 | { |
570 | 570 | ||
571 | if ( mHoliday) { | 571 | if ( mHoliday) { |
572 | if ( currentPalette == 1 ) return; | 572 | if ( currentPalette == 1 ) return; |
573 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 573 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
574 | setPalette( mHolidayPalette ); | 574 | setPalette( mHolidayPalette ); |
575 | //mLabel->setPalette( mHolidayPalette ); | 575 | //mLabel->setPalette( mHolidayPalette ); |
576 | currentPalette = 1; | 576 | currentPalette = 1; |
577 | 577 | ||
578 | } else { | 578 | } else { |
579 | if ( mPrimary ) { | 579 | if ( mPrimary ) { |
580 | if ( currentPalette == 2 ) return; | 580 | if ( currentPalette == 2 ) return; |
581 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 581 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
582 | //mLabel->setPalette( mPrimaryPalette ); | 582 | //mLabel->setPalette( mPrimaryPalette ); |
583 | setPalette( mPrimaryPalette ); | 583 | setPalette( mPrimaryPalette ); |
584 | currentPalette = 2; | 584 | currentPalette = 2; |
585 | 585 | ||
586 | } else { | 586 | } else { |
587 | if ( currentPalette == 3 ) return; | 587 | if ( currentPalette == 3 ) return; |
588 | setPalette( mNonPrimaryPalette ); | 588 | setPalette( mNonPrimaryPalette ); |
589 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 589 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
590 | //mLabel->setPalette( mNonPrimaryPalette );; | 590 | //mLabel->setPalette( mNonPrimaryPalette );; |
591 | currentPalette = 3; | 591 | currentPalette = 3; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | //QPalette pal = palette(); | 594 | //QPalette pal = palette(); |
595 | 595 | ||
596 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 596 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
597 | } | 597 | } |
598 | QPalette MonthViewCell::getPalette () | 598 | QPalette MonthViewCell::getPalette () |
599 | { | 599 | { |
600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
601 | return mStandardPalette; | 601 | return mStandardPalette; |
602 | if ( mHoliday) { | 602 | if ( mHoliday) { |
603 | return mHolidayPalette ; | 603 | return mHolidayPalette ; |
604 | } else { | 604 | } else { |
605 | if ( mPrimary ) { | 605 | if ( mPrimary ) { |
606 | return mPrimaryPalette ; | 606 | return mPrimaryPalette ; |
607 | } | 607 | } |
608 | } | 608 | } |
609 | return mNonPrimaryPalette; | 609 | return mNonPrimaryPalette; |
610 | } | 610 | } |
611 | bool MonthViewCell::isPrimary() const | 611 | bool MonthViewCell::isPrimary() const |
612 | { | 612 | { |
613 | return mPrimary; | 613 | return mPrimary; |
614 | } | 614 | } |
615 | 615 | ||
616 | void MonthViewCell::setHoliday( bool holiday ) | 616 | void MonthViewCell::setHoliday( bool holiday ) |
617 | { | 617 | { |
618 | mHoliday = holiday; | 618 | mHoliday = holiday; |
619 | //setMyPalette(); | 619 | //setMyPalette(); |
620 | } | 620 | } |
621 | 621 | ||
622 | void MonthViewCell::setHoliday( const QString &holiday ) | 622 | void MonthViewCell::setHoliday( const QString &holiday ) |
623 | { | 623 | { |
624 | mHolidayString = holiday; | 624 | mHolidayString = holiday; |
625 | 625 | ||
626 | if ( !holiday.isEmpty() ) { | 626 | if ( !holiday.isEmpty() ) { |
627 | setHoliday( true ); | 627 | setHoliday( true ); |
628 | } | 628 | } |
629 | } | 629 | } |
630 | 630 | ||
631 | void MonthViewCell::startUpdateCell() | 631 | void MonthViewCell::startUpdateCell() |
632 | { | 632 | { |
633 | blockSignals( true ); | 633 | blockSignals( true ); |
634 | mdayCount = 0; | 634 | mdayCount = 0; |
635 | setFocusPolicy(NoFocus); | 635 | setFocusPolicy(NoFocus); |
636 | if ( !mMonthView->isUpdatePossible() ) | 636 | if ( !mMonthView->isUpdatePossible() ) |
637 | return; | 637 | return; |
638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
639 | while ( mitem ) { | 639 | while ( mitem ) { |
640 | mitem->setBlockRepaint( true ); | 640 | mitem->setBlockRepaint( true ); |
641 | mitem = (MonthViewItem *)mitem->next(); | 641 | mitem = (MonthViewItem *)mitem->next(); |
642 | } | 642 | } |
643 | if ( mAvailItemList.count() > 20 ) { | 643 | if ( mAvailItemList.count() > 20 ) { |
644 | mAvailItemList.setAutoDelete( true ); | 644 | mAvailItemList.setAutoDelete( true ); |
645 | mAvailItemList.clear(); | 645 | mAvailItemList.clear(); |
646 | mAvailItemList.setAutoDelete( false ); | 646 | mAvailItemList.setAutoDelete( false ); |
647 | clear(); | 647 | clear(); |
648 | } | 648 | } |
649 | 649 | ||
650 | setPrimary( mDate.month()%2 ); | 650 | setPrimary( mDate.month()%2 ); |
651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
652 | if ( mDate == QDate::currentDate() ) { | 652 | if ( mDate == QDate::currentDate() ) { |
653 | setLineWidth( 3 ); | 653 | setLineWidth( 3 ); |
654 | } else { | 654 | } else { |
655 | setLineWidth( 1 ); | 655 | setLineWidth( 1 ); |
656 | } | 656 | } |
657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
658 | //clear(); | 658 | //clear(); |
659 | while ( CurrentAvailItem ) { | 659 | while ( CurrentAvailItem ) { |
660 | MonthViewItem *item = CurrentAvailItem; | 660 | MonthViewItem *item = CurrentAvailItem; |
661 | //item->setHighlightedFalse(); | 661 | //item->setHighlightedFalse(); |
662 | item->recycle( 0, ""); | 662 | item->recycle( 0, ""); |
663 | CurrentAvailItem = (MonthViewItem *)item->next(); | 663 | CurrentAvailItem = (MonthViewItem *)item->next(); |
664 | mAvailItemList.append( item ); | 664 | mAvailItemList.append( item ); |
665 | takeItem ( item ); | 665 | takeItem ( item ); |
666 | } | 666 | } |
667 | 667 | ||
668 | #ifdef DESKTOP_VERSION | 668 | #ifdef DESKTOP_VERSION |
669 | QToolTip::remove(this); | 669 | QToolTip::remove(this); |
670 | #endif | 670 | #endif |
671 | mToolTip.clear(); | 671 | mToolTip.clear(); |
672 | //qApp->processEvents(); | 672 | //qApp->processEvents(); |
673 | #if 0 | 673 | #if 0 |
674 | if ( !mHolidayString.isEmpty() ) { | 674 | if ( !mHolidayString.isEmpty() ) { |
675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
676 | item->setPalette( mHolidayPalette ); | 676 | item->setPalette( mHolidayPalette ); |
677 | insertItem( item ); | 677 | insertItem( item ); |
678 | mToolTip.append ( mHolidayString ); | 678 | mToolTip.append ( mHolidayString ); |
679 | } | 679 | } |
680 | #endif | 680 | #endif |
681 | } | 681 | } |
682 | 682 | ||
683 | int MonthViewCell::insertEvent(Event *event) | 683 | int MonthViewCell::insertEvent(Event *event) |
684 | { | 684 | { |
685 | bool useToolTips = true; | 685 | bool useToolTips = true; |
686 | #ifndef DESKTOP_VERSION | 686 | #ifndef DESKTOP_VERSION |
687 | useToolTips = false; | 687 | useToolTips = false; |
688 | #endif | 688 | #endif |
689 | QString mToolTipText; | 689 | QString mToolTipText; |
690 | setFocusPolicy(WheelFocus); | 690 | setFocusPolicy(WheelFocus); |
691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
693 | return mdayCount; | 693 | return mdayCount; |
694 | else | 694 | else |
695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
696 | return mdayCount; | 696 | return mdayCount; |
697 | } | 697 | } |
698 | 698 | ||
699 | if ( event->isHoliday()) { | 699 | if ( event->isHoliday()) { |
700 | setHoliday( true ); | 700 | setHoliday( true ); |
701 | if ( mDate.dayOfWeek() == 7 ) | 701 | if ( mDate.dayOfWeek() == 7 ) |
702 | setLineWidth( 3 ); | 702 | setLineWidth( 3 ); |
703 | } | 703 | } |
704 | QString text; | 704 | QString text; |
705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
706 | if (event->isMultiDay()) { | 706 | if (event->isMultiDay()) { |
707 | QString prefix = "<->";multiday = 2; | 707 | QString prefix = "<->";multiday = 2; |
708 | QString time; | 708 | QString time; |
709 | if ( event->doesRecur() ) { | 709 | if ( event->doesRecur() ) { |
710 | if ( event->recursOn( mDate) ) { | 710 | if ( event->recursOn( mDate) ) { |
711 | prefix ="->" ;multiday = 1; | 711 | prefix ="->" ;multiday = 1; |
712 | } | 712 | } |
713 | else { | 713 | else { |
714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
715 | if ( event->recursOn( mDate.addDays( -days)) ) { | 715 | if ( event->recursOn( mDate.addDays( -days)) ) { |
716 | prefix ="<-" ;multiday = 3; | 716 | prefix ="<-" ;multiday = 3; |
717 | } | 717 | } |
718 | } | 718 | } |
719 | 719 | ||
720 | } else { | 720 | } else { |
721 | if (mDate == event->dtStart().date()) { | 721 | if (mDate == event->dtStart().date()) { |
722 | prefix ="->" ;multiday = 1; | 722 | prefix ="->" ;multiday = 1; |
723 | } else if (mDate == event->dtEnd().date()) { | 723 | } else if (mDate == event->dtEnd().date()) { |
724 | prefix ="<-" ;multiday = 3; | 724 | prefix ="<-" ;multiday = 3; |
725 | } | 725 | } |
726 | } | 726 | } |
727 | if ( !event->doesFloat() ) { | 727 | if ( !event->doesFloat() ) { |
728 | if ( mDate == event->dtStart().date () ) | 728 | if ( mDate == event->dtStart().date () ) |
729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
730 | else if ( mDate == event->dtEnd().date () ) | 730 | else if ( mDate == event->dtEnd().date () ) |
731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
732 | 732 | ||
733 | } | 733 | } |
734 | text = time + event->summary(); | 734 | text = time + event->summary(); |
735 | if ( useToolTips ) | 735 | if ( useToolTips ) |
736 | mToolTipText += prefix + text; | 736 | mToolTipText += prefix + text; |
737 | } else { | 737 | } else { |
738 | if (event->doesFloat()) { | 738 | if (event->doesFloat()) { |
739 | text = event->summary(); | 739 | text = event->summary(); |
740 | if ( useToolTips ) | 740 | if ( useToolTips ) |
741 | mToolTipText += text; | 741 | mToolTipText += text; |
742 | } | 742 | } |
743 | else { | 743 | else { |
744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
745 | text += " " + event->summary(); | 745 | text += " " + event->summary(); |
746 | if ( useToolTips ) | 746 | if ( useToolTips ) |
747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
748 | } | 748 | } |
749 | } | 749 | } |
750 | if ( useToolTips && ! event->location().isEmpty() ) { | 750 | if ( useToolTips && ! event->location().isEmpty() ) { |
751 | mToolTipText += " (" + event->location() +")"; | 751 | mToolTipText += " (" + event->location() +")"; |
752 | } | 752 | } |
753 | MonthViewItem *item ; | 753 | MonthViewItem *item ; |
754 | 754 | ||
755 | if ( mAvailItemList.count() ) { | 755 | if ( mAvailItemList.count() ) { |
756 | item = mAvailItemList.first(); | 756 | item = mAvailItemList.first(); |
757 | mAvailItemList.remove( item ); | 757 | mAvailItemList.remove( item ); |
758 | item->recycle( event, text ); | 758 | item->recycle( event, text ); |
759 | } else { | 759 | } else { |
760 | item = new MonthViewItem( event, text ); | 760 | item = new MonthViewItem( event, text ); |
761 | } | 761 | } |
762 | 762 | ||
763 | QPalette pal; | 763 | QPalette pal; |
764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
765 | QStringList categories = event->categories(); | 765 | QStringList categories = event->categories(); |
766 | QString cat = categories.first(); | 766 | QString cat = categories.first(); |
767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
768 | pal = getPalette(); | 768 | pal = getPalette(); |
769 | if (cat.isEmpty()) { | 769 | if (cat.isEmpty()) { |
770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); | 771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); |
772 | } else { | 772 | } else { |
773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
774 | } | 774 | } |
775 | 775 | ||
776 | } else { | 776 | } else { |
777 | if (cat.isEmpty()) { | 777 | if (cat.isEmpty()) { |
778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); | 779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); |
780 | } else { | 780 | } else { |
781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
782 | } | 782 | } |
783 | } | 783 | } |
784 | 784 | ||
785 | } else { | 785 | } else { |
786 | pal = mStandardPalette ; | 786 | pal = mStandardPalette ; |
787 | } | 787 | } |
788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
789 | item->setPalette( pal ); | 789 | item->setPalette( pal ); |
790 | item->setRecur( event->doesRecur() ); | 790 | item->setRecur( event->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->doesRecur() ); | 881 | item->setRecur( todo->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 | //selection( item ); | 1108 | //selection( item ); |
1109 | //qApp->processEvents(); | 1109 | //qApp->processEvents(); |
1110 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1110 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1111 | Incidence *incidence = eventItem->incidence(); | 1111 | Incidence *incidence = eventItem->incidence(); |
1112 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1112 | if ( incidence ) { |
1113 | mMonthView->showContextMenu( incidence ); | ||
1114 | selection( item ); | ||
1115 | doHighLight( incidence ); | ||
1116 | } | ||
1113 | } | 1117 | } |
1114 | 1118 | ||
1115 | void MonthViewCell::selection( QListBoxItem *item ) | 1119 | void MonthViewCell::selection( QListBoxItem *item ) |
1116 | { | 1120 | { |
1117 | if ( !item ) { | 1121 | if ( !item ) { |
1118 | emit highlightIncidence( 0 , this, 0 ); | 1122 | emit highlightIncidence( 0 , this, 0 ); |
1119 | return; | 1123 | return; |
1120 | } | 1124 | } |
1121 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); | 1125 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); |
1122 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); | 1126 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); |
1123 | mMonthView->setSelectedCell( this ); | 1127 | mMonthView->setSelectedCell( this ); |
1124 | } | 1128 | } |
1125 | 1129 | ||
1126 | void MonthViewCell::deHighLight() | 1130 | void MonthViewCell::deHighLight() |
1127 | { | 1131 | { |
1128 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1132 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1129 | while ( mitem ) { | 1133 | while ( mitem ) { |
1130 | if ( mitem->setHighlightedFalse() ) | 1134 | if ( mitem->setHighlightedFalse() ) |
1131 | updateItem ( mitem ); | 1135 | updateItem ( mitem ); |
1132 | mitem = (MonthViewItem *)mitem->next(); | 1136 | mitem = (MonthViewItem *)mitem->next(); |
1133 | } | 1137 | } |
1134 | } | 1138 | } |
1135 | // returns true if no inc found | 1139 | // returns true if no inc found |
1136 | bool MonthViewCell::doHighLight( Incidence * inc ) | 1140 | bool MonthViewCell::doHighLight( Incidence * inc ) |
1137 | { | 1141 | { |
1138 | 1142 | ||
1139 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1143 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1140 | while ( mitem ) { | 1144 | while ( mitem ) { |
1141 | if ( mitem->incidence() == inc ) { | 1145 | if ( mitem->incidence() == inc ) { |
1142 | if ( mitem->setHighlighted( inc ) ) | 1146 | if ( mitem->setHighlighted( inc ) ) |
1143 | updateItem ( mitem ); | 1147 | updateItem ( mitem ); |
1144 | return false; | 1148 | return false; |
1145 | } | 1149 | } |
1146 | mitem = (MonthViewItem *)mitem->next(); | 1150 | mitem = (MonthViewItem *)mitem->next(); |
1147 | } | 1151 | } |
1148 | return true; | 1152 | return true; |
1149 | } | 1153 | } |
1150 | // ******************************************************************************* | 1154 | // ******************************************************************************* |
1151 | // ******************************************************************************* | 1155 | // ******************************************************************************* |
1152 | // ******************************************************************************* | 1156 | // ******************************************************************************* |
1153 | 1157 | ||
1154 | 1158 | ||
1155 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1159 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1156 | : KOEventView( calendar, parent, name ), | 1160 | : KOEventView( calendar, parent, name ), |
1157 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1161 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1158 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1162 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1159 | { | 1163 | { |
1160 | mFlagKeyPressed = false; | 1164 | mFlagKeyPressed = false; |
1161 | mShortDayLabelsM = false; | 1165 | mShortDayLabelsM = false; |
1162 | mShortDayLabelsW = false; | 1166 | mShortDayLabelsW = false; |
1163 | skipResize = false; | 1167 | skipResize = false; |
1164 | clPending = true; | 1168 | clPending = true; |
1165 | mPopupCell = 0; | 1169 | mPopupCell = 0; |
1166 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1170 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1167 | mWidStack = new QWidgetStack( this ); | 1171 | mWidStack = new QWidgetStack( this ); |
1168 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1172 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1169 | mMonthView = new QWidget( mWidStack ); | 1173 | mMonthView = new QWidget( mWidStack ); |
1170 | mWeekView = new QWidget( mWidStack ); | 1174 | mWeekView = new QWidget( mWidStack ); |
1171 | #if QT_VERSION >= 0x030000 | 1175 | #if QT_VERSION >= 0x030000 |
1172 | mWidStack->addWidget(mMonthView ); | 1176 | mWidStack->addWidget(mMonthView ); |
1173 | mWidStack->addWidget(mWeekView ); | 1177 | mWidStack->addWidget(mWeekView ); |
1174 | #else | 1178 | #else |
1175 | mWidStack->addWidget( mMonthView, 1 ); | 1179 | mWidStack->addWidget( mMonthView, 1 ); |
1176 | mWidStack->addWidget( mWeekView , 1 ); | 1180 | mWidStack->addWidget( mWeekView , 1 ); |
1177 | #endif | 1181 | #endif |
1178 | hb->addWidget( mNavigatorBar ); | 1182 | hb->addWidget( mNavigatorBar ); |
1179 | hb->addWidget( mWidStack ); | 1183 | hb->addWidget( mWidStack ); |
1180 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1184 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1181 | updatePossible = false; | 1185 | updatePossible = false; |
1182 | //updatePossible = true; | 1186 | //updatePossible = true; |
1183 | mCells.setAutoDelete( true ); | 1187 | mCells.setAutoDelete( true ); |
1184 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1188 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1185 | mDayLabels.resize( mDaysPerWeek ); | 1189 | mDayLabels.resize( mDaysPerWeek ); |
1186 | mDayLabelsW.resize( mDaysPerWeek ); | 1190 | mDayLabelsW.resize( mDaysPerWeek ); |
1187 | QFont bfont = font(); | 1191 | QFont bfont = font(); |
1188 | if ( QApplication::desktop()->width() < 650 ) { | 1192 | if ( QApplication::desktop()->width() < 650 ) { |
1189 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1193 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1190 | } | 1194 | } |
1191 | bfont.setBold( true ); | 1195 | bfont.setBold( true ); |
1192 | int i; | 1196 | int i; |
1193 | 1197 | ||
1194 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1198 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1195 | QLabel *label = new QLabel( mMonthView ); | 1199 | QLabel *label = new QLabel( mMonthView ); |
1196 | label->setFont(bfont); | 1200 | label->setFont(bfont); |
1197 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1201 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1198 | label->setLineWidth(1); | 1202 | label->setLineWidth(1); |
1199 | label->setAlignment(AlignCenter); | 1203 | label->setAlignment(AlignCenter); |
1200 | mDayLabels.insert( i, label ); | 1204 | mDayLabels.insert( i, label ); |
1201 | label = new QLabel( mWeekView ); | 1205 | label = new QLabel( mWeekView ); |
1202 | label->setFont(bfont); | 1206 | label->setFont(bfont); |
1203 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1207 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1204 | label->setLineWidth(1); | 1208 | label->setLineWidth(1); |
1205 | label->setAlignment(AlignCenter); | 1209 | label->setAlignment(AlignCenter); |
1206 | mDayLabelsW.insert( i, label ); | 1210 | mDayLabelsW.insert( i, label ); |
1207 | } | 1211 | } |
1208 | 1212 | ||
1209 | bfont.setBold( false ); | 1213 | bfont.setBold( false ); |
1210 | mWeekLabels.resize( mNumWeeks+1 ); | 1214 | mWeekLabels.resize( mNumWeeks+1 ); |
1211 | mWeekLabelsW.resize( 2 ); | 1215 | mWeekLabelsW.resize( 2 ); |
1212 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1216 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1213 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1217 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1214 | label->setFocusPolicy(NoFocus); | 1218 | label->setFocusPolicy(NoFocus); |
1215 | label->setFont(bfont); | 1219 | label->setFont(bfont); |
1216 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1220 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1217 | label->setFlat(true); | 1221 | label->setFlat(true); |
1218 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1222 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1219 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1223 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1220 | //label->setLineWidth(1); | 1224 | //label->setLineWidth(1); |
1221 | //label->setAlignment(AlignCenter); | 1225 | //label->setAlignment(AlignCenter); |
1222 | mWeekLabels.insert( i, label ); | 1226 | mWeekLabels.insert( i, label ); |
1223 | } | 1227 | } |
1224 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1228 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1225 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1229 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); |
1226 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1230 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1227 | 1231 | ||
1228 | for( i = 0; i < 1+1; i++ ) { | 1232 | for( i = 0; i < 1+1; i++ ) { |
1229 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1233 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1230 | label->setFocusPolicy(NoFocus); | 1234 | label->setFocusPolicy(NoFocus); |
1231 | label->setFont(bfont); | 1235 | label->setFont(bfont); |
1232 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1236 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1233 | label->setFlat(true); | 1237 | label->setFlat(true); |
1234 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1238 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1235 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1239 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1236 | //label->setLineWidth(1); | 1240 | //label->setLineWidth(1); |
1237 | //label->setAlignment(AlignCenter); | 1241 | //label->setAlignment(AlignCenter); |
1238 | mWeekLabelsW.insert( i, label ); | 1242 | mWeekLabelsW.insert( i, label ); |
1239 | } | 1243 | } |
1240 | mWeekLabelsW[1]->setText( i18n("W")); | 1244 | mWeekLabelsW[1]->setText( i18n("W")); |
1241 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1245 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); |
1242 | 1246 | ||
1243 | 1247 | ||
1244 | int row, col; | 1248 | int row, col; |
1245 | mCells.resize( mNumCells ); | 1249 | mCells.resize( mNumCells ); |
1246 | for( row = 0; row < mNumWeeks; ++row ) { | 1250 | for( row = 0; row < mNumWeeks; ++row ) { |
1247 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1251 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1248 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1252 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1249 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1253 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1250 | 1254 | ||
1251 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1255 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1252 | SLOT( defaultAction( Incidence * ) ) ); | 1256 | SLOT( defaultAction( Incidence * ) ) ); |
1253 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1257 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1254 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1258 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1255 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1259 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1256 | SIGNAL( showDaySignal( QDate ) ) ); | 1260 | SIGNAL( showDaySignal( QDate ) ) ); |
1257 | connect( cell, SIGNAL( nextCell() ), | 1261 | connect( cell, SIGNAL( nextCell() ), |
1258 | SLOT( nextCell() ) ); | 1262 | SLOT( nextCell() ) ); |
1259 | connect( cell, SIGNAL( prevCell() ), | 1263 | connect( cell, SIGNAL( prevCell() ), |
1260 | SLOT( prevCell() ) ); | 1264 | SLOT( prevCell() ) ); |
1261 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1265 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1262 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1266 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1263 | } | 1267 | } |
1264 | } | 1268 | } |
1265 | mCellsW.resize( mDaysPerWeek ); | 1269 | mCellsW.resize( mDaysPerWeek ); |
1266 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1270 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1267 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1271 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1268 | mCellsW.insert( col, cell ); | 1272 | mCellsW.insert( col, cell ); |
1269 | 1273 | ||
1270 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1274 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1271 | SLOT( defaultAction( Incidence * ) ) ); | 1275 | SLOT( defaultAction( Incidence * ) ) ); |
1272 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1276 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1273 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1277 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1274 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1278 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1275 | SIGNAL( showDaySignal( QDate ) ) ); | 1279 | SIGNAL( showDaySignal( QDate ) ) ); |
1276 | connect( cell, SIGNAL( nextCell() ), | 1280 | connect( cell, SIGNAL( nextCell() ), |
1277 | SLOT( nextCell() ) ); | 1281 | SLOT( nextCell() ) ); |
1278 | connect( cell, SIGNAL( prevCell() ), | 1282 | connect( cell, SIGNAL( prevCell() ), |
1279 | SLOT( prevCell() ) ); | 1283 | SLOT( prevCell() ) ); |
1280 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1284 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1281 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1285 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1282 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1286 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1283 | } | 1287 | } |
1284 | 1288 | ||
1285 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1289 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1286 | mContextMenu = eventPopup(); | 1290 | mContextMenu = eventPopup(); |
1287 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1291 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1288 | i18n("New Event..."),this, | 1292 | i18n("New Event..."),this, |
1289 | SLOT(slotNewEvent()),false); | 1293 | SLOT(slotNewEvent()),false); |
1290 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1294 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1291 | i18n("New Todo..."),this, | 1295 | i18n("New Todo..."),this, |
1292 | SLOT(slotNewTodo()),false); | 1296 | SLOT(slotNewTodo()),false); |
1293 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1297 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1294 | i18n("Journal"),this, | 1298 | i18n("Journal"),this, |
1295 | SLOT(slotEditJournal()),false); | 1299 | SLOT(slotEditJournal()),false); |
1296 | 1300 | ||
1297 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, | 1301 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, |
1298 | SLOT( catChanged( Incidence * ) )); | 1302 | SLOT( catChanged( Incidence * ) )); |
1299 | 1303 | ||
1300 | 1304 | ||
1301 | QString pathString = ""; | 1305 | QString pathString = ""; |
1302 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 1306 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
1303 | if ( QApplication::desktop()->width() < 480 ) | 1307 | if ( QApplication::desktop()->width() < 480 ) |
1304 | pathString += "icons16/"; | 1308 | pathString += "icons16/"; |
1305 | } else | 1309 | } else |
1306 | pathString += "iconsmini/"; | 1310 | pathString += "iconsmini/"; |
1307 | mNewItemMenu = new QPopupMenu( this ); | 1311 | mNewItemMenu = new QPopupMenu( this ); |
1308 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); | 1312 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); |
1309 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); | 1313 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); |
1310 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); | 1314 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); |
1311 | 1315 | ||
1312 | // updateConfig(); //useless here... | 1316 | // updateConfig(); //useless here... |
1313 | // ... but we need mWidthLongDayLabel computed | 1317 | // ... but we need mWidthLongDayLabel computed |
1314 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1318 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1315 | mWidthLongDayLabel = 0; | 1319 | mWidthLongDayLabel = 0; |
1316 | for (int i = 0; i < 7; i++) { | 1320 | for (int i = 0; i < 7; i++) { |
1317 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1321 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1318 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1322 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1319 | } | 1323 | } |
1320 | 1324 | ||
1321 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1325 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1322 | 1326 | ||
1323 | #if 0 | 1327 | #if 0 |
1324 | if ( mShowWeekView ) | 1328 | if ( mShowWeekView ) |
1325 | mWidStack->raiseWidget( mWeekView ); | 1329 | mWidStack->raiseWidget( mWeekView ); |
1326 | else | 1330 | else |
1327 | mWidStack->raiseWidget( mMonthView ); | 1331 | mWidStack->raiseWidget( mMonthView ); |
1328 | #endif | 1332 | #endif |
1329 | 1333 | ||
1330 | emit incidenceSelected( 0 ); | 1334 | emit incidenceSelected( 0 ); |
1331 | 1335 | ||
1332 | mComputeLayoutTimer = new QTimer( this ); | 1336 | mComputeLayoutTimer = new QTimer( this ); |
1333 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1337 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1334 | 1338 | ||
1335 | 1339 | ||
1336 | #ifndef DESKTOP_VERSION | 1340 | #ifndef DESKTOP_VERSION |
1337 | resize( QApplication::desktop()->size() ); | 1341 | resize( QApplication::desktop()->size() ); |
1338 | #else | 1342 | #else |
1339 | resize(640, 480 ); | 1343 | resize(640, 480 ); |
1340 | updatePossible = true; | 1344 | updatePossible = true; |
1341 | #endif | 1345 | #endif |
1342 | computeLayout(); | 1346 | computeLayout(); |
1343 | 1347 | ||
1344 | if ( mShowWeekView ) | 1348 | if ( mShowWeekView ) |
1345 | mWidStack->raiseWidget( mWeekView ); | 1349 | mWidStack->raiseWidget( mWeekView ); |
1346 | else | 1350 | else |
1347 | mWidStack->raiseWidget( mMonthView ); | 1351 | mWidStack->raiseWidget( mMonthView ); |
1348 | } | 1352 | } |
1349 | 1353 | ||
1350 | KOMonthView::~KOMonthView() | 1354 | KOMonthView::~KOMonthView() |
1351 | { | 1355 | { |
1352 | delete mContextMenu; | 1356 | delete mContextMenu; |
1353 | } | 1357 | } |
1354 | 1358 | ||
1355 | void KOMonthView::catChanged( Incidence * ) | 1359 | void KOMonthView::catChanged( Incidence * ) |
1356 | { | 1360 | { |
1357 | updateView(); | 1361 | updateView(); |
1358 | } | 1362 | } |
1359 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) | 1363 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) |
1360 | { | 1364 | { |
1361 | static Incidence * lastInc = 0; | 1365 | static Incidence * lastInc = 0; |
1362 | static MonthViewCell * lastCell = 0; | 1366 | static MonthViewCell * lastCell = 0; |
1363 | 1367 | ||
1364 | if ( lastInc == inc && lastCell == mc ) | 1368 | if ( lastInc == inc && lastCell == mc ) |
1365 | return; | 1369 | return; |
1366 | lastInc = inc; | 1370 | lastInc = inc; |
1367 | lastCell = mc; | 1371 | lastCell = mc; |
1368 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | 1372 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); |
1369 | 1373 | ||
1370 | bool weekview = false; | 1374 | bool weekview = false; |
1371 | uint index = 0; | 1375 | uint index = 0; |
1372 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1376 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1373 | if ( mCellsW[i] == mc ) { | 1377 | if ( mCellsW[i] == mc ) { |
1374 | weekview = true; | 1378 | weekview = true; |
1375 | index = i; | 1379 | index = i; |
1376 | break; | 1380 | break; |
1377 | } | 1381 | } |
1378 | } | 1382 | } |
1379 | QPtrVector<MonthViewCell> *cells; | 1383 | QPtrVector<MonthViewCell> *cells; |
1380 | if ( weekview ) | 1384 | if ( weekview ) |
1381 | cells = &mCellsW; | 1385 | cells = &mCellsW; |
1382 | else { | 1386 | else { |
1383 | for (uint i = 0; i < mCells.count(); ++i) { | 1387 | for (uint i = 0; i < mCells.count(); ++i) { |
1384 | if ( mCells[i] == mc ) { | 1388 | if ( mCells[i] == mc ) { |
1385 | index = i; | 1389 | index = i; |
1386 | break; | 1390 | break; |
1387 | } | 1391 | } |
1388 | } | 1392 | } |
1389 | cells = &mCells; | 1393 | cells = &mCells; |
1390 | } | 1394 | } |
1391 | for (uint i = 0; i < (*cells).count(); ++i) { | 1395 | for (uint i = 0; i < (*cells).count(); ++i) { |
1392 | (*cells)[i]->deHighLight(); | 1396 | (*cells)[i]->deHighLight(); |
1393 | } | 1397 | } |
1394 | if ( ! inc ) | 1398 | if ( ! inc ) |
1395 | return; | 1399 | return; |
1396 | 1400 | ||
1397 | uint count = (*cells).count(); | 1401 | uint count = (*cells).count(); |
1398 | bool goLeft = (mday > 1 && index > 0); | 1402 | bool goLeft = (mday > 1 && index > 0); |
1399 | bool goRight = (mday < 3 && mday > 0 && index < count -1); | 1403 | bool goRight = (mday < 3 && mday > 0 && index < count -1); |
1400 | for (uint iii = 1; iii < count; ++iii) { | 1404 | for (uint iii = 1; iii < count; ++iii) { |
1401 | if ( goLeft ) { | 1405 | if ( goLeft ) { |
1402 | int left = index - iii; | 1406 | int left = index - iii; |
1403 | if ( left >= 0 ) { | 1407 | if ( left >= 0 ) { |
1404 | if ( (*cells)[(uint)left]->doHighLight(inc) ) | 1408 | if ( (*cells)[(uint)left]->doHighLight(inc) ) |
1405 | goLeft = false; | 1409 | goLeft = false; |
1406 | } else | 1410 | } else |
1407 | goLeft = false; | 1411 | goLeft = false; |
1408 | } | 1412 | } |
1409 | if ( goRight ) { | 1413 | if ( goRight ) { |
1410 | uint right = index + iii; | 1414 | uint right = index + iii; |
1411 | if ( right < count ) { | 1415 | if ( right < count ) { |
1412 | if ( (*cells)[right]->doHighLight(inc) ) | 1416 | if ( (*cells)[right]->doHighLight(inc) ) |
1413 | goRight = false; | 1417 | goRight = false; |
1414 | 1418 | ||
1415 | } else | 1419 | } else |
1416 | goRight = false; | 1420 | goRight = false; |
1417 | } | 1421 | } |
1418 | 1422 | ||
1419 | } | 1423 | } |
1420 | #if 0 | 1424 | #if 0 |
1421 | if ( mday > 1 && index > 0 ) | 1425 | if ( mday > 1 && index > 0 ) |
1422 | for (int i = index-1; i >= 0; --i) { | 1426 | for (int i = index-1; i >= 0; --i) { |
1423 | //qDebug("index %d iii %d ", index, i); | 1427 | //qDebug("index %d iii %d ", index, i); |
1424 | if ( (*cells)[(uint)i]->doHighLight(inc) ) | 1428 | if ( (*cells)[(uint)i]->doHighLight(inc) ) |
1425 | break; | 1429 | break; |
1426 | } | 1430 | } |
1427 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) | 1431 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) |
1428 | for (uint i = index+1; i < (*cells).count(); ++i) { | 1432 | for (uint i = index+1; i < (*cells).count(); ++i) { |
1429 | if ( (*cells)[i]->doHighLight(inc) ) | 1433 | if ( (*cells)[i]->doHighLight(inc) ) |
1430 | break; | 1434 | break; |
1431 | } | 1435 | } |
1432 | #endif | 1436 | #endif |
1433 | 1437 | ||
1434 | } | 1438 | } |
1435 | void KOMonthView::selectInternalWeekNum ( int n ) | 1439 | void KOMonthView::selectInternalWeekNum ( int n ) |
1436 | { | 1440 | { |
1437 | switchView(); | 1441 | switchView(); |
1438 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1442 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1439 | emit selectMonth (); | 1443 | emit selectMonth (); |
1440 | else | 1444 | else |
1441 | emit selectWeekNum ( n ); | 1445 | emit selectWeekNum ( n ); |
1442 | } | 1446 | } |
1443 | 1447 | ||
1444 | int KOMonthView::currentWeek() | 1448 | int KOMonthView::currentWeek() |
1445 | { | 1449 | { |
1446 | if ( mShowWeekView ) | 1450 | if ( mShowWeekView ) |
1447 | return mWeekLabelsW[0]->getWeekNum(); | 1451 | return mWeekLabelsW[0]->getWeekNum(); |
1448 | return mWeekLabels[0]->getWeekNum(); | 1452 | return mWeekLabels[0]->getWeekNum(); |
1449 | } | 1453 | } |
1450 | void KOMonthView::switchView() | 1454 | void KOMonthView::switchView() |
1451 | { | 1455 | { |
1452 | if ( selectedCell( ) ) | 1456 | if ( selectedCell( ) ) |
1453 | selectedCell()->deselect(); | 1457 | selectedCell()->deselect(); |
1454 | mShowWeekView = !mShowWeekView; | 1458 | mShowWeekView = !mShowWeekView; |
1455 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1459 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1456 | if ( clPending ) { | 1460 | if ( clPending ) { |
1457 | computeLayout(); | 1461 | computeLayout(); |
1458 | updateConfig(); | 1462 | updateConfig(); |
1459 | } | 1463 | } |
1460 | if ( mShowWeekView ) | 1464 | if ( mShowWeekView ) |
1461 | mWidStack->raiseWidget( mWeekView ); | 1465 | mWidStack->raiseWidget( mWeekView ); |
1462 | else | 1466 | else |
1463 | mWidStack->raiseWidget( mMonthView ); | 1467 | mWidStack->raiseWidget( mMonthView ); |
1464 | clPending = false; | 1468 | clPending = false; |
1465 | } | 1469 | } |
1466 | 1470 | ||
1467 | int KOMonthView::maxDatesHint() | 1471 | int KOMonthView::maxDatesHint() |
1468 | { | 1472 | { |
1469 | return mNumCells; | 1473 | return mNumCells; |
1470 | } | 1474 | } |
1471 | 1475 | ||
1472 | int KOMonthView::currentDateCount() | 1476 | int KOMonthView::currentDateCount() |
1473 | { | 1477 | { |
1474 | return mNumCells; | 1478 | return mNumCells; |
1475 | } | 1479 | } |
1476 | 1480 | ||
1477 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1481 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1478 | { | 1482 | { |
1479 | QPtrList<Incidence> selected; | 1483 | QPtrList<Incidence> selected; |
1480 | 1484 | ||
1481 | if ( mSelectedCell ) { | 1485 | if ( mSelectedCell ) { |
1482 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1486 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1483 | if ( incidence ) selected.append( incidence ); | 1487 | if ( incidence ) selected.append( incidence ); |
1484 | } | 1488 | } |
1485 | 1489 | ||
1486 | return selected; | 1490 | return selected; |
1487 | } | 1491 | } |
1488 | 1492 | ||
1489 | DateList KOMonthView::selectedDates() | 1493 | DateList KOMonthView::selectedDates() |
1490 | { | 1494 | { |
1491 | DateList selected; | 1495 | DateList selected; |
1492 | 1496 | ||
1493 | if ( mSelectedCell ) { | 1497 | if ( mSelectedCell ) { |
1494 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1498 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1495 | if ( qd.isValid() ) selected.append( qd ); | 1499 | if ( qd.isValid() ) selected.append( qd ); |
1496 | } | 1500 | } |
1497 | 1501 | ||
1498 | return selected; | 1502 | return selected; |
1499 | } | 1503 | } |
1500 | #if 0 | 1504 | #if 0 |
1501 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1505 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1502 | const QDate &td) | 1506 | const QDate &td) |
1503 | { | 1507 | { |
1504 | #ifndef KORG_NOPRINTER | 1508 | #ifndef KORG_NOPRINTER |
1505 | calPrinter->preview(CalPrinter::Month, fd, td); | 1509 | calPrinter->preview(CalPrinter::Month, fd, td); |
1506 | #endif | 1510 | #endif |
1507 | } | 1511 | } |
1508 | #endif | 1512 | #endif |
1509 | void KOMonthView::updateConfig() | 1513 | void KOMonthView::updateConfig() |
1510 | { | 1514 | { |
1511 | 1515 | ||
1512 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1516 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1513 | 1517 | ||
1514 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1518 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1515 | mWeekStartsMonday = true; | 1519 | mWeekStartsMonday = true; |
1516 | } | 1520 | } |
1517 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1521 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1518 | mWidthLongDayLabel = 0; | 1522 | mWidthLongDayLabel = 0; |
1519 | 1523 | ||
1520 | for (int i = 0; i < 7; i++) { | 1524 | for (int i = 0; i < 7; i++) { |
1521 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1525 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1522 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1526 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1523 | } | 1527 | } |
1524 | bool temp = mShowSatSunComp ; | 1528 | bool temp = mShowSatSunComp ; |
1525 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1529 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1526 | if ( ! mShowWeekView ) { | 1530 | if ( ! mShowWeekView ) { |
1527 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1531 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1528 | computeLayout(); | 1532 | computeLayout(); |
1529 | } else | 1533 | } else |
1530 | doComputeLayoutWeek(); | 1534 | doComputeLayoutWeek(); |
1531 | updateDayLabels(); | 1535 | updateDayLabels(); |
1532 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1536 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1533 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1537 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1534 | //resizeEvent( 0 ); | 1538 | //resizeEvent( 0 ); |
1535 | for (uint i = 0; i < mCells.count(); ++i) { | 1539 | for (uint i = 0; i < mCells.count(); ++i) { |
1536 | mCells[i]->updateConfig(); | 1540 | mCells[i]->updateConfig(); |
1537 | } | 1541 | } |
1538 | 1542 | ||
1539 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1543 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1540 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1544 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1541 | } | 1545 | } |
1542 | #ifdef DESKTOP_VERSION | 1546 | #ifdef DESKTOP_VERSION |
1543 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1547 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1544 | #endif | 1548 | #endif |
1545 | updateView(); | 1549 | updateView(); |
1546 | } | 1550 | } |
1547 | 1551 | ||
1548 | void KOMonthView::updateDayLabels() | 1552 | void KOMonthView::updateDayLabels() |
1549 | { | 1553 | { |
1550 | 1554 | ||
1551 | QPtrVector<QLabel> *mDayLabelsT; | 1555 | QPtrVector<QLabel> *mDayLabelsT; |
1552 | 1556 | ||
1553 | mDayLabelsT = &mDayLabelsW; | 1557 | mDayLabelsT = &mDayLabelsW; |
1554 | for (int i = 0; i < 7; i++) { | 1558 | for (int i = 0; i < 7; i++) { |
1555 | { | 1559 | { |
1556 | bool show = mShortDayLabelsW; | 1560 | bool show = mShortDayLabelsW; |
1557 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1561 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1558 | show = true; | 1562 | show = true; |
1559 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1563 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1560 | } | 1564 | } |
1561 | } | 1565 | } |
1562 | mDayLabelsT = &mDayLabels; | 1566 | mDayLabelsT = &mDayLabels; |
1563 | for (int i = 0; i < 7; i++) { | 1567 | for (int i = 0; i < 7; i++) { |
1564 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1568 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1565 | bool show = mShortDayLabelsM; | 1569 | bool show = mShortDayLabelsM; |
1566 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1570 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1567 | show = true; | 1571 | show = true; |
1568 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1572 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1569 | } else { | 1573 | } else { |
1570 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1574 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1571 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1575 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1572 | 1576 | ||
1573 | } | 1577 | } |
1574 | } | 1578 | } |
1575 | 1579 | ||
1576 | } | 1580 | } |
1577 | 1581 | ||
1578 | void KOMonthView::clearList() | 1582 | void KOMonthView::clearList() |
1579 | { | 1583 | { |
1580 | unsigned int i; | 1584 | unsigned int i; |
1581 | for( i = 0; i < mCells.size(); ++i ) { | 1585 | for( i = 0; i < mCells.size(); ++i ) { |
1582 | mCells[i]->clear(); | 1586 | mCells[i]->clear(); |
1583 | } | 1587 | } |
1584 | for( i = 0; i < mCellsW.size(); ++i ) { | 1588 | for( i = 0; i < mCellsW.size(); ++i ) { |
1585 | mCellsW[i]->clear(); | 1589 | mCellsW[i]->clear(); |
1586 | } | 1590 | } |
1587 | } | 1591 | } |
1588 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1592 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1589 | { | 1593 | { |
1590 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1594 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1591 | 1595 | ||
1592 | QPtrVector<MonthViewCell> *cells; | 1596 | QPtrVector<MonthViewCell> *cells; |
1593 | QPtrVector<QLabel> *dayLabels; | 1597 | QPtrVector<QLabel> *dayLabels; |
1594 | QPtrVector<KOWeekButton> *weekLabels; | 1598 | QPtrVector<KOWeekButton> *weekLabels; |
1595 | uint weekNum = 6; | 1599 | uint weekNum = 6; |
1596 | mStartDate = start; | 1600 | mStartDate = start; |
1597 | if ( mShowWeekView ) { | 1601 | if ( mShowWeekView ) { |
1598 | weekNum = 1; | 1602 | weekNum = 1; |
1599 | cells = &mCellsW; | 1603 | cells = &mCellsW; |
1600 | dayLabels = &mDayLabelsW; | 1604 | dayLabels = &mDayLabelsW; |
1601 | weekLabels = &mWeekLabelsW; | 1605 | weekLabels = &mWeekLabelsW; |
1602 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1606 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1603 | mStartDate = mStartDate.addDays( 1 ); | 1607 | mStartDate = mStartDate.addDays( 1 ); |
1604 | } | 1608 | } |
1605 | } else { | 1609 | } else { |
1606 | cells = &mCells; | 1610 | cells = &mCells; |
1607 | dayLabels = &mDayLabels; | 1611 | dayLabels = &mDayLabels; |
1608 | weekLabels = &mWeekLabels; | 1612 | weekLabels = &mWeekLabels; |
1609 | } | 1613 | } |
1610 | 1614 | ||
1611 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1615 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1612 | 1616 | ||
1613 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1617 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1614 | mWeekStartsMonday = true; | 1618 | mWeekStartsMonday = true; |
1615 | } | 1619 | } |
1616 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1620 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1617 | 1621 | ||
1618 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1622 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1619 | mStartDate = mStartDate.addDays( -1 ); | 1623 | mStartDate = mStartDate.addDays( -1 ); |
1620 | } | 1624 | } |
1621 | uint i; | 1625 | uint i; |
1622 | for( i = 0; i < (*cells).size(); ++i ) { | 1626 | for( i = 0; i < (*cells).size(); ++i ) { |
1623 | QDate date = mStartDate.addDays( i ); | 1627 | QDate date = mStartDate.addDays( i ); |
1624 | (*cells)[i]->setDate( date ); | 1628 | (*cells)[i]->setDate( date ); |
1625 | 1629 | ||
1626 | #ifndef KORG_NOPLUGINS | 1630 | #ifndef KORG_NOPLUGINS |
1627 | // add holiday, if present | 1631 | // add holiday, if present |
1628 | QString hstring(KOCore::self()->holiday(date)); | 1632 | QString hstring(KOCore::self()->holiday(date)); |
1629 | (*cells)[i]->setHoliday( hstring ); | 1633 | (*cells)[i]->setHoliday( hstring ); |
1630 | #endif | 1634 | #endif |
1631 | 1635 | ||
1632 | } | 1636 | } |
1633 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1637 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1634 | for( i = 0; i < weekNum; ++i ) { | 1638 | for( i = 0; i < weekNum; ++i ) { |
1635 | int wno; | 1639 | int wno; |
1636 | // remember, according to ISO 8601, the first week of the year is the | 1640 | // remember, according to ISO 8601, the first week of the year is the |
1637 | // first week that contains a thursday. Thus we must subtract off 4, | 1641 | // first week that contains a thursday. Thus we must subtract off 4, |
1638 | // not just 1. | 1642 | // not just 1. |
1639 | int dayOfYear = date.dayOfYear(); | 1643 | int dayOfYear = date.dayOfYear(); |
1640 | if (dayOfYear % 7 != 0) | 1644 | if (dayOfYear % 7 != 0) |
1641 | wno = dayOfYear / 7 + 1; | 1645 | wno = dayOfYear / 7 + 1; |
1642 | else | 1646 | else |
1643 | wno =dayOfYear / 7; | 1647 | wno =dayOfYear / 7; |
1644 | (*weekLabels)[i]->setWeekNum( wno ); | 1648 | (*weekLabels)[i]->setWeekNum( wno ); |
1645 | date = date.addDays( 7 ); | 1649 | date = date.addDays( 7 ); |
1646 | } | 1650 | } |
1647 | updateView(); | 1651 | updateView(); |
1648 | } | 1652 | } |
1649 | 1653 | ||
1650 | void KOMonthView::showEvents(QPtrList<Event>) | 1654 | void KOMonthView::showEvents(QPtrList<Event>) |
1651 | { | 1655 | { |
1652 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1656 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1653 | } | 1657 | } |
1654 | 1658 | ||
1655 | void KOMonthView::changeEventDisplay(Event *, int) | 1659 | void KOMonthView::changeEventDisplay(Event *, int) |
1656 | { | 1660 | { |
1657 | // this should be re-written to be much more efficient, but this | 1661 | // this should be re-written to be much more efficient, but this |
1658 | // quick-and-dirty-hack gets the job done for right now. | 1662 | // quick-and-dirty-hack gets the job done for right now. |
1659 | //qDebug("KOMonthView::changeEventDisplay "); | 1663 | //qDebug("KOMonthView::changeEventDisplay "); |
1660 | updateView(); | 1664 | updateView(); |
1661 | } | 1665 | } |
1662 | 1666 | ||
1663 | void KOMonthView::updateView() | 1667 | void KOMonthView::updateView() |
1664 | { | 1668 | { |
1665 | 1669 | ||
1666 | if ( !updatePossible ) | 1670 | if ( !updatePossible ) |
1667 | return; | 1671 | return; |
1668 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1672 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1669 | //QTime ti; | 1673 | //QTime ti; |
1670 | //ti.start(); | 1674 | //ti.start(); |
1671 | clearSelection(); | 1675 | clearSelection(); |
1672 | QPtrVector<MonthViewCell> *cells; | 1676 | QPtrVector<MonthViewCell> *cells; |
1673 | if ( mShowWeekView ) { | 1677 | if ( mShowWeekView ) { |
1674 | cells = &mCellsW; | 1678 | cells = &mCellsW; |
1675 | } else { | 1679 | } else { |
1676 | cells = &mCells; | 1680 | cells = &mCells; |
1677 | } | 1681 | } |
1678 | #if 1 | 1682 | #if 1 |
1679 | int i; | 1683 | int i; |
1680 | int timeSpan = (*cells).size()-1; | 1684 | int timeSpan = (*cells).size()-1; |
1681 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1685 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1682 | timeSpan = 6; | 1686 | timeSpan = 6; |
1683 | for( i = 0; i < timeSpan + 1; ++i ) { | 1687 | for( i = 0; i < timeSpan + 1; ++i ) { |
1684 | (*cells)[i]->startUpdateCell(); | 1688 | (*cells)[i]->startUpdateCell(); |
1685 | } | 1689 | } |
1686 | 1690 | ||
1687 | QPtrList<Event> events = calendar()->events(); | 1691 | QPtrList<Event> events = calendar()->events(); |
1688 | Event *event; | 1692 | Event *event; |
1689 | QDateTime dt; | 1693 | QDateTime dt; |
1690 | QDate endDate = mStartDate.addDays( timeSpan ); | 1694 | QDate endDate = mStartDate.addDays( timeSpan ); |
1691 | for( event = events.first(); event; event = events.next() ) { // for event | 1695 | for( event = events.first(); event; event = events.next() ) { // for event |
1692 | if ( event->doesRecur() ) { | 1696 | if ( event->doesRecur() ) { |
1693 | bool last; | 1697 | bool last; |
1694 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1698 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1695 | QDateTime incidenceEnd; | 1699 | QDateTime incidenceEnd; |
1696 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1700 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1697 | bool invalid = false; | 1701 | bool invalid = false; |
1698 | while( true ) { | 1702 | while( true ) { |
1699 | if ( incidenceStart.isValid() ) { | 1703 | if ( incidenceStart.isValid() ) { |
1700 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1704 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1701 | int st = incidenceStart.date().daysTo( endDate ); | 1705 | int st = incidenceStart.date().daysTo( endDate ); |
1702 | if ( st >= 0 ) { // start before timeend | 1706 | if ( st >= 0 ) { // start before timeend |
1703 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1707 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1704 | if ( end >= 0 ) { // end after timestart --- got one! | 1708 | if ( end >= 0 ) { // end after timestart --- got one! |
1705 | //normalize | 1709 | //normalize |
1706 | st = timeSpan - st; | 1710 | st = timeSpan - st; |
1707 | if ( st < 0 ) st = 0; | 1711 | if ( st < 0 ) st = 0; |
1708 | if ( end > timeSpan ) end = timeSpan; | 1712 | if ( end > timeSpan ) end = timeSpan; |
1709 | int iii; | 1713 | int iii; |
1710 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1714 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1711 | for ( iii = st;iii<= end;++iii) | 1715 | for ( iii = st;iii<= end;++iii) |
1712 | (*cells)[iii]->insertEvent( event ); | 1716 | (*cells)[iii]->insertEvent( event ); |
1713 | } | 1717 | } |
1714 | } | 1718 | } |
1715 | } else { | 1719 | } else { |
1716 | if ( invalid ) | 1720 | if ( invalid ) |
1717 | break; | 1721 | break; |
1718 | invalid = true; | 1722 | invalid = true; |
1719 | //qDebug("invalid %s", event->summary().latin1()); | 1723 | //qDebug("invalid %s", event->summary().latin1()); |
1720 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1724 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1721 | } | 1725 | } |
1722 | if ( last ) | 1726 | if ( last ) |
1723 | break; | 1727 | break; |
1724 | bool ok; | 1728 | bool ok; |
1725 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1729 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1726 | if ( ! ok ) | 1730 | if ( ! ok ) |
1727 | break; | 1731 | break; |
1728 | if ( incidenceStart.date() > endDate ) | 1732 | if ( incidenceStart.date() > endDate ) |
1729 | break; | 1733 | break; |
1730 | } | 1734 | } |
1731 | } else { // no recur | 1735 | } else { // no recur |
1732 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1736 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1733 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1737 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1734 | continue; | 1738 | continue; |
1735 | int st = event->dtStart().date().daysTo( endDate ); | 1739 | int st = event->dtStart().date().daysTo( endDate ); |
1736 | if ( st >= 0 ) { // start before timeend | 1740 | if ( st >= 0 ) { // start before timeend |
1737 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1741 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1738 | if ( end >= 0 ) { // end after timestart --- got one! | 1742 | if ( end >= 0 ) { // end after timestart --- got one! |
1739 | //normalize | 1743 | //normalize |
1740 | st = timeSpan - st; | 1744 | st = timeSpan - st; |
1741 | if ( st < 0 ) st = 0; | 1745 | if ( st < 0 ) st = 0; |
1742 | if ( end > timeSpan ) end = timeSpan; | 1746 | if ( end > timeSpan ) end = timeSpan; |
1743 | int iii; | 1747 | int iii; |
1744 | for ( iii = st;iii<= end;++iii) | 1748 | for ( iii = st;iii<= end;++iii) |
1745 | (*cells)[iii]->insertEvent( event ); | 1749 | (*cells)[iii]->insertEvent( event ); |
1746 | } | 1750 | } |
1747 | } | 1751 | } |
1748 | } | 1752 | } |
1749 | } | 1753 | } |
1750 | // insert due todos | 1754 | // insert due todos |
1751 | QPtrList<Todo> todos = calendar()->todos( ); | 1755 | QPtrList<Todo> todos = calendar()->todos( ); |
1752 | Todo *todo; | 1756 | Todo *todo; |
1753 | for(todo = todos.first(); todo; todo = todos.next()) { | 1757 | for(todo = todos.first(); todo; todo = todos.next()) { |
1754 | //insertTodo( todo ); | 1758 | //insertTodo( todo ); |
1755 | if ( todo->hasDueDate() ) { | 1759 | if ( todo->hasDueDate() ) { |
1756 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1760 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1757 | if ( day >= 0 && day < timeSpan + 1) { | 1761 | if ( day >= 0 && day < timeSpan + 1) { |
1758 | (*cells)[day]->insertTodo( todo ); | 1762 | (*cells)[day]->insertTodo( todo ); |
1759 | } | 1763 | } |
1760 | } | 1764 | } |
1761 | } | 1765 | } |
1762 | 1766 | ||
1763 | for( i = 0; i < timeSpan+1; ++i ) { | 1767 | for( i = 0; i < timeSpan+1; ++i ) { |
1764 | (*cells)[i]->finishUpdateCell(); | 1768 | (*cells)[i]->finishUpdateCell(); |
1765 | } | 1769 | } |
1766 | processSelectionChange(); | 1770 | processSelectionChange(); |
1767 | //qApp->processEvents(); | 1771 | //qApp->processEvents(); |
1768 | for( i = 0; i < timeSpan+1; ++i ) { | 1772 | for( i = 0; i < timeSpan+1; ++i ) { |
1769 | //(*cells)[i]->repaintfinishUpdateCell(); | 1773 | //(*cells)[i]->repaintfinishUpdateCell(); |
1770 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); | 1774 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); |
1771 | } | 1775 | } |
1772 | setKeyBFocus(); | 1776 | setKeyBFocus(); |
1773 | #else | 1777 | #else |
1774 | // old code | 1778 | // old code |
1775 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1779 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1776 | int i; | 1780 | int i; |
1777 | for( i = 0; i < (*cells).count(); ++i ) { | 1781 | for( i = 0; i < (*cells).count(); ++i ) { |
1778 | (*cells)[i]->updateCell(); | 1782 | (*cells)[i]->updateCell(); |
1779 | } | 1783 | } |
1780 | 1784 | ||
1781 | //qDebug("KOMonthView::updateView() "); | 1785 | //qDebug("KOMonthView::updateView() "); |
1782 | processSelectionChange(); | 1786 | processSelectionChange(); |
1783 | // qDebug("---------------------------------------------------------------------+ "); | 1787 | // qDebug("---------------------------------------------------------------------+ "); |
1784 | (*cells)[0]->setFocus(); | 1788 | (*cells)[0]->setFocus(); |
1785 | #endif | 1789 | #endif |
1786 | 1790 | ||
1787 | //qDebug("update time %d ", ti.elapsed()); | 1791 | //qDebug("update time %d ", ti.elapsed()); |
1788 | } | 1792 | } |
1789 | 1793 | ||
1790 | void KOMonthView::setKeyBoardFocus() | 1794 | void KOMonthView::setKeyBoardFocus() |
1791 | { | 1795 | { |
1792 | //qDebug("KOMonthView::setKeyBoardFocus() "); | 1796 | //qDebug("KOMonthView::setKeyBoardFocus() "); |
1793 | bool shootAgain = false; | 1797 | bool shootAgain = false; |
1794 | if ( mShowWeekView ) { | 1798 | if ( mShowWeekView ) { |
1795 | shootAgain = !mWeekLabelsW[1]->hasFocus(); | 1799 | shootAgain = !mWeekLabelsW[1]->hasFocus(); |
1796 | mWeekLabelsW[1]->setFocus(); | 1800 | mWeekLabelsW[1]->setFocus(); |
1797 | } | 1801 | } |
1798 | else { | 1802 | else { |
1799 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); | 1803 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); |
1800 | mWeekLabels[mNumWeeks]->setFocus(); | 1804 | mWeekLabels[mNumWeeks]->setFocus(); |
1801 | } | 1805 | } |
1802 | --mKBFcounter; | 1806 | --mKBFcounter; |
1803 | if ( shootAgain && mKBFcounter > 0 ) { | 1807 | if ( shootAgain && mKBFcounter > 0 ) { |
1804 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); | 1808 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); |
1805 | } | 1809 | } |
1806 | } | 1810 | } |
1807 | void KOMonthView::setKeyBFocus() | 1811 | void KOMonthView::setKeyBFocus() |
1808 | { | 1812 | { |
1809 | //qDebug("KOMonthView::setKeyBFocus() "); | 1813 | //qDebug("KOMonthView::setKeyBFocus() "); |
1810 | mKBFcounter = 10; | 1814 | mKBFcounter = 10; |
1811 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); | 1815 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); |
1812 | } | 1816 | } |
1813 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1817 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1814 | { | 1818 | { |
1815 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1819 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1816 | if ( isVisible() ) { | 1820 | if ( isVisible() ) { |
1817 | //qDebug("KOMonthView::isVisible "); | 1821 | //qDebug("KOMonthView::isVisible "); |
1818 | slotComputeLayout(); | 1822 | slotComputeLayout(); |
1819 | } else | 1823 | } else |
1820 | mComputeLayoutTimer->start( 100 ); | 1824 | mComputeLayoutTimer->start( 100 ); |
1821 | if ( e ) | 1825 | if ( e ) |
1822 | KOEventView::resizeEvent( e ); | 1826 | KOEventView::resizeEvent( e ); |
1823 | } | 1827 | } |
1824 | 1828 | ||
1825 | void KOMonthView::slotComputeLayout() | 1829 | void KOMonthView::slotComputeLayout() |
1826 | { | 1830 | { |
1827 | mComputeLayoutTimer->stop(); | 1831 | mComputeLayoutTimer->stop(); |
1828 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | 1832 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); |
1829 | computeLayout(); | 1833 | computeLayout(); |
1830 | clPending = true; | 1834 | clPending = true; |
1831 | setKeyBFocus(); | 1835 | setKeyBFocus(); |
1832 | } | 1836 | } |
1833 | 1837 | ||
1834 | void KOMonthView::doComputeLayoutWeek() | 1838 | void KOMonthView::doComputeLayoutWeek() |
1835 | { | 1839 | { |
1836 | 1840 | ||
1837 | int daysToShow; | 1841 | int daysToShow; |
1838 | bool combinedSatSun = false; | 1842 | bool combinedSatSun = false; |
1839 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1843 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1840 | daysToShow = 6; | 1844 | daysToShow = 6; |
1841 | combinedSatSun = true; | 1845 | combinedSatSun = true; |
1842 | } | 1846 | } |
1843 | int wid = width();//e | 1847 | int wid = width();//e |
1844 | int hei = height()-1-mNavigatorBar->height(); | 1848 | int hei = height()-1-mNavigatorBar->height(); |
1845 | #ifdef DESKTOP_VERSION | 1849 | #ifdef DESKTOP_VERSION |
1846 | if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { | 1850 | if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { |
1847 | daysToShow = 2; | 1851 | daysToShow = 2; |
1848 | } else | 1852 | } else |
1849 | #endif | 1853 | #endif |
1850 | { | 1854 | { |
1851 | if ( wid < hei + 40 ) | 1855 | if ( wid < hei + 40 ) |
1852 | daysToShow = 2; | 1856 | daysToShow = 2; |
1853 | else | 1857 | else |
1854 | daysToShow = 3; | 1858 | daysToShow = 3; |
1855 | } | 1859 | } |
1856 | bool landscape = (daysToShow == 3); | 1860 | bool landscape = (daysToShow == 3); |
1857 | mShowSatSunComp = true; | 1861 | mShowSatSunComp = true; |
1858 | combinedSatSun = true; | 1862 | combinedSatSun = true; |
1859 | 1863 | ||
1860 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1864 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1861 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1865 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1862 | int weeklabelwid = fm.width( "888" ); | 1866 | int weeklabelwid = fm.width( "888" ); |
1863 | wid -= weeklabelwid; | 1867 | wid -= weeklabelwid; |
1864 | 1868 | ||
1865 | int colWid = wid / daysToShow; | 1869 | int colWid = wid / daysToShow; |
1866 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1870 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1867 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1871 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1868 | int colModulo = wid % daysToShow; | 1872 | int colModulo = wid % daysToShow; |
1869 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1873 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1870 | //qDebug("rowmod %d ", rowModulo); | 1874 | //qDebug("rowmod %d ", rowModulo); |
1871 | int i; | 1875 | int i; |
1872 | int x,y,w,h; | 1876 | int x,y,w,h; |
1873 | x= 0; | 1877 | x= 0; |
1874 | y= 0; | 1878 | y= 0; |
1875 | w = colWid; | 1879 | w = colWid; |
1876 | h = dayLabelHei ; | 1880 | h = dayLabelHei ; |
1877 | for ( i = 0; i < 7; i++) { | 1881 | for ( i = 0; i < 7; i++) { |
1878 | if ( i && !( i % daysToShow) && i < 6) { | 1882 | if ( i && !( i % daysToShow) && i < 6) { |
1879 | y += hei/(5-daysToShow); | 1883 | y += hei/(5-daysToShow); |
1880 | x = 0; | 1884 | x = 0; |
1881 | w = colWid; | 1885 | w = colWid; |
1882 | } | 1886 | } |
1883 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1887 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1884 | ++w; | 1888 | ++w; |
1885 | } | 1889 | } |
1886 | int xC,yC,wC,hC; | 1890 | int xC,yC,wC,hC; |
1887 | if ( i >= 5 ) { | 1891 | if ( i >= 5 ) { |
1888 | int wi = width() - x - weeklabelwid; | 1892 | int wi = width() - x - weeklabelwid; |
1889 | if ( i == 5 ) { | 1893 | if ( i == 5 ) { |
1890 | xC = x+weeklabelwid; | 1894 | xC = x+weeklabelwid; |
1891 | yC = y; | 1895 | yC = y; |
1892 | wC = wi/2+wi%2; | 1896 | wC = wi/2+wi%2; |
1893 | hC = h; | 1897 | hC = h; |
1894 | } else { | 1898 | } else { |
1895 | xC = x+weeklabelwid; | 1899 | xC = x+weeklabelwid; |
1896 | yC = y; | 1900 | yC = y; |
1897 | wC = wi; | 1901 | wC = wi; |
1898 | hC = h; | 1902 | hC = h; |
1899 | } | 1903 | } |
1900 | x = x - w + wi - (wi/2 ); | 1904 | x = x - w + wi - (wi/2 ); |
1901 | } | 1905 | } |
1902 | else { | 1906 | else { |
1903 | int wi = w; | 1907 | int wi = w; |
1904 | if ( !(( i+1) % daysToShow)) { | 1908 | if ( !(( i+1) % daysToShow)) { |
1905 | wi = width() - x - weeklabelwid; | 1909 | wi = width() - x - weeklabelwid; |
1906 | } | 1910 | } |
1907 | xC = x+weeklabelwid; | 1911 | xC = x+weeklabelwid; |
1908 | yC = y; | 1912 | yC = y; |
1909 | wC = wi; | 1913 | wC = wi; |
1910 | hC = h; | 1914 | hC = h; |
1911 | } | 1915 | } |
1912 | mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); | 1916 | mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); |
1913 | 1917 | ||
1914 | 1918 | ||
1915 | x += w; | 1919 | x += w; |
1916 | } | 1920 | } |
1917 | x= 0; | 1921 | x= 0; |
1918 | y= dayLabelHei; | 1922 | y= dayLabelHei; |
1919 | w = colWid; | 1923 | w = colWid; |
1920 | h = cellHei; | 1924 | h = cellHei; |
1921 | int max = 0; | 1925 | int max = 0; |
1922 | int w_count = mCellsW.count(); | 1926 | int w_count = mCellsW.count(); |
1923 | for ( i = 0; i < w_count; ++i) { | 1927 | for ( i = 0; i < w_count; ++i) { |
1924 | if ( i > 6 ) { | 1928 | if ( i > 6 ) { |
1925 | mCellsW[i]->hide(); | 1929 | mCellsW[i]->hide(); |
1926 | continue; | 1930 | continue; |
1927 | } | 1931 | } |
1928 | 1932 | ||
1929 | w = colWid; | 1933 | w = colWid; |
1930 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1934 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1931 | ++w; | 1935 | ++w; |
1932 | } | 1936 | } |
1933 | if ( i == (daysToShow-1-rowModulo)*7) | 1937 | if ( i == (daysToShow-1-rowModulo)*7) |
1934 | ++h; | 1938 | ++h; |
1935 | 1939 | ||
1936 | int xC,yC,wC,hC; | 1940 | int xC,yC,wC,hC; |
1937 | if ( i >= 5 ) { | 1941 | if ( i >= 5 ) { |
1938 | if ( i ==5 ) { | 1942 | if ( i ==5 ) { |
1939 | max = h/2; | 1943 | max = h/2; |
1940 | xC = x+weeklabelwid; | 1944 | xC = x+weeklabelwid; |
1941 | yC = y; | 1945 | yC = y; |
1942 | wC = w; | 1946 | wC = w; |
1943 | hC = max; | 1947 | hC = max; |
1944 | x -= w ;y += h/2; | 1948 | x -= w ;y += h/2; |
1945 | } else { | 1949 | } else { |
1946 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1950 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1947 | ++w; | 1951 | ++w; |
1948 | } | 1952 | } |
1949 | max = h-h/2; | 1953 | max = h-h/2; |
1950 | xC = x+weeklabelwid; | 1954 | xC = x+weeklabelwid; |
1951 | yC = y; | 1955 | yC = y; |
1952 | wC = w; | 1956 | wC = w; |
1953 | hC = max; | 1957 | hC = max; |
1954 | y -= h/2; | 1958 | y -= h/2; |
1955 | } | 1959 | } |
1956 | } else { | 1960 | } else { |
1957 | max = h; | 1961 | max = h; |
1958 | xC = x+weeklabelwid; | 1962 | xC = x+weeklabelwid; |
1959 | yC = y; | 1963 | yC = y; |
1960 | wC = w; | 1964 | wC = w; |
1961 | hC = h; | 1965 | hC = h; |
1962 | } | 1966 | } |
1963 | mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); | 1967 | mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); |
1964 | 1968 | ||
1965 | 1969 | ||
1966 | x += w; | 1970 | x += w; |
1967 | if ( x + w/2 > wid ) { | 1971 | if ( x + w/2 > wid ) { |
1968 | x = 0; | 1972 | x = 0; |
1969 | y += h+dayLabelHei ; | 1973 | y += h+dayLabelHei ; |
1970 | } | 1974 | } |
1971 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); | 1975 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); |
1972 | } | 1976 | } |
1973 | y= dayLabelHei; | 1977 | y= dayLabelHei; |
1974 | h = cellHei ; | 1978 | h = cellHei ; |
1975 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1979 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1976 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1980 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1977 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1981 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1978 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1982 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1979 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1983 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1980 | updateDayLabels(); | 1984 | updateDayLabels(); |
1981 | //bool forceUpdate = !updatePossible; | 1985 | //bool forceUpdate = !updatePossible; |
1982 | updatePossible = true; | 1986 | updatePossible = true; |
1983 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1987 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1984 | //if ( forceUpdate ) | 1988 | //if ( forceUpdate ) |
1985 | // updateView(); | 1989 | // updateView(); |
1986 | } | 1990 | } |
1987 | void KOMonthView::computeLayoutWeek() | 1991 | void KOMonthView::computeLayoutWeek() |
1988 | { | 1992 | { |
1989 | static int lastWid = 0; | 1993 | static int lastWid = 0; |
1990 | static int lastHei = 0; | 1994 | static int lastHei = 0; |
1991 | int tWid = topLevelWidget()->size().width(); | 1995 | int tWid = topLevelWidget()->size().width(); |
1992 | int tHei = topLevelWidget()->size().height(); | 1996 | int tHei = topLevelWidget()->size().height(); |
1993 | int wid = width();//e | 1997 | int wid = width();//e |
1994 | int hei = height()-1-mNavigatorBar->height(); | 1998 | int hei = height()-1-mNavigatorBar->height(); |
1995 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1999 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1996 | return; | 2000 | return; |
1997 | 2001 | ||
1998 | if ( lastWid == width() && lastHei == height() ) { | 2002 | if ( lastWid == width() && lastHei == height() ) { |
1999 | //qDebug("KOListWeekView::No compute layout needed "); | 2003 | //qDebug("KOListWeekView::No compute layout needed "); |
2000 | return; | 2004 | return; |
2001 | } | 2005 | } |
2002 | lastWid = width(); | 2006 | lastWid = width(); |
2003 | lastHei = height(); | 2007 | lastHei = height(); |
2004 | doComputeLayoutWeek(); | 2008 | doComputeLayoutWeek(); |
2005 | } | 2009 | } |
2006 | int KOMonthView::mapWeekLayout( int index, bool landscape ) | 2010 | int KOMonthView::mapWeekLayout( int index, bool landscape ) |
2007 | { | 2011 | { |
2008 | if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) | 2012 | if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) |
2009 | return index; | 2013 | return index; |
2010 | int diff = 0; | 2014 | int diff = 0; |
2011 | if ( !landscape ) diff = 1; | 2015 | if ( !landscape ) diff = 1; |
2012 | switch( index ) { | 2016 | switch( index ) { |
2013 | case 0: | 2017 | case 0: |
2014 | case 5: | 2018 | case 5: |
2015 | case 6: | 2019 | case 6: |
2016 | return index; | 2020 | return index; |
2017 | break; | 2021 | break; |
2018 | case 1: | 2022 | case 1: |
2019 | return 2+diff; | 2023 | return 2+diff; |
2020 | break; | 2024 | break; |
2021 | case 2: | 2025 | case 2: |
2022 | return 4-(3*diff); | 2026 | return 4-(3*diff); |
2023 | break; | 2027 | break; |
2024 | case 3: | 2028 | case 3: |
2025 | return 1+(3*diff); | 2029 | return 1+(3*diff); |
2026 | break; | 2030 | break; |
2027 | case 4: | 2031 | case 4: |
2028 | return 3-diff; | 2032 | return 3-diff; |
2029 | break; | 2033 | break; |
2030 | default: | 2034 | default: |
2031 | qDebug("KO: Error in mapping week layout "); | 2035 | qDebug("KO: Error in mapping week layout "); |
2032 | return index; | 2036 | return index; |
2033 | break; | 2037 | break; |
2034 | } | 2038 | } |
2035 | return index; | 2039 | return index; |
2036 | } | 2040 | } |
2037 | void KOMonthView::computeLayout() | 2041 | void KOMonthView::computeLayout() |
2038 | { | 2042 | { |
2039 | 2043 | ||
2040 | 2044 | ||
2041 | static int lastWid = 0; | 2045 | static int lastWid = 0; |
2042 | static int lastHei = 0; | 2046 | static int lastHei = 0; |
2043 | 2047 | ||
2044 | if ( mShowWeekView ){ | 2048 | if ( mShowWeekView ){ |
2045 | computeLayoutWeek(); | 2049 | computeLayoutWeek(); |
2046 | return; | 2050 | return; |
2047 | } | 2051 | } |
2048 | int daysToShow = 7; | 2052 | int daysToShow = 7; |
2049 | bool combinedSatSun = false; | 2053 | bool combinedSatSun = false; |
2050 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 2054 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
2051 | daysToShow = 6; | 2055 | daysToShow = 6; |
2052 | combinedSatSun = true; | 2056 | combinedSatSun = true; |
2053 | } | 2057 | } |
2054 | int tWid = topLevelWidget()->size().width(); | 2058 | int tWid = topLevelWidget()->size().width(); |
2055 | int tHei = topLevelWidget()->size().height(); | 2059 | int tHei = topLevelWidget()->size().height(); |
2056 | 2060 | ||
2057 | int wid = width();//e | 2061 | int wid = width();//e |
2058 | int hei = height()-1-mNavigatorBar->height(); | 2062 | int hei = height()-1-mNavigatorBar->height(); |
2059 | 2063 | ||
2060 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 2064 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
2061 | return; | 2065 | return; |
2062 | } | 2066 | } |
2063 | if ( lastWid == width() && lastHei == height() ){ | 2067 | if ( lastWid == width() && lastHei == height() ){ |
2064 | //qDebug("KOMonthview::No compute layout needed "); | 2068 | //qDebug("KOMonthview::No compute layout needed "); |
2065 | return; | 2069 | return; |
2066 | } | 2070 | } |
2067 | 2071 | ||
2068 | lastWid = width(); | 2072 | lastWid = width(); |
2069 | lastHei = height(); | 2073 | lastHei = height(); |
2070 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); | 2074 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); |
2071 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 2075 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
2072 | int weeklabelwid = fm.width( "888" ); | 2076 | int weeklabelwid = fm.width( "888" ); |
2073 | wid -= weeklabelwid; | 2077 | wid -= weeklabelwid; |
2074 | 2078 | ||
2075 | int colWid = wid / daysToShow; | 2079 | int colWid = wid / daysToShow; |
2076 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 2080 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
2077 | int cellHei = (hei - dayLabelHei) /6; | 2081 | int cellHei = (hei - dayLabelHei) /6; |
2078 | int colModulo = wid % daysToShow; | 2082 | int colModulo = wid % daysToShow; |
2079 | int rowModulo = (hei- dayLabelHei) % 6; | 2083 | int rowModulo = (hei- dayLabelHei) % 6; |
2080 | //qDebug("rowmod %d ", rowModulo); | 2084 | //qDebug("rowmod %d ", rowModulo); |
2081 | int i; | 2085 | int i; |
2082 | int x,y,w,h; | 2086 | int x,y,w,h; |
2083 | x= 0; | 2087 | x= 0; |
2084 | y= 0; | 2088 | y= 0; |
2085 | w = colWid; | 2089 | w = colWid; |
2086 | h = dayLabelHei ; | 2090 | h = dayLabelHei ; |
2087 | for ( i = 0; i < 7; i++) { | 2091 | for ( i = 0; i < 7; i++) { |
2088 | if ( i == daysToShow-colModulo ) | 2092 | if ( i == daysToShow-colModulo ) |
2089 | ++w; | 2093 | ++w; |
2090 | if ( combinedSatSun ) { | 2094 | if ( combinedSatSun ) { |
2091 | if ( i >= daysToShow-1 ) { | 2095 | if ( i >= daysToShow-1 ) { |
2092 | 2096 | ||
2093 | if ( i == 6 ) | 2097 | if ( i == 6 ) |
2094 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); | 2098 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); |
2095 | else | 2099 | else |
2096 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 2100 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
2097 | x -= w/2 ; | 2101 | x -= w/2 ; |
2098 | } | 2102 | } |
2099 | else | 2103 | else |
2100 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 2104 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
2101 | } else | 2105 | } else |
2102 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 2106 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
2103 | x += w; | 2107 | x += w; |
2104 | } | 2108 | } |
2105 | x= 0; | 2109 | x= 0; |
2106 | y= dayLabelHei; | 2110 | y= dayLabelHei; |
2107 | w = colWid; | 2111 | w = colWid; |
2108 | h = cellHei ; | 2112 | h = cellHei ; |
2109 | int max = 0; | 2113 | int max = 0; |
2110 | int mc_count = mCells.count(); | 2114 | int mc_count = mCells.count(); |
2111 | for ( i = 0; i < mc_count; ++i) { | 2115 | for ( i = 0; i < mc_count; ++i) { |
2112 | //qDebug("iii %d ", i); | 2116 | //qDebug("iii %d ", i); |
2113 | w = colWid; | 2117 | w = colWid; |
2114 | if ( ((i) % 7) >= 7-colModulo ) { | 2118 | if ( ((i) % 7) >= 7-colModulo ) { |
2115 | ++w; | 2119 | ++w; |
2116 | } | 2120 | } |
2117 | if ( i == (6-rowModulo)*7) | 2121 | if ( i == (6-rowModulo)*7) |
2118 | ++h; | 2122 | ++h; |
2119 | if ( combinedSatSun ) { | 2123 | if ( combinedSatSun ) { |
2120 | if ( (i)%7 >= daysToShow-1 ) { | 2124 | if ( (i)%7 >= daysToShow-1 ) { |
2121 | if ( (i)%7 == daysToShow-1 ) { | 2125 | if ( (i)%7 == daysToShow-1 ) { |
2122 | w = width()-x-weeklabelwid; | 2126 | w = width()-x-weeklabelwid; |
2123 | max = h/2; | 2127 | max = h/2; |
2124 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 2128 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
2125 | x -= w ;y += h/2; | 2129 | x -= w ;y += h/2; |
2126 | } else { | 2130 | } else { |
2127 | w = width()-x-weeklabelwid; | 2131 | w = width()-x-weeklabelwid; |
2128 | max = h-h/2; | 2132 | max = h-h/2; |
2129 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 2133 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
2130 | y -= h/2; | 2134 | y -= h/2; |
2131 | } | 2135 | } |
2132 | } else { | 2136 | } else { |
2133 | max = h; | 2137 | max = h; |
2134 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 2138 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
2135 | } | 2139 | } |
2136 | 2140 | ||
2137 | } | 2141 | } |
2138 | else { | 2142 | else { |
2139 | max = h; | 2143 | max = h; |
2140 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 2144 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
2141 | } | 2145 | } |
2142 | x += w; | 2146 | x += w; |
2143 | if ( x + w/2 > wid ) { | 2147 | if ( x + w/2 > wid ) { |
2144 | x = 0; | 2148 | x = 0; |
2145 | y += h; | 2149 | y += h; |
2146 | } | 2150 | } |
2147 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); | 2151 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); |
2148 | } | 2152 | } |
2149 | y= dayLabelHei; | 2153 | y= dayLabelHei; |
2150 | h = cellHei ; | 2154 | h = cellHei ; |
2151 | for ( i = 0; i < 6; i++) { | 2155 | for ( i = 0; i < 6; i++) { |
2152 | if ( i == (6-rowModulo)) | 2156 | if ( i == (6-rowModulo)) |
2153 | ++h; | 2157 | ++h; |
2154 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 2158 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
2155 | y += h; | 2159 | y += h; |
2156 | } | 2160 | } |
2157 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 2161 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
2158 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 2162 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
2159 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 2163 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
2160 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 2164 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
2161 | updateDayLabels(); | 2165 | updateDayLabels(); |
2162 | //bool forceUpdate = !updatePossible; | 2166 | //bool forceUpdate = !updatePossible; |
2163 | updatePossible = true; | 2167 | updatePossible = true; |
2164 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 2168 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
2165 | } | 2169 | } |
2166 | 2170 | ||
2167 | void KOMonthView::showContextMenu( Incidence *incidence ) | 2171 | void KOMonthView::showContextMenu( Incidence *incidence ) |
2168 | { | 2172 | { |
2169 | if( incidence ) | 2173 | if( incidence ) |
2170 | mContextMenu->showIncidencePopup(incidence); | 2174 | mContextMenu->showIncidencePopup(incidence); |
2171 | else { | 2175 | else { |
2172 | //qDebug("KOMonthView::showContextMenu "); | 2176 | //qDebug("KOMonthView::showContextMenu "); |
2173 | mNewItemMenu->popup(QCursor::pos()); | 2177 | mNewItemMenu->popup(QCursor::pos()); |
2174 | } | 2178 | } |
2175 | /* | 2179 | /* |
2176 | if( incidence && incidence->typeID() == eventID ) { | 2180 | if( incidence && incidence->typeID() == eventID ) { |
2177 | Event *event = static_cast<Event *>(incidence); | 2181 | Event *event = static_cast<Event *>(incidence); |
2178 | mContextMenu->showEventPopup(event); | 2182 | mContextMenu->showEventPopup(event); |
2179 | } else { | 2183 | } else { |
2180 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 2184 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
2181 | } | 2185 | } |
2182 | */ | 2186 | */ |
2183 | } | 2187 | } |
2184 | MonthViewCell * KOMonthView::selectedCell( ) | 2188 | MonthViewCell * KOMonthView::selectedCell( ) |
2185 | { | 2189 | { |
2186 | return mSelectedCell; | 2190 | return mSelectedCell; |
2187 | } | 2191 | } |
2188 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 2192 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
2189 | { | 2193 | { |
2190 | //qDebug("KOMonthView::setSelectedCell %d", cell); | 2194 | //qDebug("KOMonthView::setSelectedCell %d", cell); |
2191 | if ( mSelectedCell && mSelectedCell != cell ) { | 2195 | if ( mSelectedCell && mSelectedCell != cell ) { |
2192 | MonthViewCell * mvc = mSelectedCell; | 2196 | MonthViewCell * mvc = mSelectedCell; |
2193 | mSelectedCell = cell; | 2197 | mSelectedCell = cell; |
2194 | mvc->deselect(); | 2198 | mvc->deselect(); |
2195 | } else | 2199 | } else |
2196 | mSelectedCell = cell; | 2200 | mSelectedCell = cell; |
2197 | // if ( mSelectedCell ) | 2201 | // if ( mSelectedCell ) |
2198 | // mSelectedCell->select(); | 2202 | // mSelectedCell->select(); |
2199 | if ( !mSelectedCell ) | 2203 | if ( !mSelectedCell ) |
2200 | emit incidenceSelected( 0 ); | 2204 | emit incidenceSelected( 0 ); |
2201 | else | 2205 | else |
2202 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 2206 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
2203 | } | 2207 | } |
2204 | 2208 | ||
2205 | void KOMonthView::processSelectionChange() | 2209 | void KOMonthView::processSelectionChange() |
2206 | { | 2210 | { |
2207 | QPtrList<Incidence> incidences = selectedIncidences(); | 2211 | QPtrList<Incidence> incidences = selectedIncidences(); |
2208 | if (incidences.count() > 0) { | 2212 | if (incidences.count() > 0) { |
2209 | emit incidenceSelected( incidences.first() ); | 2213 | emit incidenceSelected( incidences.first() ); |
2210 | } else { | 2214 | } else { |
2211 | emit incidenceSelected( 0 ); | 2215 | emit incidenceSelected( 0 ); |
2212 | clearSelection(); | 2216 | clearSelection(); |
2213 | } | 2217 | } |
2214 | } | 2218 | } |
2215 | 2219 | ||
2216 | void KOMonthView::clearSelection() | 2220 | void KOMonthView::clearSelection() |
2217 | { | 2221 | { |
2218 | if ( mSelectedCell ) { | 2222 | if ( mSelectedCell ) { |
2219 | mSelectedCell->deselect(); | 2223 | mSelectedCell->deselect(); |
2220 | mSelectedCell = 0; | 2224 | mSelectedCell = 0; |
2221 | } | 2225 | } |
2222 | } | 2226 | } |
2223 | 2227 | ||
2224 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) | 2228 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) |
2225 | { | 2229 | { |
2226 | if ( !e->isAutoRepeat() ) { | 2230 | if ( !e->isAutoRepeat() ) { |
2227 | mFlagKeyPressed = false; | 2231 | mFlagKeyPressed = false; |
2228 | } | 2232 | } |
2229 | } | 2233 | } |
2230 | 2234 | ||
2231 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 2235 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
2232 | { | 2236 | { |
2233 | 2237 | ||
2234 | qApp->processEvents(); | 2238 | qApp->processEvents(); |
2235 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2239 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2236 | //e->ignore(); | 2240 | //e->ignore(); |
2237 | e->accept(); | 2241 | e->accept(); |
2238 | return; | 2242 | return; |
2239 | } | 2243 | } |
2240 | if (! e->isAutoRepeat() ) | 2244 | if (! e->isAutoRepeat() ) |
2241 | mFlagKeyPressed = true; | 2245 | mFlagKeyPressed = true; |
2242 | switch(e->key()) { | 2246 | switch(e->key()) { |
2243 | case Key_Up: | 2247 | case Key_Up: |
2244 | { | 2248 | { |
2245 | if ( mShowWeekView ) { | 2249 | if ( mShowWeekView ) { |
2246 | emit selectWeekNum ( currentWeek() - 1 ); | 2250 | emit selectWeekNum ( currentWeek() - 1 ); |
2247 | } | 2251 | } |
2248 | else { | 2252 | else { |
2249 | emit prevMonth(); | 2253 | emit prevMonth(); |
2250 | } | 2254 | } |
2251 | } | 2255 | } |
2252 | e->accept(); | 2256 | e->accept(); |
2253 | break; | 2257 | break; |
2254 | case Key_Down: | 2258 | case Key_Down: |
2255 | { | 2259 | { |
2256 | if ( mShowWeekView ) { | 2260 | if ( mShowWeekView ) { |
2257 | emit selectWeekNum ( currentWeek() +1); | 2261 | emit selectWeekNum ( currentWeek() +1); |
2258 | } | 2262 | } |
2259 | else { | 2263 | else { |
2260 | emit nextMonth(); | 2264 | emit nextMonth(); |
2261 | } | 2265 | } |
2262 | 2266 | ||
2263 | } | 2267 | } |
2264 | e->accept(); | 2268 | e->accept(); |
2265 | break; | 2269 | break; |
2266 | case Key_Return: | 2270 | case Key_Return: |
2267 | case Key_Enter: | 2271 | case Key_Enter: |
2268 | { | 2272 | { |
2269 | selectInternalWeekNum ( currentWeek() ); | 2273 | selectInternalWeekNum ( currentWeek() ); |
2270 | } | 2274 | } |
2271 | e->accept(); | 2275 | e->accept(); |
2272 | break; | 2276 | break; |
2273 | case Key_D: | 2277 | case Key_D: |
2274 | if ( mSelectedCell ) { | 2278 | if ( mSelectedCell ) { |
2275 | mSelectedCell->showDay(); | 2279 | mSelectedCell->showDay(); |
2276 | e->accept(); | 2280 | e->accept(); |
2277 | } else { | 2281 | } else { |
2278 | e->ignore(); | 2282 | e->ignore(); |
2279 | } | 2283 | } |
2280 | break; | 2284 | break; |
2281 | default: | 2285 | default: |
2282 | e->ignore(); | 2286 | e->ignore(); |
2283 | break; | 2287 | break; |
2284 | } | 2288 | } |
2285 | } | 2289 | } |
2286 | 2290 | ||
2287 | void KOMonthView::nextCell() | 2291 | void KOMonthView::nextCell() |
2288 | { | 2292 | { |
2289 | focusNextPrevChild ( true ); | 2293 | focusNextPrevChild ( true ); |
2290 | } | 2294 | } |
2291 | void KOMonthView::prevCell() | 2295 | void KOMonthView::prevCell() |
2292 | { | 2296 | { |
2293 | focusNextPrevChild ( false ); | 2297 | focusNextPrevChild ( false ); |
2294 | } | 2298 | } |
2295 | 2299 | ||
2296 | void KOMonthView::slotNewTodo() | 2300 | void KOMonthView::slotNewTodo() |
2297 | { | 2301 | { |
2298 | //qDebug("KOMonthView::slotNewTodo() "); | 2302 | //qDebug("KOMonthView::slotNewTodo() "); |
2299 | if ( mPopupCell ){ | 2303 | if ( mPopupCell ){ |
2300 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2304 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2301 | emit newTodoSignal(dt,true); | 2305 | emit newTodoSignal(dt,true); |
2302 | } | 2306 | } |
2303 | mPopupCell = 0; | 2307 | mPopupCell = 0; |
2304 | } | 2308 | } |
2305 | void KOMonthView::slotNewEvent() | 2309 | void KOMonthView::slotNewEvent() |
2306 | { | 2310 | { |
2307 | if ( mPopupCell ) { | 2311 | if ( mPopupCell ) { |
2308 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2312 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2309 | emit newEventSignal( dt ); | 2313 | emit newEventSignal( dt ); |
2310 | } | 2314 | } |
2311 | //qDebug("KOMonthView::slotNewEvent() "); | 2315 | //qDebug("KOMonthView::slotNewEvent() "); |
2312 | mPopupCell = 0; | 2316 | mPopupCell = 0; |
2313 | } | 2317 | } |
2314 | 2318 | ||
2315 | void KOMonthView::slotEditJournal() | 2319 | void KOMonthView::slotEditJournal() |
2316 | { | 2320 | { |
2317 | if ( mPopupCell ) | 2321 | if ( mPopupCell ) |
2318 | emit showJournalSignal( 7, mPopupCell->date() ); | 2322 | emit showJournalSignal( 7, mPopupCell->date() ); |
2319 | //qDebug("KOMonthView::slotEditJournal() "); | 2323 | //qDebug("KOMonthView::slotEditJournal() "); |
2320 | mPopupCell = 0; | 2324 | mPopupCell = 0; |
2321 | } | 2325 | } |
2322 | 2326 | ||
2323 | void KOMonthView::setPopupCell( MonthViewCell * c) | 2327 | void KOMonthView::setPopupCell( MonthViewCell * c) |
2324 | { | 2328 | { |
2325 | mPopupCell = c; | 2329 | mPopupCell = c; |
2326 | } | 2330 | } |