author | zautrix <zautrix> | 2005-06-27 21:06:01 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-27 21:06:01 (UTC) |
commit | 386f48c2011e49c7c145bad7754a725cabc25dd5 (patch) (unidiff) | |
tree | 104009f871e81468f2b4b5ba779b12c25a409c32 | |
parent | bf664c505e66f54dd03c3518386fdeab43108e56 (diff) | |
download | kdepimpi-386f48c2011e49c7c145bad7754a725cabc25dd5.zip kdepimpi-386f48c2011e49c7c145bad7754a725cabc25dd5.tar.gz kdepimpi-386f48c2011e49c7c145bad7754a725cabc25dd5.tar.bz2 |
mont fix
-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,1109 +1,1108 @@ | |||
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 { |
726 | if (event->doesFloat()) { | 725 | if (event->doesFloat()) { |
727 | text = event->summary(); | 726 | text = event->summary(); |
728 | if ( useToolTips ) | 727 | if ( useToolTips ) |
729 | mToolTipText += text; | 728 | mToolTipText += text; |
730 | } | 729 | } |
731 | else { | 730 | else { |
732 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 731 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
733 | text += " " + event->summary(); | 732 | text += " " + event->summary(); |
734 | if ( useToolTips ) | 733 | if ( useToolTips ) |
735 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 734 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
736 | } | 735 | } |
737 | } | 736 | } |
738 | if ( useToolTips && ! event->location().isEmpty() ) { | 737 | if ( useToolTips && ! event->location().isEmpty() ) { |
739 | mToolTipText += " (" + event->location() +")"; | 738 | mToolTipText += " (" + event->location() +")"; |
740 | } | 739 | } |
741 | MonthViewItem *item ; | 740 | MonthViewItem *item ; |
742 | 741 | ||
743 | if ( mAvailItemList.count() ) { | 742 | if ( mAvailItemList.count() ) { |
744 | item = mAvailItemList.first(); | 743 | item = mAvailItemList.first(); |
745 | mAvailItemList.remove( item ); | 744 | mAvailItemList.remove( item ); |
746 | item->recycle( event, text ); | 745 | item->recycle( event, text ); |
747 | } else { | 746 | } else { |
748 | item = new MonthViewItem( event, text ); | 747 | item = new MonthViewItem( event, text ); |
749 | } | 748 | } |
750 | 749 | ||
751 | QPalette pal; | 750 | QPalette pal; |
752 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 751 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
753 | QStringList categories = event->categories(); | 752 | QStringList categories = event->categories(); |
754 | QString cat = categories.first(); | 753 | QString cat = categories.first(); |
755 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 754 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
756 | pal = getPalette(); | 755 | pal = getPalette(); |
757 | if (cat.isEmpty()) { | 756 | if (cat.isEmpty()) { |
758 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 757 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
759 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); | 758 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); |
760 | } else { | 759 | } else { |
761 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 760 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
762 | } | 761 | } |
763 | 762 | ||
764 | } else { | 763 | } else { |
765 | if (cat.isEmpty()) { | 764 | if (cat.isEmpty()) { |
766 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 765 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
767 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); | 766 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); |
768 | } else { | 767 | } else { |
769 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 768 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
770 | } | 769 | } |
771 | } | 770 | } |
772 | 771 | ||
773 | } else { | 772 | } else { |
774 | pal = mStandardPalette ; | 773 | pal = mStandardPalette ; |
775 | } | 774 | } |
776 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 775 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
777 | item->setPalette( pal ); | 776 | item->setPalette( pal ); |
778 | item->setRecur( event->recurrence()->doesRecur() ); | 777 | item->setRecur( event->recurrence()->doesRecur() ); |
779 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); | 778 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); |
780 | item->setMoreInfo( event->description().length() > 0 ); | 779 | item->setMoreInfo( event->description().length() > 0 ); |
781 | #ifdef DESKTOP_VERSION | 780 | #ifdef DESKTOP_VERSION |
782 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 781 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
783 | KOPrefs::instance()->email()); | 782 | KOPrefs::instance()->email()); |
784 | if ( me != 0 ) { | 783 | if ( me != 0 ) { |
785 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 784 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
786 | item->setReply(true && multiday < 2); | 785 | item->setReply(true && multiday < 2); |
787 | else | 786 | else |
788 | item->setReply(false); | 787 | item->setReply(false); |
789 | } else | 788 | } else |
790 | item->setReply(false); | 789 | item->setReply(false); |
791 | #endif | 790 | #endif |
792 | 791 | ||
793 | item->setMultiDay( multiday ); | 792 | item->setMultiDay( multiday ); |
794 | if ( multiday ) { | 793 | if ( multiday ) { |
795 | insertItem( item ,mdayCount); | 794 | insertItem( item ,mdayCount); |
796 | ++mdayCount; | 795 | ++mdayCount; |
797 | } else { | 796 | } else { |
798 | uint i = mdayCount; | 797 | uint i = mdayCount; |
799 | uint pos = mdayCount; | 798 | uint pos = mdayCount; |
800 | uint itcount = count(); | 799 | uint itcount = count(); |
801 | if ( itcount > 1000 ) { | 800 | if ( itcount > 1000 ) { |
802 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); | 801 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); |
803 | itcount = 0; | 802 | itcount = 0; |
804 | } | 803 | } |
805 | for ( i = pos; i < itcount;++i ) { | 804 | for ( i = pos; i < itcount;++i ) { |
806 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); | 805 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); |
807 | QListBoxItem* it = this->item ( i ); | 806 | QListBoxItem* it = this->item ( i ); |
808 | if ( it && text < it->text() ) { | 807 | if ( it && text < it->text() ) { |
809 | pos = i; | 808 | pos = i; |
810 | break; | 809 | break; |
811 | } | 810 | } |
812 | ++pos; | 811 | ++pos; |
813 | } | 812 | } |
814 | insertItem( item ,pos); | 813 | insertItem( item ,pos); |
815 | } | 814 | } |
816 | if ( useToolTips ) { | 815 | if ( useToolTips ) { |
817 | mToolTip.append( mToolTipText ); | 816 | mToolTip.append( mToolTipText ); |
818 | } | 817 | } |
819 | return mdayCount; | 818 | return mdayCount; |
820 | } | 819 | } |
821 | void MonthViewCell::insertTodo(Todo *todo) | 820 | void MonthViewCell::insertTodo(Todo *todo) |
822 | { | 821 | { |
823 | setFocusPolicy(WheelFocus); | 822 | setFocusPolicy(WheelFocus); |
824 | QString text; | 823 | QString text; |
825 | if (todo->hasDueDate()) { | 824 | if (todo->hasDueDate()) { |
826 | if (!todo->doesFloat()) { | 825 | if (!todo->doesFloat()) { |
827 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 826 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
828 | text += " "; | 827 | text += " "; |
829 | } | 828 | } |
830 | } | 829 | } |
831 | text += todo->summary(); | 830 | text += todo->summary(); |
832 | MonthViewItem *item ; | 831 | MonthViewItem *item ; |
833 | if ( mAvailItemList.count() ) { | 832 | if ( mAvailItemList.count() ) { |
834 | item = mAvailItemList.first(); | 833 | item = mAvailItemList.first(); |
835 | mAvailItemList.remove( item ); | 834 | mAvailItemList.remove( item ); |
836 | item->recycle( todo, text ); | 835 | item->recycle( todo, text ); |
837 | } else { | 836 | } else { |
838 | item = new MonthViewItem( todo, text ); | 837 | item = new MonthViewItem( todo, text ); |
839 | } | 838 | } |
840 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 839 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
841 | //item->setPalette( mStandardPalette ); | 840 | //item->setPalette( mStandardPalette ); |
842 | QPalette pal; | 841 | QPalette pal; |
843 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 842 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
844 | QStringList categories = todo->categories(); | 843 | QStringList categories = todo->categories(); |
845 | QString cat = categories.first(); | 844 | QString cat = categories.first(); |
846 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 845 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
847 | pal = getPalette(); | 846 | pal = getPalette(); |
848 | if (cat.isEmpty()) { | 847 | if (cat.isEmpty()) { |
849 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 848 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
850 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); | 849 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); |
851 | } else { | 850 | } else { |
852 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 851 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
853 | } | 852 | } |
854 | 853 | ||
855 | } else { | 854 | } else { |
856 | if (cat.isEmpty()) { | 855 | if (cat.isEmpty()) { |
857 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 856 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
858 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); | 857 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); |
859 | } else { | 858 | } else { |
860 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 859 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
861 | } | 860 | } |
862 | } | 861 | } |
863 | 862 | ||
864 | } else { | 863 | } else { |
865 | pal = mStandardPalette ; | 864 | pal = mStandardPalette ; |
866 | } | 865 | } |
867 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 866 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
868 | item->setPalette( pal ); | 867 | item->setPalette( pal ); |
869 | item->setRecur( todo->recurrence()->doesRecur() ); | 868 | item->setRecur( todo->recurrence()->doesRecur() ); |
870 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); | 869 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); |
871 | item->setMoreInfo( todo->description().length() > 0 ); | 870 | item->setMoreInfo( todo->description().length() > 0 ); |
872 | insertItem( item , count()); | 871 | insertItem( item , count()); |
873 | #ifdef DESKTOP_VERSION | 872 | #ifdef DESKTOP_VERSION |
874 | mToolTip.append( text ); | 873 | mToolTip.append( text ); |
875 | #endif | 874 | #endif |
876 | } | 875 | } |
877 | void MonthViewCell::repaintfinishUpdateCell() | 876 | void MonthViewCell::repaintfinishUpdateCell() |
878 | { | 877 | { |
879 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 878 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
880 | while ( mitem ) { | 879 | while ( mitem ) { |
881 | mitem->setBlockRepaint( false ); | 880 | mitem->setBlockRepaint( false ); |
882 | updateItem ( mitem ); | 881 | updateItem ( mitem ); |
883 | mitem = (MonthViewItem *)mitem->next(); | 882 | mitem = (MonthViewItem *)mitem->next(); |
884 | } | 883 | } |
885 | } | 884 | } |
886 | void MonthViewCell::finishUpdateCell() | 885 | void MonthViewCell::finishUpdateCell() |
887 | { | 886 | { |
888 | 887 | ||
889 | 888 | ||
890 | 889 | ||
891 | #ifdef DESKTOP_VERSION | 890 | #ifdef DESKTOP_VERSION |
892 | if (mToolTip.count() > 0 ) { | 891 | if (mToolTip.count() > 0 ) { |
893 | mToolTip.sort(); | 892 | mToolTip.sort(); |
894 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 893 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
895 | } | 894 | } |
896 | #endif | 895 | #endif |
897 | //sort(); | 896 | //sort(); |
898 | //setMyPalette(); | 897 | //setMyPalette(); |
899 | setMyPalette(); | 898 | setMyPalette(); |
900 | 899 | ||
901 | resizeEvent( 0 ); | 900 | resizeEvent( 0 ); |
902 | 901 | ||
903 | } | 902 | } |
904 | void MonthViewCell::updateCell() | 903 | void MonthViewCell::updateCell() |
905 | { | 904 | { |
906 | if ( !mMonthView->isUpdatePossible() ) | 905 | if ( !mMonthView->isUpdatePossible() ) |
907 | return; | 906 | return; |
908 | startUpdateCell(); | 907 | startUpdateCell(); |
909 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 908 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
910 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 909 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
911 | Event *event; | 910 | Event *event; |
912 | for( event = events.first(); event; event = events.next() ) { // for event | 911 | for( event = events.first(); event; event = events.next() ) { // for event |
913 | insertEvent(event); | 912 | insertEvent(event); |
914 | } | 913 | } |
915 | // insert due todos | 914 | // insert due todos |
916 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 915 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
917 | Todo *todo; | 916 | Todo *todo; |
918 | for(todo = todos.first(); todo; todo = todos.next()) { | 917 | for(todo = todos.first(); todo; todo = todos.next()) { |
919 | insertTodo( todo ); | 918 | insertTodo( todo ); |
920 | } | 919 | } |
921 | finishUpdateCell(); | 920 | finishUpdateCell(); |
922 | // if ( isVisible()) | 921 | // if ( isVisible()) |
923 | //qApp->processEvents(); | 922 | //qApp->processEvents(); |
924 | } | 923 | } |
925 | 924 | ||
926 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 925 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
927 | { | 926 | { |
928 | 927 | ||
929 | if ( bigFont ) { | 928 | if ( bigFont ) { |
930 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 929 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
931 | int ps = fo.pointSize() + 2; | 930 | int ps = fo.pointSize() + 2; |
932 | if ( ps < 18 ) | 931 | if ( ps < 18 ) |
933 | ps += 2; | 932 | ps += 2; |
934 | fo.setPointSize( ps ); | 933 | fo.setPointSize( ps ); |
935 | setFont( fo ); | 934 | setFont( fo ); |
936 | } else | 935 | } else |
937 | setFont( KOPrefs::instance()->mMonthViewFont ); | 936 | setFont( KOPrefs::instance()->mMonthViewFont ); |
938 | 937 | ||
939 | QFontMetrics fm( font() ); | 938 | QFontMetrics fm( font() ); |
940 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 939 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
941 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 940 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
942 | mHolidayPalette = mStandardPalette; | 941 | mHolidayPalette = mStandardPalette; |
943 | mPrimaryPalette = mStandardPalette; | 942 | mPrimaryPalette = mStandardPalette; |
944 | mNonPrimaryPalette = mStandardPalette; | 943 | mNonPrimaryPalette = mStandardPalette; |
945 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 944 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
946 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 945 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
947 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 946 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
948 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 947 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
949 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 948 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
950 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 949 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
951 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 950 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
952 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 951 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
953 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 952 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
954 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 953 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
955 | } | 954 | } |
956 | //updateCell(); | 955 | //updateCell(); |
957 | } | 956 | } |
958 | 957 | ||
959 | void MonthViewCell::enableScrollBars( bool enabled ) | 958 | void MonthViewCell::enableScrollBars( bool enabled ) |
960 | { | 959 | { |
961 | 960 | ||
962 | return; | 961 | return; |
963 | if ( enabled ) { | 962 | if ( enabled ) { |
964 | QListBoxItem *fi = firstItem (); | 963 | QListBoxItem *fi = firstItem (); |
965 | if (fi ) { | 964 | if (fi ) { |
966 | int ihei = fi->height( this ); | 965 | int ihei = fi->height( this ); |
967 | int hei = numRows () * ihei; | 966 | int hei = numRows () * ihei; |
968 | if ( hei < height() - horizontalScrollBar()->height () ) { | 967 | if ( hei < height() - horizontalScrollBar()->height () ) { |
969 | setVScrollBarMode(QScrollView::AlwaysOff); | 968 | setVScrollBarMode(QScrollView::AlwaysOff); |
970 | } | 969 | } |
971 | else | 970 | else |
972 | setVScrollBarMode(QScrollView::Auto); | 971 | setVScrollBarMode(QScrollView::Auto); |
973 | if ( ihei *3 > height() ) { | 972 | if ( ihei *3 > height() ) { |
974 | setHScrollBarMode(QScrollView::AlwaysOff); | 973 | setHScrollBarMode(QScrollView::AlwaysOff); |
975 | } | 974 | } |
976 | else { | 975 | else { |
977 | setHScrollBarMode(QScrollView::Auto); | 976 | setHScrollBarMode(QScrollView::Auto); |
978 | } | 977 | } |
979 | } else { | 978 | } else { |
980 | setVScrollBarMode(QScrollView::Auto); | 979 | setVScrollBarMode(QScrollView::Auto); |
981 | setHScrollBarMode(QScrollView::Auto); | 980 | setHScrollBarMode(QScrollView::Auto); |
982 | } | 981 | } |
983 | } else { | 982 | } else { |
984 | setVScrollBarMode(QScrollView::AlwaysOff); | 983 | setVScrollBarMode(QScrollView::AlwaysOff); |
985 | setHScrollBarMode(QScrollView::AlwaysOff); | 984 | setHScrollBarMode(QScrollView::AlwaysOff); |
986 | } | 985 | } |
987 | } | 986 | } |
988 | 987 | ||
989 | Incidence *MonthViewCell::selectedIncidence() | 988 | Incidence *MonthViewCell::selectedIncidence() |
990 | { | 989 | { |
991 | int index = currentItem(); | 990 | int index = currentItem(); |
992 | if ( index < 0 ) return 0; | 991 | if ( index < 0 ) return 0; |
993 | 992 | ||
994 | MonthViewItem *mitem = | 993 | MonthViewItem *mitem = |
995 | static_cast<MonthViewItem *>( item( index ) ); | 994 | static_cast<MonthViewItem *>( item( index ) ); |
996 | 995 | ||
997 | if ( !mitem ) return 0; | 996 | if ( !mitem ) return 0; |
998 | 997 | ||
999 | return mitem->incidence(); | 998 | return mitem->incidence(); |
1000 | } | 999 | } |
1001 | 1000 | ||
1002 | QDate MonthViewCell::selectedIncidenceDate() | 1001 | QDate MonthViewCell::selectedIncidenceDate() |
1003 | { | 1002 | { |
1004 | QDate qd; | 1003 | QDate qd; |
1005 | int index = currentItem(); | 1004 | int index = currentItem(); |
1006 | if ( index < 0 ) return qd; | 1005 | if ( index < 0 ) return qd; |
1007 | return mDate; | 1006 | return mDate; |
1008 | } | 1007 | } |
1009 | 1008 | ||
1010 | void MonthViewCell::deselect() | 1009 | void MonthViewCell::deselect() |
1011 | { | 1010 | { |
1012 | clearSelection(); | 1011 | clearSelection(); |
1013 | enableScrollBars( false ); | 1012 | enableScrollBars( false ); |
1014 | // updateCell(); | 1013 | // updateCell(); |
1015 | } | 1014 | } |
1016 | void MonthViewCell::select() | 1015 | void MonthViewCell::select() |
1017 | { | 1016 | { |
1018 | ;// updateCell(); | 1017 | ;// updateCell(); |
1019 | } | 1018 | } |
1020 | 1019 | ||
1021 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 1020 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
1022 | { | 1021 | { |
1023 | if ( !mMonthView->isUpdatePossible() ) | 1022 | if ( !mMonthView->isUpdatePossible() ) |
1024 | return; | 1023 | return; |
1025 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 1024 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
1026 | deselect(); | 1025 | deselect(); |
1027 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 1026 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
1028 | 1027 | ||
1029 | QString text; | 1028 | QString text; |
1030 | mLabel->setText( text ); | 1029 | mLabel->setText( text ); |
1031 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 1030 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
1032 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 1031 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
1033 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 1032 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
1034 | mLabel->resize( mLabelBigSize ); | 1033 | mLabel->resize( mLabelBigSize ); |
1035 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 1034 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
1036 | } else { | 1035 | } else { |
1037 | mLabel->resize( mLabelSize ); | 1036 | mLabel->resize( mLabelSize ); |
1038 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 1037 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
1039 | } | 1038 | } |
1040 | mLabel->setText( text ); | 1039 | mLabel->setText( text ); |
1041 | 1040 | ||
1042 | int size = height() - mLabel->height() - lineWidth()-1; | 1041 | int size = height() - mLabel->height() - lineWidth()-1; |
1043 | //qDebug("LW %d ", lineWidth()); | 1042 | //qDebug("LW %d ", lineWidth()); |
1044 | if ( size > 0 ) | 1043 | if ( size > 0 ) |
1045 | verticalScrollBar()->setMaximumHeight( size ); | 1044 | verticalScrollBar()->setMaximumHeight( size ); |
1046 | size = width() - mLabel->width() -lineWidth()-1; | 1045 | size = width() - mLabel->width() -lineWidth()-1; |
1047 | if ( size > 0 ) | 1046 | if ( size > 0 ) |
1048 | horizontalScrollBar()->setMaximumWidth( size ); | 1047 | horizontalScrollBar()->setMaximumWidth( size ); |
1049 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1048 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1050 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1049 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1051 | // mItemList->resize ( width(), height () ); | 1050 | // mItemList->resize ( width(), height () ); |
1052 | if ( e ) | 1051 | if ( e ) |
1053 | KNoScrollListBox::resizeEvent ( e ); | 1052 | KNoScrollListBox::resizeEvent ( e ); |
1054 | } | 1053 | } |
1055 | 1054 | ||
1056 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1055 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
1057 | { | 1056 | { |
1058 | 1057 | ||
1059 | if ( !item ) { | 1058 | if ( !item ) { |
1060 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1059 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1061 | emit newEventSignal( dt ); | 1060 | emit newEventSignal( dt ); |
1062 | return; | 1061 | return; |
1063 | } | 1062 | } |
1064 | 1063 | ||
1065 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1064 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1066 | Incidence *incidence = eventItem->incidence(); | 1065 | Incidence *incidence = eventItem->incidence(); |
1067 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1066 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1068 | } | 1067 | } |
1069 | void MonthViewCell::showDay() | 1068 | void MonthViewCell::showDay() |
1070 | { | 1069 | { |
1071 | emit showDaySignal( date() ); | 1070 | emit showDaySignal( date() ); |
1072 | } | 1071 | } |
1073 | void MonthViewCell::newEvent() | 1072 | void MonthViewCell::newEvent() |
1074 | { | 1073 | { |
1075 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1074 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1076 | emit newEventSignal( dt ); | 1075 | emit newEventSignal( dt ); |
1077 | } | 1076 | } |
1078 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1077 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
1079 | { | 1078 | { |
1080 | mMonthView->setSelectedCell( this ); | 1079 | mMonthView->setSelectedCell( this ); |
1081 | if ( item == 0 ) { | 1080 | if ( item == 0 ) { |
1082 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1081 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1083 | emit newEventSignal( dt ); | 1082 | emit newEventSignal( dt ); |
1084 | return; | 1083 | return; |
1085 | } | 1084 | } |
1086 | 1085 | ||
1087 | } | 1086 | } |
1088 | 1087 | ||
1089 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1088 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1090 | { | 1089 | { |
1091 | mMonthView->setPopupCell( this ); | 1090 | mMonthView->setPopupCell( this ); |
1092 | if ( !item ) { | 1091 | if ( !item ) { |
1093 | mMonthView->showContextMenu( 0 ); | 1092 | mMonthView->showContextMenu( 0 ); |
1094 | return; | 1093 | return; |
1095 | } | 1094 | } |
1096 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1095 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1097 | Incidence *incidence = eventItem->incidence(); | 1096 | Incidence *incidence = eventItem->incidence(); |
1098 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1097 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
1099 | } | 1098 | } |
1100 | 1099 | ||
1101 | void MonthViewCell::selection( QListBoxItem *item ) | 1100 | void MonthViewCell::selection( QListBoxItem *item ) |
1102 | { | 1101 | { |
1103 | if ( !item ) { | 1102 | if ( !item ) { |
1104 | emit highligtIncidence( 0 , this, 0 ); | 1103 | emit highligtIncidence( 0 , this, 0 ); |
1105 | return; | 1104 | return; |
1106 | } | 1105 | } |
1107 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); | 1106 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); |
1108 | emit highligtIncidence( it->incidence(), this, it->multiDay() ); | 1107 | emit highligtIncidence( it->incidence(), this, it->multiDay() ); |
1109 | mMonthView->setSelectedCell( this ); | 1108 | mMonthView->setSelectedCell( this ); |