summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-27 19:29:38 (UTC)
committer zautrix <zautrix>2005-06-27 19:29:38 (UTC)
commitd730e4b5cd81965f224b69efcc91dd58253f0b98 (patch) (unidiff)
tree38874ec3d889bee7ab12a79a1ef690e6c47aac5f
parent427221638f1e652bd57a37835a1de0134266c3f7 (diff)
downloadkdepimpi-d730e4b5cd81965f224b69efcc91dd58253f0b98.zip
kdepimpi-d730e4b5cd81965f224b69efcc91dd58253f0b98.tar.gz
kdepimpi-d730e4b5cd81965f224b69efcc91dd58253f0b98.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp57
-rw-r--r--korganizer/komonthview.h6
2 files changed, 18 insertions, 45 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 00e5a6f..aeb3974 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1416 +1,1391 @@
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
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
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
68protected: 68protected:
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 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::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}
90KNoScrollListBox::~KNoScrollListBox() 90KNoScrollListBox::~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
100void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 100void 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}
136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
137{ 137{
138 int i = currentItem (); 138 int i = currentItem ();
139 if ( i >= 0 ) { 139 if ( i >= 0 ) {
140 setSelected ( i, false ); 140 setSelected ( i, false );
141 } 141 }
142 QListBox::focusOutEvent ( e ); 142 QListBox::focusOutEvent ( e );
143 setVScrollBarMode(QScrollView::AlwaysOff); 143 setVScrollBarMode(QScrollView::AlwaysOff);
144 setHScrollBarMode(QScrollView::AlwaysOff); 144 setHScrollBarMode(QScrollView::AlwaysOff);
145 emit highligtIncidence( 0, (MonthViewCell*)this, 0 ); 145 emit highligtIncidence( 0, (MonthViewCell*)this, 0 );
146} 146}
147 147
148QString KNoScrollListBox::getWhatsThisText(QPoint p) 148QString KNoScrollListBox::getWhatsThisText(QPoint p)
149{ 149{
150 QListBoxItem* item = itemAt ( p ); 150 QListBoxItem* item = itemAt ( p );
151 if ( ! item ) { 151 if ( ! item ) {
152 return i18n("Click in the cell\nto add an event!"); 152 return i18n("Click in the cell\nto add an event!");
153 } 153 }
154 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 154 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
155 KOPrefs::instance()->mWTshowDetails, 155 KOPrefs::instance()->mWTshowDetails,
156 KOPrefs::instance()->mWTshowCreated, 156 KOPrefs::instance()->mWTshowCreated,
157 KOPrefs::instance()->mWTshowChanged); 157 KOPrefs::instance()->mWTshowChanged);
158} 158}
159void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 159void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
160{ 160{
161 //qDebug("KNoScrollListBox::keyPressEvent "); 161 //qDebug("KNoScrollListBox::keyPressEvent ");
162 switch(e->key()) { 162 switch(e->key()) {
163 case Key_Right: 163 case Key_Right:
164 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 164 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
165 { 165 {
166 e->ignore(); 166 e->ignore();
167 return; 167 return;
168 } 168 }
169 scrollBy(10,0); 169 scrollBy(10,0);
170 break; 170 break;
171 case Key_Left: 171 case Key_Left:
172 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 172 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
173 { 173 {
174 e->ignore(); 174 e->ignore();
175 return; 175 return;
176 } 176 }
177 scrollBy(-10,0); 177 scrollBy(-10,0);
178 break; 178 break;
179 case Key_Up: 179 case Key_Up:
180 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 180 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
181 e->ignore(); 181 e->ignore();
182 break; 182 break;
183 } 183 }
184 if ( count() ) { 184 if ( count() ) {
185 if ( currentItem() == 0 ) { 185 if ( currentItem() == 0 ) {
186 emit prevCell(); 186 emit prevCell();
187 } else { 187 } else {
188 setCurrentItem((currentItem()+count()-1)%count()); 188 setCurrentItem((currentItem()+count()-1)%count());
189 if(!itemVisible(currentItem())) { 189 if(!itemVisible(currentItem())) {
190 if((unsigned int) currentItem() == (count()-1)) { 190 if((unsigned int) currentItem() == (count()-1)) {
191 setTopItem(currentItem()-numItemsVisible()+1); 191 setTopItem(currentItem()-numItemsVisible()+1);
192 } else { 192 } else {
193 setTopItem(topItem()-1); 193 setTopItem(topItem()-1);
194 } 194 }
195 } 195 }
196 } 196 }
197 } 197 }
198 break; 198 break;
199 case Key_Down: 199 case Key_Down:
200 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 200 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
201 e->ignore(); 201 e->ignore();
202 break; 202 break;
203 } 203 }
204 if ( count () ) { 204 if ( count () ) {
205 if ( currentItem()+1 == count () ) { 205 if ( currentItem()+1 == count () ) {
206 emit nextCell(); 206 emit nextCell();
207 } else { 207 } else {
208 setCurrentItem((currentItem()+1)%count()); 208 setCurrentItem((currentItem()+1)%count());
209 if(!itemVisible(currentItem())) { 209 if(!itemVisible(currentItem())) {
210 if(currentItem() == 0) { 210 if(currentItem() == 0) {
211 setTopItem(0); 211 setTopItem(0);
212 } else { 212 } else {
213 setTopItem(topItem()+1); 213 setTopItem(topItem()+1);
214 } 214 }
215 } 215 }
216 } 216 }
217 } 217 }
218 break; 218 break;
219 case Key_I: 219 case Key_I:
220 QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 220 QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
221 e->ignore(); 221 e->ignore();
222 break; 222 break;
223 case Key_Return: 223 case Key_Return:
224 case Key_Enter: 224 case Key_Enter:
225 { 225 {
226 if ( currentItem() >= 0 ) { 226 if ( currentItem() >= 0 ) {
227 emit doubleClicked( item( currentItem() ) ); 227 emit doubleClicked( item( currentItem() ) );
228 e->accept(); 228 e->accept();
229 } else { 229 } else {
230 e->ignore(); 230 e->ignore();
231 } 231 }
232 } 232 }
233 break; 233 break;
234 case Key_Shift: 234 case Key_Shift:
235 emit shiftDown(); 235 emit shiftDown();
236 break; 236 break;
237 default: 237 default:
238 e->ignore(); 238 e->ignore();
239 break; 239 break;
240 } 240 }
241} 241}
242 242
243void KNoScrollListBox::oneDown() 243void KNoScrollListBox::oneDown()
244{ 244{
245 if ( count () ) { 245 if ( count () ) {
246 if ( currentItem()+1 == count () ) { 246 if ( currentItem()+1 == count () ) {
247 emit nextCell(); 247 emit nextCell();
248 } else { 248 } else {
249 resetOnFocusIn = false; 249 resetOnFocusIn = false;
250 setCurrentItem((currentItem()+1)%count()); 250 setCurrentItem((currentItem()+1)%count());
251 if(!itemVisible(currentItem())) { 251 if(!itemVisible(currentItem())) {
252 if(currentItem() == 0) { 252 if(currentItem() == 0) {
253 setTopItem(0); 253 setTopItem(0);
254 } else { 254 } else {
255 setTopItem(topItem()+1); 255 setTopItem(topItem()+1);
256 } 256 }
257 } 257 }
258 } 258 }
259 } 259 }
260} 260}
261void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 261void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
262{ 262{
263 switch(e->key()) { 263 switch(e->key()) {
264 case Key_Shift: 264 case Key_Shift:
265 emit shiftUp(); 265 emit shiftUp();
266 break; 266 break;
267 default: 267 default:
268 break; 268 break;
269 } 269 }
270} 270}
271 271
272void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 272void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
273{ 273{
274 QListBox::mousePressEvent(e); 274 QListBox::mousePressEvent(e);
275 275
276 if(e->button() == RightButton) { 276 if(e->button() == RightButton) {
277 emit rightClick(); 277 emit rightClick();
278 } 278 }
279} 279}
280 280
281MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 281MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s)
282 : QListBoxItem() 282 : QListBoxItem()
283{ 283{
284 mDisplayHightlighted = false;
285 mblockRepaint = true; 284 mblockRepaint = true;
286 setText( s );
287 mMultiday = 0;
288 mIncidence = incidence;
289 mDate = qd;
290 mRecur = false;
291 mAlarm = false;
292 mReply = false;
293 mInfo = false;
294 mdayPos = 0;
295 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 285 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
286 recycle( incidence, s );
296} 287}
297void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 288void MonthViewItem::recycle( Incidence *incidence, const QString & s)
298{ 289{
299 mDisplayHightlighted = false; 290 mDisplayHightlighted = false;
300 setText( s ); 291 setText( s );
301 mMultiday = 0; 292 mMultiday = 0;
302 mIncidence = incidence; 293 mIncidence = incidence;
303 mDate = qd;
304 mRecur = false;
305 mAlarm = false;
306 mReply = false;
307 mInfo = false;
308 mdayPos = 0;
309}
310void MonthViewItem::clearData()
311{
312 mDisplayHightlighted = false;
313 setText( "" );
314 mMultiday = 0;
315 mIncidence = 0;
316 mRecur = false; 294 mRecur = false;
317 mAlarm = false; 295 mAlarm = false;
318 mReply = false; 296 mReply = false;
319 mInfo = false; 297 mInfo = false;
320 mdayPos = 0; 298 mdayPos = 0;
321} 299}
300
322bool MonthViewItem::setHighlightedFalse() 301bool MonthViewItem::setHighlightedFalse()
323{ 302{
324 if ( !mDisplayHightlighted ) 303 if ( !mDisplayHightlighted )
325 return false; 304 return false;
326 mDisplayHightlighted = false; 305 mDisplayHightlighted = false;
327 return true; 306 return true;
328} 307}
329 308
330bool MonthViewItem::setHighlighted( Incidence * inc ) 309bool MonthViewItem::setHighlighted( Incidence * inc )
331{ 310{
332 if ( inc == mIncidence ) { 311 if ( inc == mIncidence ) {
333 if ( mDisplayHightlighted ) 312 if ( mDisplayHightlighted )
334 return false; 313 return false;
335 mDisplayHightlighted = true; 314 mDisplayHightlighted = true;
336 return true; 315 return true;
337 } else { 316 } else {
338 if ( !mDisplayHightlighted ) 317 if ( !mDisplayHightlighted )
339 return false; 318 return false;
340 mDisplayHightlighted = false; 319 mDisplayHightlighted = false;
341 return true; 320 return true;
342 } 321 }
343 return false; 322 return false;
344} 323}
345void MonthViewItem::paint(QPainter *p) 324void MonthViewItem::paint(QPainter *p)
346{ 325{
347 if ( mblockRepaint ) { 326 if ( mblockRepaint || !mIncidence ) {
348 return; 327 return;
349 } 328 }
350#if QT_VERSION >= 0x030000 329#if QT_VERSION >= 0x030000
351 bool sel = isSelected(); 330 bool sel = isSelected();
352#else 331#else
353 bool sel = selected(); 332 bool sel = selected();
354#endif 333#endif
355 int heihei = height( listBox () ); 334 int heihei = height( listBox () );
356 int x = 1; 335 int x = 1;
357 if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted ) 336 if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted || sel )
358 { 337 {
359 if ( mDisplayHightlighted ) 338 if ( mDisplayHightlighted )
360 sel = true; 339 sel = true;
361 p->setBackgroundColor( palette().color( QPalette::Normal, \ 340 p->setBackgroundColor( palette().color( QPalette::Normal, \
362 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 341 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
363 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); 342 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei );
364 } 343 }
365 344
366 //int y = 3;//(height() - mRecurPixmap.height()) /2; 345 //int y = 3;//(height() - mRecurPixmap.height()) /2;
367 int size = PIXMAP_SIZE; 346 int size = PIXMAP_SIZE;
368 if ( QApplication::desktop()->width() < 300 ) 347 if ( QApplication::desktop()->width() < 300 )
369 size = 3; 348 size = 3;
370 int y = (heihei - size -1 ) /2; 349 int y = (heihei - size -1 ) /2;
371 350
372 if ( mIncidence->calID() > 1 ) { 351 if ( mIncidence->calID() > 1 ) {
373 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); 352 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
374 p->drawRect ( x, y-2,size,size+4); 353 p->drawRect ( x, y-2,size,size+4);
375 x += size + 1; 354 x += size + 1;
376 } 355 }
377 if ( KOPrefs::instance()->mMonthShowIcons ) { 356 if ( KOPrefs::instance()->mMonthShowIcons ) {
378 if ( mInfo ) { 357 if ( mInfo ) {
379 p->fillRect ( x, y,size,size, Qt::darkGreen ); 358 p->fillRect ( x, y,size,size, Qt::darkGreen );
380 x += size + 1; 359 x += size + 1;
381 } 360 }
382 if ( mRecur ) { 361 if ( mRecur ) {
383 p->fillRect ( x, y,size,size, Qt::blue ); 362 p->fillRect ( x, y,size,size, Qt::blue );
384 x += size + 1; 363 x += size + 1;
385 } 364 }
386 if ( mAlarm ) { 365 if ( mAlarm ) {
387 p->fillRect ( x, y,size,size, Qt::red ); 366 p->fillRect ( x, y,size,size, Qt::red );
388 x += size + 1; 367 x += size + 1;
389 } 368 }
390 if ( mReply ) { 369 if ( mReply ) {
391 p->fillRect ( x, y,size,size, Qt::yellow ); 370 p->fillRect ( x, y,size,size, Qt::yellow );
392 x += size + 1; 371 x += size + 1;
393 } 372 }
394 } 373 }
395 if ( mMultiday ) { 374 if ( mMultiday ) {
396 int yyy = y+(size/2); 375 int yyy = y+(size/2);
397 int sizeM = size+2; 376 int sizeM = size+2;
398 p->setBrush( QBrush::SolidPattern ); 377 p->setBrush( QBrush( p->pen().color() ) );
399 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 378 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
400 if ( mMultiday == 2 || mMultiday == 3 ) { 379 if ( mMultiday == 2 || mMultiday == 3 ) {
401 QPointArray pa ( 3 ); 380 QPointArray pa ( 3 );
402 pa.setPoint (0, x, yyy ); 381 pa.setPoint (0, x, yyy );
403 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 382 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
404 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 383 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
405 p->drawPolygon( pa ); 384 p->drawPolygon( pa );
406 } 385 }
407 if ( mMultiday == 2 || mMultiday == 1 ) { 386 if ( mMultiday == 2 || mMultiday == 1 ) {
408 QPointArray pa ( 3 ); 387 QPointArray pa ( 3 );
409 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 388 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
410 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 389 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
411 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 390 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
412 p->drawPolygon( pa ); 391 p->drawPolygon( pa );
413 } 392 }
414 if ( mMultiday == 1 ) { 393 if ( mMultiday == 1 ) {
415 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 394 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
416 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 395 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
417 } 396 }
418 if ( mMultiday == 3 ) { 397 if ( mMultiday == 3 ) {
419 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 398 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
420 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 399 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
421 400
422 } 401 }
423 x += sizeM/2 + 1; 402 x += sizeM/2 + 1;
424 x += sizeM + 1; 403 x += sizeM + 1;
425 } 404 }
426 405
427 if ( mIncidence->typeID() == todoID ){ 406 if ( mIncidence->typeID() == todoID ){
428 Todo* td = ( Todo* ) mIncidence; 407 Todo* td = ( Todo* ) mIncidence;
429 if ( td->isCompleted() ) { 408 if ( td->isCompleted() ) {
430 int half = size/2; 409 int half = size/2;
431 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 410 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
432 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 411 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
433 x += half+half + 4; 412 x += half+half + 4;
434 413
435 } else { 414 } else {
436 int val = td->percentComplete()/20; 415 int val = td->percentComplete()/20;
437 p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); 416 p->fillRect ( x+1, y-2, val ,size+4,p->pen().color() );
438 p->drawRect ( x, y-2,7,size+4); 417 p->drawRect ( x, y-2,7,size+4);
439 x += size + 3; 418 x += size + 3;
440 } 419 }
441 } 420 }
442 QFontMetrics fm = p->fontMetrics(); 421 QFontMetrics fm = p->fontMetrics();
443 int yPos; 422 int yPos;
444 int pmheight = size; 423 int pmheight = size;
445 if( pmheight < fm.height() ) 424 if( pmheight < fm.height() )
446 yPos = fm.ascent() + fm.leading()/2; 425 yPos = fm.ascent() + fm.leading()/2;
447 else 426 else
448 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 427 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
449 p->setPen( palette().color( QPalette::Normal, sel ? \ 428 p->setPen( palette().color( QPalette::Normal, sel ? \
450 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 429 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
451 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { 430 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
452 p->drawText( x, yPos, text() ); 431 p->drawText( x, yPos, text() );
453 if ( mIncidence->cancelled() ) { 432 if ( mIncidence->cancelled() ) {
454 int wid = fm.width( text() ); 433 int wid = fm.width( text() );
455 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 434 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
456 } 435 }
457 } else { 436 } else {
458 QString pText = text(); 437 QString pText = text();
459 if( pText.mid(2,1) == ":" ) 438 if( pText.mid(2,1) == ":" )
460 pText = pText.mid( 6 ); 439 pText = pText.mid( 6 );
461 p->drawText( x, yPos, pText ); 440 p->drawText( x, yPos, pText );
462 if ( mIncidence->cancelled() ) { 441 if ( mIncidence->cancelled() ) {
463 int wid = fm.width( pText ); 442 int wid = fm.width( pText );
464 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 443 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
465 } 444 }
466 } 445 }
467} 446}
468 447
469int MonthViewItem::height(const QListBox *lb) const 448int MonthViewItem::height(const QListBox *lb) const
470{ 449{
471 int ret = 10; 450 int ret = 10;
472 if ( lb ) 451 if ( lb )
473 ret = lb->fontMetrics().lineSpacing()+1; 452 ret = lb->fontMetrics().lineSpacing()+1;
474 return ret; 453 return ret;
475} 454}
476 455
477int MonthViewItem::width(const QListBox *lb) const 456int MonthViewItem::width(const QListBox *lb) const
478{ 457{
479 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 458 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
480 int size = PIXMAP_SIZE; 459 int size = PIXMAP_SIZE;
481 if ( QApplication::desktop()->width() < 300 ) 460 if ( QApplication::desktop()->width() < 300 )
482 size = 3; 461 size = 3;
483 int x = 1; 462 int x = 1;
484 if ( KOPrefs::instance()->mMonthShowIcons ) { 463 if ( KOPrefs::instance()->mMonthShowIcons ) {
485 if ( mInfo ) { 464 if ( mInfo ) {
486 x += size + 1; 465 x += size + 1;
487 } 466 }
488 if( mRecur ) { 467 if( mRecur ) {
489 x += size+1; 468 x += size+1;
490 } 469 }
491 if( mAlarm ) { 470 if( mAlarm ) {
492 x += size+1; 471 x += size+1;
493 } 472 }
494 if( mReply ) { 473 if( mReply ) {
495 x += size+1; 474 x += size+1;
496 } 475 }
497 } 476 }
498 if( mMultiday ) { 477 if( mMultiday ) {
499 x += size+1+2+size/2; 478 x += size+1+2+size/2;
500 } 479 }
501 return( x + lb->fontMetrics().width( text() ) + 1 ); 480 return( x + lb->fontMetrics().width( text() ) + 1 );
502 } 481 }
503 if ( ! lb ) 482 if ( ! lb )
504 return 10; 483 return 10;
505 return lb->width(); 484 return lb->width();
506} 485}
507 486
508 487
509MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 488MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
510 : KNoScrollListBox( par ), 489 : KNoScrollListBox( par ),
511 mMonthView( parent ) 490 mMonthView( parent )
512{ 491{
513 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 492 //QVBoxLayout *topLayout = new QVBoxLayout( this );
514 currentPalette = 0; 493 currentPalette = 0;
515 // mLabel = new QLabel( this );QPushButton 494 // mLabel = new QLabel( this );QPushButton
516 mLabel = new QPushButton( this ); 495 mLabel = new QPushButton( this );
517 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 496 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
518 //mLabel->setLineWidth( 1 ); 497 //mLabel->setLineWidth( 1 );
519 //mLabel->setAlignment( AlignCenter ); 498 //mLabel->setAlignment( AlignCenter );
520 mLabel->setFlat( true ); 499 mLabel->setFlat( true );
521 mLabel->setFocusPolicy(NoFocus); 500 mLabel->setFocusPolicy(NoFocus);
522 //mItemList = new KNoScrollListBox( this ); 501 //mItemList = new KNoScrollListBox( this );
523 setMinimumSize( 10, 10 ); 502 setMinimumSize( 10, 10 );
524 setFrameStyle( QFrame::Panel | QFrame::Plain ); 503 setFrameStyle( QFrame::Panel | QFrame::Plain );
525 setLineWidth( 1 ); 504 setLineWidth( 1 );
526 //topLayout->addWidget( mItemList ); 505 //topLayout->addWidget( mItemList );
527 mLabel->raise(); 506 mLabel->raise();
528 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 507 // QColor( 0,0,255 ) QColor( 160,1600,255 )
529 mStandardPalette = palette(); 508 mStandardPalette = palette();
530 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 509 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
531 510
532 enableScrollBars( false ); 511 enableScrollBars( false );
533 updateConfig(); 512 updateConfig();
534 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 513 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
535 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 514 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
536 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 515 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
537 SLOT( defaultAction( QListBoxItem * ) ) ); 516 SLOT( defaultAction( QListBoxItem * ) ) );
538 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 517 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
539 const QPoint &) ), 518 const QPoint &) ),
540 SLOT( contextMenu( QListBoxItem * ) ) ); 519 SLOT( contextMenu( QListBoxItem * ) ) );
541 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 520 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
542 SLOT( selection( QListBoxItem * ) ) ); 521 SLOT( selection( QListBoxItem * ) ) );
543 522
544 /* 523 /*
545 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 524 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
546 SLOT( selection( QListBoxItem * ) ) ); 525 SLOT( selection( QListBoxItem * ) ) );
547 */ 526 */
548} 527}
549#ifdef DESKTOP_VERSION 528#ifdef DESKTOP_VERSION
550QToolTipGroup *MonthViewCell::toolTipGroup() 529QToolTipGroup *MonthViewCell::toolTipGroup()
551{ 530{
552 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 531 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
553 return mToolTipGroup; 532 return mToolTipGroup;
554} 533}
555#endif 534#endif
556 535
557void MonthViewCell::setDate( const QDate &date ) 536void MonthViewCell::setDate( const QDate &date )
558{ 537{
559 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 538 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
560 mDate = date; 539 mDate = date;
561 540
562 541
563 542
564 //resizeEvent( 0 ); 543 //resizeEvent( 0 );
565} 544}
566 545
567QDate MonthViewCell::date() const 546QDate MonthViewCell::date() const
568{ 547{
569 return mDate; 548 return mDate;
570} 549}
571 550
572void MonthViewCell::setPrimary( bool primary ) 551void MonthViewCell::setPrimary( bool primary )
573{ 552{
574 mPrimary = primary; 553 mPrimary = primary;
575 //setMyPalette(); 554 //setMyPalette();
576} 555}
577void MonthViewCell::setMyPalette() 556void MonthViewCell::setMyPalette()
578{ 557{
579 558
580 if ( mHoliday) { 559 if ( mHoliday) {
581 if ( currentPalette == 1 ) return; 560 if ( currentPalette == 1 ) return;
582 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 561 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
583 setPalette( mHolidayPalette ); 562 setPalette( mHolidayPalette );
584 //mLabel->setPalette( mHolidayPalette ); 563 //mLabel->setPalette( mHolidayPalette );
585 currentPalette = 1; 564 currentPalette = 1;
586 565
587 } else { 566 } else {
588 if ( mPrimary ) { 567 if ( mPrimary ) {
589 if ( currentPalette == 2 ) return; 568 if ( currentPalette == 2 ) return;
590 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 569 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
591 //mLabel->setPalette( mPrimaryPalette ); 570 //mLabel->setPalette( mPrimaryPalette );
592 setPalette( mPrimaryPalette ); 571 setPalette( mPrimaryPalette );
593 currentPalette = 2; 572 currentPalette = 2;
594 573
595 } else { 574 } else {
596 if ( currentPalette == 3 ) return; 575 if ( currentPalette == 3 ) return;
597 setPalette( mNonPrimaryPalette ); 576 setPalette( mNonPrimaryPalette );
598 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 577 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
599 //mLabel->setPalette( mNonPrimaryPalette );; 578 //mLabel->setPalette( mNonPrimaryPalette );;
600 currentPalette = 3; 579 currentPalette = 3;
601 } 580 }
602 } 581 }
603 //QPalette pal = palette(); 582 //QPalette pal = palette();
604 583
605 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 584 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
606} 585}
607QPalette MonthViewCell::getPalette () 586QPalette MonthViewCell::getPalette ()
608{ 587{
609 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 588 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
610 return mStandardPalette; 589 return mStandardPalette;
611 if ( mHoliday) { 590 if ( mHoliday) {
612 return mHolidayPalette ; 591 return mHolidayPalette ;
613 } else { 592 } else {
614 if ( mPrimary ) { 593 if ( mPrimary ) {
615 return mPrimaryPalette ; 594 return mPrimaryPalette ;
616 } 595 }
617 } 596 }
618 return mNonPrimaryPalette; 597 return mNonPrimaryPalette;
619} 598}
620bool MonthViewCell::isPrimary() const 599bool MonthViewCell::isPrimary() const
621{ 600{
622 return mPrimary; 601 return mPrimary;
623} 602}
624 603
625void MonthViewCell::setHoliday( bool holiday ) 604void MonthViewCell::setHoliday( bool holiday )
626{ 605{
627 mHoliday = holiday; 606 mHoliday = holiday;
628 //setMyPalette(); 607 //setMyPalette();
629} 608}
630 609
631void MonthViewCell::setHoliday( const QString &holiday ) 610void MonthViewCell::setHoliday( const QString &holiday )
632{ 611{
633 mHolidayString = holiday; 612 mHolidayString = holiday;
634 613
635 if ( !holiday.isEmpty() ) { 614 if ( !holiday.isEmpty() ) {
636 setHoliday( true ); 615 setHoliday( true );
637 } 616 }
638} 617}
639 618
640void MonthViewCell::startUpdateCell() 619void MonthViewCell::startUpdateCell()
641{ 620{
642 621
643 mdayCount = 0; 622 mdayCount = 0;
644 setFocusPolicy(NoFocus); 623 setFocusPolicy(NoFocus);
645 if ( !mMonthView->isUpdatePossible() ) 624 if ( !mMonthView->isUpdatePossible() )
646 return; 625 return;
647 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 626 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
648 while ( mitem ) { 627 while ( mitem ) {
649 mitem->setBlockRepaint( true ); 628 mitem->setBlockRepaint( true );
650 mitem = (MonthViewItem *)mitem->next(); 629 mitem = (MonthViewItem *)mitem->next();
651 } 630 }
652 if ( mAvailItemList.count() > 20 ) { 631 if ( mAvailItemList.count() > 20 ) {
653 mAvailItemList.setAutoDelete( true ); 632 mAvailItemList.setAutoDelete( true );
654 mAvailItemList.clear(); 633 mAvailItemList.clear();
655 mAvailItemList.setAutoDelete( false ); 634 mAvailItemList.setAutoDelete( false );
656 clear(); 635 clear();
657 } 636 }
658 637
659 setPrimary( mDate.month()%2 ); 638 setPrimary( mDate.month()%2 );
660 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 639 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
661 if ( mDate == QDate::currentDate() ) { 640 if ( mDate == QDate::currentDate() ) {
662 setLineWidth( 3 ); 641 setLineWidth( 3 );
663 } else { 642 } else {
664 setLineWidth( 1 ); 643 setLineWidth( 1 );
665 } 644 }
666 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 645 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
667 //clear(); 646 //clear();
668 while ( CurrentAvailItem ) { 647 while ( CurrentAvailItem ) {
669 MonthViewItem *item = CurrentAvailItem; 648 MonthViewItem *item = CurrentAvailItem;
670 //item->setHighlightedFalse(); 649 //item->setHighlightedFalse();
671 item->clearData(); 650 item->recycle( 0, "");
672 CurrentAvailItem = (MonthViewItem *)item->next(); 651 CurrentAvailItem = (MonthViewItem *)item->next();
673 mAvailItemList.append( item ); 652 mAvailItemList.append( item );
674 takeItem ( item ); 653 takeItem ( item );
675 } 654 }
676 655
677#ifdef DESKTOP_VERSION 656#ifdef DESKTOP_VERSION
678 QToolTip::remove(this); 657 QToolTip::remove(this);
679#endif 658#endif
680 mToolTip.clear(); 659 mToolTip.clear();
681 //qApp->processEvents(); 660 //qApp->processEvents();
682#if 0 661#if 0
683 if ( !mHolidayString.isEmpty() ) { 662 if ( !mHolidayString.isEmpty() ) {
684 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 663 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
685 item->setPalette( mHolidayPalette ); 664 item->setPalette( mHolidayPalette );
686 insertItem( item ); 665 insertItem( item );
687 mToolTip.append ( mHolidayString ); 666 mToolTip.append ( mHolidayString );
688 } 667 }
689#endif 668#endif
690} 669}
691 670
692int MonthViewCell::insertEvent(Event *event) 671int MonthViewCell::insertEvent(Event *event)
693{ 672{
694 bool useToolTips = true; 673 bool useToolTips = true;
695#ifndef DESKTOP_VERSION 674#ifndef DESKTOP_VERSION
696 useToolTips = false; 675 useToolTips = false;
697#endif 676#endif
698 QString mToolTipText; 677 QString mToolTipText;
699 setFocusPolicy(WheelFocus); 678 setFocusPolicy(WheelFocus);
700 if ( !(event->doesRecur() == Recurrence::rNone) ) { 679 if ( !(event->doesRecur() == Recurrence::rNone) ) {
701 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 680 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
702 return mdayCount; 681 return mdayCount;
703 else 682 else
704 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 683 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
705 return mdayCount; 684 return mdayCount;
706 } 685 }
707 686
708 if ( event->isHoliday()) { 687 if ( event->isHoliday()) {
709 setHoliday( true ); 688 setHoliday( true );
710 if ( mDate.dayOfWeek() == 7 ) 689 if ( mDate.dayOfWeek() == 7 )
711 setLineWidth( 3 ); 690 setLineWidth( 3 );
712 } 691 }
713 QString text; 692 QString text;
714 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 693 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
715 if (event->isMultiDay()) { 694 if (event->isMultiDay()) {
716 QString prefix = "<->";multiday = 2; 695 QString prefix = "<->";multiday = 2;
717 QString time; 696 QString time;
718 if ( event->doesRecur() ) { 697 if ( event->doesRecur() ) {
719 if ( event->recursOn( mDate) ) { 698 if ( event->recursOn( mDate) ) {
720 prefix ="->" ;multiday = 1; 699 prefix ="->" ;multiday = 1;
721 } 700 }
722 else { 701 else {
723 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 702 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
724 if ( event->recursOn( mDate.addDays( -days)) ) { 703 if ( event->recursOn( mDate.addDays( -days)) ) {
725 prefix ="<-" ;multiday = 3; 704 prefix ="<-" ;multiday = 3;
726 } 705 }
727 } 706 }
728 707
729 } else { 708 } else {
730 if (mDate == event->dtStart().date()) { 709 if (mDate == event->dtStart().date()) {
731 prefix ="->" ;multiday = 1; 710 prefix ="->" ;multiday = 1;
732 } else if (mDate == event->dtEnd().date()) { 711 } else if (mDate == event->dtEnd().date()) {
733 prefix ="<-" ;multiday = 3; 712 prefix ="<-" ;multiday = 3;
734 } 713 }
735 } 714 }
736 if ( !event->doesFloat() ) { 715 if ( !event->doesFloat() ) {
737 if ( mDate == event->dtStart().date () ) 716 if ( mDate == event->dtStart().date () )
738 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 717 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
739 else if ( mDate == event->dtEnd().date () ) 718 else if ( mDate == event->dtEnd().date () )
740 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 719 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
741 720
742 } 721 }
743 text = time + event->summary(); 722 text = time + event->summary();
744 if ( useToolTips ) 723 if ( useToolTips )
745 mToolTipText += prefix + text; 724 mToolTipText += prefix + text;
746 } else { 725 } else {
747 if (event->doesFloat()) { 726 if (event->doesFloat()) {
748 text = event->summary(); 727 text = event->summary();
749 if ( useToolTips ) 728 if ( useToolTips )
750 mToolTipText += text; 729 mToolTipText += text;
751 } 730 }
752 else { 731 else {
753 text = KGlobal::locale()->formatTime(event->dtStart().time()); 732 text = KGlobal::locale()->formatTime(event->dtStart().time());
754 text += " " + event->summary(); 733 text += " " + event->summary();
755 if ( useToolTips ) 734 if ( useToolTips )
756 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 735 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
757 } 736 }
758 } 737 }
759 if ( useToolTips && ! event->location().isEmpty() ) { 738 if ( useToolTips && ! event->location().isEmpty() ) {
760 mToolTipText += " (" + event->location() +")"; 739 mToolTipText += " (" + event->location() +")";
761 } 740 }
762 MonthViewItem *item ; 741 MonthViewItem *item ;
763 742
764 if ( mAvailItemList.count() ) { 743 if ( mAvailItemList.count() ) {
765 item = mAvailItemList.first(); 744 item = mAvailItemList.first();
766 mAvailItemList.remove( item ); 745 mAvailItemList.remove( item );
767 item->recycle( event, mDate, text ); 746 item->recycle( event, text );
768 } else { 747 } else {
769 item = new MonthViewItem( event, mDate, text ); 748 item = new MonthViewItem( event, text );
770 } 749 }
771 750
772 QPalette pal; 751 QPalette pal;
773 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 752 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
774 QStringList categories = event->categories(); 753 QStringList categories = event->categories();
775 QString cat = categories.first(); 754 QString cat = categories.first();
776 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 755 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
777 pal = getPalette(); 756 pal = getPalette();
778 if (cat.isEmpty()) { 757 if (cat.isEmpty()) {
779 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 758 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
780 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); 759 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() ));
781 } else { 760 } else {
782 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 761 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
783 } 762 }
784 763
785 } else { 764 } else {
786 if (cat.isEmpty()) { 765 if (cat.isEmpty()) {
787 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 766 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
788 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); 767 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() ));
789 } else { 768 } else {
790 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 769 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
791 } 770 }
792 } 771 }
793 772
794 } else { 773 } else {
795 pal = mStandardPalette ; 774 pal = mStandardPalette ;
796 } 775 }
776 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor);
797 item->setPalette( pal ); 777 item->setPalette( pal );
798 item->setRecur( event->recurrence()->doesRecur() ); 778 item->setRecur( event->recurrence()->doesRecur() );
799 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); 779 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() );
800 item->setMoreInfo( event->description().length() > 0 ); 780 item->setMoreInfo( event->description().length() > 0 );
801#ifdef DESKTOP_VERSION 781#ifdef DESKTOP_VERSION
802 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 782 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
803 KOPrefs::instance()->email()); 783 KOPrefs::instance()->email());
804 if ( me != 0 ) { 784 if ( me != 0 ) {
805 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 785 if ( me->status() == Attendee::NeedsAction && me->RSVP())
806 item->setReply(true && multiday < 2); 786 item->setReply(true && multiday < 2);
807 else 787 else
808 item->setReply(false); 788 item->setReply(false);
809 } else 789 } else
810 item->setReply(false); 790 item->setReply(false);
811#endif 791#endif
812 792
813 item->setMultiDay( multiday ); 793 item->setMultiDay( multiday );
814 if ( multiday ) { 794 if ( multiday ) {
815 insertItem( item ,mdayCount); 795 insertItem( item ,mdayCount);
816 ++mdayCount; 796 ++mdayCount;
817 } else { 797 } else {
818 uint i = mdayCount; 798 uint i = mdayCount;
819 uint pos = mdayCount; 799 uint pos = mdayCount;
820 uint itcount = count(); 800 uint itcount = count();
821 if ( itcount > 1000 ) { 801 if ( itcount > 1000 ) {
822 qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); 802 qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount);
823 itcount = 0; 803 itcount = 0;
824 } 804 }
825 for ( i = pos; i < itcount;++i ) { 805 for ( i = pos; i < itcount;++i ) {
826 // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); 806 // qDebug("i %d mday %u count %d ",i,itcount,mdayCount );
827 QListBoxItem* it = this->item ( i ); 807 QListBoxItem* it = this->item ( i );
828 if ( it && text < it->text() ) { 808 if ( it && text < it->text() ) {
829 pos = i; 809 pos = i;
830 break; 810 break;
831 } 811 }
832 ++pos; 812 ++pos;
833 } 813 }
834 insertItem( item ,pos); 814 insertItem( item ,pos);
835 } 815 }
836 if ( useToolTips ) { 816 if ( useToolTips ) {
837 mToolTip.append( mToolTipText ); 817 mToolTip.append( mToolTipText );
838 } 818 }
839 return mdayCount; 819 return mdayCount;
840} 820}
841void MonthViewCell::insertTodo(Todo *todo) 821void MonthViewCell::insertTodo(Todo *todo)
842{ 822{
843 setFocusPolicy(WheelFocus); 823 setFocusPolicy(WheelFocus);
844 QString text; 824 QString text;
845 if (todo->hasDueDate()) { 825 if (todo->hasDueDate()) {
846 if (!todo->doesFloat()) { 826 if (!todo->doesFloat()) {
847 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 827 text += KGlobal::locale()->formatTime(todo->dtDue().time());
848 text += " "; 828 text += " ";
849 } 829 }
850 } 830 }
851 text += todo->summary(); 831 text += todo->summary();
852 MonthViewItem *item ; 832 MonthViewItem *item ;
853 if ( mAvailItemList.count() ) { 833 if ( mAvailItemList.count() ) {
854 item = mAvailItemList.first(); 834 item = mAvailItemList.first();
855 mAvailItemList.remove( item ); 835 mAvailItemList.remove( item );
856 item->recycle( todo, mDate, text ); 836 item->recycle( todo, text );
857 } else { 837 } else {
858 item = new MonthViewItem( todo, mDate, text ); 838 item = new MonthViewItem( todo, text );
859 } 839 }
860 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 840 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
861 //item->setPalette( mStandardPalette ); 841 //item->setPalette( mStandardPalette );
862 QPalette pal; 842 QPalette pal;
863 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 843 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
864 QStringList categories = todo->categories(); 844 QStringList categories = todo->categories();
865 QString cat = categories.first(); 845 QString cat = categories.first();
866 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 846 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
867 pal = getPalette(); 847 pal = getPalette();
868 if (cat.isEmpty()) { 848 if (cat.isEmpty()) {
869 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 849 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
870 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); 850 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() ));
871 } else { 851 } else {
872 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 852 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
873 } 853 }
874 854
875 } else { 855 } else {
876 if (cat.isEmpty()) { 856 if (cat.isEmpty()) {
877 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 857 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
878 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); 858 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() ));
879 } else { 859 } else {
880 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 860 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
881 } 861 }
882 } 862 }
883 863
884 } else { 864 } else {
885 pal = mStandardPalette ; 865 pal = mStandardPalette ;
886 } 866 }
867 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor);
887 item->setPalette( pal ); 868 item->setPalette( pal );
888 item->setRecur( todo->recurrence()->doesRecur() ); 869 item->setRecur( todo->recurrence()->doesRecur() );
889 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); 870 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() );
890 item->setMoreInfo( todo->description().length() > 0 ); 871 item->setMoreInfo( todo->description().length() > 0 );
891 insertItem( item , count()); 872 insertItem( item , count());
892#ifdef DESKTOP_VERSION 873#ifdef DESKTOP_VERSION
893 mToolTip.append( text ); 874 mToolTip.append( text );
894#endif 875#endif
895} 876}
896void MonthViewCell::repaintfinishUpdateCell() 877void MonthViewCell::repaintfinishUpdateCell()
897{ 878{
898 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 879 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
899 while ( mitem ) { 880 while ( mitem ) {
900 mitem->setBlockRepaint( false ); 881 mitem->setBlockRepaint( false );
901 updateItem ( mitem ); 882 updateItem ( mitem );
902 mitem = (MonthViewItem *)mitem->next(); 883 mitem = (MonthViewItem *)mitem->next();
903 } 884 }
904} 885}
905void MonthViewCell::finishUpdateCell() 886void MonthViewCell::finishUpdateCell()
906{ 887{
907 888
908 889
909 890
910#ifdef DESKTOP_VERSION 891#ifdef DESKTOP_VERSION
911 if (mToolTip.count() > 0 ) { 892 if (mToolTip.count() > 0 ) {
912 mToolTip.sort(); 893 mToolTip.sort();
913 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 894 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
914 } 895 }
915#endif 896#endif
916 //sort(); 897 //sort();
917 //setMyPalette(); 898 //setMyPalette();
918 setMyPalette(); 899 setMyPalette();
919 900
920 resizeEvent( 0 ); 901 resizeEvent( 0 );
921 902
922} 903}
923void MonthViewCell::updateCell() 904void MonthViewCell::updateCell()
924{ 905{
925 if ( !mMonthView->isUpdatePossible() ) 906 if ( !mMonthView->isUpdatePossible() )
926 return; 907 return;
927 startUpdateCell(); 908 startUpdateCell();
928 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 909 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
929 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 910 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
930 Event *event; 911 Event *event;
931 for( event = events.first(); event; event = events.next() ) { // for event 912 for( event = events.first(); event; event = events.next() ) { // for event
932 insertEvent(event); 913 insertEvent(event);
933 } 914 }
934 // insert due todos 915 // insert due todos
935 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 916 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
936 Todo *todo; 917 Todo *todo;
937 for(todo = todos.first(); todo; todo = todos.next()) { 918 for(todo = todos.first(); todo; todo = todos.next()) {
938 insertTodo( todo ); 919 insertTodo( todo );
939 } 920 }
940 finishUpdateCell(); 921 finishUpdateCell();
941 // if ( isVisible()) 922 // if ( isVisible())
942 //qApp->processEvents(); 923 //qApp->processEvents();
943} 924}
944 925
945void MonthViewCell::updateConfig( bool bigFont ) // = false 926void MonthViewCell::updateConfig( bool bigFont ) // = false
946{ 927{
947 928
948 if ( bigFont ) { 929 if ( bigFont ) {
949 QFont fo = KOPrefs::instance()->mMonthViewFont; 930 QFont fo = KOPrefs::instance()->mMonthViewFont;
950 int ps = fo.pointSize() + 2; 931 int ps = fo.pointSize() + 2;
951 if ( ps < 18 ) 932 if ( ps < 18 )
952 ps += 2; 933 ps += 2;
953 fo.setPointSize( ps ); 934 fo.setPointSize( ps );
954 setFont( fo ); 935 setFont( fo );
955 } else 936 } else
956 setFont( KOPrefs::instance()->mMonthViewFont ); 937 setFont( KOPrefs::instance()->mMonthViewFont );
957 938
958 QFontMetrics fm( font() ); 939 QFontMetrics fm( font() );
959 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 940 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
960 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 941 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
961 mHolidayPalette = mStandardPalette; 942 mHolidayPalette = mStandardPalette;
962 mPrimaryPalette = mStandardPalette; 943 mPrimaryPalette = mStandardPalette;
963 mNonPrimaryPalette = mStandardPalette; 944 mNonPrimaryPalette = mStandardPalette;
964 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 945 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
965 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 946 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
966 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 947 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
967 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 948 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
968 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 949 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
969 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 950 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
970 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 951 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
971 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 952 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
972 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 953 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
973 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 954 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
974 } 955 }
975 //updateCell(); 956 //updateCell();
976} 957}
977 958
978void MonthViewCell::enableScrollBars( bool enabled ) 959void MonthViewCell::enableScrollBars( bool enabled )
979{ 960{
980 961
981 return; 962 return;
982 if ( enabled ) { 963 if ( enabled ) {
983 QListBoxItem *fi = firstItem (); 964 QListBoxItem *fi = firstItem ();
984 if (fi ) { 965 if (fi ) {
985 int ihei = fi->height( this ); 966 int ihei = fi->height( this );
986 int hei = numRows () * ihei; 967 int hei = numRows () * ihei;
987 if ( hei < height() - horizontalScrollBar()->height () ) { 968 if ( hei < height() - horizontalScrollBar()->height () ) {
988 setVScrollBarMode(QScrollView::AlwaysOff); 969 setVScrollBarMode(QScrollView::AlwaysOff);
989 } 970 }
990 else 971 else
991 setVScrollBarMode(QScrollView::Auto); 972 setVScrollBarMode(QScrollView::Auto);
992 if ( ihei *3 > height() ) { 973 if ( ihei *3 > height() ) {
993 setHScrollBarMode(QScrollView::AlwaysOff); 974 setHScrollBarMode(QScrollView::AlwaysOff);
994 } 975 }
995 else { 976 else {
996 setHScrollBarMode(QScrollView::Auto); 977 setHScrollBarMode(QScrollView::Auto);
997 } 978 }
998 } else { 979 } else {
999 setVScrollBarMode(QScrollView::Auto); 980 setVScrollBarMode(QScrollView::Auto);
1000 setHScrollBarMode(QScrollView::Auto); 981 setHScrollBarMode(QScrollView::Auto);
1001 } 982 }
1002 } else { 983 } else {
1003 setVScrollBarMode(QScrollView::AlwaysOff); 984 setVScrollBarMode(QScrollView::AlwaysOff);
1004 setHScrollBarMode(QScrollView::AlwaysOff); 985 setHScrollBarMode(QScrollView::AlwaysOff);
1005 } 986 }
1006} 987}
1007 988
1008Incidence *MonthViewCell::selectedIncidence() 989Incidence *MonthViewCell::selectedIncidence()
1009{ 990{
1010 int index = currentItem(); 991 int index = currentItem();
1011 if ( index < 0 ) return 0; 992 if ( index < 0 ) return 0;
1012 993
1013 MonthViewItem *mitem = 994 MonthViewItem *mitem =
1014 static_cast<MonthViewItem *>( item( index ) ); 995 static_cast<MonthViewItem *>( item( index ) );
1015 996
1016 if ( !mitem ) return 0; 997 if ( !mitem ) return 0;
1017 998
1018 return mitem->incidence(); 999 return mitem->incidence();
1019} 1000}
1020 1001
1021QDate MonthViewCell::selectedIncidenceDate() 1002QDate MonthViewCell::selectedIncidenceDate()
1022{ 1003{
1023 QDate qd; 1004 QDate qd;
1024 int index = currentItem(); 1005 int index = currentItem();
1025 if ( index < 0 ) return qd; 1006 if ( index < 0 ) return qd;
1026 1007 return mDate;
1027 MonthViewItem *mitem =
1028 static_cast<MonthViewItem *>( item( index ) );
1029
1030 if ( !mitem ) return qd;
1031
1032 return mitem->incidenceDate();
1033} 1008}
1034 1009
1035void MonthViewCell::deselect() 1010void MonthViewCell::deselect()
1036{ 1011{
1037 clearSelection(); 1012 clearSelection();
1038 enableScrollBars( false ); 1013 enableScrollBars( false );
1039 // updateCell(); 1014 // updateCell();
1040} 1015}
1041void MonthViewCell::select() 1016void MonthViewCell::select()
1042{ 1017{
1043 ;// updateCell(); 1018 ;// updateCell();
1044} 1019}
1045 1020
1046void MonthViewCell::resizeEvent ( QResizeEvent * e ) 1021void MonthViewCell::resizeEvent ( QResizeEvent * e )
1047{ 1022{
1048 if ( !mMonthView->isUpdatePossible() ) 1023 if ( !mMonthView->isUpdatePossible() )
1049 return; 1024 return;
1050 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 1025 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
1051 deselect(); 1026 deselect();
1052 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 1027 mLabel->setMaximumHeight( height() - lineWidth()*2 );
1053 1028
1054 QString text; 1029 QString text;
1055 mLabel->setText( text ); 1030 mLabel->setText( text );
1056 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 1031 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
1057 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 1032 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
1058 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 1033 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
1059 mLabel->resize( mLabelBigSize ); 1034 mLabel->resize( mLabelBigSize );
1060 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1035 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1061 } else { 1036 } else {
1062 mLabel->resize( mLabelSize ); 1037 mLabel->resize( mLabelSize );
1063 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1038 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1064 } 1039 }
1065 mLabel->setText( text ); 1040 mLabel->setText( text );
1066 1041
1067 int size = height() - mLabel->height() - lineWidth()-1; 1042 int size = height() - mLabel->height() - lineWidth()-1;
1068 //qDebug("LW %d ", lineWidth()); 1043 //qDebug("LW %d ", lineWidth());
1069 if ( size > 0 ) 1044 if ( size > 0 )
1070 verticalScrollBar()->setMaximumHeight( size ); 1045 verticalScrollBar()->setMaximumHeight( size );
1071 size = width() - mLabel->width() -lineWidth()-1; 1046 size = width() - mLabel->width() -lineWidth()-1;
1072 if ( size > 0 ) 1047 if ( size > 0 )
1073 horizontalScrollBar()->setMaximumWidth( size ); 1048 horizontalScrollBar()->setMaximumWidth( size );
1074 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1049 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1075 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1050 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1076 // mItemList->resize ( width(), height () ); 1051 // mItemList->resize ( width(), height () );
1077 if ( e ) 1052 if ( e )
1078 KNoScrollListBox::resizeEvent ( e ); 1053 KNoScrollListBox::resizeEvent ( e );
1079} 1054}
1080 1055
1081void MonthViewCell::defaultAction( QListBoxItem *item ) 1056void MonthViewCell::defaultAction( QListBoxItem *item )
1082{ 1057{
1083 1058
1084 if ( !item ) { 1059 if ( !item ) {
1085 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1060 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1086 emit newEventSignal( dt ); 1061 emit newEventSignal( dt );
1087 return; 1062 return;
1088 } 1063 }
1089 1064
1090 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1065 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1091 Incidence *incidence = eventItem->incidence(); 1066 Incidence *incidence = eventItem->incidence();
1092 if ( incidence ) mMonthView->defaultAction( incidence ); 1067 if ( incidence ) mMonthView->defaultAction( incidence );
1093} 1068}
1094void MonthViewCell::showDay() 1069void MonthViewCell::showDay()
1095{ 1070{
1096 emit showDaySignal( date() ); 1071 emit showDaySignal( date() );
1097} 1072}
1098void MonthViewCell::newEvent() 1073void MonthViewCell::newEvent()
1099{ 1074{
1100 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1075 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1101 emit newEventSignal( dt ); 1076 emit newEventSignal( dt );
1102} 1077}
1103void MonthViewCell::cellClicked( QListBoxItem *item ) 1078void MonthViewCell::cellClicked( QListBoxItem *item )
1104{ 1079{
1105 mMonthView->setSelectedCell( this ); 1080 mMonthView->setSelectedCell( this );
1106 if ( item == 0 ) { 1081 if ( item == 0 ) {
1107 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1082 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1108 emit newEventSignal( dt ); 1083 emit newEventSignal( dt );
1109 return; 1084 return;
1110 } 1085 }
1111 1086
1112} 1087}
1113 1088
1114void MonthViewCell::contextMenu( QListBoxItem *item ) 1089void MonthViewCell::contextMenu( QListBoxItem *item )
1115{ 1090{
1116 mMonthView->setPopupCell( this ); 1091 mMonthView->setPopupCell( this );
1117 if ( !item ) { 1092 if ( !item ) {
1118 mMonthView->showContextMenu( 0 ); 1093 mMonthView->showContextMenu( 0 );
1119 return; 1094 return;
1120 } 1095 }
1121 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1096 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1122 Incidence *incidence = eventItem->incidence(); 1097 Incidence *incidence = eventItem->incidence();
1123 if ( incidence ) mMonthView->showContextMenu( incidence ); 1098 if ( incidence ) mMonthView->showContextMenu( incidence );
1124} 1099}
1125 1100
1126void MonthViewCell::selection( QListBoxItem *item ) 1101void MonthViewCell::selection( QListBoxItem *item )
1127{ 1102{
1128 if ( !item ) { 1103 if ( !item ) {
1129 emit highligtIncidence( 0 , this, 0 ); 1104 emit highligtIncidence( 0 , this, 0 );
1130 return; 1105 return;
1131 } 1106 }
1132 MonthViewItem * it = (static_cast<MonthViewItem *>( item )); 1107 MonthViewItem * it = (static_cast<MonthViewItem *>( item ));
1133 emit highligtIncidence( it->incidence(), this, it->multiDay() ); 1108 emit highligtIncidence( it->incidence(), this, it->multiDay() );
1134 mMonthView->setSelectedCell( this ); 1109 mMonthView->setSelectedCell( this );
1135} 1110}
1136 1111
1137void MonthViewCell::deHightLight() 1112void MonthViewCell::deHightLight()
1138{ 1113{
1139 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 1114 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
1140 while ( mitem ) { 1115 while ( mitem ) {
1141 if ( mitem->setHighlightedFalse() ) 1116 if ( mitem->setHighlightedFalse() )
1142 updateItem ( mitem ); 1117 updateItem ( mitem );
1143 mitem = (MonthViewItem *)mitem->next(); 1118 mitem = (MonthViewItem *)mitem->next();
1144 } 1119 }
1145} 1120}
1146// returns true if no inc found 1121// returns true if no inc found
1147bool MonthViewCell::doHightLight( Incidence * inc ) 1122bool MonthViewCell::doHightLight( Incidence * inc )
1148{ 1123{
1149 1124
1150 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 1125 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
1151 while ( mitem ) { 1126 while ( mitem ) {
1152 if ( mitem->incidence() == inc ) { 1127 if ( mitem->incidence() == inc ) {
1153 if ( mitem->setHighlighted( inc ) ) 1128 if ( mitem->setHighlighted( inc ) )
1154 updateItem ( mitem ); 1129 updateItem ( mitem );
1155 return false; 1130 return false;
1156 } 1131 }
1157 mitem = (MonthViewItem *)mitem->next(); 1132 mitem = (MonthViewItem *)mitem->next();
1158 } 1133 }
1159 return true; 1134 return true;
1160} 1135}
1161// ******************************************************************************* 1136// *******************************************************************************
1162// ******************************************************************************* 1137// *******************************************************************************
1163// ******************************************************************************* 1138// *******************************************************************************
1164 1139
1165 1140
1166KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1141KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1167 : KOEventView( calendar, parent, name ), 1142 : KOEventView( calendar, parent, name ),
1168 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1143 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1169 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1144 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1170{ 1145{
1171 mFlagKeyPressed = false; 1146 mFlagKeyPressed = false;
1172 mShortDayLabelsM = false; 1147 mShortDayLabelsM = false;
1173 mShortDayLabelsW = false; 1148 mShortDayLabelsW = false;
1174 skipResize = false; 1149 skipResize = false;
1175 clPending = true; 1150 clPending = true;
1176 mPopupCell = 0; 1151 mPopupCell = 0;
1177 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1152 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1178 mWidStack = new QWidgetStack( this ); 1153 mWidStack = new QWidgetStack( this );
1179 QVBoxLayout* hb = new QVBoxLayout( this ); 1154 QVBoxLayout* hb = new QVBoxLayout( this );
1180 mMonthView = new QWidget( mWidStack ); 1155 mMonthView = new QWidget( mWidStack );
1181 mWeekView = new QWidget( mWidStack ); 1156 mWeekView = new QWidget( mWidStack );
1182#if QT_VERSION >= 0x030000 1157#if QT_VERSION >= 0x030000
1183 mWidStack->addWidget(mMonthView ); 1158 mWidStack->addWidget(mMonthView );
1184 mWidStack->addWidget(mWeekView ); 1159 mWidStack->addWidget(mWeekView );
1185#else 1160#else
1186 mWidStack->addWidget( mMonthView, 1 ); 1161 mWidStack->addWidget( mMonthView, 1 );
1187 mWidStack->addWidget( mWeekView , 1 ); 1162 mWidStack->addWidget( mWeekView , 1 );
1188#endif 1163#endif
1189 hb->addWidget( mNavigatorBar ); 1164 hb->addWidget( mNavigatorBar );
1190 hb->addWidget( mWidStack ); 1165 hb->addWidget( mWidStack );
1191 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1166 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1192 updatePossible = false; 1167 updatePossible = false;
1193 //updatePossible = true; 1168 //updatePossible = true;
1194 mCells.setAutoDelete( true ); 1169 mCells.setAutoDelete( true );
1195 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1170 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1196 mDayLabels.resize( mDaysPerWeek ); 1171 mDayLabels.resize( mDaysPerWeek );
1197 mDayLabelsW.resize( mDaysPerWeek ); 1172 mDayLabelsW.resize( mDaysPerWeek );
1198 QFont bfont = font(); 1173 QFont bfont = font();
1199 if ( QApplication::desktop()->width() < 650 ) { 1174 if ( QApplication::desktop()->width() < 650 ) {
1200 bfont.setPointSize( bfont.pointSize() - 2 ); 1175 bfont.setPointSize( bfont.pointSize() - 2 );
1201 } 1176 }
1202 bfont.setBold( true ); 1177 bfont.setBold( true );
1203 int i; 1178 int i;
1204 1179
1205 for( i = 0; i < mDaysPerWeek; i++ ) { 1180 for( i = 0; i < mDaysPerWeek; i++ ) {
1206 QLabel *label = new QLabel( mMonthView ); 1181 QLabel *label = new QLabel( mMonthView );
1207 label->setFont(bfont); 1182 label->setFont(bfont);
1208 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1183 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1209 label->setLineWidth(1); 1184 label->setLineWidth(1);
1210 label->setAlignment(AlignCenter); 1185 label->setAlignment(AlignCenter);
1211 mDayLabels.insert( i, label ); 1186 mDayLabels.insert( i, label );
1212 label = new QLabel( mWeekView ); 1187 label = new QLabel( mWeekView );
1213 label->setFont(bfont); 1188 label->setFont(bfont);
1214 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1189 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1215 label->setLineWidth(1); 1190 label->setLineWidth(1);
1216 label->setAlignment(AlignCenter); 1191 label->setAlignment(AlignCenter);
1217 mDayLabelsW.insert( i, label ); 1192 mDayLabelsW.insert( i, label );
1218 } 1193 }
1219 1194
1220 bfont.setBold( false ); 1195 bfont.setBold( false );
1221 mWeekLabels.resize( mNumWeeks+1 ); 1196 mWeekLabels.resize( mNumWeeks+1 );
1222 mWeekLabelsW.resize( 2 ); 1197 mWeekLabelsW.resize( 2 );
1223 for( i = 0; i < mNumWeeks+1; i++ ) { 1198 for( i = 0; i < mNumWeeks+1; i++ ) {
1224 KOWeekButton *label = new KOWeekButton( mMonthView ); 1199 KOWeekButton *label = new KOWeekButton( mMonthView );
1225 label->setFocusPolicy(NoFocus); 1200 label->setFocusPolicy(NoFocus);
1226 label->setFont(bfont); 1201 label->setFont(bfont);
1227 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1202 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1228 label->setFlat(true); 1203 label->setFlat(true);
1229 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1204 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1230 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1205 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1231 //label->setLineWidth(1); 1206 //label->setLineWidth(1);
1232 //label->setAlignment(AlignCenter); 1207 //label->setAlignment(AlignCenter);
1233 mWeekLabels.insert( i, label ); 1208 mWeekLabels.insert( i, label );
1234 } 1209 }
1235 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1210 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1236 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1211 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1237 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1212 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1238 1213
1239 for( i = 0; i < 1+1; i++ ) { 1214 for( i = 0; i < 1+1; i++ ) {
1240 KOWeekButton *label = new KOWeekButton( mWeekView ); 1215 KOWeekButton *label = new KOWeekButton( mWeekView );
1241 label->setFocusPolicy(NoFocus); 1216 label->setFocusPolicy(NoFocus);
1242 label->setFont(bfont); 1217 label->setFont(bfont);
1243 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1218 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1244 label->setFlat(true); 1219 label->setFlat(true);
1245 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1220 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1246 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1221 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1247 //label->setLineWidth(1); 1222 //label->setLineWidth(1);
1248 //label->setAlignment(AlignCenter); 1223 //label->setAlignment(AlignCenter);
1249 mWeekLabelsW.insert( i, label ); 1224 mWeekLabelsW.insert( i, label );
1250 } 1225 }
1251 mWeekLabelsW[1]->setText( i18n("W")); 1226 mWeekLabelsW[1]->setText( i18n("W"));
1252 mWeekLabelsW[1]->setFocusPolicy(WheelFocus); 1227 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1253 1228
1254 1229
1255 int row, col; 1230 int row, col;
1256 mCells.resize( mNumCells ); 1231 mCells.resize( mNumCells );
1257 for( row = 0; row < mNumWeeks; ++row ) { 1232 for( row = 0; row < mNumWeeks; ++row ) {
1258 for( col = 0; col < mDaysPerWeek; ++col ) { 1233 for( col = 0; col < mDaysPerWeek; ++col ) {
1259 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1234 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1260 mCells.insert( row * mDaysPerWeek + col, cell ); 1235 mCells.insert( row * mDaysPerWeek + col, cell );
1261 1236
1262 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1237 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1263 SLOT( defaultAction( Incidence * ) ) ); 1238 SLOT( defaultAction( Incidence * ) ) );
1264 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1239 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1265 SIGNAL( newEventSignal( QDateTime ) ) ); 1240 SIGNAL( newEventSignal( QDateTime ) ) );
1266 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1241 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1267 SIGNAL( showDaySignal( QDate ) ) ); 1242 SIGNAL( showDaySignal( QDate ) ) );
1268 connect( cell, SIGNAL( nextCell() ), 1243 connect( cell, SIGNAL( nextCell() ),
1269 SLOT( nextCell() ) ); 1244 SLOT( nextCell() ) );
1270 connect( cell, SIGNAL( prevCell() ), 1245 connect( cell, SIGNAL( prevCell() ),
1271 SLOT( prevCell() ) ); 1246 SLOT( prevCell() ) );
1272 connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ), 1247 connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ),
1273 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); 1248 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
1274 } 1249 }
1275 } 1250 }
1276 mCellsW.resize( mDaysPerWeek ); 1251 mCellsW.resize( mDaysPerWeek );
1277 for( col = 0; col < mDaysPerWeek; ++col ) { 1252 for( col = 0; col < mDaysPerWeek; ++col ) {
1278 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1253 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1279 mCellsW.insert( col, cell ); 1254 mCellsW.insert( col, cell );
1280 1255
1281 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1256 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1282 SLOT( defaultAction( Incidence * ) ) ); 1257 SLOT( defaultAction( Incidence * ) ) );
1283 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1258 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1284 SIGNAL( newEventSignal( QDateTime ) ) ); 1259 SIGNAL( newEventSignal( QDateTime ) ) );
1285 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1260 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1286 SIGNAL( showDaySignal( QDate ) ) ); 1261 SIGNAL( showDaySignal( QDate ) ) );
1287 connect( cell, SIGNAL( nextCell() ), 1262 connect( cell, SIGNAL( nextCell() ),
1288 SLOT( nextCell() ) ); 1263 SLOT( nextCell() ) );
1289 connect( cell, SIGNAL( prevCell() ), 1264 connect( cell, SIGNAL( prevCell() ),
1290 SLOT( prevCell() ) ); 1265 SLOT( prevCell() ) );
1291 connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ), 1266 connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ),
1292 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); 1267 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
1293 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1268 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1294 } 1269 }
1295 1270
1296 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1271 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1297 mContextMenu = eventPopup(); 1272 mContextMenu = eventPopup();
1298 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1273 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1299 i18n("New Event..."),this, 1274 i18n("New Event..."),this,
1300 SLOT(slotNewEvent()),false); 1275 SLOT(slotNewEvent()),false);
1301 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1276 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1302 i18n("New Todo..."),this, 1277 i18n("New Todo..."),this,
1303 SLOT(slotNewTodo()),false); 1278 SLOT(slotNewTodo()),false);
1304 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1279 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1305 i18n("Journal"),this, 1280 i18n("Journal"),this,
1306 SLOT(slotEditJournal()),false); 1281 SLOT(slotEditJournal()),false);
1307 1282
1308 1283
1309 1284
1310 QString pathString = ""; 1285 QString pathString = "";
1311 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 1286 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
1312 if ( QApplication::desktop()->width() < 480 ) 1287 if ( QApplication::desktop()->width() < 480 )
1313 pathString += "icons16/"; 1288 pathString += "icons16/";
1314 } else 1289 } else
1315 pathString += "iconsmini/"; 1290 pathString += "iconsmini/";
1316 mNewItemMenu = new QPopupMenu( this ); 1291 mNewItemMenu = new QPopupMenu( this );
1317 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); 1292 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent()));
1318 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); 1293 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false);
1319 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); 1294 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false);
1320 1295
1321 // updateConfig(); //useless here... 1296 // updateConfig(); //useless here...
1322 // ... but we need mWidthLongDayLabel computed 1297 // ... but we need mWidthLongDayLabel computed
1323 QFontMetrics fontmetric(mDayLabels[0]->font()); 1298 QFontMetrics fontmetric(mDayLabels[0]->font());
1324 mWidthLongDayLabel = 0; 1299 mWidthLongDayLabel = 0;
1325 for (int i = 0; i < 7; i++) { 1300 for (int i = 0; i < 7; i++) {
1326 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1301 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1327 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1302 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1328 } 1303 }
1329 1304
1330 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1305 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1331 1306
1332#if 0 1307#if 0
1333 if ( mShowWeekView ) 1308 if ( mShowWeekView )
1334 mWidStack->raiseWidget( mWeekView ); 1309 mWidStack->raiseWidget( mWeekView );
1335 else 1310 else
1336 mWidStack->raiseWidget( mMonthView ); 1311 mWidStack->raiseWidget( mMonthView );
1337#endif 1312#endif
1338 1313
1339 emit incidenceSelected( 0 ); 1314 emit incidenceSelected( 0 );
1340 1315
1341 mComputeLayoutTimer = new QTimer( this ); 1316 mComputeLayoutTimer = new QTimer( this );
1342 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1317 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1343 1318
1344 1319
1345#ifndef DESKTOP_VERSION 1320#ifndef DESKTOP_VERSION
1346 resize( QApplication::desktop()->size() ); 1321 resize( QApplication::desktop()->size() );
1347#else 1322#else
1348 resize(640, 480 ); 1323 resize(640, 480 );
1349 updatePossible = true; 1324 updatePossible = true;
1350#endif 1325#endif
1351 computeLayout(); 1326 computeLayout();
1352 1327
1353 if ( mShowWeekView ) 1328 if ( mShowWeekView )
1354 mWidStack->raiseWidget( mWeekView ); 1329 mWidStack->raiseWidget( mWeekView );
1355 else 1330 else
1356 mWidStack->raiseWidget( mMonthView ); 1331 mWidStack->raiseWidget( mMonthView );
1357} 1332}
1358 1333
1359KOMonthView::~KOMonthView() 1334KOMonthView::~KOMonthView()
1360{ 1335{
1361 delete mContextMenu; 1336 delete mContextMenu;
1362} 1337}
1363 1338
1364void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) 1339void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday )
1365{ 1340{
1366 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); 1341 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
1367 static Incidence * lastInc = 0; 1342 static Incidence * lastInc = 0;
1368 static MonthViewCell * lastCell = 0; 1343 static MonthViewCell * lastCell = 0;
1369 1344
1370 if ( lastInc == inc && lastCell == mc ) 1345 if ( lastInc == inc && lastCell == mc )
1371 return; 1346 return;
1372 lastInc = inc; 1347 lastInc = inc;
1373 lastCell = mc; 1348 lastCell = mc;
1374 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); 1349 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
1375 1350
1376 bool weekview = false; 1351 bool weekview = false;
1377 int index = 0; 1352 int index = 0;
1378 for (uint i = 0; i < mCellsW.count(); ++i) { 1353 for (uint i = 0; i < mCellsW.count(); ++i) {
1379 if ( mCellsW[i] == mc ) { 1354 if ( mCellsW[i] == mc ) {
1380 weekview = true; 1355 weekview = true;
1381 index = i; 1356 index = i;
1382 break; 1357 break;
1383 } 1358 }
1384 } 1359 }
1385 QPtrVector<MonthViewCell> *cells; 1360 QPtrVector<MonthViewCell> *cells;
1386 if ( weekview ) 1361 if ( weekview )
1387 cells = &mCellsW; 1362 cells = &mCellsW;
1388 else { 1363 else {
1389 for (uint i = 0; i < mCells.count(); ++i) { 1364 for (uint i = 0; i < mCells.count(); ++i) {
1390 if ( mCells[i] == mc ) { 1365 if ( mCells[i] == mc ) {
1391 index = i; 1366 index = i;
1392 break; 1367 break;
1393 } 1368 }
1394 } 1369 }
1395 cells = &mCells; 1370 cells = &mCells;
1396 } 1371 }
1397 for (uint i = 0; i < (*cells).count(); ++i) { 1372 for (uint i = 0; i < (*cells).count(); ++i) {
1398 (*cells)[i]->deHightLight(); 1373 (*cells)[i]->deHightLight();
1399 } 1374 }
1400 if ( ! inc ) 1375 if ( ! inc )
1401 return; 1376 return;
1402 if ( mday > 1 && index > 0 ) 1377 if ( mday > 1 && index > 0 )
1403 for (int i = index-1; i >= 0; --i) { 1378 for (int i = index-1; i >= 0; --i) {
1404 //qDebug("index %d iii %d ", index, i); 1379 //qDebug("index %d iii %d ", index, i);
1405 if ( (*cells)[(uint)i]->doHightLight(inc) ) 1380 if ( (*cells)[(uint)i]->doHightLight(inc) )
1406 break; 1381 break;
1407 } 1382 }
1408 if ( mday < 3 && mday > 0 && index < (*cells).count()-1) 1383 if ( mday < 3 && mday > 0 && index < (*cells).count()-1)
1409 for (uint i = index+1; i < (*cells).count(); ++i) { 1384 for (uint i = index+1; i < (*cells).count(); ++i) {
1410 if ( (*cells)[i]->doHightLight(inc) ) 1385 if ( (*cells)[i]->doHightLight(inc) )
1411 break; 1386 break;
1412 } 1387 }
1413 1388
1414} 1389}
1415void KOMonthView::selectInternalWeekNum ( int n ) 1390void KOMonthView::selectInternalWeekNum ( int n )
1416{ 1391{
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index ac97860..2622d10 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,347 +1,345 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qintdict.h> 31#include <qintdict.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qvaluelist.h> 33#include <qvaluelist.h>
34#include <qptrvector.h> 34#include <qptrvector.h>
35 35
36#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
37#include <libkcal/event.h> 37#include <libkcal/event.h>
38 38
39#include "koeventview.h" 39#include "koeventview.h"
40#include "navigatorbar.h" 40#include "navigatorbar.h"
41 41
42#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
43class QToolTipGroup; 43class QToolTipGroup;
44#endif 44#endif
45 45
46class KNOWhatsThis; 46class KNOWhatsThis;
47class MonthViewCell; 47class MonthViewCell;
48class KOWeekButton : public QPushButton 48class KOWeekButton : public QPushButton
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 public: 51 public:
52 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 52 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
53 QPushButton( parent, name) 53 QPushButton( parent, name)
54 { 54 {
55 connect( this, SIGNAL( clicked() ), 55 connect( this, SIGNAL( clicked() ),
56 SLOT( bottonClicked() )); 56 SLOT( bottonClicked() ));
57 mNumber = -1; 57 mNumber = -1;
58 } 58 }
59 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 59 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
60 int getWeekNum() { return mNumber;} 60 int getWeekNum() { return mNumber;}
61 signals: 61 signals:
62 void selectWeekNum ( int ); 62 void selectWeekNum ( int );
63private: 63private:
64 void focusInEvent ( QFocusEvent * ){;} 64 void focusInEvent ( QFocusEvent * ){;}
65 int mNumber; 65 int mNumber;
66 void keyPressEvent ( QKeyEvent * e ) 66 void keyPressEvent ( QKeyEvent * e )
67 { 67 {
68 e->ignore(); 68 e->ignore();
69 } 69 }
70 70
71private slots : 71private slots :
72 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 72 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
73}; 73};
74 74
75class KNoScrollListBox: public QListBox 75class KNoScrollListBox: public QListBox
76{ 76{
77 Q_OBJECT 77 Q_OBJECT
78 public: 78 public:
79 KNoScrollListBox(QWidget *parent=0, const char *name=0); 79 KNoScrollListBox(QWidget *parent=0, const char *name=0);
80 ~KNoScrollListBox(); 80 ~KNoScrollListBox();
81 QString getWhatsThisText(QPoint p) ; 81 QString getWhatsThisText(QPoint p) ;
82 82
83 signals: 83 signals:
84 void shiftDown(); 84 void shiftDown();
85 void shiftUp(); 85 void shiftUp();
86 void rightClick(); 86 void rightClick();
87 void nextCell(); 87 void nextCell();
88 void prevCell(); 88 void prevCell();
89 void highligtIncidence( Incidence * , MonthViewCell*, int ); 89 void highligtIncidence( Incidence * , MonthViewCell*, int );
90 90
91 protected slots: 91 protected slots:
92 void oneDown(); 92 void oneDown();
93 void keyPressEvent(QKeyEvent *); 93 void keyPressEvent(QKeyEvent *);
94 void keyReleaseEvent(QKeyEvent *); 94 void keyReleaseEvent(QKeyEvent *);
95 void mousePressEvent(QMouseEvent *); 95 void mousePressEvent(QMouseEvent *);
96 void focusInEvent ( QFocusEvent * ); 96 void focusInEvent ( QFocusEvent * );
97 void focusOutEvent ( QFocusEvent * ); 97 void focusOutEvent ( QFocusEvent * );
98 98
99 private: 99 private:
100 bool resetOnFocusIn; 100 bool resetOnFocusIn;
101 KNOWhatsThis * mWT; 101 KNOWhatsThis * mWT;
102}; 102};
103 103
104 104
105class MonthViewItem: public QListBoxItem 105class MonthViewItem: public QListBoxItem
106{ 106{
107 public: 107 public:
108 MonthViewItem( Incidence *, QDate qd, const QString & title ); 108 MonthViewItem( Incidence *,const QString & title );
109 void recycle( Incidence *incidence, QDate qd, const QString & s); 109 void recycle( Incidence *incidence, const QString & s);
110 void clearData();
111 void setRecur(bool on) { mRecur = on; } 110 void setRecur(bool on) { mRecur = on; }
112 void setAlarm(bool on) { mAlarm = on; } 111 void setAlarm(bool on) { mAlarm = on; }
113 void setReply(bool on) { mReply = on; } 112 void setReply(bool on) { mReply = on; }
114 void setMoreInfo(bool on) { mInfo = on; } 113 void setMoreInfo(bool on) { mInfo = on; }
115 void setMultiDay(int type) { mMultiday = type; } 114 void setMultiDay(int type) { mMultiday = type; }
116 int multiDay() { return mMultiday; } 115 int multiDay() { return mMultiday; }
117 void setMultiDayPos(int type) { mdayPos = type; } 116 void setMultiDayPos(int type) { mdayPos = type; }
118 int gettMultiDayPos() { return mdayPos; } 117 int gettMultiDayPos() { return mdayPos; }
119 void setBlockRepaint(bool on) { mblockRepaint = on; } 118 void setBlockRepaint(bool on) { mblockRepaint = on; }
120 bool setHighlighted( Incidence * ); 119 bool setHighlighted( Incidence * );
121 120
122 void setPalette(const QPalette &p) { mPalette = p; } 121 void setPalette(const QPalette &p) { mPalette = p; }
123 QPalette palette() const { return mPalette; } 122 QPalette palette() const { return mPalette; }
124 bool setHighlightedFalse(); 123 bool setHighlightedFalse();
125 Incidence *incidence() const { return mIncidence; } 124 Incidence *incidence() const { return mIncidence; }
126 QDate incidenceDate() { return mDate; }
127 125
128 protected: 126 protected:
129 virtual void paint(QPainter *); 127 virtual void paint(QPainter *);
130 virtual int height(const QListBox *) const; 128 virtual int height(const QListBox *) const;
131 virtual int width(const QListBox *) const; 129 virtual int width(const QListBox *) const;
132 130
133 private: 131 private:
134 int mdayPos; 132 int mdayPos;
135 bool isWeekItem; 133 bool isWeekItem;
136 bool mblockRepaint; 134 bool mblockRepaint;
137 int mMultiday; 135 int mMultiday;
138 bool mRecur; 136 bool mRecur;
139 bool mAlarm; 137 bool mAlarm;
140 bool mReply; 138 bool mReply;
141 bool mInfo; 139 bool mInfo;
142 bool mDisplayHightlighted; 140 bool mDisplayHightlighted;
143 141
144 QPalette mPalette; 142 QPalette mPalette;
145 QDate mDate; 143 QDate mDate;
146 144
147 Incidence *mIncidence; 145 Incidence *mIncidence;
148}; 146};
149 147
150 148
151class KOMonthView; 149class KOMonthView;
152 150
153class MonthViewCell : public KNoScrollListBox 151class MonthViewCell : public KNoScrollListBox
154{ 152{
155 Q_OBJECT 153 Q_OBJECT
156 public: 154 public:
157 MonthViewCell(KOMonthView *,QWidget* ); 155 MonthViewCell(KOMonthView *,QWidget* );
158 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} 156 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
159 157
160 void setDate( const QDate & ); 158 void setDate( const QDate & );
161 QDate date() const; 159 QDate date() const;
162 160
163 void setPrimary( bool ); 161 void setPrimary( bool );
164 bool isPrimary() const; 162 bool isPrimary() const;
165 163
166 void setHoliday( bool ); 164 void setHoliday( bool );
167 void setHoliday( const QString & ); 165 void setHoliday( const QString & );
168 166
169 void updateCell(); 167 void updateCell();
170 void startUpdateCell(); 168 void startUpdateCell();
171 void finishUpdateCell(); 169 void finishUpdateCell();
172 void repaintfinishUpdateCell(); 170 void repaintfinishUpdateCell();
173 int insertEvent(Event *); 171 int insertEvent(Event *);
174 void insertTodo(Todo *); 172 void insertTodo(Todo *);
175 173
176 void updateConfig( bool bigFont = false ); 174 void updateConfig( bool bigFont = false );
177 175
178 void enableScrollBars( bool ); 176 void enableScrollBars( bool );
179 177
180 Incidence *selectedIncidence(); 178 Incidence *selectedIncidence();
181 QDate selectedIncidenceDate(); 179 QDate selectedIncidenceDate();
182 QPushButton * dateLabel() { return mLabel; } 180 QPushButton * dateLabel() { return mLabel; }
183 void deHightLight(); 181 void deHightLight();
184 bool doHightLight( Incidence *); 182 bool doHightLight( Incidence *);
185 void deselect(); 183 void deselect();
186 void select(); 184 void select();
187#ifdef DESKTOP_VERSION 185#ifdef DESKTOP_VERSION
188 static QToolTipGroup *toolTipGroup(); 186 static QToolTipGroup *toolTipGroup();
189#endif 187#endif
190 signals: 188 signals:
191 void defaultAction( Incidence * ); 189 void defaultAction( Incidence * );
192 void newEventSignal( QDateTime ); 190 void newEventSignal( QDateTime );
193 void showDaySignal( QDate ); 191 void showDaySignal( QDate );
194 192
195 protected: 193 protected:
196 QStringList mToolTip; 194 QStringList mToolTip;
197 void resizeEvent( QResizeEvent * ); 195 void resizeEvent( QResizeEvent * );
198 196
199public slots: 197public slots:
200 void showDay(); 198 void showDay();
201 protected slots: 199 protected slots:
202 void defaultAction( QListBoxItem * ); 200 void defaultAction( QListBoxItem * );
203 void contextMenu( QListBoxItem * ); 201 void contextMenu( QListBoxItem * );
204 void selection( QListBoxItem * ); 202 void selection( QListBoxItem * );
205 void cellClicked( QListBoxItem * ); 203 void cellClicked( QListBoxItem * );
206 void newEvent(); 204 void newEvent();
207 205
208 private: 206 private:
209 int mdayCount; 207 int mdayCount;
210 QPtrList <MonthViewItem> mAvailItemList; 208 QPtrList <MonthViewItem> mAvailItemList;
211 KOMonthView *mMonthView; 209 KOMonthView *mMonthView;
212 int currentPalette; 210 int currentPalette;
213 211
214 QDate mDate; 212 QDate mDate;
215 bool mPrimary; 213 bool mPrimary;
216 bool mHoliday; 214 bool mHoliday;
217 QString mHolidayString; 215 QString mHolidayString;
218 216
219 //QLabel *mLabel; 217 //QLabel *mLabel;
220 QPushButton *mLabel; 218 QPushButton *mLabel;
221 //QListBox *mItemList; 219 //QListBox *mItemList;
222#ifdef DESKTOP_VERSION 220#ifdef DESKTOP_VERSION
223 static QToolTipGroup *mToolTipGroup; 221 static QToolTipGroup *mToolTipGroup;
224#endif 222#endif
225 QSize mLabelSize; 223 QSize mLabelSize;
226 QSize mLabelBigSize; 224 QSize mLabelBigSize;
227 QPalette mHolidayPalette; 225 QPalette mHolidayPalette;
228 QPalette mStandardPalette; 226 QPalette mStandardPalette;
229 QPalette mPrimaryPalette; 227 QPalette mPrimaryPalette;
230 QPalette mNonPrimaryPalette; 228 QPalette mNonPrimaryPalette;
231 void setMyPalette(); 229 void setMyPalette();
232 QPalette getPalette (); 230 QPalette getPalette ();
233 231
234}; 232};
235 233
236 234
237class KOMonthView: public KOEventView 235class KOMonthView: public KOEventView
238{ 236{
239 Q_OBJECT 237 Q_OBJECT
240 public: 238 public:
241 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 239 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
242 ~KOMonthView(); 240 ~KOMonthView();
243 241
244 /** Returns maximum number of days supported by the komonthview */ 242 /** Returns maximum number of days supported by the komonthview */
245 virtual int maxDatesHint(); 243 virtual int maxDatesHint();
246 244
247 /** Returns number of currently shown dates. */ 245 /** Returns number of currently shown dates. */
248 virtual int currentDateCount(); 246 virtual int currentDateCount();
249 247
250 /** returns the currently selected events */ 248 /** returns the currently selected events */
251 virtual QPtrList<Incidence> selectedIncidences(); 249 virtual QPtrList<Incidence> selectedIncidences();
252 250
253 /** returns dates of the currently selected events */ 251 /** returns dates of the currently selected events */
254 virtual DateList selectedDates(); 252 virtual DateList selectedDates();
255 253
256 virtual void printPreview(CalPrinter *calPrinter, 254 virtual void printPreview(CalPrinter *calPrinter,
257 const QDate &, const QDate &); 255 const QDate &, const QDate &);
258 bool isMonthView() { return !mShowWeekView; } 256 bool isMonthView() { return !mShowWeekView; }
259 bool isUpdatePossible() { return updatePossible; } 257 bool isUpdatePossible() { return updatePossible; }
260 258
261 MonthViewCell * selectedCell(); 259 MonthViewCell * selectedCell();
262 bool skipResize; 260 bool skipResize;
263 NavigatorBar* navigatorBar() { return mNavigatorBar ;} 261 NavigatorBar* navigatorBar() { return mNavigatorBar ;}
264 void clearList(); 262 void clearList();
265 public slots: 263 public slots:
266 void incidenceHighlighted( Incidence *, MonthViewCell*, int ); 264 void incidenceHighlighted( Incidence *, MonthViewCell*, int );
267 void nextCell(); 265 void nextCell();
268 void prevCell(); 266 void prevCell();
269 virtual void updateView(); 267 virtual void updateView();
270 virtual void updateConfig(); 268 virtual void updateConfig();
271 virtual void showDates(const QDate &start, const QDate &end); 269 virtual void showDates(const QDate &start, const QDate &end);
272 virtual void showEvents(QPtrList<Event> eventList); 270 virtual void showEvents(QPtrList<Event> eventList);
273 271
274 void changeEventDisplay(Event *, int); 272 void changeEventDisplay(Event *, int);
275 273
276 void clearSelection(); 274 void clearSelection();
277 275
278 void showContextMenu( Incidence * ); 276 void showContextMenu( Incidence * );
279 277
280 void setSelectedCell( MonthViewCell * ); 278 void setSelectedCell( MonthViewCell * );
281 void setPopupCell( MonthViewCell * ); 279 void setPopupCell( MonthViewCell * );
282 void switchView(); 280 void switchView();
283 void setKeyBoardFocus(); 281 void setKeyBoardFocus();
284 void setKeyBFocus(); 282 void setKeyBFocus();
285 283
286 protected slots: 284 protected slots:
287 void slotNewTodo(); 285 void slotNewTodo();
288 void slotNewEvent(); 286 void slotNewEvent();
289 void slotEditJournal(); 287 void slotEditJournal();
290 void slotComputeLayout(); 288 void slotComputeLayout();
291 void selectInternalWeekNum ( int ); 289 void selectInternalWeekNum ( int );
292 void processSelectionChange(); 290 void processSelectionChange();
293 signals: 291 signals:
294 void nextMonth(); 292 void nextMonth();
295 void prevMonth(); 293 void prevMonth();
296 void selectWeekNum ( int ); 294 void selectWeekNum ( int );
297 void selectMonth (); 295 void selectMonth ();
298 void showDaySignal( QDate ); 296 void showDaySignal( QDate );
299 void newTodoSignal( QDateTime, bool ); 297 void newTodoSignal( QDateTime, bool );
300 void showJournalSignal( int,QDate ); 298 void showJournalSignal( int,QDate );
301 protected: 299 protected:
302 void resizeEvent(QResizeEvent *); 300 void resizeEvent(QResizeEvent *);
303 void viewChanged(); 301 void viewChanged();
304 void updateDayLabels(); 302 void updateDayLabels();
305 303
306 private: 304 private:
307 QTimer* mComputeLayoutTimer; 305 QTimer* mComputeLayoutTimer;
308 NavigatorBar* mNavigatorBar; 306 NavigatorBar* mNavigatorBar;
309 int currentWeek(); 307 int currentWeek();
310 bool clPending; 308 bool clPending;
311 QWidgetStack * mWidStack; 309 QWidgetStack * mWidStack;
312 QWidget* mMonthView; 310 QWidget* mMonthView;
313 QWidget* mWeekView; 311 QWidget* mWeekView;
314 bool mShowWeekView; 312 bool mShowWeekView;
315 bool updatePossible; 313 bool updatePossible;
316 int mDaysPerWeek; 314 int mDaysPerWeek;
317 int mNumWeeks; 315 int mNumWeeks;
318 int mNumCells; 316 int mNumCells;
319 //bool mWeekStartsMonday; 317 //bool mWeekStartsMonday;
320 bool mShowSatSunComp; 318 bool mShowSatSunComp;
321 void computeLayout(); 319 void computeLayout();
322 void computeLayoutWeek(); 320 void computeLayoutWeek();
323 321
324 QPtrVector<MonthViewCell> mCells; 322 QPtrVector<MonthViewCell> mCells;
325 QPtrVector<QLabel> mDayLabels; 323 QPtrVector<QLabel> mDayLabels;
326 QPtrVector<KOWeekButton> mWeekLabels; 324 QPtrVector<KOWeekButton> mWeekLabels;
327 QPtrVector<MonthViewCell> mCellsW; 325 QPtrVector<MonthViewCell> mCellsW;
328 QPtrVector<QLabel> mDayLabelsW; 326 QPtrVector<QLabel> mDayLabelsW;
329 QPtrVector<KOWeekButton> mWeekLabelsW; 327 QPtrVector<KOWeekButton> mWeekLabelsW;
330 328
331 bool mShortDayLabelsM; 329 bool mShortDayLabelsM;
332 bool mShortDayLabelsW; 330 bool mShortDayLabelsW;
333 int mWidthLongDayLabel; 331 int mWidthLongDayLabel;
334 332
335 QDate mStartDate; 333 QDate mStartDate;
336 334
337 MonthViewCell *mSelectedCell; 335 MonthViewCell *mSelectedCell;
338 MonthViewCell *mPopupCell; 336 MonthViewCell *mPopupCell;
339 bool mFlagKeyPressed; 337 bool mFlagKeyPressed;
340 KOEventPopupMenu *mContextMenu; 338 KOEventPopupMenu *mContextMenu;
341 QPopupMenu *mNewItemMenu; 339 QPopupMenu *mNewItemMenu;
342 void keyPressEvent ( QKeyEvent * ) ; 340 void keyPressEvent ( QKeyEvent * ) ;
343 void keyReleaseEvent ( QKeyEvent * ) ; 341 void keyReleaseEvent ( QKeyEvent * ) ;
344 342
345}; 343};
346 344
347#endif 345#endif