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