-rw-r--r-- | korganizer/komonthview.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index aeb3974..64b0e95 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,725 +1,724 @@ | |||
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 highligtIncidence( 0, (MonthViewCell*)this, 0 ); | 145 | emit highligtIncidence( 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 ( currentItem()+1 == count () ) { | 205 | if ( 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 ( currentItem()+1 == count () ) { | 246 | if ( 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 | mDisplayHightlighted = false; | 290 | mDisplayHightlighted = 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 ( !mDisplayHightlighted ) | 303 | if ( !mDisplayHightlighted ) |
304 | return false; | 304 | return false; |
305 | mDisplayHightlighted = false; | 305 | mDisplayHightlighted = 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 ( mDisplayHightlighted ) | 312 | if ( mDisplayHightlighted ) |
313 | return false; | 313 | return false; |
314 | mDisplayHightlighted = true; | 314 | mDisplayHightlighted = true; |
315 | return true; | 315 | return true; |
316 | } else { | 316 | } else { |
317 | if ( !mDisplayHightlighted ) | 317 | if ( !mDisplayHightlighted ) |
318 | return false; | 318 | return false; |
319 | mDisplayHightlighted = false; | 319 | mDisplayHightlighted = 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 || mDisplayHightlighted || sel ) | 336 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted || sel ) |
337 | { | 337 | { |
338 | if ( mDisplayHightlighted ) | 338 | |
339 | sel = true; | ||
340 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 339 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
341 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 340 | sel ||mDisplayHightlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); |
342 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); | 341 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); |
343 | } | 342 | } |
344 | 343 | ||
345 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
346 | int size = PIXMAP_SIZE; | 345 | int size = PIXMAP_SIZE; |
347 | if ( QApplication::desktop()->width() < 300 ) | 346 | if ( QApplication::desktop()->width() < 300 ) |
348 | size = 3; | 347 | size = 3; |
349 | int y = (heihei - size -1 ) /2; | 348 | int y = (heihei - size -1 ) /2; |
350 | 349 | ||
351 | if ( mIncidence->calID() > 1 ) { | 350 | if ( mIncidence->calID() > 1 ) { |
352 | 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() ) ); |
353 | p->drawRect ( x, y-2,size,size+4); | 352 | p->drawRect ( x, y-2,size,size+4); |
354 | x += size + 1; | 353 | x += size + 1; |
355 | } | 354 | } |
356 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 355 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
357 | if ( mInfo ) { | 356 | if ( mInfo ) { |
358 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
359 | x += size + 1; | 358 | x += size + 1; |
360 | } | 359 | } |
361 | if ( mRecur ) { | 360 | if ( mRecur ) { |
362 | p->fillRect ( x, y,size,size, Qt::blue ); | 361 | p->fillRect ( x, y,size,size, Qt::blue ); |
363 | x += size + 1; | 362 | x += size + 1; |
364 | } | 363 | } |
365 | if ( mAlarm ) { | 364 | if ( mAlarm ) { |
366 | p->fillRect ( x, y,size,size, Qt::red ); | 365 | p->fillRect ( x, y,size,size, Qt::red ); |
367 | x += size + 1; | 366 | x += size + 1; |
368 | } | 367 | } |
369 | if ( mReply ) { | 368 | if ( mReply ) { |
370 | p->fillRect ( x, y,size,size, Qt::yellow ); | 369 | p->fillRect ( x, y,size,size, Qt::yellow ); |
371 | x += size + 1; | 370 | x += size + 1; |
372 | } | 371 | } |
373 | } | 372 | } |
374 | if ( mMultiday ) { | 373 | if ( mMultiday ) { |
375 | int yyy = y+(size/2); | 374 | int yyy = y+(size/2); |
376 | int sizeM = size+2; | 375 | int sizeM = size+2; |
377 | p->setBrush( QBrush( p->pen().color() ) ); | 376 | p->setBrush( QBrush( p->pen().color() ) ); |
378 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 377 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
379 | if ( mMultiday == 2 || mMultiday == 3 ) { | 378 | if ( mMultiday == 2 || mMultiday == 3 ) { |
380 | QPointArray pa ( 3 ); | 379 | QPointArray pa ( 3 ); |
381 | pa.setPoint (0, x, yyy ); | 380 | pa.setPoint (0, x, yyy ); |
382 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 381 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
383 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 382 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
384 | p->drawPolygon( pa ); | 383 | p->drawPolygon( pa ); |
385 | } | 384 | } |
386 | if ( mMultiday == 2 || mMultiday == 1 ) { | 385 | if ( mMultiday == 2 || mMultiday == 1 ) { |
387 | QPointArray pa ( 3 ); | 386 | QPointArray pa ( 3 ); |
388 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 387 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
389 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 388 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
390 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 389 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
391 | p->drawPolygon( pa ); | 390 | p->drawPolygon( pa ); |
392 | } | 391 | } |
393 | if ( mMultiday == 1 ) { | 392 | if ( mMultiday == 1 ) { |
394 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 393 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
395 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 394 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
396 | } | 395 | } |
397 | if ( mMultiday == 3 ) { | 396 | if ( mMultiday == 3 ) { |
398 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 397 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
399 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 398 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
400 | 399 | ||
401 | } | 400 | } |
402 | x += sizeM/2 + 1; | 401 | x += sizeM/2 + 1; |
403 | x += sizeM + 1; | 402 | x += sizeM + 1; |
404 | } | 403 | } |
405 | 404 | ||
406 | if ( mIncidence->typeID() == todoID ){ | 405 | if ( mIncidence->typeID() == todoID ){ |
407 | Todo* td = ( Todo* ) mIncidence; | 406 | Todo* td = ( Todo* ) mIncidence; |
408 | if ( td->isCompleted() ) { | 407 | if ( td->isCompleted() ) { |
409 | int half = size/2; | 408 | int half = size/2; |
410 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 409 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
411 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 410 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
412 | x += half+half + 4; | 411 | x += half+half + 4; |
413 | 412 | ||
414 | } else { | 413 | } else { |
415 | int val = td->percentComplete()/20; | 414 | int val = td->percentComplete()/20; |
416 | p->fillRect ( x+1, y-2, val ,size+4,p->pen().color() ); | 415 | p->fillRect ( x+1, y-2, val ,size+4,p->pen().color() ); |
417 | p->drawRect ( x, y-2,7,size+4); | 416 | p->drawRect ( x, y-2,7,size+4); |
418 | x += size + 3; | 417 | x += size + 3; |
419 | } | 418 | } |
420 | } | 419 | } |
421 | QFontMetrics fm = p->fontMetrics(); | 420 | QFontMetrics fm = p->fontMetrics(); |
422 | int yPos; | 421 | int yPos; |
423 | int pmheight = size; | 422 | int pmheight = size; |
424 | if( pmheight < fm.height() ) | 423 | if( pmheight < fm.height() ) |
425 | yPos = fm.ascent() + fm.leading()/2; | 424 | yPos = fm.ascent() + fm.leading()/2; |
426 | else | 425 | else |
427 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 426 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
428 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 427 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
429 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 428 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
430 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { | 429 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { |
431 | p->drawText( x, yPos, text() ); | 430 | p->drawText( x, yPos, text() ); |
432 | if ( mIncidence->cancelled() ) { | 431 | if ( mIncidence->cancelled() ) { |
433 | int wid = fm.width( text() ); | 432 | int wid = fm.width( text() ); |
434 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 433 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
435 | } | 434 | } |
436 | } else { | 435 | } else { |
437 | QString pText = text(); | 436 | QString pText = text(); |
438 | if( pText.mid(2,1) == ":" ) | 437 | if( pText.mid(2,1) == ":" ) |
439 | pText = pText.mid( 6 ); | 438 | pText = pText.mid( 6 ); |
440 | p->drawText( x, yPos, pText ); | 439 | p->drawText( x, yPos, pText ); |
441 | if ( mIncidence->cancelled() ) { | 440 | if ( mIncidence->cancelled() ) { |
442 | int wid = fm.width( pText ); | 441 | int wid = fm.width( pText ); |
443 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 442 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
444 | } | 443 | } |
445 | } | 444 | } |
446 | } | 445 | } |
447 | 446 | ||
448 | int MonthViewItem::height(const QListBox *lb) const | 447 | int MonthViewItem::height(const QListBox *lb) const |
449 | { | 448 | { |
450 | int ret = 10; | 449 | int ret = 10; |
451 | if ( lb ) | 450 | if ( lb ) |
452 | ret = lb->fontMetrics().lineSpacing()+1; | 451 | ret = lb->fontMetrics().lineSpacing()+1; |
453 | return ret; | 452 | return ret; |
454 | } | 453 | } |
455 | 454 | ||
456 | int MonthViewItem::width(const QListBox *lb) const | 455 | int MonthViewItem::width(const QListBox *lb) const |
457 | { | 456 | { |
458 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 457 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
459 | int size = PIXMAP_SIZE; | 458 | int size = PIXMAP_SIZE; |
460 | if ( QApplication::desktop()->width() < 300 ) | 459 | if ( QApplication::desktop()->width() < 300 ) |
461 | size = 3; | 460 | size = 3; |
462 | int x = 1; | 461 | int x = 1; |
463 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 462 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
464 | if ( mInfo ) { | 463 | if ( mInfo ) { |
465 | x += size + 1; | 464 | x += size + 1; |
466 | } | 465 | } |
467 | if( mRecur ) { | 466 | if( mRecur ) { |
468 | x += size+1; | 467 | x += size+1; |
469 | } | 468 | } |
470 | if( mAlarm ) { | 469 | if( mAlarm ) { |
471 | x += size+1; | 470 | x += size+1; |
472 | } | 471 | } |
473 | if( mReply ) { | 472 | if( mReply ) { |
474 | x += size+1; | 473 | x += size+1; |
475 | } | 474 | } |
476 | } | 475 | } |
477 | if( mMultiday ) { | 476 | if( mMultiday ) { |
478 | x += size+1+2+size/2; | 477 | x += size+1+2+size/2; |
479 | } | 478 | } |
480 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 479 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
481 | } | 480 | } |
482 | if ( ! lb ) | 481 | if ( ! lb ) |
483 | return 10; | 482 | return 10; |
484 | return lb->width(); | 483 | return lb->width(); |
485 | } | 484 | } |
486 | 485 | ||
487 | 486 | ||
488 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 487 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
489 | : KNoScrollListBox( par ), | 488 | : KNoScrollListBox( par ), |
490 | mMonthView( parent ) | 489 | mMonthView( parent ) |
491 | { | 490 | { |
492 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 491 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
493 | currentPalette = 0; | 492 | currentPalette = 0; |
494 | // mLabel = new QLabel( this );QPushButton | 493 | // mLabel = new QLabel( this );QPushButton |
495 | mLabel = new QPushButton( this ); | 494 | mLabel = new QPushButton( this ); |
496 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 495 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
497 | //mLabel->setLineWidth( 1 ); | 496 | //mLabel->setLineWidth( 1 ); |
498 | //mLabel->setAlignment( AlignCenter ); | 497 | //mLabel->setAlignment( AlignCenter ); |
499 | mLabel->setFlat( true ); | 498 | mLabel->setFlat( true ); |
500 | mLabel->setFocusPolicy(NoFocus); | 499 | mLabel->setFocusPolicy(NoFocus); |
501 | //mItemList = new KNoScrollListBox( this ); | 500 | //mItemList = new KNoScrollListBox( this ); |
502 | setMinimumSize( 10, 10 ); | 501 | setMinimumSize( 10, 10 ); |
503 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 502 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
504 | setLineWidth( 1 ); | 503 | setLineWidth( 1 ); |
505 | //topLayout->addWidget( mItemList ); | 504 | //topLayout->addWidget( mItemList ); |
506 | mLabel->raise(); | 505 | mLabel->raise(); |
507 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 506 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
508 | mStandardPalette = palette(); | 507 | mStandardPalette = palette(); |
509 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 508 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
510 | 509 | ||
511 | enableScrollBars( false ); | 510 | enableScrollBars( false ); |
512 | updateConfig(); | 511 | updateConfig(); |
513 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 512 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
514 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 513 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
515 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 514 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
516 | SLOT( defaultAction( QListBoxItem * ) ) ); | 515 | SLOT( defaultAction( QListBoxItem * ) ) ); |
517 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 516 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
518 | const QPoint &) ), | 517 | const QPoint &) ), |
519 | SLOT( contextMenu( QListBoxItem * ) ) ); | 518 | SLOT( contextMenu( QListBoxItem * ) ) ); |
520 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 519 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
521 | SLOT( selection( QListBoxItem * ) ) ); | 520 | SLOT( selection( QListBoxItem * ) ) ); |
522 | 521 | ||
523 | /* | 522 | /* |
524 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 523 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
525 | SLOT( selection( QListBoxItem * ) ) ); | 524 | SLOT( selection( QListBoxItem * ) ) ); |
526 | */ | 525 | */ |
527 | } | 526 | } |
528 | #ifdef DESKTOP_VERSION | 527 | #ifdef DESKTOP_VERSION |
529 | QToolTipGroup *MonthViewCell::toolTipGroup() | 528 | QToolTipGroup *MonthViewCell::toolTipGroup() |
530 | { | 529 | { |
531 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 530 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
532 | return mToolTipGroup; | 531 | return mToolTipGroup; |
533 | } | 532 | } |
534 | #endif | 533 | #endif |
535 | 534 | ||
536 | void MonthViewCell::setDate( const QDate &date ) | 535 | void MonthViewCell::setDate( const QDate &date ) |
537 | { | 536 | { |
538 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 537 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
539 | mDate = date; | 538 | mDate = date; |
540 | 539 | ||
541 | 540 | ||
542 | 541 | ||
543 | //resizeEvent( 0 ); | 542 | //resizeEvent( 0 ); |
544 | } | 543 | } |
545 | 544 | ||
546 | QDate MonthViewCell::date() const | 545 | QDate MonthViewCell::date() const |
547 | { | 546 | { |
548 | return mDate; | 547 | return mDate; |
549 | } | 548 | } |
550 | 549 | ||
551 | void MonthViewCell::setPrimary( bool primary ) | 550 | void MonthViewCell::setPrimary( bool primary ) |
552 | { | 551 | { |
553 | mPrimary = primary; | 552 | mPrimary = primary; |
554 | //setMyPalette(); | 553 | //setMyPalette(); |
555 | } | 554 | } |
556 | void MonthViewCell::setMyPalette() | 555 | void MonthViewCell::setMyPalette() |
557 | { | 556 | { |
558 | 557 | ||
559 | if ( mHoliday) { | 558 | if ( mHoliday) { |
560 | if ( currentPalette == 1 ) return; | 559 | if ( currentPalette == 1 ) return; |
561 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 560 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
562 | setPalette( mHolidayPalette ); | 561 | setPalette( mHolidayPalette ); |
563 | //mLabel->setPalette( mHolidayPalette ); | 562 | //mLabel->setPalette( mHolidayPalette ); |
564 | currentPalette = 1; | 563 | currentPalette = 1; |
565 | 564 | ||
566 | } else { | 565 | } else { |
567 | if ( mPrimary ) { | 566 | if ( mPrimary ) { |
568 | if ( currentPalette == 2 ) return; | 567 | if ( currentPalette == 2 ) return; |
569 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 568 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
570 | //mLabel->setPalette( mPrimaryPalette ); | 569 | //mLabel->setPalette( mPrimaryPalette ); |
571 | setPalette( mPrimaryPalette ); | 570 | setPalette( mPrimaryPalette ); |
572 | currentPalette = 2; | 571 | currentPalette = 2; |
573 | 572 | ||
574 | } else { | 573 | } else { |
575 | if ( currentPalette == 3 ) return; | 574 | if ( currentPalette == 3 ) return; |
576 | setPalette( mNonPrimaryPalette ); | 575 | setPalette( mNonPrimaryPalette ); |
577 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 576 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
578 | //mLabel->setPalette( mNonPrimaryPalette );; | 577 | //mLabel->setPalette( mNonPrimaryPalette );; |
579 | currentPalette = 3; | 578 | currentPalette = 3; |
580 | } | 579 | } |
581 | } | 580 | } |
582 | //QPalette pal = palette(); | 581 | //QPalette pal = palette(); |
583 | 582 | ||
584 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 583 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
585 | } | 584 | } |
586 | QPalette MonthViewCell::getPalette () | 585 | QPalette MonthViewCell::getPalette () |
587 | { | 586 | { |
588 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 587 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
589 | return mStandardPalette; | 588 | return mStandardPalette; |
590 | if ( mHoliday) { | 589 | if ( mHoliday) { |
591 | return mHolidayPalette ; | 590 | return mHolidayPalette ; |
592 | } else { | 591 | } else { |
593 | if ( mPrimary ) { | 592 | if ( mPrimary ) { |
594 | return mPrimaryPalette ; | 593 | return mPrimaryPalette ; |
595 | } | 594 | } |
596 | } | 595 | } |
597 | return mNonPrimaryPalette; | 596 | return mNonPrimaryPalette; |
598 | } | 597 | } |
599 | bool MonthViewCell::isPrimary() const | 598 | bool MonthViewCell::isPrimary() const |
600 | { | 599 | { |
601 | return mPrimary; | 600 | return mPrimary; |
602 | } | 601 | } |
603 | 602 | ||
604 | void MonthViewCell::setHoliday( bool holiday ) | 603 | void MonthViewCell::setHoliday( bool holiday ) |
605 | { | 604 | { |
606 | mHoliday = holiday; | 605 | mHoliday = holiday; |
607 | //setMyPalette(); | 606 | //setMyPalette(); |
608 | } | 607 | } |
609 | 608 | ||
610 | void MonthViewCell::setHoliday( const QString &holiday ) | 609 | void MonthViewCell::setHoliday( const QString &holiday ) |
611 | { | 610 | { |
612 | mHolidayString = holiday; | 611 | mHolidayString = holiday; |
613 | 612 | ||
614 | if ( !holiday.isEmpty() ) { | 613 | if ( !holiday.isEmpty() ) { |
615 | setHoliday( true ); | 614 | setHoliday( true ); |
616 | } | 615 | } |
617 | } | 616 | } |
618 | 617 | ||
619 | void MonthViewCell::startUpdateCell() | 618 | void MonthViewCell::startUpdateCell() |
620 | { | 619 | { |
621 | 620 | ||
622 | mdayCount = 0; | 621 | mdayCount = 0; |
623 | setFocusPolicy(NoFocus); | 622 | setFocusPolicy(NoFocus); |
624 | if ( !mMonthView->isUpdatePossible() ) | 623 | if ( !mMonthView->isUpdatePossible() ) |
625 | return; | 624 | return; |
626 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 625 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
627 | while ( mitem ) { | 626 | while ( mitem ) { |
628 | mitem->setBlockRepaint( true ); | 627 | mitem->setBlockRepaint( true ); |
629 | mitem = (MonthViewItem *)mitem->next(); | 628 | mitem = (MonthViewItem *)mitem->next(); |
630 | } | 629 | } |
631 | if ( mAvailItemList.count() > 20 ) { | 630 | if ( mAvailItemList.count() > 20 ) { |
632 | mAvailItemList.setAutoDelete( true ); | 631 | mAvailItemList.setAutoDelete( true ); |
633 | mAvailItemList.clear(); | 632 | mAvailItemList.clear(); |
634 | mAvailItemList.setAutoDelete( false ); | 633 | mAvailItemList.setAutoDelete( false ); |
635 | clear(); | 634 | clear(); |
636 | } | 635 | } |
637 | 636 | ||
638 | setPrimary( mDate.month()%2 ); | 637 | setPrimary( mDate.month()%2 ); |
639 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 638 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
640 | if ( mDate == QDate::currentDate() ) { | 639 | if ( mDate == QDate::currentDate() ) { |
641 | setLineWidth( 3 ); | 640 | setLineWidth( 3 ); |
642 | } else { | 641 | } else { |
643 | setLineWidth( 1 ); | 642 | setLineWidth( 1 ); |
644 | } | 643 | } |
645 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 644 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
646 | //clear(); | 645 | //clear(); |
647 | while ( CurrentAvailItem ) { | 646 | while ( CurrentAvailItem ) { |
648 | MonthViewItem *item = CurrentAvailItem; | 647 | MonthViewItem *item = CurrentAvailItem; |
649 | //item->setHighlightedFalse(); | 648 | //item->setHighlightedFalse(); |
650 | item->recycle( 0, ""); | 649 | item->recycle( 0, ""); |
651 | CurrentAvailItem = (MonthViewItem *)item->next(); | 650 | CurrentAvailItem = (MonthViewItem *)item->next(); |
652 | mAvailItemList.append( item ); | 651 | mAvailItemList.append( item ); |
653 | takeItem ( item ); | 652 | takeItem ( item ); |
654 | } | 653 | } |
655 | 654 | ||
656 | #ifdef DESKTOP_VERSION | 655 | #ifdef DESKTOP_VERSION |
657 | QToolTip::remove(this); | 656 | QToolTip::remove(this); |
658 | #endif | 657 | #endif |
659 | mToolTip.clear(); | 658 | mToolTip.clear(); |
660 | //qApp->processEvents(); | 659 | //qApp->processEvents(); |
661 | #if 0 | 660 | #if 0 |
662 | if ( !mHolidayString.isEmpty() ) { | 661 | if ( !mHolidayString.isEmpty() ) { |
663 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 662 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
664 | item->setPalette( mHolidayPalette ); | 663 | item->setPalette( mHolidayPalette ); |
665 | insertItem( item ); | 664 | insertItem( item ); |
666 | mToolTip.append ( mHolidayString ); | 665 | mToolTip.append ( mHolidayString ); |
667 | } | 666 | } |
668 | #endif | 667 | #endif |
669 | } | 668 | } |
670 | 669 | ||
671 | int MonthViewCell::insertEvent(Event *event) | 670 | int MonthViewCell::insertEvent(Event *event) |
672 | { | 671 | { |
673 | bool useToolTips = true; | 672 | bool useToolTips = true; |
674 | #ifndef DESKTOP_VERSION | 673 | #ifndef DESKTOP_VERSION |
675 | useToolTips = false; | 674 | useToolTips = false; |
676 | #endif | 675 | #endif |
677 | QString mToolTipText; | 676 | QString mToolTipText; |
678 | setFocusPolicy(WheelFocus); | 677 | setFocusPolicy(WheelFocus); |
679 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 678 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
680 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 679 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
681 | return mdayCount; | 680 | return mdayCount; |
682 | else | 681 | else |
683 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 682 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
684 | return mdayCount; | 683 | return mdayCount; |
685 | } | 684 | } |
686 | 685 | ||
687 | if ( event->isHoliday()) { | 686 | if ( event->isHoliday()) { |
688 | setHoliday( true ); | 687 | setHoliday( true ); |
689 | if ( mDate.dayOfWeek() == 7 ) | 688 | if ( mDate.dayOfWeek() == 7 ) |
690 | setLineWidth( 3 ); | 689 | setLineWidth( 3 ); |
691 | } | 690 | } |
692 | QString text; | 691 | QString text; |
693 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 692 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
694 | if (event->isMultiDay()) { | 693 | if (event->isMultiDay()) { |
695 | QString prefix = "<->";multiday = 2; | 694 | QString prefix = "<->";multiday = 2; |
696 | QString time; | 695 | QString time; |
697 | if ( event->doesRecur() ) { | 696 | if ( event->doesRecur() ) { |
698 | if ( event->recursOn( mDate) ) { | 697 | if ( event->recursOn( mDate) ) { |
699 | prefix ="->" ;multiday = 1; | 698 | prefix ="->" ;multiday = 1; |
700 | } | 699 | } |
701 | else { | 700 | else { |
702 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 701 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
703 | if ( event->recursOn( mDate.addDays( -days)) ) { | 702 | if ( event->recursOn( mDate.addDays( -days)) ) { |
704 | prefix ="<-" ;multiday = 3; | 703 | prefix ="<-" ;multiday = 3; |
705 | } | 704 | } |
706 | } | 705 | } |
707 | 706 | ||
708 | } else { | 707 | } else { |
709 | if (mDate == event->dtStart().date()) { | 708 | if (mDate == event->dtStart().date()) { |
710 | prefix ="->" ;multiday = 1; | 709 | prefix ="->" ;multiday = 1; |
711 | } else if (mDate == event->dtEnd().date()) { | 710 | } else if (mDate == event->dtEnd().date()) { |
712 | prefix ="<-" ;multiday = 3; | 711 | prefix ="<-" ;multiday = 3; |
713 | } | 712 | } |
714 | } | 713 | } |
715 | if ( !event->doesFloat() ) { | 714 | if ( !event->doesFloat() ) { |
716 | if ( mDate == event->dtStart().date () ) | 715 | if ( mDate == event->dtStart().date () ) |
717 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 716 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
718 | else if ( mDate == event->dtEnd().date () ) | 717 | else if ( mDate == event->dtEnd().date () ) |
719 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 718 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
720 | 719 | ||
721 | } | 720 | } |
722 | text = time + event->summary(); | 721 | text = time + event->summary(); |
723 | if ( useToolTips ) | 722 | if ( useToolTips ) |
724 | mToolTipText += prefix + text; | 723 | mToolTipText += prefix + text; |
725 | } else { | 724 | } else { |