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